From 4703b92f79212739043436ae6139d09827f101e7 Mon Sep 17 00:00:00 2001 From: Alan Rynne Date: Thu, 14 Mar 2024 16:35:46 +0100 Subject: [PATCH 001/261] =?UTF-8?q?Initial=20state=20for=20DUI3/Alpha=20de?= =?UTF-8?q?velopment=20kick-off=20=F0=9F=9A=80=20(#3228)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat(dui3): Adds DUI3 projects and current implementation This is coming from dui3000 branch!!! It was squashed and selectively comited here. * chore(core): Flagged some classes as ComVisible * chore(acad/rhino/revit): Temporary modification of converters to work with DUI3 This should be revised/reverted before finalising DUI3 * Fix(Styling): fix remaining styling issues after squash * Remove unused using statements * Chore(Dui3): Add slnf for DUI3 projects (#3088) Add solution filter for DUI3 projects * Align with core changes * Feat (DUI3): ArcGIS POC (#3156) * Bump System.Threading.Tasks.Dataflow to version 6 - It was causing assembly load error on ArcGIS * Init ArcGIS project template for DUI3 * Fix warnings as much as possible * Fix solution filter merge conflicts * Finding DI Shape (Broken commit) This commit is broken but finding the shape is a bit painful and slow, don't want to lose progress * Partial Assembly Setup & DI as per above * DUI3 DI solution filter some more assembly/solution org * Standing up the plugin Plugin is loading with Autofac dependency. Carving in other dependencies ahs begun... * Fix (DUI3): CNX-8930 Add UseWPF prop to AutoCAD projects (#3178) Add UseWPF prop to AutoCAD projects * Panel Appearing Have the CefSharp panel appearing * feat(dui3): DUI3 project copy paste merge * feat(dui3): DUI3 Connectors project copy paste merge * feat(dui3): highlighting an empty model sender card throws an error * feat(dui3): quite a few fixes, do sync with with dui3 web * Binding work in Progress DI of bindings and dependencies * Bindings injected Bindings are now injected but need to unpick the relationship between the bridge and the binding (given they know about each other) * feat(dui3): acad23 send * feat(dui3): acad23 receive + layers * feat(dui3): acad receive, highlight receiver cards & a few more tweaks * feat(dui3): fixes a bug in the selection bindings; fixes a bg in the get objects from document function that used a risky method (replaced with a more gentle one) * feat(dui3): revert unintentional proj change * DI Bindings With DI in the mix, the bindings are creating associations with Revit from within different contexts and this causing some explosions. Ideally the eventing methods should bind loosely and be decoupled from the implementation. Gotta rethink a bit * De-coupled bridge and bindings not entirely happy with it but the binding and bridge are not circular dependencies, and they can now be bound together. This has the neat effect of resolving everything on the right context and it loads up. The bindings do appear to be broken, so I'm going to need to dig into that. * Bindings Injected Finally these are being injected neatly, so most statics and discovery made that bit easier. The bindings also appear to be working, calling into the C# code from Revit on selection change. Next up: get the calling into each binding, get some account context in there, start in on the kits or lack thereof :D * Binding NOT working Seems on the browser side it's still broken from a binding POV * Binding now really DOES work Binding had the appearance of working, but I failed in my refactor to understand that some of the changes - Method -> Property change of return type, etc... were breaking the symmetry required on the JS side as well and things stop working. Now working pretty fine. Next steps: bind some unnecessary changes and re-instate DI for Panel. Check this works and the look at Send operation and Kits * Re-instated the DI for CefSharpPanel The re-instated DI still works, now the contract is being honoured * Updated Id Id -> ModelCardId * DUI3/Dev -> DI DUI3 Merged main DUI3 branch * Remove cefsharp 121.3.7 version existence on project * TypeLoadException was blowing up the deserializing of the SenderModelCard * Interim fix of DiscriminatedObjectConverter * Statics clean-up Removed the obvious statics that remain in the DUI area and converted some to consts * Binding re-instate Re-instate the binding for document changed * Library Additions Added Objects, Converters related libs and moved over 'enough' to add Floor.cs * Minor changes... to namespaces * DI Converter Shape Have added some nascent interfaces and a class for discovering the converters and wiring this into the Send binding * Disposing & Factories Organised some factories and dispose pattern ready for send operation * Logging woes + DI Problems with lifetimes The microsoft logging extensions did not want to load here, but have nailed the versions. Also had issues with DI of factory but resolved * Type discovery Discovering types dynamically * Tweaks Tweaks --------- Co-authored-by: oguzhankoral Co-authored-by: Oğuzhan Koral <45078678+oguzhankoral@users.noreply.github.com> Co-authored-by: Jedd Morgan <45512892+JR-Morgan@users.noreply.github.com> Co-authored-by: Ian Hawley Co-authored-by: Dimitrie Stefanescu --- All.sln | 366 +++++++++++++- .../Speckle.Connectors.Revit2023.csproj | 255 ++++++++++ .../Speckle.Connectors.Revit2023/app.config | 35 ++ .../Bindings/BasicConnectorBindingRevit.cs | 159 ++++++ .../Bindings/Filters.cs | 32 ++ .../Bindings/ReceiveBinding.cs | 154 ++++++ .../Bindings/RevitBaseBinding.cs | 56 +++ .../Bindings/SelectionBinding.cs | 56 +++ .../Bindings/SendBinding.cs | 159 ++++++ .../DependencyInjection/AutofacUIModule.cs | 85 ++++ .../HostApp/Elements.cs | 14 + .../HostApp/RevitDocumentStore.cs | 151 ++++++ .../Plugin/CefSharpPanel.xaml | 17 + .../Plugin/CefSharpPanel.xaml.cs | 30 ++ .../Plugin/IRevitIdleManager.cs | 20 + .../Plugin/IRevitPlugin.cs | 12 + .../Plugin/RevitCommand.cs | 19 + .../Plugin/RevitContext.cs | 28 ++ .../Plugin/RevitExternalApplication.cs | 130 +++++ .../Plugin/RevitIdleManager.cs | 61 +++ .../Plugin/RevitPlugin.cs | 149 ++++++ .../Plugin/RevitSettings.cs | 20 + .../Plugin/Speckle.Connectors.Revit2023.addin | 12 + .../Speckle.Connectors.RevitShared.projitems | 44 ++ .../Speckle.Connectors.RevitShared.shproj | 13 + .../AutofacRevitConverterModule.cs | 22 + ...rters.Revit2023.DependencyInjection.csproj | 16 + .../Speckle.Converters.Revit2023.csproj | 19 + .../RevitConverterToSpeckle.cs | 25 + .../Speckle.Converters.RevitShared.projitems | 15 + .../Speckle.Converters.RevitShared.shproj | 13 + .../ToSpeckle/FloorConversionToSpeckle.cs | 16 + .../ISpeckleConverterToHost.cs | 6 + .../ISpeckleConverterToSpeckle.cs | 6 + .../Objects/FloorConversion.cs | 3 + .../Objects/IHostObjectToSpeckleConversion.cs | 10 + .../Objects/ISpeckleObjectToHostConversion.cs | 10 + .../Speckle.Converters.Common/ReceiveMode.cs | 25 + .../Speckle.Converters.Common.csproj | 14 + .../Bindings/AccountBinding.cs | 30 ++ .../Bindings/IBasicConnectorBinding.cs | 28 ++ .../Bindings/IBinding.cs | 23 + .../Bindings/IReceiveBinding.cs | 28 ++ .../Bindings/ISelectionBinding.cs | 19 + .../Bindings/ISendBinding.cs | 72 +++ .../Bindings/ISendBindingUICommands.cs | 12 + .../Bindings/SendBindingUICommands.cs | 21 + .../Bridge/BrowserBridge.cs | 296 +++++++++++ .../Speckle.Connectors.DUI/Bridge/IBridge.cs | 44 ++ .../GlobalSuppressions.cs | 14 + .../Models/Card/ModelCard.cs | 26 + .../Models/DocumentInfo.cs | 13 + .../Models/DocumentModelStore.cs | 67 +++ .../Objects/ISpeckleHostObject.cs | 8 + .../Settings/CardSetting.cs | 12 + .../Speckle.Connectors.DUI.csproj | 23 + .../Utils/DiscriminatedObject.cs | 16 + .../Utils/DiscriminatedObjectConverter.cs | 131 +++++ .../Utils/ModelNotFoundException.cs | 16 + .../Utils/PropertyValidator.cs | 53 ++ .../BuiltElements/Floor.cs | 37 ++ .../BuiltElements/Level.cs | 29 ++ .../Common/EncodingOptimisations.cs | 103 ++++ .../Common/IDisplayValue.cs | 26 + .../Speckle.Objects.Common/Geometry/Arc.cs | 294 +++++++++++ .../Speckle.Objects.Common/Geometry/Box.cs | 77 +++ .../Speckle.Objects.Common/Geometry/Circle.cs | 99 ++++ .../Speckle.Objects.Common/Geometry/Curve.cs | 204 ++++++++ .../Geometry/Ellipse.cs | 122 +++++ .../Geometry/Interfaces.cs | 79 +++ .../Speckle.Objects.Common/Geometry/Line.cs | 134 +++++ .../Speckle.Objects.Common/Geometry/Mesh.cs | 254 ++++++++++ .../Speckle.Objects.Common/Geometry/Plane.cs | 133 +++++ .../Speckle.Objects.Common/Geometry/Point.cs | 242 +++++++++ .../Geometry/Polycurve.cs | 167 +++++++ .../Geometry/Polyline.cs | 267 ++++++++++ .../Speckle.Objects.Common/Geometry/Vector.cs | 261 ++++++++++ .../Primitives/Interval.cs | 27 + .../Primitives/Interval2d.cs | 23 + .../Speckle.Objects.Common.csproj | 14 + .../Speckle.Objects.Common/Utils/Transform.cs | 464 ++++++++++++++++++ .../Speckle.Objects.Revit.csproj | 7 + .../DependencyInjection/AutofacContainer.cs | 107 ++++ .../DependencyInjection/Factory.cs | 19 + .../DependencyInjection/IFactory.cs | 12 + .../DependencyInjection/IScopedFactory.cs | 9 + .../NameAndRankValueAttribute.cs | 16 + .../DependencyInjection/NamedTypeInjector.cs | 63 +++ .../DependencyInjection/ScopedFactory.cs | 43 ++ .../Speckle.Autofac/Files/IStorageInfo.cs | 8 + CNX-8892/Speckle.Autofac/Files/StorageInfo.cs | 12 + .../Speckle.Autofac/GlobalSuppressions.cs | 21 + .../Speckle.Autofac/Speckle.Autofac.csproj | 19 + .../Cancellation/CancellationManager.cs | 76 +++ .../Cancellation/ICancelable.cs | 9 + .../Reflection/AssemblyExtensions.cs | 23 + .../Speckle.Connectors.Utils.csproj | 15 + .../SpeckleTopLevelExceptionHandler.cs | 45 ++ .../Bindings/BasicConnectorBinding.cs | 54 ++ ConnectorArcGIS/Bindings/Factory.cs | 20 + ConnectorArcGIS/Config.daml | 67 +++ ConnectorArcGIS/ConnectorArcGIS.csproj | 117 +++++ ConnectorArcGIS/ConnectorArcGIS.sln | 25 + ConnectorArcGIS/DarkImages/AddInDesktop16.png | Bin 0 -> 1314 bytes ConnectorArcGIS/DarkImages/AddInDesktop32.png | Bin 0 -> 1744 bytes ConnectorArcGIS/Images/AddInDesktop16.png | Bin 0 -> 524 bytes ConnectorArcGIS/Images/AddInDesktop32.png | Bin 0 -> 948 bytes ConnectorArcGIS/Properties/AssemblyInfo.cs | 54 ++ .../Properties/launchSettings.json | 9 + ConnectorArcGIS/SpeckleDUI3.xaml | 41 ++ ConnectorArcGIS/SpeckleDUI3.xaml.cs | 62 +++ ConnectorArcGIS/SpeckleDUI3ViewModel.cs | 92 ++++ ConnectorArcGIS/SpeckleModule.cs | 51 ++ ConnectorArcGIS/Utils/ArcGisDocumentStore.cs | 21 + ConnectorArcGIS/app.config | 15 + .../ConnectorAutocad2022DUI3.csproj | 50 ++ .../ConnectorAutocad2023DUI3.csproj | 47 ++ .../AutocadCivilDUI3Shared.projitems | 34 ++ .../AutocadCivilDUI3Shared.shproj | 11 + .../Bindings/BasicConnectorBindingAutocad.cs | 131 +++++ .../Bindings/Factory.cs | 35 ++ .../Bindings/Filters.cs | 31 ++ .../Bindings/ReceiveBinding.cs | 228 +++++++++ .../Bindings/SelectionBinding.cs | 74 +++ .../Bindings/SendBinding.cs | 201 ++++++++ .../DUI3PanelWebView.xaml | 20 + .../DUI3PanelWebView.xaml.cs | 40 ++ .../AutocadCivilDUI3Shared/Entry.cs | 72 +++ .../Extensions/Editor.cs | 27 + .../Extensions/Extends3d.cs | 39 ++ .../Utils/AutocadDocumentManager.cs | 149 ++++++ .../Utils/AutocadDocumentModelStore.cs | 82 ++++ .../Utils/AutocadIdleManager.cs | 40 ++ .../AutocadCivilDUI3Shared/Utils/Objects.cs | 37 ++ .../Utils/TransactionContext.cs | 29 ++ .../AutocadCivilDUI3Shared/Utils/Utils.cs | 92 ++++ .../ConnectorAutocadCivil.slnf | 4 + .../Properties/launchSettings.json | 8 + .../Revit2020DUI3/Revit2020DUI3.csproj | 66 +++ .../Properties/launchSettings.json | 8 + .../Revit2023DUI3/Revit2023DUI3.csproj | 52 ++ .../Bindings/BasicConnectorBindingRevit.cs | 138 ++++++ .../RevitDUI3Shared/Bindings/Factory.cs | 30 ++ .../RevitDUI3Shared/Bindings/Filters.cs | 32 ++ .../Bindings/ReceiveBinding.cs | 166 +++++++ .../Bindings/SelectionBinding.cs | 52 ++ .../RevitDUI3Shared/Bindings/SendBinding.cs | 209 ++++++++ .../RevitDUI3Shared/CefSharpPanel.xaml | 18 + .../RevitDUI3Shared/CefSharpPanel.xaml.cs | 29 ++ .../RevitDUI3/RevitDUI3Shared/Entry.cs | 156 ++++++ .../RevitDUI3Shared/RevitDUI3Shared.projitems | 37 ++ .../RevitDUI3Shared/RevitDUI3Shared.shproj | 11 + .../RevitDUI3Shared/SpeckleRevit2DUI3.addin | 12 + .../SpeckleRevitDUI3Command.cs | 18 + .../RevitDUI3Shared/Utils/Elements.cs | 11 + .../RevitDUI3Shared/Utils/RevitAppProvider.cs | 22 + .../Utils/RevitDocumentStore.cs | 138 ++++++ .../RevitDUI3Shared/Utils/RevitIdleManager.cs | 39 ++ .../RevitDUI3Shared/Utils/Schemas.cs | 42 ++ .../Speckle.Connectors.Revit2023/Class1.cs | 12 + .../Properties/AssemblyInfo.cs | 36 ++ .../Speckle.Connectors.Revit2023.csproj | 80 +++ .../packages.config | 4 + .../RevitPlugin/IRevitPlugin.cs | 11 + .../RevitPlugin/RevitExternalApplication.cs | 65 +++ .../RevitPlugin/RevitSettings.cs | 10 + .../RevitPlugin/SpeckleRevit.addin | 12 + .../RevitPlugin/SpeckleRevitCommand.cs | 19 + .../Speckle.Connectors.RevitShared.projitems | 20 + .../Speckle.Connectors.RevitShared.shproj | 13 + ConnectorRhino/ConnectorRhino.slnf | 4 +- .../Bindings/BasicConnectorBinding.cs | 108 ++++ .../ConnectorRhinoWebUI/Bindings/Factory.cs | 54 ++ .../ConnectorRhinoWebUI/Bindings/Filters.cs | 63 +++ .../Bindings/ReceiveBinding.cs | 194 ++++++++ .../Bindings/SelectionBinding.cs | 57 +++ .../Bindings/SendBinding.cs | 283 +++++++++++ .../ConnectorRhinoWebUI/Commands.cs | 174 +++++++ .../ConnectorRhinoWebUI.csproj | 63 +++ .../EmbeddedResources/plugin-utility.ico | Bin 0 -> 33583 bytes .../Extensions/BoundingBox.cs | 35 ++ .../ConnectorRhinoWebUI/PanelHosts.cs | 27 + ConnectorRhino/ConnectorRhinoWebUI/Plugin.cs | 26 + .../Properties/AssemblyInfo.cs | 20 + .../Properties/launchSettings.json | 8 + .../SpeckleWebUiPanelWebView2.xaml | 18 + .../SpeckleWebUiPanelWebView2.xaml.cs | 86 ++++ .../Utils/RhinoDocumentStore.cs | 58 +++ .../Utils/RhinoIdleManager.cs | 45 ++ .../Utils/SpeckleRhinoObject.cs | 27 + .../ConnectorRhinoWebUI/Utils/Utils.cs | 17 + .../ConnectorRhinoWebUI/WebUIPanelCef.xaml | 16 + .../ConnectorRhinoWebUI/WebUIPanelCef.xaml.cs | 35 ++ .../WebUIPanelWebView2.xaml | 19 + .../WebUIPanelWebView2.xaml.cs | 40 ++ Core/Core/Api/GraphQL/Models.cs | 3 + Core/Core/Credentials/Account.cs | 3 + Core/Core/Credentials/Responses.cs | 7 + DUI3-CNX-8893.slnf | 90 ++++ DUI3.slnf | 156 ++++++ DesktopUI3/DUI3/Bindings/AccountBinding.cs | 24 + DesktopUI3/DUI3/Bindings/ConfigBinding.cs | 131 +++++ .../DUI3/Bindings/IBasicConnectorBinding.cs | 38 ++ DesktopUI3/DUI3/Bindings/IReceiveBinding.cs | 49 ++ DesktopUI3/DUI3/Bindings/ISelectionBinding.cs | 19 + DesktopUI3/DUI3/Bindings/ISendBinding.cs | 89 ++++ DesktopUI3/DUI3/Bindings/TestBinding.cs | 64 +++ DesktopUI3/DUI3/Bridge.cs | 187 +++++++ DesktopUI3/DUI3/BridgeV2.cs | 282 +++++++++++ DesktopUI3/DUI3/Config/ConnectorConfig.cs | 22 + DesktopUI3/DUI3/Config/GlobalConfig.cs | 11 + DesktopUI3/DUI3/Config/UiConfig.cs | 11 + DesktopUI3/DUI3/DUI3.csproj | 20 + DesktopUI3/DUI3/Interfaces.cs | 58 +++ DesktopUI3/DUI3/Models/Card/ModelCardError.cs | 9 + .../DUI3/Models/Card/ModelCardNotification.cs | 10 + .../DUI3/Models/Card/ModelCardProgress.cs | 17 + DesktopUI3/DUI3/Models/ConversionReport.cs | 47 ++ DesktopUI3/DUI3/Models/DocumentInfo.cs | 16 + DesktopUI3/DUI3/Models/DocumentModelStore.cs | 63 +++ DesktopUI3/DUI3/Models/Form.cs | 47 ++ DesktopUI3/DUI3/Models/ModelCard.cs | 27 + DesktopUI3/DUI3/Models/NotificationLevel.cs | 12 + DesktopUI3/DUI3/Objects/ConversionContext.cs | 17 + DesktopUI3/DUI3/Objects/ISpeckleHostObject.cs | 8 + DesktopUI3/DUI3/Objects/ReportObject.cs | 14 + DesktopUI3/DUI3/Objects/SpeckleHostObject.cs | 18 + DesktopUI3/DUI3/Onboarding/Factory.cs | 33 ++ DesktopUI3/DUI3/Onboarding/OnboardingData.cs | 11 + .../DUI3/Operations/CancellationManager.cs | 83 ++++ DesktopUI3/DUI3/Operations/Operations.cs | 60 +++ DesktopUI3/DUI3/Settings/CardSetting.cs | 14 + DesktopUI3/DUI3/Utils/Accounts.cs | 15 + DesktopUI3/DUI3/Utils/Converters.cs | 13 + DesktopUI3/DUI3/Utils/DiscriminatedObject.cs | 15 + .../Utils/DiscriminatedObjectConverter.cs | 119 +++++ DesktopUI3/DUI3/Utils/Exceptions.cs | 15 + DesktopUI3/DUI3/Utils/PropertyValidator.cs | 53 ++ .../Utils/SerializationSettingsFactory.cs | 26 + DesktopUI3/DUI3/Utils/Traversal.cs | 114 +++++ DesktopUI3/DUI3/yarn.lock | 4 + DesktopUI3/yarn.lock | 4 + .../Converter.AutocadCivil.Utils.cs | 5 + .../ConverterAutocadCivil.Other.cs | 5 +- .../ConverterRhinoGh.Utils.cs | 5 + 245 files changed, 14102 insertions(+), 4 deletions(-) create mode 100644 CNX-8892/Connectors/Revit/Speckle.Connectors.Revit2023/Speckle.Connectors.Revit2023.csproj create mode 100644 CNX-8892/Connectors/Revit/Speckle.Connectors.Revit2023/app.config create mode 100644 CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/BasicConnectorBindingRevit.cs create mode 100644 CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/Filters.cs create mode 100644 CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/ReceiveBinding.cs create mode 100644 CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/RevitBaseBinding.cs create mode 100644 CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SelectionBinding.cs create mode 100644 CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SendBinding.cs create mode 100644 CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/AutofacUIModule.cs create mode 100644 CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/Elements.cs create mode 100644 CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/RevitDocumentStore.cs create mode 100644 CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/CefSharpPanel.xaml create mode 100644 CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/CefSharpPanel.xaml.cs create mode 100644 CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/IRevitIdleManager.cs create mode 100644 CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/IRevitPlugin.cs create mode 100644 CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitCommand.cs create mode 100644 CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitContext.cs create mode 100644 CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitExternalApplication.cs create mode 100644 CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitIdleManager.cs create mode 100644 CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitPlugin.cs create mode 100644 CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitSettings.cs create mode 100644 CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/Speckle.Connectors.Revit2023.addin create mode 100644 CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Speckle.Connectors.RevitShared.projitems create mode 100644 CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Speckle.Connectors.RevitShared.shproj create mode 100644 CNX-8892/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/AutofacRevitConverterModule.cs create mode 100644 CNX-8892/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/Speckle.Converters.Revit2023.DependencyInjection.csproj create mode 100644 CNX-8892/Converters/Revit/Speckle.Converters.Revit2023/Speckle.Converters.Revit2023.csproj create mode 100644 CNX-8892/Converters/Revit/Speckle.Converters.RevitShared/RevitConverterToSpeckle.cs create mode 100644 CNX-8892/Converters/Revit/Speckle.Converters.RevitShared/Speckle.Converters.RevitShared.projitems create mode 100644 CNX-8892/Converters/Revit/Speckle.Converters.RevitShared/Speckle.Converters.RevitShared.shproj create mode 100644 CNX-8892/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/FloorConversionToSpeckle.cs create mode 100644 CNX-8892/Converters/Speckle.Converters.Common/ISpeckleConverterToHost.cs create mode 100644 CNX-8892/Converters/Speckle.Converters.Common/ISpeckleConverterToSpeckle.cs create mode 100644 CNX-8892/Converters/Speckle.Converters.Common/Objects/FloorConversion.cs create mode 100644 CNX-8892/Converters/Speckle.Converters.Common/Objects/IHostObjectToSpeckleConversion.cs create mode 100644 CNX-8892/Converters/Speckle.Converters.Common/Objects/ISpeckleObjectToHostConversion.cs create mode 100644 CNX-8892/Converters/Speckle.Converters.Common/ReceiveMode.cs create mode 100644 CNX-8892/Converters/Speckle.Converters.Common/Speckle.Converters.Common.csproj create mode 100644 CNX-8892/DUI3/Speckle.Connectors.DUI/Bindings/AccountBinding.cs create mode 100644 CNX-8892/DUI3/Speckle.Connectors.DUI/Bindings/IBasicConnectorBinding.cs create mode 100644 CNX-8892/DUI3/Speckle.Connectors.DUI/Bindings/IBinding.cs create mode 100644 CNX-8892/DUI3/Speckle.Connectors.DUI/Bindings/IReceiveBinding.cs create mode 100644 CNX-8892/DUI3/Speckle.Connectors.DUI/Bindings/ISelectionBinding.cs create mode 100644 CNX-8892/DUI3/Speckle.Connectors.DUI/Bindings/ISendBinding.cs create mode 100644 CNX-8892/DUI3/Speckle.Connectors.DUI/Bindings/ISendBindingUICommands.cs create mode 100644 CNX-8892/DUI3/Speckle.Connectors.DUI/Bindings/SendBindingUICommands.cs create mode 100644 CNX-8892/DUI3/Speckle.Connectors.DUI/Bridge/BrowserBridge.cs create mode 100644 CNX-8892/DUI3/Speckle.Connectors.DUI/Bridge/IBridge.cs create mode 100644 CNX-8892/DUI3/Speckle.Connectors.DUI/GlobalSuppressions.cs create mode 100644 CNX-8892/DUI3/Speckle.Connectors.DUI/Models/Card/ModelCard.cs create mode 100644 CNX-8892/DUI3/Speckle.Connectors.DUI/Models/DocumentInfo.cs create mode 100644 CNX-8892/DUI3/Speckle.Connectors.DUI/Models/DocumentModelStore.cs create mode 100644 CNX-8892/DUI3/Speckle.Connectors.DUI/Objects/ISpeckleHostObject.cs create mode 100644 CNX-8892/DUI3/Speckle.Connectors.DUI/Settings/CardSetting.cs create mode 100644 CNX-8892/DUI3/Speckle.Connectors.DUI/Speckle.Connectors.DUI.csproj create mode 100644 CNX-8892/DUI3/Speckle.Connectors.DUI/Utils/DiscriminatedObject.cs create mode 100644 CNX-8892/DUI3/Speckle.Connectors.DUI/Utils/DiscriminatedObjectConverter.cs create mode 100644 CNX-8892/DUI3/Speckle.Connectors.DUI/Utils/ModelNotFoundException.cs create mode 100644 CNX-8892/DUI3/Speckle.Connectors.DUI/Utils/PropertyValidator.cs create mode 100644 CNX-8892/Objects/Speckle.Objects.Common/BuiltElements/Floor.cs create mode 100644 CNX-8892/Objects/Speckle.Objects.Common/BuiltElements/Level.cs create mode 100644 CNX-8892/Objects/Speckle.Objects.Common/Common/EncodingOptimisations.cs create mode 100644 CNX-8892/Objects/Speckle.Objects.Common/Common/IDisplayValue.cs create mode 100644 CNX-8892/Objects/Speckle.Objects.Common/Geometry/Arc.cs create mode 100644 CNX-8892/Objects/Speckle.Objects.Common/Geometry/Box.cs create mode 100644 CNX-8892/Objects/Speckle.Objects.Common/Geometry/Circle.cs create mode 100644 CNX-8892/Objects/Speckle.Objects.Common/Geometry/Curve.cs create mode 100644 CNX-8892/Objects/Speckle.Objects.Common/Geometry/Ellipse.cs create mode 100644 CNX-8892/Objects/Speckle.Objects.Common/Geometry/Interfaces.cs create mode 100644 CNX-8892/Objects/Speckle.Objects.Common/Geometry/Line.cs create mode 100644 CNX-8892/Objects/Speckle.Objects.Common/Geometry/Mesh.cs create mode 100644 CNX-8892/Objects/Speckle.Objects.Common/Geometry/Plane.cs create mode 100644 CNX-8892/Objects/Speckle.Objects.Common/Geometry/Point.cs create mode 100644 CNX-8892/Objects/Speckle.Objects.Common/Geometry/Polycurve.cs create mode 100644 CNX-8892/Objects/Speckle.Objects.Common/Geometry/Polyline.cs create mode 100644 CNX-8892/Objects/Speckle.Objects.Common/Geometry/Vector.cs create mode 100644 CNX-8892/Objects/Speckle.Objects.Common/Primitives/Interval.cs create mode 100644 CNX-8892/Objects/Speckle.Objects.Common/Primitives/Interval2d.cs create mode 100644 CNX-8892/Objects/Speckle.Objects.Common/Speckle.Objects.Common.csproj create mode 100644 CNX-8892/Objects/Speckle.Objects.Common/Utils/Transform.cs create mode 100644 CNX-8892/Objects/Speckle.Objects.Revit/Speckle.Objects.Revit.csproj create mode 100644 CNX-8892/Speckle.Autofac/DependencyInjection/AutofacContainer.cs create mode 100644 CNX-8892/Speckle.Autofac/DependencyInjection/Factory.cs create mode 100644 CNX-8892/Speckle.Autofac/DependencyInjection/IFactory.cs create mode 100644 CNX-8892/Speckle.Autofac/DependencyInjection/IScopedFactory.cs create mode 100644 CNX-8892/Speckle.Autofac/DependencyInjection/NameAndRankValueAttribute.cs create mode 100644 CNX-8892/Speckle.Autofac/DependencyInjection/NamedTypeInjector.cs create mode 100644 CNX-8892/Speckle.Autofac/DependencyInjection/ScopedFactory.cs create mode 100644 CNX-8892/Speckle.Autofac/Files/IStorageInfo.cs create mode 100644 CNX-8892/Speckle.Autofac/Files/StorageInfo.cs create mode 100644 CNX-8892/Speckle.Autofac/GlobalSuppressions.cs create mode 100644 CNX-8892/Speckle.Autofac/Speckle.Autofac.csproj create mode 100644 CNX-8892/Speckle.Connectors.Utils/Cancellation/CancellationManager.cs create mode 100644 CNX-8892/Speckle.Connectors.Utils/Cancellation/ICancelable.cs create mode 100644 CNX-8892/Speckle.Connectors.Utils/Reflection/AssemblyExtensions.cs create mode 100644 CNX-8892/Speckle.Connectors.Utils/Speckle.Connectors.Utils.csproj create mode 100644 CNX-8892/Speckle.Connectors.Utils/SpeckleTopLevelExceptionHandler.cs create mode 100644 ConnectorArcGIS/Bindings/BasicConnectorBinding.cs create mode 100644 ConnectorArcGIS/Bindings/Factory.cs create mode 100644 ConnectorArcGIS/Config.daml create mode 100644 ConnectorArcGIS/ConnectorArcGIS.csproj create mode 100644 ConnectorArcGIS/ConnectorArcGIS.sln create mode 100644 ConnectorArcGIS/DarkImages/AddInDesktop16.png create mode 100644 ConnectorArcGIS/DarkImages/AddInDesktop32.png create mode 100644 ConnectorArcGIS/Images/AddInDesktop16.png create mode 100644 ConnectorArcGIS/Images/AddInDesktop32.png create mode 100644 ConnectorArcGIS/Properties/AssemblyInfo.cs create mode 100644 ConnectorArcGIS/Properties/launchSettings.json create mode 100644 ConnectorArcGIS/SpeckleDUI3.xaml create mode 100644 ConnectorArcGIS/SpeckleDUI3.xaml.cs create mode 100644 ConnectorArcGIS/SpeckleDUI3ViewModel.cs create mode 100644 ConnectorArcGIS/SpeckleModule.cs create mode 100644 ConnectorArcGIS/Utils/ArcGisDocumentStore.cs create mode 100644 ConnectorArcGIS/app.config create mode 100644 ConnectorAutocadCivil/AutocadCivilDUI3/Autocad2022/ConnectorAutocad2022DUI3.csproj create mode 100644 ConnectorAutocadCivil/AutocadCivilDUI3/Autocad2023/ConnectorAutocad2023DUI3.csproj create mode 100644 ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/AutocadCivilDUI3Shared.projitems create mode 100644 ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/AutocadCivilDUI3Shared.shproj create mode 100644 ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Bindings/BasicConnectorBindingAutocad.cs create mode 100644 ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Bindings/Factory.cs create mode 100644 ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Bindings/Filters.cs create mode 100644 ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Bindings/ReceiveBinding.cs create mode 100644 ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Bindings/SelectionBinding.cs create mode 100644 ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Bindings/SendBinding.cs create mode 100644 ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/DUI3PanelWebView.xaml create mode 100644 ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/DUI3PanelWebView.xaml.cs create mode 100644 ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Entry.cs create mode 100644 ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Extensions/Editor.cs create mode 100644 ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Extensions/Extends3d.cs create mode 100644 ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Utils/AutocadDocumentManager.cs create mode 100644 ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Utils/AutocadDocumentModelStore.cs create mode 100644 ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Utils/AutocadIdleManager.cs create mode 100644 ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Utils/Objects.cs create mode 100644 ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Utils/TransactionContext.cs create mode 100644 ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Utils/Utils.cs create mode 100644 ConnectorRevit/RevitDUI3/Revit2020DUI3/Properties/launchSettings.json create mode 100644 ConnectorRevit/RevitDUI3/Revit2020DUI3/Revit2020DUI3.csproj create mode 100644 ConnectorRevit/RevitDUI3/Revit2023DUI3/Properties/launchSettings.json create mode 100644 ConnectorRevit/RevitDUI3/Revit2023DUI3/Revit2023DUI3.csproj create mode 100644 ConnectorRevit/RevitDUI3/RevitDUI3Shared/Bindings/BasicConnectorBindingRevit.cs create mode 100644 ConnectorRevit/RevitDUI3/RevitDUI3Shared/Bindings/Factory.cs create mode 100644 ConnectorRevit/RevitDUI3/RevitDUI3Shared/Bindings/Filters.cs create mode 100644 ConnectorRevit/RevitDUI3/RevitDUI3Shared/Bindings/ReceiveBinding.cs create mode 100644 ConnectorRevit/RevitDUI3/RevitDUI3Shared/Bindings/SelectionBinding.cs create mode 100644 ConnectorRevit/RevitDUI3/RevitDUI3Shared/Bindings/SendBinding.cs create mode 100644 ConnectorRevit/RevitDUI3/RevitDUI3Shared/CefSharpPanel.xaml create mode 100644 ConnectorRevit/RevitDUI3/RevitDUI3Shared/CefSharpPanel.xaml.cs create mode 100644 ConnectorRevit/RevitDUI3/RevitDUI3Shared/Entry.cs create mode 100644 ConnectorRevit/RevitDUI3/RevitDUI3Shared/RevitDUI3Shared.projitems create mode 100644 ConnectorRevit/RevitDUI3/RevitDUI3Shared/RevitDUI3Shared.shproj create mode 100644 ConnectorRevit/RevitDUI3/RevitDUI3Shared/SpeckleRevit2DUI3.addin create mode 100644 ConnectorRevit/RevitDUI3/RevitDUI3Shared/SpeckleRevitDUI3Command.cs create mode 100644 ConnectorRevit/RevitDUI3/RevitDUI3Shared/Utils/Elements.cs create mode 100644 ConnectorRevit/RevitDUI3/RevitDUI3Shared/Utils/RevitAppProvider.cs create mode 100644 ConnectorRevit/RevitDUI3/RevitDUI3Shared/Utils/RevitDocumentStore.cs create mode 100644 ConnectorRevit/RevitDUI3/RevitDUI3Shared/Utils/RevitIdleManager.cs create mode 100644 ConnectorRevit/RevitDUI3/RevitDUI3Shared/Utils/Schemas.cs create mode 100644 ConnectorRevit/RevitDUI3/Speckle.Connectors.Revit2023/Class1.cs create mode 100644 ConnectorRevit/RevitDUI3/Speckle.Connectors.Revit2023/Properties/AssemblyInfo.cs create mode 100644 ConnectorRevit/RevitDUI3/Speckle.Connectors.Revit2023/Speckle.Connectors.Revit2023.csproj create mode 100644 ConnectorRevit/RevitDUI3/Speckle.Connectors.Revit2023/packages.config create mode 100644 ConnectorRevit/RevitDUI3/Speckle.Connectors.RevitShared/RevitPlugin/IRevitPlugin.cs create mode 100644 ConnectorRevit/RevitDUI3/Speckle.Connectors.RevitShared/RevitPlugin/RevitExternalApplication.cs create mode 100644 ConnectorRevit/RevitDUI3/Speckle.Connectors.RevitShared/RevitPlugin/RevitSettings.cs create mode 100644 ConnectorRevit/RevitDUI3/Speckle.Connectors.RevitShared/RevitPlugin/SpeckleRevit.addin create mode 100644 ConnectorRevit/RevitDUI3/Speckle.Connectors.RevitShared/RevitPlugin/SpeckleRevitCommand.cs create mode 100644 ConnectorRevit/RevitDUI3/Speckle.Connectors.RevitShared/Speckle.Connectors.RevitShared.projitems create mode 100644 ConnectorRevit/RevitDUI3/Speckle.Connectors.RevitShared/Speckle.Connectors.RevitShared.shproj create mode 100644 ConnectorRhino/ConnectorRhinoWebUI/Bindings/BasicConnectorBinding.cs create mode 100644 ConnectorRhino/ConnectorRhinoWebUI/Bindings/Factory.cs create mode 100644 ConnectorRhino/ConnectorRhinoWebUI/Bindings/Filters.cs create mode 100644 ConnectorRhino/ConnectorRhinoWebUI/Bindings/ReceiveBinding.cs create mode 100644 ConnectorRhino/ConnectorRhinoWebUI/Bindings/SelectionBinding.cs create mode 100644 ConnectorRhino/ConnectorRhinoWebUI/Bindings/SendBinding.cs create mode 100644 ConnectorRhino/ConnectorRhinoWebUI/Commands.cs create mode 100644 ConnectorRhino/ConnectorRhinoWebUI/ConnectorRhinoWebUI.csproj create mode 100644 ConnectorRhino/ConnectorRhinoWebUI/EmbeddedResources/plugin-utility.ico create mode 100644 ConnectorRhino/ConnectorRhinoWebUI/Extensions/BoundingBox.cs create mode 100644 ConnectorRhino/ConnectorRhinoWebUI/PanelHosts.cs create mode 100644 ConnectorRhino/ConnectorRhinoWebUI/Plugin.cs create mode 100644 ConnectorRhino/ConnectorRhinoWebUI/Properties/AssemblyInfo.cs create mode 100644 ConnectorRhino/ConnectorRhinoWebUI/Properties/launchSettings.json create mode 100644 ConnectorRhino/ConnectorRhinoWebUI/SpeckleWebUiPanelWebView2.xaml create mode 100644 ConnectorRhino/ConnectorRhinoWebUI/SpeckleWebUiPanelWebView2.xaml.cs create mode 100644 ConnectorRhino/ConnectorRhinoWebUI/Utils/RhinoDocumentStore.cs create mode 100644 ConnectorRhino/ConnectorRhinoWebUI/Utils/RhinoIdleManager.cs create mode 100644 ConnectorRhino/ConnectorRhinoWebUI/Utils/SpeckleRhinoObject.cs create mode 100644 ConnectorRhino/ConnectorRhinoWebUI/Utils/Utils.cs create mode 100644 ConnectorRhino/ConnectorRhinoWebUI/WebUIPanelCef.xaml create mode 100644 ConnectorRhino/ConnectorRhinoWebUI/WebUIPanelCef.xaml.cs create mode 100644 ConnectorRhino/ConnectorRhinoWebUI/WebUIPanelWebView2.xaml create mode 100644 ConnectorRhino/ConnectorRhinoWebUI/WebUIPanelWebView2.xaml.cs create mode 100644 DUI3-CNX-8893.slnf create mode 100644 DUI3.slnf create mode 100644 DesktopUI3/DUI3/Bindings/AccountBinding.cs create mode 100644 DesktopUI3/DUI3/Bindings/ConfigBinding.cs create mode 100644 DesktopUI3/DUI3/Bindings/IBasicConnectorBinding.cs create mode 100644 DesktopUI3/DUI3/Bindings/IReceiveBinding.cs create mode 100644 DesktopUI3/DUI3/Bindings/ISelectionBinding.cs create mode 100644 DesktopUI3/DUI3/Bindings/ISendBinding.cs create mode 100644 DesktopUI3/DUI3/Bindings/TestBinding.cs create mode 100644 DesktopUI3/DUI3/Bridge.cs create mode 100644 DesktopUI3/DUI3/BridgeV2.cs create mode 100644 DesktopUI3/DUI3/Config/ConnectorConfig.cs create mode 100644 DesktopUI3/DUI3/Config/GlobalConfig.cs create mode 100644 DesktopUI3/DUI3/Config/UiConfig.cs create mode 100644 DesktopUI3/DUI3/DUI3.csproj create mode 100644 DesktopUI3/DUI3/Interfaces.cs create mode 100644 DesktopUI3/DUI3/Models/Card/ModelCardError.cs create mode 100644 DesktopUI3/DUI3/Models/Card/ModelCardNotification.cs create mode 100644 DesktopUI3/DUI3/Models/Card/ModelCardProgress.cs create mode 100644 DesktopUI3/DUI3/Models/ConversionReport.cs create mode 100644 DesktopUI3/DUI3/Models/DocumentInfo.cs create mode 100644 DesktopUI3/DUI3/Models/DocumentModelStore.cs create mode 100644 DesktopUI3/DUI3/Models/Form.cs create mode 100644 DesktopUI3/DUI3/Models/ModelCard.cs create mode 100644 DesktopUI3/DUI3/Models/NotificationLevel.cs create mode 100644 DesktopUI3/DUI3/Objects/ConversionContext.cs create mode 100644 DesktopUI3/DUI3/Objects/ISpeckleHostObject.cs create mode 100644 DesktopUI3/DUI3/Objects/ReportObject.cs create mode 100644 DesktopUI3/DUI3/Objects/SpeckleHostObject.cs create mode 100644 DesktopUI3/DUI3/Onboarding/Factory.cs create mode 100644 DesktopUI3/DUI3/Onboarding/OnboardingData.cs create mode 100644 DesktopUI3/DUI3/Operations/CancellationManager.cs create mode 100644 DesktopUI3/DUI3/Operations/Operations.cs create mode 100644 DesktopUI3/DUI3/Settings/CardSetting.cs create mode 100644 DesktopUI3/DUI3/Utils/Accounts.cs create mode 100644 DesktopUI3/DUI3/Utils/Converters.cs create mode 100644 DesktopUI3/DUI3/Utils/DiscriminatedObject.cs create mode 100644 DesktopUI3/DUI3/Utils/DiscriminatedObjectConverter.cs create mode 100644 DesktopUI3/DUI3/Utils/Exceptions.cs create mode 100644 DesktopUI3/DUI3/Utils/PropertyValidator.cs create mode 100644 DesktopUI3/DUI3/Utils/SerializationSettingsFactory.cs create mode 100644 DesktopUI3/DUI3/Utils/Traversal.cs create mode 100644 DesktopUI3/DUI3/yarn.lock create mode 100644 DesktopUI3/yarn.lock diff --git a/All.sln b/All.sln index 83ebd163a9..9f0848a37b 100644 --- a/All.sln +++ b/All.sln @@ -430,6 +430,30 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BatchUploader.OperationDriv EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BatchUploader.Sdk", "ConnectorCore\BatchUploader.Sdk\BatchUploader.Sdk.csproj", "{2CC777EB-BD63-4FAB-BC3A-68A640D2E639}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ConnectorsDUI3", "ConnectorsDUI3", "{F1666772-262D-4577-976F-89A1C0E2D73E}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Rhino", "Rhino", "{1F00E9FB-6478-4350-A495-C5667D749832}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConnectorRhinoWebUI", "ConnectorRhino\ConnectorRhinoWebUI\ConnectorRhinoWebUI.csproj", "{CC672C3F-482D-4137-AF8A-D0EC67D0EA7D}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DUI3", "DesktopUI3\DUI3\DUI3.csproj", "{D93D6296-B138-4853-A505-F2AB11B551DB}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "AutocadCivil", "AutocadCivil", "{EA1F6DBC-41B6-4FA6-8A05-89FF91105543}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConnectorAutocad2023DUI3", "ConnectorAutocadCivil\AutocadCivilDUI3\Autocad2023\ConnectorAutocad2023DUI3.csproj", "{1E5C7198-1065-4015-ACB5-BDFA1DC43589}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConnectorAutocad2022DUI3", "ConnectorAutocadCivil\AutocadCivilDUI3\Autocad2022\ConnectorAutocad2022DUI3.csproj", "{5698290F-250F-4336-ADF8-F269A36D1178}" +EndProject +Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "AutocadCivilDUI3Shared", "ConnectorAutocadCivil\AutocadCivilDUI3\AutocadCivilDUI3Shared\AutocadCivilDUI3Shared.shproj", "{2BDE80E8-5F26-4E57-BBA6-109120F5D4EE}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Revit", "Revit", "{047CA18F-AD79-4C31-985D-EEA8E070985D}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Revit2020DUI3", "ConnectorRevit\RevitDUI3\Revit2020DUI3\Revit2020DUI3.csproj", "{2113F03B-BB8D-470B-A9A1-97BB9A554A44}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Revit2023DUI3", "ConnectorRevit\RevitDUI3\Revit2023DUI3\Revit2023DUI3.csproj", "{A364B196-38A3-45AB-A54A-F04D17C0B2DA}" +EndProject +Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "RevitDUI3Shared", "ConnectorRevit\RevitDUI3\RevitDUI3Shared\RevitDUI3Shared.shproj", "{3D7F0278-6CF2-4588-A101-4027ABB8B87F}" +EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConnectorRhino8", "ConnectorRhino\ConnectorRhino8\ConnectorRhino8.csproj", "{D22A887D-976C-4DBF-AE5B-9039F169E61C}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConverterRhino8", "Objects\Converters\ConverterRhinoGh\ConverterRhino8\ConverterRhino8.csproj", "{89996067-3233-410A-A6A1-39E2F11F0626}" @@ -438,9 +462,9 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{5009BB59 EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Speckle.Core.Tests.Unit", "Core\Tests\Speckle.Core.Tests.Unit\Speckle.Core.Tests.Unit.csproj", "{2A88A9EA-EB11-49FD-BE95-DA6FC8F6CB3D}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Speckle.Core.Tests.Performance", "Core\Tests\Speckle.Core.Tests.Performance\Speckle.Core.Tests.Performance.csproj", "{1DE6EF69-0782-4FD7-A2A7-9F697426882D}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Speckle.Core.Tests.Performance", "Core\Tests\Speckle.Core.Tests.Performance\Speckle.Core.Tests.Performance.csproj", "{1DE6EF69-0782-4FD7-A2A7-9F697426882D}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Speckle.Core.Tests.Integration", "Core\Tests\Speckle.Core.Tests.Integration\Speckle.Core.Tests.Integration.csproj", "{FB2DEE1D-788B-45B6-B80C-D8F7C8390C37}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Speckle.Core.Tests.Integration", "Core\Tests\Speckle.Core.Tests.Integration\Speckle.Core.Tests.Integration.csproj", "{FB2DEE1D-788B-45B6-B80C-D8F7C8390C37}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConnectorGrasshopper8", "ConnectorGrasshopper\ConnectorGrasshopper8\ConnectorGrasshopper8.csproj", "{FDBC3082-1FAD-4701-A121-802F591D2D35}" ProjectSection(ProjectDependencies) = postProject @@ -449,10 +473,50 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConnectorGrasshopper8", "Co EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConverterGrasshopper8", "Objects\Converters\ConverterRhinoGh\ConverterGrasshopper8\ConverterGrasshopper8.csproj", "{15C4FF29-0370-4860-B80A-06CC5E0E8D5F}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ArcGIS", "ArcGIS", "{738FB542-F186-4473-8B70-B08D7EDC1EFD}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConnectorArcGIS", "ConnectorArcGIS\ConnectorArcGIS.csproj", "{63A209B9-3BBA-465C-8D8C-DC9E1F7D379D}" +EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{8A909E95-7A39-4B21-A04A-E168478E71F0}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Objects.Tests.Unit", "Objects\Tests\Objects.Tests.Unit\Objects.Tests.Unit.csproj", "{9E74F0E6-94B4-46BD-B1CA-DD874B459399}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "CNX-8892 - DUI3, DI, Kits", "CNX-8892 - DUI3, DI, Kits", "{9DB74760-01DE-4AC1-A81B-BC7784351D22}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Revit", "Revit", "{4838C66E-8677-4FBD-9609-25376042E981}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Connectors", "Connectors", "{33D19E88-F3AE-4D28-B588-D91CCF9E3BA8}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Objects", "Objects", "{B92E6216-2CBA-4EA5-B94B-0A7658C7F84B}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Converters", "Converters", "{1FE3C60E-7865-40A5-9794-55ECB64F6489}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Speckle.Connectors.Revit2023", "CNX-8892\Connectors\Revit\Speckle.Connectors.Revit2023\Speckle.Connectors.Revit2023.csproj", "{E1FF75EC-2BDF-4276-9C81-6EB195661348}" +EndProject +Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Speckle.Connectors.RevitShared", "CNX-8892\Connectors\Revit\Speckle.Connectors.RevitShared\Speckle.Connectors.RevitShared.shproj", "{32AEA787-C986-4B76-A57F-0DA5453AA1F5}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Speckle.Autofac", "CNX-8892\Speckle.Autofac\Speckle.Autofac.csproj", "{E854650A-9F2A-43D3-AB70-D9E34B33D2D6}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "DUI", "DUI", "{FD4D6594-D81E-456F-8F2E-35B09E04A755}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Speckle.Connectors.DUI", "CNX-8892\DUI3\Speckle.Connectors.DUI\Speckle.Connectors.DUI.csproj", "{86E64130-2DCE-4F51-B07C-B87138046E21}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Speckle.Connectors.Utils", "CNX-8892\Speckle.Connectors.Utils\Speckle.Connectors.Utils.csproj", "{D495D104-61D9-4476-B909-1C0E79C3650C}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Speckle.Converters.Revit2023", "CNX-8892\Converters\Revit\Speckle.Converters.Revit2023\Speckle.Converters.Revit2023.csproj", "{E577F692-C9E9-46A6-B9F1-CF70C93F1280}" +EndProject +Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Speckle.Converters.RevitShared", "CNX-8892\Converters\Revit\Speckle.Converters.RevitShared\Speckle.Converters.RevitShared.shproj", "{9655BE78-8070-4B9F-B0DC-68BB6150B52C}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Revit", "Revit", "{D92751C8-1039-4005-90B2-913E55E0B8BD}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Speckle.Converters.Common", "CNX-8892\Converters\Speckle.Converters.Common\Speckle.Converters.Common.csproj", "{3217D8B5-AE8F-4364-81CF-8B7C2BEF6445}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Speckle.Objects.Common", "CNX-8892\Objects\Speckle.Objects.Common\Speckle.Objects.Common.csproj", "{746047E4-BE3D-43D0-99E0-76259D262AC6}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Speckle.Objects.Revit", "CNX-8892\Objects\Speckle.Objects.Revit\Speckle.Objects.Revit.csproj", "{D32342E4-3223-48A0-8DF6-A1475BE27628}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Speckle.Converters.Revit2023.DependencyInjection", "CNX-8892\Converters\Revit\Speckle.Converters.Revit2023.DependencyInjection\Speckle.Converters.Revit2023.DependencyInjection.csproj", "{81F92B31-C647-4A82-A464-8322814F50E6}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug Mac|Any CPU = Debug Mac|Any CPU @@ -2135,6 +2199,104 @@ Global {2CC777EB-BD63-4FAB-BC3A-68A640D2E639}.Release|Any CPU.Build.0 = Release|Any CPU {2CC777EB-BD63-4FAB-BC3A-68A640D2E639}.Release|x64.ActiveCfg = Release|Any CPU {2CC777EB-BD63-4FAB-BC3A-68A640D2E639}.Release|x64.Build.0 = Release|Any CPU + {CC672C3F-482D-4137-AF8A-D0EC67D0EA7D}.Debug Mac|Any CPU.ActiveCfg = Debug|Any CPU + {CC672C3F-482D-4137-AF8A-D0EC67D0EA7D}.Debug Mac|Any CPU.Build.0 = Debug|Any CPU + {CC672C3F-482D-4137-AF8A-D0EC67D0EA7D}.Debug Mac|x64.ActiveCfg = Debug|Any CPU + {CC672C3F-482D-4137-AF8A-D0EC67D0EA7D}.Debug Mac|x64.Build.0 = Debug|Any CPU + {CC672C3F-482D-4137-AF8A-D0EC67D0EA7D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {CC672C3F-482D-4137-AF8A-D0EC67D0EA7D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {CC672C3F-482D-4137-AF8A-D0EC67D0EA7D}.Debug|x64.ActiveCfg = Debug|Any CPU + {CC672C3F-482D-4137-AF8A-D0EC67D0EA7D}.Debug|x64.Build.0 = Debug|Any CPU + {CC672C3F-482D-4137-AF8A-D0EC67D0EA7D}.Release Mac|Any CPU.ActiveCfg = Debug|Any CPU + {CC672C3F-482D-4137-AF8A-D0EC67D0EA7D}.Release Mac|Any CPU.Build.0 = Debug|Any CPU + {CC672C3F-482D-4137-AF8A-D0EC67D0EA7D}.Release Mac|x64.ActiveCfg = Debug|Any CPU + {CC672C3F-482D-4137-AF8A-D0EC67D0EA7D}.Release Mac|x64.Build.0 = Debug|Any CPU + {CC672C3F-482D-4137-AF8A-D0EC67D0EA7D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {CC672C3F-482D-4137-AF8A-D0EC67D0EA7D}.Release|Any CPU.Build.0 = Release|Any CPU + {CC672C3F-482D-4137-AF8A-D0EC67D0EA7D}.Release|x64.ActiveCfg = Release|Any CPU + {CC672C3F-482D-4137-AF8A-D0EC67D0EA7D}.Release|x64.Build.0 = Release|Any CPU + {D93D6296-B138-4853-A505-F2AB11B551DB}.Debug Mac|Any CPU.ActiveCfg = Debug|Any CPU + {D93D6296-B138-4853-A505-F2AB11B551DB}.Debug Mac|Any CPU.Build.0 = Debug|Any CPU + {D93D6296-B138-4853-A505-F2AB11B551DB}.Debug Mac|x64.ActiveCfg = Debug|Any CPU + {D93D6296-B138-4853-A505-F2AB11B551DB}.Debug Mac|x64.Build.0 = Debug|Any CPU + {D93D6296-B138-4853-A505-F2AB11B551DB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D93D6296-B138-4853-A505-F2AB11B551DB}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D93D6296-B138-4853-A505-F2AB11B551DB}.Debug|x64.ActiveCfg = Debug|x64 + {D93D6296-B138-4853-A505-F2AB11B551DB}.Debug|x64.Build.0 = Debug|x64 + {D93D6296-B138-4853-A505-F2AB11B551DB}.Release Mac|Any CPU.ActiveCfg = Debug|Any CPU + {D93D6296-B138-4853-A505-F2AB11B551DB}.Release Mac|Any CPU.Build.0 = Debug|Any CPU + {D93D6296-B138-4853-A505-F2AB11B551DB}.Release Mac|x64.ActiveCfg = Debug|Any CPU + {D93D6296-B138-4853-A505-F2AB11B551DB}.Release Mac|x64.Build.0 = Debug|Any CPU + {D93D6296-B138-4853-A505-F2AB11B551DB}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D93D6296-B138-4853-A505-F2AB11B551DB}.Release|Any CPU.Build.0 = Release|Any CPU + {D93D6296-B138-4853-A505-F2AB11B551DB}.Release|x64.ActiveCfg = Release|Any CPU + {D93D6296-B138-4853-A505-F2AB11B551DB}.Release|x64.Build.0 = Release|Any CPU + {1E5C7198-1065-4015-ACB5-BDFA1DC43589}.Debug Mac|Any CPU.ActiveCfg = Debug|Any CPU + {1E5C7198-1065-4015-ACB5-BDFA1DC43589}.Debug Mac|Any CPU.Build.0 = Debug|Any CPU + {1E5C7198-1065-4015-ACB5-BDFA1DC43589}.Debug Mac|x64.ActiveCfg = Debug|Any CPU + {1E5C7198-1065-4015-ACB5-BDFA1DC43589}.Debug Mac|x64.Build.0 = Debug|Any CPU + {1E5C7198-1065-4015-ACB5-BDFA1DC43589}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1E5C7198-1065-4015-ACB5-BDFA1DC43589}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1E5C7198-1065-4015-ACB5-BDFA1DC43589}.Debug|x64.ActiveCfg = Debug|Any CPU + {1E5C7198-1065-4015-ACB5-BDFA1DC43589}.Debug|x64.Build.0 = Debug|Any CPU + {1E5C7198-1065-4015-ACB5-BDFA1DC43589}.Release Mac|Any CPU.ActiveCfg = Debug|Any CPU + {1E5C7198-1065-4015-ACB5-BDFA1DC43589}.Release Mac|Any CPU.Build.0 = Debug|Any CPU + {1E5C7198-1065-4015-ACB5-BDFA1DC43589}.Release Mac|x64.ActiveCfg = Debug|Any CPU + {1E5C7198-1065-4015-ACB5-BDFA1DC43589}.Release Mac|x64.Build.0 = Debug|Any CPU + {1E5C7198-1065-4015-ACB5-BDFA1DC43589}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1E5C7198-1065-4015-ACB5-BDFA1DC43589}.Release|Any CPU.Build.0 = Release|Any CPU + {1E5C7198-1065-4015-ACB5-BDFA1DC43589}.Release|x64.ActiveCfg = Release|Any CPU + {1E5C7198-1065-4015-ACB5-BDFA1DC43589}.Release|x64.Build.0 = Release|Any CPU + {5698290F-250F-4336-ADF8-F269A36D1178}.Debug Mac|Any CPU.ActiveCfg = Debug|Any CPU + {5698290F-250F-4336-ADF8-F269A36D1178}.Debug Mac|Any CPU.Build.0 = Debug|Any CPU + {5698290F-250F-4336-ADF8-F269A36D1178}.Debug Mac|x64.ActiveCfg = Debug|Any CPU + {5698290F-250F-4336-ADF8-F269A36D1178}.Debug Mac|x64.Build.0 = Debug|Any CPU + {5698290F-250F-4336-ADF8-F269A36D1178}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5698290F-250F-4336-ADF8-F269A36D1178}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5698290F-250F-4336-ADF8-F269A36D1178}.Debug|x64.ActiveCfg = Debug|Any CPU + {5698290F-250F-4336-ADF8-F269A36D1178}.Debug|x64.Build.0 = Debug|Any CPU + {5698290F-250F-4336-ADF8-F269A36D1178}.Release Mac|Any CPU.ActiveCfg = Debug|Any CPU + {5698290F-250F-4336-ADF8-F269A36D1178}.Release Mac|Any CPU.Build.0 = Debug|Any CPU + {5698290F-250F-4336-ADF8-F269A36D1178}.Release Mac|x64.ActiveCfg = Debug|Any CPU + {5698290F-250F-4336-ADF8-F269A36D1178}.Release Mac|x64.Build.0 = Debug|Any CPU + {5698290F-250F-4336-ADF8-F269A36D1178}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5698290F-250F-4336-ADF8-F269A36D1178}.Release|Any CPU.Build.0 = Release|Any CPU + {5698290F-250F-4336-ADF8-F269A36D1178}.Release|x64.ActiveCfg = Release|Any CPU + {5698290F-250F-4336-ADF8-F269A36D1178}.Release|x64.Build.0 = Release|Any CPU + {2113F03B-BB8D-470B-A9A1-97BB9A554A44}.Debug Mac|Any CPU.ActiveCfg = Debug|Any CPU + {2113F03B-BB8D-470B-A9A1-97BB9A554A44}.Debug Mac|Any CPU.Build.0 = Debug|Any CPU + {2113F03B-BB8D-470B-A9A1-97BB9A554A44}.Debug Mac|x64.ActiveCfg = Debug|Any CPU + {2113F03B-BB8D-470B-A9A1-97BB9A554A44}.Debug Mac|x64.Build.0 = Debug|Any CPU + {2113F03B-BB8D-470B-A9A1-97BB9A554A44}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2113F03B-BB8D-470B-A9A1-97BB9A554A44}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2113F03B-BB8D-470B-A9A1-97BB9A554A44}.Debug|x64.ActiveCfg = Debug|x64 + {2113F03B-BB8D-470B-A9A1-97BB9A554A44}.Debug|x64.Build.0 = Debug|x64 + {2113F03B-BB8D-470B-A9A1-97BB9A554A44}.Release Mac|Any CPU.ActiveCfg = Debug|Any CPU + {2113F03B-BB8D-470B-A9A1-97BB9A554A44}.Release Mac|Any CPU.Build.0 = Debug|Any CPU + {2113F03B-BB8D-470B-A9A1-97BB9A554A44}.Release Mac|x64.ActiveCfg = Debug|Any CPU + {2113F03B-BB8D-470B-A9A1-97BB9A554A44}.Release Mac|x64.Build.0 = Debug|Any CPU + {2113F03B-BB8D-470B-A9A1-97BB9A554A44}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2113F03B-BB8D-470B-A9A1-97BB9A554A44}.Release|Any CPU.Build.0 = Release|Any CPU + {2113F03B-BB8D-470B-A9A1-97BB9A554A44}.Release|x64.ActiveCfg = Release|x64 + {2113F03B-BB8D-470B-A9A1-97BB9A554A44}.Release|x64.Build.0 = Release|x64 + {A364B196-38A3-45AB-A54A-F04D17C0B2DA}.Debug Mac|Any CPU.ActiveCfg = Debug|Any CPU + {A364B196-38A3-45AB-A54A-F04D17C0B2DA}.Debug Mac|Any CPU.Build.0 = Debug|Any CPU + {A364B196-38A3-45AB-A54A-F04D17C0B2DA}.Debug Mac|x64.ActiveCfg = Debug|Any CPU + {A364B196-38A3-45AB-A54A-F04D17C0B2DA}.Debug Mac|x64.Build.0 = Debug|Any CPU + {A364B196-38A3-45AB-A54A-F04D17C0B2DA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A364B196-38A3-45AB-A54A-F04D17C0B2DA}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A364B196-38A3-45AB-A54A-F04D17C0B2DA}.Debug|x64.ActiveCfg = Debug|x64 + {A364B196-38A3-45AB-A54A-F04D17C0B2DA}.Debug|x64.Build.0 = Debug|x64 + {A364B196-38A3-45AB-A54A-F04D17C0B2DA}.Release Mac|Any CPU.ActiveCfg = Debug|Any CPU + {A364B196-38A3-45AB-A54A-F04D17C0B2DA}.Release Mac|Any CPU.Build.0 = Debug|Any CPU + {A364B196-38A3-45AB-A54A-F04D17C0B2DA}.Release Mac|x64.ActiveCfg = Debug|Any CPU + {A364B196-38A3-45AB-A54A-F04D17C0B2DA}.Release Mac|x64.Build.0 = Debug|Any CPU + {A364B196-38A3-45AB-A54A-F04D17C0B2DA}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A364B196-38A3-45AB-A54A-F04D17C0B2DA}.Release|Any CPU.Build.0 = Release|Any CPU + {A364B196-38A3-45AB-A54A-F04D17C0B2DA}.Release|x64.ActiveCfg = Release|x64 + {A364B196-38A3-45AB-A54A-F04D17C0B2DA}.Release|x64.Build.0 = Release|x64 + {D22A887D-976C-4DBF-AE5B-9039F169E61C}.Debug Mac|Any CPU.ActiveCfg = Debug Mac|Any CPU + {D22A887D-976C-4DBF-AE5B-9039F169E61C}.Debug Mac|Any CPU.ActiveCfg = Debug Mac|Any CPU {D22A887D-976C-4DBF-AE5B-9039F169E61C}.Debug Mac|Any CPU.ActiveCfg = Debug Mac|Any CPU {D22A887D-976C-4DBF-AE5B-9039F169E61C}.Debug Mac|x64.ActiveCfg = Debug|Any CPU {D22A887D-976C-4DBF-AE5B-9039F169E61C}.Debug Mac|x64.Build.0 = Debug|Any CPU @@ -2239,6 +2401,22 @@ Global {15C4FF29-0370-4860-B80A-06CC5E0E8D5F}.Release|Any CPU.Build.0 = Release|Any CPU {15C4FF29-0370-4860-B80A-06CC5E0E8D5F}.Release|x64.ActiveCfg = Release|Any CPU {15C4FF29-0370-4860-B80A-06CC5E0E8D5F}.Release|x64.Build.0 = Release|Any CPU + {63A209B9-3BBA-465C-8D8C-DC9E1F7D379D}.Debug Mac|Any CPU.ActiveCfg = Debug|Any CPU + {63A209B9-3BBA-465C-8D8C-DC9E1F7D379D}.Debug Mac|Any CPU.Build.0 = Debug|Any CPU + {63A209B9-3BBA-465C-8D8C-DC9E1F7D379D}.Debug Mac|x64.ActiveCfg = Debug|Any CPU + {63A209B9-3BBA-465C-8D8C-DC9E1F7D379D}.Debug Mac|x64.Build.0 = Debug|Any CPU + {63A209B9-3BBA-465C-8D8C-DC9E1F7D379D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {63A209B9-3BBA-465C-8D8C-DC9E1F7D379D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {63A209B9-3BBA-465C-8D8C-DC9E1F7D379D}.Debug|x64.ActiveCfg = Debug|Any CPU + {63A209B9-3BBA-465C-8D8C-DC9E1F7D379D}.Debug|x64.Build.0 = Debug|Any CPU + {63A209B9-3BBA-465C-8D8C-DC9E1F7D379D}.Release Mac|Any CPU.ActiveCfg = Debug|Any CPU + {63A209B9-3BBA-465C-8D8C-DC9E1F7D379D}.Release Mac|Any CPU.Build.0 = Debug|Any CPU + {63A209B9-3BBA-465C-8D8C-DC9E1F7D379D}.Release Mac|x64.ActiveCfg = Debug|Any CPU + {63A209B9-3BBA-465C-8D8C-DC9E1F7D379D}.Release Mac|x64.Build.0 = Debug|Any CPU + {63A209B9-3BBA-465C-8D8C-DC9E1F7D379D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {63A209B9-3BBA-465C-8D8C-DC9E1F7D379D}.Release|Any CPU.Build.0 = Release|Any CPU + {63A209B9-3BBA-465C-8D8C-DC9E1F7D379D}.Release|x64.ActiveCfg = Release|Any CPU + {63A209B9-3BBA-465C-8D8C-DC9E1F7D379D}.Release|x64.Build.0 = Release|Any CPU {9E74F0E6-94B4-46BD-B1CA-DD874B459399}.Debug Mac|Any CPU.ActiveCfg = Debug|Any CPU {9E74F0E6-94B4-46BD-B1CA-DD874B459399}.Debug Mac|Any CPU.Build.0 = Debug|Any CPU {9E74F0E6-94B4-46BD-B1CA-DD874B459399}.Debug Mac|x64.ActiveCfg = Debug|Any CPU @@ -2255,6 +2433,150 @@ Global {9E74F0E6-94B4-46BD-B1CA-DD874B459399}.Release|Any CPU.Build.0 = Release|Any CPU {9E74F0E6-94B4-46BD-B1CA-DD874B459399}.Release|x64.ActiveCfg = Release|Any CPU {9E74F0E6-94B4-46BD-B1CA-DD874B459399}.Release|x64.Build.0 = Release|Any CPU + {E1FF75EC-2BDF-4276-9C81-6EB195661348}.Debug Mac|Any CPU.ActiveCfg = Debug|Any CPU + {E1FF75EC-2BDF-4276-9C81-6EB195661348}.Debug Mac|Any CPU.Build.0 = Debug|Any CPU + {E1FF75EC-2BDF-4276-9C81-6EB195661348}.Debug Mac|x64.ActiveCfg = Debug|Any CPU + {E1FF75EC-2BDF-4276-9C81-6EB195661348}.Debug Mac|x64.Build.0 = Debug|Any CPU + {E1FF75EC-2BDF-4276-9C81-6EB195661348}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E1FF75EC-2BDF-4276-9C81-6EB195661348}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E1FF75EC-2BDF-4276-9C81-6EB195661348}.Debug|x64.ActiveCfg = Debug|x64 + {E1FF75EC-2BDF-4276-9C81-6EB195661348}.Debug|x64.Build.0 = Debug|x64 + {E1FF75EC-2BDF-4276-9C81-6EB195661348}.Release Mac|Any CPU.ActiveCfg = Release|Any CPU + {E1FF75EC-2BDF-4276-9C81-6EB195661348}.Release Mac|Any CPU.Build.0 = Release|Any CPU + {E1FF75EC-2BDF-4276-9C81-6EB195661348}.Release Mac|x64.ActiveCfg = Release|Any CPU + {E1FF75EC-2BDF-4276-9C81-6EB195661348}.Release Mac|x64.Build.0 = Release|Any CPU + {E1FF75EC-2BDF-4276-9C81-6EB195661348}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E1FF75EC-2BDF-4276-9C81-6EB195661348}.Release|Any CPU.Build.0 = Release|Any CPU + {E1FF75EC-2BDF-4276-9C81-6EB195661348}.Release|x64.ActiveCfg = Release|Any CPU + {E1FF75EC-2BDF-4276-9C81-6EB195661348}.Release|x64.Build.0 = Release|Any CPU + {E854650A-9F2A-43D3-AB70-D9E34B33D2D6}.Debug Mac|Any CPU.ActiveCfg = Debug|Any CPU + {E854650A-9F2A-43D3-AB70-D9E34B33D2D6}.Debug Mac|Any CPU.Build.0 = Debug|Any CPU + {E854650A-9F2A-43D3-AB70-D9E34B33D2D6}.Debug Mac|x64.ActiveCfg = Debug|Any CPU + {E854650A-9F2A-43D3-AB70-D9E34B33D2D6}.Debug Mac|x64.Build.0 = Debug|Any CPU + {E854650A-9F2A-43D3-AB70-D9E34B33D2D6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E854650A-9F2A-43D3-AB70-D9E34B33D2D6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E854650A-9F2A-43D3-AB70-D9E34B33D2D6}.Debug|x64.ActiveCfg = Debug|x64 + {E854650A-9F2A-43D3-AB70-D9E34B33D2D6}.Debug|x64.Build.0 = Debug|x64 + {E854650A-9F2A-43D3-AB70-D9E34B33D2D6}.Release Mac|Any CPU.ActiveCfg = Release|Any CPU + {E854650A-9F2A-43D3-AB70-D9E34B33D2D6}.Release Mac|Any CPU.Build.0 = Release|Any CPU + {E854650A-9F2A-43D3-AB70-D9E34B33D2D6}.Release Mac|x64.ActiveCfg = Release|Any CPU + {E854650A-9F2A-43D3-AB70-D9E34B33D2D6}.Release Mac|x64.Build.0 = Release|Any CPU + {E854650A-9F2A-43D3-AB70-D9E34B33D2D6}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E854650A-9F2A-43D3-AB70-D9E34B33D2D6}.Release|Any CPU.Build.0 = Release|Any CPU + {E854650A-9F2A-43D3-AB70-D9E34B33D2D6}.Release|x64.ActiveCfg = Release|Any CPU + {E854650A-9F2A-43D3-AB70-D9E34B33D2D6}.Release|x64.Build.0 = Release|Any CPU + {86E64130-2DCE-4F51-B07C-B87138046E21}.Debug Mac|Any CPU.ActiveCfg = Debug|Any CPU + {86E64130-2DCE-4F51-B07C-B87138046E21}.Debug Mac|Any CPU.Build.0 = Debug|Any CPU + {86E64130-2DCE-4F51-B07C-B87138046E21}.Debug Mac|x64.ActiveCfg = Debug|Any CPU + {86E64130-2DCE-4F51-B07C-B87138046E21}.Debug Mac|x64.Build.0 = Debug|Any CPU + {86E64130-2DCE-4F51-B07C-B87138046E21}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {86E64130-2DCE-4F51-B07C-B87138046E21}.Debug|Any CPU.Build.0 = Debug|Any CPU + {86E64130-2DCE-4F51-B07C-B87138046E21}.Debug|x64.ActiveCfg = Debug|x64 + {86E64130-2DCE-4F51-B07C-B87138046E21}.Debug|x64.Build.0 = Debug|x64 + {86E64130-2DCE-4F51-B07C-B87138046E21}.Release Mac|Any CPU.ActiveCfg = Release|Any CPU + {86E64130-2DCE-4F51-B07C-B87138046E21}.Release Mac|Any CPU.Build.0 = Release|Any CPU + {86E64130-2DCE-4F51-B07C-B87138046E21}.Release Mac|x64.ActiveCfg = Release|Any CPU + {86E64130-2DCE-4F51-B07C-B87138046E21}.Release Mac|x64.Build.0 = Release|Any CPU + {86E64130-2DCE-4F51-B07C-B87138046E21}.Release|Any CPU.ActiveCfg = Release|Any CPU + {86E64130-2DCE-4F51-B07C-B87138046E21}.Release|Any CPU.Build.0 = Release|Any CPU + {86E64130-2DCE-4F51-B07C-B87138046E21}.Release|x64.ActiveCfg = Release|Any CPU + {86E64130-2DCE-4F51-B07C-B87138046E21}.Release|x64.Build.0 = Release|Any CPU + {D495D104-61D9-4476-B909-1C0E79C3650C}.Debug Mac|Any CPU.ActiveCfg = Debug|Any CPU + {D495D104-61D9-4476-B909-1C0E79C3650C}.Debug Mac|Any CPU.Build.0 = Debug|Any CPU + {D495D104-61D9-4476-B909-1C0E79C3650C}.Debug Mac|x64.ActiveCfg = Debug|Any CPU + {D495D104-61D9-4476-B909-1C0E79C3650C}.Debug Mac|x64.Build.0 = Debug|Any CPU + {D495D104-61D9-4476-B909-1C0E79C3650C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D495D104-61D9-4476-B909-1C0E79C3650C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D495D104-61D9-4476-B909-1C0E79C3650C}.Debug|x64.ActiveCfg = Debug|x64 + {D495D104-61D9-4476-B909-1C0E79C3650C}.Debug|x64.Build.0 = Debug|x64 + {D495D104-61D9-4476-B909-1C0E79C3650C}.Release Mac|Any CPU.ActiveCfg = Release|Any CPU + {D495D104-61D9-4476-B909-1C0E79C3650C}.Release Mac|Any CPU.Build.0 = Release|Any CPU + {D495D104-61D9-4476-B909-1C0E79C3650C}.Release Mac|x64.ActiveCfg = Release|Any CPU + {D495D104-61D9-4476-B909-1C0E79C3650C}.Release Mac|x64.Build.0 = Release|Any CPU + {D495D104-61D9-4476-B909-1C0E79C3650C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D495D104-61D9-4476-B909-1C0E79C3650C}.Release|Any CPU.Build.0 = Release|Any CPU + {D495D104-61D9-4476-B909-1C0E79C3650C}.Release|x64.ActiveCfg = Release|Any CPU + {D495D104-61D9-4476-B909-1C0E79C3650C}.Release|x64.Build.0 = Release|Any CPU + {E577F692-C9E9-46A6-B9F1-CF70C93F1280}.Debug Mac|Any CPU.ActiveCfg = Debug|Any CPU + {E577F692-C9E9-46A6-B9F1-CF70C93F1280}.Debug Mac|Any CPU.Build.0 = Debug|Any CPU + {E577F692-C9E9-46A6-B9F1-CF70C93F1280}.Debug Mac|x64.ActiveCfg = Debug|Any CPU + {E577F692-C9E9-46A6-B9F1-CF70C93F1280}.Debug Mac|x64.Build.0 = Debug|Any CPU + {E577F692-C9E9-46A6-B9F1-CF70C93F1280}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E577F692-C9E9-46A6-B9F1-CF70C93F1280}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E577F692-C9E9-46A6-B9F1-CF70C93F1280}.Debug|x64.ActiveCfg = Debug|Any CPU + {E577F692-C9E9-46A6-B9F1-CF70C93F1280}.Debug|x64.Build.0 = Debug|Any CPU + {E577F692-C9E9-46A6-B9F1-CF70C93F1280}.Release Mac|Any CPU.ActiveCfg = Release|Any CPU + {E577F692-C9E9-46A6-B9F1-CF70C93F1280}.Release Mac|Any CPU.Build.0 = Release|Any CPU + {E577F692-C9E9-46A6-B9F1-CF70C93F1280}.Release Mac|x64.ActiveCfg = Release|Any CPU + {E577F692-C9E9-46A6-B9F1-CF70C93F1280}.Release Mac|x64.Build.0 = Release|Any CPU + {E577F692-C9E9-46A6-B9F1-CF70C93F1280}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E577F692-C9E9-46A6-B9F1-CF70C93F1280}.Release|Any CPU.Build.0 = Release|Any CPU + {E577F692-C9E9-46A6-B9F1-CF70C93F1280}.Release|x64.ActiveCfg = Release|Any CPU + {E577F692-C9E9-46A6-B9F1-CF70C93F1280}.Release|x64.Build.0 = Release|Any CPU + {3217D8B5-AE8F-4364-81CF-8B7C2BEF6445}.Debug Mac|Any CPU.ActiveCfg = Debug|Any CPU + {3217D8B5-AE8F-4364-81CF-8B7C2BEF6445}.Debug Mac|Any CPU.Build.0 = Debug|Any CPU + {3217D8B5-AE8F-4364-81CF-8B7C2BEF6445}.Debug Mac|x64.ActiveCfg = Debug|Any CPU + {3217D8B5-AE8F-4364-81CF-8B7C2BEF6445}.Debug Mac|x64.Build.0 = Debug|Any CPU + {3217D8B5-AE8F-4364-81CF-8B7C2BEF6445}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3217D8B5-AE8F-4364-81CF-8B7C2BEF6445}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3217D8B5-AE8F-4364-81CF-8B7C2BEF6445}.Debug|x64.ActiveCfg = Debug|Any CPU + {3217D8B5-AE8F-4364-81CF-8B7C2BEF6445}.Debug|x64.Build.0 = Debug|Any CPU + {3217D8B5-AE8F-4364-81CF-8B7C2BEF6445}.Release Mac|Any CPU.ActiveCfg = Release|Any CPU + {3217D8B5-AE8F-4364-81CF-8B7C2BEF6445}.Release Mac|Any CPU.Build.0 = Release|Any CPU + {3217D8B5-AE8F-4364-81CF-8B7C2BEF6445}.Release Mac|x64.ActiveCfg = Release|Any CPU + {3217D8B5-AE8F-4364-81CF-8B7C2BEF6445}.Release Mac|x64.Build.0 = Release|Any CPU + {3217D8B5-AE8F-4364-81CF-8B7C2BEF6445}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3217D8B5-AE8F-4364-81CF-8B7C2BEF6445}.Release|Any CPU.Build.0 = Release|Any CPU + {3217D8B5-AE8F-4364-81CF-8B7C2BEF6445}.Release|x64.ActiveCfg = Release|Any CPU + {3217D8B5-AE8F-4364-81CF-8B7C2BEF6445}.Release|x64.Build.0 = Release|Any CPU + {746047E4-BE3D-43D0-99E0-76259D262AC6}.Debug Mac|Any CPU.ActiveCfg = Debug|Any CPU + {746047E4-BE3D-43D0-99E0-76259D262AC6}.Debug Mac|Any CPU.Build.0 = Debug|Any CPU + {746047E4-BE3D-43D0-99E0-76259D262AC6}.Debug Mac|x64.ActiveCfg = Debug|Any CPU + {746047E4-BE3D-43D0-99E0-76259D262AC6}.Debug Mac|x64.Build.0 = Debug|Any CPU + {746047E4-BE3D-43D0-99E0-76259D262AC6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {746047E4-BE3D-43D0-99E0-76259D262AC6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {746047E4-BE3D-43D0-99E0-76259D262AC6}.Debug|x64.ActiveCfg = Debug|Any CPU + {746047E4-BE3D-43D0-99E0-76259D262AC6}.Debug|x64.Build.0 = Debug|Any CPU + {746047E4-BE3D-43D0-99E0-76259D262AC6}.Release Mac|Any CPU.ActiveCfg = Release|Any CPU + {746047E4-BE3D-43D0-99E0-76259D262AC6}.Release Mac|Any CPU.Build.0 = Release|Any CPU + {746047E4-BE3D-43D0-99E0-76259D262AC6}.Release Mac|x64.ActiveCfg = Release|Any CPU + {746047E4-BE3D-43D0-99E0-76259D262AC6}.Release Mac|x64.Build.0 = Release|Any CPU + {746047E4-BE3D-43D0-99E0-76259D262AC6}.Release|Any CPU.ActiveCfg = Release|Any CPU + {746047E4-BE3D-43D0-99E0-76259D262AC6}.Release|Any CPU.Build.0 = Release|Any CPU + {746047E4-BE3D-43D0-99E0-76259D262AC6}.Release|x64.ActiveCfg = Release|Any CPU + {746047E4-BE3D-43D0-99E0-76259D262AC6}.Release|x64.Build.0 = Release|Any CPU + {D32342E4-3223-48A0-8DF6-A1475BE27628}.Debug Mac|Any CPU.ActiveCfg = Debug|Any CPU + {D32342E4-3223-48A0-8DF6-A1475BE27628}.Debug Mac|Any CPU.Build.0 = Debug|Any CPU + {D32342E4-3223-48A0-8DF6-A1475BE27628}.Debug Mac|x64.ActiveCfg = Debug|Any CPU + {D32342E4-3223-48A0-8DF6-A1475BE27628}.Debug Mac|x64.Build.0 = Debug|Any CPU + {D32342E4-3223-48A0-8DF6-A1475BE27628}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D32342E4-3223-48A0-8DF6-A1475BE27628}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D32342E4-3223-48A0-8DF6-A1475BE27628}.Debug|x64.ActiveCfg = Debug|Any CPU + {D32342E4-3223-48A0-8DF6-A1475BE27628}.Debug|x64.Build.0 = Debug|Any CPU + {D32342E4-3223-48A0-8DF6-A1475BE27628}.Release Mac|Any CPU.ActiveCfg = Release|Any CPU + {D32342E4-3223-48A0-8DF6-A1475BE27628}.Release Mac|Any CPU.Build.0 = Release|Any CPU + {D32342E4-3223-48A0-8DF6-A1475BE27628}.Release Mac|x64.ActiveCfg = Release|Any CPU + {D32342E4-3223-48A0-8DF6-A1475BE27628}.Release Mac|x64.Build.0 = Release|Any CPU + {D32342E4-3223-48A0-8DF6-A1475BE27628}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D32342E4-3223-48A0-8DF6-A1475BE27628}.Release|Any CPU.Build.0 = Release|Any CPU + {D32342E4-3223-48A0-8DF6-A1475BE27628}.Release|x64.ActiveCfg = Release|Any CPU + {D32342E4-3223-48A0-8DF6-A1475BE27628}.Release|x64.Build.0 = Release|Any CPU + {81F92B31-C647-4A82-A464-8322814F50E6}.Debug Mac|Any CPU.ActiveCfg = Debug|Any CPU + {81F92B31-C647-4A82-A464-8322814F50E6}.Debug Mac|Any CPU.Build.0 = Debug|Any CPU + {81F92B31-C647-4A82-A464-8322814F50E6}.Debug Mac|x64.ActiveCfg = Debug|Any CPU + {81F92B31-C647-4A82-A464-8322814F50E6}.Debug Mac|x64.Build.0 = Debug|Any CPU + {81F92B31-C647-4A82-A464-8322814F50E6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {81F92B31-C647-4A82-A464-8322814F50E6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {81F92B31-C647-4A82-A464-8322814F50E6}.Debug|x64.ActiveCfg = Debug|Any CPU + {81F92B31-C647-4A82-A464-8322814F50E6}.Debug|x64.Build.0 = Debug|Any CPU + {81F92B31-C647-4A82-A464-8322814F50E6}.Release Mac|Any CPU.ActiveCfg = Release|Any CPU + {81F92B31-C647-4A82-A464-8322814F50E6}.Release Mac|Any CPU.Build.0 = Release|Any CPU + {81F92B31-C647-4A82-A464-8322814F50E6}.Release Mac|x64.ActiveCfg = Release|Any CPU + {81F92B31-C647-4A82-A464-8322814F50E6}.Release Mac|x64.Build.0 = Release|Any CPU + {81F92B31-C647-4A82-A464-8322814F50E6}.Release|Any CPU.ActiveCfg = Release|Any CPU + {81F92B31-C647-4A82-A464-8322814F50E6}.Release|Any CPU.Build.0 = Release|Any CPU + {81F92B31-C647-4A82-A464-8322814F50E6}.Release|x64.ActiveCfg = Release|Any CPU + {81F92B31-C647-4A82-A464-8322814F50E6}.Release|x64.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -2413,6 +2735,17 @@ Global {A0C9EBE0-A56A-4D07-B6EF-2EEAEC45D6C4} = {C6FF0E4F-38A3-4464-98E9-AB71D74B06F4} {7F0206A9-61D4-4D3A-9B43-789DABA7C143} = {DA9DFC36-C53F-4B19-8911-BF7605230BA7} {2CC777EB-BD63-4FAB-BC3A-68A640D2E639} = {DA9DFC36-C53F-4B19-8911-BF7605230BA7} + {1F00E9FB-6478-4350-A495-C5667D749832} = {F1666772-262D-4577-976F-89A1C0E2D73E} + {CC672C3F-482D-4137-AF8A-D0EC67D0EA7D} = {1F00E9FB-6478-4350-A495-C5667D749832} + {D93D6296-B138-4853-A505-F2AB11B551DB} = {F1666772-262D-4577-976F-89A1C0E2D73E} + {EA1F6DBC-41B6-4FA6-8A05-89FF91105543} = {F1666772-262D-4577-976F-89A1C0E2D73E} + {1E5C7198-1065-4015-ACB5-BDFA1DC43589} = {EA1F6DBC-41B6-4FA6-8A05-89FF91105543} + {5698290F-250F-4336-ADF8-F269A36D1178} = {EA1F6DBC-41B6-4FA6-8A05-89FF91105543} + {2BDE80E8-5F26-4E57-BBA6-109120F5D4EE} = {EA1F6DBC-41B6-4FA6-8A05-89FF91105543} + {047CA18F-AD79-4C31-985D-EEA8E070985D} = {F1666772-262D-4577-976F-89A1C0E2D73E} + {2113F03B-BB8D-470B-A9A1-97BB9A554A44} = {047CA18F-AD79-4C31-985D-EEA8E070985D} + {A364B196-38A3-45AB-A54A-F04D17C0B2DA} = {047CA18F-AD79-4C31-985D-EEA8E070985D} + {3D7F0278-6CF2-4588-A101-4027ABB8B87F} = {047CA18F-AD79-4C31-985D-EEA8E070985D} {D22A887D-976C-4DBF-AE5B-9039F169E61C} = {E94E7327-5A9B-48EE-93CC-E9E9A5B980F1} {89996067-3233-410A-A6A1-39E2F11F0626} = {1FD850CA-A8D7-41DC-9316-B315800437E1} {5009BB59-0F77-4202-8FD2-DECC07E93146} = {8AA78EE8-C33B-4BC5-992A-E5DE7AB0BEC7} @@ -2421,8 +2754,27 @@ Global {FB2DEE1D-788B-45B6-B80C-D8F7C8390C37} = {5009BB59-0F77-4202-8FD2-DECC07E93146} {FDBC3082-1FAD-4701-A121-802F591D2D35} = {9461B162-AD2F-4F60-BCE4-E72DCEFD4608} {15C4FF29-0370-4860-B80A-06CC5E0E8D5F} = {1FD850CA-A8D7-41DC-9316-B315800437E1} + {738FB542-F186-4473-8B70-B08D7EDC1EFD} = {F1666772-262D-4577-976F-89A1C0E2D73E} + {63A209B9-3BBA-465C-8D8C-DC9E1F7D379D} = {738FB542-F186-4473-8B70-B08D7EDC1EFD} {8A909E95-7A39-4B21-A04A-E168478E71F0} = {E3916A0F-68D5-4C84-ACAE-41547F75E454} {9E74F0E6-94B4-46BD-B1CA-DD874B459399} = {8A909E95-7A39-4B21-A04A-E168478E71F0} + {4838C66E-8677-4FBD-9609-25376042E981} = {33D19E88-F3AE-4D28-B588-D91CCF9E3BA8} + {33D19E88-F3AE-4D28-B588-D91CCF9E3BA8} = {9DB74760-01DE-4AC1-A81B-BC7784351D22} + {B92E6216-2CBA-4EA5-B94B-0A7658C7F84B} = {9DB74760-01DE-4AC1-A81B-BC7784351D22} + {1FE3C60E-7865-40A5-9794-55ECB64F6489} = {9DB74760-01DE-4AC1-A81B-BC7784351D22} + {E1FF75EC-2BDF-4276-9C81-6EB195661348} = {4838C66E-8677-4FBD-9609-25376042E981} + {32AEA787-C986-4B76-A57F-0DA5453AA1F5} = {4838C66E-8677-4FBD-9609-25376042E981} + {E854650A-9F2A-43D3-AB70-D9E34B33D2D6} = {9DB74760-01DE-4AC1-A81B-BC7784351D22} + {FD4D6594-D81E-456F-8F2E-35B09E04A755} = {9DB74760-01DE-4AC1-A81B-BC7784351D22} + {86E64130-2DCE-4F51-B07C-B87138046E21} = {FD4D6594-D81E-456F-8F2E-35B09E04A755} + {D495D104-61D9-4476-B909-1C0E79C3650C} = {9DB74760-01DE-4AC1-A81B-BC7784351D22} + {E577F692-C9E9-46A6-B9F1-CF70C93F1280} = {D92751C8-1039-4005-90B2-913E55E0B8BD} + {9655BE78-8070-4B9F-B0DC-68BB6150B52C} = {D92751C8-1039-4005-90B2-913E55E0B8BD} + {D92751C8-1039-4005-90B2-913E55E0B8BD} = {1FE3C60E-7865-40A5-9794-55ECB64F6489} + {3217D8B5-AE8F-4364-81CF-8B7C2BEF6445} = {1FE3C60E-7865-40A5-9794-55ECB64F6489} + {746047E4-BE3D-43D0-99E0-76259D262AC6} = {B92E6216-2CBA-4EA5-B94B-0A7658C7F84B} + {D32342E4-3223-48A0-8DF6-A1475BE27628} = {B92E6216-2CBA-4EA5-B94B-0A7658C7F84B} + {81F92B31-C647-4A82-A464-8322814F50E6} = {D92751C8-1039-4005-90B2-913E55E0B8BD} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {1D43D91B-4F01-4A78-8250-CC6F9BD93A14} @@ -2436,19 +2788,24 @@ Global Objects\Converters\ConverterRevit\ConverterRevitTests\ConverterRevitTestsShared\ConverterRevitTestsShared.projitems*{1085f4b5-fdad-4ff8-b144-dddbd9454f55}*SharedItemsImports = 13 Objects\Converters\ConverterRhinoGh\ConverterRhinoGhShared\ConverterRhinoGhShared.projitems*{15c4ff29-0370-4860-b80a-06cc5e0e8d5f}*SharedItemsImports = 5 Objects\Converters\ConverterRevit\ConverterRevitTests\ConverterRevitTestsShared\ConverterRevitTestsShared.projitems*{1d1b6eda-8fd9-4758-9195-c3476db31f4e}*SharedItemsImports = 5 + ConnectorAutocadCivil\AutocadCivilDUI3\AutocadCivilDUI3Shared\AutocadCivilDUI3Shared.projitems*{1e5c7198-1065-4015-acb5-bdfa1dc43589}*SharedItemsImports = 5 Objects\Converters\ConverterAutocadCivil\ConverterAutocadCivilShared\ConverterAutocadCivilShared.projitems*{1f21e740-6b05-47bd-8d2a-c9ed5e91c577}*SharedItemsImports = 5 + ConnectorRevit\RevitDUI3\RevitDUI3Shared\RevitDUI3Shared.projitems*{2113f03b-bb8d-470b-a9a1-97bb9a554a44}*SharedItemsImports = 5 Objects\Converters\ConverterCSI\ConverterCSIShared\ConverterCSIShared.projitems*{21223ba5-c6e8-405d-b581-106c4726edc0}*SharedItemsImports = 5 ConnectorNavisworks\ConnectorNavisworks\ConnectorNavisworks.Shared.projitems*{2568500e-f1bc-440e-9150-db4820b3fad6}*SharedItemsImports = 5 ConnectorAutocadCivil\ConnectorAutocadCivil\ConnectorAutocadCivilShared.projitems*{2639e37d-80d3-415a-b4d1-20d7f321f27f}*SharedItemsImports = 5 Objects\Converters\ConverterRhinoGh\ConverterRhinoGhShared\ConverterRhinoGhShared.projitems*{26eca1be-f5b2-4a41-9658-46a4a917bfe6}*SharedItemsImports = 5 ConnectorRevit\ConnectorRevit\ConnectorRevit.projitems*{27a79aca-7ea8-4406-8bb8-216578cc3ab7}*SharedItemsImports = 5 ConnectorTeklaStructures\ConnectorTeklaStructuresShared\ConnectorTeklaStructuresShared.projitems*{28e2ea7f-ffd1-4e13-9165-0243b5ac82f5}*SharedItemsImports = 13 + ConnectorAutocadCivil\AutocadCivilDUI3\AutocadCivilDUI3Shared\AutocadCivilDUI3Shared.projitems*{2bde80e8-5f26-4e57-bba6-109120f5d4ee}*SharedItemsImports = 13 Objects\Converters\ConverterAutocadCivil\ConverterAutocadCivilShared\ConverterAutocadCivilShared.projitems*{2d0f9f8a-2e89-4780-978a-cd92d6d7b843}*SharedItemsImports = 13 Objects\Converters\ConverterRevit\ConverterRevitShared\ConverterRevitShared.projitems*{2dcd648d-dca5-4d2a-8b14-ad2cb85d24b0}*SharedItemsImports = 13 + CNX-8892\Connectors\Revit\Speckle.Connectors.RevitShared\Speckle.Connectors.RevitShared.projitems*{32aea787-c986-4b76-a57f-0da5453aa1f5}*SharedItemsImports = 13 ConnectorBentley\ConnectorBentleyShared\ConnectorBentleyShared.projitems*{372d9f0f-ede9-4050-bf8c-758911c5c2e0}*SharedItemsImports = 13 ConnectorTeklaStructures\ConnectorTeklaStructuresShared\ConnectorTeklaStructuresShared.projitems*{3af1ef30-0906-4926-a02c-4e3ad666352a}*SharedItemsImports = 5 ConnectorAutocadCivil\ConnectorAutocadCivil\ConnectorAutocadCivilShared.projitems*{3b9189b9-e485-448a-8793-9b9587a36791}*SharedItemsImports = 5 Objects\Converters\ConverterRhinoGh\ConverterRhinoGhShared\ConverterRhinoGhShared.projitems*{3cdef4cc-2cfa-4939-8427-3ed00fa9db55}*SharedItemsImports = 5 + ConnectorRevit\RevitDUI3\RevitDUI3Shared\RevitDUI3Shared.projitems*{3d7f0278-6cf2-4588-a101-4027abb8b87f}*SharedItemsImports = 13 Objects\Converters\ConverterDynamo\ConverterDynamoShared\ConverterDynamoShared.projitems*{3df12639-78b6-41b3-a046-a675035369be}*SharedItemsImports = 5 ConnectorAutocadCivil\ConnectorAutocadCivil\ConnectorAutocadCivilShared.projitems*{3e30d170-3cb4-4728-97d5-887c5019da9b}*SharedItemsImports = 5 Objects\Converters\ConverterBentley\ConverterBentleyShared\ConverterBentleyShared.projitems*{425f0d00-6608-4bd2-a1e0-2730c9f2bfd3}*SharedItemsImports = 13 @@ -2462,6 +2819,7 @@ Global ConnectorTeklaStructures\ConnectorTeklaStructuresShared\ConnectorTeklaStructuresShared.projitems*{511c2fb0-9c73-4ac9-ba59-c8a84c089c59}*SharedItemsImports = 5 ConnectorRevit\RevitSharedResources\RevitSharedResources.projitems*{521a7d9c-637f-4965-a6e6-ba96df99807d}*SharedItemsImports = 5 Objects\Converters\ConverterRevit\ConverterRevitTests\ConverterRevitTestsShared\ConverterRevitTestsShared.projitems*{54e90327-5f48-468d-9349-17aaceaa0a77}*SharedItemsImports = 5 + ConnectorAutocadCivil\AutocadCivilDUI3\AutocadCivilDUI3Shared\AutocadCivilDUI3Shared.projitems*{5698290f-250f-4336-adf8-f269a36d1178}*SharedItemsImports = 5 ConnectorBentley\ConnectorBentleyShared\ConnectorBentleyShared.projitems*{57bf94a8-8f73-4d1a-91d2-b10cc64178b6}*SharedItemsImports = 5 ConnectorRevit\ConnectorRevit\ConnectorRevit.projitems*{586a5a37-93f6-427e-8df8-c10db4d6822a}*SharedItemsImports = 5 ConnectorAutocadCivil\ConnectorAutocadCivil\ConnectorAutocadCivilShared.projitems*{58a88f1a-7489-46d2-949d-2fc3f68c8d84}*SharedItemsImports = 5 @@ -2494,9 +2852,11 @@ Global Objects\Converters\ConverterBentley\ConverterBentleyShared\ConverterBentleyShared.projitems*{8b50fa79-2ff0-4efa-b50f-9bf47ff3e130}*SharedItemsImports = 5 Objects\Converters\ConverterCSI\ConverterCSIShared\ConverterCSIShared.projitems*{907aed7a-719b-4157-8cc9-d21cb26e9243}*SharedItemsImports = 5 Objects\Converters\ConverterBentley\ConverterBentleyShared\ConverterBentleyShared.projitems*{931fc9a8-18b4-4ac5-81d9-14c48499bfb5}*SharedItemsImports = 5 + CNX-8892\Converters\Revit\Speckle.Converters.RevitShared\Speckle.Converters.RevitShared.projitems*{9655be78-8070-4b9f-b0dc-68bb6150b52c}*SharedItemsImports = 13 ConnectorRevit\ConnectorRevit\ConnectorRevit.projitems*{9a1e899a-f821-4519-aad1-0789a4e9ccb3}*SharedItemsImports = 5 ConnectorNavisworks\ConnectorNavisworks\ConnectorNavisworks.Shared.projitems*{9a7d7f9a-4fe1-4053-950b-50b43bc81087}*SharedItemsImports = 5 ConnectorCSI\ConnectorCSIShared\ConnectorCSIShared.projitems*{9d188843-8841-4a76-a844-efbe8e32ee05}*SharedItemsImports = 5 + ConnectorRevit\RevitDUI3\RevitDUI3Shared\RevitDUI3Shared.projitems*{a364b196-38a3-45ab-a54a-f04d17c0b2da}*SharedItemsImports = 5 ConnectorBentley\ConnectorBentleyShared\ConnectorBentleyShared.projitems*{a3a0ee09-6055-4009-ab8e-13fbc1a403a9}*SharedItemsImports = 5 ConnectorNavisworks\ConnectorNavisworks\ConnectorNavisworks.Shared.projitems*{a517a609-cab1-4b33-b83c-1b13b34e4560}*SharedItemsImports = 13 ConnectorRhino\ConnectorRhino\ConnectorRhinoShared\ConnectorRhinoShared.projitems*{a64acbf9-db82-4839-af99-57ed2e7989f4}*SharedItemsImports = 5 @@ -2528,6 +2888,8 @@ Global Objects\Converters\ConverterAutocadCivil\ConverterAutocadCivilShared\ConverterAutocadCivilShared.projitems*{d9f443b5-c55b-4ad8-9c70-bc3d2be781be}*SharedItemsImports = 5 ConnectorNavisworks\ConnectorNavisworks\ConnectorNavisworks.Shared.projitems*{debc2174-5e31-4b6e-8680-690d75e50e2d}*SharedItemsImports = 5 ConnectorRevit\ConnectorRevit\ConnectorRevit.projitems*{dfdfdbb8-018b-4dcb-a012-54227abf53a7}*SharedItemsImports = 5 + CNX-8892\Connectors\Revit\Speckle.Connectors.RevitShared\Speckle.Connectors.RevitShared.projitems*{e1ff75ec-2bdf-4276-9c81-6eb195661348}*SharedItemsImports = 4 + CNX-8892\Converters\Revit\Speckle.Converters.RevitShared\Speckle.Converters.RevitShared.projitems*{e577f692-c9e9-46a6-b9f1-cf70c93f1280}*SharedItemsImports = 5 ConnectorRevit\RevitSharedResources\RevitSharedResources.projitems*{ea34ac83-5825-4473-a572-d5127fd33b1b}*SharedItemsImports = 5 Objects\Converters\ConverterRhinoGh\ConverterRhinoGhShared\ConverterRhinoGhShared.projitems*{ea81f83c-1485-49c8-ab05-9df2798d70ec}*SharedItemsImports = 5 Objects\Converters\ConverterTeklaStructures\ConverterTeklaStructuresShared\ConverterTeklaStructuresShared.projitems*{eb52e451-9ed8-460e-9ee4-6717bfb12eab}*SharedItemsImports = 5 diff --git a/CNX-8892/Connectors/Revit/Speckle.Connectors.Revit2023/Speckle.Connectors.Revit2023.csproj b/CNX-8892/Connectors/Revit/Speckle.Connectors.Revit2023/Speckle.Connectors.Revit2023.csproj new file mode 100644 index 0000000000..23bf0abfc0 --- /dev/null +++ b/CNX-8892/Connectors/Revit/Speckle.Connectors.Revit2023/Speckle.Connectors.Revit2023.csproj @@ -0,0 +1,255 @@ + + + + + + + + + + + + + + + + + + + + + + Enable + 10.0 + Debug + AnyCPU + {E1FF75EC-2BDF-4276-9C81-6EB195661348} + Library + Properties + Speckle.Connectors.Revit2023 + Speckle.Connectors.Revit2023 + v4.8 + 512 + true + + + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 0 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + true + bin\x64\Debug\ + DEBUG;TRACE + 0 + + CA5399;CA1862; + + CS1591;CS1573; + + CS8618; + + CA1303;CA1304;CA1305;CA1307;CA1308;CA1309;CA1310;CA1311;CA2101; + NU1701; + + CA1815;CA1054; + + full + x64 + + ; + + CA1416; CA1417; CA1418; CA1831; CA2013; CA2014; CA2015; CA2017; + CA2018; CA2200; CA2252; CA2247; CA2255; CA2256; CA2257; CA2258; + + CA1420; CA1422; CA2259; CA2260; + + CA1856; CA1857; CA2021; CA2261; + + CA2100; CA2119; CA2153; CA2300; CA2301; CA2302; CA2305; + CA2310; CA2311; CA2312; CA2315; CA2321; CA2322; CA2326; CA2327; + CA2328; CA2329; CA2330; CA2350; CA2351; CA2352; CA2353; CA2354; + CA2355; CA2356; CA2361; CA2362; CA3001; CA3002; CA3003; CA3004; + CA3006; CA3007; CA3008; CA3009; CA3010; CA3011; CA3012; CA3061; + CA3076; CA3077; CA3147; CA5350; CA5351; CA5358; CA5359; + CA5360; CA5361; CA5362; CA5363; CA5364; CA5365; CA5366; CA5367; + CA5368; CA5370; CA5371; CA5372; CA5373; CA5374; CA5375; + CA5376; CA5377; CA5378; CA5379; CA5380; CA5381; CA5382; CA5383; + CA5384; CA5385; CA5386; CA5387; CA5388; CA5389; CA5390; CA5391; + CA5392; CA5393; CA5395; CA5396; CA5397; CA5398; + CA5400; CA5401; CA5402; CA5403; CA5404; CA5405; + + + CS0183; CS0184; CS0197; CS0420; CS0465; CS0602; CS0626; CS0657; CS0658; CS0672; CS0684; CS0688; + CS1030; CS1058; CS1060; CS1200; CS1201; CS1202; CS1203; + CS1522; CS1589; CS1590; CS1592; CS1598; + CS1607; CS1616; CS1633; CS1634; CS1635; CS1645; CS1658; CS1682; CS1683; CS1684; CS1685; CS1687; CS1690; CS1691; CS1692; CS1694; CS1695; CS1696; CS1697; CS1699; + CS1707; CS1709; CS1720; CS1723; CS1762; + CS1911; CS1956; CS1957; + CS2002; CS2014; CS2023; CS2029; + CS3000; CS3001; CS3002; CS3003; CS3004; CS3005; CS3006; CS3008; CS3009; CS3010; CS3011; CS3012; CS3013; CS3014; CS3015; CS3017; CS3018; CS3022; CS3023; CS3024; CS3026; CS3027; + CS5000; + + + 10.0 + prompt + + + true + bin\x64\Release\ + TRACE + true + + CA5399;CA1862; + + CS1591;CS1573; + + CS8618; + + CA1303;CA1304;CA1305;CA1307;CA1308;CA1309;CA1310;CA1311;CA2101; + NU1701; + + CA1815;CA1054; + + pdbonly + x64 + + ; + + CA1416; CA1417; CA1418; CA1831; CA2013; CA2014; CA2015; CA2017; + CA2018; CA2200; CA2252; CA2247; CA2255; CA2256; CA2257; CA2258; + + CA1420; CA1422; CA2259; CA2260; + + CA1856; CA1857; CA2021; CA2261; + + CA2100; CA2119; CA2153; CA2300; CA2301; CA2302; CA2305; + CA2310; CA2311; CA2312; CA2315; CA2321; CA2322; CA2326; CA2327; + CA2328; CA2329; CA2330; CA2350; CA2351; CA2352; CA2353; CA2354; + CA2355; CA2356; CA2361; CA2362; CA3001; CA3002; CA3003; CA3004; + CA3006; CA3007; CA3008; CA3009; CA3010; CA3011; CA3012; CA3061; + CA3076; CA3077; CA3147; CA5350; CA5351; CA5358; CA5359; + CA5360; CA5361; CA5362; CA5363; CA5364; CA5365; CA5366; CA5367; + CA5368; CA5370; CA5371; CA5372; CA5373; CA5374; CA5375; + CA5376; CA5377; CA5378; CA5379; CA5380; CA5381; CA5382; CA5383; + CA5384; CA5385; CA5386; CA5387; CA5388; CA5389; CA5390; CA5391; + CA5392; CA5393; CA5395; CA5396; CA5397; CA5398; + CA5400; CA5401; CA5402; CA5403; CA5404; CA5405; + + + CS0183; CS0184; CS0197; CS0420; CS0465; CS0602; CS0626; CS0657; CS0658; CS0672; CS0684; CS0688; + CS1030; CS1058; CS1060; CS1200; CS1201; CS1202; CS1203; + CS1522; CS1589; CS1590; CS1592; CS1598; + CS1607; CS1616; CS1633; CS1634; CS1635; CS1645; CS1658; CS1682; CS1683; CS1684; CS1685; CS1687; CS1690; CS1691; CS1692; CS1694; CS1695; CS1696; CS1697; CS1699; + CS1707; CS1709; CS1720; CS1723; CS1762; + CS1911; CS1956; CS1957; + CS2002; CS2014; CS2023; CS2029; + CS3000; CS3001; CS3002; CS3003; CS3004; CS3005; CS3006; CS3008; CS3009; CS3010; CS3011; CS3012; CS3013; CS3014; CS3015; CS3017; CS3018; CS3022; CS3023; CS3024; CS3026; CS3027; + CS5000; + + + 10.0 + prompt + + + + + + + + + + + + + + + + + + + + {a2c8730a-b605-483e-914e-61f3ed7954d9} + Core + + + {3217D8B5-AE8F-4364-81CF-8B7C2BEF6445} + Speckle.Converters.Common + + + {86E64130-2DCE-4F51-B07C-B87138046E21} + Speckle.Connectors.DUI + + + {e854650a-9f2a-43d3-ab70-d9e34b33d2d6} + Speckle.Autofac + + + {d495d104-61d9-4476-b909-1c0e79c3650c} + Speckle.Connectors.Utils + + + + + + + + + + + + + + 5.2.0 + + + 92.0.260 + + + 92.0.260 + + + 7.0.0 + + + 7.0.0 + + + 7.0.0 + + + 2.0.1 + + + 2024.0.0 + + + 2.12.0 + + + 7.0.0 + + + 13.0.2 + + + 7.0.2 + + + + + \ No newline at end of file diff --git a/CNX-8892/Connectors/Revit/Speckle.Connectors.Revit2023/app.config b/CNX-8892/Connectors/Revit/Speckle.Connectors.Revit2023/app.config new file mode 100644 index 0000000000..533b795deb --- /dev/null +++ b/CNX-8892/Connectors/Revit/Speckle.Connectors.Revit2023/app.config @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/BasicConnectorBindingRevit.cs b/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/BasicConnectorBindingRevit.cs new file mode 100644 index 0000000000..60d856ad6c --- /dev/null +++ b/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/BasicConnectorBindingRevit.cs @@ -0,0 +1,159 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using Autodesk.Revit.DB; +using Autodesk.Revit.UI; +using Revit.Async; +using Speckle.Connectors.Utils.Reflection; +using Speckle.Connectors.DUI.Bindings; +using Speckle.Connectors.DUI.Bridge; +using Speckle.Connectors.DUI.Models; +using Speckle.Connectors.DUI.Models.Card; +using Speckle.Connectors.Revit.Plugin; +using Speckle.Connectors.Revit.HostApp; +using Speckle.Connectors.Revit.Bindings; + +namespace Speckle.Connectors.DUI.Bindings; + +internal class BasicConnectorBindingRevit : IBasicConnectorBinding +{ + // POC: name and bridge might be better for them to be protected props? + public string Name { get; private set; } + public IBridge Parent { get; private set; } + + protected readonly RevitDocumentStore _store; + protected readonly RevitContext _revitContext; + private readonly RevitSettings _revitSettings; + + public BasicConnectorBindingRevit( + RevitDocumentStore store, + RevitSettings revitSettings, + IBridge parent, + RevitContext revitContext + ) + { + Name = "baseBinding"; + Parent = parent; + _store = store; + _revitContext = revitContext; + _revitSettings = revitSettings; + + // POC: event binding? + _store.DocumentChanged += (_, _) => + { + parent.Send(Name, BasicConnectorBindingEvents.DOCUMENT_CHANGED); + }; + } + + public string GetConnectorVersion() + { + return Assembly.GetAssembly(GetType()).GetVersion(); + } + + public string GetSourceApplicationName() => _revitSettings.HostSlug; // POC: maybe not right place but... + + public string GetSourceApplicationVersion() + { + // POC: maybe not right place but... + return _revitSettings.HostAppVersion; + } + + public DocumentInfo GetDocumentInfo() + { + // POC: not sure why this would ever be null, is this needed? + if (_revitContext.UIApplication == null) + { + return null; + } + + var doc = _revitContext.UIApplication.ActiveUIDocument.Document; + + return new DocumentInfo + { + Name = doc.Title, + Id = doc.GetHashCode().ToString(), + Location = doc.PathName + }; + } + + public DocumentModelStore GetDocumentState() => _store; + + public void AddModel(ModelCard model) + { + _store.Models.Add(model); + } + + public void UpdateModel(ModelCard model) + { + int idx = _store.Models.FindIndex(m => model.ModelCardId == m.ModelCardId); + _store.Models[idx] = model; + } + + public void RemoveModel(ModelCard model) + { + int index = _store.Models.FindIndex(m => m.ModelCardId == model.ModelCardId); + _store.Models.RemoveAt(index); + } + + public void HighlightModel(string modelCardId) + { + // POC: don't know if we can rely on storing the ActiveUIDocument, hence getting it each time + var activeUIDoc = _revitContext.UIApplication.ActiveUIDocument; + var doc = _revitContext.UIApplication.ActiveUIDocument.Document; + + // POC: as sendermodelcard, surely we should cast here? better to have invalidcast which is the real reason than NRE + SenderModelCard model = _store.GetModelById(modelCardId) as SenderModelCard; + List objectsIds = model.SendFilter.GetObjectIds(); + + // POC: GetElementsFromDocument could be interfaced out, extension is cleaner + List elementIds = doc.GetElements(objectsIds).Select(e => e.Id).ToList(); + + // UiDocument operations should be wrapped into RevitTask, otherwise doesn't work on other tasks. + RevitTask.RunAsync(() => + { + activeUIDoc.Selection.SetElementIds(elementIds); + activeUIDoc.ShowElements(elementIds); + + // Create a BoundingBoxXYZ to encompass the selected elements + BoundingBoxXYZ selectionBoundingBox = new(); + bool first = true; + + foreach (ElementId elementId in elementIds) + { + Element element = doc.GetElement(elementId); + + if (element != null) + { + BoundingBoxXYZ elementBoundingBox = element.get_BoundingBox(null); + + if (elementBoundingBox != null) + { + if (first) + { + selectionBoundingBox = elementBoundingBox; + first = false; + } + else + { + // selectionBoundingBox.Min = XYZ.Min(selectionBoundingBox.Min, elementBoundingBox.Min); + // selectionBoundingBox.Max = XYZ.Max(selectionBoundingBox.Max, elementBoundingBox.Max); + } + } + } + } + + // Zoom the view to the selection bounding box + if (!first) + { + View activeView = activeUIDoc.ActiveView; + + using Transaction tr = new(doc, "Zoom to Selection"); + tr.Start(); + activeView.CropBox = selectionBoundingBox; + doc.Regenerate(); + tr.Commit(); + } + }); + } +} diff --git a/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/Filters.cs b/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/Filters.cs new file mode 100644 index 0000000000..99675c5032 --- /dev/null +++ b/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/Filters.cs @@ -0,0 +1,32 @@ +using System.Collections.Generic; +using System.Linq; +using Speckle.Connectors.DUI.Bindings; + +namespace Speckle.Connectors.Revit.Bindings; + +public class RevitEverythingFilter : EverythingSendFilter +{ + public override List GetObjectIds() + { + // TODO + return new List(); + } + + public override bool CheckExpiry(string[] changedObjectIds) + { + return true; + } +} + +public class RevitSelectionFilter : DirectSelectionSendFilter +{ + public override List GetObjectIds() + { + return SelectedObjectIds; + } + + public override bool CheckExpiry(string[] changedObjectIds) + { + return SelectedObjectIds.Intersect(changedObjectIds).Any(); + } +} diff --git a/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/ReceiveBinding.cs b/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/ReceiveBinding.cs new file mode 100644 index 0000000000..f30fa6664d --- /dev/null +++ b/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/ReceiveBinding.cs @@ -0,0 +1,154 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading; +using Autodesk.Revit.DB; +using Autodesk.Revit.UI; +using Revit.Async; +using Speckle.Connectors.DUI.Bindings; +using Speckle.Connectors.DUI.Bridge; +using Speckle.Connectors.Revit.Bindings; +using Speckle.Connectors.Revit.HostApp; +using Speckle.Connectors.Revit.Plugin; +using Speckle.Connectors.Utils.Cancellation; +using Speckle.Core.Kits; +using Speckle.Core.Logging; +using Speckle.Core.Models; + +namespace Speckle.Connectors.Revit.Bindings; + +internal class ReceiveBinding : RevitBaseBinding, ICancelable +{ + public CancellationManager CancellationManager { get; } = new(); + + public ReceiveBinding(RevitContext revitContext, RevitDocumentStore store, IBridge bridge) + : base("receiveBinding", store, bridge, revitContext) { } + + public void CancelReceive(string modelCardId) => CancellationManager.CancelOperation(modelCardId); + + public async void Receive(string modelCardId, string versionId) + { + try + { + //// 0 - Init cancellation token source -> Manager also cancel it if exist before + //CancellationTokenSource cts = CancellationManager.InitCancellationTokenSource(modelCardId); + + //// 1 - Get receiver card + //ReceiverModelCard model = _store.GetModelById(modelCardId) as ReceiverModelCard; + + //// 2 - Get commit object from server + //Base commitObject = await Operations.GetCommitBase(Parent, model, versionId, cts.Token).ConfigureAwait(true); + + //if (cts.IsCancellationRequested) + //{ + // return; + //} + + //// 3 - Get converter + //ISpeckleConverter converter = Converters.GetConverter(Doc, RevitAppProvider.Version()); + + //// 4 - Traverse commit object + //List objectsToConvert = Traversal.GetObjectsToConvert(commitObject, converter); + + //// 5 - Bake objects + //BakeObjects(objectsToConvert, converter, modelCardId, cts); + } + catch (Exception e) + { + //if (e is OperationCanceledException) + //{ + // Progress.CancelReceive(Parent, modelCardId); + // return; + //} + //throw; + } + } + + //private async void BakeObjects( + // List objectsToConvert, + // ISpeckleConverter converter, + // string modelCardId, + // CancellationTokenSource cts + //) + //{ + // (bool success, Exception exception) = await RevitTask + // .RunAsync(app => + // { + // string transactionName = $"Baking model from {modelCardId}"; + // using TransactionGroup g = new(Doc, transactionName); + // using Transaction t = new(Doc, transactionName); + // g.Start(); + // t.Start(); + + // try + // { + // converter.SetContextDocument(t); + // List errors = new(); + // int count = 0; + // foreach (Base objToConvert in objectsToConvert) + // { + // count++; + // if (cts.IsCancellationRequested) + // { + // Progress.CancelReceive(Parent, modelCardId, (double)count / objectsToConvert.Count); + // break; + // } + // try + // { + // double progress = (double)count / objectsToConvert.Count; + // Progress.ReceiverProgressToBrowser(Parent, modelCardId, progress); + // object convertedObject = converter.ConvertToNative(objToConvert); + // RefreshView(); + // } + // catch (SpeckleException e) + // { + // errors.Add($"Object couldn't converted with id: {objToConvert.id}, type: {objToConvert.speckle_type}\n"); + // Console.WriteLine(e); + // } + // } + // Notification.ReportReceive(Parent, errors, modelCardId, objectsToConvert.Count); + + // t.Commit(); + + // if (t.GetStatus() == TransactionStatus.RolledBack) + // { + // int numberOfErrors = 0; // Previously get from errorEater + // return ( + // false, + // new SpeckleException( + // $"The Revit API could not resolve {numberOfErrors} unique errors and {numberOfErrors} total errors when trying to commit the Speckle model. The whole transaction is being rolled back." + // ) + // ); + // } + + // g.Assimilate(); + // return (true, null); + // } + // catch (SpeckleException ex) + // { + // t.RollBack(); + // g.RollBack(); + // return (false, ex); //We can't throw exceptions in from RevitTask, but we can return it along with a success status + // } + // }) + // .ConfigureAwait(false); + //} + + //private void RefreshView() + //{ + // // regenerate the document and then implement a hack to "refresh" the view + // UiDoc.Document.Regenerate(); + + // // get the active ui view + // View view = UiDoc.ActiveGraphicalView ?? UiDoc.ActiveView; + // if (view is TableView) + // { + // return; + // } + + // UIView uiView = UiDoc.GetOpenUIViews().FirstOrDefault(uv => uv.ViewId.Equals(view.Id)); + + // // "refresh" the active view + // uiView?.Zoom(1); + //} +} diff --git a/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/RevitBaseBinding.cs b/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/RevitBaseBinding.cs new file mode 100644 index 0000000000..8aa7f66ebc --- /dev/null +++ b/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/RevitBaseBinding.cs @@ -0,0 +1,56 @@ +using System; +using System.Collections.Generic; +using System.Text; +using Autofac.Core; +using Speckle.Connectors.DUI.Bindings; +using Speckle.Connectors.DUI.Bridge; +using Speckle.Connectors.Revit.HostApp; +using Speckle.Connectors.Revit.Plugin; + +namespace Speckle.Connectors.Revit.Bindings; + +internal abstract class RevitBaseBinding : IBinding, IDisposable +{ + // POC: name and bridge might be better for them to be protected props? + public string Name { get; protected set; } + public IBridge Parent { get; protected set; } + + private bool _disposed = false; + + protected readonly RevitDocumentStore _store; + protected readonly RevitContext _revitContext; + + public RevitBaseBinding(string name, RevitDocumentStore store, IBridge bridge, RevitContext revitContext) + { + Name = name; + Parent = bridge; + _store = store; + _revitContext = revitContext; + } + + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } + + protected virtual void Dispose(bool disposing) + { + if (disposing && !_disposed) + { + // give subclasses the chance to dispose + Disposing(disposing, _disposed); + + _disposed = true; + } + } + + protected virtual void Disposing(bool isDipsosing, bool disposedState) { } + + // might be needed in future... + ~RevitBaseBinding() + { + // POC: is there anything janky about calling virtuals during finalizer? :thinking-face + Dispose(false); + } +} diff --git a/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SelectionBinding.cs b/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SelectionBinding.cs new file mode 100644 index 0000000000..53a46022fd --- /dev/null +++ b/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SelectionBinding.cs @@ -0,0 +1,56 @@ +using System.Collections.Generic; +using System.Linq; +using Autodesk.Revit.DB; +using Autodesk.Revit.UI; +using Speckle.Connectors.DUI.Bindings; +using Speckle.Connectors.DUI.Bridge; +using Speckle.Connectors.Revit.HostApp; +using Speckle.Connectors.Revit.Plugin; + +namespace Speckle.Connectors.Revit.Bindings; + +// POC: we need a base a RevitBaseBinding +internal class SelectionBinding : RevitBaseBinding, ISelectionBinding +{ + private readonly IRevitIdleManager _revitIdleManager; + + public SelectionBinding( + RevitContext revitContext, + RevitDocumentStore store, + IRevitIdleManager idleManager, + IBridge bridge + ) + : base("selectionBinding", store, bridge, revitContext) + { + _revitIdleManager = idleManager; + + // POC: we can inject the solution here + // TODO: Need to figure it out equivalent of SelectionChanged for Revit2020 + _revitContext.UIApplication.SelectionChanged += (_, _) => _revitIdleManager.SubscribeToIdle(OnSelectionChanged); + + _revitContext.UIApplication.ViewActivated += (_, _) => + { + Parent.Send(SelectionBindingEvents.SET_SELECTION, new SelectionInfo()); + }; + } + + private void OnSelectionChanged() + { + Parent.Send(SelectionBindingEvents.SET_SELECTION, GetSelection()); + } + + public SelectionInfo GetSelection() + { + List els = _revitContext.UIApplication.ActiveUIDocument.Selection + .GetElementIds() + .Select(id => _revitContext.UIApplication.ActiveUIDocument.Document.GetElement(id)) + .ToList(); + List cats = els.Select(el => el.Category?.Name ?? el.Name).Distinct().ToList(); + List ids = els.Select(el => el.UniqueId.ToString()).ToList(); + return new SelectionInfo() + { + SelectedObjectIds = ids, + Summary = $"{els.Count} objects ({string.Join(", ", cats)})" + }; + } +} diff --git a/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SendBinding.cs b/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SendBinding.cs new file mode 100644 index 0000000000..d861411455 --- /dev/null +++ b/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SendBinding.cs @@ -0,0 +1,159 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading; +using Autodesk.Revit.UI; +using Autodesk.Revit.DB; +using Speckle.Core.Kits; +using Speckle.Core.Credentials; +using Speckle.Core.Transports; +using Speckle.Core.Models; +using Speckle.Connectors.DUI.Bindings; +using Speckle.Connectors.Utils.Cancellation; +using Speckle.Connectors.DUI.Bridge; +using Speckle.Connectors.Revit.HostApp; +using Speckle.Connectors.Revit.Plugin; +using Speckle.Connectors.Revit.Bindings; +using Speckle.Core.Logging; +using Speckle.Connectors.Utils; +using Autofac.Features.Indexed; +using Speckle.Autofac.DependencyInjection; +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; +using System.Windows.Forms.VisualStyles; + +namespace Speckle.Connectors.Revit.Bindings; + +internal class SendBinding : RevitBaseBinding, ICancelable +{ + // POC:does it need injecting? + public CancellationManager CancellationManager { get; } = new(); + + // POC: does it need injecting? + private HashSet ChangedObjectIds { get; set; } = new(); + + // In the context of the SEND operation, we're only ever expecting ONE conversion + private readonly IScopedFactory _speckleConverterToSpeckleFactory; + private readonly ISpeckleConverterToSpeckle _speckleConverterToSpeckle; + private readonly IRevitIdleManager _idleManager; + + public SendBinding( + IScopedFactory speckleConverterToSpeckleFactory, + IRevitIdleManager idleManager, + RevitContext revitContext, + RevitDocumentStore store, + IBridge bridge + ) + : base("sendBinding", store, bridge, revitContext) + { + _speckleConverterToSpeckleFactory = speckleConverterToSpeckleFactory; + _speckleConverterToSpeckle = _speckleConverterToSpeckleFactory.ResolveScopedInstance(); + _idleManager = idleManager; + + // TODO expiry events + // TODO filters need refresh events + revitContext.UIApplication.Application.DocumentChanged += (_, e) => DocChangeHandler(e); + } + + public List GetSendFilters() + { + return new List { new RevitEverythingFilter(), new RevitSelectionFilter() }; + } + + public async void Send(string modelCardId) + { + SpeckleTopLevelExceptionHandler.Run( + () => HandleSend(modelCardId), + HandleSpeckleException, + HandleUnexpectedException, + HandleFatalException + ); + } + + public void CancelSend(string modelCardId) + { + CancellationManager.CancelOperation(modelCardId); + } + + private void HandleSend(string modelCardId) + { + _speckleConverterToSpeckle.Convert(); + } + + private bool HandleSpeckleException(SpeckleException spex) + { + // POC: do something here + + return false; + } + + private bool HandleUnexpectedException(Exception ex) + { + // POC: do something here + + return false; + } + + private bool HandleFatalException(Exception ex) + { + // POC: do something here + + return false; + } + + /// + /// Keeps track of the changed element ids as well as checks if any of them need to trigger + /// a filter refresh (e.g., views being added). + /// + /// + private void DocChangeHandler(Autodesk.Revit.DB.Events.DocumentChangedEventArgs e) + { + ICollection addedElementIds = e.GetAddedElementIds(); + ICollection deletedElementIds = e.GetDeletedElementIds(); + ICollection modifiedElementIds = e.GetModifiedElementIds(); + + foreach (ElementId elementId in addedElementIds) + { + ChangedObjectIds.Add(elementId.IntegerValue.ToString()); + } + + foreach (ElementId elementId in deletedElementIds) + { + ChangedObjectIds.Add(elementId.IntegerValue.ToString()); + } + + foreach (ElementId elementId in modifiedElementIds) + { + ChangedObjectIds.Add(elementId.IntegerValue.ToString()); + } + + // TODO: CHECK IF ANY OF THE ABOVE ELEMENTS NEED TO TRIGGER A FILTER REFRESH + _idleManager.SubscribeToIdle(RunExpirationChecks); + } + + private void RunExpirationChecks() + { + List senders = _store.GetSenders(); + List expiredSenderIds = new(); + + foreach (var sender in senders) + { + bool isExpired = sender.SendFilter.CheckExpiry(ChangedObjectIds.ToArray()); + if (isExpired) + { + expiredSenderIds.Add(sender.ModelCardId); + } + } + + SendBindingUICommands.SetModelsExpired(Parent, expiredSenderIds); + ChangedObjectIds = new HashSet(); + } + + protected override void Disposing(bool isDipsosing, bool disposedState) + { + if (isDipsosing && !disposedState) + { + _speckleConverterToSpeckleFactory.Dispose(); + } + } +} diff --git a/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/AutofacUIModule.cs b/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/AutofacUIModule.cs new file mode 100644 index 0000000000..ecab4b5208 --- /dev/null +++ b/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/AutofacUIModule.cs @@ -0,0 +1,85 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Text; +using Autofac; +using CefSharp; +using Microsoft.Extensions.Logging; +using Serilog; +using Speckle.Autofac.DependencyInjection; +using Speckle.Connectors.DUI.Bindings; +using Speckle.Connectors.DUI.Bridge; +using Speckle.Connectors.DUI.Utils; +using Speckle.Connectors.Revit.Bindings; +using Speckle.Connectors.Revit.HostApp; +using Speckle.Connectors.Revit.Plugin; +using Speckle.Converters.Common; +using Speckle.Newtonsoft.Json; +using Speckle.Newtonsoft.Json.Serialization; + +namespace Speckle.Connectors.Revit.DependencyInjection; + +// POC: should interface out things that are not +class AutofacUIModule : Module +{ + protected override void Load(ContainerBuilder builder) + { + builder.RegisterInstance(new RevitContext()); + + // POC: different versons for different versions of CEF + builder.RegisterInstance(BindingOptions.DefaultBinder); + + // create JSON Settings + // POC: this could be created through a factory or delegate, maybe delegate factory + // https://autofac.readthedocs.io/en/latest/advanced/delegate-factories.html + JsonSerializerSettings settings = + new() + { + Error = (object sender, Newtonsoft.Json.Serialization.ErrorEventArgs args) => + { + Console.WriteLine("*** JSON ERROR: " + args.ErrorContext.ToString()); + }, + ContractResolver = new CamelCasePropertyNamesContractResolver(), + NullValueHandling = NullValueHandling.Ignore, + ReferenceLoopHandling = ReferenceLoopHandling.Ignore, + DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate, + Converters = { new DiscriminatedObjectConverter(), new AbstractConverter() } + }; + + var panel = new CefSharpPanel(); + panel.Browser.JavascriptObjectRepository.NameConverter = null; + + builder.RegisterInstance(panel).SingleInstance(); + builder.RegisterInstance(settings).SingleInstance(); + builder.RegisterType().As().SingleInstance(); + builder.RegisterType().As().InstancePerDependency(); + + // register UI bindings + builder.RegisterType().As().SingleInstance(); + builder.RegisterType().As().SingleInstance(); + builder.RegisterType().As().SingleInstance(); + builder.RegisterType().As().SingleInstance(); + builder.RegisterType().As().SingleInstance(); + builder.RegisterType().As().SingleInstance(); + + // register + builder.RegisterType().SingleInstance(); + + builder + .RegisterType>() + .As>() + .InstancePerLifetimeScope(); + + // POC: logging factory couldn't be added, which is the recommendation, due to janky dependencies + // having a SpeckleLogging service, might be interesting, if a service can listen on a local port or use named pipes + var current = Directory.GetCurrentDirectory(); + var serilogLogger = new LoggerConfiguration().MinimumLevel + .Debug() + .WriteTo.File("log.txt", rollingInterval: RollingInterval.Day) + .CreateLogger(); + + ILoggerFactory loggerFactory = new LoggerFactory(); + var serilog = loggerFactory.AddSerilog(serilogLogger); + builder.RegisterInstance(loggerFactory).As().SingleInstance(); + } +} diff --git a/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/Elements.cs b/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/Elements.cs new file mode 100644 index 0000000000..1718e5606e --- /dev/null +++ b/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/Elements.cs @@ -0,0 +1,14 @@ +using System.Collections.Generic; +using System.Linq; +using Autodesk.Revit.DB; + +namespace Speckle.Connectors.Revit.HostApp; + +// POC: is this really better than injection? :/ +public static class Elements +{ + public static IEnumerable GetElements(this Document doc, IEnumerable objectIds) + { + return objectIds.Select(doc.GetElement).Where(x => x != null); + } +} diff --git a/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/RevitDocumentStore.cs b/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/RevitDocumentStore.cs new file mode 100644 index 0000000000..a96156e9fa --- /dev/null +++ b/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/RevitDocumentStore.cs @@ -0,0 +1,151 @@ +using System; +using System.Collections.Generic; +using Autodesk.Revit.DB; +using Autodesk.Revit.DB.ExtensibleStorage; +using Autodesk.Revit.UI; +using Revit.Async; +using Speckle.Connectors.DUI.Models; +using Speckle.Connectors.DUI.Models.Card; +using Speckle.Connectors.Revit.Plugin; +using Speckle.Core.Logging; +using Speckle.Newtonsoft.Json; + +namespace Speckle.Connectors.Revit.HostApp; + +// POC: should be interfaced out +internal class RevitDocumentStore : DocumentModelStore +{ + // POC: move to somewhere central? + private static readonly Guid s_revitDocumentStoreId = new("D35B3695-EDC9-4E15-B62A-D3FC2CB83FA3"); + + private readonly RevitContext _revitContext; + + public RevitDocumentStore(RevitContext revitContext, JsonSerializerSettings serializerSettings) + : base(serializerSettings) + { + _revitContext = revitContext; + + UIApplication uiApplication = _revitContext.UIApplication; + + uiApplication.ApplicationClosing += (_, _) => WriteToFile(); + + uiApplication.Application.DocumentSaving += (_, _) => WriteToFile(); + uiApplication.Application.DocumentSynchronizingWithCentral += (_, _) => WriteToFile(); + + uiApplication.ViewActivated += (_, e) => + { + if (e.Document == null) + { + return; + } + + if (e.PreviousActiveView?.Document.PathName == e.CurrentActiveView.Document.PathName) + { + return; + } + + IsDocumentInit = true; + ReadFromFile(); + OnDocumentChanged(); + }; + + uiApplication.Application.DocumentOpening += (_, _) => IsDocumentInit = false; + uiApplication.Application.DocumentOpened += (_, _) => IsDocumentInit = false; + } + + public override void WriteToFile() + { + UIDocument doc = _revitContext.UIApplication.ActiveUIDocument; + + // POC: this can happen? + if (doc == null) + { + return; + } + + RevitTask.RunAsync(() => { + // POC: re-instate + //using Transaction t = new(doc.Document, "Speckle Write State"); + //t.Start(); + //using DataStorage ds = GetSettingsDataStorage(doc.Document) ?? DataStorage.Create(doc.Document); + + //using Entity stateEntity = new(DocumentModelStoreSchema.GetSchema()); + //string serializedModels = Serialize(); + //stateEntity.Set("contents", serializedModels); + + //using Entity idEntity = new(IdStorageSchema.GetSchema()); + //idEntity.Set("Id", s_revitDocumentStoreId); + + //ds.SetEntity(idEntity); + //ds.SetEntity(stateEntity); + //t.Commit(); + }); + } + + public override void ReadFromFile() + { + try + { + Entity stateEntity = GetSpeckleEntity(_revitContext.UIApplication.ActiveUIDocument.Document); + if (stateEntity == null || !stateEntity.IsValid()) + { + Models = new List(); + return; + } + + string modelsString = stateEntity.Get("contents"); + Models = Deserialize(modelsString); + } + // POC: hmmmmm, is this valid? Do we really throw an exception if the entity does not exist? + catch (SpeckleException) + { + Models = new List(); + } + } + + private DataStorage GetSettingsDataStorage(Document doc) + { + // POC: re-instate + //using FilteredElementCollector collector = new(doc); + //FilteredElementCollector dataStorages = collector.OfClass(typeof(DataStorage)); + + //foreach (Element element in dataStorages) + //{ + // DataStorage dataStorage = (DataStorage)element; + // Entity settingIdEntity = dataStorage.GetEntity(IdStorageSchema.GetSchema()); + // if (!settingIdEntity.IsValid()) + // { + // continue; + // } + + // Guid id = settingIdEntity.Get("Id"); + // if (!id.Equals(s_revitDocumentStoreId)) + // { + // continue; + // } + + // return dataStorage; + //} + return null; + } + + private Entity GetSpeckleEntity(Document doc) + { + // POC: re-instate + //using FilteredElementCollector collector = new(doc); + + //FilteredElementCollector dataStorages = collector.OfClass(typeof(DataStorage)); + //foreach (Element element in dataStorages) + //{ + // DataStorage dataStorage = (DataStorage)element; + // Entity settingEntity = dataStorage.GetEntity(DocumentModelStoreSchema.GetSchema()); + // if (!settingEntity.IsValid()) + // { + // continue; + // } + + // return settingEntity; + //} + return null; + } +} diff --git a/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/CefSharpPanel.xaml b/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/CefSharpPanel.xaml new file mode 100644 index 0000000000..822ed7514e --- /dev/null +++ b/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/CefSharpPanel.xaml @@ -0,0 +1,17 @@ + + + + + + diff --git a/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/CefSharpPanel.xaml.cs b/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/CefSharpPanel.xaml.cs new file mode 100644 index 0000000000..4f9ae25537 --- /dev/null +++ b/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/CefSharpPanel.xaml.cs @@ -0,0 +1,30 @@ +using System.Windows.Controls; +using Autodesk.Revit.UI; +using CefSharp; +using CefSharp.DevTools; +using System.Windows.Threading; + +namespace Speckle.Connectors.Revit; + +public partial class CefSharpPanel : Page, Autodesk.Revit.UI.IDockablePaneProvider +{ + public CefSharpPanel() + { + InitializeComponent(); + } + + public void ExecuteScriptAsync(string script) => + Browser.Dispatcher.Invoke(() => Browser.ExecuteScriptAsync(script), DispatcherPriority.Background); + + public void ShowDevTools() => Browser.ShowDevTools(); + + public void SetupDockablePane(Autodesk.Revit.UI.DockablePaneProviderData data) + { + data.FrameworkElement = this; + data.InitialState = new Autodesk.Revit.UI.DockablePaneState + { + DockPosition = DockPosition.Tabbed, + TabBehind = Autodesk.Revit.UI.DockablePanes.BuiltInDockablePanes.ProjectBrowser + }; + } +} diff --git a/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/IRevitIdleManager.cs b/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/IRevitIdleManager.cs new file mode 100644 index 0000000000..43d47e605b --- /dev/null +++ b/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/IRevitIdleManager.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Concurrent; +using System.Collections.Generic; +using Autodesk.Revit.UI; +using Autodesk.Revit.UI.Events; + +namespace Speckle.Connectors.Revit.Plugin; + +// POC: needs interface +// is probably misnamed, perhaps OnIdleCallbackManager +internal interface IRevitIdleManager +{ + /// + /// Subscribe deferred action to Idling event to run it whenever Revit becomes idle. + /// + /// Action to call whenever Revit becomes Idle. + /// some events in host app are trigerred many times, we might get 10x per object + /// Making this more like a deferred action, so we don't update the UI many times + void SubscribeToIdle(Action action); +} diff --git a/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/IRevitPlugin.cs b/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/IRevitPlugin.cs new file mode 100644 index 0000000000..74e8234187 --- /dev/null +++ b/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/IRevitPlugin.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Text; +using Autodesk.Revit.UI; + +namespace Speckle.Connectors.Revit.Plugin; + +internal interface IRevitPlugin +{ + void Initialise(); + void Shutdown(); +} diff --git a/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitCommand.cs b/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitCommand.cs new file mode 100644 index 0000000000..14648bce3e --- /dev/null +++ b/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitCommand.cs @@ -0,0 +1,19 @@ +using Autodesk.Revit.Attributes; +using Autodesk.Revit.DB; +using Autodesk.Revit.UI; +using Speckle.Connectors.Revit; +using Speckle.Connectors.Revit.Plugin; + +namespace Speckle.Connectors.Revit.Plugin; + +[Transaction(TransactionMode.Manual)] +internal class SpeckleRevitCommand : IExternalCommand +{ + public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) + { + DockablePane panel = commandData.Application.GetDockablePane(RevitExternalApplication.DoackablePanelId); + panel.Show(); + + return Result.Succeeded; + } +} diff --git a/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitContext.cs b/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitContext.cs new file mode 100644 index 0000000000..5af32c3fba --- /dev/null +++ b/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitContext.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Text; +using Autodesk.Revit.UI; + +namespace Speckle.Connectors.Revit.Plugin +{ + public class RevitContext + { + private CefSharpPanel? _panel; + + private UIApplication? _uiApplication; + + public UIApplication? UIApplication + { + get => _uiApplication; + set + { + if (_uiApplication != null) + { + throw new ArgumentException("UIApplication already set"); + } + + _uiApplication = value; + } + } + } +} diff --git a/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitExternalApplication.cs b/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitExternalApplication.cs new file mode 100644 index 0000000000..d6df910c09 --- /dev/null +++ b/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitExternalApplication.cs @@ -0,0 +1,130 @@ +using System; +using System.Linq; +using System.Windows.Threading; +using Autodesk.Revit.DB; +using Autodesk.Revit.UI; +using Speckle.Autofac.DependencyInjection; +using Speckle.Autofac.Files; +using Speckle.Connectors.DUI.Bridge; +using Speckle.Connectors.Revit.DependencyInjection; +using CefSharp; +using CefSharp.DevTools; +using System.Reflection; +using System.IO; +using Autofac; +using Speckle.Converters.Common.Objects; + +namespace Speckle.Connectors.Revit.Plugin; + +internal class RevitExternalApplication : IExternalApplication +{ + private IRevitPlugin? _revitPlugin = null; + private AutofacContainer? _container = null; + + // POC: this is getting hard coded - need a way of injecting it + // I am beginning to think the shared project is not the way + // and an assembly which is invoked with some specialisation is the right way to go + // maybe subclassing, or some hook to inject som configuration + private readonly RevitSettings _revitSettings; + + // POC: move to somewhere central? + public static readonly DockablePaneId DoackablePanelId = new(new Guid("{f7b5da7c-366c-4b13-8455-b56f433f461e}")); + + public RevitExternalApplication() + { + // POC: load from JSON file? + _revitSettings = new RevitSettings + { + RevitPanelName = "Speckle DUI3 (DI)", + RevitTabName = "Speckle", + RevitTabTitle = "Speckle DUI3 (DI)", + RevitVersionName = "2023", + RevitButtonName = "Speckle DUI3 (DI)", + RevitButtonText = "Revit Connector", + ModuleFolders = new string[] + { + "C:\\Users\\imhaw\\AppData\\Roaming\\Autodesk\\REVIT\\Addins\\2023\\Speckle.Connectors.Revit2023" + } + }; + } + + public Result OnStartup(UIControlledApplication application) + { + try + { + // POC: not sure what this is doing... could be messing up our Aliasing???? + AppDomain.CurrentDomain.AssemblyResolve += OnAssemblyResolve; + + _container = new AutofacContainer(new StorageInfo()); + + _container.PreBuildEvent += _container_PreBuildEvent; + + // POC: re-instate, can this be done with some injected class? +#if REVIT2020 + // Panel.Browser.JavascriptObjectRepository.NameConverter = null; // not available in cef65, we need the below + BindingOptions bindingOptions = new () { CamelCaseJavascriptNames = false }; +#endif + + // init DI + _container + .LoadAutofacModules(_revitSettings.ModuleFolders) + .AddSingletonInstance(_revitSettings) // apply revit settings into DI + .AddSingletonInstance(application) // inject UIControlledApplication application + .Build(); + + // resolve root object + _revitPlugin = _container.Resolve(); + _revitPlugin.Initialise(); + } + catch (Exception ex) + { + // POC: feedback? + return Result.Failed; + } + + return Result.Succeeded; + } + + private void _container_PreBuildEvent(object sender, ContainerBuilder containerBuilder) + { + containerBuilder.InjectNamedTypes(); + } + + public Result OnShutdown(UIControlledApplication application) + { + try + { + // POC: could this be more a generic Connector Init() Shutdown() + // possibly with injected pieces or with some abstract methods? + // need to look for commonality + _revitPlugin.Shutdown(); + } + catch (Exception ex) + { + // POC: feedback? + return Result.Failed; + } + + return Result.Succeeded; + } + + private Assembly OnAssemblyResolve(object sender, ResolveEventArgs args) + { + // POC: tight binding to files + Assembly assembly = null; + string name = args.Name.Split(',')[0]; + string path = Path.GetDirectoryName(typeof(RevitPlugin).Assembly.Location); + + if (path != null) + { + string assemblyFile = Path.Combine(path, name + ".dll"); + + if (File.Exists(assemblyFile)) + { + assembly = Assembly.LoadFrom(assemblyFile); + } + } + + return assembly; + } +} diff --git a/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitIdleManager.cs b/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitIdleManager.cs new file mode 100644 index 0000000000..1b7f858702 --- /dev/null +++ b/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitIdleManager.cs @@ -0,0 +1,61 @@ +using System; +using System.Collections.Concurrent; +using System.Collections.Generic; +using Autodesk.Revit.UI; +using Autodesk.Revit.UI.Events; + +namespace Speckle.Connectors.Revit.Plugin; + +// POC: needs interface +// is probably misnamed, perhaps OnIdleCallbackManager +internal class RevitIdleManager : IRevitIdleManager +{ + private readonly UIApplication _uiApplication; + + private readonly ConcurrentDictionary _calls = new(); + + // POC: still not thread safe + private volatile bool _hasSubscribed = false; + + public RevitIdleManager(RevitContext revitContext) + { + _uiApplication = revitContext.UIApplication; + } + + /// + /// Subscribe deferred action to Idling event to run it whenever Revit becomes idle. + /// + /// Action to call whenever Revit becomes Idle. + /// some events in host app are trigerred many times, we might get 10x per object + /// Making this more like a deferred action, so we don't update the UI many times + public void SubscribeToIdle(Action action) + { + // POC: key for method is brittle | thread safe is not this is + // I want to be called back ONCE when the host app has become idle once more + // would this work "action.Method.Name" with anonymous function, including the SAME function + // does this work across class instances? Should it? What about functions of the same name? Fully qualified name might be better + _calls[action.Method.Name] = action; + + if (_hasSubscribed) + { + return; + } + + _hasSubscribed = true; + _uiApplication.Idling += RevitAppOnIdle; + } + + private void RevitAppOnIdle(object sender, IdlingEventArgs e) + { + foreach (KeyValuePair kvp in _calls) + { + kvp.Value(); + } + + _calls.Clear(); + _uiApplication.Idling -= RevitAppOnIdle; + + // setting last will delay ntering re-subscritption + _hasSubscribed = false; + } +} diff --git a/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitPlugin.cs b/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitPlugin.cs new file mode 100644 index 0000000000..4771d8bc09 --- /dev/null +++ b/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitPlugin.cs @@ -0,0 +1,149 @@ +using System; +using System.Collections.Generic; +using System.Data; +using System.Text; +using System.Reflection; +using Autodesk.Revit.UI; +using Autodesk.Revit.ApplicationServices; +using Autodesk.Revit.DB.Events; +using Revit.Async; +using CefSharp; +using System.Linq; +using System.IO; +using Speckle.Connectors.DUI.Bridge; +using Speckle.Connectors.DUI.Bindings; +using Autofac; +using Speckle.Connectors.Revit.HostApp; +using System.Diagnostics; + +namespace Speckle.Connectors.Revit.Plugin; + +internal class RevitPlugin : IRevitPlugin +{ + private readonly UIControlledApplication _uIControlledApplication; + private readonly RevitSettings _revitSettings; + private readonly IEnumerable> _bindings; // should be lazy to ensure the bindings are not created too early + private readonly BindingOptions _bindingOptions; + private readonly CefSharpPanel _panel; + private readonly RevitContext _revitContext; + private readonly CefSharpPanel _cefSharpPanel; + + public RevitPlugin( + UIControlledApplication uIControlledApplication, + RevitSettings revitSettings, + IEnumerable> bindings, + BindingOptions bindingOptions, + RevitContext revitContext, + CefSharpPanel cefSharpPanel + ) + { + _uIControlledApplication = uIControlledApplication; + _revitSettings = revitSettings; + _bindings = bindings; + _bindingOptions = bindingOptions; + _revitContext = revitContext; + _cefSharpPanel = cefSharpPanel; + } + + public void Initialise() + { + _uIControlledApplication.ControlledApplication.ApplicationInitialized += OnApplicationInitialized; + + CreateTabAndRibbonPanel(_uIControlledApplication); + } + + public void Shutdown() + { + // POC: should we be cleaning up the RibbonPanel etc... + // Should we be indicating to any active in-flight functions that we are being closed? + } + + // POC: Could be injected but maybe not worthwhile + private void CreateTabAndRibbonPanel(UIControlledApplication application) + { + // POC: some top-level handling and feedback here + try + { + application.CreateRibbonTab(_revitSettings.RevitTabName); + } + catch (ArgumentException) + { + throw; + } + + RibbonPanel specklePanel = application.CreateRibbonPanel(_revitSettings.RevitTabName, _revitSettings.RevitTabTitle); + PushButton _ = + specklePanel.AddItem( + new PushButtonData( + _revitSettings.RevitButtonName, + _revitSettings.RevitButtonText, + typeof(RevitExternalApplication).Assembly.Location, + typeof(SpeckleRevitCommand).FullName + ) + ) as PushButton; + } + + private void OnApplicationInitialized(object sender, Autodesk.Revit.DB.Events.ApplicationInitializedEventArgs e) + { + var uiApplication = new UIApplication(sender as Application); + _revitContext.UIApplication = uiApplication; + + // POC: might be worth to interface this out, we shall see... + RevitTask.Initialize(uiApplication); + + RegisterPanelAndInitializePlugin(); + } + + private void RegisterPanelAndInitializePlugin() + { + CefSharpSettings.ConcurrentTaskExecution = true; + + _uIControlledApplication.RegisterDockablePane( + RevitExternalApplication.DoackablePanelId, + _revitSettings.RevitPanelName, + _cefSharpPanel + ); + + // binding the bindings to each bridge + foreach (IBinding binding in _bindings.Select(x => x.Value)) + { + Debug.WriteLine(binding.Name); + binding.Parent.AssociateWithBinding(binding, _cefSharpPanel.Browser.ExecuteScriptAsync, _cefSharpPanel); + } + + _cefSharpPanel.Browser.IsBrowserInitializedChanged += (sender, e) => + { + // POC dev tools + _cefSharpPanel.ShowDevTools(); + + foreach (IBinding binding in _bindings.Select(x => x.Value)) + { + IBridge bridge = binding.Parent; + + _cefSharpPanel.Browser.JavascriptObjectRepository.Register( + bridge.FrontendBoundName, + bridge, + true, + _bindingOptions + ); + } + + _cefSharpPanel.Browser.Load("https://deploy-preview-2076--boisterous-douhua-e3cefb.netlify.app/"); + + // POC: not sure where this comes from +#if REVIT2020 + // NOTE: Cef65 does not work with DUI3 in yarn dev mode. To test things you need to do `yarn build` and serve the build + // folder at port 3000 (or change it to something else if you want to). Guru meditation: Je sais, pas ideal. Mais q'est que nous pouvons faire? Rien. C'est l'autodesk vie. + // NOTE: To run the ui from a build, follow these steps: + // - run `yarn build` in the DUI3 folder + // - run ` PORT=3003 node .output/server/index.mjs` after the build + + CefSharpPanel.Browser.Load("http://localhost:3003"); + CefSharpPanel.Browser.ShowDevTools(); +#endif +#if REVIT2023 + CefSharpPanel.Browser.Load("http://localhost:8082"); +#endif + }; + } +} diff --git a/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitSettings.cs b/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitSettings.cs new file mode 100644 index 0000000000..c86dbdf337 --- /dev/null +++ b/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitSettings.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Windows.Media.Converters; +using Microsoft.SqlServer.Server; + +namespace Speckle.Connectors.Revit.Plugin; + +internal class RevitSettings // POC: need to derive some interface for things that require IHostSettings +{ + public string RevitPanelName { get; set; } + public string RevitVersionName { get; set; } + public string RevitTabName { get; set; } + public string RevitTabTitle { get; set; } + public string RevitButtonName { get; set; } + public string RevitButtonText { get; set; } + public string HostSlug { get; set; } // POC: from generic IHostSettings interface + public string HostAppVersion { get; set; } // POC as HostSlug?? + public string[] ModuleFolders { get; set; } +} diff --git a/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/Speckle.Connectors.Revit2023.addin b/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/Speckle.Connectors.Revit2023.addin new file mode 100644 index 0000000000..17a6874f65 --- /dev/null +++ b/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/Speckle.Connectors.Revit2023.addin @@ -0,0 +1,12 @@ + + + + Speckle Revit Connector | DUI3 + Kits + DI + Speckle Revit Connector | DUI3 + Kits + DI + Speckle.Connectors.Revit2023\Speckle.Connectors.Revit2023.dll + Speckle.Connectors.Revit.Plugin.RevitExternalApplication + 27ccff2c-011c-4374-bb79-b93990d0c86a + speckle + Speckle: Empowering your design and construction data. For any problems, visit our community forum https://speckle.community + + diff --git a/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Speckle.Connectors.RevitShared.projitems b/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Speckle.Connectors.RevitShared.projitems new file mode 100644 index 0000000000..a6c8ec36a2 --- /dev/null +++ b/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Speckle.Connectors.RevitShared.projitems @@ -0,0 +1,44 @@ + + + + $(MSBuildAllProjects);$(MSBuildThisFileFullPath) + true + 32aea787-c986-4b76-a57f-0da5453aa1f5 + + + Speckle.Connectors.Revit + + + + Always + + + + + + + + + + + + + + CefSharpPanel.xaml + + + + + + + + + + + + + Designer + MSBuild:Compile + + + \ No newline at end of file diff --git a/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Speckle.Connectors.RevitShared.shproj b/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Speckle.Connectors.RevitShared.shproj new file mode 100644 index 0000000000..20bc9ab496 --- /dev/null +++ b/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Speckle.Connectors.RevitShared.shproj @@ -0,0 +1,13 @@ + + + + 32aea787-c986-4b76-a57f-0da5453aa1f5 + 14.0 + + + + + + + + \ No newline at end of file diff --git a/CNX-8892/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/AutofacRevitConverterModule.cs b/CNX-8892/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/AutofacRevitConverterModule.cs new file mode 100644 index 0000000000..9395ef160d --- /dev/null +++ b/CNX-8892/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/AutofacRevitConverterModule.cs @@ -0,0 +1,22 @@ +// POC: not sure we should have this here as it attaches us to autofac, maybe a bit prematurely... +using Autofac; +using Speckle.Autofac.DependencyInjection; +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; +using Speckle.Converters.RevitShared; + +namespace Speckle.Converters.Revit2023; + +public class AutofacRevitConverterModule : Module +{ + protected override void Load(ContainerBuilder builder) + { + // most things should be InstancePerLifetimeScope so we get one per operation + builder.RegisterType().As(); + + // factory for conversions + builder + .RegisterType>() + .As>(); + } +} diff --git a/CNX-8892/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/Speckle.Converters.Revit2023.DependencyInjection.csproj b/CNX-8892/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/Speckle.Converters.Revit2023.DependencyInjection.csproj new file mode 100644 index 0000000000..99b2d59b52 --- /dev/null +++ b/CNX-8892/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/Speckle.Converters.Revit2023.DependencyInjection.csproj @@ -0,0 +1,16 @@ + + + + netstandard2.0 + + + + + + + + True + + + + diff --git a/CNX-8892/Converters/Revit/Speckle.Converters.Revit2023/Speckle.Converters.Revit2023.csproj b/CNX-8892/Converters/Revit/Speckle.Converters.Revit2023/Speckle.Converters.Revit2023.csproj new file mode 100644 index 0000000000..8c3efcbe9c --- /dev/null +++ b/CNX-8892/Converters/Revit/Speckle.Converters.Revit2023/Speckle.Converters.Revit2023.csproj @@ -0,0 +1,19 @@ + + + + 10.0 + enable + netstandard2.0 + + + + + + + + + + + + + diff --git a/CNX-8892/Converters/Revit/Speckle.Converters.RevitShared/RevitConverterToSpeckle.cs b/CNX-8892/Converters/Revit/Speckle.Converters.RevitShared/RevitConverterToSpeckle.cs new file mode 100644 index 0000000000..3cb3427a80 --- /dev/null +++ b/CNX-8892/Converters/Revit/Speckle.Converters.RevitShared/RevitConverterToSpeckle.cs @@ -0,0 +1,25 @@ +using Autodesk.Revit.DB; +using Autofac.Features.Indexed; +using Speckle.Autofac.DependencyInjection; +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; + +namespace Speckle.Converters.RevitShared; + +// POC: maybe possible to restrict the access so this cannot be created directly? +public class RevitConverterToSpeckle : ISpeckleConverterToSpeckle +{ + private readonly IFactory _toSpeckle; + + public RevitConverterToSpeckle(IFactory toSpeckle) + { + _toSpeckle = toSpeckle; + } + + public void Convert() + { + var objectConverter = _toSpeckle.ResolveInstance(nameof(Floor)); + + int t = -1; + } +} diff --git a/CNX-8892/Converters/Revit/Speckle.Converters.RevitShared/Speckle.Converters.RevitShared.projitems b/CNX-8892/Converters/Revit/Speckle.Converters.RevitShared/Speckle.Converters.RevitShared.projitems new file mode 100644 index 0000000000..78bfc3eb0b --- /dev/null +++ b/CNX-8892/Converters/Revit/Speckle.Converters.RevitShared/Speckle.Converters.RevitShared.projitems @@ -0,0 +1,15 @@ + + + + $(MSBuildAllProjects);$(MSBuildThisFileFullPath) + true + 9655be78-8070-4b9f-b0dc-68bb6150b52c + + + Speckle.Converters.RevitShared + + + + + + \ No newline at end of file diff --git a/CNX-8892/Converters/Revit/Speckle.Converters.RevitShared/Speckle.Converters.RevitShared.shproj b/CNX-8892/Converters/Revit/Speckle.Converters.RevitShared/Speckle.Converters.RevitShared.shproj new file mode 100644 index 0000000000..086a77a4aa --- /dev/null +++ b/CNX-8892/Converters/Revit/Speckle.Converters.RevitShared/Speckle.Converters.RevitShared.shproj @@ -0,0 +1,13 @@ + + + + 9655be78-8070-4b9f-b0dc-68bb6150b52c + 14.0 + + + + + + + + diff --git a/CNX-8892/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/FloorConversionToSpeckle.cs b/CNX-8892/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/FloorConversionToSpeckle.cs new file mode 100644 index 0000000000..b4a347e4dd --- /dev/null +++ b/CNX-8892/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/FloorConversionToSpeckle.cs @@ -0,0 +1,16 @@ +using Autodesk.Revit.DB; +using Speckle.Autofac.DependencyInjection; +using Speckle.Converters.Common.Objects; + +namespace Speckle.Converters.Common.ToSpeckle; + +// POC: reminder - writing classes and creating interfaces is a bit like organising your space +// if you have a structure for organising things, your interfaces, then finding your stuff, your classes & methods, becomes easy +// having a lack of interfaces or large interfaces is a bit like lacking structure, when all of your stuff, your classes & methods +// clould be anywhere or all in once place - rooting through box 274 for something you need, when said box has a miriad different +// and unrelated items, is no fun. Plus when you need that item, you end up bringing out the whole box/ +[NameAndRankValue(nameof(Floor), 0)] +public class FloorConversionToSpeckle : IHostObjectToSpeckleConversion +{ + public void Convert() => throw new System.NotImplementedException(); +} diff --git a/CNX-8892/Converters/Speckle.Converters.Common/ISpeckleConverterToHost.cs b/CNX-8892/Converters/Speckle.Converters.Common/ISpeckleConverterToHost.cs new file mode 100644 index 0000000000..4f50dd644e --- /dev/null +++ b/CNX-8892/Converters/Speckle.Converters.Common/ISpeckleConverterToHost.cs @@ -0,0 +1,6 @@ +namespace Speckle.Converters.Common; + +public interface ISpeckleConverterToHost +{ + void Convert(); +} diff --git a/CNX-8892/Converters/Speckle.Converters.Common/ISpeckleConverterToSpeckle.cs b/CNX-8892/Converters/Speckle.Converters.Common/ISpeckleConverterToSpeckle.cs new file mode 100644 index 0000000000..bf2334b77d --- /dev/null +++ b/CNX-8892/Converters/Speckle.Converters.Common/ISpeckleConverterToSpeckle.cs @@ -0,0 +1,6 @@ +namespace Speckle.Converters.Common; + +public interface ISpeckleConverterToSpeckle +{ + void Convert(); +} diff --git a/CNX-8892/Converters/Speckle.Converters.Common/Objects/FloorConversion.cs b/CNX-8892/Converters/Speckle.Converters.Common/Objects/FloorConversion.cs new file mode 100644 index 0000000000..16613848df --- /dev/null +++ b/CNX-8892/Converters/Speckle.Converters.Common/Objects/FloorConversion.cs @@ -0,0 +1,3 @@ +namespace Speckle.Converters.Common.Objects; + +public class FloorConversion { } diff --git a/CNX-8892/Converters/Speckle.Converters.Common/Objects/IHostObjectToSpeckleConversion.cs b/CNX-8892/Converters/Speckle.Converters.Common/Objects/IHostObjectToSpeckleConversion.cs new file mode 100644 index 0000000000..957f73605e --- /dev/null +++ b/CNX-8892/Converters/Speckle.Converters.Common/Objects/IHostObjectToSpeckleConversion.cs @@ -0,0 +1,10 @@ +namespace Speckle.Converters.Common.Objects; + +// POC: NEXT UP +// * begin scope: https://stackoverflow.com/questions/49595198/autofac-resolving-through-factory-methods +// Interceptors? + +public interface IHostObjectToSpeckleConversion +{ + void Convert(); +} diff --git a/CNX-8892/Converters/Speckle.Converters.Common/Objects/ISpeckleObjectToHostConversion.cs b/CNX-8892/Converters/Speckle.Converters.Common/Objects/ISpeckleObjectToHostConversion.cs new file mode 100644 index 0000000000..0bdbbf648a --- /dev/null +++ b/CNX-8892/Converters/Speckle.Converters.Common/Objects/ISpeckleObjectToHostConversion.cs @@ -0,0 +1,10 @@ +namespace Speckle.Converters.Common.Objects; + +// POC: NEXT UP +// * begin scope: https://stackoverflow.com/questions/49595198/autofac-resolving-through-factory-methods +// Interceptors? + +public interface IHostToSpeckleConverter +{ + void Convert(); +} diff --git a/CNX-8892/Converters/Speckle.Converters.Common/ReceiveMode.cs b/CNX-8892/Converters/Speckle.Converters.Common/ReceiveMode.cs new file mode 100644 index 0000000000..b24701062d --- /dev/null +++ b/CNX-8892/Converters/Speckle.Converters.Common/ReceiveMode.cs @@ -0,0 +1,25 @@ +namespace Speckle.Converters.Common; + +// NOTE: Do not change the order of the existing ones +/// +/// Receive modes indicate what to do and not do when receiving objects +/// +public enum ReceiveMode +{ + /// + /// Attemts updating previously received objects by ID, deletes previously received objects that do not exist anymore and creates new ones + /// + // POC: these could be numbered explicitly if the order matters, gaps could be included, + // so 1000, 2000, 3000 for plenty of expansion + Update, + + /// + /// Always creates new objects + /// + Create, + + /// + /// Ignores updating previously received objects and does not attempt updating or deleting them, creates new objects + /// + Ignore +} diff --git a/CNX-8892/Converters/Speckle.Converters.Common/Speckle.Converters.Common.csproj b/CNX-8892/Converters/Speckle.Converters.Common/Speckle.Converters.Common.csproj new file mode 100644 index 0000000000..1980c4b184 --- /dev/null +++ b/CNX-8892/Converters/Speckle.Converters.Common/Speckle.Converters.Common.csproj @@ -0,0 +1,14 @@ + + + + 10.0 + enable + netstandard2.0 + + + + + + + + diff --git a/CNX-8892/DUI3/Speckle.Connectors.DUI/Bindings/AccountBinding.cs b/CNX-8892/DUI3/Speckle.Connectors.DUI/Bindings/AccountBinding.cs new file mode 100644 index 0000000000..08d66d19ec --- /dev/null +++ b/CNX-8892/DUI3/Speckle.Connectors.DUI/Bindings/AccountBinding.cs @@ -0,0 +1,30 @@ +using System.Linq; +using Speckle.Connectors.DUI.Bridge; +using Speckle.Core.Credentials; + +namespace Speckle.Connectors.DUI.Bindings; + +// TODO: this needs splitting into different files + +public class AccountBinding : IBinding +{ + public string Name { get; set; } = "accountsBinding"; + public IBridge Parent { get; private set; } + + public AccountBinding(IBridge bridge) + { + Parent = bridge; + } + + public Account[] GetAccounts() + { + return AccountManager.GetAccounts().ToArray(); + // NOTE: removing the avatars is no longer needed as we've resolved the issue described below via the bridge implementation. + // .Select( + // a => + // { + // a.userInfo.avatar = null; // removing this as the get accounts call was a too large string to do "executeScriptAsync" with (this was not happening if this was a direct return from a binding call). + // return a; + // }).ToArray(); + } +} diff --git a/CNX-8892/DUI3/Speckle.Connectors.DUI/Bindings/IBasicConnectorBinding.cs b/CNX-8892/DUI3/Speckle.Connectors.DUI/Bindings/IBasicConnectorBinding.cs new file mode 100644 index 0000000000..730057b33f --- /dev/null +++ b/CNX-8892/DUI3/Speckle.Connectors.DUI/Bindings/IBasicConnectorBinding.cs @@ -0,0 +1,28 @@ +using Speckle.Connectors.DUI.Models; +using Speckle.Connectors.DUI.Models.Card; + +namespace Speckle.Connectors.DUI.Bindings; + +public interface IBasicConnectorBinding : IBinding +{ + public string GetSourceApplicationName(); + public string GetSourceApplicationVersion(); + public string GetConnectorVersion(); + public DocumentInfo GetDocumentInfo(); + public DocumentModelStore GetDocumentState(); + public void AddModel(ModelCard model); + public void UpdateModel(ModelCard model); + public void RemoveModel(ModelCard model); + + /// + /// Highlights the objects attached to this sender in the host application. + /// + /// + public void HighlightModel(string modelCardId); +} + +public static class BasicConnectorBindingEvents +{ + public const string DISPLAY_TOAST_NOTIFICATION = "DisplayToastNotification"; + public const string DOCUMENT_CHANGED = "documentChanged"; +} diff --git a/CNX-8892/DUI3/Speckle.Connectors.DUI/Bindings/IBinding.cs b/CNX-8892/DUI3/Speckle.Connectors.DUI/Bindings/IBinding.cs new file mode 100644 index 0000000000..88382706cb --- /dev/null +++ b/CNX-8892/DUI3/Speckle.Connectors.DUI/Bindings/IBinding.cs @@ -0,0 +1,23 @@ +using Speckle.Connectors.DUI.Bridge; + +namespace Speckle.Connectors.DUI.Bindings; + +/// +/// Describes the most basic binding. +/// +public interface IBinding +{ + /// + /// This will be the name under which it will be available in the Frontend, e.g. + /// window.superBinding, or window.mapperBinding. Please use camelCase even if + /// it hurts. + /// + public string Name { get; } + + /// + /// Bindings will be wrapped by a browser specific bridge, and they will need + /// to use that bridge to send events to the Frontend, via SendToBrowser(IHostAppEvent) or SendToBrowser(string). + /// TODO: we'll probably need a factory class of sorts to handle the proper wrapping. Currently, on bridge instantiation the parent is set in the bindings class that has been wrapped around. Not vvv elegant. + /// + public IBridge Parent { get; } +} diff --git a/CNX-8892/DUI3/Speckle.Connectors.DUI/Bindings/IReceiveBinding.cs b/CNX-8892/DUI3/Speckle.Connectors.DUI/Bindings/IReceiveBinding.cs new file mode 100644 index 0000000000..afd6eb4fa0 --- /dev/null +++ b/CNX-8892/DUI3/Speckle.Connectors.DUI/Bindings/IReceiveBinding.cs @@ -0,0 +1,28 @@ +using Speckle.Connectors.DUI.Models.Card; + +namespace Speckle.Connectors.DUI.Bindings; + +public interface IReceiveBinding : IBinding +{ + /// + /// Instructs the host app to start receiving this model version. + /// + /// Model card id + /// Version id to receive + public void Receive(string modelCardId, string versionId); + + /// + /// Instructs the host app to cancel the receiving for a given model. + /// + /// + public void CancelReceive(string modelCardId); +} + +public static class ReceiveBindingEvents +{ + public const string RECEIVERS_EXPIRED = "receiversExpired"; + public const string RECEIVERS_PROGRESS = "receiverProgress"; + public const string NOTIFY = "notify"; +} + +public class ReceiverModelCard : ModelCard { } diff --git a/CNX-8892/DUI3/Speckle.Connectors.DUI/Bindings/ISelectionBinding.cs b/CNX-8892/DUI3/Speckle.Connectors.DUI/Bindings/ISelectionBinding.cs new file mode 100644 index 0000000000..c7cd2ece98 --- /dev/null +++ b/CNX-8892/DUI3/Speckle.Connectors.DUI/Bindings/ISelectionBinding.cs @@ -0,0 +1,19 @@ +using System.Collections.Generic; + +namespace Speckle.Connectors.DUI.Bindings; + +public interface ISelectionBinding : IBinding +{ + public SelectionInfo GetSelection(); +} + +public static class SelectionBindingEvents +{ + public const string SET_SELECTION = "setSelection"; +} + +public class SelectionInfo +{ + public List SelectedObjectIds { get; set; } + public string Summary { get; set; } +} diff --git a/CNX-8892/DUI3/Speckle.Connectors.DUI/Bindings/ISendBinding.cs b/CNX-8892/DUI3/Speckle.Connectors.DUI/Bindings/ISendBinding.cs new file mode 100644 index 0000000000..f475ad0989 --- /dev/null +++ b/CNX-8892/DUI3/Speckle.Connectors.DUI/Bindings/ISendBinding.cs @@ -0,0 +1,72 @@ +using System.Collections.Generic; +using Speckle.Connectors.DUI.Models.Card; +using Speckle.Connectors.DUI.Utils; + +namespace Speckle.Connectors.DUI.Bindings; + +public interface ISendBinding : IBinding +{ + public List GetSendFilters(); + + /// + /// Instructs the host app to start sending this model. + /// + /// + public void Send(string modelCardId); + + /// + /// Instructs the host app to cancel the sending for a given model. + /// + /// + public void CancelSend(string modelCardId); +} + +public class SenderModelCard : ModelCard +{ + public ISendFilter SendFilter { get; set; } +} + +public interface ISendFilter +{ + public string Name { get; set; } + public string Summary { get; set; } + public bool IsDefault { get; set; } + + /// + /// Gets the ids of the objects targeted by the filter from the host application. + /// + /// + public List GetObjectIds(); + + /// + /// Checks whether any of the targeted objects are affected by changes from the host application. + /// + /// + /// + public bool CheckExpiry(string[] changedObjectIds); +} + +public abstract class EverythingSendFilter : DiscriminatedObject, ISendFilter +{ + public string Name { get; set; } = "Everything"; + public string Summary { get; set; } = "All supported objects in the file."; + public bool IsDefault { get; set; } + public abstract List GetObjectIds(); + public abstract bool CheckExpiry(string[] changedObjectIds); +} + +public abstract class DirectSelectionSendFilter : DiscriminatedObject, ISendFilter +{ + public string Name { get; set; } = "Selection"; + public string Summary { get; set; } + public bool IsDefault { get; set; } + public List SelectedObjectIds { get; set; } = new List(); + public abstract List GetObjectIds(); + public abstract bool CheckExpiry(string[] changedObjectIds); +} + +public class CreateVersionArgs +{ + public string ModelCardId { get; set; } + public string ObjectId { get; set; } +} diff --git a/CNX-8892/DUI3/Speckle.Connectors.DUI/Bindings/ISendBindingUICommands.cs b/CNX-8892/DUI3/Speckle.Connectors.DUI/Bindings/ISendBindingUICommands.cs new file mode 100644 index 0000000000..77b0620ed1 --- /dev/null +++ b/CNX-8892/DUI3/Speckle.Connectors.DUI/Bindings/ISendBindingUICommands.cs @@ -0,0 +1,12 @@ +using System.Collections.Generic; + +namespace Speckle.Connectors.DUI.Bindings; + +public interface ISendBindingUICommands +{ + public void RefreshSendFilters(string frontEndName); + + public void SetModelsExpired(string frontEndName, IEnumerable expiredModelIds); + + public void SetModelCreatedVersionId(string frontEndName, string modelCardId, string versionId); +} diff --git a/CNX-8892/DUI3/Speckle.Connectors.DUI/Bindings/SendBindingUICommands.cs b/CNX-8892/DUI3/Speckle.Connectors.DUI/Bindings/SendBindingUICommands.cs new file mode 100644 index 0000000000..5382336358 --- /dev/null +++ b/CNX-8892/DUI3/Speckle.Connectors.DUI/Bindings/SendBindingUICommands.cs @@ -0,0 +1,21 @@ +using System.Collections.Generic; +using Speckle.Connectors.DUI.Bridge; + +namespace Speckle.Connectors.DUI.Bindings; + +// POC: have put this static back but unsure about it or the IBridge having this responsibility... and the static +public static class SendBindingUICommands +{ + private const string REFRESH_SEND_FILTERS_UI_COMMAND_NAME = "refreshSendFilters"; + private const string SET_MODELS_EXPIRED_UI_COMMAND_NAME = "setModelsExpired"; + private const string SET_MODEL_CREATED_VERSION_ID_UI_COMMAND_NAME = "setModelCreatedVersionId"; + + // POC.. the only reasons this needs the bridge is to send? realtionship to these messages and the bridge is unclear + public static void RefreshSendFilters(IBridge bridge) => bridge.Send(REFRESH_SEND_FILTERS_UI_COMMAND_NAME); + + public static void SetModelsExpired(IBridge bridge, IEnumerable expiredModelIds) => + bridge.Send(SET_MODELS_EXPIRED_UI_COMMAND_NAME, expiredModelIds); + + public static void SetModelCreatedVersionId(IBridge bridge, string modelCardId, string versionId) => + bridge.Send(SET_MODEL_CREATED_VERSION_ID_UI_COMMAND_NAME, new { modelCardId, versionId }); +} diff --git a/CNX-8892/DUI3/Speckle.Connectors.DUI/Bridge/BrowserBridge.cs b/CNX-8892/DUI3/Speckle.Connectors.DUI/Bridge/BrowserBridge.cs new file mode 100644 index 0000000000..c927af7c5e --- /dev/null +++ b/CNX-8892/DUI3/Speckle.Connectors.DUI/Bridge/BrowserBridge.cs @@ -0,0 +1,296 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using System.Runtime.InteropServices; +using System.Threading; +using Speckle.Newtonsoft.Json; +using System.Threading.Tasks; +using Speckle.Core.Logging; +using Speckle.Connectors.DUI.Bindings; +using System.Threading.Tasks.Dataflow; +using System.Diagnostics; +using Microsoft.Extensions.Logging; + +namespace Speckle.Connectors.DUI.Bridge; + +/// +/// Wraps a binding class, and manages its calls from the Frontend to .NET, and sending events from .NET to the the Frontend. +/// Initially inspired by: https://github.com/johot/WebView2-better-bridge +/// +[ClassInterface(ClassInterfaceType.AutoDual)] +[ComVisible(true)] +public class BrowserBridge : IBridge +{ + /// + /// The name under which we expect the frontend to hoist this bindings class to the global scope. + /// e.g., `receiveBindings` should be available as `window.receiveBindings`. + /// + + private readonly JsonSerializerSettings _serializerOptions; + private readonly Dictionary _resultsStore = new(); + private readonly SynchronizationContext _mainThreadContext; + + private Dictionary BindingMethodCache { get; set; } + private ActionBlock _actionBlock; + private Action? _scriptMethod; + + private IBinding _binding; + private Type _bindingType; + + private readonly ILogger _logger; + + // POC: what is this excatly? + public Action ShowDevToolsAction { get; set; } + + public string FrontendBoundName { get; private set; } + + public object Browser { get; private set; } + + public IBinding Binding + { + get => _binding; + private set + { + if (_binding != null || this != value.Parent) + { + throw new ArgumentException($"Binding: {FrontendBoundName} is already bound or does not match bridge"); + } + + _binding = value; + } + } + + private struct RunMethodArgs + { + public string MethodName; + public string RequestId; + public string MethodArgs; + } + + /// + /// Creates a new bridge. + /// + /// The actual binding class. + public BrowserBridge(JsonSerializerSettings jsonSerializerSettings, ILoggerFactory loggerFactory) + { + _serializerOptions = jsonSerializerSettings; + _logger = loggerFactory.CreateLogger(); + + // Capture the main thread's SynchronizationContext + _mainThreadContext = SynchronizationContext.Current; + } + + public void AssociateWithBinding(IBinding binding, Action scriptMethod, object browser) + { + // set via binding property to ensure explosion if already bound + Binding = binding; + FrontendBoundName = binding.Name; + Browser = browser; + _scriptMethod = scriptMethod; + + _bindingType = binding.GetType(); + BindingMethodCache = new Dictionary(); + + // Note: we need to filter out getter and setter methods here because they are not really nicely + // supported across browsers, hence the !method.IsSpecialName. + foreach (var m in _bindingType.GetMethods().Where(method => !method.IsSpecialName)) + { + BindingMethodCache[m.Name] = m; + } + + // Whenever the ui will call run method inside .net, it will post a message to this action block. + // This conveniently executes the code outside the UI thread and does not block during long operations (such as sending). + _actionBlock = new ActionBlock( + args => ExecuteMethod(args.MethodName, args.RequestId, args.MethodArgs), + new ExecutionDataflowBlockOptions + { + MaxDegreeOfParallelism = 1000, + CancellationToken = new CancellationTokenSource(TimeSpan.FromHours(3)).Token // Not sure we need such a long time. + } + ); + + // + _logger.LogInformation("Bridge bound to front end name {FrontEndName}", binding.Name); + } + + /// + /// Used by the Frontend bridge logic to understand which methods are available. + /// + /// + public string[] GetBindingsMethodNames() + { + var bindingNames = BindingMethodCache.Keys.ToArray(); + Debug.WriteLine($"{FrontendBoundName}: " + JsonConvert.SerializeObject(bindingNames, Formatting.Indented)); + return bindingNames; + } + + /// + /// This method posts the requested call to our action block executor. + /// + /// + /// + /// + public void RunMethod(string methodName, string requestId, string args) + { + _actionBlock.Post( + new RunMethodArgs + { + MethodName = methodName, + RequestId = requestId, + MethodArgs = args + } + ); + } + + /// + /// Run actions on main thread. + /// + /// Action to run on main thread. + public void RunOnMainThread(Action action) + { + _mainThreadContext.Post( + _ => + { + // Execute the action on the main thread + action.Invoke(); + }, + null + ); + } + + /// + /// Used by the action block to invoke the actual method called by the UI. + /// + /// + /// + /// + /// + private void ExecuteMethod(string methodName, string requestId, string args) + { + // Note: You might be tempted to make this method async Task to prevent the task.Wait() below. + // Do not do that! Cef65 doesn't like waiting for async .NET methods. + // Note: we have this pokemon catch 'em all here because throwing errors in .NET is + // very risky, and we might crash the host application. Behaviour seems also to differ + // between various browser controls (e.g.: cefsharp handles things nicely - basically + // passing back the exception to the browser, but webview throws an access violation + // error that kills Rhino.). + try + { + if (!BindingMethodCache.TryGetValue(methodName, out MethodInfo method)) + { + throw new SpeckleException( + $"Cannot find method {methodName} in bindings class {_bindingType.AssemblyQualifiedName}." + ); + } + + var parameters = method.GetParameters(); + var jsonArgsArray = JsonConvert.DeserializeObject(args); + if (parameters.Length != jsonArgsArray.Length) + { + throw new SpeckleException( + $"Wrong number of arguments when invoking binding function {methodName}, expected {parameters.Length}, but got {jsonArgsArray.Length}." + ); + } + + var typedArgs = new object[jsonArgsArray.Length]; + + for (int i = 0; i < typedArgs.Length; i++) + { + var ccc = JsonConvert.DeserializeObject(jsonArgsArray[i], parameters[i].ParameterType, _serializerOptions); + typedArgs[i] = ccc; + } + + var resultTyped = method.Invoke(Binding, typedArgs); + + // Was it an async method (in bridgeClass?) + var resultTypedTask = resultTyped as Task; + + string resultJson; + + // Was the method called async? + if (resultTypedTask == null) + { + // Regular method: no need to await things + resultJson = JsonConvert.SerializeObject(resultTyped, _serializerOptions); + } + else // It's an async call + { + // See note at start of function. Do not asyncify! + resultTypedTask.Wait(); + + // If has a "Result" property return the value otherwise null (Task etc) + PropertyInfo resultProperty = resultTypedTask.GetType().GetProperty("Result"); + object taskResult = resultProperty?.GetValue(resultTypedTask); + resultJson = JsonConvert.SerializeObject(taskResult, _serializerOptions); + } + + NotifyUIMethodCallResultReady(requestId, resultJson); + } + catch (SpeckleException e) + { + // TODO: properly log the exeception. + var serializedError = JsonConvert.SerializeObject( + new { Error = e.Message, InnerError = e.InnerException?.Message }, + _serializerOptions + ); + + NotifyUIMethodCallResultReady(requestId, serializedError); + } + } + + /// + /// Notifies the UI that the method call is ready. We do not give the result back to the ui here via ExecuteScriptAsync + /// because of limitations we discovered along the way (e.g, / chars need to be escaped). + /// + /// + /// + private void NotifyUIMethodCallResultReady(string requestId, string serializedData = null) + { + _resultsStore[requestId] = serializedData; + string script = $"{FrontendBoundName}.responseReady('{requestId}')"; + _scriptMethod!(script); + } + + /// + /// Called by the ui to get back the serialized result of the method. See comments above for why. + /// + /// + /// + public string GetCallResult(string requestId) + { + var res = _resultsStore[requestId]; + _resultsStore.Remove(requestId); + return res; + } + + /// + /// Shows the dev tools. This is currently only needed for CefSharp - other browser + /// controls allow for right click + inspect. + /// + public void ShowDevTools() + { + ShowDevToolsAction(); + } + + public void OpenUrl(string url) + { + Process.Start(url); + } + + public void Send(string eventName) + { + var script = $"{FrontendBoundName}.emit('{eventName}')"; + + _scriptMethod!(script); + } + + public void Send(string eventName, T data) + where T : class + { + string payload = JsonConvert.SerializeObject(data, _serializerOptions); + var script = $"{FrontendBoundName}.emit('{eventName}', '{payload}')"; + + _scriptMethod!(script); + } +} diff --git a/CNX-8892/DUI3/Speckle.Connectors.DUI/Bridge/IBridge.cs b/CNX-8892/DUI3/Speckle.Connectors.DUI/Bridge/IBridge.cs new file mode 100644 index 0000000000..b4b1efdd75 --- /dev/null +++ b/CNX-8892/DUI3/Speckle.Connectors.DUI/Bridge/IBridge.cs @@ -0,0 +1,44 @@ +using System; +using Speckle.Connectors.DUI.Bindings; +using Speckle.Newtonsoft.Json; + +namespace Speckle.Connectors.DUI.Bridge; + +/// +/// Describes a bridge - a wrapper class around a specific browser host. Not needed right now, +/// but if in the future we will have other bridge classes (e.g, ones that wrap around other browsers), +/// it just might be useful. +/// +public interface IBridge +{ + // POC: documnetation comments + string FrontendBoundName { get; } + + void AssociateWithBinding(IBinding binding, Action scriptMethod, object browser); + + /// + /// This method is called by the Frontend bridge to understand what it can actually call. It should return the method names of the bindings that this bridge wraps around. + /// + /// + public string[] GetBindingsMethodNames(); + + /// + /// This method is called by the Frontend bridge when invoking any of the wrapped binding's methods. + /// + /// + /// + /// + public void RunMethod(string methodName, string requestId, string args); + + /// + /// Run actions on main thread. + /// Some applications might need to run some operations on main thread as deferred actions. + /// + /// Action to run on main thread. + public void RunOnMainThread(Action action); + + public void Send(string eventName); + + public void Send(string eventName, T data) + where T : class; +} diff --git a/CNX-8892/DUI3/Speckle.Connectors.DUI/GlobalSuppressions.cs b/CNX-8892/DUI3/Speckle.Connectors.DUI/GlobalSuppressions.cs new file mode 100644 index 0000000000..1e481a130a --- /dev/null +++ b/CNX-8892/DUI3/Speckle.Connectors.DUI/GlobalSuppressions.cs @@ -0,0 +1,14 @@ +// This file is used by Code Analysis to maintain SuppressMessage +// attributes that are applied to this project. +// Project-level suppressions either have no target or are given +// a specific target and scoped to a namespace, type, member, etc. + +using System.Diagnostics.CodeAnalysis; + +[assembly: SuppressMessage( + "Performance", + "CA1848:Use the LoggerMessage delegates", + Justification = "", + Scope = "member", + Target = "~M:Speckle.Connectors.DUI.Bridge.BrowserBridge.AssociateWithBinding(Speckle.Connectors.DUI.Bindings.IBinding,System.Action{System.String},System.Object)" +)] diff --git a/CNX-8892/DUI3/Speckle.Connectors.DUI/Models/Card/ModelCard.cs b/CNX-8892/DUI3/Speckle.Connectors.DUI/Models/Card/ModelCard.cs new file mode 100644 index 0000000000..29be3e792e --- /dev/null +++ b/CNX-8892/DUI3/Speckle.Connectors.DUI/Models/Card/ModelCard.cs @@ -0,0 +1,26 @@ +using System.Collections.Generic; +using Speckle.Connectors.DUI.Utils; + +namespace Speckle.Connectors.DUI.Models.Card; + +public class ModelCard : DiscriminatedObject +{ + /// + /// This is a unique id generated by the ui to make model cards easier to reference around. + /// It's not the actual model (branch) id. + /// + public string ModelCardId { get; set; } + + /// + /// Model id. FKA branch id. + /// + public string ModelId { get; set; } + + /// + /// Project id. FKA stream id. + /// + public string ProjectId { get; set; } + public string AccountId { get; set; } + + public List Settings { get; set; } +} diff --git a/CNX-8892/DUI3/Speckle.Connectors.DUI/Models/DocumentInfo.cs b/CNX-8892/DUI3/Speckle.Connectors.DUI/Models/DocumentInfo.cs new file mode 100644 index 0000000000..39ac1302aa --- /dev/null +++ b/CNX-8892/DUI3/Speckle.Connectors.DUI/Models/DocumentInfo.cs @@ -0,0 +1,13 @@ +namespace Speckle.Connectors.DUI.Models; + +public class DocumentInfo +{ + public string Location { get; set; + //?.Replace("\\", "\\\\"); // for some reason, when returning variables from a direct binding call + //we don't need this. nevertheless, after switching to a post response back to the ui, + //we need this to ensure deserialization in js doesn't throw. it's frustrating! + } + + public string Name { get; set; } + public string Id { get; set; } +} diff --git a/CNX-8892/DUI3/Speckle.Connectors.DUI/Models/DocumentModelStore.cs b/CNX-8892/DUI3/Speckle.Connectors.DUI/Models/DocumentModelStore.cs new file mode 100644 index 0000000000..1c35fe52fe --- /dev/null +++ b/CNX-8892/DUI3/Speckle.Connectors.DUI/Models/DocumentModelStore.cs @@ -0,0 +1,67 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using Speckle.Connectors.DUI.Utils; +using Speckle.Connectors.DUI.Objects; +using Speckle.Newtonsoft.Json; +using Speckle.Connectors.DUI.Bindings; +using Speckle.Connectors.DUI.Models.Card; + +namespace Speckle.Connectors.DUI.Models; + +/// +/// Encapsulates the state Speckle needs to persist in the host app's document. +/// +public abstract class DocumentModelStore : DiscriminatedObject +{ + public List SpeckleHostObjects { get; set; } = new List(); + + public List Models { get; set; } = new List(); + + private readonly JsonSerializerSettings _serializerOptions; + + protected DocumentModelStore(JsonSerializerSettings serializerOption) + { + _serializerOptions = serializerOption; + } + + /// + /// This event is triggered by each specific host app implementation of the document model store. + /// + // POC: unsure about the PublicAPI annotation, unsure if this changed handle should live here on the store... :/ + public event EventHandler DocumentChanged; + + public virtual bool IsDocumentInit { get; set; } + + // TODO: not sure about this, throwing an exception, needs some thought... + public ModelCard GetModelById(string id) + { + var model = Models.First(model => model.ModelCardId == id) ?? throw new ModelNotFoundException(); + return model; + } + + protected void OnDocumentChanged() => DocumentChanged?.Invoke(this, EventArgs.Empty); + + // POC: why not IEnumerable? + public List GetSenders() => + Models.Where(model => model.TypeDiscriminator == nameof(SenderModelCard)).Cast().ToList(); + + // POC: why not IEnumerable? + public List GetReceivers() => + Models.Where(model => model.TypeDiscriminator == nameof(ReceiverModelCard)).Cast().ToList(); + + protected string Serialize() + { + return JsonConvert.SerializeObject(Models, _serializerOptions); + } + + // POC: this seemms more like a IModelsDeserializer?, seems disconnected from this class + protected List Deserialize(string models) + { + return JsonConvert.DeserializeObject>(models, _serializerOptions); + } + + public abstract void WriteToFile(); + + public abstract void ReadFromFile(); +} diff --git a/CNX-8892/DUI3/Speckle.Connectors.DUI/Objects/ISpeckleHostObject.cs b/CNX-8892/DUI3/Speckle.Connectors.DUI/Objects/ISpeckleHostObject.cs new file mode 100644 index 0000000000..e3637ceabf --- /dev/null +++ b/CNX-8892/DUI3/Speckle.Connectors.DUI/Objects/ISpeckleHostObject.cs @@ -0,0 +1,8 @@ +namespace Speckle.Connectors.DUI.Objects; + +public interface ISpeckleHostObject +{ + public string ApplicationId { get; } + public string SpeckleId { get; } + public bool IsExpired { get; } +} diff --git a/CNX-8892/DUI3/Speckle.Connectors.DUI/Settings/CardSetting.cs b/CNX-8892/DUI3/Speckle.Connectors.DUI/Settings/CardSetting.cs new file mode 100644 index 0000000000..5ce5fd83fb --- /dev/null +++ b/CNX-8892/DUI3/Speckle.Connectors.DUI/Settings/CardSetting.cs @@ -0,0 +1,12 @@ +using System.Collections.Generic; + +namespace Speckle.Connectors.DUI.Utils; + +public class CardSetting : DiscriminatedObject +{ + public string Id { get; set; } + public string Title { get; set; } + public string Type { get; set; } + public object Value { get; set; } + public List? Enum { get; set; } +} diff --git a/CNX-8892/DUI3/Speckle.Connectors.DUI/Speckle.Connectors.DUI.csproj b/CNX-8892/DUI3/Speckle.Connectors.DUI/Speckle.Connectors.DUI.csproj new file mode 100644 index 0000000000..60a9ec6b2b --- /dev/null +++ b/CNX-8892/DUI3/Speckle.Connectors.DUI/Speckle.Connectors.DUI.csproj @@ -0,0 +1,23 @@ + + + + enable + netstandard2.0 + x64 + AnyCPU;x64 + + + + + + + + + + + + + + + + diff --git a/CNX-8892/DUI3/Speckle.Connectors.DUI/Utils/DiscriminatedObject.cs b/CNX-8892/DUI3/Speckle.Connectors.DUI/Utils/DiscriminatedObject.cs new file mode 100644 index 0000000000..b7385bbff6 --- /dev/null +++ b/CNX-8892/DUI3/Speckle.Connectors.DUI/Utils/DiscriminatedObject.cs @@ -0,0 +1,16 @@ +namespace Speckle.Connectors.DUI.Utils; + +/// +/// Any polymorphic type base should inherit from this class in order for it to be properly deserialized. +/// - Class inheritance scenario For example, if you have a base class BaseSettings, and from it you create RhinoBaseSettings & AutocadBaseSettings, the BaseSetting class should inherit from this class. +/// - Interface scenario: you have an ISenderCard interface, which you implement as ReceiverCard and SenderCard. Both ReceiverCard and SenderCard should inherit from this class. +/// +/// POC: should probaby be changed to attribute instead of inheritence? TBC +public class DiscriminatedObject +{ + public string TypeDiscriminator + { + get => this.GetType().Name; + set { } + } +} diff --git a/CNX-8892/DUI3/Speckle.Connectors.DUI/Utils/DiscriminatedObjectConverter.cs b/CNX-8892/DUI3/Speckle.Connectors.DUI/Utils/DiscriminatedObjectConverter.cs new file mode 100644 index 0000000000..faca3fe869 --- /dev/null +++ b/CNX-8892/DUI3/Speckle.Connectors.DUI/Utils/DiscriminatedObjectConverter.cs @@ -0,0 +1,131 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Reflection; +using Speckle.Core.Serialisation; +using Speckle.Newtonsoft.Json; +using Speckle.Newtonsoft.Json.Linq; +using Speckle.Newtonsoft.Json.Serialization; + +namespace Speckle.Connectors.DUI.Utils; + +/// +/// This converter ensures we can do polymorphic deserialization to concrete types. It is automatically added to all +/// serialization settings from . This converter is intended +/// for use only with UI bound types, not Speckle Bases. +/// +// POC: automatic registration of compatible objects +public class DiscriminatedObjectConverter : JsonConverter +{ + private readonly JsonSerializer _localSerializer = + new() + { + DefaultValueHandling = DefaultValueHandling.Ignore, + ContractResolver = new CamelCasePropertyNamesContractResolver(), + NullValueHandling = NullValueHandling.Ignore + }; + + public override void WriteJson(JsonWriter writer, DiscriminatedObject value, JsonSerializer serializer) + { + var jo = JObject.FromObject(value, _localSerializer); + jo.WriteTo(writer); + } + + public override DiscriminatedObject ReadJson( + JsonReader reader, + Type objectType, + DiscriminatedObject existingValue, + bool hasExistingValue, + JsonSerializer serializer + ) + { + JObject jsonObject = JObject.Load(reader); + + var typeName = + jsonObject.Value("typeDiscriminator") + ?? throw new SpeckleDeserializeException( + "DUI3 Discriminator converter deserialization failed: did not find a typeDiscriminator field." + ); + var type = + GetTypeByName(typeName) + ?? throw new SpeckleDeserializeException( + "DUI3 Discriminator converter deserialization failed, type not found: " + typeName + ); + var obj = Activator.CreateInstance(type); + serializer.Populate(jsonObject.CreateReader(), obj); + + // Store the JSON property names in the object for later comparison + if (obj is PropertyValidator pv) + { + // Capture property names from JSON + var jsonPropertyNames = jsonObject.Properties().Select(p => p.Name).ToList(); + + pv.JsonPropertyNames = jsonPropertyNames; + } + + // POC: cast? throw if null? + return obj as DiscriminatedObject; + } + + // POC: remove, replace with DI + private readonly Dictionary _typeCache = new(); + + private Type? GetTypeByName(string name) + { + _typeCache.TryGetValue(name, out Type myType); + if (myType != null) + { + return myType; + } + + // POC: why does this exist like this? + // The assemblies within the CurrentDomain are not necessarily loaded + // probably we can leverage DI here so we already know the types, possibly DI plus an attribute + // then we can cache everything on startup + foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies().Reverse()) + { + List? types; + + try + { + // POC: contains is weak + // working by accident, ModelCard is contained within SenderModelCard :O + // comparisons :D + var type = assembly.DefinedTypes.FirstOrDefault(t => !string.IsNullOrEmpty(t?.Name) && t?.Name == name); + if (type != null) + { + _typeCache[name] = type; + return type; + } + } + // POC: this Exception pattern is too broad and should be resticted but fixes the above issues + // the call above is causing load of all assemblies (which is also possibly not good) + // AND it explodes for me loading an exception, so at the last this should + // catch System.Reflection.ReflectionTypeLoadException (and anthing else DefinedTypes might throw) + catch (ReflectionTypeLoadException ex) + { + // POC: logging + Debug.WriteLine("***" + ex.Message); + } + } + + // should this throw instead? :/ + return null; + } +} + +public class AbstractConverter : JsonConverter +{ + public override bool CanConvert(Type objectType) => objectType == typeof(TAbstract); + + public override object ReadJson( + JsonReader reader, + Type objectType, + object existingValue, + JsonSerializer serializer + ) => serializer.Deserialize(reader); + + public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) => + serializer.Serialize(writer, value); +} diff --git a/CNX-8892/DUI3/Speckle.Connectors.DUI/Utils/ModelNotFoundException.cs b/CNX-8892/DUI3/Speckle.Connectors.DUI/Utils/ModelNotFoundException.cs new file mode 100644 index 0000000000..742050b6b3 --- /dev/null +++ b/CNX-8892/DUI3/Speckle.Connectors.DUI/Utils/ModelNotFoundException.cs @@ -0,0 +1,16 @@ +// POC: why is SpeckleException in this namespace? :8 +using System; +using Speckle.Core.Logging; + +namespace Speckle.Connectors.DUI.Utils; + +public class ModelNotFoundException : SpeckleException +{ + public ModelNotFoundException(string message) + : base(message) { } + + public ModelNotFoundException(string message, Exception inner) + : base(message, inner) { } + + public ModelNotFoundException() { } +} diff --git a/CNX-8892/DUI3/Speckle.Connectors.DUI/Utils/PropertyValidator.cs b/CNX-8892/DUI3/Speckle.Connectors.DUI/Utils/PropertyValidator.cs new file mode 100644 index 0000000000..b4fd6f1fd8 --- /dev/null +++ b/CNX-8892/DUI3/Speckle.Connectors.DUI/Utils/PropertyValidator.cs @@ -0,0 +1,53 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using Speckle.Newtonsoft.Json; + +namespace Speckle.Connectors.DUI.Utils; + +public class PropertyValidator : DiscriminatedObject +{ + [JsonIgnore] + public List JsonPropertyNames { get; set; } + + public bool InitializeNewProperties() + { + bool isUpdated = false; + var properties = this.GetType().GetProperties(); + + // Create a new instance of the current type to get default values + var defaultInstance = Activator.CreateInstance(this.GetType()); + + foreach (var property in properties) + { + if (property.GetValue(this) == null) + { + // Get the default value from the new instance + var defaultValue = property.GetValue(defaultInstance); + + // Set this default value to the current instance + property.SetValue(this, defaultValue); + isUpdated = true; + } + } + + return isUpdated; // Return true if any property was updated + } + + public bool CheckRemovedProperties() + { + bool removedPropertiesExist = false; + var currentPropertyNames = this.GetType().GetProperties().Select(p => p.Name).ToList(); + + foreach (var jsonPropName in JsonPropertyNames) + { + if (!currentPropertyNames.Contains(jsonPropName)) + { + // This property was in the JSON but not in the class + removedPropertiesExist = true; + } + } + + return removedPropertiesExist; + } +} diff --git a/CNX-8892/Objects/Speckle.Objects.Common/BuiltElements/Floor.cs b/CNX-8892/Objects/Speckle.Objects.Common/BuiltElements/Floor.cs new file mode 100644 index 0000000000..d322d3c5aa --- /dev/null +++ b/CNX-8892/Objects/Speckle.Objects.Common/BuiltElements/Floor.cs @@ -0,0 +1,37 @@ +using System.Collections.Generic; +using Speckle.Core.Kits; +using Speckle.Core.Models; +using Speckle.Objects.Common; +using Speckle.Objects.Geometry; + +namespace Speckle.Objects.BuiltElements; + +public class Floor : Base, IDisplayValue> +{ + public Floor() { } + + [SchemaInfo("Floor", "Creates a Speckle floor", "BIM", "Architecture")] + public Floor( + [SchemaMainParam] ICurve outline, + List? voids = null, + [SchemaParamInfo("Any nested elements that this floor might have")] List? elements = null + ) + { + this.outline = outline; + + this.voids = voids ?? new(); + + this.elements = elements; + } + + public ICurve outline { get; set; } + public List voids { get; set; } = new(); + + [DetachProperty] + public List? elements { get; set; } + public virtual Level? level { get; internal set; } + public string units { get; set; } + + [DetachProperty] + public List displayValue { get; set; } +} diff --git a/CNX-8892/Objects/Speckle.Objects.Common/BuiltElements/Level.cs b/CNX-8892/Objects/Speckle.Objects.Common/BuiltElements/Level.cs new file mode 100644 index 0000000000..d96a7d488a --- /dev/null +++ b/CNX-8892/Objects/Speckle.Objects.Common/BuiltElements/Level.cs @@ -0,0 +1,29 @@ +using Speckle.Core.Kits; +using Speckle.Core.Models; + +namespace Speckle.Objects.BuiltElements; + +public class Level : Base +{ + //public List elements { get; set; } + + public Level() { } + + /// + /// SchemaBuilder constructor for a Speckle level + /// + /// + /// + /// Assign units when using this constructor due to param + [SchemaInfo("Level", "Creates a Speckle level", "BIM", "Architecture")] + public Level(string name, double elevation) + { + this.name = name; + this.elevation = elevation; + } + + public string name { get; set; } + public double elevation { get; set; } + + public string units { get; set; } +} diff --git a/CNX-8892/Objects/Speckle.Objects.Common/Common/EncodingOptimisations.cs b/CNX-8892/Objects/Speckle.Objects.Common/Common/EncodingOptimisations.cs new file mode 100644 index 0000000000..72d6e10caa --- /dev/null +++ b/CNX-8892/Objects/Speckle.Objects.Common/Common/EncodingOptimisations.cs @@ -0,0 +1,103 @@ +using System; +using System.Collections.Generic; +using Speckle.Objects.Geometry; + +namespace Speckle.Objects.Common; + +public static class CurveTypeEncoding +{ + public const double Arc = 0; + public const double Circle = 1; + public const double Curve = 2; + public const double Ellipse = 3; + public const double Line = 4; + public const double Polyline = 5; + public const double PolyCurve = 6; +} + +public static class CurveArrayEncodingExtensions +{ + public static List ToArray(List curves) + { + // POC: eek + var list = new List(); + foreach (var curve in curves) + { + switch (curve) + { + case Arc a: + list.AddRange(a.ToList()); + break; + case Circle c: + list.AddRange(c.ToList()); + break; + case Curve c: + list.AddRange(c.ToList()); + break; + case Ellipse e: + list.AddRange(e.ToList()); + break; + case Line l: + list.AddRange(l.ToList()); + break; + case Polycurve p: + list.AddRange(p.ToList()); + break; + case Polyline p: + list.AddRange(p.ToList()); + break; + default: + throw new Exception($"Unkown curve type: {curve.GetType()}."); + } + } + + return list; + } + + public static List FromArray(List list) + { + var curves = new List(); + if (list.Count == 0) + { + return curves; + } + + var done = false; + var currentIndex = 0; + + while (!done) + { + var itemLength = (int)list[currentIndex]; + var item = list.GetRange(currentIndex, itemLength + 1); + + switch (item[1]) + { + case CurveTypeEncoding.Arc: + curves.Add(Arc.FromList(item)); + break; + case CurveTypeEncoding.Circle: + curves.Add(Circle.FromList(item)); + break; + case CurveTypeEncoding.Curve: + curves.Add(Curve.FromList(item)); + break; + case CurveTypeEncoding.Ellipse: + curves.Add(Ellipse.FromList(item)); + break; + case CurveTypeEncoding.Line: + curves.Add(Line.FromList(item)); + break; + case CurveTypeEncoding.Polyline: + curves.Add(Polyline.FromList(item)); + break; + case CurveTypeEncoding.PolyCurve: + curves.Add(Polycurve.FromList(item)); + break; + } + + currentIndex += itemLength + 1; + done = currentIndex >= list.Count; + } + return curves; + } +} diff --git a/CNX-8892/Objects/Speckle.Objects.Common/Common/IDisplayValue.cs b/CNX-8892/Objects/Speckle.Objects.Common/Common/IDisplayValue.cs new file mode 100644 index 0000000000..c25a36193d --- /dev/null +++ b/CNX-8892/Objects/Speckle.Objects.Common/Common/IDisplayValue.cs @@ -0,0 +1,26 @@ +namespace Speckle.Objects.Common; + +// POC: still accurate? +/// +/// Specifies displayable value(s) to be used as a fallback +/// if a displayable form cannot be converted. +/// +/// +/// objects that represent conceptual / abstract / mathematically derived geometry +/// can use to be used in case the object lacks a natively displayable form. +/// (e.g , , ) +/// +/// +/// Type of display value. +/// Expected to be either a type or a of s, +/// most likely or . +/// +public interface IDisplayValue +{ + /// + /// (s) will be used to display this + /// if a native displayable object cannot be converted. + /// + // POC: Pascal case? Is this for JS benefit? + T displayValue { get; set; } +} diff --git a/CNX-8892/Objects/Speckle.Objects.Common/Geometry/Arc.cs b/CNX-8892/Objects/Speckle.Objects.Common/Geometry/Arc.cs new file mode 100644 index 0000000000..3f35f41ff2 --- /dev/null +++ b/CNX-8892/Objects/Speckle.Objects.Common/Geometry/Arc.cs @@ -0,0 +1,294 @@ +using System; +using System.Collections.Generic; +using Speckle.Core.Kits; +using Speckle.Core.Logging; +using Speckle.Core.Models; +using Speckle.Objects.Common; +using Speckle.Objects.Primitives; +using Speckle.Objects.Utils; + +namespace Speckle.Objects.Geometry; + +/// +/// Represents a sub-curve of a three-dimensional circle. +/// +public class Arc : Base, IHasBoundingBox, ICurve, IHasArea, ITransformable +{ + /// + public Arc() { } + + /// + /// Constructs a new using angle values. + /// + /// The Plane where the arc will be drawn + /// The radius of the Arc + /// The angle formed between the start point and the X Axis of the plane + /// The angle formed between the end point and the X Axis of the plane + /// The total angle of the Arc in Radians + /// The object's units + /// The object's unique application ID + public Arc( + Plane plane, + double radius, + double startAngle, + double endAngle, + double angleRadians, + string units = Units.Meters, + string? applicationId = null + ) + { + this.plane = plane; + this.radius = radius; + this.startAngle = startAngle; + this.endAngle = endAngle; + this.angleRadians = angleRadians; + domain = angleRadians > 0 ? new Interval(0, angleRadians) : new Interval(angleRadians, 0); + this.applicationId = applicationId; + this.units = units; + } + + /// + /// Initialise an `Arc` using the arc angle and the start and end points. + /// The radius, midpoint, start angle, and end angle will be calculated. + /// For now, this assumes 2D arcs on the XY plane + /// + /// The start point of the arc + /// The end point of the arc + /// The arc angle + /// Units (defaults to "m") + /// ID given to the arc in the authoring programme (defaults to null) + public Arc( + Point startPoint, + Point endPoint, + double angleRadians, + string units = Units.Meters, + string? applicationId = null + ) + : this( + new Plane(startPoint, new Vector(0, 0, 1), new Vector(1, 0, 0), new Vector(0, 1, 0), units), + startPoint, + endPoint, + angleRadians, + units, + applicationId + ) { } + + /// + /// Initialise an `Arc` using a plane, the arc angle and the start and end points. + /// The radius, midpoint, start angle, and end angle will be calculated. + /// + /// The Plane where the arc will be drawn + /// The start point of the arc + /// The end point of the arc + /// The arc angle + /// Units (defaults to "m") + /// ID given to the arc in the authoring programme (defaults to null) + public Arc( + Plane plane, + Point startPoint, + Point endPoint, + double angleRadians, + string units = Units.Meters, + string? applicationId = null + ) + { + // don't be annoying + if (angleRadians > Math.PI * 2) + { + throw new SpeckleException("Can't create an arc with an angle greater than 2pi"); + } + + if (startPoint == endPoint) + { + throw new SpeckleException("Can't create an arc where the start and end points are the same"); + } + + this.units = units; + this.startPoint = startPoint; + this.endPoint = endPoint; + this.angleRadians = angleRadians; + domain = angleRadians > 0 ? new Interval(0, angleRadians) : new Interval(angleRadians, 0); + this.applicationId = applicationId; + + // find chord and chord angle which may differ from the arc angle + var chordMidpoint = Point.Midpoint(startPoint, endPoint); + var chordLength = Point.Distance(startPoint, endPoint); + var chordAngle = angleRadians; + if (chordAngle > Math.PI) + { + chordAngle -= Math.PI * 2; + } + else if (chordAngle < -Math.PI) + { + chordAngle += Math.PI * 2; + } + // use the law of cosines for an isosceles triangle to get the radius + radius = chordLength / Math.Sqrt(2 - 2 * Math.Cos(chordAngle)); + + // find the chord vector then calculate the perpendicular vector which points to the centre + // which can be used to find the circle centre point + var dir = chordAngle < 0 ? -1 : 1; + var centreToChord = Math.Sqrt(Math.Pow((double)radius, 2) - Math.Pow(chordLength * 0.5, 2)); + var perp = Vector.CrossProduct(new Vector(endPoint - startPoint), plane.normal); + var circleCentre = chordMidpoint + new Point(perp.Unit() * centreToChord * -dir); + plane.origin = circleCentre; + + // use the perpendicular vector in the other direction (from the centre to the arc) to find the arc midpoint + midPoint = + angleRadians > Math.PI + ? chordMidpoint + new Point(perp.Unit() * ((double)radius + centreToChord) * -dir) + : chordMidpoint + new Point(perp.Unit() * ((double)radius - centreToChord) * dir); + + // find the start angle using trig (correcting for quadrant position) and add the arc angle to get the end angle + startAngle = Math.Tan((startPoint.y - circleCentre.y) / (startPoint.x - circleCentre.x)) % (2 * Math.PI); + if (startPoint.x > circleCentre.x && startPoint.y < circleCentre.y) // Q4 + { + startAngle *= -1; + } + else if (startPoint.x < circleCentre.x && startPoint.y < circleCentre.y) // Q3 + { + startAngle += Math.PI; + } + else if (startPoint.x < circleCentre.x && startPoint.y > circleCentre.y) // Q2 + { + startAngle = Math.PI - startAngle; + } + + endAngle = startAngle + angleRadians; + // Set the plane of this arc + this.plane = plane; + } + + /// + /// The radius of the + /// + public double? radius { get; set; } + + /// + /// The start angle of the based on it's + /// + public double? startAngle { get; set; } + + /// + /// The end angle of the based on it's + /// + public double? endAngle { get; set; } + + /// + /// The inner angle of the + /// + public double angleRadians { get; set; } + + /// + /// Gets or sets the plane of the . The plane origin is the center. + /// + public Plane plane { get; set; } + + /// + /// The start of the + /// + public Point startPoint { get; set; } + + /// + /// Gets or sets the point at 0.5 length. + /// + public Point midPoint { get; set; } + + /// + /// The end of the + /// + public Point endPoint { get; set; } + + /// + /// The units this object was specified in. + /// + public string units { get; set; } + + /// + public Interval domain { get; set; } = new(0, 0); + + /// + public double length { get; set; } + + /// + public double area { get; set; } + + /// + public Box bbox { get; set; } + + /// + public bool TransformTo(Transform transform, out Arc transformed) + { + startPoint.TransformTo(transform, out Point transformedStartPoint); + midPoint.TransformTo(transform, out Point transformedMidpoint); + endPoint.TransformTo(transform, out Point transformedEndPoint); + plane.TransformTo(transform, out Plane pln); + var arc = new Arc(pln, transformedStartPoint, transformedEndPoint, angleRadians, units) + { + midPoint = transformedMidpoint, + domain = domain + }; + transformed = arc; + return true; + } + + /// + public bool TransformTo(Transform transform, out ITransformable transformed) + { + var res = TransformTo(transform, out Arc arc); + transformed = arc; + return res; + } + + /// + /// Creates a flat list with the values of the + /// This is only used for serialisation purposes. + /// + /// A list of numbers representing the 's value + public List ToList() + { + var list = new List(); + list.Add(radius ?? 0); + list.Add(startAngle ?? 0); + list.Add(endAngle ?? 0); + list.Add(angleRadians); + list.Add(domain?.start ?? 0); + list.Add(domain?.end ?? 0); + + list.AddRange(plane.ToList()); + list.AddRange(startPoint.ToList()); + list.AddRange(midPoint.ToList()); + list.AddRange(endPoint.ToList()); + list.Add(Units.GetEncodingFromUnit(units)); + list.Insert(0, CurveTypeEncoding.Arc); + list.Insert(0, list.Count); + return list; + } + + /// + /// Creates a new instance based on a flat list of numerical values. + /// This is only used for deserialisation purposes. + /// + /// The input list should be the result of having called + /// A list of numbers + /// A new with the values assigned from the list. + public static Arc FromList(List list) + { + var arc = new Arc + { + radius = list[2], + startAngle = list[3], + endAngle = list[4], + angleRadians = list[5], + domain = new Interval(list[6], list[7]), + units = Units.GetUnitFromEncoding(list[list.Count - 1]), + plane = Plane.FromList(list.GetRange(8, 13)) + }; + arc.startPoint = Point.FromList(list.GetRange(21, 3), arc.units); + arc.midPoint = Point.FromList(list.GetRange(24, 3), arc.units); + arc.endPoint = Point.FromList(list.GetRange(27, 3), arc.units); + arc.plane.units = arc.units; + + return arc; + } +} diff --git a/CNX-8892/Objects/Speckle.Objects.Common/Geometry/Box.cs b/CNX-8892/Objects/Speckle.Objects.Common/Geometry/Box.cs new file mode 100644 index 0000000000..c6a9ab26b4 --- /dev/null +++ b/CNX-8892/Objects/Speckle.Objects.Common/Geometry/Box.cs @@ -0,0 +1,77 @@ +using Speckle.Core.Kits; +using Speckle.Core.Models; +using Speckle.Objects.Primitives; + +namespace Speckle.Objects.Geometry; + +/// +/// Represents a 3-dimensional box oriented on a plane. +/// +public class Box : Base, IHasVolume, IHasArea, IHasBoundingBox +{ + /// + public Box() { } + + /// + /// Constructs a new instance with a and coordinate intervals for all 3 axis {x , y , z} + /// + /// The plane the box will be oriented by. + /// The range of coordinates (min, max) for the X axis + /// The range of coordinates (min, max) for the Y axis + /// The range of coordinates (min, max) for the Z axis + /// The units the coordinates are in. + /// The unique application ID of the object. + public Box( + Plane basePlane, + Interval xSize, + Interval ySize, + Interval zSize, + string units = Units.Meters, + string? applicationId = null + ) + { + this.basePlane = basePlane; + this.xSize = xSize; + this.ySize = ySize; + this.zSize = zSize; + this.applicationId = applicationId; + this.units = units; + } + + /// + /// Gets or sets the plane that defines the orientation of the + /// + public Plane basePlane { get; set; } + + /// + /// Gets or sets the that defines the min and max coordinate in the X direction + /// + public Interval xSize { get; set; } + + /// + /// Gets or sets the that defines the min and max coordinate in the Y direction + /// + public Interval ySize { get; set; } + + /// + /// Gets or sets the that defines the min and max coordinate in the Y direction + /// + public Interval zSize { get; set; } + + /// + /// The units this object's coordinates are in. + /// + /// + /// This should be one of + /// + public string units { get; set; } + + /// + public double area { get; set; } + + /// + public Box bbox { get; } + + /// + public double volume { get; set; } +} diff --git a/CNX-8892/Objects/Speckle.Objects.Common/Geometry/Circle.cs b/CNX-8892/Objects/Speckle.Objects.Common/Geometry/Circle.cs new file mode 100644 index 0000000000..f728495ec6 --- /dev/null +++ b/CNX-8892/Objects/Speckle.Objects.Common/Geometry/Circle.cs @@ -0,0 +1,99 @@ +using System.Collections.Generic; +using Speckle.Core.Kits; +using Speckle.Core.Models; +using Speckle.Objects.Common; +using Speckle.Objects.Primitives; + +namespace Speckle.Objects.Geometry; + +/// +/// Represents a circular curve based on a base and a as radius. +/// +public class Circle : Base, ICurve, IHasArea, IHasBoundingBox +{ + /// + /// Constructs an empty instance. + /// + public Circle() { } + + /// + /// Constructs a new instance. + /// + /// The plane where the circle lies + /// The radius of the circle + /// The units the circle is modeled in + /// The unique ID of this circle in a specific application + public Circle(Plane plane, double radius, string units = Units.Meters, string? applicationId = null) + { + this.plane = plane; + this.radius = radius; + this.applicationId = applicationId; + this.units = units; + } + + /// + /// The radius of the circle + /// + public double? radius { get; set; } + + /// + /// The the circle lies in. + /// + public Plane plane { get; set; } + + /// + /// The units this object was modeled in. + /// + public string units { get; set; } + + /// + public Interval domain { get; set; } = new(0, 1); + + /// + public double length { get; set; } + + //public Point center { get; set; } + + /// + public double area { get; set; } + + /// + public Box bbox { get; set; } + + /// + /// Returns the coordinates of this as a list of numbers + /// + /// A list of values representing the + public List ToList() + { + var list = new List(); + + list.Add(radius ?? 0); + list.Add(domain?.start ?? 0); + list.Add(domain?.end ?? 1); + list.AddRange(plane.ToList()); + + list.Add(Units.GetEncodingFromUnit(units)); + list.Insert(0, CurveTypeEncoding.Circle); + list.Insert(0, list.Count); + return list; + } + + /// + /// Creates a new based on a list of coordinates and the unit they're drawn in. + /// + /// The list of values representing this + /// A new with the provided values. + public static Circle FromList(List list) + { + var circle = new Circle + { + radius = list[2], + domain = new Interval(list[3], list[4]), + plane = Plane.FromList(list.GetRange(5, 13)), + units = Units.GetUnitFromEncoding(list[list.Count - 1]) + }; + + return circle; + } +} diff --git a/CNX-8892/Objects/Speckle.Objects.Common/Geometry/Curve.cs b/CNX-8892/Objects/Speckle.Objects.Common/Geometry/Curve.cs new file mode 100644 index 0000000000..ce8fc975dc --- /dev/null +++ b/CNX-8892/Objects/Speckle.Objects.Common/Geometry/Curve.cs @@ -0,0 +1,204 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using Speckle.Objects.Primitives; +using Speckle.Core.Kits; +using Speckle.Core.Logging; +using Speckle.Core.Models; +using Speckle.Objects.Common; +using Speckle.Objects.Utils; + +namespace Speckle.Objects.Geometry; + +public class Curve : Base, ICurve, IHasBoundingBox, IHasArea, ITransformable, IDisplayValue +{ + /// + /// Constructs an empty instance. + /// + public Curve() { } + + /// + /// Constructs a new instance based on displayValue a polyline. + /// + /// The polyline that will be this curve's + /// The units this curve is be modelled in + /// The unique ID of this curve in a specific application + public Curve(Polyline poly, string units = Units.Meters, string? applicationId = null) + { + displayValue = poly; + this.applicationId = applicationId; + this.units = units; + } + + public int degree { get; set; } + + public bool periodic { get; set; } + + /// + /// "True" if weights differ, "False" if weights are the same. + /// + public bool rational { get; set; } + + [DetachProperty, Chunkable(31250)] + public List points { get; set; } + + /// + /// Gets or sets the weights for this . Use a default value of 1 for unweighted points. + /// + [DetachProperty, Chunkable(31250)] + public List weights { get; set; } + + /// + /// Gets or sets the knots for this . Count should be equal to count + + 1. + /// + [DetachProperty, Chunkable(31250)] + public List knots { get; set; } + + public bool closed { get; set; } + + /// + /// The units this object was specified in. + /// + public string units { get; set; } + + /// + public Interval domain { get; set; } = new Interval(0, 1); + + /// + public double length { get; set; } + + /// + [DetachProperty] + public Polyline displayValue { get; set; } + + /// + public double area { get; set; } + + /// + public Box bbox { get; set; } + + /// + public bool TransformTo(Transform transform, out Curve transformed) + { + // transform points + var transformedPoints = new List(); + foreach (var point in GetPoints()) + { + point.TransformTo(transform, out Point transformedPoint); + transformedPoints.Add(transformedPoint); + } + + var result = displayValue.TransformTo(transform, out ITransformable polyline); + transformed = new Curve + { + degree = degree, + periodic = periodic, + rational = rational, + points = transformedPoints.SelectMany(o => o.ToList()).ToList(), + weights = weights, + knots = knots, + displayValue = (Polyline)polyline, + closed = closed, + units = units, + applicationId = applicationId, + domain = domain != null ? new Interval { start = domain.start, end = domain.end } : new Interval(0, 1) + }; + + return result; + } + + /// + public bool TransformTo(Transform transform, out ITransformable transformed) + { + var res = TransformTo(transform, out Curve curve); + transformed = curve; + return res; + } + + /// as list of s + /// when list is malformed + public List GetPoints() + { + if (points.Count % 3 != 0) + { + throw new SpeckleException( + $"{nameof(Curve)}.{nameof(points)} list is malformed: expected length to be multiple of 3" + ); + } + + var pts = new List(points.Count / 3); + for (int i = 2; i < points.Count; i += 3) + { + pts.Add(new Point(points[i - 2], points[i - 1], points[i], units)); + } + + return pts; + } + + /// + /// Returns the values of this as a list of numbers + /// + /// A list of values representing the + public List ToList() + { + var list = new List(); + var curve = this; + list.Add(curve.degree); // 0 + list.Add(curve.periodic ? 1 : 0); // 1 + list.Add(curve.rational ? 1 : 0); // 2 + list.Add(curve.closed ? 1 : 0); // 3 + list.Add(curve.domain?.start ?? 0); // 4 + list.Add(curve.domain?.end ?? 1); // 5 + + list.Add(curve.points.Count); // 6 + list.Add(curve.weights.Count); // 7 + list.Add(curve.knots.Count); // 8 + + list.AddRange(curve.points); // 9 onwards + list.AddRange(curve.weights); + list.AddRange(curve.knots); + + list.Add(Units.GetEncodingFromUnit(units)); + list.Insert(0, CurveTypeEncoding.Curve); + list.Insert(0, list.Count); + return list; + } + + /// + /// Creates a new based on a list of coordinates and the unit they're drawn in. + /// + /// The list of values representing this + /// A new with the provided values. + public static Curve FromList(List list) + { + if (list[0] != list.Count - 1) + { + throw new Exception($"Incorrect length. Expected {list[0]}, got {list.Count}."); + } + + if (list[1] != CurveTypeEncoding.Curve) + { + throw new Exception($"Wrong curve type. Expected {CurveTypeEncoding.Curve}, got {list[1]}."); + } + + var curve = new Curve + { + degree = (int)list[2], + periodic = list[3] == 1, + rational = list[4] == 1, + closed = list[5] == 1, + domain = new Interval(list[6], list[7]) + }; + + var pointsCount = (int)list[8]; + var weightsCount = (int)list[9]; + var knotsCount = (int)list[10]; + + curve.points = list.GetRange(11, pointsCount); + curve.weights = list.GetRange(11 + pointsCount, weightsCount); + curve.knots = list.GetRange(11 + pointsCount + weightsCount, knotsCount); + + curve.units = Units.GetUnitFromEncoding(list[list.Count - 1]); + return curve; + } +} diff --git a/CNX-8892/Objects/Speckle.Objects.Common/Geometry/Ellipse.cs b/CNX-8892/Objects/Speckle.Objects.Common/Geometry/Ellipse.cs new file mode 100644 index 0000000000..29b84e5505 --- /dev/null +++ b/CNX-8892/Objects/Speckle.Objects.Common/Geometry/Ellipse.cs @@ -0,0 +1,122 @@ +using System.Collections.Generic; +using Speckle.Core.Kits; +using Speckle.Core.Models; +using Speckle.Objects.Common; +using Speckle.Objects.Primitives; + +namespace Speckle.Objects.Geometry; + +public class Ellipse : Base, ICurve, IHasArea +{ + /// + /// Initializes a new instance of the class. + /// This constructor is only intended for serialization/deserialization purposes. + /// Use other constructors to manually create ellipses. + /// + public Ellipse() { } + + /// + /// Initializes a new instance of the class. + /// + /// The plane to draw the ellipse in. + /// First radius of the ellipse. + /// Second radius of the ellipse. + /// Application ID, defaults to null. + public Ellipse(Plane plane, double radius1, double radius2, string units = Units.Meters, string? applicationId = null) + : this(plane, radius1, radius2, new Interval(0, 1), null, units) { } + + /// + /// Initializes a new instance of the class. + /// + /// The plane to draw the ellipse in. + /// First radius of the ellipse. + /// Second radius of the ellipse. + /// The curve's internal parametrization domain. + /// The domain to trim the curve with. Will be null if the ellipse is not trimmed. + /// Application ID, defaults to null. + public Ellipse( + Plane plane, + double radius1, + double radius2, + Interval domain, + Interval? trimDomain, + string units = Units.Meters, + string? applicationId = null + ) + { + this.plane = plane; + firstRadius = radius1; + secondRadius = radius2; + this.domain = domain; + this.trimDomain = trimDomain; + this.applicationId = applicationId; + this.units = units; + } + + /// + /// Gets or sets the first radius of the . This is usually the major radius. + /// + public double? firstRadius { get; set; } + + /// + /// Gets or sets the second radius of the . This is usually the minor radius. + /// + public double? secondRadius { get; set; } + + /// + /// Gets or sets the plane to draw this ellipse in. + /// + public Plane plane { get; set; } + + /// + /// Gets or set the domain interval to trim this with. + /// + public Interval? trimDomain { get; set; } + + /// + public Box bbox { get; set; } + + public string units { get; set; } + + /// + /// Gets or sets the domain interval for this . + /// + public Interval domain { get; set; } = new(0, 0); + + /// + public double length { get; set; } + + //public Point center { get; set; } + + /// + public double area { get; set; } + + public List ToList() + { + var list = new List(); + list.Add(firstRadius ?? 0); + list.Add(secondRadius ?? 0); + list.Add(domain?.start ?? 0); + list.Add(domain?.end ?? 0); + + list.AddRange(plane.ToList()); + + list.Add(Units.GetEncodingFromUnit(units)); + list.Insert(0, CurveTypeEncoding.Ellipse); + list.Insert(0, list.Count); + return list; + } + + public static Ellipse FromList(List list) + { + var ellipse = new Ellipse + { + firstRadius = list[2], + secondRadius = list[3], + domain = new Interval(list[4], list[5]), + plane = Plane.FromList(list.GetRange(6, 13)), + units = Units.GetUnitFromEncoding(list[list.Count - 1]) + }; + return ellipse; + } +} diff --git a/CNX-8892/Objects/Speckle.Objects.Common/Geometry/Interfaces.cs b/CNX-8892/Objects/Speckle.Objects.Common/Geometry/Interfaces.cs new file mode 100644 index 0000000000..f1f771e896 --- /dev/null +++ b/CNX-8892/Objects/Speckle.Objects.Common/Geometry/Interfaces.cs @@ -0,0 +1,79 @@ +using Speckle.Core.Models; +using Speckle.Objects.Primitives; +using Speckle.Objects.Utils; + +namespace Speckle.Objects.Geometry; + +/// +/// Represents an object that has a +/// +public interface IHasBoundingBox +{ + /// + /// The bounding box containing the object. + /// + Box bbox { get; } +} + +/// +/// Represents a object that has +/// +public interface IHasArea +{ + /// + /// The area of the object + /// + double area { get; set; } +} + +/// +/// Represents an object that has +/// +public interface IHasVolume +{ + /// + /// The volume of the object + /// + double volume { get; set; } +} + +/// +/// Represents +/// +public interface ICurve +{ + /// + /// The length of the curve. + /// + double length { get; set; } + + /// + /// The numerical domain driving the curve's internal parametrization. + /// + Interval domain { get; set; } +} + +/// +/// Generic Interface for transformable objects. +/// +/// The type of object to support transformations. +public interface ITransformable : ITransformable + where T : ITransformable +{ + /// + bool TransformTo(Transform transform, out T transformed); +} + +/// +/// Interface for transformable objects where the type may not be known on convert (eg ICurve implementations) +/// +public interface ITransformable +{ + /// + /// Returns a copy of the object with it's coordinates transformed by the provided + /// + /// The to be applied. + /// The transformed copy of the object. + /// True if the transform operation was successful, false otherwise. + bool TransformTo(Transform transform, out ITransformable transformed); +} diff --git a/CNX-8892/Objects/Speckle.Objects.Common/Geometry/Line.cs b/CNX-8892/Objects/Speckle.Objects.Common/Geometry/Line.cs new file mode 100644 index 0000000000..ccd63ebcc5 --- /dev/null +++ b/CNX-8892/Objects/Speckle.Objects.Common/Geometry/Line.cs @@ -0,0 +1,134 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using Speckle.Core.Kits; +using Speckle.Core.Logging; +using Speckle.Core.Models; +using Speckle.Newtonsoft.Json; +using Speckle.Objects.Common; +using Speckle.Objects.Primitives; +using Speckle.Objects.Utils; + +namespace Speckle.Objects.Geometry; + +public class Line : Base, ICurve, IHasBoundingBox, ITransformable +{ + public Line() { } + + [Obsolete("Line should not use a constructor that only sets the start point. Deprecated in 2.18.", true)] + public Line(double x, double y, double z = 0, string units = Units.Meters, string? applicationId = null) + { + start = new Point(x, y, z); +#pragma warning disable CS8625 // Cannot convert null literal to non-nullable reference type. Reason: Obsolete. + end = null; +#pragma warning restore CS8625 // Cannot convert null literal to non-nullable reference type. Reason: Obsolete. + this.applicationId = applicationId; + this.units = units; + } + + public Line(Point start, Point end, string units = Units.Meters, string? applicationId = null) + { + this.start = start; + this.end = end; + length = Point.Distance(start, end); + this.applicationId = applicationId; + this.units = units; + } + + public Line(IList coordinates, string units = Units.Meters, string? applicationId = null) + { + if (coordinates.Count < 6) + { + throw new SpeckleException("Line from coordinate array requires 6 coordinates."); + } + + start = new Point(coordinates[0], coordinates[1], coordinates[2], units, applicationId); + end = new Point(coordinates[3], coordinates[4], coordinates[5], units, applicationId); + length = Point.Distance(start, end); + this.applicationId = applicationId; + this.units = units; + } + + [Obsolete("Use IList constructor", true)] + public Line(IEnumerable coordinatesArray, string units = Units.Meters, string? applicationId = null) + : this(coordinatesArray.ToList(), units, applicationId) { } + + /// + /// OBSOLETE - This is just here for backwards compatibility. + /// You should not use this for anything. Access coordinates using start and end point. + /// + + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public List value + { +#pragma warning disable CS8603 // Possible null reference return. Reason: Obsolete. + get => null; +#pragma warning restore CS8603 // Possible null reference return. Reason: Obsolete. + set + { + if (value == null) + { + return; + } + + start = new Point(value[0], value[1], value[2]); + end = new Point(value[3], value[4], value[5]); + } + } + + public double area { get; set; } + + public string units { get; set; } + + public Point start { get; set; } + public Point end { get; set; } + + public Interval domain { get; set; } = new(0, 1); + public double length { get; set; } + + public Box bbox { get; set; } + + public bool TransformTo(Transform transform, out Line transformed) + { + start.TransformTo(transform, out Point transformedStart); + end.TransformTo(transform, out Point transformedEnd); + transformed = new Line + { + start = transformedStart, + end = transformedEnd, + applicationId = applicationId, + units = units, + domain = domain is null ? new(0, 1) : new() { start = domain.start, end = domain.end } + }; + return true; + } + + public bool TransformTo(Transform transform, out ITransformable transformed) + { + var res = TransformTo(transform, out Line line); + transformed = line; + return res; + } + + public List ToList() + { + var list = new List(); + list.AddRange(start.ToList()); + list.AddRange(end.ToList()); + list.Add(domain?.start ?? 0); + list.Add(domain?.end ?? 1); + list.Add(Units.GetEncodingFromUnit(units)); + list.Insert(0, CurveTypeEncoding.Line); + list.Insert(0, list.Count); + return list; + } + + public static Line FromList(List list) + { + var units = Units.GetUnitFromEncoding(list[list.Count - 1]); + var startPt = new Point(list[2], list[3], list[4], units); + var endPt = new Point(list[5], list[6], list[7], units); + var line = new Line(startPt, endPt, units) { domain = new Interval(list[8], list[9]) }; + return line; + } +} diff --git a/CNX-8892/Objects/Speckle.Objects.Common/Geometry/Mesh.cs b/CNX-8892/Objects/Speckle.Objects.Common/Geometry/Mesh.cs new file mode 100644 index 0000000000..111a27e937 --- /dev/null +++ b/CNX-8892/Objects/Speckle.Objects.Common/Geometry/Mesh.cs @@ -0,0 +1,254 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using Speckle.Core.Kits; +using Speckle.Core.Logging; +using Speckle.Core.Models; +using Speckle.Newtonsoft.Json; +using Speckle.Objects.Utils; + +namespace Speckle.Objects.Geometry; + +public class Mesh : Base, IHasBoundingBox, IHasVolume, IHasArea, ITransformable +{ + public Mesh() { } + + /// + /// Constructs a new mesh from it's raw values. + /// + /// + /// + /// + /// + /// + /// + public Mesh( + List vertices, + List faces, + List? colors = null, + List? texture_coords = null, + string units = Units.Meters, + string? applicationId = null + ) + { + this.vertices = vertices; + this.faces = faces; + this.colors = colors ?? this.colors; + textureCoordinates = texture_coords ?? textureCoordinates; + this.applicationId = applicationId; + this.units = units; + } + + [Obsolete("Use lists constructor", true)] + public Mesh( + double[] vertices, + int[] faces, + int[]? colors = null, + double[]? texture_coords = null, + string units = Units.Meters, + string? applicationId = null + ) + : this( + vertices.ToList(), + faces.ToList(), + colors?.ToList() ?? new(), + texture_coords?.ToList() ?? new(), + units, + applicationId + ) { } + + [DetachProperty, Chunkable(31250)] + public List vertices { get; set; } = new(); + + [DetachProperty, Chunkable(62500)] + public List faces { get; set; } = new(); + + /// Vertex colors as ARGB s + [DetachProperty, Chunkable(62500)] + public List colors { get; set; } = new(); + + [DetachProperty, Chunkable(31250)] + public List textureCoordinates { get; set; } = new(); + + /// + /// The unit's this is in. + /// This should be one of + /// + public string units { get; set; } = Units.None; + + /// + public double area { get; set; } + + /// + public Box bbox { get; set; } + + /// + public double volume { get; set; } + + /// + public bool Transform(Transform transform) + { + // transform vertices + vertices = GetPoints() + .SelectMany(vertex => + { + vertex.TransformTo(transform, out Point transformedVertex); + return transformedVertex.ToList(); + }) + .ToList(); + + return true; + } + + /// + public bool TransformTo(Transform transform, out Mesh transformed) + { + // transform vertices + var transformedVertices = new List(); + foreach (var vertex in GetPoints()) + { + vertex.TransformTo(transform, out Point transformedVertex); + transformedVertices.Add(transformedVertex); + } + + transformed = new Mesh + { + vertices = transformedVertices.SelectMany(o => o.ToList()).ToList(), + textureCoordinates = textureCoordinates, + applicationId = applicationId ?? id, + faces = faces, + colors = colors, + units = units + }; + transformed["renderMaterial"] = this["renderMaterial"]; + + return true; + } + + /// + public bool TransformTo(Transform transform, out ITransformable transformed) + { + var res = TransformTo(transform, out Mesh brep); + transformed = brep; + return res; + } + + #region Convenience Methods + + [JsonIgnore] + public int VerticesCount => vertices.Count / 3; + + [JsonIgnore] + public int TextureCoordinatesCount => textureCoordinates.Count / 2; + + /// + /// Gets a vertex as a by + /// + /// The index of the vertex + /// Vertex as a + public Point GetPoint(int index) + { + index *= 3; + return new Point(vertices[index], vertices[index + 1], vertices[index + 2], units, applicationId); + } + + /// as list of s + /// when list is malformed + public List GetPoints() + { + if (vertices.Count % 3 != 0) + { + throw new SpeckleException( + $"{nameof(Mesh)}.{nameof(vertices)} list is malformed: expected length to be multiple of 3" + ); + } + + var pts = new List(vertices.Count / 3); + for (int i = 2; i < vertices.Count; i += 3) + { + pts.Add(new Point(vertices[i - 2], vertices[i - 1], vertices[i], units)); + } + + return pts; + } + + /// + /// Gets a texture coordinate as a by + /// + /// The index of the texture coordinate + /// Texture coordinate as a + public (double, double) GetTextureCoordinate(int index) + { + index *= 2; + return (textureCoordinates[index], textureCoordinates[index + 1]); + } + + /// + /// If not already so, this method will align + /// such that a vertex and its corresponding texture coordinates have the same index. + /// This alignment is what is expected by most applications.
+ ///
+ /// + /// If the calling application expects + /// vertices.count == textureCoordinates.count + /// Then this method should be called by the MeshToNative method before parsing and + /// to ensure compatibility with geometry originating from applications that map to using vertex instance index (rather than vertex index) + ///
+ /// , , and lists will be modified to contain no shared vertices (vertices shared between polygons) + ///
+ public void AlignVerticesWithTexCoordsByIndex() + { + if (textureCoordinates.Count == 0) + { + return; + } + + if (TextureCoordinatesCount == VerticesCount) + { + return; //Tex-coords already aligned as expected + } + + var facesUnique = new List(faces.Count); + var verticesUnique = new List(TextureCoordinatesCount * 3); + bool hasColors = colors.Count > 0; + var colorsUnique = hasColors ? new List(TextureCoordinatesCount) : null; + + int nIndex = 0; + while (nIndex < faces.Count) + { + int n = faces[nIndex]; + if (n < 3) + { + n += 3; // 0 -> 3, 1 -> 4 + } + + if (nIndex + n >= faces.Count) + { + break; //Malformed face list + } + + facesUnique.Add(n); + for (int i = 1; i <= n; i++) + { + int vertIndex = faces[nIndex + i]; + int newVertIndex = verticesUnique.Count / 3; + + var (x, y, z) = GetPoint(vertIndex); + verticesUnique.Add(x); + verticesUnique.Add(y); + verticesUnique.Add(z); + + colorsUnique?.Add(colors[vertIndex]); + facesUnique.Add(newVertIndex); + } + + nIndex += n + 1; + } + + vertices = verticesUnique; + colors = colorsUnique ?? colors; + faces = facesUnique; + } + + #endregion +} diff --git a/CNX-8892/Objects/Speckle.Objects.Common/Geometry/Plane.cs b/CNX-8892/Objects/Speckle.Objects.Common/Geometry/Plane.cs new file mode 100644 index 0000000000..4c92be25e1 --- /dev/null +++ b/CNX-8892/Objects/Speckle.Objects.Common/Geometry/Plane.cs @@ -0,0 +1,133 @@ +using System.Collections.Generic; +using Speckle.Core.Kits; +using Speckle.Core.Models; +using Speckle.Objects.Utils; + +namespace Speckle.Objects.Geometry; + +/// +/// A 3-dimensional Plane consisting of an origin , and 3 as it's X, Y and Z axis. +/// +public class Plane : Base, ITransformable +{ + /// + /// Constructs an empty + /// + public Plane() { } + + /// + /// Constructs a new given it's individual values. + /// + /// The point to be used as origin + /// The vector to be used as Z axis + /// The vector to be used as the X axis + /// The vector to be used as the Y axis + /// The units the coordinates are in. + /// The unique ID of this polyline in a specific application + public Plane( + Point origin, + Vector normal, + Vector xDir, + Vector yDir, + string units = Units.Meters, + string? applicationId = null + ) + { + this.origin = origin; + this.normal = normal; + xdir = xDir; + ydir = yDir; + this.applicationId = applicationId; + this.units = units; + } + + /// + /// The s origin point. + /// + public Point origin { get; set; } + + /// + /// The s Z axis. + /// + public Vector normal { get; set; } + + /// + /// The s X axis. + /// + public Vector xdir { get; set; } + + /// + /// The s Y axis. + /// + public Vector ydir { get; set; } + + /// + /// The unit's this is in. + /// This should be one of + /// + public string units { get; set; } + + /// + public bool TransformTo(Transform transform, out Plane transformed) + { + origin.TransformTo(transform, out Point transformedOrigin); + normal.TransformTo(transform, out Vector transformedNormal); + xdir.TransformTo(transform, out Vector transformedXdir); + ydir.TransformTo(transform, out Vector transformedYdir); + transformed = new Plane + { + origin = transformedOrigin, + normal = transformedNormal, + xdir = transformedXdir, + ydir = transformedYdir, + applicationId = applicationId, + units = units + }; + + return true; + } + + /// + public bool TransformTo(Transform transform, out ITransformable transformed) + { + var res = TransformTo(transform, out Plane plane); + transformed = plane; + return res; + } + + /// + /// Returns the values of this as a list of numbers + /// + /// A list of values representing the Plane. + + public List ToList() + { + var list = new List(); + + list.AddRange(origin.ToList()); + list.AddRange(normal.ToList()); + list.AddRange(xdir.ToList()); + list.AddRange(ydir.ToList()); + list.Add(Units.GetEncodingFromUnit(units)); + + return list; + } + + /// + /// Creates a new based on a list of values and the unit they're drawn in. + /// + /// The list of values representing this plane + /// A new with the provided values. + public static Plane FromList(List list) + { + var plane = new Plane(); + + var units = Units.GetUnitFromEncoding(list[list.Count - 1]); + plane.origin = new Point(list[0], list[1], list[2], units); + plane.normal = new Vector(list[3], list[4], list[5], units); + plane.xdir = new Vector(list[6], list[7], list[8], units); + plane.ydir = new Vector(list[9], list[10], list[11], units); + + return plane; + } +} diff --git a/CNX-8892/Objects/Speckle.Objects.Common/Geometry/Point.cs b/CNX-8892/Objects/Speckle.Objects.Common/Geometry/Point.cs new file mode 100644 index 0000000000..ed5a5b4b2e --- /dev/null +++ b/CNX-8892/Objects/Speckle.Objects.Common/Geometry/Point.cs @@ -0,0 +1,242 @@ +using System; +using System.Collections.Generic; +using Speckle.Core.Kits; +using Speckle.Core.Models; +using Speckle.Newtonsoft.Json; +using Speckle.Objects.Utils; + +namespace Speckle.Objects.Geometry; + +/// +/// A 3-dimensional point +/// +/// +/// TODO: The Point class does not override the Equality operator, which means that there may be cases where `Equals` is used instead of `==`, as the comparison will be done by reference, not value. +/// +public class Point : Base, ITransformable +{ + /// + public Point() { } + + /// + /// Constructs a new from a set of coordinates and it's units. + /// + /// The x coordinate + /// The y coordinate + /// The z coordinate + /// The units of the point's coordinates. Defaults to Meters. + /// The object's unique application ID + public Point(double x, double y, double z = 0d, string units = Units.Meters, string? applicationId = null) + { + this.x = x; + this.y = y; + this.z = z; + this.applicationId = applicationId; + this.units = units; + } + + /// + /// Constructs a new from a + /// + /// The Vector whose coordinates will be used for the Point + public Point(Vector vector) + : this(vector.x, vector.y, vector.z, vector.units, vector.applicationId) { } + + /// + /// Gets or sets the coordinates of the + /// + [JsonProperty(NullValueHandling = NullValueHandling.Ignore), Obsolete("Use x,y,z properties instead", true)] + public List value + { + get => null!; + set + { + x = value[0]; + y = value[1]; + z = value.Count > 2 ? value[2] : 0; + } + } + + /// + /// The x coordinate of the point. + /// + public double x { get; set; } + + /// + /// The y coordinate of the point. + /// + public double y { get; set; } + + /// + /// The z coordinate of the point. + /// + public double z { get; set; } + + /// + /// The units this is in. + /// This should be one of the units specified in + /// + public string units { get; set; } = Units.None; + + [JsonIgnore, Obsolete("Bounding box no longer applicable to point as of 2.18", true)] + public Box? bbox { get; set; } + + /// + public bool TransformTo(Transform transform, out Point transformed) + { + var matrix = transform.matrix; + + var unitFactor = Units.GetConversionFactor(transform.units, units); // applied to translation vector + var divisor = matrix.M41 + matrix.M42 + matrix.M43 + unitFactor * matrix.M44; + var x = (this.x * matrix.M11 + this.y * matrix.M12 + this.z * matrix.M13 + unitFactor * matrix.M14) / divisor; + var y = (this.x * matrix.M21 + this.y * matrix.M22 + this.z * matrix.M23 + unitFactor * matrix.M24) / divisor; + var z = (this.x * matrix.M31 + this.y * matrix.M32 + this.z * matrix.M33 + unitFactor * matrix.M34) / divisor; + + transformed = new Point(x, y, z) { units = units, applicationId = applicationId }; + return true; + } + + /// + public bool TransformTo(Transform transform, out ITransformable transformed) + { + var res = TransformTo(transform, out Point pt); + transformed = pt; + return res; + } + + /// + /// Returns the coordinates of this as a list of numbers + /// + /// A list of coordinates {x, y, z} + public List ToList() + { + return new List { x, y, z }; + } + + /// + /// Creates a new based on a list of coordinates and the unit they're drawn in. + /// + /// The list of coordinates {x, y, z} + /// The units the coordinates are in + /// A new with the provided coordinates. + public static Point FromList(IList list, string units) + { + return new Point(list[0], list[1], list[2], units); + } + + /// + /// Deconstructs a into it's coordinates and units + /// + /// The x coordinate + /// The y coordinate + /// The z coordinate + /// The units the point's coordinates are in. + public void Deconstruct(out double x, out double y, out double z, out string? units) + { + Deconstruct(out x, out y, out z); + units = this.units; + } + + /// + /// Deconstructs a into it's coordinates and units + /// + /// The x coordinate + /// The y coordinate + /// The z coordinate + public void Deconstruct(out double x, out double y, out double z) + { + x = this.x; + y = this.y; + z = this.z; + } + + public static Point operator +(Point point1, Point point2) => + new(point1.x + point2.x, point1.y + point2.y, point1.z + point2.z, point1.units); + + public static Point operator -(Point point1, Point point2) => + new(point1.x - point2.x, point1.y - point2.y, point1.z - point2.z, point1.units); + + public static Point operator *(Point point1, Point point2) => + new(point1.x * point2.x, point1.y * point2.y, point1.z * point2.z, point1.units); + + public static Point operator *(Point point, double val) => + new(point.x * val, point.y * val, point.z * val, point.units); + + public static Point operator /(Point point, double val) => + new(point.x / val, point.y / val, point.z / val, point.units); + + public static bool operator ==(Point? point1, Point? point2) + { + if (point1 is null && point2 is null) + { + return true; + } + else if (point1 is null || point2 is null) + { + return false; + } + + return point1.units == point2.units && point1.x == point2.x && point1.y == point2.y && point1.z == point2.z; + } + + public static bool operator !=(Point? point1, Point? point2) => !(point1 == point2); + + /// + /// Computes a point equidistant from two points. + /// + /// First point. + /// Second point. + /// A point at the same distance from and + public static Point Midpoint(Point point1, Point point2) + { + return new Point( + 0.5 * (point1.x + point2.x), + 0.5 * (point1.y + point2.y), + 0.5 * (point1.z + point2.z), + point1.units + ); + } + + /// + /// Computes the distance between two points + /// + /// First point. + /// Second point. + /// The distance from to + public static double Distance(Point point1, Point point2) + { + return Math.Sqrt( + Math.Pow(point1.x - point2.x, 2) + Math.Pow(point1.y - point2.y, 2) + Math.Pow(point1.z - point2.z, 2) + ); + } + + /// + /// Computes the distance between two points. + /// + /// point for distance measurement + /// The length of the line between this and the other point + public double DistanceTo(Point point) + { + return Math.Sqrt(Math.Pow(x - point.x, 2) + Math.Pow(y - point.y, 2) + Math.Pow(z - point.z, 2)); + } + + public static Point Add(Point left, Point right) + { + throw new NotImplementedException(); + } + + public override bool Equals(object obj) + { + if (ReferenceEquals(this, obj)) + { + return true; + } + + if (ReferenceEquals(obj, null)) + { + return false; + } + + throw new NotImplementedException(); + } +} diff --git a/CNX-8892/Objects/Speckle.Objects.Common/Geometry/Polycurve.cs b/CNX-8892/Objects/Speckle.Objects.Common/Geometry/Polycurve.cs new file mode 100644 index 0000000000..0e143ccbab --- /dev/null +++ b/CNX-8892/Objects/Speckle.Objects.Common/Geometry/Polycurve.cs @@ -0,0 +1,167 @@ +using System; +using System.Collections.Generic; +using Speckle.Core.Kits; +using Speckle.Core.Models; +using Speckle.Objects.Common; +using Speckle.Objects.Primitives; +using Speckle.Objects.Utils; + +namespace Speckle.Objects.Geometry; + +/// +/// A curve that is comprised of multiple curves connected. +/// +public class Polycurve : Base, ICurve, IHasArea, IHasBoundingBox, ITransformable +{ + /// + /// Constructs a new empty instance. + /// + public Polycurve() { } + + /// + /// Constructs a new empty with defined units and unique application ID. + /// + /// The units the Polycurve was modelled in. + /// The unique ID of this polyline in a specific application + public Polycurve(string units = Units.Meters, string? applicationId = null) + { + this.applicationId = applicationId; + this.units = units; + } + + /// + /// Gets or sets the list of segments that comprise this + /// + public List segments { get; set; } = new(); + + /// + /// Gets or sets a Boolean value indicating if the is closed + /// (i.e. The start point of the first segment and the end point of the last segment coincide.) + /// + public bool closed { get; set; } + + /// + /// The unit's this is in. + /// This should be one of + /// + public string units { get; set; } + + /// + /// The internal domain of this curve. + /// + public Interval domain { get; set; } = new(0, 1); + + /// + public double length { get; set; } + + /// + public double area { get; set; } + + /// + public Box bbox { get; set; } + + /// + public bool TransformTo(Transform transform, out ITransformable polycurve) + { + // transform segments + var success = true; + var transformed = new List(); + foreach (var curve in segments) + { + if (curve is ITransformable c) + { + c.TransformTo(transform, out ITransformable tc); + transformed.Add((ICurve)tc); + } + else + { + success = false; + } + } + + polycurve = new Polycurve + { + segments = transformed, + applicationId = applicationId, + closed = closed, + units = units + }; + + return success; + } + + /// + /// Constructs a new instance from an existing curve. + /// + /// The polyline to be used when constructing the + /// A with the same shape as the provided polyline. + public static implicit operator Polycurve(Polyline polyline) + { + Polycurve polycurve = + new() + { + units = polyline.units, + area = polyline.area, + domain = polyline.domain, + closed = polyline.closed, + bbox = polyline.bbox, + length = polyline.length + }; + + var points = polyline.GetPoints(); + for (var i = 0; i < points.Count - 1; i++) + { + var line = new Line(points[i], points[i + 1], polyline.units); + polycurve.segments.Add(line); + } + if (polyline.closed) + { + var line = new Line(points[points.Count - 1], points[0], polyline.units); + polycurve.segments.Add(line); + } + + return polycurve; + } + + /// + /// Returns the values of this as a list of numbers + /// + /// A list of values representing the polycurve. + public List ToList() + { + var list = new List(); + list.Add(closed ? 1 : 0); + list.Add(domain?.start ?? 0); + list.Add(domain?.end ?? 1); + + var crvs = CurveArrayEncodingExtensions.ToArray(segments); + list.Add(crvs.Count); + list.AddRange(crvs); + + list.Add(Units.GetEncodingFromUnit(units)); + list.Insert(0, CurveTypeEncoding.PolyCurve); + list.Insert(0, list.Count); + + return list; + } + + /// + /// Creates a new based on a list of coordinates and the unit they're drawn in. + /// + /// The list of values representing this polycurve + /// A new with the provided values. + public static Polycurve FromList(List list) + { + var polycurve = new Polycurve { closed = list[2] == 1, domain = new Interval(list[3], list[4]) }; + + var temp = list.GetRange(6, (int)list[5]); + polycurve.segments = CurveArrayEncodingExtensions.FromArray(temp); + polycurve.units = Units.GetUnitFromEncoding(list[list.Count - 1]); + return polycurve; + } + + public Polycurve ToPolycurve() + { + throw new NotImplementedException(); + } +} diff --git a/CNX-8892/Objects/Speckle.Objects.Common/Geometry/Polyline.cs b/CNX-8892/Objects/Speckle.Objects.Common/Geometry/Polyline.cs new file mode 100644 index 0000000000..7640b1ffde --- /dev/null +++ b/CNX-8892/Objects/Speckle.Objects.Common/Geometry/Polyline.cs @@ -0,0 +1,267 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using Speckle.Core.Kits; +using Speckle.Core.Logging; +using Speckle.Core.Models; +using Speckle.Newtonsoft.Json; +using Speckle.Objects.Common; +using Speckle.Objects.Primitives; +using Speckle.Objects.Utils; + +namespace Speckle.Objects.Geometry; + +/// +/// A polyline curve, defined by a set of vertices. +/// +public class Polyline : Base, ICurve, IHasArea, IHasBoundingBox, IConvertible, ITransformable +{ + /// + /// Constructs an empty + /// + public Polyline() { } + + /// + /// Constructs a new instance from a flat list of coordinates. + /// + /// The array of 3-dimensional coordinates [x1,y1,z1,x2,y2,... + /// The units the coordinates are in. + /// The unique ID of this polyline in a specific application + [Obsolete("Use list constructor instead", true)] + public Polyline(IEnumerable coordinatesArray, string units = Units.Meters, string? applicationId = null) + : this(coordinatesArray.ToList(), units, applicationId) { } + + /// + /// Constructs a new instance from a flat list of coordinates. + /// + /// The list of 3-dimensional coordinates [x1,y1,z1,x2,y2,... + /// The units the coordinates are in. + /// The unique ID of this polyline in a specific application + public Polyline(List coordinates, string units = Units.Meters, string? applicationId = null) + { + value = coordinates; + this.units = units; + this.applicationId = applicationId; + } + + /// + /// Gets or sets the raw coordinates that define this polyline. Use GetPoints instead to access this data as instances instead. + /// + [DetachProperty, Chunkable(31250)] + public List value { get; set; } = new(); + + /// + /// If true, do not add the last point to the value list. Polyline first and last points should be unique. + /// + public bool closed { get; set; } + + /// + /// The unit's this is in. + /// This should be one of + /// + public string units { get; set; } + + /// + /// Gets the list of points representing the vertices of this polyline. + /// + [JsonIgnore, Obsolete("Use " + nameof(GetPoints) + " Instead", true)] + public List points => GetPoints(); + + /// + public object ToType(Type conversionType, IFormatProvider provider) + { + if (conversionType == typeof(Polycurve)) + { + return (Polycurve)this; + } + + throw new InvalidCastException(); + } + + /// + public TypeCode GetTypeCode() + { + throw new NotImplementedException(); + } + + /// + public bool ToBoolean(IFormatProvider provider) + { + throw new NotImplementedException(); + } + + /// + public byte ToByte(IFormatProvider provider) + { + throw new NotImplementedException(); + } + + /// + public char ToChar(IFormatProvider provider) + { + throw new NotImplementedException(); + } + + /// + public DateTime ToDateTime(IFormatProvider provider) + { + throw new NotImplementedException(); + } + + /// + public decimal ToDecimal(IFormatProvider provider) + { + throw new NotImplementedException(); + } + + /// + public double ToDouble(IFormatProvider provider) + { + throw new NotImplementedException(); + } + + /// + public short ToInt16(IFormatProvider provider) + { + throw new NotImplementedException(); + } + + /// + public int ToInt32(IFormatProvider provider) + { + throw new NotImplementedException(); + } + + /// + public long ToInt64(IFormatProvider provider) + { + throw new NotImplementedException(); + } + + /// + public sbyte ToSByte(IFormatProvider provider) + { + throw new NotImplementedException(); + } + + /// + public float ToSingle(IFormatProvider provider) + { + throw new NotImplementedException(); + } + + /// + public string ToString(IFormatProvider provider) + { + throw new NotImplementedException(); + } + + /// + public ushort ToUInt16(IFormatProvider provider) + { + throw new NotImplementedException(); + } + + /// + public uint ToUInt32(IFormatProvider provider) + { + throw new NotImplementedException(); + } + + /// + public ulong ToUInt64(IFormatProvider provider) + { + throw new NotImplementedException(); + } + + /// + /// The internal domain of this curve. + /// + public Interval domain { get; set; } = new(0, 1); + + /// + public double length { get; set; } + + /// + public double area { get; set; } + + /// + public Box bbox { get; set; } + + /// + public bool TransformTo(Transform transform, out ITransformable transformed) + { + // transform points + var transformedPoints = new List(); + foreach (var point in GetPoints()) + { + point.TransformTo(transform, out Point transformedPoint); + transformedPoints.Add(transformedPoint); + } + + transformed = new Polyline + { + value = transformedPoints.SelectMany(o => o.ToList()).ToList(), + closed = closed, + applicationId = applicationId, + units = units + }; + + return true; + } + + ///This function may be suboptimal for performance for polylines with many points + /// as List of s + /// when list is malformed + public List GetPoints() + { + if (value.Count % 3 != 0) + { + throw new SpeckleException( + $"{nameof(Polyline)}.{nameof(value)} list is malformed: expected length to be multiple of 3" + ); + } + + var pts = new List(value.Count / 3); + for (int i = 2; i < value.Count; i += 3) + { + pts.Add(new Point(value[i - 2], value[i - 1], value[i], units)); + } + + return pts; + } + + /// + /// Returns the values of this as a list of numbers + /// + /// A list of values representing the polyline. + public List ToList() + { + var list = new List(); + list.Add(closed ? 1 : 0); // 2 + list.Add(domain?.start ?? 0); // 3 + list.Add(domain?.end ?? 1); // 4 + list.Add(value.Count); // 5 + list.AddRange(value); // 6 onwards + + list.Add(Units.GetEncodingFromUnit(units)); + list.Insert(0, CurveTypeEncoding.Polyline); // 1 + list.Insert(0, list.Count); // 0 + return list; + } + + /// + /// Creates a new based on a list of coordinates and the unit they're drawn in. + /// + /// The list of values representing this polyline + /// A new with the provided values. + + public static Polyline FromList(List list) + { + var polyline = new Polyline { closed = list[2] == 1, domain = new Interval(list[3], list[4]) }; + var pointCount = (int)list[5]; + polyline.value = list.GetRange(6, pointCount); + polyline.units = Units.GetUnitFromEncoding(list[list.Count - 1]); + return polyline; + } +} diff --git a/CNX-8892/Objects/Speckle.Objects.Common/Geometry/Vector.cs b/CNX-8892/Objects/Speckle.Objects.Common/Geometry/Vector.cs new file mode 100644 index 0000000000..a80fe2cfad --- /dev/null +++ b/CNX-8892/Objects/Speckle.Objects.Common/Geometry/Vector.cs @@ -0,0 +1,261 @@ +using System; +using System.Collections.Generic; +using Speckle.Core.Kits; +using Speckle.Core.Models; +using Speckle.Newtonsoft.Json; +using Speckle.Objects.Utils; + +namespace Speckle.Objects.Geometry; + +/// +/// A 3-dimensional vector +/// +public class Vector : Base, IHasBoundingBox, ITransformable +{ + /// + public Vector() { } + + /// + /// Constructs a new 2D from it's X and Y coordinates. + /// + /// The x coordinate of the vector + /// The y coordinate of the vector + /// The units the coordinates are in. + /// The unique application ID of the object. + public Vector(double x, double y, string units = Units.Meters, string? applicationId = null) + { + this.x = x; + this.y = y; + z = 0; + this.applicationId = applicationId; + this.units = units; + } + + /// + /// Constructs a new 2D from it's X and Y coordinates. + /// + /// The x coordinate of the vector + /// The y coordinate of the vector + /// The y coordinate of the vector + /// The units the coordinates are in. + /// The unique application ID of the object. + public Vector(double x, double y, double z, string units = Units.Meters, string? applicationId = null) + { + this.x = x; + this.y = y; + this.z = z; + this.applicationId = applicationId; + this.units = units; + } + + /// + /// Constructs a new from a + /// + /// The point whose coordinates will be used + /// The unique application ID of the object. + public Vector(Point point, string? applicationId = null) + : this(point.x, point.y, point.z, point.units ?? Units.None, applicationId) { } + + /// + /// Gets or sets the coordinates of the vector + /// + [ + JsonProperty(NullValueHandling = NullValueHandling.Ignore), + Obsolete("Use X,Y,Z fields to access coordinates instead", true) + ] + public List value + { +#pragma warning disable CS8603 // Possible null reference return. + get => null; +#pragma warning restore CS8603 // Possible null reference return. + set + { + x = value[0]; + y = value[1]; + z = value.Count > 2 ? value[2] : 0; + } + } + + /// + /// The unit's this is in. + /// This should be one of + /// + public string units { get; set; } = Units.None; + + /// + /// The x coordinate of the vector. + /// + public double x { get; set; } + + /// + /// The y coordinate of the vector. + /// + public double y { get; set; } + + /// + /// The z coordinate of the vector. + /// + public double z { get; set; } + + /// + /// Gets the Euclidean length of this vector. + /// + /// Length of the vector. + [JsonIgnore] + public double Length => Math.Sqrt(DotProduct(this, this)); + + /// + public Box bbox { get; set; } + + /// + public bool TransformTo(Transform transform, out Vector transformed) + { + var m = transform.matrix; + var tX = x * m.M11 + y * m.M12 + z * m.M13; + var tY = x * m.M21 + y * m.M22 + z * m.M23; + var tZ = x * m.M31 + y * m.M32 + z * m.M33; + transformed = new Vector(tX, tY, tZ, units, applicationId); + return true; + } + + /// + public bool TransformTo(Transform transform, out ITransformable transformed) + { + _ = TransformTo(transform, out Vector vec); + transformed = vec; + return true; + } + + /// + /// Returns the coordinates of this as a list of numbers + /// + /// A list of coordinates {x, y, z} + public List ToList() + { + return new List { x, y, z }; + } + + /// + /// Creates a new vector based on a list of coordinates and the unit they're drawn in. + /// + /// The list of coordinates {x, y, z} + /// The units the coordinates are in + /// A new with the provided coordinates. + public static Vector FromList(List list, string units) + { + return new Vector(list[0], list[1], list[2], units); + } + + /// + /// Divides a vector by a numerical value. This will divide each coordinate by the provided value. + /// + /// The vector to divide + /// The value to divide by + /// The resulting + public static Vector operator /(Vector vector, double val) => + new(vector.x / val, vector.y / val, vector.z / val, vector.units); + + /// + /// Multiplies a vector by a numerical value. This will multiply each coordinate by the provided value. + /// + /// The vector to multiply + /// The value to multiply by + /// The resulting + public static Vector operator *(Vector vector, double val) => + new(vector.x * val, vector.y * val, vector.z * val, vector.units); + + /// + /// Adds two vectors by adding each of their coordinates. + /// + /// The first vector + /// The second vector + /// The resulting + public static Vector operator +(Vector vector1, Vector vector2) => + new(vector1.x + vector2.x, vector1.y + vector2.y, vector1.z + vector2.z, vector1.units); + + /// + /// Subtracts two vectors by subtracting each of their coordinates. + /// + /// The first vector + /// The second vector + /// The resulting + public static Vector operator -(Vector vector1, Vector vector2) => + new(vector1.x - vector2.x, vector1.y - vector2.y, vector1.z - vector2.z, vector1.units); + + /// + /// Gets the scalar product (dot product) of two given vectors + /// Dot product = u1*v1 + u2*v2 + u3*v3. + /// + /// First vector. + /// Second vector. + /// Numerical value of the dot product. + public static double DotProduct(Vector u, Vector v) + { + return u.x * v.x + u.y * v.y + u.z * v.z; + } + + /// + /// Computes the vector product (cross product) of two given vectors + /// Cross product = { u2 * v3 - u3 * v2; u3 * v1 - u1 * v3; u1 * v2 - u2 * v1 }. + /// + /// First vector. + /// Second vector. + /// Vector result of the cross product. + public static Vector CrossProduct(Vector u, Vector v) + { + var x = u.y * v.z - u.z * v.y; + var y = u.z * v.x - u.x * v.z; + var z = u.x * v.y - u.y * v.x; + + return new Vector(x, y, z); + } + + public static double Angle(Vector u, Vector v) + { + return Math.Acos(DotProduct(u, v) / (u.Length * v.Length)); + } + + [Obsolete("Renamed to " + nameof(Normalize), true)] + public void Unitize() + { + Normalize(); + } + + /// + /// Compute and return a unit vector from this vector + /// + /// a normalized unit vector + public void Normalize() + { + var length = Length; + x /= length; + y /= length; + z /= length; + } + + /// + /// Inverses the direction of the vector, equivalent to multiplying by -1 + /// + /// A pointing in the opposite direction + public Vector Negate() + { + x *= -1; + y *= -1; + z *= -1; + return this; + } + + /// + /// Returns a normalized copy of this vector. + /// + /// A copy of this vector unitized. + public Vector Unit() + { + return this / Length; + } + + public static Vector Divide(Vector left, Vector right) + { + throw new NotImplementedException(); + } +} diff --git a/CNX-8892/Objects/Speckle.Objects.Common/Primitives/Interval.cs b/CNX-8892/Objects/Speckle.Objects.Common/Primitives/Interval.cs new file mode 100644 index 0000000000..3b2ecd6f0c --- /dev/null +++ b/CNX-8892/Objects/Speckle.Objects.Common/Primitives/Interval.cs @@ -0,0 +1,27 @@ +using System; +using Speckle.Core.Models; +using Speckle.Newtonsoft.Json; + +namespace Speckle.Objects.Primitives; + +public class Interval : Base +{ + public Interval() { } + + public Interval(double start, double end) + { + this.start = start; + this.end = end; + } + + public double? start { get; set; } + public double? end { get; set; } + + [JsonIgnore] + public double Length => Math.Abs((end ?? 0) - (start ?? 0)); + + public override string ToString() + { + return base.ToString() + $"[{start}, {end}]"; + } +} diff --git a/CNX-8892/Objects/Speckle.Objects.Common/Primitives/Interval2d.cs b/CNX-8892/Objects/Speckle.Objects.Common/Primitives/Interval2d.cs new file mode 100644 index 0000000000..d044c0f820 --- /dev/null +++ b/CNX-8892/Objects/Speckle.Objects.Common/Primitives/Interval2d.cs @@ -0,0 +1,23 @@ +using Speckle.Core.Models; + +namespace Speckle.Objects.Primitives; + +public class Interval2d : Base +{ + public Interval2d() { } + + public Interval2d(Interval u, Interval v) + { + this.u = u; + this.v = v; + } + + public Interval2d(double start_u, double end_u, double start_v, double end_v) + { + u = new Interval(start_u, end_u); + v = new Interval(start_v, end_v); + } + + public Interval u { get; set; } + public Interval v { get; set; } +} diff --git a/CNX-8892/Objects/Speckle.Objects.Common/Speckle.Objects.Common.csproj b/CNX-8892/Objects/Speckle.Objects.Common/Speckle.Objects.Common.csproj new file mode 100644 index 0000000000..02d764eedd --- /dev/null +++ b/CNX-8892/Objects/Speckle.Objects.Common/Speckle.Objects.Common.csproj @@ -0,0 +1,14 @@ + + + + 10.0 + enable + netstandard2.0 + disable + + + + + + + diff --git a/CNX-8892/Objects/Speckle.Objects.Common/Utils/Transform.cs b/CNX-8892/Objects/Speckle.Objects.Common/Utils/Transform.cs new file mode 100644 index 0000000000..39bbf697e9 --- /dev/null +++ b/CNX-8892/Objects/Speckle.Objects.Common/Utils/Transform.cs @@ -0,0 +1,464 @@ +using System; +using System.Collections.Generic; +using System.DoubleNumerics; +using Speckle.Core.Kits; +using Speckle.Core.Logging; +using Speckle.Core.Models; +using Speckle.Newtonsoft.Json; +using Speckle.Objects.Geometry; + +namespace Speckle.Objects.Utils; + +/// +/// Generic transform class +/// +public class Transform : Base +{ + public Transform() { } + + /// + /// Construct a transform from a row-based double array of size 16 + /// + /// + /// + /// + public Transform(double[] value, string units = Units.None) + { + if (value.Length != 16) + { + throw new ArgumentException( + $"{nameof(Transform)}.{nameof(value)} array is malformed: expected length to be 16", + nameof(value) + ); + } + + matrix = CreateMatrix(value); + this.units = units; + } + + /// + /// Construct a transform from a row-based float array of size 16 + /// + /// + /// + /// + public Transform(float[] value, string units = Units.None) + { + if (value.Length != 16) + { + throw new SpeckleException($"{nameof(Transform)}.{nameof(value)} array is malformed: expected length to be 16"); + } + + matrix = CreateMatrix(value); + this.units = units; + } + + /// + /// Construct a transform from a 4x4 matrix and translation units + /// + /// + /// + public Transform(Matrix4x4 matrix, string units = Units.None) + { + this.matrix = matrix; + this.units = units; + } + + /// + /// Construct a transform given the x, y, and z bases and the translation vector + /// + /// + /// + /// + /// + public Transform(Vector x, Vector y, Vector z, Vector translation) + { + matrix = new Matrix4x4( + x.x, + y.x, + z.x, + translation.x, + x.y, + y.y, + z.y, + translation.y, + x.z, + y.z, + z.z, + translation.z, + 0f, + 0f, + 0f, + 1f + ); + units = translation.units; + } + + /// + /// The column-based 4x4 transform matrix + /// + /// + /// Graphics based apps typically use column-based matrices, where the last column defines translation. + /// Modelling apps may use row-based matrices, where the last row defines translation. Transpose if so. + /// + public Matrix4x4 matrix { get; set; } = Matrix4x4.Identity; + + /// + /// Units for translation + /// + public string units { get; set; } = Units.None; + + /// + /// Decomposes matrix into its scaling, rotation, and translation components + /// + /// + /// + /// + /// True if successful, false otherwise + public void Decompose(out Vector3 scale, out Quaternion rotation, out Vector4 translation) + { + // translation + translation = new Vector4(matrix.M14, matrix.M24, matrix.M34, matrix.M44); + + // scale + // this should account for non-uniform scaling + Vector4 basis4dX = new(matrix.M11, matrix.M21, matrix.M31, matrix.M41); + Vector4 basis4dY = new(matrix.M12, matrix.M22, matrix.M32, matrix.M42); + Vector4 basis4dZ = new(matrix.M13, matrix.M23, matrix.M33, matrix.M43); + + // Check for mirroring + Vector3 basisX = new(matrix.M11, matrix.M21, matrix.M31); + Vector3 basisY = new(matrix.M12, matrix.M22, matrix.M32); + Vector3 basisZ = new(matrix.M13, matrix.M23, matrix.M33); + // Negative determinant means flip on Z. + // TODO: Add tests and figure out exactly why this is. Jedd and myself have some theories but it would be nice to document this properly + double determinant = Vector3.Dot(Vector3.Cross(basisX, basisY), basisZ) < 0 ? -1 : 1; + + // Compute the scale, but only multiply the Z scale by the determinant to flag negative scaling on Z axis (see todo above) + scale = new Vector3(basis4dX.Length(), basis4dY.Length(), basis4dZ.Length() * determinant); + + // rotation + // this is using a z-up convention for basis vectors + var up = new Vector3(matrix.M13, matrix.M23, matrix.M33); + var forward = new Vector3(matrix.M12, matrix.M22, matrix.M32); + rotation = LookRotation(forward, up); + } + + private static Quaternion LookRotation(Vector3 forward, Vector3 up) + { + Vector3 vector = new(forward.X / forward.Length(), forward.Y / forward.Length(), forward.Z / forward.Length()); + Vector3 vector2 = Vector3.Cross(up, forward); + Vector3 vector3 = Vector3.Cross(vector, vector2); + var m00 = vector2.X; + var m01 = vector2.Y; + var m02 = vector2.Z; + var m10 = vector3.X; + var m11 = vector3.Y; + var m12 = vector3.Z; + var m20 = vector.X; + var m21 = vector.Y; + var m22 = vector.Z; + + var num8 = m00 + m11 + m22; + if (num8 > 0d) + { + var num = Math.Sqrt(num8 + 1d); + num = 0.5d / num; + return new Quaternion((m12 - m21) * num, (m20 - m02) * num, (m01 - m10) * num, num * 0.5d); + } + if (m00 >= m11 && m00 >= m22) + { + var num7 = Math.Sqrt(1d + m00 - m11 - m22); + var num4 = 0.5d / num7; + return new Quaternion(0.5d * num7, (m01 + m10) * num4, (m02 + m20) * num4, (m12 - m21) * num4); + } + if (m11 > m22) + { + var num6 = Math.Sqrt(1d + m11 - m00 - m22); + var num3 = 0.5d / num6; + return new Quaternion((m10 + m01) * num3, 0.5d * num6, (m21 + m12) * num3, (m20 - m02) * num3); + } + var num5 = Math.Sqrt(1d + m22 - m00 - m11); + var num2 = 0.5d / num5; + return new Quaternion((m20 + m02) * num2, (m21 + m12) * num2, 0.5d * num5, (m01 - m10) * num2); + } + + /// + /// Converts this transform to the input units + /// + /// The target units + /// A matrix array with the translation scaled by input units + /// If either the transform's or the given is , will return the matrix array data unscaled + public double[] ConvertToUnits(string newUnits) + { + if (newUnits == null || units == null) + { + return ToArray(); + } + + var sf = Units.GetConversionFactor(units, newUnits); + + return new[] + { + matrix.M11, + matrix.M12, + matrix.M13, + matrix.M14 * sf, + matrix.M21, + matrix.M22, + matrix.M23, + matrix.M24 * sf, + matrix.M31, + matrix.M32, + matrix.M33, + matrix.M34 * sf, + matrix.M41, + matrix.M42, + matrix.M43, + matrix.M44 + }; + } + + public Transform Inverse() + { + if (Matrix4x4.Invert(matrix, out var transformed)) + { + return new Transform(transformed); + } + throw new SpeckleException("Could not create inverse transform"); + } + + /// + /// Returns the matrix that results from multiplying two matrices together. + /// + /// The first transform + /// The second transform + /// A transform matrix with the units of the first transform + public static Transform operator *(Transform t1, Transform t2) + { + var convertedTransform = CreateMatrix(t2.ConvertToUnits(t1.units)); + var newMatrix = t1.matrix * convertedTransform; + return new Transform(newMatrix, t1.units); + } + + /// + /// Returns the double array of the transform matrix + /// + /// + public double[] ToArray() + { + return new double[] + { + matrix.M11, + matrix.M12, + matrix.M13, + matrix.M14, + matrix.M21, + matrix.M22, + matrix.M23, + matrix.M24, + matrix.M31, + matrix.M32, + matrix.M33, + matrix.M34, + matrix.M41, + matrix.M42, + matrix.M43, + matrix.M44 + }; + } + + // Creates a matrix4x4 from a double array + internal static Matrix4x4 CreateMatrix(double[] value) + { + return new Matrix4x4( + value[0], + value[1], + value[2], + value[3], + value[4], + value[5], + value[6], + value[7], + value[8], + value[9], + value[10], + value[11], + value[12], + value[13], + value[14], + value[15] + ); + } + + // Creates a matrix from a float array + internal static Matrix4x4 CreateMatrix(float[] value) + { + return new Matrix4x4( + Convert.ToDouble(value[0]), + Convert.ToDouble(value[1]), + Convert.ToDouble(value[2]), + Convert.ToDouble(value[3]), + Convert.ToDouble(value[4]), + Convert.ToDouble(value[5]), + Convert.ToDouble(value[6]), + Convert.ToDouble(value[7]), + Convert.ToDouble(value[8]), + Convert.ToDouble(value[9]), + Convert.ToDouble(value[10]), + Convert.ToDouble(value[11]), + Convert.ToDouble(value[12]), + Convert.ToDouble(value[13]), + Convert.ToDouble(value[14]), + Convert.ToDouble(value[15]) + ); + } + + #region obsolete + + [JsonIgnore, Obsolete("Use the matrix property", true)] + [System.Diagnostics.CodeAnalysis.SuppressMessage( + "Performance", + "CA1819:Properties should not return arrays", + Justification = "Obsolete" + )] + public double[] value + { + get => ToArray(); + set => matrix = CreateMatrix(value); + } + + [JsonIgnore, Obsolete("Use Decompose method", true)] + public double rotationZ + { + get + { + Decompose(out _, out Quaternion rotation, out _); + return Math.Acos(rotation.W) * 2; + } + } + + /// + /// Transform a flat list of doubles representing points + /// + [Obsolete("Use transform method in Point class", true)] + public List ApplyToPoints(List points) + { + if (points.Count % 3 != 0) + { + throw new SpeckleException( + "Cannot apply transform as the points list is malformed: expected length to be multiple of 3" + ); + } + + var transformed = new List(points.Count); + for (var i = 0; i < points.Count; i += 3) + { + var point = new Point(points[i], points[i + 1], points[i + 2]); + point.TransformTo(this, out Point transformedPoint); + transformed.AddRange(transformedPoint.ToList()); + } + return transformed; + } + + /// + /// Transform a flat list of speckle Points + /// + [Obsolete("Use transform method in Point class", true)] + public List ApplyToPoints(List points) + { + var transformedPoints = new List(); + foreach (var point in points) + { + point.TransformTo(this, out Point transformedPoint); + transformedPoints.Add(transformedPoint); + } + return transformedPoints; + } + + /// + /// Transform a single speckle Point + /// + [Obsolete("Use transform method in Point class", true)] + public Point? ApplyToPoint(Point point) + { + if (point == null) + { + return null; + } + + point.TransformTo(this, out Point transformedPoint); + return transformedPoint; + } + + /// + /// Transform a list of three doubles representing a point + /// + [Obsolete("Use transform method in Point class", true)] + public List ApplyToPoint(List point) + { + var newPoint = new Point(point[0], point[1], point[2]); + newPoint.TransformTo(this, out Point transformed); + return transformed.ToList(); + } + + /// + /// Transform a single speckle Vector + /// + [Obsolete("Use transform method in Vector class", true)] + public Vector ApplyToVector(Vector vector) + { + var newCoords = ApplyToVector(new List { vector.x, vector.y, vector.z }); + + return new Vector(newCoords[0], newCoords[1], newCoords[2], vector.units, vector.applicationId); + } + + /// + /// Transform a list of three doubles representing a vector + /// + [Obsolete("Use transform method in Vector class", true)] + public List ApplyToVector(List vector) + { + var newPoint = new List(); + + for (var i = 0; i < 12; i += 4) + { + newPoint.Add(vector[0] * value[i] + vector[1] * value[i + 1] + vector[2] * value[i + 2]); + } + + return newPoint; + } + + /// + /// Transform a flat list of ICurves. Note that if any of the ICurves does not implement `ITransformable`, + /// it will not be returned. + /// + [Obsolete("Use transform method in Curve class", true)] + public List ApplyToCurves(List curves, out bool success) + { + // TODO: move to curve class + success = true; + var transformed = new List(); + foreach (var curve in curves) + { + if (curve is ITransformable c) + { + c.TransformTo(this, out ITransformable tc); + transformed.Add((ICurve)tc); + } + else + { + success = false; + } + } + + return transformed; + } + + public static Transform Multiply(Transform left, Transform right) + { + throw new NotImplementedException(); + } + + #endregion +} diff --git a/CNX-8892/Objects/Speckle.Objects.Revit/Speckle.Objects.Revit.csproj b/CNX-8892/Objects/Speckle.Objects.Revit/Speckle.Objects.Revit.csproj new file mode 100644 index 0000000000..dbdcea46b6 --- /dev/null +++ b/CNX-8892/Objects/Speckle.Objects.Revit/Speckle.Objects.Revit.csproj @@ -0,0 +1,7 @@ + + + + netstandard2.0 + + + diff --git a/CNX-8892/Speckle.Autofac/DependencyInjection/AutofacContainer.cs b/CNX-8892/Speckle.Autofac/DependencyInjection/AutofacContainer.cs new file mode 100644 index 0000000000..96b19744eb --- /dev/null +++ b/CNX-8892/Speckle.Autofac/DependencyInjection/AutofacContainer.cs @@ -0,0 +1,107 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using Autofac; +using Microsoft.Extensions.Logging; +using Speckle.Autofac.Files; +using Speckle.Core.Logging; +using Module = Autofac.Module; + +namespace Speckle.Autofac.DependencyInjection; + +// POC: wrap the IContainer or expose it? +public class AutofacContainer +{ + public delegate void PreBuildEventHandler(object sender, ContainerBuilder containerBuilder); + + // Declare the event. + public event PreBuildEventHandler PreBuildEvent; + + private readonly ContainerBuilder _builder; + private readonly IStorageInfo _storageInfo; + + private IContainer _container; + + public AutofacContainer(IStorageInfo storageInfo) + { + _storageInfo = storageInfo; + + _builder = new ContainerBuilder(); + } + + // POC: HOW TO GET TYPES loaded, this feels a bit heavy handed and relies on Autofac where we can probably do something different + public AutofacContainer LoadAutofacModules(IEnumerable dependencyPaths) + { + // look for assemblies in these paths that offer autofac modules + foreach (string path in dependencyPaths) + { + // POC: naming conventions + // find assemblies + var assembliesInPath = _storageInfo.GetFilenamesInDirectory(path, "Speckle*.dll"); + + foreach (var file in assembliesInPath) + { + // POC: ignore already loaded? Or just get that instead of loading it? + + try + { + // inspect the assemblies for Autofac.Module + var assembly = Assembly.LoadFrom(file); + var moduleClasses = assembly.GetTypes().Where(x => x.BaseType == typeof(Module)); + + // create each module + // POC: could look for some attribute here + foreach (var moduleClass in moduleClasses) + { + var module = (Module)Activator.CreateInstance(moduleClass); + _builder.RegisterModule(module); + } + } + // POC: catch only certain exceptions + catch (Exception ex) when (!ex.IsFatal()) { } + } + } + + return this; + } + + public AutofacContainer AddModule(Module module) + { + _builder.RegisterModule(module); + + return this; + } + + public AutofacContainer AddSingletonInstance(T instance) + where T : class + { + _builder.RegisterInstance(instance); + + return this; + } + + public AutofacContainer Build() + { + // before we build give some last minute registration options. + PreBuildEvent?.Invoke(this, _builder); + + _container = _builder.Build(); + + // POC: we could create the factory on construction of the container and then inject that and store it + var logger = _container.Resolve().CreateLogger(); + + // POC: we could probably expand on this + List assemblies = AppDomain.CurrentDomain.GetAssemblies().Select(x => x.FullName).ToList(); + logger.LogInformation("Loaded assemblies: {@Assemblies}", assemblies); + + return this; + } + + public T Resolve() + where T : class + { + // POC: resolve null check with a check and throw perhaps? + return _container.Resolve(); + } +} diff --git a/CNX-8892/Speckle.Autofac/DependencyInjection/Factory.cs b/CNX-8892/Speckle.Autofac/DependencyInjection/Factory.cs new file mode 100644 index 0000000000..caf7f90922 --- /dev/null +++ b/CNX-8892/Speckle.Autofac/DependencyInjection/Factory.cs @@ -0,0 +1,19 @@ +using Autofac.Features.Indexed; + +namespace Speckle.Autofac.DependencyInjection; + +public class Factory : IFactory + where T : class +{ + private readonly IIndex _types; + + public Factory(IIndex types) + { + _types = types; + } + + public T ResolveInstance(K strongName) + { + return _types[strongName]; + } +} diff --git a/CNX-8892/Speckle.Autofac/DependencyInjection/IFactory.cs b/CNX-8892/Speckle.Autofac/DependencyInjection/IFactory.cs new file mode 100644 index 0000000000..4c9ca9fa35 --- /dev/null +++ b/CNX-8892/Speckle.Autofac/DependencyInjection/IFactory.cs @@ -0,0 +1,12 @@ +namespace Speckle.Autofac.DependencyInjection; + +// POC: NEXT UP +// * begin scope: https://stackoverflow.com/questions/49595198/autofac-resolving-through-factory-methods +// Interceptors? + +// POC: this might be somehting that could go in a wholly converter agnostic project +public interface IFactory + where T : class +{ + T ResolveInstance(K strongName); +} diff --git a/CNX-8892/Speckle.Autofac/DependencyInjection/IScopedFactory.cs b/CNX-8892/Speckle.Autofac/DependencyInjection/IScopedFactory.cs new file mode 100644 index 0000000000..4a3cab3d37 --- /dev/null +++ b/CNX-8892/Speckle.Autofac/DependencyInjection/IScopedFactory.cs @@ -0,0 +1,9 @@ +using System; + +namespace Speckle.Autofac.DependencyInjection; + +public interface IScopedFactory : IDisposable + where T : class +{ + T ResolveScopedInstance(); +} diff --git a/CNX-8892/Speckle.Autofac/DependencyInjection/NameAndRankValueAttribute.cs b/CNX-8892/Speckle.Autofac/DependencyInjection/NameAndRankValueAttribute.cs new file mode 100644 index 0000000000..8ecd2b454f --- /dev/null +++ b/CNX-8892/Speckle.Autofac/DependencyInjection/NameAndRankValueAttribute.cs @@ -0,0 +1,16 @@ +using System; + +namespace Speckle.Autofac.DependencyInjection; + +[AttributeUsage(AttributeTargets.Class)] +public sealed class NameAndRankValueAttribute : Attribute +{ + public string Name { get; private set; } + public int Rank { get; private set; } + + public NameAndRankValueAttribute(string name, int rank) + { + Name = name; + Rank = rank; + } +} diff --git a/CNX-8892/Speckle.Autofac/DependencyInjection/NamedTypeInjector.cs b/CNX-8892/Speckle.Autofac/DependencyInjection/NamedTypeInjector.cs new file mode 100644 index 0000000000..4afd8b2b43 --- /dev/null +++ b/CNX-8892/Speckle.Autofac/DependencyInjection/NamedTypeInjector.cs @@ -0,0 +1,63 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using Autofac; +using Speckle.Core.Logging; + +namespace Speckle.Autofac.DependencyInjection; + +public static class NamedTypeInjector +{ + public static ContainerBuilder InjectNamedTypes(this ContainerBuilder containerBuilder) + where T : class + { + List types = new(); + + foreach (var asm in AppDomain.CurrentDomain.GetAssemblies().Where(x => x.GetName().Name.StartsWith("Speckle"))) + { + try + { + var asmTypes = asm.GetTypes(); + types.AddRange(asmTypes.Where(y => y.GetInterface(typeof(T).Name) != null)); + } + catch (Exception ex) when (!ex.IsFatal()) + { + // POC: be more specific + } + } + + // we only care about named types + var byName = types + .Where(x => x.GetCustomAttribute() != null) + .Select(x => + { + var nameAndRank = x.GetCustomAttribute(); + + return (name: nameAndRank.Name, rank: nameAndRank.Rank, type: x); + }) + .ToList(); + + // we'll register the types accordingly + var names = byName.Select(x => x.name).Distinct(); + foreach (string name in names) + { + var namedTypes = byName.Where(x => x.name == name).OrderByDescending(y => y.rank).ToList(); + + // first type + var first = namedTypes[0]; + + // POC: may need to be instance per lifecycle scope + containerBuilder.RegisterType(first.type).Keyed(first.name).InstancePerLifetimeScope(); + + // register subsequent types with rank + namedTypes.RemoveAt(0); + foreach (var other in namedTypes) + { + containerBuilder.RegisterType(other.type).Keyed($"{other.name}|{other.rank}").InstancePerLifetimeScope(); + } + } + + return containerBuilder; + } +} diff --git a/CNX-8892/Speckle.Autofac/DependencyInjection/ScopedFactory.cs b/CNX-8892/Speckle.Autofac/DependencyInjection/ScopedFactory.cs new file mode 100644 index 0000000000..50f6247309 --- /dev/null +++ b/CNX-8892/Speckle.Autofac/DependencyInjection/ScopedFactory.cs @@ -0,0 +1,43 @@ +using System; +using Autofac; + +namespace Speckle.Autofac.DependencyInjection; + +public class ScopedFactory : IScopedFactory + where T : class +{ + private readonly ILifetimeScope _lifetimeScope; + private bool _disposed = false; + + public ScopedFactory(ILifetimeScope parentScope) + { + _lifetimeScope = parentScope.BeginLifetimeScope(); + } + + public T ResolveScopedInstance() + { + return _lifetimeScope.Resolve(); + } + + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } + + protected virtual void Dispose(bool disposing) + { + if (disposing && !_disposed) + { + // POC: check: but I think dispose will end the scope + _lifetimeScope.Dispose(); + _disposed = true; + } + } + + // might be needed in future... + ~ScopedFactory() + { + Dispose(false); + } +} diff --git a/CNX-8892/Speckle.Autofac/Files/IStorageInfo.cs b/CNX-8892/Speckle.Autofac/Files/IStorageInfo.cs new file mode 100644 index 0000000000..1f5c2a733b --- /dev/null +++ b/CNX-8892/Speckle.Autofac/Files/IStorageInfo.cs @@ -0,0 +1,8 @@ +using System.Collections.Generic; + +namespace Speckle.Autofac.Files; + +public interface IStorageInfo +{ + IEnumerable GetFilenamesInDirectory(string path, string pattern); +} diff --git a/CNX-8892/Speckle.Autofac/Files/StorageInfo.cs b/CNX-8892/Speckle.Autofac/Files/StorageInfo.cs new file mode 100644 index 0000000000..c9cbeab3fa --- /dev/null +++ b/CNX-8892/Speckle.Autofac/Files/StorageInfo.cs @@ -0,0 +1,12 @@ +using System.Collections.Generic; +using System.IO; + +namespace Speckle.Autofac.Files; + +public class StorageInfo : IStorageInfo +{ + public IEnumerable GetFilenamesInDirectory(string path, string pattern) + { + return Directory.GetFiles(path, pattern); + } +} diff --git a/CNX-8892/Speckle.Autofac/GlobalSuppressions.cs b/CNX-8892/Speckle.Autofac/GlobalSuppressions.cs new file mode 100644 index 0000000000..2501a9ef35 --- /dev/null +++ b/CNX-8892/Speckle.Autofac/GlobalSuppressions.cs @@ -0,0 +1,21 @@ +// This file is used by Code Analysis to maintain SuppressMessage +// attributes that are applied to this project. +// Project-level suppressions either have no target or are given +// a specific target and scoped to a namespace, type, member, etc. + +using System.Diagnostics.CodeAnalysis; + +[assembly: SuppressMessage( + "Performance", + "CA1805:Do not initialize unnecessarily", + Justification = "", + Scope = "member", + Target = "~F:Speckle.Autofac.DependencyInjection.ScopedFactory`1._disposed" +)] +[assembly: SuppressMessage( + "Performance", + "CA1848:Use the LoggerMessage delegates", + Justification = "", + Scope = "member", + Target = "~M:Speckle.Autofac.DependencyInjection.AutofacContainer.Build~Speckle.Autofac.DependencyInjection.AutofacContainer" +)] diff --git a/CNX-8892/Speckle.Autofac/Speckle.Autofac.csproj b/CNX-8892/Speckle.Autofac/Speckle.Autofac.csproj new file mode 100644 index 0000000000..02c1cb29d8 --- /dev/null +++ b/CNX-8892/Speckle.Autofac/Speckle.Autofac.csproj @@ -0,0 +1,19 @@ + + + + true + netstandard2.0 + x64 + AnyCPU;x64 + + + + + + + + + + + + diff --git a/CNX-8892/Speckle.Connectors.Utils/Cancellation/CancellationManager.cs b/CNX-8892/Speckle.Connectors.Utils/Cancellation/CancellationManager.cs new file mode 100644 index 0000000000..52913510f9 --- /dev/null +++ b/CNX-8892/Speckle.Connectors.Utils/Cancellation/CancellationManager.cs @@ -0,0 +1,76 @@ +using System.Collections.Generic; +using System.Threading; + +namespace Speckle.Connectors.Utils.Cancellation; + +/// +/// Util class to manage cancellations. +/// +public class CancellationManager +{ + /// + /// Dictionary to relate with registered id. + /// + private readonly Dictionary _operationsInProgress = new(); + + /// + /// Get token with registered id. + /// + /// Id of the operation. + /// CancellationToken that belongs to operation. + public CancellationToken GetToken(string id) + { + return _operationsInProgress[id].Token; + } + + /// + /// Whether given id registered or not. + /// + /// Id to check registration. + /// Whether given id registered or not. + public bool IsExist(string id) + { + return _operationsInProgress.ContainsKey(id); + } + + /// + /// Initialize a token source for cancellable operation. + /// + /// Id to register token. + /// Initialized cancellation token source. + public CancellationTokenSource InitCancellationTokenSource(string id) + { + if (IsExist(id)) + { + CancelOperation(id); + } + + var cts = new CancellationTokenSource(); + _operationsInProgress[id] = cts; + return cts; + } + + /// + /// Cancel operation. + /// + /// Id to cancel operation. + public void CancelOperation(string id) + { + if (_operationsInProgress.TryGetValue(id, out CancellationTokenSource cts)) + { + cts.Cancel(); + cts.Dispose(); + _operationsInProgress.Remove(id); + } + } + + /// + /// Whether cancellation requested already or not. + /// + /// Id to check cancellation requested already or not. + /// + public bool IsCancellationRequested(string id) + { + return _operationsInProgress[id].IsCancellationRequested; + } +} diff --git a/CNX-8892/Speckle.Connectors.Utils/Cancellation/ICancelable.cs b/CNX-8892/Speckle.Connectors.Utils/Cancellation/ICancelable.cs new file mode 100644 index 0000000000..5a9d9f7048 --- /dev/null +++ b/CNX-8892/Speckle.Connectors.Utils/Cancellation/ICancelable.cs @@ -0,0 +1,9 @@ +namespace Speckle.Connectors.Utils.Cancellation; + +/// +/// Provides a mechanism for cancelling operations. +/// +public interface ICancelable +{ + public CancellationManager CancellationManager { get; } +} diff --git a/CNX-8892/Speckle.Connectors.Utils/Reflection/AssemblyExtensions.cs b/CNX-8892/Speckle.Connectors.Utils/Reflection/AssemblyExtensions.cs new file mode 100644 index 0000000000..6fc4915f07 --- /dev/null +++ b/CNX-8892/Speckle.Connectors.Utils/Reflection/AssemblyExtensions.cs @@ -0,0 +1,23 @@ +using System.Linq; +using System.Reflection; + +namespace Speckle.Connectors.Utils.Reflection; + +public static class AssemblyExtensions +{ + public static string GetVersion(this Assembly assembly) + { + // this is adapted from Serilog extension method, but we might find the fallback is enough: assembly.GetName()?.Version?.ToString(); + var attribute = + assembly.GetCustomAttributes().FirstOrDefault(x => x.GetType() == typeof(AssemblyInformationalVersionAttribute)) + as AssemblyInformationalVersionAttribute; + if (attribute != null) + { + return attribute.InformationalVersion; + } + + // otherwise use assembly version + // POC: missing version? + return assembly.GetName()?.Version?.ToString() ?? "Missing Version"; + } +} diff --git a/CNX-8892/Speckle.Connectors.Utils/Speckle.Connectors.Utils.csproj b/CNX-8892/Speckle.Connectors.Utils/Speckle.Connectors.Utils.csproj new file mode 100644 index 0000000000..c214cdbd2c --- /dev/null +++ b/CNX-8892/Speckle.Connectors.Utils/Speckle.Connectors.Utils.csproj @@ -0,0 +1,15 @@ + + + + 10.0 + enable + netstandard2.0 + x64 + AnyCPU;x64 + + + + + + + diff --git a/CNX-8892/Speckle.Connectors.Utils/SpeckleTopLevelExceptionHandler.cs b/CNX-8892/Speckle.Connectors.Utils/SpeckleTopLevelExceptionHandler.cs new file mode 100644 index 0000000000..f74c866e77 --- /dev/null +++ b/CNX-8892/Speckle.Connectors.Utils/SpeckleTopLevelExceptionHandler.cs @@ -0,0 +1,45 @@ +using System; +using Speckle.Core.Logging; + +namespace Speckle.Connectors.Utils; + +// POC: consider wisdom of static +public static class SpeckleTopLevelExceptionHandler +{ + // POC: async/await? + // handlers for + public static void Run( + Action run, + Func? speckleError = null, + Func? unexpectedError = null, + Func? fatalError = null + ) + { + // POC: TL-handler + try + { + run(); + } + catch (SpeckleException spex) + { + if (speckleError == null || !speckleError(spex)) + { + throw; + } + } + catch (Exception ex) when (!ex.IsFatal()) + { + if (unexpectedError == null || !unexpectedError(ex)) + { + throw; + } + } + catch (Exception ex) when (ex.IsFatal()) + { + if (fatalError == null || !fatalError(ex)) + { + throw; + } + } + } +} diff --git a/ConnectorArcGIS/Bindings/BasicConnectorBinding.cs b/ConnectorArcGIS/Bindings/BasicConnectorBinding.cs new file mode 100644 index 0000000000..ff598acd77 --- /dev/null +++ b/ConnectorArcGIS/Bindings/BasicConnectorBinding.cs @@ -0,0 +1,54 @@ +using System.Reflection; +using ConnectorArcGIS.Utils; +using DUI3; +using DUI3.Bindings; +using DUI3.Models; +using Sentry.Reflection; + +namespace ConnectorArcGIS.Bindings; + +public class BasicConnectorBinding : IBasicConnectorBinding +{ + public string Name { get; set; } = "baseBinding"; + public IBridge Parent { get; set; } + + private readonly ArcGisDocumentStore _store; + + public BasicConnectorBinding(ArcGisDocumentStore store) + { + _store = store; + } + + public string GetSourceApplicationName() => "ArcGIS"; + + public string GetSourceApplicationVersion() => "3"; + + public string GetConnectorVersion() => Assembly.GetAssembly(GetType()).GetNameAndVersion().Version; + + // TODO + public DocumentInfo GetDocumentInfo() => + new() + { + Location = "", + Name = "", + Id = "" + }; + + public DocumentModelStore GetDocumentState() => _store; + + public void AddModel(ModelCard model) => _store.Models.Add(model); + + public void UpdateModel(ModelCard model) + { + int idx = _store.Models.FindIndex(m => model.Id == m.Id); + _store.Models[idx] = model; + } + + public void RemoveModel(ModelCard model) + { + int index = _store.Models.FindIndex(m => m.Id == model.Id); + _store.Models.RemoveAt(index); + } + + public void HighlightModel(string modelCardId) => throw new System.NotImplementedException(); +} diff --git a/ConnectorArcGIS/Bindings/Factory.cs b/ConnectorArcGIS/Bindings/Factory.cs new file mode 100644 index 0000000000..962b27520d --- /dev/null +++ b/ConnectorArcGIS/Bindings/Factory.cs @@ -0,0 +1,20 @@ +using System.Collections.Generic; +using ConnectorArcGIS.Utils; +using DUI3; +using DUI3.Bindings; + +namespace ConnectorArcGIS.Bindings; + +public static class Factory +{ + private static readonly ArcGisDocumentStore s_store = new(); + + public static List CreateBindings() + { + BasicConnectorBinding baseBindings = new(s_store); + List bindingsList = + new() { new ConfigBinding("ArcGIS"), new AccountBinding(), new TestBinding(), baseBindings }; + + return bindingsList; + } +} diff --git a/ConnectorArcGIS/Config.daml b/ConnectorArcGIS/Config.daml new file mode 100644 index 0000000000..e4fd5de1d8 --- /dev/null +++ b/ConnectorArcGIS/Config.daml @@ -0,0 +1,67 @@ + + + + + Speckle + Speckle connector for ArcGIS + Images\AddinDesktop32.png + Speckle Systems + Speckle Systems + 8/5/2021 12:24:21 PM + Framework + + + + + + + + + + + + + + + + + + + + + + diff --git a/ConnectorArcGIS/ConnectorArcGIS.csproj b/ConnectorArcGIS/ConnectorArcGIS.csproj new file mode 100644 index 0000000000..092b314a29 --- /dev/null +++ b/ConnectorArcGIS/ConnectorArcGIS.csproj @@ -0,0 +1,117 @@ + + + + net6.0-windows + win10-x64 + false + true + false + 1591;CA1416 + true + true + 10 + AnyCPU + + + + C:\Program Files\ArcGIS\Pro\bin\Microsoft.Web.WebView2.Core.dll + False + False + + + C:\Program Files\ArcGIS\Pro\bin\Microsoft.Web.WebView2.Wpf.dll + False + False + + + C:\Program Files\ArcGIS\Pro\bin\ArcGIS.Desktop.Framework.dll + false + True + + + C:\Program Files\ArcGIS\Pro\bin\ArcGIS.Core.dll + False + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\Core\ArcGIS.Desktop.Core.dll + False + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\Mapping\ArcGIS.Desktop.Mapping.dll + False + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\Catalog\ArcGIS.Desktop.Catalog.dll + False + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\Editing\ArcGIS.Desktop.Editing.dll + False + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\DesktopExtensions\ArcGIS.Desktop.Extensions.dll + false + True + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\GeoProcessing\ArcGIS.Desktop.GeoProcessing.dll + False + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\Layout\ArcGIS.Desktop.Layouts.dll + False + False + + + C:\Program Files\ArcGIS\Pro\bin\ArcGIS.Desktop.Shared.Wpf.dll + False + False + + + C:\Program Files\ArcGIS\Pro\bin\ArcGIS.Desktop.Ribbon.Wpf.dll + False + False + + + C:\Program Files\ArcGIS\Pro\bin\ArcGIS.Desktop.DataGrid.Contrib.Wpf.dll + False + False + + + C:\Program Files\ArcGIS\Pro\bin\ArcGIS.Desktop.Resources.dll + false + True + + + C:\Program Files\ArcGIS\Pro\bin\ArcGIS.Desktop.Resources.dll + False + False + + + C:\Program Files\ArcGIS\Pro\bin\ESRI.ArcGIS.ItemIndex.dll + False + False + + + + + + + + + + + + + + + + + + diff --git a/ConnectorArcGIS/ConnectorArcGIS.sln b/ConnectorArcGIS/ConnectorArcGIS.sln new file mode 100644 index 0000000000..767d10ee43 --- /dev/null +++ b/ConnectorArcGIS/ConnectorArcGIS.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.31727.386 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConnectorArcGIS", "ConnectorArcGIS.csproj", "{79682455-2EAC-4B08-9227-C62F56349AD5}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {79682455-2EAC-4B08-9227-C62F56349AD5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {79682455-2EAC-4B08-9227-C62F56349AD5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {79682455-2EAC-4B08-9227-C62F56349AD5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {79682455-2EAC-4B08-9227-C62F56349AD5}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {8B79B969-1105-4E2D-94AF-82CDDA11DE8F} + EndGlobalSection +EndGlobal diff --git a/ConnectorArcGIS/DarkImages/AddInDesktop16.png b/ConnectorArcGIS/DarkImages/AddInDesktop16.png new file mode 100644 index 0000000000000000000000000000000000000000..0118942a923d37745dced41536d71172f7517deb GIT binary patch literal 1314 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`k|nMYCBgY=CFO}lsSJ)O`AMk? zp1FzXsX?iUDV2pMQ*9U+m^Cs(B1$5BeXNr6bM+EIYV;~{3xK*A7;Nk-3KEmEQ%e+* zQqwc@Y?a>c-mj#PnPRIHZt82`Ti~3Uk?B!Ylp0*+7m{3+ootz+WN)WnQ(*-(AUCxn zQK2F?C$HG5!d3}vt`(3C64qBz04piUwpD^SD#ABF!8yMuRl!uxOgGuU%v{0TQqR!T z+}y-mN5ROz&{W^RSl`${*T~q)#K6kLNC66zfVLH-q*(>IxIyg#@@$ndN=gc>^!3Zj z%k|2Q_413-^$jg8E%gnI^o@*kfhu&1EAvVcD|GXUm0>2hq!uR^WfqiV=I1GZOiWD5 zFD$Tv3bSNU;+l1ennz|zM-B0$V)JVzP|XC=H|jx7ncO3BHWAB;NpiyW)Z+ZoqGVvir744~DzI`cN=+=uFAB-e&w+(vKt_H^esM;Afr7I$IMft0d=ry1 z^FV@{U|qhxR-SpqC5d^-sh%#jNbn4Gmq*EQ}4@91Trf z9F2`FOx&CdV0vBhlS^|`^GaZPQ-FG%U0huajGRnx>IEf;+ybD@E~!PCWvMA{Mftf3 zV2@j6;&zJxPV=C8Q?R%N>JLMldi8;h(Fa8@Qgp+FfN2QCgeP7g2cG;>^MGl-2$;A{ z^UHoRFfdN=ba4!+xHV_eSudtQk>mf3ADc`I;N%lh@rhWMHCaSu#|rTc+b*73D_z|f zchKzJnb0k|)r|_C3qu72JFMDTIvVAZpRQPZcJC7h=Cdqs6d>g;Fd(<~UJ81^dm+<(73@IuqYmV0m9+Os7i{i0=el#xWp=L=ll zcWrlNR9(*{VE_OC literal 0 HcmV?d00001 diff --git a/ConnectorArcGIS/DarkImages/AddInDesktop32.png b/ConnectorArcGIS/DarkImages/AddInDesktop32.png new file mode 100644 index 0000000000000000000000000000000000000000..9713e3b1548cc2ee78c60ad4ffb3a46566609b2b GIT binary patch literal 1744 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdz$r9IylHmNblJdl&R0hYC{G?O` z&)mfH)S%SFl*+=BsWuD@%o>>?5hW46K32*3xq68pHF_1f1wh>l3^w)^1&PVosU-?Y zsp*+{wo31J?^jaDOtDo8H}y5}EpSfF$n>ZxN)4{^3rViZPPR-@vbR&PsjvbXkegbP zs8ErclUHn2VXFi-*9yo63F|8hm3bwJ6}oxF$}kgLQj3#|G7CyF^YauyCMG83 zmzLNn0bL65LT&-v*t}wBFaZNhzap_f-%!s0*lEl2^R8JRMC7?NanVBh8&MvO521ZWi7A`KPhK8g6oCT>m!FugAM$)&lec_lEtDG0q5IQ4=OL~a4lW|!2W%(B!Jx1#)91+d4hGI6`b z6sLJmy(zfeVun+%KF~4xpy)-4ZkP}-4S|^O#0%uWlYeR+FwGYM6ZcJlSNy;{W9RAO z7*cU-Pq?qYaH7Dxw|Vt6-sL_XG#dCA=nEb^pfQtK4{2?@f5-Yn6Pn-PZZfE9Y0HrEx1H z9!!{UoHf^M-t)%bq7T3S{`vE#W^-XsO7HozXLCLFraX~2kgXt)p=H#>-|A#wX*ttK zsyEz0fq7Ti0YpasWR z+$R{k6EQaQOgubCjeVsOtlnOk{w`C6b(O-k z!?%v*K6AM`eR77=`V*;bYYY>29(i2Y;i6QsaMQ#fQ$;238P%!+a}++v7ICVt;*4J- z(t7o6^o7?q*{10_e_A1~bF=-!5qqwE6AORrn%yeg8+zd1YNnkg1x*k3n|IH?7GcRX zm5aSBol`57Z&RkUjQpL}K6dR7mnSsJ-QzxQ+bj^ZpL1#Y`=~J1hg`^%fgqBz3;E zypY`VWYg}1goK7Hr>$HfCJm_;pKI;?o2*r3d5-OQQhbGzDPtR#z=0d{_h&}7^PSf8 zb>5gD)M&Ftrs?+EygIQdKZL&Ay+5huW~Qg(^y=;BTJBYZU1$4y=WKYiF?T?MgwEt` zT`TsR|L}eiBb-#bV0KB@XNO?X7m|OEe!um$R*<1vcj3z0E6+0PZcey)bXUf@iL7he zsyA4hS#t{wI^H6T7(3Ke0lyCJVujWX{t((u~qp@l3TlWoH zzfI9w__aZNhOnDxgV^fc$14>N2duI-*SXET!S?cG;RSYO0%GFg(Vy;~h>>%(s=VC@S26m4%0k2Q>`~uZ6p00i_ I>zopr0LdSn0ssI2 literal 0 HcmV?d00001 diff --git a/ConnectorArcGIS/Images/AddInDesktop16.png b/ConnectorArcGIS/Images/AddInDesktop16.png new file mode 100644 index 0000000000000000000000000000000000000000..5910bbf3dcd0cb09139b0c9926e00f96131d4757 GIT binary patch literal 524 zcmV+n0`vWeP)#SV*!XQdtWo`zW)u3-ITZ)bVS)1Hr@Kl zz{$$UaP`DN21cm=1AtUN5Gz1JiI2g=(Ssq}!4R(tz+M1pW@cqxuV5w1AS5Nuz{e%d z@ciLDhV#4Ef^E~*)jrVX(1?VK7tH?T6 zV6mVetE9oe&dLMU{OQ|Eumra#H^Zy{AHiV&j|FE@unXFbz5|BS4@5LRd2^9LP1=Fs z?(<^|fByc0Yxw-(Jy;XE3zP*}8B8QO7*;|Jc<}h%4F!2wFfb;P zxhYzAxw&0+>vq3KuWs}H(rta=aCh(dp7Z^j&-d3E1qyPfy+g$3^PX-BvM8b`0+z$sEF<`iyY2Ae<*Q&c8r=f|8OVVw3&**j?e;Ck zVzCTK2dhb)&pH4-5R^=}QQ41M&;^P5et#gz9sk7zdQ8wtsg|iA)B@4{v}Z_qW$A36 zS|g1a!az2SYcVJTJ5US^%!I)ois|a14(e*jz5%?O4nZ^~0%zAJ4|Px%*Qkl&E^=T> z6egvpHz0tI--L%3oLe-0T-F58R?EQ6YCCj}{U&QYu6$zv)bbcNKmd3m+_>vfks-#) zS+kcvH2!lU0R_CwMvf`X*4FLOL@5)Jax6; z@zjyXMoRSp5m`dtYk{B>43|ldep^vNO<~0$sBgFmzQ8Al#W%p^tOAj@!pP@Q82B&( z?xq{SRhAgbf_ZT#W>f)e8~?(cDQ3_(ZOVn^KRz(!*X6hUv&46xLfHSK4s) z{cGSW+o5wJma#18FFSjjaa9}vYo3#w*qX9np;VV%hI1#I$w)f=d;}b3hh_~hDsnr%?w?u=t}mEXYC)KkXZhqyUjxwE z(wvcdBbC~Wuqt9 + + + + + + + + diff --git a/ConnectorArcGIS/SpeckleDUI3.xaml.cs b/ConnectorArcGIS/SpeckleDUI3.xaml.cs new file mode 100644 index 0000000000..9d10d9ac17 --- /dev/null +++ b/ConnectorArcGIS/SpeckleDUI3.xaml.cs @@ -0,0 +1,62 @@ +/* + + Copyright 2022 Esri + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + + See the License for the specific language governing permissions and + limitations under the License. + +*/ + +using System.Collections.Generic; +using System.Windows.Controls; +using System.Windows.Threading; +using DUI3; +using Microsoft.Web.WebView2.Core; +using Speckle.Core.Logging; + +namespace ConnectorArcGIS; + +/// +/// Interaction logic for WebViewBrowserView.xaml +/// +public partial class SpeckleDUI3 : UserControl +{ + public SpeckleDUI3() + { + InitializeComponent(); + Browser.CoreWebView2InitializationCompleted += OnInitialized; + } + + private void ShowDevToolsMethod() => Browser.CoreWebView2.OpenDevToolsWindow(); + + private void ExecuteScriptAsyncMethod(string script) + { + if (!Browser.IsInitialized) + { + throw new SpeckleException("Failed to execute script, Webview2 is not initialized yet."); + } + + Browser.Dispatcher.Invoke(() => Browser.ExecuteScriptAsync(script), DispatcherPriority.Background); + } + + private void OnInitialized(object sender, CoreWebView2InitializationCompletedEventArgs e) + { + List bindings = Bindings.Factory.CreateBindings(); + + foreach (IBinding binding in bindings) + { + BrowserBridge bridge = new(Browser, binding, ExecuteScriptAsyncMethod, ShowDevToolsMethod); + Browser.CoreWebView2.AddHostObjectToScript(binding.Name, bridge); + } + } +} diff --git a/ConnectorArcGIS/SpeckleDUI3ViewModel.cs b/ConnectorArcGIS/SpeckleDUI3ViewModel.cs new file mode 100644 index 0000000000..561a13d42e --- /dev/null +++ b/ConnectorArcGIS/SpeckleDUI3ViewModel.cs @@ -0,0 +1,92 @@ +/* + + Copyright 2022 Esri + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + + See the License for the specific language governing permissions and + limitations under the License. + +*/ + +using ArcGIS.Core.CIM; +using ArcGIS.Desktop.Core; +using ArcGIS.Desktop.Framework; +using ArcGIS.Desktop.Framework.Contracts; + +using System.Threading.Tasks; + +namespace ConnectorArcGIS; + +internal class SpeckleDUI3ViewModel : ViewStatePane +{ + private const string VIEW_PANE_ID = "SpeckleDUI3_SpeckleDUI3"; + + /// + /// Consume the passed in CIMView. Call the base constructor to wire up the CIMView. + /// + public SpeckleDUI3ViewModel(CIMView view) + : base(view) { } + + /// + /// Create a new instance of the pane. + /// + internal static SpeckleDUI3ViewModel Create() + { + // Otherwise crash on SqliteConnection + SQLitePCL.Batteries.Init(); + var view = new CIMGenericView { ViewType = VIEW_PANE_ID }; + return FrameworkApplication.Panes.Create(VIEW_PANE_ID, new object[] { view }) as SpeckleDUI3ViewModel; + } + + #region Pane Overrides + + /// + /// Must be overridden in child classes used to persist the state of the view to the CIM. + /// + public override CIMView ViewState + { + get + { + _cimView.InstanceID = (int)InstanceID; + return _cimView; + } + } + + /// + /// Called when the pane is initialized. + /// + protected override async Task InitializeAsync() + { + await base.InitializeAsync(); + } + + /// + /// Called when the pane is uninitialized. + /// + protected override async Task UninitializeAsync() + { + await base.UninitializeAsync(); + } + + #endregion Pane Overrides +} + +/// +/// Button implementation to create a new instance of the pane and activate it. +/// +internal class SpeckleDUI3OpenButton : Button +{ + protected override void OnClick() + { + SpeckleDUI3ViewModel.Create(); + } +} diff --git a/ConnectorArcGIS/SpeckleModule.cs b/ConnectorArcGIS/SpeckleModule.cs new file mode 100644 index 0000000000..e50ef359d4 --- /dev/null +++ b/ConnectorArcGIS/SpeckleModule.cs @@ -0,0 +1,51 @@ +/* + + Copyright 2022 Esri + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + + See the License for the specific language governing permissions and + limitations under the License. + +*/ + +using ArcGIS.Desktop.Framework; +using ArcGIS.Desktop.Framework.Contracts; + +namespace ConnectorArcGIS; + +/// +/// This sample shows how to implement pane that contains an Edge WebView2 control using the built-in ArcGIS Pro SDK's WebBrowser control. For details on how to utilize the WebBrowser control in an add-in see here: https://github.com/Esri/arcgis-pro-sdk/wiki/ProConcepts-Framework#webbrowser For details on how to utilize the Microsoft Edge web browser control in an add-in see here: https://github.com/Esri/arcgis-pro-sdk/wiki/ProConcepts-Framework#webbrowser-control +/// +internal class SpeckleModule : Module +{ + private static SpeckleModule s_this; + + /// + /// Retrieve the singleton instance to this module here + /// + public static SpeckleModule Current => + s_this ??= (SpeckleModule)FrameworkApplication.FindModule("ConnectorArcGIS_Module"); + + #region Overrides + /// + /// Called by Framework when ArcGIS Pro is closing + /// + /// False to prevent Pro from closing, otherwise True + protected override bool CanUnload() + { + //TODO - add your business logic + //return false to ~cancel~ Application close + return true; + } + + #endregion Overrides +} diff --git a/ConnectorArcGIS/Utils/ArcGisDocumentStore.cs b/ConnectorArcGIS/Utils/ArcGisDocumentStore.cs new file mode 100644 index 0000000000..dbd331d35c --- /dev/null +++ b/ConnectorArcGIS/Utils/ArcGisDocumentStore.cs @@ -0,0 +1,21 @@ +using DUI3.Models; + +namespace ConnectorArcGIS.Utils; + +public class ArcGisDocumentStore : DocumentModelStore +{ + public ArcGisDocumentStore() + { + // Subscribe here document related events like OnSave, OnClose, OnOpen etc... + } + + public override void WriteToFile() + { + // Implement the logic to save it to file + } + + public override void ReadFromFile() + { + // Implement the logic to read it from file + } +} diff --git a/ConnectorArcGIS/app.config b/ConnectorArcGIS/app.config new file mode 100644 index 0000000000..0c6db14149 --- /dev/null +++ b/ConnectorArcGIS/app.config @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ConnectorAutocadCivil/AutocadCivilDUI3/Autocad2022/ConnectorAutocad2022DUI3.csproj b/ConnectorAutocadCivil/AutocadCivilDUI3/Autocad2022/ConnectorAutocad2022DUI3.csproj new file mode 100644 index 0000000000..a81dca74cc --- /dev/null +++ b/ConnectorAutocadCivil/AutocadCivilDUI3/Autocad2022/ConnectorAutocad2022DUI3.csproj @@ -0,0 +1,50 @@ + + + Speckle.ConnectorAutocadDUI3 + ConnectorAutocadDUI3 + true + net48 + Program + $(ProgramW6432)\Autodesk\AutoCAD 2022\acad.exe + x64 + ConnectorAutocad2022DUI3 + ConnectorAutocad2022DUI3 + $(DefineConstants);AUTOCAD2022DUI3 + false + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ..\..\..\..\..\..\..\..\Windows\Microsoft.NET\assembly\GAC_MSIL\WindowsFormsIntegration\v4.0_4.0.0.0__31bf3856ad364e35\WindowsFormsIntegration.dll + + + + + diff --git a/ConnectorAutocadCivil/AutocadCivilDUI3/Autocad2023/ConnectorAutocad2023DUI3.csproj b/ConnectorAutocadCivil/AutocadCivilDUI3/Autocad2023/ConnectorAutocad2023DUI3.csproj new file mode 100644 index 0000000000..7292ea6470 --- /dev/null +++ b/ConnectorAutocadCivil/AutocadCivilDUI3/Autocad2023/ConnectorAutocad2023DUI3.csproj @@ -0,0 +1,47 @@ + + + Speckle.ConnectorAutocadDUI3 + ConnectorAutocadDUI3 + true + net48 + Program + $(ProgramW6432)\Autodesk\AutoCAD 2023\acad.exe + x64 + ConnectorAutocad2023DUI3 + ConnectorAutocad2023DUI3 + $(DefineConstants);AUTOCAD2023DUI3 + false + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/AutocadCivilDUI3Shared.projitems b/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/AutocadCivilDUI3Shared.projitems new file mode 100644 index 0000000000..5aebdd642f --- /dev/null +++ b/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/AutocadCivilDUI3Shared.projitems @@ -0,0 +1,34 @@ + + + + $(MSBuildAllProjects);$(MSBuildThisFileFullPath) + true + C0FBC7B6-923D-4D92-96FC-B217F620512D + + + AutocadCivilDUI3Shared + + + + + + + + + + DUI3PanelWebView.xaml + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/AutocadCivilDUI3Shared.shproj b/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/AutocadCivilDUI3Shared.shproj new file mode 100644 index 0000000000..99045e1070 --- /dev/null +++ b/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/AutocadCivilDUI3Shared.shproj @@ -0,0 +1,11 @@ + + + + {2BDE80E8-5F26-4E57-BBA6-109120F5D4EE} + + + + + + + diff --git a/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Bindings/BasicConnectorBindingAutocad.cs b/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Bindings/BasicConnectorBindingAutocad.cs new file mode 100644 index 0000000000..381323f891 --- /dev/null +++ b/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Bindings/BasicConnectorBindingAutocad.cs @@ -0,0 +1,131 @@ +using System; +using System.Linq; +using System.Reflection; +using AutocadCivilDUI3Shared.Extensions; +using AutocadCivilDUI3Shared.Utils; +using Autodesk.AutoCAD.ApplicationServices; +using Autodesk.AutoCAD.DatabaseServices; +using DUI3; +using DUI3.Bindings; +using DUI3.Models; +using Sentry.Reflection; +using Speckle.Core.Credentials; +using Application = Autodesk.AutoCAD.ApplicationServices.Core.Application; + +namespace Speckle.ConnectorAutocadDUI3.Bindings; + +public class BasicConnectorBindingAutocad : IBasicConnectorBinding +{ + public string Name { get; set; } = "baseBinding"; + public IBridge Parent { get; set; } + + private static Document Doc => Application.DocumentManager.MdiActiveDocument; + private readonly AutocadDocumentModelStore _store; + + public BasicConnectorBindingAutocad(AutocadDocumentModelStore store) + { + _store = store; + _store.DocumentChanged += (_, _) => + { + BasicConnectorBindingCommands.NotifyDocumentChanged(Parent); + }; + } + + public string GetConnectorVersion() => Assembly.GetAssembly(GetType()).GetNameAndVersion().Version; + + public string GetSourceApplicationName() => Core.Kits.HostApplications.AutoCAD.Slug; + + public string GetSourceApplicationVersion() + { +#if AUTOCAD2023DUI3 + return "2023"; +# endif +#if AUTOCAD2022DUI3 + return "2022"; +#endif + } + + public Account[] GetAccounts() => AccountManager.GetAccounts().ToArray(); + + public DocumentInfo GetDocumentInfo() + { + if (Doc == null) return null; + string name = Doc.Name.Split(System.IO.Path.PathSeparator).Reverse().First(); + return new DocumentInfo() + { + Name = name, + Id = Doc.Name, + Location = Doc.Name + }; + } + + public DocumentModelStore GetDocumentState() => _store; + + public void AddModel(ModelCard model) => _store.Models.Add(model); + + public void UpdateModel(ModelCard model) + { + int idx = _store.Models.FindIndex(m => model.ModelCardId == m.ModelCardId); + _store.Models[idx] = model; + } + + public void RemoveModel(ModelCard model) + { + int index = _store.Models.FindIndex(m => m.ModelCardId == model.ModelCardId); + _store.Models.RemoveAt(index); + } + + public void HighlightModel(string modelCardId) + { + if (Doc == null) + { + return; + } + var objectIds = Array.Empty(); + + var model = _store.GetModelById(modelCardId); + if (model == null) + { + return; // TODO: RECEIVERS + } + + if (model is SenderModelCard senderModelCard) + { + var dbObjects = Objects.GetObjectsFromDocument(Doc, senderModelCard.SendFilter.GetObjectIds()); + objectIds = dbObjects.Select(tuple => tuple.obj.Id).ToArray(); + } + + if (model is ReceiverModelCard { ReceiveResult: { } } receiverModelCard && receiverModelCard.ReceiveResult.BakedObjectIds.Count != 0) + { + var dbObjects = Objects.GetObjectsFromDocument(Doc, receiverModelCard.ReceiveResult.BakedObjectIds); + objectIds = dbObjects.Select(tuple => tuple.obj.Id).ToArray(); + } + + if (objectIds.Length == 0) + { + BasicConnectorBindingCommands.SetModelError(Parent, modelCardId, new OperationCanceledException("No objects found to highlight.") ); + return; + } + + Parent.RunOnMainThread(() => + { + Doc.Editor.SetImpliedSelection(Array.Empty()); // Deselects + Doc.Editor.SetImpliedSelection(objectIds); // Selects + Doc.Editor.UpdateScreen(); + + Extents3d selectedExtents = new(); + var tr = Doc.TransactionManager.StartTransaction(); + foreach (ObjectId objectId in objectIds) + { + Entity entity = tr.GetObject(objectId, OpenMode.ForRead) as Entity; + if (entity != null) + { + selectedExtents.AddExtents(entity.GeometricExtents); + } + } + Doc.Editor.Zoom(selectedExtents); + tr.Commit(); + Autodesk.AutoCAD.Internal.Utils.FlushGraphics(); + }); + } +} diff --git a/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Bindings/Factory.cs b/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Bindings/Factory.cs new file mode 100644 index 0000000000..ae41088dec --- /dev/null +++ b/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Bindings/Factory.cs @@ -0,0 +1,35 @@ +using System.Collections.Generic; +using AutocadCivilDUI3Shared.Utils; +using ConnectorAutocadDUI3.Bindings; +using DUI3; +using DUI3.Bindings; +using Speckle.ConnectorAutocadDUI3.Bindings; + +namespace AutocadCivilDUI3Shared.Bindings; + +public static class Factory +{ + private static readonly AutocadDocumentModelStore s_store = new(); + + public static List CreateBindings() + { + BasicConnectorBindingAutocad baseBindings = new(s_store); + SendBinding sendBindings = new(s_store); + ReceiveBinding receiveBindings = new(s_store); + SelectionBinding selectionBinding = new(); + + List bindingsList = + new() + { + new ConfigBinding("Autocad"), + new AccountBinding(), + new TestBinding(), + baseBindings, + sendBindings, + receiveBindings, + selectionBinding + }; + + return bindingsList; + } +} diff --git a/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Bindings/Filters.cs b/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Bindings/Filters.cs new file mode 100644 index 0000000000..6d7e2b3fa6 --- /dev/null +++ b/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Bindings/Filters.cs @@ -0,0 +1,31 @@ +using System.Collections.Generic; +using System.Linq; +using DUI3.Bindings; + +namespace AutocadCivilDUI3Shared.Bindings; + +public class AutocadEverythingFilter : EverythingSendFilter +{ + public override bool CheckExpiry(string[] changedObjectIds) + { + return true; + } + + public override List GetObjectIds() + { + return new List(); + } +} + +public class AutocadSelectionFilter : DirectSelectionSendFilter +{ + public override bool CheckExpiry(string[] changedObjectIds) + { + return SelectedObjectIds.Intersect(changedObjectIds).Any(); + } + + public override List GetObjectIds() + { + return SelectedObjectIds; + } +} diff --git a/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Bindings/ReceiveBinding.cs b/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Bindings/ReceiveBinding.cs new file mode 100644 index 0000000000..0491ca2201 --- /dev/null +++ b/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Bindings/ReceiveBinding.cs @@ -0,0 +1,228 @@ +using System; +using DUI3; +using DUI3.Bindings; +using DUI3.Models; +using AutocadCivilDUI3Shared.Utils; +using Autodesk.AutoCAD.ApplicationServices; +using Autodesk.AutoCAD.DatabaseServices; +using Speckle.Core.Kits; +using Speckle.Core.Models; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Threading; +using Autodesk.AutoCAD.EditorInput; +using Autodesk.AutoCAD.LayerManager; +using DUI3.Models.Card; +using DUI3.Operations; +using DUI3.Utils; + +namespace ConnectorAutocadDUI3.Bindings; + +public class ReceiveBinding : IReceiveBinding, ICancelable +{ + public string Name { get; set; } = "receiveBinding"; + public IBridge Parent { get; set; } + + private readonly DocumentModelStore _store; + + public CancellationManager CancellationManager { get; } = new(); + + private Document Doc => Autodesk.AutoCAD.ApplicationServices.Core.Application.DocumentManager.MdiActiveDocument; + + public ReceiveBinding(DocumentModelStore store) + { + _store = store; + } + + public void CancelReceive(string modelCardId) => CancellationManager.CancelOperation(modelCardId); + + public async void Receive(string modelCardId) + { + try + { + // 0 - Init cancellation token source -> Manager also cancel it if exist before + var cts = CancellationManager.InitCancellationTokenSource(modelCardId); + + // 1 - Get receiver card + var modelCard = _store.GetModelById(modelCardId) as ReceiverModelCard; + + // 2 - Get commit object from server + var commitObject = await Operations.GetCommitBase(Parent, modelCard, cts.Token).ConfigureAwait(true); + + if (cts.IsCancellationRequested) + { + throw new OperationCanceledException(cts.Token); + } + + // 3 - Get converter + ISpeckleConverter converter = Converters.GetConverter(Doc, Utils.VersionedAppName); + + // 4 - Traverse commit object + BasicConnectorBindingCommands.SetModelProgress(Parent, modelCardId, new ModelCardProgress() { Status = "Parsing structure" }); + var objectsToConvert = new List<(List,Base)>(); + foreach (var (objPath, obj) in commitObject.TraverseWithPath((obj) => obj is not Collection)) + { + if (cts.IsCancellationRequested) + { + throw new OperationCanceledException(cts.Token); + } + if (obj is not Collection && converter.CanConvertToNative(obj)) + { + objectsToConvert.Add((objPath, obj)); + } + } + + if (objectsToConvert.Count == 0) + { + throw new Exception("No convertible objects found."); + } + + var baseLayerPrefix = $"SPK-{modelCard.ProjectName}-{modelCard.ModelName}-"; + BasicConnectorBindingCommands.SetModelProgress(Parent, modelCardId, new ModelCardProgress() { Status = "Starting conversion" }); + + using var docLock = Doc.LockDocument(); + using var transaction = Doc.Database.TransactionManager.StartTransaction(); + + CreateLayerFilter(modelCard.ProjectName, modelCard.ModelName); + var convertedObjectIds = BakeObjects(objectsToConvert, baseLayerPrefix, modelCardId, cts, converter); + + Autodesk.AutoCAD.Internal.Utils.FlushGraphics(); + ReceiveBindingUiCommands.SetModelConversionResult(Parent, modelCardId, new ReceiveResult() { BakedObjectIds = convertedObjectIds, Display = true }); + transaction.Commit(); + } + catch (Exception e) + { + if (e is OperationCanceledException) + { + return; + } + BasicConnectorBindingCommands.SetModelError(Parent, modelCardId, e); + } + } + + private List BakeObjects(List<(List,Base)> objects, string baseLayerPrefix, string modelCardId, CancellationTokenSource cts, ISpeckleConverter converter) + { + BasicConnectorBindingCommands.SetModelProgress(Parent, modelCardId, new ModelCardProgress() { Status = "Converting" }); + var uniqueLayerNames = new HashSet(); + var handleValues = new List(); + var count = 0; + foreach (var (path, obj) in objects) + { + if (cts.IsCancellationRequested) + { + throw new OperationCanceledException(cts.Token); + } + + try + { + var layerFullName = baseLayerPrefix + string.Join("-", path); + layerFullName = Utils.RemoveInvalidChars(layerFullName); + + if (uniqueLayerNames.Add(layerFullName)) + { + CreateLayerOrPurge(layerFullName); + } + + var converted = converter.ConvertToNative(obj); + var flattened = Traversal.FlattenToNativeConversionResult(converted); + foreach (Entity conversionResult in flattened.Cast()) + { + if(conversionResult == null) + { + continue; + } + + conversionResult.Append(layerFullName); + handleValues.Add(conversionResult.Handle.Value.ToString()); + BasicConnectorBindingCommands.SetModelProgress(Parent, modelCardId, new ModelCardProgress() { Status = "Converting", Progress = (double)++count/objects.Count }); + } + } + catch (Exception e) // DO NOT CATCH SPECIFIC STUFF, conversion errors should be recoverable + { + // TODO: you know, report, etc. + Debug.WriteLine("conversion error happened."); + } + } + return handleValues; + } + + /// + /// Will create a layer with the provided name, or, if it finds an existing one, will "purge" all objects from it. + /// This ensures we're creating the new objects we've just received rather than overlaying them. + /// + /// + private void CreateLayerOrPurge(string layerName) + { + using var transaction = Doc.TransactionManager.TopTransaction; + + var layerTable = transaction.TransactionManager.GetObject(Doc.Database.LayerTableId, OpenMode.ForRead) as LayerTable; + var layerTableRecord = new LayerTableRecord() { Name = layerName }; + + var hasLayer = layerTable.Has(layerName); + if (hasLayer) + { + var tvs = new[] { new TypedValue((int)DxfCode.LayerName, layerName) }; + var selectionFilter = new SelectionFilter(tvs); + var selectionResult = Doc.Editor.SelectAll(selectionFilter).Value; + if (selectionResult == null) + { + return; + } + foreach (SelectedObject selectedObject in selectionResult) + { + transaction.GetObject(selectedObject.ObjectId, OpenMode.ForWrite).Erase(); + } + + return; + } + + layerTable.UpgradeOpen(); + layerTable.Add(layerTableRecord); + transaction.AddNewlyCreatedDBObject(layerTableRecord, true); + } + + /// + /// Creates a layer filter for the just received model, grouped under a top level filter "Speckle". Note: manual close and open of the layer properties panel required (it's an acad thing). + /// This comes in handy to quickly access the layers created for this specific model. + /// + /// + /// + private void CreateLayerFilter(string projectName, string modelName) + { + using var docLock = Doc.LockDocument(); + var filterName = Utils.RemoveInvalidChars($@"{projectName}-{modelName}"); + var layerFilterTree = Doc.Database.LayerFilters; + var layerFilterCollection = layerFilterTree.Root.NestedFilters; + var groupFilterName = "Speckle"; + LayerFilter groupFilter = null; + + foreach (LayerFilter existingFilter in layerFilterCollection) + { + if(existingFilter.Name == groupFilterName) + { + groupFilter = existingFilter; + break; + } + } + + if (groupFilter == null) + { + groupFilter = new LayerFilter() { Name = "Speckle", FilterExpression = $"NAME==\"SPK-*\""}; + layerFilterCollection.Add(groupFilter); + } + + var layerFilterExpression = $"NAME==\"SPK-{filterName}*\""; + foreach (LayerFilter lf in groupFilter.NestedFilters) + { + if (lf.Name == filterName) + { + lf.FilterExpression = layerFilterExpression; + return; + } + } + var layerFilter = new LayerFilter() { Name = filterName, FilterExpression = layerFilterExpression }; + groupFilter.NestedFilters.Add(layerFilter); + Doc.Database.LayerFilters = layerFilterTree; + } +} diff --git a/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Bindings/SelectionBinding.cs b/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Bindings/SelectionBinding.cs new file mode 100644 index 0000000000..9f71349cf6 --- /dev/null +++ b/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Bindings/SelectionBinding.cs @@ -0,0 +1,74 @@ +using System.Collections.Generic; +using Autodesk.AutoCAD.ApplicationServices; +using Autodesk.AutoCAD.DatabaseServices; +using Autodesk.AutoCAD.EditorInput; +using DUI3; +using DUI3.Bindings; +using Application = Autodesk.AutoCAD.ApplicationServices.Core.Application; + +namespace AutocadCivilDUI3Shared.Bindings; + +public class SelectionBinding : ISelectionBinding +{ + public string Name { get; set; } = "selectionBinding"; + public IBridge Parent { get; set; } + + private readonly List _visitedDocuments = new(); + + public SelectionBinding() + { + Application.DocumentManager.DocumentActivated += (sender, e) => OnDocumentChanged(e.Document); + } + + private void OnDocumentChanged(Document document) + { + // TODO: null check here + if (document == null) + { + return; + } + if (!_visitedDocuments.Contains(document)) + { + document.ImpliedSelectionChanged += (_, _) => + { + Parent.RunOnMainThread(OnSelectionChanged); + }; + _visitedDocuments.Add(document); + } + } + + private void OnSelectionChanged() + { + SelectionInfo selInfo = GetSelection(); + Parent.SendToBrowser(DUI3.Bindings.SelectionBindingEvents.SetSelection, selInfo); + } + + public SelectionInfo GetSelection() + { + + Document doc = Application.DocumentManager.MdiActiveDocument; + List objs = new(); + if (doc != null) + { + PromptSelectionResult selection = doc.Editor.SelectImplied(); + if (selection.Status == PromptStatus.OK) + { + using var tr = doc.TransactionManager.StartTransaction(); + foreach (SelectedObject obj in selection.Value) + { + var dbObject = tr.GetObject(obj.ObjectId, OpenMode.ForRead); + if (dbObject == null /*|| !dbObject.Visible()*/ ) + { + continue; + } + + var handleString = dbObject.Handle.Value.ToString(); + objs.Add(handleString); + } + tr.Commit(); + tr.Dispose(); + } + } + return new SelectionInfo { SelectedObjectIds = objs, Summary = $"{objs.Count} objects" }; + } +} diff --git a/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Bindings/SendBinding.cs b/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Bindings/SendBinding.cs new file mode 100644 index 0000000000..e993f3e073 --- /dev/null +++ b/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Bindings/SendBinding.cs @@ -0,0 +1,201 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Threading; +using AutocadCivilDUI3Shared.Utils; +using Autodesk.AutoCAD.ApplicationServices; +using Autodesk.AutoCAD.DatabaseServices; +using DUI3; +using DUI3.Bindings; +using DUI3.Models.Card; +using DUI3.Operations; +using DUI3.Utils; +using Speckle.Core.Api; +using Speckle.Core.Kits; +using Speckle.Core.Models; +using Speckle.Core.Transports; +using Application = Autodesk.AutoCAD.ApplicationServices.Core.Application; + +namespace AutocadCivilDUI3Shared.Bindings; + +public class SendBinding : ISendBinding, ICancelable +{ + public string Name { get; set; } = "sendBinding"; + + public IBridge Parent { get; set; } + + private readonly AutocadDocumentModelStore _store; + + private Document Doc => Application.DocumentManager.MdiActiveDocument; + + private HashSet ChangedObjectIds { get; set; } = new(); + + public SendBinding(AutocadDocumentModelStore store) + { + _store = store; + Application.DocumentManager.DocumentActivated += (sender, args) => SubscribeToObjectChanges(args.Document); + } + + private readonly List _docSubsTracker = new(); + private void SubscribeToObjectChanges(Document doc) + { + if (doc == null || doc.Database == null || _docSubsTracker.Contains(doc.Name)) + { + return; + } + + _docSubsTracker.Add(doc.Name); + doc.Database.ObjectAppended += (_, e) => OnChangeChangedObjectIds(e.DBObject); + doc.Database.ObjectErased += (_, e) => OnChangeChangedObjectIds(e.DBObject); + doc.Database.ObjectModified += (_, e) => OnChangeChangedObjectIds(e.DBObject); + } + + private void OnChangeChangedObjectIds(DBObject dBObject) + { + ChangedObjectIds.Add(dBObject.Handle.Value.ToString()); + AutocadIdleManager.SubscribeToIdle(RunExpirationChecks); + } + + public List GetSendFilters() => new() { new AutocadEverythingFilter(), new AutocadSelectionFilter() }; + + public CancellationManager CancellationManager { get; } = new(); + + public void Send(string modelCardId) + { + Parent.RunOnMainThread(() => SendInternal(modelCardId)); + } + + private async void SendInternal(string modelCardId) + { + try + { + // 0 - Init cancellation token source -> Manager also cancel it if exist before + var cts = CancellationManager.InitCancellationTokenSource(modelCardId); + + // 1 - Setup + var model = _store.GetModelById(modelCardId) as SenderModelCard; + var account = Accounts.GetAccount(model.AccountId); + var converter = Converters.GetConverter(Doc, Utils.Utils.VersionedAppName); + + // 2 - Get elements to convert + var dbObjects = Objects.GetObjectsFromDocument(Doc, model.SendFilter.GetObjectIds()); + if (dbObjects.Count == 0) + { + throw new InvalidOperationException("No objects were found. Please update your send filter!"); + } + // 5 - Convert objects + var commitObject = ConvertObjects(dbObjects, converter, modelCardId, cts); + + if (cts.IsCancellationRequested) + { + return; + } + + // 6 - Get transports + List transports = new() { new ServerTransport(account, model.ProjectId) }; + + // 7 - Serialize and Send objects + BasicConnectorBindingCommands.SetModelProgress(Parent, modelCardId, new ModelCardProgress { Status = "Uploading..." }); + string objectId = await Speckle.Core.Api.Operations + .Send(commitObject, cts.Token, transports, disposeTransports: true) + .ConfigureAwait(true); + + if (cts.IsCancellationRequested) + { + throw new OperationCanceledException(cts.Token); + } + + // 8 - Create Version + BasicConnectorBindingCommands.SetModelProgress(Parent, modelCardId, new ModelCardProgress { Status = "Linking version to model..." }); + + // 8 - Create the version (commit) + var apiClient = new Client(account); + string versionId = await apiClient.CommitCreate(new CommitCreateInput() + { + streamId = model.ProjectId, branchName = model.ModelId, sourceApplication = "Rhino", objectId = objectId + }, cts.Token).ConfigureAwait(true); + + SendBindingUiCommands.SetModelCreatedVersionId(Parent, modelCardId, versionId); + apiClient.Dispose(); + } + catch (Exception e) // NOTE: Always catch everything we can! + { + if (e is OperationCanceledException) + { + return; + } + + BasicConnectorBindingCommands.SetModelError(Parent, modelCardId, e); + } + } + + public void CancelSend(string modelCardId) => CancellationManager.CancelOperation(modelCardId); + + private void RunExpirationChecks() + { + List senders = _store.GetSenders(); + string[] objectIdsList = ChangedObjectIds.ToArray(); + List expiredSenderIds = new(); + + foreach (SenderModelCard sender in senders) + { + bool isExpired = sender.SendFilter.CheckExpiry(objectIdsList); + if (isExpired) + { + expiredSenderIds.Add(sender.ModelCardId); + } + } + + SendBindingUiCommands.SetModelsExpired(Parent, expiredSenderIds); + ChangedObjectIds = new HashSet(); + } + + private Base ConvertObjects( + List<(DBObject obj, string layer, string applicationId)> dbObjects, + ISpeckleConverter converter, + string modelCardId, + CancellationTokenSource cts + ) + { + var modelWithLayers = new Collection() { name = Doc.Name.Split( new [] {"\\"}, StringSplitOptions.None).Reverse().First(), collectionType = "root" }; + var collectionCache = new Dictionary(); + int count = 0; + + foreach (var tuple in dbObjects) + { + if (cts.IsCancellationRequested) + { + throw new OperationCanceledException(cts.Token); + } + try + { + Base converted = converter.ConvertToSpeckle(tuple.obj); + converted.applicationId = tuple.applicationId; + + if (converted == null) + { + // TODO: report, error out, etc. + } + + // Create and add a collection for each layer if not done so already. + if (!collectionCache.ContainsKey(tuple.layer)) + { + collectionCache[tuple.layer] = new Collection() { name = tuple.layer, collectionType = "layer" }; + modelWithLayers.elements.Add(collectionCache[tuple.layer]); + } + + collectionCache[tuple.layer].elements.Add(converted); + + BasicConnectorBindingCommands.SetModelProgress(Parent, modelCardId, new ModelCardProgress() { Status = "Converting", Progress = (double)++count / dbObjects.Count}); + } + catch (Exception e) // THE FUCK + { + // TODO: Add to report, etc. + Debug.WriteLine(e.Message); + } + } + + return modelWithLayers; + } +} diff --git a/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/DUI3PanelWebView.xaml b/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/DUI3PanelWebView.xaml new file mode 100644 index 0000000000..5565b36d5e --- /dev/null +++ b/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/DUI3PanelWebView.xaml @@ -0,0 +1,20 @@ + + + + + + + + + diff --git a/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/DUI3PanelWebView.xaml.cs b/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/DUI3PanelWebView.xaml.cs new file mode 100644 index 0000000000..c85dab5ce3 --- /dev/null +++ b/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/DUI3PanelWebView.xaml.cs @@ -0,0 +1,40 @@ +using System.Collections.Generic; +using System.Windows.Controls; +using System.Windows.Threading; +using AutocadCivilDUI3Shared.Bindings; +using DUI3; +using Microsoft.Web.WebView2.Core; +using Speckle.Core.Logging; + +namespace Speckle.ConnectorAutocadDUI3; + +public partial class Dui3PanelWebView : UserControl +{ + public Dui3PanelWebView() + { + InitializeComponent(); + Browser.CoreWebView2InitializationCompleted += Browser_Initialized_Completed; + } + + private void ShowDevToolsMethod() => Browser.CoreWebView2.OpenDevToolsWindow(); + + private void ExecuteScriptAsyncMethod(string script) + { + if (!Browser.IsInitialized) + { + throw new SpeckleException("Failed to execute script, Webview2 is not initialized yet."); + } + Browser.Dispatcher.Invoke(() => Browser.ExecuteScriptAsync(script), DispatcherPriority.Background); + } + + private void Browser_Initialized_Completed(object sender, CoreWebView2InitializationCompletedEventArgs e) + { + List bindings = Factory.CreateBindings(); + + foreach (IBinding binding in bindings) + { + var bridge = new BrowserBridge(Browser, binding, ExecuteScriptAsyncMethod, ShowDevToolsMethod); + Browser.CoreWebView2.AddHostObjectToScript(binding.Name, bridge); + } + } +} diff --git a/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Entry.cs b/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Entry.cs new file mode 100644 index 0000000000..f9dfc6ace7 --- /dev/null +++ b/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Entry.cs @@ -0,0 +1,72 @@ +using System; +using System.Drawing; +using System.IO; +using System.Reflection; +using Autodesk.AutoCAD.Windows; +using Autodesk.AutoCAD.Runtime; +using Speckle.ConnectorAutocadDUI3; + +namespace AutocadCivilDUI3Shared; + +public class App : IExtensionApplication +{ + public void Initialize() => AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(OnAssemblyResolve); + + public void Terminate() + { + // Shh. + } + + private Assembly OnAssemblyResolve(object sender, ResolveEventArgs args) + { + Assembly a = null; + string name = args.Name.Split(',')[0]; + string path = Path.GetDirectoryName(typeof(App).Assembly.Location); + + string assemblyFile = Path.Combine(path, name + ".dll"); + + if (File.Exists(assemblyFile)) + { + a = Assembly.LoadFrom(assemblyFile); + } + + return a; + } +} + +public class SpeckleAutocadDui3Command +{ + private static PaletteSet PaletteSet { get; set; } + private static readonly Guid s_id = new("6AD40744-85BF-4B62-9408-5D3CCEB8B876"); + + [CommandMethod("SpeckleDUI3")] + public void SpeckleCommand() + { + if (PaletteSet != null) + { + FocusPalette(); + return; + } + + PaletteSet = new PaletteSet("Speckle DUI3", s_id) + { + Size = new Size(400, 500), + DockEnabled = (DockSides)((int)DockSides.Left + (int)DockSides.Right) + }; + + // NOTE: Autocad 2022 seems to support Webview2 rather well, hence I (Dim) have removed + // all references to Cef. CefSharp also worked rather fine, and we would need to match + // the correct versions, etc.. But it seems it's not needed! + var panelWebView = new Dui3PanelWebView(); + + PaletteSet.AddVisual("Speckle DUI3 WebView", panelWebView); + + FocusPalette(); + } + + private void FocusPalette() + { + PaletteSet.KeepFocus = true; + PaletteSet.Visible = true; + } +} diff --git a/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Extensions/Editor.cs b/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Extensions/Editor.cs new file mode 100644 index 0000000000..f388b0c4ee --- /dev/null +++ b/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Extensions/Editor.cs @@ -0,0 +1,27 @@ +using System; +using Autodesk.AutoCAD.DatabaseServices; +using Autodesk.AutoCAD.EditorInput; +using Autodesk.AutoCAD.Geometry; + +namespace AutocadCivilDUI3Shared.Extensions; + +public static class EditorExtensions +{ + public static void Zoom(this Editor editor, Extents3d ext) + { + if (editor == null) + { + throw new ArgumentNullException(nameof(editor)); + } + using ViewTableRecord view = editor.GetCurrentView(); + Matrix3d worldToEye = + Matrix3d.WorldToPlane(view.ViewDirection) + * Matrix3d.Displacement(Point3d.Origin - view.Target) + * Matrix3d.Rotation(view.ViewTwist, view.ViewDirection, view.Target); + ext.TransformBy(worldToEye); + view.Width = ext.MaxPoint.X - ext.MinPoint.X; + view.Height = ext.MaxPoint.Y - ext.MinPoint.Y; + view.CenterPoint = new Point2d((ext.MaxPoint.X + ext.MinPoint.X) / 2.0, (ext.MaxPoint.Y + ext.MinPoint.Y) / 2.0); + editor.SetCurrentView(view); + } +} diff --git a/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Extensions/Extends3d.cs b/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Extensions/Extends3d.cs new file mode 100644 index 0000000000..5f05fec54f --- /dev/null +++ b/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Extensions/Extends3d.cs @@ -0,0 +1,39 @@ +using Autodesk.AutoCAD.DatabaseServices; +using Autodesk.AutoCAD.EditorInput; + +namespace AutocadCivilDUI3Shared.Extensions; + +public static class Extends3dExtensions +{ + public static Extents3d FromObjectIds(Editor editor) + { + Transaction tr = editor.Document.Database.TransactionManager.StartTransaction(); + + PromptSelectionResult selectionResult = editor.SelectImplied(); + + if (selectionResult.Status == PromptStatus.OK) + { + SelectionSet selectionSet = selectionResult.Value; + + if (selectionSet.Count > 0) + { + // Create a bounding box to include all selected objects + Extents3d selectedExtents = new(); + + foreach (ObjectId objectId in selectionSet.GetObjectIds()) + { + Entity entity = tr.GetObject(objectId, OpenMode.ForRead) as Entity; + if (entity != null) + { + selectedExtents.AddExtents(entity.GeometricExtents); + } + } + tr.Commit(); + return selectedExtents; + } + } + + tr.Commit(); + return new Extents3d(); + } +} diff --git a/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Utils/AutocadDocumentManager.cs b/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Utils/AutocadDocumentManager.cs new file mode 100644 index 0000000000..73cc0dd995 --- /dev/null +++ b/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Utils/AutocadDocumentManager.cs @@ -0,0 +1,149 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Text; +using Autodesk.AutoCAD.ApplicationServices; +using Autodesk.AutoCAD.DatabaseServices; + +namespace AutocadCivilDUI3Shared.Utils; + +public static class AutocadDocumentManager +{ + private const string SPECKLE_KEY = "Speckle_DUI3"; + private const string SPECKLE_MODEL_CARDS_KEY = "Speckle_DUI3_Model_Cards"; + + /// + /// Returns all the speckle model cards present in the current document. + /// + /// + /// + public static string ReadModelCards(Document doc) + { + if (doc == null) + { + return null; + } + + using (TransactionContext.StartTransaction(doc)) + { + Transaction tr = doc.Database.TransactionManager.TopTransaction; + DBDictionary nod = (DBDictionary)tr.GetObject(doc.Database.NamedObjectsDictionaryId, OpenMode.ForRead); + if (!nod.Contains(SPECKLE_KEY)) + { + return null; + } + + DBDictionary speckleDict = tr.GetObject(nod.GetAt(SPECKLE_KEY), OpenMode.ForRead) as DBDictionary; + if (speckleDict == null || speckleDict.Count == 0) + { + return null; + } + + ObjectId id = speckleDict.GetAt(SPECKLE_MODEL_CARDS_KEY); + if (id == ObjectId.Null) + { + return null; + } + + Xrecord record = tr.GetObject(id, OpenMode.ForRead) as Xrecord; + string value = GetXrecordData(record); + + try + { + //Try to decode here because there is old data + return Base64Decode(value); + } + catch (ApplicationException e) + { + Debug.WriteLine(e); + return null; + } + } + } + + /// + /// Writes the model cards to the current document. + /// + /// + /// + public static void WriteModelCards(Document doc, string modelCardsString) + { + if (doc == null) + { + return; + } + + using (TransactionContext.StartTransaction(doc)) + { + Transaction tr = doc.Database.TransactionManager.TopTransaction; + var nod = (DBDictionary)tr.GetObject(doc.Database.NamedObjectsDictionaryId, OpenMode.ForRead); + DBDictionary speckleDict; + if (nod.Contains(SPECKLE_KEY)) + { + speckleDict = (DBDictionary)tr.GetObject(nod.GetAt(SPECKLE_KEY), OpenMode.ForWrite); + } + else + { + speckleDict = new DBDictionary(); + nod.UpgradeOpen(); + nod.SetAt(SPECKLE_KEY, speckleDict); + tr.AddNewlyCreatedDBObject(speckleDict, true); + } + Xrecord xRec = new(); + xRec.Data = CreateResultBuffer(modelCardsString); + speckleDict.SetAt(SPECKLE_MODEL_CARDS_KEY, xRec); + tr.AddNewlyCreatedDBObject(xRec, true); + } + } + + private static ResultBuffer CreateResultBuffer(string value) + { + int size = 1024; + var valueEncoded = Base64Encode(value); + var valueEncodedList = SplitString(valueEncoded, size); + + ResultBuffer rb = new(); + + foreach (string valueEncodedSplit in valueEncodedList) + { + rb.Add(new TypedValue((int)DxfCode.Text, valueEncodedSplit)); + } + + return rb; + } + + private static string GetXrecordData(Xrecord pXrecord) + { + StringBuilder valueEncoded = new(); + foreach (TypedValue typedValue in pXrecord.Data) + { + if (typedValue.TypeCode == (int)DxfCode.Text) + { + valueEncoded.Append(typedValue.Value.ToString()); + } + } + + return valueEncoded.ToString(); + } + + private static string Base64Encode(string plainText) + { + var plainTextBytes = System.Text.Encoding.UTF8.GetBytes(plainText); + return System.Convert.ToBase64String(plainTextBytes); + } + + private static string Base64Decode(string base64EncodedData) + { + var base64EncodedBytes = System.Convert.FromBase64String(base64EncodedData); + return System.Text.Encoding.UTF8.GetString(base64EncodedBytes); + } + + private static IEnumerable SplitString(string text, int chunkSize) + { + for (int offset = 0; offset < text.Length; offset += chunkSize) + { + int size = Math.Min(chunkSize, text.Length - offset); + yield return text.Substring(offset, size); + } + } +} diff --git a/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Utils/AutocadDocumentModelStore.cs b/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Utils/AutocadDocumentModelStore.cs new file mode 100644 index 0000000000..4711f51045 --- /dev/null +++ b/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Utils/AutocadDocumentModelStore.cs @@ -0,0 +1,82 @@ +using System.Collections.Generic; +using Autodesk.AutoCAD.ApplicationServices; +using DUI3.Models; +using Application = Autodesk.AutoCAD.ApplicationServices.Core.Application; + +namespace AutocadCivilDUI3Shared.Utils; + +public class AutocadDocumentModelStore : DocumentModelStore +{ + private static Document Doc { get; set; } + private static string s_previousDocName; + + public AutocadDocumentModelStore() + { + if (Doc != null) + { + IsDocumentInit = true; + } + + Application.DocumentManager.DocumentToBeDestroyed += (_,_) => WriteToFile(); + Application.DocumentManager.DocumentActivated += (_, e) => OnDocChangeInternal(e.Document); + Autodesk.AutoCAD.ApplicationServices.Application.DocumentWindowCollection.DocumentWindowActivated += + (_, args) => OnDocChangeInternal(args.DocumentWindow.Document as Document); + } + + /// + /// Tracks whether the doc has been subscribed to save events. + /// TODO: two separate docs can have the same name, this is a brittle implementation - should be correlated with file location. + /// + private readonly List _saveToDocSubTracker = new(); + + private void OnDocChangeInternal(Document doc) + { + Doc = doc; + var nullDocName = "Null Doc"; + var currentDocName = doc != null ? doc.Name : nullDocName; + if (s_previousDocName == currentDocName) + { + return; + } + + s_previousDocName = doc != null ? doc.Name : nullDocName; + + if (doc!=null && !_saveToDocSubTracker.Contains(doc.Name)) + { + doc.BeginDocumentClose += (_,_) => WriteToFile(); + doc.Database.BeginSave += (_,_) => WriteToFile(); + _saveToDocSubTracker.Add(doc.Name); + } + + ReadFromFile(); + OnDocumentChanged(); + } + + public override void ReadFromFile() + { + Models = new List(); + if (Doc == null) + { + return; + } + + string serializedModelCards = AutocadDocumentManager.ReadModelCards(Doc); + if (serializedModelCards == null) + { + return; + } + + Models = Deserialize(serializedModelCards); + } + + public override void WriteToFile() + { + if (Doc == null) + { + return; + } + + string modelCardsString = Serialize(); + AutocadDocumentManager.WriteModelCards(Doc, modelCardsString); + } +} diff --git a/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Utils/AutocadIdleManager.cs b/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Utils/AutocadIdleManager.cs new file mode 100644 index 0000000000..2d8cefd1d0 --- /dev/null +++ b/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Utils/AutocadIdleManager.cs @@ -0,0 +1,40 @@ +using System; +using System.Collections.Concurrent; +using Autodesk.AutoCAD.ApplicationServices.Core; + +namespace AutocadCivilDUI3Shared.Utils; + +public static class AutocadIdleManager +{ + private static readonly ConcurrentDictionary s_sCalls = new(); + private static bool s_hasSubscribed; + + /// + /// Subscribe deferred action to RhinoIdle event to run it whenever Rhino become idle. + /// + /// Action to call whenever Rhino become Idle. + public static void SubscribeToIdle(Action action) + { + s_sCalls[action.Method.Name] = action; + + if (s_hasSubscribed) + { + return; + } + + s_hasSubscribed = true; + Application.Idle += OnIdleHandler; + } + + private static void OnIdleHandler(object sender, EventArgs e) + { + foreach (var kvp in s_sCalls) + { + kvp.Value(); + } + + s_sCalls.Clear(); + s_hasSubscribed = false; + Application.Idle -= OnIdleHandler; + } +} diff --git a/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Utils/Objects.cs b/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Utils/Objects.cs new file mode 100644 index 0000000000..471f89f472 --- /dev/null +++ b/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Utils/Objects.cs @@ -0,0 +1,37 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using Autodesk.AutoCAD.ApplicationServices; +using Autodesk.AutoCAD.DatabaseServices; + +namespace AutocadCivilDUI3Shared.Utils; + +public static class Objects +{ + public static List<(DBObject obj, string layer, string applicationId)> GetObjectsFromDocument(Document doc, IEnumerable objectIds) + { + using DocumentLock acLckDoc = doc.LockDocument(); + var dbObjects = new List<(DBObject, string layer, string applicationId)>(); + using Transaction tr = doc.Database.TransactionManager.StartTransaction(); + foreach (var objectIdHandle in objectIds) + { + var handle = new Handle(Convert.ToInt64(objectIdHandle)); + var hasFoundObjectId = doc.Database.TryGetObjectId(handle, out ObjectId myObjectId); + if (!hasFoundObjectId) + { + continue; + } + + var dbObject = tr.GetObject(myObjectId, OpenMode.ForRead); + if(dbObject == null) + { + continue; + } + + var layer = (dbObject as Entity)?.Layer; + dbObjects.Add((dbObject, layer, objectIdHandle)); + } + tr.Commit(); + return dbObjects; + } +} diff --git a/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Utils/TransactionContext.cs b/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Utils/TransactionContext.cs new file mode 100644 index 0000000000..cda196ea10 --- /dev/null +++ b/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Utils/TransactionContext.cs @@ -0,0 +1,29 @@ +using System; +using Autodesk.AutoCAD.ApplicationServices; +using Document = Autodesk.AutoCAD.ApplicationServices.Document; +using Autodesk.AutoCAD.DatabaseServices; + +namespace AutocadCivilDUI3Shared.Utils; + +public class TransactionContext : IDisposable +{ + private DocumentLock _documentLock; + private Transaction _transaction; + + public static TransactionContext StartTransaction(Document document) => new(document); + + private TransactionContext(Document document) + { + _documentLock = document.LockDocument(); + _transaction = document.Database.TransactionManager.StartTransaction(); + } + + public void Dispose() + { + _transaction?.Commit(); + _transaction = null; + + _documentLock?.Dispose(); + _documentLock = null; + } +} diff --git a/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Utils/Utils.cs b/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Utils/Utils.cs new file mode 100644 index 0000000000..0ba9ac7452 --- /dev/null +++ b/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Utils/Utils.cs @@ -0,0 +1,92 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Reflection; +using Autodesk.AutoCAD.ApplicationServices; +using Autodesk.AutoCAD.DatabaseServices; +using Autodesk.AutoCAD.EditorInput; +using Speckle.Core.Kits; + +namespace AutocadCivilDUI3Shared.Utils; + +public static class Utils +{ +#if AUTOCAD2021DUI3 + public static readonly string VersionedAppName = HostApplications.AutoCAD.GetVersion(HostAppVersion.v2021); + public static readonly string AppName = HostApplications.AutoCAD.Name; + public static readonly string Slug = HostApplications.AutoCAD.Slug; +#elif AUTOCAD2022DUI3 + public static readonly string VersionedAppName = HostApplications.AutoCAD.GetVersion(HostAppVersion.v2022); + public static readonly string AppName = HostApplications.AutoCAD.Name; + public static readonly string Slug = HostApplications.AutoCAD.Slug; +#elif AUTOCAD2023DUI3 + public static readonly string VersionedAppName = HostApplications.AutoCAD.GetVersion(HostAppVersion.v2023); + public static readonly string AppName = HostApplications.AutoCAD.Name; + public static readonly string Slug = HostApplications.AutoCAD.Slug; +#elif AUTOCAD2024DUI3 + public static readonly string VersionedAppName = HostApplications.AutoCAD.GetVersion(HostAppVersion.v2024); + public static readonly string AppName = HostApplications.AutoCAD.Name; + public static readonly string Slug = HostApplications.AutoCAD.Slug; +#endif + public static readonly string InvalidChars = @"<>/\:;""?*|=,‘"; + + public static string RemoveInvalidChars(string str) + { + foreach (char c in InvalidChars) + { + str = str.Replace(c.ToString(), string.Empty); + } + + return str; + } + + /// + /// Adds an entity to the autocad database model space record + /// + /// + /// + public static ObjectId Append(this Entity entity, string layer = null) + { + var db = entity.Database ?? Application.DocumentManager.MdiActiveDocument.Database; + Transaction tr = db.TransactionManager.TopTransaction; + if (tr == null) + { + return ObjectId.Null; + } + + BlockTableRecord btr = db.GetModelSpace(OpenMode.ForWrite); + if (entity.IsNewObject) + { + if (layer != null) + { + entity.Layer = layer; + } + + var id = btr.AppendEntity(entity); + tr.AddNewlyCreatedDBObject(entity, true); + return id; + } + else + { + if (layer != null) + { + entity.Layer = layer; + } + + return entity.Id; + } + } + + /// + /// Gets the document model space + /// + /// + /// + /// + public static BlockTableRecord GetModelSpace(this Database db, OpenMode mode = OpenMode.ForRead) + { + return (BlockTableRecord)SymbolUtilityServices.GetBlockModelSpaceId(db).GetObject(mode); + } + +} diff --git a/ConnectorAutocadCivil/ConnectorAutocadCivil.slnf b/ConnectorAutocadCivil/ConnectorAutocadCivil.slnf index b6dc9fe55a..b9ea145ffd 100644 --- a/ConnectorAutocadCivil/ConnectorAutocadCivil.slnf +++ b/ConnectorAutocadCivil/ConnectorAutocadCivil.slnf @@ -2,6 +2,9 @@ "solution": { "path": "..\\All.sln", "projects": [ + "ConnectorAutocadCivil\\AutocadCivilDUI3\\Autocad2022\\ConnectorAutocad2022DUI3.csproj", + "ConnectorAutocadCivil\\AutocadCivilDUI3\\Autocad2023\\ConnectorAutocad2023DUI3.csproj", + "ConnectorAutocadCivil\\AutocadCivilDUI3\\AutocadCivilDUI3Shared\\AutocadCivilDUI3Shared.shproj", "ConnectorAutocadCivil\\ConnectorAutocad2021\\ConnectorAutocad2021.csproj", "ConnectorAutocadCivil\\ConnectorAutocad2022\\ConnectorAutocad2022.csproj", "ConnectorAutocadCivil\\ConnectorAutocad2023\\ConnectorAutocad2023.csproj", @@ -16,6 +19,7 @@ "Core\\Transports\\DiskTransport\\DiskTransport.csproj", "DesktopUI2\\AvaloniaHwndHost\\AvaloniaHwndHost.csproj", "DesktopUI2\\DesktopUI2\\DesktopUI2.csproj", + "DesktopUI3\\DUI3\\DUI3.csproj", "Objects\\Converters\\ConverterAutocadCivil\\ConverterAutocad2021\\ConverterAutocad2021.csproj", "Objects\\Converters\\ConverterAutocadCivil\\ConverterAutocad2022\\ConverterAutocad2022.csproj", "Objects\\Converters\\ConverterAutocadCivil\\ConverterAutocad2023\\ConverterAutocad2023.csproj", diff --git a/ConnectorRevit/RevitDUI3/Revit2020DUI3/Properties/launchSettings.json b/ConnectorRevit/RevitDUI3/Revit2020DUI3/Properties/launchSettings.json new file mode 100644 index 0000000000..d9b9256495 --- /dev/null +++ b/ConnectorRevit/RevitDUI3/Revit2020DUI3/Properties/launchSettings.json @@ -0,0 +1,8 @@ +{ + "profiles": { + "ConnectorRevit2020DUI3": { + "commandName": "Executable", + "executablePath": "C:\\Program Files\\Autodesk\\Revit 2020\\Revit.exe" + } + } +} diff --git a/ConnectorRevit/RevitDUI3/Revit2020DUI3/Revit2020DUI3.csproj b/ConnectorRevit/RevitDUI3/Revit2020DUI3/Revit2020DUI3.csproj new file mode 100644 index 0000000000..0f5d126834 --- /dev/null +++ b/ConnectorRevit/RevitDUI3/Revit2020DUI3/Revit2020DUI3.csproj @@ -0,0 +1,66 @@ + + + true + Speckle.ConnectorRevitDUI3 + SpeckleConnectorRevitDUI3 + net48 + true + SpeckleRevit2DUI3 + 2020 + ConnectorRevitDUI3 + ConnectorRevitDUI3 + bin\$(Configuration)\ + true + $(DefineConstants);REVIT2020 + false + AnyCPU;x64 + + + x64 + false + + + x64 + false + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ConnectorRevit/RevitDUI3/Revit2023DUI3/Properties/launchSettings.json b/ConnectorRevit/RevitDUI3/Revit2023DUI3/Properties/launchSettings.json new file mode 100644 index 0000000000..79de978532 --- /dev/null +++ b/ConnectorRevit/RevitDUI3/Revit2023DUI3/Properties/launchSettings.json @@ -0,0 +1,8 @@ +{ + "profiles": { + "ConnectorRevit2023DUI3": { + "commandName": "Executable", + "executablePath": "C:\\Program Files\\Autodesk\\Revit 2023\\Revit.exe" + } + } +} diff --git a/ConnectorRevit/RevitDUI3/Revit2023DUI3/Revit2023DUI3.csproj b/ConnectorRevit/RevitDUI3/Revit2023DUI3/Revit2023DUI3.csproj new file mode 100644 index 0000000000..dea154ac98 --- /dev/null +++ b/ConnectorRevit/RevitDUI3/Revit2023DUI3/Revit2023DUI3.csproj @@ -0,0 +1,52 @@ + + + Speckle.ConnectorRevitDUI3 + SpeckleConnectorRevitDUI3 + net48 + true + SpeckleRevit2DUI3 + 2023 + ConnectorRevitDUI3 + ConnectorRevitDUI3 + bin\$(Configuration)\ + true + $(DefineConstants);REVIT2023 + false + AnyCPU;x64 + + + x64 + + + x64 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ConnectorRevit/RevitDUI3/RevitDUI3Shared/Bindings/BasicConnectorBindingRevit.cs b/ConnectorRevit/RevitDUI3/RevitDUI3Shared/Bindings/BasicConnectorBindingRevit.cs new file mode 100644 index 0000000000..3ca0a7cd6f --- /dev/null +++ b/ConnectorRevit/RevitDUI3/RevitDUI3Shared/Bindings/BasicConnectorBindingRevit.cs @@ -0,0 +1,138 @@ +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using Autodesk.Revit.DB; +using Autodesk.Revit.UI; +using DUI3; +using DUI3.Bindings; +using DUI3.Models; +using Revit.Async; +using Sentry.Reflection; +using Speckle.ConnectorRevitDUI3.Utils; +using Speckle.Core.Kits; + +namespace Speckle.ConnectorRevitDUI3.Bindings; + +public class BasicConnectorBindingRevit : IBasicConnectorBinding +{ + public string Name { get; set; } = "baseBinding"; + public IBridge Parent { get; set; } + + // POC: statics should go + private static UIApplication RevitApp { get; set; } + private static UIDocument UiDocument => RevitApp.ActiveUIDocument; + private static Document Doc => UiDocument.Document; + + private readonly RevitDocumentStore _store; + + public BasicConnectorBindingRevit(RevitDocumentStore store) + { + RevitApp = RevitAppProvider.RevitApp; + _store = store; + _store.DocumentChanged += (_, _) => + { + BasicConnectorBindingCommands.NotifyDocumentChanged(Parent); + }; + } + + public string GetConnectorVersion() => Assembly.GetAssembly(GetType()).GetNameAndVersion().Version; + + public string GetSourceApplicationName() => HostApplications.Revit.Slug; + + public string GetSourceApplicationVersion() + { +#if REVIT2020 + return "2020"; +#endif +#if REVIT2023 + return "2023"; +#endif + } + + public DocumentInfo GetDocumentInfo() + { + if (UiDocument == null) + { + return null; + } + + return new DocumentInfo + { + Name = UiDocument.Document.Title, + Id = UiDocument.Document.GetHashCode().ToString(), + Location = UiDocument.Document.PathName + }; + } + + public DocumentModelStore GetDocumentState() => _store; + + public void AddModel(ModelCard model) => _store.Models.Add(model); + + public void UpdateModel(ModelCard model) + { + int idx = _store.Models.FindIndex(m => model.ModelCardId == m.ModelCardId); + _store.Models[idx] = model; + } + + public void RemoveModel(ModelCard model) + { + int index = _store.Models.FindIndex(m => m.ModelCardId == model.ModelCardId); + _store.Models.RemoveAt(index); + } + + public void HighlightModel(string modelCardId) + { + SenderModelCard model = _store.GetModelById(modelCardId) as SenderModelCard; + List objectsIds = model.SendFilter.GetObjectIds(); + List elements = Utils.Elements.GetElementsFromDocument(Doc, objectsIds); + + List elementIds = elements.Select(e => e.Id).ToList(); + + // UiDocument operations should be wrapped into RevitTask, otherwise doesn't work on other tasks. + RevitTask.RunAsync(() => + { + UiDocument.Selection.SetElementIds(elementIds); + UiDocument.ShowElements(elementIds); + + // Create a BoundingBoxXYZ to encompass the selected elements + BoundingBoxXYZ selectionBoundingBox = new(); + bool first = true; + + foreach (ElementId elementId in elementIds) + { + Element element = Doc.GetElement(elementId); + + if (element != null) + { + BoundingBoxXYZ elementBoundingBox = element.get_BoundingBox(null); + + if (elementBoundingBox != null) + { + if (first) + { + selectionBoundingBox = elementBoundingBox; + first = false; + } + else + { + // selectionBoundingBox.Min = XYZ.Min(selectionBoundingBox.Min, elementBoundingBox.Min); + // selectionBoundingBox.Max = XYZ.Max(selectionBoundingBox.Max, elementBoundingBox.Max); + } + } + } + } + + // Zoom the view to the selection bounding box + if (!first) + { + View activeView = UiDocument.ActiveView; + + using Transaction tr = new(Doc, "Zoom to Selection"); + tr.Start(); + activeView.CropBox = selectionBoundingBox; + Doc.Regenerate(); + tr.Commit(); + } + }); + } +} diff --git a/ConnectorRevit/RevitDUI3/RevitDUI3Shared/Bindings/Factory.cs b/ConnectorRevit/RevitDUI3/RevitDUI3Shared/Bindings/Factory.cs new file mode 100644 index 0000000000..293ff7ad15 --- /dev/null +++ b/ConnectorRevit/RevitDUI3/RevitDUI3Shared/Bindings/Factory.cs @@ -0,0 +1,30 @@ +using System.Collections.Generic; +using DUI3; +using DUI3.Bindings; +using Speckle.ConnectorRevitDUI3.Utils; + +namespace Speckle.ConnectorRevitDUI3.Bindings; + +public static class Factory +{ + public static List CreateBindings(RevitDocumentStore store) + { + BasicConnectorBindingRevit baseBinding = new(store); + SelectionBinding selectionBinding = new(); + SendBinding sendBinding = new(store); + ReceiveBinding receiveBinding = new(store); + List bindingsList = + new() + { + new ConfigBinding("Revit"), + new AccountBinding(), + new TestBinding(), + baseBinding, + selectionBinding, + sendBinding, + receiveBinding + }; + + return bindingsList; + } +} diff --git a/ConnectorRevit/RevitDUI3/RevitDUI3Shared/Bindings/Filters.cs b/ConnectorRevit/RevitDUI3/RevitDUI3Shared/Bindings/Filters.cs new file mode 100644 index 0000000000..4b6fb21e21 --- /dev/null +++ b/ConnectorRevit/RevitDUI3/RevitDUI3Shared/Bindings/Filters.cs @@ -0,0 +1,32 @@ +using System.Collections.Generic; +using System.Linq; +using DUI3.Bindings; + +namespace Speckle.ConnectorRevitDUI3.Bindings; + +public class RevitEverythingFilter : EverythingSendFilter +{ + public override List GetObjectIds() + { + // TODO + return new List(); + } + + public override bool CheckExpiry(string[] changedObjectIds) + { + return true; + } +} + +public class RevitSelectionFilter : DirectSelectionSendFilter +{ + public override List GetObjectIds() + { + return SelectedObjectIds; + } + + public override bool CheckExpiry(string[] changedObjectIds) + { + return SelectedObjectIds.Intersect(changedObjectIds).Any(); + } +} diff --git a/ConnectorRevit/RevitDUI3/RevitDUI3Shared/Bindings/ReceiveBinding.cs b/ConnectorRevit/RevitDUI3/RevitDUI3Shared/Bindings/ReceiveBinding.cs new file mode 100644 index 0000000000..34268d6e3d --- /dev/null +++ b/ConnectorRevit/RevitDUI3/RevitDUI3Shared/Bindings/ReceiveBinding.cs @@ -0,0 +1,166 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading; +using Autodesk.Revit.DB; +using Autodesk.Revit.UI; +using DUI3; +using DUI3.Bindings; +using DUI3.Models.Card; +using DUI3.Utils; +using DUI3.Operations; +using Revit.Async; +using Speckle.ConnectorRevitDUI3.Utils; +using Speckle.Core.Kits; +using Speckle.Core.Logging; +using Speckle.Core.Models; + +namespace Speckle.ConnectorRevitDUI3.Bindings; + +public class ReceiveBinding : IBinding, ICancelable +{ + public string Name { get; set; } = "receiveBinding"; + public IBridge Parent { get; set; } + private readonly RevitDocumentStore _store; + private static UIApplication s_revitApp; + + private static Document Doc => UiDoc.Document; + private static UIDocument UiDoc => s_revitApp.ActiveUIDocument; + + public CancellationManager CancellationManager { get; } = new(); + + public ReceiveBinding(RevitDocumentStore store) + { + s_revitApp = RevitAppProvider.RevitApp; + _store = store; + } + + public void CancelReceive(string modelCardId) => CancellationManager.CancelOperation(modelCardId); + + public async void Receive(string modelCardId, string versionId) + { + try + { + // 0 - Init cancellation token source -> Manager also cancel it if exist before + CancellationTokenSource cts = CancellationManager.InitCancellationTokenSource(modelCardId); + + // 1 - Get receiver card + ReceiverModelCard modelCard = _store.GetModelById(modelCardId) as ReceiverModelCard; + + // 2 - Get commit object from server + Base commitObject = await Operations.GetCommitBase(Parent, modelCard, cts.Token).ConfigureAwait(true); + + if (cts.IsCancellationRequested) + { + throw new OperationCanceledException(cts.Token); + } + + // 3 - Get converter + ISpeckleConverter converter = Converters.GetConverter(Doc, RevitAppProvider.Version()); + + // 4 - Traverse commit object + List objectsToConvert = Traversal.GetObjectsToConvert(commitObject, converter); + + // 5 - Bake objects + BakeObjects(objectsToConvert, converter, modelCardId, cts); + } + catch (Exception e) + { + if (e is OperationCanceledException) + { + return; + } + + BasicConnectorBindingCommands.SetModelError(Parent, modelCardId, e); + } + } + + private async void BakeObjects( + List objectsToConvert, + ISpeckleConverter converter, + string modelCardId, + CancellationTokenSource cts + ) + { + (bool success, Exception exception) = await RevitTask + .RunAsync(app => + { + string transactionName = $"Baking model from {modelCardId}"; + using TransactionGroup g = new(Doc, transactionName); + using Transaction t = new(Doc, transactionName); + g.Start(); + t.Start(); + + try + { + converter.SetContextDocument(t); + List errors = new(); + int count = 0; + + foreach (Base objToConvert in objectsToConvert) + { + count++; + if (cts.IsCancellationRequested) + { + throw new OperationCanceledException(cts.Token); + } + + try + { + double progress = (double)count / objectsToConvert.Count; + BasicConnectorBindingCommands.SetModelProgress(Parent, modelCardId, new ModelCardProgress() { Status = "Converting", Progress = progress}); + + object convertedObject = converter.ConvertToNative(objToConvert); + RefreshView(); + } + catch (SpeckleException e) + { + errors.Add($"Object couldn't converted with id: {objToConvert.id}, type: {objToConvert.speckle_type}\n"); + Console.WriteLine(e); + } + } + + t.Commit(); + + if (t.GetStatus() == TransactionStatus.RolledBack) + { + int numberOfErrors = 0; // Previously get from errorEater + return ( + false, + new SpeckleException( + $"The Revit API could not resolve {numberOfErrors} unique errors and {numberOfErrors} total errors when trying to commit the Speckle model. The whole transaction is being rolled back." + ) + ); + } + + g.Assimilate(); + return (true, null); + } + catch (SpeckleException ex) + { + t.RollBack(); + g.RollBack(); + return (false, ex); //We can't throw exceptions in from RevitTask, but we can return it along with a success status + } + }) + .ConfigureAwait(false); + } + + private void RefreshView() + { + // regenerate the document and then implement a hack to "refresh" the view + UiDoc.Document.Regenerate(); + + // get the active ui view + View view = UiDoc.ActiveGraphicalView ?? UiDoc.ActiveView; + if (view is TableView) + { + return; + } + + UIView uiView = UiDoc.GetOpenUIViews().FirstOrDefault(uv => uv.ViewId.Equals(view.Id)); + + // "refresh" the active view + uiView?.Zoom(1); + } +} diff --git a/ConnectorRevit/RevitDUI3/RevitDUI3Shared/Bindings/SelectionBinding.cs b/ConnectorRevit/RevitDUI3/RevitDUI3Shared/Bindings/SelectionBinding.cs new file mode 100644 index 0000000000..adb8aedf4d --- /dev/null +++ b/ConnectorRevit/RevitDUI3/RevitDUI3Shared/Bindings/SelectionBinding.cs @@ -0,0 +1,52 @@ +using System.Collections.Generic; +using System.Linq; +using Autodesk.Revit.DB; +using Autodesk.Revit.UI; +using DUI3; +using DUI3.Bindings; +using Speckle.ConnectorRevitDUI3.Utils; + +namespace Speckle.ConnectorRevitDUI3.Bindings; + +public class SelectionBinding : ISelectionBinding +{ + public string Name { get; set; } = "selectionBinding"; + public IBridge Parent { get; set; } + private static UIApplication RevitApp { get; set; } + + public SelectionBinding() + { + RevitApp = RevitAppProvider.RevitApp; + + // TODO: Need to figure it out equivalent of SelectionChanged for Revit2020 +#if REVIT2023 + RevitApp.SelectionChanged += (_,_) => RevitIdleManager.SubscribeToIdle(OnSelectionChanged); +#endif + + RevitApp.ViewActivated += (_, _) => + { + Parent?.SendToBrowser(SelectionBindingEvents.SetSelection, new SelectionInfo()); + }; + } + + private void OnSelectionChanged() + { + var selectionInfo = GetSelection(); + Parent?.SendToBrowser(SelectionBindingEvents.SetSelection, selectionInfo); + } + + public SelectionInfo GetSelection() + { + List els = RevitApp.ActiveUIDocument.Selection + .GetElementIds() + .Select(id => RevitApp.ActiveUIDocument.Document.GetElement(id)) + .ToList(); + List cats = els.Select(el => el.Category?.Name ?? el.Name).Distinct().ToList(); + List ids = els.Select(el => el.UniqueId.ToString()).ToList(); + return new SelectionInfo() + { + SelectedObjectIds = ids, + Summary = $"{els.Count} objects ({string.Join(", ", cats)})" + }; + } +} diff --git a/ConnectorRevit/RevitDUI3/RevitDUI3Shared/Bindings/SendBinding.cs b/ConnectorRevit/RevitDUI3/RevitDUI3Shared/Bindings/SendBinding.cs new file mode 100644 index 0000000000..f4637885a1 --- /dev/null +++ b/ConnectorRevit/RevitDUI3/RevitDUI3Shared/Bindings/SendBinding.cs @@ -0,0 +1,209 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading; +using Autodesk.Revit.UI; +using Autodesk.Revit.DB; +using DUI3; +using DUI3.Bindings; +using DUI3.Models.Card; +using DUI3.Operations; +using Speckle.ConnectorRevitDUI3.Utils; +using Speckle.Core.Kits; +using Speckle.Core.Credentials; +using Speckle.Core.Transports; +using Speckle.Core.Models; +using DUI3.Utils; +using Speckle.Core.Api; +using Operations = DUI3.Operations.Operations; + +namespace Speckle.ConnectorRevitDUI3.Bindings; + +public class SendBinding : ISendBinding, ICancelable +{ + public string Name { get; set; } = "sendBinding"; + public IBridge Parent { get; set; } + + private readonly RevitDocumentStore _store; + + private static UIApplication s_revitApp; + + private static Document Doc => s_revitApp.ActiveUIDocument.Document; + + public CancellationManager CancellationManager { get; } = new(); + + private HashSet ChangedObjectIds { get; set; } = new(); + + public SendBinding(RevitDocumentStore store) + { + s_revitApp = RevitAppProvider.RevitApp; + _store = store; + + // TODO expiry events + // TODO filters need refresh events + s_revitApp.Application.DocumentChanged += (_, e) => DocChangeHandler(e); + } + + public List GetSendFilters() + { + return new List { new RevitEverythingFilter(), new RevitSelectionFilter() }; + } + + private Base ConvertElements( + List elements, + ISpeckleConverter converter, + string modelCardId, + CancellationTokenSource cts + ) + { + var commitObject = new Base(); + + var convertedObjects = new List(); + int count = 0; + foreach (var revitElement in elements) + { + if (cts.IsCancellationRequested) + { + throw new OperationCanceledException(); + } + + count++; + convertedObjects.Add(converter.ConvertToSpeckle(revitElement)); + double progress = (double)count / elements.Count; + BasicConnectorBindingCommands.SetModelProgress( + Parent, + modelCardId, + new ModelCardProgress() { Status = "Converting", Progress = progress } + ); + } + + commitObject["@elements"] = convertedObjects; + + return commitObject; + } + + public async void Send(string modelCardId) + { + try + { + // 0 - Init cancellation token source -> Manager also cancel it if exist before + CancellationTokenSource cts = CancellationManager.InitCancellationTokenSource(modelCardId); + + // 1 - Get model + SenderModelCard model = _store.GetModelById(modelCardId) as SenderModelCard; + + // 2 - Check account exist + Account account = Accounts.GetAccount(model.AccountId); + + // 3 - Get elements to convert + List elements = Utils.Elements.GetElementsFromDocument(Doc, model.SendFilter.GetObjectIds()); + + // 4 - Get converter + ISpeckleConverter converter = Converters.GetConverter(Doc, RevitAppProvider.Version()); + + // 5 - Convert objects + Base commitObject = ConvertElements(elements, converter, modelCardId, cts); + + if (cts.IsCancellationRequested) + { + throw new OperationCanceledException(cts.Token); + } + + // 6 - Get transports + List transports = new() { new ServerTransport(account, model.ProjectId) }; + + // 7 - Serialize and Send objects + BasicConnectorBindingCommands.SetModelProgress( + Parent, + modelCardId, + new ModelCardProgress { Status = "Uploading..." } + ); + string objectId = await Speckle.Core.Api.Operations + .Send(commitObject, cts.Token, transports, disposeTransports: true) + .ConfigureAwait(true); + + BasicConnectorBindingCommands.SetModelProgress( + Parent, + modelCardId, + new ModelCardProgress { Status = "Linking version to model..." } + ); + + // 8 - Create Version + var apiClient = new Client(account); + string versionId = await apiClient + .CommitCreate( + new CommitCreateInput() + { + streamId = model.ProjectId, + branchName = model.ModelId, + sourceApplication = "Rhino", + objectId = objectId + }, + cts.Token + ) + .ConfigureAwait(true); + + SendBindingUiCommands.SetModelCreatedVersionId(Parent, modelCardId, versionId); + apiClient.Dispose(); + } + catch (Exception e) + { + if (e is OperationCanceledException) + { + return; + } + + BasicConnectorBindingCommands.SetModelError(Parent, modelCardId, e); + } + } + + public void CancelSend(string modelCardId) => CancellationManager.CancelOperation(modelCardId); + + /// + /// Keeps track of the changed element ids as well as checks if any of them need to trigger + /// a filter refresh (e.g., views being added). + /// + /// + private void DocChangeHandler(Autodesk.Revit.DB.Events.DocumentChangedEventArgs e) + { + ICollection addedElementIds = e.GetAddedElementIds(); + ICollection deletedElementIds = e.GetDeletedElementIds(); + ICollection modifiedElementIds = e.GetModifiedElementIds(); + + foreach (ElementId elementId in addedElementIds) + { + ChangedObjectIds.Add(elementId.IntegerValue.ToString()); + } + + foreach (ElementId elementId in deletedElementIds) + { + ChangedObjectIds.Add(elementId.IntegerValue.ToString()); + } + + foreach (ElementId elementId in modifiedElementIds) + { + ChangedObjectIds.Add(elementId.IntegerValue.ToString()); + } + + // TODO: CHECK IF ANY OF THE ABOVE ELEMENTS NEED TO TRIGGER A FILTER REFRESH + // POC: re-instate + // RevitIdleManager.SubscribeToIdle(RunExpirationChecks); + } + + private void RunExpirationChecks() + { + List senders = _store.GetSenders(); + List expiredSenderIds = new(); + + foreach (var sender in senders) + { + bool isExpired = sender.SendFilter.CheckExpiry(ChangedObjectIds.ToArray()); + if (isExpired) + { + expiredSenderIds.Add(sender.ModelCardId); + } + } + SendBindingUiCommands.SetModelsExpired(Parent, expiredSenderIds); + ChangedObjectIds = new HashSet(); + } +} diff --git a/ConnectorRevit/RevitDUI3/RevitDUI3Shared/CefSharpPanel.xaml b/ConnectorRevit/RevitDUI3/RevitDUI3Shared/CefSharpPanel.xaml new file mode 100644 index 0000000000..67ccdb42f6 --- /dev/null +++ b/ConnectorRevit/RevitDUI3/RevitDUI3Shared/CefSharpPanel.xaml @@ -0,0 +1,18 @@ + + + + + + diff --git a/ConnectorRevit/RevitDUI3/RevitDUI3Shared/CefSharpPanel.xaml.cs b/ConnectorRevit/RevitDUI3/RevitDUI3Shared/CefSharpPanel.xaml.cs new file mode 100644 index 0000000000..e9f6dc3336 --- /dev/null +++ b/ConnectorRevit/RevitDUI3/RevitDUI3Shared/CefSharpPanel.xaml.cs @@ -0,0 +1,29 @@ +using System.Windows.Controls; +using Autodesk.Revit.UI; +using CefSharp; +using System.Windows.Threading; + +namespace Speckle.ConnectorRevitDUI3; + +public partial class CefSharpPanel : Page, Autodesk.Revit.UI.IDockablePaneProvider +{ + public CefSharpPanel() + { + InitializeComponent(); + } + + public void ExecuteScriptAsync(string script) => + Browser.Dispatcher.Invoke(() => Browser.ExecuteScriptAsync(script), DispatcherPriority.Background); + + public void ShowDevTools() => Browser.ShowDevTools(); + + public void SetupDockablePane(Autodesk.Revit.UI.DockablePaneProviderData data) + { + data.FrameworkElement = this; + data.InitialState = new Autodesk.Revit.UI.DockablePaneState + { + DockPosition = DockPosition.Tabbed, + TabBehind = Autodesk.Revit.UI.DockablePanes.BuiltInDockablePanes.ProjectBrowser + }; + } +} diff --git a/ConnectorRevit/RevitDUI3/RevitDUI3Shared/Entry.cs b/ConnectorRevit/RevitDUI3/RevitDUI3Shared/Entry.cs new file mode 100644 index 0000000000..d8ab4ffa1c --- /dev/null +++ b/ConnectorRevit/RevitDUI3/RevitDUI3Shared/Entry.cs @@ -0,0 +1,156 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Linq; +using System.Reflection; +using Autodesk.Revit.ApplicationServices; +using Autodesk.Revit.DB.Events; +using Autodesk.Revit.UI; +using CefSharp; +using DUI3; +using Revit.Async; +using Speckle.ConnectorRevitDUI3.Bindings; +using Speckle.ConnectorRevitDUI3.Utils; +using ArgumentException = Autodesk.Revit.Exceptions.ArgumentException; + +namespace Speckle.ConnectorRevitDUI3; + +public class App : IExternalApplication +{ + private static UIApplication AppInstance { get; set; } + private static UIControlledApplication UiCtrlApp { get; set; } + private static RevitDocumentStore RevitDocumentStore { get; set; } + + public Result OnStartup(UIControlledApplication application) + { + UiCtrlApp = application; + UiCtrlApp.ControlledApplication.ApplicationInitialized += ControlledApplicationOnApplicationInitialized; + CreateTabAndRibbonPanel(application); + + return Result.Succeeded; + } + + private void ControlledApplicationOnApplicationInitialized(object sender, ApplicationInitializedEventArgs e) + { + AppDomain.CurrentDomain.AssemblyResolve += OnAssemblyResolve; + AppInstance = new UIApplication(sender as Application); + RevitAppProvider.RevitApp = AppInstance; + RevitTask.Initialize(AppInstance); + + RegisterPanelAndInitializePlugin(AppInstance); + } + + private void CreateTabAndRibbonPanel(UIControlledApplication application) + { + string tabName = "Speckle"; + try + { + application.CreateRibbonTab(tabName); + } + catch (ArgumentException e) + { + Debug.WriteLine(e.Message); + } + + RibbonPanel specklePanel = application.CreateRibbonPanel(tabName, "Speckle 2 DUI3"); + PushButton _ = + specklePanel.AddItem( + new PushButtonData( + "Speckle 2 DUI3", + "Revit Connector", + typeof(App).Assembly.Location, + typeof(SpeckleRevitDui3Command).FullName + ) + ) as PushButton; + } + + internal static readonly DockablePaneId PanelId = new(new Guid("{85F73DA4-3EF4-4870-BDBC-FD2D238EED31}")); + public static CefSharpPanel CefSharpPanel { get; private set; } + + private void RegisterPanelAndInitializePlugin(UIApplication application) + { + CefSharpSettings.ConcurrentTaskExecution = true; + + CefSharpPanel = new CefSharpPanel(); + UiCtrlApp.RegisterDockablePane(PanelId, "Speckle DUI3", CefSharpPanel); + + RevitDocumentStore = new RevitDocumentStore(); + IEnumerable bridges = Factory + .CreateBindings(RevitDocumentStore) + .Select( + binding => + new BrowserBridge( + CefSharpPanel.Browser, + binding, + CefSharpPanel.ExecuteScriptAsync, + CefSharpPanel.ShowDevTools + ) + ); + +#if REVIT2020 + // Panel.Browser.JavascriptObjectRepository.NameConverter = null; // not available in cef65, we need the below + BindingOptions bindingOptions = new () { CamelCaseJavascriptNames = false }; +#endif + +#if REVIT2023 + CefSharpPanel.Browser.JavascriptObjectRepository.NameConverter = null; + BindingOptions bindingOptions = BindingOptions.DefaultBinder; +#endif + + CefSharpPanel.Browser.IsBrowserInitializedChanged += (sender, e) => + { + foreach (BrowserBridge bridge in bridges) + { + CefSharpPanel.Browser.JavascriptObjectRepository.Register( + bridge.FrontendBoundName, + bridge, + true, + bindingOptions + ); + } + +#if REVIT2020 + // NOTE: Cef65 does not work with DUI3 in yarn dev mode. To test things you need to do `yarn build` and serve the build + // folder at port 3000 (or change it to something else if you want to). Guru meditation: Je sais, pas ideal. Mais q'est que nous pouvons faire? Rien. C'est l'autodesk vie. + // NOTE: To run the ui from a build, follow these steps: + // - run `yarn build` in the DUI3 folder + // - run ` PORT=3003 node .output/server/index.mjs` after the build + + CefSharpPanel.Browser.Load("http://localhost:3003"); + CefSharpPanel.Browser.ShowDevTools(); +#endif + +#if REVIT2023 + CefSharpPanel.Browser.Load("http://localhost:8082"); +#endif + }; + } + + public Result OnShutdown(UIControlledApplication application) => Result.Succeeded; + + /// + /// Prevents some dll conflicts. + /// + /// + /// + /// + private static Assembly OnAssemblyResolve(object sender, ResolveEventArgs args) + { + Assembly assembly = null; + string name = args.Name.Split(',')[0]; + string path = Path.GetDirectoryName(typeof(App).Assembly.Location); + + if (path != null) + { + string assemblyFile = Path.Combine(path, name + ".dll"); + + if (File.Exists(assemblyFile)) + { + assembly = Assembly.LoadFrom(assemblyFile); + } + } + + return assembly; + } +} diff --git a/ConnectorRevit/RevitDUI3/RevitDUI3Shared/RevitDUI3Shared.projitems b/ConnectorRevit/RevitDUI3/RevitDUI3Shared/RevitDUI3Shared.projitems new file mode 100644 index 0000000000..8d57458a2b --- /dev/null +++ b/ConnectorRevit/RevitDUI3/RevitDUI3Shared/RevitDUI3Shared.projitems @@ -0,0 +1,37 @@ + + + + $(MSBuildAllProjects);$(MSBuildThisFileFullPath) + true + 7917CDBC-7BCF-4EE0-A80F-500C626468BA + + + RevitDUI3Shared + + + + + + + + + + + Panel.xaml + + + + + + + + + + + Always + + + + + + \ No newline at end of file diff --git a/ConnectorRevit/RevitDUI3/RevitDUI3Shared/RevitDUI3Shared.shproj b/ConnectorRevit/RevitDUI3/RevitDUI3Shared/RevitDUI3Shared.shproj new file mode 100644 index 0000000000..37cf5dcb76 --- /dev/null +++ b/ConnectorRevit/RevitDUI3/RevitDUI3Shared/RevitDUI3Shared.shproj @@ -0,0 +1,11 @@ + + + + {3D7F0278-6CF2-4588-A101-4027ABB8B87F} + + + + + + + diff --git a/ConnectorRevit/RevitDUI3/RevitDUI3Shared/SpeckleRevit2DUI3.addin b/ConnectorRevit/RevitDUI3/RevitDUI3Shared/SpeckleRevit2DUI3.addin new file mode 100644 index 0000000000..80e2f6ac7c --- /dev/null +++ b/ConnectorRevit/RevitDUI3/RevitDUI3Shared/SpeckleRevit2DUI3.addin @@ -0,0 +1,12 @@ + + + + Speckle 2 for Revit DUI3 (Experimental) + Speckle Connector for Revit DUI3 (Experimental) + SpeckleRevit2DUI3\SpeckleConnectorRevitDUI3.dll + Speckle.ConnectorRevitDUI3.App + 56F4C629-BB39-4023-804B-307AA9749792 + speckle + Speckle: Empowering your design and construction data. For any problems, visit our community forum https://speckle.community + + diff --git a/ConnectorRevit/RevitDUI3/RevitDUI3Shared/SpeckleRevitDUI3Command.cs b/ConnectorRevit/RevitDUI3/RevitDUI3Shared/SpeckleRevitDUI3Command.cs new file mode 100644 index 0000000000..e3b33f8b9b --- /dev/null +++ b/ConnectorRevit/RevitDUI3/RevitDUI3Shared/SpeckleRevitDUI3Command.cs @@ -0,0 +1,18 @@ +using Autodesk.Revit.Attributes; +using Autodesk.Revit.DB; +using Autodesk.Revit.UI; +using CefSharp; + +namespace Speckle.ConnectorRevitDUI3; + +[Transaction(TransactionMode.Manual)] +public class SpeckleRevitDui3Command : IExternalCommand +{ + public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) + { + DockablePane panel = commandData.Application.GetDockablePane(App.PanelId); + panel.Show(); + + return Result.Succeeded; + } +} diff --git a/ConnectorRevit/RevitDUI3/RevitDUI3Shared/Utils/Elements.cs b/ConnectorRevit/RevitDUI3/RevitDUI3Shared/Utils/Elements.cs new file mode 100644 index 0000000000..89f14202bc --- /dev/null +++ b/ConnectorRevit/RevitDUI3/RevitDUI3Shared/Utils/Elements.cs @@ -0,0 +1,11 @@ +using System.Collections.Generic; +using System.Linq; +using Autodesk.Revit.DB; + +namespace Speckle.ConnectorRevitDUI3.Utils; + +public static class Elements +{ + public static List GetElementsFromDocument(Document doc, IEnumerable objectIds) => + objectIds.Select(doc.GetElement).Where(x => x != null).ToList(); +} diff --git a/ConnectorRevit/RevitDUI3/RevitDUI3Shared/Utils/RevitAppProvider.cs b/ConnectorRevit/RevitDUI3/RevitDUI3Shared/Utils/RevitAppProvider.cs new file mode 100644 index 0000000000..9f585dfe91 --- /dev/null +++ b/ConnectorRevit/RevitDUI3/RevitDUI3Shared/Utils/RevitAppProvider.cs @@ -0,0 +1,22 @@ +using Autodesk.Revit.UI; + +namespace Speckle.ConnectorRevitDUI3.Utils; + +public static class RevitAppProvider +{ + /// + /// This property gets initialized in the plugin entry, on app initialization. + /// We should be able to use this in any place where we need the revit app! + /// + public static UIApplication RevitApp { get; set; } + + public static string Version() + { +#if REVIT2020 + return "Revit2020"; +#endif +#if REVIT2023 + return "Revit2023"; +#endif + } +} diff --git a/ConnectorRevit/RevitDUI3/RevitDUI3Shared/Utils/RevitDocumentStore.cs b/ConnectorRevit/RevitDUI3/RevitDUI3Shared/Utils/RevitDocumentStore.cs new file mode 100644 index 0000000000..662a9011b7 --- /dev/null +++ b/ConnectorRevit/RevitDUI3/RevitDUI3Shared/Utils/RevitDocumentStore.cs @@ -0,0 +1,138 @@ +using System; +using System.Collections.Generic; +using Autodesk.Revit.DB; +using Autodesk.Revit.DB.ExtensibleStorage; +using Autodesk.Revit.UI; +using DUI3.Models; +using Revit.Async; +using Speckle.Core.Logging; + +namespace Speckle.ConnectorRevitDUI3.Utils; + +public class RevitDocumentStore : DocumentModelStore +{ + // POC: statics to come out + private static UIApplication RevitApp { get; set; } + private static UIDocument CurrentDoc => RevitApp.ActiveUIDocument; + + private static readonly Guid s_guid = new("D35B3695-EDC9-4E15-B62A-D3FC2CB83FA3"); + + public RevitDocumentStore() + { + RevitApp = RevitAppProvider.RevitApp; + + RevitApp.ApplicationClosing += (_, _) => WriteToFile(); + RevitApp.Application.DocumentSaving += (_, _) => WriteToFile(); + RevitApp.Application.DocumentSynchronizingWithCentral += (_, _) => WriteToFile(); + + RevitApp.ViewActivated += (_, e) => + { + if (e.Document == null) + { + return; + } + + if (e.PreviousActiveView?.Document.PathName == e.CurrentActiveView.Document.PathName) + { + return; + } + + IsDocumentInit = true; + ReadFromFile(); + OnDocumentChanged(); + }; + + RevitApp.Application.DocumentOpening += (_, _) => IsDocumentInit = false; + RevitApp.Application.DocumentOpened += (_, _) => IsDocumentInit = false; + } + + public override void WriteToFile() + { + if (CurrentDoc == null) + { + return; + } + + RevitTask.RunAsync(() => + { + using Transaction t = new(CurrentDoc.Document, "Speckle Write State"); + t.Start(); + using DataStorage ds = GetSettingsDataStorage(CurrentDoc.Document) ?? DataStorage.Create(CurrentDoc.Document); + + using Entity stateEntity = new(DocumentModelStoreSchema.GetSchema()); + string serializedModels = Serialize(); + stateEntity.Set("contents", serializedModels); + + using Entity idEntity = new(IdStorageSchema.GetSchema()); + idEntity.Set("Id", s_guid); + + ds.SetEntity(idEntity); + ds.SetEntity(stateEntity); + t.Commit(); + }); + } + + public override void ReadFromFile() + { + try + { + Entity stateEntity = GetSpeckleEntity(CurrentDoc.Document); + if (stateEntity == null || !stateEntity.IsValid()) + { + Models = new List(); + return; + } + + string modelsString = stateEntity.Get("contents"); + Models = Deserialize(modelsString); + } + catch (SpeckleException) + { + Models = new List(); + } + } + + private static DataStorage GetSettingsDataStorage(Document doc) + { + using FilteredElementCollector collector = new(doc); + FilteredElementCollector dataStorages = collector.OfClass(typeof(DataStorage)); + + foreach (Element element in dataStorages) + { + DataStorage dataStorage = (DataStorage)element; + Entity settingIdEntity = dataStorage.GetEntity(IdStorageSchema.GetSchema()); + if (!settingIdEntity.IsValid()) + { + continue; + } + + Guid id = settingIdEntity.Get("Id"); + if (!id.Equals(s_guid)) + { + continue; + } + + return dataStorage; + } + return null; + } + + private static Entity GetSpeckleEntity(Document doc) + { + using FilteredElementCollector collector = new(doc); + + FilteredElementCollector dataStorages = collector.OfClass(typeof(DataStorage)); + foreach (Element element in dataStorages) + { + DataStorage dataStorage = (DataStorage)element; + Entity settingEntity = dataStorage.GetEntity(DocumentModelStoreSchema.GetSchema()); + if (!settingEntity.IsValid()) + { + continue; + } + + return settingEntity; + } + return null; + } +} diff --git a/ConnectorRevit/RevitDUI3/RevitDUI3Shared/Utils/RevitIdleManager.cs b/ConnectorRevit/RevitDUI3/RevitDUI3Shared/Utils/RevitIdleManager.cs new file mode 100644 index 0000000000..31afaed753 --- /dev/null +++ b/ConnectorRevit/RevitDUI3/RevitDUI3Shared/Utils/RevitIdleManager.cs @@ -0,0 +1,39 @@ +using System; +using System.Collections.Generic; +using Autodesk.Revit.UI.Events; + +namespace Speckle.ConnectorRevitDUI3.Utils; + +public static class RevitIdleManager +{ + private static Dictionary s_calls = new(); + private static bool s_hasSubscribed; + + /// + /// Subscribe deferred action to Idling event to run it whenever Revit becomes idle. + /// + /// Action to call whenever Revit becomes Idle. + public static void SubscribeToIdle(Action action) + { + s_calls[action.Method.Name ?? Guid.NewGuid().ToString()] = action; + + if (s_hasSubscribed) + { + return; + } + + s_hasSubscribed = true; + RevitAppProvider.RevitApp.Idling += RevitAppOnIdle; + } + + private static void RevitAppOnIdle(object sender, IdlingEventArgs e) + { + foreach (KeyValuePair kvp in s_calls) + { + kvp.Value(); + } + s_calls = new Dictionary(); + s_hasSubscribed = false; + RevitAppProvider.RevitApp.Idling -= RevitAppOnIdle; + } +} diff --git a/ConnectorRevit/RevitDUI3/RevitDUI3Shared/Utils/Schemas.cs b/ConnectorRevit/RevitDUI3/RevitDUI3Shared/Utils/Schemas.cs new file mode 100644 index 0000000000..fe609d2056 --- /dev/null +++ b/ConnectorRevit/RevitDUI3/RevitDUI3Shared/Utils/Schemas.cs @@ -0,0 +1,42 @@ +using System; +using Autodesk.Revit.DB.ExtensibleStorage; + +namespace Speckle.ConnectorRevitDUI3.Utils; + +public static class DocumentModelStoreSchema +{ + private static readonly Guid s_schemaGuid = new("D690F2B4-BDB0-4CB4-8657-17844ADF42AA"); + + public static Schema GetSchema() + { + Schema schema = Schema.Lookup(s_schemaGuid); + if (schema != null) + { + return schema; + } + + using SchemaBuilder builder = new(s_schemaGuid); + builder.SetSchemaName("DUI3State"); + builder.AddSimpleField("contents", typeof(string)); + return builder.Finish(); + } +} + +public static class IdStorageSchema +{ + private static readonly Guid s_schemaGuid = new("D0E2AD18-0DE0-41CF-A2B7-5384267061D7"); + + public static Schema GetSchema() + { + Schema schema = Schema.Lookup(s_schemaGuid); + if (schema != null) + { + return schema; + } + + using SchemaBuilder builder = new(s_schemaGuid); + builder.SetSchemaName("DataStorageUniqueId"); + builder.AddSimpleField("Id", typeof(Guid)); + return builder.Finish(); + } +} diff --git a/ConnectorRevit/RevitDUI3/Speckle.Connectors.Revit2023/Class1.cs b/ConnectorRevit/RevitDUI3/Speckle.Connectors.Revit2023/Class1.cs new file mode 100644 index 0000000000..3d7ee2f04c --- /dev/null +++ b/ConnectorRevit/RevitDUI3/Speckle.Connectors.Revit2023/Class1.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Speckle.Connectors.Revit2023 +{ + public class Class1 + { + } +} diff --git a/ConnectorRevit/RevitDUI3/Speckle.Connectors.Revit2023/Properties/AssemblyInfo.cs b/ConnectorRevit/RevitDUI3/Speckle.Connectors.Revit2023/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..8cff72a923 --- /dev/null +++ b/ConnectorRevit/RevitDUI3/Speckle.Connectors.Revit2023/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Speckle.Connectors.Revit2023")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Speckle.Connectors.Revit2023")] +[assembly: AssemblyCopyright("Copyright © 2024")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("e1ff75ec-2bdf-4276-9c81-6eb195661348")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/ConnectorRevit/RevitDUI3/Speckle.Connectors.Revit2023/Speckle.Connectors.Revit2023.csproj b/ConnectorRevit/RevitDUI3/Speckle.Connectors.Revit2023/Speckle.Connectors.Revit2023.csproj new file mode 100644 index 0000000000..9d33e84d2e --- /dev/null +++ b/ConnectorRevit/RevitDUI3/Speckle.Connectors.Revit2023/Speckle.Connectors.Revit2023.csproj @@ -0,0 +1,80 @@ + + + + + Enable + 10.0 + Debug + AnyCPU + {E1FF75EC-2BDF-4276-9C81-6EB195661348} + Library + Properties + Speckle.Connectors.Revit2023 + Speckle.Connectors.Revit2023 + v4.8 + 512 + true + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 0 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\..\..\packages\Revit_All_Main_Versions_API_x64.2023.0.0\lib\net48\AdWindows.dll + False + False + + + ..\..\..\packages\Revit_All_Main_Versions_API_x64.2023.0.0\lib\net48\RevitAPI.dll + False + False + + + ..\..\..\packages\Revit_All_Main_Versions_API_x64.2023.0.0\lib\net48\RevitAPIUI.dll + False + False + + + + + + + + + + + ..\..\..\packages\Revit_All_Main_Versions_API_x64.2023.0.0\lib\net48\UIFramework.dll + False + False + + + + + + + + + + + + {fd33c66e-cdaa-40ce-a7ea-0ee2bdce0ca4} + Speckle.Connectors.DependencyInjection + + + + + \ No newline at end of file diff --git a/ConnectorRevit/RevitDUI3/Speckle.Connectors.Revit2023/packages.config b/ConnectorRevit/RevitDUI3/Speckle.Connectors.Revit2023/packages.config new file mode 100644 index 0000000000..f7ed1d2901 --- /dev/null +++ b/ConnectorRevit/RevitDUI3/Speckle.Connectors.Revit2023/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/ConnectorRevit/RevitDUI3/Speckle.Connectors.RevitShared/RevitPlugin/IRevitPlugin.cs b/ConnectorRevit/RevitDUI3/Speckle.Connectors.RevitShared/RevitPlugin/IRevitPlugin.cs new file mode 100644 index 0000000000..4c38ec5021 --- /dev/null +++ b/ConnectorRevit/RevitDUI3/Speckle.Connectors.RevitShared/RevitPlugin/IRevitPlugin.cs @@ -0,0 +1,11 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Speckle.Connectors.RevitShared.RevitPlugin; + +internal interface IRevitPlugin +{ + void Initialise(); + void Shutdown(); +} diff --git a/ConnectorRevit/RevitDUI3/Speckle.Connectors.RevitShared/RevitPlugin/RevitExternalApplication.cs b/ConnectorRevit/RevitDUI3/Speckle.Connectors.RevitShared/RevitPlugin/RevitExternalApplication.cs new file mode 100644 index 0000000000..db9a5e4478 --- /dev/null +++ b/ConnectorRevit/RevitDUI3/Speckle.Connectors.RevitShared/RevitPlugin/RevitExternalApplication.cs @@ -0,0 +1,65 @@ +using System; +using System.Collections.Generic; +using System.Text; +using Autodesk.Revit.UI; +using Speckle.Connectors.DependencyInjection; + +namespace Speckle.Connectors.RevitShared.RevitPlugin; + +internal class RevitExternalApplication : IExternalApplication +{ + private IRevitPlugin? _revitPlugin = null; + private SpeckleDependencyContainer? _container = null; + + // POC: this is getting hard coded - need a way of injecting it + // I am beginning to think the shared project is not the way + // and an assembly which is invoked with some specialisation is the right way to go + // maybe subclassing, or some hook to inject som configuration + private RevitSettings _revitSettings = new RevitSettings { RevitVersionName = "REVIT2023" }; + + public Result OnStartup(UIControlledApplication application) + { + try + { + _container = new SpeckleDependencyContainer(); + + // *** AUTOFAC MODULES *** + + // init DI + _container + .AddDependencies(new string[] { "" }) + .AddInstance(_revitSettings) // apply revit settings into DI + .AddInstance(application) // inject UIControlledApplication application + .Build(); + + // resolve root object + _revitPlugin = _container.Resolve(); + _revitPlugin.Initialise(); + } + catch (Exception ex) + { + // POC: feedback? + return Result.Failed; + } + + return Result.Succeeded; + } + + public Result OnShutdown(UIControlledApplication application) + { + try + { + // POC: could this be more a generic Connector Init() Shutdown() + // possibly with injected pieces or with some abstract methods? + // need to look for commonality + _revitPlugin.Shutdown(); + } + catch (Exception ex) + { + // POC: feedback? + return Result.Failed; + } + + return Result.Succeeded; + } +} diff --git a/ConnectorRevit/RevitDUI3/Speckle.Connectors.RevitShared/RevitPlugin/RevitSettings.cs b/ConnectorRevit/RevitDUI3/Speckle.Connectors.RevitShared/RevitPlugin/RevitSettings.cs new file mode 100644 index 0000000000..fd0c7b8a0d --- /dev/null +++ b/ConnectorRevit/RevitDUI3/Speckle.Connectors.RevitShared/RevitPlugin/RevitSettings.cs @@ -0,0 +1,10 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Speckle.Connectors.RevitShared.RevitPlugin; + +internal class RevitSettings +{ + public string RevitVersionName { get; set; } +} diff --git a/ConnectorRevit/RevitDUI3/Speckle.Connectors.RevitShared/RevitPlugin/SpeckleRevit.addin b/ConnectorRevit/RevitDUI3/Speckle.Connectors.RevitShared/RevitPlugin/SpeckleRevit.addin new file mode 100644 index 0000000000..a1db0754ef --- /dev/null +++ b/ConnectorRevit/RevitDUI3/Speckle.Connectors.RevitShared/RevitPlugin/SpeckleRevit.addin @@ -0,0 +1,12 @@ + + + + Speckle.Connectors.Revit2023 - DUI3 (WIP) + Speckle.Connectors.Revit2023 - DUI3 (WIP) + Speckle.Connectors.Revit2023\Speckle.Connectors.Revit2023.dll + Speckle.ConnectorRevitDUI3.App + 56F4C629-BB39-4023-804B-307AA9749792 + speckle + Speckle: Empowering your design and construction data. For any problems, visit our community forum https://speckle.community + + diff --git a/ConnectorRevit/RevitDUI3/Speckle.Connectors.RevitShared/RevitPlugin/SpeckleRevitCommand.cs b/ConnectorRevit/RevitDUI3/Speckle.Connectors.RevitShared/RevitPlugin/SpeckleRevitCommand.cs new file mode 100644 index 0000000000..1494cae947 --- /dev/null +++ b/ConnectorRevit/RevitDUI3/Speckle.Connectors.RevitShared/RevitPlugin/SpeckleRevitCommand.cs @@ -0,0 +1,19 @@ +using Autodesk.Revit.Attributes; +using Autodesk.Revit.DB; +using Autodesk.Revit.UI; +using CefSharp; + +namespace Speckle.RevitPlugin; + +[Transaction(TransactionMode.Manual)] +public class SpeckleRevitCommand : IExternalCommand +{ + public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) + { + DockablePane panel = commandData.Application.GetDockablePane(App.PanelId); + panel.Show(); + + App.CefSharpPanel.Browser.ShowDevTools(); + return Result.Succeeded; + } +} diff --git a/ConnectorRevit/RevitDUI3/Speckle.Connectors.RevitShared/Speckle.Connectors.RevitShared.projitems b/ConnectorRevit/RevitDUI3/Speckle.Connectors.RevitShared/Speckle.Connectors.RevitShared.projitems new file mode 100644 index 0000000000..d8025bd015 --- /dev/null +++ b/ConnectorRevit/RevitDUI3/Speckle.Connectors.RevitShared/Speckle.Connectors.RevitShared.projitems @@ -0,0 +1,20 @@ + + + + $(MSBuildAllProjects);$(MSBuildThisFileFullPath) + true + 32aea787-c986-4b76-a57f-0da5453aa1f5 + + + Speckle.Connectors.RevitShared + + + + + + + + + + + \ No newline at end of file diff --git a/ConnectorRevit/RevitDUI3/Speckle.Connectors.RevitShared/Speckle.Connectors.RevitShared.shproj b/ConnectorRevit/RevitDUI3/Speckle.Connectors.RevitShared/Speckle.Connectors.RevitShared.shproj new file mode 100644 index 0000000000..cd8d375b77 --- /dev/null +++ b/ConnectorRevit/RevitDUI3/Speckle.Connectors.RevitShared/Speckle.Connectors.RevitShared.shproj @@ -0,0 +1,13 @@ + + + + 32aea787-c986-4b76-a57f-0da5453aa1f5 + 14.0 + + + + + + + + diff --git a/ConnectorRhino/ConnectorRhino.slnf b/ConnectorRhino/ConnectorRhino.slnf index 40d01b1231..4e9da1d6a1 100644 --- a/ConnectorRhino/ConnectorRhino.slnf +++ b/ConnectorRhino/ConnectorRhino.slnf @@ -7,16 +7,18 @@ "ConnectorGrasshopper\\ConnectorGrasshopper8\\ConnectorGrasshopper8.csproj", "ConnectorGrasshopper\\ConnectorGrasshopperShared\\ConnectorGrasshopperShared.shproj", "ConnectorGrasshopper\\ConnectorGrasshopperUtils\\ConnectorGrasshopperUtils.csproj", + "ConnectorRhino\\ConnectorRhino\\ConnectorRhinoShared\\ConnectorRhinoShared.shproj", "ConnectorRhino\\ConnectorRhino6\\ConnectorRhino6.csproj", "ConnectorRhino\\ConnectorRhino7\\ConnectorRhino7.csproj", "ConnectorRhino\\ConnectorRhino8\\ConnectorRhino8.csproj", - "ConnectorRhino\\ConnectorRhino\\ConnectorRhinoShared\\ConnectorRhinoShared.shproj", + "ConnectorRhino\\ConnectorRhinoWebUI\\ConnectorRhinoWebUI.csproj", "Core\\Core\\Core.csproj", "Core\\Tests\\Speckle.Core.Tests.Unit\\Speckle.Core.Tests.Unit.csproj", "Core\\Transports\\DiskTransport\\DiskTransport.csproj", "Core\\Transports\\MongoDBTransport\\MongoDBTransport.csproj", "DesktopUI2\\AvaloniaHwndHost\\AvaloniaHwndHost.csproj", "DesktopUI2\\DesktopUI2\\DesktopUI2.csproj", + "DesktopUI3\\DUI3\\DUI3.csproj", "Objects\\Converters\\ConverterRhinoGh\\ConverterGrasshopper6\\ConverterGrasshopper6.csproj", "Objects\\Converters\\ConverterRhinoGh\\ConverterGrasshopper7\\ConverterGrasshopper7.csproj", "Objects\\Converters\\ConverterRhinoGh\\ConverterGrasshopper8\\ConverterGrasshopper8.csproj", diff --git a/ConnectorRhino/ConnectorRhinoWebUI/Bindings/BasicConnectorBinding.cs b/ConnectorRhino/ConnectorRhinoWebUI/Bindings/BasicConnectorBinding.cs new file mode 100644 index 0000000000..6eca0cf022 --- /dev/null +++ b/ConnectorRhino/ConnectorRhinoWebUI/Bindings/BasicConnectorBinding.cs @@ -0,0 +1,108 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using ConnectorRhinoWebUI.Extensions; +using ConnectorRhinoWebUI.Utils; +using DUI3; +using DUI3.Bindings; +using DUI3.Models; +using Rhino; +using Rhino.DocObjects; +using Rhino.Geometry; +using Sentry.Reflection; + +namespace ConnectorRhinoWebUI.Bindings; + +public class BasicConnectorBinding : IBasicConnectorBinding +{ + public string Name { get; set; } = "baseBinding"; + public IBridge Parent { get; set; } + private readonly RhinoDocumentStore _store; + + public BasicConnectorBinding(RhinoDocumentStore store) + { + _store = store; + _store.DocumentChanged += (_, _) => + { + BasicConnectorBindingCommands.NotifyDocumentChanged(Parent); + }; + } + + public string GetConnectorVersion() => Assembly.GetAssembly(GetType()).GetNameAndVersion().Version; + + public string GetSourceApplicationName() => "Rhino"; + + public string GetSourceApplicationVersion() => "7"; + + public DocumentInfo GetDocumentInfo() => + new() + { + Location = RhinoDoc.ActiveDoc.Path, + Name = RhinoDoc.ActiveDoc.Name, + Id = RhinoDoc.ActiveDoc.RuntimeSerialNumber.ToString() + }; + + public DocumentModelStore GetDocumentState() => _store; + + public void AddModel(ModelCard model) => _store.Models.Add(model); + + public void UpdateModel(ModelCard model) + { + int idx = _store.Models.FindIndex(m => model.ModelCardId == m.ModelCardId); + _store.Models[idx] = model; + } + + public void RemoveModel(ModelCard model) + { + int index = _store.Models.FindIndex(m => m.ModelCardId == model.ModelCardId); + _store.Models.RemoveAt(index); + } + + public void HighlightModel(string modelCardId) + { + var objectIds = new List(); + var myModel = _store.GetModelById(modelCardId); + + if (myModel is SenderModelCard sender) + { + objectIds = sender.SendFilter.GetObjectIds(); + } + + if (myModel is ReceiverModelCard receiver && receiver.ReceiveResult != null) + { + objectIds = receiver.ReceiveResult.BakedObjectIds; + } + + if (objectIds.Count == 0) + { + BasicConnectorBindingCommands.SetModelError(Parent, modelCardId, new OperationCanceledException("No objects found to highlight.") ); + return; + } + + List rhinoObjects = objectIds + .Select((id) => RhinoDoc.ActiveDoc.Objects.FindId(new Guid(id))).Where(o => o!=null) + .ToList(); + + RhinoDoc.ActiveDoc.Objects.UnselectAll(); + + if (rhinoObjects.Count == 0) + { + BasicConnectorBindingCommands.SetModelError(Parent,modelCardId, new OperationCanceledException("No objects found to highlight.") ); + return; + } + + RhinoDoc.ActiveDoc.Objects.Select(rhinoObjects.Select(o => o.Id)); + + // Calculate the bounding box of the selected objects + BoundingBox boundingBox = BoundingBoxExtensions.UnionRhinoObjects(rhinoObjects); + + // Zoom to the calculated bounding box + if (boundingBox.IsValid) + { + RhinoDoc.ActiveDoc.Views.ActiveView.ActiveViewport.ZoomBoundingBox(boundingBox); + } + + RhinoDoc.ActiveDoc.Views.Redraw(); + } +} diff --git a/ConnectorRhino/ConnectorRhinoWebUI/Bindings/Factory.cs b/ConnectorRhino/ConnectorRhinoWebUI/Bindings/Factory.cs new file mode 100644 index 0000000000..7c30d71704 --- /dev/null +++ b/ConnectorRhino/ConnectorRhinoWebUI/Bindings/Factory.cs @@ -0,0 +1,54 @@ +using System.Collections.Generic; +using ConnectorRhinoWebUI.Utils; +using DUI3; +using DUI3.Bindings; +using DUI3.Onboarding; + +namespace ConnectorRhinoWebUI.Bindings; + +/// +/// Creates the required bindings, in the correct order, and scaffolds any dependencies. +/// +public static class Factory +{ + private static readonly RhinoDocumentStore s_store = new(); + + public static List CreateBindings() + { + BasicConnectorBinding baseBindings = new(s_store); + SendBinding sendBindings = new(s_store); + ReceiveBinding receiveBindings = new(s_store); + SelectionBinding selectionBindings = new(); + + // Where we pass connector specific onboardings to config binding. + // Below code is just a sample for now! + Dictionary sampleOnboardingsData = + new() + { + { + "mapper", + new OnboardingData() + { + Title = "Mapper", + Blurb = "Map your objects for Revit!", + Completed = false, + Page = "/onboarding/rhino/mapper" + } + } + }; + + List bindingsList = + new() + { + new ConfigBinding(Utils.Utils.AppName, sampleOnboardingsData), + new AccountBinding(), + new TestBinding(), + baseBindings, + sendBindings, + receiveBindings, + selectionBindings + }; + + return bindingsList; + } +} diff --git a/ConnectorRhino/ConnectorRhinoWebUI/Bindings/Filters.cs b/ConnectorRhino/ConnectorRhinoWebUI/Bindings/Filters.cs new file mode 100644 index 0000000000..c99abfdd08 --- /dev/null +++ b/ConnectorRhino/ConnectorRhinoWebUI/Bindings/Filters.cs @@ -0,0 +1,63 @@ +using System.Collections.Generic; +using System.Linq; +using DUI3.Bindings; +using DUI3.Models; +using Rhino; + +namespace ConnectorRhinoWebUI.Bindings; + +public class RhinoEverythingFilter : EverythingSendFilter +{ + public override List GetObjectIds() + { + return new List(); // TODO + } + + public override bool CheckExpiry(string[] changedObjectIds) + { + return true; + } +} + +public class RhinoSelectionFilter : DirectSelectionSendFilter +{ + public override List GetObjectIds() + { + return SelectedObjectIds; + } + + public override bool CheckExpiry(string[] changedObjectIds) + { + return SelectedObjectIds.Intersect(changedObjectIds).Any(); + } +} + +public class RhinoLayerFilter : ListValueInput, ISendFilter +{ + public string Name { get; set; } + public string Summary { get; set; } + public bool IsDefault { get; set; } + + public RhinoLayerFilter() + { + Name = "Layers"; + Summary = "How many layers are actually selected. UI should populate this."; + foreach (var layer in RhinoDoc.ActiveDoc.Layers) + { + if(layer.IsDeleted || layer.Disposed) continue; + + Options.Add(new ListValueItem() { Id = layer.Id.ToString(), Name = layer.FullPath }); + } + } + + public List GetObjectIds() + { + return new List(); // TODO: based on the SelectedOptions field + } + + public bool CheckExpiry(string[] changedObjectIds) + { + // TODO + return false; + } +} diff --git a/ConnectorRhino/ConnectorRhinoWebUI/Bindings/ReceiveBinding.cs b/ConnectorRhino/ConnectorRhinoWebUI/Bindings/ReceiveBinding.cs new file mode 100644 index 0000000000..df6cc185b5 --- /dev/null +++ b/ConnectorRhino/ConnectorRhinoWebUI/Bindings/ReceiveBinding.cs @@ -0,0 +1,194 @@ +using System; +using System.Collections.Generic; +using System.Threading; +using DUI3; +using DUI3.Bindings; +using DUI3.Models; +using DUI3.Models.Card; +using DUI3.Operations; +using DUI3.Settings; +using DUI3.Utils; +using Rhino; +using Rhino.DocObjects; +using Rhino.Geometry; +using Speckle.Core.Kits; +using Speckle.Core.Models; + +using ICancelable = DUI3.Operations.ICancelable; + +namespace ConnectorRhinoWebUI.Bindings; + +public class ReceiveBinding : IReceiveBinding, ICancelable +{ + public string Name { get; set; } = "receiveBinding"; + public IBridge Parent { get; set; } + + private readonly DocumentModelStore _store; + + private RhinoDoc Doc => RhinoDoc.ActiveDoc; + + public CancellationManager CancellationManager { get; } = new(); + + public ReceiveBinding(DocumentModelStore store) + { + _store = store; + } + + public void CancelReceive(string modelCardId) => CancellationManager.CancelOperation(modelCardId); + + public async void Receive(string modelCardId) + { + try + { + // 0 - Init cancellation token source -> Manager also cancel it if exist before + CancellationTokenSource cts = CancellationManager.InitCancellationTokenSource(modelCardId); + + // 1 - Get receiver card + ReceiverModelCard modelCard = _store.GetModelById(modelCardId) as ReceiverModelCard; + + BasicConnectorBindingCommands.SetModelProgress(Parent, modelCardId, new ModelCardProgress() { Status = "Downloading" }); + + // 2 - Get commit object from server + Base commitObject = await Operations.GetCommitBase(Parent, modelCard, cts.Token).ConfigureAwait(true); + + if (cts.IsCancellationRequested) + { + throw new OperationCanceledException(cts.Token); + } + + // 3 - Get converter + ISpeckleConverter converter = Converters.GetConverter(Doc, "Rhino7"); + + var objectsToConvert = new List<(List,Base)>(); + + BasicConnectorBindingCommands.SetModelProgress(Parent, modelCardId, new ModelCardProgress() { Status = "Parsing structure" }); + + foreach (var (objPath, obj) in commitObject.TraverseWithPath(obj => obj is not Collection && converter.CanConvertToNative(obj))) // note the "obj is not collection" is working around a bug of sorts in the rh converter where we assume collections always have a collectionType; also unsure why collection to layer is in the converter (it's fine, but weird) + { + if (cts.IsCancellationRequested) + { + throw new OperationCanceledException(cts.Token); + } + + if (obj is not Collection && converter.CanConvertToNative(obj)) + { + objectsToConvert.Add((objPath, obj)); + } + } + + var baseLayerName = $"Project {modelCard.ProjectName}: Model {modelCard.ModelName}"; + var convertedIds = BakeObjects(objectsToConvert, baseLayerName, modelCardId, cts, converter); + + var receiveResult = new ReceiveResult() { BakedObjectIds = convertedIds, Display = true }; + + ReceiveBindingUiCommands.SetModelConversionResult(Parent, modelCardId, receiveResult ); + + // 7 - Redraw the view to render baked objects + Doc.Views.Redraw(); + } + catch (Exception e) + { + if (e is OperationCanceledException) // We do not want to display an error, we just stop sending. + { + return; + } + + BasicConnectorBindingCommands.SetModelError(Parent, modelCardId, e); // NOTE: should be a shard UI binding command + } + } + + private List BakeObjects(List<(List,Base)> objects, string baseLayerName, string modelCardId, CancellationTokenSource cts, ISpeckleConverter converter) + { + // LETS FUCK AROUND AND FIND OUT + var rootLayerName = baseLayerName; + var rootLayerIndex = Doc.Layers.Find(rootLayerName, true); + + if (rootLayerIndex >= 0) + { + foreach ( var layer in RhinoDoc.ActiveDoc.Layers[ rootLayerIndex ].GetChildren() ) + { + RhinoDoc.ActiveDoc.Layers.Purge( layer.Index, false ); + } + } + + var cache = new Dictionary(); + rootLayerIndex = Doc.Layers.Add(new Layer() { Name = rootLayerName }); + cache.Add(rootLayerName, rootLayerIndex); + + var newObjectIds = new List(); + var count = 0; + foreach(var (path, baseObj) in objects) + { + if (cts.IsCancellationRequested) + { + throw new OperationCanceledException(cts.Token); + } + var fullLayerName = string.Join("::", path); + var layerIndex = -1; + if (cache.ContainsKey(fullLayerName)) + { + layerIndex = cache[fullLayerName]; + } + + if (layerIndex == -1) + { + layerIndex = GetAndCreateLayerFromPath(path, rootLayerName, cache); + } + + BasicConnectorBindingCommands.SetModelProgress(Parent, modelCardId, new ModelCardProgress() { Status = "Converting & creating objects", Progress = (double)++count/objects.Count }); + + var converted = converter.ConvertToNative(baseObj); + if (converted is GeometryBase newObject) + { + var newObjectGuid = Doc.Objects.Add(newObject, new ObjectAttributes() { LayerIndex = layerIndex }); + newObjectIds.Add(newObjectGuid.ToString()); + } + // else something weird happened? a block maybe? also, blocks are treated like $$$ now tbh so i won't dive into them + } + + return newObjectIds; + } + + private int GetAndCreateLayerFromPath(List path, string baseLayerName, Dictionary cache) + { + var currentLayerName = baseLayerName; + var previousLayer = Doc.Layers.FindName(currentLayerName); + foreach (var layerName in path) + { + currentLayerName = baseLayerName + Layer.PathSeparator + layerName; + currentLayerName = currentLayerName.Replace("{", "").Replace("}", ""); // Rhino specific cleanup for gh (see RemoveInvalidRhinoChars) + if (cache.TryGetValue(currentLayerName, out int value)) + { + previousLayer = Doc.Layers.FindIndex(value); + continue; + } + var cleanNewLayerName = layerName.Replace("{", "").Replace("}", ""); + var newLayer = new Layer() { Name = cleanNewLayerName, ParentLayerId = previousLayer.Id }; + var index = Doc.Layers.Add(newLayer); + cache.Add(currentLayerName, index); + previousLayer = Doc.Layers.FindIndex(index); // note we need to get the correct id out, hence why we're double calling this + } + return previousLayer.Index; + } + + public List GetReceiveSettings() => + new() + { + new() + { + Id = "mergeCoplanarFaces", + Title = "Merge Coplanar Faces", + Value = true, + Type = "boolean" + }, + new() + { + Id = "receiveMode", + Title = "Receive Mode", + Value = "Update", + Type = "string", + Enum = new List() { "Update", "Create", "Ignore" } + } + }; + +} diff --git a/ConnectorRhino/ConnectorRhinoWebUI/Bindings/SelectionBinding.cs b/ConnectorRhino/ConnectorRhinoWebUI/Bindings/SelectionBinding.cs new file mode 100644 index 0000000000..f510edc2f3 --- /dev/null +++ b/ConnectorRhino/ConnectorRhinoWebUI/Bindings/SelectionBinding.cs @@ -0,0 +1,57 @@ +using System.Collections.Generic; +using System.Linq; +using ConnectorRhinoWebUI.Utils; +using DUI3; +using DUI3.Bindings; +using Rhino; +using Rhino.DocObjects; + +namespace ConnectorRhinoWebUI.Bindings; + +public class SelectionBinding : ISelectionBinding +{ + public string Name { get; set; } = "selectionBinding"; + public IBridge Parent { get; set; } + + public SelectionBinding() + { + RhinoDoc.SelectObjects += (_, _) => + { + RhinoIdleManager.SubscribeToIdle(OnSelectionChanged); + }; + RhinoDoc.DeselectObjects += (_, _) => + { + RhinoIdleManager.SubscribeToIdle(OnSelectionChanged); + }; + RhinoDoc.DeselectAllObjects += (_, _) => + { + RhinoIdleManager.SubscribeToIdle(OnSelectionChanged); + }; + + RhinoDoc.EndOpenDocumentInitialViewUpdate += (_, _) => + { + // Resets selection doc change + Parent?.SendToBrowser(SelectionBindingEvents.SetSelection, new SelectionInfo()); + }; + } + + private void OnSelectionChanged() + { + SelectionInfo selInfo = GetSelection(); + Parent?.SendToBrowser(SelectionBindingEvents.SetSelection, selInfo); + } + + public SelectionInfo GetSelection() + { + List objects = RhinoDoc.ActiveDoc.Objects.GetSelectedObjects(false, false).ToList(); + List objectIds = objects.Select(o => o.Id.ToString()).ToList(); + int layerCount = objects.Select(o => o.Attributes.LayerIndex).Distinct().Count(); + List objectTypes = objects.Select(o => o.ObjectType.ToString()).Distinct().ToList(); + return new SelectionInfo + { + SelectedObjectIds = objectIds, + Summary = + $"{objectIds.Count} objects ({string.Join(", ", objectTypes)}) from {layerCount} layer{(layerCount != 1 ? "s" : "")}" + }; + } +} diff --git a/ConnectorRhino/ConnectorRhinoWebUI/Bindings/SendBinding.cs b/ConnectorRhino/ConnectorRhinoWebUI/Bindings/SendBinding.cs new file mode 100644 index 0000000000..d881e24784 --- /dev/null +++ b/ConnectorRhino/ConnectorRhinoWebUI/Bindings/SendBinding.cs @@ -0,0 +1,283 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading; +using ConnectorRhinoWebUI.Utils; +using DUI3; +using DUI3.Bindings; +using DUI3.Models; +using DUI3.Models.Card; +using DUI3.Operations; +using DUI3.Settings; +using Rhino; +using Rhino.DocObjects; +using Speckle.Core.Credentials; +using Speckle.Core.Models; +using Speckle.Core.Transports; +using DUI3.Utils; +using Speckle.Core.Api; +using Speckle.Core.Kits; + +namespace ConnectorRhinoWebUI.Bindings; + +public class SendBinding : ISendBinding, ICancelable +{ + public string Name { get; set; } = "sendBinding"; + public IBridge Parent { get; set; } + private readonly DocumentModelStore _store; + public CancellationManager CancellationManager { get; } = new(); + + private HashSet ChangedObjectIds { get; set; } = new(); + + public SendBinding(DocumentModelStore store) + { + _store = store; + + RhinoDoc.LayerTableEvent += (_, _) => + { + SendBindingUiCommands.RefreshSendFilters(Parent); + }; + + RhinoDoc.AddRhinoObject += (_, e) => + { + // NOTE: This does not work if rhino starts and opens a blank doc; + if (!_store.IsDocumentInit) + { + return; + } + + ChangedObjectIds.Add(e.ObjectId.ToString()); + RhinoIdleManager.SubscribeToIdle(RunExpirationChecks); + }; + + RhinoDoc.DeleteRhinoObject += (_, e) => + { + // NOTE: This does not work if rhino starts and opens a blank doc; + if (!_store.IsDocumentInit) + { + return; + } + + ChangedObjectIds.Add(e.ObjectId.ToString()); + RhinoIdleManager.SubscribeToIdle(RunExpirationChecks); + }; + + RhinoDoc.ReplaceRhinoObject += (_, e) => + { + // NOTE: This does not work if rhino starts and opens a blank doc; + if (!_store.IsDocumentInit) + { + return; + } + + ChangedObjectIds.Add(e.NewRhinoObject.Id.ToString()); + ChangedObjectIds.Add(e.OldRhinoObject.Id.ToString()); + RhinoIdleManager.SubscribeToIdle(RunExpirationChecks); + }; + } + + public List GetSendFilters() + { + return new List() + { + new RhinoEverythingFilter(), + new RhinoSelectionFilter() { IsDefault = true }, + new RhinoLayerFilter() + }; + } + + public List GetSendSettings() + { + return new List() + { + new() + { + Id = "includeAttributes", + Title = "Include Attributes", + Value = true, + Type = "boolean" + }, + }; + } + + public async void Send(string modelCardId) + { + try + { + // 0 - Init cancellation token source -> Manager also cancel it if exist before + CancellationTokenSource cts = CancellationManager.InitCancellationTokenSource(modelCardId); + + // 1 - Get model + + if (_store.GetModelById(modelCardId) is not SenderModelCard model) + { + throw new InvalidOperationException("No publish model card was found."); + } + + // 2 - Check account exist + Account account = Accounts.GetAccount(model.AccountId); + + // 3 - Get elements to convert, throw early if nothing is selected + List rhinoObjects = GetObjectsFromDocument(model); + + if (rhinoObjects.Count == 0) + { + throw new InvalidOperationException("No objects were found. Please update your send filter!"); + } + + // 4 - Get converter + ISpeckleConverter converter = Converters.GetConverter(RhinoDoc.ActiveDoc, "Rhino7"); + + // 5 - Convert objects + Base commitObject = ConvertObjects(rhinoObjects, converter, modelCardId, cts); + + if (cts.IsCancellationRequested) + { + throw new OperationCanceledException(cts.Token); + } + + // 6 - Get transports + List transports = new() { new ServerTransport(account, model.ProjectId) }; + + // 7 - Serialize and Send objects + BasicConnectorBindingCommands.SetModelProgress(Parent, modelCardId, new ModelCardProgress { Status = "Uploading..." }); + string objectId = await Speckle.Core.Api.Operations + .Send(commitObject, cts.Token, transports, disposeTransports: true) + .ConfigureAwait(true); + + BasicConnectorBindingCommands.SetModelProgress(Parent, modelCardId, new ModelCardProgress { Status = "Linking version to model..." }); + + // 8 - Create the version (commit) + var apiClient = new Client(account); + string versionId = await apiClient.CommitCreate(new CommitCreateInput() + { + streamId = model.ProjectId, branchName = model.ModelId, sourceApplication = "Rhino", objectId = objectId + }, cts.Token).ConfigureAwait(true); + + SendBindingUiCommands.SetModelCreatedVersionId(Parent, modelCardId, versionId); + apiClient.Dispose(); + } +#pragma warning disable CA1031 + catch (Exception e) +#pragma warning restore CA1031 + { + if (e is OperationCanceledException) // We do not want to display an error, we just stop sending. + { + return; + } + + BasicConnectorBindingCommands.SetModelError(Parent, modelCardId, e); + } + } + + public void CancelSend(string modelCardId) => CancellationManager.CancelOperation(modelCardId); + + private Base ConvertObjects( + List rhinoObjects, + ISpeckleConverter converter, + string modelCardId, + CancellationTokenSource cts + ) + { + var modelWithLayers = new Collection { name = RhinoDoc.ActiveDoc.Name }; + int count = 0; + + Dictionary layerCollectionCache = new(); + + foreach (RhinoObject rhinoObject in rhinoObjects) + { + if (cts.IsCancellationRequested) + { + throw new OperationCanceledException(cts.Token); + } + + // 1. get object layer + var layer = RhinoDoc.ActiveDoc.Layers[rhinoObject.Attributes.LayerIndex]; + + // 2. get or create a nested collection for it + var collectionHost = GetAndCreateObjectHostCollection(layerCollectionCache, layer, modelWithLayers); + + // 3. convert + var converted = converter.ConvertToSpeckle(rhinoObject); + converted.applicationId = rhinoObject.Id.ToString(); + + // 4. add to host + collectionHost.elements.Add(converted); + + BasicConnectorBindingCommands.SetModelProgress(Parent, modelCardId, new ModelCardProgress(){ Status = "Converting", Progress = (double)++count / rhinoObjects.Count}); + + // NOTE: useful for testing ui states, pls keep for now so we can easily uncomment + // Thread.Sleep(550); + } + + // 5. profit + return modelWithLayers; + } + + private Collection GetAndCreateObjectHostCollection(Dictionary layerCollectionCache, Layer layer, Collection modelWithLayers) + { + if (layerCollectionCache.TryGetValue(layer.Index, out Collection value)) + { + return value; + } + + var names = layer.FullPath.Split(new[] {Layer.PathSeparator}, StringSplitOptions.None); + var path = names[0]; + var index = 0; + var previousCollection = modelWithLayers; + foreach (var layerName in names) + { + var existingLayerIndex = RhinoDoc.ActiveDoc.Layers.FindByFullPath(path, -1); + Collection childCollection = null; + if (layerCollectionCache.ContainsKey(existingLayerIndex)) + { + childCollection = layerCollectionCache[existingLayerIndex]; + } + else + { + childCollection = new Collection(layerName, "layer") + { + applicationId = RhinoDoc.ActiveDoc.Layers[existingLayerIndex].Id.ToString() + }; + previousCollection.elements.Add(childCollection); + layerCollectionCache[existingLayerIndex] = childCollection; + } + + previousCollection = childCollection; + + if (index < names.Length - 1) + { + path += Layer.PathSeparator + names[index+1]; + } + index++; + } + + layerCollectionCache[layer.Index] = previousCollection; + return previousCollection; + // var collectionHost = modelLayers.Traverse(m => m is not Collection).FirstOrDefault(obj => (obj as Collection)?.name == layer.Name) as Collection; // works, but it's better with a cache + } + + private List GetObjectsFromDocument(SenderModelCard model) + { + List objectsIds = model.SendFilter.GetObjectIds(); + return objectsIds.Select((id) => RhinoDoc.ActiveDoc.Objects.FindId(new Guid(id))).Where(obj => obj!=null).ToList(); + } + + private void RunExpirationChecks() + { + List senders = _store.GetSenders(); + string[] objectIdsList = ChangedObjectIds.ToArray(); + List expiredSenderIds = new(); + + foreach (SenderModelCard sender in senders) + { + bool isExpired = sender.SendFilter.CheckExpiry(objectIdsList); + if (isExpired) + { + expiredSenderIds.Add(sender.ModelCardId); + } + } + SendBindingUiCommands.SetModelsExpired(Parent, expiredSenderIds); + ChangedObjectIds = new HashSet(); + } +} diff --git a/ConnectorRhino/ConnectorRhinoWebUI/Commands.cs b/ConnectorRhino/ConnectorRhinoWebUI/Commands.cs new file mode 100644 index 0000000000..f8f4a763d2 --- /dev/null +++ b/ConnectorRhino/ConnectorRhinoWebUI/Commands.cs @@ -0,0 +1,174 @@ +using System; +using Rhino; +using Rhino.Commands; +using Rhino.Input.Custom; +using Rhino.UI; + +namespace ConnectorRhinoWebUI; + +// NOTE: we have two commands to test both cefsharp and webview2 in the same host app. + +/// +/// Webview2 Panel +/// +public class SpeckleWebUiWebView2Command : Command +{ + public override string EnglishName => "SpeckleWebUIWebView2"; + + public SpeckleWebUiWebView2Command() + { + Panels.RegisterPanel( + ConnectorRhinoWebUiPlugin.Instance, + typeof(SpeckleWebUiWebView2PanelHost), + "DUI3WebView", + System.Drawing.SystemIcons.Information, + PanelType.System + ); + } + + protected override Result RunCommand(RhinoDoc doc, RunMode mode) + { + Guid panelId = typeof(SpeckleWebUiWebView2PanelHost).GUID; + + if (mode == RunMode.Interactive) + { + Panels.OpenPanel(panelId); + return Result.Success; + } + + bool panelVisible = Panels.IsPanelVisible(panelId); + + string prompt = panelVisible + ? "SpeckleWebUIWebView2 panel is visible. New value" + : "SpeckleWebUIWebView2 panel is hidden. New value"; + + using GetOption go = new(); + go.SetCommandPrompt(prompt); + int hideIndex = go.AddOption("Hide"); + int showIndex = go.AddOption("Show"); + int toggleIndex = go.AddOption("Toggle"); + go.Get(); + + if (go.CommandResult() != Result.Success) + { + return go.CommandResult(); + } + + CommandLineOption option = go.Option(); + if (null == option) + { + return Result.Failure; + } + + int index = option.Index; + if (index == hideIndex) + { + if (panelVisible) + { + Panels.ClosePanel(panelId); + } + } + else if (index == showIndex) + { + if (!panelVisible) + { + Panels.OpenPanel(panelId); + } + } + else if (index == toggleIndex) + { + switch (panelVisible) + { + case true: + Panels.ClosePanel(panelId); + break; + default: + Panels.OpenPanel(panelId); + break; + } + } + return Result.Success; + } +} + +/// +/// Cefsharp Panel +/// +public class SpeckleRhinoWebUiCefCommand : Command +{ + public override string EnglishName => "SpeckleRhinoWebUICef"; + + public SpeckleRhinoWebUiCefCommand() + { + Panels.RegisterPanel( + ConnectorRhinoWebUiPlugin.Instance, + typeof(SpeckleWebUiCefPanelHost), + "DUI3CefSharp", + System.Drawing.SystemIcons.Information, + PanelType.System + ); + } + + protected override Result RunCommand(RhinoDoc doc, RunMode mode) + { + Guid panelId = typeof(SpeckleWebUiCefPanelHost).GUID; + + if (mode == RunMode.Interactive) + { + Panels.OpenPanel(panelId); + return Result.Success; + } + + bool panelVisible = Panels.IsPanelVisible(panelId); + + string prompt = panelVisible + ? "SpeckleRhinoWebUICef panel is visible. New value" + : "SpeckleRhinoWebUICef panel is hidden. New value"; + + using GetOption go = new(); + go.SetCommandPrompt(prompt); + int hideIndex = go.AddOption("Hide"); + int showIndex = go.AddOption("Show"); + int toggleIndex = go.AddOption("Toggle"); + go.Get(); + + if (go.CommandResult() != Result.Success) + { + return go.CommandResult(); + } + + CommandLineOption option = go.Option(); + if (null == option) + { + return Result.Failure; + } + + int index = option.Index; + if (index == hideIndex) + { + if (panelVisible) + { + Panels.ClosePanel(panelId); + } + } + else if (index == showIndex) + { + if (!panelVisible) + { + Panels.OpenPanel(panelId); + } + } + else if (index == toggleIndex) + { + if (panelVisible) + { + Panels.ClosePanel(panelId); + } + else + { + Panels.OpenPanel(panelId); + } + } + return Result.Success; + } +} diff --git a/ConnectorRhino/ConnectorRhinoWebUI/ConnectorRhinoWebUI.csproj b/ConnectorRhino/ConnectorRhinoWebUI/ConnectorRhinoWebUI.csproj new file mode 100644 index 0000000000..3bc44cfe78 --- /dev/null +++ b/ConnectorRhino/ConnectorRhinoWebUI/ConnectorRhinoWebUI.csproj @@ -0,0 +1,63 @@ + + + + net48 + 1.0 + ConnectorRhinoWebUI + Description of ConnectorRhinoWebUI + .rhp + true + x64 + + + + + + + + + + + + + + + + + + + + + + + + + + + + MSBuild:Compile + Wpf + Designer + + + + + + + + + + C:\Program Files\Rhino 7\System\Rhino.exe + + Program + + + + TRACE;RHINO_7_DUI3; + + + + TRACE;RHINO_7_DUI3; + + + diff --git a/ConnectorRhino/ConnectorRhinoWebUI/EmbeddedResources/plugin-utility.ico b/ConnectorRhino/ConnectorRhinoWebUI/EmbeddedResources/plugin-utility.ico new file mode 100644 index 0000000000000000000000000000000000000000..022d1f78842c15850a45c0405c872e51c1070015 GIT binary patch literal 33583 zcmbrlWmr_-8#cOUVCWPCq(e$tkxnU<1_h)`1nH87p+Op?TUw>0duUV|q#Nn(A!gmy~O&#<8LCpZzzjOG|1(i~Gc`OgsfD$v(b4h3oa znW}ts`Ws(!zC4_9apn0XpBs-6Rkrk3Y`;`LeX7|&3O*K3fBY;d3nh8A;5zaa6y9x9 zRSNb4Xo=XJoIop1)cl5kNEQ|WB|uaH>V`nOZD9Y`w^jT|po;%e9&QJ(IFT1C+9lxw z;o9P>U>FW1pyn5X53r!;x*+8RqR~@KDm4Q9T@a`?!~feCJRd>@SfoQn-eR)6UDj_gQjI-oO2vgS{$g*HZR_uf792;>y{ZA^D*D%~y*AUn1yw+ncXfSp6TG zX;Z6=SkIQ$)*s|b<7|~BE(NdGfGjWFMICN?UE9J|R`s%mRpGw3&l9g{Q;$?xYlsK- zk9>!RbNOf+;B$ZI8YV==FH_qa5I*FZdSCDx)b}&;_8}jAl%L$q2;Lx8UFn{NHK;Q zaw8&2`})%-Awh>h?ZD(9^q6X$5Se%PlaU(&Uqb(X+}JG#$SEm<)k-jueqll&5E5!? zJWWl_^QP@>>l@*c!~1!5Yk@a!-oTavP=w(`bV1ta*_&LqR>q5z<5N?yv4T6-ZU26J z{`m3ZQJP_Qm_d!zP@c_1@j1Pt{akHeT3VV+E}If2CGft?73_2ecZP3fIyM?&S5DX3NK7|^$dCQLENbX2pQGKK21%7LNhX9K=( zr4qCzA$asOq@S8R3?KS)@-;}NJ76`G(sa7Q$W$m3!^`hmh|c%We7W#0Lg58qy)UL9 z!1Wu}{i@%Bp}BQdL)7r?g1Ft<)jxrKam@S{eFWR{4UT!lCByeC{1^(D_V}M|4jr#W z@r@7o`(d}>5=+4u4Lug!NoZ+lx4X-aBes(V?3*?_dt8sBS|nQDvhwWF9Q74x6OOK;S;RK7L@%7uI4KQ>YW}NGAmgq5BCP9h?n&)kMWN1q)>Vuf>O_f)*XIPSiqp4Hw~2#DXxi8XU*Ia~pVh17 zfbd{!Vy%QyJWq!>X{5*nj)+zxz@Z$212oTEEqXA}OuLMnUpT8i9q8w%JPtzJ*_#$1 zuf=z-yrBz;xb^e5x3lA3_%vV6?>0d4uA8!(7pRC!egGs7_`rB&y}iZmZvXJDF51sq zi`7V*njQ}cFNf%q>t7@2CfV=TR)+^DP6(9N`Q3iXH4aByo=h8IC$XysRaNmb7?=HQ zIni0yoj3HR069(DAFBgBM!4tD%l%mlv`PwOf)y}`@qSVZU@cV{XzJ*wLB6)OMlTH1k85!- zzX&`ERg4t{s;dR$AAe=ym7-r;UuWbLNLXMWWzg_!Od%rHcclKFaKnf--Y*paYI^ib z;H%Q{;Iom@8%R69`|cZWKbl<)CbTDOz5)2*7XvJDGWz<|XCPCPM=?_q{26dj+N-$F z(S=u+29}ueiMQKnRCDi3ALqRAmzAPx;p5>cKsZJZMulUsFn2Kt2t?kcQOllL4dvU< z*Sl3nI}qdI)_LO%f*H?df`QTge}+z;Cv8_t1<&XOJO}WGh3>V#-6Sk{FA8QbRL)l< za_g_I$%U7%$?*d{2y{b~hcs}eQN;So7fjs3zx^o;F_0K;K52&2v$KJ9^Cx)QAXD2X znE08`ZSfA~>R57KQi@S9mq;bMy)(#h`qdPM$O;z-VG&ubQ<;rX$dke?==wo9#|2(YV* zE2B6U4PK;3UI}9lWr!yBpyc-78p?wl(|V>)ly_u+N9PL_+4}g3Bzm0CiCraQ(bJj^}hi)MMgGD3eDposFG6oXV2--{wCp zN+~|R+}g=dK@9cSZ=QtKzS~F(+hwUHNlAJ;znTGJf{~_pH-^`*m3MqW(V46ApbcSEx(RB?k2Wr`Wc2sCGX1;f!4EOaW|pN z$`wix+bQmd$jIVODRSV3ft0+~AgWg-X3`E3Y&EYbz`m z(fnVQ#alsVgohm{|6)yY@?v#q1i6^|Zs8qYVamN8?kE7k*rhff?R5)Cz`yP=!qC0` zIQH`LUj<`6WRR_`F>MZB&QRvHz5=c|x$xe9Gp{uS?O3}=9lM}`u+CsCSx-+9#QaT@ z%sNCQEY1jvoQ^=q{LU2f1czUWlwd|PYXC!KO_eca2UJ) zeH(Zu`BoeqqkA1eut$D+i+wafovVHm#j1H0{c3_QDIa{zU%${dx6WtEce|r!InK{F za~l}Z1(8Ur6Hf1VWvwcOf^KgV6lxXtxViIkFh8fm^~M@C3;97xBtRz@Y(zn}$%!e( zo0W@jHwVt6k@nZM3CpBbAS^{>Txg&26()1m!g~GjF-`=|^tg|po2X_L zO}QSqe0lS+#3qI59n-UC_!aRwQo)VOA}&tdAv9S_)8=H4o@En+822`vZS6dNQ7z-R zl3}a(;`Z`@=_TF2zoTuDAY{++nFglQt{`4T1Fx(fB?yfn)*1kbi%IRt=gD$TX4wr* z1y3~n1t|fA&bwLGr06B3pWF08)Ku< zOUWV;tyqs`b|40pOcmQqiO%w(g)Aoj%g7v92MXaBXY%AT@Cm!3{bu*$-3}(!|E4wF zi!+AO4wp-Ji5d3aNPM@>1DREkJ_DQw1Om^K$&wPSQy3SgV{}(uF=jzzj`2o=Mf`3A zjc81#2GeUNQ~j1?A7TO~!5s2twv znXf*IjeOBaPPIfWY@@<*eHgu@tt-Qgw=GF4;u-Hv&!xl7ZY<9*V$+3=smxz^yA`x3 zxb;R?*5?S>6}4;Ws9;}a4F5QZk_1Id#7foOM}xXD~stQxOv!eW7PP{14Hr=^|$Y*^!56CgsK5fAMew8BZLgxvI!w+IFvijm5Y zrb+tL_j_SpDEucV=A=Ni2Og9kKx-o6R=cb58I2zu^1#s7tqegn^}$$#wY`u9nl?Rh zB04E~{r4=~{+6T!G(rm_q8K?48E&vh0?xGVvAiG2y&-AYLuC2m=xq1aDHUr@2M9w! z!Iq7Ze0*`m@U`V_$(1vB<4nro94tkVH}K?(pyqF%^ZS1A5@Sn{VTV^nVxCF?C-5Y&h~KeKDj z9!7!a!zHtx`^gR(82%N8_WSW)FD6RV!y}GyY>Z?>Au?3V^8Dpq=i6h(Q9n%+C%19~ zjJMcGoY4@(n+eE)xfv0>F%Ke2+35?FI7Z{P2u94qZx2Kr_hzaw$_ZD>xT;V`9c9iH z#%*}bZij15vwj@hyXvR$z!VuQR7o<1fKkr@5rDd7perxsx(7Die1J|V0ZAlowU{z*-d^p_Y70>uPn+EC z*mafYNa5Pg*VX7e*2$}Foa^@lK0mVhm?P%?d%bD>1c6RZZeVSrdk=B~kpvor3Rv{b zaGm4{uk4dD&fHjV!`=bM`q^Uc)SJWUa<{7-n6G&R*KB|D2jvW*q2T^SE4ylj{4~oC zeDq^d@B(Tg>MmV}U{Gq80?eI#wF|&HO4_$%a6d%=Du_eygQH0JZ36sOQ>HRlZ!lO-=D95DdmV z^~Cdh?7ds$DdYTa`M*Ewp~NRpbmh{WCmY$}9J=QD zq{5utI69=%>do9adhNcVJV(a==gBN#;|3y~ibUsNr!PPY?og(1Fh&3aRMd4-CReI# zDlb>tCGID9WjPBZVdeO~`-E1f!tl|y^3g-I_jW;GxPy#6MGXtAV=JG|!HNV7Y5~zy zvi(w@(u4-P@w(gbq2sPt{GqdCBAHHqzr77?zcc+6xu7(^Wi|T=b6Bp=dW;DI2V7Nc$?4F+PHZ&%n_k|dKJtFF8RGyYo(qC z$SWyz?zdP?aCSAiR9DeME5R$T2)<+qp05*2!)kXXBy%Wr1pCe^5B_HmLQb(j{r1x7 zR`uiSy6M<31IMQ1*v$E7=Tx@{<2I0oDA*ql82)y56oA54PW3kK#B~K7Q|Ae5XWlQI zPzU(@S$Sn(OxtZyHcR#jZV|;K+`nFwCoA=1u*GX)&&?{&H-V_nzk{+s*L+w;O--mU zTOFg#82j0WMOMyn=KcwFY1LG_??d-qh{Xzcw}GVY;9Q=5e{P*taxHjAzQ47?!5x=- zSp^FEJ5G&ZeXLh%IW_o5uw_^~nO;dkX5#^khCcAG9|htyZj{+$#gRb5$(%O#-^ER1 zw*gs{(6@=UT=!X{69+c7UShVn7`1vlrmb>o8$>`ts->m?iV89R*I_$Nu2=2byLPxvmDL4!G_0xq^B_3SGbJyBR}Wo*zaJQBm{KPoBKq1FSKiPF z>7UO3P_>=V>t+ds{P2M?kA8dmT_zy;zD84Sqky(-N#e~*!(UWi+0Kc8j6FXwJ!b1^ zmY~D|!6IL!@);FJN;Qf^&A_WSQoMnwk)?(sbXF;bIFNz(&}uOMmqM*Z^K+E7DF1m z5eYAbLN^EY*@_4tBK*=4lQH*vmCvy8r7pubCN^2YbRx~=b@#SptX@R0$J#oHJitX& z9&o}6?%=HnfZVUS38PM_a6t4n|W@rgadarh5&OLEpKi!m!0#iQR1q^kw%BuM(9$ z-Y9$&l+`fKz)y`uF>L>SmM%@)KPUX-9p=G&-4{E`60F;WX^&?%r9XcLr949&G%WA; zF}#jmdWWfBYt8fu?1HXt|FQ0oFjtr~p43gRv>df-?~BVEtrw*lpX!J7F#Pw751_dL z2r|XE+#Ppm!3ZH;9_Z*X+xbzfeSw+Nvf}Yn{}#+{ymN!>Nah`rK_BB+Lj1tgY2K6` z%pTh-PJs_V!DYY^ipC##{b4l3dV#t_=exU&UvC&6DJYXajfZ09WQ@r32yw;gPW&C* zjzS}q9o1L=O-u@8O-^_mTZ;Ix4ehm`428YW+B-SNpZpkX)*CFz`1Az^gKq*>2O=Av zA}Z1iTPp19en*=0auSYb?z5G5z$nMn5emN@aT&nd7k8ykds71eRrA|?PpMdn$Xfkw zXG?(-hq~Tk&}*^c`S)}aw+f0M_rs_~XD#6k-d=WA7@?|Zq!n*i5&oGc>wb+wwCK#ibM1Rg1#QJyNwlF6Zr`lt_*`kK z3+VDtY_Y=e?`vU7@bUDrk}15dflPSzpZhY~FJU%E?-b$vcaa39ytB@GD-ocPaU@YO%9yv@VGYXepZXy%xq<;1N=)oOX zq)bb_{Q*zK0uD556~7Mhx4yq*Br8z0(lH1FoA}8o-RdY4uddEp^?Tei=>>whErYrp ztfJG^cxUua_;zN`+5K=PiRj+92=78g~72C6BLQgXG)eQdsAc$K`#F zwO-&x)e_;(ilfRI1;(pWk9b!z;WKA<>uCaGBUEV{>(%>llA!goqt;vAG*xs~Bg{{5 zr}gll01bkiC?G1}*RNmy%oUDWRnF0!l>p6KM9co$+R}6c)-lt3-3}MLD*q<^)2p@C zOa=$vCp0yDSaCT6EJ#V`*#XV88^`0>zPs>qdjby?yDjUBnAoZ1o0%zA#(;n;1BxA@ zFQZojYV!)Mpv!jW<)!SEorlCTC@WHEYpbuP-vnE;oiMM)6M9wHJAe54(P%!#!B)!! z&VXMO#gIMgA1eKTCWk;(%$_>D7%Uc5$-dQ>S;o=$W%N=mm{Pa^yg|r7Qv0>&6^JvYhyU%xrW;cJ!x$ z@;g$P9jvj@ld?ONhA`e1fp+g7PSO81HpbtNYD9~DlDaA3qEmy|-1*m&Bh~r$0?SM;Qc(y@dSPG=cDBgeV&YWLEDHvMK4p zcrmB8P@s8gXPIihQsj@PD&jHiD0f4$=N`M{cXo!#35bCB(5ombSz98gw9dLV~OPvY(S}N&t z@wG22IT<(L4k`Xazm0l);#pb+ZiO7Ym(m1IOa2d?ZQRv>s$MkRCkarjWyXbsY_e>x zb57TV+F}V89JY;ZJ6&lKL}NvDBN}`#DI#BHNtl?Ef$$BbstI48&crfB-1V8fyTYke zcaTF-L<>KAMpoZ`!nUKHTfo|?C&MHoM~>&ac3W#dPr;^|g`+v9d1=Zxgo{HQj=9E( zIeP}QQnh1~!c1;W0+6^gCO&lZ#&DAJ-R#%4*mzr7`ucbsWX>>ej5Ym`9M6+p%GDGD zhm)P#t^cjtH+{V_<|E-y%K`-cwx~8P82e}!Pci9l=~&){IZLV+wk2;SdZjvZ%2cgNjvlN^5ONqpfe zq>N}HHgspAc+5`5Rv0Fx%>U#`#wXl`NA1eI(2291ot@)ti#S<9=PTVxV@S4`M@l4( zo&pe#*D-S~I*W2HhB5N?c%KakKg;F2kI&D*Ra@c9t2e(~(_Q|aV9(aBXXnK@$hALy zD8c`otI#c?MA1R;v!P!Cr75`r$|e=P{3Y6(JmzhsjTlC+}JDpioj(1L0-J&*3LlrgD0=YSGrcGZ5m)SjY~3a zRP$c&&y3*pzSvOBf{KI)s1A){QgF~?<`pSi9Kz-wtV`N;aPB=5QSm&*zEc z_lJSSd?;Mo>GDt${}Wnng)4?LJiQjsec+tJ2dE{frET4F2SVsa8xJ1eP#GPvo_XsV zy!6>~aIycZzyiKJ@FepBS>Jh&MFftq;c)=HMOYjIcXUrj{C|In&MzW)&@*-9I9`a0 z=(GS6;d6jzUX0{Q6N}Y4I#Po2UsqK%C$M+-Z$-1QNZbzAIPJro^^e!Dw{n6_PrYxY zjO7`54kT!q`+b)Y#Gd8S5z2|IY-~@n8SXXv7YuDekQLuWHKVvg!h}PuvaJF?*Sf5l zQR`JRJ~S_oD=P08m?@)*(Dx}2kz%B3`9*>07Kk zD6Pso?zYxu0*jsn;h>Tx8{GAkj#%Ot$dW#i+>T&|rbCrexx)qqUd}a({SNuQy&g{z zGoQy8##(Q;2$n{dQnhxoV4>Dp5c4aPNi)&cy*52e>%`IgfR&0_4T1 ze)IvfQ$4ivI+H8*6PTH9J+s3h>SRd7JIo$?=w19+t6Pw2NDbjX{}MWYKRQnqXy^*` zj%?xyYyyorRpRI}9Lo`MiM9+FO`d*s^ zc;ysF(-YS>3mXPVqW4NgW}mJ$I=%F4q?p_$jEJVXUi-thvK}X$zkKUjxZxPq?Pnal zd@U7+1FJunUkRm@NVV#g2tsdxJw>tI=YjHvfS@lqK=I}qBlS6cjJ29Uu4b?Sj7PY( zfu@$_`v~TtmjB`=K!tf_5<%G52R=SJeZ99=9Y4@puvEet4$*z#8R6zaXmzw2-K1Hd z*yKk?M6=|%9^BM^5KSAa3IR;h=?d`=~c8PbF`wO9PpgOpzg>L7i&DC{`wkK|(ah>FR(|U!;xD>-G0Ss}-||GR z7!5^tyqMIOh@gI(Xu<_n5GS>(-ARze69EyCjC?E=u6VuwOr5O2#@u!%*z&6P1tVWV zyFbp!gUv-(V#2$oLENfTjx#i+ij+>xnyBnRY@X1D%wPq}{>Saqy#`KC@l01D4AN3h z#}ymG`+jKy_&!((4BKA=E`o^cE#Aj0ZIf?I|7k=h7Px(ZSep+$w-6igQdnnQ$GmDu0AGm8eUh$+Ydo?%&$+SoSI|ewTkZ8H^$HP|r>c zkl;+JiC6NW&(&fLQ=P}R){{RAf4r~)4(IV3mIa1v6DJ}_Sys?{e`h;c_a#?3DKL1# zAil~AKZxr{znl(XjrT_pXkfp?Flbm9CG8`ywXyxB`jtsKUC@MmeL6}Jr{^8ioV2Rp zuKud)x9mo;;wg*nSc-{m4&khg$%}WZHpS~lQ$-JbQOk5{-wAKA`Y@bG)$d{#0*!&; z1p`!<7_|kg-`r{TY{;N~+#Q2b0-jel!YAOQNLsa+nq-k7>dJQKI&doy>9OoLZP6-6 zbgyn(OlVyd_E(}Qt#x9e$Rd*$ALII*mIvuSbx%b_FK|q+(e%hlX!6Iq5fXSi?^fDs zkc8$J_5fnRe=nwV|Gii$a?DRtBQRIrTSQLb^S>XTd1BH)C;kZ*1i_a$4CcAL^SXk; z0x?)wKtU%K5A%Hn&SDa&1*n_vTs@JwzIV9XCe>Yg&IO})=M(Bu|I3FD!N>b^s#T{u zx@nia5drI$4KJ)QvHrXn{h^8ZgAsvTVNC8hW;I{w#plN}hRRYij7F`4|25%d_U?`Hu=PkD>p%UCj$(idteEA2<;%I z4^6NrnaDtL%M0%kSF45t#@+-sJn75WV)aq3c<`p!3w(3N^kWObNPTbHKSu+&P7z?D zqm6$%d0LLDbDWK*82^lB*ImE!9p6nvt# zvQJv6x$+&yG_ne{e?$Dk|Hh_xHU`}qb0vQK3k@C64K2FkHE2&Qi+<||bXkbWn%lZP zD(~eiRy_ny6WOrF?22EUU8r%w65p6KnaLyxvgcL3#P))CXK0&NQ!$!sZEDV2wcERhSv}AW`*P^-r}e9^K71`;Hd_y4 zU)}tLeAs1ahHe}>7PJXm3}g;TWmdTNI+rc%`J4tYP*+w2_{Xmtt zKC-))>wUaQVL@&visp$6BVzJXM>GQq;(M+k&U!zQ?(v?>NGLv~DY`Yt_^P`#xJ0)y z2;KcP#|HKq*mt$Pvoenmz292wG;r(~a`Rnm@d!uvdX2&5-ri@<=T88~);f$sA8Xe2 zr6(_~-7%~SlFCU@Ri=6u1E$tldBOZtD`ao}**nqTx}i9my!`wGu5u6?MS-B3!i`uEKP`sjyrs>H0f%zi0kgCa9Uj z>*M3#npa$uJ$GWP?`o_FThGUpRc_aA0>A4>LP$vy)G9iBNMT+Gs_prjEgvz9__`dX zJ~peNjG_Ti7c}WkO$wMOdn@#~htF)XlnF4q9yQ`A64rkxY3igD|BwR`7{A%&J!Gc1Wq zXJ(qniIV)y>}S7})YQ)5Y!g_xl*)2%a$tkQ;t?W#TJ#=W2_f=wk-Sw=(_Lq|r_^7rpn>!?7=q2pKxAo<4ru^A|R~ zk&SN78uteMDC(=8ud+O0xh(4%?u+a8P40mUxRMwkq>(d!e7VyOqY%h%gC0)zJ$-M! z1EwA1TNgDc=UofPo_cL24v}c&Vx{ggJ&^{!G?l4=wj~Pqv(Nh8&LrxMlvmdWhwW`6 zj?9XVVHPE4`9BuMwi?p7B2PNx76Wt~GDNVJ=1wKtQMP19t!G5s2KCWi0V-t1@KJDc zd_-L><>&%-(yx~ta)x+zdo+%tFa|CvlbJRjVM3uN==Rt5WjY|e%N{Y$ljMf9%eUB} zn)lf?zufs&$hqotwX^p5&&wm#!|*!-H6w89xyk$+<5Md36I#h+b$lmy*b<5$*xEFmGn7<*18B0qf0ABTiui9TwIq;6vQ z)xY@==NT#l$Zf-ddJ4kC)K_}aeFwP6wc^J9*2!EpjpYA0#yo2>d%{cQ*mYWy)ABEh5qhKT8DoAw{~yFedFp~2y?-2(y>d96YAzqZqg zS(qg1@$Ih*Smaill)~k-d>adj8n)n>v*w^RcceVn`Ouuy@E3QDzjOVZ=e6#ojI)qW zM?Ei92hazqir7YXPinE`hWEvhB`L`VBfBk# zDcs{eTlMKVsSb9hePnT_L(qDEobI1n3y2x_LFlaiUqZAEX{rEKh0{G{XTA~eewi1U zoIRIv+o4&)ED!sL)QiLT(pOlVQL3>6?Z#h#$KTGmhB09F?>DgEx7I|9ytQ|VMj*>9 z?|$1wsX&2(a9ICQo7Ub}L_4|{RGo75jXow8A+R^8nk*hsa!N`EYRSAp=~Ia|{Ns~n5Eafd73$wt64&*PnM z=$?SN&vzCH+mTlWB#%hxw~xO4Hr-f8cLH;c)4{Tk=#W4DOY-^7L-fu+g#zYEey@7> zp25y0pQ-A)SL zGX=lFE6S46kDpfa$v-{^xB9lV2#2y$>IW-|wH0i5(C>K+pSseKI%VTKu@;c4ud?H}_ zJ+54u%WRB}srVN^OnJK9UIOiCwf2dT-N!Z>>POTIWKn^dqG?^U5& zrc#dEeUKJ|y%KU=nQ|&;0)jgwUh5n)RUf&ny9E=aTI=3Z(zKU~GsfQ0$ji!V-tb9< z*WDs-*poJI@Oe7MG;rRPGz6xfquzP0Uwkl~vlqs?X(=P+*9Gw1KCgqR{wj6%t4JBX zZxp)svAYLQBNG(Ru-F7uM83lzQiV2BtlRWRGa2Jo{%9szGw<3T^FR3^mA~N;c}GJF zdg0u}mo2-?iH>OavrY91!Zunhq(6sSv9XNkC#t2~P~4uM9vWb=lx*HVjTAmWbhhfm z@cqQ%Rpkr?*|s@-^_bc5T9QTnyCjZ;1m$qVzNUY|s<>m)CPG{ySUH{5Y4-=oVuQ{F zXX82HmxuHgVpEzd*j=f)b`?n$2*Udfn6)I}t{Pp4N_!Eh!p%VJ@Sgg{zz7*~d8P0! zWvp6sdv6?w@!Iyj~P#1LYICa_&EQPPUoKA@=*B9R0^U<$cvB6#B>NQ z5yY8U#4IRf=gznuR<6kS@M<&%=!gce2MpYn#ALMGf5>mXt&_Q@^9& z&|$<_XpGi5RS#(hBD`jxdZ$x!gpbC>x;Xa=PhO-CwRa_+r`=y4h?EjBzK1v};P^}v zf`a~$!tYm4ji}!8%L}(q2%5z(N=RTD>q$|Fv9o_>zGd@?;v>aq>BI z&F*6T$WazJ<@JXovu>pkc?=tAn_d6B4n)$6M4K{e&(|AEK1Uy{@g#>%*(Y|APhz^b z%Lj>nJ$C=H zK?nWHUB6SwX_UBHv_<*0>CN+!O_({0Uf&=-`jCY)7cdh(-B*j9lzt%?dBRQz9WAwt zh#5;v36OBJOJ#J~Qym|a(ySV39>N)Zc4sJok-3T=DosQ;!nBy=;`1jCfn2CnPrpH= z?KEusW#5)8IlLE;B?O2uAsY)@s(C=4i)SWa#K^0IpP7@1Q=ZX3M`*5e38N??(Ngu=FquP_Ue4BOanO3U@f{wI2c!#13p0)|ZHYB47U0jRm zTEH7BBv}k#*!TwX1Fy(W#9-Ki0nrW&ZmT0NBrb0CaX_UcuBIkwVEZAh^u4RU0qz8l z@dK6-FB_>dgd)Q{gjGUA8l5z4d0Y@iPj91R{X51!uB?^8T+T2sS2><^+I0}<*DUEz zPJq2AKLzD8|Jge+k3y}TMdc|qe5+LN$ECdw@1z1q?%bH%eTJMF;0PZC-JB zlY?*hM&aF&^UFnY7M{1P=69qz>(jGFeo9~(UWlHKjmb8$6r$|QA8V|N@=mT zkwva%J)<{9vnA*b^1N?wv%5|+)yNZKD5%VSHReK_N#rFD-oM#sBgZeZo3xm2)J!Cm zH|w>>CGjjyIgN-dK7HHURn*NXmxkvf%CqBkAw-%chS{$d@285kCefV_Zy+7f9k|Z7 z*sxNw?A5w0hp+RG%Y~l%mPoZ5FVKAukiU(cL?Q68%j5e+v!OrIFJ#aywdW^W`{S{ z!eiT|no(K>sa$}05Qfsz{Hn%rdN|k6&7&uu+bYFEI@@)p`GR?~;djUz^r@eK<8FBH z3!1SM)YL0K(}PnQyRya?%SK|8TM@|2LOI_=Gs&ch9!3Kq=%3@fI_3BrBQX2Ozd62| z_BA|mqwBDp8OKa9qRqi9+U@VdWmxDVai6987!m>f@vU6HTT{I{ `oL`4X z`(pvlfA|RDkz2P>Ekv=@fyrWI`{JIn?OBw~$ZJYz3m1fVts{iy)!s-6d`kV;=U}=r zw_&jn(6|#s@~>Sk3;R5lI2o<`sd%(>k*bJVjKOIfMm~GJfSTAkU3qO4dGLg6TKZPE z)Y1tdz+X!E8{;_@hTn$hU(6H%K2FY)dKyXq6)l}ZjT*o0@9e&cjwd=AOIZxwJ7U8h zbHGEy8Is=Lmq5A0HUNPfD! zUhPSzy)EJyStfoMs`O|W2EIwGQF#UyB@DuPa=#R}3E8Um2ZD{Oa}M=yz2Dy;6h8G#%B`8$XgI3zR6!Ssv2d{km&G6lq+>eXoxX%ypDm8IC@ELz zaXVo6^BP0P#OkIU{yBU=MKS}X}98NJ$*ktvteAlDA&<_@Iu99nPn^ZDijKcA!sFLh-U+KMY*$o9VHa*sMM2|VO#36CZ40SG zWFjt4@$sUb*er}#aAKs5SuiY@1iaxBFvwNhc>Ei3i*ny$e%?1U>KX^cGfrR*SY>t(_ zGVnw#67s`$Eq{F~__aU2hHr5rrs)9_s6V2{cRD{&C~IdHAlZUMETW=xKd)$c=Re>7 z@FaANtHq|8xKfXM&%L*wfe5X9Col()KgMbMtAx*du|u_m_jse9Cg0+xo2J4^d@ehm z3<*vuxv7|h^(O|*FEL1ihScOoE2GXo4&s!|1IGs?doD&!ym<>-T!u*=Ezv!_tl`lf zTzx|ZA_dIvEPk;cSuJ+F%^a@!aFu!avIBa>B+c^N>I0M0qHgIqmp01eG0AXuaLMrI z3x6}wA^1dcR@mn|MDz#CM@3v>!}U1mE+9s5ey@ z2!vyfaAT6b?vHp;pSs#T`)uf2pzRkhZOPb>6x?GBT#I*9fz`5p)i)tGG!ln5Z^(wc zwM~5Y4>LLrX=Az2XpKq0h=Q!ZE9bq5AhN1a%B{%(lLa}0>e%Qr=Ko}g7ZQf~hv@p3 z7igSfiHXDot1?x<+a{g=8Le0fC|U6ML*UQ-+)lmpoeSSV(_ujwYf6rrlB(iL@o*L; zLVTG$e%0tp2^&PF=lsMhJbNt6#`L^unBUoscze2~uAfQzR|GUkMg$!8^{-#HBt`)T zYubXzFYcf}J5vPGemn0_prfk;Nzb9U&g^HuW0R>{&$ zg_158^oWYmm-%@%>_Icdd}5zIs2V#G_0yo4My9ds0G+bQ;5NEMAsb9m(DHPI42{Io>isKbXS#sO8S{xTB@^p@KgAwSNs8+B-UT3dTH^UI8pEUo46kY^-8K| z4;AO;^NB)|6~f=e**&pANLQ5E4y{&cS%C8*4}HJu7a?J1W2H>3V;nC1?R^Z-`JzJa zZ0k3cz7Om@7nBkCFekG;TORs>PloRyhOJS6QUbB_*U>TUcN%5Sf_gOwie{H5%ozxL z3%SHT*{T|SAnK?5r~ElEs>VcE)aw~PdcVJV&L^P^DH=0wi7#F55XGSPwgT zSgJ-1;@K#If}S5&?gTRmFljB}lO%@hvtTMJWlOsR2=Sy|qEv6}N(T^hdUzhk=<#?p z(Bo|pIIg2sWBSLDEfV!QCgZT$bH^3Cce=@4?pDSa-o9>+SsZok3m z7Z5dTV?El;^Kzd2=4uDLC@xI)sI8S!L%%pU=|jz{jt=0-ssH;YM+#D#5fxNgpxBeS zr7SVoAzYa^sp_)jr;T&0Y=BMI{7>xb$K~zTRHMw7)FIP)+f}A^TI^{O?WyI14J^kc z9uL4Oa853+;Li)WFmv;adJ`J~*>COVGu0W*#k6W~%U%(ivR*fCP&e0&z|JYsQD zLb=-PhOeTq+EXL$>5wyNl_6u(HlKTZc;~SvOYCD(d*-{bSGc{5nO*JN@6{ITiPzbM zvsuqIH$OV;u6(juOO741Qb%fZcHg+ILe++>)VJ%3l47-Q^(YCmIm=x$)_H8z~pA_aE3_s+`DsxFb)qti<=4`{I>-_H$mYS$DUp z?x=xY-b+Q-St;2uX}3l-f3HY&TEhT&tBztR<6!U*iby9FaLtnkmJTt#)Hd zz+YjDhp;`O_j_XB_3ItrZL8=UeyuY^@)nk9 zzv;qBg)#PS(a+r<2Fp*e7+N?X-EmaP_Dto9dA}VH>gzo5U@mLX6SHg`3yq?%9(6bK zW(L;E3yn}OO>r(Yd^AvR@Nu7ATNbG+lqeKO>v0_IU#77RSdG^nK0o%J?Um5z*!60@ zyAtb_J@qxE<5$S^7vj(M&=)%pIrNIZ!PYw`9JKs%j%vP z{4uv)JL0mfqgRm6ur2!(!?&6VDX|vL5H^a^@i_jrjl_u6S*k~Lp2+U$D7sgK{L8=J zn!Rz671x%VEecsPyKuqr9LLxt?YSK5IZ+~O??kM$Q@TCzWYu8yAtx3~SIjxye?WqF zO22&v*B@WjeYvIQ661-stnvEBug0?~l=2pc$X;K0_|RL|*?V|47UqRY;aLfWei5wx zi*@&}RXeX;>D4P{?y40v54T42tC)QtxL=y^wEoIF&40fa?;o0#+Fx1BI;Zzfb4FOj z)W!`JXUVCq>Jm|&-hI-jA+vO}62b%LIOg^d3L4^FyPIe8N88(XGph#c9&%&J^z}d7 z-rHpE4$)~r`SVge`pxQaeevB4-NH+uSqYQ;wzK+IU+EF9YR==2Jz6kDN+|5Wal6#& z(Hnl6)1cZx8ESaZ!p8*Hs(qPLwB3sEmK7du)cZ0xeV z3+IF)YtCFw(owa+wE+g)rxtV0FEI)!xO2;_f9)pLVl5vTpF+uj39$|)Rf#vImPKEz zsqr&)_DKIZX_Nc((6T*$I-RSF5;2&Uz<(2OsD00OQ&B-x@iekgj@1yd4M=!V2-#?) z%FLVW1Y#wnY{*h``-yDI@;#T=gFUWjoy~7PzYii?0kL|yxH%^}dC%7)$7GKomNy}~ zkq}KGWV4}v)4x6Nck}?4#S+!$h)&g$Vi$5bqP1L(NDay3I?IWx{T=+jhX+@hC8y8e zWy}6rH3*!R4?)uAk>BvLwH!{U2Ocm@6%sNwGR8ile8p1j*aLQeF(b)nyxH z;IMc6U<}{fJWop0m11{RYJ-uQ(io~Pg}$nia3SXrZgy~1m1>khnmys0nf$Q*m(7OvL&PN05mIcpUayeGa>X&hvkg2wZ7)PiFj(aUX2l4%-5}QIwj5^C^kQ zh+c_(^8yj$<%Yo;GR!z4WyAhS_$d}5!+t8mg3-hAy5S`r)?7!$nUly*+=2Afi?Mfx zA6E7-gSA2%I*wlJ$%+{KlVqS{g5XM~G6eK-#N#`+P+L)k%O}#18@~yu%R{jz$OkjX z^C9C19i_$UI2=w6q3j<)Qc_YUN&hTuNgp+pVI1EKcgjmqQ*r?%$C8l~yADUlT!PnWSh$jUR&9ED#JJ{9;(h}qw@3# zoKM`2EHW38r;oz|GYxc>5d&XO3u(uW{iELpPmwP-^;ZJ%F4=GmH2%AH}^k--_Y>Zv%077=w`=YoNTF!^5aKQb}R|` zv1^gJcoudHvd4h-jdLL;av7SN>gwuHSXhYX&!2y`inXzq$b6h3Q;8OB#oZYYj8KHsL+}#-V%2H%5h~vn(#K)Qh~9YIHHF-qw+*5N)oprZ_Q$)&+x?`4*IZA zl!TFjBr*;szsK<5!TtO9VP<9qRaI5^_>6{yg#{zWxN+k?lA$&6Qyh7xvKV|;iV{fl z_e3R`55+rUkh?MzX@MiLj>urHK-VO3M9!a!`WG)ggpaXf$1->qhK1o=K>-R1&ttf! zCv$Ddk|lpB-`eNDhfi?R*8)bkGx(;ObwEW@0Yg$8NT2_3{FDJ*SNmERF>6w+ zM-Nn|C83PWh5Us<7{gU#WaFC{V8Mcg=-9C%6ciMgJT!DZPGk|CF#jAgesXhjajmKf z5fKqg|5IH=kbczo5wu@bQI0N3GO$&WLf+yTDBZFOzZ$k@uv=)WAuTN(Ij3{+XU1_1 z9XbpF0h6(H+ja&&?f=u{-rTu!$@4K|u=nfN?=SCzAB~^Nu_bgOlc%!D7|+Lrq9R-_yMn5!YE)EQMN;x1X8h~v=`ruFt_$wfR67M-+6HckuAh zBL+9^`;j9@g2&^bq@?6a(3yL!g@4haMa;NRR8#~dx|Y*iLqmhCAv{Kx?A5zBe)(kt zCItjA_{UF}fXZvv@ZiA%JR|QX+6R7qe$B>C1!yh&d-pbuSGv|w-6b$E2%|=gLcjj~ zVNaexXG24D>0%19l?sC~I(h?x{ocL%cuMsAYebG7J$keVdu!sSZDnU?!^OpgnRk4? zBgPVacOubMf~HKx;w4MT_}WP3z;Tq9SKvC)?`!YgMNLf&qN1XhHHqr`<>lqHsb;6v z>VE-4s%KePS~4=2o12rlFdgwb6UbVVjuR(N;P~-O96g$fEwQnTZ0*~(XUbCDUZBGX z+G`ZQ9XIgm@&x8%4!bOPnP)+_yvrp97m2EL3nsL=Fgwc z(Au?YLEopB$h!ZvwNcQ{m+~Kp|4V#Z>)!u3{wlVp=o{Tmof^KMbQ^Sa8%dAk%_VVh z@i)Y9QuQsy6IxGLNazhmR1}TGCOIKCB{7C%#Kh1@;*b&lFUg9xfovNANkCRYK$4J^ zl!V-Sl7gI+fTSTO-AMA%98miCr=Q+_2mbU9(wtjo`VB>1|6w>g#1rQ{yihn|G%k$t zMe*2)D47s|(qE_Ga^P>cGA$StGv}dl&H_}0hU5C82;5k*0yWE{a64)(YS%{NUi2nB z*c69{aXavM$1XhGm567F2l3)y3hGl*(UAHlUT2)Z+pKKh)M;3AdEaHf`u~n!{O6xv zS}H2RvaK>Kl~iD*tO_fYcCc1egLOM~*r>IKjk*T9YG|UXrWS0qv|+2Q13R6LuW5FWzDQH~Y5-zSske?|2sL!~8XyUSYB7e`?Gh338!#=S&S2 z>k(@nQ%;cAvmBW7ddgLU#iA3B=5zt4Icf5LGbg=5`;*C<W1}DrD|vBr=CEJt%ZT=C zJuaVb$v|3ki?fo%D{oB>2B}HGoy5qDATcHs6IWKO{pV}8&K*OJXpVb(X-w0VgCB_# znM!gRE7DViY*-}CE+kxpTZhx9TOo2zG?5W|L1R-WUrMvM@(AWB(Ab)K9!GTAr)##_ zRpHJu>;zNUMhr9caw zYaX*tlxik_8Xo}PL9TFauYhoqc8D}@kJXl%2s2fOG4X+(&dm5k>tDarT>i9N!^@ZO z>g9yq8VZQA)WAAxEo|tjgDD28Fjtks)yt)yWSEzi$JnB#Oqs&?&YBi#34dDe>66Fk z-nk<@J18=|H`{eYoP#cWxvJoIR7XYWrKZi}^5x5n4>Bld3f$b>U}tBChs35XNG;`0 z>rp?DmAWD(6S?CYI$?*S9(Hx(VxmDim?%nN!-}PX=Hct>OYEG#F#b>K7jkv&i}A!> zD@fnMpVp}-BM@r9J)D)D!m&OHOlTU%Qj)LwRz z_(qzh@8wV1x_kRJrcWmSQ_ts|&Odzki1FXdoH>*6xi;n5^tdJbX$%kbO;b68f`Z`h|0|ix6Br*r@a);3et-<( zSE6=nO4JS=8XDS^-ABhQ;ZG}{J9mz;&)eJEleXt${U6bce~mu(YuBonzE4O0| zynQXTls|3nHW_a-Nqhl~-=KE+fddC((4aw#Ux%(O-rn8}&ad&N_rHa|pk3-KN=Zop zozFBcE-q%Cx!`_t^6%l_oc6y~rX~E}l@;_^Yv!csuO?92;@QE&Q83&a=e@_Fc$_~j z`3IpaXa>q>%thtgg{Tf&iklIUxc&PY)UMlr`y1o%Xlp#4ChR3YyO@OfLr3u{Edy^) zoMLQ-ge#S!IqCnLKLOdAecrUK=E(m)QARLd9?b);IS|qy#Cb<77W)w)Vsl{=drPa5 zfG@REP_u+4A%UHO-}t-sz4{Tz{aiI5L@m?&{B1sb+vzKcd%8Q^ABqi!ka z)22DmhYLQePhuKY&G2%^920f&U7?Aw-E8pU`Lp-cGBYztEKdb<{;B#TwkL|}27a#2 zSY@q^^|qZb$+a79-KZupHRqYw4ytpPmX=a|{3HIfK5d+STa0lq$1b8vhTG_&yOkM! z88HI;_V358-Fq;D=n`M5PusY1u^67l9Wj8!-<~BgYcw8g>Cy-U5`BT{1YfI9+cr)=!M1JNhN|jnLG{n_r@9UK zEpG)g2Zq6wmj=yg?r + /// Calculate bounding box with given rhino objects. + /// + /// RhinoObjects to calculate union of bounding box. + /// + public static BoundingBox UnionRhinoObjects(IEnumerable rhinoObjects) + { + BoundingBox boundingBox = BoundingBox.Unset; + foreach (RhinoObject obj in rhinoObjects) + { + BoundingBox objBoundingBox = obj.Geometry.GetBoundingBox(false); + if (objBoundingBox.IsValid) + { + if (boundingBox.IsValid) + { + boundingBox.Union(objBoundingBox); + } + else + { + boundingBox = objBoundingBox; + } + } + } + + return boundingBox; + } +} diff --git a/ConnectorRhino/ConnectorRhinoWebUI/PanelHosts.cs b/ConnectorRhino/ConnectorRhinoWebUI/PanelHosts.cs new file mode 100644 index 0000000000..0140a81362 --- /dev/null +++ b/ConnectorRhino/ConnectorRhinoWebUI/PanelHosts.cs @@ -0,0 +1,27 @@ +using System.Runtime.InteropServices; + +namespace ConnectorRhinoWebUI; + +[Guid("39BC44A4-C9DC-4B0A-9A51-4C31ACBCD76A")] +public class SpeckleWebUiWebView2PanelHost : RhinoWindows.Controls.WpfElementHost +{ + private readonly uint _docSn; + + public SpeckleWebUiWebView2PanelHost(uint docSn) + : base(new WebUiPanelWebView2(), null) + { + _docSn = docSn; + } +} + +[Guid("55B9125D-E8CA-4F65-B016-60DA932AB694")] +public class SpeckleWebUiCefPanelHost : RhinoWindows.Controls.WpfElementHost +{ + private readonly uint _docSn; + + public SpeckleWebUiCefPanelHost(uint docSn) + : base(new WebUiPanelCef(), null) + { + _docSn = docSn; + } +} diff --git a/ConnectorRhino/ConnectorRhinoWebUI/Plugin.cs b/ConnectorRhino/ConnectorRhinoWebUI/Plugin.cs new file mode 100644 index 0000000000..3e640602e4 --- /dev/null +++ b/ConnectorRhino/ConnectorRhinoWebUI/Plugin.cs @@ -0,0 +1,26 @@ +using ConnectorRhinoWebUI.Utils; +using Rhino; +using Rhino.PlugIns; + +namespace ConnectorRhinoWebUI; + +/// +/// Every RhinoCommon .rhp assembly must have one and only one PlugIn-derived +/// class. DO NOT create instances of this class yourself. It is the +/// responsibility of Rhino to create an instance of this class. +/// To complete plug-in information, please also see all PlugInDescription +/// attributes in AssemblyInfo.cs (you might need to click "Project" -> +/// "Show All Files" to see it in the "Solution Explorer" window). +/// +public class ConnectorRhinoWebUiPlugin : PlugIn +{ + public static ConnectorRhinoWebUiPlugin Instance { get; private set; } + + public override PlugInLoadTime LoadTime => PlugInLoadTime.AtStartup; + + public ConnectorRhinoWebUiPlugin() + { + Instance = this; + RhinoIdleManager.SubscribeToIdle(() => RhinoApp.RunScript("SpeckleWebUIWebView2", false)); + } +} diff --git a/ConnectorRhino/ConnectorRhinoWebUI/Properties/AssemblyInfo.cs b/ConnectorRhino/ConnectorRhinoWebUI/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..504a629210 --- /dev/null +++ b/ConnectorRhino/ConnectorRhinoWebUI/Properties/AssemblyInfo.cs @@ -0,0 +1,20 @@ +using System.Runtime.InteropServices; +using Rhino.PlugIns; + +// Plug-in Description Attributes - all of these are optional. +// These will show in Rhino's option dialog, in the tab Plug-ins. +[assembly: PlugInDescription(DescriptionType.Address, "")] +[assembly: PlugInDescription(DescriptionType.Country, "")] +[assembly: PlugInDescription(DescriptionType.Email, "")] +[assembly: PlugInDescription(DescriptionType.Phone, "")] +[assembly: PlugInDescription(DescriptionType.Fax, "")] +[assembly: PlugInDescription(DescriptionType.Organization, "")] +[assembly: PlugInDescription(DescriptionType.UpdateUrl, "")] +[assembly: PlugInDescription(DescriptionType.WebSite, "")] + +// Icons should be Windows .ico files and contain 32-bit images in the following sizes: 16, 24, 32, 48, and 256. +[assembly: PlugInDescription(DescriptionType.Icon, "ConnectorRhinoWebUI.EmbeddedResources.plugin-utility.ico")] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +// This will also be the Guid of the Rhino plug-in +[assembly: Guid("aef36d52-808d-4ad4-bf45-efb5350fb3cc")] diff --git a/ConnectorRhino/ConnectorRhinoWebUI/Properties/launchSettings.json b/ConnectorRhino/ConnectorRhinoWebUI/Properties/launchSettings.json new file mode 100644 index 0000000000..627d38a6c3 --- /dev/null +++ b/ConnectorRhino/ConnectorRhinoWebUI/Properties/launchSettings.json @@ -0,0 +1,8 @@ +{ + "profiles": { + "ConnectorRhinoWebUI": { + "commandName": "Project", + "nativeDebugging": false + } + } +} \ No newline at end of file diff --git a/ConnectorRhino/ConnectorRhinoWebUI/SpeckleWebUiPanelWebView2.xaml b/ConnectorRhino/ConnectorRhinoWebUI/SpeckleWebUiPanelWebView2.xaml new file mode 100644 index 0000000000..6574b29245 --- /dev/null +++ b/ConnectorRhino/ConnectorRhinoWebUI/SpeckleWebUiPanelWebView2.xaml @@ -0,0 +1,18 @@ + + + + + + + + diff --git a/ConnectorRhino/ConnectorRhinoWebUI/SpeckleWebUiPanelWebView2.xaml.cs b/ConnectorRhino/ConnectorRhinoWebUI/SpeckleWebUiPanelWebView2.xaml.cs new file mode 100644 index 0000000000..d646b07530 --- /dev/null +++ b/ConnectorRhino/ConnectorRhinoWebUI/SpeckleWebUiPanelWebView2.xaml.cs @@ -0,0 +1,86 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Windows.Controls; +using ConnectorRhinoWebUI.Bindings; +using DUI3; +using DUI3.Bindings; +using DUI3.Models; +using Microsoft.Web.WebView2.Core; +using Microsoft.Web.WebView2.Wpf; +using Speckle.Core.Logging; + +namespace ConnectorRhinoWebUI +{ + /// + /// Interaction logic for SpeckleWebUiPanelWebView2.xaml + /// + public partial class SpeckleWebUiPanelWebView2 : UserControl + { + public SpeckleWebUiPanelWebView2() + { + InitializeComponent(); + Browser.CoreWebView2InitializationCompleted += Browser_Initialized_Completed; + } + + private void Browser_Initialized_Completed(object sender, EventArgs e) + { + Browser.CoreWebView2.OpenDevToolsWindow(); + + void ExecuteScriptAsyncMethod(string script) + { + if (!Browser.IsInitialized) + { + throw new SpeckleException("Failed to execute script, Webview2 is not initialized yet."); + } + + Browser.ExecuteScriptAsync(script); + } + + void ShowDevToolsMethod() => Browser.CoreWebView2.OpenDevToolsWindow(); + + var documentState = new DocumentModelStore(); + + var bindingsToProvide = new List(); + + // Test bindings + bindingsToProvide.Add(new TestBinding()); + bindingsToProvide.Add(new ConfigBinding()); + + // var testBindingBridge = new DUI3.BrowserBridge(Browser, testBinding, executeScriptAsyncMethod, showDevToolsMethod); + // Browser.CoreWebView2.AddHostObjectToScript(testBindingBridge.FrontendBoundName, testBindingBridge); + + var docState = new DocumentModelStore(); + + // Base bindings + var baseBindings = new BasicConnectorBindingRhino(); + var baseBindingsBridge = new DUI3.BrowserBridge( + Browser, + baseBindings, + ExecuteScriptAsyncMethod, + ShowDevToolsMethod + ); + Browser.CoreWebView2.AddHostObjectToScript(baseBindingsBridge.FrontendBoundName, baseBindingsBridge); + + // Config bindings + var configBindings = new ConfigBinding(); + var configBindingsBridge = new BrowserBridge( + Browser, + configBindings, + ExecuteScriptAsyncMethod, + ShowDevToolsMethod + ); + Browser.CoreWebView2.AddHostObjectToScript(configBindingsBridge.FrontendBoundName, configBindingsBridge); + + // Selection bindings + var selectionBinding = new SelectionBinding(); + var selectionBindingBridge = new BrowserBridge( + Browser, + selectionBinding, + ExecuteScriptAsyncMethod, + ShowDevToolsMethod + ); + Browser.CoreWebView2.AddHostObjectToScript(selectionBindingBridge.FrontendBoundName, selectionBindingBridge); + } + } +} diff --git a/ConnectorRhino/ConnectorRhinoWebUI/Utils/RhinoDocumentStore.cs b/ConnectorRhino/ConnectorRhinoWebUI/Utils/RhinoDocumentStore.cs new file mode 100644 index 0000000000..ff4a80b5b6 --- /dev/null +++ b/ConnectorRhino/ConnectorRhinoWebUI/Utils/RhinoDocumentStore.cs @@ -0,0 +1,58 @@ +using System.Collections.Generic; +using DUI3.Models; +using Rhino; + +namespace ConnectorRhinoWebUI.Utils; + +public class RhinoDocumentStore : DocumentModelStore +{ + private const string SPECKLE_KEY = "Speckle_DUI3"; + public override bool IsDocumentInit { get; set; } = true; // Note: because of rhino implementation details regarding expiry checking of sender cards. + + public RhinoDocumentStore() + { + RhinoDoc.BeginSaveDocument += (_, _) => WriteToFile(); + RhinoDoc.CloseDocument += (_, _) => WriteToFile(); + RhinoDoc.BeginOpenDocument += (_, _) => IsDocumentInit = false; + RhinoDoc.EndOpenDocument += (_, e) => + { + if (e.Merge) + { + return; + } + + if (e.Document == null) + { + return; + } + + IsDocumentInit = true; + ReadFromFile(); + OnDocumentChanged(); + }; + } + + public override void WriteToFile() + { + if (RhinoDoc.ActiveDoc == null) + { + return; // Should throw + } + + RhinoDoc.ActiveDoc?.Strings.Delete(SPECKLE_KEY); + + string serializedState = Serialize(); + RhinoDoc.ActiveDoc?.Strings.SetString(SPECKLE_KEY, SPECKLE_KEY, serializedState); + } + + public override void ReadFromFile() + { + string stateString = RhinoDoc.ActiveDoc.Strings.GetValue(SPECKLE_KEY, SPECKLE_KEY) ?? null; + if (stateString == null) + { + Models = new List(); + return; + } + Models = Deserialize(stateString); + } +} diff --git a/ConnectorRhino/ConnectorRhinoWebUI/Utils/RhinoIdleManager.cs b/ConnectorRhino/ConnectorRhinoWebUI/Utils/RhinoIdleManager.cs new file mode 100644 index 0000000000..b64ed9d687 --- /dev/null +++ b/ConnectorRhino/ConnectorRhinoWebUI/Utils/RhinoIdleManager.cs @@ -0,0 +1,45 @@ +using System; +using System.Collections.Concurrent; +using Rhino; + +namespace ConnectorRhinoWebUI.Utils; + +/// +/// Rhino Idle Manager is a helper util to manage deferred actions. +/// +public static class RhinoIdleManager +{ + // NOTE: ConcurrentDictionary possibly removing the collection has been modified errors in here + private static readonly ConcurrentDictionary s_sCalls = new(); + private static bool s_hasSubscribed; + + /// + /// Subscribe deferred action to RhinoIdle event to run it whenever Rhino become idle. + /// + /// Action to call whenever Rhino become Idle. + public static void SubscribeToIdle(Action action) + { + s_sCalls[action.Method.Name] = action; + + if (s_hasSubscribed) + { + return; + } + + s_hasSubscribed = true; + RhinoApp.Idle += RhinoAppOnIdle; + } + + private static void RhinoAppOnIdle(object sender, EventArgs e) + { + foreach (var kvp in s_sCalls) + { + kvp.Value(); + } + + s_sCalls.Clear(); + + s_hasSubscribed = false; + RhinoApp.Idle -= RhinoAppOnIdle; + } +} diff --git a/ConnectorRhino/ConnectorRhinoWebUI/Utils/SpeckleRhinoObject.cs b/ConnectorRhino/ConnectorRhinoWebUI/Utils/SpeckleRhinoObject.cs new file mode 100644 index 0000000000..3c2b255343 --- /dev/null +++ b/ConnectorRhino/ConnectorRhinoWebUI/Utils/SpeckleRhinoObject.cs @@ -0,0 +1,27 @@ +using DUI3.Objects; +using Rhino.DocObjects; + +namespace ConnectorRhinoWebUI.Utils; + +// We get from conversion (result of ToNative) +// Information the Connector needs to track objects +public class SpeckleRhinoObject : SpeckleHostObject +{ + public override RhinoObject NativeObject { get; } + public new string ApplicationId { get; } + public new string SpeckleId { get; } + public new bool IsExpired { get; } + + public SpeckleRhinoObject(RhinoObject rhinoObject, string applicationId, string speckleId, bool isExpired = false) + { + NativeObject = rhinoObject; + ApplicationId = applicationId; + SpeckleId = speckleId; + IsExpired = isExpired; + } + + public override SpeckleHostObject WithExpiredStatus(bool status = true) + { + return new SpeckleRhinoObject(this.NativeObject, this.ApplicationId, this.SpeckleId, status); + } +} diff --git a/ConnectorRhino/ConnectorRhinoWebUI/Utils/Utils.cs b/ConnectorRhino/ConnectorRhinoWebUI/Utils/Utils.cs new file mode 100644 index 0000000000..4b6b5d5db9 --- /dev/null +++ b/ConnectorRhino/ConnectorRhinoWebUI/Utils/Utils.cs @@ -0,0 +1,17 @@ +using Speckle.Core.Kits; + +namespace ConnectorRhinoWebUI.Utils; + +public static class Utils +{ +#if RHINO6 + public static string RhinoAppName = HostApplications.Rhino.GetVersion(HostAppVersion.v6); + public static string AppName = "Rhino"; +#elif RHINO7 + public static string RhinoAppName = HostApplications.Rhino.GetVersion(HostAppVersion.v7); + public static string AppName = "Rhino"; +#else + public static readonly string RhinoAppName = HostApplications.Rhino.GetVersion(HostAppVersion.v7); + public static readonly string AppName = "Rhino"; +#endif +} diff --git a/ConnectorRhino/ConnectorRhinoWebUI/WebUIPanelCef.xaml b/ConnectorRhino/ConnectorRhinoWebUI/WebUIPanelCef.xaml new file mode 100644 index 0000000000..7bdd7c1814 --- /dev/null +++ b/ConnectorRhino/ConnectorRhinoWebUI/WebUIPanelCef.xaml @@ -0,0 +1,16 @@ + + + + + diff --git a/ConnectorRhino/ConnectorRhinoWebUI/WebUIPanelCef.xaml.cs b/ConnectorRhino/ConnectorRhinoWebUI/WebUIPanelCef.xaml.cs new file mode 100644 index 0000000000..1c24a0c658 --- /dev/null +++ b/ConnectorRhino/ConnectorRhinoWebUI/WebUIPanelCef.xaml.cs @@ -0,0 +1,35 @@ +using System.Collections.Generic; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Threading; +using CefSharp; +using DUI3; + +namespace ConnectorRhinoWebUI; + +public partial class WebUiPanelCef : UserControl +{ + public WebUiPanelCef() + { + CefSharpSettings.ConcurrentTaskExecution = true; + InitializeComponent(); + Browser.IsBrowserInitializedChanged += OnInitialized; + } + + private void ShowDevToolsMethod() => Browser.ShowDevTools(); + + private void ExecuteScriptAsyncMethod(string script) => + Browser.Dispatcher.Invoke(() => Browser.EvaluateScriptAsync(script), DispatcherPriority.Background); + + private void OnInitialized(object sender, DependencyPropertyChangedEventArgs e) + { + Browser.JavascriptObjectRepository.NameConverter = null; + + List bindings = Bindings.Factory.CreateBindings(); + foreach (IBinding binding in bindings) + { + BrowserBridge bridge = new(Browser, binding, ExecuteScriptAsyncMethod, ShowDevToolsMethod); + Browser.JavascriptObjectRepository.Register(bridge.FrontendBoundName, bridge, true); + } + } +} diff --git a/ConnectorRhino/ConnectorRhinoWebUI/WebUIPanelWebView2.xaml b/ConnectorRhino/ConnectorRhinoWebUI/WebUIPanelWebView2.xaml new file mode 100644 index 0000000000..3b9dddd74c --- /dev/null +++ b/ConnectorRhino/ConnectorRhinoWebUI/WebUIPanelWebView2.xaml @@ -0,0 +1,19 @@ + + + + + + + + diff --git a/ConnectorRhino/ConnectorRhinoWebUI/WebUIPanelWebView2.xaml.cs b/ConnectorRhino/ConnectorRhinoWebUI/WebUIPanelWebView2.xaml.cs new file mode 100644 index 0000000000..3776ef8d8f --- /dev/null +++ b/ConnectorRhino/ConnectorRhinoWebUI/WebUIPanelWebView2.xaml.cs @@ -0,0 +1,40 @@ +using System.Collections.Generic; +using System.Windows.Controls; +using System.Windows.Threading; +using DUI3; +using Microsoft.Web.WebView2.Core; +using Speckle.Core.Logging; + +namespace ConnectorRhinoWebUI; + +public partial class WebUiPanelWebView2 : UserControl +{ + public WebUiPanelWebView2() + { + InitializeComponent(); + Browser.CoreWebView2InitializationCompleted += OnInitialized; + } + + private void ShowDevToolsMethod() => Browser.CoreWebView2.OpenDevToolsWindow(); + + private void ExecuteScriptAsyncMethod(string script) + { + if (!Browser.IsInitialized) + { + throw new SpeckleException("Failed to execute script, Webview2 is not initialized yet."); + } + + Browser.Dispatcher.Invoke(() => Browser.ExecuteScriptAsync(script), DispatcherPriority.Background); + } + + private void OnInitialized(object sender, CoreWebView2InitializationCompletedEventArgs e) + { + List bindings = Bindings.Factory.CreateBindings(); + + foreach (IBinding binding in bindings) + { + BrowserBridge bridge = new(Browser, binding, ExecuteScriptAsyncMethod, ShowDevToolsMethod); + Browser.CoreWebView2.AddHostObjectToScript(binding.Name, bridge); + } + } +} diff --git a/Core/Core/Api/GraphQL/Models.cs b/Core/Core/Api/GraphQL/Models.cs index e1edf79595..a38d758d38 100644 --- a/Core/Core/Api/GraphQL/Models.cs +++ b/Core/Core/Api/GraphQL/Models.cs @@ -1,6 +1,7 @@ #nullable disable using System; using System.Collections.Generic; +using System.Runtime.InteropServices; using System.Text.Json.Serialization; namespace Speckle.Core.Api; @@ -375,6 +376,8 @@ public class ServerInfoResponse } // TODO: prob remove and bring one level up and shared w Core.Credentials +[ClassInterface(ClassInterfaceType.AutoDual)] +[ComVisible(true)] public class ServerInfo { public string name { get; set; } diff --git a/Core/Core/Credentials/Account.cs b/Core/Core/Credentials/Account.cs index 0daba40f44..160602dfeb 100644 --- a/Core/Core/Credentials/Account.cs +++ b/Core/Core/Credentials/Account.cs @@ -1,5 +1,6 @@ #nullable disable using System; +using System.Runtime.InteropServices; using System.Threading.Tasks; using Speckle.Core.Api; using Speckle.Core.Helpers; @@ -7,6 +8,8 @@ namespace Speckle.Core.Credentials; +[ClassInterface(ClassInterfaceType.AutoDual)] +[ComVisible(true)] public class Account : IEquatable { private string _id { get; set; } diff --git a/Core/Core/Credentials/Responses.cs b/Core/Core/Credentials/Responses.cs index 810d3cae6a..04eb87cfc5 100644 --- a/Core/Core/Credentials/Responses.cs +++ b/Core/Core/Credentials/Responses.cs @@ -1,5 +1,6 @@ #nullable disable using System; +using System.Runtime.InteropServices; using Speckle.Core.Api; namespace Speckle.Core.Credentials; @@ -28,6 +29,8 @@ public class ActiveUserResponse public UserInfo activeUser { get; set; } } +[ClassInterface(ClassInterfaceType.AutoDual)] +[ComVisible(true)] public class UserInfo { public string id { get; set; } @@ -46,11 +49,15 @@ public class TokenExchangeResponse public string refreshToken { get; set; } } +[ClassInterface(ClassInterfaceType.AutoDual)] +[ComVisible(true)] public class Streams { public int totalCount { get; set; } } +[ClassInterface(ClassInterfaceType.AutoDual)] +[ComVisible(true)] public class Commits { public int totalCount { get; set; } diff --git a/DUI3-CNX-8893.slnf b/DUI3-CNX-8893.slnf new file mode 100644 index 0000000000..46cc6c5f92 --- /dev/null +++ b/DUI3-CNX-8893.slnf @@ -0,0 +1,90 @@ +{ + "solution": { + "path": "All.sln", + "projects": [ + "CNX-8892\\Connectors\\Revit\\Speckle.Connectors.Revit2023\\Speckle.Connectors.Revit2023.csproj", + "CNX-8892\\Connectors\\Revit\\Speckle.Connectors.RevitShared\\Speckle.Connectors.RevitShared.shproj", + "CNX-8892\\Converters\\Revit\\Speckle.Converters.Revit2023.DependencyInjection\\Speckle.Converters.Revit2023.DependencyInjection.csproj", + "CNX-8892\\Converters\\Revit\\Speckle.Converters.Revit2023\\Speckle.Converters.Revit2023.csproj", + "CNX-8892\\Converters\\Revit\\Speckle.Converters.RevitShared\\Speckle.Converters.RevitShared.shproj", + "CNX-8892\\Converters\\Speckle.Converters.Common\\Speckle.Converters.Common.csproj", + "CNX-8892\\DUI3\\Speckle.Connectors.DUI\\Speckle.Connectors.DUI.csproj", + "CNX-8892\\Objects\\Speckle.Objects.Common\\Speckle.Objects.Common.csproj", + "CNX-8892\\Objects\\Speckle.Objects.Revit\\Speckle.Objects.Revit.csproj", + "CNX-8892\\Speckle.Autofac\\Speckle.Autofac.csproj", + "CNX-8892\\Speckle.Connectors.Utils\\Speckle.Connectors.Utils.csproj", + "ConnectorRevit\\ConnectorRevit2023\\ConnectorRevit2023.csproj", + "ConnectorRevit\\ConnectorRevit\\ConnectorRevitShared.shproj", + "ConnectorRevit\\RevitDUI3\\Revit2023DUI3\\Revit2023DUI3.csproj", + "ConnectorRevit\\RevitDUI3\\RevitDUI3Shared\\RevitDUI3Shared.shproj", + "Core\\Core\\Core.csproj", + "Core\\Tests\\Speckle.Core.Tests.Integration\\Speckle.Core.Tests.Integration.csproj", + "Core\\Tests\\Speckle.Core.Tests.Performance\\Speckle.Core.Tests.Performance.csproj", + "Core\\Tests\\Speckle.Core.Tests.Unit\\Speckle.Core.Tests.Unit.csproj", + "Core\\Transports\\DiskTransport\\DiskTransport.csproj", + "Core\\Transports\\MongoDBTransport\\MongoDBTransport.csproj", + "DesktopUI3\\DUI3\\DUI3.csproj", + "Objects\\Converters\\ConverterAutocadCivil\\ConverterAdvanceSteel2023\\ConverterAdvanceSteel2023.csproj", + "Objects\\Converters\\ConverterAutocadCivil\\ConverterAdvanceSteel2024\\ConverterAdvanceSteel2024.csproj", + "Objects\\Converters\\ConverterAutocadCivil\\ConverterAutocad2021\\ConverterAutocad2021.csproj", + "Objects\\Converters\\ConverterAutocadCivil\\ConverterAutocad2022\\ConverterAutocad2022.csproj", + "Objects\\Converters\\ConverterAutocadCivil\\ConverterAutocad2023\\ConverterAutocad2023.csproj", + "Objects\\Converters\\ConverterAutocadCivil\\ConverterAutocad2024\\ConverterAutocad2024.csproj", + "Objects\\Converters\\ConverterAutocadCivil\\ConverterAutocadCivilShared\\ConverterAutocadCivilShared.shproj", + "Objects\\Converters\\ConverterAutocadCivil\\ConverterCivil2021\\ConverterCivil2021.csproj", + "Objects\\Converters\\ConverterAutocadCivil\\ConverterCivil2022\\ConverterCivil2022.csproj", + "Objects\\Converters\\ConverterAutocadCivil\\ConverterCivil2023\\ConverterCivil2023.csproj", + "Objects\\Converters\\ConverterAutocadCivil\\ConverterCivil2024\\ConverterCivil2024.csproj", + "Objects\\Converters\\ConverterBentley\\ConverterBentleyShared\\ConverterBentleyShared.shproj", + "Objects\\Converters\\ConverterBentley\\ConverterMicroStation\\ConverterMicroStation.csproj", + "Objects\\Converters\\ConverterBentley\\ConverterOpenBuildings\\ConverterOpenBuildings.csproj", + "Objects\\Converters\\ConverterBentley\\ConverterOpenRail\\ConverterOpenRail.csproj", + "Objects\\Converters\\ConverterBentley\\ConverterOpenRoads\\ConverterOpenRoads.csproj", + "Objects\\Converters\\ConverterCSI\\ConverterCSIBridge\\ConverterCSIBridge.csproj", + "Objects\\Converters\\ConverterCSI\\ConverterCSIShared\\ConverterCSIShared.shproj", + "Objects\\Converters\\ConverterCSI\\ConverterETABS\\ConverterETABS.csproj", + "Objects\\Converters\\ConverterCSI\\ConverterSAFE\\ConverterSAFE.csproj", + "Objects\\Converters\\ConverterCSI\\ConverterSAP2000\\ConverterSAP2000.csproj", + "Objects\\Converters\\ConverterDxf\\ConverterDxf\\ConverterDxf.csproj", + "Objects\\Converters\\ConverterDynamo\\ConverterDynamoRevit2021\\ConverterDynamoRevit2021.csproj", + "Objects\\Converters\\ConverterDynamo\\ConverterDynamoRevit2022\\ConverterDynamoRevit2022.csproj", + "Objects\\Converters\\ConverterDynamo\\ConverterDynamoRevit2023\\ConverterDynamoRevit2023.csproj", + "Objects\\Converters\\ConverterDynamo\\ConverterDynamoRevit2024\\ConverterDynamoRevit2024.csproj", + "Objects\\Converters\\ConverterDynamo\\ConverterDynamoRevit\\ConverterDynamoRevit.csproj", + "Objects\\Converters\\ConverterDynamo\\ConverterDynamoSandbox\\ConverterDynamoSandbox.csproj", + "Objects\\Converters\\ConverterDynamo\\ConverterDynamoShared\\ConverterDynamoShared.shproj", + "Objects\\Converters\\ConverterNavisworks\\ConverterNavisworks2020\\ConverterNavisworks2020.csproj", + "Objects\\Converters\\ConverterNavisworks\\ConverterNavisworks2021\\ConverterNavisworks2021.csproj", + "Objects\\Converters\\ConverterNavisworks\\ConverterNavisworks2022\\ConverterNavisworks2022.csproj", + "Objects\\Converters\\ConverterNavisworks\\ConverterNavisworks2023\\ConverterNavisworks2023.csproj", + "Objects\\Converters\\ConverterNavisworks\\ConverterNavisworks2024\\ConverterNavisworks2024.csproj", + "Objects\\Converters\\ConverterNavisworks\\ConverterNavisworks\\ConverterNavisworks.shproj", + "Objects\\Converters\\ConverterRevit\\ConverterRevit2020\\ConverterRevit2020.csproj", + "Objects\\Converters\\ConverterRevit\\ConverterRevit2021\\ConverterRevit2021.csproj", + "Objects\\Converters\\ConverterRevit\\ConverterRevit2022\\ConverterRevit2022.csproj", + "Objects\\Converters\\ConverterRevit\\ConverterRevit2023\\ConverterRevit2023.csproj", + "Objects\\Converters\\ConverterRevit\\ConverterRevit2024\\ConverterRevit2024.csproj", + "Objects\\Converters\\ConverterRevit\\ConverterRevitShared\\ConverterRevitShared.shproj", + "Objects\\Converters\\ConverterRevit\\ConverterRevitTests\\ConverterRevitTests2021\\ConverterRevitTests2021.csproj", + "Objects\\Converters\\ConverterRevit\\ConverterRevitTests\\ConverterRevitTests2022\\ConverterRevitTests2022.csproj", + "Objects\\Converters\\ConverterRevit\\ConverterRevitTests\\ConverterRevitTests2023\\ConverterRevitTests2023.csproj", + "Objects\\Converters\\ConverterRevit\\ConverterRevitTests\\ConverterRevitTestsShared\\ConverterRevitTestsShared.shproj", + "Objects\\Converters\\ConverterRevit\\ConverterRevitTests\\TestGenerator\\TestGenerator.csproj", + "Objects\\Converters\\ConverterRhinoGh\\ConverterGrasshopper6\\ConverterGrasshopper6.csproj", + "Objects\\Converters\\ConverterRhinoGh\\ConverterGrasshopper7\\ConverterGrasshopper7.csproj", + "Objects\\Converters\\ConverterRhinoGh\\ConverterGrasshopper8\\ConverterGrasshopper8.csproj", + "Objects\\Converters\\ConverterRhinoGh\\ConverterRhino6\\ConverterRhino6.csproj", + "Objects\\Converters\\ConverterRhinoGh\\ConverterRhino7\\ConverterRhino7.csproj", + "Objects\\Converters\\ConverterRhinoGh\\ConverterRhino8\\ConverterRhino8.csproj", + "Objects\\Converters\\ConverterRhinoGh\\ConverterRhinoGhShared\\ConverterRhinoGhShared.shproj", + "Objects\\Converters\\ConverterTeklaStructures\\ConverterTeklaStructures2020\\ConverterTeklaStructures2020.csproj", + "Objects\\Converters\\ConverterTeklaStructures\\ConverterTeklaStructures2021\\ConverterTeklaStructures2021.csproj", + "Objects\\Converters\\ConverterTeklaStructures\\ConverterTeklaStructures2022\\ConverterTeklaStructures2022.csproj", + "Objects\\Converters\\ConverterTeklaStructures\\ConverterTeklaStructures2023\\ConverterTeklaStructures2023.csproj", + "Objects\\Converters\\ConverterTeklaStructures\\ConverterTeklaStructuresShared\\ConverterTeklaStructuresShared.shproj", + "Objects\\Converters\\StructuralUtilities\\PolygonMesher\\PolygonMesher.csproj", + "Objects\\Objects\\Objects.csproj", + "Objects\\Tests\\Objects.Tests.Unit\\Objects.Tests.Unit.csproj" + ] + } +} \ No newline at end of file diff --git a/DUI3.slnf b/DUI3.slnf new file mode 100644 index 0000000000..bd4cd6a75b --- /dev/null +++ b/DUI3.slnf @@ -0,0 +1,156 @@ +{ + "solution": { + "path": "All.sln", + "projects": [ + "Automate\\Speckle.Automate.Sdk\\Speckle.Automate.Sdk.csproj", + "Automate\\Tests\\Speckle.Automate.Sdk.Tests.Integration\\Speckle.Automate.Sdk.Tests.Integration.csproj", + "CNX-8892\\Connectors\\Revit\\Speckle.Connectors.Revit2023\\Speckle.Connectors.Revit2023.csproj", + "CNX-8892\\Connectors\\Revit\\Speckle.Connectors.RevitShared\\Speckle.Connectors.RevitShared.shproj", + "CNX-8892\\Connectors\\Speckle.Connectors.Autofac\\Speckle.Connectors.Autofac.csproj", + "CNX-8892\\Connectors\\Speckle.Connectors.Utils\\Speckle.Connectors.Utils.csproj", + "CNX-8892\\Speckle.Autofac\\Speckle.Autofac.csproj", + "ConnectorArcGIS\\ConnectorArcGIS.csproj", + "ConnectorArchicad\\ConnectorArchicad\\ConnectorArchicad.csproj", + "ConnectorAutocadCivil\\AdvanceSteelAddinRegistrator\\AdvanceSteelAddinRegistrator.csproj", + "ConnectorAutocadCivil\\AutocadCivilDUI3\\Autocad2022\\ConnectorAutocad2022DUI3.csproj", + "ConnectorAutocadCivil\\AutocadCivilDUI3\\Autocad2023\\ConnectorAutocad2023DUI3.csproj", + "ConnectorAutocadCivil\\AutocadCivilDUI3\\AutocadCivilDUI3Shared\\AutocadCivilDUI3Shared.shproj", + "ConnectorAutocadCivil\\ConnectorAdvanceSteel2023\\ConnectorAdvanceSteel2023.csproj", + "ConnectorAutocadCivil\\ConnectorAdvanceSteel2024\\ConnectorAdvanceSteel2024.csproj", + "ConnectorAutocadCivil\\ConnectorAutocad2021\\ConnectorAutocad2021.csproj", + "ConnectorAutocadCivil\\ConnectorAutocad2022\\ConnectorAutocad2022.csproj", + "ConnectorAutocadCivil\\ConnectorAutocad2023\\ConnectorAutocad2023.csproj", + "ConnectorAutocadCivil\\ConnectorAutocad2024\\ConnectorAutocad2024.csproj", + "ConnectorAutocadCivil\\ConnectorAutocadCivil\\ConnectorAutocadCivilShared.shproj", + "ConnectorAutocadCivil\\ConnectorCivil2021\\ConnectorCivil2021.csproj", + "ConnectorAutocadCivil\\ConnectorCivil2022\\ConnectorCivil2022.csproj", + "ConnectorAutocadCivil\\ConnectorCivil2023\\ConnectorCivil2023.csproj", + "ConnectorAutocadCivil\\ConnectorCivil2024\\ConnectorCivil2024.csproj", + "ConnectorBentley\\ConnectorBentleyShared\\ConnectorBentleyShared.shproj", + "ConnectorBentley\\ConnectorMicroStation\\ConnectorMicroStation.csproj", + "ConnectorBentley\\ConnectorOpenBuildings\\ConnectorOpenBuildings.csproj", + "ConnectorBentley\\ConnectorOpenRail\\ConnectorOpenRail.csproj", + "ConnectorBentley\\ConnectorOpenRoads\\ConnectorOpenRoads.csproj", + "ConnectorCSI\\ConnectorCSIBridge\\ConnectorCSIBridge.csproj", + "ConnectorCSI\\ConnectorCSIShared\\ConnectorCSIShared.shproj", + "ConnectorCSI\\ConnectorETABS\\ConnectorETABS.csproj", + "ConnectorCSI\\ConnectorSAFE\\ConnectorSAFE.csproj", + "ConnectorCSI\\ConnectorSAP2000\\ConnectorSAP2000.csproj", + "ConnectorCSI\\DriverCSharp\\DriverCSharp.csproj", + "ConnectorCSI\\DriverPluginCSharp\\DriverPluginCSharp.csproj", + "ConnectorCore\\BatchUploader.OperationDriver\\BatchUploader.OperationDriver.csproj", + "ConnectorCore\\BatchUploader.Sdk\\BatchUploader.Sdk.csproj", + "ConnectorDynamo\\ConnectorDynamoExtension\\ConnectorDynamoExtension.csproj", + "ConnectorDynamo\\ConnectorDynamoFunctions\\ConnectorDynamoFunctions.csproj", + "ConnectorDynamo\\ConnectorDynamo\\ConnectorDynamo.csproj", + "ConnectorGrasshopper\\ConnectorGrasshopper6\\ConnectorGrasshopper6.csproj", + "ConnectorGrasshopper\\ConnectorGrasshopper7\\ConnectorGrasshopper7.csproj", + "ConnectorGrasshopper\\ConnectorGrasshopper8\\ConnectorGrasshopper8.csproj", + "ConnectorGrasshopper\\ConnectorGrasshopperShared\\ConnectorGrasshopperShared.shproj", + "ConnectorGrasshopper\\ConnectorGrasshopperUtils\\ConnectorGrasshopperUtils.csproj", + "ConnectorNavisworks\\ConnectorNavisworks2020\\ConnectorNavisworks2020.csproj", + "ConnectorNavisworks\\ConnectorNavisworks2021\\ConnectorNavisworks2021.csproj", + "ConnectorNavisworks\\ConnectorNavisworks2022\\ConnectorNavisworks2022.csproj", + "ConnectorNavisworks\\ConnectorNavisworks2023\\ConnectorNavisworks2023.csproj", + "ConnectorNavisworks\\ConnectorNavisworks2024\\ConnectorNavisworks2024.csproj", + "ConnectorNavisworks\\ConnectorNavisworks\\ConnectorNavisworks.shproj", + "ConnectorRevit\\ConnectorRevit2020\\ConnectorRevit2020.csproj", + "ConnectorRevit\\ConnectorRevit2021\\ConnectorRevit2021.csproj", + "ConnectorRevit\\ConnectorRevit2022\\ConnectorRevit2022.csproj", + "ConnectorRevit\\ConnectorRevit2023\\ConnectorRevit2023.csproj", + "ConnectorRevit\\ConnectorRevit2024\\ConnectorRevit2024.csproj", + "ConnectorRevit\\ConnectorRevit\\ConnectorRevitShared.shproj", + "ConnectorRevit\\RevitDUI3\\Revit2020DUI3\\Revit2020DUI3.csproj", + "ConnectorRevit\\RevitDUI3\\Revit2023DUI3\\Revit2023DUI3.csproj", + "ConnectorRevit\\RevitDUI3\\RevitDUI3Shared\\RevitDUI3Shared.shproj", + "ConnectorRevit\\RevitSharedResources2020\\RevitSharedResources2020.csproj", + "ConnectorRevit\\RevitSharedResources2021\\RevitSharedResources2021.csproj", + "ConnectorRevit\\RevitSharedResources2022\\RevitSharedResources2022.csproj", + "ConnectorRevit\\RevitSharedResources2023\\RevitSharedResources2023.csproj", + "ConnectorRevit\\RevitSharedResources2024\\RevitSharedResources2024.csproj", + "ConnectorRevit\\RevitSharedResources\\RevitSharedResources.shproj", + "ConnectorRhino\\ConnectorRhino6\\ConnectorRhino6.csproj", + "ConnectorRhino\\ConnectorRhino7\\ConnectorRhino7.csproj", + "ConnectorRhino\\ConnectorRhino8\\ConnectorRhino8.csproj", + "ConnectorRhino\\ConnectorRhinoWebUI\\ConnectorRhinoWebUI.csproj", + "ConnectorRhino\\ConnectorRhino\\ConnectorRhinoShared\\ConnectorRhinoShared.shproj", + "ConnectorTeklaStructures\\ConnectorTeklaStructures2020\\ConnectorTeklaStructures2020.csproj", + "ConnectorTeklaStructures\\ConnectorTeklaStructures2021\\ConnectorTeklaStructures2021.csproj", + "ConnectorTeklaStructures\\ConnectorTeklaStructures2022\\ConnectorTeklaStructures2022.csproj", + "ConnectorTeklaStructures\\ConnectorTeklaStructures2023\\ConnectorTeklaStructures2023.csproj", + "ConnectorTeklaStructures\\ConnectorTeklaStructuresShared\\ConnectorTeklaStructuresShared.shproj", + "Core\\Core\\Core.csproj", + "Core\\Tests\\Speckle.Core.Tests.Integration\\Speckle.Core.Tests.Integration.csproj", + "Core\\Tests\\Speckle.Core.Tests.Performance\\Speckle.Core.Tests.Performance.csproj", + "Core\\Tests\\Speckle.Core.Tests.Unit\\Speckle.Core.Tests.Unit.csproj", + "Core\\Transports\\DiskTransport\\DiskTransport.csproj", + "Core\\Transports\\MongoDBTransport\\MongoDBTransport.csproj", + "DesktopUI2\\AvaloniaHwndHost\\AvaloniaHwndHost.csproj", + "DesktopUI2\\DesktopUI2.Launcher\\DesktopUI2.Launcher.csproj", + "DesktopUI2\\DesktopUI2.WPF\\DesktopUI2.WPF.csproj", + "DesktopUI2\\DesktopUI2\\DesktopUI2.csproj", + "DesktopUI3\\DUI3\\DUI3.csproj", + "Objects\\Converters\\ConverterAutocadCivil\\ConverterAdvanceSteel2023\\ConverterAdvanceSteel2023.csproj", + "Objects\\Converters\\ConverterAutocadCivil\\ConverterAdvanceSteel2024\\ConverterAdvanceSteel2024.csproj", + "Objects\\Converters\\ConverterAutocadCivil\\ConverterAutocad2021\\ConverterAutocad2021.csproj", + "Objects\\Converters\\ConverterAutocadCivil\\ConverterAutocad2022\\ConverterAutocad2022.csproj", + "Objects\\Converters\\ConverterAutocadCivil\\ConverterAutocad2023\\ConverterAutocad2023.csproj", + "Objects\\Converters\\ConverterAutocadCivil\\ConverterAutocad2024\\ConverterAutocad2024.csproj", + "Objects\\Converters\\ConverterAutocadCivil\\ConverterAutocadCivilShared\\ConverterAutocadCivilShared.shproj", + "Objects\\Converters\\ConverterAutocadCivil\\ConverterCivil2021\\ConverterCivil2021.csproj", + "Objects\\Converters\\ConverterAutocadCivil\\ConverterCivil2022\\ConverterCivil2022.csproj", + "Objects\\Converters\\ConverterAutocadCivil\\ConverterCivil2023\\ConverterCivil2023.csproj", + "Objects\\Converters\\ConverterAutocadCivil\\ConverterCivil2024\\ConverterCivil2024.csproj", + "Objects\\Converters\\ConverterBentley\\ConverterBentleyShared\\ConverterBentleyShared.shproj", + "Objects\\Converters\\ConverterBentley\\ConverterMicroStation\\ConverterMicroStation.csproj", + "Objects\\Converters\\ConverterBentley\\ConverterOpenBuildings\\ConverterOpenBuildings.csproj", + "Objects\\Converters\\ConverterBentley\\ConverterOpenRail\\ConverterOpenRail.csproj", + "Objects\\Converters\\ConverterBentley\\ConverterOpenRoads\\ConverterOpenRoads.csproj", + "Objects\\Converters\\ConverterCSI\\ConverterCSIBridge\\ConverterCSIBridge.csproj", + "Objects\\Converters\\ConverterCSI\\ConverterCSIShared\\ConverterCSIShared.shproj", + "Objects\\Converters\\ConverterCSI\\ConverterETABS\\ConverterETABS.csproj", + "Objects\\Converters\\ConverterCSI\\ConverterSAFE\\ConverterSAFE.csproj", + "Objects\\Converters\\ConverterCSI\\ConverterSAP2000\\ConverterSAP2000.csproj", + "Objects\\Converters\\ConverterDxf\\ConverterDxf\\ConverterDxf.csproj", + "Objects\\Converters\\ConverterDynamo\\ConverterDynamoRevit2021\\ConverterDynamoRevit2021.csproj", + "Objects\\Converters\\ConverterDynamo\\ConverterDynamoRevit2022\\ConverterDynamoRevit2022.csproj", + "Objects\\Converters\\ConverterDynamo\\ConverterDynamoRevit2023\\ConverterDynamoRevit2023.csproj", + "Objects\\Converters\\ConverterDynamo\\ConverterDynamoRevit2024\\ConverterDynamoRevit2024.csproj", + "Objects\\Converters\\ConverterDynamo\\ConverterDynamoRevit\\ConverterDynamoRevit.csproj", + "Objects\\Converters\\ConverterDynamo\\ConverterDynamoSandbox\\ConverterDynamoSandbox.csproj", + "Objects\\Converters\\ConverterDynamo\\ConverterDynamoShared\\ConverterDynamoShared.shproj", + "Objects\\Converters\\ConverterNavisworks\\ConverterNavisworks2020\\ConverterNavisworks2020.csproj", + "Objects\\Converters\\ConverterNavisworks\\ConverterNavisworks2021\\ConverterNavisworks2021.csproj", + "Objects\\Converters\\ConverterNavisworks\\ConverterNavisworks2022\\ConverterNavisworks2022.csproj", + "Objects\\Converters\\ConverterNavisworks\\ConverterNavisworks2023\\ConverterNavisworks2023.csproj", + "Objects\\Converters\\ConverterNavisworks\\ConverterNavisworks2024\\ConverterNavisworks2024.csproj", + "Objects\\Converters\\ConverterNavisworks\\ConverterNavisworks\\ConverterNavisworks.shproj", + "Objects\\Converters\\ConverterRevit\\ConverterRevit2020\\ConverterRevit2020.csproj", + "Objects\\Converters\\ConverterRevit\\ConverterRevit2021\\ConverterRevit2021.csproj", + "Objects\\Converters\\ConverterRevit\\ConverterRevit2022\\ConverterRevit2022.csproj", + "Objects\\Converters\\ConverterRevit\\ConverterRevit2023\\ConverterRevit2023.csproj", + "Objects\\Converters\\ConverterRevit\\ConverterRevit2024\\ConverterRevit2024.csproj", + "Objects\\Converters\\ConverterRevit\\ConverterRevitShared\\ConverterRevitShared.shproj", + "Objects\\Converters\\ConverterRevit\\ConverterRevitTests\\ConverterRevitTests2021\\ConverterRevitTests2021.csproj", + "Objects\\Converters\\ConverterRevit\\ConverterRevitTests\\ConverterRevitTests2022\\ConverterRevitTests2022.csproj", + "Objects\\Converters\\ConverterRevit\\ConverterRevitTests\\ConverterRevitTests2023\\ConverterRevitTests2023.csproj", + "Objects\\Converters\\ConverterRevit\\ConverterRevitTests\\ConverterRevitTestsShared\\ConverterRevitTestsShared.shproj", + "Objects\\Converters\\ConverterRevit\\ConverterRevitTests\\TestGenerator\\TestGenerator.csproj", + "Objects\\Converters\\ConverterRhinoGh\\ConverterGrasshopper6\\ConverterGrasshopper6.csproj", + "Objects\\Converters\\ConverterRhinoGh\\ConverterGrasshopper7\\ConverterGrasshopper7.csproj", + "Objects\\Converters\\ConverterRhinoGh\\ConverterGrasshopper8\\ConverterGrasshopper8.csproj", + "Objects\\Converters\\ConverterRhinoGh\\ConverterRhino6\\ConverterRhino6.csproj", + "Objects\\Converters\\ConverterRhinoGh\\ConverterRhino7\\ConverterRhino7.csproj", + "Objects\\Converters\\ConverterRhinoGh\\ConverterRhino8\\ConverterRhino8.csproj", + "Objects\\Converters\\ConverterRhinoGh\\ConverterRhinoGhShared\\ConverterRhinoGhShared.shproj", + "Objects\\Converters\\ConverterTeklaStructures\\ConverterTeklaStructures2020\\ConverterTeklaStructures2020.csproj", + "Objects\\Converters\\ConverterTeklaStructures\\ConverterTeklaStructures2021\\ConverterTeklaStructures2021.csproj", + "Objects\\Converters\\ConverterTeklaStructures\\ConverterTeklaStructures2022\\ConverterTeklaStructures2022.csproj", + "Objects\\Converters\\ConverterTeklaStructures\\ConverterTeklaStructures2023\\ConverterTeklaStructures2023.csproj", + "Objects\\Converters\\ConverterTeklaStructures\\ConverterTeklaStructuresShared\\ConverterTeklaStructuresShared.shproj", + "Objects\\Converters\\StructuralUtilities\\PolygonMesher\\PolygonMesher.csproj", + "Objects\\Objects\\Objects.csproj", + "Objects\\Tests\\Objects.Tests.Unit\\Objects.Tests.Unit.csproj" + ] + } +} \ No newline at end of file diff --git a/DesktopUI3/DUI3/Bindings/AccountBinding.cs b/DesktopUI3/DUI3/Bindings/AccountBinding.cs new file mode 100644 index 0000000000..d5004f4246 --- /dev/null +++ b/DesktopUI3/DUI3/Bindings/AccountBinding.cs @@ -0,0 +1,24 @@ +using System.Linq; +using JetBrains.Annotations; +using Speckle.Core.Credentials; + +namespace DUI3.Bindings; + +public class AccountBinding : IBinding +{ + public string Name { get; set; } = "accountsBinding"; + public IBridge Parent { get; set; } + + [PublicAPI] + public Account[] GetAccounts() + { + return AccountManager.GetAccounts().ToArray(); + // NOTE: removing the avatars is no longer needed as we've resolved the issue described below via the bridge implementation. + // .Select( + // a => + // { + // a.userInfo.avatar = null; // removing this as the get accounts call was a too large string to do "executeScriptAsync" with (this was not happening if this was a direct return from a binding call). + // return a; + // }).ToArray(); + } +} diff --git a/DesktopUI3/DUI3/Bindings/ConfigBinding.cs b/DesktopUI3/DUI3/Bindings/ConfigBinding.cs new file mode 100644 index 0000000000..d2489f5bb1 --- /dev/null +++ b/DesktopUI3/DUI3/Bindings/ConfigBinding.cs @@ -0,0 +1,131 @@ +using System.Collections.Generic; +using System.Diagnostics; +using DUI3.Config; +using DUI3.Onboarding; +using DUI3.Utils; +using JetBrains.Annotations; +using Speckle.Core.Logging; +using Speckle.Core.Transports; +using Speckle.Newtonsoft.Json; + +namespace DUI3.Bindings; + +/// +/// Responsible to initialize, validate and retrieve configuration data from AppData/Config.db +/// +public class ConfigBinding : IBinding +{ + public string Name { get; set; } = "configBinding"; + public IBridge Parent { get; set; } + private string HostAppName { get; } + private Dictionary ConnectorOnboardings { get; } + + private static readonly SQLiteTransport s_configStorage = new(scope: "Config"); + private readonly JsonSerializerSettings _serializerOptions = SerializationSettingsFactory.GetSerializerSettings(); + + public ConfigBinding(string hostAppName, Dictionary connectorOnboardings = null) + { + this.HostAppName = hostAppName; + + // If connectorOnboardings is null, initialize it as an empty dictionary + connectorOnboardings ??= new Dictionary(); + this.ConnectorOnboardings = connectorOnboardings; + } + + [PublicAPI] + public UiConfig GetConfig() + { + try + { + return GetOrInitConfig(); + } + catch (SpeckleException e) + { + Debug.WriteLine(e.Message); + // Fallbacks to default configs if something wrong + UiConfig uiConfig = InitDefaultConfig(); + s_configStorage.UpdateObject("configDUI3", JsonConvert.SerializeObject(uiConfig, _serializerOptions)); + return uiConfig; + } + } + + public void UpdateGlobalConfig(GlobalConfig newGlobalConfig) + { + try + { + UiConfig uiConfig = GetOrInitConfig(); + uiConfig.Global = newGlobalConfig; + s_configStorage.UpdateObject("configDUI3", JsonConvert.SerializeObject(uiConfig, _serializerOptions)); + } + catch (SpeckleException e) + { + Debug.WriteLine(e.Message); + // TODO: Log error + } + } + + public void UpdateConnectorConfig(ConnectorConfig newConnectorConfig) + { + try + { + UiConfig uiConfig = GetOrInitConfig(); + uiConfig.Connectors[HostAppName] = newConnectorConfig; + s_configStorage.UpdateObject("configDUI3", JsonConvert.SerializeObject(uiConfig, _serializerOptions)); + } + catch (SpeckleException e) + { + Debug.WriteLine(e.Message); + // TODO: Log error + } + } + + private void ValidateConfigs(UiConfig uiConfig, PropertyValidator config) + { + bool globalConfigsAdded = config.InitializeNewProperties(); + bool globalConfigRemoved = config.CheckRemovedProperties(); + if (globalConfigsAdded || globalConfigRemoved) + { + s_configStorage.UpdateObject("configDUI3", JsonConvert.SerializeObject(uiConfig, _serializerOptions)); + } + } + + private UiConfig GetOrInitConfig() + { + // 1 - If it is not exist, init and return. + string configDui3String = s_configStorage.GetObject("configDUI3"); + if (string.IsNullOrEmpty(configDui3String)) + { + return InitDefaultConfig(); + } + + UiConfig config = JsonConvert.DeserializeObject(configDui3String, _serializerOptions); + + // 2- Check global configs updated or not. + ValidateConfigs(config, config.Global); + + // 3- If connector config already exist in UiConfig, just return it. + if (config.Connectors.TryGetValue(HostAppName.ToLower(), out ConnectorConfig value)) + { + ConnectorConfig existingConnectorConfig = value; + ValidateConfigs(config, existingConnectorConfig); + + return config; + } + + // 4- If connector config didn't initialized yet, init and attach it, then return. + ConnectorConfig connectorConfig = new(HostAppName, ConnectorOnboardings); + config.Connectors.Add(HostAppName, connectorConfig); + s_configStorage.UpdateObject("configDUI3", JsonConvert.SerializeObject(config, _serializerOptions)); + return config; + } + + private UiConfig InitDefaultConfig() + { + ConnectorConfig connectorConfig = new(HostAppName, ConnectorOnboardings); + Dictionary defaultConfigs = new() { { HostAppName, connectorConfig } }; + UiConfig defaultConfig = new() { Global = new GlobalConfig(), Connectors = defaultConfigs }; + string serializedConfigs = JsonConvert.SerializeObject(defaultConfig, _serializerOptions); + s_configStorage.UpdateObject("configDUI3", serializedConfigs); + return defaultConfig; + } +} diff --git a/DesktopUI3/DUI3/Bindings/IBasicConnectorBinding.cs b/DesktopUI3/DUI3/Bindings/IBasicConnectorBinding.cs new file mode 100644 index 0000000000..3067cd6052 --- /dev/null +++ b/DesktopUI3/DUI3/Bindings/IBasicConnectorBinding.cs @@ -0,0 +1,38 @@ +using System; +using DUI3.Models; +using DUI3.Models.Card; + +namespace DUI3.Bindings; + +public interface IBasicConnectorBinding : IBinding +{ + public string GetSourceApplicationName(); + public string GetSourceApplicationVersion(); + public string GetConnectorVersion(); + public DocumentInfo GetDocumentInfo(); + public DocumentModelStore GetDocumentState(); + public void AddModel(ModelCard model); + public void UpdateModel(ModelCard model); + public void RemoveModel(ModelCard model); + + /// + /// Highlights the objects attached to this sender in the host application. + /// + /// + public void HighlightModel(string modelCardId); +} + +public static class BasicConnectorBindingCommands +{ + private const string NOTIFY_DOCUMENT_CHANGED_EVENT_NAME = "documentChanged"; + private const string SET_MODEL_PROGRESS_UI_COMMAND_NAME = "setModelProgress"; + private const string SET_MODEL_ERROR_UI_COMMAND_NAME = "setModelError"; + + public static void NotifyDocumentChanged(IBridge bridge) => bridge.SendToBrowser(NOTIFY_DOCUMENT_CHANGED_EVENT_NAME); + + public static void SetModelProgress(IBridge bridge, string modelCardId, ModelCardProgress progress) => + bridge.SendToBrowser(SET_MODEL_PROGRESS_UI_COMMAND_NAME, new { modelCardId, progress }); + + public static void SetModelError(IBridge bridge, string modelCardId, Exception error) => + bridge.SendToBrowser(SET_MODEL_ERROR_UI_COMMAND_NAME, new { modelCardId, error = error.Message }); +} diff --git a/DesktopUI3/DUI3/Bindings/IReceiveBinding.cs b/DesktopUI3/DUI3/Bindings/IReceiveBinding.cs new file mode 100644 index 0000000000..2ad10e3c89 --- /dev/null +++ b/DesktopUI3/DUI3/Bindings/IReceiveBinding.cs @@ -0,0 +1,49 @@ +using System.Collections.Generic; +using DUI3.Models; +using DUI3.Models.Card; +using DUI3.Utils; + +namespace DUI3.Bindings; + +public interface IReceiveBinding : IBinding +{ + /// + /// Instructs the host app to start receiving this model version. + /// + /// Model card id + public void Receive(string modelCardId); + + /// + /// Instructs the host app to cancel the receiving for a given model. + /// + /// + public void CancelReceive(string modelCardId); +} + +public static class ReceiveBindingUiCommands +{ + private const string SET_MODEL_RECEIVE_RESULT_UI_COMMAND_NAME = "setModelReceiveResult"; + + public static void SetModelConversionResult(IBridge bridge, string modelCardId, ReceiveResult receiveResult) => + bridge.SendToBrowser(SET_MODEL_RECEIVE_RESULT_UI_COMMAND_NAME, new { modelCardId, receiveResult }); + +} + +public class ReceiverModelCard : ModelCard +{ + public string SelectedVersionId { get; set; } + public string LatestVersionId { get; set; } + public string ProjectName { get; set; } + public string ModelName { get; set; } + public bool HasDismissedUpdateWarning { get; set; } + public ReceiveResult ReceiveResult { get; set; } +} + +public class ReceiveResult : DiscriminatedObject +{ + public List BakedObjectIds { get; set; } + + public bool Display { get; set; } = false; + + // TODO/THINK Later: results, reports, etc. ? +} diff --git a/DesktopUI3/DUI3/Bindings/ISelectionBinding.cs b/DesktopUI3/DUI3/Bindings/ISelectionBinding.cs new file mode 100644 index 0000000000..9dcd594ebd --- /dev/null +++ b/DesktopUI3/DUI3/Bindings/ISelectionBinding.cs @@ -0,0 +1,19 @@ +using System.Collections.Generic; + +namespace DUI3.Bindings; + +public interface ISelectionBinding : IBinding +{ + public SelectionInfo GetSelection(); +} + +public static class SelectionBindingEvents +{ + public static readonly string SetSelection = "setSelection"; +} + +public class SelectionInfo +{ + public List SelectedObjectIds { get; set; } + public string Summary { get; set; } +} diff --git a/DesktopUI3/DUI3/Bindings/ISendBinding.cs b/DesktopUI3/DUI3/Bindings/ISendBinding.cs new file mode 100644 index 0000000000..0753e37fe3 --- /dev/null +++ b/DesktopUI3/DUI3/Bindings/ISendBinding.cs @@ -0,0 +1,89 @@ +using System; +using System.Collections.Generic; +using DUI3.Models; +using DUI3.Models.Card; +using DUI3.Utils; + +namespace DUI3.Bindings; + +public interface ISendBinding : IBinding +{ + public List GetSendFilters(); + + /// + /// Instructs the host app to start sending this model. + /// + /// + public void Send(string modelCardId); + + /// + /// Instructs the host app to cancel the sending for a given model. + /// + /// + public void CancelSend(string modelCardId); +} + +public static class SendBindingUiCommands +{ + private const string REFRESH_SEND_FILTERS_UI_COMMAND_NAME = "refreshSendFilters"; + private const string SET_MODELS_EXPIRED_UI_COMMAND_NAME = "setModelsExpired"; + private const string SET_MODEL_CREATED_VERSION_ID_UI_COMMAND_NAME = "setModelCreatedVersionId"; + + public static void RefreshSendFilters(IBridge bridge) => + bridge.SendToBrowser(REFRESH_SEND_FILTERS_UI_COMMAND_NAME); + + public static void SetModelsExpired(IBridge bridge, IEnumerable expiredModelIds) => + bridge.SendToBrowser(SET_MODELS_EXPIRED_UI_COMMAND_NAME, expiredModelIds); + + public static void SetModelCreatedVersionId(IBridge bridge,string modelCardId, string versionId ) => + bridge.SendToBrowser(SET_MODEL_CREATED_VERSION_ID_UI_COMMAND_NAME, new { modelCardId, versionId }); +} + +public class SenderModelCard : ModelCard +{ + public ISendFilter SendFilter { get; set; } +} + +public interface ISendFilter +{ + public string Name { get; set; } + public string Summary { get; set; } + public bool IsDefault { get; set; } + /// + /// Gets the ids of the objects targeted by the filter from the host application. + /// + /// + public List GetObjectIds(); + + /// + /// Checks whether any of the targeted objects are affected by changes from the host application. + /// + /// + /// + public bool CheckExpiry(string[] changedObjectIds); +} + +public abstract class EverythingSendFilter : DiscriminatedObject, ISendFilter +{ + public string Name { get; set; } = "Everything"; + public string Summary { get; set; } = "All supported objects in the file."; + public bool IsDefault { get; set; } + public abstract List GetObjectIds(); + public abstract bool CheckExpiry(string[] changedObjectIds); +} + +public abstract class DirectSelectionSendFilter : DiscriminatedObject, ISendFilter +{ + public string Name { get; set; } = "Selection"; + public string Summary { get; set; } + public bool IsDefault { get; set; } + public List SelectedObjectIds { get; set; } = new List(); + public abstract List GetObjectIds(); + public abstract bool CheckExpiry(string[] changedObjectIds); +} + +public class CreateVersionArgs +{ + public string ModelCardId { get; set; } + public string ObjectId { get; set; } +} diff --git a/DesktopUI3/DUI3/Bindings/TestBinding.cs b/DesktopUI3/DUI3/Bindings/TestBinding.cs new file mode 100644 index 0000000000..1f90ef0245 --- /dev/null +++ b/DesktopUI3/DUI3/Bindings/TestBinding.cs @@ -0,0 +1,64 @@ +using System; +using System.Diagnostics; +using Speckle.Core.Logging; + +namespace DUI3.Bindings; + +/// +/// Meant as a testing ground for various scenarios. Note this binding is directly scaffolded from here - no need for +/// implementations in host applications. +/// +public class TestBinding : IBinding +{ + public string Name { get; set; } = "testBinding"; + public IBridge Parent { get; set; } + + public string SayHi(string name, int count, bool sayHelloNotHi) + { + var baseGreeting = $"{(sayHelloNotHi ? "Hello" : "Hi")} {name}!"; + var finalGreeting = ""; + for (int i = 0; i < Math.Max(1, Math.Abs(count)); i++) + { + finalGreeting += baseGreeting + Environment.NewLine; + } + + return finalGreeting; + } + + public void ShouldThrow() + { + throw new SpeckleException("I am supposed to throw."); + } + + public void GoAway() + { + Debug.WriteLine("Okay, going away."); + } + + public object GetComplexType() + { + return new { Id = GetHashCode().ToString(), count = GetHashCode() }; + } + + public void TriggerEvent(string eventName) + { + switch (eventName) + { + case "emptyTestEvent": + Parent.SendToBrowser("emptyTestEvent"); + break; + case "testEvent": + default: + Parent.SendToBrowser( + "testEvent", + new + { + IsOk = true, + Name = "foo", + Count = 42 + } + ); + break; + } + } +} diff --git a/DesktopUI3/DUI3/Bridge.cs b/DesktopUI3/DUI3/Bridge.cs new file mode 100644 index 0000000000..fe522cf4c1 --- /dev/null +++ b/DesktopUI3/DUI3/Bridge.cs @@ -0,0 +1,187 @@ +// using System; +// using System.Collections.Generic; +// using System.Linq; +// using System.Reflection; +// using System.Runtime.InteropServices; +// using Speckle.Newtonsoft.Json; +// using System.Threading.Tasks; +// using Speckle.Core.Logging; +// +// namespace DUI3 +// { +// +// /// +// /// Wraps a binding class, and manages its calls from the Frontend to .NET, and sending events from .NET to the the Frontend. +// /// See also: https://github.com/johot/WebView2-better-bridge +// /// +// [ClassInterface(ClassInterfaceType.AutoDual)] +// [ComVisible(true)] +// public class BrowserBridge : IBridge +// { +// /// +// /// The name under which we expect the frontend to hoist this bindings class to the global scope. +// /// e.g., `receiveBindings` should be available as `window.receiveBindings`. +// /// +// public string FrontendBoundName { get; } +// +// public object Browser { get; } +// +// public IBinding Binding { get; } +// +// public Action ExecuteScriptAsync { get; set; } +// public Action ShowDevToolsAction { get; set; } +// private Type BindingType { get; set; } +// private Dictionary BindingMethodCache { get; set; } +// +// private JsonSerializerSettings _serializerOptions = DUI3.Utils.SerializationSettingsFactory.GetSerializerSettings(); +// +// /// +// /// Creates a new bridge. +// /// +// /// The host browser instance. +// /// The actual binding class. +// /// A simple action that does the browser's version of executeScriptAsync(string). +// public BrowserBridge(object browser, IBinding binding, Action executeScriptAsync, Action showDevToolsAction) +// { +// FrontendBoundName = binding.Name; +// Browser = browser; +// Binding = binding; +// +// BindingType = Binding.GetType(); +// BindingMethodCache = new Dictionary(); +// // Note: we need to filter out getter and setter methods here because they are not really nicely +// // supported across browsers, hence the !method.IsSpecialName. +// foreach(var m in BindingType.GetMethods().Where(method => !method.IsSpecialName)) +// { +// BindingMethodCache[m.Name] = m; +// } +// +// Binding.Parent = this; +// +// ExecuteScriptAsync = executeScriptAsync; +// ShowDevToolsAction = showDevToolsAction; +// } +// +// /// +// /// Used by the Frontend bridge logic to understand which methods are available. +// /// +// /// +// public string[] GetBindingsMethodNames() +// { +// return BindingMethodCache.Keys.ToArray(); +// } +// +// /// +// /// Used by the Frontend bridge to call into .NET. +// /// TODO: Check and test +// /// +// /// +// /// +// /// +// public string RunMethod(string methodName, string args) +// { +// // Note: You might be tempted to make this method async Task to prevent the task.Wait() below. +// // Do not do that! Cef65 doesn't like waiting for async .NET methods. +// // Note: we have this pokemon catch 'em all here because throwing errors in .NET is +// // very risky, and we might crash the host application. Behaviour seems also to differ +// // between various browser controls (e.g.: cefsharp handles things nicely - basically +// // passing back the exception to the browser, but webview throws an access violation +// // error that kills Rhino.). +// try +// { +// if (!BindingMethodCache.ContainsKey(methodName)) +// throw new SpeckleException($"Cannot find method {methodName} in bindings class {BindingType.AssemblyQualifiedName}."); +// +// var method = BindingMethodCache[methodName]; +// var parameters = method.GetParameters(); +// var jsonArgsArray = JsonConvert.DeserializeObject(args); +// +// if (parameters.Length != jsonArgsArray.Length) +// throw new SpeckleException($"Wrong number of arguments when invoking binding function {methodName}, expected {parameters.Length}, but got {jsonArgsArray.Length}."); +// +// var typedArgs = new object[jsonArgsArray.Length]; +// +// for (int i = 0; i < typedArgs.Length; i++) +// { +// var ccc = JsonConvert.DeserializeObject(jsonArgsArray[i], parameters[i].ParameterType, _serializerOptions); +// typedArgs[i] = ccc; +// } +// +// +// +// var resultTyped = method.Invoke(Binding, typedArgs); +// +// // Was it an async method (in bridgeClass?) +// var resultTypedTask = resultTyped as Task; +// +// string resultJson; +// +// // Was the method called async? +// if (resultTypedTask == null) +// { +// // Regular method: no need to await things +// resultJson = JsonConvert.SerializeObject(resultTyped, _serializerOptions); +// } +// else // It's an async call +// { +// // See note at start of function. Do not asyncify! +// resultTypedTask.Wait(); +// +// // If has a "Result" property return the value otherwise null (Task etc) +// var resultProperty = resultTypedTask.GetType().GetProperty("Result"); +// var taskResult = resultProperty != null ? resultProperty.GetValue(resultTypedTask) : null; +// resultJson =JsonConvert.SerializeObject(taskResult, _serializerOptions); +// } +// +// return resultJson; +// } +// catch (Exception e) +// { +// // TODO: properly log the exeception. +// return JsonConvert.SerializeObject(new { Error = e.Message, InnerError = e.InnerException?.Message }, _serializerOptions); +// } +// } +// +// /// +// /// Notifies the Frontend about something by doing the browser specific way for `browser.ExecuteScriptAsync("window.FrontendBoundName.on(eventName, etc.)")`. +// /// +// /// +// public void SendToBrowser(string eventName, object data = null) +// { +// string script; +// if (data != null) +// { +// var payload = JsonConvert.SerializeObject(data, _serializerOptions); +// script = $"{FrontendBoundName}.emit('{eventName}', '{payload}')"; +// } +// else +// { +// script = $"{FrontendBoundName}.emit('{eventName}')"; +// } +// ExecuteScriptAsync(script); +// } +// +// /// +// /// Shows the dev tools. This is currently only needed for CefSharp - other browser +// /// controls allow for right click + inspect. +// /// +// public void ShowDevTools() +// { +// ShowDevToolsAction(); +// } +// +// public void OpenUrl(string url) +// { +// try +// { +// System.Diagnostics.Process.Start(url); +// } +// catch (Exception _) +// { +// // TODO: Log. If it ever happens. +// } +// +// } +// } +// +// } diff --git a/DesktopUI3/DUI3/BridgeV2.cs b/DesktopUI3/DUI3/BridgeV2.cs new file mode 100644 index 0000000000..03dfb29d32 --- /dev/null +++ b/DesktopUI3/DUI3/BridgeV2.cs @@ -0,0 +1,282 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using System.Runtime.InteropServices; +using System.Threading; +using Speckle.Newtonsoft.Json; +using System.Threading.Tasks; +using System.Threading.Tasks.Dataflow; +using Speckle.Core.Logging; + +namespace DUI3; + +/// +/// Wraps a binding class, and manages its calls from the Frontend to .NET, and sending events from .NET to the the Frontend. +/// Initially inspired by: https://github.com/johot/WebView2-better-bridge +/// +[ClassInterface(ClassInterfaceType.AutoDual)] +[ComVisible(true)] +public class BrowserBridge : IBridge +{ + /// + /// The name under which we expect the frontend to hoist this bindings class to the global scope. + /// e.g., `receiveBindings` should be available as `window.receiveBindings`. + /// + public string FrontendBoundName { get; } + public object Browser { get; } + public IBinding Binding { get; } + public Action ExecuteScriptAsync { get; set; } + public Action ShowDevToolsAction { get; set; } + private Type BindingType { get; set; } + private Dictionary BindingMethodCache { get; set; } + private readonly JsonSerializerSettings _serializerOptions = + DUI3.Utils.SerializationSettingsFactory.GetSerializerSettings(); + private readonly ActionBlock _actionBlock; + private readonly SynchronizationContext _mainThreadContext; + + private struct RunMethodArgs + { + public string MethodName; + public string RequestId; + public string MethodArgs; + } + + /// + /// Creates a new bridge. + /// + /// The host browser instance. + /// The actual binding class. + /// A simple action that does the browser's version of executeScriptAsync(string). + public BrowserBridge(object browser, IBinding binding, Action executeScriptAsync, Action showDevToolsAction) + { + FrontendBoundName = binding.Name; + Browser = browser; + Binding = binding; + + BindingType = Binding.GetType(); + BindingMethodCache = new Dictionary(); + // Note: we need to filter out getter and setter methods here because they are not really nicely + // supported across browsers, hence the !method.IsSpecialName. + foreach (var m in BindingType.GetMethods().Where(method => !method.IsSpecialName)) + { + BindingMethodCache[m.Name] = m; + } + + Binding.Parent = this; + + ExecuteScriptAsync = executeScriptAsync; + ShowDevToolsAction = showDevToolsAction; + + // Capture the main thread's SynchronizationContext + _mainThreadContext = SynchronizationContext.Current; + + // Whenever the ui will call run method inside .net, it will post a message to this action block. + // This conveniently executes the code outside the UI thread and does not block during long operations (such as sending). + _actionBlock = new ActionBlock( + args => ExecuteMethod(args.MethodName, args.RequestId, args.MethodArgs), + new ExecutionDataflowBlockOptions + { + MaxDegreeOfParallelism = 1000, + CancellationToken = new CancellationTokenSource(TimeSpan.FromHours(3)).Token // Not sure we need such a long time. + } + ); + } + + /// + /// Used by the Frontend bridge logic to understand which methods are available. + /// + /// + public string[] GetBindingsMethodNames() + { + return BindingMethodCache.Keys.ToArray(); + } + + /// + /// This method posts the requested call to our action block executor. + /// + /// + /// + /// + public void RunMethod(string methodName, string requestId, string args) + { + _actionBlock.Post( + new RunMethodArgs + { + MethodName = methodName, + RequestId = requestId, + MethodArgs = args + } + ); + } + + /// + /// Run actions on main thread. + /// + /// Action to run on main thread. + public void RunOnMainThread(Action action) + { + _mainThreadContext.Post( + _ => + { + // Execute the action on the main thread + action.Invoke(); + }, + null + ); + } + + /// + /// Used by the action block to invoke the actual method called by the UI. + /// + /// + /// + /// + /// + private void ExecuteMethod(string methodName, string requestId, string args) + { + // Note: You might be tempted to make this method async Task to prevent the task.Wait() below. + // Do not do that! Cef65 doesn't like waiting for async .NET methods. + // Note: we have this pokemon catch 'em all here because throwing errors in .NET is + // very risky, and we might crash the host application. Behaviour seems also to differ + // between various browser controls (e.g.: cefsharp handles things nicely - basically + // passing back the exception to the browser, but webview throws an access violation + // error that kills Rhino.). + try + { + if (!BindingMethodCache.ContainsKey(methodName)) + { + throw new SpeckleException( + $"Cannot find method {methodName} in bindings class {BindingType.AssemblyQualifiedName}." + ); + } + + var method = BindingMethodCache[methodName]; + var parameters = method.GetParameters(); + var jsonArgsArray = JsonConvert.DeserializeObject(args); + + if (parameters.Length != jsonArgsArray.Length) + { + throw new SpeckleException( + $"Wrong number of arguments when invoking binding function {methodName}, expected {parameters.Length}, but got {jsonArgsArray.Length}." + ); + } + + var typedArgs = new object[jsonArgsArray.Length]; + + for (int i = 0; i < typedArgs.Length; i++) + { + var ccc = JsonConvert.DeserializeObject(jsonArgsArray[i], parameters[i].ParameterType, _serializerOptions); + typedArgs[i] = ccc; + } + + var resultTyped = method.Invoke(Binding, typedArgs); + + // Was it an async method (in bridgeClass?) + var resultTypedTask = resultTyped as Task; + + string resultJson; + + // Was the method called async? + if (resultTypedTask == null) + { + // Regular method: no need to await things + resultJson = JsonConvert.SerializeObject(resultTyped, _serializerOptions); + } + else // It's an async call + { + // See note at start of function. Do not asyncify! + resultTypedTask.Wait(); + + // If has a "Result" property return the value otherwise null (Task etc) + PropertyInfo resultProperty = resultTypedTask.GetType().GetProperty("Result"); + object taskResult = resultProperty?.GetValue(resultTypedTask); + resultJson = JsonConvert.SerializeObject(taskResult, _serializerOptions); + } + + NotifyUIMethodCallResultReady(requestId, resultJson); + } + catch (Exception e) // DO NOT EVER CAPTURE SPECIFIC EXCEPTIONS HERE (unknown ones will slip) - WE DO NOT WANT TO BUBBLE SHIT UP IN CRAZY CONTEXTS; They should be gracefully sent to the UI; THIS COMES FROM "NEVER CRASH THE HOST APP IF POSSIBLE" RULE + { + // TODO: properly log the exeception. + var serializedError = JsonConvert.SerializeObject( + new { Error = e.Message, InnerError = e.InnerException?.Message }, + _serializerOptions + ); + + NotifyUIMethodCallResultReady(requestId, serializedError); + } + } + + /// + /// NOTE: This method suffers from a limitation: returning strings to the ui via a script invocation is not the same + /// as returning strings from a method. The more reliable approach was the latter. Keeping it here for the sake of + /// "do not do things this way" demo. + /// + /// + /// + private void ReturnResultToBinding_old(string requestId, string serializedData = null) + { + string script = $"{FrontendBoundName}.receiveResponse('{requestId}', '{serializedData}')"; // sending the string this way makes for some strange deserialization issues. + ExecuteScriptAsync(script); + } + + private readonly Dictionary _resultsStore = new(); + + /// + /// Notifies the UI that the method call is ready. We do not give the result back to the ui here via ExecuteScriptAsync + /// because of limitations we discovered along the way (e.g, / chars need to be escaped). + /// + /// + /// + private void NotifyUIMethodCallResultReady(string requestId, string serializedData = null) + { + _resultsStore[requestId] = serializedData; + string script = $"{FrontendBoundName}.responseReady('{requestId}')"; + ExecuteScriptAsync(script); + } + + /// + /// Called by the ui to get back the serialized result of the method. See comments above for why. + /// + /// + /// + public string GetCallResult(string requestId) + { + var res = _resultsStore[requestId]; + _resultsStore.Remove(requestId); + return res; + } + + /// + /// Notifies the Frontend about something by doing the browser specific way for `browser.ExecuteScriptAsync("window.FrontendBoundName.on(eventName, etc.)")`. + /// + public void SendToBrowser(string eventName, object data = null) + { + string script; + if (data != null) + { + var payload = JsonConvert.SerializeObject(data, _serializerOptions); + script = $"{FrontendBoundName}.emit('{eventName}', '{payload}')"; + } + else + { + script = $"{FrontendBoundName}.emit('{eventName}')"; + } + ExecuteScriptAsync(script); + } + + /// + /// Shows the dev tools. This is currently only needed for CefSharp - other browser + /// controls allow for right click + inspect. + /// + public void ShowDevTools() + { + ShowDevToolsAction(); + } + + public void OpenUrl(string url) + { + System.Diagnostics.Process.Start(url); + } +} diff --git a/DesktopUI3/DUI3/Config/ConnectorConfig.cs b/DesktopUI3/DUI3/Config/ConnectorConfig.cs new file mode 100644 index 0000000000..d7f247d842 --- /dev/null +++ b/DesktopUI3/DUI3/Config/ConnectorConfig.cs @@ -0,0 +1,22 @@ +using System.Collections.Generic; +using DUI3.Onboarding; +using DUI3.Utils; + +namespace DUI3.Config; + +public class ConnectorConfig : PropertyValidator +{ + public string HostApp { set; get; } + + public bool? DarkTheme { set; get; } = false; + + public Dictionary Onboardings { get; set; } + + public ConnectorConfig() { } + + public ConnectorConfig(string hostApp, Dictionary onboardings) + { + HostApp = hostApp; + this.Onboardings = onboardings; + } +} diff --git a/DesktopUI3/DUI3/Config/GlobalConfig.cs b/DesktopUI3/DUI3/Config/GlobalConfig.cs new file mode 100644 index 0000000000..7088b9a6b5 --- /dev/null +++ b/DesktopUI3/DUI3/Config/GlobalConfig.cs @@ -0,0 +1,11 @@ +using System.Collections.Generic; +using DUI3.Onboarding; +using DUI3.Utils; + +namespace DUI3.Config; + +public class GlobalConfig : PropertyValidator +{ + public bool? OnboardingSkipped { get; set; } = false; + public Dictionary Onboardings { get; set; } = Factory.CreateDefaults(); +} diff --git a/DesktopUI3/DUI3/Config/UiConfig.cs b/DesktopUI3/DUI3/Config/UiConfig.cs new file mode 100644 index 0000000000..de00b6430e --- /dev/null +++ b/DesktopUI3/DUI3/Config/UiConfig.cs @@ -0,0 +1,11 @@ +using System.Collections.Generic; +using DUI3.Utils; + +namespace DUI3.Config; + +public class UiConfig : DiscriminatedObject +{ + public GlobalConfig Global { get; set; } + + public Dictionary Connectors { get; set; } +} diff --git a/DesktopUI3/DUI3/DUI3.csproj b/DesktopUI3/DUI3/DUI3.csproj new file mode 100644 index 0000000000..46a8ea5330 --- /dev/null +++ b/DesktopUI3/DUI3/DUI3.csproj @@ -0,0 +1,20 @@ + + + + netstandard2.0 + Library + AnyCPU;x64 + + + + + + + + + + + + + + diff --git a/DesktopUI3/DUI3/Interfaces.cs b/DesktopUI3/DUI3/Interfaces.cs new file mode 100644 index 0000000000..7937bc5b37 --- /dev/null +++ b/DesktopUI3/DUI3/Interfaces.cs @@ -0,0 +1,58 @@ +using System; + +namespace DUI3; + +/// +/// Describes the most basic binding. +/// +public interface IBinding +{ + /// + /// This will be the name under which it will be available in the Frontend, e.g. + /// window.superBinding, or window.mapperBinding. Please use camelCase even if + /// it hurts. + /// + public string Name { get; set; } + + /// + /// Bindings will be wrapped by a browser specific bridge, and they will need + /// to use that bridge to send events to the Frontend, via SendToBrowser(IHostAppEvent) or SendToBrowser(string). + /// TODO: we'll probably need a factory class of sorts to handle the proper wrapping. Currently, on bridge instantiation the parent is set in the bindings class that has been wrapped around. Not vvv elegant. + /// + public IBridge Parent { get; set; } +} + +/// +/// Describes a bridge - a wrapper class around a specific browser host. Not needed right now, +/// but if in the future we will have other bridge classes (e.g, ones that wrap around other browsers), +/// it just might be useful. +/// +public interface IBridge +{ + /// + /// This method is called by the Frontend bridge to understand what it can actually call. It should return the method names of the bindings that this bridge wraps around. + /// + /// + public string[] GetBindingsMethodNames(); + + /// + /// This method is called by the Frontend bridge when invoking any of the wrapped binding's methods. + /// + /// + /// + /// + public void RunMethod(string methodName, string requestId, string args); + + /// + /// Run actions on main thread. + /// Some applications might need to run some operations on main thread as deferred actions. + /// + /// Action to run on main thread. + public void RunOnMainThread(Action action); + + /// + /// Sends to the Frontend an event with an optional payload. + /// + /// + public void SendToBrowser(string eventName, object data = null); +} diff --git a/DesktopUI3/DUI3/Models/Card/ModelCardError.cs b/DesktopUI3/DUI3/Models/Card/ModelCardError.cs new file mode 100644 index 0000000000..2850531d02 --- /dev/null +++ b/DesktopUI3/DUI3/Models/Card/ModelCardError.cs @@ -0,0 +1,9 @@ +using System; + +namespace DUI3.Models.Card; + +public class ModelCardError +{ + public string ModelCardId { get; set; } + public Exception Error { get; set; } +} diff --git a/DesktopUI3/DUI3/Models/Card/ModelCardNotification.cs b/DesktopUI3/DUI3/Models/Card/ModelCardNotification.cs new file mode 100644 index 0000000000..392f852793 --- /dev/null +++ b/DesktopUI3/DUI3/Models/Card/ModelCardNotification.cs @@ -0,0 +1,10 @@ +namespace DUI3.Models.Card; + +public class ModelCardNotification +{ + public string ModelCardId { get; set; } + public string Text { get; set; } + public string Level { get; set; } + public int Timeout { get; set; } + public bool Dismissible { get; set; } = true; +} diff --git a/DesktopUI3/DUI3/Models/Card/ModelCardProgress.cs b/DesktopUI3/DUI3/Models/Card/ModelCardProgress.cs new file mode 100644 index 0000000000..e35afd124e --- /dev/null +++ b/DesktopUI3/DUI3/Models/Card/ModelCardProgress.cs @@ -0,0 +1,17 @@ +using System; + +namespace DUI3.Models.Card; + +public class ModelCardProgress +{ + public string ModelCardId { get; set; } + public string Status { get; set; } + + /// + /// Progress value between 0 and 1 to calculate UI progress bar width. + /// If it is null it will swooshing on UI. + /// + public double? Progress { get; set; } +} + + diff --git a/DesktopUI3/DUI3/Models/ConversionReport.cs b/DesktopUI3/DUI3/Models/ConversionReport.cs new file mode 100644 index 0000000000..a96fc4ee64 --- /dev/null +++ b/DesktopUI3/DUI3/Models/ConversionReport.cs @@ -0,0 +1,47 @@ +using System.Collections.Generic; + +namespace DUI3.Models; + +public class ConversionReport +{ + /// + /// An overall summary. + /// + public string Summary { get; set; } + + /// + /// Specific reports for sets of objects (e.g., failed conversions, conversion fallbacks, etc. + /// + public List Items { get; set; } + + public (ReportItem success, ReportItem warning, ReportItem danger) InitializeSuccessWarningDangerReport() + { + var success = new ReportItem() { Level = NotificationLevel.Success, Message = "Successful conversions"}; + var warning = new ReportItem() { Level = NotificationLevel.Warning, Message = "Partially successful conversions"}; + var danger = new ReportItem() { Level = NotificationLevel.Danger, Message = "Failed conversions"}; + + Items.Add(success); + Items.Add(warning); + Items.Add(danger); + return (success, warning, danger); + } +} + +public class ReportItem +{ + /// + /// A short message. + /// + public string Message { get; set; } + + /// + /// Warning, Info, Success, Danger - etc. Use the NotificationLevel class. + /// + public string Level { get; set; } + + /// + /// The affected objects. + /// + public List ObjectIds { get; set; } = new(); + +} diff --git a/DesktopUI3/DUI3/Models/DocumentInfo.cs b/DesktopUI3/DUI3/Models/DocumentInfo.cs new file mode 100644 index 0000000000..9ed0aa4c43 --- /dev/null +++ b/DesktopUI3/DUI3/Models/DocumentInfo.cs @@ -0,0 +1,16 @@ +using JetBrains.Annotations; + +namespace DUI3.Models; + +[PublicAPI] +public class DocumentInfo +{ + public string Location { get; set; + //?.Replace("\\", "\\\\"); // for some reason, when returning variables from a direct binding call + //we don't need this. nevertheless, after switching to a post response back to the ui, + //we need this to ensure deserialization in js doesn't throw. it's frustrating! + } + + public string Name { get; set; } + public string Id { get; set; } +} diff --git a/DesktopUI3/DUI3/Models/DocumentModelStore.cs b/DesktopUI3/DUI3/Models/DocumentModelStore.cs new file mode 100644 index 0000000000..3013752d3e --- /dev/null +++ b/DesktopUI3/DUI3/Models/DocumentModelStore.cs @@ -0,0 +1,63 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using DUI3.Bindings; +using DUI3.Objects; +using DUI3.Utils; +using JetBrains.Annotations; +using Speckle.Newtonsoft.Json; + +namespace DUI3.Models; + +/// +/// Encapsulates the state Speckle needs to persist in the host app's document. +/// +public abstract class DocumentModelStore : DiscriminatedObject +{ + // POC: public setter? + public List SpeckleHostObjects { get; set; } = new List(); + + // POC: public setter? + public List Models { get; set; } = new List(); + + private static readonly JsonSerializerSettings s_serializerOptions = + DUI3.Utils.SerializationSettingsFactory.GetSerializerSettings(); + + /// + /// This event is triggered by each specific host app implementation of the document model store. + /// + [PublicAPI] + public event EventHandler DocumentChanged; + + public virtual bool IsDocumentInit { get; set; } + + public ModelCard GetModelById(string id) + { + var model = Models.First(model => model.ModelCardId == id) ?? throw new ModelNotFoundException(); + return model; + } + + protected void OnDocumentChanged() => DocumentChanged?.Invoke(this, EventArgs.Empty); + + public List GetSenders() => + Models.Where(model => model.TypeDiscriminator == nameof(SenderModelCard)).Cast().ToList(); + + public List GetReceivers() => + Models.Where(model => model.TypeDiscriminator == nameof(ReceiverModelCard)).Cast().ToList(); + + protected string Serialize() + { + var serialized = JsonConvert.SerializeObject(Models, s_serializerOptions); + return serialized; + } + + protected static List Deserialize(string models) + { + var deserializedModels = JsonConvert.DeserializeObject>(models, s_serializerOptions); + return deserializedModels; + } + + public abstract void WriteToFile(); + + public abstract void ReadFromFile(); +} diff --git a/DesktopUI3/DUI3/Models/Form.cs b/DesktopUI3/DUI3/Models/Form.cs new file mode 100644 index 0000000000..8cb3cb92c4 --- /dev/null +++ b/DesktopUI3/DUI3/Models/Form.cs @@ -0,0 +1,47 @@ +using System.Collections.Generic; +using DUI3.Utils; + +namespace DUI3.Models; + +public class FormInputBase : DiscriminatedObject +{ + public string Label { get; set; } + public bool ShowLabel { get; set; } +} + +public class FormTextInput : FormInputBase +{ + public string Value { get; set; } + public string Placeholder { get; set; } +} + +public class BooleanValueInput : FormInputBase +{ + public bool Value { get; set; } +} + +public class ListValueInput : FormInputBase +{ + public List Options { get; set; } = new(); + public List SelectedOptions { get; set; } = new(); + public bool MultiSelect { get; set; } = true; +} + +public class ListValueItem : DiscriminatedObject +{ + public string Id { get; set; } + public string Name { get; set; } + public string Color { get; set; } +} + +public class TreeValueInput : FormInputBase +{ + public List Nodes { get; set; } = new(); + public bool MultiSelect { get; set; } = true; +} + +public class TreeListValueItem : ListValueItem +{ + public bool Selected { get; set; } + public List Nodes { get; set; } = new(); +} diff --git a/DesktopUI3/DUI3/Models/ModelCard.cs b/DesktopUI3/DUI3/Models/ModelCard.cs new file mode 100644 index 0000000000..d1c4b29f74 --- /dev/null +++ b/DesktopUI3/DUI3/Models/ModelCard.cs @@ -0,0 +1,27 @@ +using System.Collections.Generic; +using DUI3.Settings; +using DUI3.Utils; + +namespace DUI3.Models; + +public class ModelCard : DiscriminatedObject +{ + /// + /// This is a unique id generated by the ui to make model cards easier to reference around. + /// It's not the actual model (branch) id. + /// + public string ModelCardId { get; set; } + + /// + /// Model id. FKA branch id. + /// + public string ModelId { get; set; } + + /// + /// Project id. FKA stream id. + /// + public string ProjectId { get; set; } + public string AccountId { get; set; } + + public List Settings { get; set; } +} diff --git a/DesktopUI3/DUI3/Models/NotificationLevel.cs b/DesktopUI3/DUI3/Models/NotificationLevel.cs new file mode 100644 index 0000000000..94ca2125e6 --- /dev/null +++ b/DesktopUI3/DUI3/Models/NotificationLevel.cs @@ -0,0 +1,12 @@ +namespace DUI3.Models; + +/// +/// Use this class to ensure coherent styling of any items (e.g., notifications) in the frontend based on their status. +/// +public static class NotificationLevel +{ + public static readonly string Danger = "danger"; + public static readonly string Warning = "warning"; + public static readonly string Info = "info"; + public static readonly string Success = "success"; +} diff --git a/DesktopUI3/DUI3/Objects/ConversionContext.cs b/DesktopUI3/DUI3/Objects/ConversionContext.cs new file mode 100644 index 0000000000..4b8aab6052 --- /dev/null +++ b/DesktopUI3/DUI3/Objects/ConversionContext.cs @@ -0,0 +1,17 @@ +using Speckle.Core.Models; + +namespace DUI3.Objects; + +// TODO: This should be move to the core? +// What we pass into conversion +// Info that the converter needs to convert an object +public class ConversionContext //Name pending +{ + public Base ToConvert { get; set; } + public string ParentApplicationId { get; set; } //Rhino, we interpret this as layer path, in other connectors we interpret this as parent object id + // TODO: public List LocalToGlobalTransformation { get; set; } // For connectors which don't have blocks + + //public string LayerPath { get; set; } //What rhino needs <-- Not actually rhino specific, speckle collections paths, we can create this always + //public ElementId hostElementId { get; set; } //What Revit needs + //public UnityObject parentObject { get; set; } //Reference to the parent object +} diff --git a/DesktopUI3/DUI3/Objects/ISpeckleHostObject.cs b/DesktopUI3/DUI3/Objects/ISpeckleHostObject.cs new file mode 100644 index 0000000000..2958f09824 --- /dev/null +++ b/DesktopUI3/DUI3/Objects/ISpeckleHostObject.cs @@ -0,0 +1,8 @@ +namespace DUI3.Objects; + +public interface ISpeckleHostObject +{ + public string ApplicationId { get; } + public string SpeckleId { get; } + public bool IsExpired { get; } +} diff --git a/DesktopUI3/DUI3/Objects/ReportObject.cs b/DesktopUI3/DUI3/Objects/ReportObject.cs new file mode 100644 index 0000000000..b599eb0d46 --- /dev/null +++ b/DesktopUI3/DUI3/Objects/ReportObject.cs @@ -0,0 +1,14 @@ +namespace DUI3.Objects; + +public enum ConversionResult +{ + Success, + Failed +} + +// Information the UI needs to report objects +public class ReportObject +{ + public SpeckleHostObject SpeckleHostObject { get; } + public ConversionResult ConversionResult { get; } +} diff --git a/DesktopUI3/DUI3/Objects/SpeckleHostObject.cs b/DesktopUI3/DUI3/Objects/SpeckleHostObject.cs new file mode 100644 index 0000000000..6875a1a282 --- /dev/null +++ b/DesktopUI3/DUI3/Objects/SpeckleHostObject.cs @@ -0,0 +1,18 @@ +namespace DUI3.Objects; + +//Operations.Receive gives us Base object --> Creates speckle base objects into C# base objects +//Traverse function to get Traversal Context maps Base -> TraversalContext (with parental hierarchy) +//Map Traversal contexts to ConversionContexts + ??Reporting object?? +//Perform conversion - might need to create more report objects on the fly as we convert (for Instances) +//Map conversion result to SpeckleHostObject + +// result of a ToNative conversion... +public abstract class SpeckleHostObject : ISpeckleHostObject +{ + public virtual T NativeObject { get; } + public string ApplicationId { get; } + public string SpeckleId { get; } + public bool IsExpired { get; } + + public abstract SpeckleHostObject WithExpiredStatus(bool status = true); +} diff --git a/DesktopUI3/DUI3/Onboarding/Factory.cs b/DesktopUI3/DUI3/Onboarding/Factory.cs new file mode 100644 index 0000000000..865bd1d0f1 --- /dev/null +++ b/DesktopUI3/DUI3/Onboarding/Factory.cs @@ -0,0 +1,33 @@ +using System.Collections.Generic; + +namespace DUI3.Onboarding; + +public static class Factory +{ + public static OnboardingData CreateSend() + { + return new() + { + Title = "Send", + Blurb = "Send first model to Speckleverse!", + Completed = false, + Page = "/onboarding/send", + }; + } + + public static OnboardingData CreateReceive() + { + return new() + { + Title = "Receive", + Blurb = "Receive first model from Speckleverse!", + Completed = false, + Page = "/onboarding/receive", + }; + } + + public static Dictionary CreateDefaults() + { + return new Dictionary() { { "send", CreateSend() }, { "receive", CreateReceive() } }; + } +} diff --git a/DesktopUI3/DUI3/Onboarding/OnboardingData.cs b/DesktopUI3/DUI3/Onboarding/OnboardingData.cs new file mode 100644 index 0000000000..76ad6226fa --- /dev/null +++ b/DesktopUI3/DUI3/Onboarding/OnboardingData.cs @@ -0,0 +1,11 @@ +using DUI3.Utils; + +namespace DUI3.Onboarding; + +public class OnboardingData : DiscriminatedObject +{ + public string Title { get; set; } + public string Blurb { get; set; } + public bool? Completed { get; set; } = false; + public string Page { get; set; } +} diff --git a/DesktopUI3/DUI3/Operations/CancellationManager.cs b/DesktopUI3/DUI3/Operations/CancellationManager.cs new file mode 100644 index 0000000000..0d833ae10f --- /dev/null +++ b/DesktopUI3/DUI3/Operations/CancellationManager.cs @@ -0,0 +1,83 @@ +using System.Collections.Generic; +using System.Threading; + +namespace DUI3.Operations; + +/// +/// Provides a mechanism for cancelling operations. +/// +public interface ICancelable +{ + public CancellationManager CancellationManager { get; } +} + +/// +/// Util class to manage cancellations. +/// +public class CancellationManager +{ + /// + /// Dictionary to relate with registered id. + /// + private readonly Dictionary _operationsInProgress = new(); + + /// + /// Get token with registered id. + /// + /// Id of the operation. + /// CancellationToken that belongs to operation. + public CancellationToken GetToken(string id) + { + return _operationsInProgress[id].Token; + } + + /// + /// Whether given id registered or not. + /// + /// Id to check registration. + /// Whether given id registered or not. + public bool IsExist(string id) + { + return _operationsInProgress.ContainsKey(id); + } + + /// + /// Initialize a token source for cancellable operation. + /// + /// Id to register token. + /// Initialized cancellation token source. + public CancellationTokenSource InitCancellationTokenSource(string id) + { + if (IsExist(id)) + { + CancelOperation(id); + } + + var cts = new CancellationTokenSource(); + _operationsInProgress[id] = cts; + return cts; + } + + /// + /// Cancel operation. + /// + /// Id to cancel operation. + public void CancelOperation(string id) + { + if (_operationsInProgress.TryGetValue(id, out CancellationTokenSource cts)) + { + cts.Cancel(); + _operationsInProgress.Remove(id); + } + } + + /// + /// Whether cancellation requested already or not. + /// + /// Id to check cancellation requested already or not. + /// + public bool IsCancellationRequested(string id) + { + return _operationsInProgress[id].IsCancellationRequested; + } +} diff --git a/DesktopUI3/DUI3/Operations/Operations.cs b/DesktopUI3/DUI3/Operations/Operations.cs new file mode 100644 index 0000000000..2d129b750e --- /dev/null +++ b/DesktopUI3/DUI3/Operations/Operations.cs @@ -0,0 +1,60 @@ +#nullable enable +using System; +using System.Threading; +using System.Threading.Tasks; +using DUI3.Bindings; + +using DUI3.Utils; +using Speckle.Core.Api; +using Speckle.Core.Credentials; +using Speckle.Core.Logging; +using Speckle.Core.Models; +using Speckle.Core.Transports; + +namespace DUI3.Operations; + +public static class Operations +{ + public static async Task GetCommitBase( + IBridge parent, + ReceiverModelCard modelCard, + CancellationToken token + ) + { + Account account = Accounts.GetAccount(modelCard.AccountId); + Client client = new(account); + + Commit version = await client.CommitGet(modelCard.ProjectId, modelCard.SelectedVersionId, token).ConfigureAwait(false); + + Base commitObject = await ReceiveCommit(account, modelCard.ProjectId, version.referencedObject, parent, token) + .ConfigureAwait(true); + + client.Dispose(); + return commitObject; + } + + /// + /// Convenience wrapper around with connector-style error handling + /// + /// the to receive + /// The requested commit data + /// Thrown when any receive operation errors + /// Thrown when requests a cancellation + private static async Task ReceiveCommit( + Account account, + string projectId, + string referencedObjectId, + IBridge parent, + CancellationToken token + ) + { + using ServerTransport transport = new(account, projectId); + + Base? commitObject = + await Speckle.Core.Api.Operations.Receive(referencedObjectId, cancellationToken: token, remoteTransport: transport).ConfigureAwait(false) + ?? throw new SpeckleException( + $"Failed to receive commit: {referencedObjectId} objects from server: {nameof(Speckle.Core.Api.Operations)} returned null" + ); + return commitObject; + } +} diff --git a/DesktopUI3/DUI3/Settings/CardSetting.cs b/DesktopUI3/DUI3/Settings/CardSetting.cs new file mode 100644 index 0000000000..e0d74c8a37 --- /dev/null +++ b/DesktopUI3/DUI3/Settings/CardSetting.cs @@ -0,0 +1,14 @@ +#nullable enable +using System.Collections.Generic; +using DUI3.Utils; + +namespace DUI3.Settings; + +public class CardSetting : DiscriminatedObject +{ + public string Id { get; set; } + public string Title { get; set; } + public string Type { get; set; } + public object Value { get; set; } + public List? Enum { get; set; } +} diff --git a/DesktopUI3/DUI3/Utils/Accounts.cs b/DesktopUI3/DUI3/Utils/Accounts.cs new file mode 100644 index 0000000000..56759a5f97 --- /dev/null +++ b/DesktopUI3/DUI3/Utils/Accounts.cs @@ -0,0 +1,15 @@ +using System.Linq; +using Speckle.Core.Credentials; + +namespace DUI3.Utils; + +public static class Accounts +{ + public static Account GetAccount(string accountId) + { + Account account = + AccountManager.GetAccounts().FirstOrDefault(acc => acc.id == accountId) + ?? throw new SpeckleAccountManagerException(); + return account; + } +} diff --git a/DesktopUI3/DUI3/Utils/Converters.cs b/DesktopUI3/DUI3/Utils/Converters.cs new file mode 100644 index 0000000000..17eed144ed --- /dev/null +++ b/DesktopUI3/DUI3/Utils/Converters.cs @@ -0,0 +1,13 @@ +using Speckle.Core.Kits; + +namespace DUI3.Utils; + +public static class Converters +{ + public static ISpeckleConverter GetConverter(T document, string appNameVersion) + { + ISpeckleConverter converter = KitManager.GetDefaultKit().LoadConverter(appNameVersion); + converter.SetContextDocument(document); + return converter; + } +} diff --git a/DesktopUI3/DUI3/Utils/DiscriminatedObject.cs b/DesktopUI3/DUI3/Utils/DiscriminatedObject.cs new file mode 100644 index 0000000000..e90b31c874 --- /dev/null +++ b/DesktopUI3/DUI3/Utils/DiscriminatedObject.cs @@ -0,0 +1,15 @@ +namespace DUI3.Utils; + +/// +/// Any polymorphic type base should inherit from this class in order for it to be properly deserialized. +/// - Class inheritance scenario For example, if you have a base class BaseSettings, and from it you create RhinoBaseSettings & AutocadBaseSettings, the BaseSetting class should inherit from this class. +/// - Interface scenario: you have an ISenderCard interface, which you implement as ReceiverCard and SenderCard. Both ReceiverCard and SenderCard should inherit from this class. +/// +public class DiscriminatedObject +{ + public string TypeDiscriminator + { + get => this.GetType().Name; + set { } + } +} diff --git a/DesktopUI3/DUI3/Utils/DiscriminatedObjectConverter.cs b/DesktopUI3/DUI3/Utils/DiscriminatedObjectConverter.cs new file mode 100644 index 0000000000..0afbb16778 --- /dev/null +++ b/DesktopUI3/DUI3/Utils/DiscriminatedObjectConverter.cs @@ -0,0 +1,119 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Reflection; +using Speckle.Core.Logging; +using Speckle.Newtonsoft.Json; +using Speckle.Newtonsoft.Json.Linq; +using Speckle.Newtonsoft.Json.Serialization; + +namespace DUI3.Utils; + +/// +/// This converter ensures we can do polymorphic deserialization to concrete types. It is automatically added to all +/// serialization settings from . This converter is intended +/// for use only with UI bound types, not Speckle Bases. +/// +public class DiscriminatedObjectConverter : JsonConverter +{ + private readonly JsonSerializer _localSerializer = + new() + { + DefaultValueHandling = DefaultValueHandling.Ignore, + ContractResolver = new CamelCasePropertyNamesContractResolver(), + NullValueHandling = NullValueHandling.Ignore + }; + + public override void WriteJson(JsonWriter writer, DiscriminatedObject value, JsonSerializer serializer) + { + var jo = JObject.FromObject(value, _localSerializer); + jo.WriteTo(writer); + } + + public override DiscriminatedObject ReadJson( + JsonReader reader, + Type objectType, + DiscriminatedObject existingValue, + bool hasExistingValue, + JsonSerializer serializer + ) + { + JObject jsonObject = JObject.Load(reader); + + var typeName = + jsonObject.Value("typeDiscriminator") + ?? throw new Speckle.Core.Serialisation.SpeckleDeserializeException( + "DUI3 Discriminator converter deserialization failed: did not find a typeDiscriminator field." + ); + var type = + GetTypeByName(typeName) + ?? throw new Speckle.Core.Serialisation.SpeckleDeserializeException( + "DUI3 Discriminator converter deserialization failed, type not found: " + typeName + ); + var obj = Activator.CreateInstance(type); + serializer.Populate(jsonObject.CreateReader(), obj); + + // Store the JSON property names in the object for later comparison + if (obj is PropertyValidator pv) + { + // Capture property names from JSON + var jsonPropertyNames = jsonObject.Properties().Select(p => p.Name).ToList(); + + pv.JsonPropertyNames = jsonPropertyNames; + } + + return obj as DiscriminatedObject; + } + + private static readonly Dictionary s_typeCache = new(); + + private Type GetTypeByName(string name) + { + s_typeCache.TryGetValue(name, out Type myType); + if (myType != null) + { + return myType; + } + + foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies().Reverse()) + { + try + { + // assembly. + var allAssemblyTypes = assembly.DefinedTypes; + var assemblyTypesEnumerable = allAssemblyTypes.ToList(); + if (assemblyTypesEnumerable.Any()) + { + var type = assemblyTypesEnumerable.FirstOrDefault(t => t.FullName != null && t.FullName.Contains(name)); + + if (type != null) + { + s_typeCache[name] = type; + return type; + } + } + } + catch (Exception e) // DO NOT CHANGE THIS TO SPECKLE EXCEPTION + { + Debug.WriteLine(e.Message); + } + } + return null; + } +} + +public class AbstractConverter : JsonConverter +{ + public override bool CanConvert(Type objectType) => objectType == typeof(TAbstract); + + public override object ReadJson( + JsonReader reader, + Type objectType, + object existingValue, + JsonSerializer serializer + ) => serializer.Deserialize(reader); + + public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) => + serializer.Serialize(writer, value); +} diff --git a/DesktopUI3/DUI3/Utils/Exceptions.cs b/DesktopUI3/DUI3/Utils/Exceptions.cs new file mode 100644 index 0000000000..c1f461c1c8 --- /dev/null +++ b/DesktopUI3/DUI3/Utils/Exceptions.cs @@ -0,0 +1,15 @@ +using System; +using Speckle.Core.Logging; + +namespace DUI3.Utils; + +public class ModelNotFoundException : SpeckleException +{ + public ModelNotFoundException(string message) + : base(message) { } + + public ModelNotFoundException(string message, Exception inner) + : base(message, inner) { } + + public ModelNotFoundException() { } +} diff --git a/DesktopUI3/DUI3/Utils/PropertyValidator.cs b/DesktopUI3/DUI3/Utils/PropertyValidator.cs new file mode 100644 index 0000000000..fb095d8fbe --- /dev/null +++ b/DesktopUI3/DUI3/Utils/PropertyValidator.cs @@ -0,0 +1,53 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using Speckle.Newtonsoft.Json; + +namespace DUI3.Utils; + +public class PropertyValidator : DiscriminatedObject +{ + [JsonIgnore] + public List JsonPropertyNames { get; set; } + + public bool InitializeNewProperties() + { + bool isUpdated = false; + var properties = this.GetType().GetProperties(); + + // Create a new instance of the current type to get default values + var defaultInstance = Activator.CreateInstance(this.GetType()); + + foreach (var property in properties) + { + if (property.GetValue(this) == null) + { + // Get the default value from the new instance + var defaultValue = property.GetValue(defaultInstance); + + // Set this default value to the current instance + property.SetValue(this, defaultValue); + isUpdated = true; + } + } + + return isUpdated; // Return true if any property was updated + } + + public bool CheckRemovedProperties() + { + bool removedPropertiesExist = false; + var currentPropertyNames = this.GetType().GetProperties().Select(p => p.Name).ToList(); + + foreach (var jsonPropName in JsonPropertyNames) + { + if (!currentPropertyNames.Contains(jsonPropName)) + { + // This property was in the JSON but not in the class + removedPropertiesExist = true; + } + } + + return removedPropertiesExist; + } +} diff --git a/DesktopUI3/DUI3/Utils/SerializationSettingsFactory.cs b/DesktopUI3/DUI3/Utils/SerializationSettingsFactory.cs new file mode 100644 index 0000000000..d6d407e6ce --- /dev/null +++ b/DesktopUI3/DUI3/Utils/SerializationSettingsFactory.cs @@ -0,0 +1,26 @@ +using DUI3.Bindings; +using Speckle.Newtonsoft.Json; +using Speckle.Newtonsoft.Json.Serialization; + +namespace DUI3.Utils; + +public static class SerializationSettingsFactory +{ + /// + /// Get the canonical Newtonsoft serialization/deserialization settings which we use in DUI3, which currently consist of a camel case name strategy and a discriminated object converter. + /// + /// + public static JsonSerializerSettings GetSerializerSettings() + { + var serializerOptions = new JsonSerializerSettings + { + ContractResolver = new CamelCasePropertyNamesContractResolver(), + NullValueHandling = NullValueHandling.Ignore, + ReferenceLoopHandling = ReferenceLoopHandling.Ignore, + DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate, + Converters = { new DiscriminatedObjectConverter(), new AbstractConverter() } + }; + + return serializerOptions; + } +} diff --git a/DesktopUI3/DUI3/Utils/Traversal.cs b/DesktopUI3/DUI3/Utils/Traversal.cs new file mode 100644 index 0000000000..bf670fe692 --- /dev/null +++ b/DesktopUI3/DUI3/Utils/Traversal.cs @@ -0,0 +1,114 @@ +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using Speckle.Core.Kits; +using Speckle.Core.Models; +using Speckle.Core.Models.Extensions; +using Speckle.Core.Models.GraphTraversal; + +namespace DUI3.Utils; + +public static class Traversal +{ + public static List GetObjectsToConvert(Base commitObject, ISpeckleConverter converter) + { + var traverseFunction = DefaultTraversal.CreateTraverseFunc(converter); + + return traverseFunction + .Traverse(commitObject) + .Select(tc => tc.Current) // Previously we were creating ApplicationObject, now just returning Base object. + .Reverse() + .ToList(); + } + + /// + /// A variation of the OG Traversal extension from Alan, but with tracking the object path as well. + /// + /// + /// + /// + public static IEnumerable<(List,Base)> TraverseWithPath(this Base root, BaseExtensions.BaseRecursionBreaker recursionBreaker) + { + var stack = new Stack<(List,Base)>(); + stack.Push((new List(), root)); + + while (stack.Count > 0) + { + (List path, Base current) = stack.Pop(); + yield return (path, current); + + if (recursionBreaker(current)) + { + continue; + } + + foreach (string child in current.GetDynamicMemberNames()) + { + // NOTE: we can store collections rather than just path names. Where we have an actual collection, use that, where not, create a mock one based on the prop name + var localPathFragment = child; + if (current is Collection { name: { } } c) + { + localPathFragment = c.name; + } + + var newPath = new List(path) { localPathFragment }; + switch (current[child]) + { + case Base o: + stack.Push((newPath, o)); + break; + case IDictionary dictionary: + { + foreach (object obj in dictionary.Keys) + { + if (obj is Base b) + { + stack.Push((newPath, b)); + } + } + + break; + } + case IList collection: + { + foreach (object obj in collection) + { + if (obj is Base b) + { + stack.Push((newPath, b)); + } + } + break; + } + } + } + } + } + + /// + /// Utility function to flatten a conversion result that might have nested lists of objects. + /// This happens, for example, in the case of multiple display value fallbacks for a given object. + /// + /// + /// + public static List FlattenToNativeConversionResult(object item) + { + var convertedList = new List(); + void Flatten(object item) + { + if (item is IList list) + { + foreach (object child in list) + { + Flatten(child); + } + } + else + { + convertedList.Add(item); + } + } + Flatten(item); + return convertedList; + } +} diff --git a/DesktopUI3/DUI3/yarn.lock b/DesktopUI3/DUI3/yarn.lock new file mode 100644 index 0000000000..fb57ccd13a --- /dev/null +++ b/DesktopUI3/DUI3/yarn.lock @@ -0,0 +1,4 @@ +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 + + diff --git a/DesktopUI3/yarn.lock b/DesktopUI3/yarn.lock new file mode 100644 index 0000000000..fb57ccd13a --- /dev/null +++ b/DesktopUI3/yarn.lock @@ -0,0 +1,4 @@ +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 + + diff --git a/Objects/Converters/ConverterAutocadCivil/ConverterAutocadCivilShared/Converter.AutocadCivil.Utils.cs b/Objects/Converters/ConverterAutocadCivil/ConverterAutocadCivilShared/Converter.AutocadCivil.Utils.cs index abe25556eb..078bb18770 100644 --- a/Objects/Converters/ConverterAutocadCivil/ConverterAutocadCivilShared/Converter.AutocadCivil.Utils.cs +++ b/Objects/Converters/ConverterAutocadCivil/ConverterAutocadCivilShared/Converter.AutocadCivil.Utils.cs @@ -94,6 +94,11 @@ public Dictionary LineTypeDictionary /// public static string RemoveInvalidChars(string str) { + // TOOD: DUI3! this is temporary check since DUI3 not fully implemented! + if (str == null) + { + return ""; + } // using this to handle rhino nested layer syntax // replace "::" layer delimiter with "$" (acad standard) string cleanDelimiter = str.Replace("::", "$"); diff --git a/Objects/Converters/ConverterAutocadCivil/ConverterAutocadCivilShared/ConverterAutocadCivil.Other.cs b/Objects/Converters/ConverterAutocadCivil/ConverterAutocadCivilShared/ConverterAutocadCivil.Other.cs index f97cea6124..338ac88f40 100644 --- a/Objects/Converters/ConverterAutocadCivil/ConverterAutocadCivilShared/ConverterAutocadCivil.Other.cs +++ b/Objects/Converters/ConverterAutocadCivil/ConverterAutocadCivilShared/ConverterAutocadCivil.Other.cs @@ -588,8 +588,11 @@ public ObjectId DefinitionToNativeDB(Base definition, out List notes) { notes = new List(); + // TODO: DUI3! Ignore commit info while implementing DUI3! Later find a similar way or use as below! + var commitInfo = "dui3_test"; + // get the definition name - var commitInfo = RemoveInvalidChars(Doc.UserData["commit"] as string); + // var commitInfo = RemoveInvalidAutocadChars(Doc.UserData["commit"] as string); string definitionName = definition is BlockDefinition blockDef ? RemoveInvalidChars(blockDef.name) : definition is RevitSymbolElementType revitDef diff --git a/Objects/Converters/ConverterRhinoGh/ConverterRhinoGhShared/ConverterRhinoGh.Utils.cs b/Objects/Converters/ConverterRhinoGh/ConverterRhinoGhShared/ConverterRhinoGh.Utils.cs index 47d0c30d3d..9994577428 100644 --- a/Objects/Converters/ConverterRhinoGh/ConverterRhinoGhShared/ConverterRhinoGh.Utils.cs +++ b/Objects/Converters/ConverterRhinoGh/ConverterRhinoGhShared/ConverterRhinoGh.Utils.cs @@ -82,6 +82,11 @@ public int GetMaterialIndex(string name) private string GetCommitInfo() { + if (Doc.Notes == null) + { + return "Unknown commit"; + } + var segments = Doc.Notes.Split(new[] { "%%%" }, StringSplitOptions.None).ToList(); return segments.Count > 1 ? segments[1] : "Unknown commit"; } From 06713cad05491da7651b284e2b10386eca8d381f Mon Sep 17 00:00:00 2001 From: Alan Rynne Date: Thu, 14 Mar 2024 16:37:24 +0100 Subject: [PATCH 002/261] Dim's history rebased MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sorry Dim, I seem to be the author of all your changes now 🤣🙌🏼 Co-authored-by: Dimitrie Stefanescu --- .../Bindings/SendBinding.cs | 76 ++++--- .../Bindings/BasicConnectorBindingRevit.cs | 65 ++---- .../RevitDUI3Shared/Bindings/Factory.cs | 5 +- .../RevitDUI3Shared/Bindings/Filters.cs | 3 +- .../Bindings/ReceiveBinding.cs | 2 +- .../Bindings/SelectionBinding.cs | 16 +- .../RevitDUI3Shared/Bindings/SendBinding.cs | 168 ++++++++++++--- .../RevitDUI3/RevitDUI3Shared/Entry.cs | 1 + .../RevitDUI3Shared/RevitDUI3Shared.projitems | 2 +- .../RevitDUI3Shared/Utils/Elements.cs | 11 - .../RevitDUI3Shared/Utils/PortedOverStuff.cs | 189 ++++++++++++++++ .../Bindings/BasicConnectorBinding.cs | 20 +- .../ConnectorRhinoWebUI/Bindings/Filters.cs | 48 ++--- .../Bindings/SendBinding.cs | 108 ++++++---- .../Operations/Operations.Send.Obsolete.cs | 2 +- Core/Core/Api/Operations/Operations.Send.cs | 2 +- Core/Core/Models/Extras.cs | 6 +- .../Serialisation/BaseObjectSerializerV2.cs | 52 ++++- DesktopUI3/DUI3/Bindings/ISendBinding.cs | 10 +- DesktopUI3/DUI3/Operations/Send.cs | 201 ++++++++++++++++++ 20 files changed, 767 insertions(+), 220 deletions(-) delete mode 100644 ConnectorRevit/RevitDUI3/RevitDUI3Shared/Utils/Elements.cs create mode 100644 ConnectorRevit/RevitDUI3/RevitDUI3Shared/Utils/PortedOverStuff.cs create mode 100644 DesktopUI3/DUI3/Operations/Send.cs diff --git a/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Bindings/SendBinding.cs b/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Bindings/SendBinding.cs index e993f3e073..09f62513cc 100644 --- a/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Bindings/SendBinding.cs +++ b/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Bindings/SendBinding.cs @@ -29,12 +29,25 @@ public class SendBinding : ISendBinding, ICancelable private Document Doc => Application.DocumentManager.MdiActiveDocument; + /// + /// Used internally to aggregate the changed objects' id. + /// private HashSet ChangedObjectIds { get; set; } = new(); + /// + /// Keeps track of previously converted objects as a dictionary of (applicationId, object reference). + /// + private readonly Dictionary _convertedObjectReferences = new(); + public SendBinding(AutocadDocumentModelStore store) { _store = store; Application.DocumentManager.DocumentActivated += (sender, args) => SubscribeToObjectChanges(args.Document); + if (Application.DocumentManager.CurrentDocument != null) + { + // NOTE: catches the case when autocad just opens up with a blank new doc + SubscribeToObjectChanges(Application.DocumentManager.CurrentDocument); + } } private readonly List _docSubsTracker = new(); @@ -74,33 +87,39 @@ private async void SendInternal(string modelCardId) var cts = CancellationManager.InitCancellationTokenSource(modelCardId); // 1 - Setup - var model = _store.GetModelById(modelCardId) as SenderModelCard; - var account = Accounts.GetAccount(model.AccountId); + var modelCard = _store.GetModelById(modelCardId) as SenderModelCard; + var account = Accounts.GetAccount(modelCard.AccountId); var converter = Converters.GetConverter(Doc, Utils.Utils.VersionedAppName); // 2 - Get elements to convert - var dbObjects = Objects.GetObjectsFromDocument(Doc, model.SendFilter.GetObjectIds()); + var dbObjects = Objects.GetObjectsFromDocument(Doc, modelCard.SendFilter.GetObjectIds()); if (dbObjects.Count == 0) { throw new InvalidOperationException("No objects were found. Please update your send filter!"); } // 5 - Convert objects - var commitObject = ConvertObjects(dbObjects, converter, modelCardId, cts); + var commitObject = ConvertObjects(dbObjects, converter, modelCard, cts); if (cts.IsCancellationRequested) { return; } - // 6 - Get transports - List transports = new() { new ServerTransport(account, model.ProjectId) }; - // 7 - Serialize and Send objects + var transport = new ServerTransport(account, modelCard.ProjectId); BasicConnectorBindingCommands.SetModelProgress(Parent, modelCardId, new ModelCardProgress { Status = "Uploading..." }); - string objectId = await Speckle.Core.Api.Operations - .Send(commitObject, cts.Token, transports, disposeTransports: true) + var sendResult = await SendHelper + .Send(commitObject, transport, true, null, cts.Token) .ConfigureAwait(true); - + + // Store the converted references in memory for future send operations, overwriting the existing values for the given application id. + foreach (var kvp in sendResult.convertedReferences) + { + _convertedObjectReferences[kvp.Key + modelCard.ProjectId] = kvp.Value; + } + // It's important to reset the model card's list of changed obj ids so as to ensure we accurately keep track of changes between send operations. + modelCard.ChangedObjectIds = new(); + if (cts.IsCancellationRequested) { throw new OperationCanceledException(cts.Token); @@ -113,13 +132,15 @@ private async void SendInternal(string modelCardId) var apiClient = new Client(account); string versionId = await apiClient.CommitCreate(new CommitCreateInput() { - streamId = model.ProjectId, branchName = model.ModelId, sourceApplication = "Rhino", objectId = objectId + streamId = modelCard.ProjectId, branchName = modelCard.ModelId, sourceApplication = "Rhino", objectId = sendResult.rootObjId }, cts.Token).ConfigureAwait(true); SendBindingUiCommands.SetModelCreatedVersionId(Parent, modelCardId, versionId); apiClient.Dispose(); } - catch (Exception e) // NOTE: Always catch everything we can! +#pragma warning disable CA1031 + catch (Exception e) // All exceptions should be handled here if possible, otherwise we enter "crashing the host app" territory. +#pragma warning restore CA1031 { if (e is OperationCanceledException) { @@ -138,12 +159,14 @@ private void RunExpirationChecks() string[] objectIdsList = ChangedObjectIds.ToArray(); List expiredSenderIds = new(); - foreach (SenderModelCard sender in senders) + foreach (SenderModelCard modelCard in senders) { - bool isExpired = sender.SendFilter.CheckExpiry(objectIdsList); + var intersection = modelCard.SendFilter.GetObjectIds().Intersect(objectIdsList).ToList(); + bool isExpired = intersection.Any(); if (isExpired) { - expiredSenderIds.Add(sender.ModelCardId); + expiredSenderIds.Add(modelCard.ModelCardId); + modelCard.ChangedObjectIds.UnionWith(intersection); } } @@ -154,7 +177,7 @@ private void RunExpirationChecks() private Base ConvertObjects( List<(DBObject obj, string layer, string applicationId)> dbObjects, ISpeckleConverter converter, - string modelCardId, + SenderModelCard modelCard, CancellationTokenSource cts ) { @@ -170,14 +193,19 @@ CancellationTokenSource cts } try { - Base converted = converter.ConvertToSpeckle(tuple.obj); - converted.applicationId = tuple.applicationId; - - if (converted == null) + Base converted; + var applicationId = tuple.applicationId; + + if (!modelCard.ChangedObjectIds.Contains(applicationId) && _convertedObjectReferences.TryGetValue(applicationId + modelCard.ProjectId, out ObjectReference value)) { - // TODO: report, error out, etc. + converted = value; } - + else + { + converted = converter.ConvertToSpeckle(tuple.obj); + converted.applicationId = applicationId; + } + // Create and add a collection for each layer if not done so already. if (!collectionCache.ContainsKey(tuple.layer)) { @@ -187,9 +215,9 @@ CancellationTokenSource cts collectionCache[tuple.layer].elements.Add(converted); - BasicConnectorBindingCommands.SetModelProgress(Parent, modelCardId, new ModelCardProgress() { Status = "Converting", Progress = (double)++count / dbObjects.Count}); + BasicConnectorBindingCommands.SetModelProgress(Parent, modelCard.ModelCardId, new ModelCardProgress() { Status = "Converting", Progress = (double)++count / dbObjects.Count}); } - catch (Exception e) // THE FUCK + catch (Exception e) { // TODO: Add to report, etc. Debug.WriteLine(e.Message); diff --git a/ConnectorRevit/RevitDUI3/RevitDUI3Shared/Bindings/BasicConnectorBindingRevit.cs b/ConnectorRevit/RevitDUI3/RevitDUI3Shared/Bindings/BasicConnectorBindingRevit.cs index 3ca0a7cd6f..bf4db61c2e 100644 --- a/ConnectorRevit/RevitDUI3/RevitDUI3Shared/Bindings/BasicConnectorBindingRevit.cs +++ b/ConnectorRevit/RevitDUI3/RevitDUI3Shared/Bindings/BasicConnectorBindingRevit.cs @@ -1,3 +1,4 @@ +using System; using System.Collections.Generic; using System.Linq; using System.Reflection; @@ -66,73 +67,43 @@ public DocumentInfo GetDocumentInfo() public DocumentModelStore GetDocumentState() => _store; - public void AddModel(ModelCard model) => _store.Models.Add(model); + public void AddModel(ModelCard model) + { + _store.Models.Add(model); + _store.WriteToFile(); + } public void UpdateModel(ModelCard model) { int idx = _store.Models.FindIndex(m => model.ModelCardId == m.ModelCardId); _store.Models[idx] = model; + _store.WriteToFile(); } public void RemoveModel(ModelCard model) { int index = _store.Models.FindIndex(m => m.ModelCardId == model.ModelCardId); _store.Models.RemoveAt(index); + _store.WriteToFile(); } public void HighlightModel(string modelCardId) { - SenderModelCard model = _store.GetModelById(modelCardId) as SenderModelCard; - List objectsIds = model.SendFilter.GetObjectIds(); - List elements = Utils.Elements.GetElementsFromDocument(Doc, objectsIds); - - List elementIds = elements.Select(e => e.Id).ToList(); + // TODO: Support receivers + var senderModelCard = _store.GetModelById(modelCardId) as SenderModelCard; - // UiDocument operations should be wrapped into RevitTask, otherwise doesn't work on other tasks. + var elementIds = senderModelCard.SendFilter.GetObjectIds().Select(ElementId.Parse).ToList(); + + if (elementIds.Count == 0) + { + BasicConnectorBindingCommands.SetModelError(Parent, modelCardId, new OperationCanceledException("No objects found to highlight.") ); + return; + } + RevitTask.RunAsync(() => { UiDocument.Selection.SetElementIds(elementIds); UiDocument.ShowElements(elementIds); - - // Create a BoundingBoxXYZ to encompass the selected elements - BoundingBoxXYZ selectionBoundingBox = new(); - bool first = true; - - foreach (ElementId elementId in elementIds) - { - Element element = Doc.GetElement(elementId); - - if (element != null) - { - BoundingBoxXYZ elementBoundingBox = element.get_BoundingBox(null); - - if (elementBoundingBox != null) - { - if (first) - { - selectionBoundingBox = elementBoundingBox; - first = false; - } - else - { - // selectionBoundingBox.Min = XYZ.Min(selectionBoundingBox.Min, elementBoundingBox.Min); - // selectionBoundingBox.Max = XYZ.Max(selectionBoundingBox.Max, elementBoundingBox.Max); - } - } - } - } - - // Zoom the view to the selection bounding box - if (!first) - { - View activeView = UiDocument.ActiveView; - - using Transaction tr = new(Doc, "Zoom to Selection"); - tr.Start(); - activeView.CropBox = selectionBoundingBox; - Doc.Regenerate(); - tr.Commit(); - } }); } } diff --git a/ConnectorRevit/RevitDUI3/RevitDUI3Shared/Bindings/Factory.cs b/ConnectorRevit/RevitDUI3/RevitDUI3Shared/Bindings/Factory.cs index 293ff7ad15..5e83874158 100644 --- a/ConnectorRevit/RevitDUI3/RevitDUI3Shared/Bindings/Factory.cs +++ b/ConnectorRevit/RevitDUI3/RevitDUI3Shared/Bindings/Factory.cs @@ -12,7 +12,8 @@ public static List CreateBindings(RevitDocumentStore store) BasicConnectorBindingRevit baseBinding = new(store); SelectionBinding selectionBinding = new(); SendBinding sendBinding = new(store); - ReceiveBinding receiveBinding = new(store); + // TODO: Revit receive is very flaky right now, removing + // ReceiveBinding receiveBinding = new(store); List bindingsList = new() { @@ -22,7 +23,7 @@ public static List CreateBindings(RevitDocumentStore store) baseBinding, selectionBinding, sendBinding, - receiveBinding + // receiveBinding // See above note on receives }; return bindingsList; diff --git a/ConnectorRevit/RevitDUI3/RevitDUI3Shared/Bindings/Filters.cs b/ConnectorRevit/RevitDUI3/RevitDUI3Shared/Bindings/Filters.cs index 4b6fb21e21..bd03a1c72b 100644 --- a/ConnectorRevit/RevitDUI3/RevitDUI3Shared/Bindings/Filters.cs +++ b/ConnectorRevit/RevitDUI3/RevitDUI3Shared/Bindings/Filters.cs @@ -4,11 +4,12 @@ namespace Speckle.ConnectorRevitDUI3.Bindings; +// TODO: implement properly public class RevitEverythingFilter : EverythingSendFilter { public override List GetObjectIds() { - // TODO + return new List(); } diff --git a/ConnectorRevit/RevitDUI3/RevitDUI3Shared/Bindings/ReceiveBinding.cs b/ConnectorRevit/RevitDUI3/RevitDUI3Shared/Bindings/ReceiveBinding.cs index 34268d6e3d..9f9b527d68 100644 --- a/ConnectorRevit/RevitDUI3/RevitDUI3Shared/Bindings/ReceiveBinding.cs +++ b/ConnectorRevit/RevitDUI3/RevitDUI3Shared/Bindings/ReceiveBinding.cs @@ -37,7 +37,7 @@ public ReceiveBinding(RevitDocumentStore store) public void CancelReceive(string modelCardId) => CancellationManager.CancelOperation(modelCardId); - public async void Receive(string modelCardId, string versionId) + public async void Receive(string modelCardId) { try { diff --git a/ConnectorRevit/RevitDUI3/RevitDUI3Shared/Bindings/SelectionBinding.cs b/ConnectorRevit/RevitDUI3/RevitDUI3Shared/Bindings/SelectionBinding.cs index adb8aedf4d..0162b3e7c6 100644 --- a/ConnectorRevit/RevitDUI3/RevitDUI3Shared/Bindings/SelectionBinding.cs +++ b/ConnectorRevit/RevitDUI3/RevitDUI3Shared/Bindings/SelectionBinding.cs @@ -1,6 +1,4 @@ -using System.Collections.Generic; -using System.Linq; -using Autodesk.Revit.DB; +using System.Linq; using Autodesk.Revit.UI; using DUI3; using DUI3.Bindings; @@ -37,16 +35,12 @@ private void OnSelectionChanged() public SelectionInfo GetSelection() { - List els = RevitApp.ActiveUIDocument.Selection - .GetElementIds() - .Select(id => RevitApp.ActiveUIDocument.Document.GetElement(id)) - .ToList(); - List cats = els.Select(el => el.Category?.Name ?? el.Name).Distinct().ToList(); - List ids = els.Select(el => el.UniqueId.ToString()).ToList(); + // TODO: filter supported stuff + var selectionIds = RevitApp.ActiveUIDocument.Selection.GetElementIds().Select(id => id.ToString()).ToList(); return new SelectionInfo() { - SelectedObjectIds = ids, - Summary = $"{els.Count} objects ({string.Join(", ", cats)})" + SelectedObjectIds = selectionIds, + Summary = $"{selectionIds.Count} objects selected." }; } } diff --git a/ConnectorRevit/RevitDUI3/RevitDUI3Shared/Bindings/SendBinding.cs b/ConnectorRevit/RevitDUI3/RevitDUI3Shared/Bindings/SendBinding.cs index f4637885a1..a84c40d7fe 100644 --- a/ConnectorRevit/RevitDUI3/RevitDUI3Shared/Bindings/SendBinding.cs +++ b/ConnectorRevit/RevitDUI3/RevitDUI3Shared/Bindings/SendBinding.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Diagnostics; using System.Linq; using System.Threading; using Autodesk.Revit.UI; @@ -14,8 +15,8 @@ using Speckle.Core.Transports; using Speckle.Core.Models; using DUI3.Utils; +using RevitSharedResources.Interfaces; using Speckle.Core.Api; -using Operations = DUI3.Operations.Operations; namespace Speckle.ConnectorRevitDUI3.Bindings; @@ -32,21 +33,32 @@ public class SendBinding : ISendBinding, ICancelable public CancellationManager CancellationManager { get; } = new(); + /// + /// Used internally to aggregate the changed objects' id. + /// private HashSet ChangedObjectIds { get; set; } = new(); + /// + /// Keeps track of previously converted objects as a dictionary of (applicationId, object reference). + /// + private readonly Dictionary _convertedObjectReferences = new(); + + /// + /// Thingie we ported from the DUI2 Era. + /// + private static IRevitDocumentAggregateCache revitDocumentAggregateCache; public SendBinding(RevitDocumentStore store) { s_revitApp = RevitAppProvider.RevitApp; _store = store; - - // TODO expiry events - // TODO filters need refresh events - s_revitApp.Application.DocumentChanged += (_, e) => DocChangeHandler(e); + + s_revitApp.Application.DocumentChanged += (_, e) => StoreChangedElementIdsAndScheduleExpiryCheck(e); + revitDocumentAggregateCache = new RevitDocumentAggregateCache(new UIDocumentProvider(s_revitApp)); } public List GetSendFilters() { - return new List { new RevitEverythingFilter(), new RevitSelectionFilter() }; + return new List { new RevitSelectionFilter() {IsDefault = true} }; } private Base ConvertElements( @@ -90,28 +102,40 @@ public async void Send(string modelCardId) CancellationTokenSource cts = CancellationManager.InitCancellationTokenSource(modelCardId); // 1 - Get model - SenderModelCard model = _store.GetModelById(modelCardId) as SenderModelCard; + SenderModelCard modelCard = _store.GetModelById(modelCardId) as SenderModelCard; // 2 - Check account exist - Account account = Accounts.GetAccount(model.AccountId); + Account account = Accounts.GetAccount(modelCard.AccountId); // 3 - Get elements to convert - List elements = Utils.Elements.GetElementsFromDocument(Doc, model.SendFilter.GetObjectIds()); + var ids = modelCard.SendFilter.GetObjectIds(); + var elements = new List(); + foreach (var id in ids) + { + var el = Doc.GetElement(ElementId.Parse(id)); + if (el != null) + { + elements.Add(el); + } + } + + if (elements.Count == 0) + { + throw new InvalidOperationException("No objects were found. Please update your send filter!"); + } // 4 - Get converter ISpeckleConverter converter = Converters.GetConverter(Doc, RevitAppProvider.Version()); - + converter.SetContextDocument(revitDocumentAggregateCache); + // 5 - Convert objects - Base commitObject = ConvertElements(elements, converter, modelCardId, cts); + Base commitObject = ConvertElements(elements, converter, modelCard, cts); if (cts.IsCancellationRequested) { throw new OperationCanceledException(cts.Token); } - - // 6 - Get transports - List transports = new() { new ServerTransport(account, model.ProjectId) }; - + // 7 - Serialize and Send objects BasicConnectorBindingCommands.SetModelProgress( Parent, @@ -146,7 +170,9 @@ public async void Send(string modelCardId) SendBindingUiCommands.SetModelCreatedVersionId(Parent, modelCardId, versionId); apiClient.Dispose(); } - catch (Exception e) +#pragma warning disable CA1031 + catch (Exception e) // All exceptions should be handled here if possible, otherwise we enter "crashing the host app" territory. +#pragma warning restore CA1031 { if (e is OperationCanceledException) { @@ -158,13 +184,104 @@ public async void Send(string modelCardId) } public void CancelSend(string modelCardId) => CancellationManager.CancelOperation(modelCardId); + + private Base ConvertElements( + List elements, + ISpeckleConverter converter, + SenderModelCard modelCard, + CancellationTokenSource cts + ) + { + int count = 0; + var rootObject = new Collection { name = Doc.PathName.Split('\\').Reverse().First().Split('.').First() }; + var collectionCache = new Dictionary(); + + foreach (var revitElement in elements) + { + if (cts.IsCancellationRequested) + { + throw new OperationCanceledException(); + } + + var cat = revitElement.Category.Name; + var level = Doc.GetElement(revitElement.LevelId) as Level; + var path = new[] { level == null ? "No level": level.Name, cat }; + var collection = GetAndCreateObjectHostCollection(path, collectionCache, rootObject); + + count++; + try + { + Base converted; + var applicationId = revitElement.Id.ToString(); + if (!modelCard.ChangedObjectIds.Contains(applicationId) && _convertedObjectReferences.TryGetValue(applicationId + modelCard.ProjectId, out ObjectReference value)) + { + converted = value; + } + else + { + converted = converter.ConvertToSpeckle(revitElement); + converted.applicationId = applicationId; + } + + collection.elements.Add(converted); + BasicConnectorBindingCommands.SetModelProgress(Parent, modelCard.ModelCardId, new ModelCardProgress() { Status = "Converting", Progress = (double)count / elements.Count }); + } + catch (Exception e) + { + // TODO: Add to report, etc. + Debug.WriteLine(e.Message); + } + + } + return rootObject; + } + /// + /// Creates and nests collections based on the provided path within the root collection provided. This will not return a new collection each time is called, but an existing one if one is found. + /// For example, you can use this to use (or re-use) a new collection for a path of (level, category) as it's currently implemented. + /// + /// + /// + /// + /// + private Collection GetAndCreateObjectHostCollection(IEnumerable path, Dictionary cache, Collection root) + { + string fullPathName = string.Join("", path); + if (cache.TryGetValue(fullPathName, out Collection value)) + { + return value; + } + + string flatPathName = ""; + Collection previousCollection = root; + + foreach (var pathItem in path) + { + flatPathName += pathItem; + Collection childCollection; + if (cache.ContainsKey(flatPathName)) + { + childCollection = cache[flatPathName]; + } + else + { + childCollection = new Collection(pathItem, "layer"); + previousCollection.elements.Add(childCollection); + cache[flatPathName] = childCollection; + } + + previousCollection = childCollection; + } + + return previousCollection; + } + /// /// Keeps track of the changed element ids as well as checks if any of them need to trigger /// a filter refresh (e.g., views being added). /// /// - private void DocChangeHandler(Autodesk.Revit.DB.Events.DocumentChangedEventArgs e) + private void StoreChangedElementIdsAndScheduleExpiryCheck(Autodesk.Revit.DB.Events.DocumentChangedEventArgs e) { ICollection addedElementIds = e.GetAddedElementIds(); ICollection deletedElementIds = e.GetDeletedElementIds(); @@ -172,17 +289,17 @@ private void DocChangeHandler(Autodesk.Revit.DB.Events.DocumentChangedEventArgs foreach (ElementId elementId in addedElementIds) { - ChangedObjectIds.Add(elementId.IntegerValue.ToString()); + ChangedObjectIds.Add(elementId.ToString()); } foreach (ElementId elementId in deletedElementIds) { - ChangedObjectIds.Add(elementId.IntegerValue.ToString()); + ChangedObjectIds.Add(elementId.ToString()); } foreach (ElementId elementId in modifiedElementIds) { - ChangedObjectIds.Add(elementId.IntegerValue.ToString()); + ChangedObjectIds.Add(elementId.ToString()); } // TODO: CHECK IF ANY OF THE ABOVE ELEMENTS NEED TO TRIGGER A FILTER REFRESH @@ -194,13 +311,16 @@ private void RunExpirationChecks() { List senders = _store.GetSenders(); List expiredSenderIds = new(); - - foreach (var sender in senders) + string[] objectIdsList = ChangedObjectIds.ToArray(); + + foreach (var modelCard in senders) { - bool isExpired = sender.SendFilter.CheckExpiry(ChangedObjectIds.ToArray()); + var intersection = modelCard.SendFilter.GetObjectIds().Intersect(objectIdsList).ToList(); + bool isExpired = intersection.Any(); if (isExpired) { - expiredSenderIds.Add(sender.ModelCardId); + expiredSenderIds.Add(modelCard.ModelCardId); + modelCard.ChangedObjectIds.UnionWith(intersection); } } SendBindingUiCommands.SetModelsExpired(Parent, expiredSenderIds); diff --git a/ConnectorRevit/RevitDUI3/RevitDUI3Shared/Entry.cs b/ConnectorRevit/RevitDUI3/RevitDUI3Shared/Entry.cs index d8ab4ffa1c..2f554e3021 100644 --- a/ConnectorRevit/RevitDUI3/RevitDUI3Shared/Entry.cs +++ b/ConnectorRevit/RevitDUI3/RevitDUI3Shared/Entry.cs @@ -100,6 +100,7 @@ private void RegisterPanelAndInitializePlugin(UIApplication application) CefSharpPanel.Browser.IsBrowserInitializedChanged += (sender, e) => { + // TODO: check if it is actually initialised or not foreach (BrowserBridge bridge in bridges) { CefSharpPanel.Browser.JavascriptObjectRepository.Register( diff --git a/ConnectorRevit/RevitDUI3/RevitDUI3Shared/RevitDUI3Shared.projitems b/ConnectorRevit/RevitDUI3/RevitDUI3Shared/RevitDUI3Shared.projitems index 8d57458a2b..f3a47a4072 100644 --- a/ConnectorRevit/RevitDUI3/RevitDUI3Shared/RevitDUI3Shared.projitems +++ b/ConnectorRevit/RevitDUI3/RevitDUI3Shared/RevitDUI3Shared.projitems @@ -20,7 +20,7 @@ Panel.xaml - + diff --git a/ConnectorRevit/RevitDUI3/RevitDUI3Shared/Utils/Elements.cs b/ConnectorRevit/RevitDUI3/RevitDUI3Shared/Utils/Elements.cs deleted file mode 100644 index 89f14202bc..0000000000 --- a/ConnectorRevit/RevitDUI3/RevitDUI3Shared/Utils/Elements.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System.Collections.Generic; -using System.Linq; -using Autodesk.Revit.DB; - -namespace Speckle.ConnectorRevitDUI3.Utils; - -public static class Elements -{ - public static List GetElementsFromDocument(Document doc, IEnumerable objectIds) => - objectIds.Select(doc.GetElement).Where(x => x != null).ToList(); -} diff --git a/ConnectorRevit/RevitDUI3/RevitDUI3Shared/Utils/PortedOverStuff.cs b/ConnectorRevit/RevitDUI3/RevitDUI3Shared/Utils/PortedOverStuff.cs new file mode 100644 index 0000000000..b73fb7aa5a --- /dev/null +++ b/ConnectorRevit/RevitDUI3/RevitDUI3Shared/Utils/PortedOverStuff.cs @@ -0,0 +1,189 @@ +#nullable enable +using UI = Autodesk.Revit.UI; +using System; +using System.Collections.Generic; +using Autodesk.Revit.DB; +using RevitSharedResources.Interfaces; + +namespace Speckle.ConnectorRevitDUI3.Utils; + +// +// Do note, these are copy-pasted constructs from the dui2 connector. +// + +/// +/// Provides the current to any dependencies which may need it +/// +public class UIDocumentProvider +{ + private UI.UIApplication revitApplication; + + public UIDocumentProvider(UI.UIApplication revitApplication) + { + this.revitApplication = revitApplication; + } + + private UI.UIDocument uiDocument; + + public UI.UIDocument Entity + { + get => uiDocument ?? revitApplication.ActiveUIDocument; + set => uiDocument = value; + } +} + + + +/// +/// Simple conversion cache to store elements that are retrieved and may be needed again throughout the conversion operation +/// +public sealed class RevitDocumentAggregateCache : IRevitDocumentAggregateCache +{ + private readonly Dictionary objectCaches; + private readonly UIDocumentProvider uiDocumentProvider; + public Document Document => uiDocumentProvider.Entity.Document; + + public RevitDocumentAggregateCache(UIDocumentProvider uiDocumentProvider) + { + this.uiDocumentProvider = uiDocumentProvider; + this.objectCaches = new(); + } + + public IRevitObjectCache GetOrInitializeEmptyCacheOfType(out bool isExistingCache) + { + return GetOrInitializeCacheOfTypeNullable(null, out isExistingCache); + } + + public IRevitObjectCache GetOrInitializeCacheOfType( + Action> initializer, + out bool isExistingCache + ) + { + return GetOrInitializeCacheOfTypeNullable(initializer, out isExistingCache); + } + + private IRevitObjectCache GetOrInitializeCacheOfTypeNullable( + Action>? initializer, + out bool isExistingCache + ) + { + if (!objectCaches.TryGetValue(typeof(T), out var singleCache)) + { + isExistingCache = false; + singleCache = new RevitObjectCache(this); + if (initializer != null) + { + initializer((IRevitObjectCache)singleCache); + } + objectCaches.Add(typeof(T), singleCache); + } + else + { + isExistingCache = true; + } + return (IRevitObjectCache)singleCache; + } + + public IRevitObjectCache? TryGetCacheOfType() + { + if (!objectCaches.TryGetValue(typeof(T), out var singleCache)) + { + return null; + } + return singleCache as IRevitObjectCache; + } + + public void Invalidate() + { + objectCaches.Remove(typeof(T)); + } + + public void InvalidateAll() + { + objectCaches.Clear(); + } +} + +/// +/// Storage of a single type of object in the +/// +/// +internal class RevitObjectCache : IRevitObjectCache +{ + private readonly Dictionary dataStorage; + public IRevitDocumentAggregateCache ParentCache { get; } + + public RevitObjectCache(IRevitDocumentAggregateCache parentCache) + { + ParentCache = parentCache; + dataStorage = new(); + } + + public T GetOrAdd(string key, Func factory, out bool isExistingValue) + { + if (!dataStorage.TryGetValue(key, out var value)) + { + isExistingValue = false; + value = factory(); + dataStorage.Add(key, value); + } + else + { + isExistingValue = true; + } + + return value; + } + + public T? TryGet(string key) + { + if (!dataStorage.TryGetValue(key, out var value)) + { + return default(T); + } + + return value; + } + + public bool ContainsKey(string key) + { + return dataStorage.ContainsKey(key); + } + + public ICollection GetAllKeys() + { + return dataStorage.Keys; + } + + public ICollection GetAllObjects() + { + return dataStorage.Values; + } + + public void Set(string key, T value) + { + dataStorage[key] = value; + } + + public void AddMany(IEnumerable elements, Func keyFactory) + { + foreach (var element in elements) + { + var key = keyFactory(element); + dataStorage[key] = element; + } + } + + public void AddMany(Dictionary elementMap) + { + foreach (var kvp in elementMap) + { + dataStorage[kvp.Key] = kvp.Value; + } + } + + public void Remove(string key) + { + dataStorage.Remove(key); + } +} diff --git a/ConnectorRhino/ConnectorRhinoWebUI/Bindings/BasicConnectorBinding.cs b/ConnectorRhino/ConnectorRhinoWebUI/Bindings/BasicConnectorBinding.cs index 6eca0cf022..43c15ee6e8 100644 --- a/ConnectorRhino/ConnectorRhinoWebUI/Bindings/BasicConnectorBinding.cs +++ b/ConnectorRhino/ConnectorRhinoWebUI/Bindings/BasicConnectorBinding.cs @@ -58,7 +58,7 @@ public void RemoveModel(ModelCard model) int index = _store.Models.FindIndex(m => m.ModelCardId == model.ModelCardId); _store.Models.RemoveAt(index); } - + public void HighlightModel(string modelCardId) { var objectIds = new List(); @@ -73,25 +73,27 @@ public void HighlightModel(string modelCardId) { objectIds = receiver.ReceiveResult.BakedObjectIds; } - + if (objectIds.Count == 0) { - BasicConnectorBindingCommands.SetModelError(Parent, modelCardId, new OperationCanceledException("No objects found to highlight.") ); - return; + BasicConnectorBindingCommands.SetModelError(Parent, modelCardId, + new OperationCanceledException("No objects found to highlight.")); + return; } - + List rhinoObjects = objectIds - .Select((id) => RhinoDoc.ActiveDoc.Objects.FindId(new Guid(id))).Where(o => o!=null) + .Select((id) => RhinoDoc.ActiveDoc.Objects.FindId(new Guid(id))).Where(o => o != null) .ToList(); - + RhinoDoc.ActiveDoc.Objects.UnselectAll(); if (rhinoObjects.Count == 0) { - BasicConnectorBindingCommands.SetModelError(Parent,modelCardId, new OperationCanceledException("No objects found to highlight.") ); + BasicConnectorBindingCommands.SetModelError(Parent, modelCardId, + new OperationCanceledException("No objects found to highlight.")); return; } - + RhinoDoc.ActiveDoc.Objects.Select(rhinoObjects.Select(o => o.Id)); // Calculate the bounding box of the selected objects diff --git a/ConnectorRhino/ConnectorRhinoWebUI/Bindings/Filters.cs b/ConnectorRhino/ConnectorRhinoWebUI/Bindings/Filters.cs index c99abfdd08..a23de0ec92 100644 --- a/ConnectorRhino/ConnectorRhinoWebUI/Bindings/Filters.cs +++ b/ConnectorRhino/ConnectorRhinoWebUI/Bindings/Filters.cs @@ -8,56 +8,42 @@ namespace ConnectorRhinoWebUI.Bindings; public class RhinoEverythingFilter : EverythingSendFilter { - public override List GetObjectIds() - { - return new List(); // TODO - } + public override List GetObjectIds() => new List(); // TODO - public override bool CheckExpiry(string[] changedObjectIds) - { - return true; - } + public override bool CheckExpiry(string[] changedObjectIds) => true; } public class RhinoSelectionFilter : DirectSelectionSendFilter { - public override List GetObjectIds() - { - return SelectedObjectIds; - } + public override List GetObjectIds() => SelectedObjectIds; - public override bool CheckExpiry(string[] changedObjectIds) - { - return SelectedObjectIds.Intersect(changedObjectIds).Any(); - } + public override bool CheckExpiry(string[] changedObjectIds) => SelectedObjectIds.Intersect(changedObjectIds).Any(); } public class RhinoLayerFilter : ListValueInput, ISendFilter { - public string Name { get; set; } - public string Summary { get; set; } - public bool IsDefault { get; set; } - public RhinoLayerFilter() { Name = "Layers"; Summary = "How many layers are actually selected. UI should populate this."; foreach (var layer in RhinoDoc.ActiveDoc.Layers) { - if(layer.IsDeleted || layer.Disposed) continue; - - Options.Add(new ListValueItem() { Id = layer.Id.ToString(), Name = layer.FullPath }); + if (layer.IsDeleted || layer.Disposed) + { + continue; + } + + Options.Add(new ListValueItem { Id = layer.Id.ToString(), Name = layer.FullPath }); } } - public List GetObjectIds() - { - return new List(); // TODO: based on the SelectedOptions field - } + public string Name { get; set; } + public string Summary { get; set; } + public bool IsDefault { get; set; } - public bool CheckExpiry(string[] changedObjectIds) - { + public List GetObjectIds() => new List(); // TODO: based on the SelectedOptions field + + public bool CheckExpiry(string[] changedObjectIds) => // TODO - return false; - } + false; } diff --git a/ConnectorRhino/ConnectorRhinoWebUI/Bindings/SendBinding.cs b/ConnectorRhino/ConnectorRhinoWebUI/Bindings/SendBinding.cs index d881e24784..569c8b9bea 100644 --- a/ConnectorRhino/ConnectorRhinoWebUI/Bindings/SendBinding.cs +++ b/ConnectorRhino/ConnectorRhinoWebUI/Bindings/SendBinding.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Linq; using System.Threading; +using System.Threading.Tasks; using ConnectorRhinoWebUI.Utils; using DUI3; using DUI3.Bindings; @@ -26,8 +27,15 @@ public class SendBinding : ISendBinding, ICancelable public IBridge Parent { get; set; } private readonly DocumentModelStore _store; public CancellationManager CancellationManager { get; } = new(); - + + /// + /// Used internally to aggregate the changed objects' id. + /// private HashSet ChangedObjectIds { get; set; } = new(); + /// + /// Keeps track of previously converted objects as a dictionary of (applicationId, object reference). + /// + private readonly Dictionary _convertedObjectReferences = new(); public SendBinding(DocumentModelStore store) { @@ -109,16 +117,16 @@ public async void Send(string modelCardId) // 1 - Get model - if (_store.GetModelById(modelCardId) is not SenderModelCard model) + if (_store.GetModelById(modelCardId) is not SenderModelCard modelCard) { throw new InvalidOperationException("No publish model card was found."); } // 2 - Check account exist - Account account = Accounts.GetAccount(model.AccountId); + Account account = Accounts.GetAccount(modelCard.AccountId); // 3 - Get elements to convert, throw early if nothing is selected - List rhinoObjects = GetObjectsFromDocument(model); + List rhinoObjects = modelCard.SendFilter.GetObjectIds().Select(id => RhinoDoc.ActiveDoc.Objects.FindId(new Guid(id))).Where(obj => obj!=null).ToList(); if (rhinoObjects.Count == 0) { @@ -127,23 +135,32 @@ public async void Send(string modelCardId) // 4 - Get converter ISpeckleConverter converter = Converters.GetConverter(RhinoDoc.ActiveDoc, "Rhino7"); - + // 5 - Convert objects - Base commitObject = ConvertObjects(rhinoObjects, converter, modelCardId, cts); + Base commitObject = ConvertObjects(rhinoObjects, converter, modelCard, cts); if (cts.IsCancellationRequested) { throw new OperationCanceledException(cts.Token); } - - // 6 - Get transports - List transports = new() { new ServerTransport(account, model.ProjectId) }; - + // 7 - Serialize and Send objects BasicConnectorBindingCommands.SetModelProgress(Parent, modelCardId, new ModelCardProgress { Status = "Uploading..." }); - string objectId = await Speckle.Core.Api.Operations - .Send(commitObject, cts.Token, transports, disposeTransports: true) + var transport = new ServerTransport(account, modelCard.ProjectId); + var sendResult = await SendHelper + .Send(commitObject, transport, true, null, cts.Token) .ConfigureAwait(true); + + // Store the converted references in memory for future send operations, overwriting the existing values for the given application id. + foreach (var kvp in sendResult.convertedReferences) + { + // TODO: Bug in here, we need to encapsulate cache not only by app id, but also by project id, + // TODO: as otherwise we assume incorrectly that an object exists for a given project (e.g, send box to project 1, send same unchanged box to project 2) + _convertedObjectReferences[kvp.Key + modelCard.ProjectId] = kvp.Value; + } + // It's important to reset the model card's list of changed obj ids so as to ensure we accurately keep track of changes between send operations. + // NOTE: ChangedObjectIds is currently JsonIgnored, but could actually be useful for highlighting changes in host app. + modelCard.ChangedObjectIds = new(); BasicConnectorBindingCommands.SetModelProgress(Parent, modelCardId, new ModelCardProgress { Status = "Linking version to model..." }); @@ -151,14 +168,14 @@ public async void Send(string modelCardId) var apiClient = new Client(account); string versionId = await apiClient.CommitCreate(new CommitCreateInput() { - streamId = model.ProjectId, branchName = model.ModelId, sourceApplication = "Rhino", objectId = objectId + streamId = modelCard.ProjectId, branchName = modelCard.ModelId, sourceApplication = "Rhino", objectId = sendResult.rootObjId }, cts.Token).ConfigureAwait(true); SendBindingUiCommands.SetModelCreatedVersionId(Parent, modelCardId, versionId); apiClient.Dispose(); } #pragma warning disable CA1031 - catch (Exception e) + catch (Exception e) // All exceptions should be handled here if possible, otherwise we enter "crashing the host app" territory. #pragma warning restore CA1031 { if (e is OperationCanceledException) // We do not want to display an error, we just stop sending. @@ -172,18 +189,14 @@ public async void Send(string modelCardId) public void CancelSend(string modelCardId) => CancellationManager.CancelOperation(modelCardId); - private Base ConvertObjects( - List rhinoObjects, - ISpeckleConverter converter, - string modelCardId, - CancellationTokenSource cts - ) + private Base ConvertObjects(List rhinoObjects, ISpeckleConverter converter, SenderModelCard modelCard, CancellationTokenSource cts) { - var modelWithLayers = new Collection { name = RhinoDoc.ActiveDoc.Name }; + var rootObjectCollection = new Collection { name = RhinoDoc.ActiveDoc.Name ?? "Unnamed document" }; int count = 0; Dictionary layerCollectionCache = new(); + // TODO: Handle blocks. foreach (RhinoObject rhinoObject in rhinoObjects) { if (cts.IsCancellationRequested) @@ -195,26 +208,43 @@ CancellationTokenSource cts var layer = RhinoDoc.ActiveDoc.Layers[rhinoObject.Attributes.LayerIndex]; // 2. get or create a nested collection for it - var collectionHost = GetAndCreateObjectHostCollection(layerCollectionCache, layer, modelWithLayers); + var collectionHost = GetHostObjectCollection(layerCollectionCache, layer, rootObjectCollection); + var applicationId = rhinoObject.Id.ToString(); - // 3. convert - var converted = converter.ConvertToSpeckle(rhinoObject); - converted.applicationId = rhinoObject.Id.ToString(); + // 3. get from cache or convert: + // What we actually do here is check if the object has been previously converted AND has not changed. + // If that's the case, we insert in the host collection just its object reference which has been saved from the prior conversion. + Base converted; + if (!modelCard.ChangedObjectIds.Contains(applicationId) && _convertedObjectReferences.TryGetValue(applicationId + modelCard.ProjectId, out ObjectReference value)) + { + converted = value; + } + else + { + converted = converter.ConvertToSpeckle(rhinoObject); + converted.applicationId = applicationId; + } // 4. add to host collectionHost.elements.Add(converted); - - BasicConnectorBindingCommands.SetModelProgress(Parent, modelCardId, new ModelCardProgress(){ Status = "Converting", Progress = (double)++count / rhinoObjects.Count}); + BasicConnectorBindingCommands.SetModelProgress(Parent, modelCard.ModelCardId, new ModelCardProgress(){ Status = "Converting", Progress = (double)++count / rhinoObjects.Count}); // NOTE: useful for testing ui states, pls keep for now so we can easily uncomment // Thread.Sleep(550); } // 5. profit - return modelWithLayers; + return rootObjectCollection; } - private Collection GetAndCreateObjectHostCollection(Dictionary layerCollectionCache, Layer layer, Collection modelWithLayers) + /// + /// Returns the host collection based on the provided layer. If it's not found, it will be created and hosted within the the rootObjectCollection. + /// + /// + /// + /// + /// + private Collection GetHostObjectCollection(Dictionary layerCollectionCache, Layer layer, Collection rootObjectCollection) { if (layerCollectionCache.TryGetValue(layer.Index, out Collection value)) { @@ -224,7 +254,7 @@ private Collection GetAndCreateObjectHostCollection(Dictionary var names = layer.FullPath.Split(new[] {Layer.PathSeparator}, StringSplitOptions.None); var path = names[0]; var index = 0; - var previousCollection = modelWithLayers; + var previousCollection = rootObjectCollection; foreach (var layerName in names) { var existingLayerIndex = RhinoDoc.ActiveDoc.Layers.FindByFullPath(path, -1); @@ -254,27 +284,25 @@ private Collection GetAndCreateObjectHostCollection(Dictionary layerCollectionCache[layer.Index] = previousCollection; return previousCollection; - // var collectionHost = modelLayers.Traverse(m => m is not Collection).FirstOrDefault(obj => (obj as Collection)?.name == layer.Name) as Collection; // works, but it's better with a cache } - private List GetObjectsFromDocument(SenderModelCard model) - { - List objectsIds = model.SendFilter.GetObjectIds(); - return objectsIds.Select((id) => RhinoDoc.ActiveDoc.Objects.FindId(new Guid(id))).Where(obj => obj!=null).ToList(); - } - + /// + /// Checks if any sender model cards contain any of the changed objects. If so, also updates the changed objects hashset for each model card - this last part is important for on send change detection. + /// private void RunExpirationChecks() { List senders = _store.GetSenders(); string[] objectIdsList = ChangedObjectIds.ToArray(); List expiredSenderIds = new(); - foreach (SenderModelCard sender in senders) + foreach (SenderModelCard modelCard in senders) { - bool isExpired = sender.SendFilter.CheckExpiry(objectIdsList); + var intersection = modelCard.SendFilter.GetObjectIds().Intersect(objectIdsList).ToList(); + bool isExpired = intersection.Any(); if (isExpired) { - expiredSenderIds.Add(sender.ModelCardId); + expiredSenderIds.Add(modelCard.ModelCardId); + modelCard.ChangedObjectIds.UnionWith(intersection); } } SendBindingUiCommands.SetModelsExpired(Parent, expiredSenderIds); diff --git a/Core/Core/Api/Operations/Operations.Send.Obsolete.cs b/Core/Core/Api/Operations/Operations.Send.Obsolete.cs index 2d07a601eb..39ebc58305 100644 --- a/Core/Core/Api/Operations/Operations.Send.Obsolete.cs +++ b/Core/Core/Api/Operations/Operations.Send.Obsolete.cs @@ -162,7 +162,7 @@ public static async Task Send( } else { - serializerV2 = new BaseObjectSerializerV2(transports, internalProgressAction, cancellationToken); + serializerV2 = new BaseObjectSerializerV2(transports, internalProgressAction, false, cancellationToken); } foreach (var t in transports) diff --git a/Core/Core/Api/Operations/Operations.Send.cs b/Core/Core/Api/Operations/Operations.Send.cs index 882a831c24..bf42693564 100644 --- a/Core/Core/Api/Operations/Operations.Send.cs +++ b/Core/Core/Api/Operations/Operations.Send.cs @@ -92,7 +92,7 @@ public static async Task Send( var internalProgressAction = GetInternalProgressAction(onProgressAction); - BaseObjectSerializerV2 serializerV2 = new(transports, internalProgressAction, cancellationToken); + BaseObjectSerializerV2 serializerV2 = new(transports, internalProgressAction, false, cancellationToken); foreach (var t in transports) { diff --git a/Core/Core/Models/Extras.cs b/Core/Core/Models/Extras.cs index fae7201fc7..79006ad9df 100644 --- a/Core/Core/Models/Extras.cs +++ b/Core/Core/Models/Extras.cs @@ -59,11 +59,13 @@ public class DataChunk : Base public List data { get; set; } = new(); } -public class ObjectReference +public class ObjectReference : Base { - public string speckle_type = "reference"; + public new string speckle_type = "reference"; public string referencedId { get; set; } + + public Dictionary closure { get; set; } } public class ProgressEventArgs : EventArgs diff --git a/Core/Core/Serialisation/BaseObjectSerializerV2.cs b/Core/Core/Serialisation/BaseObjectSerializerV2.cs index eef522c00d..88dfa48855 100644 --- a/Core/Core/Serialisation/BaseObjectSerializerV2.cs +++ b/Core/Core/Serialisation/BaseObjectSerializerV2.cs @@ -26,6 +26,13 @@ public class BaseObjectSerializerV2 private readonly Dictionary> _typedPropertiesCache = new(); private readonly Action? _onProgressAction; + private readonly bool _trackDetachedChildren; + /// + /// Keeps track of all detached children created during serialisation that have an applicationId (provided this serializer instance has been told to track detached children). + /// This is currently used to cache previously converted objects and avoid their conversion if they haven't changed. See the DUI3 send bindings in rhino or another host app. + /// + public Dictionary ObjectReferences { get; } = new (); + /// The sync transport. This transport will be used synchronously. public IReadOnlyCollection WriteTransports { get; } @@ -37,15 +44,24 @@ public class BaseObjectSerializerV2 public BaseObjectSerializerV2() : this(Array.Empty()) { } + /// + /// Creates a new Serializer instance. + /// + /// The transports detached children should be persisted to. + /// Used to track progress. + /// Whether to store all detachable objects while serializing. They can be retrieved via post serialization. + /// public BaseObjectSerializerV2( IReadOnlyCollection writeTransports, Action? onProgressAction = null, + bool trackDetachedChildren = false, CancellationToken cancellationToken = default ) { WriteTransports = writeTransports; _onProgressAction = onProgressAction; CancellationToken = cancellationToken; + _trackDetachedChildren = trackDetachedChildren; } /// The object to serialize @@ -111,6 +127,22 @@ public string Serialize(Base baseObj) switch (obj) { + // Start with object references so they're not captured by the Base class case below + // Note: this change was needed as we've made the ObjectReference type inherit from Base for + // the purpose of the "do not convert unchanged previously converted objects" POC. + case ObjectReference r: + { + Dictionary ret = new() { ["speckle_type"] = r.speckle_type, ["referencedId"] = r.referencedId, ["__closure"] = r.closure }; + if(r.closure is not null) + { + foreach (var kvp in r.closure) + { + UpdateParentClosures(kvp.Key); + } + } + UpdateParentClosures(r.referencedId); + return ret; + } // Complex enough to deserve its own function case Base b: return PreserializeBase(b, computeClosures, inheritedDetachInfo); @@ -141,11 +173,6 @@ public string Serialize(Base baseObj) return ret; } - case ObjectReference r: - { - Dictionary ret = new() { ["speckle_type"] = r.speckle_type, ["referencedId"] = r.referencedId }; - return ret; - } case Enum: return (int)obj; // Support for simple types @@ -204,7 +231,7 @@ public string Serialize(Base baseObj) throw new ArgumentException($"Unsupported value in serialization: {obj.GetType()}"); } } - + public IDictionary? PreserializeBase( Base baseObj, bool computeClosures = false, @@ -301,12 +328,21 @@ public string Serialize(Base baseObj) string id = (string)convertedBase["id"]!; StoreObject(id, json); ObjectReference objRef = new() { referencedId = id }; - var objRefConverted = (IDictionary?)PreserializeObject(objRef); + var objRefConverted = (IDictionary?) PreserializeObject(objRef); UpdateParentClosures(id); _onProgressAction?.Invoke("S", 1); + + // add to obj refs to return + if (baseObj.applicationId != null && _trackDetachedChildren) // && baseObj is not DataChunk && baseObj is not Abstract) // not needed, as data chunks will never have application ids, and abstract objs are not really used. + { + ObjectReferences[baseObj.applicationId] = new ObjectReference() + { + referencedId = id, applicationId = baseObj.applicationId, closure = closure + }; + } + return objRefConverted; } - return convertedBase; } diff --git a/DesktopUI3/DUI3/Bindings/ISendBinding.cs b/DesktopUI3/DUI3/Bindings/ISendBinding.cs index 0753e37fe3..ec15779331 100644 --- a/DesktopUI3/DUI3/Bindings/ISendBinding.cs +++ b/DesktopUI3/DUI3/Bindings/ISendBinding.cs @@ -3,6 +3,7 @@ using DUI3.Models; using DUI3.Models.Card; using DUI3.Utils; +using Speckle.Newtonsoft.Json; namespace DUI3.Bindings; @@ -42,6 +43,9 @@ public static void SetModelCreatedVersionId(IBridge bridge,string modelCardId, s public class SenderModelCard : ModelCard { public ISendFilter SendFilter { get; set; } + + [JsonIgnore] + public HashSet ChangedObjectIds { get; set; } = new(); } public interface ISendFilter @@ -81,9 +85,3 @@ public abstract class DirectSelectionSendFilter : DiscriminatedObject, ISendFilt public abstract List GetObjectIds(); public abstract bool CheckExpiry(string[] changedObjectIds); } - -public class CreateVersionArgs -{ - public string ModelCardId { get; set; } - public string ObjectId { get; set; } -} diff --git a/DesktopUI3/DUI3/Operations/Send.cs b/DesktopUI3/DUI3/Operations/Send.cs new file mode 100644 index 0000000000..ad91c9a3eb --- /dev/null +++ b/DesktopUI3/DUI3/Operations/Send.cs @@ -0,0 +1,201 @@ +#nullable enable +using System; +using System.Collections.Concurrent; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using Serilog.Context; +using Speckle.Core.Logging; +using Speckle.Core.Models; +using Speckle.Core.Serialisation; +using Speckle.Core.Transports; +using Speckle.Newtonsoft.Json.Linq; + +namespace DUI3.Operations; + +/// +/// NOTE: Contains copy pasted code from the OG Send operations in Core (the non-obsolete ones). +/// +public static class SendHelper +{ + + /// + /// IMPORTANT: Copy pasted function from Operations.Send in Core, but this time returning the converted references from the serializer. + /// Sends a Speckle Object to the provided and (optionally) the default local cache + /// + /// + /// + /// When , an additional will be included + /// The or was + /// + /// using ServerTransport destination = new(account, streamId); + /// string objectId = await Send(mySpeckleObject, destination, true); + /// + public static async Task<(string rootObjId, Dictionary convertedReferences)> Send( + Base value, + ITransport transport, + bool useDefaultCache, + Action>? onProgressAction = null, + CancellationToken cancellationToken = default + ) + { + if (transport is null) + { + throw new ArgumentNullException(nameof(transport), "Expected a transport to be explicitly specified"); + } + + List transports = new() { transport }; + using SQLiteTransport? localCache = useDefaultCache ? new SQLiteTransport { TransportName = "LC" } : null; + if (localCache is not null) + { + transports.Add(localCache); + } + + return await Send(value, transports, onProgressAction, cancellationToken).ConfigureAwait(false); + } + + /// + /// IMPORTANT: Copy pasted function from Operations.Send in Core, but this time returning the converted references from the serializer. + /// It's marked as private as DUI3 only uses the one above. + /// Note that this should be structured better in the future - this is here to minimise core changes coming from DUI3. + /// + /// + /// + /// + /// + /// + /// + /// + /// + private static async Task<(string rootObjId, Dictionary convertedReferences)> Send( + Base value, + IReadOnlyCollection transports, + Action>? onProgressAction = null, + CancellationToken cancellationToken = default) + { + if (value is null) + { + throw new ArgumentNullException(nameof(value)); + } + + if (transports.Count == 0) + { + throw new ArgumentException("Expected at least on transport to be specified", nameof(transports)); + } + + var transportContext = transports.ToDictionary(t => t.TransportName, t => t.TransportContext); + + // make sure all logs in the operation have the proper context + using (LogContext.PushProperty("transportContext", transportContext)) + using (LogContext.PushProperty("correlationId", Guid.NewGuid().ToString())) + { + var sendTimer = Stopwatch.StartNew(); + SpeckleLog.Logger.Information("Starting send operation"); + + var internalProgressAction = GetInternalProgressAction(onProgressAction); + + BaseObjectSerializerV2 serializerV2 = new(transports, internalProgressAction, trackDetachedChildren: true, cancellationToken); + + foreach (var t in transports) + { + t.OnProgressAction = internalProgressAction; + t.CancellationToken = cancellationToken; + t.BeginWrite(); + } + + (string rootObjId, Dictionary) serializerReturnValue; + try + { + serializerReturnValue = await SerializerSend(value, serializerV2, cancellationToken).ConfigureAwait(false); + } + catch (Exception ex) when (!ex.IsFatal()) + { + SpeckleLog.Logger.Information( + ex, + "Send operation failed after {elapsed} seconds", + sendTimer.Elapsed.TotalSeconds + ); + if (ex is OperationCanceledException or SpeckleException) + { + throw; + } + + throw new SpeckleException("Send operation was unsuccessful", ex); + } + finally + { + foreach (var t in transports) + { + t.EndWrite(); + } + } + + sendTimer.Stop(); + SpeckleLog.Logger + .ForContext("transportElapsedBreakdown", transports.ToDictionary(t => t.TransportName, t => t.Elapsed)) + .ForContext("note", "the elapsed summary doesn't need to add up to the total elapsed... Threading magic...") + .ForContext("serializerElapsed", serializerV2.Elapsed) + .Information( + "Finished sending {objectCount} objects after {elapsed}, result {objectId}", + transports.Max(t => t.SavedObjectCount), + sendTimer.Elapsed.TotalSeconds, + serializerReturnValue.rootObjId + ); + return serializerReturnValue; + } + } + + internal static async Task<(string rootObjectId, Dictionary convertedReferences)> SerializerSend( + Base value, + BaseObjectSerializerV2 serializer, + CancellationToken cancellationToken = default + ) + { + string obj = serializer.Serialize(value); + Task[] transportAwaits = serializer.WriteTransports.Select(t => t.WriteComplete()).ToArray(); + + cancellationToken.ThrowIfCancellationRequested(); + + await Task.WhenAll(transportAwaits).ConfigureAwait(false); + + var parsed = JObject.Parse(obj); + JToken? idToken = parsed.GetValue("id"); + + if (idToken == null) + { + throw new SpeckleException("Failed to get id of serialized object"); + } + + return (idToken.ToString(), serializer.ObjectReferences); + } + + /// + /// Factory for progress actions used internally inside send and receive methods. + /// + /// + /// + private static Action? GetInternalProgressAction( + Action>? onProgressAction + ) + { + if (onProgressAction is null) + { + return null; + } + + var localProgressDict = new ConcurrentDictionary(); + + return (name, processed) => + { + if (!localProgressDict.TryAdd(name, processed)) + { + localProgressDict[name] += processed; + } + + onProgressAction.Invoke(localProgressDict); + }; + } + +} From fc7962b3ce2e105b4fa7d1459a64399c482ffcc1 Mon Sep 17 00:00:00 2001 From: Alan Rynne Date: Thu, 14 Mar 2024 16:46:02 +0100 Subject: [PATCH 003/261] chore: Format files with csharpier --- .../Bindings/BasicConnectorBindingAutocad.cs | 20 ++-- .../Bindings/ReceiveBinding.cs | 75 ++++++++++----- .../Bindings/SelectionBinding.cs | 5 +- .../Bindings/SendBinding.cs | 57 +++++++---- .../Utils/AutocadDocumentModelStore.cs | 26 ++--- .../Utils/AutocadIdleManager.cs | 2 +- .../AutocadCivilDUI3Shared/Utils/Objects.cs | 9 +- .../AutocadCivilDUI3Shared/Utils/Utils.cs | 1 - .../Bindings/ReceiveBinding.cs | 16 ++-- .../Speckle.Connectors.Revit2023/Class1.cs | 4 +- .../Bindings/BasicConnectorBinding.cs | 27 ++++-- .../ConnectorRhinoWebUI/Bindings/Filters.cs | 7 +- .../Bindings/ReceiveBinding.cs | 69 +++++++++----- .../Bindings/SendBinding.cs | 95 ++++++++++++------- .../Utils/RhinoIdleManager.cs | 2 +- .../DUI3/Bindings/IBasicConnectorBinding.cs | 6 +- DesktopUI3/DUI3/Bindings/IReceiveBinding.cs | 5 +- DesktopUI3/DUI3/Bindings/ISendBinding.cs | 8 +- .../DUI3/Models/Card/ModelCardProgress.cs | 2 - DesktopUI3/DUI3/Models/ConversionReport.cs | 17 ++-- DesktopUI3/DUI3/Operations/Operations.cs | 16 ++-- DesktopUI3/DUI3/Utils/Traversal.cs | 13 ++- 22 files changed, 302 insertions(+), 180 deletions(-) diff --git a/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Bindings/BasicConnectorBindingAutocad.cs b/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Bindings/BasicConnectorBindingAutocad.cs index 381323f891..9aa7ea0f2b 100644 --- a/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Bindings/BasicConnectorBindingAutocad.cs +++ b/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Bindings/BasicConnectorBindingAutocad.cs @@ -49,7 +49,8 @@ public string GetSourceApplicationVersion() public DocumentInfo GetDocumentInfo() { - if (Doc == null) return null; + if (Doc == null) + return null; string name = Doc.Name.Split(System.IO.Path.PathSeparator).Reverse().First(); return new DocumentInfo() { @@ -82,7 +83,7 @@ public void HighlightModel(string modelCardId) return; } var objectIds = Array.Empty(); - + var model = _store.GetModelById(modelCardId); if (model == null) { @@ -95,18 +96,25 @@ public void HighlightModel(string modelCardId) objectIds = dbObjects.Select(tuple => tuple.obj.Id).ToArray(); } - if (model is ReceiverModelCard { ReceiveResult: { } } receiverModelCard && receiverModelCard.ReceiveResult.BakedObjectIds.Count != 0) + if ( + model is ReceiverModelCard { ReceiveResult: { } } receiverModelCard + && receiverModelCard.ReceiveResult.BakedObjectIds.Count != 0 + ) { var dbObjects = Objects.GetObjectsFromDocument(Doc, receiverModelCard.ReceiveResult.BakedObjectIds); objectIds = dbObjects.Select(tuple => tuple.obj.Id).ToArray(); } - + if (objectIds.Length == 0) { - BasicConnectorBindingCommands.SetModelError(Parent, modelCardId, new OperationCanceledException("No objects found to highlight.") ); + BasicConnectorBindingCommands.SetModelError( + Parent, + modelCardId, + new OperationCanceledException("No objects found to highlight.") + ); return; } - + Parent.RunOnMainThread(() => { Doc.Editor.SetImpliedSelection(Array.Empty()); // Deselects diff --git a/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Bindings/ReceiveBinding.cs b/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Bindings/ReceiveBinding.cs index 0491ca2201..bb92b2c5fb 100644 --- a/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Bindings/ReceiveBinding.cs +++ b/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Bindings/ReceiveBinding.cs @@ -59,8 +59,12 @@ public async void Receive(string modelCardId) ISpeckleConverter converter = Converters.GetConverter(Doc, Utils.VersionedAppName); // 4 - Traverse commit object - BasicConnectorBindingCommands.SetModelProgress(Parent, modelCardId, new ModelCardProgress() { Status = "Parsing structure" }); - var objectsToConvert = new List<(List,Base)>(); + BasicConnectorBindingCommands.SetModelProgress( + Parent, + modelCardId, + new ModelCardProgress() { Status = "Parsing structure" } + ); + var objectsToConvert = new List<(List, Base)>(); foreach (var (objPath, obj) in commitObject.TraverseWithPath((obj) => obj is not Collection)) { if (cts.IsCancellationRequested) @@ -79,16 +83,24 @@ public async void Receive(string modelCardId) } var baseLayerPrefix = $"SPK-{modelCard.ProjectName}-{modelCard.ModelName}-"; - BasicConnectorBindingCommands.SetModelProgress(Parent, modelCardId, new ModelCardProgress() { Status = "Starting conversion" }); - + BasicConnectorBindingCommands.SetModelProgress( + Parent, + modelCardId, + new ModelCardProgress() { Status = "Starting conversion" } + ); + using var docLock = Doc.LockDocument(); using var transaction = Doc.Database.TransactionManager.StartTransaction(); - + CreateLayerFilter(modelCard.ProjectName, modelCard.ModelName); var convertedObjectIds = BakeObjects(objectsToConvert, baseLayerPrefix, modelCardId, cts, converter); Autodesk.AutoCAD.Internal.Utils.FlushGraphics(); - ReceiveBindingUiCommands.SetModelConversionResult(Parent, modelCardId, new ReceiveResult() { BakedObjectIds = convertedObjectIds, Display = true }); + ReceiveBindingUiCommands.SetModelConversionResult( + Parent, + modelCardId, + new ReceiveResult() { BakedObjectIds = convertedObjectIds, Display = true } + ); transaction.Commit(); } catch (Exception e) @@ -101,9 +113,19 @@ public async void Receive(string modelCardId) } } - private List BakeObjects(List<(List,Base)> objects, string baseLayerPrefix, string modelCardId, CancellationTokenSource cts, ISpeckleConverter converter) + private List BakeObjects( + List<(List, Base)> objects, + string baseLayerPrefix, + string modelCardId, + CancellationTokenSource cts, + ISpeckleConverter converter + ) { - BasicConnectorBindingCommands.SetModelProgress(Parent, modelCardId, new ModelCardProgress() { Status = "Converting" }); + BasicConnectorBindingCommands.SetModelProgress( + Parent, + modelCardId, + new ModelCardProgress() { Status = "Converting" } + ); var uniqueLayerNames = new HashSet(); var handleValues = new List(); var count = 0; @@ -113,29 +135,33 @@ private List BakeObjects(List<(List,Base)> objects, string baseL { throw new OperationCanceledException(cts.Token); } - + try { var layerFullName = baseLayerPrefix + string.Join("-", path); layerFullName = Utils.RemoveInvalidChars(layerFullName); - + if (uniqueLayerNames.Add(layerFullName)) { CreateLayerOrPurge(layerFullName); } - + var converted = converter.ConvertToNative(obj); var flattened = Traversal.FlattenToNativeConversionResult(converted); foreach (Entity conversionResult in flattened.Cast()) { - if(conversionResult == null) + if (conversionResult == null) { continue; } conversionResult.Append(layerFullName); handleValues.Add(conversionResult.Handle.Value.ToString()); - BasicConnectorBindingCommands.SetModelProgress(Parent, modelCardId, new ModelCardProgress() { Status = "Converting", Progress = (double)++count/objects.Count }); + BasicConnectorBindingCommands.SetModelProgress( + Parent, + modelCardId, + new ModelCardProgress() { Status = "Converting", Progress = (double)++count / objects.Count } + ); } } catch (Exception e) // DO NOT CATCH SPECIFIC STUFF, conversion errors should be recoverable @@ -155,8 +181,9 @@ private List BakeObjects(List<(List,Base)> objects, string baseL private void CreateLayerOrPurge(string layerName) { using var transaction = Doc.TransactionManager.TopTransaction; - - var layerTable = transaction.TransactionManager.GetObject(Doc.Database.LayerTableId, OpenMode.ForRead) as LayerTable; + + var layerTable = + transaction.TransactionManager.GetObject(Doc.Database.LayerTableId, OpenMode.ForRead) as LayerTable; var layerTableRecord = new LayerTableRecord() { Name = layerName }; var hasLayer = layerTable.Has(layerName); @@ -173,18 +200,18 @@ private void CreateLayerOrPurge(string layerName) { transaction.GetObject(selectedObject.ObjectId, OpenMode.ForWrite).Erase(); } - + return; } - + layerTable.UpgradeOpen(); layerTable.Add(layerTableRecord); transaction.AddNewlyCreatedDBObject(layerTableRecord, true); } - + /// /// Creates a layer filter for the just received model, grouped under a top level filter "Speckle". Note: manual close and open of the layer properties panel required (it's an acad thing). - /// This comes in handy to quickly access the layers created for this specific model. + /// This comes in handy to quickly access the layers created for this specific model. /// /// /// @@ -193,13 +220,13 @@ private void CreateLayerFilter(string projectName, string modelName) using var docLock = Doc.LockDocument(); var filterName = Utils.RemoveInvalidChars($@"{projectName}-{modelName}"); var layerFilterTree = Doc.Database.LayerFilters; - var layerFilterCollection = layerFilterTree.Root.NestedFilters; + var layerFilterCollection = layerFilterTree.Root.NestedFilters; var groupFilterName = "Speckle"; LayerFilter groupFilter = null; - + foreach (LayerFilter existingFilter in layerFilterCollection) { - if(existingFilter.Name == groupFilterName) + if (existingFilter.Name == groupFilterName) { groupFilter = existingFilter; break; @@ -208,10 +235,10 @@ private void CreateLayerFilter(string projectName, string modelName) if (groupFilter == null) { - groupFilter = new LayerFilter() { Name = "Speckle", FilterExpression = $"NAME==\"SPK-*\""}; + groupFilter = new LayerFilter() { Name = "Speckle", FilterExpression = $"NAME==\"SPK-*\"" }; layerFilterCollection.Add(groupFilter); } - + var layerFilterExpression = $"NAME==\"SPK-{filterName}*\""; foreach (LayerFilter lf in groupFilter.NestedFilters) { diff --git a/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Bindings/SelectionBinding.cs b/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Bindings/SelectionBinding.cs index 9f71349cf6..917b103f1d 100644 --- a/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Bindings/SelectionBinding.cs +++ b/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Bindings/SelectionBinding.cs @@ -45,7 +45,6 @@ private void OnSelectionChanged() public SelectionInfo GetSelection() { - Document doc = Application.DocumentManager.MdiActiveDocument; List objs = new(); if (doc != null) @@ -57,7 +56,9 @@ public SelectionInfo GetSelection() foreach (SelectedObject obj in selection.Value) { var dbObject = tr.GetObject(obj.ObjectId, OpenMode.ForRead); - if (dbObject == null /*|| !dbObject.Visible()*/ ) + if ( + dbObject == null /*|| !dbObject.Visible()*/ + ) { continue; } diff --git a/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Bindings/SendBinding.cs b/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Bindings/SendBinding.cs index e993f3e073..d083ad3bce 100644 --- a/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Bindings/SendBinding.cs +++ b/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Bindings/SendBinding.cs @@ -38,6 +38,7 @@ public SendBinding(AutocadDocumentModelStore store) } private readonly List _docSubsTracker = new(); + private void SubscribeToObjectChanges(Document doc) { if (doc == null || doc.Database == null || _docSubsTracker.Contains(doc.Name)) @@ -50,9 +51,9 @@ private void SubscribeToObjectChanges(Document doc) doc.Database.ObjectErased += (_, e) => OnChangeChangedObjectIds(e.DBObject); doc.Database.ObjectModified += (_, e) => OnChangeChangedObjectIds(e.DBObject); } - + private void OnChangeChangedObjectIds(DBObject dBObject) - { + { ChangedObjectIds.Add(dBObject.Handle.Value.ToString()); AutocadIdleManager.SubscribeToIdle(RunExpirationChecks); } @@ -96,7 +97,11 @@ private async void SendInternal(string modelCardId) List transports = new() { new ServerTransport(account, model.ProjectId) }; // 7 - Serialize and Send objects - BasicConnectorBindingCommands.SetModelProgress(Parent, modelCardId, new ModelCardProgress { Status = "Uploading..." }); + BasicConnectorBindingCommands.SetModelProgress( + Parent, + modelCardId, + new ModelCardProgress { Status = "Uploading..." } + ); string objectId = await Speckle.Core.Api.Operations .Send(commitObject, cts.Token, transports, disposeTransports: true) .ConfigureAwait(true); @@ -107,15 +112,27 @@ private async void SendInternal(string modelCardId) } // 8 - Create Version - BasicConnectorBindingCommands.SetModelProgress(Parent, modelCardId, new ModelCardProgress { Status = "Linking version to model..." }); - + BasicConnectorBindingCommands.SetModelProgress( + Parent, + modelCardId, + new ModelCardProgress { Status = "Linking version to model..." } + ); + // 8 - Create the version (commit) var apiClient = new Client(account); - string versionId = await apiClient.CommitCreate(new CommitCreateInput() - { - streamId = model.ProjectId, branchName = model.ModelId, sourceApplication = "Rhino", objectId = objectId - }, cts.Token).ConfigureAwait(true); - + string versionId = await apiClient + .CommitCreate( + new CommitCreateInput() + { + streamId = model.ProjectId, + branchName = model.ModelId, + sourceApplication = "Rhino", + objectId = objectId + }, + cts.Token + ) + .ConfigureAwait(true); + SendBindingUiCommands.SetModelCreatedVersionId(Parent, modelCardId, versionId); apiClient.Dispose(); } @@ -125,7 +142,7 @@ private async void SendInternal(string modelCardId) { return; } - + BasicConnectorBindingCommands.SetModelError(Parent, modelCardId, e); } } @@ -146,7 +163,7 @@ private void RunExpirationChecks() expiredSenderIds.Add(sender.ModelCardId); } } - + SendBindingUiCommands.SetModelsExpired(Parent, expiredSenderIds); ChangedObjectIds = new HashSet(); } @@ -158,7 +175,11 @@ private Base ConvertObjects( CancellationTokenSource cts ) { - var modelWithLayers = new Collection() { name = Doc.Name.Split( new [] {"\\"}, StringSplitOptions.None).Reverse().First(), collectionType = "root" }; + var modelWithLayers = new Collection() + { + name = Doc.Name.Split(new[] { "\\" }, StringSplitOptions.None).Reverse().First(), + collectionType = "root" + }; var collectionCache = new Dictionary(); int count = 0; @@ -177,17 +198,21 @@ CancellationTokenSource cts { // TODO: report, error out, etc. } - + // Create and add a collection for each layer if not done so already. if (!collectionCache.ContainsKey(tuple.layer)) { collectionCache[tuple.layer] = new Collection() { name = tuple.layer, collectionType = "layer" }; modelWithLayers.elements.Add(collectionCache[tuple.layer]); } - + collectionCache[tuple.layer].elements.Add(converted); - BasicConnectorBindingCommands.SetModelProgress(Parent, modelCardId, new ModelCardProgress() { Status = "Converting", Progress = (double)++count / dbObjects.Count}); + BasicConnectorBindingCommands.SetModelProgress( + Parent, + modelCardId, + new ModelCardProgress() { Status = "Converting", Progress = (double)++count / dbObjects.Count } + ); } catch (Exception e) // THE FUCK { diff --git a/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Utils/AutocadDocumentModelStore.cs b/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Utils/AutocadDocumentModelStore.cs index 4711f51045..c846d80ba8 100644 --- a/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Utils/AutocadDocumentModelStore.cs +++ b/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Utils/AutocadDocumentModelStore.cs @@ -17,18 +17,18 @@ public AutocadDocumentModelStore() IsDocumentInit = true; } - Application.DocumentManager.DocumentToBeDestroyed += (_,_) => WriteToFile(); + Application.DocumentManager.DocumentToBeDestroyed += (_, _) => WriteToFile(); Application.DocumentManager.DocumentActivated += (_, e) => OnDocChangeInternal(e.Document); - Autodesk.AutoCAD.ApplicationServices.Application.DocumentWindowCollection.DocumentWindowActivated += - (_, args) => OnDocChangeInternal(args.DocumentWindow.Document as Document); + Autodesk.AutoCAD.ApplicationServices.Application.DocumentWindowCollection.DocumentWindowActivated += (_, args) => + OnDocChangeInternal(args.DocumentWindow.Document as Document); } /// /// Tracks whether the doc has been subscribed to save events. - /// TODO: two separate docs can have the same name, this is a brittle implementation - should be correlated with file location. + /// TODO: two separate docs can have the same name, this is a brittle implementation - should be correlated with file location. /// private readonly List _saveToDocSubTracker = new(); - + private void OnDocChangeInternal(Document doc) { Doc = doc; @@ -38,16 +38,16 @@ private void OnDocChangeInternal(Document doc) { return; } - + s_previousDocName = doc != null ? doc.Name : nullDocName; - - if (doc!=null && !_saveToDocSubTracker.Contains(doc.Name)) + + if (doc != null && !_saveToDocSubTracker.Contains(doc.Name)) { - doc.BeginDocumentClose += (_,_) => WriteToFile(); - doc.Database.BeginSave += (_,_) => WriteToFile(); + doc.BeginDocumentClose += (_, _) => WriteToFile(); + doc.Database.BeginSave += (_, _) => WriteToFile(); _saveToDocSubTracker.Add(doc.Name); } - + ReadFromFile(); OnDocumentChanged(); } @@ -59,13 +59,13 @@ public override void ReadFromFile() { return; } - + string serializedModelCards = AutocadDocumentManager.ReadModelCards(Doc); if (serializedModelCards == null) { return; } - + Models = Deserialize(serializedModelCards); } diff --git a/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Utils/AutocadIdleManager.cs b/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Utils/AutocadIdleManager.cs index 2d8cefd1d0..ac19493921 100644 --- a/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Utils/AutocadIdleManager.cs +++ b/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Utils/AutocadIdleManager.cs @@ -16,7 +16,7 @@ public static class AutocadIdleManager public static void SubscribeToIdle(Action action) { s_sCalls[action.Method.Name] = action; - + if (s_hasSubscribed) { return; diff --git a/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Utils/Objects.cs b/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Utils/Objects.cs index 471f89f472..4fdd80d8c9 100644 --- a/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Utils/Objects.cs +++ b/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Utils/Objects.cs @@ -8,7 +8,10 @@ namespace AutocadCivilDUI3Shared.Utils; public static class Objects { - public static List<(DBObject obj, string layer, string applicationId)> GetObjectsFromDocument(Document doc, IEnumerable objectIds) + public static List<(DBObject obj, string layer, string applicationId)> GetObjectsFromDocument( + Document doc, + IEnumerable objectIds + ) { using DocumentLock acLckDoc = doc.LockDocument(); var dbObjects = new List<(DBObject, string layer, string applicationId)>(); @@ -21,9 +24,9 @@ public static class Objects { continue; } - + var dbObject = tr.GetObject(myObjectId, OpenMode.ForRead); - if(dbObject == null) + if (dbObject == null) { continue; } diff --git a/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Utils/Utils.cs b/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Utils/Utils.cs index 0ba9ac7452..654b5d570a 100644 --- a/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Utils/Utils.cs +++ b/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Utils/Utils.cs @@ -88,5 +88,4 @@ public static BlockTableRecord GetModelSpace(this Database db, OpenMode mode = O { return (BlockTableRecord)SymbolUtilityServices.GetBlockModelSpaceId(db).GetObject(mode); } - } diff --git a/ConnectorRevit/RevitDUI3/RevitDUI3Shared/Bindings/ReceiveBinding.cs b/ConnectorRevit/RevitDUI3/RevitDUI3Shared/Bindings/ReceiveBinding.cs index 34268d6e3d..f192722a4a 100644 --- a/ConnectorRevit/RevitDUI3/RevitDUI3Shared/Bindings/ReceiveBinding.cs +++ b/ConnectorRevit/RevitDUI3/RevitDUI3Shared/Bindings/ReceiveBinding.cs @@ -70,7 +70,7 @@ public async void Receive(string modelCardId, string versionId) { return; } - + BasicConnectorBindingCommands.SetModelError(Parent, modelCardId, e); } } @@ -96,7 +96,7 @@ CancellationTokenSource cts converter.SetContextDocument(t); List errors = new(); int count = 0; - + foreach (Base objToConvert in objectsToConvert) { count++; @@ -104,12 +104,16 @@ CancellationTokenSource cts { throw new OperationCanceledException(cts.Token); } - + try { double progress = (double)count / objectsToConvert.Count; - BasicConnectorBindingCommands.SetModelProgress(Parent, modelCardId, new ModelCardProgress() { Status = "Converting", Progress = progress}); - + BasicConnectorBindingCommands.SetModelProgress( + Parent, + modelCardId, + new ModelCardProgress() { Status = "Converting", Progress = progress } + ); + object convertedObject = converter.ConvertToNative(objToConvert); RefreshView(); } @@ -119,7 +123,7 @@ CancellationTokenSource cts Console.WriteLine(e); } } - + t.Commit(); if (t.GetStatus() == TransactionStatus.RolledBack) diff --git a/ConnectorRevit/RevitDUI3/Speckle.Connectors.Revit2023/Class1.cs b/ConnectorRevit/RevitDUI3/Speckle.Connectors.Revit2023/Class1.cs index 3d7ee2f04c..4ea4d39b06 100644 --- a/ConnectorRevit/RevitDUI3/Speckle.Connectors.Revit2023/Class1.cs +++ b/ConnectorRevit/RevitDUI3/Speckle.Connectors.Revit2023/Class1.cs @@ -6,7 +6,5 @@ namespace Speckle.Connectors.Revit2023 { - public class Class1 - { - } + public class Class1 { } } diff --git a/ConnectorRhino/ConnectorRhinoWebUI/Bindings/BasicConnectorBinding.cs b/ConnectorRhino/ConnectorRhinoWebUI/Bindings/BasicConnectorBinding.cs index 6eca0cf022..7078c5c4c3 100644 --- a/ConnectorRhino/ConnectorRhinoWebUI/Bindings/BasicConnectorBinding.cs +++ b/ConnectorRhino/ConnectorRhinoWebUI/Bindings/BasicConnectorBinding.cs @@ -58,7 +58,7 @@ public void RemoveModel(ModelCard model) int index = _store.Models.FindIndex(m => m.ModelCardId == model.ModelCardId); _store.Models.RemoveAt(index); } - + public void HighlightModel(string modelCardId) { var objectIds = new List(); @@ -73,25 +73,34 @@ public void HighlightModel(string modelCardId) { objectIds = receiver.ReceiveResult.BakedObjectIds; } - + if (objectIds.Count == 0) { - BasicConnectorBindingCommands.SetModelError(Parent, modelCardId, new OperationCanceledException("No objects found to highlight.") ); - return; + BasicConnectorBindingCommands.SetModelError( + Parent, + modelCardId, + new OperationCanceledException("No objects found to highlight.") + ); + return; } - + List rhinoObjects = objectIds - .Select((id) => RhinoDoc.ActiveDoc.Objects.FindId(new Guid(id))).Where(o => o!=null) + .Select((id) => RhinoDoc.ActiveDoc.Objects.FindId(new Guid(id))) + .Where(o => o != null) .ToList(); - + RhinoDoc.ActiveDoc.Objects.UnselectAll(); if (rhinoObjects.Count == 0) { - BasicConnectorBindingCommands.SetModelError(Parent,modelCardId, new OperationCanceledException("No objects found to highlight.") ); + BasicConnectorBindingCommands.SetModelError( + Parent, + modelCardId, + new OperationCanceledException("No objects found to highlight.") + ); return; } - + RhinoDoc.ActiveDoc.Objects.Select(rhinoObjects.Select(o => o.Id)); // Calculate the bounding box of the selected objects diff --git a/ConnectorRhino/ConnectorRhinoWebUI/Bindings/Filters.cs b/ConnectorRhino/ConnectorRhinoWebUI/Bindings/Filters.cs index c99abfdd08..705a81b28c 100644 --- a/ConnectorRhino/ConnectorRhinoWebUI/Bindings/Filters.cs +++ b/ConnectorRhino/ConnectorRhinoWebUI/Bindings/Filters.cs @@ -36,7 +36,7 @@ public class RhinoLayerFilter : ListValueInput, ISendFilter { public string Name { get; set; } public string Summary { get; set; } - public bool IsDefault { get; set; } + public bool IsDefault { get; set; } public RhinoLayerFilter() { @@ -44,8 +44,9 @@ public RhinoLayerFilter() Summary = "How many layers are actually selected. UI should populate this."; foreach (var layer in RhinoDoc.ActiveDoc.Layers) { - if(layer.IsDeleted || layer.Disposed) continue; - + if (layer.IsDeleted || layer.Disposed) + continue; + Options.Add(new ListValueItem() { Id = layer.Id.ToString(), Name = layer.FullPath }); } } diff --git a/ConnectorRhino/ConnectorRhinoWebUI/Bindings/ReceiveBinding.cs b/ConnectorRhino/ConnectorRhinoWebUI/Bindings/ReceiveBinding.cs index df6cc185b5..a91ad26940 100644 --- a/ConnectorRhino/ConnectorRhinoWebUI/Bindings/ReceiveBinding.cs +++ b/ConnectorRhino/ConnectorRhinoWebUI/Bindings/ReceiveBinding.cs @@ -45,9 +45,13 @@ public async void Receive(string modelCardId) // 1 - Get receiver card ReceiverModelCard modelCard = _store.GetModelById(modelCardId) as ReceiverModelCard; - - BasicConnectorBindingCommands.SetModelProgress(Parent, modelCardId, new ModelCardProgress() { Status = "Downloading" }); - + + BasicConnectorBindingCommands.SetModelProgress( + Parent, + modelCardId, + new ModelCardProgress() { Status = "Downloading" } + ); + // 2 - Get commit object from server Base commitObject = await Operations.GetCommitBase(Parent, modelCard, cts.Token).ConfigureAwait(true); @@ -59,17 +63,25 @@ public async void Receive(string modelCardId) // 3 - Get converter ISpeckleConverter converter = Converters.GetConverter(Doc, "Rhino7"); - var objectsToConvert = new List<(List,Base)>(); - - BasicConnectorBindingCommands.SetModelProgress(Parent, modelCardId, new ModelCardProgress() { Status = "Parsing structure" }); + var objectsToConvert = new List<(List, Base)>(); + + BasicConnectorBindingCommands.SetModelProgress( + Parent, + modelCardId, + new ModelCardProgress() { Status = "Parsing structure" } + ); - foreach (var (objPath, obj) in commitObject.TraverseWithPath(obj => obj is not Collection && converter.CanConvertToNative(obj))) // note the "obj is not collection" is working around a bug of sorts in the rh converter where we assume collections always have a collectionType; also unsure why collection to layer is in the converter (it's fine, but weird) + foreach ( + var (objPath, obj) in commitObject.TraverseWithPath( + obj => obj is not Collection && converter.CanConvertToNative(obj) + ) + ) // note the "obj is not collection" is working around a bug of sorts in the rh converter where we assume collections always have a collectionType; also unsure why collection to layer is in the converter (it's fine, but weird) { if (cts.IsCancellationRequested) { throw new OperationCanceledException(cts.Token); } - + if (obj is not Collection && converter.CanConvertToNative(obj)) { objectsToConvert.Add((objPath, obj)); @@ -78,11 +90,11 @@ public async void Receive(string modelCardId) var baseLayerName = $"Project {modelCard.ProjectName}: Model {modelCard.ModelName}"; var convertedIds = BakeObjects(objectsToConvert, baseLayerName, modelCardId, cts, converter); - + var receiveResult = new ReceiveResult() { BakedObjectIds = convertedIds, Display = true }; - - ReceiveBindingUiCommands.SetModelConversionResult(Parent, modelCardId, receiveResult ); - + + ReceiveBindingUiCommands.SetModelConversionResult(Parent, modelCardId, receiveResult); + // 7 - Redraw the view to render baked objects Doc.Views.Redraw(); } @@ -97,17 +109,23 @@ public async void Receive(string modelCardId) } } - private List BakeObjects(List<(List,Base)> objects, string baseLayerName, string modelCardId, CancellationTokenSource cts, ISpeckleConverter converter) + private List BakeObjects( + List<(List, Base)> objects, + string baseLayerName, + string modelCardId, + CancellationTokenSource cts, + ISpeckleConverter converter + ) { - // LETS FUCK AROUND AND FIND OUT + // LETS FUCK AROUND AND FIND OUT var rootLayerName = baseLayerName; var rootLayerIndex = Doc.Layers.Find(rootLayerName, true); - + if (rootLayerIndex >= 0) { - foreach ( var layer in RhinoDoc.ActiveDoc.Layers[ rootLayerIndex ].GetChildren() ) + foreach (var layer in RhinoDoc.ActiveDoc.Layers[rootLayerIndex].GetChildren()) { - RhinoDoc.ActiveDoc.Layers.Purge( layer.Index, false ); + RhinoDoc.ActiveDoc.Layers.Purge(layer.Index, false); } } @@ -117,7 +135,7 @@ private List BakeObjects(List<(List,Base)> objects, string baseL var newObjectIds = new List(); var count = 0; - foreach(var (path, baseObj) in objects) + foreach (var (path, baseObj) in objects) { if (cts.IsCancellationRequested) { @@ -129,14 +147,18 @@ private List BakeObjects(List<(List,Base)> objects, string baseL { layerIndex = cache[fullLayerName]; } - + if (layerIndex == -1) { layerIndex = GetAndCreateLayerFromPath(path, rootLayerName, cache); } - - BasicConnectorBindingCommands.SetModelProgress(Parent, modelCardId, new ModelCardProgress() { Status = "Converting & creating objects", Progress = (double)++count/objects.Count }); - + + BasicConnectorBindingCommands.SetModelProgress( + Parent, + modelCardId, + new ModelCardProgress() { Status = "Converting & creating objects", Progress = (double)++count / objects.Count } + ); + var converted = converter.ConvertToNative(baseObj); if (converted is GeometryBase newObject) { @@ -145,7 +167,7 @@ private List BakeObjects(List<(List,Base)> objects, string baseL } // else something weird happened? a block maybe? also, blocks are treated like $$$ now tbh so i won't dive into them } - + return newObjectIds; } @@ -190,5 +212,4 @@ public List GetReceiveSettings() => Enum = new List() { "Update", "Create", "Ignore" } } }; - } diff --git a/ConnectorRhino/ConnectorRhinoWebUI/Bindings/SendBinding.cs b/ConnectorRhino/ConnectorRhinoWebUI/Bindings/SendBinding.cs index d881e24784..628bb81294 100644 --- a/ConnectorRhino/ConnectorRhinoWebUI/Bindings/SendBinding.cs +++ b/ConnectorRhino/ConnectorRhinoWebUI/Bindings/SendBinding.cs @@ -32,7 +32,7 @@ public class SendBinding : ISendBinding, ICancelable public SendBinding(DocumentModelStore store) { _store = store; - + RhinoDoc.LayerTableEvent += (_, _) => { SendBindingUiCommands.RefreshSendFilters(Parent); @@ -80,8 +80,8 @@ public List GetSendFilters() { return new List() { - new RhinoEverythingFilter(), - new RhinoSelectionFilter() { IsDefault = true }, + new RhinoEverythingFilter(), + new RhinoSelectionFilter() { IsDefault = true }, new RhinoLayerFilter() }; } @@ -113,7 +113,7 @@ public async void Send(string modelCardId) { throw new InvalidOperationException("No publish model card was found."); } - + // 2 - Check account exist Account account = Accounts.GetAccount(model.AccountId); @@ -140,20 +140,36 @@ public async void Send(string modelCardId) List transports = new() { new ServerTransport(account, model.ProjectId) }; // 7 - Serialize and Send objects - BasicConnectorBindingCommands.SetModelProgress(Parent, modelCardId, new ModelCardProgress { Status = "Uploading..." }); + BasicConnectorBindingCommands.SetModelProgress( + Parent, + modelCardId, + new ModelCardProgress { Status = "Uploading..." } + ); string objectId = await Speckle.Core.Api.Operations .Send(commitObject, cts.Token, transports, disposeTransports: true) .ConfigureAwait(true); - - BasicConnectorBindingCommands.SetModelProgress(Parent, modelCardId, new ModelCardProgress { Status = "Linking version to model..." }); - + + BasicConnectorBindingCommands.SetModelProgress( + Parent, + modelCardId, + new ModelCardProgress { Status = "Linking version to model..." } + ); + // 8 - Create the version (commit) var apiClient = new Client(account); - string versionId = await apiClient.CommitCreate(new CommitCreateInput() - { - streamId = model.ProjectId, branchName = model.ModelId, sourceApplication = "Rhino", objectId = objectId - }, cts.Token).ConfigureAwait(true); - + string versionId = await apiClient + .CommitCreate( + new CommitCreateInput() + { + streamId = model.ProjectId, + branchName = model.ModelId, + sourceApplication = "Rhino", + objectId = objectId + }, + cts.Token + ) + .ConfigureAwait(true); + SendBindingUiCommands.SetModelCreatedVersionId(Parent, modelCardId, versionId); apiClient.Dispose(); } @@ -171,7 +187,7 @@ public async void Send(string modelCardId) } public void CancelSend(string modelCardId) => CancellationManager.CancelOperation(modelCardId); - + private Base ConvertObjects( List rhinoObjects, ISpeckleConverter converter, @@ -181,9 +197,9 @@ CancellationTokenSource cts { var modelWithLayers = new Collection { name = RhinoDoc.ActiveDoc.Name }; int count = 0; - + Dictionary layerCollectionCache = new(); - + foreach (RhinoObject rhinoObject in rhinoObjects) { if (cts.IsCancellationRequested) @@ -193,35 +209,43 @@ CancellationTokenSource cts // 1. get object layer var layer = RhinoDoc.ActiveDoc.Layers[rhinoObject.Attributes.LayerIndex]; - + // 2. get or create a nested collection for it var collectionHost = GetAndCreateObjectHostCollection(layerCollectionCache, layer, modelWithLayers); - + // 3. convert var converted = converter.ConvertToSpeckle(rhinoObject); converted.applicationId = rhinoObject.Id.ToString(); - + // 4. add to host collectionHost.elements.Add(converted); - - BasicConnectorBindingCommands.SetModelProgress(Parent, modelCardId, new ModelCardProgress(){ Status = "Converting", Progress = (double)++count / rhinoObjects.Count}); - - // NOTE: useful for testing ui states, pls keep for now so we can easily uncomment - // Thread.Sleep(550); + + BasicConnectorBindingCommands.SetModelProgress( + Parent, + modelCardId, + new ModelCardProgress() { Status = "Converting", Progress = (double)++count / rhinoObjects.Count } + ); + + // NOTE: useful for testing ui states, pls keep for now so we can easily uncomment + // Thread.Sleep(550); } - + // 5. profit return modelWithLayers; } - private Collection GetAndCreateObjectHostCollection(Dictionary layerCollectionCache, Layer layer, Collection modelWithLayers) + private Collection GetAndCreateObjectHostCollection( + Dictionary layerCollectionCache, + Layer layer, + Collection modelWithLayers + ) { if (layerCollectionCache.TryGetValue(layer.Index, out Collection value)) { return value; } - - var names = layer.FullPath.Split(new[] {Layer.PathSeparator}, StringSplitOptions.None); + + var names = layer.FullPath.Split(new[] { Layer.PathSeparator }, StringSplitOptions.None); var path = names[0]; var index = 0; var previousCollection = modelWithLayers; @@ -242,16 +266,16 @@ private Collection GetAndCreateObjectHostCollection(Dictionary previousCollection.elements.Add(childCollection); layerCollectionCache[existingLayerIndex] = childCollection; } - + previousCollection = childCollection; - + if (index < names.Length - 1) { - path += Layer.PathSeparator + names[index+1]; + path += Layer.PathSeparator + names[index + 1]; } index++; } - + layerCollectionCache[layer.Index] = previousCollection; return previousCollection; // var collectionHost = modelLayers.Traverse(m => m is not Collection).FirstOrDefault(obj => (obj as Collection)?.name == layer.Name) as Collection; // works, but it's better with a cache @@ -260,9 +284,12 @@ private Collection GetAndCreateObjectHostCollection(Dictionary private List GetObjectsFromDocument(SenderModelCard model) { List objectsIds = model.SendFilter.GetObjectIds(); - return objectsIds.Select((id) => RhinoDoc.ActiveDoc.Objects.FindId(new Guid(id))).Where(obj => obj!=null).ToList(); + return objectsIds + .Select((id) => RhinoDoc.ActiveDoc.Objects.FindId(new Guid(id))) + .Where(obj => obj != null) + .ToList(); } - + private void RunExpirationChecks() { List senders = _store.GetSenders(); diff --git a/ConnectorRhino/ConnectorRhinoWebUI/Utils/RhinoIdleManager.cs b/ConnectorRhino/ConnectorRhinoWebUI/Utils/RhinoIdleManager.cs index b64ed9d687..608a649df9 100644 --- a/ConnectorRhino/ConnectorRhinoWebUI/Utils/RhinoIdleManager.cs +++ b/ConnectorRhino/ConnectorRhinoWebUI/Utils/RhinoIdleManager.cs @@ -20,7 +20,7 @@ public static class RhinoIdleManager public static void SubscribeToIdle(Action action) { s_sCalls[action.Method.Name] = action; - + if (s_hasSubscribed) { return; diff --git a/DesktopUI3/DUI3/Bindings/IBasicConnectorBinding.cs b/DesktopUI3/DUI3/Bindings/IBasicConnectorBinding.cs index 3067cd6052..b7013d8dc8 100644 --- a/DesktopUI3/DUI3/Bindings/IBasicConnectorBinding.cs +++ b/DesktopUI3/DUI3/Bindings/IBasicConnectorBinding.cs @@ -29,10 +29,10 @@ public static class BasicConnectorBindingCommands private const string SET_MODEL_ERROR_UI_COMMAND_NAME = "setModelError"; public static void NotifyDocumentChanged(IBridge bridge) => bridge.SendToBrowser(NOTIFY_DOCUMENT_CHANGED_EVENT_NAME); - - public static void SetModelProgress(IBridge bridge, string modelCardId, ModelCardProgress progress) => + + public static void SetModelProgress(IBridge bridge, string modelCardId, ModelCardProgress progress) => bridge.SendToBrowser(SET_MODEL_PROGRESS_UI_COMMAND_NAME, new { modelCardId, progress }); - + public static void SetModelError(IBridge bridge, string modelCardId, Exception error) => bridge.SendToBrowser(SET_MODEL_ERROR_UI_COMMAND_NAME, new { modelCardId, error = error.Message }); } diff --git a/DesktopUI3/DUI3/Bindings/IReceiveBinding.cs b/DesktopUI3/DUI3/Bindings/IReceiveBinding.cs index 2ad10e3c89..293f7ce5c1 100644 --- a/DesktopUI3/DUI3/Bindings/IReceiveBinding.cs +++ b/DesktopUI3/DUI3/Bindings/IReceiveBinding.cs @@ -23,10 +23,9 @@ public interface IReceiveBinding : IBinding public static class ReceiveBindingUiCommands { private const string SET_MODEL_RECEIVE_RESULT_UI_COMMAND_NAME = "setModelReceiveResult"; - + public static void SetModelConversionResult(IBridge bridge, string modelCardId, ReceiveResult receiveResult) => bridge.SendToBrowser(SET_MODEL_RECEIVE_RESULT_UI_COMMAND_NAME, new { modelCardId, receiveResult }); - } public class ReceiverModelCard : ModelCard @@ -44,6 +43,6 @@ public class ReceiveResult : DiscriminatedObject public List BakedObjectIds { get; set; } public bool Display { get; set; } = false; - + // TODO/THINK Later: results, reports, etc. ? } diff --git a/DesktopUI3/DUI3/Bindings/ISendBinding.cs b/DesktopUI3/DUI3/Bindings/ISendBinding.cs index 0753e37fe3..aa3c586201 100644 --- a/DesktopUI3/DUI3/Bindings/ISendBinding.cs +++ b/DesktopUI3/DUI3/Bindings/ISendBinding.cs @@ -29,13 +29,12 @@ public static class SendBindingUiCommands private const string SET_MODELS_EXPIRED_UI_COMMAND_NAME = "setModelsExpired"; private const string SET_MODEL_CREATED_VERSION_ID_UI_COMMAND_NAME = "setModelCreatedVersionId"; - public static void RefreshSendFilters(IBridge bridge) => - bridge.SendToBrowser(REFRESH_SEND_FILTERS_UI_COMMAND_NAME); + public static void RefreshSendFilters(IBridge bridge) => bridge.SendToBrowser(REFRESH_SEND_FILTERS_UI_COMMAND_NAME); - public static void SetModelsExpired(IBridge bridge, IEnumerable expiredModelIds) => + public static void SetModelsExpired(IBridge bridge, IEnumerable expiredModelIds) => bridge.SendToBrowser(SET_MODELS_EXPIRED_UI_COMMAND_NAME, expiredModelIds); - public static void SetModelCreatedVersionId(IBridge bridge,string modelCardId, string versionId ) => + public static void SetModelCreatedVersionId(IBridge bridge, string modelCardId, string versionId) => bridge.SendToBrowser(SET_MODEL_CREATED_VERSION_ID_UI_COMMAND_NAME, new { modelCardId, versionId }); } @@ -49,6 +48,7 @@ public interface ISendFilter public string Name { get; set; } public string Summary { get; set; } public bool IsDefault { get; set; } + /// /// Gets the ids of the objects targeted by the filter from the host application. /// diff --git a/DesktopUI3/DUI3/Models/Card/ModelCardProgress.cs b/DesktopUI3/DUI3/Models/Card/ModelCardProgress.cs index e35afd124e..32cffe151c 100644 --- a/DesktopUI3/DUI3/Models/Card/ModelCardProgress.cs +++ b/DesktopUI3/DUI3/Models/Card/ModelCardProgress.cs @@ -13,5 +13,3 @@ public class ModelCardProgress /// public double? Progress { get; set; } } - - diff --git a/DesktopUI3/DUI3/Models/ConversionReport.cs b/DesktopUI3/DUI3/Models/ConversionReport.cs index a96fc4ee64..e50cc9837d 100644 --- a/DesktopUI3/DUI3/Models/ConversionReport.cs +++ b/DesktopUI3/DUI3/Models/ConversionReport.cs @@ -8,7 +8,7 @@ public class ConversionReport /// An overall summary. /// public string Summary { get; set; } - + /// /// Specific reports for sets of objects (e.g., failed conversions, conversion fallbacks, etc. /// @@ -16,11 +16,11 @@ public class ConversionReport public (ReportItem success, ReportItem warning, ReportItem danger) InitializeSuccessWarningDangerReport() { - var success = new ReportItem() { Level = NotificationLevel.Success, Message = "Successful conversions"}; - var warning = new ReportItem() { Level = NotificationLevel.Warning, Message = "Partially successful conversions"}; - var danger = new ReportItem() { Level = NotificationLevel.Danger, Message = "Failed conversions"}; + var success = new ReportItem() { Level = NotificationLevel.Success, Message = "Successful conversions" }; + var warning = new ReportItem() { Level = NotificationLevel.Warning, Message = "Partially successful conversions" }; + var danger = new ReportItem() { Level = NotificationLevel.Danger, Message = "Failed conversions" }; - Items.Add(success); + Items.Add(success); Items.Add(warning); Items.Add(danger); return (success, warning, danger); @@ -33,15 +33,14 @@ public class ReportItem /// A short message. /// public string Message { get; set; } - + /// - /// Warning, Info, Success, Danger - etc. Use the NotificationLevel class. + /// Warning, Info, Success, Danger - etc. Use the NotificationLevel class. /// public string Level { get; set; } - + /// /// The affected objects. /// public List ObjectIds { get; set; } = new(); - } diff --git a/DesktopUI3/DUI3/Operations/Operations.cs b/DesktopUI3/DUI3/Operations/Operations.cs index 2d129b750e..46b4389a8d 100644 --- a/DesktopUI3/DUI3/Operations/Operations.cs +++ b/DesktopUI3/DUI3/Operations/Operations.cs @@ -15,20 +15,18 @@ namespace DUI3.Operations; public static class Operations { - public static async Task GetCommitBase( - IBridge parent, - ReceiverModelCard modelCard, - CancellationToken token - ) + public static async Task GetCommitBase(IBridge parent, ReceiverModelCard modelCard, CancellationToken token) { Account account = Accounts.GetAccount(modelCard.AccountId); Client client = new(account); - Commit version = await client.CommitGet(modelCard.ProjectId, modelCard.SelectedVersionId, token).ConfigureAwait(false); + Commit version = await client + .CommitGet(modelCard.ProjectId, modelCard.SelectedVersionId, token) + .ConfigureAwait(false); Base commitObject = await ReceiveCommit(account, modelCard.ProjectId, version.referencedObject, parent, token) .ConfigureAwait(true); - + client.Dispose(); return commitObject; } @@ -51,7 +49,9 @@ CancellationToken token using ServerTransport transport = new(account, projectId); Base? commitObject = - await Speckle.Core.Api.Operations.Receive(referencedObjectId, cancellationToken: token, remoteTransport: transport).ConfigureAwait(false) + await Speckle.Core.Api.Operations + .Receive(referencedObjectId, cancellationToken: token, remoteTransport: transport) + .ConfigureAwait(false) ?? throw new SpeckleException( $"Failed to receive commit: {referencedObjectId} objects from server: {nameof(Speckle.Core.Api.Operations)} returned null" ); diff --git a/DesktopUI3/DUI3/Utils/Traversal.cs b/DesktopUI3/DUI3/Utils/Traversal.cs index bf670fe692..f472b4731d 100644 --- a/DesktopUI3/DUI3/Utils/Traversal.cs +++ b/DesktopUI3/DUI3/Utils/Traversal.cs @@ -20,18 +20,21 @@ public static List GetObjectsToConvert(Base commitObject, ISpeckleConverte .Reverse() .ToList(); } - + /// /// A variation of the OG Traversal extension from Alan, but with tracking the object path as well. /// /// /// /// - public static IEnumerable<(List,Base)> TraverseWithPath(this Base root, BaseExtensions.BaseRecursionBreaker recursionBreaker) + public static IEnumerable<(List, Base)> TraverseWithPath( + this Base root, + BaseExtensions.BaseRecursionBreaker recursionBreaker + ) { - var stack = new Stack<(List,Base)>(); + var stack = new Stack<(List, Base)>(); stack.Push((new List(), root)); - + while (stack.Count > 0) { (List path, Base current) = stack.Pop(); @@ -84,7 +87,7 @@ public static List GetObjectsToConvert(Base commitObject, ISpeckleConverte } } } - + /// /// Utility function to flatten a conversion result that might have nested lists of objects. /// This happens, for example, in the case of multiple display value fallbacks for a given object. From d403210f926c64f71310d5f225758d443e11c847 Mon Sep 17 00:00:00 2001 From: Alan Rynne Date: Thu, 14 Mar 2024 17:52:51 +0100 Subject: [PATCH 004/261] chore: Delete yarn.lock files and ignore always --- .gitignore | 2 ++ DesktopUI3/DUI3/yarn.lock | 4 ---- DesktopUI3/yarn.lock | 4 ---- 3 files changed, 2 insertions(+), 8 deletions(-) delete mode 100644 DesktopUI3/DUI3/yarn.lock delete mode 100644 DesktopUI3/yarn.lock diff --git a/.gitignore b/.gitignore index 86ceee4974..80e3955846 100644 --- a/.gitignore +++ b/.gitignore @@ -377,3 +377,5 @@ ConnectorNavisworks/ConnectorNavisworks/Sample Models ConnectorArchicad/AddOn/Build* **/dist/ + +**/yarn.lock diff --git a/DesktopUI3/DUI3/yarn.lock b/DesktopUI3/DUI3/yarn.lock deleted file mode 100644 index fb57ccd13a..0000000000 --- a/DesktopUI3/DUI3/yarn.lock +++ /dev/null @@ -1,4 +0,0 @@ -# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. -# yarn lockfile v1 - - diff --git a/DesktopUI3/yarn.lock b/DesktopUI3/yarn.lock deleted file mode 100644 index fb57ccd13a..0000000000 --- a/DesktopUI3/yarn.lock +++ /dev/null @@ -1,4 +0,0 @@ -# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. -# yarn lockfile v1 - - From 32749dd4972b04786a77dc2cb4b447f6ec0d2adf Mon Sep 17 00:00:00 2001 From: Alan Rynne Date: Thu, 14 Mar 2024 21:00:04 +0100 Subject: [PATCH 005/261] chore: Reformat files --- .../Bindings/SendBinding.cs | 49 ++++++---- .../Bindings/BasicConnectorBindingRevit.cs | 10 +- .../RevitDUI3Shared/Bindings/Filters.cs | 1 - .../RevitDUI3Shared/Bindings/SendBinding.cs | 49 ++++++---- .../RevitDUI3Shared/Utils/PortedOverStuff.cs | 2 - .../Bindings/SendBinding.cs | 96 +++++++++++++------ Core/Core/Models/Extras.cs | 4 +- .../Serialisation/BaseObjectSerializerV2.cs | 31 +++--- DesktopUI3/DUI3/Operations/Send.cs | 35 ++++--- 9 files changed, 175 insertions(+), 102 deletions(-) diff --git a/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Bindings/SendBinding.cs b/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Bindings/SendBinding.cs index 7619b2fa17..3fc26997e2 100644 --- a/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Bindings/SendBinding.cs +++ b/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Bindings/SendBinding.cs @@ -34,12 +34,12 @@ public class SendBinding : ISendBinding, ICancelable /// Used internally to aggregate the changed objects' id. /// private HashSet ChangedObjectIds { get; set; } = new(); + /// /// Keeps track of previously converted objects as a dictionary of (applicationId, object reference). /// private readonly Dictionary _convertedObjectReferences = new(); - public SendBinding(AutocadDocumentModelStore store) { _store = store; @@ -109,11 +109,13 @@ private async void SendInternal(string modelCardId) // 7 - Serialize and Send objects var transport = new ServerTransport(account, modelCard.ProjectId); - BasicConnectorBindingCommands.SetModelProgress(Parent, modelCardId, new ModelCardProgress { Status = "Uploading..." }); - var sendResult = await SendHelper - .Send(commitObject, transport, true, null, cts.Token) - .ConfigureAwait(true); - + BasicConnectorBindingCommands.SetModelProgress( + Parent, + modelCardId, + new ModelCardProgress { Status = "Uploading..." } + ); + var sendResult = await SendHelper.Send(commitObject, transport, true, null, cts.Token).ConfigureAwait(true); + // Store the converted references in memory for future send operations, overwriting the existing values for the given application id. foreach (var kvp in sendResult.convertedReferences) { @@ -121,7 +123,7 @@ private async void SendInternal(string modelCardId) } // It's important to reset the model card's list of changed obj ids so as to ensure we accurately keep track of changes between send operations. modelCard.ChangedObjectIds = new(); - + if (cts.IsCancellationRequested) { throw new OperationCanceledException(cts.Token); @@ -136,11 +138,19 @@ private async void SendInternal(string modelCardId) // 8 - Create the version (commit) var apiClient = new Client(account); - string versionId = await apiClient.CommitCreate(new CommitCreateInput() - { - streamId = modelCard.ProjectId, branchName = modelCard.ModelId, sourceApplication = "Rhino", objectId = sendResult.rootObjId - }, cts.Token).ConfigureAwait(true); - + string versionId = await apiClient + .CommitCreate( + new CommitCreateInput() + { + streamId = modelCard.ProjectId, + branchName = modelCard.ModelId, + sourceApplication = "Rhino", + objectId = sendResult.rootObjId + }, + cts.Token + ) + .ConfigureAwait(true); + SendBindingUiCommands.SetModelCreatedVersionId(Parent, modelCardId, versionId); apiClient.Dispose(); } @@ -203,8 +213,11 @@ CancellationTokenSource cts { Base converted; var applicationId = tuple.applicationId; - - if (!modelCard.ChangedObjectIds.Contains(applicationId) && _convertedObjectReferences.TryGetValue(applicationId + modelCard.ProjectId, out ObjectReference value)) + + if ( + !modelCard.ChangedObjectIds.Contains(applicationId) + && _convertedObjectReferences.TryGetValue(applicationId + modelCard.ProjectId, out ObjectReference value) + ) { converted = value; } @@ -222,8 +235,12 @@ CancellationTokenSource cts } collectionCache[tuple.layer].elements.Add(converted); - - BasicConnectorBindingCommands.SetModelProgress(Parent, modelCard.ModelCardId, new ModelCardProgress() { Status = "Converting", Progress = (double)++count / dbObjects.Count}); + + BasicConnectorBindingCommands.SetModelProgress( + Parent, + modelCard.ModelCardId, + new ModelCardProgress() { Status = "Converting", Progress = (double)++count / dbObjects.Count } + ); } catch (Exception e) when (!e.IsFatal()) { diff --git a/ConnectorRevit/RevitDUI3/RevitDUI3Shared/Bindings/BasicConnectorBindingRevit.cs b/ConnectorRevit/RevitDUI3/RevitDUI3Shared/Bindings/BasicConnectorBindingRevit.cs index bf4db61c2e..dcaec00fde 100644 --- a/ConnectorRevit/RevitDUI3/RevitDUI3Shared/Bindings/BasicConnectorBindingRevit.cs +++ b/ConnectorRevit/RevitDUI3/RevitDUI3Shared/Bindings/BasicConnectorBindingRevit.cs @@ -93,13 +93,17 @@ public void HighlightModel(string modelCardId) var senderModelCard = _store.GetModelById(modelCardId) as SenderModelCard; var elementIds = senderModelCard.SendFilter.GetObjectIds().Select(ElementId.Parse).ToList(); - + if (elementIds.Count == 0) { - BasicConnectorBindingCommands.SetModelError(Parent, modelCardId, new OperationCanceledException("No objects found to highlight.") ); + BasicConnectorBindingCommands.SetModelError( + Parent, + modelCardId, + new OperationCanceledException("No objects found to highlight.") + ); return; } - + RevitTask.RunAsync(() => { UiDocument.Selection.SetElementIds(elementIds); diff --git a/ConnectorRevit/RevitDUI3/RevitDUI3Shared/Bindings/Filters.cs b/ConnectorRevit/RevitDUI3/RevitDUI3Shared/Bindings/Filters.cs index bd03a1c72b..02fda2e8e8 100644 --- a/ConnectorRevit/RevitDUI3/RevitDUI3Shared/Bindings/Filters.cs +++ b/ConnectorRevit/RevitDUI3/RevitDUI3Shared/Bindings/Filters.cs @@ -9,7 +9,6 @@ public class RevitEverythingFilter : EverythingSendFilter { public override List GetObjectIds() { - return new List(); } diff --git a/ConnectorRevit/RevitDUI3/RevitDUI3Shared/Bindings/SendBinding.cs b/ConnectorRevit/RevitDUI3/RevitDUI3Shared/Bindings/SendBinding.cs index a84c40d7fe..a36284eb33 100644 --- a/ConnectorRevit/RevitDUI3/RevitDUI3Shared/Bindings/SendBinding.cs +++ b/ConnectorRevit/RevitDUI3/RevitDUI3Shared/Bindings/SendBinding.cs @@ -37,11 +37,12 @@ public class SendBinding : ISendBinding, ICancelable /// Used internally to aggregate the changed objects' id. /// private HashSet ChangedObjectIds { get; set; } = new(); + /// /// Keeps track of previously converted objects as a dictionary of (applicationId, object reference). /// private readonly Dictionary _convertedObjectReferences = new(); - + /// /// Thingie we ported from the DUI2 Era. /// @@ -51,14 +52,14 @@ public SendBinding(RevitDocumentStore store) { s_revitApp = RevitAppProvider.RevitApp; _store = store; - + s_revitApp.Application.DocumentChanged += (_, e) => StoreChangedElementIdsAndScheduleExpiryCheck(e); revitDocumentAggregateCache = new RevitDocumentAggregateCache(new UIDocumentProvider(s_revitApp)); } public List GetSendFilters() { - return new List { new RevitSelectionFilter() {IsDefault = true} }; + return new List { new RevitSelectionFilter() { IsDefault = true } }; } private Base ConvertElements( @@ -118,7 +119,7 @@ public async void Send(string modelCardId) elements.Add(el); } } - + if (elements.Count == 0) { throw new InvalidOperationException("No objects were found. Please update your send filter!"); @@ -127,7 +128,7 @@ public async void Send(string modelCardId) // 4 - Get converter ISpeckleConverter converter = Converters.GetConverter(Doc, RevitAppProvider.Version()); converter.SetContextDocument(revitDocumentAggregateCache); - + // 5 - Convert objects Base commitObject = ConvertElements(elements, converter, modelCard, cts); @@ -135,7 +136,7 @@ public async void Send(string modelCardId) { throw new OperationCanceledException(cts.Token); } - + // 7 - Serialize and Send objects BasicConnectorBindingCommands.SetModelProgress( Parent, @@ -184,7 +185,7 @@ public async void Send(string modelCardId) } public void CancelSend(string modelCardId) => CancellationManager.CancelOperation(modelCardId); - + private Base ConvertElements( List elements, ISpeckleConverter converter, @@ -195,7 +196,7 @@ CancellationTokenSource cts int count = 0; var rootObject = new Collection { name = Doc.PathName.Split('\\').Reverse().First().Split('.').First() }; var collectionCache = new Dictionary(); - + foreach (var revitElement in elements) { if (cts.IsCancellationRequested) @@ -205,7 +206,7 @@ CancellationTokenSource cts var cat = revitElement.Category.Name; var level = Doc.GetElement(revitElement.LevelId) as Level; - var path = new[] { level == null ? "No level": level.Name, cat }; + var path = new[] { level == null ? "No level" : level.Name, cat }; var collection = GetAndCreateObjectHostCollection(path, collectionCache, rootObject); count++; @@ -213,7 +214,10 @@ CancellationTokenSource cts { Base converted; var applicationId = revitElement.Id.ToString(); - if (!modelCard.ChangedObjectIds.Contains(applicationId) && _convertedObjectReferences.TryGetValue(applicationId + modelCard.ProjectId, out ObjectReference value)) + if ( + !modelCard.ChangedObjectIds.Contains(applicationId) + && _convertedObjectReferences.TryGetValue(applicationId + modelCard.ProjectId, out ObjectReference value) + ) { converted = value; } @@ -222,39 +226,46 @@ CancellationTokenSource cts converted = converter.ConvertToSpeckle(revitElement); converted.applicationId = applicationId; } - + collection.elements.Add(converted); - BasicConnectorBindingCommands.SetModelProgress(Parent, modelCard.ModelCardId, new ModelCardProgress() { Status = "Converting", Progress = (double)count / elements.Count }); + BasicConnectorBindingCommands.SetModelProgress( + Parent, + modelCard.ModelCardId, + new ModelCardProgress() { Status = "Converting", Progress = (double)count / elements.Count } + ); } catch (Exception e) { // TODO: Add to report, etc. Debug.WriteLine(e.Message); } - } return rootObject; } /// /// Creates and nests collections based on the provided path within the root collection provided. This will not return a new collection each time is called, but an existing one if one is found. - /// For example, you can use this to use (or re-use) a new collection for a path of (level, category) as it's currently implemented. + /// For example, you can use this to use (or re-use) a new collection for a path of (level, category) as it's currently implemented. /// /// /// /// /// - private Collection GetAndCreateObjectHostCollection(IEnumerable path, Dictionary cache, Collection root) + private Collection GetAndCreateObjectHostCollection( + IEnumerable path, + Dictionary cache, + Collection root + ) { string fullPathName = string.Join("", path); if (cache.TryGetValue(fullPathName, out Collection value)) { return value; } - + string flatPathName = ""; Collection previousCollection = root; - + foreach (var pathItem in path) { flatPathName += pathItem; @@ -275,7 +286,7 @@ private Collection GetAndCreateObjectHostCollection(IEnumerable path, Di return previousCollection; } - + /// /// Keeps track of the changed element ids as well as checks if any of them need to trigger /// a filter refresh (e.g., views being added). @@ -312,7 +323,7 @@ private void RunExpirationChecks() List senders = _store.GetSenders(); List expiredSenderIds = new(); string[] objectIdsList = ChangedObjectIds.ToArray(); - + foreach (var modelCard in senders) { var intersection = modelCard.SendFilter.GetObjectIds().Intersect(objectIdsList).ToList(); diff --git a/ConnectorRevit/RevitDUI3/RevitDUI3Shared/Utils/PortedOverStuff.cs b/ConnectorRevit/RevitDUI3/RevitDUI3Shared/Utils/PortedOverStuff.cs index b73fb7aa5a..8bcada0259 100644 --- a/ConnectorRevit/RevitDUI3/RevitDUI3Shared/Utils/PortedOverStuff.cs +++ b/ConnectorRevit/RevitDUI3/RevitDUI3Shared/Utils/PortedOverStuff.cs @@ -32,8 +32,6 @@ public UI.UIDocument Entity } } - - /// /// Simple conversion cache to store elements that are retrieved and may be needed again throughout the conversion operation /// diff --git a/ConnectorRhino/ConnectorRhinoWebUI/Bindings/SendBinding.cs b/ConnectorRhino/ConnectorRhinoWebUI/Bindings/SendBinding.cs index fc2ee1d98c..10509c6d63 100644 --- a/ConnectorRhino/ConnectorRhinoWebUI/Bindings/SendBinding.cs +++ b/ConnectorRhino/ConnectorRhinoWebUI/Bindings/SendBinding.cs @@ -28,11 +28,12 @@ public class SendBinding : ISendBinding, ICancelable public IBridge Parent { get; set; } private readonly DocumentModelStore _store; public CancellationManager CancellationManager { get; } = new(); - + /// /// Used internally to aggregate the changed objects' id. /// private HashSet ChangedObjectIds { get; set; } = new(); + /// /// Keeps track of previously converted objects as a dictionary of (applicationId, object reference). /// @@ -126,7 +127,11 @@ public async void Send(string modelCardId) Account account = Accounts.GetAccount(modelCard.AccountId); // 3 - Get elements to convert, throw early if nothing is selected - List rhinoObjects = modelCard.SendFilter.GetObjectIds().Select(id => RhinoDoc.ActiveDoc.Objects.FindId(new Guid(id))).Where(obj => obj!=null).ToList(); + List rhinoObjects = modelCard.SendFilter + .GetObjectIds() + .Select(id => RhinoDoc.ActiveDoc.Objects.FindId(new Guid(id))) + .Where(obj => obj != null) + .ToList(); if (rhinoObjects.Count == 0) { @@ -135,7 +140,7 @@ public async void Send(string modelCardId) // 4 - Get converter ISpeckleConverter converter = Converters.GetConverter(RhinoDoc.ActiveDoc, "Rhino7"); - + // 5 - Convert objects Base commitObject = ConvertObjects(rhinoObjects, converter, modelCard, cts); @@ -143,34 +148,48 @@ public async void Send(string modelCardId) { throw new OperationCanceledException(cts.Token); } - + // 7 - Serialize and Send objects - BasicConnectorBindingCommands.SetModelProgress(Parent, modelCardId, new ModelCardProgress { Status = "Uploading..." }); + BasicConnectorBindingCommands.SetModelProgress( + Parent, + modelCardId, + new ModelCardProgress { Status = "Uploading..." } + ); var transport = new ServerTransport(account, modelCard.ProjectId); - var sendResult = await SendHelper - .Send(commitObject, transport, true, null, cts.Token) - .ConfigureAwait(true); + var sendResult = await SendHelper.Send(commitObject, transport, true, null, cts.Token).ConfigureAwait(true); // Store the converted references in memory for future send operations, overwriting the existing values for the given application id. foreach (var kvp in sendResult.convertedReferences) { // TODO: Bug in here, we need to encapsulate cache not only by app id, but also by project id, - // TODO: as otherwise we assume incorrectly that an object exists for a given project (e.g, send box to project 1, send same unchanged box to project 2) + // TODO: as otherwise we assume incorrectly that an object exists for a given project (e.g, send box to project 1, send same unchanged box to project 2) _convertedObjectReferences[kvp.Key + modelCard.ProjectId] = kvp.Value; } // It's important to reset the model card's list of changed obj ids so as to ensure we accurately keep track of changes between send operations. // NOTE: ChangedObjectIds is currently JsonIgnored, but could actually be useful for highlighting changes in host app. modelCard.ChangedObjectIds = new(); - - BasicConnectorBindingCommands.SetModelProgress(Parent, modelCardId, new ModelCardProgress { Status = "Linking version to model..." }); - + + BasicConnectorBindingCommands.SetModelProgress( + Parent, + modelCardId, + new ModelCardProgress { Status = "Linking version to model..." } + ); + // 8 - Create the version (commit) var apiClient = new Client(account); - string versionId = await apiClient.CommitCreate(new CommitCreateInput() - { - streamId = modelCard.ProjectId, branchName = modelCard.ModelId, sourceApplication = "Rhino", objectId = sendResult.rootObjId - }, cts.Token).ConfigureAwait(true); - + string versionId = await apiClient + .CommitCreate( + new CommitCreateInput() + { + streamId = modelCard.ProjectId, + branchName = modelCard.ModelId, + sourceApplication = "Rhino", + objectId = sendResult.rootObjId + }, + cts.Token + ) + .ConfigureAwait(true); + SendBindingUiCommands.SetModelCreatedVersionId(Parent, modelCardId, versionId); apiClient.Dispose(); } @@ -186,7 +205,13 @@ public async void Send(string modelCardId) } public void CancelSend(string modelCardId) => CancellationManager.CancelOperation(modelCardId); - private Base ConvertObjects(List rhinoObjects, ISpeckleConverter converter, SenderModelCard modelCard, CancellationTokenSource cts) + + private Base ConvertObjects( + List rhinoObjects, + ISpeckleConverter converter, + SenderModelCard modelCard, + CancellationTokenSource cts + ) { var rootObjectCollection = new Collection { name = RhinoDoc.ActiveDoc.Name ?? "Unnamed document" }; int count = 0; @@ -206,12 +231,15 @@ private Base ConvertObjects(List rhinoObjects, ISpeckleConverter co // 2. get or create a nested collection for it var collectionHost = GetHostObjectCollection(layerCollectionCache, layer, rootObjectCollection); var applicationId = rhinoObject.Id.ToString(); - - // 3. get from cache or convert: + + // 3. get from cache or convert: // What we actually do here is check if the object has been previously converted AND has not changed. - // If that's the case, we insert in the host collection just its object reference which has been saved from the prior conversion. + // If that's the case, we insert in the host collection just its object reference which has been saved from the prior conversion. Base converted; - if (!modelCard.ChangedObjectIds.Contains(applicationId) && _convertedObjectReferences.TryGetValue(applicationId + modelCard.ProjectId, out ObjectReference value)) + if ( + !modelCard.ChangedObjectIds.Contains(applicationId) + && _convertedObjectReferences.TryGetValue(applicationId + modelCard.ProjectId, out ObjectReference value) + ) { converted = value; } @@ -220,19 +248,23 @@ private Base ConvertObjects(List rhinoObjects, ISpeckleConverter co converted = converter.ConvertToSpeckle(rhinoObject); converted.applicationId = applicationId; } - + // 4. add to host collectionHost.elements.Add(converted); - BasicConnectorBindingCommands.SetModelProgress(Parent, modelCard.ModelCardId, new ModelCardProgress(){ Status = "Converting", Progress = (double)++count / rhinoObjects.Count}); - - // NOTE: useful for testing ui states, pls keep for now so we can easily uncomment - // Thread.Sleep(550); + BasicConnectorBindingCommands.SetModelProgress( + Parent, + modelCard.ModelCardId, + new ModelCardProgress() { Status = "Converting", Progress = (double)++count / rhinoObjects.Count } + ); + + // NOTE: useful for testing ui states, pls keep for now so we can easily uncomment + // Thread.Sleep(550); } // 5. profit return rootObjectCollection; } - + /// /// Returns the host collection based on the provided layer. If it's not found, it will be created and hosted within the the rootObjectCollection. /// @@ -240,7 +272,11 @@ private Base ConvertObjects(List rhinoObjects, ISpeckleConverter co /// /// /// - private Collection GetHostObjectCollection(Dictionary layerCollectionCache, Layer layer, Collection rootObjectCollection) + private Collection GetHostObjectCollection( + Dictionary layerCollectionCache, + Layer layer, + Collection rootObjectCollection + ) { if (layerCollectionCache.TryGetValue(layer.Index, out Collection value)) { @@ -281,7 +317,7 @@ private Collection GetHostObjectCollection(Dictionary layerColl layerCollectionCache[layer.Index] = previousCollection; return previousCollection; } - + /// /// Checks if any sender model cards contain any of the changed objects. If so, also updates the changed objects hashset for each model card - this last part is important for on send change detection. /// diff --git a/Core/Core/Models/Extras.cs b/Core/Core/Models/Extras.cs index 79006ad9df..371d97b6d2 100644 --- a/Core/Core/Models/Extras.cs +++ b/Core/Core/Models/Extras.cs @@ -64,8 +64,8 @@ public class ObjectReference : Base public new string speckle_type = "reference"; public string referencedId { get; set; } - - public Dictionary closure { get; set; } + + public Dictionary closure { get; set; } } public class ProgressEventArgs : EventArgs diff --git a/Core/Core/Serialisation/BaseObjectSerializerV2.cs b/Core/Core/Serialisation/BaseObjectSerializerV2.cs index 88dfa48855..5e63b5ec25 100644 --- a/Core/Core/Serialisation/BaseObjectSerializerV2.cs +++ b/Core/Core/Serialisation/BaseObjectSerializerV2.cs @@ -27,12 +27,13 @@ public class BaseObjectSerializerV2 private readonly Action? _onProgressAction; private readonly bool _trackDetachedChildren; + /// /// Keeps track of all detached children created during serialisation that have an applicationId (provided this serializer instance has been told to track detached children). /// This is currently used to cache previously converted objects and avoid their conversion if they haven't changed. See the DUI3 send bindings in rhino or another host app. /// - public Dictionary ObjectReferences { get; } = new (); - + public Dictionary ObjectReferences { get; } = new(); + /// The sync transport. This transport will be used synchronously. public IReadOnlyCollection WriteTransports { get; } @@ -128,12 +129,18 @@ public string Serialize(Base baseObj) switch (obj) { // Start with object references so they're not captured by the Base class case below - // Note: this change was needed as we've made the ObjectReference type inherit from Base for + // Note: this change was needed as we've made the ObjectReference type inherit from Base for // the purpose of the "do not convert unchanged previously converted objects" POC. case ObjectReference r: { - Dictionary ret = new() { ["speckle_type"] = r.speckle_type, ["referencedId"] = r.referencedId, ["__closure"] = r.closure }; - if(r.closure is not null) + Dictionary ret = + new() + { + ["speckle_type"] = r.speckle_type, + ["referencedId"] = r.referencedId, + ["__closure"] = r.closure + }; + if (r.closure is not null) { foreach (var kvp in r.closure) { @@ -231,7 +238,7 @@ public string Serialize(Base baseObj) throw new ArgumentException($"Unsupported value in serialization: {obj.GetType()}"); } } - + public IDictionary? PreserializeBase( Base baseObj, bool computeClosures = false, @@ -328,19 +335,21 @@ public string Serialize(Base baseObj) string id = (string)convertedBase["id"]!; StoreObject(id, json); ObjectReference objRef = new() { referencedId = id }; - var objRefConverted = (IDictionary?) PreserializeObject(objRef); + var objRefConverted = (IDictionary?)PreserializeObject(objRef); UpdateParentClosures(id); _onProgressAction?.Invoke("S", 1); - - // add to obj refs to return + + // add to obj refs to return if (baseObj.applicationId != null && _trackDetachedChildren) // && baseObj is not DataChunk && baseObj is not Abstract) // not needed, as data chunks will never have application ids, and abstract objs are not really used. { ObjectReferences[baseObj.applicationId] = new ObjectReference() { - referencedId = id, applicationId = baseObj.applicationId, closure = closure + referencedId = id, + applicationId = baseObj.applicationId, + closure = closure }; } - + return objRefConverted; } return convertedBase; diff --git a/DesktopUI3/DUI3/Operations/Send.cs b/DesktopUI3/DUI3/Operations/Send.cs index ad91c9a3eb..60273ef5db 100644 --- a/DesktopUI3/DUI3/Operations/Send.cs +++ b/DesktopUI3/DUI3/Operations/Send.cs @@ -16,11 +16,10 @@ namespace DUI3.Operations; /// -/// NOTE: Contains copy pasted code from the OG Send operations in Core (the non-obsolete ones). +/// NOTE: Contains copy pasted code from the OG Send operations in Core (the non-obsolete ones). /// public static class SendHelper { - /// /// IMPORTANT: Copy pasted function from Operations.Send in Core, but this time returning the converted references from the serializer. /// Sends a Speckle Object to the provided and (optionally) the default local cache @@ -33,7 +32,7 @@ public static class SendHelper /// using ServerTransport destination = new(account, streamId); /// string objectId = await Send(mySpeckleObject, destination, true); /// - public static async Task<(string rootObjId, Dictionary convertedReferences)> Send( + public static async Task<(string rootObjId, Dictionary convertedReferences)> Send( Base value, ITransport transport, bool useDefaultCache, @@ -55,11 +54,11 @@ public static class SendHelper return await Send(value, transports, onProgressAction, cancellationToken).ConfigureAwait(false); } - + /// /// IMPORTANT: Copy pasted function from Operations.Send in Core, but this time returning the converted references from the serializer. /// It's marked as private as DUI3 only uses the one above. - /// Note that this should be structured better in the future - this is here to minimise core changes coming from DUI3. + /// Note that this should be structured better in the future - this is here to minimise core changes coming from DUI3. /// /// /// @@ -73,7 +72,8 @@ public static class SendHelper Base value, IReadOnlyCollection transports, Action>? onProgressAction = null, - CancellationToken cancellationToken = default) + CancellationToken cancellationToken = default + ) { if (value is null) { @@ -96,7 +96,8 @@ public static class SendHelper var internalProgressAction = GetInternalProgressAction(onProgressAction); - BaseObjectSerializerV2 serializerV2 = new(transports, internalProgressAction, trackDetachedChildren: true, cancellationToken); + BaseObjectSerializerV2 serializerV2 = + new(transports, internalProgressAction, trackDetachedChildren: true, cancellationToken); foreach (var t in transports) { @@ -105,7 +106,7 @@ public static class SendHelper t.BeginWrite(); } - (string rootObjId, Dictionary) serializerReturnValue; + (string rootObjId, Dictionary) serializerReturnValue; try { serializerReturnValue = await SerializerSend(value, serializerV2, cancellationToken).ConfigureAwait(false); @@ -146,12 +147,11 @@ public static class SendHelper return serializerReturnValue; } } - - internal static async Task<(string rootObjectId, Dictionary convertedReferences)> SerializerSend( - Base value, - BaseObjectSerializerV2 serializer, - CancellationToken cancellationToken = default - ) + + internal static async Task<( + string rootObjectId, + Dictionary convertedReferences + )> SerializerSend(Base value, BaseObjectSerializerV2 serializer, CancellationToken cancellationToken = default) { string obj = serializer.Serialize(value); Task[] transportAwaits = serializer.WriteTransports.Select(t => t.WriteComplete()).ToArray(); @@ -162,15 +162,15 @@ public static class SendHelper var parsed = JObject.Parse(obj); JToken? idToken = parsed.GetValue("id"); - + if (idToken == null) { throw new SpeckleException("Failed to get id of serialized object"); } - + return (idToken.ToString(), serializer.ObjectReferences); } - + /// /// Factory for progress actions used internally inside send and receive methods. /// @@ -197,5 +197,4 @@ public static class SendHelper onProgressAction.Invoke(localProgressDict); }; } - } From c42f53c8bcc3dd58a20e39c95953b0d1b87e7709 Mon Sep 17 00:00:00 2001 From: Alan Rynne Date: Thu, 14 Mar 2024 21:15:30 +0100 Subject: [PATCH 006/261] fix(ci): Revert changes to ConnectorRhino.slnf --- ConnectorRhino/ConnectorRhino.slnf | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/ConnectorRhino/ConnectorRhino.slnf b/ConnectorRhino/ConnectorRhino.slnf index 4e9da1d6a1..2b79cebc61 100644 --- a/ConnectorRhino/ConnectorRhino.slnf +++ b/ConnectorRhino/ConnectorRhino.slnf @@ -7,18 +7,15 @@ "ConnectorGrasshopper\\ConnectorGrasshopper8\\ConnectorGrasshopper8.csproj", "ConnectorGrasshopper\\ConnectorGrasshopperShared\\ConnectorGrasshopperShared.shproj", "ConnectorGrasshopper\\ConnectorGrasshopperUtils\\ConnectorGrasshopperUtils.csproj", - "ConnectorRhino\\ConnectorRhino\\ConnectorRhinoShared\\ConnectorRhinoShared.shproj", "ConnectorRhino\\ConnectorRhino6\\ConnectorRhino6.csproj", "ConnectorRhino\\ConnectorRhino7\\ConnectorRhino7.csproj", "ConnectorRhino\\ConnectorRhino8\\ConnectorRhino8.csproj", - "ConnectorRhino\\ConnectorRhinoWebUI\\ConnectorRhinoWebUI.csproj", "Core\\Core\\Core.csproj", "Core\\Tests\\Speckle.Core.Tests.Unit\\Speckle.Core.Tests.Unit.csproj", "Core\\Transports\\DiskTransport\\DiskTransport.csproj", "Core\\Transports\\MongoDBTransport\\MongoDBTransport.csproj", "DesktopUI2\\AvaloniaHwndHost\\AvaloniaHwndHost.csproj", "DesktopUI2\\DesktopUI2\\DesktopUI2.csproj", - "DesktopUI3\\DUI3\\DUI3.csproj", "Objects\\Converters\\ConverterRhinoGh\\ConverterGrasshopper6\\ConverterGrasshopper6.csproj", "Objects\\Converters\\ConverterRhinoGh\\ConverterGrasshopper7\\ConverterGrasshopper7.csproj", "Objects\\Converters\\ConverterRhinoGh\\ConverterGrasshopper8\\ConverterGrasshopper8.csproj", @@ -30,4 +27,4 @@ "Objects\\Tests\\Objects.Tests.Unit\\Objects.Tests.Unit.csproj" ] } -} \ No newline at end of file +} From 7eabc76e7f665f16e455bf86deed61a07a05da6a Mon Sep 17 00:00:00 2001 From: Jedd Morgan <45512892+JR-Morgan@users.noreply.github.com> Date: Fri, 15 Mar 2024 15:49:17 +0000 Subject: [PATCH 007/261] Restructured DUI3 projects + enforced warnings for new projects (#3231) * Restructured DUI3 projects + enforced warnings for new projects * slnf --- All.sln | 128 ++++---- .../Speckle.Connectors.Revit2023.csproj | 276 +++--------------- .../Bindings/BasicConnectorBindingRevit.cs | 4 - .../Bindings/ReceiveBinding.cs | 11 - .../Bindings/RevitBaseBinding.cs | 3 - .../Bindings/SelectionBinding.cs | 1 - .../Bindings/SendBinding.cs | 10 - .../DependencyInjection/AutofacUIModule.cs | 2 - .../Plugin/CefSharpPanel.xaml.cs | 1 - .../Plugin/IRevitIdleManager.cs | 4 - .../Plugin/IRevitPlugin.cs | 5 - .../Plugin/RevitCommand.cs | 2 - .../Plugin/RevitContext.cs | 29 +- .../Plugin/RevitExternalApplication.cs | 11 +- .../Plugin/RevitPlugin.cs | 7 - .../Plugin/RevitSettings.cs | 6 - .../AutofacRevitConverterModule.cs | 3 +- ...rters.Revit2023.DependencyInjection.csproj | 6 +- .../Speckle.Converters.Revit2023.csproj | 7 +- .../RevitConverterToSpeckle.cs | 3 +- .../Speckle.Connectors.DUI.csproj | 12 +- CNX-8892/Directory.Build.Props | 11 + .../Speckle.Objects.Common.csproj | 4 + .../DependencyInjection/AutofacContainer.cs | 4 +- .../DependencyInjection/Factory.cs | 19 ++ .../DependencyInjection/IFactory.cs | 6 +- .../DependencyInjection/IScopedFactory.cs | 0 .../NameAndRankValueAttribute.cs | 0 .../DependencyInjection/NamedTypeInjector.cs | 0 .../DependencyInjection/ScopedFactory.cs | 0 .../Speckle.Autofac/Files/IStorageInfo.cs | 0 .../Speckle.Autofac/Files/StorageInfo.cs | 0 .../Speckle.Autofac/GlobalSuppressions.cs | 0 .../Speckle.Autofac/Speckle.Autofac.csproj | 5 +- .../Cancellation/CancellationManager.cs | 0 .../Cancellation/ICancelable.cs | 0 .../Reflection/AssemblyExtensions.cs | 4 +- .../Speckle.Connectors.Utils.csproj | 7 +- .../SpeckleTopLevelExceptionHandler.cs | 0 .../ISpeckleConverterToHost.cs | 0 .../ISpeckleConverterToSpeckle.cs | 0 .../Objects/FloorConversion.cs | 0 .../Objects/IHostObjectToSpeckleConversion.cs | 0 .../Objects/ISpeckleObjectToHostConversion.cs | 0 .../Speckle.Converters.Common/ReceiveMode.cs | 0 .../Speckle.Converters.Common.csproj | 4 +- .../DependencyInjection/Factory.cs | 19 -- .../Revit2023DUI3/Revit2023DUI3.csproj | 6 - DUI3-CNX-8893.slnf | 28 +- DesktopUI3/DUI3/DUI3.csproj | 2 - Directory.Build.props | 2 +- 51 files changed, 186 insertions(+), 466 deletions(-) create mode 100644 CNX-8892/Directory.Build.Props rename CNX-8892/{ => Sdk}/Speckle.Autofac/DependencyInjection/AutofacContainer.cs (95%) create mode 100644 CNX-8892/Sdk/Speckle.Autofac/DependencyInjection/Factory.cs rename CNX-8892/{ => Sdk}/Speckle.Autofac/DependencyInjection/IFactory.cs (70%) rename CNX-8892/{ => Sdk}/Speckle.Autofac/DependencyInjection/IScopedFactory.cs (100%) rename CNX-8892/{ => Sdk}/Speckle.Autofac/DependencyInjection/NameAndRankValueAttribute.cs (100%) rename CNX-8892/{ => Sdk}/Speckle.Autofac/DependencyInjection/NamedTypeInjector.cs (100%) rename CNX-8892/{ => Sdk}/Speckle.Autofac/DependencyInjection/ScopedFactory.cs (100%) rename CNX-8892/{ => Sdk}/Speckle.Autofac/Files/IStorageInfo.cs (100%) rename CNX-8892/{ => Sdk}/Speckle.Autofac/Files/StorageInfo.cs (100%) rename CNX-8892/{ => Sdk}/Speckle.Autofac/GlobalSuppressions.cs (100%) rename CNX-8892/{ => Sdk}/Speckle.Autofac/Speckle.Autofac.csproj (74%) rename CNX-8892/{ => Sdk}/Speckle.Connectors.Utils/Cancellation/CancellationManager.cs (100%) rename CNX-8892/{ => Sdk}/Speckle.Connectors.Utils/Cancellation/ICancelable.cs (100%) rename CNX-8892/{ => Sdk}/Speckle.Connectors.Utils/Reflection/AssemblyExtensions.cs (75%) rename CNX-8892/{ => Sdk}/Speckle.Connectors.Utils/Speckle.Connectors.Utils.csproj (53%) rename CNX-8892/{ => Sdk}/Speckle.Connectors.Utils/SpeckleTopLevelExceptionHandler.cs (100%) rename CNX-8892/{Converters => Sdk}/Speckle.Converters.Common/ISpeckleConverterToHost.cs (100%) rename CNX-8892/{Converters => Sdk}/Speckle.Converters.Common/ISpeckleConverterToSpeckle.cs (100%) rename CNX-8892/{Converters => Sdk}/Speckle.Converters.Common/Objects/FloorConversion.cs (100%) rename CNX-8892/{Converters => Sdk}/Speckle.Converters.Common/Objects/IHostObjectToSpeckleConversion.cs (100%) rename CNX-8892/{Converters => Sdk}/Speckle.Converters.Common/Objects/ISpeckleObjectToHostConversion.cs (100%) rename CNX-8892/{Converters => Sdk}/Speckle.Converters.Common/ReceiveMode.cs (100%) rename CNX-8892/{Converters => Sdk}/Speckle.Converters.Common/Speckle.Converters.Common.csproj (72%) delete mode 100644 CNX-8892/Speckle.Autofac/DependencyInjection/Factory.cs diff --git a/All.sln b/All.sln index 9f0848a37b..a354775543 100644 --- a/All.sln +++ b/All.sln @@ -2,7 +2,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.1.32210.238 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Connectors", "Connectors", "{DD7DA7E3-FBB7-4216-852B-A4A5BF3AB9AB}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "LegacyConnectors", "LegacyConnectors", "{DD7DA7E3-FBB7-4216-852B-A4A5BF3AB9AB}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Dynamo", "Dynamo", "{CB6F8F77-4487-469B-896A-1EEEC4451A04}" EndProject @@ -481,7 +481,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{8A909E95 EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Objects.Tests.Unit", "Objects\Tests\Objects.Tests.Unit\Objects.Tests.Unit.csproj", "{9E74F0E6-94B4-46BD-B1CA-DD874B459399}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "CNX-8892 - DUI3, DI, Kits", "CNX-8892 - DUI3, DI, Kits", "{9DB74760-01DE-4AC1-A81B-BC7784351D22}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "CNX-8892", "CNX-8892", "{9DB74760-01DE-4AC1-A81B-BC7784351D22}" + ProjectSection(SolutionItems) = preProject + CNX-8892\Directory.Build.Props = CNX-8892\Directory.Build.Props + EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Revit", "Revit", "{4838C66E-8677-4FBD-9609-25376042E981}" EndProject @@ -495,28 +498,30 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Speckle.Connectors.Revit202 EndProject Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Speckle.Connectors.RevitShared", "CNX-8892\Connectors\Revit\Speckle.Connectors.RevitShared\Speckle.Connectors.RevitShared.shproj", "{32AEA787-C986-4B76-A57F-0DA5453AA1F5}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Speckle.Autofac", "CNX-8892\Speckle.Autofac\Speckle.Autofac.csproj", "{E854650A-9F2A-43D3-AB70-D9E34B33D2D6}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "DUI", "DUI", "{FD4D6594-D81E-456F-8F2E-35B09E04A755}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "DUI3", "DUI3", "{FD4D6594-D81E-456F-8F2E-35B09E04A755}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Speckle.Connectors.DUI", "CNX-8892\DUI3\Speckle.Connectors.DUI\Speckle.Connectors.DUI.csproj", "{86E64130-2DCE-4F51-B07C-B87138046E21}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Speckle.Connectors.Utils", "CNX-8892\Speckle.Connectors.Utils\Speckle.Connectors.Utils.csproj", "{D495D104-61D9-4476-B909-1C0E79C3650C}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Speckle.Converters.Revit2023", "CNX-8892\Converters\Revit\Speckle.Converters.Revit2023\Speckle.Converters.Revit2023.csproj", "{E577F692-C9E9-46A6-B9F1-CF70C93F1280}" EndProject Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Speckle.Converters.RevitShared", "CNX-8892\Converters\Revit\Speckle.Converters.RevitShared\Speckle.Converters.RevitShared.shproj", "{9655BE78-8070-4B9F-B0DC-68BB6150B52C}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Revit", "Revit", "{D92751C8-1039-4005-90B2-913E55E0B8BD}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Speckle.Converters.Common", "CNX-8892\Converters\Speckle.Converters.Common\Speckle.Converters.Common.csproj", "{3217D8B5-AE8F-4364-81CF-8B7C2BEF6445}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Speckle.Objects.Common", "CNX-8892\Objects\Speckle.Objects.Common\Speckle.Objects.Common.csproj", "{746047E4-BE3D-43D0-99E0-76259D262AC6}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Speckle.Objects.Revit", "CNX-8892\Objects\Speckle.Objects.Revit\Speckle.Objects.Revit.csproj", "{D32342E4-3223-48A0-8DF6-A1475BE27628}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Speckle.Converters.Revit2023.DependencyInjection", "CNX-8892\Converters\Revit\Speckle.Converters.Revit2023.DependencyInjection\Speckle.Converters.Revit2023.DependencyInjection.csproj", "{81F92B31-C647-4A82-A464-8322814F50E6}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Sdk", "Sdk", "{2E00592E-558D-492D-88F9-3ECEE4C0C7DA}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Speckle.Autofac", "CNX-8892\Sdk\Speckle.Autofac\Speckle.Autofac.csproj", "{7661D48B-9B2C-4549-AE6C-EE07914A1DE6}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Speckle.Connectors.Utils", "CNX-8892\Sdk\Speckle.Connectors.Utils\Speckle.Connectors.Utils.csproj", "{12173832-4E42-4879-B37E-30B34A72B06D}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Speckle.Converters.Common", "CNX-8892\Sdk\Speckle.Converters.Common\Speckle.Converters.Common.csproj", "{3954A8FD-6D5A-4A42-BED0-383A2EF40B57}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug Mac|Any CPU = Debug Mac|Any CPU @@ -2449,22 +2454,6 @@ Global {E1FF75EC-2BDF-4276-9C81-6EB195661348}.Release|Any CPU.Build.0 = Release|Any CPU {E1FF75EC-2BDF-4276-9C81-6EB195661348}.Release|x64.ActiveCfg = Release|Any CPU {E1FF75EC-2BDF-4276-9C81-6EB195661348}.Release|x64.Build.0 = Release|Any CPU - {E854650A-9F2A-43D3-AB70-D9E34B33D2D6}.Debug Mac|Any CPU.ActiveCfg = Debug|Any CPU - {E854650A-9F2A-43D3-AB70-D9E34B33D2D6}.Debug Mac|Any CPU.Build.0 = Debug|Any CPU - {E854650A-9F2A-43D3-AB70-D9E34B33D2D6}.Debug Mac|x64.ActiveCfg = Debug|Any CPU - {E854650A-9F2A-43D3-AB70-D9E34B33D2D6}.Debug Mac|x64.Build.0 = Debug|Any CPU - {E854650A-9F2A-43D3-AB70-D9E34B33D2D6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {E854650A-9F2A-43D3-AB70-D9E34B33D2D6}.Debug|Any CPU.Build.0 = Debug|Any CPU - {E854650A-9F2A-43D3-AB70-D9E34B33D2D6}.Debug|x64.ActiveCfg = Debug|x64 - {E854650A-9F2A-43D3-AB70-D9E34B33D2D6}.Debug|x64.Build.0 = Debug|x64 - {E854650A-9F2A-43D3-AB70-D9E34B33D2D6}.Release Mac|Any CPU.ActiveCfg = Release|Any CPU - {E854650A-9F2A-43D3-AB70-D9E34B33D2D6}.Release Mac|Any CPU.Build.0 = Release|Any CPU - {E854650A-9F2A-43D3-AB70-D9E34B33D2D6}.Release Mac|x64.ActiveCfg = Release|Any CPU - {E854650A-9F2A-43D3-AB70-D9E34B33D2D6}.Release Mac|x64.Build.0 = Release|Any CPU - {E854650A-9F2A-43D3-AB70-D9E34B33D2D6}.Release|Any CPU.ActiveCfg = Release|Any CPU - {E854650A-9F2A-43D3-AB70-D9E34B33D2D6}.Release|Any CPU.Build.0 = Release|Any CPU - {E854650A-9F2A-43D3-AB70-D9E34B33D2D6}.Release|x64.ActiveCfg = Release|Any CPU - {E854650A-9F2A-43D3-AB70-D9E34B33D2D6}.Release|x64.Build.0 = Release|Any CPU {86E64130-2DCE-4F51-B07C-B87138046E21}.Debug Mac|Any CPU.ActiveCfg = Debug|Any CPU {86E64130-2DCE-4F51-B07C-B87138046E21}.Debug Mac|Any CPU.Build.0 = Debug|Any CPU {86E64130-2DCE-4F51-B07C-B87138046E21}.Debug Mac|x64.ActiveCfg = Debug|Any CPU @@ -2481,22 +2470,6 @@ Global {86E64130-2DCE-4F51-B07C-B87138046E21}.Release|Any CPU.Build.0 = Release|Any CPU {86E64130-2DCE-4F51-B07C-B87138046E21}.Release|x64.ActiveCfg = Release|Any CPU {86E64130-2DCE-4F51-B07C-B87138046E21}.Release|x64.Build.0 = Release|Any CPU - {D495D104-61D9-4476-B909-1C0E79C3650C}.Debug Mac|Any CPU.ActiveCfg = Debug|Any CPU - {D495D104-61D9-4476-B909-1C0E79C3650C}.Debug Mac|Any CPU.Build.0 = Debug|Any CPU - {D495D104-61D9-4476-B909-1C0E79C3650C}.Debug Mac|x64.ActiveCfg = Debug|Any CPU - {D495D104-61D9-4476-B909-1C0E79C3650C}.Debug Mac|x64.Build.0 = Debug|Any CPU - {D495D104-61D9-4476-B909-1C0E79C3650C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {D495D104-61D9-4476-B909-1C0E79C3650C}.Debug|Any CPU.Build.0 = Debug|Any CPU - {D495D104-61D9-4476-B909-1C0E79C3650C}.Debug|x64.ActiveCfg = Debug|x64 - {D495D104-61D9-4476-B909-1C0E79C3650C}.Debug|x64.Build.0 = Debug|x64 - {D495D104-61D9-4476-B909-1C0E79C3650C}.Release Mac|Any CPU.ActiveCfg = Release|Any CPU - {D495D104-61D9-4476-B909-1C0E79C3650C}.Release Mac|Any CPU.Build.0 = Release|Any CPU - {D495D104-61D9-4476-B909-1C0E79C3650C}.Release Mac|x64.ActiveCfg = Release|Any CPU - {D495D104-61D9-4476-B909-1C0E79C3650C}.Release Mac|x64.Build.0 = Release|Any CPU - {D495D104-61D9-4476-B909-1C0E79C3650C}.Release|Any CPU.ActiveCfg = Release|Any CPU - {D495D104-61D9-4476-B909-1C0E79C3650C}.Release|Any CPU.Build.0 = Release|Any CPU - {D495D104-61D9-4476-B909-1C0E79C3650C}.Release|x64.ActiveCfg = Release|Any CPU - {D495D104-61D9-4476-B909-1C0E79C3650C}.Release|x64.Build.0 = Release|Any CPU {E577F692-C9E9-46A6-B9F1-CF70C93F1280}.Debug Mac|Any CPU.ActiveCfg = Debug|Any CPU {E577F692-C9E9-46A6-B9F1-CF70C93F1280}.Debug Mac|Any CPU.Build.0 = Debug|Any CPU {E577F692-C9E9-46A6-B9F1-CF70C93F1280}.Debug Mac|x64.ActiveCfg = Debug|Any CPU @@ -2513,22 +2486,6 @@ Global {E577F692-C9E9-46A6-B9F1-CF70C93F1280}.Release|Any CPU.Build.0 = Release|Any CPU {E577F692-C9E9-46A6-B9F1-CF70C93F1280}.Release|x64.ActiveCfg = Release|Any CPU {E577F692-C9E9-46A6-B9F1-CF70C93F1280}.Release|x64.Build.0 = Release|Any CPU - {3217D8B5-AE8F-4364-81CF-8B7C2BEF6445}.Debug Mac|Any CPU.ActiveCfg = Debug|Any CPU - {3217D8B5-AE8F-4364-81CF-8B7C2BEF6445}.Debug Mac|Any CPU.Build.0 = Debug|Any CPU - {3217D8B5-AE8F-4364-81CF-8B7C2BEF6445}.Debug Mac|x64.ActiveCfg = Debug|Any CPU - {3217D8B5-AE8F-4364-81CF-8B7C2BEF6445}.Debug Mac|x64.Build.0 = Debug|Any CPU - {3217D8B5-AE8F-4364-81CF-8B7C2BEF6445}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {3217D8B5-AE8F-4364-81CF-8B7C2BEF6445}.Debug|Any CPU.Build.0 = Debug|Any CPU - {3217D8B5-AE8F-4364-81CF-8B7C2BEF6445}.Debug|x64.ActiveCfg = Debug|Any CPU - {3217D8B5-AE8F-4364-81CF-8B7C2BEF6445}.Debug|x64.Build.0 = Debug|Any CPU - {3217D8B5-AE8F-4364-81CF-8B7C2BEF6445}.Release Mac|Any CPU.ActiveCfg = Release|Any CPU - {3217D8B5-AE8F-4364-81CF-8B7C2BEF6445}.Release Mac|Any CPU.Build.0 = Release|Any CPU - {3217D8B5-AE8F-4364-81CF-8B7C2BEF6445}.Release Mac|x64.ActiveCfg = Release|Any CPU - {3217D8B5-AE8F-4364-81CF-8B7C2BEF6445}.Release Mac|x64.Build.0 = Release|Any CPU - {3217D8B5-AE8F-4364-81CF-8B7C2BEF6445}.Release|Any CPU.ActiveCfg = Release|Any CPU - {3217D8B5-AE8F-4364-81CF-8B7C2BEF6445}.Release|Any CPU.Build.0 = Release|Any CPU - {3217D8B5-AE8F-4364-81CF-8B7C2BEF6445}.Release|x64.ActiveCfg = Release|Any CPU - {3217D8B5-AE8F-4364-81CF-8B7C2BEF6445}.Release|x64.Build.0 = Release|Any CPU {746047E4-BE3D-43D0-99E0-76259D262AC6}.Debug Mac|Any CPU.ActiveCfg = Debug|Any CPU {746047E4-BE3D-43D0-99E0-76259D262AC6}.Debug Mac|Any CPU.Build.0 = Debug|Any CPU {746047E4-BE3D-43D0-99E0-76259D262AC6}.Debug Mac|x64.ActiveCfg = Debug|Any CPU @@ -2577,6 +2534,54 @@ Global {81F92B31-C647-4A82-A464-8322814F50E6}.Release|Any CPU.Build.0 = Release|Any CPU {81F92B31-C647-4A82-A464-8322814F50E6}.Release|x64.ActiveCfg = Release|Any CPU {81F92B31-C647-4A82-A464-8322814F50E6}.Release|x64.Build.0 = Release|Any CPU + {7661D48B-9B2C-4549-AE6C-EE07914A1DE6}.Debug Mac|Any CPU.ActiveCfg = Debug|Any CPU + {7661D48B-9B2C-4549-AE6C-EE07914A1DE6}.Debug Mac|Any CPU.Build.0 = Debug|Any CPU + {7661D48B-9B2C-4549-AE6C-EE07914A1DE6}.Debug Mac|x64.ActiveCfg = Debug|Any CPU + {7661D48B-9B2C-4549-AE6C-EE07914A1DE6}.Debug Mac|x64.Build.0 = Debug|Any CPU + {7661D48B-9B2C-4549-AE6C-EE07914A1DE6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7661D48B-9B2C-4549-AE6C-EE07914A1DE6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7661D48B-9B2C-4549-AE6C-EE07914A1DE6}.Debug|x64.ActiveCfg = Debug|Any CPU + {7661D48B-9B2C-4549-AE6C-EE07914A1DE6}.Debug|x64.Build.0 = Debug|Any CPU + {7661D48B-9B2C-4549-AE6C-EE07914A1DE6}.Release Mac|Any CPU.ActiveCfg = Debug|Any CPU + {7661D48B-9B2C-4549-AE6C-EE07914A1DE6}.Release Mac|Any CPU.Build.0 = Debug|Any CPU + {7661D48B-9B2C-4549-AE6C-EE07914A1DE6}.Release Mac|x64.ActiveCfg = Debug|Any CPU + {7661D48B-9B2C-4549-AE6C-EE07914A1DE6}.Release Mac|x64.Build.0 = Debug|Any CPU + {7661D48B-9B2C-4549-AE6C-EE07914A1DE6}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7661D48B-9B2C-4549-AE6C-EE07914A1DE6}.Release|Any CPU.Build.0 = Release|Any CPU + {7661D48B-9B2C-4549-AE6C-EE07914A1DE6}.Release|x64.ActiveCfg = Release|Any CPU + {7661D48B-9B2C-4549-AE6C-EE07914A1DE6}.Release|x64.Build.0 = Release|Any CPU + {12173832-4E42-4879-B37E-30B34A72B06D}.Debug Mac|Any CPU.ActiveCfg = Debug|Any CPU + {12173832-4E42-4879-B37E-30B34A72B06D}.Debug Mac|Any CPU.Build.0 = Debug|Any CPU + {12173832-4E42-4879-B37E-30B34A72B06D}.Debug Mac|x64.ActiveCfg = Debug|Any CPU + {12173832-4E42-4879-B37E-30B34A72B06D}.Debug Mac|x64.Build.0 = Debug|Any CPU + {12173832-4E42-4879-B37E-30B34A72B06D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {12173832-4E42-4879-B37E-30B34A72B06D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {12173832-4E42-4879-B37E-30B34A72B06D}.Debug|x64.ActiveCfg = Debug|Any CPU + {12173832-4E42-4879-B37E-30B34A72B06D}.Debug|x64.Build.0 = Debug|Any CPU + {12173832-4E42-4879-B37E-30B34A72B06D}.Release Mac|Any CPU.ActiveCfg = Debug|Any CPU + {12173832-4E42-4879-B37E-30B34A72B06D}.Release Mac|Any CPU.Build.0 = Debug|Any CPU + {12173832-4E42-4879-B37E-30B34A72B06D}.Release Mac|x64.ActiveCfg = Debug|Any CPU + {12173832-4E42-4879-B37E-30B34A72B06D}.Release Mac|x64.Build.0 = Debug|Any CPU + {12173832-4E42-4879-B37E-30B34A72B06D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {12173832-4E42-4879-B37E-30B34A72B06D}.Release|Any CPU.Build.0 = Release|Any CPU + {12173832-4E42-4879-B37E-30B34A72B06D}.Release|x64.ActiveCfg = Release|Any CPU + {12173832-4E42-4879-B37E-30B34A72B06D}.Release|x64.Build.0 = Release|Any CPU + {3954A8FD-6D5A-4A42-BED0-383A2EF40B57}.Debug Mac|Any CPU.ActiveCfg = Debug|Any CPU + {3954A8FD-6D5A-4A42-BED0-383A2EF40B57}.Debug Mac|Any CPU.Build.0 = Debug|Any CPU + {3954A8FD-6D5A-4A42-BED0-383A2EF40B57}.Debug Mac|x64.ActiveCfg = Debug|Any CPU + {3954A8FD-6D5A-4A42-BED0-383A2EF40B57}.Debug Mac|x64.Build.0 = Debug|Any CPU + {3954A8FD-6D5A-4A42-BED0-383A2EF40B57}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3954A8FD-6D5A-4A42-BED0-383A2EF40B57}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3954A8FD-6D5A-4A42-BED0-383A2EF40B57}.Debug|x64.ActiveCfg = Debug|Any CPU + {3954A8FD-6D5A-4A42-BED0-383A2EF40B57}.Debug|x64.Build.0 = Debug|Any CPU + {3954A8FD-6D5A-4A42-BED0-383A2EF40B57}.Release Mac|Any CPU.ActiveCfg = Debug|Any CPU + {3954A8FD-6D5A-4A42-BED0-383A2EF40B57}.Release Mac|Any CPU.Build.0 = Debug|Any CPU + {3954A8FD-6D5A-4A42-BED0-383A2EF40B57}.Release Mac|x64.ActiveCfg = Debug|Any CPU + {3954A8FD-6D5A-4A42-BED0-383A2EF40B57}.Release Mac|x64.Build.0 = Debug|Any CPU + {3954A8FD-6D5A-4A42-BED0-383A2EF40B57}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3954A8FD-6D5A-4A42-BED0-383A2EF40B57}.Release|Any CPU.Build.0 = Release|Any CPU + {3954A8FD-6D5A-4A42-BED0-383A2EF40B57}.Release|x64.ActiveCfg = Release|Any CPU + {3954A8FD-6D5A-4A42-BED0-383A2EF40B57}.Release|x64.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -2764,17 +2769,18 @@ Global {1FE3C60E-7865-40A5-9794-55ECB64F6489} = {9DB74760-01DE-4AC1-A81B-BC7784351D22} {E1FF75EC-2BDF-4276-9C81-6EB195661348} = {4838C66E-8677-4FBD-9609-25376042E981} {32AEA787-C986-4B76-A57F-0DA5453AA1F5} = {4838C66E-8677-4FBD-9609-25376042E981} - {E854650A-9F2A-43D3-AB70-D9E34B33D2D6} = {9DB74760-01DE-4AC1-A81B-BC7784351D22} - {FD4D6594-D81E-456F-8F2E-35B09E04A755} = {9DB74760-01DE-4AC1-A81B-BC7784351D22} {86E64130-2DCE-4F51-B07C-B87138046E21} = {FD4D6594-D81E-456F-8F2E-35B09E04A755} - {D495D104-61D9-4476-B909-1C0E79C3650C} = {9DB74760-01DE-4AC1-A81B-BC7784351D22} {E577F692-C9E9-46A6-B9F1-CF70C93F1280} = {D92751C8-1039-4005-90B2-913E55E0B8BD} {9655BE78-8070-4B9F-B0DC-68BB6150B52C} = {D92751C8-1039-4005-90B2-913E55E0B8BD} {D92751C8-1039-4005-90B2-913E55E0B8BD} = {1FE3C60E-7865-40A5-9794-55ECB64F6489} - {3217D8B5-AE8F-4364-81CF-8B7C2BEF6445} = {1FE3C60E-7865-40A5-9794-55ECB64F6489} {746047E4-BE3D-43D0-99E0-76259D262AC6} = {B92E6216-2CBA-4EA5-B94B-0A7658C7F84B} {D32342E4-3223-48A0-8DF6-A1475BE27628} = {B92E6216-2CBA-4EA5-B94B-0A7658C7F84B} {81F92B31-C647-4A82-A464-8322814F50E6} = {D92751C8-1039-4005-90B2-913E55E0B8BD} + {2E00592E-558D-492D-88F9-3ECEE4C0C7DA} = {9DB74760-01DE-4AC1-A81B-BC7784351D22} + {FD4D6594-D81E-456F-8F2E-35B09E04A755} = {9DB74760-01DE-4AC1-A81B-BC7784351D22} + {7661D48B-9B2C-4549-AE6C-EE07914A1DE6} = {2E00592E-558D-492D-88F9-3ECEE4C0C7DA} + {12173832-4E42-4879-B37E-30B34A72B06D} = {2E00592E-558D-492D-88F9-3ECEE4C0C7DA} + {3954A8FD-6D5A-4A42-BED0-383A2EF40B57} = {2E00592E-558D-492D-88F9-3ECEE4C0C7DA} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {1D43D91B-4F01-4A78-8250-CC6F9BD93A14} diff --git a/CNX-8892/Connectors/Revit/Speckle.Connectors.Revit2023/Speckle.Connectors.Revit2023.csproj b/CNX-8892/Connectors/Revit/Speckle.Connectors.Revit2023/Speckle.Connectors.Revit2023.csproj index 23bf0abfc0..47c582a4eb 100644 --- a/CNX-8892/Connectors/Revit/Speckle.Connectors.Revit2023/Speckle.Connectors.Revit2023.csproj +++ b/CNX-8892/Connectors/Revit/Speckle.Connectors.Revit2023/Speckle.Connectors.Revit2023.csproj @@ -1,255 +1,59 @@ - - - - - - - - - - - - - - - - - - - - + - Enable - 10.0 - Debug - AnyCPU - {E1FF75EC-2BDF-4276-9C81-6EB195661348} - Library - Properties - Speckle.Connectors.Revit2023 - Speckle.Connectors.Revit2023 - v4.8 - 512 - true - - - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 0 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - true - bin\x64\Debug\ - DEBUG;TRACE - 0 - - CA5399;CA1862; - - CS1591;CS1573; - - CS8618; - - CA1303;CA1304;CA1305;CA1307;CA1308;CA1309;CA1310;CA1311;CA2101; - NU1701; - - CA1815;CA1054; - - full + net48 x64 - - ; - - CA1416; CA1417; CA1418; CA1831; CA2013; CA2014; CA2015; CA2017; - CA2018; CA2200; CA2252; CA2247; CA2255; CA2256; CA2257; CA2258; - - CA1420; CA1422; CA2259; CA2260; - - CA1856; CA1857; CA2021; CA2261; - - CA2100; CA2119; CA2153; CA2300; CA2301; CA2302; CA2305; - CA2310; CA2311; CA2312; CA2315; CA2321; CA2322; CA2326; CA2327; - CA2328; CA2329; CA2330; CA2350; CA2351; CA2352; CA2353; CA2354; - CA2355; CA2356; CA2361; CA2362; CA3001; CA3002; CA3003; CA3004; - CA3006; CA3007; CA3008; CA3009; CA3010; CA3011; CA3012; CA3061; - CA3076; CA3077; CA3147; CA5350; CA5351; CA5358; CA5359; - CA5360; CA5361; CA5362; CA5363; CA5364; CA5365; CA5366; CA5367; - CA5368; CA5370; CA5371; CA5372; CA5373; CA5374; CA5375; - CA5376; CA5377; CA5378; CA5379; CA5380; CA5381; CA5382; CA5383; - CA5384; CA5385; CA5386; CA5387; CA5388; CA5389; CA5390; CA5391; - CA5392; CA5393; CA5395; CA5396; CA5397; CA5398; - CA5400; CA5401; CA5402; CA5403; CA5404; CA5405; - - - CS0183; CS0184; CS0197; CS0420; CS0465; CS0602; CS0626; CS0657; CS0658; CS0672; CS0684; CS0688; - CS1030; CS1058; CS1060; CS1200; CS1201; CS1202; CS1203; - CS1522; CS1589; CS1590; CS1592; CS1598; - CS1607; CS1616; CS1633; CS1634; CS1635; CS1645; CS1658; CS1682; CS1683; CS1684; CS1685; CS1687; CS1690; CS1691; CS1692; CS1694; CS1695; CS1696; CS1697; CS1699; - CS1707; CS1709; CS1720; CS1723; CS1762; - CS1911; CS1956; CS1957; - CS2002; CS2014; CS2023; CS2029; - CS3000; CS3001; CS3002; CS3003; CS3004; CS3005; CS3006; CS3008; CS3009; CS3010; CS3011; CS3012; CS3013; CS3014; CS3015; CS3017; CS3018; CS3022; CS3023; CS3024; CS3026; CS3027; - CS5000; - - - 10.0 - prompt + win-x64 + true + enable - - true - bin\x64\Release\ - TRACE - true - - CA5399;CA1862; - - CS1591;CS1573; - - CS8618; - - CA1303;CA1304;CA1305;CA1307;CA1308;CA1309;CA1310;CA1311;CA2101; - NU1701; - - CA1815;CA1054; - - pdbonly - x64 - - ; - - CA1416; CA1417; CA1418; CA1831; CA2013; CA2014; CA2015; CA2017; - CA2018; CA2200; CA2252; CA2247; CA2255; CA2256; CA2257; CA2258; - - CA1420; CA1422; CA2259; CA2260; - - CA1856; CA1857; CA2021; CA2261; - - CA2100; CA2119; CA2153; CA2300; CA2301; CA2302; CA2305; - CA2310; CA2311; CA2312; CA2315; CA2321; CA2322; CA2326; CA2327; - CA2328; CA2329; CA2330; CA2350; CA2351; CA2352; CA2353; CA2354; - CA2355; CA2356; CA2361; CA2362; CA3001; CA3002; CA3003; CA3004; - CA3006; CA3007; CA3008; CA3009; CA3010; CA3011; CA3012; CA3061; - CA3076; CA3077; CA3147; CA5350; CA5351; CA5358; CA5359; - CA5360; CA5361; CA5362; CA5363; CA5364; CA5365; CA5366; CA5367; - CA5368; CA5370; CA5371; CA5372; CA5373; CA5374; CA5375; - CA5376; CA5377; CA5378; CA5379; CA5380; CA5381; CA5382; CA5383; - CA5384; CA5385; CA5386; CA5387; CA5388; CA5389; CA5390; CA5391; - CA5392; CA5393; CA5395; CA5396; CA5397; CA5398; - CA5400; CA5401; CA5402; CA5403; CA5404; CA5405; - - CS0183; CS0184; CS0197; CS0420; CS0465; CS0602; CS0626; CS0657; CS0658; CS0672; CS0684; CS0688; - CS1030; CS1058; CS1060; CS1200; CS1201; CS1202; CS1203; - CS1522; CS1589; CS1590; CS1592; CS1598; - CS1607; CS1616; CS1633; CS1634; CS1635; CS1645; CS1658; CS1682; CS1683; CS1684; CS1685; CS1687; CS1690; CS1691; CS1692; CS1694; CS1695; CS1696; CS1697; CS1699; - CS1707; CS1709; CS1720; CS1723; CS1762; - CS1911; CS1956; CS1957; - CS2002; CS2014; CS2023; CS2029; - CS3000; CS3001; CS3002; CS3003; CS3004; CS3005; CS3006; CS3008; CS3009; CS3010; CS3011; CS3012; CS3013; CS3014; CS3015; CS3017; CS3018; CS3022; CS3023; CS3024; CS3026; CS3027; - CS5000; - - - 10.0 - prompt + + + + false + - - - - - - + - - {a2c8730a-b605-483e-914e-61f3ed7954d9} - Core - - - {3217D8B5-AE8F-4364-81CF-8B7C2BEF6445} - Speckle.Converters.Common - - - {86E64130-2DCE-4F51-B07C-B87138046E21} - Speckle.Connectors.DUI - - - {e854650a-9f2a-43d3-ab70-d9e34b33d2d6} - Speckle.Autofac - - - {d495d104-61d9-4476-b909-1c0e79c3650c} - Speckle.Connectors.Utils - - - - - - - - - - + + + + + - - 5.2.0 - - - 92.0.260 - - - 92.0.260 - - - 7.0.0 - - - 7.0.0 - - - 7.0.0 - - - 2.0.1 - - - 2024.0.0 - - - 2.12.0 - - - 7.0.0 - - - 13.0.2 - - - 7.0.2 - + + + + + - - - \ No newline at end of file + + + + + + + + + + + + + + + + + + + diff --git a/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/BasicConnectorBindingRevit.cs b/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/BasicConnectorBindingRevit.cs index 60d856ad6c..bc1917b371 100644 --- a/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/BasicConnectorBindingRevit.cs +++ b/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/BasicConnectorBindingRevit.cs @@ -1,18 +1,14 @@ -using System; using System.Collections.Generic; using System.Linq; using System.Reflection; using Autodesk.Revit.DB; -using Autodesk.Revit.UI; using Revit.Async; using Speckle.Connectors.Utils.Reflection; -using Speckle.Connectors.DUI.Bindings; using Speckle.Connectors.DUI.Bridge; using Speckle.Connectors.DUI.Models; using Speckle.Connectors.DUI.Models.Card; using Speckle.Connectors.Revit.Plugin; using Speckle.Connectors.Revit.HostApp; -using Speckle.Connectors.Revit.Bindings; namespace Speckle.Connectors.DUI.Bindings; diff --git a/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/ReceiveBinding.cs b/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/ReceiveBinding.cs index f30fa6664d..4dd57d7d34 100644 --- a/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/ReceiveBinding.cs +++ b/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/ReceiveBinding.cs @@ -1,19 +1,8 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading; -using Autodesk.Revit.DB; -using Autodesk.Revit.UI; -using Revit.Async; -using Speckle.Connectors.DUI.Bindings; using Speckle.Connectors.DUI.Bridge; -using Speckle.Connectors.Revit.Bindings; using Speckle.Connectors.Revit.HostApp; using Speckle.Connectors.Revit.Plugin; using Speckle.Connectors.Utils.Cancellation; -using Speckle.Core.Kits; -using Speckle.Core.Logging; -using Speckle.Core.Models; namespace Speckle.Connectors.Revit.Bindings; diff --git a/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/RevitBaseBinding.cs b/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/RevitBaseBinding.cs index 8aa7f66ebc..4dc979d457 100644 --- a/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/RevitBaseBinding.cs +++ b/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/RevitBaseBinding.cs @@ -1,7 +1,4 @@ using System; -using System.Collections.Generic; -using System.Text; -using Autofac.Core; using Speckle.Connectors.DUI.Bindings; using Speckle.Connectors.DUI.Bridge; using Speckle.Connectors.Revit.HostApp; diff --git a/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SelectionBinding.cs b/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SelectionBinding.cs index 53a46022fd..d867cd254a 100644 --- a/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SelectionBinding.cs +++ b/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SelectionBinding.cs @@ -1,7 +1,6 @@ using System.Collections.Generic; using System.Linq; using Autodesk.Revit.DB; -using Autodesk.Revit.UI; using Speckle.Connectors.DUI.Bindings; using Speckle.Connectors.DUI.Bridge; using Speckle.Connectors.Revit.HostApp; diff --git a/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SendBinding.cs b/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SendBinding.cs index d861411455..40459940fd 100644 --- a/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SendBinding.cs +++ b/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SendBinding.cs @@ -1,26 +1,16 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Threading; -using Autodesk.Revit.UI; using Autodesk.Revit.DB; -using Speckle.Core.Kits; -using Speckle.Core.Credentials; -using Speckle.Core.Transports; -using Speckle.Core.Models; using Speckle.Connectors.DUI.Bindings; using Speckle.Connectors.Utils.Cancellation; using Speckle.Connectors.DUI.Bridge; using Speckle.Connectors.Revit.HostApp; using Speckle.Connectors.Revit.Plugin; -using Speckle.Connectors.Revit.Bindings; using Speckle.Core.Logging; using Speckle.Connectors.Utils; -using Autofac.Features.Indexed; using Speckle.Autofac.DependencyInjection; using Speckle.Converters.Common; -using Speckle.Converters.Common.Objects; -using System.Windows.Forms.VisualStyles; namespace Speckle.Connectors.Revit.Bindings; diff --git a/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/AutofacUIModule.cs b/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/AutofacUIModule.cs index ecab4b5208..457b4d09a2 100644 --- a/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/AutofacUIModule.cs +++ b/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/AutofacUIModule.cs @@ -1,7 +1,5 @@ using System; -using System.Collections.Generic; using System.IO; -using System.Text; using Autofac; using CefSharp; using Microsoft.Extensions.Logging; diff --git a/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/CefSharpPanel.xaml.cs b/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/CefSharpPanel.xaml.cs index 4f9ae25537..a82285335c 100644 --- a/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/CefSharpPanel.xaml.cs +++ b/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/CefSharpPanel.xaml.cs @@ -1,7 +1,6 @@ using System.Windows.Controls; using Autodesk.Revit.UI; using CefSharp; -using CefSharp.DevTools; using System.Windows.Threading; namespace Speckle.Connectors.Revit; diff --git a/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/IRevitIdleManager.cs b/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/IRevitIdleManager.cs index 43d47e605b..ab7fcc435d 100644 --- a/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/IRevitIdleManager.cs +++ b/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/IRevitIdleManager.cs @@ -1,8 +1,4 @@ using System; -using System.Collections.Concurrent; -using System.Collections.Generic; -using Autodesk.Revit.UI; -using Autodesk.Revit.UI.Events; namespace Speckle.Connectors.Revit.Plugin; diff --git a/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/IRevitPlugin.cs b/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/IRevitPlugin.cs index 74e8234187..fb88ffc44a 100644 --- a/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/IRevitPlugin.cs +++ b/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/IRevitPlugin.cs @@ -1,8 +1,3 @@ -using System; -using System.Collections.Generic; -using System.Text; -using Autodesk.Revit.UI; - namespace Speckle.Connectors.Revit.Plugin; internal interface IRevitPlugin diff --git a/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitCommand.cs b/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitCommand.cs index 14648bce3e..7101dc7b29 100644 --- a/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitCommand.cs +++ b/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitCommand.cs @@ -1,8 +1,6 @@ using Autodesk.Revit.Attributes; using Autodesk.Revit.DB; using Autodesk.Revit.UI; -using Speckle.Connectors.Revit; -using Speckle.Connectors.Revit.Plugin; namespace Speckle.Connectors.Revit.Plugin; diff --git a/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitContext.cs b/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitContext.cs index 5af32c3fba..125c249750 100644 --- a/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitContext.cs +++ b/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitContext.cs @@ -1,28 +1,25 @@ using System; -using System.Collections.Generic; -using System.Text; using Autodesk.Revit.UI; -namespace Speckle.Connectors.Revit.Plugin +namespace Speckle.Connectors.Revit.Plugin; + +public class RevitContext { - public class RevitContext - { - private CefSharpPanel? _panel; + private CefSharpPanel? _panel; - private UIApplication? _uiApplication; + private UIApplication? _uiApplication; - public UIApplication? UIApplication + public UIApplication? UIApplication + { + get => _uiApplication; + set { - get => _uiApplication; - set + if (_uiApplication != null) { - if (_uiApplication != null) - { - throw new ArgumentException("UIApplication already set"); - } - - _uiApplication = value; + throw new ArgumentException("UIApplication already set"); } + + _uiApplication = value; } } } diff --git a/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitExternalApplication.cs b/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitExternalApplication.cs index d6df910c09..d53d6e468f 100644 --- a/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitExternalApplication.cs +++ b/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitExternalApplication.cs @@ -1,14 +1,7 @@ using System; -using System.Linq; -using System.Windows.Threading; -using Autodesk.Revit.DB; using Autodesk.Revit.UI; using Speckle.Autofac.DependencyInjection; using Speckle.Autofac.Files; -using Speckle.Connectors.DUI.Bridge; -using Speckle.Connectors.Revit.DependencyInjection; -using CefSharp; -using CefSharp.DevTools; using System.Reflection; using System.IO; using Autofac; @@ -76,7 +69,7 @@ public Result OnStartup(UIControlledApplication application) _revitPlugin = _container.Resolve(); _revitPlugin.Initialise(); } - catch (Exception ex) + catch (Exception) { // POC: feedback? return Result.Failed; @@ -99,7 +92,7 @@ public Result OnShutdown(UIControlledApplication application) // need to look for commonality _revitPlugin.Shutdown(); } - catch (Exception ex) + catch (Exception) { // POC: feedback? return Result.Failed; diff --git a/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitPlugin.cs b/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitPlugin.cs index 4771d8bc09..9df09e1b24 100644 --- a/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitPlugin.cs +++ b/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitPlugin.cs @@ -1,19 +1,12 @@ using System; using System.Collections.Generic; -using System.Data; -using System.Text; -using System.Reflection; using Autodesk.Revit.UI; using Autodesk.Revit.ApplicationServices; -using Autodesk.Revit.DB.Events; using Revit.Async; using CefSharp; using System.Linq; -using System.IO; using Speckle.Connectors.DUI.Bridge; using Speckle.Connectors.DUI.Bindings; -using Autofac; -using Speckle.Connectors.Revit.HostApp; using System.Diagnostics; namespace Speckle.Connectors.Revit.Plugin; diff --git a/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitSettings.cs b/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitSettings.cs index c86dbdf337..98c7b48334 100644 --- a/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitSettings.cs +++ b/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitSettings.cs @@ -1,9 +1,3 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Windows.Media.Converters; -using Microsoft.SqlServer.Server; - namespace Speckle.Connectors.Revit.Plugin; internal class RevitSettings // POC: need to derive some interface for things that require IHostSettings diff --git a/CNX-8892/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/AutofacRevitConverterModule.cs b/CNX-8892/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/AutofacRevitConverterModule.cs index 9395ef160d..d9d19585e6 100644 --- a/CNX-8892/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/AutofacRevitConverterModule.cs +++ b/CNX-8892/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/AutofacRevitConverterModule.cs @@ -1,11 +1,12 @@ // POC: not sure we should have this here as it attaches us to autofac, maybe a bit prematurely... + using Autofac; using Speckle.Autofac.DependencyInjection; using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; using Speckle.Converters.RevitShared; -namespace Speckle.Converters.Revit2023; +namespace Speckle.Converters.Revit2023.DependencyInjection; public class AutofacRevitConverterModule : Module { diff --git a/CNX-8892/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/Speckle.Converters.Revit2023.DependencyInjection.csproj b/CNX-8892/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/Speckle.Converters.Revit2023.DependencyInjection.csproj index 99b2d59b52..bbaea7cde3 100644 --- a/CNX-8892/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/Speckle.Converters.Revit2023.DependencyInjection.csproj +++ b/CNX-8892/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/Speckle.Converters.Revit2023.DependencyInjection.csproj @@ -2,12 +2,14 @@ netstandard2.0 + x64 + enable - - + + True diff --git a/CNX-8892/Converters/Revit/Speckle.Converters.Revit2023/Speckle.Converters.Revit2023.csproj b/CNX-8892/Converters/Revit/Speckle.Converters.Revit2023/Speckle.Converters.Revit2023.csproj index 8c3efcbe9c..bace94bae5 100644 --- a/CNX-8892/Converters/Revit/Speckle.Converters.Revit2023/Speckle.Converters.Revit2023.csproj +++ b/CNX-8892/Converters/Revit/Speckle.Converters.Revit2023/Speckle.Converters.Revit2023.csproj @@ -1,9 +1,9 @@  - 10.0 - enable netstandard2.0 + x64 + enable @@ -13,7 +13,8 @@ - + + diff --git a/CNX-8892/Converters/Revit/Speckle.Converters.RevitShared/RevitConverterToSpeckle.cs b/CNX-8892/Converters/Revit/Speckle.Converters.RevitShared/RevitConverterToSpeckle.cs index 3cb3427a80..7cbd94c4a2 100644 --- a/CNX-8892/Converters/Revit/Speckle.Converters.RevitShared/RevitConverterToSpeckle.cs +++ b/CNX-8892/Converters/Revit/Speckle.Converters.RevitShared/RevitConverterToSpeckle.cs @@ -1,5 +1,4 @@ using Autodesk.Revit.DB; -using Autofac.Features.Indexed; using Speckle.Autofac.DependencyInjection; using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; @@ -20,6 +19,6 @@ public void Convert() { var objectConverter = _toSpeckle.ResolveInstance(nameof(Floor)); - int t = -1; + _ = -1; } } diff --git a/CNX-8892/DUI3/Speckle.Connectors.DUI/Speckle.Connectors.DUI.csproj b/CNX-8892/DUI3/Speckle.Connectors.DUI/Speckle.Connectors.DUI.csproj index 60a9ec6b2b..b85049117f 100644 --- a/CNX-8892/DUI3/Speckle.Connectors.DUI/Speckle.Connectors.DUI.csproj +++ b/CNX-8892/DUI3/Speckle.Connectors.DUI/Speckle.Connectors.DUI.csproj @@ -1,10 +1,8 @@  - enable netstandard2.0 - x64 - AnyCPU;x64 + enable @@ -12,12 +10,12 @@ + + false + + - - - - diff --git a/CNX-8892/Directory.Build.Props b/CNX-8892/Directory.Build.Props new file mode 100644 index 0000000000..1ec3ccfb1a --- /dev/null +++ b/CNX-8892/Directory.Build.Props @@ -0,0 +1,11 @@ + + + + + enable + + + + true + + diff --git a/CNX-8892/Objects/Speckle.Objects.Common/Speckle.Objects.Common.csproj b/CNX-8892/Objects/Speckle.Objects.Common/Speckle.Objects.Common.csproj index 02d764eedd..1c5f6eb4d6 100644 --- a/CNX-8892/Objects/Speckle.Objects.Common/Speckle.Objects.Common.csproj +++ b/CNX-8892/Objects/Speckle.Objects.Common/Speckle.Objects.Common.csproj @@ -7,6 +7,10 @@ disable + + false + + diff --git a/CNX-8892/Speckle.Autofac/DependencyInjection/AutofacContainer.cs b/CNX-8892/Sdk/Speckle.Autofac/DependencyInjection/AutofacContainer.cs similarity index 95% rename from CNX-8892/Speckle.Autofac/DependencyInjection/AutofacContainer.cs rename to CNX-8892/Sdk/Speckle.Autofac/DependencyInjection/AutofacContainer.cs index 96b19744eb..22f1af2c6b 100644 --- a/CNX-8892/Speckle.Autofac/DependencyInjection/AutofacContainer.cs +++ b/CNX-8892/Sdk/Speckle.Autofac/DependencyInjection/AutofacContainer.cs @@ -13,10 +13,8 @@ namespace Speckle.Autofac.DependencyInjection; // POC: wrap the IContainer or expose it? public class AutofacContainer { - public delegate void PreBuildEventHandler(object sender, ContainerBuilder containerBuilder); - // Declare the event. - public event PreBuildEventHandler PreBuildEvent; + public event EventHandler PreBuildEvent; private readonly ContainerBuilder _builder; private readonly IStorageInfo _storageInfo; diff --git a/CNX-8892/Sdk/Speckle.Autofac/DependencyInjection/Factory.cs b/CNX-8892/Sdk/Speckle.Autofac/DependencyInjection/Factory.cs new file mode 100644 index 0000000000..abacd860c5 --- /dev/null +++ b/CNX-8892/Sdk/Speckle.Autofac/DependencyInjection/Factory.cs @@ -0,0 +1,19 @@ +using Autofac.Features.Indexed; + +namespace Speckle.Autofac.DependencyInjection; + +public class Factory : IFactory + where TValue : class +{ + private readonly IIndex _types; + + public Factory(IIndex types) + { + _types = types; + } + + public TValue ResolveInstance(TKey strongName) + { + return _types[strongName]; + } +} diff --git a/CNX-8892/Speckle.Autofac/DependencyInjection/IFactory.cs b/CNX-8892/Sdk/Speckle.Autofac/DependencyInjection/IFactory.cs similarity index 70% rename from CNX-8892/Speckle.Autofac/DependencyInjection/IFactory.cs rename to CNX-8892/Sdk/Speckle.Autofac/DependencyInjection/IFactory.cs index 4c9ca9fa35..3a910be9cf 100644 --- a/CNX-8892/Speckle.Autofac/DependencyInjection/IFactory.cs +++ b/CNX-8892/Sdk/Speckle.Autofac/DependencyInjection/IFactory.cs @@ -5,8 +5,8 @@ namespace Speckle.Autofac.DependencyInjection; // Interceptors? // POC: this might be somehting that could go in a wholly converter agnostic project -public interface IFactory - where T : class +public interface IFactory + where TValue : class { - T ResolveInstance(K strongName); + TValue ResolveInstance(TKey strongName); } diff --git a/CNX-8892/Speckle.Autofac/DependencyInjection/IScopedFactory.cs b/CNX-8892/Sdk/Speckle.Autofac/DependencyInjection/IScopedFactory.cs similarity index 100% rename from CNX-8892/Speckle.Autofac/DependencyInjection/IScopedFactory.cs rename to CNX-8892/Sdk/Speckle.Autofac/DependencyInjection/IScopedFactory.cs diff --git a/CNX-8892/Speckle.Autofac/DependencyInjection/NameAndRankValueAttribute.cs b/CNX-8892/Sdk/Speckle.Autofac/DependencyInjection/NameAndRankValueAttribute.cs similarity index 100% rename from CNX-8892/Speckle.Autofac/DependencyInjection/NameAndRankValueAttribute.cs rename to CNX-8892/Sdk/Speckle.Autofac/DependencyInjection/NameAndRankValueAttribute.cs diff --git a/CNX-8892/Speckle.Autofac/DependencyInjection/NamedTypeInjector.cs b/CNX-8892/Sdk/Speckle.Autofac/DependencyInjection/NamedTypeInjector.cs similarity index 100% rename from CNX-8892/Speckle.Autofac/DependencyInjection/NamedTypeInjector.cs rename to CNX-8892/Sdk/Speckle.Autofac/DependencyInjection/NamedTypeInjector.cs diff --git a/CNX-8892/Speckle.Autofac/DependencyInjection/ScopedFactory.cs b/CNX-8892/Sdk/Speckle.Autofac/DependencyInjection/ScopedFactory.cs similarity index 100% rename from CNX-8892/Speckle.Autofac/DependencyInjection/ScopedFactory.cs rename to CNX-8892/Sdk/Speckle.Autofac/DependencyInjection/ScopedFactory.cs diff --git a/CNX-8892/Speckle.Autofac/Files/IStorageInfo.cs b/CNX-8892/Sdk/Speckle.Autofac/Files/IStorageInfo.cs similarity index 100% rename from CNX-8892/Speckle.Autofac/Files/IStorageInfo.cs rename to CNX-8892/Sdk/Speckle.Autofac/Files/IStorageInfo.cs diff --git a/CNX-8892/Speckle.Autofac/Files/StorageInfo.cs b/CNX-8892/Sdk/Speckle.Autofac/Files/StorageInfo.cs similarity index 100% rename from CNX-8892/Speckle.Autofac/Files/StorageInfo.cs rename to CNX-8892/Sdk/Speckle.Autofac/Files/StorageInfo.cs diff --git a/CNX-8892/Speckle.Autofac/GlobalSuppressions.cs b/CNX-8892/Sdk/Speckle.Autofac/GlobalSuppressions.cs similarity index 100% rename from CNX-8892/Speckle.Autofac/GlobalSuppressions.cs rename to CNX-8892/Sdk/Speckle.Autofac/GlobalSuppressions.cs diff --git a/CNX-8892/Speckle.Autofac/Speckle.Autofac.csproj b/CNX-8892/Sdk/Speckle.Autofac/Speckle.Autofac.csproj similarity index 74% rename from CNX-8892/Speckle.Autofac/Speckle.Autofac.csproj rename to CNX-8892/Sdk/Speckle.Autofac/Speckle.Autofac.csproj index 02c1cb29d8..4458fe63f7 100644 --- a/CNX-8892/Speckle.Autofac/Speckle.Autofac.csproj +++ b/CNX-8892/Sdk/Speckle.Autofac/Speckle.Autofac.csproj @@ -3,8 +3,7 @@ true netstandard2.0 - x64 - AnyCPU;x64 + enable @@ -13,7 +12,7 @@ - + diff --git a/CNX-8892/Speckle.Connectors.Utils/Cancellation/CancellationManager.cs b/CNX-8892/Sdk/Speckle.Connectors.Utils/Cancellation/CancellationManager.cs similarity index 100% rename from CNX-8892/Speckle.Connectors.Utils/Cancellation/CancellationManager.cs rename to CNX-8892/Sdk/Speckle.Connectors.Utils/Cancellation/CancellationManager.cs diff --git a/CNX-8892/Speckle.Connectors.Utils/Cancellation/ICancelable.cs b/CNX-8892/Sdk/Speckle.Connectors.Utils/Cancellation/ICancelable.cs similarity index 100% rename from CNX-8892/Speckle.Connectors.Utils/Cancellation/ICancelable.cs rename to CNX-8892/Sdk/Speckle.Connectors.Utils/Cancellation/ICancelable.cs diff --git a/CNX-8892/Speckle.Connectors.Utils/Reflection/AssemblyExtensions.cs b/CNX-8892/Sdk/Speckle.Connectors.Utils/Reflection/AssemblyExtensions.cs similarity index 75% rename from CNX-8892/Speckle.Connectors.Utils/Reflection/AssemblyExtensions.cs rename to CNX-8892/Sdk/Speckle.Connectors.Utils/Reflection/AssemblyExtensions.cs index 6fc4915f07..498e928615 100644 --- a/CNX-8892/Speckle.Connectors.Utils/Reflection/AssemblyExtensions.cs +++ b/CNX-8892/Sdk/Speckle.Connectors.Utils/Reflection/AssemblyExtensions.cs @@ -8,9 +8,7 @@ public static class AssemblyExtensions public static string GetVersion(this Assembly assembly) { // this is adapted from Serilog extension method, but we might find the fallback is enough: assembly.GetName()?.Version?.ToString(); - var attribute = - assembly.GetCustomAttributes().FirstOrDefault(x => x.GetType() == typeof(AssemblyInformationalVersionAttribute)) - as AssemblyInformationalVersionAttribute; + var attribute = assembly.GetCustomAttributes().OfType().FirstOrDefault(); if (attribute != null) { return attribute.InformationalVersion; diff --git a/CNX-8892/Speckle.Connectors.Utils/Speckle.Connectors.Utils.csproj b/CNX-8892/Sdk/Speckle.Connectors.Utils/Speckle.Connectors.Utils.csproj similarity index 53% rename from CNX-8892/Speckle.Connectors.Utils/Speckle.Connectors.Utils.csproj rename to CNX-8892/Sdk/Speckle.Connectors.Utils/Speckle.Connectors.Utils.csproj index c214cdbd2c..1582a2b5e4 100644 --- a/CNX-8892/Speckle.Connectors.Utils/Speckle.Connectors.Utils.csproj +++ b/CNX-8892/Sdk/Speckle.Connectors.Utils/Speckle.Connectors.Utils.csproj @@ -1,15 +1,12 @@  - 10.0 - enable netstandard2.0 - x64 - AnyCPU;x64 + enable - + diff --git a/CNX-8892/Speckle.Connectors.Utils/SpeckleTopLevelExceptionHandler.cs b/CNX-8892/Sdk/Speckle.Connectors.Utils/SpeckleTopLevelExceptionHandler.cs similarity index 100% rename from CNX-8892/Speckle.Connectors.Utils/SpeckleTopLevelExceptionHandler.cs rename to CNX-8892/Sdk/Speckle.Connectors.Utils/SpeckleTopLevelExceptionHandler.cs diff --git a/CNX-8892/Converters/Speckle.Converters.Common/ISpeckleConverterToHost.cs b/CNX-8892/Sdk/Speckle.Converters.Common/ISpeckleConverterToHost.cs similarity index 100% rename from CNX-8892/Converters/Speckle.Converters.Common/ISpeckleConverterToHost.cs rename to CNX-8892/Sdk/Speckle.Converters.Common/ISpeckleConverterToHost.cs diff --git a/CNX-8892/Converters/Speckle.Converters.Common/ISpeckleConverterToSpeckle.cs b/CNX-8892/Sdk/Speckle.Converters.Common/ISpeckleConverterToSpeckle.cs similarity index 100% rename from CNX-8892/Converters/Speckle.Converters.Common/ISpeckleConverterToSpeckle.cs rename to CNX-8892/Sdk/Speckle.Converters.Common/ISpeckleConverterToSpeckle.cs diff --git a/CNX-8892/Converters/Speckle.Converters.Common/Objects/FloorConversion.cs b/CNX-8892/Sdk/Speckle.Converters.Common/Objects/FloorConversion.cs similarity index 100% rename from CNX-8892/Converters/Speckle.Converters.Common/Objects/FloorConversion.cs rename to CNX-8892/Sdk/Speckle.Converters.Common/Objects/FloorConversion.cs diff --git a/CNX-8892/Converters/Speckle.Converters.Common/Objects/IHostObjectToSpeckleConversion.cs b/CNX-8892/Sdk/Speckle.Converters.Common/Objects/IHostObjectToSpeckleConversion.cs similarity index 100% rename from CNX-8892/Converters/Speckle.Converters.Common/Objects/IHostObjectToSpeckleConversion.cs rename to CNX-8892/Sdk/Speckle.Converters.Common/Objects/IHostObjectToSpeckleConversion.cs diff --git a/CNX-8892/Converters/Speckle.Converters.Common/Objects/ISpeckleObjectToHostConversion.cs b/CNX-8892/Sdk/Speckle.Converters.Common/Objects/ISpeckleObjectToHostConversion.cs similarity index 100% rename from CNX-8892/Converters/Speckle.Converters.Common/Objects/ISpeckleObjectToHostConversion.cs rename to CNX-8892/Sdk/Speckle.Converters.Common/Objects/ISpeckleObjectToHostConversion.cs diff --git a/CNX-8892/Converters/Speckle.Converters.Common/ReceiveMode.cs b/CNX-8892/Sdk/Speckle.Converters.Common/ReceiveMode.cs similarity index 100% rename from CNX-8892/Converters/Speckle.Converters.Common/ReceiveMode.cs rename to CNX-8892/Sdk/Speckle.Converters.Common/ReceiveMode.cs diff --git a/CNX-8892/Converters/Speckle.Converters.Common/Speckle.Converters.Common.csproj b/CNX-8892/Sdk/Speckle.Converters.Common/Speckle.Converters.Common.csproj similarity index 72% rename from CNX-8892/Converters/Speckle.Converters.Common/Speckle.Converters.Common.csproj rename to CNX-8892/Sdk/Speckle.Converters.Common/Speckle.Converters.Common.csproj index 1980c4b184..766f6bc7b1 100644 --- a/CNX-8892/Converters/Speckle.Converters.Common/Speckle.Converters.Common.csproj +++ b/CNX-8892/Sdk/Speckle.Converters.Common/Speckle.Converters.Common.csproj @@ -1,14 +1,12 @@  - 10.0 - enable netstandard2.0 + enable - diff --git a/CNX-8892/Speckle.Autofac/DependencyInjection/Factory.cs b/CNX-8892/Speckle.Autofac/DependencyInjection/Factory.cs deleted file mode 100644 index caf7f90922..0000000000 --- a/CNX-8892/Speckle.Autofac/DependencyInjection/Factory.cs +++ /dev/null @@ -1,19 +0,0 @@ -using Autofac.Features.Indexed; - -namespace Speckle.Autofac.DependencyInjection; - -public class Factory : IFactory - where T : class -{ - private readonly IIndex _types; - - public Factory(IIndex types) - { - _types = types; - } - - public T ResolveInstance(K strongName) - { - return _types[strongName]; - } -} diff --git a/ConnectorRevit/RevitDUI3/Revit2023DUI3/Revit2023DUI3.csproj b/ConnectorRevit/RevitDUI3/Revit2023DUI3/Revit2023DUI3.csproj index dea154ac98..e892cd3e1a 100644 --- a/ConnectorRevit/RevitDUI3/Revit2023DUI3/Revit2023DUI3.csproj +++ b/ConnectorRevit/RevitDUI3/Revit2023DUI3/Revit2023DUI3.csproj @@ -12,12 +12,6 @@ true $(DefineConstants);REVIT2023 false - AnyCPU;x64 - - - x64 - - x64 diff --git a/DUI3-CNX-8893.slnf b/DUI3-CNX-8893.slnf index 46cc6c5f92..e7d16349a8 100644 --- a/DUI3-CNX-8893.slnf +++ b/DUI3-CNX-8893.slnf @@ -11,8 +11,9 @@ "CNX-8892\\DUI3\\Speckle.Connectors.DUI\\Speckle.Connectors.DUI.csproj", "CNX-8892\\Objects\\Speckle.Objects.Common\\Speckle.Objects.Common.csproj", "CNX-8892\\Objects\\Speckle.Objects.Revit\\Speckle.Objects.Revit.csproj", - "CNX-8892\\Speckle.Autofac\\Speckle.Autofac.csproj", - "CNX-8892\\Speckle.Connectors.Utils\\Speckle.Connectors.Utils.csproj", + "CNX-8892\\Sdk\\Speckle.Autofac\\Speckle.Autofac.csproj", + "CNX-8892\\Sdk\\Speckle.Connectors.Utils\\Speckle.Connectors.Utils.csproj", + "CNX-8892\\Sdk\\Speckle.Converters.Common\\Speckle.Converters.Common.csproj", "ConnectorRevit\\ConnectorRevit2023\\ConnectorRevit2023.csproj", "ConnectorRevit\\ConnectorRevit\\ConnectorRevitShared.shproj", "ConnectorRevit\\RevitDUI3\\Revit2023DUI3\\Revit2023DUI3.csproj", @@ -22,7 +23,6 @@ "Core\\Tests\\Speckle.Core.Tests.Performance\\Speckle.Core.Tests.Performance.csproj", "Core\\Tests\\Speckle.Core.Tests.Unit\\Speckle.Core.Tests.Unit.csproj", "Core\\Transports\\DiskTransport\\DiskTransport.csproj", - "Core\\Transports\\MongoDBTransport\\MongoDBTransport.csproj", "DesktopUI3\\DUI3\\DUI3.csproj", "Objects\\Converters\\ConverterAutocadCivil\\ConverterAdvanceSteel2023\\ConverterAdvanceSteel2023.csproj", "Objects\\Converters\\ConverterAutocadCivil\\ConverterAdvanceSteel2024\\ConverterAdvanceSteel2024.csproj", @@ -35,16 +35,6 @@ "Objects\\Converters\\ConverterAutocadCivil\\ConverterCivil2022\\ConverterCivil2022.csproj", "Objects\\Converters\\ConverterAutocadCivil\\ConverterCivil2023\\ConverterCivil2023.csproj", "Objects\\Converters\\ConverterAutocadCivil\\ConverterCivil2024\\ConverterCivil2024.csproj", - "Objects\\Converters\\ConverterBentley\\ConverterBentleyShared\\ConverterBentleyShared.shproj", - "Objects\\Converters\\ConverterBentley\\ConverterMicroStation\\ConverterMicroStation.csproj", - "Objects\\Converters\\ConverterBentley\\ConverterOpenBuildings\\ConverterOpenBuildings.csproj", - "Objects\\Converters\\ConverterBentley\\ConverterOpenRail\\ConverterOpenRail.csproj", - "Objects\\Converters\\ConverterBentley\\ConverterOpenRoads\\ConverterOpenRoads.csproj", - "Objects\\Converters\\ConverterCSI\\ConverterCSIBridge\\ConverterCSIBridge.csproj", - "Objects\\Converters\\ConverterCSI\\ConverterCSIShared\\ConverterCSIShared.shproj", - "Objects\\Converters\\ConverterCSI\\ConverterETABS\\ConverterETABS.csproj", - "Objects\\Converters\\ConverterCSI\\ConverterSAFE\\ConverterSAFE.csproj", - "Objects\\Converters\\ConverterCSI\\ConverterSAP2000\\ConverterSAP2000.csproj", "Objects\\Converters\\ConverterDxf\\ConverterDxf\\ConverterDxf.csproj", "Objects\\Converters\\ConverterDynamo\\ConverterDynamoRevit2021\\ConverterDynamoRevit2021.csproj", "Objects\\Converters\\ConverterDynamo\\ConverterDynamoRevit2022\\ConverterDynamoRevit2022.csproj", @@ -53,12 +43,6 @@ "Objects\\Converters\\ConverterDynamo\\ConverterDynamoRevit\\ConverterDynamoRevit.csproj", "Objects\\Converters\\ConverterDynamo\\ConverterDynamoSandbox\\ConverterDynamoSandbox.csproj", "Objects\\Converters\\ConverterDynamo\\ConverterDynamoShared\\ConverterDynamoShared.shproj", - "Objects\\Converters\\ConverterNavisworks\\ConverterNavisworks2020\\ConverterNavisworks2020.csproj", - "Objects\\Converters\\ConverterNavisworks\\ConverterNavisworks2021\\ConverterNavisworks2021.csproj", - "Objects\\Converters\\ConverterNavisworks\\ConverterNavisworks2022\\ConverterNavisworks2022.csproj", - "Objects\\Converters\\ConverterNavisworks\\ConverterNavisworks2023\\ConverterNavisworks2023.csproj", - "Objects\\Converters\\ConverterNavisworks\\ConverterNavisworks2024\\ConverterNavisworks2024.csproj", - "Objects\\Converters\\ConverterNavisworks\\ConverterNavisworks\\ConverterNavisworks.shproj", "Objects\\Converters\\ConverterRevit\\ConverterRevit2020\\ConverterRevit2020.csproj", "Objects\\Converters\\ConverterRevit\\ConverterRevit2021\\ConverterRevit2021.csproj", "Objects\\Converters\\ConverterRevit\\ConverterRevit2022\\ConverterRevit2022.csproj", @@ -77,12 +61,6 @@ "Objects\\Converters\\ConverterRhinoGh\\ConverterRhino7\\ConverterRhino7.csproj", "Objects\\Converters\\ConverterRhinoGh\\ConverterRhino8\\ConverterRhino8.csproj", "Objects\\Converters\\ConverterRhinoGh\\ConverterRhinoGhShared\\ConverterRhinoGhShared.shproj", - "Objects\\Converters\\ConverterTeklaStructures\\ConverterTeklaStructures2020\\ConverterTeklaStructures2020.csproj", - "Objects\\Converters\\ConverterTeklaStructures\\ConverterTeklaStructures2021\\ConverterTeklaStructures2021.csproj", - "Objects\\Converters\\ConverterTeklaStructures\\ConverterTeklaStructures2022\\ConverterTeklaStructures2022.csproj", - "Objects\\Converters\\ConverterTeklaStructures\\ConverterTeklaStructures2023\\ConverterTeklaStructures2023.csproj", - "Objects\\Converters\\ConverterTeklaStructures\\ConverterTeklaStructuresShared\\ConverterTeklaStructuresShared.shproj", - "Objects\\Converters\\StructuralUtilities\\PolygonMesher\\PolygonMesher.csproj", "Objects\\Objects\\Objects.csproj", "Objects\\Tests\\Objects.Tests.Unit\\Objects.Tests.Unit.csproj" ] diff --git a/DesktopUI3/DUI3/DUI3.csproj b/DesktopUI3/DUI3/DUI3.csproj index 46a8ea5330..d46e3bbca8 100644 --- a/DesktopUI3/DUI3/DUI3.csproj +++ b/DesktopUI3/DUI3/DUI3.csproj @@ -3,7 +3,6 @@ netstandard2.0 Library - AnyCPU;x64 @@ -11,7 +10,6 @@ - diff --git a/Directory.Build.props b/Directory.Build.props index dbaa3aea2d..6287e38f60 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -40,7 +40,7 @@ CA1303;CA1304;CA1305;CA1307;CA1308;CA1309;CA1310;CA1311;CA2101; NU1701; - CA1815;CA1054;$(NoWarn) + CA1815;CA1054;CA1852;CA1812;CA1003;$(NoWarn) From 7e7db96a1b5c23e527766dc6d2cf6cc87f399cb5 Mon Sep 17 00:00:00 2001 From: BovineOx <73857041+BovineOx@users.noreply.github.com> Date: Mon, 18 Mar 2024 13:17:06 +0100 Subject: [PATCH 008/261] Fixed folder names (#3233) * Fixed folder names Changed CNX proj and folder names and checked Revit still working * Removed x64 Removed x64 back to AnyCPU * Project Config changes Mostly removing Platforms element and ensuring PlatformTarget is present --- All.sln | 388 +++++++++--------- ...ckle.Automate.Sdk.Tests.Integration.csproj | 4 +- .../ConnectorNavisworks2020.csproj | 1 - .../ConnectorNavisworks2021.csproj | 1 - .../ConnectorNavisworks2022.csproj | 1 - .../ConnectorNavisworks2023.csproj | 1 - .../ConnectorNavisworks2024.csproj | 1 - .../Revit2020DUI3/Revit2020DUI3.csproj | 3 +- .../Revit2023DUI3/Revit2023DUI3.csproj | 2 +- .../RevitDUI3Shared/Bindings/SendBinding.cs | 19 +- .../DiskTransport/DiskTransport.csproj | 1 - DUI3-CNX-8893.slnf => DUI3-DX.slnf | 23 +- .../Speckle.Connectors.Revit2023.csproj | 0 .../Speckle.Connectors.Revit2023/app.config | 0 .../Bindings/BasicConnectorBindingRevit.cs | 0 .../Bindings/Filters.cs | 0 .../Bindings/ReceiveBinding.cs | 0 .../Bindings/RevitBaseBinding.cs | 0 .../Bindings/SelectionBinding.cs | 0 .../Bindings/SendBinding.cs | 0 .../DependencyInjection/AutofacUIModule.cs | 2 +- .../HostApp/Elements.cs | 0 .../HostApp/RevitDocumentStore.cs | 0 .../Plugin/CefSharpPanel.xaml | 0 .../Plugin/CefSharpPanel.xaml.cs | 0 .../Plugin/IRevitIdleManager.cs | 0 .../Plugin/IRevitPlugin.cs | 0 .../Plugin/RevitCommand.cs | 0 .../Plugin/RevitContext.cs | 2 - .../Plugin/RevitExternalApplication.cs | 0 .../Plugin/RevitIdleManager.cs | 0 .../Plugin/RevitPlugin.cs | 0 .../Plugin/RevitSettings.cs | 0 .../Plugin/Speckle.Connectors.Revit2023.addin | 0 .../Speckle.Connectors.RevitShared.projitems | 0 .../Speckle.Connectors.RevitShared.shproj | 2 +- .../AutofacRevitConverterModule.cs | 0 ...rters.Revit2023.DependencyInjection.csproj | 0 .../Speckle.Converters.Revit2023.csproj | 0 .../RevitConverterToSpeckle.cs | 0 .../Speckle.Converters.RevitShared.projitems | 0 .../Speckle.Converters.RevitShared.shproj | 4 +- .../ToSpeckle/FloorConversionToSpeckle.cs | 0 .../Bindings/AccountBinding.cs | 0 .../Bindings/IBasicConnectorBinding.cs | 0 .../Bindings/IBinding.cs | 0 .../Bindings/IReceiveBinding.cs | 0 .../Bindings/ISelectionBinding.cs | 0 .../Bindings/ISendBinding.cs | 0 .../Bindings/ISendBindingUICommands.cs | 0 .../Bindings/SendBindingUICommands.cs | 0 .../Bridge/BrowserBridge.cs | 0 .../Speckle.Connectors.DUI/Bridge/IBridge.cs | 0 .../GlobalSuppressions.cs | 0 .../Models/Card/ModelCard.cs | 0 .../Models/DocumentInfo.cs | 0 .../Models/DocumentModelStore.cs | 0 .../Objects/ISpeckleHostObject.cs | 0 .../Settings/CardSetting.cs | 0 .../Speckle.Connectors.DUI.csproj | 0 .../Utils/DiscriminatedObject.cs | 0 .../Utils/DiscriminatedObjectConverter.cs | 0 .../Utils/ModelNotFoundException.cs | 0 .../Utils/PropertyValidator.cs | 0 {CNX-8892 => DUI3-DX}/Directory.Build.Props | 0 .../BuiltElements/Floor.cs | 0 .../BuiltElements/Level.cs | 0 .../Common/EncodingOptimisations.cs | 0 .../Common/IDisplayValue.cs | 0 .../Speckle.Objects.Common/Geometry/Arc.cs | 0 .../Speckle.Objects.Common/Geometry/Box.cs | 0 .../Speckle.Objects.Common/Geometry/Circle.cs | 0 .../Speckle.Objects.Common/Geometry/Curve.cs | 0 .../Geometry/Ellipse.cs | 0 .../Geometry/Interfaces.cs | 0 .../Speckle.Objects.Common/Geometry/Line.cs | 0 .../Speckle.Objects.Common/Geometry/Mesh.cs | 0 .../Speckle.Objects.Common/Geometry/Plane.cs | 0 .../Speckle.Objects.Common/Geometry/Point.cs | 0 .../Geometry/Polycurve.cs | 0 .../Geometry/Polyline.cs | 0 .../Speckle.Objects.Common/Geometry/Vector.cs | 0 .../Primitives/Interval.cs | 0 .../Primitives/Interval2d.cs | 0 .../Speckle.Objects.Common.csproj | 0 .../Speckle.Objects.Common/Utils/Transform.cs | 0 .../Speckle.Objects.Revit.csproj | 0 .../DependencyInjection/AutofacContainer.cs | 1 - .../DependencyInjection/Factory.cs | 0 .../DependencyInjection/IFactory.cs | 0 .../DependencyInjection/IScopedFactory.cs | 0 .../NameAndRankValueAttribute.cs | 0 .../DependencyInjection/NamedTypeInjector.cs | 0 .../DependencyInjection/ScopedFactory.cs | 0 .../Sdk/Speckle.Autofac/Files/IStorageInfo.cs | 0 .../Sdk/Speckle.Autofac/Files/StorageInfo.cs | 0 .../Sdk/Speckle.Autofac/GlobalSuppressions.cs | 0 .../Speckle.Autofac/Speckle.Autofac.csproj | 0 .../Cancellation/CancellationManager.cs | 0 .../Cancellation/ICancelable.cs | 0 .../Reflection/AssemblyExtensions.cs | 0 .../Speckle.Connectors.Utils.csproj | 0 .../SpeckleTopLevelExceptionHandler.cs | 0 .../ISpeckleConverterToHost.cs | 0 .../ISpeckleConverterToSpeckle.cs | 0 .../Objects/FloorConversion.cs | 0 .../Objects/IHostObjectToSpeckleConversion.cs | 0 .../Objects/ISpeckleObjectToHostConversion.cs | 0 .../Speckle.Converters.Common/ReceiveMode.cs | 0 .../Speckle.Converters.Common.csproj | 0 DesktopUI3/DUI3/Bindings/ISendBinding.cs | 2 + .../ConverterNavisworks2020.csproj | 1 - .../ConverterNavisworks2021.csproj | 1 - .../ConverterNavisworks2022.csproj | 1 - .../ConverterNavisworks2023.csproj | 1 - .../ConverterNavisworks2024.csproj | 1 - 116 files changed, 230 insertions(+), 233 deletions(-) rename DUI3-CNX-8893.slnf => DUI3-DX.slnf (80%) rename {CNX-8892 => DUI3-DX}/Connectors/Revit/Speckle.Connectors.Revit2023/Speckle.Connectors.Revit2023.csproj (100%) rename {CNX-8892 => DUI3-DX}/Connectors/Revit/Speckle.Connectors.Revit2023/app.config (100%) rename {CNX-8892 => DUI3-DX}/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/BasicConnectorBindingRevit.cs (100%) rename {CNX-8892 => DUI3-DX}/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/Filters.cs (100%) rename {CNX-8892 => DUI3-DX}/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/ReceiveBinding.cs (100%) rename {CNX-8892 => DUI3-DX}/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/RevitBaseBinding.cs (100%) rename {CNX-8892 => DUI3-DX}/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SelectionBinding.cs (100%) rename {CNX-8892 => DUI3-DX}/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SendBinding.cs (100%) rename {CNX-8892 => DUI3-DX}/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/AutofacUIModule.cs (98%) rename {CNX-8892 => DUI3-DX}/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/Elements.cs (100%) rename {CNX-8892 => DUI3-DX}/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/RevitDocumentStore.cs (100%) rename {CNX-8892 => DUI3-DX}/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/CefSharpPanel.xaml (100%) rename {CNX-8892 => DUI3-DX}/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/CefSharpPanel.xaml.cs (100%) rename {CNX-8892 => DUI3-DX}/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/IRevitIdleManager.cs (100%) rename {CNX-8892 => DUI3-DX}/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/IRevitPlugin.cs (100%) rename {CNX-8892 => DUI3-DX}/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitCommand.cs (100%) rename {CNX-8892 => DUI3-DX}/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitContext.cs (92%) rename {CNX-8892 => DUI3-DX}/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitExternalApplication.cs (100%) rename {CNX-8892 => DUI3-DX}/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitIdleManager.cs (100%) rename {CNX-8892 => DUI3-DX}/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitPlugin.cs (100%) rename {CNX-8892 => DUI3-DX}/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitSettings.cs (100%) rename {CNX-8892 => DUI3-DX}/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/Speckle.Connectors.Revit2023.addin (100%) rename {CNX-8892 => DUI3-DX}/Connectors/Revit/Speckle.Connectors.RevitShared/Speckle.Connectors.RevitShared.projitems (100%) rename {CNX-8892 => DUI3-DX}/Connectors/Revit/Speckle.Connectors.RevitShared/Speckle.Connectors.RevitShared.shproj (93%) rename {CNX-8892 => DUI3-DX}/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/AutofacRevitConverterModule.cs (100%) rename {CNX-8892 => DUI3-DX}/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/Speckle.Converters.Revit2023.DependencyInjection.csproj (100%) rename {CNX-8892 => DUI3-DX}/Converters/Revit/Speckle.Converters.Revit2023/Speckle.Converters.Revit2023.csproj (100%) rename {CNX-8892 => DUI3-DX}/Converters/Revit/Speckle.Converters.RevitShared/RevitConverterToSpeckle.cs (100%) rename {CNX-8892 => DUI3-DX}/Converters/Revit/Speckle.Converters.RevitShared/Speckle.Converters.RevitShared.projitems (100%) rename {CNX-8892 => DUI3-DX}/Converters/Revit/Speckle.Converters.RevitShared/Speckle.Converters.RevitShared.shproj (92%) rename {CNX-8892 => DUI3-DX}/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/FloorConversionToSpeckle.cs (100%) rename {CNX-8892 => DUI3-DX}/DUI3/Speckle.Connectors.DUI/Bindings/AccountBinding.cs (100%) rename {CNX-8892 => DUI3-DX}/DUI3/Speckle.Connectors.DUI/Bindings/IBasicConnectorBinding.cs (100%) rename {CNX-8892 => DUI3-DX}/DUI3/Speckle.Connectors.DUI/Bindings/IBinding.cs (100%) rename {CNX-8892 => DUI3-DX}/DUI3/Speckle.Connectors.DUI/Bindings/IReceiveBinding.cs (100%) rename {CNX-8892 => DUI3-DX}/DUI3/Speckle.Connectors.DUI/Bindings/ISelectionBinding.cs (100%) rename {CNX-8892 => DUI3-DX}/DUI3/Speckle.Connectors.DUI/Bindings/ISendBinding.cs (100%) rename {CNX-8892 => DUI3-DX}/DUI3/Speckle.Connectors.DUI/Bindings/ISendBindingUICommands.cs (100%) rename {CNX-8892 => DUI3-DX}/DUI3/Speckle.Connectors.DUI/Bindings/SendBindingUICommands.cs (100%) rename {CNX-8892 => DUI3-DX}/DUI3/Speckle.Connectors.DUI/Bridge/BrowserBridge.cs (100%) rename {CNX-8892 => DUI3-DX}/DUI3/Speckle.Connectors.DUI/Bridge/IBridge.cs (100%) rename {CNX-8892 => DUI3-DX}/DUI3/Speckle.Connectors.DUI/GlobalSuppressions.cs (100%) rename {CNX-8892 => DUI3-DX}/DUI3/Speckle.Connectors.DUI/Models/Card/ModelCard.cs (100%) rename {CNX-8892 => DUI3-DX}/DUI3/Speckle.Connectors.DUI/Models/DocumentInfo.cs (100%) rename {CNX-8892 => DUI3-DX}/DUI3/Speckle.Connectors.DUI/Models/DocumentModelStore.cs (100%) rename {CNX-8892 => DUI3-DX}/DUI3/Speckle.Connectors.DUI/Objects/ISpeckleHostObject.cs (100%) rename {CNX-8892 => DUI3-DX}/DUI3/Speckle.Connectors.DUI/Settings/CardSetting.cs (100%) rename {CNX-8892 => DUI3-DX}/DUI3/Speckle.Connectors.DUI/Speckle.Connectors.DUI.csproj (100%) rename {CNX-8892 => DUI3-DX}/DUI3/Speckle.Connectors.DUI/Utils/DiscriminatedObject.cs (100%) rename {CNX-8892 => DUI3-DX}/DUI3/Speckle.Connectors.DUI/Utils/DiscriminatedObjectConverter.cs (100%) rename {CNX-8892 => DUI3-DX}/DUI3/Speckle.Connectors.DUI/Utils/ModelNotFoundException.cs (100%) rename {CNX-8892 => DUI3-DX}/DUI3/Speckle.Connectors.DUI/Utils/PropertyValidator.cs (100%) rename {CNX-8892 => DUI3-DX}/Directory.Build.Props (100%) rename {CNX-8892 => DUI3-DX}/Objects/Speckle.Objects.Common/BuiltElements/Floor.cs (100%) rename {CNX-8892 => DUI3-DX}/Objects/Speckle.Objects.Common/BuiltElements/Level.cs (100%) rename {CNX-8892 => DUI3-DX}/Objects/Speckle.Objects.Common/Common/EncodingOptimisations.cs (100%) rename {CNX-8892 => DUI3-DX}/Objects/Speckle.Objects.Common/Common/IDisplayValue.cs (100%) rename {CNX-8892 => DUI3-DX}/Objects/Speckle.Objects.Common/Geometry/Arc.cs (100%) rename {CNX-8892 => DUI3-DX}/Objects/Speckle.Objects.Common/Geometry/Box.cs (100%) rename {CNX-8892 => DUI3-DX}/Objects/Speckle.Objects.Common/Geometry/Circle.cs (100%) rename {CNX-8892 => DUI3-DX}/Objects/Speckle.Objects.Common/Geometry/Curve.cs (100%) rename {CNX-8892 => DUI3-DX}/Objects/Speckle.Objects.Common/Geometry/Ellipse.cs (100%) rename {CNX-8892 => DUI3-DX}/Objects/Speckle.Objects.Common/Geometry/Interfaces.cs (100%) rename {CNX-8892 => DUI3-DX}/Objects/Speckle.Objects.Common/Geometry/Line.cs (100%) rename {CNX-8892 => DUI3-DX}/Objects/Speckle.Objects.Common/Geometry/Mesh.cs (100%) rename {CNX-8892 => DUI3-DX}/Objects/Speckle.Objects.Common/Geometry/Plane.cs (100%) rename {CNX-8892 => DUI3-DX}/Objects/Speckle.Objects.Common/Geometry/Point.cs (100%) rename {CNX-8892 => DUI3-DX}/Objects/Speckle.Objects.Common/Geometry/Polycurve.cs (100%) rename {CNX-8892 => DUI3-DX}/Objects/Speckle.Objects.Common/Geometry/Polyline.cs (100%) rename {CNX-8892 => DUI3-DX}/Objects/Speckle.Objects.Common/Geometry/Vector.cs (100%) rename {CNX-8892 => DUI3-DX}/Objects/Speckle.Objects.Common/Primitives/Interval.cs (100%) rename {CNX-8892 => DUI3-DX}/Objects/Speckle.Objects.Common/Primitives/Interval2d.cs (100%) rename {CNX-8892 => DUI3-DX}/Objects/Speckle.Objects.Common/Speckle.Objects.Common.csproj (100%) rename {CNX-8892 => DUI3-DX}/Objects/Speckle.Objects.Common/Utils/Transform.cs (100%) rename {CNX-8892 => DUI3-DX}/Objects/Speckle.Objects.Revit/Speckle.Objects.Revit.csproj (100%) rename {CNX-8892 => DUI3-DX}/Sdk/Speckle.Autofac/DependencyInjection/AutofacContainer.cs (99%) rename {CNX-8892 => DUI3-DX}/Sdk/Speckle.Autofac/DependencyInjection/Factory.cs (100%) rename {CNX-8892 => DUI3-DX}/Sdk/Speckle.Autofac/DependencyInjection/IFactory.cs (100%) rename {CNX-8892 => DUI3-DX}/Sdk/Speckle.Autofac/DependencyInjection/IScopedFactory.cs (100%) rename {CNX-8892 => DUI3-DX}/Sdk/Speckle.Autofac/DependencyInjection/NameAndRankValueAttribute.cs (100%) rename {CNX-8892 => DUI3-DX}/Sdk/Speckle.Autofac/DependencyInjection/NamedTypeInjector.cs (100%) rename {CNX-8892 => DUI3-DX}/Sdk/Speckle.Autofac/DependencyInjection/ScopedFactory.cs (100%) rename {CNX-8892 => DUI3-DX}/Sdk/Speckle.Autofac/Files/IStorageInfo.cs (100%) rename {CNX-8892 => DUI3-DX}/Sdk/Speckle.Autofac/Files/StorageInfo.cs (100%) rename {CNX-8892 => DUI3-DX}/Sdk/Speckle.Autofac/GlobalSuppressions.cs (100%) rename {CNX-8892 => DUI3-DX}/Sdk/Speckle.Autofac/Speckle.Autofac.csproj (100%) rename {CNX-8892 => DUI3-DX}/Sdk/Speckle.Connectors.Utils/Cancellation/CancellationManager.cs (100%) rename {CNX-8892 => DUI3-DX}/Sdk/Speckle.Connectors.Utils/Cancellation/ICancelable.cs (100%) rename {CNX-8892 => DUI3-DX}/Sdk/Speckle.Connectors.Utils/Reflection/AssemblyExtensions.cs (100%) rename {CNX-8892 => DUI3-DX}/Sdk/Speckle.Connectors.Utils/Speckle.Connectors.Utils.csproj (100%) rename {CNX-8892 => DUI3-DX}/Sdk/Speckle.Connectors.Utils/SpeckleTopLevelExceptionHandler.cs (100%) rename {CNX-8892 => DUI3-DX}/Sdk/Speckle.Converters.Common/ISpeckleConverterToHost.cs (100%) rename {CNX-8892 => DUI3-DX}/Sdk/Speckle.Converters.Common/ISpeckleConverterToSpeckle.cs (100%) rename {CNX-8892 => DUI3-DX}/Sdk/Speckle.Converters.Common/Objects/FloorConversion.cs (100%) rename {CNX-8892 => DUI3-DX}/Sdk/Speckle.Converters.Common/Objects/IHostObjectToSpeckleConversion.cs (100%) rename {CNX-8892 => DUI3-DX}/Sdk/Speckle.Converters.Common/Objects/ISpeckleObjectToHostConversion.cs (100%) rename {CNX-8892 => DUI3-DX}/Sdk/Speckle.Converters.Common/ReceiveMode.cs (100%) rename {CNX-8892 => DUI3-DX}/Sdk/Speckle.Converters.Common/Speckle.Converters.Common.csproj (100%) diff --git a/All.sln b/All.sln index a354775543..a3def65093 100644 --- a/All.sln +++ b/All.sln @@ -481,7 +481,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{8A909E95 EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Objects.Tests.Unit", "Objects\Tests\Objects.Tests.Unit\Objects.Tests.Unit.csproj", "{9E74F0E6-94B4-46BD-B1CA-DD874B459399}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "CNX-8892", "CNX-8892", "{9DB74760-01DE-4AC1-A81B-BC7784351D22}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "DUI3-DX", "DUI3-DX", "{9DB74760-01DE-4AC1-A81B-BC7784351D22}" ProjectSection(SolutionItems) = preProject CNX-8892\Directory.Build.Props = CNX-8892\Directory.Build.Props EndProjectSection @@ -494,33 +494,33 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Objects", "Objects", "{B92E EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Converters", "Converters", "{1FE3C60E-7865-40A5-9794-55ECB64F6489}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Speckle.Connectors.Revit2023", "CNX-8892\Connectors\Revit\Speckle.Connectors.Revit2023\Speckle.Connectors.Revit2023.csproj", "{E1FF75EC-2BDF-4276-9C81-6EB195661348}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "DUI3", "DUI3", "{FD4D6594-D81E-456F-8F2E-35B09E04A755}" EndProject -Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Speckle.Connectors.RevitShared", "CNX-8892\Connectors\Revit\Speckle.Connectors.RevitShared\Speckle.Connectors.RevitShared.shproj", "{32AEA787-C986-4B76-A57F-0DA5453AA1F5}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Revit", "Revit", "{D92751C8-1039-4005-90B2-913E55E0B8BD}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "DUI3", "DUI3", "{FD4D6594-D81E-456F-8F2E-35B09E04A755}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Sdk", "Sdk", "{2E00592E-558D-492D-88F9-3ECEE4C0C7DA}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Speckle.Connectors.DUI", "CNX-8892\DUI3\Speckle.Connectors.DUI\Speckle.Connectors.DUI.csproj", "{86E64130-2DCE-4F51-B07C-B87138046E21}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Speckle.Connectors.Revit2023", "DUI3-DX\Connectors\Revit\Speckle.Connectors.Revit2023\Speckle.Connectors.Revit2023.csproj", "{01F98733-7352-47AD-A594-537D979DE3DE}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Speckle.Converters.Revit2023", "CNX-8892\Converters\Revit\Speckle.Converters.Revit2023\Speckle.Converters.Revit2023.csproj", "{E577F692-C9E9-46A6-B9F1-CF70C93F1280}" +Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Speckle.Connectors.RevitShared", "DUI3-DX\Connectors\Revit\Speckle.Connectors.RevitShared\Speckle.Connectors.RevitShared.shproj", "{DC570FFF-6FE5-47BD-8BC1-B471A6067786}" EndProject -Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Speckle.Converters.RevitShared", "CNX-8892\Converters\Revit\Speckle.Converters.RevitShared\Speckle.Converters.RevitShared.shproj", "{9655BE78-8070-4B9F-B0DC-68BB6150B52C}" +Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Speckle.Converters.RevitShared", "DUI3-DX\Converters\Revit\Speckle.Converters.RevitShared\Speckle.Converters.RevitShared.shproj", "{E1C43415-3200-45F4-8BF9-A4DD7D7F2ED6}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Revit", "Revit", "{D92751C8-1039-4005-90B2-913E55E0B8BD}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Speckle.Converters.Revit2023.DependencyInjection", "DUI3-DX\Converters\Revit\Speckle.Converters.Revit2023.DependencyInjection\Speckle.Converters.Revit2023.DependencyInjection.csproj", "{83EAD6F0-3CB3-456A-AD81-072127D0DE0E}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Speckle.Objects.Common", "CNX-8892\Objects\Speckle.Objects.Common\Speckle.Objects.Common.csproj", "{746047E4-BE3D-43D0-99E0-76259D262AC6}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Speckle.Converters.Revit2023", "DUI3-DX\Converters\Revit\Speckle.Converters.Revit2023\Speckle.Converters.Revit2023.csproj", "{26391930-F86F-47E0-A5F6-B89919E38CE1}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Speckle.Objects.Revit", "CNX-8892\Objects\Speckle.Objects.Revit\Speckle.Objects.Revit.csproj", "{D32342E4-3223-48A0-8DF6-A1475BE27628}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Speckle.Connectors.DUI", "DUI3-DX\DUI3\Speckle.Connectors.DUI\Speckle.Connectors.DUI.csproj", "{D81C0B87-F0C1-4297-A147-02F001FB7E1E}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Speckle.Converters.Revit2023.DependencyInjection", "CNX-8892\Converters\Revit\Speckle.Converters.Revit2023.DependencyInjection\Speckle.Converters.Revit2023.DependencyInjection.csproj", "{81F92B31-C647-4A82-A464-8322814F50E6}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Speckle.Objects.Common", "DUI3-DX\Objects\Speckle.Objects.Common\Speckle.Objects.Common.csproj", "{CC968B23-CEED-4543-8629-808F7E66E815}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Sdk", "Sdk", "{2E00592E-558D-492D-88F9-3ECEE4C0C7DA}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Speckle.Objects.Revit", "DUI3-DX\Objects\Speckle.Objects.Revit\Speckle.Objects.Revit.csproj", "{01E762F1-C176-40B9-BA3E-9B1FECAF04FF}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Speckle.Autofac", "CNX-8892\Sdk\Speckle.Autofac\Speckle.Autofac.csproj", "{7661D48B-9B2C-4549-AE6C-EE07914A1DE6}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Speckle.Autofac", "DUI3-DX\Sdk\Speckle.Autofac\Speckle.Autofac.csproj", "{C9D4CA21-182B-4ED2-81BB-280A6FD713F6}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Speckle.Connectors.Utils", "CNX-8892\Sdk\Speckle.Connectors.Utils\Speckle.Connectors.Utils.csproj", "{12173832-4E42-4879-B37E-30B34A72B06D}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Speckle.Connectors.Utils", "DUI3-DX\Sdk\Speckle.Connectors.Utils\Speckle.Connectors.Utils.csproj", "{7291B93C-615D-42DE-B8C1-3F9DF643E0FC}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Speckle.Converters.Common", "CNX-8892\Sdk\Speckle.Converters.Common\Speckle.Converters.Common.csproj", "{3954A8FD-6D5A-4A42-BED0-383A2EF40B57}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Speckle.Converters.Common", "DUI3-DX\Sdk\Speckle.Converters.Common\Speckle.Converters.Common.csproj", "{8AEF06C0-CA5C-4460-BC2D-ADE5F35D0434}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -1403,8 +1403,8 @@ Global {74E39841-B2FA-494D-AC40-A6E505DE6B33}.Debug Mac|x64.Build.0 = Debug|x64 {74E39841-B2FA-494D-AC40-A6E505DE6B33}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {74E39841-B2FA-494D-AC40-A6E505DE6B33}.Debug|Any CPU.Build.0 = Debug|Any CPU - {74E39841-B2FA-494D-AC40-A6E505DE6B33}.Debug|x64.ActiveCfg = Debug|x64 - {74E39841-B2FA-494D-AC40-A6E505DE6B33}.Debug|x64.Build.0 = Debug|x64 + {74E39841-B2FA-494D-AC40-A6E505DE6B33}.Debug|x64.ActiveCfg = Debug|Any CPU + {74E39841-B2FA-494D-AC40-A6E505DE6B33}.Debug|x64.Build.0 = Debug|Any CPU {74E39841-B2FA-494D-AC40-A6E505DE6B33}.Release Mac|Any CPU.ActiveCfg = Release|Any CPU {74E39841-B2FA-494D-AC40-A6E505DE6B33}.Release Mac|Any CPU.Build.0 = Release|Any CPU {74E39841-B2FA-494D-AC40-A6E505DE6B33}.Release Mac|x64.ActiveCfg = Release|x64 @@ -1418,8 +1418,8 @@ Global {77D4F346-ACA5-42C8-8522-5EF176F3ADF1}.Debug Mac|x64.Build.0 = Debug|x64 {77D4F346-ACA5-42C8-8522-5EF176F3ADF1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {77D4F346-ACA5-42C8-8522-5EF176F3ADF1}.Debug|Any CPU.Build.0 = Debug|Any CPU - {77D4F346-ACA5-42C8-8522-5EF176F3ADF1}.Debug|x64.ActiveCfg = Debug|x64 - {77D4F346-ACA5-42C8-8522-5EF176F3ADF1}.Debug|x64.Build.0 = Debug|x64 + {77D4F346-ACA5-42C8-8522-5EF176F3ADF1}.Debug|x64.ActiveCfg = Debug|Any CPU + {77D4F346-ACA5-42C8-8522-5EF176F3ADF1}.Debug|x64.Build.0 = Debug|Any CPU {77D4F346-ACA5-42C8-8522-5EF176F3ADF1}.Release Mac|Any CPU.ActiveCfg = Release|Any CPU {77D4F346-ACA5-42C8-8522-5EF176F3ADF1}.Release Mac|Any CPU.Build.0 = Release|Any CPU {77D4F346-ACA5-42C8-8522-5EF176F3ADF1}.Release Mac|x64.ActiveCfg = Release|x64 @@ -1433,8 +1433,8 @@ Global {DEBC2174-5E31-4B6E-8680-690D75E50E2D}.Debug Mac|x64.Build.0 = Debug|x64 {DEBC2174-5E31-4B6E-8680-690D75E50E2D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {DEBC2174-5E31-4B6E-8680-690D75E50E2D}.Debug|Any CPU.Build.0 = Debug|Any CPU - {DEBC2174-5E31-4B6E-8680-690D75E50E2D}.Debug|x64.ActiveCfg = Debug|x64 - {DEBC2174-5E31-4B6E-8680-690D75E50E2D}.Debug|x64.Build.0 = Debug|x64 + {DEBC2174-5E31-4B6E-8680-690D75E50E2D}.Debug|x64.ActiveCfg = Debug|Any CPU + {DEBC2174-5E31-4B6E-8680-690D75E50E2D}.Debug|x64.Build.0 = Debug|Any CPU {DEBC2174-5E31-4B6E-8680-690D75E50E2D}.Release Mac|Any CPU.ActiveCfg = Release|Any CPU {DEBC2174-5E31-4B6E-8680-690D75E50E2D}.Release Mac|Any CPU.Build.0 = Release|Any CPU {DEBC2174-5E31-4B6E-8680-690D75E50E2D}.Release Mac|x64.ActiveCfg = Release|x64 @@ -1448,8 +1448,8 @@ Global {9A7D7F9A-4FE1-4053-950B-50B43BC81087}.Debug Mac|x64.Build.0 = Debug|x64 {9A7D7F9A-4FE1-4053-950B-50B43BC81087}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {9A7D7F9A-4FE1-4053-950B-50B43BC81087}.Debug|Any CPU.Build.0 = Debug|Any CPU - {9A7D7F9A-4FE1-4053-950B-50B43BC81087}.Debug|x64.ActiveCfg = Debug|x64 - {9A7D7F9A-4FE1-4053-950B-50B43BC81087}.Debug|x64.Build.0 = Debug|x64 + {9A7D7F9A-4FE1-4053-950B-50B43BC81087}.Debug|x64.ActiveCfg = Debug|Any CPU + {9A7D7F9A-4FE1-4053-950B-50B43BC81087}.Debug|x64.Build.0 = Debug|Any CPU {9A7D7F9A-4FE1-4053-950B-50B43BC81087}.Release Mac|Any CPU.ActiveCfg = Release|Any CPU {9A7D7F9A-4FE1-4053-950B-50B43BC81087}.Release Mac|Any CPU.Build.0 = Release|Any CPU {9A7D7F9A-4FE1-4053-950B-50B43BC81087}.Release Mac|x64.ActiveCfg = Release|x64 @@ -1795,8 +1795,8 @@ Global {5F8E5DD7-386E-46A6-85E4-1318CBCC4BA1}.Debug Mac|x64.Build.0 = Debug|x64 {5F8E5DD7-386E-46A6-85E4-1318CBCC4BA1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {5F8E5DD7-386E-46A6-85E4-1318CBCC4BA1}.Debug|Any CPU.Build.0 = Debug|Any CPU - {5F8E5DD7-386E-46A6-85E4-1318CBCC4BA1}.Debug|x64.ActiveCfg = Debug|x64 - {5F8E5DD7-386E-46A6-85E4-1318CBCC4BA1}.Debug|x64.Build.0 = Debug|x64 + {5F8E5DD7-386E-46A6-85E4-1318CBCC4BA1}.Debug|x64.ActiveCfg = Debug|Any CPU + {5F8E5DD7-386E-46A6-85E4-1318CBCC4BA1}.Debug|x64.Build.0 = Debug|Any CPU {5F8E5DD7-386E-46A6-85E4-1318CBCC4BA1}.Release Mac|Any CPU.ActiveCfg = Release|Any CPU {5F8E5DD7-386E-46A6-85E4-1318CBCC4BA1}.Release Mac|Any CPU.Build.0 = Release|Any CPU {5F8E5DD7-386E-46A6-85E4-1318CBCC4BA1}.Release Mac|x64.ActiveCfg = Release|x64 @@ -1810,8 +1810,8 @@ Global {2568500E-F1BC-440E-9150-DB4820B3FAD6}.Debug Mac|x64.Build.0 = Debug|x64 {2568500E-F1BC-440E-9150-DB4820B3FAD6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {2568500E-F1BC-440E-9150-DB4820B3FAD6}.Debug|Any CPU.Build.0 = Debug|Any CPU - {2568500E-F1BC-440E-9150-DB4820B3FAD6}.Debug|x64.ActiveCfg = Debug|x64 - {2568500E-F1BC-440E-9150-DB4820B3FAD6}.Debug|x64.Build.0 = Debug|x64 + {2568500E-F1BC-440E-9150-DB4820B3FAD6}.Debug|x64.ActiveCfg = Debug|Any CPU + {2568500E-F1BC-440E-9150-DB4820B3FAD6}.Debug|x64.Build.0 = Debug|Any CPU {2568500E-F1BC-440E-9150-DB4820B3FAD6}.Release Mac|Any CPU.ActiveCfg = Release|Any CPU {2568500E-F1BC-440E-9150-DB4820B3FAD6}.Release Mac|Any CPU.Build.0 = Release|Any CPU {2568500E-F1BC-440E-9150-DB4820B3FAD6}.Release Mac|x64.ActiveCfg = Release|x64 @@ -2146,8 +2146,8 @@ Global {AF51DD10-C0D5-4209-AF55-8F6476EA8A99}.Debug Mac|x64.Build.0 = Debug|Any CPU {AF51DD10-C0D5-4209-AF55-8F6476EA8A99}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {AF51DD10-C0D5-4209-AF55-8F6476EA8A99}.Debug|Any CPU.Build.0 = Debug|Any CPU - {AF51DD10-C0D5-4209-AF55-8F6476EA8A99}.Debug|x64.ActiveCfg = Debug|Any CPU - {AF51DD10-C0D5-4209-AF55-8F6476EA8A99}.Debug|x64.Build.0 = Debug|Any CPU + {AF51DD10-C0D5-4209-AF55-8F6476EA8A99}.Debug|x64.ActiveCfg = Debug|x64 + {AF51DD10-C0D5-4209-AF55-8F6476EA8A99}.Debug|x64.Build.0 = Debug|x64 {AF51DD10-C0D5-4209-AF55-8F6476EA8A99}.Release Mac|Any CPU.ActiveCfg = Debug|Any CPU {AF51DD10-C0D5-4209-AF55-8F6476EA8A99}.Release Mac|Any CPU.Build.0 = Debug|Any CPU {AF51DD10-C0D5-4209-AF55-8F6476EA8A99}.Release Mac|x64.ActiveCfg = Debug|Any CPU @@ -2162,8 +2162,8 @@ Global {A0C9EBE0-A56A-4D07-B6EF-2EEAEC45D6C4}.Debug Mac|x64.Build.0 = Debug|Any CPU {A0C9EBE0-A56A-4D07-B6EF-2EEAEC45D6C4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {A0C9EBE0-A56A-4D07-B6EF-2EEAEC45D6C4}.Debug|Any CPU.Build.0 = Debug|Any CPU - {A0C9EBE0-A56A-4D07-B6EF-2EEAEC45D6C4}.Debug|x64.ActiveCfg = Debug|Any CPU - {A0C9EBE0-A56A-4D07-B6EF-2EEAEC45D6C4}.Debug|x64.Build.0 = Debug|Any CPU + {A0C9EBE0-A56A-4D07-B6EF-2EEAEC45D6C4}.Debug|x64.ActiveCfg = Debug|x64 + {A0C9EBE0-A56A-4D07-B6EF-2EEAEC45D6C4}.Debug|x64.Build.0 = Debug|x64 {A0C9EBE0-A56A-4D07-B6EF-2EEAEC45D6C4}.Release Mac|Any CPU.ActiveCfg = Debug|Any CPU {A0C9EBE0-A56A-4D07-B6EF-2EEAEC45D6C4}.Release Mac|Any CPU.Build.0 = Debug|Any CPU {A0C9EBE0-A56A-4D07-B6EF-2EEAEC45D6C4}.Release Mac|x64.ActiveCfg = Debug|Any CPU @@ -2274,8 +2274,8 @@ Global {2113F03B-BB8D-470B-A9A1-97BB9A554A44}.Debug Mac|x64.Build.0 = Debug|Any CPU {2113F03B-BB8D-470B-A9A1-97BB9A554A44}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {2113F03B-BB8D-470B-A9A1-97BB9A554A44}.Debug|Any CPU.Build.0 = Debug|Any CPU - {2113F03B-BB8D-470B-A9A1-97BB9A554A44}.Debug|x64.ActiveCfg = Debug|x64 - {2113F03B-BB8D-470B-A9A1-97BB9A554A44}.Debug|x64.Build.0 = Debug|x64 + {2113F03B-BB8D-470B-A9A1-97BB9A554A44}.Debug|x64.ActiveCfg = Debug|Any CPU + {2113F03B-BB8D-470B-A9A1-97BB9A554A44}.Debug|x64.Build.0 = Debug|Any CPU {2113F03B-BB8D-470B-A9A1-97BB9A554A44}.Release Mac|Any CPU.ActiveCfg = Debug|Any CPU {2113F03B-BB8D-470B-A9A1-97BB9A554A44}.Release Mac|Any CPU.Build.0 = Debug|Any CPU {2113F03B-BB8D-470B-A9A1-97BB9A554A44}.Release Mac|x64.ActiveCfg = Debug|Any CPU @@ -2301,8 +2301,6 @@ Global {A364B196-38A3-45AB-A54A-F04D17C0B2DA}.Release|x64.ActiveCfg = Release|x64 {A364B196-38A3-45AB-A54A-F04D17C0B2DA}.Release|x64.Build.0 = Release|x64 {D22A887D-976C-4DBF-AE5B-9039F169E61C}.Debug Mac|Any CPU.ActiveCfg = Debug Mac|Any CPU - {D22A887D-976C-4DBF-AE5B-9039F169E61C}.Debug Mac|Any CPU.ActiveCfg = Debug Mac|Any CPU - {D22A887D-976C-4DBF-AE5B-9039F169E61C}.Debug Mac|Any CPU.ActiveCfg = Debug Mac|Any CPU {D22A887D-976C-4DBF-AE5B-9039F169E61C}.Debug Mac|x64.ActiveCfg = Debug|Any CPU {D22A887D-976C-4DBF-AE5B-9039F169E61C}.Debug Mac|x64.Build.0 = Debug|Any CPU {D22A887D-976C-4DBF-AE5B-9039F169E61C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU @@ -2438,150 +2436,150 @@ Global {9E74F0E6-94B4-46BD-B1CA-DD874B459399}.Release|Any CPU.Build.0 = Release|Any CPU {9E74F0E6-94B4-46BD-B1CA-DD874B459399}.Release|x64.ActiveCfg = Release|Any CPU {9E74F0E6-94B4-46BD-B1CA-DD874B459399}.Release|x64.Build.0 = Release|Any CPU - {E1FF75EC-2BDF-4276-9C81-6EB195661348}.Debug Mac|Any CPU.ActiveCfg = Debug|Any CPU - {E1FF75EC-2BDF-4276-9C81-6EB195661348}.Debug Mac|Any CPU.Build.0 = Debug|Any CPU - {E1FF75EC-2BDF-4276-9C81-6EB195661348}.Debug Mac|x64.ActiveCfg = Debug|Any CPU - {E1FF75EC-2BDF-4276-9C81-6EB195661348}.Debug Mac|x64.Build.0 = Debug|Any CPU - {E1FF75EC-2BDF-4276-9C81-6EB195661348}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {E1FF75EC-2BDF-4276-9C81-6EB195661348}.Debug|Any CPU.Build.0 = Debug|Any CPU - {E1FF75EC-2BDF-4276-9C81-6EB195661348}.Debug|x64.ActiveCfg = Debug|x64 - {E1FF75EC-2BDF-4276-9C81-6EB195661348}.Debug|x64.Build.0 = Debug|x64 - {E1FF75EC-2BDF-4276-9C81-6EB195661348}.Release Mac|Any CPU.ActiveCfg = Release|Any CPU - {E1FF75EC-2BDF-4276-9C81-6EB195661348}.Release Mac|Any CPU.Build.0 = Release|Any CPU - {E1FF75EC-2BDF-4276-9C81-6EB195661348}.Release Mac|x64.ActiveCfg = Release|Any CPU - {E1FF75EC-2BDF-4276-9C81-6EB195661348}.Release Mac|x64.Build.0 = Release|Any CPU - {E1FF75EC-2BDF-4276-9C81-6EB195661348}.Release|Any CPU.ActiveCfg = Release|Any CPU - {E1FF75EC-2BDF-4276-9C81-6EB195661348}.Release|Any CPU.Build.0 = Release|Any CPU - {E1FF75EC-2BDF-4276-9C81-6EB195661348}.Release|x64.ActiveCfg = Release|Any CPU - {E1FF75EC-2BDF-4276-9C81-6EB195661348}.Release|x64.Build.0 = Release|Any CPU - {86E64130-2DCE-4F51-B07C-B87138046E21}.Debug Mac|Any CPU.ActiveCfg = Debug|Any CPU - {86E64130-2DCE-4F51-B07C-B87138046E21}.Debug Mac|Any CPU.Build.0 = Debug|Any CPU - {86E64130-2DCE-4F51-B07C-B87138046E21}.Debug Mac|x64.ActiveCfg = Debug|Any CPU - {86E64130-2DCE-4F51-B07C-B87138046E21}.Debug Mac|x64.Build.0 = Debug|Any CPU - {86E64130-2DCE-4F51-B07C-B87138046E21}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {86E64130-2DCE-4F51-B07C-B87138046E21}.Debug|Any CPU.Build.0 = Debug|Any CPU - {86E64130-2DCE-4F51-B07C-B87138046E21}.Debug|x64.ActiveCfg = Debug|x64 - {86E64130-2DCE-4F51-B07C-B87138046E21}.Debug|x64.Build.0 = Debug|x64 - {86E64130-2DCE-4F51-B07C-B87138046E21}.Release Mac|Any CPU.ActiveCfg = Release|Any CPU - {86E64130-2DCE-4F51-B07C-B87138046E21}.Release Mac|Any CPU.Build.0 = Release|Any CPU - {86E64130-2DCE-4F51-B07C-B87138046E21}.Release Mac|x64.ActiveCfg = Release|Any CPU - {86E64130-2DCE-4F51-B07C-B87138046E21}.Release Mac|x64.Build.0 = Release|Any CPU - {86E64130-2DCE-4F51-B07C-B87138046E21}.Release|Any CPU.ActiveCfg = Release|Any CPU - {86E64130-2DCE-4F51-B07C-B87138046E21}.Release|Any CPU.Build.0 = Release|Any CPU - {86E64130-2DCE-4F51-B07C-B87138046E21}.Release|x64.ActiveCfg = Release|Any CPU - {86E64130-2DCE-4F51-B07C-B87138046E21}.Release|x64.Build.0 = Release|Any CPU - {E577F692-C9E9-46A6-B9F1-CF70C93F1280}.Debug Mac|Any CPU.ActiveCfg = Debug|Any CPU - {E577F692-C9E9-46A6-B9F1-CF70C93F1280}.Debug Mac|Any CPU.Build.0 = Debug|Any CPU - {E577F692-C9E9-46A6-B9F1-CF70C93F1280}.Debug Mac|x64.ActiveCfg = Debug|Any CPU - {E577F692-C9E9-46A6-B9F1-CF70C93F1280}.Debug Mac|x64.Build.0 = Debug|Any CPU - {E577F692-C9E9-46A6-B9F1-CF70C93F1280}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {E577F692-C9E9-46A6-B9F1-CF70C93F1280}.Debug|Any CPU.Build.0 = Debug|Any CPU - {E577F692-C9E9-46A6-B9F1-CF70C93F1280}.Debug|x64.ActiveCfg = Debug|Any CPU - {E577F692-C9E9-46A6-B9F1-CF70C93F1280}.Debug|x64.Build.0 = Debug|Any CPU - {E577F692-C9E9-46A6-B9F1-CF70C93F1280}.Release Mac|Any CPU.ActiveCfg = Release|Any CPU - {E577F692-C9E9-46A6-B9F1-CF70C93F1280}.Release Mac|Any CPU.Build.0 = Release|Any CPU - {E577F692-C9E9-46A6-B9F1-CF70C93F1280}.Release Mac|x64.ActiveCfg = Release|Any CPU - {E577F692-C9E9-46A6-B9F1-CF70C93F1280}.Release Mac|x64.Build.0 = Release|Any CPU - {E577F692-C9E9-46A6-B9F1-CF70C93F1280}.Release|Any CPU.ActiveCfg = Release|Any CPU - {E577F692-C9E9-46A6-B9F1-CF70C93F1280}.Release|Any CPU.Build.0 = Release|Any CPU - {E577F692-C9E9-46A6-B9F1-CF70C93F1280}.Release|x64.ActiveCfg = Release|Any CPU - {E577F692-C9E9-46A6-B9F1-CF70C93F1280}.Release|x64.Build.0 = Release|Any CPU - {746047E4-BE3D-43D0-99E0-76259D262AC6}.Debug Mac|Any CPU.ActiveCfg = Debug|Any CPU - {746047E4-BE3D-43D0-99E0-76259D262AC6}.Debug Mac|Any CPU.Build.0 = Debug|Any CPU - {746047E4-BE3D-43D0-99E0-76259D262AC6}.Debug Mac|x64.ActiveCfg = Debug|Any CPU - {746047E4-BE3D-43D0-99E0-76259D262AC6}.Debug Mac|x64.Build.0 = Debug|Any CPU - {746047E4-BE3D-43D0-99E0-76259D262AC6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {746047E4-BE3D-43D0-99E0-76259D262AC6}.Debug|Any CPU.Build.0 = Debug|Any CPU - {746047E4-BE3D-43D0-99E0-76259D262AC6}.Debug|x64.ActiveCfg = Debug|Any CPU - {746047E4-BE3D-43D0-99E0-76259D262AC6}.Debug|x64.Build.0 = Debug|Any CPU - {746047E4-BE3D-43D0-99E0-76259D262AC6}.Release Mac|Any CPU.ActiveCfg = Release|Any CPU - {746047E4-BE3D-43D0-99E0-76259D262AC6}.Release Mac|Any CPU.Build.0 = Release|Any CPU - {746047E4-BE3D-43D0-99E0-76259D262AC6}.Release Mac|x64.ActiveCfg = Release|Any CPU - {746047E4-BE3D-43D0-99E0-76259D262AC6}.Release Mac|x64.Build.0 = Release|Any CPU - {746047E4-BE3D-43D0-99E0-76259D262AC6}.Release|Any CPU.ActiveCfg = Release|Any CPU - {746047E4-BE3D-43D0-99E0-76259D262AC6}.Release|Any CPU.Build.0 = Release|Any CPU - {746047E4-BE3D-43D0-99E0-76259D262AC6}.Release|x64.ActiveCfg = Release|Any CPU - {746047E4-BE3D-43D0-99E0-76259D262AC6}.Release|x64.Build.0 = Release|Any CPU - {D32342E4-3223-48A0-8DF6-A1475BE27628}.Debug Mac|Any CPU.ActiveCfg = Debug|Any CPU - {D32342E4-3223-48A0-8DF6-A1475BE27628}.Debug Mac|Any CPU.Build.0 = Debug|Any CPU - {D32342E4-3223-48A0-8DF6-A1475BE27628}.Debug Mac|x64.ActiveCfg = Debug|Any CPU - {D32342E4-3223-48A0-8DF6-A1475BE27628}.Debug Mac|x64.Build.0 = Debug|Any CPU - {D32342E4-3223-48A0-8DF6-A1475BE27628}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {D32342E4-3223-48A0-8DF6-A1475BE27628}.Debug|Any CPU.Build.0 = Debug|Any CPU - {D32342E4-3223-48A0-8DF6-A1475BE27628}.Debug|x64.ActiveCfg = Debug|Any CPU - {D32342E4-3223-48A0-8DF6-A1475BE27628}.Debug|x64.Build.0 = Debug|Any CPU - {D32342E4-3223-48A0-8DF6-A1475BE27628}.Release Mac|Any CPU.ActiveCfg = Release|Any CPU - {D32342E4-3223-48A0-8DF6-A1475BE27628}.Release Mac|Any CPU.Build.0 = Release|Any CPU - {D32342E4-3223-48A0-8DF6-A1475BE27628}.Release Mac|x64.ActiveCfg = Release|Any CPU - {D32342E4-3223-48A0-8DF6-A1475BE27628}.Release Mac|x64.Build.0 = Release|Any CPU - {D32342E4-3223-48A0-8DF6-A1475BE27628}.Release|Any CPU.ActiveCfg = Release|Any CPU - {D32342E4-3223-48A0-8DF6-A1475BE27628}.Release|Any CPU.Build.0 = Release|Any CPU - {D32342E4-3223-48A0-8DF6-A1475BE27628}.Release|x64.ActiveCfg = Release|Any CPU - {D32342E4-3223-48A0-8DF6-A1475BE27628}.Release|x64.Build.0 = Release|Any CPU - {81F92B31-C647-4A82-A464-8322814F50E6}.Debug Mac|Any CPU.ActiveCfg = Debug|Any CPU - {81F92B31-C647-4A82-A464-8322814F50E6}.Debug Mac|Any CPU.Build.0 = Debug|Any CPU - {81F92B31-C647-4A82-A464-8322814F50E6}.Debug Mac|x64.ActiveCfg = Debug|Any CPU - {81F92B31-C647-4A82-A464-8322814F50E6}.Debug Mac|x64.Build.0 = Debug|Any CPU - {81F92B31-C647-4A82-A464-8322814F50E6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {81F92B31-C647-4A82-A464-8322814F50E6}.Debug|Any CPU.Build.0 = Debug|Any CPU - {81F92B31-C647-4A82-A464-8322814F50E6}.Debug|x64.ActiveCfg = Debug|Any CPU - {81F92B31-C647-4A82-A464-8322814F50E6}.Debug|x64.Build.0 = Debug|Any CPU - {81F92B31-C647-4A82-A464-8322814F50E6}.Release Mac|Any CPU.ActiveCfg = Release|Any CPU - {81F92B31-C647-4A82-A464-8322814F50E6}.Release Mac|Any CPU.Build.0 = Release|Any CPU - {81F92B31-C647-4A82-A464-8322814F50E6}.Release Mac|x64.ActiveCfg = Release|Any CPU - {81F92B31-C647-4A82-A464-8322814F50E6}.Release Mac|x64.Build.0 = Release|Any CPU - {81F92B31-C647-4A82-A464-8322814F50E6}.Release|Any CPU.ActiveCfg = Release|Any CPU - {81F92B31-C647-4A82-A464-8322814F50E6}.Release|Any CPU.Build.0 = Release|Any CPU - {81F92B31-C647-4A82-A464-8322814F50E6}.Release|x64.ActiveCfg = Release|Any CPU - {81F92B31-C647-4A82-A464-8322814F50E6}.Release|x64.Build.0 = Release|Any CPU - {7661D48B-9B2C-4549-AE6C-EE07914A1DE6}.Debug Mac|Any CPU.ActiveCfg = Debug|Any CPU - {7661D48B-9B2C-4549-AE6C-EE07914A1DE6}.Debug Mac|Any CPU.Build.0 = Debug|Any CPU - {7661D48B-9B2C-4549-AE6C-EE07914A1DE6}.Debug Mac|x64.ActiveCfg = Debug|Any CPU - {7661D48B-9B2C-4549-AE6C-EE07914A1DE6}.Debug Mac|x64.Build.0 = Debug|Any CPU - {7661D48B-9B2C-4549-AE6C-EE07914A1DE6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {7661D48B-9B2C-4549-AE6C-EE07914A1DE6}.Debug|Any CPU.Build.0 = Debug|Any CPU - {7661D48B-9B2C-4549-AE6C-EE07914A1DE6}.Debug|x64.ActiveCfg = Debug|Any CPU - {7661D48B-9B2C-4549-AE6C-EE07914A1DE6}.Debug|x64.Build.0 = Debug|Any CPU - {7661D48B-9B2C-4549-AE6C-EE07914A1DE6}.Release Mac|Any CPU.ActiveCfg = Debug|Any CPU - {7661D48B-9B2C-4549-AE6C-EE07914A1DE6}.Release Mac|Any CPU.Build.0 = Debug|Any CPU - {7661D48B-9B2C-4549-AE6C-EE07914A1DE6}.Release Mac|x64.ActiveCfg = Debug|Any CPU - {7661D48B-9B2C-4549-AE6C-EE07914A1DE6}.Release Mac|x64.Build.0 = Debug|Any CPU - {7661D48B-9B2C-4549-AE6C-EE07914A1DE6}.Release|Any CPU.ActiveCfg = Release|Any CPU - {7661D48B-9B2C-4549-AE6C-EE07914A1DE6}.Release|Any CPU.Build.0 = Release|Any CPU - {7661D48B-9B2C-4549-AE6C-EE07914A1DE6}.Release|x64.ActiveCfg = Release|Any CPU - {7661D48B-9B2C-4549-AE6C-EE07914A1DE6}.Release|x64.Build.0 = Release|Any CPU - {12173832-4E42-4879-B37E-30B34A72B06D}.Debug Mac|Any CPU.ActiveCfg = Debug|Any CPU - {12173832-4E42-4879-B37E-30B34A72B06D}.Debug Mac|Any CPU.Build.0 = Debug|Any CPU - {12173832-4E42-4879-B37E-30B34A72B06D}.Debug Mac|x64.ActiveCfg = Debug|Any CPU - {12173832-4E42-4879-B37E-30B34A72B06D}.Debug Mac|x64.Build.0 = Debug|Any CPU - {12173832-4E42-4879-B37E-30B34A72B06D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {12173832-4E42-4879-B37E-30B34A72B06D}.Debug|Any CPU.Build.0 = Debug|Any CPU - {12173832-4E42-4879-B37E-30B34A72B06D}.Debug|x64.ActiveCfg = Debug|Any CPU - {12173832-4E42-4879-B37E-30B34A72B06D}.Debug|x64.Build.0 = Debug|Any CPU - {12173832-4E42-4879-B37E-30B34A72B06D}.Release Mac|Any CPU.ActiveCfg = Debug|Any CPU - {12173832-4E42-4879-B37E-30B34A72B06D}.Release Mac|Any CPU.Build.0 = Debug|Any CPU - {12173832-4E42-4879-B37E-30B34A72B06D}.Release Mac|x64.ActiveCfg = Debug|Any CPU - {12173832-4E42-4879-B37E-30B34A72B06D}.Release Mac|x64.Build.0 = Debug|Any CPU - {12173832-4E42-4879-B37E-30B34A72B06D}.Release|Any CPU.ActiveCfg = Release|Any CPU - {12173832-4E42-4879-B37E-30B34A72B06D}.Release|Any CPU.Build.0 = Release|Any CPU - {12173832-4E42-4879-B37E-30B34A72B06D}.Release|x64.ActiveCfg = Release|Any CPU - {12173832-4E42-4879-B37E-30B34A72B06D}.Release|x64.Build.0 = Release|Any CPU - {3954A8FD-6D5A-4A42-BED0-383A2EF40B57}.Debug Mac|Any CPU.ActiveCfg = Debug|Any CPU - {3954A8FD-6D5A-4A42-BED0-383A2EF40B57}.Debug Mac|Any CPU.Build.0 = Debug|Any CPU - {3954A8FD-6D5A-4A42-BED0-383A2EF40B57}.Debug Mac|x64.ActiveCfg = Debug|Any CPU - {3954A8FD-6D5A-4A42-BED0-383A2EF40B57}.Debug Mac|x64.Build.0 = Debug|Any CPU - {3954A8FD-6D5A-4A42-BED0-383A2EF40B57}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {3954A8FD-6D5A-4A42-BED0-383A2EF40B57}.Debug|Any CPU.Build.0 = Debug|Any CPU - {3954A8FD-6D5A-4A42-BED0-383A2EF40B57}.Debug|x64.ActiveCfg = Debug|Any CPU - {3954A8FD-6D5A-4A42-BED0-383A2EF40B57}.Debug|x64.Build.0 = Debug|Any CPU - {3954A8FD-6D5A-4A42-BED0-383A2EF40B57}.Release Mac|Any CPU.ActiveCfg = Debug|Any CPU - {3954A8FD-6D5A-4A42-BED0-383A2EF40B57}.Release Mac|Any CPU.Build.0 = Debug|Any CPU - {3954A8FD-6D5A-4A42-BED0-383A2EF40B57}.Release Mac|x64.ActiveCfg = Debug|Any CPU - {3954A8FD-6D5A-4A42-BED0-383A2EF40B57}.Release Mac|x64.Build.0 = Debug|Any CPU - {3954A8FD-6D5A-4A42-BED0-383A2EF40B57}.Release|Any CPU.ActiveCfg = Release|Any CPU - {3954A8FD-6D5A-4A42-BED0-383A2EF40B57}.Release|Any CPU.Build.0 = Release|Any CPU - {3954A8FD-6D5A-4A42-BED0-383A2EF40B57}.Release|x64.ActiveCfg = Release|Any CPU - {3954A8FD-6D5A-4A42-BED0-383A2EF40B57}.Release|x64.Build.0 = Release|Any CPU + {01F98733-7352-47AD-A594-537D979DE3DE}.Debug Mac|Any CPU.ActiveCfg = Debug|Any CPU + {01F98733-7352-47AD-A594-537D979DE3DE}.Debug Mac|Any CPU.Build.0 = Debug|Any CPU + {01F98733-7352-47AD-A594-537D979DE3DE}.Debug Mac|x64.ActiveCfg = Debug|Any CPU + {01F98733-7352-47AD-A594-537D979DE3DE}.Debug Mac|x64.Build.0 = Debug|Any CPU + {01F98733-7352-47AD-A594-537D979DE3DE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {01F98733-7352-47AD-A594-537D979DE3DE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {01F98733-7352-47AD-A594-537D979DE3DE}.Debug|x64.ActiveCfg = Debug|x64 + {01F98733-7352-47AD-A594-537D979DE3DE}.Debug|x64.Build.0 = Debug|x64 + {01F98733-7352-47AD-A594-537D979DE3DE}.Release Mac|Any CPU.ActiveCfg = Release|Any CPU + {01F98733-7352-47AD-A594-537D979DE3DE}.Release Mac|Any CPU.Build.0 = Release|Any CPU + {01F98733-7352-47AD-A594-537D979DE3DE}.Release Mac|x64.ActiveCfg = Release|Any CPU + {01F98733-7352-47AD-A594-537D979DE3DE}.Release Mac|x64.Build.0 = Release|Any CPU + {01F98733-7352-47AD-A594-537D979DE3DE}.Release|Any CPU.ActiveCfg = Release|Any CPU + {01F98733-7352-47AD-A594-537D979DE3DE}.Release|Any CPU.Build.0 = Release|Any CPU + {01F98733-7352-47AD-A594-537D979DE3DE}.Release|x64.ActiveCfg = Release|Any CPU + {01F98733-7352-47AD-A594-537D979DE3DE}.Release|x64.Build.0 = Release|Any CPU + {83EAD6F0-3CB3-456A-AD81-072127D0DE0E}.Debug Mac|Any CPU.ActiveCfg = Debug|Any CPU + {83EAD6F0-3CB3-456A-AD81-072127D0DE0E}.Debug Mac|Any CPU.Build.0 = Debug|Any CPU + {83EAD6F0-3CB3-456A-AD81-072127D0DE0E}.Debug Mac|x64.ActiveCfg = Debug|Any CPU + {83EAD6F0-3CB3-456A-AD81-072127D0DE0E}.Debug Mac|x64.Build.0 = Debug|Any CPU + {83EAD6F0-3CB3-456A-AD81-072127D0DE0E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {83EAD6F0-3CB3-456A-AD81-072127D0DE0E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {83EAD6F0-3CB3-456A-AD81-072127D0DE0E}.Debug|x64.ActiveCfg = Debug|x64 + {83EAD6F0-3CB3-456A-AD81-072127D0DE0E}.Debug|x64.Build.0 = Debug|x64 + {83EAD6F0-3CB3-456A-AD81-072127D0DE0E}.Release Mac|Any CPU.ActiveCfg = Release|Any CPU + {83EAD6F0-3CB3-456A-AD81-072127D0DE0E}.Release Mac|Any CPU.Build.0 = Release|Any CPU + {83EAD6F0-3CB3-456A-AD81-072127D0DE0E}.Release Mac|x64.ActiveCfg = Release|Any CPU + {83EAD6F0-3CB3-456A-AD81-072127D0DE0E}.Release Mac|x64.Build.0 = Release|Any CPU + {83EAD6F0-3CB3-456A-AD81-072127D0DE0E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {83EAD6F0-3CB3-456A-AD81-072127D0DE0E}.Release|Any CPU.Build.0 = Release|Any CPU + {83EAD6F0-3CB3-456A-AD81-072127D0DE0E}.Release|x64.ActiveCfg = Release|Any CPU + {83EAD6F0-3CB3-456A-AD81-072127D0DE0E}.Release|x64.Build.0 = Release|Any CPU + {26391930-F86F-47E0-A5F6-B89919E38CE1}.Debug Mac|Any CPU.ActiveCfg = Debug|Any CPU + {26391930-F86F-47E0-A5F6-B89919E38CE1}.Debug Mac|Any CPU.Build.0 = Debug|Any CPU + {26391930-F86F-47E0-A5F6-B89919E38CE1}.Debug Mac|x64.ActiveCfg = Debug|Any CPU + {26391930-F86F-47E0-A5F6-B89919E38CE1}.Debug Mac|x64.Build.0 = Debug|Any CPU + {26391930-F86F-47E0-A5F6-B89919E38CE1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {26391930-F86F-47E0-A5F6-B89919E38CE1}.Debug|Any CPU.Build.0 = Debug|Any CPU + {26391930-F86F-47E0-A5F6-B89919E38CE1}.Debug|x64.ActiveCfg = Debug|x64 + {26391930-F86F-47E0-A5F6-B89919E38CE1}.Debug|x64.Build.0 = Debug|x64 + {26391930-F86F-47E0-A5F6-B89919E38CE1}.Release Mac|Any CPU.ActiveCfg = Release|Any CPU + {26391930-F86F-47E0-A5F6-B89919E38CE1}.Release Mac|Any CPU.Build.0 = Release|Any CPU + {26391930-F86F-47E0-A5F6-B89919E38CE1}.Release Mac|x64.ActiveCfg = Release|Any CPU + {26391930-F86F-47E0-A5F6-B89919E38CE1}.Release Mac|x64.Build.0 = Release|Any CPU + {26391930-F86F-47E0-A5F6-B89919E38CE1}.Release|Any CPU.ActiveCfg = Release|Any CPU + {26391930-F86F-47E0-A5F6-B89919E38CE1}.Release|Any CPU.Build.0 = Release|Any CPU + {26391930-F86F-47E0-A5F6-B89919E38CE1}.Release|x64.ActiveCfg = Release|Any CPU + {26391930-F86F-47E0-A5F6-B89919E38CE1}.Release|x64.Build.0 = Release|Any CPU + {D81C0B87-F0C1-4297-A147-02F001FB7E1E}.Debug Mac|Any CPU.ActiveCfg = Debug|Any CPU + {D81C0B87-F0C1-4297-A147-02F001FB7E1E}.Debug Mac|Any CPU.Build.0 = Debug|Any CPU + {D81C0B87-F0C1-4297-A147-02F001FB7E1E}.Debug Mac|x64.ActiveCfg = Debug|Any CPU + {D81C0B87-F0C1-4297-A147-02F001FB7E1E}.Debug Mac|x64.Build.0 = Debug|Any CPU + {D81C0B87-F0C1-4297-A147-02F001FB7E1E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D81C0B87-F0C1-4297-A147-02F001FB7E1E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D81C0B87-F0C1-4297-A147-02F001FB7E1E}.Debug|x64.ActiveCfg = Debug|x64 + {D81C0B87-F0C1-4297-A147-02F001FB7E1E}.Debug|x64.Build.0 = Debug|x64 + {D81C0B87-F0C1-4297-A147-02F001FB7E1E}.Release Mac|Any CPU.ActiveCfg = Release|Any CPU + {D81C0B87-F0C1-4297-A147-02F001FB7E1E}.Release Mac|Any CPU.Build.0 = Release|Any CPU + {D81C0B87-F0C1-4297-A147-02F001FB7E1E}.Release Mac|x64.ActiveCfg = Release|Any CPU + {D81C0B87-F0C1-4297-A147-02F001FB7E1E}.Release Mac|x64.Build.0 = Release|Any CPU + {D81C0B87-F0C1-4297-A147-02F001FB7E1E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D81C0B87-F0C1-4297-A147-02F001FB7E1E}.Release|Any CPU.Build.0 = Release|Any CPU + {D81C0B87-F0C1-4297-A147-02F001FB7E1E}.Release|x64.ActiveCfg = Release|Any CPU + {D81C0B87-F0C1-4297-A147-02F001FB7E1E}.Release|x64.Build.0 = Release|Any CPU + {CC968B23-CEED-4543-8629-808F7E66E815}.Debug Mac|Any CPU.ActiveCfg = Debug|Any CPU + {CC968B23-CEED-4543-8629-808F7E66E815}.Debug Mac|Any CPU.Build.0 = Debug|Any CPU + {CC968B23-CEED-4543-8629-808F7E66E815}.Debug Mac|x64.ActiveCfg = Debug|Any CPU + {CC968B23-CEED-4543-8629-808F7E66E815}.Debug Mac|x64.Build.0 = Debug|Any CPU + {CC968B23-CEED-4543-8629-808F7E66E815}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {CC968B23-CEED-4543-8629-808F7E66E815}.Debug|Any CPU.Build.0 = Debug|Any CPU + {CC968B23-CEED-4543-8629-808F7E66E815}.Debug|x64.ActiveCfg = Debug|x64 + {CC968B23-CEED-4543-8629-808F7E66E815}.Debug|x64.Build.0 = Debug|x64 + {CC968B23-CEED-4543-8629-808F7E66E815}.Release Mac|Any CPU.ActiveCfg = Release|Any CPU + {CC968B23-CEED-4543-8629-808F7E66E815}.Release Mac|Any CPU.Build.0 = Release|Any CPU + {CC968B23-CEED-4543-8629-808F7E66E815}.Release Mac|x64.ActiveCfg = Release|Any CPU + {CC968B23-CEED-4543-8629-808F7E66E815}.Release Mac|x64.Build.0 = Release|Any CPU + {CC968B23-CEED-4543-8629-808F7E66E815}.Release|Any CPU.ActiveCfg = Release|Any CPU + {CC968B23-CEED-4543-8629-808F7E66E815}.Release|Any CPU.Build.0 = Release|Any CPU + {CC968B23-CEED-4543-8629-808F7E66E815}.Release|x64.ActiveCfg = Release|Any CPU + {CC968B23-CEED-4543-8629-808F7E66E815}.Release|x64.Build.0 = Release|Any CPU + {01E762F1-C176-40B9-BA3E-9B1FECAF04FF}.Debug Mac|Any CPU.ActiveCfg = Debug|Any CPU + {01E762F1-C176-40B9-BA3E-9B1FECAF04FF}.Debug Mac|Any CPU.Build.0 = Debug|Any CPU + {01E762F1-C176-40B9-BA3E-9B1FECAF04FF}.Debug Mac|x64.ActiveCfg = Debug|Any CPU + {01E762F1-C176-40B9-BA3E-9B1FECAF04FF}.Debug Mac|x64.Build.0 = Debug|Any CPU + {01E762F1-C176-40B9-BA3E-9B1FECAF04FF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {01E762F1-C176-40B9-BA3E-9B1FECAF04FF}.Debug|Any CPU.Build.0 = Debug|Any CPU + {01E762F1-C176-40B9-BA3E-9B1FECAF04FF}.Debug|x64.ActiveCfg = Debug|x64 + {01E762F1-C176-40B9-BA3E-9B1FECAF04FF}.Debug|x64.Build.0 = Debug|x64 + {01E762F1-C176-40B9-BA3E-9B1FECAF04FF}.Release Mac|Any CPU.ActiveCfg = Release|Any CPU + {01E762F1-C176-40B9-BA3E-9B1FECAF04FF}.Release Mac|Any CPU.Build.0 = Release|Any CPU + {01E762F1-C176-40B9-BA3E-9B1FECAF04FF}.Release Mac|x64.ActiveCfg = Release|Any CPU + {01E762F1-C176-40B9-BA3E-9B1FECAF04FF}.Release Mac|x64.Build.0 = Release|Any CPU + {01E762F1-C176-40B9-BA3E-9B1FECAF04FF}.Release|Any CPU.ActiveCfg = Release|Any CPU + {01E762F1-C176-40B9-BA3E-9B1FECAF04FF}.Release|Any CPU.Build.0 = Release|Any CPU + {01E762F1-C176-40B9-BA3E-9B1FECAF04FF}.Release|x64.ActiveCfg = Release|Any CPU + {01E762F1-C176-40B9-BA3E-9B1FECAF04FF}.Release|x64.Build.0 = Release|Any CPU + {C9D4CA21-182B-4ED2-81BB-280A6FD713F6}.Debug Mac|Any CPU.ActiveCfg = Debug|Any CPU + {C9D4CA21-182B-4ED2-81BB-280A6FD713F6}.Debug Mac|Any CPU.Build.0 = Debug|Any CPU + {C9D4CA21-182B-4ED2-81BB-280A6FD713F6}.Debug Mac|x64.ActiveCfg = Debug|Any CPU + {C9D4CA21-182B-4ED2-81BB-280A6FD713F6}.Debug Mac|x64.Build.0 = Debug|Any CPU + {C9D4CA21-182B-4ED2-81BB-280A6FD713F6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C9D4CA21-182B-4ED2-81BB-280A6FD713F6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C9D4CA21-182B-4ED2-81BB-280A6FD713F6}.Debug|x64.ActiveCfg = Debug|x64 + {C9D4CA21-182B-4ED2-81BB-280A6FD713F6}.Debug|x64.Build.0 = Debug|x64 + {C9D4CA21-182B-4ED2-81BB-280A6FD713F6}.Release Mac|Any CPU.ActiveCfg = Release|Any CPU + {C9D4CA21-182B-4ED2-81BB-280A6FD713F6}.Release Mac|Any CPU.Build.0 = Release|Any CPU + {C9D4CA21-182B-4ED2-81BB-280A6FD713F6}.Release Mac|x64.ActiveCfg = Release|Any CPU + {C9D4CA21-182B-4ED2-81BB-280A6FD713F6}.Release Mac|x64.Build.0 = Release|Any CPU + {C9D4CA21-182B-4ED2-81BB-280A6FD713F6}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C9D4CA21-182B-4ED2-81BB-280A6FD713F6}.Release|Any CPU.Build.0 = Release|Any CPU + {C9D4CA21-182B-4ED2-81BB-280A6FD713F6}.Release|x64.ActiveCfg = Release|Any CPU + {C9D4CA21-182B-4ED2-81BB-280A6FD713F6}.Release|x64.Build.0 = Release|Any CPU + {7291B93C-615D-42DE-B8C1-3F9DF643E0FC}.Debug Mac|Any CPU.ActiveCfg = Debug|Any CPU + {7291B93C-615D-42DE-B8C1-3F9DF643E0FC}.Debug Mac|Any CPU.Build.0 = Debug|Any CPU + {7291B93C-615D-42DE-B8C1-3F9DF643E0FC}.Debug Mac|x64.ActiveCfg = Debug|Any CPU + {7291B93C-615D-42DE-B8C1-3F9DF643E0FC}.Debug Mac|x64.Build.0 = Debug|Any CPU + {7291B93C-615D-42DE-B8C1-3F9DF643E0FC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7291B93C-615D-42DE-B8C1-3F9DF643E0FC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7291B93C-615D-42DE-B8C1-3F9DF643E0FC}.Debug|x64.ActiveCfg = Debug|x64 + {7291B93C-615D-42DE-B8C1-3F9DF643E0FC}.Debug|x64.Build.0 = Debug|x64 + {7291B93C-615D-42DE-B8C1-3F9DF643E0FC}.Release Mac|Any CPU.ActiveCfg = Release|Any CPU + {7291B93C-615D-42DE-B8C1-3F9DF643E0FC}.Release Mac|Any CPU.Build.0 = Release|Any CPU + {7291B93C-615D-42DE-B8C1-3F9DF643E0FC}.Release Mac|x64.ActiveCfg = Release|Any CPU + {7291B93C-615D-42DE-B8C1-3F9DF643E0FC}.Release Mac|x64.Build.0 = Release|Any CPU + {7291B93C-615D-42DE-B8C1-3F9DF643E0FC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7291B93C-615D-42DE-B8C1-3F9DF643E0FC}.Release|Any CPU.Build.0 = Release|Any CPU + {7291B93C-615D-42DE-B8C1-3F9DF643E0FC}.Release|x64.ActiveCfg = Release|Any CPU + {7291B93C-615D-42DE-B8C1-3F9DF643E0FC}.Release|x64.Build.0 = Release|Any CPU + {8AEF06C0-CA5C-4460-BC2D-ADE5F35D0434}.Debug Mac|Any CPU.ActiveCfg = Debug|Any CPU + {8AEF06C0-CA5C-4460-BC2D-ADE5F35D0434}.Debug Mac|Any CPU.Build.0 = Debug|Any CPU + {8AEF06C0-CA5C-4460-BC2D-ADE5F35D0434}.Debug Mac|x64.ActiveCfg = Debug|Any CPU + {8AEF06C0-CA5C-4460-BC2D-ADE5F35D0434}.Debug Mac|x64.Build.0 = Debug|Any CPU + {8AEF06C0-CA5C-4460-BC2D-ADE5F35D0434}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8AEF06C0-CA5C-4460-BC2D-ADE5F35D0434}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8AEF06C0-CA5C-4460-BC2D-ADE5F35D0434}.Debug|x64.ActiveCfg = Debug|x64 + {8AEF06C0-CA5C-4460-BC2D-ADE5F35D0434}.Debug|x64.Build.0 = Debug|x64 + {8AEF06C0-CA5C-4460-BC2D-ADE5F35D0434}.Release Mac|Any CPU.ActiveCfg = Release|Any CPU + {8AEF06C0-CA5C-4460-BC2D-ADE5F35D0434}.Release Mac|Any CPU.Build.0 = Release|Any CPU + {8AEF06C0-CA5C-4460-BC2D-ADE5F35D0434}.Release Mac|x64.ActiveCfg = Release|Any CPU + {8AEF06C0-CA5C-4460-BC2D-ADE5F35D0434}.Release Mac|x64.Build.0 = Release|Any CPU + {8AEF06C0-CA5C-4460-BC2D-ADE5F35D0434}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8AEF06C0-CA5C-4460-BC2D-ADE5F35D0434}.Release|Any CPU.Build.0 = Release|Any CPU + {8AEF06C0-CA5C-4460-BC2D-ADE5F35D0434}.Release|x64.ActiveCfg = Release|Any CPU + {8AEF06C0-CA5C-4460-BC2D-ADE5F35D0434}.Release|x64.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -2767,25 +2765,26 @@ Global {33D19E88-F3AE-4D28-B588-D91CCF9E3BA8} = {9DB74760-01DE-4AC1-A81B-BC7784351D22} {B92E6216-2CBA-4EA5-B94B-0A7658C7F84B} = {9DB74760-01DE-4AC1-A81B-BC7784351D22} {1FE3C60E-7865-40A5-9794-55ECB64F6489} = {9DB74760-01DE-4AC1-A81B-BC7784351D22} - {E1FF75EC-2BDF-4276-9C81-6EB195661348} = {4838C66E-8677-4FBD-9609-25376042E981} - {32AEA787-C986-4B76-A57F-0DA5453AA1F5} = {4838C66E-8677-4FBD-9609-25376042E981} - {86E64130-2DCE-4F51-B07C-B87138046E21} = {FD4D6594-D81E-456F-8F2E-35B09E04A755} - {E577F692-C9E9-46A6-B9F1-CF70C93F1280} = {D92751C8-1039-4005-90B2-913E55E0B8BD} - {9655BE78-8070-4B9F-B0DC-68BB6150B52C} = {D92751C8-1039-4005-90B2-913E55E0B8BD} + {FD4D6594-D81E-456F-8F2E-35B09E04A755} = {9DB74760-01DE-4AC1-A81B-BC7784351D22} {D92751C8-1039-4005-90B2-913E55E0B8BD} = {1FE3C60E-7865-40A5-9794-55ECB64F6489} - {746047E4-BE3D-43D0-99E0-76259D262AC6} = {B92E6216-2CBA-4EA5-B94B-0A7658C7F84B} - {D32342E4-3223-48A0-8DF6-A1475BE27628} = {B92E6216-2CBA-4EA5-B94B-0A7658C7F84B} - {81F92B31-C647-4A82-A464-8322814F50E6} = {D92751C8-1039-4005-90B2-913E55E0B8BD} {2E00592E-558D-492D-88F9-3ECEE4C0C7DA} = {9DB74760-01DE-4AC1-A81B-BC7784351D22} - {FD4D6594-D81E-456F-8F2E-35B09E04A755} = {9DB74760-01DE-4AC1-A81B-BC7784351D22} - {7661D48B-9B2C-4549-AE6C-EE07914A1DE6} = {2E00592E-558D-492D-88F9-3ECEE4C0C7DA} - {12173832-4E42-4879-B37E-30B34A72B06D} = {2E00592E-558D-492D-88F9-3ECEE4C0C7DA} - {3954A8FD-6D5A-4A42-BED0-383A2EF40B57} = {2E00592E-558D-492D-88F9-3ECEE4C0C7DA} + {01F98733-7352-47AD-A594-537D979DE3DE} = {4838C66E-8677-4FBD-9609-25376042E981} + {DC570FFF-6FE5-47BD-8BC1-B471A6067786} = {4838C66E-8677-4FBD-9609-25376042E981} + {E1C43415-3200-45F4-8BF9-A4DD7D7F2ED6} = {D92751C8-1039-4005-90B2-913E55E0B8BD} + {83EAD6F0-3CB3-456A-AD81-072127D0DE0E} = {D92751C8-1039-4005-90B2-913E55E0B8BD} + {26391930-F86F-47E0-A5F6-B89919E38CE1} = {D92751C8-1039-4005-90B2-913E55E0B8BD} + {D81C0B87-F0C1-4297-A147-02F001FB7E1E} = {FD4D6594-D81E-456F-8F2E-35B09E04A755} + {CC968B23-CEED-4543-8629-808F7E66E815} = {B92E6216-2CBA-4EA5-B94B-0A7658C7F84B} + {01E762F1-C176-40B9-BA3E-9B1FECAF04FF} = {B92E6216-2CBA-4EA5-B94B-0A7658C7F84B} + {C9D4CA21-182B-4ED2-81BB-280A6FD713F6} = {2E00592E-558D-492D-88F9-3ECEE4C0C7DA} + {7291B93C-615D-42DE-B8C1-3F9DF643E0FC} = {2E00592E-558D-492D-88F9-3ECEE4C0C7DA} + {8AEF06C0-CA5C-4460-BC2D-ADE5F35D0434} = {2E00592E-558D-492D-88F9-3ECEE4C0C7DA} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {1D43D91B-4F01-4A78-8250-CC6F9BD93A14} EndGlobalSection GlobalSection(SharedMSBuildProjectFiles) = preSolution + DUI3-DX\Connectors\Revit\Speckle.Connectors.RevitShared\Speckle.Connectors.RevitShared.projitems*{01f98733-7352-47ad-a594-537d979de3de}*SharedItemsImports = 5 Objects\Converters\ConverterTeklaStructures\ConverterTeklaStructuresShared\ConverterTeklaStructuresShared.projitems*{02a24dd8-e0ca-4657-baa7-b033a4563709}*SharedItemsImports = 5 ConnectorBentley\ConnectorBentleyShared\ConnectorBentleyShared.projitems*{0420d74a-2997-4b92-844b-c3769deaa1ad}*SharedItemsImports = 5 Objects\Converters\ConverterTeklaStructures\ConverterTeklaStructuresShared\ConverterTeklaStructuresShared.projitems*{05f993a6-8651-4801-a732-9a30d1472eef}*SharedItemsImports = 5 @@ -2799,6 +2798,7 @@ Global ConnectorRevit\RevitDUI3\RevitDUI3Shared\RevitDUI3Shared.projitems*{2113f03b-bb8d-470b-a9a1-97bb9a554a44}*SharedItemsImports = 5 Objects\Converters\ConverterCSI\ConverterCSIShared\ConverterCSIShared.projitems*{21223ba5-c6e8-405d-b581-106c4726edc0}*SharedItemsImports = 5 ConnectorNavisworks\ConnectorNavisworks\ConnectorNavisworks.Shared.projitems*{2568500e-f1bc-440e-9150-db4820b3fad6}*SharedItemsImports = 5 + DUI3-DX\Converters\Revit\Speckle.Converters.RevitShared\Speckle.Converters.RevitShared.projitems*{26391930-f86f-47e0-a5f6-b89919e38ce1}*SharedItemsImports = 5 ConnectorAutocadCivil\ConnectorAutocadCivil\ConnectorAutocadCivilShared.projitems*{2639e37d-80d3-415a-b4d1-20d7f321f27f}*SharedItemsImports = 5 Objects\Converters\ConverterRhinoGh\ConverterRhinoGhShared\ConverterRhinoGhShared.projitems*{26eca1be-f5b2-4a41-9658-46a4a917bfe6}*SharedItemsImports = 5 ConnectorRevit\ConnectorRevit\ConnectorRevit.projitems*{27a79aca-7ea8-4406-8bb8-216578cc3ab7}*SharedItemsImports = 5 @@ -2806,7 +2806,6 @@ Global ConnectorAutocadCivil\AutocadCivilDUI3\AutocadCivilDUI3Shared\AutocadCivilDUI3Shared.projitems*{2bde80e8-5f26-4e57-bba6-109120f5d4ee}*SharedItemsImports = 13 Objects\Converters\ConverterAutocadCivil\ConverterAutocadCivilShared\ConverterAutocadCivilShared.projitems*{2d0f9f8a-2e89-4780-978a-cd92d6d7b843}*SharedItemsImports = 13 Objects\Converters\ConverterRevit\ConverterRevitShared\ConverterRevitShared.projitems*{2dcd648d-dca5-4d2a-8b14-ad2cb85d24b0}*SharedItemsImports = 13 - CNX-8892\Connectors\Revit\Speckle.Connectors.RevitShared\Speckle.Connectors.RevitShared.projitems*{32aea787-c986-4b76-a57f-0da5453aa1f5}*SharedItemsImports = 13 ConnectorBentley\ConnectorBentleyShared\ConnectorBentleyShared.projitems*{372d9f0f-ede9-4050-bf8c-758911c5c2e0}*SharedItemsImports = 13 ConnectorTeklaStructures\ConnectorTeklaStructuresShared\ConnectorTeklaStructuresShared.projitems*{3af1ef30-0906-4926-a02c-4e3ad666352a}*SharedItemsImports = 5 ConnectorAutocadCivil\ConnectorAutocadCivil\ConnectorAutocadCivilShared.projitems*{3b9189b9-e485-448a-8793-9b9587a36791}*SharedItemsImports = 5 @@ -2858,7 +2857,6 @@ Global Objects\Converters\ConverterBentley\ConverterBentleyShared\ConverterBentleyShared.projitems*{8b50fa79-2ff0-4efa-b50f-9bf47ff3e130}*SharedItemsImports = 5 Objects\Converters\ConverterCSI\ConverterCSIShared\ConverterCSIShared.projitems*{907aed7a-719b-4157-8cc9-d21cb26e9243}*SharedItemsImports = 5 Objects\Converters\ConverterBentley\ConverterBentleyShared\ConverterBentleyShared.projitems*{931fc9a8-18b4-4ac5-81d9-14c48499bfb5}*SharedItemsImports = 5 - CNX-8892\Converters\Revit\Speckle.Converters.RevitShared\Speckle.Converters.RevitShared.projitems*{9655be78-8070-4b9f-b0dc-68bb6150b52c}*SharedItemsImports = 13 ConnectorRevit\ConnectorRevit\ConnectorRevit.projitems*{9a1e899a-f821-4519-aad1-0789a4e9ccb3}*SharedItemsImports = 5 ConnectorNavisworks\ConnectorNavisworks\ConnectorNavisworks.Shared.projitems*{9a7d7f9a-4fe1-4053-950b-50b43bc81087}*SharedItemsImports = 5 ConnectorCSI\ConnectorCSIShared\ConnectorCSIShared.projitems*{9d188843-8841-4a76-a844-efbe8e32ee05}*SharedItemsImports = 5 @@ -2892,10 +2890,10 @@ Global Objects\Converters\ConverterRevit\ConverterRevitTests\ConverterRevitTestsShared\ConverterRevitTestsShared.projitems*{d296722d-0798-4110-9c6e-dfb0824a7251}*SharedItemsImports = 5 ConnectorRhino\ConnectorRhino\ConnectorRhinoShared\ConnectorRhinoShared.projitems*{d648bb69-b992-4d34-906e-7a547374b86c}*SharedItemsImports = 5 Objects\Converters\ConverterAutocadCivil\ConverterAutocadCivilShared\ConverterAutocadCivilShared.projitems*{d9f443b5-c55b-4ad8-9c70-bc3d2be781be}*SharedItemsImports = 5 + DUI3-DX\Connectors\Revit\Speckle.Connectors.RevitShared\Speckle.Connectors.RevitShared.projitems*{dc570fff-6fe5-47bd-8bc1-b471a6067786}*SharedItemsImports = 13 ConnectorNavisworks\ConnectorNavisworks\ConnectorNavisworks.Shared.projitems*{debc2174-5e31-4b6e-8680-690d75e50e2d}*SharedItemsImports = 5 ConnectorRevit\ConnectorRevit\ConnectorRevit.projitems*{dfdfdbb8-018b-4dcb-a012-54227abf53a7}*SharedItemsImports = 5 - CNX-8892\Connectors\Revit\Speckle.Connectors.RevitShared\Speckle.Connectors.RevitShared.projitems*{e1ff75ec-2bdf-4276-9c81-6eb195661348}*SharedItemsImports = 4 - CNX-8892\Converters\Revit\Speckle.Converters.RevitShared\Speckle.Converters.RevitShared.projitems*{e577f692-c9e9-46a6-b9f1-cf70c93f1280}*SharedItemsImports = 5 + DUI3-DX\Converters\Revit\Speckle.Converters.RevitShared\Speckle.Converters.RevitShared.projitems*{e1c43415-3200-45f4-8bf9-a4dd7d7f2ed6}*SharedItemsImports = 13 ConnectorRevit\RevitSharedResources\RevitSharedResources.projitems*{ea34ac83-5825-4473-a572-d5127fd33b1b}*SharedItemsImports = 5 Objects\Converters\ConverterRhinoGh\ConverterRhinoGhShared\ConverterRhinoGhShared.projitems*{ea81f83c-1485-49c8-ab05-9df2798d70ec}*SharedItemsImports = 5 Objects\Converters\ConverterTeklaStructures\ConverterTeklaStructuresShared\ConverterTeklaStructuresShared.projitems*{eb52e451-9ed8-460e-9ee4-6717bfb12eab}*SharedItemsImports = 5 diff --git a/Automate/Tests/Speckle.Automate.Sdk.Tests.Integration/Speckle.Automate.Sdk.Tests.Integration.csproj b/Automate/Tests/Speckle.Automate.Sdk.Tests.Integration/Speckle.Automate.Sdk.Tests.Integration.csproj index 0d5b566f3c..f71e7df6fa 100644 --- a/Automate/Tests/Speckle.Automate.Sdk.Tests.Integration/Speckle.Automate.Sdk.Tests.Integration.csproj +++ b/Automate/Tests/Speckle.Automate.Sdk.Tests.Integration/Speckle.Automate.Sdk.Tests.Integration.csproj @@ -14,8 +14,8 @@ - - + + diff --git a/ConnectorNavisworks/ConnectorNavisworks2020/ConnectorNavisworks2020.csproj b/ConnectorNavisworks/ConnectorNavisworks2020/ConnectorNavisworks2020.csproj index c3bc46cd33..b39324da4a 100644 --- a/ConnectorNavisworks/ConnectorNavisworks2020/ConnectorNavisworks2020.csproj +++ b/ConnectorNavisworks/ConnectorNavisworks2020/ConnectorNavisworks2020.csproj @@ -29,7 +29,6 @@ 2020 $(AppData)\Autodesk\ApplicationPlugins\Speckle.ConnectorNavisworks.bundle $(AppData)\Autodesk\ApplicationPlugins\Speckle.ConnectorNavisworks.bundle\Contents\$(NavisworksBuildNumber) - AnyCPU;x64 true diff --git a/ConnectorNavisworks/ConnectorNavisworks2021/ConnectorNavisworks2021.csproj b/ConnectorNavisworks/ConnectorNavisworks2021/ConnectorNavisworks2021.csproj index 213c001c05..83a33c0d95 100644 --- a/ConnectorNavisworks/ConnectorNavisworks2021/ConnectorNavisworks2021.csproj +++ b/ConnectorNavisworks/ConnectorNavisworks2021/ConnectorNavisworks2021.csproj @@ -29,7 +29,6 @@ 2021 $(AppData)\Autodesk\ApplicationPlugins\Speckle.ConnectorNavisworks.bundle $(AppData)\Autodesk\ApplicationPlugins\Speckle.ConnectorNavisworks.bundle\Contents\$(NavisworksBuildNumber) - AnyCPU;x64 true diff --git a/ConnectorNavisworks/ConnectorNavisworks2022/ConnectorNavisworks2022.csproj b/ConnectorNavisworks/ConnectorNavisworks2022/ConnectorNavisworks2022.csproj index 72ece355a2..d238fd1fa3 100644 --- a/ConnectorNavisworks/ConnectorNavisworks2022/ConnectorNavisworks2022.csproj +++ b/ConnectorNavisworks/ConnectorNavisworks2022/ConnectorNavisworks2022.csproj @@ -29,7 +29,6 @@ 2022 $(AppData)\Autodesk\ApplicationPlugins\Speckle.ConnectorNavisworks.bundle $(AppData)\Autodesk\ApplicationPlugins\Speckle.ConnectorNavisworks.bundle\Contents\$(NavisworksBuildNumber) - AnyCPU;x64 true diff --git a/ConnectorNavisworks/ConnectorNavisworks2023/ConnectorNavisworks2023.csproj b/ConnectorNavisworks/ConnectorNavisworks2023/ConnectorNavisworks2023.csproj index f85901641d..e34e605375 100644 --- a/ConnectorNavisworks/ConnectorNavisworks2023/ConnectorNavisworks2023.csproj +++ b/ConnectorNavisworks/ConnectorNavisworks2023/ConnectorNavisworks2023.csproj @@ -29,7 +29,6 @@ 2023 $(AppData)\Autodesk\ApplicationPlugins\Speckle.ConnectorNavisworks.bundle $(AppData)\Autodesk\ApplicationPlugins\Speckle.ConnectorNavisworks.bundle\Contents\$(NavisworksBuildNumber) - AnyCPU;x64 true diff --git a/ConnectorNavisworks/ConnectorNavisworks2024/ConnectorNavisworks2024.csproj b/ConnectorNavisworks/ConnectorNavisworks2024/ConnectorNavisworks2024.csproj index f46df0cfd2..f84dec5a2b 100644 --- a/ConnectorNavisworks/ConnectorNavisworks2024/ConnectorNavisworks2024.csproj +++ b/ConnectorNavisworks/ConnectorNavisworks2024/ConnectorNavisworks2024.csproj @@ -29,7 +29,6 @@ 2024 $(AppData)\Autodesk\ApplicationPlugins\Speckle.ConnectorNavisworks.bundle $(AppData)\Autodesk\ApplicationPlugins\Speckle.ConnectorNavisworks.bundle\Contents\$(NavisworksBuildNumber) - AnyCPU;x64 true diff --git a/ConnectorRevit/RevitDUI3/Revit2020DUI3/Revit2020DUI3.csproj b/ConnectorRevit/RevitDUI3/Revit2020DUI3/Revit2020DUI3.csproj index 0f5d126834..f4eface7ee 100644 --- a/ConnectorRevit/RevitDUI3/Revit2020DUI3/Revit2020DUI3.csproj +++ b/ConnectorRevit/RevitDUI3/Revit2020DUI3/Revit2020DUI3.csproj @@ -1,5 +1,6 @@  + AnyCPU true Speckle.ConnectorRevitDUI3 SpeckleConnectorRevitDUI3 @@ -13,7 +14,7 @@ true $(DefineConstants);REVIT2020 false - AnyCPU;x64 + enable x64 diff --git a/ConnectorRevit/RevitDUI3/Revit2023DUI3/Revit2023DUI3.csproj b/ConnectorRevit/RevitDUI3/Revit2023DUI3/Revit2023DUI3.csproj index e892cd3e1a..171427f0c2 100644 --- a/ConnectorRevit/RevitDUI3/Revit2023DUI3/Revit2023DUI3.csproj +++ b/ConnectorRevit/RevitDUI3/Revit2023DUI3/Revit2023DUI3.csproj @@ -1,5 +1,6 @@  + AnyCPU Speckle.ConnectorRevitDUI3 SpeckleConnectorRevitDUI3 net48 @@ -12,7 +13,6 @@ true $(DefineConstants);REVIT2023 false - x64 diff --git a/ConnectorRevit/RevitDUI3/RevitDUI3Shared/Bindings/SendBinding.cs b/ConnectorRevit/RevitDUI3/RevitDUI3Shared/Bindings/SendBinding.cs index a36284eb33..70f9c758a6 100644 --- a/ConnectorRevit/RevitDUI3/RevitDUI3Shared/Bindings/SendBinding.cs +++ b/ConnectorRevit/RevitDUI3/RevitDUI3Shared/Bindings/SendBinding.cs @@ -12,7 +12,6 @@ using Speckle.ConnectorRevitDUI3.Utils; using Speckle.Core.Kits; using Speckle.Core.Credentials; -using Speckle.Core.Transports; using Speckle.Core.Models; using DUI3.Utils; using RevitSharedResources.Interfaces; @@ -143,8 +142,20 @@ public async void Send(string modelCardId) modelCardId, new ModelCardProgress { Status = "Uploading..." } ); + + throw new InvalidOperationException( + "The next method does not know about the variable transports - string objectId = await Speckle.Core.Api.Operations" + + "\r\n.Send(commitObject, cts.Token, transports, disposeTransports: true)\r\n" + + ".ConfigureAwait(true);\r\n" + ); + string objectId = await Speckle.Core.Api.Operations - .Send(commitObject, cts.Token, transports, disposeTransports: true) + .Send( + commitObject, + cts.Token, /* transports*/ + null, + disposeTransports: true + ) .ConfigureAwait(true); BasicConnectorBindingCommands.SetModelProgress( @@ -159,8 +170,8 @@ public async void Send(string modelCardId) .CommitCreate( new CommitCreateInput() { - streamId = model.ProjectId, - branchName = model.ModelId, + streamId = modelCard.ProjectId, + branchName = modelCard.ModelId, sourceApplication = "Rhino", objectId = objectId }, diff --git a/Core/Transports/DiskTransport/DiskTransport.csproj b/Core/Transports/DiskTransport/DiskTransport.csproj index f94a434a45..27826aa45b 100644 --- a/Core/Transports/DiskTransport/DiskTransport.csproj +++ b/Core/Transports/DiskTransport/DiskTransport.csproj @@ -7,7 +7,6 @@ A Disk transport for Speckle $(PackageTags) disk transport Debug;Release - AnyCPU true enable Speckle.Core.Transports diff --git a/DUI3-CNX-8893.slnf b/DUI3-DX.slnf similarity index 80% rename from DUI3-CNX-8893.slnf rename to DUI3-DX.slnf index e7d16349a8..b50b92c1ff 100644 --- a/DUI3-CNX-8893.slnf +++ b/DUI3-DX.slnf @@ -2,18 +2,6 @@ "solution": { "path": "All.sln", "projects": [ - "CNX-8892\\Connectors\\Revit\\Speckle.Connectors.Revit2023\\Speckle.Connectors.Revit2023.csproj", - "CNX-8892\\Connectors\\Revit\\Speckle.Connectors.RevitShared\\Speckle.Connectors.RevitShared.shproj", - "CNX-8892\\Converters\\Revit\\Speckle.Converters.Revit2023.DependencyInjection\\Speckle.Converters.Revit2023.DependencyInjection.csproj", - "CNX-8892\\Converters\\Revit\\Speckle.Converters.Revit2023\\Speckle.Converters.Revit2023.csproj", - "CNX-8892\\Converters\\Revit\\Speckle.Converters.RevitShared\\Speckle.Converters.RevitShared.shproj", - "CNX-8892\\Converters\\Speckle.Converters.Common\\Speckle.Converters.Common.csproj", - "CNX-8892\\DUI3\\Speckle.Connectors.DUI\\Speckle.Connectors.DUI.csproj", - "CNX-8892\\Objects\\Speckle.Objects.Common\\Speckle.Objects.Common.csproj", - "CNX-8892\\Objects\\Speckle.Objects.Revit\\Speckle.Objects.Revit.csproj", - "CNX-8892\\Sdk\\Speckle.Autofac\\Speckle.Autofac.csproj", - "CNX-8892\\Sdk\\Speckle.Connectors.Utils\\Speckle.Connectors.Utils.csproj", - "CNX-8892\\Sdk\\Speckle.Converters.Common\\Speckle.Converters.Common.csproj", "ConnectorRevit\\ConnectorRevit2023\\ConnectorRevit2023.csproj", "ConnectorRevit\\ConnectorRevit\\ConnectorRevitShared.shproj", "ConnectorRevit\\RevitDUI3\\Revit2023DUI3\\Revit2023DUI3.csproj", @@ -23,6 +11,17 @@ "Core\\Tests\\Speckle.Core.Tests.Performance\\Speckle.Core.Tests.Performance.csproj", "Core\\Tests\\Speckle.Core.Tests.Unit\\Speckle.Core.Tests.Unit.csproj", "Core\\Transports\\DiskTransport\\DiskTransport.csproj", + "DUI3-DX\\Connectors\\Revit\\Speckle.Connectors.Revit2023\\Speckle.Connectors.Revit2023.csproj", + "DUI3-DX\\Connectors\\Revit\\Speckle.Connectors.RevitShared\\Speckle.Connectors.RevitShared.shproj", + "DUI3-DX\\Converters\\Revit\\Speckle.Converters.Revit2023.DependencyInjection\\Speckle.Converters.Revit2023.DependencyInjection.csproj", + "DUI3-DX\\Converters\\Revit\\Speckle.Converters.Revit2023\\Speckle.Converters.Revit2023.csproj", + "DUI3-DX\\Converters\\Revit\\Speckle.Converters.RevitShared\\Speckle.Converters.RevitShared.shproj", + "DUI3-DX\\DUI3\\Speckle.Connectors.DUI\\Speckle.Connectors.DUI.csproj", + "DUI3-DX\\Objects\\Speckle.Objects.Common\\Speckle.Objects.Common.csproj", + "DUI3-DX\\Objects\\Speckle.Objects.Revit\\Speckle.Objects.Revit.csproj", + "DUI3-DX\\Sdk\\Speckle.Autofac\\Speckle.Autofac.csproj", + "DUI3-DX\\Sdk\\Speckle.Connectors.Utils\\Speckle.Connectors.Utils.csproj", + "DUI3-DX\\Sdk\\Speckle.Converters.Common\\Speckle.Converters.Common.csproj", "DesktopUI3\\DUI3\\DUI3.csproj", "Objects\\Converters\\ConverterAutocadCivil\\ConverterAdvanceSteel2023\\ConverterAdvanceSteel2023.csproj", "Objects\\Converters\\ConverterAutocadCivil\\ConverterAdvanceSteel2024\\ConverterAdvanceSteel2024.csproj", diff --git a/CNX-8892/Connectors/Revit/Speckle.Connectors.Revit2023/Speckle.Connectors.Revit2023.csproj b/DUI3-DX/Connectors/Revit/Speckle.Connectors.Revit2023/Speckle.Connectors.Revit2023.csproj similarity index 100% rename from CNX-8892/Connectors/Revit/Speckle.Connectors.Revit2023/Speckle.Connectors.Revit2023.csproj rename to DUI3-DX/Connectors/Revit/Speckle.Connectors.Revit2023/Speckle.Connectors.Revit2023.csproj diff --git a/CNX-8892/Connectors/Revit/Speckle.Connectors.Revit2023/app.config b/DUI3-DX/Connectors/Revit/Speckle.Connectors.Revit2023/app.config similarity index 100% rename from CNX-8892/Connectors/Revit/Speckle.Connectors.Revit2023/app.config rename to DUI3-DX/Connectors/Revit/Speckle.Connectors.Revit2023/app.config diff --git a/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/BasicConnectorBindingRevit.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/BasicConnectorBindingRevit.cs similarity index 100% rename from CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/BasicConnectorBindingRevit.cs rename to DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/BasicConnectorBindingRevit.cs diff --git a/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/Filters.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/Filters.cs similarity index 100% rename from CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/Filters.cs rename to DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/Filters.cs diff --git a/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/ReceiveBinding.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/ReceiveBinding.cs similarity index 100% rename from CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/ReceiveBinding.cs rename to DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/ReceiveBinding.cs diff --git a/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/RevitBaseBinding.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/RevitBaseBinding.cs similarity index 100% rename from CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/RevitBaseBinding.cs rename to DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/RevitBaseBinding.cs diff --git a/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SelectionBinding.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SelectionBinding.cs similarity index 100% rename from CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SelectionBinding.cs rename to DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SelectionBinding.cs diff --git a/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SendBinding.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SendBinding.cs similarity index 100% rename from CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SendBinding.cs rename to DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SendBinding.cs diff --git a/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/AutofacUIModule.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/AutofacUIModule.cs similarity index 98% rename from CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/AutofacUIModule.cs rename to DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/AutofacUIModule.cs index 457b4d09a2..c55dd4efb2 100644 --- a/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/AutofacUIModule.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/AutofacUIModule.cs @@ -18,7 +18,7 @@ namespace Speckle.Connectors.Revit.DependencyInjection; // POC: should interface out things that are not -class AutofacUIModule : Module +public class AutofacUIModule : Module { protected override void Load(ContainerBuilder builder) { diff --git a/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/Elements.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/Elements.cs similarity index 100% rename from CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/Elements.cs rename to DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/Elements.cs diff --git a/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/RevitDocumentStore.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/RevitDocumentStore.cs similarity index 100% rename from CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/RevitDocumentStore.cs rename to DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/RevitDocumentStore.cs diff --git a/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/CefSharpPanel.xaml b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/CefSharpPanel.xaml similarity index 100% rename from CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/CefSharpPanel.xaml rename to DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/CefSharpPanel.xaml diff --git a/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/CefSharpPanel.xaml.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/CefSharpPanel.xaml.cs similarity index 100% rename from CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/CefSharpPanel.xaml.cs rename to DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/CefSharpPanel.xaml.cs diff --git a/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/IRevitIdleManager.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/IRevitIdleManager.cs similarity index 100% rename from CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/IRevitIdleManager.cs rename to DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/IRevitIdleManager.cs diff --git a/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/IRevitPlugin.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/IRevitPlugin.cs similarity index 100% rename from CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/IRevitPlugin.cs rename to DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/IRevitPlugin.cs diff --git a/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitCommand.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitCommand.cs similarity index 100% rename from CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitCommand.cs rename to DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitCommand.cs diff --git a/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitContext.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitContext.cs similarity index 92% rename from CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitContext.cs rename to DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitContext.cs index 125c249750..e2fbab964d 100644 --- a/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitContext.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitContext.cs @@ -5,8 +5,6 @@ namespace Speckle.Connectors.Revit.Plugin; public class RevitContext { - private CefSharpPanel? _panel; - private UIApplication? _uiApplication; public UIApplication? UIApplication diff --git a/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitExternalApplication.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitExternalApplication.cs similarity index 100% rename from CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitExternalApplication.cs rename to DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitExternalApplication.cs diff --git a/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitIdleManager.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitIdleManager.cs similarity index 100% rename from CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitIdleManager.cs rename to DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitIdleManager.cs diff --git a/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitPlugin.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitPlugin.cs similarity index 100% rename from CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitPlugin.cs rename to DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitPlugin.cs diff --git a/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitSettings.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitSettings.cs similarity index 100% rename from CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitSettings.cs rename to DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitSettings.cs diff --git a/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/Speckle.Connectors.Revit2023.addin b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/Speckle.Connectors.Revit2023.addin similarity index 100% rename from CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/Speckle.Connectors.Revit2023.addin rename to DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/Speckle.Connectors.Revit2023.addin diff --git a/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Speckle.Connectors.RevitShared.projitems b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Speckle.Connectors.RevitShared.projitems similarity index 100% rename from CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Speckle.Connectors.RevitShared.projitems rename to DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Speckle.Connectors.RevitShared.projitems diff --git a/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Speckle.Connectors.RevitShared.shproj b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Speckle.Connectors.RevitShared.shproj similarity index 93% rename from CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Speckle.Connectors.RevitShared.shproj rename to DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Speckle.Connectors.RevitShared.shproj index 20bc9ab496..e6073eb4d9 100644 --- a/CNX-8892/Connectors/Revit/Speckle.Connectors.RevitShared/Speckle.Connectors.RevitShared.shproj +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Speckle.Connectors.RevitShared.shproj @@ -1,7 +1,7 @@ - 32aea787-c986-4b76-a57f-0da5453aa1f5 + {DC570FFF-6FE5-47BD-8BC1-B471A6067786} 14.0 diff --git a/CNX-8892/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/AutofacRevitConverterModule.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/AutofacRevitConverterModule.cs similarity index 100% rename from CNX-8892/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/AutofacRevitConverterModule.cs rename to DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/AutofacRevitConverterModule.cs diff --git a/CNX-8892/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/Speckle.Converters.Revit2023.DependencyInjection.csproj b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/Speckle.Converters.Revit2023.DependencyInjection.csproj similarity index 100% rename from CNX-8892/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/Speckle.Converters.Revit2023.DependencyInjection.csproj rename to DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/Speckle.Converters.Revit2023.DependencyInjection.csproj diff --git a/CNX-8892/Converters/Revit/Speckle.Converters.Revit2023/Speckle.Converters.Revit2023.csproj b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023/Speckle.Converters.Revit2023.csproj similarity index 100% rename from CNX-8892/Converters/Revit/Speckle.Converters.Revit2023/Speckle.Converters.Revit2023.csproj rename to DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023/Speckle.Converters.Revit2023.csproj diff --git a/CNX-8892/Converters/Revit/Speckle.Converters.RevitShared/RevitConverterToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/RevitConverterToSpeckle.cs similarity index 100% rename from CNX-8892/Converters/Revit/Speckle.Converters.RevitShared/RevitConverterToSpeckle.cs rename to DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/RevitConverterToSpeckle.cs diff --git a/CNX-8892/Converters/Revit/Speckle.Converters.RevitShared/Speckle.Converters.RevitShared.projitems b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Speckle.Converters.RevitShared.projitems similarity index 100% rename from CNX-8892/Converters/Revit/Speckle.Converters.RevitShared/Speckle.Converters.RevitShared.projitems rename to DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Speckle.Converters.RevitShared.projitems diff --git a/CNX-8892/Converters/Revit/Speckle.Converters.RevitShared/Speckle.Converters.RevitShared.shproj b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Speckle.Converters.RevitShared.shproj similarity index 92% rename from CNX-8892/Converters/Revit/Speckle.Converters.RevitShared/Speckle.Converters.RevitShared.shproj rename to DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Speckle.Converters.RevitShared.shproj index 086a77a4aa..8f0ef81afc 100644 --- a/CNX-8892/Converters/Revit/Speckle.Converters.RevitShared/Speckle.Converters.RevitShared.shproj +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Speckle.Converters.RevitShared.shproj @@ -1,7 +1,7 @@ - 9655be78-8070-4b9f-b0dc-68bb6150b52c + {E1C43415-3200-45F4-8BF9-A4DD7D7F2ED6} 14.0 @@ -10,4 +10,4 @@ - + \ No newline at end of file diff --git a/CNX-8892/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/FloorConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/FloorConversionToSpeckle.cs similarity index 100% rename from CNX-8892/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/FloorConversionToSpeckle.cs rename to DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/FloorConversionToSpeckle.cs diff --git a/CNX-8892/DUI3/Speckle.Connectors.DUI/Bindings/AccountBinding.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/AccountBinding.cs similarity index 100% rename from CNX-8892/DUI3/Speckle.Connectors.DUI/Bindings/AccountBinding.cs rename to DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/AccountBinding.cs diff --git a/CNX-8892/DUI3/Speckle.Connectors.DUI/Bindings/IBasicConnectorBinding.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/IBasicConnectorBinding.cs similarity index 100% rename from CNX-8892/DUI3/Speckle.Connectors.DUI/Bindings/IBasicConnectorBinding.cs rename to DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/IBasicConnectorBinding.cs diff --git a/CNX-8892/DUI3/Speckle.Connectors.DUI/Bindings/IBinding.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/IBinding.cs similarity index 100% rename from CNX-8892/DUI3/Speckle.Connectors.DUI/Bindings/IBinding.cs rename to DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/IBinding.cs diff --git a/CNX-8892/DUI3/Speckle.Connectors.DUI/Bindings/IReceiveBinding.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/IReceiveBinding.cs similarity index 100% rename from CNX-8892/DUI3/Speckle.Connectors.DUI/Bindings/IReceiveBinding.cs rename to DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/IReceiveBinding.cs diff --git a/CNX-8892/DUI3/Speckle.Connectors.DUI/Bindings/ISelectionBinding.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/ISelectionBinding.cs similarity index 100% rename from CNX-8892/DUI3/Speckle.Connectors.DUI/Bindings/ISelectionBinding.cs rename to DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/ISelectionBinding.cs diff --git a/CNX-8892/DUI3/Speckle.Connectors.DUI/Bindings/ISendBinding.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/ISendBinding.cs similarity index 100% rename from CNX-8892/DUI3/Speckle.Connectors.DUI/Bindings/ISendBinding.cs rename to DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/ISendBinding.cs diff --git a/CNX-8892/DUI3/Speckle.Connectors.DUI/Bindings/ISendBindingUICommands.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/ISendBindingUICommands.cs similarity index 100% rename from CNX-8892/DUI3/Speckle.Connectors.DUI/Bindings/ISendBindingUICommands.cs rename to DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/ISendBindingUICommands.cs diff --git a/CNX-8892/DUI3/Speckle.Connectors.DUI/Bindings/SendBindingUICommands.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/SendBindingUICommands.cs similarity index 100% rename from CNX-8892/DUI3/Speckle.Connectors.DUI/Bindings/SendBindingUICommands.cs rename to DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/SendBindingUICommands.cs diff --git a/CNX-8892/DUI3/Speckle.Connectors.DUI/Bridge/BrowserBridge.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/BrowserBridge.cs similarity index 100% rename from CNX-8892/DUI3/Speckle.Connectors.DUI/Bridge/BrowserBridge.cs rename to DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/BrowserBridge.cs diff --git a/CNX-8892/DUI3/Speckle.Connectors.DUI/Bridge/IBridge.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/IBridge.cs similarity index 100% rename from CNX-8892/DUI3/Speckle.Connectors.DUI/Bridge/IBridge.cs rename to DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/IBridge.cs diff --git a/CNX-8892/DUI3/Speckle.Connectors.DUI/GlobalSuppressions.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/GlobalSuppressions.cs similarity index 100% rename from CNX-8892/DUI3/Speckle.Connectors.DUI/GlobalSuppressions.cs rename to DUI3-DX/DUI3/Speckle.Connectors.DUI/GlobalSuppressions.cs diff --git a/CNX-8892/DUI3/Speckle.Connectors.DUI/Models/Card/ModelCard.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/ModelCard.cs similarity index 100% rename from CNX-8892/DUI3/Speckle.Connectors.DUI/Models/Card/ModelCard.cs rename to DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/ModelCard.cs diff --git a/CNX-8892/DUI3/Speckle.Connectors.DUI/Models/DocumentInfo.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/DocumentInfo.cs similarity index 100% rename from CNX-8892/DUI3/Speckle.Connectors.DUI/Models/DocumentInfo.cs rename to DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/DocumentInfo.cs diff --git a/CNX-8892/DUI3/Speckle.Connectors.DUI/Models/DocumentModelStore.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/DocumentModelStore.cs similarity index 100% rename from CNX-8892/DUI3/Speckle.Connectors.DUI/Models/DocumentModelStore.cs rename to DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/DocumentModelStore.cs diff --git a/CNX-8892/DUI3/Speckle.Connectors.DUI/Objects/ISpeckleHostObject.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Objects/ISpeckleHostObject.cs similarity index 100% rename from CNX-8892/DUI3/Speckle.Connectors.DUI/Objects/ISpeckleHostObject.cs rename to DUI3-DX/DUI3/Speckle.Connectors.DUI/Objects/ISpeckleHostObject.cs diff --git a/CNX-8892/DUI3/Speckle.Connectors.DUI/Settings/CardSetting.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Settings/CardSetting.cs similarity index 100% rename from CNX-8892/DUI3/Speckle.Connectors.DUI/Settings/CardSetting.cs rename to DUI3-DX/DUI3/Speckle.Connectors.DUI/Settings/CardSetting.cs diff --git a/CNX-8892/DUI3/Speckle.Connectors.DUI/Speckle.Connectors.DUI.csproj b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Speckle.Connectors.DUI.csproj similarity index 100% rename from CNX-8892/DUI3/Speckle.Connectors.DUI/Speckle.Connectors.DUI.csproj rename to DUI3-DX/DUI3/Speckle.Connectors.DUI/Speckle.Connectors.DUI.csproj diff --git a/CNX-8892/DUI3/Speckle.Connectors.DUI/Utils/DiscriminatedObject.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Utils/DiscriminatedObject.cs similarity index 100% rename from CNX-8892/DUI3/Speckle.Connectors.DUI/Utils/DiscriminatedObject.cs rename to DUI3-DX/DUI3/Speckle.Connectors.DUI/Utils/DiscriminatedObject.cs diff --git a/CNX-8892/DUI3/Speckle.Connectors.DUI/Utils/DiscriminatedObjectConverter.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Utils/DiscriminatedObjectConverter.cs similarity index 100% rename from CNX-8892/DUI3/Speckle.Connectors.DUI/Utils/DiscriminatedObjectConverter.cs rename to DUI3-DX/DUI3/Speckle.Connectors.DUI/Utils/DiscriminatedObjectConverter.cs diff --git a/CNX-8892/DUI3/Speckle.Connectors.DUI/Utils/ModelNotFoundException.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Utils/ModelNotFoundException.cs similarity index 100% rename from CNX-8892/DUI3/Speckle.Connectors.DUI/Utils/ModelNotFoundException.cs rename to DUI3-DX/DUI3/Speckle.Connectors.DUI/Utils/ModelNotFoundException.cs diff --git a/CNX-8892/DUI3/Speckle.Connectors.DUI/Utils/PropertyValidator.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Utils/PropertyValidator.cs similarity index 100% rename from CNX-8892/DUI3/Speckle.Connectors.DUI/Utils/PropertyValidator.cs rename to DUI3-DX/DUI3/Speckle.Connectors.DUI/Utils/PropertyValidator.cs diff --git a/CNX-8892/Directory.Build.Props b/DUI3-DX/Directory.Build.Props similarity index 100% rename from CNX-8892/Directory.Build.Props rename to DUI3-DX/Directory.Build.Props diff --git a/CNX-8892/Objects/Speckle.Objects.Common/BuiltElements/Floor.cs b/DUI3-DX/Objects/Speckle.Objects.Common/BuiltElements/Floor.cs similarity index 100% rename from CNX-8892/Objects/Speckle.Objects.Common/BuiltElements/Floor.cs rename to DUI3-DX/Objects/Speckle.Objects.Common/BuiltElements/Floor.cs diff --git a/CNX-8892/Objects/Speckle.Objects.Common/BuiltElements/Level.cs b/DUI3-DX/Objects/Speckle.Objects.Common/BuiltElements/Level.cs similarity index 100% rename from CNX-8892/Objects/Speckle.Objects.Common/BuiltElements/Level.cs rename to DUI3-DX/Objects/Speckle.Objects.Common/BuiltElements/Level.cs diff --git a/CNX-8892/Objects/Speckle.Objects.Common/Common/EncodingOptimisations.cs b/DUI3-DX/Objects/Speckle.Objects.Common/Common/EncodingOptimisations.cs similarity index 100% rename from CNX-8892/Objects/Speckle.Objects.Common/Common/EncodingOptimisations.cs rename to DUI3-DX/Objects/Speckle.Objects.Common/Common/EncodingOptimisations.cs diff --git a/CNX-8892/Objects/Speckle.Objects.Common/Common/IDisplayValue.cs b/DUI3-DX/Objects/Speckle.Objects.Common/Common/IDisplayValue.cs similarity index 100% rename from CNX-8892/Objects/Speckle.Objects.Common/Common/IDisplayValue.cs rename to DUI3-DX/Objects/Speckle.Objects.Common/Common/IDisplayValue.cs diff --git a/CNX-8892/Objects/Speckle.Objects.Common/Geometry/Arc.cs b/DUI3-DX/Objects/Speckle.Objects.Common/Geometry/Arc.cs similarity index 100% rename from CNX-8892/Objects/Speckle.Objects.Common/Geometry/Arc.cs rename to DUI3-DX/Objects/Speckle.Objects.Common/Geometry/Arc.cs diff --git a/CNX-8892/Objects/Speckle.Objects.Common/Geometry/Box.cs b/DUI3-DX/Objects/Speckle.Objects.Common/Geometry/Box.cs similarity index 100% rename from CNX-8892/Objects/Speckle.Objects.Common/Geometry/Box.cs rename to DUI3-DX/Objects/Speckle.Objects.Common/Geometry/Box.cs diff --git a/CNX-8892/Objects/Speckle.Objects.Common/Geometry/Circle.cs b/DUI3-DX/Objects/Speckle.Objects.Common/Geometry/Circle.cs similarity index 100% rename from CNX-8892/Objects/Speckle.Objects.Common/Geometry/Circle.cs rename to DUI3-DX/Objects/Speckle.Objects.Common/Geometry/Circle.cs diff --git a/CNX-8892/Objects/Speckle.Objects.Common/Geometry/Curve.cs b/DUI3-DX/Objects/Speckle.Objects.Common/Geometry/Curve.cs similarity index 100% rename from CNX-8892/Objects/Speckle.Objects.Common/Geometry/Curve.cs rename to DUI3-DX/Objects/Speckle.Objects.Common/Geometry/Curve.cs diff --git a/CNX-8892/Objects/Speckle.Objects.Common/Geometry/Ellipse.cs b/DUI3-DX/Objects/Speckle.Objects.Common/Geometry/Ellipse.cs similarity index 100% rename from CNX-8892/Objects/Speckle.Objects.Common/Geometry/Ellipse.cs rename to DUI3-DX/Objects/Speckle.Objects.Common/Geometry/Ellipse.cs diff --git a/CNX-8892/Objects/Speckle.Objects.Common/Geometry/Interfaces.cs b/DUI3-DX/Objects/Speckle.Objects.Common/Geometry/Interfaces.cs similarity index 100% rename from CNX-8892/Objects/Speckle.Objects.Common/Geometry/Interfaces.cs rename to DUI3-DX/Objects/Speckle.Objects.Common/Geometry/Interfaces.cs diff --git a/CNX-8892/Objects/Speckle.Objects.Common/Geometry/Line.cs b/DUI3-DX/Objects/Speckle.Objects.Common/Geometry/Line.cs similarity index 100% rename from CNX-8892/Objects/Speckle.Objects.Common/Geometry/Line.cs rename to DUI3-DX/Objects/Speckle.Objects.Common/Geometry/Line.cs diff --git a/CNX-8892/Objects/Speckle.Objects.Common/Geometry/Mesh.cs b/DUI3-DX/Objects/Speckle.Objects.Common/Geometry/Mesh.cs similarity index 100% rename from CNX-8892/Objects/Speckle.Objects.Common/Geometry/Mesh.cs rename to DUI3-DX/Objects/Speckle.Objects.Common/Geometry/Mesh.cs diff --git a/CNX-8892/Objects/Speckle.Objects.Common/Geometry/Plane.cs b/DUI3-DX/Objects/Speckle.Objects.Common/Geometry/Plane.cs similarity index 100% rename from CNX-8892/Objects/Speckle.Objects.Common/Geometry/Plane.cs rename to DUI3-DX/Objects/Speckle.Objects.Common/Geometry/Plane.cs diff --git a/CNX-8892/Objects/Speckle.Objects.Common/Geometry/Point.cs b/DUI3-DX/Objects/Speckle.Objects.Common/Geometry/Point.cs similarity index 100% rename from CNX-8892/Objects/Speckle.Objects.Common/Geometry/Point.cs rename to DUI3-DX/Objects/Speckle.Objects.Common/Geometry/Point.cs diff --git a/CNX-8892/Objects/Speckle.Objects.Common/Geometry/Polycurve.cs b/DUI3-DX/Objects/Speckle.Objects.Common/Geometry/Polycurve.cs similarity index 100% rename from CNX-8892/Objects/Speckle.Objects.Common/Geometry/Polycurve.cs rename to DUI3-DX/Objects/Speckle.Objects.Common/Geometry/Polycurve.cs diff --git a/CNX-8892/Objects/Speckle.Objects.Common/Geometry/Polyline.cs b/DUI3-DX/Objects/Speckle.Objects.Common/Geometry/Polyline.cs similarity index 100% rename from CNX-8892/Objects/Speckle.Objects.Common/Geometry/Polyline.cs rename to DUI3-DX/Objects/Speckle.Objects.Common/Geometry/Polyline.cs diff --git a/CNX-8892/Objects/Speckle.Objects.Common/Geometry/Vector.cs b/DUI3-DX/Objects/Speckle.Objects.Common/Geometry/Vector.cs similarity index 100% rename from CNX-8892/Objects/Speckle.Objects.Common/Geometry/Vector.cs rename to DUI3-DX/Objects/Speckle.Objects.Common/Geometry/Vector.cs diff --git a/CNX-8892/Objects/Speckle.Objects.Common/Primitives/Interval.cs b/DUI3-DX/Objects/Speckle.Objects.Common/Primitives/Interval.cs similarity index 100% rename from CNX-8892/Objects/Speckle.Objects.Common/Primitives/Interval.cs rename to DUI3-DX/Objects/Speckle.Objects.Common/Primitives/Interval.cs diff --git a/CNX-8892/Objects/Speckle.Objects.Common/Primitives/Interval2d.cs b/DUI3-DX/Objects/Speckle.Objects.Common/Primitives/Interval2d.cs similarity index 100% rename from CNX-8892/Objects/Speckle.Objects.Common/Primitives/Interval2d.cs rename to DUI3-DX/Objects/Speckle.Objects.Common/Primitives/Interval2d.cs diff --git a/CNX-8892/Objects/Speckle.Objects.Common/Speckle.Objects.Common.csproj b/DUI3-DX/Objects/Speckle.Objects.Common/Speckle.Objects.Common.csproj similarity index 100% rename from CNX-8892/Objects/Speckle.Objects.Common/Speckle.Objects.Common.csproj rename to DUI3-DX/Objects/Speckle.Objects.Common/Speckle.Objects.Common.csproj diff --git a/CNX-8892/Objects/Speckle.Objects.Common/Utils/Transform.cs b/DUI3-DX/Objects/Speckle.Objects.Common/Utils/Transform.cs similarity index 100% rename from CNX-8892/Objects/Speckle.Objects.Common/Utils/Transform.cs rename to DUI3-DX/Objects/Speckle.Objects.Common/Utils/Transform.cs diff --git a/CNX-8892/Objects/Speckle.Objects.Revit/Speckle.Objects.Revit.csproj b/DUI3-DX/Objects/Speckle.Objects.Revit/Speckle.Objects.Revit.csproj similarity index 100% rename from CNX-8892/Objects/Speckle.Objects.Revit/Speckle.Objects.Revit.csproj rename to DUI3-DX/Objects/Speckle.Objects.Revit/Speckle.Objects.Revit.csproj diff --git a/CNX-8892/Sdk/Speckle.Autofac/DependencyInjection/AutofacContainer.cs b/DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/AutofacContainer.cs similarity index 99% rename from CNX-8892/Sdk/Speckle.Autofac/DependencyInjection/AutofacContainer.cs rename to DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/AutofacContainer.cs index 22f1af2c6b..2819954750 100644 --- a/CNX-8892/Sdk/Speckle.Autofac/DependencyInjection/AutofacContainer.cs +++ b/DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/AutofacContainer.cs @@ -41,7 +41,6 @@ public AutofacContainer LoadAutofacModules(IEnumerable dependencyPaths) foreach (var file in assembliesInPath) { // POC: ignore already loaded? Or just get that instead of loading it? - try { // inspect the assemblies for Autofac.Module diff --git a/CNX-8892/Sdk/Speckle.Autofac/DependencyInjection/Factory.cs b/DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/Factory.cs similarity index 100% rename from CNX-8892/Sdk/Speckle.Autofac/DependencyInjection/Factory.cs rename to DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/Factory.cs diff --git a/CNX-8892/Sdk/Speckle.Autofac/DependencyInjection/IFactory.cs b/DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/IFactory.cs similarity index 100% rename from CNX-8892/Sdk/Speckle.Autofac/DependencyInjection/IFactory.cs rename to DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/IFactory.cs diff --git a/CNX-8892/Sdk/Speckle.Autofac/DependencyInjection/IScopedFactory.cs b/DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/IScopedFactory.cs similarity index 100% rename from CNX-8892/Sdk/Speckle.Autofac/DependencyInjection/IScopedFactory.cs rename to DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/IScopedFactory.cs diff --git a/CNX-8892/Sdk/Speckle.Autofac/DependencyInjection/NameAndRankValueAttribute.cs b/DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/NameAndRankValueAttribute.cs similarity index 100% rename from CNX-8892/Sdk/Speckle.Autofac/DependencyInjection/NameAndRankValueAttribute.cs rename to DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/NameAndRankValueAttribute.cs diff --git a/CNX-8892/Sdk/Speckle.Autofac/DependencyInjection/NamedTypeInjector.cs b/DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/NamedTypeInjector.cs similarity index 100% rename from CNX-8892/Sdk/Speckle.Autofac/DependencyInjection/NamedTypeInjector.cs rename to DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/NamedTypeInjector.cs diff --git a/CNX-8892/Sdk/Speckle.Autofac/DependencyInjection/ScopedFactory.cs b/DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/ScopedFactory.cs similarity index 100% rename from CNX-8892/Sdk/Speckle.Autofac/DependencyInjection/ScopedFactory.cs rename to DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/ScopedFactory.cs diff --git a/CNX-8892/Sdk/Speckle.Autofac/Files/IStorageInfo.cs b/DUI3-DX/Sdk/Speckle.Autofac/Files/IStorageInfo.cs similarity index 100% rename from CNX-8892/Sdk/Speckle.Autofac/Files/IStorageInfo.cs rename to DUI3-DX/Sdk/Speckle.Autofac/Files/IStorageInfo.cs diff --git a/CNX-8892/Sdk/Speckle.Autofac/Files/StorageInfo.cs b/DUI3-DX/Sdk/Speckle.Autofac/Files/StorageInfo.cs similarity index 100% rename from CNX-8892/Sdk/Speckle.Autofac/Files/StorageInfo.cs rename to DUI3-DX/Sdk/Speckle.Autofac/Files/StorageInfo.cs diff --git a/CNX-8892/Sdk/Speckle.Autofac/GlobalSuppressions.cs b/DUI3-DX/Sdk/Speckle.Autofac/GlobalSuppressions.cs similarity index 100% rename from CNX-8892/Sdk/Speckle.Autofac/GlobalSuppressions.cs rename to DUI3-DX/Sdk/Speckle.Autofac/GlobalSuppressions.cs diff --git a/CNX-8892/Sdk/Speckle.Autofac/Speckle.Autofac.csproj b/DUI3-DX/Sdk/Speckle.Autofac/Speckle.Autofac.csproj similarity index 100% rename from CNX-8892/Sdk/Speckle.Autofac/Speckle.Autofac.csproj rename to DUI3-DX/Sdk/Speckle.Autofac/Speckle.Autofac.csproj diff --git a/CNX-8892/Sdk/Speckle.Connectors.Utils/Cancellation/CancellationManager.cs b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Cancellation/CancellationManager.cs similarity index 100% rename from CNX-8892/Sdk/Speckle.Connectors.Utils/Cancellation/CancellationManager.cs rename to DUI3-DX/Sdk/Speckle.Connectors.Utils/Cancellation/CancellationManager.cs diff --git a/CNX-8892/Sdk/Speckle.Connectors.Utils/Cancellation/ICancelable.cs b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Cancellation/ICancelable.cs similarity index 100% rename from CNX-8892/Sdk/Speckle.Connectors.Utils/Cancellation/ICancelable.cs rename to DUI3-DX/Sdk/Speckle.Connectors.Utils/Cancellation/ICancelable.cs diff --git a/CNX-8892/Sdk/Speckle.Connectors.Utils/Reflection/AssemblyExtensions.cs b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Reflection/AssemblyExtensions.cs similarity index 100% rename from CNX-8892/Sdk/Speckle.Connectors.Utils/Reflection/AssemblyExtensions.cs rename to DUI3-DX/Sdk/Speckle.Connectors.Utils/Reflection/AssemblyExtensions.cs diff --git a/CNX-8892/Sdk/Speckle.Connectors.Utils/Speckle.Connectors.Utils.csproj b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Speckle.Connectors.Utils.csproj similarity index 100% rename from CNX-8892/Sdk/Speckle.Connectors.Utils/Speckle.Connectors.Utils.csproj rename to DUI3-DX/Sdk/Speckle.Connectors.Utils/Speckle.Connectors.Utils.csproj diff --git a/CNX-8892/Sdk/Speckle.Connectors.Utils/SpeckleTopLevelExceptionHandler.cs b/DUI3-DX/Sdk/Speckle.Connectors.Utils/SpeckleTopLevelExceptionHandler.cs similarity index 100% rename from CNX-8892/Sdk/Speckle.Connectors.Utils/SpeckleTopLevelExceptionHandler.cs rename to DUI3-DX/Sdk/Speckle.Connectors.Utils/SpeckleTopLevelExceptionHandler.cs diff --git a/CNX-8892/Sdk/Speckle.Converters.Common/ISpeckleConverterToHost.cs b/DUI3-DX/Sdk/Speckle.Converters.Common/ISpeckleConverterToHost.cs similarity index 100% rename from CNX-8892/Sdk/Speckle.Converters.Common/ISpeckleConverterToHost.cs rename to DUI3-DX/Sdk/Speckle.Converters.Common/ISpeckleConverterToHost.cs diff --git a/CNX-8892/Sdk/Speckle.Converters.Common/ISpeckleConverterToSpeckle.cs b/DUI3-DX/Sdk/Speckle.Converters.Common/ISpeckleConverterToSpeckle.cs similarity index 100% rename from CNX-8892/Sdk/Speckle.Converters.Common/ISpeckleConverterToSpeckle.cs rename to DUI3-DX/Sdk/Speckle.Converters.Common/ISpeckleConverterToSpeckle.cs diff --git a/CNX-8892/Sdk/Speckle.Converters.Common/Objects/FloorConversion.cs b/DUI3-DX/Sdk/Speckle.Converters.Common/Objects/FloorConversion.cs similarity index 100% rename from CNX-8892/Sdk/Speckle.Converters.Common/Objects/FloorConversion.cs rename to DUI3-DX/Sdk/Speckle.Converters.Common/Objects/FloorConversion.cs diff --git a/CNX-8892/Sdk/Speckle.Converters.Common/Objects/IHostObjectToSpeckleConversion.cs b/DUI3-DX/Sdk/Speckle.Converters.Common/Objects/IHostObjectToSpeckleConversion.cs similarity index 100% rename from CNX-8892/Sdk/Speckle.Converters.Common/Objects/IHostObjectToSpeckleConversion.cs rename to DUI3-DX/Sdk/Speckle.Converters.Common/Objects/IHostObjectToSpeckleConversion.cs diff --git a/CNX-8892/Sdk/Speckle.Converters.Common/Objects/ISpeckleObjectToHostConversion.cs b/DUI3-DX/Sdk/Speckle.Converters.Common/Objects/ISpeckleObjectToHostConversion.cs similarity index 100% rename from CNX-8892/Sdk/Speckle.Converters.Common/Objects/ISpeckleObjectToHostConversion.cs rename to DUI3-DX/Sdk/Speckle.Converters.Common/Objects/ISpeckleObjectToHostConversion.cs diff --git a/CNX-8892/Sdk/Speckle.Converters.Common/ReceiveMode.cs b/DUI3-DX/Sdk/Speckle.Converters.Common/ReceiveMode.cs similarity index 100% rename from CNX-8892/Sdk/Speckle.Converters.Common/ReceiveMode.cs rename to DUI3-DX/Sdk/Speckle.Converters.Common/ReceiveMode.cs diff --git a/CNX-8892/Sdk/Speckle.Converters.Common/Speckle.Converters.Common.csproj b/DUI3-DX/Sdk/Speckle.Converters.Common/Speckle.Converters.Common.csproj similarity index 100% rename from CNX-8892/Sdk/Speckle.Converters.Common/Speckle.Converters.Common.csproj rename to DUI3-DX/Sdk/Speckle.Converters.Common/Speckle.Converters.Common.csproj diff --git a/DesktopUI3/DUI3/Bindings/ISendBinding.cs b/DesktopUI3/DUI3/Bindings/ISendBinding.cs index 65a8b8dcc3..59c75ec703 100644 --- a/DesktopUI3/DUI3/Bindings/ISendBinding.cs +++ b/DesktopUI3/DUI3/Bindings/ISendBinding.cs @@ -42,6 +42,8 @@ public static void SetModelCreatedVersionId(IBridge bridge, string modelCardId, public class SenderModelCard : ModelCard { public ISendFilter SendFilter { get; set; } + public string ProjectId { get; set; } + public string ModelId { get; set; } [JsonIgnore] public HashSet ChangedObjectIds { get; set; } = new(); diff --git a/Objects/Converters/ConverterNavisworks/ConverterNavisworks2020/ConverterNavisworks2020.csproj b/Objects/Converters/ConverterNavisworks/ConverterNavisworks2020/ConverterNavisworks2020.csproj index fa1e9ee2c7..1dc2afda3b 100644 --- a/Objects/Converters/ConverterNavisworks/ConverterNavisworks2020/ConverterNavisworks2020.csproj +++ b/Objects/Converters/ConverterNavisworks/ConverterNavisworks2020/ConverterNavisworks2020.csproj @@ -3,7 +3,6 @@ SpeckleConverterNavisworks Objects.Converter.Navisworks2020 Objects.Converter.Navisworks - AnyCPU;x64 bin\x64\$(Configuration) true $(DefineConstants);NAVMAN17 diff --git a/Objects/Converters/ConverterNavisworks/ConverterNavisworks2021/ConverterNavisworks2021.csproj b/Objects/Converters/ConverterNavisworks/ConverterNavisworks2021/ConverterNavisworks2021.csproj index 3494efb2f4..aafe1b03a8 100644 --- a/Objects/Converters/ConverterNavisworks/ConverterNavisworks2021/ConverterNavisworks2021.csproj +++ b/Objects/Converters/ConverterNavisworks/ConverterNavisworks2021/ConverterNavisworks2021.csproj @@ -3,7 +3,6 @@ SpeckleConverterNavisworks Objects.Converter.Navisworks2021 Objects.Converter.Navisworks - AnyCPU;x64 bin\x64\$(Configuration) true $(DefineConstants);NAVMAN18 diff --git a/Objects/Converters/ConverterNavisworks/ConverterNavisworks2022/ConverterNavisworks2022.csproj b/Objects/Converters/ConverterNavisworks/ConverterNavisworks2022/ConverterNavisworks2022.csproj index dc26fb29a6..6f0de2a027 100644 --- a/Objects/Converters/ConverterNavisworks/ConverterNavisworks2022/ConverterNavisworks2022.csproj +++ b/Objects/Converters/ConverterNavisworks/ConverterNavisworks2022/ConverterNavisworks2022.csproj @@ -3,7 +3,6 @@ SpeckleConverterNavisworks Objects.Converter.Navisworks2022 Objects.Converter.Navisworks - AnyCPU;x64 bin\x64\$(Configuration) true $(DefineConstants);NAVMAN19 diff --git a/Objects/Converters/ConverterNavisworks/ConverterNavisworks2023/ConverterNavisworks2023.csproj b/Objects/Converters/ConverterNavisworks/ConverterNavisworks2023/ConverterNavisworks2023.csproj index f752f554f7..ed59912974 100644 --- a/Objects/Converters/ConverterNavisworks/ConverterNavisworks2023/ConverterNavisworks2023.csproj +++ b/Objects/Converters/ConverterNavisworks/ConverterNavisworks2023/ConverterNavisworks2023.csproj @@ -3,7 +3,6 @@ SpeckleConverterNavisworks Objects.Converter.Navisworks2023 Objects.Converter.Navisworks - AnyCPU;x64 bin\x64\$(Configuration) true $(DefineConstants);NAVMAN20 diff --git a/Objects/Converters/ConverterNavisworks/ConverterNavisworks2024/ConverterNavisworks2024.csproj b/Objects/Converters/ConverterNavisworks/ConverterNavisworks2024/ConverterNavisworks2024.csproj index 65fcd43333..2d190db12d 100644 --- a/Objects/Converters/ConverterNavisworks/ConverterNavisworks2024/ConverterNavisworks2024.csproj +++ b/Objects/Converters/ConverterNavisworks/ConverterNavisworks2024/ConverterNavisworks2024.csproj @@ -3,7 +3,6 @@ SpeckleConverterNavisworks Objects.Converter.Navisworks2024 Objects.Converter.Navisworks - AnyCPU;x64 bin\x64\$(Configuration) true $(DefineConstants);NAVMAN21 From 688089a7e6e07f974e541f148f7763201b378051 Mon Sep 17 00:00:00 2001 From: Alan Rynne Date: Mon, 18 Mar 2024 14:38:30 +0100 Subject: [PATCH 009/261] feat(dui3): Rhino7 project working with DI (#3236) * feat(dui3): Rhino7 project working with DI * fix: Incorrect formatting after disabling pre-commit hook. * fix: Minor edits to solution and slnf --- All.sln | 65 ++- DUI3-DX.slnf | 17 +- .../Bindings/BasicConnectorBindingRevit.cs | 4 +- .../Bindings/SendBinding.cs | 8 +- .../Bindings/RhinoBasicConnectorBinding.cs | 118 ++++++ .../Bindings/RhinoSelectionBinding.cs | 61 +++ .../Bindings/RhinoSendBinding.cs | 380 ++++++++++++++++++ .../DependencyInjection/AutofacRhinoModule.cs | 86 ++++ .../DependencyInjection/RhinoPlugin.cs | 30 ++ .../EmbeddedResources/plugin-utility.ico | Bin 0 -> 33583 bytes .../Extensions/BoundingBox.cs | 35 ++ .../Filters/RhinoEverythingFilter.cs | 11 + .../Filters/RhinoSelectionFilter.cs | 12 + .../HostApp/RhinoContext.cs | 8 + .../HostApp/RhinoDocumentStore.cs | 61 +++ .../HostApp/RhinoIdleManager.cs | 45 +++ .../HostApp/RhinoSettings.cs | 19 + .../HostApp/SpeckleRhinoPanel.xaml | 12 +- .../HostApp/SpeckleRhinoPanel.xaml.cs | 46 +++ .../HostApp/SpeckleRhinoPanelHost.cs | 16 + .../Interfaces/IRhinoPlugin.cs | 7 + .../Speckle.Connectors.Rhino7Command.cs | 95 +++++ .../Plugin/Speckle.Connectors.Rhino7Plugin.cs | 105 +++++ .../Properties/AssemblyInfo.cs | 20 + .../Properties/launchSettings.json | 8 + .../Speckle.Connectors.Rhino7.csproj | 36 ++ .../AutofacRhinoConverterModule.cs | 22 + ...nverters.Rhino7.DependencyInjection.csproj | 15 + .../RhinoConverterToSpeckle.cs | 23 ++ .../Speckle.Converters.Rhino7.csproj | 14 + .../Bindings/IBasicConnectorBinding.cs | 26 ++ .../Bindings/ISendBinding.cs | 2 + .../Bindings/SendBindingUICommands.cs | 25 +- .../Models/Card/ModelCardError.cs | 9 + .../Models/Card/ModelCardNotification.cs | 10 + .../Models/Card/ModelCardProgress.cs | 13 + .../Operations/Send.cs | 200 +++++++++ 37 files changed, 1631 insertions(+), 33 deletions(-) create mode 100644 DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoBasicConnectorBinding.cs create mode 100644 DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSelectionBinding.cs create mode 100644 DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSendBinding.cs create mode 100644 DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/AutofacRhinoModule.cs create mode 100644 DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/RhinoPlugin.cs create mode 100644 DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/EmbeddedResources/plugin-utility.ico create mode 100644 DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Extensions/BoundingBox.cs create mode 100644 DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Filters/RhinoEverythingFilter.cs create mode 100644 DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Filters/RhinoSelectionFilter.cs create mode 100644 DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/RhinoContext.cs create mode 100644 DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/RhinoDocumentStore.cs create mode 100644 DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/RhinoIdleManager.cs create mode 100644 DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/RhinoSettings.cs rename ConnectorRhino/ConnectorRhinoWebUI/SpeckleWebUiPanelWebView2.xaml => DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/SpeckleRhinoPanel.xaml (65%) create mode 100644 DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/SpeckleRhinoPanel.xaml.cs create mode 100644 DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/SpeckleRhinoPanelHost.cs create mode 100644 DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Interfaces/IRhinoPlugin.cs create mode 100644 DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Plugin/Speckle.Connectors.Rhino7Command.cs create mode 100644 DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Plugin/Speckle.Connectors.Rhino7Plugin.cs create mode 100644 DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Properties/AssemblyInfo.cs create mode 100644 DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Properties/launchSettings.json create mode 100644 DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Speckle.Connectors.Rhino7.csproj create mode 100644 DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/AutofacRhinoConverterModule.cs create mode 100644 DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/Speckle.Converters.Rhino7.DependencyInjection.csproj create mode 100644 DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/RhinoConverterToSpeckle.cs create mode 100644 DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Speckle.Converters.Rhino7.csproj create mode 100644 DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/ModelCardError.cs create mode 100644 DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/ModelCardNotification.cs create mode 100644 DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/ModelCardProgress.cs create mode 100644 DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/Send.cs diff --git a/All.sln b/All.sln index a3def65093..1a23a534b2 100644 --- a/All.sln +++ b/All.sln @@ -483,7 +483,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Objects.Tests.Unit", "Objec EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "DUI3-DX", "DUI3-DX", "{9DB74760-01DE-4AC1-A81B-BC7784351D22}" ProjectSection(SolutionItems) = preProject - CNX-8892\Directory.Build.Props = CNX-8892\Directory.Build.Props + DUI3-DX\Directory.Build.Props = DUI3-DX\Directory.Build.Props EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Revit", "Revit", "{4838C66E-8677-4FBD-9609-25376042E981}" @@ -522,6 +522,16 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Speckle.Connectors.Utils", EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Speckle.Converters.Common", "DUI3-DX\Sdk\Speckle.Converters.Common\Speckle.Converters.Common.csproj", "{8AEF06C0-CA5C-4460-BC2D-ADE5F35D0434}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Rhino", "Rhino", "{9584AEE5-CD59-46E6-93E6-2DC2B5285B75}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Speckle.Connectors.Rhino7", "DUI3-DX\Connectors\Rhino\Speckle.Connectors.Rhino7\Speckle.Connectors.Rhino7.csproj", "{1E2644A9-6B31-4350-8772-CEAAD6EE0B21}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Rhino", "Rhino", "{34C2C062-E43F-4FB5-B839-64BC044CCEF3}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Speckle.Converters.Rhino7", "DUI3-DX\Converters\Rhino\Speckle.Converters.Rhino7\Speckle.Converters.Rhino7.csproj", "{65A2F556-F14A-49F3-8A92-7F2E1E7ED3B5}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Speckle.Converters.Rhino7.DependencyInjection", "DUI3-DX\Converters\Rhino\Speckle.Converters.Rhino7.DependencyInjection\Speckle.Converters.Rhino7.DependencyInjection.csproj", "{9C1ECA1D-DE98-4FB7-92D0-FC45BB308E5D}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug Mac|Any CPU = Debug Mac|Any CPU @@ -2580,6 +2590,54 @@ Global {8AEF06C0-CA5C-4460-BC2D-ADE5F35D0434}.Release|Any CPU.Build.0 = Release|Any CPU {8AEF06C0-CA5C-4460-BC2D-ADE5F35D0434}.Release|x64.ActiveCfg = Release|Any CPU {8AEF06C0-CA5C-4460-BC2D-ADE5F35D0434}.Release|x64.Build.0 = Release|Any CPU + {1E2644A9-6B31-4350-8772-CEAAD6EE0B21}.Debug Mac|Any CPU.ActiveCfg = Debug|Any CPU + {1E2644A9-6B31-4350-8772-CEAAD6EE0B21}.Debug Mac|Any CPU.Build.0 = Debug|Any CPU + {1E2644A9-6B31-4350-8772-CEAAD6EE0B21}.Debug Mac|x64.ActiveCfg = Debug|Any CPU + {1E2644A9-6B31-4350-8772-CEAAD6EE0B21}.Debug Mac|x64.Build.0 = Debug|Any CPU + {1E2644A9-6B31-4350-8772-CEAAD6EE0B21}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1E2644A9-6B31-4350-8772-CEAAD6EE0B21}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1E2644A9-6B31-4350-8772-CEAAD6EE0B21}.Debug|x64.ActiveCfg = Debug|Any CPU + {1E2644A9-6B31-4350-8772-CEAAD6EE0B21}.Debug|x64.Build.0 = Debug|Any CPU + {1E2644A9-6B31-4350-8772-CEAAD6EE0B21}.Release Mac|Any CPU.ActiveCfg = Debug|Any CPU + {1E2644A9-6B31-4350-8772-CEAAD6EE0B21}.Release Mac|Any CPU.Build.0 = Debug|Any CPU + {1E2644A9-6B31-4350-8772-CEAAD6EE0B21}.Release Mac|x64.ActiveCfg = Debug|Any CPU + {1E2644A9-6B31-4350-8772-CEAAD6EE0B21}.Release Mac|x64.Build.0 = Debug|Any CPU + {1E2644A9-6B31-4350-8772-CEAAD6EE0B21}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1E2644A9-6B31-4350-8772-CEAAD6EE0B21}.Release|Any CPU.Build.0 = Release|Any CPU + {1E2644A9-6B31-4350-8772-CEAAD6EE0B21}.Release|x64.ActiveCfg = Release|Any CPU + {1E2644A9-6B31-4350-8772-CEAAD6EE0B21}.Release|x64.Build.0 = Release|Any CPU + {65A2F556-F14A-49F3-8A92-7F2E1E7ED3B5}.Debug Mac|Any CPU.ActiveCfg = Debug|Any CPU + {65A2F556-F14A-49F3-8A92-7F2E1E7ED3B5}.Debug Mac|Any CPU.Build.0 = Debug|Any CPU + {65A2F556-F14A-49F3-8A92-7F2E1E7ED3B5}.Debug Mac|x64.ActiveCfg = Debug|Any CPU + {65A2F556-F14A-49F3-8A92-7F2E1E7ED3B5}.Debug Mac|x64.Build.0 = Debug|Any CPU + {65A2F556-F14A-49F3-8A92-7F2E1E7ED3B5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {65A2F556-F14A-49F3-8A92-7F2E1E7ED3B5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {65A2F556-F14A-49F3-8A92-7F2E1E7ED3B5}.Debug|x64.ActiveCfg = Debug|Any CPU + {65A2F556-F14A-49F3-8A92-7F2E1E7ED3B5}.Debug|x64.Build.0 = Debug|Any CPU + {65A2F556-F14A-49F3-8A92-7F2E1E7ED3B5}.Release Mac|Any CPU.ActiveCfg = Debug|Any CPU + {65A2F556-F14A-49F3-8A92-7F2E1E7ED3B5}.Release Mac|Any CPU.Build.0 = Debug|Any CPU + {65A2F556-F14A-49F3-8A92-7F2E1E7ED3B5}.Release Mac|x64.ActiveCfg = Debug|Any CPU + {65A2F556-F14A-49F3-8A92-7F2E1E7ED3B5}.Release Mac|x64.Build.0 = Debug|Any CPU + {65A2F556-F14A-49F3-8A92-7F2E1E7ED3B5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {65A2F556-F14A-49F3-8A92-7F2E1E7ED3B5}.Release|Any CPU.Build.0 = Release|Any CPU + {65A2F556-F14A-49F3-8A92-7F2E1E7ED3B5}.Release|x64.ActiveCfg = Release|Any CPU + {65A2F556-F14A-49F3-8A92-7F2E1E7ED3B5}.Release|x64.Build.0 = Release|Any CPU + {9C1ECA1D-DE98-4FB7-92D0-FC45BB308E5D}.Debug Mac|Any CPU.ActiveCfg = Debug|Any CPU + {9C1ECA1D-DE98-4FB7-92D0-FC45BB308E5D}.Debug Mac|Any CPU.Build.0 = Debug|Any CPU + {9C1ECA1D-DE98-4FB7-92D0-FC45BB308E5D}.Debug Mac|x64.ActiveCfg = Debug|Any CPU + {9C1ECA1D-DE98-4FB7-92D0-FC45BB308E5D}.Debug Mac|x64.Build.0 = Debug|Any CPU + {9C1ECA1D-DE98-4FB7-92D0-FC45BB308E5D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9C1ECA1D-DE98-4FB7-92D0-FC45BB308E5D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9C1ECA1D-DE98-4FB7-92D0-FC45BB308E5D}.Debug|x64.ActiveCfg = Debug|Any CPU + {9C1ECA1D-DE98-4FB7-92D0-FC45BB308E5D}.Debug|x64.Build.0 = Debug|Any CPU + {9C1ECA1D-DE98-4FB7-92D0-FC45BB308E5D}.Release Mac|Any CPU.ActiveCfg = Debug|Any CPU + {9C1ECA1D-DE98-4FB7-92D0-FC45BB308E5D}.Release Mac|Any CPU.Build.0 = Debug|Any CPU + {9C1ECA1D-DE98-4FB7-92D0-FC45BB308E5D}.Release Mac|x64.ActiveCfg = Debug|Any CPU + {9C1ECA1D-DE98-4FB7-92D0-FC45BB308E5D}.Release Mac|x64.Build.0 = Debug|Any CPU + {9C1ECA1D-DE98-4FB7-92D0-FC45BB308E5D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9C1ECA1D-DE98-4FB7-92D0-FC45BB308E5D}.Release|Any CPU.Build.0 = Release|Any CPU + {9C1ECA1D-DE98-4FB7-92D0-FC45BB308E5D}.Release|x64.ActiveCfg = Release|Any CPU + {9C1ECA1D-DE98-4FB7-92D0-FC45BB308E5D}.Release|x64.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -2779,6 +2837,11 @@ Global {C9D4CA21-182B-4ED2-81BB-280A6FD713F6} = {2E00592E-558D-492D-88F9-3ECEE4C0C7DA} {7291B93C-615D-42DE-B8C1-3F9DF643E0FC} = {2E00592E-558D-492D-88F9-3ECEE4C0C7DA} {8AEF06C0-CA5C-4460-BC2D-ADE5F35D0434} = {2E00592E-558D-492D-88F9-3ECEE4C0C7DA} + {9584AEE5-CD59-46E6-93E6-2DC2B5285B75} = {33D19E88-F3AE-4D28-B588-D91CCF9E3BA8} + {1E2644A9-6B31-4350-8772-CEAAD6EE0B21} = {9584AEE5-CD59-46E6-93E6-2DC2B5285B75} + {34C2C062-E43F-4FB5-B839-64BC044CCEF3} = {1FE3C60E-7865-40A5-9794-55ECB64F6489} + {65A2F556-F14A-49F3-8A92-7F2E1E7ED3B5} = {34C2C062-E43F-4FB5-B839-64BC044CCEF3} + {9C1ECA1D-DE98-4FB7-92D0-FC45BB308E5D} = {34C2C062-E43F-4FB5-B839-64BC044CCEF3} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {1D43D91B-4F01-4A78-8250-CC6F9BD93A14} diff --git a/DUI3-DX.slnf b/DUI3-DX.slnf index b50b92c1ff..ad0e874dab 100644 --- a/DUI3-DX.slnf +++ b/DUI3-DX.slnf @@ -11,18 +11,21 @@ "Core\\Tests\\Speckle.Core.Tests.Performance\\Speckle.Core.Tests.Performance.csproj", "Core\\Tests\\Speckle.Core.Tests.Unit\\Speckle.Core.Tests.Unit.csproj", "Core\\Transports\\DiskTransport\\DiskTransport.csproj", + "DesktopUI3\\DUI3\\DUI3.csproj", "DUI3-DX\\Connectors\\Revit\\Speckle.Connectors.Revit2023\\Speckle.Connectors.Revit2023.csproj", "DUI3-DX\\Connectors\\Revit\\Speckle.Connectors.RevitShared\\Speckle.Connectors.RevitShared.shproj", + "DUI3-DX\\Connectors\\Rhino\\Speckle.Connectors.Rhino7\\Speckle.Connectors.Rhino7.csproj", "DUI3-DX\\Converters\\Revit\\Speckle.Converters.Revit2023.DependencyInjection\\Speckle.Converters.Revit2023.DependencyInjection.csproj", "DUI3-DX\\Converters\\Revit\\Speckle.Converters.Revit2023\\Speckle.Converters.Revit2023.csproj", "DUI3-DX\\Converters\\Revit\\Speckle.Converters.RevitShared\\Speckle.Converters.RevitShared.shproj", + "DUI3-DX\\Converters\\Rhino\\Speckle.Converters.Rhino7.DependencyInjection\\Speckle.Converters.Rhino7.DependencyInjection.csproj", + "DUI3-DX\\Converters\\Rhino\\Speckle.Converters.Rhino7\\Speckle.Converters.Rhino7.csproj", "DUI3-DX\\DUI3\\Speckle.Connectors.DUI\\Speckle.Connectors.DUI.csproj", "DUI3-DX\\Objects\\Speckle.Objects.Common\\Speckle.Objects.Common.csproj", "DUI3-DX\\Objects\\Speckle.Objects.Revit\\Speckle.Objects.Revit.csproj", "DUI3-DX\\Sdk\\Speckle.Autofac\\Speckle.Autofac.csproj", "DUI3-DX\\Sdk\\Speckle.Connectors.Utils\\Speckle.Connectors.Utils.csproj", "DUI3-DX\\Sdk\\Speckle.Converters.Common\\Speckle.Converters.Common.csproj", - "DesktopUI3\\DUI3\\DUI3.csproj", "Objects\\Converters\\ConverterAutocadCivil\\ConverterAdvanceSteel2023\\ConverterAdvanceSteel2023.csproj", "Objects\\Converters\\ConverterAutocadCivil\\ConverterAdvanceSteel2024\\ConverterAdvanceSteel2024.csproj", "Objects\\Converters\\ConverterAutocadCivil\\ConverterAutocad2021\\ConverterAutocad2021.csproj", @@ -35,24 +38,12 @@ "Objects\\Converters\\ConverterAutocadCivil\\ConverterCivil2023\\ConverterCivil2023.csproj", "Objects\\Converters\\ConverterAutocadCivil\\ConverterCivil2024\\ConverterCivil2024.csproj", "Objects\\Converters\\ConverterDxf\\ConverterDxf\\ConverterDxf.csproj", - "Objects\\Converters\\ConverterDynamo\\ConverterDynamoRevit2021\\ConverterDynamoRevit2021.csproj", - "Objects\\Converters\\ConverterDynamo\\ConverterDynamoRevit2022\\ConverterDynamoRevit2022.csproj", - "Objects\\Converters\\ConverterDynamo\\ConverterDynamoRevit2023\\ConverterDynamoRevit2023.csproj", - "Objects\\Converters\\ConverterDynamo\\ConverterDynamoRevit2024\\ConverterDynamoRevit2024.csproj", - "Objects\\Converters\\ConverterDynamo\\ConverterDynamoRevit\\ConverterDynamoRevit.csproj", - "Objects\\Converters\\ConverterDynamo\\ConverterDynamoSandbox\\ConverterDynamoSandbox.csproj", - "Objects\\Converters\\ConverterDynamo\\ConverterDynamoShared\\ConverterDynamoShared.shproj", "Objects\\Converters\\ConverterRevit\\ConverterRevit2020\\ConverterRevit2020.csproj", "Objects\\Converters\\ConverterRevit\\ConverterRevit2021\\ConverterRevit2021.csproj", "Objects\\Converters\\ConverterRevit\\ConverterRevit2022\\ConverterRevit2022.csproj", "Objects\\Converters\\ConverterRevit\\ConverterRevit2023\\ConverterRevit2023.csproj", "Objects\\Converters\\ConverterRevit\\ConverterRevit2024\\ConverterRevit2024.csproj", "Objects\\Converters\\ConverterRevit\\ConverterRevitShared\\ConverterRevitShared.shproj", - "Objects\\Converters\\ConverterRevit\\ConverterRevitTests\\ConverterRevitTests2021\\ConverterRevitTests2021.csproj", - "Objects\\Converters\\ConverterRevit\\ConverterRevitTests\\ConverterRevitTests2022\\ConverterRevitTests2022.csproj", - "Objects\\Converters\\ConverterRevit\\ConverterRevitTests\\ConverterRevitTests2023\\ConverterRevitTests2023.csproj", - "Objects\\Converters\\ConverterRevit\\ConverterRevitTests\\ConverterRevitTestsShared\\ConverterRevitTestsShared.shproj", - "Objects\\Converters\\ConverterRevit\\ConverterRevitTests\\TestGenerator\\TestGenerator.csproj", "Objects\\Converters\\ConverterRhinoGh\\ConverterGrasshopper6\\ConverterGrasshopper6.csproj", "Objects\\Converters\\ConverterRhinoGh\\ConverterGrasshopper7\\ConverterGrasshopper7.csproj", "Objects\\Converters\\ConverterRhinoGh\\ConverterGrasshopper8\\ConverterGrasshopper8.csproj", diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/BasicConnectorBindingRevit.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/BasicConnectorBindingRevit.cs index bc1917b371..230408c2ed 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/BasicConnectorBindingRevit.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/BasicConnectorBindingRevit.cs @@ -34,7 +34,7 @@ RevitContext revitContext _store = store; _revitContext = revitContext; _revitSettings = revitSettings; - + Commands = new BasicConnectorBindingCommands(parent); // POC: event binding? _store.DocumentChanged += (_, _) => { @@ -152,4 +152,6 @@ public void HighlightModel(string modelCardId) } }); } + + public BasicConnectorBindingCommands Commands { get; } } diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SendBinding.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SendBinding.cs index 40459940fd..19ff2be6e7 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SendBinding.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SendBinding.cs @@ -14,7 +14,7 @@ namespace Speckle.Connectors.Revit.Bindings; -internal class SendBinding : RevitBaseBinding, ICancelable +internal class SendBinding : RevitBaseBinding, ICancelable, ISendBinding { // POC:does it need injecting? public CancellationManager CancellationManager { get; } = new(); @@ -39,7 +39,7 @@ IBridge bridge _speckleConverterToSpeckleFactory = speckleConverterToSpeckleFactory; _speckleConverterToSpeckle = _speckleConverterToSpeckleFactory.ResolveScopedInstance(); _idleManager = idleManager; - + Commands = new SendBindingUICommands(bridge); // TODO expiry events // TODO filters need refresh events revitContext.UIApplication.Application.DocumentChanged += (_, e) => DocChangeHandler(e); @@ -65,6 +65,8 @@ public void CancelSend(string modelCardId) CancellationManager.CancelOperation(modelCardId); } + public SendBindingUICommands Commands { get; } + private void HandleSend(string modelCardId) { _speckleConverterToSpeckle.Convert(); @@ -135,7 +137,7 @@ private void RunExpirationChecks() } } - SendBindingUICommands.SetModelsExpired(Parent, expiredSenderIds); + Commands.SetModelsExpired(expiredSenderIds); ChangedObjectIds = new HashSet(); } diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoBasicConnectorBinding.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoBasicConnectorBinding.cs new file mode 100644 index 0000000000..022051adca --- /dev/null +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoBasicConnectorBinding.cs @@ -0,0 +1,118 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using Rhino; +using Rhino.DocObjects; +using Rhino.Geometry; +using Sentry.Reflection; +using Speckle.Connectors.DUI.Bindings; +using Speckle.Connectors.DUI.Bridge; +using Speckle.Connectors.DUI.Models; +using Speckle.Connectors.DUI.Models.Card; +using Speckle.Connectors.Rhino7.Extensions; +using Speckle.Connectors.Rhino7.HostApp; + +namespace Speckle.Connectors.Rhino7.Bindings; + +public class RhinoBasicConnectorBinding : IBasicConnectorBinding +{ + public string Name { get; set; } = "baseBinding"; + public IBridge Parent { get; set; } + public BasicConnectorBindingCommands Commands { get; } + + private readonly DocumentModelStore _store; + private readonly RhinoSettings _settings; + + public RhinoBasicConnectorBinding(DocumentModelStore store, RhinoSettings settings, IBridge parent) + { + _store = store; + _settings = settings; + Parent = parent; + Commands = new BasicConnectorBindingCommands(parent); + + _store.DocumentChanged += (_, _) => + { + Commands.NotifyDocumentChanged(); + }; + } + + public string GetConnectorVersion() => + typeof(RhinoBasicConnectorBinding).Assembly.GetNameAndVersion().Version ?? "No version"; + + public string GetSourceApplicationName() => _settings.HostAppInfo.Slug; + + public string GetSourceApplicationVersion() => "7"; + + public DocumentInfo GetDocumentInfo() => + new() + { + Location = RhinoDoc.ActiveDoc.Path, + Name = RhinoDoc.ActiveDoc.Name, + Id = RhinoDoc.ActiveDoc.RuntimeSerialNumber.ToString() + }; + + public DocumentModelStore GetDocumentState() => _store; + + public void AddModel(ModelCard model) => _store.Models.Add(model); + + public void UpdateModel(ModelCard model) + { + int idx = _store.Models.FindIndex(m => model.ModelCardId == m.ModelCardId); + _store.Models[idx] = model; + } + + public void RemoveModel(ModelCard model) + { + int index = _store.Models.FindIndex(m => m.ModelCardId == model.ModelCardId); + _store.Models.RemoveAt(index); + } + + public void HighlightModel(string modelCardId) + { + var objectIds = new List(); + var myModel = _store.GetModelById(modelCardId); + + if (myModel is SenderModelCard sender) + { + objectIds = sender.SendFilter.GetObjectIds(); + } + + // TODO: Disabled receiver specifics + // if (myModel is ReceiverModelCard receiver && receiver.ReceiveResult != null) + // { + // objectIds = receiver.ReceiveResult.BakedObjectIds; + // } + + if (objectIds.Count == 0) + { + Commands.SetModelError(modelCardId, new OperationCanceledException("No objects found to highlight.")); + return; + } + + List rhinoObjects = objectIds + .Select((id) => RhinoDoc.ActiveDoc.Objects.FindId(new Guid(id))) + .Where(o => o != null) + .ToList(); + + RhinoDoc.ActiveDoc.Objects.UnselectAll(); + + if (rhinoObjects.Count == 0) + { + Commands.SetModelError(modelCardId, new OperationCanceledException("No objects found to highlight.")); + return; + } + + RhinoDoc.ActiveDoc.Objects.Select(rhinoObjects.Select(o => o.Id)); + + // Calculate the bounding box of the selected objects + BoundingBox boundingBox = BoundingBoxExtensions.UnionRhinoObjects(rhinoObjects); + + // Zoom to the calculated bounding box + if (boundingBox.IsValid) + { + RhinoDoc.ActiveDoc.Views.ActiveView.ActiveViewport.ZoomBoundingBox(boundingBox); + } + + RhinoDoc.ActiveDoc.Views.Redraw(); + } +} diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSelectionBinding.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSelectionBinding.cs new file mode 100644 index 0000000000..23618e5d06 --- /dev/null +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSelectionBinding.cs @@ -0,0 +1,61 @@ +using System.Collections.Generic; +using System.Linq; +using Rhino; +using Rhino.DocObjects; +using Speckle.Connectors.DUI.Bindings; +using Speckle.Connectors.DUI.Bridge; +using Speckle.Connectors.Rhino7.HostApp; + +namespace Speckle.Connectors.Rhino7.Bindings; + +public class RhinoSelectionBinding : ISelectionBinding +{ + private const string SELECTION_EVENT = "setSelection"; + + public string Name { get; set; } = "selectionBinding"; + public IBridge Parent { get; set; } + + public RhinoSelectionBinding(RhinoIdleManager idleManager, IBridge parent) + { + Parent = parent; + + RhinoDoc.SelectObjects += (_, _) => + { + idleManager.SubscribeToIdle(OnSelectionChanged); + }; + RhinoDoc.DeselectObjects += (_, _) => + { + idleManager.SubscribeToIdle(OnSelectionChanged); + }; + RhinoDoc.DeselectAllObjects += (_, _) => + { + idleManager.SubscribeToIdle(OnSelectionChanged); + }; + + RhinoDoc.EndOpenDocumentInitialViewUpdate += (_, _) => + { + // Resets selection doc change + Parent?.Send(SELECTION_EVENT, new SelectionInfo()); + }; + } + + private void OnSelectionChanged() + { + SelectionInfo selInfo = GetSelection(); + Parent?.Send(SELECTION_EVENT, selInfo); + } + + public SelectionInfo GetSelection() + { + List objects = RhinoDoc.ActiveDoc.Objects.GetSelectedObjects(false, false).ToList(); + List objectIds = objects.Select(o => o.Id.ToString()).ToList(); + int layerCount = objects.Select(o => o.Attributes.LayerIndex).Distinct().Count(); + List objectTypes = objects.Select(o => o.ObjectType.ToString()).Distinct().ToList(); + return new SelectionInfo + { + SelectedObjectIds = objectIds, + Summary = + $"{objectIds.Count} objects ({string.Join(", ", objectTypes)}) from {layerCount} layer{(layerCount != 1 ? "s" : "")}" + }; + } +} diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSendBinding.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSendBinding.cs new file mode 100644 index 0000000000..4a506f4936 --- /dev/null +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSendBinding.cs @@ -0,0 +1,380 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading; +using Rhino; +using Rhino.DocObjects; +using Speckle.Autofac.DependencyInjection; +using Speckle.Core.Credentials; +using Speckle.Core.Models; +using Speckle.Core.Transports; +using Speckle.Connectors.DUI.Bindings; +using Speckle.Connectors.DUI.Bridge; +using Speckle.Connectors.DUI.Models; +using Speckle.Connectors.DUI.Models.Card; +using Speckle.Connectors.DUI.Utils; +using Speckle.Connectors.Rhino7.Filters; +using Speckle.Connectors.Rhino7.HostApp; +using Speckle.Connectors.Utils.Cancellation; +using Speckle.Connectors.Utils.Operations; +using Speckle.Converters.Common; +using Speckle.Core.Api; +using Speckle.Core.Kits; +using Speckle.Core.Logging; +using ICancelable = System.Reactive.Disposables.ICancelable; + +namespace Speckle.Connectors.Rhino7.Bindings; + +public class RhinoSendBinding : ISendBinding, ICancelable +{ + public string Name { get; } = "sendBinding"; + public SendBindingUICommands Commands { get; } + public IBridge Parent { get; set; } + + private readonly DocumentModelStore _store; + private readonly RhinoIdleManager _idleManager; + private readonly RhinoSettings _rhinoSettings; + private readonly RhinoContext _rhinoContext; + private readonly IBasicConnectorBinding _basicConnectorBinding; + private readonly ISpeckleConverterToSpeckle _toSpeckleConverter; + private readonly IScopedFactory _speckleConverterToSpeckleFactory; + + public CancellationManager CancellationManager { get; } = new(); + + /// + /// Used internally to aggregate the changed objects' id. + /// + private HashSet ChangedObjectIds { get; set; } = new(); + + /// + /// Keeps track of previously converted objects as a dictionary of (applicationId, object reference). + /// + private readonly Dictionary _convertedObjectReferences = new(); + + public RhinoSendBinding( + DocumentModelStore store, + RhinoIdleManager idleManager, + RhinoSettings rhinoSettings, + IBridge parent, + IBasicConnectorBinding basicConnectorBinding, + IScopedFactory speckleConverterToSpeckleFactory, + RhinoContext rhinoContext + ) + { + _store = store; + _idleManager = idleManager; + _rhinoSettings = rhinoSettings; + _basicConnectorBinding = basicConnectorBinding; + _speckleConverterToSpeckleFactory = speckleConverterToSpeckleFactory; + _rhinoContext = rhinoContext; + _toSpeckleConverter = _speckleConverterToSpeckleFactory.ResolveScopedInstance(); + + Parent = parent; + Commands = new SendBindingUICommands(parent); + + RhinoDoc.LayerTableEvent += (_, _) => + { + Commands.RefreshSendFilters(); + }; + + RhinoDoc.AddRhinoObject += (_, e) => + { + // NOTE: This does not work if rhino starts and opens a blank doc; + if (!_store.IsDocumentInit) + { + return; + } + + ChangedObjectIds.Add(e.ObjectId.ToString()); + _idleManager.SubscribeToIdle(RunExpirationChecks); + }; + + RhinoDoc.DeleteRhinoObject += (_, e) => + { + // NOTE: This does not work if rhino starts and opens a blank doc; + if (!_store.IsDocumentInit) + { + return; + } + + ChangedObjectIds.Add(e.ObjectId.ToString()); + _idleManager.SubscribeToIdle(RunExpirationChecks); + }; + + RhinoDoc.ReplaceRhinoObject += (_, e) => + { + // NOTE: This does not work if rhino starts and opens a blank doc; + if (!_store.IsDocumentInit) + { + return; + } + + ChangedObjectIds.Add(e.NewRhinoObject.Id.ToString()); + ChangedObjectIds.Add(e.OldRhinoObject.Id.ToString()); + _idleManager.SubscribeToIdle(RunExpirationChecks); + }; + } + + public List GetSendFilters() + { + return new List + { + new RhinoEverythingFilter(), + new RhinoSelectionFilter { IsDefault = true } + }; + } + + public List GetSendSettings() + { + return new List + { + new() + { + Id = "includeAttributes", + Title = "Include Attributes", + Value = true, + Type = "boolean" + }, + }; + } + + public async void Send(string modelCardId) + { + try + { + // 0 - Init cancellation token source -> Manager also cancel it if exist before + CancellationTokenSource cts = CancellationManager.InitCancellationTokenSource(modelCardId); + + // 1 - Get model + + if (_store.GetModelById(modelCardId) is not SenderModelCard modelCard) + { + throw new InvalidOperationException("No publish model card was found."); + } + + // 2 - Check account exist + // TODO: FETCHING ACCOUNTS BY ID ONLY IS UNSAFE + Account account = + AccountManager.GetAccounts().FirstOrDefault(acc => acc.id == modelCard.AccountId) + ?? throw new SpeckleAccountManagerException(); + + // 3 - Get elements to convert, throw early if nothing is selected + List rhinoObjects = modelCard.SendFilter + .GetObjectIds() + .Select(id => RhinoDoc.ActiveDoc.Objects.FindId(new Guid(id))) + .Where(obj => obj != null) + .ToList(); + + if (rhinoObjects.Count == 0) + { + throw new InvalidOperationException("No objects were found. Please update your send filter!"); + } + + // 4 - Get converter + ISpeckleConverter converter = KitManager + .GetDefaultKit() + .LoadConverter(_rhinoSettings.HostAppInfo.GetVersion(_rhinoSettings.HostAppVersion)); + converter.SetContextDocument(RhinoDoc.ActiveDoc); + // 5 - Convert objects + Base commitObject = ConvertObjects(rhinoObjects, converter, modelCard, cts); + + if (cts.IsCancellationRequested) + { + throw new OperationCanceledException(cts.Token); + } + + // 7 - Serialize and Send objects + _basicConnectorBinding.Commands.SetModelProgress(modelCardId, new ModelCardProgress { Status = "Uploading..." }); + + var transport = new ServerTransport(account, modelCard.ProjectId); + var sendResult = await SendHelper.Send(commitObject, transport, true, null, cts.Token).ConfigureAwait(true); + + // Store the converted references in memory for future send operations, overwriting the existing values for the given application id. + foreach (var kvp in sendResult.convertedReferences) + { + // TODO: Bug in here, we need to encapsulate cache not only by app id, but also by project id, + // TODO: as otherwise we assume incorrectly that an object exists for a given project (e.g, send box to project 1, send same unchanged box to project 2) + _convertedObjectReferences[kvp.Key + modelCard.ProjectId] = kvp.Value; + } + // It's important to reset the model card's list of changed obj ids so as to ensure we accurately keep track of changes between send operations. + // NOTE: ChangedObjectIds is currently JsonIgnored, but could actually be useful for highlighting changes in host app. + //modelCard.ChangedObjectIds = new(); + + _basicConnectorBinding.Commands.SetModelProgress( + modelCardId, + new ModelCardProgress { Status = "Linking version to model..." } + ); + + // 8 - Create the version (commit) + var apiClient = new Client(account); + string versionId = await apiClient + .CommitCreate( + new CommitCreateInput + { + streamId = modelCard.ProjectId, + branchName = modelCard.ModelId, + sourceApplication = "Rhino", + objectId = sendResult.rootObjId + }, + cts.Token + ) + .ConfigureAwait(true); + + Commands.SetModelCreatedVersionId(modelCardId, versionId); + apiClient.Dispose(); + } + catch (OperationCanceledException) + { + return; + } + catch (Exception e) when (!e.IsFatal()) // All exceptions should be handled here if possible, otherwise we enter "crashing the host app" territory. + { + _basicConnectorBinding.Commands.SetModelError(modelCardId, e); + } + } + + public void CancelSend(string modelCardId) => CancellationManager.CancelOperation(modelCardId); + + private Base ConvertObjects( + List rhinoObjects, + ISpeckleConverter converter, + SenderModelCard modelCard, + CancellationTokenSource cts + ) + { + var rootObjectCollection = new Collection { name = RhinoDoc.ActiveDoc.Name ?? "Unnamed document" }; + int count = 0; + + Dictionary layerCollectionCache = new(); + // TODO: Handle blocks. + foreach (RhinoObject rhinoObject in rhinoObjects) + { + if (cts.IsCancellationRequested) + { + throw new OperationCanceledException(cts.Token); + } + + // 1. get object layer + var layer = RhinoDoc.ActiveDoc.Layers[rhinoObject.Attributes.LayerIndex]; + + // 2. get or create a nested collection for it + var collectionHost = GetHostObjectCollection(layerCollectionCache, layer, rootObjectCollection); + var applicationId = rhinoObject.Id.ToString(); + + // 3. get from cache or convert: + // What we actually do here is check if the object has been previously converted AND has not changed. + // If that's the case, we insert in the host collection just its object reference which has been saved from the prior conversion. + /*Base converted; + if ( + !modelCard.ChangedObjectIds.Contains(applicationId) + && _convertedObjectReferences.TryGetValue(applicationId + modelCard.ProjectId, out ObjectReference value) + ) + { + converted = value; + } + else + { + converted = converter.ConvertToSpeckle(rhinoObject); + converted.applicationId = applicationId; + }*/ + + var converted = converter.ConvertToSpeckle(rhinoObject); + converted.applicationId = applicationId; + + // 4. add to host + collectionHost.elements.Add(converted); + _basicConnectorBinding.Commands.SetModelProgress( + modelCard.ModelCardId, + new ModelCardProgress { Status = "Converting", Progress = (double)++count / rhinoObjects.Count } + ); + + // NOTE: useful for testing ui states, pls keep for now so we can easily uncomment + // Thread.Sleep(550); + } + + // 5. profit + return rootObjectCollection; + } + + /// + /// Returns the host collection based on the provided layer. If it's not found, it will be created and hosted within the the rootObjectCollection. + /// + /// + /// + /// + /// + private Collection GetHostObjectCollection( + Dictionary layerCollectionCache, + Layer layer, + Collection rootObjectCollection + ) + { + if (layerCollectionCache.TryGetValue(layer.Index, out Collection value)) + { + return value; + } + + var names = layer.FullPath.Split(new[] { Layer.PathSeparator }, StringSplitOptions.None); + var path = names[0]; + var index = 0; + var previousCollection = rootObjectCollection; + foreach (var layerName in names) + { + var existingLayerIndex = RhinoDoc.ActiveDoc.Layers.FindByFullPath(path, -1); + Collection childCollection = null; + if (layerCollectionCache.ContainsKey(existingLayerIndex)) + { + childCollection = layerCollectionCache[existingLayerIndex]; + } + else + { + childCollection = new Collection(layerName, "layer") + { + applicationId = RhinoDoc.ActiveDoc.Layers[existingLayerIndex].Id.ToString() + }; + previousCollection.elements.Add(childCollection); + layerCollectionCache[existingLayerIndex] = childCollection; + } + + previousCollection = childCollection; + + if (index < names.Length - 1) + { + path += Layer.PathSeparator + names[index + 1]; + } + index++; + } + + layerCollectionCache[layer.Index] = previousCollection; + return previousCollection; + } + + /// + /// Checks if any sender model cards contain any of the changed objects. If so, also updates the changed objects hashset for each model card - this last part is important for on send change detection. + /// + private void RunExpirationChecks() + { + List senders = _store.GetSenders(); + List expiredSenderIds = new(); + + foreach (var sender in senders) + { + bool isExpired = sender.SendFilter.CheckExpiry(ChangedObjectIds.ToArray()); + if (isExpired) + { + expiredSenderIds.Add(sender.ModelCardId); + } + } + + Commands.SetModelsExpired(expiredSenderIds); + ChangedObjectIds = new HashSet(); + } + + public void Dispose() + { + // TODO release managed resources here + IsDisposed = true; + } + + public bool IsDisposed { get; private set; } +} diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/AutofacRhinoModule.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/AutofacRhinoModule.cs new file mode 100644 index 0000000000..8936c7994e --- /dev/null +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/AutofacRhinoModule.cs @@ -0,0 +1,86 @@ +using System; +using System.Collections.Generic; +using Autofac; +using Microsoft.Extensions.Logging; +using Rhino.Commands; +using Rhino.PlugIns; +using Serilog; +using Speckle.Autofac.DependencyInjection; +using Speckle.Connectors.DUI.Bindings; +using Speckle.Connectors.DUI.Bridge; +using Speckle.Connectors.DUI.Models; +using Speckle.Connectors.DUI.Utils; +using Speckle.Connectors.Rhino7.Bindings; +using Speckle.Connectors.Rhino7.HostApp; +using Speckle.Connectors.Rhino7.Interfaces; +using Speckle.Connectors.Rhino7.Plugin; +using Speckle.Converters.Common; +using Speckle.Newtonsoft.Json; +using Speckle.Newtonsoft.Json.Serialization; + +namespace Speckle.Connectors.Rhino7.DependencyInjection; + +public class AutofacRhinoModule : Module +{ + protected override void Load(ContainerBuilder builder) + { + RegisterLoggerFactory(builder); + + // Register instances initialised by Rhino + builder.RegisterInstance(SpeckleConnectorsRhino7Plugin.Instance); + builder.RegisterInstance(SpeckleConnectorsRhino7Command.Instance); + + // Register DUI3 related stuff + builder.RegisterInstance(GetJsonSerializerSettings()).SingleInstance(); + builder.RegisterType().SingleInstance(); + builder.RegisterType().As().InstancePerDependency(); //TODO: Verify why we need one bridge instance per dependency. + + // Register other connector specific types + builder.RegisterType().As().SingleInstance(); + builder.RegisterType().As().SingleInstance(); + builder.RegisterType().SingleInstance(); + builder.RegisterType().InstancePerLifetimeScope(); + + // Register bindings + builder.RegisterType().As().SingleInstance(); + builder.RegisterType().As().As().SingleInstance(); + builder.RegisterType().As().SingleInstance(); + builder.RegisterType().As().SingleInstance(); + + // Register converter factory + builder + .RegisterType>() + .As>() + .InstancePerLifetimeScope(); + } + + private static JsonSerializerSettings GetJsonSerializerSettings() + { + // Register WebView2 panel stuff + JsonSerializerSettings settings = + new() + { + Error = (_, args) => + { + Console.WriteLine("*** JSON ERROR: " + args.ErrorContext); + }, + ContractResolver = new CamelCasePropertyNamesContractResolver(), + NullValueHandling = NullValueHandling.Ignore, + ReferenceLoopHandling = ReferenceLoopHandling.Ignore, + DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate, + Converters = { new DiscriminatedObjectConverter(), new AbstractConverter() } + }; + return settings; + } + + private static void RegisterLoggerFactory(ContainerBuilder builder) + { + var serilogLogger = new LoggerConfiguration().MinimumLevel + .Debug() + .WriteTo.File("log.txt", rollingInterval: RollingInterval.Day) + .CreateLogger(); + + ILoggerFactory loggerFactory = new LoggerFactory().AddSerilog(serilogLogger); + builder.RegisterInstance(loggerFactory).As().SingleInstance(); + } +} diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/RhinoPlugin.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/RhinoPlugin.cs new file mode 100644 index 0000000000..7c5a9c63cb --- /dev/null +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/RhinoPlugin.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using Rhino; +using Speckle.Connectors.DUI.Bindings; +using Speckle.Connectors.Rhino7.HostApp; +using Speckle.Connectors.Rhino7.Interfaces; +using Speckle.Connectors.Rhino7.Plugin; + +namespace Speckle.Connectors.Rhino7.DependencyInjection; + +public class RhinoPlugin : IRhinoPlugin +{ + private readonly RhinoIdleManager _idleManager; + private readonly SpeckleRhinoPanel _panel; + private readonly RhinoSettings _settings; + + public RhinoPlugin(SpeckleRhinoPanel panel, RhinoSettings settings, RhinoIdleManager idleManager) + { + _panel = panel; + _settings = settings; + _idleManager = idleManager; + } + + public void Initialise() + { + _idleManager.SubscribeToIdle(() => RhinoApp.RunScript(SpeckleConnectorsRhino7Command.Instance.EnglishName, false)); + } + + public void Shutdown() { } +} diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/EmbeddedResources/plugin-utility.ico b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/EmbeddedResources/plugin-utility.ico new file mode 100644 index 0000000000000000000000000000000000000000..022d1f78842c15850a45c0405c872e51c1070015 GIT binary patch literal 33583 zcmbrlWmr_-8#cOUVCWPCq(e$tkxnU<1_h)`1nH87p+Op?TUw>0duUV|q#Nn(A!gmy~O&#<8LCpZzzjOG|1(i~Gc`OgsfD$v(b4h3oa znW}ts`Ws(!zC4_9apn0XpBs-6Rkrk3Y`;`LeX7|&3O*K3fBY;d3nh8A;5zaa6y9x9 zRSNb4Xo=XJoIop1)cl5kNEQ|WB|uaH>V`nOZD9Y`w^jT|po;%e9&QJ(IFT1C+9lxw z;o9P>U>FW1pyn5X53r!;x*+8RqR~@KDm4Q9T@a`?!~feCJRd>@SfoQn-eR)6UDj_gQjI-oO2vgS{$g*HZR_uf792;>y{ZA^D*D%~y*AUn1yw+ncXfSp6TG zX;Z6=SkIQ$)*s|b<7|~BE(NdGfGjWFMICN?UE9J|R`s%mRpGw3&l9g{Q;$?xYlsK- zk9>!RbNOf+;B$ZI8YV==FH_qa5I*FZdSCDx)b}&;_8}jAl%L$q2;Lx8UFn{NHK;Q zaw8&2`})%-Awh>h?ZD(9^q6X$5Se%PlaU(&Uqb(X+}JG#$SEm<)k-jueqll&5E5!? zJWWl_^QP@>>l@*c!~1!5Yk@a!-oTavP=w(`bV1ta*_&LqR>q5z<5N?yv4T6-ZU26J z{`m3ZQJP_Qm_d!zP@c_1@j1Pt{akHeT3VV+E}If2CGft?73_2ecZP3fIyM?&S5DX3NK7|^$dCQLENbX2pQGKK21%7LNhX9K=( zr4qCzA$asOq@S8R3?KS)@-;}NJ76`G(sa7Q$W$m3!^`hmh|c%We7W#0Lg58qy)UL9 z!1Wu}{i@%Bp}BQdL)7r?g1Ft<)jxrKam@S{eFWR{4UT!lCByeC{1^(D_V}M|4jr#W z@r@7o`(d}>5=+4u4Lug!NoZ+lx4X-aBes(V?3*?_dt8sBS|nQDvhwWF9Q74x6OOK;S;RK7L@%7uI4KQ>YW}NGAmgq5BCP9h?n&)kMWN1q)>Vuf>O_f)*XIPSiqp4Hw~2#DXxi8XU*Ia~pVh17 zfbd{!Vy%QyJWq!>X{5*nj)+zxz@Z$212oTEEqXA}OuLMnUpT8i9q8w%JPtzJ*_#$1 zuf=z-yrBz;xb^e5x3lA3_%vV6?>0d4uA8!(7pRC!egGs7_`rB&y}iZmZvXJDF51sq zi`7V*njQ}cFNf%q>t7@2CfV=TR)+^DP6(9N`Q3iXH4aByo=h8IC$XysRaNmb7?=HQ zIni0yoj3HR069(DAFBgBM!4tD%l%mlv`PwOf)y}`@qSVZU@cV{XzJ*wLB6)OMlTH1k85!- zzX&`ERg4t{s;dR$AAe=ym7-r;UuWbLNLXMWWzg_!Od%rHcclKFaKnf--Y*paYI^ib z;H%Q{;Iom@8%R69`|cZWKbl<)CbTDOz5)2*7XvJDGWz<|XCPCPM=?_q{26dj+N-$F z(S=u+29}ueiMQKnRCDi3ALqRAmzAPx;p5>cKsZJZMulUsFn2Kt2t?kcQOllL4dvU< z*Sl3nI}qdI)_LO%f*H?df`QTge}+z;Cv8_t1<&XOJO}WGh3>V#-6Sk{FA8QbRL)l< za_g_I$%U7%$?*d{2y{b~hcs}eQN;So7fjs3zx^o;F_0K;K52&2v$KJ9^Cx)QAXD2X znE08`ZSfA~>R57KQi@S9mq;bMy)(#h`qdPM$O;z-VG&ubQ<;rX$dke?==wo9#|2(YV* zE2B6U4PK;3UI}9lWr!yBpyc-78p?wl(|V>)ly_u+N9PL_+4}g3Bzm0CiCraQ(bJj^}hi)MMgGD3eDposFG6oXV2--{wCp zN+~|R+}g=dK@9cSZ=QtKzS~F(+hwUHNlAJ;znTGJf{~_pH-^`*m3MqW(V46ApbcSEx(RB?k2Wr`Wc2sCGX1;f!4EOaW|pN z$`wix+bQmd$jIVODRSV3ft0+~AgWg-X3`E3Y&EYbz`m z(fnVQ#alsVgohm{|6)yY@?v#q1i6^|Zs8qYVamN8?kE7k*rhff?R5)Cz`yP=!qC0` zIQH`LUj<`6WRR_`F>MZB&QRvHz5=c|x$xe9Gp{uS?O3}=9lM}`u+CsCSx-+9#QaT@ z%sNCQEY1jvoQ^=q{LU2f1czUWlwd|PYXC!KO_eca2UJ) zeH(Zu`BoeqqkA1eut$D+i+wafovVHm#j1H0{c3_QDIa{zU%${dx6WtEce|r!InK{F za~l}Z1(8Ur6Hf1VWvwcOf^KgV6lxXtxViIkFh8fm^~M@C3;97xBtRz@Y(zn}$%!e( zo0W@jHwVt6k@nZM3CpBbAS^{>Txg&26()1m!g~GjF-`=|^tg|po2X_L zO}QSqe0lS+#3qI59n-UC_!aRwQo)VOA}&tdAv9S_)8=H4o@En+822`vZS6dNQ7z-R zl3}a(;`Z`@=_TF2zoTuDAY{++nFglQt{`4T1Fx(fB?yfn)*1kbi%IRt=gD$TX4wr* z1y3~n1t|fA&bwLGr06B3pWF08)Ku< zOUWV;tyqs`b|40pOcmQqiO%w(g)Aoj%g7v92MXaBXY%AT@Cm!3{bu*$-3}(!|E4wF zi!+AO4wp-Ji5d3aNPM@>1DREkJ_DQw1Om^K$&wPSQy3SgV{}(uF=jzzj`2o=Mf`3A zjc81#2GeUNQ~j1?A7TO~!5s2twv znXf*IjeOBaPPIfWY@@<*eHgu@tt-Qgw=GF4;u-Hv&!xl7ZY<9*V$+3=smxz^yA`x3 zxb;R?*5?S>6}4;Ws9;}a4F5QZk_1Id#7foOM}xXD~stQxOv!eW7PP{14Hr=^|$Y*^!56CgsK5fAMew8BZLgxvI!w+IFvijm5Y zrb+tL_j_SpDEucV=A=Ni2Og9kKx-o6R=cb58I2zu^1#s7tqegn^}$$#wY`u9nl?Rh zB04E~{r4=~{+6T!G(rm_q8K?48E&vh0?xGVvAiG2y&-AYLuC2m=xq1aDHUr@2M9w! z!Iq7Ze0*`m@U`V_$(1vB<4nro94tkVH}K?(pyqF%^ZS1A5@Sn{VTV^nVxCF?C-5Y&h~KeKDj z9!7!a!zHtx`^gR(82%N8_WSW)FD6RV!y}GyY>Z?>Au?3V^8Dpq=i6h(Q9n%+C%19~ zjJMcGoY4@(n+eE)xfv0>F%Ke2+35?FI7Z{P2u94qZx2Kr_hzaw$_ZD>xT;V`9c9iH z#%*}bZij15vwj@hyXvR$z!VuQR7o<1fKkr@5rDd7perxsx(7Die1J|V0ZAlowU{z*-d^p_Y70>uPn+EC z*mafYNa5Pg*VX7e*2$}Foa^@lK0mVhm?P%?d%bD>1c6RZZeVSrdk=B~kpvor3Rv{b zaGm4{uk4dD&fHjV!`=bM`q^Uc)SJWUa<{7-n6G&R*KB|D2jvW*q2T^SE4ylj{4~oC zeDq^d@B(Tg>MmV}U{Gq80?eI#wF|&HO4_$%a6d%=Du_eygQH0JZ36sOQ>HRlZ!lO-=D95DdmV z^~Cdh?7ds$DdYTa`M*Ewp~NRpbmh{WCmY$}9J=QD zq{5utI69=%>do9adhNcVJV(a==gBN#;|3y~ibUsNr!PPY?og(1Fh&3aRMd4-CReI# zDlb>tCGID9WjPBZVdeO~`-E1f!tl|y^3g-I_jW;GxPy#6MGXtAV=JG|!HNV7Y5~zy zvi(w@(u4-P@w(gbq2sPt{GqdCBAHHqzr77?zcc+6xu7(^Wi|T=b6Bp=dW;DI2V7Nc$?4F+PHZ&%n_k|dKJtFF8RGyYo(qC z$SWyz?zdP?aCSAiR9DeME5R$T2)<+qp05*2!)kXXBy%Wr1pCe^5B_HmLQb(j{r1x7 zR`uiSy6M<31IMQ1*v$E7=Tx@{<2I0oDA*ql82)y56oA54PW3kK#B~K7Q|Ae5XWlQI zPzU(@S$Sn(OxtZyHcR#jZV|;K+`nFwCoA=1u*GX)&&?{&H-V_nzk{+s*L+w;O--mU zTOFg#82j0WMOMyn=KcwFY1LG_??d-qh{Xzcw}GVY;9Q=5e{P*taxHjAzQ47?!5x=- zSp^FEJ5G&ZeXLh%IW_o5uw_^~nO;dkX5#^khCcAG9|htyZj{+$#gRb5$(%O#-^ER1 zw*gs{(6@=UT=!X{69+c7UShVn7`1vlrmb>o8$>`ts->m?iV89R*I_$Nu2=2byLPxvmDL4!G_0xq^B_3SGbJyBR}Wo*zaJQBm{KPoBKq1FSKiPF z>7UO3P_>=V>t+ds{P2M?kA8dmT_zy;zD84Sqky(-N#e~*!(UWi+0Kc8j6FXwJ!b1^ zmY~D|!6IL!@);FJN;Qf^&A_WSQoMnwk)?(sbXF;bIFNz(&}uOMmqM*Z^K+E7DF1m z5eYAbLN^EY*@_4tBK*=4lQH*vmCvy8r7pubCN^2YbRx~=b@#SptX@R0$J#oHJitX& z9&o}6?%=HnfZVUS38PM_a6t4n|W@rgadarh5&OLEpKi!m!0#iQR1q^kw%BuM(9$ z-Y9$&l+`fKz)y`uF>L>SmM%@)KPUX-9p=G&-4{E`60F;WX^&?%r9XcLr949&G%WA; zF}#jmdWWfBYt8fu?1HXt|FQ0oFjtr~p43gRv>df-?~BVEtrw*lpX!J7F#Pw751_dL z2r|XE+#Ppm!3ZH;9_Z*X+xbzfeSw+Nvf}Yn{}#+{ymN!>Nah`rK_BB+Lj1tgY2K6` z%pTh-PJs_V!DYY^ipC##{b4l3dV#t_=exU&UvC&6DJYXajfZ09WQ@r32yw;gPW&C* zjzS}q9o1L=O-u@8O-^_mTZ;Ix4ehm`428YW+B-SNpZpkX)*CFz`1Az^gKq*>2O=Av zA}Z1iTPp19en*=0auSYb?z5G5z$nMn5emN@aT&nd7k8ykds71eRrA|?PpMdn$Xfkw zXG?(-hq~Tk&}*^c`S)}aw+f0M_rs_~XD#6k-d=WA7@?|Zq!n*i5&oGc>wb+wwCK#ibM1Rg1#QJyNwlF6Zr`lt_*`kK z3+VDtY_Y=e?`vU7@bUDrk}15dflPSzpZhY~FJU%E?-b$vcaa39ytB@GD-ocPaU@YO%9yv@VGYXepZXy%xq<;1N=)oOX zq)bb_{Q*zK0uD556~7Mhx4yq*Br8z0(lH1FoA}8o-RdY4uddEp^?Tei=>>whErYrp ztfJG^cxUua_;zN`+5K=PiRj+92=78g~72C6BLQgXG)eQdsAc$K`#F zwO-&x)e_;(ilfRI1;(pWk9b!z;WKA<>uCaGBUEV{>(%>llA!goqt;vAG*xs~Bg{{5 zr}gll01bkiC?G1}*RNmy%oUDWRnF0!l>p6KM9co$+R}6c)-lt3-3}MLD*q<^)2p@C zOa=$vCp0yDSaCT6EJ#V`*#XV88^`0>zPs>qdjby?yDjUBnAoZ1o0%zA#(;n;1BxA@ zFQZojYV!)Mpv!jW<)!SEorlCTC@WHEYpbuP-vnE;oiMM)6M9wHJAe54(P%!#!B)!! z&VXMO#gIMgA1eKTCWk;(%$_>D7%Uc5$-dQ>S;o=$W%N=mm{Pa^yg|r7Qv0>&6^JvYhyU%xrW;cJ!x$ z@;g$P9jvj@ld?ONhA`e1fp+g7PSO81HpbtNYD9~DlDaA3qEmy|-1*m&Bh~r$0?SM;Qc(y@dSPG=cDBgeV&YWLEDHvMK4p zcrmB8P@s8gXPIihQsj@PD&jHiD0f4$=N`M{cXo!#35bCB(5ombSz98gw9dLV~OPvY(S}N&t z@wG22IT<(L4k`Xazm0l);#pb+ZiO7Ym(m1IOa2d?ZQRv>s$MkRCkarjWyXbsY_e>x zb57TV+F}V89JY;ZJ6&lKL}NvDBN}`#DI#BHNtl?Ef$$BbstI48&crfB-1V8fyTYke zcaTF-L<>KAMpoZ`!nUKHTfo|?C&MHoM~>&ac3W#dPr;^|g`+v9d1=Zxgo{HQj=9E( zIeP}QQnh1~!c1;W0+6^gCO&lZ#&DAJ-R#%4*mzr7`ucbsWX>>ej5Ym`9M6+p%GDGD zhm)P#t^cjtH+{V_<|E-y%K`-cwx~8P82e}!Pci9l=~&){IZLV+wk2;SdZjvZ%2cgNjvlN^5ONqpfe zq>N}HHgspAc+5`5Rv0Fx%>U#`#wXl`NA1eI(2291ot@)ti#S<9=PTVxV@S4`M@l4( zo&pe#*D-S~I*W2HhB5N?c%KakKg;F2kI&D*Ra@c9t2e(~(_Q|aV9(aBXXnK@$hALy zD8c`otI#c?MA1R;v!P!Cr75`r$|e=P{3Y6(JmzhsjTlC+}JDpioj(1L0-J&*3LlrgD0=YSGrcGZ5m)SjY~3a zRP$c&&y3*pzSvOBf{KI)s1A){QgF~?<`pSi9Kz-wtV`N;aPB=5QSm&*zEc z_lJSSd?;Mo>GDt${}Wnng)4?LJiQjsec+tJ2dE{frET4F2SVsa8xJ1eP#GPvo_XsV zy!6>~aIycZzyiKJ@FepBS>Jh&MFftq;c)=HMOYjIcXUrj{C|In&MzW)&@*-9I9`a0 z=(GS6;d6jzUX0{Q6N}Y4I#Po2UsqK%C$M+-Z$-1QNZbzAIPJro^^e!Dw{n6_PrYxY zjO7`54kT!q`+b)Y#Gd8S5z2|IY-~@n8SXXv7YuDekQLuWHKVvg!h}PuvaJF?*Sf5l zQR`JRJ~S_oD=P08m?@)*(Dx}2kz%B3`9*>07Kk zD6Pso?zYxu0*jsn;h>Tx8{GAkj#%Ot$dW#i+>T&|rbCrexx)qqUd}a({SNuQy&g{z zGoQy8##(Q;2$n{dQnhxoV4>Dp5c4aPNi)&cy*52e>%`IgfR&0_4T1 ze)IvfQ$4ivI+H8*6PTH9J+s3h>SRd7JIo$?=w19+t6Pw2NDbjX{}MWYKRQnqXy^*` zj%?xyYyyorRpRI}9Lo`MiM9+FO`d*s^ zc;ysF(-YS>3mXPVqW4NgW}mJ$I=%F4q?p_$jEJVXUi-thvK}X$zkKUjxZxPq?Pnal zd@U7+1FJunUkRm@NVV#g2tsdxJw>tI=YjHvfS@lqK=I}qBlS6cjJ29Uu4b?Sj7PY( zfu@$_`v~TtmjB`=K!tf_5<%G52R=SJeZ99=9Y4@puvEet4$*z#8R6zaXmzw2-K1Hd z*yKk?M6=|%9^BM^5KSAa3IR;h=?d`=~c8PbF`wO9PpgOpzg>L7i&DC{`wkK|(ah>FR(|U!;xD>-G0Ss}-||GR z7!5^tyqMIOh@gI(Xu<_n5GS>(-ARze69EyCjC?E=u6VuwOr5O2#@u!%*z&6P1tVWV zyFbp!gUv-(V#2$oLENfTjx#i+ij+>xnyBnRY@X1D%wPq}{>Saqy#`KC@l01D4AN3h z#}ymG`+jKy_&!((4BKA=E`o^cE#Aj0ZIf?I|7k=h7Px(ZSep+$w-6igQdnnQ$GmDu0AGm8eUh$+Ydo?%&$+SoSI|ewTkZ8H^$HP|r>c zkl;+JiC6NW&(&fLQ=P}R){{RAf4r~)4(IV3mIa1v6DJ}_Sys?{e`h;c_a#?3DKL1# zAil~AKZxr{znl(XjrT_pXkfp?Flbm9CG8`ywXyxB`jtsKUC@MmeL6}Jr{^8ioV2Rp zuKud)x9mo;;wg*nSc-{m4&khg$%}WZHpS~lQ$-JbQOk5{-wAKA`Y@bG)$d{#0*!&; z1p`!<7_|kg-`r{TY{;N~+#Q2b0-jel!YAOQNLsa+nq-k7>dJQKI&doy>9OoLZP6-6 zbgyn(OlVyd_E(}Qt#x9e$Rd*$ALII*mIvuSbx%b_FK|q+(e%hlX!6Iq5fXSi?^fDs zkc8$J_5fnRe=nwV|Gii$a?DRtBQRIrTSQLb^S>XTd1BH)C;kZ*1i_a$4CcAL^SXk; z0x?)wKtU%K5A%Hn&SDa&1*n_vTs@JwzIV9XCe>Yg&IO})=M(Bu|I3FD!N>b^s#T{u zx@nia5drI$4KJ)QvHrXn{h^8ZgAsvTVNC8hW;I{w#plN}hRRYij7F`4|25%d_U?`Hu=PkD>p%UCj$(idteEA2<;%I z4^6NrnaDtL%M0%kSF45t#@+-sJn75WV)aq3c<`p!3w(3N^kWObNPTbHKSu+&P7z?D zqm6$%d0LLDbDWK*82^lB*ImE!9p6nvt# zvQJv6x$+&yG_ne{e?$Dk|Hh_xHU`}qb0vQK3k@C64K2FkHE2&Qi+<||bXkbWn%lZP zD(~eiRy_ny6WOrF?22EUU8r%w65p6KnaLyxvgcL3#P))CXK0&NQ!$!sZEDV2wcERhSv}AW`*P^-r}e9^K71`;Hd_y4 zU)}tLeAs1ahHe}>7PJXm3}g;TWmdTNI+rc%`J4tYP*+w2_{Xmtt zKC-))>wUaQVL@&visp$6BVzJXM>GQq;(M+k&U!zQ?(v?>NGLv~DY`Yt_^P`#xJ0)y z2;KcP#|HKq*mt$Pvoenmz292wG;r(~a`Rnm@d!uvdX2&5-ri@<=T88~);f$sA8Xe2 zr6(_~-7%~SlFCU@Ri=6u1E$tldBOZtD`ao}**nqTx}i9my!`wGu5u6?MS-B3!i`uEKP`sjyrs>H0f%zi0kgCa9Uj z>*M3#npa$uJ$GWP?`o_FThGUpRc_aA0>A4>LP$vy)G9iBNMT+Gs_prjEgvz9__`dX zJ~peNjG_Ti7c}WkO$wMOdn@#~htF)XlnF4q9yQ`A64rkxY3igD|BwR`7{A%&J!Gc1Wq zXJ(qniIV)y>}S7})YQ)5Y!g_xl*)2%a$tkQ;t?W#TJ#=W2_f=wk-Sw=(_Lq|r_^7rpn>!?7=q2pKxAo<4ru^A|R~ zk&SN78uteMDC(=8ud+O0xh(4%?u+a8P40mUxRMwkq>(d!e7VyOqY%h%gC0)zJ$-M! z1EwA1TNgDc=UofPo_cL24v}c&Vx{ggJ&^{!G?l4=wj~Pqv(Nh8&LrxMlvmdWhwW`6 zj?9XVVHPE4`9BuMwi?p7B2PNx76Wt~GDNVJ=1wKtQMP19t!G5s2KCWi0V-t1@KJDc zd_-L><>&%-(yx~ta)x+zdo+%tFa|CvlbJRjVM3uN==Rt5WjY|e%N{Y$ljMf9%eUB} zn)lf?zufs&$hqotwX^p5&&wm#!|*!-H6w89xyk$+<5Md36I#h+b$lmy*b<5$*xEFmGn7<*18B0qf0ABTiui9TwIq;6vQ z)xY@==NT#l$Zf-ddJ4kC)K_}aeFwP6wc^J9*2!EpjpYA0#yo2>d%{cQ*mYWy)ABEh5qhKT8DoAw{~yFedFp~2y?-2(y>d96YAzqZqg zS(qg1@$Ih*Smaill)~k-d>adj8n)n>v*w^RcceVn`Ouuy@E3QDzjOVZ=e6#ojI)qW zM?Ei92hazqir7YXPinE`hWEvhB`L`VBfBk# zDcs{eTlMKVsSb9hePnT_L(qDEobI1n3y2x_LFlaiUqZAEX{rEKh0{G{XTA~eewi1U zoIRIv+o4&)ED!sL)QiLT(pOlVQL3>6?Z#h#$KTGmhB09F?>DgEx7I|9ytQ|VMj*>9 z?|$1wsX&2(a9ICQo7Ub}L_4|{RGo75jXow8A+R^8nk*hsa!N`EYRSAp=~Ia|{Ns~n5Eafd73$wt64&*PnM z=$?SN&vzCH+mTlWB#%hxw~xO4Hr-f8cLH;c)4{Tk=#W4DOY-^7L-fu+g#zYEey@7> zp25y0pQ-A)SL zGX=lFE6S46kDpfa$v-{^xB9lV2#2y$>IW-|wH0i5(C>K+pSseKI%VTKu@;c4ud?H}_ zJ+54u%WRB}srVN^OnJK9UIOiCwf2dT-N!Z>>POTIWKn^dqG?^U5& zrc#dEeUKJ|y%KU=nQ|&;0)jgwUh5n)RUf&ny9E=aTI=3Z(zKU~GsfQ0$ji!V-tb9< z*WDs-*poJI@Oe7MG;rRPGz6xfquzP0Uwkl~vlqs?X(=P+*9Gw1KCgqR{wj6%t4JBX zZxp)svAYLQBNG(Ru-F7uM83lzQiV2BtlRWRGa2Jo{%9szGw<3T^FR3^mA~N;c}GJF zdg0u}mo2-?iH>OavrY91!Zunhq(6sSv9XNkC#t2~P~4uM9vWb=lx*HVjTAmWbhhfm z@cqQ%Rpkr?*|s@-^_bc5T9QTnyCjZ;1m$qVzNUY|s<>m)CPG{ySUH{5Y4-=oVuQ{F zXX82HmxuHgVpEzd*j=f)b`?n$2*Udfn6)I}t{Pp4N_!Eh!p%VJ@Sgg{zz7*~d8P0! zWvp6sdv6?w@!Iyj~P#1LYICa_&EQPPUoKA@=*B9R0^U<$cvB6#B>NQ z5yY8U#4IRf=gznuR<6kS@M<&%=!gce2MpYn#ALMGf5>mXt&_Q@^9& z&|$<_XpGi5RS#(hBD`jxdZ$x!gpbC>x;Xa=PhO-CwRa_+r`=y4h?EjBzK1v};P^}v zf`a~$!tYm4ji}!8%L}(q2%5z(N=RTD>q$|Fv9o_>zGd@?;v>aq>BI z&F*6T$WazJ<@JXovu>pkc?=tAn_d6B4n)$6M4K{e&(|AEK1Uy{@g#>%*(Y|APhz^b z%Lj>nJ$C=H zK?nWHUB6SwX_UBHv_<*0>CN+!O_({0Uf&=-`jCY)7cdh(-B*j9lzt%?dBRQz9WAwt zh#5;v36OBJOJ#J~Qym|a(ySV39>N)Zc4sJok-3T=DosQ;!nBy=;`1jCfn2CnPrpH= z?KEusW#5)8IlLE;B?O2uAsY)@s(C=4i)SWa#K^0IpP7@1Q=ZX3M`*5e38N??(Ngu=FquP_Ue4BOanO3U@f{wI2c!#13p0)|ZHYB47U0jRm zTEH7BBv}k#*!TwX1Fy(W#9-Ki0nrW&ZmT0NBrb0CaX_UcuBIkwVEZAh^u4RU0qz8l z@dK6-FB_>dgd)Q{gjGUA8l5z4d0Y@iPj91R{X51!uB?^8T+T2sS2><^+I0}<*DUEz zPJq2AKLzD8|Jge+k3y}TMdc|qe5+LN$ECdw@1z1q?%bH%eTJMF;0PZC-JB zlY?*hM&aF&^UFnY7M{1P=69qz>(jGFeo9~(UWlHKjmb8$6r$|QA8V|N@=mT zkwva%J)<{9vnA*b^1N?wv%5|+)yNZKD5%VSHReK_N#rFD-oM#sBgZeZo3xm2)J!Cm zH|w>>CGjjyIgN-dK7HHURn*NXmxkvf%CqBkAw-%chS{$d@285kCefV_Zy+7f9k|Z7 z*sxNw?A5w0hp+RG%Y~l%mPoZ5FVKAukiU(cL?Q68%j5e+v!OrIFJ#aywdW^W`{S{ z!eiT|no(K>sa$}05Qfsz{Hn%rdN|k6&7&uu+bYFEI@@)p`GR?~;djUz^r@eK<8FBH z3!1SM)YL0K(}PnQyRya?%SK|8TM@|2LOI_=Gs&ch9!3Kq=%3@fI_3BrBQX2Ozd62| z_BA|mqwBDp8OKa9qRqi9+U@VdWmxDVai6987!m>f@vU6HTT{I{ `oL`4X z`(pvlfA|RDkz2P>Ekv=@fyrWI`{JIn?OBw~$ZJYz3m1fVts{iy)!s-6d`kV;=U}=r zw_&jn(6|#s@~>Sk3;R5lI2o<`sd%(>k*bJVjKOIfMm~GJfSTAkU3qO4dGLg6TKZPE z)Y1tdz+X!E8{;_@hTn$hU(6H%K2FY)dKyXq6)l}ZjT*o0@9e&cjwd=AOIZxwJ7U8h zbHGEy8Is=Lmq5A0HUNPfD! zUhPSzy)EJyStfoMs`O|W2EIwGQF#UyB@DuPa=#R}3E8Um2ZD{Oa}M=yz2Dy;6h8G#%B`8$XgI3zR6!Ssv2d{km&G6lq+>eXoxX%ypDm8IC@ELz zaXVo6^BP0P#OkIU{yBU=MKS}X}98NJ$*ktvteAlDA&<_@Iu99nPn^ZDijKcA!sFLh-U+KMY*$o9VHa*sMM2|VO#36CZ40SG zWFjt4@$sUb*er}#aAKs5SuiY@1iaxBFvwNhc>Ei3i*ny$e%?1U>KX^cGfrR*SY>t(_ zGVnw#67s`$Eq{F~__aU2hHr5rrs)9_s6V2{cRD{&C~IdHAlZUMETW=xKd)$c=Re>7 z@FaANtHq|8xKfXM&%L*wfe5X9Col()KgMbMtAx*du|u_m_jse9Cg0+xo2J4^d@ehm z3<*vuxv7|h^(O|*FEL1ihScOoE2GXo4&s!|1IGs?doD&!ym<>-T!u*=Ezv!_tl`lf zTzx|ZA_dIvEPk;cSuJ+F%^a@!aFu!avIBa>B+c^N>I0M0qHgIqmp01eG0AXuaLMrI z3x6}wA^1dcR@mn|MDz#CM@3v>!}U1mE+9s5ey@ z2!vyfaAT6b?vHp;pSs#T`)uf2pzRkhZOPb>6x?GBT#I*9fz`5p)i)tGG!ln5Z^(wc zwM~5Y4>LLrX=Az2XpKq0h=Q!ZE9bq5AhN1a%B{%(lLa}0>e%Qr=Ko}g7ZQf~hv@p3 z7igSfiHXDot1?x<+a{g=8Le0fC|U6ML*UQ-+)lmpoeSSV(_ujwYf6rrlB(iL@o*L; zLVTG$e%0tp2^&PF=lsMhJbNt6#`L^unBUoscze2~uAfQzR|GUkMg$!8^{-#HBt`)T zYubXzFYcf}J5vPGemn0_prfk;Nzb9U&g^HuW0R>{&$ zg_158^oWYmm-%@%>_Icdd}5zIs2V#G_0yo4My9ds0G+bQ;5NEMAsb9m(DHPI42{Io>isKbXS#sO8S{xTB@^p@KgAwSNs8+B-UT3dTH^UI8pEUo46kY^-8K| z4;AO;^NB)|6~f=e**&pANLQ5E4y{&cS%C8*4}HJu7a?J1W2H>3V;nC1?R^Z-`JzJa zZ0k3cz7Om@7nBkCFekG;TORs>PloRyhOJS6QUbB_*U>TUcN%5Sf_gOwie{H5%ozxL z3%SHT*{T|SAnK?5r~ElEs>VcE)aw~PdcVJV&L^P^DH=0wi7#F55XGSPwgT zSgJ-1;@K#If}S5&?gTRmFljB}lO%@hvtTMJWlOsR2=Sy|qEv6}N(T^hdUzhk=<#?p z(Bo|pIIg2sWBSLDEfV!QCgZT$bH^3Cce=@4?pDSa-o9>+SsZok3m z7Z5dTV?El;^Kzd2=4uDLC@xI)sI8S!L%%pU=|jz{jt=0-ssH;YM+#D#5fxNgpxBeS zr7SVoAzYa^sp_)jr;T&0Y=BMI{7>xb$K~zTRHMw7)FIP)+f}A^TI^{O?WyI14J^kc z9uL4Oa853+;Li)WFmv;adJ`J~*>COVGu0W*#k6W~%U%(ivR*fCP&e0&z|JYsQD zLb=-PhOeTq+EXL$>5wyNl_6u(HlKTZc;~SvOYCD(d*-{bSGc{5nO*JN@6{ITiPzbM zvsuqIH$OV;u6(juOO741Qb%fZcHg+ILe++>)VJ%3l47-Q^(YCmIm=x$)_H8z~pA_aE3_s+`DsxFb)qti<=4`{I>-_H$mYS$DUp z?x=xY-b+Q-St;2uX}3l-f3HY&TEhT&tBztR<6!U*iby9FaLtnkmJTt#)Hd zz+YjDhp;`O_j_XB_3ItrZL8=UeyuY^@)nk9 zzv;qBg)#PS(a+r<2Fp*e7+N?X-EmaP_Dto9dA}VH>gzo5U@mLX6SHg`3yq?%9(6bK zW(L;E3yn}OO>r(Yd^AvR@Nu7ATNbG+lqeKO>v0_IU#77RSdG^nK0o%J?Um5z*!60@ zyAtb_J@qxE<5$S^7vj(M&=)%pIrNIZ!PYw`9JKs%j%vP z{4uv)JL0mfqgRm6ur2!(!?&6VDX|vL5H^a^@i_jrjl_u6S*k~Lp2+U$D7sgK{L8=J zn!Rz671x%VEecsPyKuqr9LLxt?YSK5IZ+~O??kM$Q@TCzWYu8yAtx3~SIjxye?WqF zO22&v*B@WjeYvIQ661-stnvEBug0?~l=2pc$X;K0_|RL|*?V|47UqRY;aLfWei5wx zi*@&}RXeX;>D4P{?y40v54T42tC)QtxL=y^wEoIF&40fa?;o0#+Fx1BI;Zzfb4FOj z)W!`JXUVCq>Jm|&-hI-jA+vO}62b%LIOg^d3L4^FyPIe8N88(XGph#c9&%&J^z}d7 z-rHpE4$)~r`SVge`pxQaeevB4-NH+uSqYQ;wzK+IU+EF9YR==2Jz6kDN+|5Wal6#& z(Hnl6)1cZx8ESaZ!p8*Hs(qPLwB3sEmK7du)cZ0xeV z3+IF)YtCFw(owa+wE+g)rxtV0FEI)!xO2;_f9)pLVl5vTpF+uj39$|)Rf#vImPKEz zsqr&)_DKIZX_Nc((6T*$I-RSF5;2&Uz<(2OsD00OQ&B-x@iekgj@1yd4M=!V2-#?) z%FLVW1Y#wnY{*h``-yDI@;#T=gFUWjoy~7PzYii?0kL|yxH%^}dC%7)$7GKomNy}~ zkq}KGWV4}v)4x6Nck}?4#S+!$h)&g$Vi$5bqP1L(NDay3I?IWx{T=+jhX+@hC8y8e zWy}6rH3*!R4?)uAk>BvLwH!{U2Ocm@6%sNwGR8ile8p1j*aLQeF(b)nyxH z;IMc6U<}{fJWop0m11{RYJ-uQ(io~Pg}$nia3SXrZgy~1m1>khnmys0nf$Q*m(7OvL&PN05mIcpUayeGa>X&hvkg2wZ7)PiFj(aUX2l4%-5}QIwj5^C^kQ zh+c_(^8yj$<%Yo;GR!z4WyAhS_$d}5!+t8mg3-hAy5S`r)?7!$nUly*+=2Afi?Mfx zA6E7-gSA2%I*wlJ$%+{KlVqS{g5XM~G6eK-#N#`+P+L)k%O}#18@~yu%R{jz$OkjX z^C9C19i_$UI2=w6q3j<)Qc_YUN&hTuNgp+pVI1EKcgjmqQ*r?%$C8l~yADUlT!PnWSh$jUR&9ED#JJ{9;(h}qw@3# zoKM`2EHW38r;oz|GYxc>5d&XO3u(uW{iELpPmwP-^;ZJ%F4=GmH2%AH}^k--_Y>Zv%077=w`=YoNTF!^5aKQb}R|` zv1^gJcoudHvd4h-jdLL;av7SN>gwuHSXhYX&!2y`inXzq$b6h3Q;8OB#oZYYj8KHsL+}#-V%2H%5h~vn(#K)Qh~9YIHHF-qw+*5N)oprZ_Q$)&+x?`4*IZA zl!TFjBr*;szsK<5!TtO9VP<9qRaI5^_>6{yg#{zWxN+k?lA$&6Qyh7xvKV|;iV{fl z_e3R`55+rUkh?MzX@MiLj>urHK-VO3M9!a!`WG)ggpaXf$1->qhK1o=K>-R1&ttf! zCv$Ddk|lpB-`eNDhfi?R*8)bkGx(;ObwEW@0Yg$8NT2_3{FDJ*SNmERF>6w+ zM-Nn|C83PWh5Us<7{gU#WaFC{V8Mcg=-9C%6ciMgJT!DZPGk|CF#jAgesXhjajmKf z5fKqg|5IH=kbczo5wu@bQI0N3GO$&WLf+yTDBZFOzZ$k@uv=)WAuTN(Ij3{+XU1_1 z9XbpF0h6(H+ja&&?f=u{-rTu!$@4K|u=nfN?=SCzAB~^Nu_bgOlc%!D7|+Lrq9R-_yMn5!YE)EQMN;x1X8h~v=`ruFt_$wfR67M-+6HckuAh zBL+9^`;j9@g2&^bq@?6a(3yL!g@4haMa;NRR8#~dx|Y*iLqmhCAv{Kx?A5zBe)(kt zCItjA_{UF}fXZvv@ZiA%JR|QX+6R7qe$B>C1!yh&d-pbuSGv|w-6b$E2%|=gLcjj~ zVNaexXG24D>0%19l?sC~I(h?x{ocL%cuMsAYebG7J$keVdu!sSZDnU?!^OpgnRk4? zBgPVacOubMf~HKx;w4MT_}WP3z;Tq9SKvC)?`!YgMNLf&qN1XhHHqr`<>lqHsb;6v z>VE-4s%KePS~4=2o12rlFdgwb6UbVVjuR(N;P~-O96g$fEwQnTZ0*~(XUbCDUZBGX z+G`ZQ9XIgm@&x8%4!bOPnP)+_yvrp97m2EL3nsL=Fgwc z(Au?YLEopB$h!ZvwNcQ{m+~Kp|4V#Z>)!u3{wlVp=o{Tmof^KMbQ^Sa8%dAk%_VVh z@i)Y9QuQsy6IxGLNazhmR1}TGCOIKCB{7C%#Kh1@;*b&lFUg9xfovNANkCRYK$4J^ zl!V-Sl7gI+fTSTO-AMA%98miCr=Q+_2mbU9(wtjo`VB>1|6w>g#1rQ{yihn|G%k$t zMe*2)D47s|(qE_Ga^P>cGA$StGv}dl&H_}0hU5C82;5k*0yWE{a64)(YS%{NUi2nB z*c69{aXavM$1XhGm567F2l3)y3hGl*(UAHlUT2)Z+pKKh)M;3AdEaHf`u~n!{O6xv zS}H2RvaK>Kl~iD*tO_fYcCc1egLOM~*r>IKjk*T9YG|UXrWS0qv|+2Q13R6LuW5FWzDQH~Y5-zSske?|2sL!~8XyUSYB7e`?Gh338!#=S&S2 z>k(@nQ%;cAvmBW7ddgLU#iA3B=5zt4Icf5LGbg=5`;*C<W1}DrD|vBr=CEJt%ZT=C zJuaVb$v|3ki?fo%D{oB>2B}HGoy5qDATcHs6IWKO{pV}8&K*OJXpVb(X-w0VgCB_# znM!gRE7DViY*-}CE+kxpTZhx9TOo2zG?5W|L1R-WUrMvM@(AWB(Ab)K9!GTAr)##_ zRpHJu>;zNUMhr9caw zYaX*tlxik_8Xo}PL9TFauYhoqc8D}@kJXl%2s2fOG4X+(&dm5k>tDarT>i9N!^@ZO z>g9yq8VZQA)WAAxEo|tjgDD28Fjtks)yt)yWSEzi$JnB#Oqs&?&YBi#34dDe>66Fk z-nk<@J18=|H`{eYoP#cWxvJoIR7XYWrKZi}^5x5n4>Bld3f$b>U}tBChs35XNG;`0 z>rp?DmAWD(6S?CYI$?*S9(Hx(VxmDim?%nN!-}PX=Hct>OYEG#F#b>K7jkv&i}A!> zD@fnMpVp}-BM@r9J)D)D!m&OHOlTU%Qj)LwRz z_(qzh@8wV1x_kRJrcWmSQ_ts|&Odzki1FXdoH>*6xi;n5^tdJbX$%kbO;b68f`Z`h|0|ix6Br*r@a);3et-<( zSE6=nO4JS=8XDS^-ABhQ;ZG}{J9mz;&)eJEleXt${U6bce~mu(YuBonzE4O0| zynQXTls|3nHW_a-Nqhl~-=KE+fddC((4aw#Ux%(O-rn8}&ad&N_rHa|pk3-KN=Zop zozFBcE-q%Cx!`_t^6%l_oc6y~rX~E}l@;_^Yv!csuO?92;@QE&Q83&a=e@_Fc$_~j z`3IpaXa>q>%thtgg{Tf&iklIUxc&PY)UMlr`y1o%Xlp#4ChR3YyO@OfLr3u{Edy^) zoMLQ-ge#S!IqCnLKLOdAecrUK=E(m)QARLd9?b);IS|qy#Cb<77W)w)Vsl{=drPa5 zfG@REP_u+4A%UHO-}t-sz4{Tz{aiI5L@m?&{B1sb+vzKcd%8Q^ABqi!ka z)22DmhYLQePhuKY&G2%^920f&U7?Aw-E8pU`Lp-cGBYztEKdb<{;B#TwkL|}27a#2 zSY@q^^|qZb$+a79-KZupHRqYw4ytpPmX=a|{3HIfK5d+STa0lq$1b8vhTG_&yOkM! z88HI;_V358-Fq;D=n`M5PusY1u^67l9Wj8!-<~BgYcw8g>Cy-U5`BT{1YfI9+cr)=!M1JNhN|jnLG{n_r@9UK zEpG)g2Zq6wmj=yg?r + /// Calculate bounding box with given rhino objects. + /// + /// RhinoObjects to calculate union of bounding box. + /// + public static BoundingBox UnionRhinoObjects(IEnumerable rhinoObjects) + { + BoundingBox boundingBox = BoundingBox.Unset; + foreach (RhinoObject obj in rhinoObjects) + { + BoundingBox objBoundingBox = obj.Geometry.GetBoundingBox(false); + if (objBoundingBox.IsValid) + { + if (boundingBox.IsValid) + { + boundingBox.Union(objBoundingBox); + } + else + { + boundingBox = objBoundingBox; + } + } + } + + return boundingBox; + } +} diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Filters/RhinoEverythingFilter.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Filters/RhinoEverythingFilter.cs new file mode 100644 index 0000000000..fefb2acf0d --- /dev/null +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Filters/RhinoEverythingFilter.cs @@ -0,0 +1,11 @@ +using System.Collections.Generic; +using Speckle.Connectors.DUI.Bindings; + +namespace Speckle.Connectors.Rhino7.Filters; + +public class RhinoEverythingFilter : EverythingSendFilter +{ + public override List GetObjectIds() => new(); // TODO + + public override bool CheckExpiry(string[] changedObjectIds) => true; +} diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Filters/RhinoSelectionFilter.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Filters/RhinoSelectionFilter.cs new file mode 100644 index 0000000000..4ca0e742c6 --- /dev/null +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Filters/RhinoSelectionFilter.cs @@ -0,0 +1,12 @@ +using System.Collections.Generic; +using System.Linq; +using Speckle.Connectors.DUI.Bindings; + +namespace Speckle.Connectors.Rhino7.Filters; + +public class RhinoSelectionFilter : DirectSelectionSendFilter +{ + public override List GetObjectIds() => SelectedObjectIds; + + public override bool CheckExpiry(string[] changedObjectIds) => SelectedObjectIds.Intersect(changedObjectIds).Any(); +} diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/RhinoContext.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/RhinoContext.cs new file mode 100644 index 0000000000..17b532035a --- /dev/null +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/RhinoContext.cs @@ -0,0 +1,8 @@ +using Rhino; + +namespace Speckle.Connectors.Rhino7.HostApp; + +public class RhinoContext +{ + public RhinoDoc Document { get; } = RhinoDoc.ActiveDoc; +} diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/RhinoDocumentStore.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/RhinoDocumentStore.cs new file mode 100644 index 0000000000..368c643764 --- /dev/null +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/RhinoDocumentStore.cs @@ -0,0 +1,61 @@ +using System.Collections.Generic; +using Rhino; +using Speckle.Connectors.DUI.Models; +using Speckle.Connectors.DUI.Models.Card; +using Speckle.Newtonsoft.Json; + +namespace Speckle.Connectors.Rhino7.HostApp; + +public class RhinoDocumentStore : DocumentModelStore +{ + private const string SPECKLE_KEY = "Speckle_DUI3"; + public override bool IsDocumentInit { get; set; } = true; // Note: because of rhino implementation details regarding expiry checking of sender cards. + + public RhinoDocumentStore(JsonSerializerSettings jsonSerializerSettings) + : base(jsonSerializerSettings) + { + RhinoDoc.BeginSaveDocument += (_, _) => WriteToFile(); + RhinoDoc.CloseDocument += (_, _) => WriteToFile(); + RhinoDoc.BeginOpenDocument += (_, _) => IsDocumentInit = false; + RhinoDoc.EndOpenDocument += (_, e) => + { + if (e.Merge) + { + return; + } + + if (e.Document == null) + { + return; + } + + IsDocumentInit = true; + ReadFromFile(); + OnDocumentChanged(); + }; + } + + public override void WriteToFile() + { + if (RhinoDoc.ActiveDoc == null) + { + return; // Should throw + } + + RhinoDoc.ActiveDoc?.Strings.Delete(SPECKLE_KEY); + + string serializedState = Serialize(); + RhinoDoc.ActiveDoc?.Strings.SetString(SPECKLE_KEY, SPECKLE_KEY, serializedState); + } + + public override void ReadFromFile() + { + string stateString = RhinoDoc.ActiveDoc.Strings.GetValue(SPECKLE_KEY, SPECKLE_KEY); + if (stateString == null) + { + Models = new List(); + return; + } + Models = Deserialize(stateString); + } +} diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/RhinoIdleManager.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/RhinoIdleManager.cs new file mode 100644 index 0000000000..fbb1afe4f7 --- /dev/null +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/RhinoIdleManager.cs @@ -0,0 +1,45 @@ +using System; +using System.Collections.Concurrent; +using Rhino; + +namespace Speckle.Connectors.Rhino7.HostApp; + +/// +/// Rhino Idle Manager is a helper util to manage deferred actions. +/// +public class RhinoIdleManager +{ + // NOTE: ConcurrentDictionary possibly removing the collection has been modified errors in here + private readonly ConcurrentDictionary _sCalls = new(); + private bool _hasSubscribed; + + /// + /// Subscribe deferred action to RhinoIdle event to run it whenever Rhino become idle. + /// + /// Action to call whenever Rhino become Idle. + public void SubscribeToIdle(Action action) + { + _sCalls[action.Method.Name] = action; + + if (_hasSubscribed) + { + return; + } + + _hasSubscribed = true; + RhinoApp.Idle += RhinoAppOnIdle; + } + + private void RhinoAppOnIdle(object sender, EventArgs e) + { + foreach (var kvp in _sCalls) + { + kvp.Value(); + } + + _sCalls.Clear(); + + _hasSubscribed = false; + RhinoApp.Idle -= RhinoAppOnIdle; + } +} diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/RhinoSettings.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/RhinoSettings.cs new file mode 100644 index 0000000000..61c310a2de --- /dev/null +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/RhinoSettings.cs @@ -0,0 +1,19 @@ +using System.IO; +using Speckle.Core.Kits; + +namespace Speckle.Connectors.Rhino7.HostApp; + +public class RhinoSettings +{ + public RhinoSettings(HostApplication hostAppInfo, HostAppVersion hostAppVersion) + { + HostAppInfo = hostAppInfo; + HostAppVersion = hostAppVersion; + Modules = new[] { new DirectoryInfo(typeof(RhinoSettings).Assembly.ToString()).Parent.FullName }; + } + + public HostApplication HostAppInfo { get; private set; } + public HostAppVersion HostAppVersion { get; private set; } + + public string[] Modules { get; private set; } +} diff --git a/ConnectorRhino/ConnectorRhinoWebUI/SpeckleWebUiPanelWebView2.xaml b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/SpeckleRhinoPanel.xaml similarity index 65% rename from ConnectorRhino/ConnectorRhinoWebUI/SpeckleWebUiPanelWebView2.xaml rename to DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/SpeckleRhinoPanel.xaml index 6574b29245..14d79465ad 100644 --- a/ConnectorRhino/ConnectorRhinoWebUI/SpeckleWebUiPanelWebView2.xaml +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/SpeckleRhinoPanel.xaml @@ -1,4 +1,4 @@ - - - + + diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/SpeckleRhinoPanel.xaml.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/SpeckleRhinoPanel.xaml.cs new file mode 100644 index 0000000000..cde06f8802 --- /dev/null +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/SpeckleRhinoPanel.xaml.cs @@ -0,0 +1,46 @@ +using System; +using System.Collections.Generic; +using System.Windows.Controls; +using System.Windows.Threading; +using Microsoft.Web.WebView2.Core; +using Speckle.Connectors.DUI.Bindings; +using Speckle.Connectors.DUI.Bridge; +using Speckle.Core.Logging; + +namespace Speckle.Connectors.Rhino7.HostApp; + +public partial class SpeckleRhinoPanel : UserControl +{ + private readonly IEnumerable> _bindings; + + public SpeckleRhinoPanel(IEnumerable> bindings) + { + _bindings = bindings; + InitializeComponent(); + Browser.CoreWebView2InitializationCompleted += OnInitialized; + } + + public void ShowDevToolsMethod() => Browser.CoreWebView2.OpenDevToolsWindow(); + + public void ExecuteScriptAsyncMethod(string script) + { + if (!Browser.IsInitialized) + { + throw new SpeckleException("Failed to execute script, Webview2 is not initialized yet."); + } + + Browser.Dispatcher.Invoke(() => Browser.ExecuteScriptAsync(script), DispatcherPriority.Background); + } + + private void OnInitialized(object sender, CoreWebView2InitializationCompletedEventArgs e) + { + //TODO: Pass bindings to browser bridge here! + foreach (Lazy lazyBinding in _bindings) + { + var binding = lazyBinding.Value; + binding.Parent.AssociateWithBinding(binding, ExecuteScriptAsyncMethod, Browser); + Console.WriteLine(); + Browser.CoreWebView2.AddHostObjectToScript(binding.Name, binding.Parent); + } + } +} diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/SpeckleRhinoPanelHost.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/SpeckleRhinoPanelHost.cs new file mode 100644 index 0000000000..f28af83539 --- /dev/null +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/SpeckleRhinoPanelHost.cs @@ -0,0 +1,16 @@ +using System.Runtime.InteropServices; +using Speckle.Connectors.Rhino7.Plugin; + +namespace Speckle.Connectors.Rhino7.HostApp; + +[Guid("39BC44A4-C9DC-4B0A-9A51-4C31ACBCD76A")] +public class SpeckleRhinoPanelHost : RhinoWindows.Controls.WpfElementHost +{ + private readonly uint _docSn; + + public SpeckleRhinoPanelHost(uint docSn) + : base(SpeckleConnectorsRhino7Plugin.Instance.Container?.Resolve(), null) + { + _docSn = docSn; + } +} diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Interfaces/IRhinoPlugin.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Interfaces/IRhinoPlugin.cs new file mode 100644 index 0000000000..487c2968f5 --- /dev/null +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Interfaces/IRhinoPlugin.cs @@ -0,0 +1,7 @@ +namespace Speckle.Connectors.Rhino7.Interfaces; + +public interface IRhinoPlugin +{ + void Initialise(); + void Shutdown(); +} diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Plugin/Speckle.Connectors.Rhino7Command.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Plugin/Speckle.Connectors.Rhino7Command.cs new file mode 100644 index 0000000000..1a8e18fba9 --- /dev/null +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Plugin/Speckle.Connectors.Rhino7Command.cs @@ -0,0 +1,95 @@ +using System; +using Rhino; +using Rhino.Commands; +using Rhino.Input.Custom; +using Rhino.UI; +using Speckle.Connectors.Rhino7.HostApp; + +namespace Speckle.Connectors.Rhino7.Plugin; + +public class SpeckleConnectorsRhino7Command : Command +{ + public SpeckleConnectorsRhino7Command() + { + // Rhino only creates one instance of each command class defined in a + // plug-in, so it is safe to store a reference in a static property. + Instance = this; + Panels.RegisterPanel( + SpeckleConnectorsRhino7Plugin.Instance, + typeof(SpeckleRhinoPanelHost), + "SpeckleRhino7DUI3", + System.Drawing.SystemIcons.Information, + PanelType.System + ); + } + + ///The only instance of this command. + public static SpeckleConnectorsRhino7Command Instance { get; private set; } + + ///The command name as it appears on the Rhino command line. + public override string EnglishName => "SpeckleNewUI"; + + protected override Result RunCommand(RhinoDoc doc, RunMode mode) + { + Guid panelId = typeof(SpeckleRhinoPanelHost).GUID; + + if (mode == RunMode.Interactive) + { + Panels.OpenPanel(panelId); + return Result.Success; + } + + bool panelVisible = Panels.IsPanelVisible(panelId); + + string prompt = panelVisible + ? "SpeckleWebUIWebView2 panel is visible. New value" + : "SpeckleWebUIWebView2 panel is hidden. New value"; + + using GetOption go = new(); + go.SetCommandPrompt(prompt); + int hideIndex = go.AddOption("Hide"); + int showIndex = go.AddOption("Show"); + int toggleIndex = go.AddOption("Toggle"); + go.Get(); + + if (go.CommandResult() != Result.Success) + { + return go.CommandResult(); + } + + CommandLineOption option = go.Option(); + if (null == option) + { + return Result.Failure; + } + + int index = option.Index; + if (index == hideIndex) + { + if (panelVisible) + { + Panels.ClosePanel(panelId); + } + } + else if (index == showIndex) + { + if (!panelVisible) + { + Panels.OpenPanel(panelId); + } + } + else if (index == toggleIndex) + { + switch (panelVisible) + { + case true: + Panels.ClosePanel(panelId); + break; + default: + Panels.OpenPanel(panelId); + break; + } + } + return Result.Success; + } +} diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Plugin/Speckle.Connectors.Rhino7Plugin.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Plugin/Speckle.Connectors.Rhino7Plugin.cs new file mode 100644 index 0000000000..9d0e3831e3 --- /dev/null +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Plugin/Speckle.Connectors.Rhino7Plugin.cs @@ -0,0 +1,105 @@ +using System; +using System.IO; +using System.Reflection; +using Autofac; +using Rhino.PlugIns; +using Speckle.Autofac.DependencyInjection; +using Speckle.Autofac.Files; +using Speckle.Connectors.Rhino7.DependencyInjection; +using Speckle.Connectors.Rhino7.HostApp; +using Speckle.Connectors.Rhino7.Interfaces; +using Speckle.Converters.Common.Objects; +using Speckle.Core.Kits; +using Speckle.Core.Logging; +using Speckle.Core.Models.Extensions; + +namespace Speckle.Connectors.Rhino7.Plugin; + +/// +/// Every RhinoCommon .rhp assembly must have one and only one PlugIn-derived +/// class. DO NOT create instances of this class yourself. It is the +/// responsibility of Rhino to create an instance of this class. +/// To complete plug-in information, please also see all PlugInDescription +/// attributes in AssemblyInfo.cs (you might need to click "Project" -> +/// "Show All Files" to see it in the "Solution Explorer" window). +/// +public class SpeckleConnectorsRhino7Plugin : PlugIn +{ + private IRhinoPlugin? _rhinoPlugin; + + public AutofacContainer? Container { get; private set; } + + public SpeckleConnectorsRhino7Plugin() + { + Instance = this; + } + + ///Gets the only instance of the Speckle_Connectors_Rhino7Plugin plug-in. + public static SpeckleConnectorsRhino7Plugin Instance { get; private set; } + + // You can override methods here to change the plug-in behavior on + // loading and shut down, add options pages to the Rhino _Option command + // and maintain plug-in wide options in a document. + + protected override LoadReturnCode OnLoad(ref string errorMessage) + { + try + { + AppDomain.CurrentDomain.AssemblyResolve += OnAssemblyResolve; + + Container = new AutofacContainer(new StorageInfo()); + Container.PreBuildEvent += _container_PreBuildEvent; + + // Register Settings + var rhinoSettings = new RhinoSettings(HostApplications.Rhino, HostAppVersion.v7); + + Container + .AddModule(new AutofacRhinoModule()) + .LoadAutofacModules(rhinoSettings.Modules) + .AddSingletonInstance(rhinoSettings) + .Build(); + + // Resolve root plugin object and initialise. + _rhinoPlugin = Container.Resolve(); + _rhinoPlugin.Initialise(); + + return LoadReturnCode.Success; + } + catch (Exception e) when (!e.IsFatal()) + { + errorMessage = e.ToFormattedString(); + return LoadReturnCode.ErrorNoDialog; + } + } + + protected override void OnShutdown() + { + _rhinoPlugin?.Shutdown(); + base.OnShutdown(); + } + + private Assembly OnAssemblyResolve(object sender, ResolveEventArgs args) + { + // POC: tight binding to files + Assembly assembly = null; + string name = args.Name.Split(',')[0]; + string path = Path.GetDirectoryName(typeof(SpeckleConnectorsRhino7Plugin).Assembly.Location); + + if (path != null) + { + string assemblyFile = Path.Combine(path, name + ".dll"); + + if (File.Exists(assemblyFile)) + { + assembly = Assembly.LoadFrom(assemblyFile); + } + } + + return assembly; + } + + private void _container_PreBuildEvent(object sender, ContainerBuilder containerBuilder) + { + containerBuilder.InjectNamedTypes(); + } +} diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Properties/AssemblyInfo.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..88eada7ed2 --- /dev/null +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Properties/AssemblyInfo.cs @@ -0,0 +1,20 @@ +using System.Runtime.InteropServices; +using Rhino.PlugIns; + +// Plug-in Description Attributes - all of these are optional. +// These will show in Rhino's option dialog, in the tab Plug-ins. +[assembly: PlugInDescription(DescriptionType.Address, "")] +[assembly: PlugInDescription(DescriptionType.Country, "")] +[assembly: PlugInDescription(DescriptionType.Email, "")] +[assembly: PlugInDescription(DescriptionType.Phone, "")] +[assembly: PlugInDescription(DescriptionType.Fax, "")] +[assembly: PlugInDescription(DescriptionType.Organization, "")] +[assembly: PlugInDescription(DescriptionType.UpdateUrl, "")] +[assembly: PlugInDescription(DescriptionType.WebSite, "")] + +// Icons should be Windows .ico files and contain 32-bit images in the following sizes: 16, 24, 32, 48, and 256. +[assembly: PlugInDescription(DescriptionType.Icon, "Speckle.Connectors.Rhino7.EmbeddedResources.plugin-utility.ico")] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +// This will also be the Guid of the Rhino plug-in +[assembly: Guid("2153799A-0CEC-40DE-BC3A-01E5055222FF")] diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Properties/launchSettings.json b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Properties/launchSettings.json new file mode 100644 index 0000000000..6f5a29e954 --- /dev/null +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Properties/launchSettings.json @@ -0,0 +1,8 @@ +{ + "profiles": { + "Speckle.Connectors.Rhino7": { + "commandName": "Executable", + "executablePath": "C:\\Program Files\\Rhino 7\\System\\Rhino.exe" + } + } +} diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Speckle.Connectors.Rhino7.csproj b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Speckle.Connectors.Rhino7.csproj new file mode 100644 index 0000000000..36b1254e79 --- /dev/null +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Speckle.Connectors.Rhino7.csproj @@ -0,0 +1,36 @@ + + + net48 + .rhp + enable + true + true + + + + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + + + + + + + + + + + diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/AutofacRhinoConverterModule.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/AutofacRhinoConverterModule.cs new file mode 100644 index 0000000000..ae9a61ec70 --- /dev/null +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/AutofacRhinoConverterModule.cs @@ -0,0 +1,22 @@ +// POC: not sure we should have this here as it attaches us to autofac, maybe a bit prematurely... + +using Autofac; +using Speckle.Autofac.DependencyInjection; +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; + +namespace Speckle.Converters.Rhino7.DependencyInjection; + +public class AutofacRhinoConverterModule : Module +{ + protected override void Load(ContainerBuilder builder) + { + // most things should be InstancePerLifetimeScope so we get one per operation + builder.RegisterType().As(); + + // factory for conversions + builder + .RegisterType>() + .As>(); + } +} diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/Speckle.Converters.Rhino7.DependencyInjection.csproj b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/Speckle.Converters.Rhino7.DependencyInjection.csproj new file mode 100644 index 0000000000..0d104af798 --- /dev/null +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/Speckle.Converters.Rhino7.DependencyInjection.csproj @@ -0,0 +1,15 @@ + + + + netstandard2.0 + enable + enable + + + + + + + + + diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/RhinoConverterToSpeckle.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/RhinoConverterToSpeckle.cs new file mode 100644 index 0000000000..fa86361fc0 --- /dev/null +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/RhinoConverterToSpeckle.cs @@ -0,0 +1,23 @@ +using Speckle.Autofac.DependencyInjection; +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; +using Speckle.Objects.Geometry; + +namespace Speckle.Converters.Rhino7; + +public class RhinoConverterToSpeckle : ISpeckleConverterToSpeckle +{ + private readonly IFactory _toSpeckle; + + public RhinoConverterToSpeckle(IFactory toSpeckle) + { + _toSpeckle = toSpeckle; + } + + public void Convert() + { + var objectConverter = _toSpeckle.ResolveInstance(nameof(Point)); + + Console.WriteLine(objectConverter); + } +} diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Speckle.Converters.Rhino7.csproj b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Speckle.Converters.Rhino7.csproj new file mode 100644 index 0000000000..4c9e81bcbf --- /dev/null +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Speckle.Converters.Rhino7.csproj @@ -0,0 +1,14 @@ + + + + netstandard2.0 + enable + enable + + + + + + + + diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/IBasicConnectorBinding.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/IBasicConnectorBinding.cs index 730057b33f..91d8b1a019 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/IBasicConnectorBinding.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/IBasicConnectorBinding.cs @@ -1,3 +1,5 @@ +using System; +using Speckle.Connectors.DUI.Bridge; using Speckle.Connectors.DUI.Models; using Speckle.Connectors.DUI.Models.Card; @@ -19,6 +21,8 @@ public interface IBasicConnectorBinding : IBinding /// /// public void HighlightModel(string modelCardId); + + public BasicConnectorBindingCommands Commands { get; } } public static class BasicConnectorBindingEvents @@ -26,3 +30,25 @@ public static class BasicConnectorBindingEvents public const string DISPLAY_TOAST_NOTIFICATION = "DisplayToastNotification"; public const string DOCUMENT_CHANGED = "documentChanged"; } + +public class BasicConnectorBindingCommands +{ + private const string NOTIFY_DOCUMENT_CHANGED_EVENT_NAME = "documentChanged"; + private const string SET_MODEL_PROGRESS_UI_COMMAND_NAME = "setModelProgress"; + private const string SET_MODEL_ERROR_UI_COMMAND_NAME = "setModelError"; + + private IBridge _bridge; + + public BasicConnectorBindingCommands(IBridge bridge) + { + _bridge = bridge; + } + + public void NotifyDocumentChanged() => _bridge.Send(NOTIFY_DOCUMENT_CHANGED_EVENT_NAME); + + public void SetModelProgress(string modelCardId, ModelCardProgress progress) => + _bridge.Send(SET_MODEL_PROGRESS_UI_COMMAND_NAME, new { modelCardId, progress }); + + public void SetModelError(string modelCardId, Exception error) => + _bridge.Send(SET_MODEL_ERROR_UI_COMMAND_NAME, new { modelCardId, error = error.Message }); +} diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/ISendBinding.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/ISendBinding.cs index f475ad0989..e0071ae2b3 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/ISendBinding.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/ISendBinding.cs @@ -19,6 +19,8 @@ public interface ISendBinding : IBinding /// /// public void CancelSend(string modelCardId); + + public SendBindingUICommands Commands { get; } } public class SenderModelCard : ModelCard diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/SendBindingUICommands.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/SendBindingUICommands.cs index 5382336358..e6220da9b5 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/SendBindingUICommands.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/SendBindingUICommands.cs @@ -4,18 +4,25 @@ namespace Speckle.Connectors.DUI.Bindings; // POC: have put this static back but unsure about it or the IBridge having this responsibility... and the static -public static class SendBindingUICommands +public class SendBindingUICommands { - private const string REFRESH_SEND_FILTERS_UI_COMMAND_NAME = "refreshSendFilters"; - private const string SET_MODELS_EXPIRED_UI_COMMAND_NAME = "setModelsExpired"; - private const string SET_MODEL_CREATED_VERSION_ID_UI_COMMAND_NAME = "setModelCreatedVersionId"; + private string REFRESH_SEND_FILTERS_UI_COMMAND_NAME = "refreshSendFilters"; + private string SET_MODELS_EXPIRED_UI_COMMAND_NAME = "setModelsExpired"; + private string SET_MODEL_CREATED_VERSION_ID_UI_COMMAND_NAME = "setModelCreatedVersionId"; + + private IBridge _bridge; + + public SendBindingUICommands(IBridge bridge) + { + _bridge = bridge; + } // POC.. the only reasons this needs the bridge is to send? realtionship to these messages and the bridge is unclear - public static void RefreshSendFilters(IBridge bridge) => bridge.Send(REFRESH_SEND_FILTERS_UI_COMMAND_NAME); + public void RefreshSendFilters() => _bridge.Send(REFRESH_SEND_FILTERS_UI_COMMAND_NAME); - public static void SetModelsExpired(IBridge bridge, IEnumerable expiredModelIds) => - bridge.Send(SET_MODELS_EXPIRED_UI_COMMAND_NAME, expiredModelIds); + public void SetModelsExpired(IEnumerable expiredModelIds) => + _bridge.Send(SET_MODELS_EXPIRED_UI_COMMAND_NAME, expiredModelIds); - public static void SetModelCreatedVersionId(IBridge bridge, string modelCardId, string versionId) => - bridge.Send(SET_MODEL_CREATED_VERSION_ID_UI_COMMAND_NAME, new { modelCardId, versionId }); + public void SetModelCreatedVersionId(string modelCardId, string versionId) => + _bridge.Send(SET_MODEL_CREATED_VERSION_ID_UI_COMMAND_NAME, new { modelCardId, versionId }); } diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/ModelCardError.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/ModelCardError.cs new file mode 100644 index 0000000000..cf2ab19116 --- /dev/null +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/ModelCardError.cs @@ -0,0 +1,9 @@ +using System; + +namespace Speckle.Connectors.DUI.Models.Card; + +public class ModelCardError +{ + public string ModelCardId { get; set; } + public Exception Error { get; set; } +} diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/ModelCardNotification.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/ModelCardNotification.cs new file mode 100644 index 0000000000..0970fcdcf7 --- /dev/null +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/ModelCardNotification.cs @@ -0,0 +1,10 @@ +namespace Speckle.Connectors.DUI.Models.Card; + +public class ModelCardNotification +{ + public string ModelCardId { get; set; } + public string Text { get; set; } + public string Level { get; set; } + public int Timeout { get; set; } + public bool Dismissible { get; set; } = true; +} diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/ModelCardProgress.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/ModelCardProgress.cs new file mode 100644 index 0000000000..88a8a66d39 --- /dev/null +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/ModelCardProgress.cs @@ -0,0 +1,13 @@ +namespace Speckle.Connectors.DUI.Models.Card; + +public class ModelCardProgress +{ + public string ModelCardId { get; set; } + public string Status { get; set; } + + /// + /// Progress value between 0 and 1 to calculate UI progress bar width. + /// If it is null it will swooshing on UI. + /// + public double? Progress { get; set; } +} diff --git a/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/Send.cs b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/Send.cs new file mode 100644 index 0000000000..0cddcd797d --- /dev/null +++ b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/Send.cs @@ -0,0 +1,200 @@ +#nullable enable +using System; +using System.Collections.Concurrent; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using Serilog.Context; +using Speckle.Core.Logging; +using Speckle.Core.Models; +using Speckle.Core.Serialisation; +using Speckle.Core.Transports; +using Speckle.Newtonsoft.Json.Linq; + +namespace Speckle.Connectors.Utils.Operations; + +/// +/// NOTE: Contains copy pasted code from the OG Send operations in Core (the non-obsolete ones). +/// +public static class SendHelper +{ + /// + /// IMPORTANT: Copy pasted function from Operations.Send in Core, but this time returning the converted references from the serializer. + /// Sends a Speckle Object to the provided and (optionally) the default local cache + /// + /// + /// + /// When , an additional will be included + /// The or was + /// + /// using ServerTransport destination = new(account, streamId); + /// string objectId = await Send(mySpeckleObject, destination, true); + /// + public static async Task<(string rootObjId, Dictionary convertedReferences)> Send( + Base value, + ITransport transport, + bool useDefaultCache, + Action>? onProgressAction = null, + CancellationToken cancellationToken = default + ) + { + if (transport is null) + { + throw new ArgumentNullException(nameof(transport), "Expected a transport to be explicitly specified"); + } + + List transports = new() { transport }; + using SQLiteTransport? localCache = useDefaultCache ? new SQLiteTransport { TransportName = "LC" } : null; + if (localCache is not null) + { + transports.Add(localCache); + } + + return await Send(value, transports, onProgressAction, cancellationToken).ConfigureAwait(false); + } + + /// + /// IMPORTANT: Copy pasted function from Operations.Send in Core, but this time returning the converted references from the serializer. + /// It's marked as private as DUI3 only uses the one above. + /// Note that this should be structured better in the future - this is here to minimise core changes coming from DUI3. + /// + /// + /// + /// + /// + /// + /// + /// + /// + private static async Task<(string rootObjId, Dictionary convertedReferences)> Send( + Base value, + IReadOnlyCollection transports, + Action>? onProgressAction = null, + CancellationToken cancellationToken = default + ) + { + if (value is null) + { + throw new ArgumentNullException(nameof(value)); + } + + if (transports.Count == 0) + { + throw new ArgumentException("Expected at least on transport to be specified", nameof(transports)); + } + + var transportContext = transports.ToDictionary(t => t.TransportName, t => t.TransportContext); + + // make sure all logs in the operation have the proper context + using (LogContext.PushProperty("transportContext", transportContext)) + using (LogContext.PushProperty("correlationId", Guid.NewGuid().ToString())) + { + var sendTimer = Stopwatch.StartNew(); + SpeckleLog.Logger.Information("Starting send operation"); + + var internalProgressAction = GetInternalProgressAction(onProgressAction); + + BaseObjectSerializerV2 serializerV2 = + new(transports, internalProgressAction, trackDetachedChildren: true, cancellationToken); + + foreach (var t in transports) + { + t.OnProgressAction = internalProgressAction; + t.CancellationToken = cancellationToken; + t.BeginWrite(); + } + + (string rootObjId, Dictionary) serializerReturnValue; + try + { + serializerReturnValue = await SerializerSend(value, serializerV2, cancellationToken).ConfigureAwait(false); + } + catch (Exception ex) when (!ex.IsFatal()) + { + SpeckleLog.Logger.Information( + ex, + "Send operation failed after {elapsed} seconds", + sendTimer.Elapsed.TotalSeconds + ); + if (ex is OperationCanceledException or SpeckleException) + { + throw; + } + + throw new SpeckleException("Send operation was unsuccessful", ex); + } + finally + { + foreach (var t in transports) + { + t.EndWrite(); + } + } + + sendTimer.Stop(); + SpeckleLog.Logger + .ForContext("transportElapsedBreakdown", transports.ToDictionary(t => t.TransportName, t => t.Elapsed)) + .ForContext("note", "the elapsed summary doesn't need to add up to the total elapsed... Threading magic...") + .ForContext("serializerElapsed", serializerV2.Elapsed) + .Information( + "Finished sending {objectCount} objects after {elapsed}, result {objectId}", + transports.Max(t => t.SavedObjectCount), + sendTimer.Elapsed.TotalSeconds, + serializerReturnValue.rootObjId + ); + return serializerReturnValue; + } + } + + internal static async Task<( + string rootObjectId, + Dictionary convertedReferences + )> SerializerSend(Base value, BaseObjectSerializerV2 serializer, CancellationToken cancellationToken = default) + { + string obj = serializer.Serialize(value); + Task[] transportAwaits = serializer.WriteTransports.Select(t => t.WriteComplete()).ToArray(); + + cancellationToken.ThrowIfCancellationRequested(); + + await Task.WhenAll(transportAwaits).ConfigureAwait(false); + + var parsed = JObject.Parse(obj); + JToken? idToken = parsed.GetValue("id"); + + if (idToken == null) + { + throw new SpeckleException("Failed to get id of serialized object"); + } + + return (idToken.ToString(), serializer.ObjectReferences); + } + + /// + /// Factory for progress actions used internally inside send and receive methods. + /// + /// + /// + private static Action? GetInternalProgressAction( + Action>? onProgressAction + ) + { + if (onProgressAction is null) + { + return null; + } + + var localProgressDict = new ConcurrentDictionary(); + + return (name, processed) => + { + if (!localProgressDict.TryAdd(name, processed)) + { + localProgressDict[name] += processed; + } + + onProgressAction.Invoke(localProgressDict); + }; + } +} From d814572c0968d43f6c607c635695dc75991d3897 Mon Sep 17 00:00:00 2001 From: Alan Rynne Date: Tue, 19 Mar 2024 18:08:56 +0100 Subject: [PATCH 010/261] ci: Quick CI build check for DUI3-DX.slnf and formatting enforcement (#3237) * ci: Quick and dirty CI build check for DUI3-DX.slnf and formatting enforcement * ci: typo * fix: Run formatting * ci: Slimmed down DUI3-DX solutions * fix: Warnings in build * fix(dui3): Fixed all warnings that are treated as errors on CI --- .circleci/scripts/config-template.yml | 18 +++++++++++ DUI3-DX.slnf | 30 ------------------- .../Bindings/ReceiveBinding.cs | 3 +- .../Plugin/RevitExternalApplication.cs | 5 ++-- .../Bindings/RhinoSendBinding.cs | 16 ++++++---- .../DependencyInjection/AutofacRhinoModule.cs | 1 - .../DependencyInjection/RhinoPlugin.cs | 3 -- .../HostApp/RhinoSettings.cs | 5 ++-- .../HostApp/SpeckleRhinoPanel.xaml.cs | 1 - .../Plugin/Speckle.Connectors.Rhino7Plugin.cs | 8 ++--- .../Speckle.Connectors.DUI/Bridge/IBridge.cs | 1 - .../Operations/Send.cs | 3 +- 12 files changed, 42 insertions(+), 52 deletions(-) diff --git a/.circleci/scripts/config-template.yml b/.circleci/scripts/config-template.yml index 2a4b2a1546..66856d6ef2 100644 --- a/.circleci/scripts/config-template.yml +++ b/.circleci/scripts/config-template.yml @@ -18,6 +18,9 @@ workflows: - build-sdk: requires: - get-ci-tools + build-dui3: + jobs: + - build-dui3-job nuget: jobs: - build-sdk: @@ -84,6 +87,21 @@ commands: --collect:"XPlat Code Coverage" -- DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.Format=opencover jobs: # Each project will have individual jobs for each specific task it has to execute (build, release...) + build-dui3-job: + executor: + name: win/default + shell: bash.exe + steps: + - checkout + - run: + name: Enforce formatting + command: | + dotnet tool restore + dotnet csharpier --check . + - run: + name: Build DUI3 Solution filter + command: | + dotnet build DUI3-DX.slnf -c Release -p:IsDesktopBuild=false build-sdk: docker: - image: cimg/base:2021.01 diff --git a/DUI3-DX.slnf b/DUI3-DX.slnf index ad0e874dab..dccc0fcfbc 100644 --- a/DUI3-DX.slnf +++ b/DUI3-DX.slnf @@ -2,16 +2,11 @@ "solution": { "path": "All.sln", "projects": [ - "ConnectorRevit\\ConnectorRevit2023\\ConnectorRevit2023.csproj", - "ConnectorRevit\\ConnectorRevit\\ConnectorRevitShared.shproj", - "ConnectorRevit\\RevitDUI3\\Revit2023DUI3\\Revit2023DUI3.csproj", - "ConnectorRevit\\RevitDUI3\\RevitDUI3Shared\\RevitDUI3Shared.shproj", "Core\\Core\\Core.csproj", "Core\\Tests\\Speckle.Core.Tests.Integration\\Speckle.Core.Tests.Integration.csproj", "Core\\Tests\\Speckle.Core.Tests.Performance\\Speckle.Core.Tests.Performance.csproj", "Core\\Tests\\Speckle.Core.Tests.Unit\\Speckle.Core.Tests.Unit.csproj", "Core\\Transports\\DiskTransport\\DiskTransport.csproj", - "DesktopUI3\\DUI3\\DUI3.csproj", "DUI3-DX\\Connectors\\Revit\\Speckle.Connectors.Revit2023\\Speckle.Connectors.Revit2023.csproj", "DUI3-DX\\Connectors\\Revit\\Speckle.Connectors.RevitShared\\Speckle.Connectors.RevitShared.shproj", "DUI3-DX\\Connectors\\Rhino\\Speckle.Connectors.Rhino7\\Speckle.Connectors.Rhino7.csproj", @@ -26,31 +21,6 @@ "DUI3-DX\\Sdk\\Speckle.Autofac\\Speckle.Autofac.csproj", "DUI3-DX\\Sdk\\Speckle.Connectors.Utils\\Speckle.Connectors.Utils.csproj", "DUI3-DX\\Sdk\\Speckle.Converters.Common\\Speckle.Converters.Common.csproj", - "Objects\\Converters\\ConverterAutocadCivil\\ConverterAdvanceSteel2023\\ConverterAdvanceSteel2023.csproj", - "Objects\\Converters\\ConverterAutocadCivil\\ConverterAdvanceSteel2024\\ConverterAdvanceSteel2024.csproj", - "Objects\\Converters\\ConverterAutocadCivil\\ConverterAutocad2021\\ConverterAutocad2021.csproj", - "Objects\\Converters\\ConverterAutocadCivil\\ConverterAutocad2022\\ConverterAutocad2022.csproj", - "Objects\\Converters\\ConverterAutocadCivil\\ConverterAutocad2023\\ConverterAutocad2023.csproj", - "Objects\\Converters\\ConverterAutocadCivil\\ConverterAutocad2024\\ConverterAutocad2024.csproj", - "Objects\\Converters\\ConverterAutocadCivil\\ConverterAutocadCivilShared\\ConverterAutocadCivilShared.shproj", - "Objects\\Converters\\ConverterAutocadCivil\\ConverterCivil2021\\ConverterCivil2021.csproj", - "Objects\\Converters\\ConverterAutocadCivil\\ConverterCivil2022\\ConverterCivil2022.csproj", - "Objects\\Converters\\ConverterAutocadCivil\\ConverterCivil2023\\ConverterCivil2023.csproj", - "Objects\\Converters\\ConverterAutocadCivil\\ConverterCivil2024\\ConverterCivil2024.csproj", - "Objects\\Converters\\ConverterDxf\\ConverterDxf\\ConverterDxf.csproj", - "Objects\\Converters\\ConverterRevit\\ConverterRevit2020\\ConverterRevit2020.csproj", - "Objects\\Converters\\ConverterRevit\\ConverterRevit2021\\ConverterRevit2021.csproj", - "Objects\\Converters\\ConverterRevit\\ConverterRevit2022\\ConverterRevit2022.csproj", - "Objects\\Converters\\ConverterRevit\\ConverterRevit2023\\ConverterRevit2023.csproj", - "Objects\\Converters\\ConverterRevit\\ConverterRevit2024\\ConverterRevit2024.csproj", - "Objects\\Converters\\ConverterRevit\\ConverterRevitShared\\ConverterRevitShared.shproj", - "Objects\\Converters\\ConverterRhinoGh\\ConverterGrasshopper6\\ConverterGrasshopper6.csproj", - "Objects\\Converters\\ConverterRhinoGh\\ConverterGrasshopper7\\ConverterGrasshopper7.csproj", - "Objects\\Converters\\ConverterRhinoGh\\ConverterGrasshopper8\\ConverterGrasshopper8.csproj", - "Objects\\Converters\\ConverterRhinoGh\\ConverterRhino6\\ConverterRhino6.csproj", - "Objects\\Converters\\ConverterRhinoGh\\ConverterRhino7\\ConverterRhino7.csproj", - "Objects\\Converters\\ConverterRhinoGh\\ConverterRhino8\\ConverterRhino8.csproj", - "Objects\\Converters\\ConverterRhinoGh\\ConverterRhinoGhShared\\ConverterRhinoGhShared.shproj", "Objects\\Objects\\Objects.csproj", "Objects\\Tests\\Objects.Tests.Unit\\Objects.Tests.Unit.csproj" ] diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/ReceiveBinding.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/ReceiveBinding.cs index 4dd57d7d34..6aa4c4a6e8 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/ReceiveBinding.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/ReceiveBinding.cs @@ -3,6 +3,7 @@ using Speckle.Connectors.Revit.HostApp; using Speckle.Connectors.Revit.Plugin; using Speckle.Connectors.Utils.Cancellation; +using Speckle.Core.Logging; namespace Speckle.Connectors.Revit.Bindings; @@ -42,7 +43,7 @@ public async void Receive(string modelCardId, string versionId) //// 5 - Bake objects //BakeObjects(objectsToConvert, converter, modelCardId, cts); } - catch (Exception e) + catch (Exception e) when (!e.IsFatal()) { //if (e is OperationCanceledException) //{ diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitExternalApplication.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitExternalApplication.cs index d53d6e468f..1232176e5a 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitExternalApplication.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitExternalApplication.cs @@ -6,6 +6,7 @@ using System.IO; using Autofac; using Speckle.Converters.Common.Objects; +using Speckle.Core.Logging; namespace Speckle.Connectors.Revit.Plugin; @@ -69,7 +70,7 @@ public Result OnStartup(UIControlledApplication application) _revitPlugin = _container.Resolve(); _revitPlugin.Initialise(); } - catch (Exception) + catch (Exception e) when (!e.IsFatal()) { // POC: feedback? return Result.Failed; @@ -92,7 +93,7 @@ public Result OnShutdown(UIControlledApplication application) // need to look for commonality _revitPlugin.Shutdown(); } - catch (Exception) + catch (Exception e) when (!e.IsFatal()) { // POC: feedback? return Result.Failed; diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSendBinding.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSendBinding.cs index 4a506f4936..e3baac5c38 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSendBinding.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSendBinding.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; using System.Linq; using System.Threading; using Rhino; @@ -25,7 +26,7 @@ namespace Speckle.Connectors.Rhino7.Bindings; -public class RhinoSendBinding : ISendBinding, ICancelable +public sealed class RhinoSendBinding : ISendBinding, ICancelable { public string Name { get; } = "sendBinding"; public SendBindingUICommands Commands { get; } @@ -138,6 +139,11 @@ public List GetSendSettings() }; } + [SuppressMessage( + "Maintainability", + "CA1506:Avoid excessive class coupling", + Justification = "Being refactored on in parallel, muting this issue so CI can pass initially." + )] public async void Send(string modelCardId) { try @@ -321,10 +327,10 @@ Collection rootObjectCollection foreach (var layerName in names) { var existingLayerIndex = RhinoDoc.ActiveDoc.Layers.FindByFullPath(path, -1); - Collection childCollection = null; - if (layerCollectionCache.ContainsKey(existingLayerIndex)) + Collection? childCollection = null; + if (layerCollectionCache.TryGetValue(existingLayerIndex, out Collection? collection)) { - childCollection = layerCollectionCache[existingLayerIndex]; + childCollection = collection; } else { @@ -372,8 +378,8 @@ private void RunExpirationChecks() public void Dispose() { - // TODO release managed resources here IsDisposed = true; + _speckleConverterToSpeckleFactory.Dispose(); } public bool IsDisposed { get; private set; } diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/AutofacRhinoModule.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/AutofacRhinoModule.cs index 8936c7994e..703e782a13 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/AutofacRhinoModule.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/AutofacRhinoModule.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using Autofac; using Microsoft.Extensions.Logging; using Rhino.Commands; diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/RhinoPlugin.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/RhinoPlugin.cs index 7c5a9c63cb..272816a3cc 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/RhinoPlugin.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/RhinoPlugin.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; using Rhino; -using Speckle.Connectors.DUI.Bindings; using Speckle.Connectors.Rhino7.HostApp; using Speckle.Connectors.Rhino7.Interfaces; using Speckle.Connectors.Rhino7.Plugin; diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/RhinoSettings.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/RhinoSettings.cs index 61c310a2de..14a224a60d 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/RhinoSettings.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/RhinoSettings.cs @@ -1,4 +1,5 @@ -using System.IO; +using System.Collections.Generic; +using System.IO; using Speckle.Core.Kits; namespace Speckle.Connectors.Rhino7.HostApp; @@ -15,5 +16,5 @@ public RhinoSettings(HostApplication hostAppInfo, HostAppVersion hostAppVersion) public HostApplication HostAppInfo { get; private set; } public HostAppVersion HostAppVersion { get; private set; } - public string[] Modules { get; private set; } + public IReadOnlyList Modules { get; private set; } } diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/SpeckleRhinoPanel.xaml.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/SpeckleRhinoPanel.xaml.cs index cde06f8802..849cbfd0e6 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/SpeckleRhinoPanel.xaml.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/SpeckleRhinoPanel.xaml.cs @@ -4,7 +4,6 @@ using System.Windows.Threading; using Microsoft.Web.WebView2.Core; using Speckle.Connectors.DUI.Bindings; -using Speckle.Connectors.DUI.Bridge; using Speckle.Core.Logging; namespace Speckle.Connectors.Rhino7.HostApp; diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Plugin/Speckle.Connectors.Rhino7Plugin.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Plugin/Speckle.Connectors.Rhino7Plugin.cs index 9d0e3831e3..7c44725f2b 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Plugin/Speckle.Connectors.Rhino7Plugin.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Plugin/Speckle.Connectors.Rhino7Plugin.cs @@ -48,7 +48,7 @@ protected override LoadReturnCode OnLoad(ref string errorMessage) AppDomain.CurrentDomain.AssemblyResolve += OnAssemblyResolve; Container = new AutofacContainer(new StorageInfo()); - Container.PreBuildEvent += _container_PreBuildEvent; + Container.PreBuildEvent += ContainerPreBuildEvent; // Register Settings var rhinoSettings = new RhinoSettings(HostApplications.Rhino, HostAppVersion.v7); @@ -78,10 +78,10 @@ protected override void OnShutdown() base.OnShutdown(); } - private Assembly OnAssemblyResolve(object sender, ResolveEventArgs args) + private Assembly? OnAssemblyResolve(object sender, ResolveEventArgs args) { // POC: tight binding to files - Assembly assembly = null; + Assembly? assembly = null; string name = args.Name.Split(',')[0]; string path = Path.GetDirectoryName(typeof(SpeckleConnectorsRhino7Plugin).Assembly.Location); @@ -98,7 +98,7 @@ private Assembly OnAssemblyResolve(object sender, ResolveEventArgs args) return assembly; } - private void _container_PreBuildEvent(object sender, ContainerBuilder containerBuilder) + private void ContainerPreBuildEvent(object sender, ContainerBuilder containerBuilder) { containerBuilder.InjectNamedTypes(); } diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/IBridge.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/IBridge.cs index b4b1efdd75..4d7914dc5a 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/IBridge.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/IBridge.cs @@ -1,6 +1,5 @@ using System; using Speckle.Connectors.DUI.Bindings; -using Speckle.Newtonsoft.Json; namespace Speckle.Connectors.DUI.Bridge; diff --git a/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/Send.cs b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/Send.cs index 0cddcd797d..44e4cb21a6 100644 --- a/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/Send.cs +++ b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/Send.cs @@ -1,5 +1,4 @@ -#nullable enable -using System; +using System; using System.Collections.Concurrent; using System.Collections.Generic; using System.Diagnostics; From afb8b516fa5cce684cdc49aa68bc3fc668b69c26 Mon Sep 17 00:00:00 2001 From: Alan Rynne Date: Thu, 21 Mar 2024 14:41:43 +0100 Subject: [PATCH 011/261] POC: Rhino 7 DUI3/DI Connector using Modular converters and conversion context pattern (#3242) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: Initial prototype conversions. UNTESTED * IRawConversion Automatically finding and registering the IRawConversion<> for each IHostObjectToSpeckleConverter * feat: More converters + minor (non-breaking) tweaks in objects * fix: broken ref in Revit * feat(dui3): Working modular converters with DI and DUI3 🥳 * Riffing on ConversionContext Riffing on ConversionContext * feat: Brep conversion working with circular reference fix * Tidying merge Removed new objects files as we're using existing objects + some fixes * ConversionContext and stack Added to Rhino * feat: Updated all conversions to consume conversion context * fix: Missed some things that should come from context * fix: Formatting * fix: Fixed all warnings to get ✅🚀 * fix: Initialize unit converter as Single instance --------- Co-authored-by: Ian Hawley --- All.sln | 19 + DUI3-DX.slnf | 2 + .../Speckle.Connectors.Revit2023.csproj | 1 + .../Bindings/SendBinding.cs | 2 +- .../Plugin/RevitExternalApplication.cs | 9 +- .../Bindings/RhinoSendBinding.cs | 71 +-- .../DependencyInjection/AutofacRhinoModule.cs | 3 + .../Plugin/Speckle.Connectors.Rhino7Plugin.cs | 2 + .../Properties/launchSettings.json | 3 +- .../Speckle.Connectors.Rhino7.csproj | 15 +- .../RevitConverterToSpeckle.cs | 6 +- .../ToSpeckle/FloorConversionToSpeckle.cs | 6 +- .../AutofacRhinoConverterModule.cs | 14 +- ...nverters.Rhino7.DependencyInjection.csproj | 6 +- .../Geometry/ArcToSpeckleConverter.cs | 48 ++ .../Geometry/BoxToSpeckleConverter.cs | 40 ++ .../Geometry/BrepToSpeckleConverter.cs | 200 ++++++++ .../Geometry/CircleToSpeckleConverter.cs | 32 ++ .../ControlPointToSpeckleConverter.cs | 24 + .../Geometry/CurveToSpeckleConverter.cs | 96 ++++ .../Geometry/EllipseToSpeckleConverter.cs | 44 ++ .../Geometry/IntervalToSpeckleConverter.cs | 13 + .../Geometry/LineToSpeckleConverter.cs | 39 ++ .../Geometry/MeshToSpeckleConverter.cs | 63 +++ .../Geometry/NurbsCurveConverter.cs | 62 +++ .../NurbsSurfaceToSpeckleConverter.cs | 72 +++ .../Geometry/PlaneToSpeckleConverter.cs | 37 ++ .../Geometry/PointToSpeckleConverter.cs | 23 + .../Geometry/PolyCurveToSpeckleConverter.cs | 137 ++++++ .../Geometry/PolylineToSpeckleConverter.cs | 49 ++ .../Geometry/VectorToSpeckleConverter.cs | 22 + .../Speckle.Converters.Rhino7/GlobalUsings.cs | 3 + .../RhinoConversionContextStack.cs | 17 + .../RhinoConverterToSpeckle.cs | 43 +- .../RhinoToSpeckleUnitConverter.cs | 37 ++ .../Speckle.Converters.Rhino7.csproj | 7 +- .../BuiltElements/Floor.cs | 37 -- .../BuiltElements/Level.cs | 29 -- .../Common/EncodingOptimisations.cs | 103 ---- .../Common/IDisplayValue.cs | 26 - .../Speckle.Objects.Common/Geometry/Arc.cs | 294 ----------- .../Speckle.Objects.Common/Geometry/Box.cs | 77 --- .../Speckle.Objects.Common/Geometry/Circle.cs | 99 ---- .../Speckle.Objects.Common/Geometry/Curve.cs | 204 -------- .../Geometry/Ellipse.cs | 122 ----- .../Geometry/Interfaces.cs | 79 --- .../Speckle.Objects.Common/Geometry/Line.cs | 134 ----- .../Speckle.Objects.Common/Geometry/Mesh.cs | 254 ---------- .../Speckle.Objects.Common/Geometry/Plane.cs | 133 ----- .../Speckle.Objects.Common/Geometry/Point.cs | 242 --------- .../Geometry/Polycurve.cs | 167 ------- .../Geometry/Polyline.cs | 267 ---------- .../Speckle.Objects.Common/Geometry/Vector.cs | 261 ---------- .../Primitives/Interval.cs | 27 - .../Primitives/Interval2d.cs | 23 - .../Speckle.Objects.Common/Utils/Transform.cs | 464 ------------------ .../DependencyInjection/Factory.cs | 5 +- .../DependencyInjection/IFactory.cs | 2 +- .../NamedTypeInjector.cs | 45 +- ...nverters.Common.DependencyInjection.csproj | 18 + .../ContextWrapper.cs | 34 ++ .../ConversionContext.cs | 15 + .../ConversionContextStack.cs | 47 ++ .../IConversionContextStack.cs | 18 + .../IHostToSpeckleUnitConverter.cs | 6 + .../ISpeckleConverterToSpeckle.cs | 4 +- .../NameAndRankValueAttribute.cs | 8 +- .../Objects/IHostObjectToSpeckleConversion.cs | 4 +- .../Objects/IRawConversion.cs | 6 + .../Speckle.Converters.Common.csproj | 2 +- .../SpeckleConversionException.cs | 14 + 71 files changed, 1410 insertions(+), 3127 deletions(-) create mode 100644 DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Geometry/ArcToSpeckleConverter.cs create mode 100644 DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Geometry/BoxToSpeckleConverter.cs create mode 100644 DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Geometry/BrepToSpeckleConverter.cs create mode 100644 DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Geometry/CircleToSpeckleConverter.cs create mode 100644 DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Geometry/ControlPointToSpeckleConverter.cs create mode 100644 DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Geometry/CurveToSpeckleConverter.cs create mode 100644 DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Geometry/EllipseToSpeckleConverter.cs create mode 100644 DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Geometry/IntervalToSpeckleConverter.cs create mode 100644 DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Geometry/LineToSpeckleConverter.cs create mode 100644 DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Geometry/MeshToSpeckleConverter.cs create mode 100644 DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Geometry/NurbsCurveConverter.cs create mode 100644 DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Geometry/NurbsSurfaceToSpeckleConverter.cs create mode 100644 DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Geometry/PlaneToSpeckleConverter.cs create mode 100644 DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Geometry/PointToSpeckleConverter.cs create mode 100644 DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Geometry/PolyCurveToSpeckleConverter.cs create mode 100644 DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Geometry/PolylineToSpeckleConverter.cs create mode 100644 DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Geometry/VectorToSpeckleConverter.cs create mode 100644 DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/GlobalUsings.cs create mode 100644 DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/RhinoConversionContextStack.cs create mode 100644 DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/RhinoToSpeckleUnitConverter.cs delete mode 100644 DUI3-DX/Objects/Speckle.Objects.Common/BuiltElements/Floor.cs delete mode 100644 DUI3-DX/Objects/Speckle.Objects.Common/BuiltElements/Level.cs delete mode 100644 DUI3-DX/Objects/Speckle.Objects.Common/Common/EncodingOptimisations.cs delete mode 100644 DUI3-DX/Objects/Speckle.Objects.Common/Common/IDisplayValue.cs delete mode 100644 DUI3-DX/Objects/Speckle.Objects.Common/Geometry/Arc.cs delete mode 100644 DUI3-DX/Objects/Speckle.Objects.Common/Geometry/Box.cs delete mode 100644 DUI3-DX/Objects/Speckle.Objects.Common/Geometry/Circle.cs delete mode 100644 DUI3-DX/Objects/Speckle.Objects.Common/Geometry/Curve.cs delete mode 100644 DUI3-DX/Objects/Speckle.Objects.Common/Geometry/Ellipse.cs delete mode 100644 DUI3-DX/Objects/Speckle.Objects.Common/Geometry/Interfaces.cs delete mode 100644 DUI3-DX/Objects/Speckle.Objects.Common/Geometry/Line.cs delete mode 100644 DUI3-DX/Objects/Speckle.Objects.Common/Geometry/Mesh.cs delete mode 100644 DUI3-DX/Objects/Speckle.Objects.Common/Geometry/Plane.cs delete mode 100644 DUI3-DX/Objects/Speckle.Objects.Common/Geometry/Point.cs delete mode 100644 DUI3-DX/Objects/Speckle.Objects.Common/Geometry/Polycurve.cs delete mode 100644 DUI3-DX/Objects/Speckle.Objects.Common/Geometry/Polyline.cs delete mode 100644 DUI3-DX/Objects/Speckle.Objects.Common/Geometry/Vector.cs delete mode 100644 DUI3-DX/Objects/Speckle.Objects.Common/Primitives/Interval.cs delete mode 100644 DUI3-DX/Objects/Speckle.Objects.Common/Primitives/Interval2d.cs delete mode 100644 DUI3-DX/Objects/Speckle.Objects.Common/Utils/Transform.cs rename DUI3-DX/Sdk/{Speckle.Autofac/DependencyInjection => Speckle.Converters.Common.DependencyInjection}/NamedTypeInjector.cs (52%) create mode 100644 DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/Speckle.Converters.Common.DependencyInjection.csproj create mode 100644 DUI3-DX/Sdk/Speckle.Converters.Common/ContextWrapper.cs create mode 100644 DUI3-DX/Sdk/Speckle.Converters.Common/ConversionContext.cs create mode 100644 DUI3-DX/Sdk/Speckle.Converters.Common/ConversionContextStack.cs create mode 100644 DUI3-DX/Sdk/Speckle.Converters.Common/IConversionContextStack.cs create mode 100644 DUI3-DX/Sdk/Speckle.Converters.Common/IHostToSpeckleUnitConverter.cs rename DUI3-DX/Sdk/{Speckle.Autofac/DependencyInjection => Speckle.Converters.Common}/NameAndRankValueAttribute.cs (57%) create mode 100644 DUI3-DX/Sdk/Speckle.Converters.Common/Objects/IRawConversion.cs create mode 100644 DUI3-DX/Sdk/Speckle.Converters.Common/SpeckleConversionException.cs diff --git a/All.sln b/All.sln index 1a23a534b2..1c7cabd2ad 100644 --- a/All.sln +++ b/All.sln @@ -532,6 +532,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Speckle.Converters.Rhino7", EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Speckle.Converters.Rhino7.DependencyInjection", "DUI3-DX\Converters\Rhino\Speckle.Converters.Rhino7.DependencyInjection\Speckle.Converters.Rhino7.DependencyInjection.csproj", "{9C1ECA1D-DE98-4FB7-92D0-FC45BB308E5D}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Speckle.Converters.Common.DependencyInjection", "DUI3-DX\Sdk\Speckle.Converters.Common.DependencyInjection\Speckle.Converters.Common.DependencyInjection.csproj", "{11F7D41B-AFCA-4D29-BC08-285A14BF3A3B}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug Mac|Any CPU = Debug Mac|Any CPU @@ -2638,6 +2640,22 @@ Global {9C1ECA1D-DE98-4FB7-92D0-FC45BB308E5D}.Release|Any CPU.Build.0 = Release|Any CPU {9C1ECA1D-DE98-4FB7-92D0-FC45BB308E5D}.Release|x64.ActiveCfg = Release|Any CPU {9C1ECA1D-DE98-4FB7-92D0-FC45BB308E5D}.Release|x64.Build.0 = Release|Any CPU + {11F7D41B-AFCA-4D29-BC08-285A14BF3A3B}.Debug Mac|Any CPU.ActiveCfg = Debug|Any CPU + {11F7D41B-AFCA-4D29-BC08-285A14BF3A3B}.Debug Mac|Any CPU.Build.0 = Debug|Any CPU + {11F7D41B-AFCA-4D29-BC08-285A14BF3A3B}.Debug Mac|x64.ActiveCfg = Debug|Any CPU + {11F7D41B-AFCA-4D29-BC08-285A14BF3A3B}.Debug Mac|x64.Build.0 = Debug|Any CPU + {11F7D41B-AFCA-4D29-BC08-285A14BF3A3B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {11F7D41B-AFCA-4D29-BC08-285A14BF3A3B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {11F7D41B-AFCA-4D29-BC08-285A14BF3A3B}.Debug|x64.ActiveCfg = Debug|Any CPU + {11F7D41B-AFCA-4D29-BC08-285A14BF3A3B}.Debug|x64.Build.0 = Debug|Any CPU + {11F7D41B-AFCA-4D29-BC08-285A14BF3A3B}.Release Mac|Any CPU.ActiveCfg = Debug|Any CPU + {11F7D41B-AFCA-4D29-BC08-285A14BF3A3B}.Release Mac|Any CPU.Build.0 = Debug|Any CPU + {11F7D41B-AFCA-4D29-BC08-285A14BF3A3B}.Release Mac|x64.ActiveCfg = Debug|Any CPU + {11F7D41B-AFCA-4D29-BC08-285A14BF3A3B}.Release Mac|x64.Build.0 = Debug|Any CPU + {11F7D41B-AFCA-4D29-BC08-285A14BF3A3B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {11F7D41B-AFCA-4D29-BC08-285A14BF3A3B}.Release|Any CPU.Build.0 = Release|Any CPU + {11F7D41B-AFCA-4D29-BC08-285A14BF3A3B}.Release|x64.ActiveCfg = Release|Any CPU + {11F7D41B-AFCA-4D29-BC08-285A14BF3A3B}.Release|x64.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -2842,6 +2860,7 @@ Global {34C2C062-E43F-4FB5-B839-64BC044CCEF3} = {1FE3C60E-7865-40A5-9794-55ECB64F6489} {65A2F556-F14A-49F3-8A92-7F2E1E7ED3B5} = {34C2C062-E43F-4FB5-B839-64BC044CCEF3} {9C1ECA1D-DE98-4FB7-92D0-FC45BB308E5D} = {34C2C062-E43F-4FB5-B839-64BC044CCEF3} + {11F7D41B-AFCA-4D29-BC08-285A14BF3A3B} = {2E00592E-558D-492D-88F9-3ECEE4C0C7DA} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {1D43D91B-4F01-4A78-8250-CC6F9BD93A14} diff --git a/DUI3-DX.slnf b/DUI3-DX.slnf index dccc0fcfbc..ef95d0d660 100644 --- a/DUI3-DX.slnf +++ b/DUI3-DX.slnf @@ -20,7 +20,9 @@ "DUI3-DX\\Objects\\Speckle.Objects.Revit\\Speckle.Objects.Revit.csproj", "DUI3-DX\\Sdk\\Speckle.Autofac\\Speckle.Autofac.csproj", "DUI3-DX\\Sdk\\Speckle.Connectors.Utils\\Speckle.Connectors.Utils.csproj", + "DUI3-DX\\Sdk\\Speckle.Converters.Common.DependencyInjection\\Speckle.Converters.Common.DependencyInjection.csproj", "DUI3-DX\\Sdk\\Speckle.Converters.Common\\Speckle.Converters.Common.csproj", + "Objects\\Converters\\ConverterRhinoGh\\ConverterRhinoGhShared\\ConverterRhinoGhShared.shproj", "Objects\\Objects\\Objects.csproj", "Objects\\Tests\\Objects.Tests.Unit\\Objects.Tests.Unit.csproj" ] diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.Revit2023/Speckle.Connectors.Revit2023.csproj b/DUI3-DX/Connectors/Revit/Speckle.Connectors.Revit2023/Speckle.Connectors.Revit2023.csproj index 47c582a4eb..4e4ff963e6 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.Revit2023/Speckle.Connectors.Revit2023.csproj +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.Revit2023/Speckle.Connectors.Revit2023.csproj @@ -26,6 +26,7 @@ + diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SendBinding.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SendBinding.cs index 19ff2be6e7..af40fd9f3d 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SendBinding.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SendBinding.cs @@ -69,7 +69,7 @@ public void CancelSend(string modelCardId) private void HandleSend(string modelCardId) { - _speckleConverterToSpeckle.Convert(); + _speckleConverterToSpeckle.Convert(null); } private bool HandleSpeckleException(SpeckleException spex) diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitExternalApplication.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitExternalApplication.cs index 1232176e5a..b3f8488a54 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitExternalApplication.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitExternalApplication.cs @@ -5,6 +5,7 @@ using System.Reflection; using System.IO; using Autofac; +using Speckle.Converters.Common.DependencyInjection; using Speckle.Converters.Common.Objects; using Speckle.Core.Logging; @@ -48,17 +49,9 @@ public Result OnStartup(UIControlledApplication application) { // POC: not sure what this is doing... could be messing up our Aliasing???? AppDomain.CurrentDomain.AssemblyResolve += OnAssemblyResolve; - _container = new AutofacContainer(new StorageInfo()); - _container.PreBuildEvent += _container_PreBuildEvent; - // POC: re-instate, can this be done with some injected class? -#if REVIT2020 - // Panel.Browser.JavascriptObjectRepository.NameConverter = null; // not available in cef65, we need the below - BindingOptions bindingOptions = new () { CamelCaseJavascriptNames = false }; -#endif - // init DI _container .LoadAutofacModules(_revitSettings.ModuleFolders) diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSendBinding.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSendBinding.cs index e3baac5c38..da81252515 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSendBinding.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSendBinding.cs @@ -20,7 +20,6 @@ using Speckle.Connectors.Utils.Operations; using Speckle.Converters.Common; using Speckle.Core.Api; -using Speckle.Core.Kits; using Speckle.Core.Logging; using ICancelable = System.Reactive.Disposables.ICancelable; @@ -50,7 +49,8 @@ public sealed class RhinoSendBinding : ISendBinding, ICancelable /// /// Keeps track of previously converted objects as a dictionary of (applicationId, object reference). /// - private readonly Dictionary _convertedObjectReferences = new(); + /// POC: Commented out this for now, relates to change tracking feature + // private readonly Dictionary _convertedObjectReferences = new(); public RhinoSendBinding( DocumentModelStore store, @@ -177,17 +177,10 @@ public async void Send(string modelCardId) } // 4 - Get converter - ISpeckleConverter converter = KitManager - .GetDefaultKit() - .LoadConverter(_rhinoSettings.HostAppInfo.GetVersion(_rhinoSettings.HostAppVersion)); - converter.SetContextDocument(RhinoDoc.ActiveDoc); - // 5 - Convert objects - Base commitObject = ConvertObjects(rhinoObjects, converter, modelCard, cts); - - if (cts.IsCancellationRequested) - { - throw new OperationCanceledException(cts.Token); - } + + var commitObject = ConvertObjects(rhinoObjects, modelCard, cts.Token); + + cts.Token.ThrowIfCancellationRequested(); // 7 - Serialize and Send objects _basicConnectorBinding.Commands.SetModelProgress(modelCardId, new ModelCardProgress { Status = "Uploading..." }); @@ -196,12 +189,12 @@ public async void Send(string modelCardId) var sendResult = await SendHelper.Send(commitObject, transport, true, null, cts.Token).ConfigureAwait(true); // Store the converted references in memory for future send operations, overwriting the existing values for the given application id. - foreach (var kvp in sendResult.convertedReferences) - { - // TODO: Bug in here, we need to encapsulate cache not only by app id, but also by project id, - // TODO: as otherwise we assume incorrectly that an object exists for a given project (e.g, send box to project 1, send same unchanged box to project 2) - _convertedObjectReferences[kvp.Key + modelCard.ProjectId] = kvp.Value; - } + // foreach (var kvp in sendResult.convertedReferences) + // { + // // TODO: Bug in here, we need to encapsulate cache not only by app id, but also by project id, + // // TODO: as otherwise we assume incorrectly that an object exists for a given project (e.g, send box to project 1, send same unchanged box to project 2) + // _convertedObjectReferences[kvp.Key + modelCard.ProjectId] = kvp.Value; + // } // It's important to reset the model card's list of changed obj ids so as to ensure we accurately keep track of changes between send operations. // NOTE: ChangedObjectIds is currently JsonIgnored, but could actually be useful for highlighting changes in host app. //modelCard.ChangedObjectIds = new(); @@ -243,11 +236,12 @@ public async void Send(string modelCardId) private Base ConvertObjects( List rhinoObjects, - ISpeckleConverter converter, SenderModelCard modelCard, - CancellationTokenSource cts + CancellationToken cancellationToken ) { + ISpeckleConverterToSpeckle converter = _speckleConverterToSpeckleFactory.ResolveScopedInstance(); + var rootObjectCollection = new Collection { name = RhinoDoc.ActiveDoc.Name ?? "Unnamed document" }; int count = 0; @@ -255,10 +249,7 @@ CancellationTokenSource cts // TODO: Handle blocks. foreach (RhinoObject rhinoObject in rhinoObjects) { - if (cts.IsCancellationRequested) - { - throw new OperationCanceledException(cts.Token); - } + cancellationToken.ThrowIfCancellationRequested(); // 1. get object layer var layer = RhinoDoc.ActiveDoc.Layers[rhinoObject.Attributes.LayerIndex]; @@ -283,16 +274,28 @@ CancellationTokenSource cts converted = converter.ConvertToSpeckle(rhinoObject); converted.applicationId = applicationId; }*/ + try + { + var converted = converter.Convert(rhinoObject); + converted.applicationId = applicationId; - var converted = converter.ConvertToSpeckle(rhinoObject); - converted.applicationId = applicationId; - - // 4. add to host - collectionHost.elements.Add(converted); - _basicConnectorBinding.Commands.SetModelProgress( - modelCard.ModelCardId, - new ModelCardProgress { Status = "Converting", Progress = (double)++count / rhinoObjects.Count } - ); + // 4. add to host + collectionHost.elements.Add(converted); + _basicConnectorBinding.Commands.SetModelProgress( + modelCard.ModelCardId, + new ModelCardProgress { Status = "Converting", Progress = (double)++count / rhinoObjects.Count } + ); + } + catch (SpeckleConversionException e) + { + // DO something with the exception + Console.WriteLine(e); + } + catch (NotSupportedException e) + { + // DO something with the exception + Console.WriteLine(e); + } // NOTE: useful for testing ui states, pls keep for now so we can easily uncomment // Thread.Sleep(550); diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/AutofacRhinoModule.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/AutofacRhinoModule.cs index 703e782a13..3da5049631 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/AutofacRhinoModule.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/AutofacRhinoModule.cs @@ -1,6 +1,7 @@ using System; using Autofac; using Microsoft.Extensions.Logging; +using Rhino; using Rhino.Commands; using Rhino.PlugIns; using Serilog; @@ -14,6 +15,7 @@ using Speckle.Connectors.Rhino7.Interfaces; using Speckle.Connectors.Rhino7.Plugin; using Speckle.Converters.Common; +using Speckle.Converters.Rhino7; using Speckle.Newtonsoft.Json; using Speckle.Newtonsoft.Json.Serialization; @@ -45,6 +47,7 @@ protected override void Load(ContainerBuilder builder) builder.RegisterType().As().As().SingleInstance(); builder.RegisterType().As().SingleInstance(); builder.RegisterType().As().SingleInstance(); + builder.RegisterType().As>().SingleInstance(); // Register converter factory builder diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Plugin/Speckle.Connectors.Rhino7Plugin.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Plugin/Speckle.Connectors.Rhino7Plugin.cs index 7c44725f2b..515413ace0 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Plugin/Speckle.Connectors.Rhino7Plugin.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Plugin/Speckle.Connectors.Rhino7Plugin.cs @@ -1,4 +1,5 @@ using System; + using System.IO; using System.Reflection; using Autofac; @@ -8,6 +9,7 @@ using Speckle.Connectors.Rhino7.DependencyInjection; using Speckle.Connectors.Rhino7.HostApp; using Speckle.Connectors.Rhino7.Interfaces; +using Speckle.Converters.Common.DependencyInjection; using Speckle.Converters.Common.Objects; using Speckle.Core.Kits; using Speckle.Core.Logging; diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Properties/launchSettings.json b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Properties/launchSettings.json index 6f5a29e954..2594cdac28 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Properties/launchSettings.json +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Properties/launchSettings.json @@ -2,7 +2,8 @@ "profiles": { "Speckle.Connectors.Rhino7": { "commandName": "Executable", - "executablePath": "C:\\Program Files\\Rhino 7\\System\\Rhino.exe" + "executablePath": "C:\\Program Files\\Rhino 7\\System\\Rhino.exe", + "commandLineArgs": "$(TargetPath)" } } } diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Speckle.Connectors.Rhino7.csproj b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Speckle.Connectors.Rhino7.csproj index 36b1254e79..88c2374719 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Speckle.Connectors.Rhino7.csproj +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Speckle.Connectors.Rhino7.csproj @@ -1,4 +1,4 @@ - + net48 .rhp @@ -12,25 +12,22 @@ - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - + - + + - - + + diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/RevitConverterToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/RevitConverterToSpeckle.cs index 7cbd94c4a2..1c6a975165 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/RevitConverterToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/RevitConverterToSpeckle.cs @@ -2,6 +2,7 @@ using Speckle.Autofac.DependencyInjection; using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; +using Speckle.Core.Models; namespace Speckle.Converters.RevitShared; @@ -15,10 +16,11 @@ public RevitConverterToSpeckle(IFactory _toSpeckle = toSpeckle; } - public void Convert() + public Base Convert(object target) { var objectConverter = _toSpeckle.ResolveInstance(nameof(Floor)); - _ = -1; + return objectConverter?.Convert(target) + ?? throw new SpeckleConversionException("No converter or conversion returned null"); } } diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/FloorConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/FloorConversionToSpeckle.cs index b4a347e4dd..a22fb5034b 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/FloorConversionToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/FloorConversionToSpeckle.cs @@ -1,8 +1,8 @@ using Autodesk.Revit.DB; -using Speckle.Autofac.DependencyInjection; using Speckle.Converters.Common.Objects; +using Speckle.Core.Models; -namespace Speckle.Converters.Common.ToSpeckle; +namespace Speckle.Converters.Common; // POC: reminder - writing classes and creating interfaces is a bit like organising your space // if you have a structure for organising things, your interfaces, then finding your stuff, your classes & methods, becomes easy @@ -12,5 +12,5 @@ namespace Speckle.Converters.Common.ToSpeckle; [NameAndRankValue(nameof(Floor), 0)] public class FloorConversionToSpeckle : IHostObjectToSpeckleConversion { - public void Convert() => throw new System.NotImplementedException(); + public Base Convert(object target) => throw new System.NotImplementedException(); } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/AutofacRhinoConverterModule.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/AutofacRhinoConverterModule.cs index ae9a61ec70..3ea12f35fb 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/AutofacRhinoConverterModule.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/AutofacRhinoConverterModule.cs @@ -1,9 +1,8 @@ -// POC: not sure we should have this here as it attaches us to autofac, maybe a bit prematurely... - using Autofac; using Speckle.Autofac.DependencyInjection; using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; +using Rhino; namespace Speckle.Converters.Rhino7.DependencyInjection; @@ -11,8 +10,17 @@ public class AutofacRhinoConverterModule : Module { protected override void Load(ContainerBuilder builder) { + // POC: below comment maybe incorrect (sorry if I wrote that!) stateless services + // can be injected as Singleton(), only where we have state we wish to wrap in a unit of work + // should be InstancePerLifetimeScope // most things should be InstancePerLifetimeScope so we get one per operation - builder.RegisterType().As(); + builder.RegisterType().As().SingleInstance(); + + // single stack per conversion + builder + .RegisterType() + .As>() + .InstancePerLifetimeScope(); // factory for conversions builder diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/Speckle.Converters.Rhino7.DependencyInjection.csproj b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/Speckle.Converters.Rhino7.DependencyInjection.csproj index 0d104af798..b098e1e7c4 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/Speckle.Converters.Rhino7.DependencyInjection.csproj +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/Speckle.Converters.Rhino7.DependencyInjection.csproj @@ -1,7 +1,7 @@ - netstandard2.0 + net48 enable enable @@ -12,4 +12,8 @@ + + + + diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Geometry/ArcToSpeckleConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Geometry/ArcToSpeckleConverter.cs new file mode 100644 index 0000000000..d1da861e90 --- /dev/null +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Geometry/ArcToSpeckleConverter.cs @@ -0,0 +1,48 @@ +using Rhino; +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; +using Speckle.Core.Models; + +namespace Speckle.Converters.Rhino7.Geometry; + +[NameAndRankValue(nameof(RG.Arc), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +public class ArcToSpeckleConverter : IHostObjectToSpeckleConversion, IRawConversion +{ + private readonly IRawConversion _pointConverter; + private readonly IRawConversion _planeConverter; + private readonly IRawConversion _boxConverter; + private readonly IConversionContextStack _contextStack; + + public ArcToSpeckleConverter( + IRawConversion pointConverter, + IRawConversion planeConverter, + IRawConversion boxConverter, + IConversionContextStack contextStack + ) + { + _pointConverter = pointConverter; + _planeConverter = planeConverter; + _boxConverter = boxConverter; + _contextStack = contextStack; + } + + public Base Convert(object target) => RawConvert((RG.Arc)target); + + public SOG.Arc RawConvert(RG.Arc target) => + new( + _planeConverter.RawConvert(target.Plane), + target.Radius, + target.StartAngle, + target.EndAngle, + target.Angle, + _contextStack.Current.SpeckleUnits + ) + { + startPoint = _pointConverter.RawConvert(target.StartPoint), + midPoint = _pointConverter.RawConvert(target.MidPoint), + endPoint = _pointConverter.RawConvert(target.EndPoint), + domain = new SOP.Interval(0, 1), + length = target.Length, + bbox = _boxConverter.RawConvert(new RG.Box(target.BoundingBox())) + }; +} diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Geometry/BoxToSpeckleConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Geometry/BoxToSpeckleConverter.cs new file mode 100644 index 0000000000..d3bc116f10 --- /dev/null +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Geometry/BoxToSpeckleConverter.cs @@ -0,0 +1,40 @@ +using Rhino; +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; +using Speckle.Core.Models; + +namespace Speckle.Converters.Rhino7.Geometry; + +[NameAndRankValue(nameof(RG.Box), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +public class BoxToSpeckleConverter : IHostObjectToSpeckleConversion, IRawConversion +{ + private readonly IRawConversion _planeConverter; + private readonly IRawConversion _intervalConverter; + private readonly IConversionContextStack _contextStack; + + public BoxToSpeckleConverter( + IRawConversion planeConverter, + IRawConversion intervalConverter, + IConversionContextStack contextStack + ) + { + _planeConverter = planeConverter; + _intervalConverter = intervalConverter; + _contextStack = contextStack; + } + + public Base Convert(object target) => RawConvert((RG.Box)target); + + public SOG.Box RawConvert(RG.Box target) => + new( + _planeConverter.RawConvert(target.Plane), + _intervalConverter.RawConvert(target.X), + _intervalConverter.RawConvert(target.Y), + _intervalConverter.RawConvert(target.Z), + _contextStack.Current.SpeckleUnits + ) + { + area = target.Area, + volume = target.Volume + }; +} diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Geometry/BrepToSpeckleConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Geometry/BrepToSpeckleConverter.cs new file mode 100644 index 0000000000..56fd0e5b46 --- /dev/null +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Geometry/BrepToSpeckleConverter.cs @@ -0,0 +1,200 @@ +using Objects; +using Rhino; +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; +using Speckle.Core.Kits; +using Speckle.Core.Logging; +using Speckle.Core.Models; + +namespace Speckle.Converters.Rhino7.Geometry; + +[NameAndRankValue(nameof(RG.Brep), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +public class BrepToSpeckleConverter : IHostObjectToSpeckleConversion, IRawConversion +{ + private readonly IRawConversion _pointConverter; + private readonly IRawConversion _curveConverter; + private readonly IRawConversion _surfaceConverter; + private readonly IRawConversion _meshConverter; + private readonly IRawConversion _boxConverter; + private readonly IRawConversion _intervalConverter; + private readonly IConversionContextStack _contextStack; + + public BrepToSpeckleConverter( + IRawConversion pointConverter, + IRawConversion curveConverter, + IRawConversion surfaceConverter, + IRawConversion meshConverter, + IRawConversion boxConverter, + IRawConversion intervalConverter, + IConversionContextStack contextStack + ) + { + _pointConverter = pointConverter; + _curveConverter = curveConverter; + _surfaceConverter = surfaceConverter; + _meshConverter = meshConverter; + _boxConverter = boxConverter; + _intervalConverter = intervalConverter; + _contextStack = contextStack; + } + + public Base Convert(object target) => RawConvert((RG.Brep)target); + + public SOG.Brep RawConvert(RG.Brep target) + { + var tol = _contextStack.Current.Document.ModelAbsoluteTolerance; + target.Repair(tol); + + // POC: This should come as part of the user settings in the context object. + // if (PreprocessGeometry) + // { + // brep = BrepEncoder.ToRawBrep(brep, 1.0, Doc.ModelAngleToleranceRadians, Doc.ModelRelativeTolerance); + // } + + // get display mesh and attach render material to it if it exists + var displayMesh = GetBrepDisplayMesh(target); + var displayValue = new List(); + if (displayMesh != null) + { + displayValue.Add(_meshConverter.RawConvert(displayMesh)); + } + + // POC: Swap input material for something coming from the context. + // if (displayValue != null && mat != null) + // { + // displayValue["renderMaterial"] = mat; + // } + + // Vertices, uv curves, 3d curves and surfaces + var vertices = target.Vertices.Select(vertex => _pointConverter.RawConvert(vertex.Location)).ToList(); + var curves3d = target.Curves3D.Select(curve3d => _curveConverter.RawConvert(curve3d)).ToList(); + var surfaces = target.Surfaces.Select(srf => _surfaceConverter.RawConvert(srf.ToNurbsSurface())).ToList(); + + List curves2d; + using (_contextStack.Push(Units.None)) + { + // Curves2D are unitless, so we convert them within a new pushed context with None units. + curves2d = target.Curves2D.Select(curve2d => _curveConverter.RawConvert(curve2d)).ToList(); + } + + var speckleBrep = new SOG.Brep + { + Vertices = vertices, + Curve3D = curves3d, + Curve2D = curves2d, + Surfaces = surfaces, + displayValue = displayValue, + IsClosed = target.IsSolid, + Orientation = (SOG.BrepOrientation)target.SolidOrientation, + volume = target.IsSolid ? target.GetVolume() : 0, + area = target.GetArea(), + bbox = _boxConverter.RawConvert(new RG.Box(target.GetBoundingBox(false))), + units = _contextStack.Current.SpeckleUnits + }; + + // Brep non-geometry types + var faces = ConvertBrepFaces(target, speckleBrep); + var edges = ConvertBrepEdges(target, speckleBrep); + var loops = ConvertBrepLoops(target, speckleBrep); + var trims = ConvertBrepTrims(target, speckleBrep); + + return speckleBrep; + } + + private static List ConvertBrepFaces(RG.Brep brep, SOG.Brep speckleParent) => + brep.Faces + .Select( + f => + new SOG.BrepFace( + speckleParent, + f.SurfaceIndex, + f.Loops.Select(l => l.LoopIndex).ToList(), + f.OuterLoop.LoopIndex, + f.OrientationIsReversed + ) + ) + .ToList(); + + private List ConvertBrepEdges(RG.Brep brep, SOG.Brep speckleParent) => + brep.Edges + .Select( + edge => + new SOG.BrepEdge( + speckleParent, + edge.EdgeCurveIndex, + edge.TrimIndices(), + edge.StartVertex?.VertexIndex ?? -1, + edge.EndVertex?.VertexIndex ?? -1, + edge.ProxyCurveIsReversed, + _intervalConverter.RawConvert(edge.Domain) + ) + ) + .ToList(); + + private List ConvertBrepTrims(RG.Brep brep, SOG.Brep speckleParent) => + brep.Trims + .Select(trim => + { + var t = new SOG.BrepTrim( + speckleParent, + trim.Edge?.EdgeIndex ?? -1, + trim.Face.FaceIndex, + trim.Loop.LoopIndex, + trim.TrimCurveIndex, + (int)trim.IsoStatus, + (SOG.BrepTrimType)trim.TrimType, + trim.IsReversed(), + trim.StartVertex.VertexIndex, + trim.EndVertex.VertexIndex + ) + { + Domain = _intervalConverter.RawConvert(trim.Domain) + }; + + return t; + }) + .ToList(); + + private List ConvertBrepLoops(RG.Brep brep, SOG.Brep speckleParent) => + brep.Loops + .Select( + loop => + new SOG.BrepLoop( + speckleParent, + loop.Face.FaceIndex, + loop.Trims.Select(t => t.TrimIndex).ToList(), + (SOG.BrepLoopType)loop.LoopType + ) + ) + .ToList(); + + private RG.Mesh? GetBrepDisplayMesh(RG.Brep brep) + { + var joinedMesh = new RG.Mesh(); + + // get from settings + //Settings.TryGetValue("sendMeshSetting", out string meshSetting); + + RG.MeshingParameters mySettings = new(0.05, 0.05); + // switch (SelectedMeshSettings) + // { + // case MeshSettings.CurrentDoc: + // mySettings = RH.MeshingParameters.DocumentCurrentSetting(Doc); + // break; + // case MeshSettings.Default: + // default: + // mySettings = new RH.MeshingParameters(0.05, 0.05); + // break; + // } + + try + { + joinedMesh.Append(RG.Mesh.CreateFromBrep(brep, mySettings)); + return joinedMesh; + } + catch (Exception ex) when (!ex.IsFatal()) + { + return null; + } + } +} diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Geometry/CircleToSpeckleConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Geometry/CircleToSpeckleConverter.cs new file mode 100644 index 0000000000..8481810404 --- /dev/null +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Geometry/CircleToSpeckleConverter.cs @@ -0,0 +1,32 @@ +using Rhino; +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; +using Speckle.Core.Models; + +namespace Speckle.Converters.Rhino7.Geometry; + +[NameAndRankValue(nameof(RG.Circle), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +public class CircleToSpeckleConverter : IHostObjectToSpeckleConversion, IRawConversion +{ + private readonly IRawConversion _planeConverter; + private readonly IConversionContextStack _contextStack; + + public CircleToSpeckleConverter( + IRawConversion planeConverter, + IConversionContextStack contextStack + ) + { + _planeConverter = planeConverter; + _contextStack = contextStack; + } + + public Base Convert(object target) => RawConvert((RG.Circle)target); + + public SOG.Circle RawConvert(RG.Circle target) => + new(_planeConverter.RawConvert(target.Plane), target.Radius, _contextStack.Current.SpeckleUnits) + { + domain = new SOP.Interval(0, 1), + length = 2 * Math.PI * target.Radius, + area = Math.PI * Math.Pow(target.Radius, 2) + }; +} diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Geometry/ControlPointToSpeckleConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Geometry/ControlPointToSpeckleConverter.cs new file mode 100644 index 0000000000..98d83e32ea --- /dev/null +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Geometry/ControlPointToSpeckleConverter.cs @@ -0,0 +1,24 @@ +using Rhino; +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; +using Speckle.Core.Models; + +namespace Speckle.Converters.Rhino7.Geometry; + +[NameAndRankValue(nameof(RG.ControlPoint), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +public class ControlPointToSpeckleConverter + : IHostObjectToSpeckleConversion, + IRawConversion +{ + private readonly IConversionContextStack _contextStack; + + public ControlPointToSpeckleConverter(IConversionContextStack contextStack) + { + _contextStack = contextStack; + } + + public SOG.ControlPoint RawConvert(RG.ControlPoint target) => + new(target.Location.X, target.Location.Y, target.Location.Z, target.Weight, _contextStack.Current.SpeckleUnits); + + public Base Convert(object target) => RawConvert((RG.ControlPoint)target); +} diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Geometry/CurveToSpeckleConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Geometry/CurveToSpeckleConverter.cs new file mode 100644 index 0000000000..8cb2cc9171 --- /dev/null +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Geometry/CurveToSpeckleConverter.cs @@ -0,0 +1,96 @@ +using Objects; +using Rhino; +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; +using Speckle.Core.Models; + +namespace Speckle.Converters.Rhino7.Geometry; + +[NameAndRankValue(nameof(RG.Curve), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +public class CurveToSpeckleConverter : IHostObjectToSpeckleConversion, IRawConversion +{ + private readonly IRawConversion _polyCurveConverter; + private readonly IRawConversion _circleConverter; + private readonly IRawConversion _arcConverter; + private readonly IRawConversion _ellipseConverter; + private readonly IRawConversion _polylineConverter; + private readonly IRawConversion _nurbsCurveConverter; + private readonly IRawConversion _intervalConverter; + private readonly IConversionContextStack _contextStack; + + public CurveToSpeckleConverter( + IRawConversion polyCurveConverter, + IRawConversion circleConverter, + IRawConversion arcConverter, + IRawConversion ellipseConverter, + IRawConversion polylineConverter, + IRawConversion nurbsCurveConverter, + IRawConversion intervalConverter, + IConversionContextStack contextStack + ) + { + _polyCurveConverter = polyCurveConverter; + _circleConverter = circleConverter; + _arcConverter = arcConverter; + _ellipseConverter = ellipseConverter; + _polylineConverter = polylineConverter; + _nurbsCurveConverter = nurbsCurveConverter; + _intervalConverter = intervalConverter; + _contextStack = contextStack; + } + + public Base Convert(object target) => (Base)RawConvert((RG.Curve)target); // POC: ICurve and Base are not related so we need to cast here. + + public ICurve RawConvert(RG.Curve target) + { + var tolerance = _contextStack.Current.Document.ModelAbsoluteTolerance; + + if (target is RG.PolyCurve polyCurve) + { + return _polyCurveConverter.RawConvert(polyCurve); + } + + if (target.IsCircle(tolerance) && target.IsClosed) + { + if (target.TryGetCircle(out var getObj, tolerance)) + { + var cir = _circleConverter.RawConvert(getObj); + cir.domain = _intervalConverter.RawConvert(target.Domain); + return cir; + } + } + + if (target.IsArc(tolerance)) + { + if (target.TryGetArc(out var getObj, tolerance)) + { + var arc = _arcConverter.RawConvert(getObj); + arc.domain = _intervalConverter.RawConvert(target.Domain); + return arc; + } + } + + if (target.IsEllipse(tolerance) && target.IsClosed) + { + target.TryGetPlane(out RG.Plane pln, tolerance); + if (target.TryGetEllipse(pln, out var getObj, tolerance)) + { + var ellipse = _ellipseConverter.RawConvert(getObj); + ellipse.domain = _intervalConverter.RawConvert(target.Domain); + return ellipse; + } + } + + if (target.IsLinear(tolerance) || target.IsPolyline()) + { + if (target.TryGetPolyline(out var getObj)) + { + var polyline = _polylineConverter.RawConvert(getObj); + polyline.domain = _intervalConverter.RawConvert(target.Domain); + return polyline; + } + } + + return _nurbsCurveConverter.RawConvert(target.ToNurbsCurve()); + } +} diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Geometry/EllipseToSpeckleConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Geometry/EllipseToSpeckleConverter.cs new file mode 100644 index 0000000000..33fb1d7243 --- /dev/null +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Geometry/EllipseToSpeckleConverter.cs @@ -0,0 +1,44 @@ +using Rhino; +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; +using Speckle.Core.Models; + +namespace Speckle.Converters.Rhino7.Geometry; + +[NameAndRankValue(nameof(RG.Ellipse), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +public class EllipseToSpeckleConverter : IHostObjectToSpeckleConversion, IRawConversion +{ + private readonly IRawConversion _planeConverter; + private readonly IRawConversion _boxConverter; + private readonly IConversionContextStack _contextStack; + + public EllipseToSpeckleConverter( + IRawConversion planeConverter, + IRawConversion boxConverter, + IConversionContextStack contextStack + ) + { + _planeConverter = planeConverter; + _boxConverter = boxConverter; + _contextStack = contextStack; + } + + public Base Convert(object target) => RawConvert((RG.Ellipse)target); + + public SOG.Ellipse RawConvert(RG.Ellipse target) + { + var nurbsCurve = target.ToNurbsCurve(); + return new( + _planeConverter.RawConvert(target.Plane), + target.Radius1, + target.Radius2, + _contextStack.Current.SpeckleUnits + ) + { + domain = new SOP.Interval(0, 1), + length = nurbsCurve.GetLength(), + area = Math.PI * target.Radius1 * target.Radius2, + bbox = _boxConverter.RawConvert(new RG.Box(nurbsCurve.GetBoundingBox(true))) + }; + } +} diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Geometry/IntervalToSpeckleConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Geometry/IntervalToSpeckleConverter.cs new file mode 100644 index 0000000000..4f32124367 --- /dev/null +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Geometry/IntervalToSpeckleConverter.cs @@ -0,0 +1,13 @@ +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; +using Speckle.Core.Models; + +namespace Speckle.Converters.Rhino7.Geometry; + +[NameAndRankValue(nameof(RG.Interval), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +public class IntervalToSpeckleConverter : IHostObjectToSpeckleConversion, IRawConversion +{ + public Base Convert(object target) => RawConvert((RG.Interval)target); + + public SOP.Interval RawConvert(RG.Interval target) => new(target.T0, target.T1); +} diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Geometry/LineToSpeckleConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Geometry/LineToSpeckleConverter.cs new file mode 100644 index 0000000000..bb412df60c --- /dev/null +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Geometry/LineToSpeckleConverter.cs @@ -0,0 +1,39 @@ +using Rhino; +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; +using Speckle.Core.Models; + +namespace Speckle.Converters.Rhino7.Geometry; + +[NameAndRankValue(nameof(RG.Line), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +public class LineToSpeckleConverter : IHostObjectToSpeckleConversion, IRawConversion +{ + private readonly IRawConversion _pointConverter; + private readonly IRawConversion _boxConverter; + private readonly IConversionContextStack _contextStack; + + public LineToSpeckleConverter( + IRawConversion pointConverter, + IRawConversion boxConverter, + IConversionContextStack contextStack + ) + { + _pointConverter = pointConverter; + _boxConverter = boxConverter; + _contextStack = contextStack; + } + + public Base Convert(object target) => RawConvert((RG.Line)target); + + public SOG.Line RawConvert(RG.Line target) => + new( + _pointConverter.RawConvert(target.From), + _pointConverter.RawConvert(target.To), + _contextStack.Current.SpeckleUnits + ) + { + length = target.Length, + domain = new SOP.Interval(0, target.Length), + bbox = _boxConverter.RawConvert(new RG.Box(target.BoundingBox)) + }; +} diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Geometry/MeshToSpeckleConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Geometry/MeshToSpeckleConverter.cs new file mode 100644 index 0000000000..9056c86f62 --- /dev/null +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Geometry/MeshToSpeckleConverter.cs @@ -0,0 +1,63 @@ +using Rhino; +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; +using Speckle.Core.Models; + +namespace Speckle.Converters.Rhino7.Geometry; + +[NameAndRankValue(nameof(RG.Mesh), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +public class MeshToSpeckleConverter : IHostObjectToSpeckleConversion, IRawConversion +{ + private readonly IRawConversion _pointConverter; + private readonly IRawConversion _boxConverter; + private readonly IConversionContextStack _contextStack; + + public MeshToSpeckleConverter( + IRawConversion pointConverter, + IRawConversion boxConverter, + IConversionContextStack contextStack + ) + { + _pointConverter = pointConverter; + _boxConverter = boxConverter; + _contextStack = contextStack; + } + + public Base Convert(object target) => RawConvert((RG.Mesh)target); + + public SOG.Mesh RawConvert(RG.Mesh target) + { + if (target.Vertices.Count == 0 || target.Faces.Count == 0) + { + throw new SpeckleConversionException("Cannot convert a mesh with 0 vertices/faces"); + } + + var vertexCoordinates = target.Vertices.ToPoint3dArray().SelectMany(pt => new[] { pt.X, pt.Y, pt.Z }).ToList(); + var faces = new List(); + + foreach (RG.MeshNgon polygon in target.GetNgonAndFacesEnumerable()) + { + var vertIndices = polygon.BoundaryVertexIndexList(); + int n = vertIndices.Length; + faces.Add(n); + faces.AddRange(vertIndices.Select(vertIndex => (int)vertIndex)); + } + + var textureCoordinates = new List(target.TextureCoordinates.Count * 2); + foreach (var textureCoord in target.TextureCoordinates) + { + textureCoordinates.Add(textureCoord.X); + textureCoordinates.Add(textureCoord.Y); + } + + var colors = target.VertexColors.Select(cl => cl.ToArgb()).ToList(); + var volume = target.IsClosed ? target.Volume() : 0; + var bbox = _boxConverter.RawConvert(new RG.Box(target.GetBoundingBox(true))); // POC: Why do we use accurate BBox? it's slower. + + return new SOG.Mesh(vertexCoordinates, faces, colors, textureCoordinates, _contextStack.Current.SpeckleUnits) + { + volume = volume, + bbox = bbox + }; + } +} diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Geometry/NurbsCurveConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Geometry/NurbsCurveConverter.cs new file mode 100644 index 0000000000..34c7af2b37 --- /dev/null +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Geometry/NurbsCurveConverter.cs @@ -0,0 +1,62 @@ +using Rhino; +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; +using Speckle.Core.Models; + +namespace Speckle.Converters.Rhino7.Geometry; + +[NameAndRankValue(nameof(RG.NurbsCurve), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +public class NurbsCurveConverter : IHostObjectToSpeckleConversion, IRawConversion +{ + private readonly IRawConversion _polylineConverter; + private readonly IRawConversion _intervalConverter; + private readonly IRawConversion _boxConverter; + private readonly IConversionContextStack _contextStack; + + public NurbsCurveConverter( + IRawConversion polylineConverter, + IRawConversion intervalConverter, + IRawConversion boxConverter, + IConversionContextStack contextStack + ) + { + _polylineConverter = polylineConverter; + _intervalConverter = intervalConverter; + _boxConverter = boxConverter; + _contextStack = contextStack; + } + + public Base Convert(object target) => RawConvert((RG.NurbsCurve)target); + + public SOG.Curve RawConvert(RG.NurbsCurve target) + { + target.ToPolyline(0, 1, 0, 0, 0, 0.1, 0, 0, true).TryGetPolyline(out var poly); + SOG.Polyline displayValue = _polylineConverter.RawConvert(poly); + + var nurbsCurve = target.ToNurbsCurve(); + + // increase knot multiplicity to (# control points + degree + 1) + // add extra knots at start & end because Rhino's knot multiplicity standard is (# control points + degree - 1) + var knots = nurbsCurve.Knots.ToList(); + knots.Insert(0, knots[0]); + knots.Insert(knots.Count - 1, knots[knots.Count - 1]); + + var myCurve = new SOG.Curve(displayValue, _contextStack.Current.SpeckleUnits) + { + weights = nurbsCurve.Points.Select(ctp => ctp.Weight).ToList(), + points = nurbsCurve.Points + .SelectMany(ctp => new[] { ctp.Location.X, ctp.Location.Y, ctp.Location.Z, ctp.Weight }) + .ToList(), + knots = knots, + degree = nurbsCurve.Degree, + periodic = nurbsCurve.IsPeriodic, + rational = nurbsCurve.IsRational, + domain = _intervalConverter.RawConvert(nurbsCurve.Domain), + closed = nurbsCurve.IsClosed, + length = nurbsCurve.GetLength(), + bbox = _boxConverter.RawConvert(new RG.Box(nurbsCurve.GetBoundingBox(true))) + }; + + return myCurve; + } +} diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Geometry/NurbsSurfaceToSpeckleConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Geometry/NurbsSurfaceToSpeckleConverter.cs new file mode 100644 index 0000000000..6d13308f96 --- /dev/null +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Geometry/NurbsSurfaceToSpeckleConverter.cs @@ -0,0 +1,72 @@ +using Rhino; +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; +using Speckle.Core.Models; + +namespace Speckle.Converters.Rhino7.Geometry; + +[NameAndRankValue(nameof(RG.NurbsSurface), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +public class NurbsSurfaceToSpeckleConverter + : IHostObjectToSpeckleConversion, + IRawConversion +{ + private readonly IRawConversion _boxConverter; + private readonly IRawConversion _intervalConverter; + private readonly IRawConversion _controlPointConverter; + private readonly IConversionContextStack _contextStack; + + public NurbsSurfaceToSpeckleConverter( + IRawConversion boxConverter, + IRawConversion intervalConverter, + IRawConversion controlPointConverter, + IConversionContextStack contextStack + ) + { + _boxConverter = boxConverter; + _intervalConverter = intervalConverter; + _controlPointConverter = controlPointConverter; + _contextStack = contextStack; + } + + public Base Convert(object target) => RawConvert((RG.NurbsSurface)target); + + public SOG.Surface RawConvert(RG.NurbsSurface target) + { + var result = new SOG.Surface + { + degreeU = target.OrderU - 1, + degreeV = target.OrderV - 1, + rational = target.IsRational, + closedU = target.IsClosed(0), + closedV = target.IsClosed(1), + domainU = _intervalConverter.RawConvert(target.Domain(0)), + domainV = _intervalConverter.RawConvert(target.Domain(1)), + knotsU = target.KnotsU.ToList(), + knotsV = target.KnotsV.ToList(), + units = _contextStack.Current.SpeckleUnits, + bbox = _boxConverter.RawConvert(new RG.Box(target.GetBoundingBox(true))) + }; + + result.SetControlPoints(ControlPointsToSpeckle(target.Points)); + + return result; + } + + public List> ControlPointsToSpeckle(RG.Collections.NurbsSurfacePointList controlPoints) + { + var points = new List>(); + for (var i = 0; i < controlPoints.CountU; i++) + { + var row = new List(); + for (var j = 0; j < controlPoints.CountV; j++) + { + var pt = controlPoints.GetControlPoint(i, j); + row.Add(_controlPointConverter.RawConvert(pt)); + } + + points.Add(row); + } + + return points; + } +} diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Geometry/PlaneToSpeckleConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Geometry/PlaneToSpeckleConverter.cs new file mode 100644 index 0000000000..92f40b38f9 --- /dev/null +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Geometry/PlaneToSpeckleConverter.cs @@ -0,0 +1,37 @@ +using Rhino; +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; +using Speckle.Core.Models; + +namespace Speckle.Converters.Rhino7.Geometry; + +// POC: not sure I like the place of the default rank +[NameAndRankValue(nameof(Rhino.Geometry.Plane), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +public class PlaneToSpeckleConverter : IHostObjectToSpeckleConversion, IRawConversion +{ + private readonly IRawConversion _vectorConverter; + private readonly IRawConversion _pointConverter; + private readonly IConversionContextStack _contextStack; + + public PlaneToSpeckleConverter( + IRawConversion vectorConverter, + IRawConversion pointConverter, + IConversionContextStack contextStack + ) + { + _vectorConverter = vectorConverter; + _pointConverter = pointConverter; + _contextStack = contextStack; + } + + public Base Convert(object target) => RawConvert((RG.Plane)target); + + public SOG.Plane RawConvert(RG.Plane target) => + new( + _pointConverter.RawConvert(target.Origin), + _vectorConverter.RawConvert(target.ZAxis), + _vectorConverter.RawConvert(target.XAxis), + _vectorConverter.RawConvert(target.YAxis), + _contextStack.Current.SpeckleUnits + ); +} diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Geometry/PointToSpeckleConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Geometry/PointToSpeckleConverter.cs new file mode 100644 index 0000000000..3ef512e84b --- /dev/null +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Geometry/PointToSpeckleConverter.cs @@ -0,0 +1,23 @@ +using Rhino; +using Speckle.Converters.Common.Objects; +using Speckle.Converters.Common; +using Speckle.Core.Models; + +namespace Speckle.Converters.Rhino7.Geometry; + +// POC: not sure I like the place of the default rank +[NameAndRankValue(nameof(RG.Point3d), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +public class PointToSpeckleConverter : IHostObjectToSpeckleConversion, IRawConversion +{ + private readonly IConversionContextStack _contextStack; + + public PointToSpeckleConverter(IConversionContextStack contextStack) + { + _contextStack = contextStack; + } + + public Base Convert(object target) => RawConvert((RG.Point3d)target); + + public SOG.Point RawConvert(RG.Point3d target) => + new(target.X, target.Y, target.Z, _contextStack.Current.SpeckleUnits); +} diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Geometry/PolyCurveToSpeckleConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Geometry/PolyCurveToSpeckleConverter.cs new file mode 100644 index 0000000000..2670553a53 --- /dev/null +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Geometry/PolyCurveToSpeckleConverter.cs @@ -0,0 +1,137 @@ +using Objects; +using Rhino; +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; +using Speckle.Core.Models; + +namespace Speckle.Converters.Rhino7.Geometry; + +[NameAndRankValue(nameof(RG.PolyCurve), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +public class PolyCurveToSpeckleConverter : IHostObjectToSpeckleConversion, IRawConversion +{ + public IRawConversion CurveConverter { get; set; } // This created a circular dependency on the constructor, making it a property allows for the container to resolve it correctly + private readonly IRawConversion _intervalConverter; + private readonly IRawConversion _boxConverter; + private readonly IConversionContextStack _contextStack; + + public PolyCurveToSpeckleConverter( + IRawConversion intervalConverter, + IRawConversion boxConverter, + IConversionContextStack contextStack + ) + { + _intervalConverter = intervalConverter; + _boxConverter = boxConverter; + _contextStack = contextStack; + } + + public Base Convert(object target) => RawConvert((RG.PolyCurve)target); + + public SOG.Polycurve RawConvert(RG.PolyCurve target) + { + var segments = new List(); + CurveSegments(segments, target, true); + + var myPoly = new SOG.Polycurve + { + closed = target.IsClosed, + domain = _intervalConverter.RawConvert(target.Domain), + length = target.GetLength(), + bbox = _boxConverter.RawConvert(new RG.Box(target.GetBoundingBox(true))), + segments = segments.Select(CurveConverter.RawConvert).ToList(), + units = _contextStack.Current.SpeckleUnits + }; + return myPoly; + } + + // Proper explosion of polycurves: + // (C) The Rutten David https://www.grasshopper3d.com/forum/topics/explode-closed-planar-curve-using-rhinocommon + private bool CurveSegments(List curveList, RG.Curve crv, bool recursive) + { + if (crv == null) + { + return false; + } + + if (crv is RG.PolyCurve polyCurve) + { + if (recursive) + { + polyCurve.RemoveNesting(); + } + + RG.Curve[] segments = polyCurve.Explode(); + + if (segments == null) + { + return false; + } + + if (segments.Length == 0) + { + return false; + } + + if (recursive) + { + foreach (RG.Curve s in segments) + { + CurveSegments(curveList, s, recursive); + } + } + else + { + foreach (RG.Curve s in segments) + { + var dup = (RG.Curve)s.DuplicateShallow(); + curveList.Add(dup); + } + } + + return true; + } + + //Nothing else worked, lets assume it's a nurbs curve and go from there... + var nurbs = crv.ToNurbsCurve(); + if (nurbs == null) + { + return false; + } + + double t0 = nurbs.Domain.Min; + double t1 = nurbs.Domain.Max; + + int ln = curveList.Count; + + do + { + if (!nurbs.GetNextDiscontinuity(RG.Continuity.C1_locus_continuous, t0, t1, out double t)) + { + break; + } + + var trim = new RG.Interval(t0, t); + if (trim.Length < 1e-10) + { + t0 = t; + continue; + } + + var m = nurbs.DuplicateCurve(); + m = m.Trim(trim); + if (m.IsValid) + { + curveList.Add(m); + } + + t0 = t; + } while (true); + + if (curveList.Count == ln) + { + curveList.Add(nurbs); + } + + return true; + } +} diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Geometry/PolylineToSpeckleConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Geometry/PolylineToSpeckleConverter.cs new file mode 100644 index 0000000000..bcdba2faa8 --- /dev/null +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Geometry/PolylineToSpeckleConverter.cs @@ -0,0 +1,49 @@ +using Rhino; +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; +using Speckle.Core.Models; + +namespace Speckle.Converters.Rhino7.Geometry; + +[NameAndRankValue(nameof(RG.Polyline), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +public class PolylineToSpeckleConverter : IHostObjectToSpeckleConversion, IRawConversion +{ + private readonly IRawConversion _pointConverter; + private readonly IRawConversion _boxConverter; + private readonly IConversionContextStack _contextStack; + + public PolylineToSpeckleConverter( + IRawConversion pointConverter, + IRawConversion boxConverter, + IConversionContextStack contextStack + ) + { + _pointConverter = pointConverter; + _boxConverter = boxConverter; + _contextStack = contextStack; + } + + public Base Convert(object target) => RawConvert((RG.Polyline)target); + + public SOG.Polyline RawConvert(RG.Polyline target) + { + // POC: Original polyline conversion had a domain as input, as well as the side-effect of returning a `Line` if the polyline had 2 points only. + + var box = _boxConverter.RawConvert(new RG.Box(target.BoundingBox)); + var points = target.Select(pt => _pointConverter.RawConvert(pt)).ToList(); + + if (target.IsClosed) + { + points.RemoveAt(points.Count - 1); + } + + return new SOG.Polyline( + points.SelectMany(pt => new[] { pt.x, pt.y, pt.z }).ToList(), + _contextStack.Current.SpeckleUnits + ) + { + bbox = box, + length = target.Length + }; + } +} diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Geometry/VectorToSpeckleConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Geometry/VectorToSpeckleConverter.cs new file mode 100644 index 0000000000..9db6fb87cc --- /dev/null +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Geometry/VectorToSpeckleConverter.cs @@ -0,0 +1,22 @@ +using Rhino; +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; +using Speckle.Core.Kits; +using Speckle.Core.Models; + +namespace Speckle.Converters.Rhino7.Geometry; + +[Common.NameAndRankValue(nameof(RG.Vector3d), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +public class VectorToSpeckleConverter : IHostObjectToSpeckleConversion, IRawConversion +{ + private readonly IConversionContextStack _contextStack; + + public VectorToSpeckleConverter(IConversionContextStack contextStack) + { + _contextStack = contextStack; + } + + public Base Convert(object target) => RawConvert((RG.Vector3d)target); + + public SOG.Vector RawConvert(RG.Vector3d target) => new(target.X, target.Y, target.Z, Units.Meters); +} diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/GlobalUsings.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/GlobalUsings.cs new file mode 100644 index 0000000000..baa44c188e --- /dev/null +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/GlobalUsings.cs @@ -0,0 +1,3 @@ +global using RG = Rhino.Geometry; +global using SOG = Objects.Geometry; +global using SOP = Objects.Primitive; diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/RhinoConversionContextStack.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/RhinoConversionContextStack.cs new file mode 100644 index 0000000000..081332e022 --- /dev/null +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/RhinoConversionContextStack.cs @@ -0,0 +1,17 @@ +using System.Diagnostics.CodeAnalysis; +using Rhino; +using Speckle.Converters.Common; + +namespace Speckle.Converters.Rhino7; + +// POC: Suppressed naming warning for now, but we should evaluate if we should follow this or disable it. +[SuppressMessage( + "Naming", + "CA1711:Identifiers should not have incorrect suffix", + Justification = "Name ends in Stack but it is in fact a Stack, just not inheriting from `System.Collections.Stack`" +)] +public class RhinoConversionContextStack : ConversionContextStack +{ + public RhinoConversionContextStack(IHostToSpeckleUnitConverter unitConverter) + : base(RhinoDoc.ActiveDoc, RhinoDoc.ActiveDoc.ModelUnitSystem, unitConverter) { } +} diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/RhinoConverterToSpeckle.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/RhinoConverterToSpeckle.cs index fa86361fc0..16620086ea 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/RhinoConverterToSpeckle.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/RhinoConverterToSpeckle.cs @@ -1,23 +1,54 @@ -using Speckle.Autofac.DependencyInjection; +using Rhino; +using Rhino.DocObjects; +using Speckle.Autofac.DependencyInjection; using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; -using Speckle.Objects.Geometry; +using Speckle.Core.Models; namespace Speckle.Converters.Rhino7; public class RhinoConverterToSpeckle : ISpeckleConverterToSpeckle { private readonly IFactory _toSpeckle; + private readonly IHostToSpeckleUnitConverter _unitConverter; - public RhinoConverterToSpeckle(IFactory toSpeckle) + public RhinoConverterToSpeckle( + IFactory toSpeckle, + IHostToSpeckleUnitConverter unitConverter + ) { _toSpeckle = toSpeckle; + _unitConverter = unitConverter; } - public void Convert() + public Base Convert(object target) { - var objectConverter = _toSpeckle.ResolveInstance(nameof(Point)); + if (target is not RhinoObject rhinoObject) + { + throw new NotSupportedException( + $"Conversion of {target.GetType().Name} to Speckle is not supported. Only objects that inherit from RhinoObject are." + ); + } - Console.WriteLine(objectConverter); + Type type = rhinoObject.Geometry.GetType(); + + try + { + var objectConverter = _toSpeckle.ResolveInstance(type.Name); + + if (objectConverter == null) + { + throw new NotSupportedException($"No conversion found for {target.GetType().Name}"); + } + + var convertedObject = objectConverter.Convert(rhinoObject.Geometry); + + return convertedObject; + } + catch (SpeckleConversionException e) + { + Console.WriteLine(e); + throw; // Just rethrowing for now, Logs may be needed here. + } } } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/RhinoToSpeckleUnitConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/RhinoToSpeckleUnitConverter.cs new file mode 100644 index 0000000000..6af3c49551 --- /dev/null +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/RhinoToSpeckleUnitConverter.cs @@ -0,0 +1,37 @@ +using Rhino; +using Speckle.Converters.Common; +using Speckle.Core.Kits; +using Speckle.Core.Logging; // POC: boy do I think this is the wrong place for SpeckleException! + +namespace Speckle.Converters.Rhino7; + +public class RhinoToSpeckleUnitConverter : IHostToSpeckleUnitConverter +{ + private readonly Dictionary _unitMapping = new(); + + public RhinoToSpeckleUnitConverter() + { + // POC: we should have a unit test to confirm these are as expected and don't change + _unitMapping[UnitSystem.None] = Units.Meters; + _unitMapping[UnitSystem.Millimeters] = Units.Millimeters; + _unitMapping[UnitSystem.Centimeters] = Units.Centimeters; + _unitMapping[UnitSystem.Meters] = Units.Meters; + _unitMapping[UnitSystem.Kilometers] = Units.Kilometers; + _unitMapping[UnitSystem.Inches] = Units.Inches; + _unitMapping[UnitSystem.Feet] = Units.Feet; + _unitMapping[UnitSystem.Yards] = Units.Yards; + _unitMapping[UnitSystem.Miles] = Units.Miles; + _unitMapping[UnitSystem.Unset] = Units.Meters; + } + + public string ConvertOrThrow(UnitSystem hostUnit) + { + if (_unitMapping.TryGetValue(hostUnit, out string value)) + { + return value; + } + + // POC: probably would prefer something more specific + throw new SpeckleException($"The Unit System \"{hostUnit}\" is unsupported."); + } +} diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Speckle.Converters.Rhino7.csproj b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Speckle.Converters.Rhino7.csproj index 4c9e81bcbf..b0b071e7ae 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Speckle.Converters.Rhino7.csproj +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Speckle.Converters.Rhino7.csproj @@ -1,12 +1,15 @@ - netstandard2.0 + net48 enable enable - + + + + diff --git a/DUI3-DX/Objects/Speckle.Objects.Common/BuiltElements/Floor.cs b/DUI3-DX/Objects/Speckle.Objects.Common/BuiltElements/Floor.cs deleted file mode 100644 index d322d3c5aa..0000000000 --- a/DUI3-DX/Objects/Speckle.Objects.Common/BuiltElements/Floor.cs +++ /dev/null @@ -1,37 +0,0 @@ -using System.Collections.Generic; -using Speckle.Core.Kits; -using Speckle.Core.Models; -using Speckle.Objects.Common; -using Speckle.Objects.Geometry; - -namespace Speckle.Objects.BuiltElements; - -public class Floor : Base, IDisplayValue> -{ - public Floor() { } - - [SchemaInfo("Floor", "Creates a Speckle floor", "BIM", "Architecture")] - public Floor( - [SchemaMainParam] ICurve outline, - List? voids = null, - [SchemaParamInfo("Any nested elements that this floor might have")] List? elements = null - ) - { - this.outline = outline; - - this.voids = voids ?? new(); - - this.elements = elements; - } - - public ICurve outline { get; set; } - public List voids { get; set; } = new(); - - [DetachProperty] - public List? elements { get; set; } - public virtual Level? level { get; internal set; } - public string units { get; set; } - - [DetachProperty] - public List displayValue { get; set; } -} diff --git a/DUI3-DX/Objects/Speckle.Objects.Common/BuiltElements/Level.cs b/DUI3-DX/Objects/Speckle.Objects.Common/BuiltElements/Level.cs deleted file mode 100644 index d96a7d488a..0000000000 --- a/DUI3-DX/Objects/Speckle.Objects.Common/BuiltElements/Level.cs +++ /dev/null @@ -1,29 +0,0 @@ -using Speckle.Core.Kits; -using Speckle.Core.Models; - -namespace Speckle.Objects.BuiltElements; - -public class Level : Base -{ - //public List elements { get; set; } - - public Level() { } - - /// - /// SchemaBuilder constructor for a Speckle level - /// - /// - /// - /// Assign units when using this constructor due to param - [SchemaInfo("Level", "Creates a Speckle level", "BIM", "Architecture")] - public Level(string name, double elevation) - { - this.name = name; - this.elevation = elevation; - } - - public string name { get; set; } - public double elevation { get; set; } - - public string units { get; set; } -} diff --git a/DUI3-DX/Objects/Speckle.Objects.Common/Common/EncodingOptimisations.cs b/DUI3-DX/Objects/Speckle.Objects.Common/Common/EncodingOptimisations.cs deleted file mode 100644 index 72d6e10caa..0000000000 --- a/DUI3-DX/Objects/Speckle.Objects.Common/Common/EncodingOptimisations.cs +++ /dev/null @@ -1,103 +0,0 @@ -using System; -using System.Collections.Generic; -using Speckle.Objects.Geometry; - -namespace Speckle.Objects.Common; - -public static class CurveTypeEncoding -{ - public const double Arc = 0; - public const double Circle = 1; - public const double Curve = 2; - public const double Ellipse = 3; - public const double Line = 4; - public const double Polyline = 5; - public const double PolyCurve = 6; -} - -public static class CurveArrayEncodingExtensions -{ - public static List ToArray(List curves) - { - // POC: eek - var list = new List(); - foreach (var curve in curves) - { - switch (curve) - { - case Arc a: - list.AddRange(a.ToList()); - break; - case Circle c: - list.AddRange(c.ToList()); - break; - case Curve c: - list.AddRange(c.ToList()); - break; - case Ellipse e: - list.AddRange(e.ToList()); - break; - case Line l: - list.AddRange(l.ToList()); - break; - case Polycurve p: - list.AddRange(p.ToList()); - break; - case Polyline p: - list.AddRange(p.ToList()); - break; - default: - throw new Exception($"Unkown curve type: {curve.GetType()}."); - } - } - - return list; - } - - public static List FromArray(List list) - { - var curves = new List(); - if (list.Count == 0) - { - return curves; - } - - var done = false; - var currentIndex = 0; - - while (!done) - { - var itemLength = (int)list[currentIndex]; - var item = list.GetRange(currentIndex, itemLength + 1); - - switch (item[1]) - { - case CurveTypeEncoding.Arc: - curves.Add(Arc.FromList(item)); - break; - case CurveTypeEncoding.Circle: - curves.Add(Circle.FromList(item)); - break; - case CurveTypeEncoding.Curve: - curves.Add(Curve.FromList(item)); - break; - case CurveTypeEncoding.Ellipse: - curves.Add(Ellipse.FromList(item)); - break; - case CurveTypeEncoding.Line: - curves.Add(Line.FromList(item)); - break; - case CurveTypeEncoding.Polyline: - curves.Add(Polyline.FromList(item)); - break; - case CurveTypeEncoding.PolyCurve: - curves.Add(Polycurve.FromList(item)); - break; - } - - currentIndex += itemLength + 1; - done = currentIndex >= list.Count; - } - return curves; - } -} diff --git a/DUI3-DX/Objects/Speckle.Objects.Common/Common/IDisplayValue.cs b/DUI3-DX/Objects/Speckle.Objects.Common/Common/IDisplayValue.cs deleted file mode 100644 index c25a36193d..0000000000 --- a/DUI3-DX/Objects/Speckle.Objects.Common/Common/IDisplayValue.cs +++ /dev/null @@ -1,26 +0,0 @@ -namespace Speckle.Objects.Common; - -// POC: still accurate? -/// -/// Specifies displayable value(s) to be used as a fallback -/// if a displayable form cannot be converted. -/// -/// -/// objects that represent conceptual / abstract / mathematically derived geometry -/// can use to be used in case the object lacks a natively displayable form. -/// (e.g , , ) -/// -/// -/// Type of display value. -/// Expected to be either a type or a of s, -/// most likely or . -/// -public interface IDisplayValue -{ - /// - /// (s) will be used to display this - /// if a native displayable object cannot be converted. - /// - // POC: Pascal case? Is this for JS benefit? - T displayValue { get; set; } -} diff --git a/DUI3-DX/Objects/Speckle.Objects.Common/Geometry/Arc.cs b/DUI3-DX/Objects/Speckle.Objects.Common/Geometry/Arc.cs deleted file mode 100644 index 3f35f41ff2..0000000000 --- a/DUI3-DX/Objects/Speckle.Objects.Common/Geometry/Arc.cs +++ /dev/null @@ -1,294 +0,0 @@ -using System; -using System.Collections.Generic; -using Speckle.Core.Kits; -using Speckle.Core.Logging; -using Speckle.Core.Models; -using Speckle.Objects.Common; -using Speckle.Objects.Primitives; -using Speckle.Objects.Utils; - -namespace Speckle.Objects.Geometry; - -/// -/// Represents a sub-curve of a three-dimensional circle. -/// -public class Arc : Base, IHasBoundingBox, ICurve, IHasArea, ITransformable -{ - /// - public Arc() { } - - /// - /// Constructs a new using angle values. - /// - /// The Plane where the arc will be drawn - /// The radius of the Arc - /// The angle formed between the start point and the X Axis of the plane - /// The angle formed between the end point and the X Axis of the plane - /// The total angle of the Arc in Radians - /// The object's units - /// The object's unique application ID - public Arc( - Plane plane, - double radius, - double startAngle, - double endAngle, - double angleRadians, - string units = Units.Meters, - string? applicationId = null - ) - { - this.plane = plane; - this.radius = radius; - this.startAngle = startAngle; - this.endAngle = endAngle; - this.angleRadians = angleRadians; - domain = angleRadians > 0 ? new Interval(0, angleRadians) : new Interval(angleRadians, 0); - this.applicationId = applicationId; - this.units = units; - } - - /// - /// Initialise an `Arc` using the arc angle and the start and end points. - /// The radius, midpoint, start angle, and end angle will be calculated. - /// For now, this assumes 2D arcs on the XY plane - /// - /// The start point of the arc - /// The end point of the arc - /// The arc angle - /// Units (defaults to "m") - /// ID given to the arc in the authoring programme (defaults to null) - public Arc( - Point startPoint, - Point endPoint, - double angleRadians, - string units = Units.Meters, - string? applicationId = null - ) - : this( - new Plane(startPoint, new Vector(0, 0, 1), new Vector(1, 0, 0), new Vector(0, 1, 0), units), - startPoint, - endPoint, - angleRadians, - units, - applicationId - ) { } - - /// - /// Initialise an `Arc` using a plane, the arc angle and the start and end points. - /// The radius, midpoint, start angle, and end angle will be calculated. - /// - /// The Plane where the arc will be drawn - /// The start point of the arc - /// The end point of the arc - /// The arc angle - /// Units (defaults to "m") - /// ID given to the arc in the authoring programme (defaults to null) - public Arc( - Plane plane, - Point startPoint, - Point endPoint, - double angleRadians, - string units = Units.Meters, - string? applicationId = null - ) - { - // don't be annoying - if (angleRadians > Math.PI * 2) - { - throw new SpeckleException("Can't create an arc with an angle greater than 2pi"); - } - - if (startPoint == endPoint) - { - throw new SpeckleException("Can't create an arc where the start and end points are the same"); - } - - this.units = units; - this.startPoint = startPoint; - this.endPoint = endPoint; - this.angleRadians = angleRadians; - domain = angleRadians > 0 ? new Interval(0, angleRadians) : new Interval(angleRadians, 0); - this.applicationId = applicationId; - - // find chord and chord angle which may differ from the arc angle - var chordMidpoint = Point.Midpoint(startPoint, endPoint); - var chordLength = Point.Distance(startPoint, endPoint); - var chordAngle = angleRadians; - if (chordAngle > Math.PI) - { - chordAngle -= Math.PI * 2; - } - else if (chordAngle < -Math.PI) - { - chordAngle += Math.PI * 2; - } - // use the law of cosines for an isosceles triangle to get the radius - radius = chordLength / Math.Sqrt(2 - 2 * Math.Cos(chordAngle)); - - // find the chord vector then calculate the perpendicular vector which points to the centre - // which can be used to find the circle centre point - var dir = chordAngle < 0 ? -1 : 1; - var centreToChord = Math.Sqrt(Math.Pow((double)radius, 2) - Math.Pow(chordLength * 0.5, 2)); - var perp = Vector.CrossProduct(new Vector(endPoint - startPoint), plane.normal); - var circleCentre = chordMidpoint + new Point(perp.Unit() * centreToChord * -dir); - plane.origin = circleCentre; - - // use the perpendicular vector in the other direction (from the centre to the arc) to find the arc midpoint - midPoint = - angleRadians > Math.PI - ? chordMidpoint + new Point(perp.Unit() * ((double)radius + centreToChord) * -dir) - : chordMidpoint + new Point(perp.Unit() * ((double)radius - centreToChord) * dir); - - // find the start angle using trig (correcting for quadrant position) and add the arc angle to get the end angle - startAngle = Math.Tan((startPoint.y - circleCentre.y) / (startPoint.x - circleCentre.x)) % (2 * Math.PI); - if (startPoint.x > circleCentre.x && startPoint.y < circleCentre.y) // Q4 - { - startAngle *= -1; - } - else if (startPoint.x < circleCentre.x && startPoint.y < circleCentre.y) // Q3 - { - startAngle += Math.PI; - } - else if (startPoint.x < circleCentre.x && startPoint.y > circleCentre.y) // Q2 - { - startAngle = Math.PI - startAngle; - } - - endAngle = startAngle + angleRadians; - // Set the plane of this arc - this.plane = plane; - } - - /// - /// The radius of the - /// - public double? radius { get; set; } - - /// - /// The start angle of the based on it's - /// - public double? startAngle { get; set; } - - /// - /// The end angle of the based on it's - /// - public double? endAngle { get; set; } - - /// - /// The inner angle of the - /// - public double angleRadians { get; set; } - - /// - /// Gets or sets the plane of the . The plane origin is the center. - /// - public Plane plane { get; set; } - - /// - /// The start of the - /// - public Point startPoint { get; set; } - - /// - /// Gets or sets the point at 0.5 length. - /// - public Point midPoint { get; set; } - - /// - /// The end of the - /// - public Point endPoint { get; set; } - - /// - /// The units this object was specified in. - /// - public string units { get; set; } - - /// - public Interval domain { get; set; } = new(0, 0); - - /// - public double length { get; set; } - - /// - public double area { get; set; } - - /// - public Box bbox { get; set; } - - /// - public bool TransformTo(Transform transform, out Arc transformed) - { - startPoint.TransformTo(transform, out Point transformedStartPoint); - midPoint.TransformTo(transform, out Point transformedMidpoint); - endPoint.TransformTo(transform, out Point transformedEndPoint); - plane.TransformTo(transform, out Plane pln); - var arc = new Arc(pln, transformedStartPoint, transformedEndPoint, angleRadians, units) - { - midPoint = transformedMidpoint, - domain = domain - }; - transformed = arc; - return true; - } - - /// - public bool TransformTo(Transform transform, out ITransformable transformed) - { - var res = TransformTo(transform, out Arc arc); - transformed = arc; - return res; - } - - /// - /// Creates a flat list with the values of the - /// This is only used for serialisation purposes. - /// - /// A list of numbers representing the 's value - public List ToList() - { - var list = new List(); - list.Add(radius ?? 0); - list.Add(startAngle ?? 0); - list.Add(endAngle ?? 0); - list.Add(angleRadians); - list.Add(domain?.start ?? 0); - list.Add(domain?.end ?? 0); - - list.AddRange(plane.ToList()); - list.AddRange(startPoint.ToList()); - list.AddRange(midPoint.ToList()); - list.AddRange(endPoint.ToList()); - list.Add(Units.GetEncodingFromUnit(units)); - list.Insert(0, CurveTypeEncoding.Arc); - list.Insert(0, list.Count); - return list; - } - - /// - /// Creates a new instance based on a flat list of numerical values. - /// This is only used for deserialisation purposes. - /// - /// The input list should be the result of having called - /// A list of numbers - /// A new with the values assigned from the list. - public static Arc FromList(List list) - { - var arc = new Arc - { - radius = list[2], - startAngle = list[3], - endAngle = list[4], - angleRadians = list[5], - domain = new Interval(list[6], list[7]), - units = Units.GetUnitFromEncoding(list[list.Count - 1]), - plane = Plane.FromList(list.GetRange(8, 13)) - }; - arc.startPoint = Point.FromList(list.GetRange(21, 3), arc.units); - arc.midPoint = Point.FromList(list.GetRange(24, 3), arc.units); - arc.endPoint = Point.FromList(list.GetRange(27, 3), arc.units); - arc.plane.units = arc.units; - - return arc; - } -} diff --git a/DUI3-DX/Objects/Speckle.Objects.Common/Geometry/Box.cs b/DUI3-DX/Objects/Speckle.Objects.Common/Geometry/Box.cs deleted file mode 100644 index c6a9ab26b4..0000000000 --- a/DUI3-DX/Objects/Speckle.Objects.Common/Geometry/Box.cs +++ /dev/null @@ -1,77 +0,0 @@ -using Speckle.Core.Kits; -using Speckle.Core.Models; -using Speckle.Objects.Primitives; - -namespace Speckle.Objects.Geometry; - -/// -/// Represents a 3-dimensional box oriented on a plane. -/// -public class Box : Base, IHasVolume, IHasArea, IHasBoundingBox -{ - /// - public Box() { } - - /// - /// Constructs a new instance with a and coordinate intervals for all 3 axis {x , y , z} - /// - /// The plane the box will be oriented by. - /// The range of coordinates (min, max) for the X axis - /// The range of coordinates (min, max) for the Y axis - /// The range of coordinates (min, max) for the Z axis - /// The units the coordinates are in. - /// The unique application ID of the object. - public Box( - Plane basePlane, - Interval xSize, - Interval ySize, - Interval zSize, - string units = Units.Meters, - string? applicationId = null - ) - { - this.basePlane = basePlane; - this.xSize = xSize; - this.ySize = ySize; - this.zSize = zSize; - this.applicationId = applicationId; - this.units = units; - } - - /// - /// Gets or sets the plane that defines the orientation of the - /// - public Plane basePlane { get; set; } - - /// - /// Gets or sets the that defines the min and max coordinate in the X direction - /// - public Interval xSize { get; set; } - - /// - /// Gets or sets the that defines the min and max coordinate in the Y direction - /// - public Interval ySize { get; set; } - - /// - /// Gets or sets the that defines the min and max coordinate in the Y direction - /// - public Interval zSize { get; set; } - - /// - /// The units this object's coordinates are in. - /// - /// - /// This should be one of - /// - public string units { get; set; } - - /// - public double area { get; set; } - - /// - public Box bbox { get; } - - /// - public double volume { get; set; } -} diff --git a/DUI3-DX/Objects/Speckle.Objects.Common/Geometry/Circle.cs b/DUI3-DX/Objects/Speckle.Objects.Common/Geometry/Circle.cs deleted file mode 100644 index f728495ec6..0000000000 --- a/DUI3-DX/Objects/Speckle.Objects.Common/Geometry/Circle.cs +++ /dev/null @@ -1,99 +0,0 @@ -using System.Collections.Generic; -using Speckle.Core.Kits; -using Speckle.Core.Models; -using Speckle.Objects.Common; -using Speckle.Objects.Primitives; - -namespace Speckle.Objects.Geometry; - -/// -/// Represents a circular curve based on a base and a as radius. -/// -public class Circle : Base, ICurve, IHasArea, IHasBoundingBox -{ - /// - /// Constructs an empty instance. - /// - public Circle() { } - - /// - /// Constructs a new instance. - /// - /// The plane where the circle lies - /// The radius of the circle - /// The units the circle is modeled in - /// The unique ID of this circle in a specific application - public Circle(Plane plane, double radius, string units = Units.Meters, string? applicationId = null) - { - this.plane = plane; - this.radius = radius; - this.applicationId = applicationId; - this.units = units; - } - - /// - /// The radius of the circle - /// - public double? radius { get; set; } - - /// - /// The the circle lies in. - /// - public Plane plane { get; set; } - - /// - /// The units this object was modeled in. - /// - public string units { get; set; } - - /// - public Interval domain { get; set; } = new(0, 1); - - /// - public double length { get; set; } - - //public Point center { get; set; } - - /// - public double area { get; set; } - - /// - public Box bbox { get; set; } - - /// - /// Returns the coordinates of this as a list of numbers - /// - /// A list of values representing the - public List ToList() - { - var list = new List(); - - list.Add(radius ?? 0); - list.Add(domain?.start ?? 0); - list.Add(domain?.end ?? 1); - list.AddRange(plane.ToList()); - - list.Add(Units.GetEncodingFromUnit(units)); - list.Insert(0, CurveTypeEncoding.Circle); - list.Insert(0, list.Count); - return list; - } - - /// - /// Creates a new based on a list of coordinates and the unit they're drawn in. - /// - /// The list of values representing this - /// A new with the provided values. - public static Circle FromList(List list) - { - var circle = new Circle - { - radius = list[2], - domain = new Interval(list[3], list[4]), - plane = Plane.FromList(list.GetRange(5, 13)), - units = Units.GetUnitFromEncoding(list[list.Count - 1]) - }; - - return circle; - } -} diff --git a/DUI3-DX/Objects/Speckle.Objects.Common/Geometry/Curve.cs b/DUI3-DX/Objects/Speckle.Objects.Common/Geometry/Curve.cs deleted file mode 100644 index ce8fc975dc..0000000000 --- a/DUI3-DX/Objects/Speckle.Objects.Common/Geometry/Curve.cs +++ /dev/null @@ -1,204 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using Speckle.Objects.Primitives; -using Speckle.Core.Kits; -using Speckle.Core.Logging; -using Speckle.Core.Models; -using Speckle.Objects.Common; -using Speckle.Objects.Utils; - -namespace Speckle.Objects.Geometry; - -public class Curve : Base, ICurve, IHasBoundingBox, IHasArea, ITransformable, IDisplayValue -{ - /// - /// Constructs an empty instance. - /// - public Curve() { } - - /// - /// Constructs a new instance based on displayValue a polyline. - /// - /// The polyline that will be this curve's - /// The units this curve is be modelled in - /// The unique ID of this curve in a specific application - public Curve(Polyline poly, string units = Units.Meters, string? applicationId = null) - { - displayValue = poly; - this.applicationId = applicationId; - this.units = units; - } - - public int degree { get; set; } - - public bool periodic { get; set; } - - /// - /// "True" if weights differ, "False" if weights are the same. - /// - public bool rational { get; set; } - - [DetachProperty, Chunkable(31250)] - public List points { get; set; } - - /// - /// Gets or sets the weights for this . Use a default value of 1 for unweighted points. - /// - [DetachProperty, Chunkable(31250)] - public List weights { get; set; } - - /// - /// Gets or sets the knots for this . Count should be equal to count + + 1. - /// - [DetachProperty, Chunkable(31250)] - public List knots { get; set; } - - public bool closed { get; set; } - - /// - /// The units this object was specified in. - /// - public string units { get; set; } - - /// - public Interval domain { get; set; } = new Interval(0, 1); - - /// - public double length { get; set; } - - /// - [DetachProperty] - public Polyline displayValue { get; set; } - - /// - public double area { get; set; } - - /// - public Box bbox { get; set; } - - /// - public bool TransformTo(Transform transform, out Curve transformed) - { - // transform points - var transformedPoints = new List(); - foreach (var point in GetPoints()) - { - point.TransformTo(transform, out Point transformedPoint); - transformedPoints.Add(transformedPoint); - } - - var result = displayValue.TransformTo(transform, out ITransformable polyline); - transformed = new Curve - { - degree = degree, - periodic = periodic, - rational = rational, - points = transformedPoints.SelectMany(o => o.ToList()).ToList(), - weights = weights, - knots = knots, - displayValue = (Polyline)polyline, - closed = closed, - units = units, - applicationId = applicationId, - domain = domain != null ? new Interval { start = domain.start, end = domain.end } : new Interval(0, 1) - }; - - return result; - } - - /// - public bool TransformTo(Transform transform, out ITransformable transformed) - { - var res = TransformTo(transform, out Curve curve); - transformed = curve; - return res; - } - - /// as list of s - /// when list is malformed - public List GetPoints() - { - if (points.Count % 3 != 0) - { - throw new SpeckleException( - $"{nameof(Curve)}.{nameof(points)} list is malformed: expected length to be multiple of 3" - ); - } - - var pts = new List(points.Count / 3); - for (int i = 2; i < points.Count; i += 3) - { - pts.Add(new Point(points[i - 2], points[i - 1], points[i], units)); - } - - return pts; - } - - /// - /// Returns the values of this as a list of numbers - /// - /// A list of values representing the - public List ToList() - { - var list = new List(); - var curve = this; - list.Add(curve.degree); // 0 - list.Add(curve.periodic ? 1 : 0); // 1 - list.Add(curve.rational ? 1 : 0); // 2 - list.Add(curve.closed ? 1 : 0); // 3 - list.Add(curve.domain?.start ?? 0); // 4 - list.Add(curve.domain?.end ?? 1); // 5 - - list.Add(curve.points.Count); // 6 - list.Add(curve.weights.Count); // 7 - list.Add(curve.knots.Count); // 8 - - list.AddRange(curve.points); // 9 onwards - list.AddRange(curve.weights); - list.AddRange(curve.knots); - - list.Add(Units.GetEncodingFromUnit(units)); - list.Insert(0, CurveTypeEncoding.Curve); - list.Insert(0, list.Count); - return list; - } - - /// - /// Creates a new based on a list of coordinates and the unit they're drawn in. - /// - /// The list of values representing this - /// A new with the provided values. - public static Curve FromList(List list) - { - if (list[0] != list.Count - 1) - { - throw new Exception($"Incorrect length. Expected {list[0]}, got {list.Count}."); - } - - if (list[1] != CurveTypeEncoding.Curve) - { - throw new Exception($"Wrong curve type. Expected {CurveTypeEncoding.Curve}, got {list[1]}."); - } - - var curve = new Curve - { - degree = (int)list[2], - periodic = list[3] == 1, - rational = list[4] == 1, - closed = list[5] == 1, - domain = new Interval(list[6], list[7]) - }; - - var pointsCount = (int)list[8]; - var weightsCount = (int)list[9]; - var knotsCount = (int)list[10]; - - curve.points = list.GetRange(11, pointsCount); - curve.weights = list.GetRange(11 + pointsCount, weightsCount); - curve.knots = list.GetRange(11 + pointsCount + weightsCount, knotsCount); - - curve.units = Units.GetUnitFromEncoding(list[list.Count - 1]); - return curve; - } -} diff --git a/DUI3-DX/Objects/Speckle.Objects.Common/Geometry/Ellipse.cs b/DUI3-DX/Objects/Speckle.Objects.Common/Geometry/Ellipse.cs deleted file mode 100644 index 29b84e5505..0000000000 --- a/DUI3-DX/Objects/Speckle.Objects.Common/Geometry/Ellipse.cs +++ /dev/null @@ -1,122 +0,0 @@ -using System.Collections.Generic; -using Speckle.Core.Kits; -using Speckle.Core.Models; -using Speckle.Objects.Common; -using Speckle.Objects.Primitives; - -namespace Speckle.Objects.Geometry; - -public class Ellipse : Base, ICurve, IHasArea -{ - /// - /// Initializes a new instance of the class. - /// This constructor is only intended for serialization/deserialization purposes. - /// Use other constructors to manually create ellipses. - /// - public Ellipse() { } - - /// - /// Initializes a new instance of the class. - /// - /// The plane to draw the ellipse in. - /// First radius of the ellipse. - /// Second radius of the ellipse. - /// Application ID, defaults to null. - public Ellipse(Plane plane, double radius1, double radius2, string units = Units.Meters, string? applicationId = null) - : this(plane, radius1, radius2, new Interval(0, 1), null, units) { } - - /// - /// Initializes a new instance of the class. - /// - /// The plane to draw the ellipse in. - /// First radius of the ellipse. - /// Second radius of the ellipse. - /// The curve's internal parametrization domain. - /// The domain to trim the curve with. Will be null if the ellipse is not trimmed. - /// Application ID, defaults to null. - public Ellipse( - Plane plane, - double radius1, - double radius2, - Interval domain, - Interval? trimDomain, - string units = Units.Meters, - string? applicationId = null - ) - { - this.plane = plane; - firstRadius = radius1; - secondRadius = radius2; - this.domain = domain; - this.trimDomain = trimDomain; - this.applicationId = applicationId; - this.units = units; - } - - /// - /// Gets or sets the first radius of the . This is usually the major radius. - /// - public double? firstRadius { get; set; } - - /// - /// Gets or sets the second radius of the . This is usually the minor radius. - /// - public double? secondRadius { get; set; } - - /// - /// Gets or sets the plane to draw this ellipse in. - /// - public Plane plane { get; set; } - - /// - /// Gets or set the domain interval to trim this with. - /// - public Interval? trimDomain { get; set; } - - /// - public Box bbox { get; set; } - - public string units { get; set; } - - /// - /// Gets or sets the domain interval for this . - /// - public Interval domain { get; set; } = new(0, 0); - - /// - public double length { get; set; } - - //public Point center { get; set; } - - /// - public double area { get; set; } - - public List ToList() - { - var list = new List(); - list.Add(firstRadius ?? 0); - list.Add(secondRadius ?? 0); - list.Add(domain?.start ?? 0); - list.Add(domain?.end ?? 0); - - list.AddRange(plane.ToList()); - - list.Add(Units.GetEncodingFromUnit(units)); - list.Insert(0, CurveTypeEncoding.Ellipse); - list.Insert(0, list.Count); - return list; - } - - public static Ellipse FromList(List list) - { - var ellipse = new Ellipse - { - firstRadius = list[2], - secondRadius = list[3], - domain = new Interval(list[4], list[5]), - plane = Plane.FromList(list.GetRange(6, 13)), - units = Units.GetUnitFromEncoding(list[list.Count - 1]) - }; - return ellipse; - } -} diff --git a/DUI3-DX/Objects/Speckle.Objects.Common/Geometry/Interfaces.cs b/DUI3-DX/Objects/Speckle.Objects.Common/Geometry/Interfaces.cs deleted file mode 100644 index f1f771e896..0000000000 --- a/DUI3-DX/Objects/Speckle.Objects.Common/Geometry/Interfaces.cs +++ /dev/null @@ -1,79 +0,0 @@ -using Speckle.Core.Models; -using Speckle.Objects.Primitives; -using Speckle.Objects.Utils; - -namespace Speckle.Objects.Geometry; - -/// -/// Represents an object that has a -/// -public interface IHasBoundingBox -{ - /// - /// The bounding box containing the object. - /// - Box bbox { get; } -} - -/// -/// Represents a object that has -/// -public interface IHasArea -{ - /// - /// The area of the object - /// - double area { get; set; } -} - -/// -/// Represents an object that has -/// -public interface IHasVolume -{ - /// - /// The volume of the object - /// - double volume { get; set; } -} - -/// -/// Represents -/// -public interface ICurve -{ - /// - /// The length of the curve. - /// - double length { get; set; } - - /// - /// The numerical domain driving the curve's internal parametrization. - /// - Interval domain { get; set; } -} - -/// -/// Generic Interface for transformable objects. -/// -/// The type of object to support transformations. -public interface ITransformable : ITransformable - where T : ITransformable -{ - /// - bool TransformTo(Transform transform, out T transformed); -} - -/// -/// Interface for transformable objects where the type may not be known on convert (eg ICurve implementations) -/// -public interface ITransformable -{ - /// - /// Returns a copy of the object with it's coordinates transformed by the provided - /// - /// The to be applied. - /// The transformed copy of the object. - /// True if the transform operation was successful, false otherwise. - bool TransformTo(Transform transform, out ITransformable transformed); -} diff --git a/DUI3-DX/Objects/Speckle.Objects.Common/Geometry/Line.cs b/DUI3-DX/Objects/Speckle.Objects.Common/Geometry/Line.cs deleted file mode 100644 index ccd63ebcc5..0000000000 --- a/DUI3-DX/Objects/Speckle.Objects.Common/Geometry/Line.cs +++ /dev/null @@ -1,134 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using Speckle.Core.Kits; -using Speckle.Core.Logging; -using Speckle.Core.Models; -using Speckle.Newtonsoft.Json; -using Speckle.Objects.Common; -using Speckle.Objects.Primitives; -using Speckle.Objects.Utils; - -namespace Speckle.Objects.Geometry; - -public class Line : Base, ICurve, IHasBoundingBox, ITransformable -{ - public Line() { } - - [Obsolete("Line should not use a constructor that only sets the start point. Deprecated in 2.18.", true)] - public Line(double x, double y, double z = 0, string units = Units.Meters, string? applicationId = null) - { - start = new Point(x, y, z); -#pragma warning disable CS8625 // Cannot convert null literal to non-nullable reference type. Reason: Obsolete. - end = null; -#pragma warning restore CS8625 // Cannot convert null literal to non-nullable reference type. Reason: Obsolete. - this.applicationId = applicationId; - this.units = units; - } - - public Line(Point start, Point end, string units = Units.Meters, string? applicationId = null) - { - this.start = start; - this.end = end; - length = Point.Distance(start, end); - this.applicationId = applicationId; - this.units = units; - } - - public Line(IList coordinates, string units = Units.Meters, string? applicationId = null) - { - if (coordinates.Count < 6) - { - throw new SpeckleException("Line from coordinate array requires 6 coordinates."); - } - - start = new Point(coordinates[0], coordinates[1], coordinates[2], units, applicationId); - end = new Point(coordinates[3], coordinates[4], coordinates[5], units, applicationId); - length = Point.Distance(start, end); - this.applicationId = applicationId; - this.units = units; - } - - [Obsolete("Use IList constructor", true)] - public Line(IEnumerable coordinatesArray, string units = Units.Meters, string? applicationId = null) - : this(coordinatesArray.ToList(), units, applicationId) { } - - /// - /// OBSOLETE - This is just here for backwards compatibility. - /// You should not use this for anything. Access coordinates using start and end point. - /// - - [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] - public List value - { -#pragma warning disable CS8603 // Possible null reference return. Reason: Obsolete. - get => null; -#pragma warning restore CS8603 // Possible null reference return. Reason: Obsolete. - set - { - if (value == null) - { - return; - } - - start = new Point(value[0], value[1], value[2]); - end = new Point(value[3], value[4], value[5]); - } - } - - public double area { get; set; } - - public string units { get; set; } - - public Point start { get; set; } - public Point end { get; set; } - - public Interval domain { get; set; } = new(0, 1); - public double length { get; set; } - - public Box bbox { get; set; } - - public bool TransformTo(Transform transform, out Line transformed) - { - start.TransformTo(transform, out Point transformedStart); - end.TransformTo(transform, out Point transformedEnd); - transformed = new Line - { - start = transformedStart, - end = transformedEnd, - applicationId = applicationId, - units = units, - domain = domain is null ? new(0, 1) : new() { start = domain.start, end = domain.end } - }; - return true; - } - - public bool TransformTo(Transform transform, out ITransformable transformed) - { - var res = TransformTo(transform, out Line line); - transformed = line; - return res; - } - - public List ToList() - { - var list = new List(); - list.AddRange(start.ToList()); - list.AddRange(end.ToList()); - list.Add(domain?.start ?? 0); - list.Add(domain?.end ?? 1); - list.Add(Units.GetEncodingFromUnit(units)); - list.Insert(0, CurveTypeEncoding.Line); - list.Insert(0, list.Count); - return list; - } - - public static Line FromList(List list) - { - var units = Units.GetUnitFromEncoding(list[list.Count - 1]); - var startPt = new Point(list[2], list[3], list[4], units); - var endPt = new Point(list[5], list[6], list[7], units); - var line = new Line(startPt, endPt, units) { domain = new Interval(list[8], list[9]) }; - return line; - } -} diff --git a/DUI3-DX/Objects/Speckle.Objects.Common/Geometry/Mesh.cs b/DUI3-DX/Objects/Speckle.Objects.Common/Geometry/Mesh.cs deleted file mode 100644 index 111a27e937..0000000000 --- a/DUI3-DX/Objects/Speckle.Objects.Common/Geometry/Mesh.cs +++ /dev/null @@ -1,254 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using Speckle.Core.Kits; -using Speckle.Core.Logging; -using Speckle.Core.Models; -using Speckle.Newtonsoft.Json; -using Speckle.Objects.Utils; - -namespace Speckle.Objects.Geometry; - -public class Mesh : Base, IHasBoundingBox, IHasVolume, IHasArea, ITransformable -{ - public Mesh() { } - - /// - /// Constructs a new mesh from it's raw values. - /// - /// - /// - /// - /// - /// - /// - public Mesh( - List vertices, - List faces, - List? colors = null, - List? texture_coords = null, - string units = Units.Meters, - string? applicationId = null - ) - { - this.vertices = vertices; - this.faces = faces; - this.colors = colors ?? this.colors; - textureCoordinates = texture_coords ?? textureCoordinates; - this.applicationId = applicationId; - this.units = units; - } - - [Obsolete("Use lists constructor", true)] - public Mesh( - double[] vertices, - int[] faces, - int[]? colors = null, - double[]? texture_coords = null, - string units = Units.Meters, - string? applicationId = null - ) - : this( - vertices.ToList(), - faces.ToList(), - colors?.ToList() ?? new(), - texture_coords?.ToList() ?? new(), - units, - applicationId - ) { } - - [DetachProperty, Chunkable(31250)] - public List vertices { get; set; } = new(); - - [DetachProperty, Chunkable(62500)] - public List faces { get; set; } = new(); - - /// Vertex colors as ARGB s - [DetachProperty, Chunkable(62500)] - public List colors { get; set; } = new(); - - [DetachProperty, Chunkable(31250)] - public List textureCoordinates { get; set; } = new(); - - /// - /// The unit's this is in. - /// This should be one of - /// - public string units { get; set; } = Units.None; - - /// - public double area { get; set; } - - /// - public Box bbox { get; set; } - - /// - public double volume { get; set; } - - /// - public bool Transform(Transform transform) - { - // transform vertices - vertices = GetPoints() - .SelectMany(vertex => - { - vertex.TransformTo(transform, out Point transformedVertex); - return transformedVertex.ToList(); - }) - .ToList(); - - return true; - } - - /// - public bool TransformTo(Transform transform, out Mesh transformed) - { - // transform vertices - var transformedVertices = new List(); - foreach (var vertex in GetPoints()) - { - vertex.TransformTo(transform, out Point transformedVertex); - transformedVertices.Add(transformedVertex); - } - - transformed = new Mesh - { - vertices = transformedVertices.SelectMany(o => o.ToList()).ToList(), - textureCoordinates = textureCoordinates, - applicationId = applicationId ?? id, - faces = faces, - colors = colors, - units = units - }; - transformed["renderMaterial"] = this["renderMaterial"]; - - return true; - } - - /// - public bool TransformTo(Transform transform, out ITransformable transformed) - { - var res = TransformTo(transform, out Mesh brep); - transformed = brep; - return res; - } - - #region Convenience Methods - - [JsonIgnore] - public int VerticesCount => vertices.Count / 3; - - [JsonIgnore] - public int TextureCoordinatesCount => textureCoordinates.Count / 2; - - /// - /// Gets a vertex as a by - /// - /// The index of the vertex - /// Vertex as a - public Point GetPoint(int index) - { - index *= 3; - return new Point(vertices[index], vertices[index + 1], vertices[index + 2], units, applicationId); - } - - /// as list of s - /// when list is malformed - public List GetPoints() - { - if (vertices.Count % 3 != 0) - { - throw new SpeckleException( - $"{nameof(Mesh)}.{nameof(vertices)} list is malformed: expected length to be multiple of 3" - ); - } - - var pts = new List(vertices.Count / 3); - for (int i = 2; i < vertices.Count; i += 3) - { - pts.Add(new Point(vertices[i - 2], vertices[i - 1], vertices[i], units)); - } - - return pts; - } - - /// - /// Gets a texture coordinate as a by - /// - /// The index of the texture coordinate - /// Texture coordinate as a - public (double, double) GetTextureCoordinate(int index) - { - index *= 2; - return (textureCoordinates[index], textureCoordinates[index + 1]); - } - - /// - /// If not already so, this method will align - /// such that a vertex and its corresponding texture coordinates have the same index. - /// This alignment is what is expected by most applications.
- ///
- /// - /// If the calling application expects - /// vertices.count == textureCoordinates.count - /// Then this method should be called by the MeshToNative method before parsing and - /// to ensure compatibility with geometry originating from applications that map to using vertex instance index (rather than vertex index) - ///
- /// , , and lists will be modified to contain no shared vertices (vertices shared between polygons) - ///
- public void AlignVerticesWithTexCoordsByIndex() - { - if (textureCoordinates.Count == 0) - { - return; - } - - if (TextureCoordinatesCount == VerticesCount) - { - return; //Tex-coords already aligned as expected - } - - var facesUnique = new List(faces.Count); - var verticesUnique = new List(TextureCoordinatesCount * 3); - bool hasColors = colors.Count > 0; - var colorsUnique = hasColors ? new List(TextureCoordinatesCount) : null; - - int nIndex = 0; - while (nIndex < faces.Count) - { - int n = faces[nIndex]; - if (n < 3) - { - n += 3; // 0 -> 3, 1 -> 4 - } - - if (nIndex + n >= faces.Count) - { - break; //Malformed face list - } - - facesUnique.Add(n); - for (int i = 1; i <= n; i++) - { - int vertIndex = faces[nIndex + i]; - int newVertIndex = verticesUnique.Count / 3; - - var (x, y, z) = GetPoint(vertIndex); - verticesUnique.Add(x); - verticesUnique.Add(y); - verticesUnique.Add(z); - - colorsUnique?.Add(colors[vertIndex]); - facesUnique.Add(newVertIndex); - } - - nIndex += n + 1; - } - - vertices = verticesUnique; - colors = colorsUnique ?? colors; - faces = facesUnique; - } - - #endregion -} diff --git a/DUI3-DX/Objects/Speckle.Objects.Common/Geometry/Plane.cs b/DUI3-DX/Objects/Speckle.Objects.Common/Geometry/Plane.cs deleted file mode 100644 index 4c92be25e1..0000000000 --- a/DUI3-DX/Objects/Speckle.Objects.Common/Geometry/Plane.cs +++ /dev/null @@ -1,133 +0,0 @@ -using System.Collections.Generic; -using Speckle.Core.Kits; -using Speckle.Core.Models; -using Speckle.Objects.Utils; - -namespace Speckle.Objects.Geometry; - -/// -/// A 3-dimensional Plane consisting of an origin , and 3 as it's X, Y and Z axis. -/// -public class Plane : Base, ITransformable -{ - /// - /// Constructs an empty - /// - public Plane() { } - - /// - /// Constructs a new given it's individual values. - /// - /// The point to be used as origin - /// The vector to be used as Z axis - /// The vector to be used as the X axis - /// The vector to be used as the Y axis - /// The units the coordinates are in. - /// The unique ID of this polyline in a specific application - public Plane( - Point origin, - Vector normal, - Vector xDir, - Vector yDir, - string units = Units.Meters, - string? applicationId = null - ) - { - this.origin = origin; - this.normal = normal; - xdir = xDir; - ydir = yDir; - this.applicationId = applicationId; - this.units = units; - } - - /// - /// The s origin point. - /// - public Point origin { get; set; } - - /// - /// The s Z axis. - /// - public Vector normal { get; set; } - - /// - /// The s X axis. - /// - public Vector xdir { get; set; } - - /// - /// The s Y axis. - /// - public Vector ydir { get; set; } - - /// - /// The unit's this is in. - /// This should be one of - /// - public string units { get; set; } - - /// - public bool TransformTo(Transform transform, out Plane transformed) - { - origin.TransformTo(transform, out Point transformedOrigin); - normal.TransformTo(transform, out Vector transformedNormal); - xdir.TransformTo(transform, out Vector transformedXdir); - ydir.TransformTo(transform, out Vector transformedYdir); - transformed = new Plane - { - origin = transformedOrigin, - normal = transformedNormal, - xdir = transformedXdir, - ydir = transformedYdir, - applicationId = applicationId, - units = units - }; - - return true; - } - - /// - public bool TransformTo(Transform transform, out ITransformable transformed) - { - var res = TransformTo(transform, out Plane plane); - transformed = plane; - return res; - } - - /// - /// Returns the values of this as a list of numbers - /// - /// A list of values representing the Plane. - - public List ToList() - { - var list = new List(); - - list.AddRange(origin.ToList()); - list.AddRange(normal.ToList()); - list.AddRange(xdir.ToList()); - list.AddRange(ydir.ToList()); - list.Add(Units.GetEncodingFromUnit(units)); - - return list; - } - - /// - /// Creates a new based on a list of values and the unit they're drawn in. - /// - /// The list of values representing this plane - /// A new with the provided values. - public static Plane FromList(List list) - { - var plane = new Plane(); - - var units = Units.GetUnitFromEncoding(list[list.Count - 1]); - plane.origin = new Point(list[0], list[1], list[2], units); - plane.normal = new Vector(list[3], list[4], list[5], units); - plane.xdir = new Vector(list[6], list[7], list[8], units); - plane.ydir = new Vector(list[9], list[10], list[11], units); - - return plane; - } -} diff --git a/DUI3-DX/Objects/Speckle.Objects.Common/Geometry/Point.cs b/DUI3-DX/Objects/Speckle.Objects.Common/Geometry/Point.cs deleted file mode 100644 index ed5a5b4b2e..0000000000 --- a/DUI3-DX/Objects/Speckle.Objects.Common/Geometry/Point.cs +++ /dev/null @@ -1,242 +0,0 @@ -using System; -using System.Collections.Generic; -using Speckle.Core.Kits; -using Speckle.Core.Models; -using Speckle.Newtonsoft.Json; -using Speckle.Objects.Utils; - -namespace Speckle.Objects.Geometry; - -/// -/// A 3-dimensional point -/// -/// -/// TODO: The Point class does not override the Equality operator, which means that there may be cases where `Equals` is used instead of `==`, as the comparison will be done by reference, not value. -/// -public class Point : Base, ITransformable -{ - /// - public Point() { } - - /// - /// Constructs a new from a set of coordinates and it's units. - /// - /// The x coordinate - /// The y coordinate - /// The z coordinate - /// The units of the point's coordinates. Defaults to Meters. - /// The object's unique application ID - public Point(double x, double y, double z = 0d, string units = Units.Meters, string? applicationId = null) - { - this.x = x; - this.y = y; - this.z = z; - this.applicationId = applicationId; - this.units = units; - } - - /// - /// Constructs a new from a - /// - /// The Vector whose coordinates will be used for the Point - public Point(Vector vector) - : this(vector.x, vector.y, vector.z, vector.units, vector.applicationId) { } - - /// - /// Gets or sets the coordinates of the - /// - [JsonProperty(NullValueHandling = NullValueHandling.Ignore), Obsolete("Use x,y,z properties instead", true)] - public List value - { - get => null!; - set - { - x = value[0]; - y = value[1]; - z = value.Count > 2 ? value[2] : 0; - } - } - - /// - /// The x coordinate of the point. - /// - public double x { get; set; } - - /// - /// The y coordinate of the point. - /// - public double y { get; set; } - - /// - /// The z coordinate of the point. - /// - public double z { get; set; } - - /// - /// The units this is in. - /// This should be one of the units specified in - /// - public string units { get; set; } = Units.None; - - [JsonIgnore, Obsolete("Bounding box no longer applicable to point as of 2.18", true)] - public Box? bbox { get; set; } - - /// - public bool TransformTo(Transform transform, out Point transformed) - { - var matrix = transform.matrix; - - var unitFactor = Units.GetConversionFactor(transform.units, units); // applied to translation vector - var divisor = matrix.M41 + matrix.M42 + matrix.M43 + unitFactor * matrix.M44; - var x = (this.x * matrix.M11 + this.y * matrix.M12 + this.z * matrix.M13 + unitFactor * matrix.M14) / divisor; - var y = (this.x * matrix.M21 + this.y * matrix.M22 + this.z * matrix.M23 + unitFactor * matrix.M24) / divisor; - var z = (this.x * matrix.M31 + this.y * matrix.M32 + this.z * matrix.M33 + unitFactor * matrix.M34) / divisor; - - transformed = new Point(x, y, z) { units = units, applicationId = applicationId }; - return true; - } - - /// - public bool TransformTo(Transform transform, out ITransformable transformed) - { - var res = TransformTo(transform, out Point pt); - transformed = pt; - return res; - } - - /// - /// Returns the coordinates of this as a list of numbers - /// - /// A list of coordinates {x, y, z} - public List ToList() - { - return new List { x, y, z }; - } - - /// - /// Creates a new based on a list of coordinates and the unit they're drawn in. - /// - /// The list of coordinates {x, y, z} - /// The units the coordinates are in - /// A new with the provided coordinates. - public static Point FromList(IList list, string units) - { - return new Point(list[0], list[1], list[2], units); - } - - /// - /// Deconstructs a into it's coordinates and units - /// - /// The x coordinate - /// The y coordinate - /// The z coordinate - /// The units the point's coordinates are in. - public void Deconstruct(out double x, out double y, out double z, out string? units) - { - Deconstruct(out x, out y, out z); - units = this.units; - } - - /// - /// Deconstructs a into it's coordinates and units - /// - /// The x coordinate - /// The y coordinate - /// The z coordinate - public void Deconstruct(out double x, out double y, out double z) - { - x = this.x; - y = this.y; - z = this.z; - } - - public static Point operator +(Point point1, Point point2) => - new(point1.x + point2.x, point1.y + point2.y, point1.z + point2.z, point1.units); - - public static Point operator -(Point point1, Point point2) => - new(point1.x - point2.x, point1.y - point2.y, point1.z - point2.z, point1.units); - - public static Point operator *(Point point1, Point point2) => - new(point1.x * point2.x, point1.y * point2.y, point1.z * point2.z, point1.units); - - public static Point operator *(Point point, double val) => - new(point.x * val, point.y * val, point.z * val, point.units); - - public static Point operator /(Point point, double val) => - new(point.x / val, point.y / val, point.z / val, point.units); - - public static bool operator ==(Point? point1, Point? point2) - { - if (point1 is null && point2 is null) - { - return true; - } - else if (point1 is null || point2 is null) - { - return false; - } - - return point1.units == point2.units && point1.x == point2.x && point1.y == point2.y && point1.z == point2.z; - } - - public static bool operator !=(Point? point1, Point? point2) => !(point1 == point2); - - /// - /// Computes a point equidistant from two points. - /// - /// First point. - /// Second point. - /// A point at the same distance from and - public static Point Midpoint(Point point1, Point point2) - { - return new Point( - 0.5 * (point1.x + point2.x), - 0.5 * (point1.y + point2.y), - 0.5 * (point1.z + point2.z), - point1.units - ); - } - - /// - /// Computes the distance between two points - /// - /// First point. - /// Second point. - /// The distance from to - public static double Distance(Point point1, Point point2) - { - return Math.Sqrt( - Math.Pow(point1.x - point2.x, 2) + Math.Pow(point1.y - point2.y, 2) + Math.Pow(point1.z - point2.z, 2) - ); - } - - /// - /// Computes the distance between two points. - /// - /// point for distance measurement - /// The length of the line between this and the other point - public double DistanceTo(Point point) - { - return Math.Sqrt(Math.Pow(x - point.x, 2) + Math.Pow(y - point.y, 2) + Math.Pow(z - point.z, 2)); - } - - public static Point Add(Point left, Point right) - { - throw new NotImplementedException(); - } - - public override bool Equals(object obj) - { - if (ReferenceEquals(this, obj)) - { - return true; - } - - if (ReferenceEquals(obj, null)) - { - return false; - } - - throw new NotImplementedException(); - } -} diff --git a/DUI3-DX/Objects/Speckle.Objects.Common/Geometry/Polycurve.cs b/DUI3-DX/Objects/Speckle.Objects.Common/Geometry/Polycurve.cs deleted file mode 100644 index 0e143ccbab..0000000000 --- a/DUI3-DX/Objects/Speckle.Objects.Common/Geometry/Polycurve.cs +++ /dev/null @@ -1,167 +0,0 @@ -using System; -using System.Collections.Generic; -using Speckle.Core.Kits; -using Speckle.Core.Models; -using Speckle.Objects.Common; -using Speckle.Objects.Primitives; -using Speckle.Objects.Utils; - -namespace Speckle.Objects.Geometry; - -/// -/// A curve that is comprised of multiple curves connected. -/// -public class Polycurve : Base, ICurve, IHasArea, IHasBoundingBox, ITransformable -{ - /// - /// Constructs a new empty instance. - /// - public Polycurve() { } - - /// - /// Constructs a new empty with defined units and unique application ID. - /// - /// The units the Polycurve was modelled in. - /// The unique ID of this polyline in a specific application - public Polycurve(string units = Units.Meters, string? applicationId = null) - { - this.applicationId = applicationId; - this.units = units; - } - - /// - /// Gets or sets the list of segments that comprise this - /// - public List segments { get; set; } = new(); - - /// - /// Gets or sets a Boolean value indicating if the is closed - /// (i.e. The start point of the first segment and the end point of the last segment coincide.) - /// - public bool closed { get; set; } - - /// - /// The unit's this is in. - /// This should be one of - /// - public string units { get; set; } - - /// - /// The internal domain of this curve. - /// - public Interval domain { get; set; } = new(0, 1); - - /// - public double length { get; set; } - - /// - public double area { get; set; } - - /// - public Box bbox { get; set; } - - /// - public bool TransformTo(Transform transform, out ITransformable polycurve) - { - // transform segments - var success = true; - var transformed = new List(); - foreach (var curve in segments) - { - if (curve is ITransformable c) - { - c.TransformTo(transform, out ITransformable tc); - transformed.Add((ICurve)tc); - } - else - { - success = false; - } - } - - polycurve = new Polycurve - { - segments = transformed, - applicationId = applicationId, - closed = closed, - units = units - }; - - return success; - } - - /// - /// Constructs a new instance from an existing curve. - /// - /// The polyline to be used when constructing the - /// A with the same shape as the provided polyline. - public static implicit operator Polycurve(Polyline polyline) - { - Polycurve polycurve = - new() - { - units = polyline.units, - area = polyline.area, - domain = polyline.domain, - closed = polyline.closed, - bbox = polyline.bbox, - length = polyline.length - }; - - var points = polyline.GetPoints(); - for (var i = 0; i < points.Count - 1; i++) - { - var line = new Line(points[i], points[i + 1], polyline.units); - polycurve.segments.Add(line); - } - if (polyline.closed) - { - var line = new Line(points[points.Count - 1], points[0], polyline.units); - polycurve.segments.Add(line); - } - - return polycurve; - } - - /// - /// Returns the values of this as a list of numbers - /// - /// A list of values representing the polycurve. - public List ToList() - { - var list = new List(); - list.Add(closed ? 1 : 0); - list.Add(domain?.start ?? 0); - list.Add(domain?.end ?? 1); - - var crvs = CurveArrayEncodingExtensions.ToArray(segments); - list.Add(crvs.Count); - list.AddRange(crvs); - - list.Add(Units.GetEncodingFromUnit(units)); - list.Insert(0, CurveTypeEncoding.PolyCurve); - list.Insert(0, list.Count); - - return list; - } - - /// - /// Creates a new based on a list of coordinates and the unit they're drawn in. - /// - /// The list of values representing this polycurve - /// A new with the provided values. - public static Polycurve FromList(List list) - { - var polycurve = new Polycurve { closed = list[2] == 1, domain = new Interval(list[3], list[4]) }; - - var temp = list.GetRange(6, (int)list[5]); - polycurve.segments = CurveArrayEncodingExtensions.FromArray(temp); - polycurve.units = Units.GetUnitFromEncoding(list[list.Count - 1]); - return polycurve; - } - - public Polycurve ToPolycurve() - { - throw new NotImplementedException(); - } -} diff --git a/DUI3-DX/Objects/Speckle.Objects.Common/Geometry/Polyline.cs b/DUI3-DX/Objects/Speckle.Objects.Common/Geometry/Polyline.cs deleted file mode 100644 index 7640b1ffde..0000000000 --- a/DUI3-DX/Objects/Speckle.Objects.Common/Geometry/Polyline.cs +++ /dev/null @@ -1,267 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using Speckle.Core.Kits; -using Speckle.Core.Logging; -using Speckle.Core.Models; -using Speckle.Newtonsoft.Json; -using Speckle.Objects.Common; -using Speckle.Objects.Primitives; -using Speckle.Objects.Utils; - -namespace Speckle.Objects.Geometry; - -/// -/// A polyline curve, defined by a set of vertices. -/// -public class Polyline : Base, ICurve, IHasArea, IHasBoundingBox, IConvertible, ITransformable -{ - /// - /// Constructs an empty - /// - public Polyline() { } - - /// - /// Constructs a new instance from a flat list of coordinates. - /// - /// The array of 3-dimensional coordinates [x1,y1,z1,x2,y2,... - /// The units the coordinates are in. - /// The unique ID of this polyline in a specific application - [Obsolete("Use list constructor instead", true)] - public Polyline(IEnumerable coordinatesArray, string units = Units.Meters, string? applicationId = null) - : this(coordinatesArray.ToList(), units, applicationId) { } - - /// - /// Constructs a new instance from a flat list of coordinates. - /// - /// The list of 3-dimensional coordinates [x1,y1,z1,x2,y2,... - /// The units the coordinates are in. - /// The unique ID of this polyline in a specific application - public Polyline(List coordinates, string units = Units.Meters, string? applicationId = null) - { - value = coordinates; - this.units = units; - this.applicationId = applicationId; - } - - /// - /// Gets or sets the raw coordinates that define this polyline. Use GetPoints instead to access this data as instances instead. - /// - [DetachProperty, Chunkable(31250)] - public List value { get; set; } = new(); - - /// - /// If true, do not add the last point to the value list. Polyline first and last points should be unique. - /// - public bool closed { get; set; } - - /// - /// The unit's this is in. - /// This should be one of - /// - public string units { get; set; } - - /// - /// Gets the list of points representing the vertices of this polyline. - /// - [JsonIgnore, Obsolete("Use " + nameof(GetPoints) + " Instead", true)] - public List points => GetPoints(); - - /// - public object ToType(Type conversionType, IFormatProvider provider) - { - if (conversionType == typeof(Polycurve)) - { - return (Polycurve)this; - } - - throw new InvalidCastException(); - } - - /// - public TypeCode GetTypeCode() - { - throw new NotImplementedException(); - } - - /// - public bool ToBoolean(IFormatProvider provider) - { - throw new NotImplementedException(); - } - - /// - public byte ToByte(IFormatProvider provider) - { - throw new NotImplementedException(); - } - - /// - public char ToChar(IFormatProvider provider) - { - throw new NotImplementedException(); - } - - /// - public DateTime ToDateTime(IFormatProvider provider) - { - throw new NotImplementedException(); - } - - /// - public decimal ToDecimal(IFormatProvider provider) - { - throw new NotImplementedException(); - } - - /// - public double ToDouble(IFormatProvider provider) - { - throw new NotImplementedException(); - } - - /// - public short ToInt16(IFormatProvider provider) - { - throw new NotImplementedException(); - } - - /// - public int ToInt32(IFormatProvider provider) - { - throw new NotImplementedException(); - } - - /// - public long ToInt64(IFormatProvider provider) - { - throw new NotImplementedException(); - } - - /// - public sbyte ToSByte(IFormatProvider provider) - { - throw new NotImplementedException(); - } - - /// - public float ToSingle(IFormatProvider provider) - { - throw new NotImplementedException(); - } - - /// - public string ToString(IFormatProvider provider) - { - throw new NotImplementedException(); - } - - /// - public ushort ToUInt16(IFormatProvider provider) - { - throw new NotImplementedException(); - } - - /// - public uint ToUInt32(IFormatProvider provider) - { - throw new NotImplementedException(); - } - - /// - public ulong ToUInt64(IFormatProvider provider) - { - throw new NotImplementedException(); - } - - /// - /// The internal domain of this curve. - /// - public Interval domain { get; set; } = new(0, 1); - - /// - public double length { get; set; } - - /// - public double area { get; set; } - - /// - public Box bbox { get; set; } - - /// - public bool TransformTo(Transform transform, out ITransformable transformed) - { - // transform points - var transformedPoints = new List(); - foreach (var point in GetPoints()) - { - point.TransformTo(transform, out Point transformedPoint); - transformedPoints.Add(transformedPoint); - } - - transformed = new Polyline - { - value = transformedPoints.SelectMany(o => o.ToList()).ToList(), - closed = closed, - applicationId = applicationId, - units = units - }; - - return true; - } - - ///This function may be suboptimal for performance for polylines with many points - /// as List of s - /// when list is malformed - public List GetPoints() - { - if (value.Count % 3 != 0) - { - throw new SpeckleException( - $"{nameof(Polyline)}.{nameof(value)} list is malformed: expected length to be multiple of 3" - ); - } - - var pts = new List(value.Count / 3); - for (int i = 2; i < value.Count; i += 3) - { - pts.Add(new Point(value[i - 2], value[i - 1], value[i], units)); - } - - return pts; - } - - /// - /// Returns the values of this as a list of numbers - /// - /// A list of values representing the polyline. - public List ToList() - { - var list = new List(); - list.Add(closed ? 1 : 0); // 2 - list.Add(domain?.start ?? 0); // 3 - list.Add(domain?.end ?? 1); // 4 - list.Add(value.Count); // 5 - list.AddRange(value); // 6 onwards - - list.Add(Units.GetEncodingFromUnit(units)); - list.Insert(0, CurveTypeEncoding.Polyline); // 1 - list.Insert(0, list.Count); // 0 - return list; - } - - /// - /// Creates a new based on a list of coordinates and the unit they're drawn in. - /// - /// The list of values representing this polyline - /// A new with the provided values. - - public static Polyline FromList(List list) - { - var polyline = new Polyline { closed = list[2] == 1, domain = new Interval(list[3], list[4]) }; - var pointCount = (int)list[5]; - polyline.value = list.GetRange(6, pointCount); - polyline.units = Units.GetUnitFromEncoding(list[list.Count - 1]); - return polyline; - } -} diff --git a/DUI3-DX/Objects/Speckle.Objects.Common/Geometry/Vector.cs b/DUI3-DX/Objects/Speckle.Objects.Common/Geometry/Vector.cs deleted file mode 100644 index a80fe2cfad..0000000000 --- a/DUI3-DX/Objects/Speckle.Objects.Common/Geometry/Vector.cs +++ /dev/null @@ -1,261 +0,0 @@ -using System; -using System.Collections.Generic; -using Speckle.Core.Kits; -using Speckle.Core.Models; -using Speckle.Newtonsoft.Json; -using Speckle.Objects.Utils; - -namespace Speckle.Objects.Geometry; - -/// -/// A 3-dimensional vector -/// -public class Vector : Base, IHasBoundingBox, ITransformable -{ - /// - public Vector() { } - - /// - /// Constructs a new 2D from it's X and Y coordinates. - /// - /// The x coordinate of the vector - /// The y coordinate of the vector - /// The units the coordinates are in. - /// The unique application ID of the object. - public Vector(double x, double y, string units = Units.Meters, string? applicationId = null) - { - this.x = x; - this.y = y; - z = 0; - this.applicationId = applicationId; - this.units = units; - } - - /// - /// Constructs a new 2D from it's X and Y coordinates. - /// - /// The x coordinate of the vector - /// The y coordinate of the vector - /// The y coordinate of the vector - /// The units the coordinates are in. - /// The unique application ID of the object. - public Vector(double x, double y, double z, string units = Units.Meters, string? applicationId = null) - { - this.x = x; - this.y = y; - this.z = z; - this.applicationId = applicationId; - this.units = units; - } - - /// - /// Constructs a new from a - /// - /// The point whose coordinates will be used - /// The unique application ID of the object. - public Vector(Point point, string? applicationId = null) - : this(point.x, point.y, point.z, point.units ?? Units.None, applicationId) { } - - /// - /// Gets or sets the coordinates of the vector - /// - [ - JsonProperty(NullValueHandling = NullValueHandling.Ignore), - Obsolete("Use X,Y,Z fields to access coordinates instead", true) - ] - public List value - { -#pragma warning disable CS8603 // Possible null reference return. - get => null; -#pragma warning restore CS8603 // Possible null reference return. - set - { - x = value[0]; - y = value[1]; - z = value.Count > 2 ? value[2] : 0; - } - } - - /// - /// The unit's this is in. - /// This should be one of - /// - public string units { get; set; } = Units.None; - - /// - /// The x coordinate of the vector. - /// - public double x { get; set; } - - /// - /// The y coordinate of the vector. - /// - public double y { get; set; } - - /// - /// The z coordinate of the vector. - /// - public double z { get; set; } - - /// - /// Gets the Euclidean length of this vector. - /// - /// Length of the vector. - [JsonIgnore] - public double Length => Math.Sqrt(DotProduct(this, this)); - - /// - public Box bbox { get; set; } - - /// - public bool TransformTo(Transform transform, out Vector transformed) - { - var m = transform.matrix; - var tX = x * m.M11 + y * m.M12 + z * m.M13; - var tY = x * m.M21 + y * m.M22 + z * m.M23; - var tZ = x * m.M31 + y * m.M32 + z * m.M33; - transformed = new Vector(tX, tY, tZ, units, applicationId); - return true; - } - - /// - public bool TransformTo(Transform transform, out ITransformable transformed) - { - _ = TransformTo(transform, out Vector vec); - transformed = vec; - return true; - } - - /// - /// Returns the coordinates of this as a list of numbers - /// - /// A list of coordinates {x, y, z} - public List ToList() - { - return new List { x, y, z }; - } - - /// - /// Creates a new vector based on a list of coordinates and the unit they're drawn in. - /// - /// The list of coordinates {x, y, z} - /// The units the coordinates are in - /// A new with the provided coordinates. - public static Vector FromList(List list, string units) - { - return new Vector(list[0], list[1], list[2], units); - } - - /// - /// Divides a vector by a numerical value. This will divide each coordinate by the provided value. - /// - /// The vector to divide - /// The value to divide by - /// The resulting - public static Vector operator /(Vector vector, double val) => - new(vector.x / val, vector.y / val, vector.z / val, vector.units); - - /// - /// Multiplies a vector by a numerical value. This will multiply each coordinate by the provided value. - /// - /// The vector to multiply - /// The value to multiply by - /// The resulting - public static Vector operator *(Vector vector, double val) => - new(vector.x * val, vector.y * val, vector.z * val, vector.units); - - /// - /// Adds two vectors by adding each of their coordinates. - /// - /// The first vector - /// The second vector - /// The resulting - public static Vector operator +(Vector vector1, Vector vector2) => - new(vector1.x + vector2.x, vector1.y + vector2.y, vector1.z + vector2.z, vector1.units); - - /// - /// Subtracts two vectors by subtracting each of their coordinates. - /// - /// The first vector - /// The second vector - /// The resulting - public static Vector operator -(Vector vector1, Vector vector2) => - new(vector1.x - vector2.x, vector1.y - vector2.y, vector1.z - vector2.z, vector1.units); - - /// - /// Gets the scalar product (dot product) of two given vectors - /// Dot product = u1*v1 + u2*v2 + u3*v3. - /// - /// First vector. - /// Second vector. - /// Numerical value of the dot product. - public static double DotProduct(Vector u, Vector v) - { - return u.x * v.x + u.y * v.y + u.z * v.z; - } - - /// - /// Computes the vector product (cross product) of two given vectors - /// Cross product = { u2 * v3 - u3 * v2; u3 * v1 - u1 * v3; u1 * v2 - u2 * v1 }. - /// - /// First vector. - /// Second vector. - /// Vector result of the cross product. - public static Vector CrossProduct(Vector u, Vector v) - { - var x = u.y * v.z - u.z * v.y; - var y = u.z * v.x - u.x * v.z; - var z = u.x * v.y - u.y * v.x; - - return new Vector(x, y, z); - } - - public static double Angle(Vector u, Vector v) - { - return Math.Acos(DotProduct(u, v) / (u.Length * v.Length)); - } - - [Obsolete("Renamed to " + nameof(Normalize), true)] - public void Unitize() - { - Normalize(); - } - - /// - /// Compute and return a unit vector from this vector - /// - /// a normalized unit vector - public void Normalize() - { - var length = Length; - x /= length; - y /= length; - z /= length; - } - - /// - /// Inverses the direction of the vector, equivalent to multiplying by -1 - /// - /// A pointing in the opposite direction - public Vector Negate() - { - x *= -1; - y *= -1; - z *= -1; - return this; - } - - /// - /// Returns a normalized copy of this vector. - /// - /// A copy of this vector unitized. - public Vector Unit() - { - return this / Length; - } - - public static Vector Divide(Vector left, Vector right) - { - throw new NotImplementedException(); - } -} diff --git a/DUI3-DX/Objects/Speckle.Objects.Common/Primitives/Interval.cs b/DUI3-DX/Objects/Speckle.Objects.Common/Primitives/Interval.cs deleted file mode 100644 index 3b2ecd6f0c..0000000000 --- a/DUI3-DX/Objects/Speckle.Objects.Common/Primitives/Interval.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System; -using Speckle.Core.Models; -using Speckle.Newtonsoft.Json; - -namespace Speckle.Objects.Primitives; - -public class Interval : Base -{ - public Interval() { } - - public Interval(double start, double end) - { - this.start = start; - this.end = end; - } - - public double? start { get; set; } - public double? end { get; set; } - - [JsonIgnore] - public double Length => Math.Abs((end ?? 0) - (start ?? 0)); - - public override string ToString() - { - return base.ToString() + $"[{start}, {end}]"; - } -} diff --git a/DUI3-DX/Objects/Speckle.Objects.Common/Primitives/Interval2d.cs b/DUI3-DX/Objects/Speckle.Objects.Common/Primitives/Interval2d.cs deleted file mode 100644 index d044c0f820..0000000000 --- a/DUI3-DX/Objects/Speckle.Objects.Common/Primitives/Interval2d.cs +++ /dev/null @@ -1,23 +0,0 @@ -using Speckle.Core.Models; - -namespace Speckle.Objects.Primitives; - -public class Interval2d : Base -{ - public Interval2d() { } - - public Interval2d(Interval u, Interval v) - { - this.u = u; - this.v = v; - } - - public Interval2d(double start_u, double end_u, double start_v, double end_v) - { - u = new Interval(start_u, end_u); - v = new Interval(start_v, end_v); - } - - public Interval u { get; set; } - public Interval v { get; set; } -} diff --git a/DUI3-DX/Objects/Speckle.Objects.Common/Utils/Transform.cs b/DUI3-DX/Objects/Speckle.Objects.Common/Utils/Transform.cs deleted file mode 100644 index 39bbf697e9..0000000000 --- a/DUI3-DX/Objects/Speckle.Objects.Common/Utils/Transform.cs +++ /dev/null @@ -1,464 +0,0 @@ -using System; -using System.Collections.Generic; -using System.DoubleNumerics; -using Speckle.Core.Kits; -using Speckle.Core.Logging; -using Speckle.Core.Models; -using Speckle.Newtonsoft.Json; -using Speckle.Objects.Geometry; - -namespace Speckle.Objects.Utils; - -/// -/// Generic transform class -/// -public class Transform : Base -{ - public Transform() { } - - /// - /// Construct a transform from a row-based double array of size 16 - /// - /// - /// - /// - public Transform(double[] value, string units = Units.None) - { - if (value.Length != 16) - { - throw new ArgumentException( - $"{nameof(Transform)}.{nameof(value)} array is malformed: expected length to be 16", - nameof(value) - ); - } - - matrix = CreateMatrix(value); - this.units = units; - } - - /// - /// Construct a transform from a row-based float array of size 16 - /// - /// - /// - /// - public Transform(float[] value, string units = Units.None) - { - if (value.Length != 16) - { - throw new SpeckleException($"{nameof(Transform)}.{nameof(value)} array is malformed: expected length to be 16"); - } - - matrix = CreateMatrix(value); - this.units = units; - } - - /// - /// Construct a transform from a 4x4 matrix and translation units - /// - /// - /// - public Transform(Matrix4x4 matrix, string units = Units.None) - { - this.matrix = matrix; - this.units = units; - } - - /// - /// Construct a transform given the x, y, and z bases and the translation vector - /// - /// - /// - /// - /// - public Transform(Vector x, Vector y, Vector z, Vector translation) - { - matrix = new Matrix4x4( - x.x, - y.x, - z.x, - translation.x, - x.y, - y.y, - z.y, - translation.y, - x.z, - y.z, - z.z, - translation.z, - 0f, - 0f, - 0f, - 1f - ); - units = translation.units; - } - - /// - /// The column-based 4x4 transform matrix - /// - /// - /// Graphics based apps typically use column-based matrices, where the last column defines translation. - /// Modelling apps may use row-based matrices, where the last row defines translation. Transpose if so. - /// - public Matrix4x4 matrix { get; set; } = Matrix4x4.Identity; - - /// - /// Units for translation - /// - public string units { get; set; } = Units.None; - - /// - /// Decomposes matrix into its scaling, rotation, and translation components - /// - /// - /// - /// - /// True if successful, false otherwise - public void Decompose(out Vector3 scale, out Quaternion rotation, out Vector4 translation) - { - // translation - translation = new Vector4(matrix.M14, matrix.M24, matrix.M34, matrix.M44); - - // scale - // this should account for non-uniform scaling - Vector4 basis4dX = new(matrix.M11, matrix.M21, matrix.M31, matrix.M41); - Vector4 basis4dY = new(matrix.M12, matrix.M22, matrix.M32, matrix.M42); - Vector4 basis4dZ = new(matrix.M13, matrix.M23, matrix.M33, matrix.M43); - - // Check for mirroring - Vector3 basisX = new(matrix.M11, matrix.M21, matrix.M31); - Vector3 basisY = new(matrix.M12, matrix.M22, matrix.M32); - Vector3 basisZ = new(matrix.M13, matrix.M23, matrix.M33); - // Negative determinant means flip on Z. - // TODO: Add tests and figure out exactly why this is. Jedd and myself have some theories but it would be nice to document this properly - double determinant = Vector3.Dot(Vector3.Cross(basisX, basisY), basisZ) < 0 ? -1 : 1; - - // Compute the scale, but only multiply the Z scale by the determinant to flag negative scaling on Z axis (see todo above) - scale = new Vector3(basis4dX.Length(), basis4dY.Length(), basis4dZ.Length() * determinant); - - // rotation - // this is using a z-up convention for basis vectors - var up = new Vector3(matrix.M13, matrix.M23, matrix.M33); - var forward = new Vector3(matrix.M12, matrix.M22, matrix.M32); - rotation = LookRotation(forward, up); - } - - private static Quaternion LookRotation(Vector3 forward, Vector3 up) - { - Vector3 vector = new(forward.X / forward.Length(), forward.Y / forward.Length(), forward.Z / forward.Length()); - Vector3 vector2 = Vector3.Cross(up, forward); - Vector3 vector3 = Vector3.Cross(vector, vector2); - var m00 = vector2.X; - var m01 = vector2.Y; - var m02 = vector2.Z; - var m10 = vector3.X; - var m11 = vector3.Y; - var m12 = vector3.Z; - var m20 = vector.X; - var m21 = vector.Y; - var m22 = vector.Z; - - var num8 = m00 + m11 + m22; - if (num8 > 0d) - { - var num = Math.Sqrt(num8 + 1d); - num = 0.5d / num; - return new Quaternion((m12 - m21) * num, (m20 - m02) * num, (m01 - m10) * num, num * 0.5d); - } - if (m00 >= m11 && m00 >= m22) - { - var num7 = Math.Sqrt(1d + m00 - m11 - m22); - var num4 = 0.5d / num7; - return new Quaternion(0.5d * num7, (m01 + m10) * num4, (m02 + m20) * num4, (m12 - m21) * num4); - } - if (m11 > m22) - { - var num6 = Math.Sqrt(1d + m11 - m00 - m22); - var num3 = 0.5d / num6; - return new Quaternion((m10 + m01) * num3, 0.5d * num6, (m21 + m12) * num3, (m20 - m02) * num3); - } - var num5 = Math.Sqrt(1d + m22 - m00 - m11); - var num2 = 0.5d / num5; - return new Quaternion((m20 + m02) * num2, (m21 + m12) * num2, 0.5d * num5, (m01 - m10) * num2); - } - - /// - /// Converts this transform to the input units - /// - /// The target units - /// A matrix array with the translation scaled by input units - /// If either the transform's or the given is , will return the matrix array data unscaled - public double[] ConvertToUnits(string newUnits) - { - if (newUnits == null || units == null) - { - return ToArray(); - } - - var sf = Units.GetConversionFactor(units, newUnits); - - return new[] - { - matrix.M11, - matrix.M12, - matrix.M13, - matrix.M14 * sf, - matrix.M21, - matrix.M22, - matrix.M23, - matrix.M24 * sf, - matrix.M31, - matrix.M32, - matrix.M33, - matrix.M34 * sf, - matrix.M41, - matrix.M42, - matrix.M43, - matrix.M44 - }; - } - - public Transform Inverse() - { - if (Matrix4x4.Invert(matrix, out var transformed)) - { - return new Transform(transformed); - } - throw new SpeckleException("Could not create inverse transform"); - } - - /// - /// Returns the matrix that results from multiplying two matrices together. - /// - /// The first transform - /// The second transform - /// A transform matrix with the units of the first transform - public static Transform operator *(Transform t1, Transform t2) - { - var convertedTransform = CreateMatrix(t2.ConvertToUnits(t1.units)); - var newMatrix = t1.matrix * convertedTransform; - return new Transform(newMatrix, t1.units); - } - - /// - /// Returns the double array of the transform matrix - /// - /// - public double[] ToArray() - { - return new double[] - { - matrix.M11, - matrix.M12, - matrix.M13, - matrix.M14, - matrix.M21, - matrix.M22, - matrix.M23, - matrix.M24, - matrix.M31, - matrix.M32, - matrix.M33, - matrix.M34, - matrix.M41, - matrix.M42, - matrix.M43, - matrix.M44 - }; - } - - // Creates a matrix4x4 from a double array - internal static Matrix4x4 CreateMatrix(double[] value) - { - return new Matrix4x4( - value[0], - value[1], - value[2], - value[3], - value[4], - value[5], - value[6], - value[7], - value[8], - value[9], - value[10], - value[11], - value[12], - value[13], - value[14], - value[15] - ); - } - - // Creates a matrix from a float array - internal static Matrix4x4 CreateMatrix(float[] value) - { - return new Matrix4x4( - Convert.ToDouble(value[0]), - Convert.ToDouble(value[1]), - Convert.ToDouble(value[2]), - Convert.ToDouble(value[3]), - Convert.ToDouble(value[4]), - Convert.ToDouble(value[5]), - Convert.ToDouble(value[6]), - Convert.ToDouble(value[7]), - Convert.ToDouble(value[8]), - Convert.ToDouble(value[9]), - Convert.ToDouble(value[10]), - Convert.ToDouble(value[11]), - Convert.ToDouble(value[12]), - Convert.ToDouble(value[13]), - Convert.ToDouble(value[14]), - Convert.ToDouble(value[15]) - ); - } - - #region obsolete - - [JsonIgnore, Obsolete("Use the matrix property", true)] - [System.Diagnostics.CodeAnalysis.SuppressMessage( - "Performance", - "CA1819:Properties should not return arrays", - Justification = "Obsolete" - )] - public double[] value - { - get => ToArray(); - set => matrix = CreateMatrix(value); - } - - [JsonIgnore, Obsolete("Use Decompose method", true)] - public double rotationZ - { - get - { - Decompose(out _, out Quaternion rotation, out _); - return Math.Acos(rotation.W) * 2; - } - } - - /// - /// Transform a flat list of doubles representing points - /// - [Obsolete("Use transform method in Point class", true)] - public List ApplyToPoints(List points) - { - if (points.Count % 3 != 0) - { - throw new SpeckleException( - "Cannot apply transform as the points list is malformed: expected length to be multiple of 3" - ); - } - - var transformed = new List(points.Count); - for (var i = 0; i < points.Count; i += 3) - { - var point = new Point(points[i], points[i + 1], points[i + 2]); - point.TransformTo(this, out Point transformedPoint); - transformed.AddRange(transformedPoint.ToList()); - } - return transformed; - } - - /// - /// Transform a flat list of speckle Points - /// - [Obsolete("Use transform method in Point class", true)] - public List ApplyToPoints(List points) - { - var transformedPoints = new List(); - foreach (var point in points) - { - point.TransformTo(this, out Point transformedPoint); - transformedPoints.Add(transformedPoint); - } - return transformedPoints; - } - - /// - /// Transform a single speckle Point - /// - [Obsolete("Use transform method in Point class", true)] - public Point? ApplyToPoint(Point point) - { - if (point == null) - { - return null; - } - - point.TransformTo(this, out Point transformedPoint); - return transformedPoint; - } - - /// - /// Transform a list of three doubles representing a point - /// - [Obsolete("Use transform method in Point class", true)] - public List ApplyToPoint(List point) - { - var newPoint = new Point(point[0], point[1], point[2]); - newPoint.TransformTo(this, out Point transformed); - return transformed.ToList(); - } - - /// - /// Transform a single speckle Vector - /// - [Obsolete("Use transform method in Vector class", true)] - public Vector ApplyToVector(Vector vector) - { - var newCoords = ApplyToVector(new List { vector.x, vector.y, vector.z }); - - return new Vector(newCoords[0], newCoords[1], newCoords[2], vector.units, vector.applicationId); - } - - /// - /// Transform a list of three doubles representing a vector - /// - [Obsolete("Use transform method in Vector class", true)] - public List ApplyToVector(List vector) - { - var newPoint = new List(); - - for (var i = 0; i < 12; i += 4) - { - newPoint.Add(vector[0] * value[i] + vector[1] * value[i + 1] + vector[2] * value[i + 2]); - } - - return newPoint; - } - - /// - /// Transform a flat list of ICurves. Note that if any of the ICurves does not implement `ITransformable`, - /// it will not be returned. - /// - [Obsolete("Use transform method in Curve class", true)] - public List ApplyToCurves(List curves, out bool success) - { - // TODO: move to curve class - success = true; - var transformed = new List(); - foreach (var curve in curves) - { - if (curve is ITransformable c) - { - c.TransformTo(this, out ITransformable tc); - transformed.Add((ICurve)tc); - } - else - { - success = false; - } - } - - return transformed; - } - - public static Transform Multiply(Transform left, Transform right) - { - throw new NotImplementedException(); - } - - #endregion -} diff --git a/DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/Factory.cs b/DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/Factory.cs index abacd860c5..f173abc4e4 100644 --- a/DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/Factory.cs +++ b/DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/Factory.cs @@ -12,8 +12,9 @@ public Factory(IIndex types) _types = types; } - public TValue ResolveInstance(TKey strongName) + public TValue? ResolveInstance(TKey strongName) { - return _types[strongName]; + _types.TryGetValue(strongName, out TValue value); + return value; } } diff --git a/DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/IFactory.cs b/DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/IFactory.cs index 3a910be9cf..d3471c4cfb 100644 --- a/DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/IFactory.cs +++ b/DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/IFactory.cs @@ -8,5 +8,5 @@ namespace Speckle.Autofac.DependencyInjection; public interface IFactory where TValue : class { - TValue ResolveInstance(TKey strongName); + TValue? ResolveInstance(TKey strongName); } diff --git a/DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/NamedTypeInjector.cs b/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/NamedTypeInjector.cs similarity index 52% rename from DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/NamedTypeInjector.cs rename to DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/NamedTypeInjector.cs index 4afd8b2b43..465415ab33 100644 --- a/DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/NamedTypeInjector.cs +++ b/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/NamedTypeInjector.cs @@ -1,24 +1,25 @@ -using System; -using System.Collections.Generic; -using System.Linq; using System.Reflection; using Autofac; +using Speckle.Converters.Common.Objects; using Speckle.Core.Logging; -namespace Speckle.Autofac.DependencyInjection; +namespace Speckle.Converters.Common.DependencyInjection; -public static class NamedTypeInjector +public static class ConversionTypesInjector { public static ContainerBuilder InjectNamedTypes(this ContainerBuilder containerBuilder) - where T : class + where T : notnull { List types = new(); + // POC: hard-coding speckle... :/ foreach (var asm in AppDomain.CurrentDomain.GetAssemblies().Where(x => x.GetName().Name.StartsWith("Speckle"))) { try { var asmTypes = asm.GetTypes(); + + // POC: IsAssignableFrom() types.AddRange(asmTypes.Where(y => y.GetInterface(typeof(T).Name) != null)); } catch (Exception ex) when (!ex.IsFatal()) @@ -44,17 +45,47 @@ public static ContainerBuilder InjectNamedTypes(this ContainerBuilder contain { var namedTypes = byName.Where(x => x.name == name).OrderByDescending(y => y.rank).ToList(); - // first type + // first type found var first = namedTypes[0]; // POC: may need to be instance per lifecycle scope containerBuilder.RegisterType(first.type).Keyed(first.name).InstancePerLifetimeScope(); + // POC: not sure yet if... + // * This should be an array of types + // * Whether the scope should be modified or modifiable + // * Whether this is in the write project... hmmm + // POC: IsAssignableFrom() + var secondaryType = first.type.GetInterface(typeof(IRawConversion<,>).Name); + // POC: should we explode if no found? + if (secondaryType != null) + { + containerBuilder + .RegisterType(first.type) + .As(secondaryType) + .PropertiesAutowired(PropertyWiringOptions.AllowCircularDependencies) + .InstancePerLifetimeScope(); + } + // register subsequent types with rank namedTypes.RemoveAt(0); foreach (var other in namedTypes) { + // POC: is this the right scope? containerBuilder.RegisterType(other.type).Keyed($"{other.name}|{other.rank}").InstancePerLifetimeScope(); + + // POC: not sure yet if... + // * This should be an array of types + // * Whether the scope should be modified or modifiable + // * Whether this is in the write project... hmmm + // POC: IsAssignableFrom() + // NOT very DRY + secondaryType = secondaryType = first.type.GetInterface(typeof(IRawConversion<,>).Name); + // POC: should we explode if no found? + if (secondaryType != null) + { + containerBuilder.RegisterType(first.type).As(secondaryType).InstancePerLifetimeScope(); + } } } diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/Speckle.Converters.Common.DependencyInjection.csproj b/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/Speckle.Converters.Common.DependencyInjection.csproj new file mode 100644 index 0000000000..261381b8fe --- /dev/null +++ b/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/Speckle.Converters.Common.DependencyInjection.csproj @@ -0,0 +1,18 @@ + + + + netstandard2.0 + enable + enable + + + + + + + + + + + + diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common/ContextWrapper.cs b/DUI3-DX/Sdk/Speckle.Converters.Common/ContextWrapper.cs new file mode 100644 index 0000000000..77794f54e5 --- /dev/null +++ b/DUI3-DX/Sdk/Speckle.Converters.Common/ContextWrapper.cs @@ -0,0 +1,34 @@ +using System; + +namespace Speckle.Converters.Common; + +public class ContextWrapper : IDisposable + where TDocument : class +{ + private IConversionContextStack? _stack; + + public ConversionContext? Context { get; private set; } + + public ContextWrapper(IConversionContextStack stack) + { + _stack = stack; + Context = _stack.Current; + } + + protected virtual void Dispose(bool disposing) + { + if (disposing && _stack != null) + { + // technically we could be popping something not this but throwing in dispose is bad + _stack.Pop(); + _stack = null; + Context = null; + } + } + + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } +} diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common/ConversionContext.cs b/DUI3-DX/Sdk/Speckle.Converters.Common/ConversionContext.cs new file mode 100644 index 0000000000..178af2782c --- /dev/null +++ b/DUI3-DX/Sdk/Speckle.Converters.Common/ConversionContext.cs @@ -0,0 +1,15 @@ +namespace Speckle.Converters.Common; + +// POC: record? +public class ConversionContext + where TDocument : class +{ + public ConversionContext(TDocument doc, string speckleUnits) + { + Document = doc; + SpeckleUnits = speckleUnits; + } + + public TDocument Document { get; protected set; } + public string SpeckleUnits { get; private set; } +} diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common/ConversionContextStack.cs b/DUI3-DX/Sdk/Speckle.Converters.Common/ConversionContextStack.cs new file mode 100644 index 0000000000..e824ed511e --- /dev/null +++ b/DUI3-DX/Sdk/Speckle.Converters.Common/ConversionContextStack.cs @@ -0,0 +1,47 @@ +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; + +namespace Speckle.Converters.Common; + +// POC: Suppressed naming warning for now, but we should evaluate if we should follow this or disable it. +[SuppressMessage( + "Naming", + "CA1711:Identifiers should not have incorrect suffix", + Justification = "Name ends in Stack but it is in fact a Stack, just not inheriting from `System.Collections.Stack`" +)] +public class ConversionContextStack : IConversionContextStack + where TDocument : class +{ + private readonly IHostToSpeckleUnitConverter _unitConverter; + private readonly TDocument _document; + + protected ConversionContextStack( + TDocument document, + THostUnit hostUnit, + IHostToSpeckleUnitConverter unitConverter + ) + { + _document = document; + _unitConverter = unitConverter; + + _stack.Push(new ConversionContext(_document, _unitConverter.ConvertOrThrow(hostUnit))); + } + + private readonly Stack> _stack = new(); + + public ConversionContext Current => _stack.Peek(); + + public ContextWrapper Push(string speckleUnit) + { + var context = new ConversionContext(_document, speckleUnit); + _stack.Push(context); + return new ContextWrapper(this); + } + + public ContextWrapper Push(THostUnit hostUnit) + { + return Push(_unitConverter.ConvertOrThrow(hostUnit)); + } + + public void Pop() => _stack.Pop(); +} diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common/IConversionContextStack.cs b/DUI3-DX/Sdk/Speckle.Converters.Common/IConversionContextStack.cs new file mode 100644 index 0000000000..d06a35f778 --- /dev/null +++ b/DUI3-DX/Sdk/Speckle.Converters.Common/IConversionContextStack.cs @@ -0,0 +1,18 @@ +using System.Diagnostics.CodeAnalysis; + +namespace Speckle.Converters.Common; + +// POC: Suppressed naming warning for now, but we should evaluate if we should follow this or disable it. +[SuppressMessage( + "Naming", + "CA1711:Identifiers should not have incorrect suffix", + Justification = "Name ends in Stack but it is in fact a Stack, just not inheriting from `System.Collections.Stack`" +)] +public interface IConversionContextStack + where TDocument : class +{ + ContextWrapper Push(string speckleUnit); + ContextWrapper Push(THostUnit hostUnit); + void Pop(); + ConversionContext Current { get; } +} diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common/IHostToSpeckleUnitConverter.cs b/DUI3-DX/Sdk/Speckle.Converters.Common/IHostToSpeckleUnitConverter.cs new file mode 100644 index 0000000000..f4413a9ea7 --- /dev/null +++ b/DUI3-DX/Sdk/Speckle.Converters.Common/IHostToSpeckleUnitConverter.cs @@ -0,0 +1,6 @@ +namespace Speckle.Converters.Common; + +public interface IHostToSpeckleUnitConverter +{ + string ConvertOrThrow(THostUnit hostUnit); +} diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common/ISpeckleConverterToSpeckle.cs b/DUI3-DX/Sdk/Speckle.Converters.Common/ISpeckleConverterToSpeckle.cs index bf2334b77d..459cb99736 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common/ISpeckleConverterToSpeckle.cs +++ b/DUI3-DX/Sdk/Speckle.Converters.Common/ISpeckleConverterToSpeckle.cs @@ -1,6 +1,8 @@ +using Speckle.Core.Models; + namespace Speckle.Converters.Common; public interface ISpeckleConverterToSpeckle { - void Convert(); + Base Convert(object target); } diff --git a/DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/NameAndRankValueAttribute.cs b/DUI3-DX/Sdk/Speckle.Converters.Common/NameAndRankValueAttribute.cs similarity index 57% rename from DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/NameAndRankValueAttribute.cs rename to DUI3-DX/Sdk/Speckle.Converters.Common/NameAndRankValueAttribute.cs index 8ecd2b454f..e1ac7fc04b 100644 --- a/DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/NameAndRankValueAttribute.cs +++ b/DUI3-DX/Sdk/Speckle.Converters.Common/NameAndRankValueAttribute.cs @@ -1,10 +1,14 @@ -using System; +using System; -namespace Speckle.Autofac.DependencyInjection; +namespace Speckle.Converters.Common; +// POC: maybe better to put in utils/reflection [AttributeUsage(AttributeTargets.Class)] public sealed class NameAndRankValueAttribute : Attribute { + // DO NOT CHANGE! This is the base, lowest rank for a conversion + public const int SPECKLE_DEFAULT_RANK = 0; + public string Name { get; private set; } public int Rank { get; private set; } diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common/Objects/IHostObjectToSpeckleConversion.cs b/DUI3-DX/Sdk/Speckle.Converters.Common/Objects/IHostObjectToSpeckleConversion.cs index 957f73605e..f12977017e 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common/Objects/IHostObjectToSpeckleConversion.cs +++ b/DUI3-DX/Sdk/Speckle.Converters.Common/Objects/IHostObjectToSpeckleConversion.cs @@ -1,3 +1,5 @@ +using Speckle.Core.Models; + namespace Speckle.Converters.Common.Objects; // POC: NEXT UP @@ -6,5 +8,5 @@ namespace Speckle.Converters.Common.Objects; public interface IHostObjectToSpeckleConversion { - void Convert(); + Base Convert(object target); } diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common/Objects/IRawConversion.cs b/DUI3-DX/Sdk/Speckle.Converters.Common/Objects/IRawConversion.cs new file mode 100644 index 0000000000..a9d11843e1 --- /dev/null +++ b/DUI3-DX/Sdk/Speckle.Converters.Common/Objects/IRawConversion.cs @@ -0,0 +1,6 @@ +namespace Speckle.Converters.Common.Objects; + +public interface IRawConversion +{ + TOut RawConvert(TIn target); +} diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common/Speckle.Converters.Common.csproj b/DUI3-DX/Sdk/Speckle.Converters.Common/Speckle.Converters.Common.csproj index 766f6bc7b1..a375df49cf 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common/Speckle.Converters.Common.csproj +++ b/DUI3-DX/Sdk/Speckle.Converters.Common/Speckle.Converters.Common.csproj @@ -6,7 +6,7 @@ - +
diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common/SpeckleConversionException.cs b/DUI3-DX/Sdk/Speckle.Converters.Common/SpeckleConversionException.cs new file mode 100644 index 0000000000..2500ca9aab --- /dev/null +++ b/DUI3-DX/Sdk/Speckle.Converters.Common/SpeckleConversionException.cs @@ -0,0 +1,14 @@ +using System; + +namespace Speckle.Converters.Common; + +public class SpeckleConversionException : Exception +{ + public SpeckleConversionException() { } + + public SpeckleConversionException(string message) + : base(message) { } + + public SpeckleConversionException(string message, Exception innerException) + : base(message, innerException) { } +} From 522c814e5c708e58c10e3a0b19bca52be1489b65 Mon Sep 17 00:00:00 2001 From: Alan Rynne Date: Thu, 21 Mar 2024 18:09:47 +0100 Subject: [PATCH 012/261] fix: Use context to extract units on vector converter. (#3243) * fix: Use context to extract units on vector converter. * fix: Removed unnecessary using statement --- .../Geometry/VectorToSpeckleConverter.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Geometry/VectorToSpeckleConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Geometry/VectorToSpeckleConverter.cs index 9db6fb87cc..e675e7f931 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Geometry/VectorToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Geometry/VectorToSpeckleConverter.cs @@ -1,7 +1,6 @@ using Rhino; using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; -using Speckle.Core.Kits; using Speckle.Core.Models; namespace Speckle.Converters.Rhino7.Geometry; @@ -18,5 +17,6 @@ public VectorToSpeckleConverter(IConversionContextStack co public Base Convert(object target) => RawConvert((RG.Vector3d)target); - public SOG.Vector RawConvert(RG.Vector3d target) => new(target.X, target.Y, target.Z, Units.Meters); + public SOG.Vector RawConvert(RG.Vector3d target) => + new(target.X, target.Y, target.Z, _contextStack.Current.SpeckleUnits); } From c472bf9b67791027a706b94cab3b71f35fde6912 Mon Sep 17 00:00:00 2001 From: connorivy <43247197+connorivy@users.noreply.github.com> Date: Fri, 22 Mar 2024 10:13:07 -0500 Subject: [PATCH 013/261] feat(rhino) : CNX-9145 DI and creation of send operation services (#3238) * change async void to async Task * inject send filters * more DI * inject cancellation manager * inject SendBindingUICommands * simplify transport registration * add some comments * use single send operation * fix incorrect configureAwait * remove unused import * ci please stop complaining * continued conflict resolution * remove unused usings * rename things per Ian's comments * fix(dui3): Make all basic binding commands available to sendbindings command type (#3245) * chore: Added POC comments and minor cleanup * fix(dui3): Renamed `RootObjectSender` as requested + minor warning fix * fix(dui3): Use converter scoped factory as Ian's inital pattern suggested * fix(dui3): Removed unused factory and made command name const --------- Co-authored-by: Connor Ivy Co-authored-by: Alan Rynne --- All.sln.DotSettings | 2 + DUI3-DX-RHINO.slnf | 18 ++ .../Bindings/SendBinding.cs | 5 +- .../Bindings/RhinoSelectionBinding.cs | 2 +- .../Bindings/RhinoSendBinding.cs | 253 +++--------------- .../DependencyInjection/AutofacRhinoModule.cs | 21 +- .../Filters/RhinoSelectionFilter.cs | 2 +- .../Operations/Send/IRootObjectSender.cs | 23 ++ .../Operations/Send/RootObjectBuilder.cs | 229 ++++++++++++++++ .../Operations/Send/RootObjectSender.cs | 79 ++++++ .../Operations/Send/SendOperation.cs | 52 ++++ .../Speckle.Connectors.Rhino7.csproj | 2 +- .../Bindings/IBasicConnectorBinding.cs | 10 +- .../Bindings/ISendBinding.cs | 3 +- .../Bindings/SendBindingUICommands.cs | 22 +- 15 files changed, 476 insertions(+), 247 deletions(-) create mode 100644 DUI3-DX-RHINO.slnf create mode 100644 DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Send/IRootObjectSender.cs create mode 100644 DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Send/RootObjectBuilder.cs create mode 100644 DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Send/RootObjectSender.cs create mode 100644 DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Send/SendOperation.cs diff --git a/All.sln.DotSettings b/All.sln.DotSettings index 1170e1aa0a..047cb5195c 100644 --- a/All.sln.DotSettings +++ b/All.sln.DotSettings @@ -10,7 +10,9 @@ SUGGESTION SUGGESTION HINT + HINT HINT + HINT DO_NOT_SHOW HINT diff --git a/DUI3-DX-RHINO.slnf b/DUI3-DX-RHINO.slnf new file mode 100644 index 0000000000..7ffe9697a8 --- /dev/null +++ b/DUI3-DX-RHINO.slnf @@ -0,0 +1,18 @@ +{ + "solution": { + "path": "All.sln", + "projects": [ + "Core\\Core\\Core.csproj", + "DUI3-DX\\Connectors\\Rhino\\Speckle.Connectors.Rhino7\\Speckle.Connectors.Rhino7.csproj", + "DUI3-DX\\Converters\\Rhino\\Speckle.Converters.Rhino7.DependencyInjection\\Speckle.Converters.Rhino7.DependencyInjection.csproj", + "DUI3-DX\\Converters\\Rhino\\Speckle.Converters.Rhino7\\Speckle.Converters.Rhino7.csproj", + "DUI3-DX\\DUI3\\Speckle.Connectors.DUI\\Speckle.Connectors.DUI.csproj", + "DUI3-DX\\Objects\\Speckle.Objects.Common\\Speckle.Objects.Common.csproj", + "DUI3-DX\\Sdk\\Speckle.Autofac\\Speckle.Autofac.csproj", + "DUI3-DX\\Sdk\\Speckle.Connectors.Utils\\Speckle.Connectors.Utils.csproj", + "DUI3-DX\\Sdk\\Speckle.Converters.Common.DependencyInjection\\Speckle.Converters.Common.DependencyInjection.csproj", + "DUI3-DX\\Sdk\\Speckle.Converters.Common\\Speckle.Converters.Common.csproj", + "Objects\\Objects\\Objects.csproj" + ] + } +} \ No newline at end of file diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SendBinding.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SendBinding.cs index af40fd9f3d..ebdf72707e 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SendBinding.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SendBinding.cs @@ -11,6 +11,7 @@ using Speckle.Connectors.Utils; using Speckle.Autofac.DependencyInjection; using Speckle.Converters.Common; +using System.Threading.Tasks; namespace Speckle.Connectors.Revit.Bindings; @@ -50,7 +51,7 @@ public List GetSendFilters() return new List { new RevitEverythingFilter(), new RevitSelectionFilter() }; } - public async void Send(string modelCardId) + public Task Send(string modelCardId) { SpeckleTopLevelExceptionHandler.Run( () => HandleSend(modelCardId), @@ -58,6 +59,8 @@ public async void Send(string modelCardId) HandleUnexpectedException, HandleFatalException ); + + return Task.CompletedTask; } public void CancelSend(string modelCardId) diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSelectionBinding.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSelectionBinding.cs index 23618e5d06..395055fc69 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSelectionBinding.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSelectionBinding.cs @@ -12,7 +12,7 @@ public class RhinoSelectionBinding : ISelectionBinding { private const string SELECTION_EVENT = "setSelection"; - public string Name { get; set; } = "selectionBinding"; + public string Name { get; } = "selectionBinding"; public IBridge Parent { get; set; } public RhinoSelectionBinding(RhinoIdleManager idleManager, IBridge parent) diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSendBinding.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSendBinding.cs index da81252515..deafbc25fd 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSendBinding.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSendBinding.cs @@ -4,24 +4,17 @@ using System.Linq; using System.Threading; using Rhino; -using Rhino.DocObjects; -using Speckle.Autofac.DependencyInjection; -using Speckle.Core.Credentials; -using Speckle.Core.Models; -using Speckle.Core.Transports; using Speckle.Connectors.DUI.Bindings; using Speckle.Connectors.DUI.Bridge; using Speckle.Connectors.DUI.Models; using Speckle.Connectors.DUI.Models.Card; using Speckle.Connectors.DUI.Utils; -using Speckle.Connectors.Rhino7.Filters; using Speckle.Connectors.Rhino7.HostApp; using Speckle.Connectors.Utils.Cancellation; -using Speckle.Connectors.Utils.Operations; -using Speckle.Converters.Common; -using Speckle.Core.Api; using Speckle.Core.Logging; using ICancelable = System.Reactive.Disposables.ICancelable; +using System.Threading.Tasks; +using Speckle.Connectors.Rhino7.Operations.Send; namespace Speckle.Connectors.Rhino7.Bindings; @@ -33,13 +26,9 @@ public sealed class RhinoSendBinding : ISendBinding, ICancelable private readonly DocumentModelStore _store; private readonly RhinoIdleManager _idleManager; - private readonly RhinoSettings _rhinoSettings; - private readonly RhinoContext _rhinoContext; - private readonly IBasicConnectorBinding _basicConnectorBinding; - private readonly ISpeckleConverterToSpeckle _toSpeckleConverter; - private readonly IScopedFactory _speckleConverterToSpeckleFactory; - - public CancellationManager CancellationManager { get; } = new(); + private readonly List _sendFilters; + private readonly SendOperation _sendOperation; + private readonly CancellationManager _cancellationManager; /// /// Used internally to aggregate the changed objects' id. @@ -55,24 +44,25 @@ public sealed class RhinoSendBinding : ISendBinding, ICancelable public RhinoSendBinding( DocumentModelStore store, RhinoIdleManager idleManager, - RhinoSettings rhinoSettings, IBridge parent, - IBasicConnectorBinding basicConnectorBinding, - IScopedFactory speckleConverterToSpeckleFactory, - RhinoContext rhinoContext + IEnumerable sendFilters, + SendOperation sendOperation, + CancellationManager cancellationManager ) { _store = store; _idleManager = idleManager; - _rhinoSettings = rhinoSettings; - _basicConnectorBinding = basicConnectorBinding; - _speckleConverterToSpeckleFactory = speckleConverterToSpeckleFactory; - _rhinoContext = rhinoContext; - _toSpeckleConverter = _speckleConverterToSpeckleFactory.ResolveScopedInstance(); - + _sendFilters = sendFilters.ToList(); + _sendOperation = sendOperation; + _cancellationManager = cancellationManager; Parent = parent; - Commands = new SendBindingUICommands(parent); + Commands = new SendBindingUICommands(parent); // POC: Commands are tightly coupled with their bindings, at least for now, saves us injecting a factory. + SubscribeToRhinoEvents(); + } + private void SubscribeToRhinoEvents() + { + // POC: It is unclear to me why is the binding keeping track of ChangedObjectIds. Change tracking should be moved to a separate type. RhinoDoc.LayerTableEvent += (_, _) => { Commands.RefreshSendFilters(); @@ -116,14 +106,7 @@ RhinoContext rhinoContext }; } - public List GetSendFilters() - { - return new List - { - new RhinoEverythingFilter(), - new RhinoSelectionFilter { IsDefault = true } - }; - } + public List GetSendFilters() => _sendFilters; public List GetSendSettings() { @@ -144,83 +127,31 @@ public List GetSendSettings() "CA1506:Avoid excessive class coupling", Justification = "Being refactored on in parallel, muting this issue so CI can pass initially." )] - public async void Send(string modelCardId) + public async Task Send(string modelCardId) { try { // 0 - Init cancellation token source -> Manager also cancel it if exist before - CancellationTokenSource cts = CancellationManager.InitCancellationTokenSource(modelCardId); + CancellationTokenSource cts = _cancellationManager.InitCancellationTokenSource(modelCardId); // 1 - Get model - if (_store.GetModelById(modelCardId) is not SenderModelCard modelCard) { throw new InvalidOperationException("No publish model card was found."); } - // 2 - Check account exist - // TODO: FETCHING ACCOUNTS BY ID ONLY IS UNSAFE - Account account = - AccountManager.GetAccounts().FirstOrDefault(acc => acc.id == modelCard.AccountId) - ?? throw new SpeckleAccountManagerException(); - - // 3 - Get elements to convert, throw early if nothing is selected - List rhinoObjects = modelCard.SendFilter - .GetObjectIds() - .Select(id => RhinoDoc.ActiveDoc.Objects.FindId(new Guid(id))) - .Where(obj => obj != null) - .ToList(); - - if (rhinoObjects.Count == 0) - { - throw new InvalidOperationException("No objects were found. Please update your send filter!"); - } - - // 4 - Get converter - - var commitObject = ConvertObjects(rhinoObjects, modelCard, cts.Token); - - cts.Token.ThrowIfCancellationRequested(); - - // 7 - Serialize and Send objects - _basicConnectorBinding.Commands.SetModelProgress(modelCardId, new ModelCardProgress { Status = "Uploading..." }); - - var transport = new ServerTransport(account, modelCard.ProjectId); - var sendResult = await SendHelper.Send(commitObject, transport, true, null, cts.Token).ConfigureAwait(true); - - // Store the converted references in memory for future send operations, overwriting the existing values for the given application id. - // foreach (var kvp in sendResult.convertedReferences) - // { - // // TODO: Bug in here, we need to encapsulate cache not only by app id, but also by project id, - // // TODO: as otherwise we assume incorrectly that an object exists for a given project (e.g, send box to project 1, send same unchanged box to project 2) - // _convertedObjectReferences[kvp.Key + modelCard.ProjectId] = kvp.Value; - // } - // It's important to reset the model card's list of changed obj ids so as to ensure we accurately keep track of changes between send operations. - // NOTE: ChangedObjectIds is currently JsonIgnored, but could actually be useful for highlighting changes in host app. - //modelCard.ChangedObjectIds = new(); - - _basicConnectorBinding.Commands.SetModelProgress( - modelCardId, - new ModelCardProgress { Status = "Linking version to model..." } - ); - - // 8 - Create the version (commit) - var apiClient = new Client(account); - string versionId = await apiClient - .CommitCreate( - new CommitCreateInput - { - streamId = modelCard.ProjectId, - branchName = modelCard.ModelId, - sourceApplication = "Rhino", - objectId = sendResult.rootObjId - }, + string versionId = await _sendOperation + .Execute( + modelCard.SendFilter, + modelCard.AccountId, + modelCard.ProjectId, + modelCard.ModelId, + (status, progress) => OnSendOperationProgress(modelCardId, status, progress), cts.Token ) - .ConfigureAwait(true); + .ConfigureAwait(false); Commands.SetModelCreatedVersionId(modelCardId, versionId); - apiClient.Dispose(); } catch (OperationCanceledException) { @@ -228,135 +159,16 @@ public async void Send(string modelCardId) } catch (Exception e) when (!e.IsFatal()) // All exceptions should be handled here if possible, otherwise we enter "crashing the host app" territory. { - _basicConnectorBinding.Commands.SetModelError(modelCardId, e); + Commands.SetModelError(modelCardId, e); } } - public void CancelSend(string modelCardId) => CancellationManager.CancelOperation(modelCardId); - - private Base ConvertObjects( - List rhinoObjects, - SenderModelCard modelCard, - CancellationToken cancellationToken - ) + private void OnSendOperationProgress(string modelCardId, string status, double? progress) { - ISpeckleConverterToSpeckle converter = _speckleConverterToSpeckleFactory.ResolveScopedInstance(); - - var rootObjectCollection = new Collection { name = RhinoDoc.ActiveDoc.Name ?? "Unnamed document" }; - int count = 0; - - Dictionary layerCollectionCache = new(); - // TODO: Handle blocks. - foreach (RhinoObject rhinoObject in rhinoObjects) - { - cancellationToken.ThrowIfCancellationRequested(); - - // 1. get object layer - var layer = RhinoDoc.ActiveDoc.Layers[rhinoObject.Attributes.LayerIndex]; - - // 2. get or create a nested collection for it - var collectionHost = GetHostObjectCollection(layerCollectionCache, layer, rootObjectCollection); - var applicationId = rhinoObject.Id.ToString(); - - // 3. get from cache or convert: - // What we actually do here is check if the object has been previously converted AND has not changed. - // If that's the case, we insert in the host collection just its object reference which has been saved from the prior conversion. - /*Base converted; - if ( - !modelCard.ChangedObjectIds.Contains(applicationId) - && _convertedObjectReferences.TryGetValue(applicationId + modelCard.ProjectId, out ObjectReference value) - ) - { - converted = value; - } - else - { - converted = converter.ConvertToSpeckle(rhinoObject); - converted.applicationId = applicationId; - }*/ - try - { - var converted = converter.Convert(rhinoObject); - converted.applicationId = applicationId; - - // 4. add to host - collectionHost.elements.Add(converted); - _basicConnectorBinding.Commands.SetModelProgress( - modelCard.ModelCardId, - new ModelCardProgress { Status = "Converting", Progress = (double)++count / rhinoObjects.Count } - ); - } - catch (SpeckleConversionException e) - { - // DO something with the exception - Console.WriteLine(e); - } - catch (NotSupportedException e) - { - // DO something with the exception - Console.WriteLine(e); - } - - // NOTE: useful for testing ui states, pls keep for now so we can easily uncomment - // Thread.Sleep(550); - } - - // 5. profit - return rootObjectCollection; + Commands.SetModelProgress(modelCardId, new ModelCardProgress { Status = status, Progress = progress }); } - /// - /// Returns the host collection based on the provided layer. If it's not found, it will be created and hosted within the the rootObjectCollection. - /// - /// - /// - /// - /// - private Collection GetHostObjectCollection( - Dictionary layerCollectionCache, - Layer layer, - Collection rootObjectCollection - ) - { - if (layerCollectionCache.TryGetValue(layer.Index, out Collection value)) - { - return value; - } - - var names = layer.FullPath.Split(new[] { Layer.PathSeparator }, StringSplitOptions.None); - var path = names[0]; - var index = 0; - var previousCollection = rootObjectCollection; - foreach (var layerName in names) - { - var existingLayerIndex = RhinoDoc.ActiveDoc.Layers.FindByFullPath(path, -1); - Collection? childCollection = null; - if (layerCollectionCache.TryGetValue(existingLayerIndex, out Collection? collection)) - { - childCollection = collection; - } - else - { - childCollection = new Collection(layerName, "layer") - { - applicationId = RhinoDoc.ActiveDoc.Layers[existingLayerIndex].Id.ToString() - }; - previousCollection.elements.Add(childCollection); - layerCollectionCache[existingLayerIndex] = childCollection; - } - - previousCollection = childCollection; - - if (index < names.Length - 1) - { - path += Layer.PathSeparator + names[index + 1]; - } - index++; - } - - layerCollectionCache[layer.Index] = previousCollection; - return previousCollection; - } + public void CancelSend(string modelCardId) => _cancellationManager.CancelOperation(modelCardId); /// /// Checks if any sender model cards contain any of the changed objects. If so, also updates the changed objects hashset for each model card - this last part is important for on send change detection. @@ -382,7 +194,6 @@ private void RunExpirationChecks() public void Dispose() { IsDisposed = true; - _speckleConverterToSpeckleFactory.Dispose(); } public bool IsDisposed { get; private set; } diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/AutofacRhinoModule.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/AutofacRhinoModule.cs index 3da5049631..5222a889bf 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/AutofacRhinoModule.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/AutofacRhinoModule.cs @@ -11,9 +11,13 @@ using Speckle.Connectors.DUI.Models; using Speckle.Connectors.DUI.Utils; using Speckle.Connectors.Rhino7.Bindings; +using Speckle.Connectors.Rhino7.Filters; using Speckle.Connectors.Rhino7.HostApp; using Speckle.Connectors.Rhino7.Interfaces; +using Speckle.Connectors.Rhino7.Operations.Send; using Speckle.Connectors.Rhino7.Plugin; +using Speckle.Connectors.Utils.Cancellation; +using Speckle.Core.Transports; using Speckle.Converters.Common; using Speckle.Converters.Rhino7; using Speckle.Newtonsoft.Json; @@ -34,13 +38,12 @@ protected override void Load(ContainerBuilder builder) // Register DUI3 related stuff builder.RegisterInstance(GetJsonSerializerSettings()).SingleInstance(); builder.RegisterType().SingleInstance(); - builder.RegisterType().As().InstancePerDependency(); //TODO: Verify why we need one bridge instance per dependency. + builder.RegisterType().As().InstancePerDependency(); // POC: Each binding should have it's own bridge instance // Register other connector specific types builder.RegisterType().As().SingleInstance(); builder.RegisterType().As().SingleInstance(); builder.RegisterType().SingleInstance(); - builder.RegisterType().InstancePerLifetimeScope(); // Register bindings builder.RegisterType().As().SingleInstance(); @@ -49,7 +52,19 @@ protected override void Load(ContainerBuilder builder) builder.RegisterType().As().SingleInstance(); builder.RegisterType().As>().SingleInstance(); - // Register converter factory + // binding dependencies + builder.RegisterType().InstancePerDependency(); + + // register send filters + builder.RegisterType().As().InstancePerDependency(); + builder.RegisterType().As().InstancePerDependency(); + + // register send operation and dependencies + builder.RegisterType().SingleInstance(); + builder.RegisterType().SingleInstance(); + builder.RegisterType().As().SingleInstance(); + builder.RegisterType().As().InstancePerDependency(); + builder .RegisterType>() .As>() diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Filters/RhinoSelectionFilter.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Filters/RhinoSelectionFilter.cs index 4ca0e742c6..7a9db8a5d0 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Filters/RhinoSelectionFilter.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Filters/RhinoSelectionFilter.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; using Speckle.Connectors.DUI.Bindings; diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Send/IRootObjectSender.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Send/IRootObjectSender.cs new file mode 100644 index 0000000000..c0226c2f63 --- /dev/null +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Send/IRootObjectSender.cs @@ -0,0 +1,23 @@ +using System; +using System.Threading; +using System.Threading.Tasks; +using Speckle.Core.Models; + +namespace Speckle.Connectors.Rhino7.Operations.Send; + +/// +/// Contract for the send operation that handles an assembled object. +/// In production, this will send to a server. +/// In testing, this could send to a sqlite db or just save to a dictionary. +/// +public interface IRootObjectSender +{ + public Task Send( + Base commitObject, + string accountId, + string projectId, + string modelId, + Action? onOperationProgressed = null, + CancellationToken ct = default + ); +} diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Send/RootObjectBuilder.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Send/RootObjectBuilder.cs new file mode 100644 index 0000000000..d47cb8f345 --- /dev/null +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Send/RootObjectBuilder.cs @@ -0,0 +1,229 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using Rhino.DocObjects; +using Rhino; +using Speckle.Connectors.DUI.Bindings; +using Speckle.Core.Models; +using System.Threading; +using Speckle.Autofac.DependencyInjection; +using Speckle.Converters.Common; + +namespace Speckle.Connectors.Rhino7.Operations.Send; + +/// +/// Stateless builder object to turn an into a object +/// +public class RootObjectBuilder +{ + private readonly IScopedFactory _converterFactory; + + public RootObjectBuilder(IScopedFactory converterFactory) + { + _converterFactory = converterFactory; + } + + public Base Build( + ISendFilter sendFilter, + Action? onOperationProgressed = null, + CancellationToken ct = default + ) + { + List rhinoObjects = sendFilter + .GetObjectIds() + .Select(id => RhinoDoc.ActiveDoc.Objects.FindId(new Guid(id))) + .Where(obj => obj != null) + .ToList(); + + if (rhinoObjects.Count == 0) + { + throw new InvalidOperationException("No objects were found. Please update your send filter!"); + } + + Base commitObject = ConvertObjects(rhinoObjects, onOperationProgressed, ct); + + return commitObject; + } + + private Collection ConvertObjects( + List rhinoObjects, + Action? onOperationProgressed = null, + CancellationToken cancellationToken = default + ) + { + var rootObjectCollection = new Collection { name = RhinoDoc.ActiveDoc.Name ?? "Unnamed document" }; + int count = 0; + + Dictionary layerCollectionCache = new(); // POC: This seems to always start empty, so it's not caching anything out here. + + // POC: Handle blocks. + foreach (RhinoObject rhinoObject in rhinoObjects) + { + cancellationToken.ThrowIfCancellationRequested(); + + // POC: This uses the ActiveDoc but it is bad practice to do so. A context object should be injected that would contain the Doc. + var layer = RhinoDoc.ActiveDoc.Layers[rhinoObject.Attributes.LayerIndex]; + + var collectionHost = GetHostObjectCollection(layerCollectionCache, layer, rootObjectCollection); + var applicationId = rhinoObject.Id.ToString(); + + // get from cache or convert: + // POC: We're not using the cache here yet but should once the POC is working. + // What we actually do here is check if the object has been previously converted AND has not changed. + // If that's the case, we insert in the host collection just its object reference which has been saved from the prior conversion. + /*Base converted; + if ( + !modelCard.ChangedObjectIds.Contains(applicationId) + && _convertedObjectReferences.TryGetValue(applicationId + modelCard.ProjectId, out ObjectReference value) + ) + { + converted = value; + } + else + { + converted = converter.ConvertToSpeckle(rhinoObject); + converted.applicationId = applicationId; + }*/ + try + { + var converter = _converterFactory.ResolveScopedInstance(); + Base converted = converter.Convert(rhinoObject); + converted.applicationId = applicationId; + + // add to host + collectionHost.elements.Add(converted); + onOperationProgressed?.Invoke("Converting", (double)++count / rhinoObjects.Count); + } + // POC: Exception handling on conversion logic must be revisited after several connectors have working conversions + catch (SpeckleConversionException e) + { + // POC: DO something with the exception + Console.WriteLine(e); + } + catch (NotSupportedException e) + { + // POC: DO something with the exception + Console.WriteLine(e); + } + + // NOTE: useful for testing ui states, pls keep for now so we can easily uncomment + // Thread.Sleep(550); + } + + // 5. profit + return rootObjectCollection; + } + + /// + /// Returns the host collection based on the provided layer. If it's not found, it will be created and hosted within the the rootObjectCollection. + /// + /// + /// + /// + /// + private Collection GetHostObjectCollection( + Dictionary layerCollectionCache, + Layer layer, + Collection rootObjectCollection + ) + { + // POC: This entire implementation should be broken down and potentially injected in. + if (layerCollectionCache.TryGetValue(layer.Index, out Collection value)) + { + return value; + } + + var names = layer.FullPath.Split(new[] { Layer.PathSeparator }, StringSplitOptions.None); + var path = names[0]; + var index = 0; + var previousCollection = rootObjectCollection; + foreach (var layerName in names) + { + var existingLayerIndex = RhinoDoc.ActiveDoc.Layers.FindByFullPath(path, -1); + Collection? childCollection = null; + if (layerCollectionCache.TryGetValue(existingLayerIndex, out Collection? collection)) + { + childCollection = collection; + } + else + { + childCollection = new Collection(layerName, "layer") + { + applicationId = RhinoDoc.ActiveDoc.Layers[existingLayerIndex].Id.ToString() + }; + previousCollection.elements.Add(childCollection); + layerCollectionCache[existingLayerIndex] = childCollection; + } + + previousCollection = childCollection; + + if (index < names.Length - 1) + { + path += Layer.PathSeparator + names[index + 1]; + } + index++; + } + + layerCollectionCache[layer.Index] = previousCollection; + return previousCollection; + } + + //private static Collection ConvertObjects( + // List rhinoObjects, + // ISpeckleConverterToSpeckle converter, + // Action? onOperationProgressed = null, + // CancellationToken ct = default + //) + //{ + // var rootObjectCollection = new Collection { name = RhinoDoc.ActiveDoc.Name ?? "Unnamed document" }; + // int count = 0; + + // Dictionary layerCollectionCache = new(); + // // TODO: Handle blocks. + // foreach (RhinoObject rhinoObject in rhinoObjects) + // { + // ct.ThrowIfCancellationRequested(); + + // // 1. get object layer + // var layer = RhinoDoc.ActiveDoc.Layers[rhinoObject.Attributes.LayerIndex]; + + // // 2. get or create a nested collection for it + // var collectionHost = GetHostObjectCollection(layerCollectionCache, layer, rootObjectCollection); + // var applicationId = rhinoObject.Id.ToString(); + + // // 3. get from cache or convert: + // // What we actually do here is check if the object has been previously converted AND has not changed. + // // If that's the case, we insert in the host collection just its object reference which has been saved from the prior conversion. + // /*Base converted; + // if ( + // !modelCard.ChangedObjectIds.Contains(applicationId) + // && _convertedObjectReferences.TryGetValue(applicationId + modelCard.ProjectId, out ObjectReference value) + // ) + // { + // converted = value; + // } + // else + // { + // converted = converter.ConvertToSpeckle(rhinoObject); + // converted.applicationId = applicationId; + // }*/ + + // var converted = converter.ConvertToSpeckle(rhinoObject); + // converted.applicationId = applicationId; + + // // 4. add to host + // collectionHost.elements.Add(converted); + // //_basicConnectorBinding.Commands.SetModelProgress( + // // modelCard.ModelCardId, + // // new ModelCardProgress { Status = "Converting", Progress = (double)++count / rhinoObjects.Count } + // //); + // onOperationProgressed?.Invoke("Converting", (double)++count / rhinoObjects.Count); + + // // NOTE: useful for testing ui states, pls keep for now so we can easily uncomment + // // Thread.Sleep(550); + // } + + // // 5. profit + // return rootObjectCollection; + //} +} diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Send/RootObjectSender.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Send/RootObjectSender.cs new file mode 100644 index 0000000000..763871da21 --- /dev/null +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Send/RootObjectSender.cs @@ -0,0 +1,79 @@ +using System; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using Speckle.Connectors.Utils.Operations; +using Speckle.Core.Api; +using Speckle.Core.Credentials; +using Speckle.Core.Models; +using Speckle.Core.Transports; + +namespace Speckle.Connectors.Rhino7.Operations.Send; + +/// +/// Default implementation of the which takes a and sends +/// it to a server described by the parameters in the method +/// +internal sealed class RootObjectSender : IRootObjectSender +{ + // POC: Revisit this factory pattern, I think we could solve this higher up by injecting a scoped factory for `SendOperation` in the SendBinding + private readonly Func _transportFactory; + + public RootObjectSender(Func transportFactory) + { + _transportFactory = transportFactory; + } + + public async Task Send( + Base commitObject, + string accountId, + string projectId, + string modelId, + Action? onOperationProgressed = null, + CancellationToken ct = default + ) + { + ct.ThrowIfCancellationRequested(); + + onOperationProgressed?.Invoke("Uploading...", null); + + // POC: FETCHING ACCOUNTS BY ID ONLY IS UNSAFE, we should filter by server first, but the server info is not stored on the ModelCard + Account account = + AccountManager.GetAccounts().FirstOrDefault(acc => acc.id == accountId) + ?? throw new SpeckleAccountManagerException(); + + ITransport transport = _transportFactory(account, projectId); + var sendResult = await SendHelper.Send(commitObject, transport, true, null, ct).ConfigureAwait(false); + + ct.ThrowIfCancellationRequested(); + //// Store the converted references in memory for future send operations, overwriting the existing values for the given application id. + //foreach (var kvp in sendResult.ConvertedReferences) + //{ + // // TODO: Bug in here, we need to encapsulate cache not only by app id, but also by project id, + // // TODO: as otherwise we assume incorrectly that an object exists for a given project (e.g, send box to project 1, send same unchanged box to project 2) + // _convertedObjectReferences[kvp.Key + projectId] = kvp.Value; + //} + // It's important to reset the model card's list of changed obj ids so as to ensure we accurately keep track of changes between send operations. + // NOTE: ChangedObjectIds is currently JsonIgnored, but could actually be useful for highlighting changes in host app. + //modelCard.ChangedObjectIds = new(); + + onOperationProgressed?.Invoke("Linking version to model...", null); + + // 8 - Create the version (commit) + using var apiClient = new Client(account); + string versionId = await apiClient + .CommitCreate( + new CommitCreateInput + { + streamId = projectId, + branchName = modelId, + sourceApplication = "Rhino", + objectId = sendResult.rootObjId + }, + ct + ) + .ConfigureAwait(true); + + return versionId; + } +} diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Send/SendOperation.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Send/SendOperation.cs new file mode 100644 index 0000000000..96860d4dfd --- /dev/null +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Send/SendOperation.cs @@ -0,0 +1,52 @@ +using System; +using System.Threading; +using System.Threading.Tasks; +using Speckle.Connectors.DUI.Bindings; +using Speckle.Core.Models; + +namespace Speckle.Connectors.Rhino7.Operations.Send; + +/// +/// Stateless send operation orchestrator. +/// +public sealed class SendOperation +{ + private readonly RootObjectBuilder _baseBuilder; + private readonly IRootObjectSender _baseObjectSender; + + public SendOperation(RootObjectBuilder baseBuilder, IRootObjectSender baseObjectSender) + { + _baseBuilder = baseBuilder; + _baseObjectSender = baseObjectSender; + } + + /// + /// Executes a send operation given information about the host objects and the destination account. + /// + /// + /// + /// + /// + /// + /// + /// + public async Task Execute( + ISendFilter sendFilter, + string accountId, + string projectId, + string modelId, + Action? onOperationProgressed = null, + CancellationToken ct = default + ) + { + Base commitObject = _baseBuilder.Build(sendFilter, onOperationProgressed, ct); + + // base object handler is separated so we can do some testing on non-production databases + // exact interface may want to be tweaked when we implement this + string versionId = await _baseObjectSender + .Send(commitObject, accountId, projectId, modelId, onOperationProgressed, ct) + .ConfigureAwait(false); + + return versionId; + } +} diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Speckle.Connectors.Rhino7.csproj b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Speckle.Connectors.Rhino7.csproj index 88c2374719..1ac710a149 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Speckle.Connectors.Rhino7.csproj +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Speckle.Connectors.Rhino7.csproj @@ -8,7 +8,7 @@ - + diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/IBasicConnectorBinding.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/IBasicConnectorBinding.cs index 91d8b1a019..eb3be48b03 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/IBasicConnectorBinding.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/IBasicConnectorBinding.cs @@ -37,18 +37,18 @@ public class BasicConnectorBindingCommands private const string SET_MODEL_PROGRESS_UI_COMMAND_NAME = "setModelProgress"; private const string SET_MODEL_ERROR_UI_COMMAND_NAME = "setModelError"; - private IBridge _bridge; + protected IBridge Bridge { get; } public BasicConnectorBindingCommands(IBridge bridge) { - _bridge = bridge; + Bridge = bridge; } - public void NotifyDocumentChanged() => _bridge.Send(NOTIFY_DOCUMENT_CHANGED_EVENT_NAME); + public void NotifyDocumentChanged() => Bridge.Send(NOTIFY_DOCUMENT_CHANGED_EVENT_NAME); public void SetModelProgress(string modelCardId, ModelCardProgress progress) => - _bridge.Send(SET_MODEL_PROGRESS_UI_COMMAND_NAME, new { modelCardId, progress }); + Bridge.Send(SET_MODEL_PROGRESS_UI_COMMAND_NAME, new { modelCardId, progress }); public void SetModelError(string modelCardId, Exception error) => - _bridge.Send(SET_MODEL_ERROR_UI_COMMAND_NAME, new { modelCardId, error = error.Message }); + Bridge.Send(SET_MODEL_ERROR_UI_COMMAND_NAME, new { modelCardId, error = error.Message }); } diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/ISendBinding.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/ISendBinding.cs index e0071ae2b3..9c413bb7e7 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/ISendBinding.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/ISendBinding.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using System.Threading.Tasks; using Speckle.Connectors.DUI.Models.Card; using Speckle.Connectors.DUI.Utils; @@ -12,7 +13,7 @@ public interface ISendBinding : IBinding /// Instructs the host app to start sending this model. /// /// - public void Send(string modelCardId); + public Task Send(string modelCardId); /// /// Instructs the host app to cancel the sending for a given model. diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/SendBindingUICommands.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/SendBindingUICommands.cs index e6220da9b5..1263ddb1f3 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/SendBindingUICommands.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/SendBindingUICommands.cs @@ -3,26 +3,22 @@ namespace Speckle.Connectors.DUI.Bindings; -// POC: have put this static back but unsure about it or the IBridge having this responsibility... and the static -public class SendBindingUICommands +// POC: Send Commands share all commands from BasicBindings + some, this pattern should be revised +public class SendBindingUICommands : BasicConnectorBindingCommands { - private string REFRESH_SEND_FILTERS_UI_COMMAND_NAME = "refreshSendFilters"; - private string SET_MODELS_EXPIRED_UI_COMMAND_NAME = "setModelsExpired"; - private string SET_MODEL_CREATED_VERSION_ID_UI_COMMAND_NAME = "setModelCreatedVersionId"; - - private IBridge _bridge; + private const string REFRESH_SEND_FILTERS_UI_COMMAND_NAME = "refreshSendFilters"; + private const string SET_MODELS_EXPIRED_UI_COMMAND_NAME = "setModelsExpired"; + private const string SET_MODEL_CREATED_VERSION_ID_UI_COMMAND_NAME = "setModelCreatedVersionId"; public SendBindingUICommands(IBridge bridge) - { - _bridge = bridge; - } + : base(bridge) { } // POC.. the only reasons this needs the bridge is to send? realtionship to these messages and the bridge is unclear - public void RefreshSendFilters() => _bridge.Send(REFRESH_SEND_FILTERS_UI_COMMAND_NAME); + public void RefreshSendFilters() => Bridge.Send(REFRESH_SEND_FILTERS_UI_COMMAND_NAME); public void SetModelsExpired(IEnumerable expiredModelIds) => - _bridge.Send(SET_MODELS_EXPIRED_UI_COMMAND_NAME, expiredModelIds); + Bridge.Send(SET_MODELS_EXPIRED_UI_COMMAND_NAME, expiredModelIds); public void SetModelCreatedVersionId(string modelCardId, string versionId) => - _bridge.Send(SET_MODEL_CREATED_VERSION_ID_UI_COMMAND_NAME, new { modelCardId, versionId }); + Bridge.Send(SET_MODEL_CREATED_VERSION_ID_UI_COMMAND_NAME, new { modelCardId, versionId }); } From 0a7cf1ea0a79e81e71a44fc2b3bc06ed3c397b18 Mon Sep 17 00:00:00 2001 From: KatKatKateryna <89912278+KatKatKateryna@users.noreply.github.com> Date: Sat, 23 Mar 2024 03:47:29 +0800 Subject: [PATCH 014/261] [CNX-9134] dui3 dx arc gis create baseline project and bring up to include di (#3239) * copying ArcGIS project * all.sln * fixed namespaces * fixes * works with a panel button * add autofac module * fix * latest * moving things around * fixed namespace; register DUI3 * autofac working * update url * comands prop * notify in doc change * return arcgis to slnf * typo * replace View with Dockpane * factory removed; settings injected (but still an error) * typo * manual app name * a bit better * init SQL on app launch * non-working send bindings * send converter fixed * fixed * converter and slnf fix * Switched ArcGIS project to consume nugets (#3241) * Switched ArcGIS project to consume nugets * Fix formatting * switched CI to use msbuild * powershell * dotnet restore * Update to new interfaces * use settings * changes * Assembly resolve * Converters working * CI dotnet restore on seperate command * implicit usings * Fixed location * Removed sqlite init --------- Co-authored-by: Jedd Morgan <45512892+JR-Morgan@users.noreply.github.com> --- .circleci/scripts/config-template.yml | 8 +- All.sln | 69 +++- Core/Core/Kits/Applications.cs | 1 + DUI3-DX.slnf | 3 + .../Bindings/ArcGISSendBinding.cs | 309 ++++++++++++++++++ .../Bindings/BasicConnectorBinding.cs | 66 ++++ .../Speckle.Connectors.ArcGIS3/Config.daml | 69 ++++ .../DarkImages/AddInDesktop16.png | Bin 0 -> 1314 bytes .../DarkImages/AddInDesktop32.png | Bin 0 -> 1744 bytes .../AutofacArcGISModule.cs | 71 ++++ .../Filters/ArcGISEverythingFilter.cs | 10 + .../Filters/ArcGISSelectionFilter.cs | 10 + .../HostApp/ArcGISSettings.cs | 19 ++ .../HostApp/SpeckleDUI3.xaml | 23 ++ .../HostApp/SpeckleDUI3.xaml.cs | 46 +++ .../HostApp/SpeckleDUI3ViewModel.cs | 42 +++ .../HostApp/SpeckleDUI3Wrapper.cs | 16 + .../HostApp/SpeckleModule.cs | 84 +++++ .../Images/AddInDesktop16.png | Bin 0 -> 524 bytes .../Images/AddInDesktop32.png | Bin 0 -> 948 bytes .../Properties/launchSettings.json | 9 + .../Speckle.Connectors.ArcGIS3.csproj | 40 +++ .../Utils/ArcGisDocumentStore.cs | 23 ++ .../Properties/launchSettings.json | 2 +- .../AutofacArcGIS3ConverterModule.cs | 22 ++ ...verters.ArcGIS3.DependencyInjection.csproj | 13 + .../ArcGISConverterToSpeckle.cs | 40 +++ .../FakeConversion.cs | 17 + .../Speckle.Converters.ArcGIS3.csproj | 14 + .../Speckle.Converters.Rhino7.csproj | 1 - ...nverters.Common.DependencyInjection.csproj | 3 +- 31 files changed, 1021 insertions(+), 9 deletions(-) create mode 100644 DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISSendBinding.cs create mode 100644 DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/BasicConnectorBinding.cs create mode 100644 DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Config.daml create mode 100644 DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/DarkImages/AddInDesktop16.png create mode 100644 DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/DarkImages/AddInDesktop32.png create mode 100644 DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/DependencyInjection/AutofacArcGISModule.cs create mode 100644 DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Filters/ArcGISEverythingFilter.cs create mode 100644 DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Filters/ArcGISSelectionFilter.cs create mode 100644 DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/HostApp/ArcGISSettings.cs create mode 100644 DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/HostApp/SpeckleDUI3.xaml create mode 100644 DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/HostApp/SpeckleDUI3.xaml.cs create mode 100644 DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/HostApp/SpeckleDUI3ViewModel.cs create mode 100644 DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/HostApp/SpeckleDUI3Wrapper.cs create mode 100644 DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/HostApp/SpeckleModule.cs create mode 100644 DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Images/AddInDesktop16.png create mode 100644 DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Images/AddInDesktop32.png create mode 100644 DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Properties/launchSettings.json create mode 100644 DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Speckle.Connectors.ArcGIS3.csproj create mode 100644 DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Utils/ArcGisDocumentStore.cs create mode 100644 DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3.DependencyInjection/AutofacArcGIS3ConverterModule.cs create mode 100644 DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3.DependencyInjection/Speckle.Converters.ArcGIS3.DependencyInjection.csproj create mode 100644 DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ArcGISConverterToSpeckle.cs create mode 100644 DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/FakeConversion.cs create mode 100644 DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Speckle.Converters.ArcGIS3.csproj diff --git a/.circleci/scripts/config-template.yml b/.circleci/scripts/config-template.yml index 66856d6ef2..35aa609d88 100644 --- a/.circleci/scripts/config-template.yml +++ b/.circleci/scripts/config-template.yml @@ -90,7 +90,7 @@ jobs: # Each project will have individual jobs for each specific task it has to build-dui3-job: executor: name: win/default - shell: bash.exe + shell: powershell.exe steps: - checkout - run: @@ -98,10 +98,14 @@ jobs: # Each project will have individual jobs for each specific task it has to command: | dotnet tool restore dotnet csharpier --check . + - run: + name: Dotnet Restore + command: | + dotnet restore DUI3-DX.slnf - run: name: Build DUI3 Solution filter command: | - dotnet build DUI3-DX.slnf -c Release -p:IsDesktopBuild=false + msbuild DUI3-DX.slnf /p:Configuration=Release /p:IsDesktopBuild=false build-sdk: docker: - image: cimg/base:2021.01 diff --git a/All.sln b/All.sln index 1c7cabd2ad..b38151a060 100644 --- a/All.sln +++ b/All.sln @@ -524,13 +524,23 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Speckle.Converters.Common", EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Rhino", "Rhino", "{9584AEE5-CD59-46E6-93E6-2DC2B5285B75}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Speckle.Connectors.Rhino7", "DUI3-DX\Connectors\Rhino\Speckle.Connectors.Rhino7\Speckle.Connectors.Rhino7.csproj", "{1E2644A9-6B31-4350-8772-CEAAD6EE0B21}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Speckle.Connectors.Rhino7", "DUI3-DX\Connectors\Rhino\Speckle.Connectors.Rhino7\Speckle.Connectors.Rhino7.csproj", "{1E2644A9-6B31-4350-8772-CEAAD6EE0B21}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Rhino", "Rhino", "{34C2C062-E43F-4FB5-B839-64BC044CCEF3}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Speckle.Converters.Rhino7", "DUI3-DX\Converters\Rhino\Speckle.Converters.Rhino7\Speckle.Converters.Rhino7.csproj", "{65A2F556-F14A-49F3-8A92-7F2E1E7ED3B5}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Speckle.Converters.Rhino7", "DUI3-DX\Converters\Rhino\Speckle.Converters.Rhino7\Speckle.Converters.Rhino7.csproj", "{65A2F556-F14A-49F3-8A92-7F2E1E7ED3B5}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Speckle.Converters.Rhino7.DependencyInjection", "DUI3-DX\Converters\Rhino\Speckle.Converters.Rhino7.DependencyInjection\Speckle.Converters.Rhino7.DependencyInjection.csproj", "{9C1ECA1D-DE98-4FB7-92D0-FC45BB308E5D}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Speckle.Converters.Rhino7.DependencyInjection", "DUI3-DX\Converters\Rhino\Speckle.Converters.Rhino7.DependencyInjection\Speckle.Converters.Rhino7.DependencyInjection.csproj", "{9C1ECA1D-DE98-4FB7-92D0-FC45BB308E5D}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Speckle.Connectors.ArcGIS3", "DUI3-DX\Connectors\ArcGIS\Speckle.Connectors.ArcGIS3\Speckle.Connectors.ArcGIS3.csproj", "{A97F7177-86C7-4B38-A6ED-DA51BF762471}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ArcGIS", "ArcGIS", "{CE4B899D-9C0A-4B5D-B91A-CE62D2327695}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Speckle.Converters.ArcGIS3", "DUI3-DX\Converters\ArcGIS\Speckle.Converters.ArcGIS3\Speckle.Converters.ArcGIS3.csproj", "{139F7A79-69E4-4B8A-B2A5-6A30A66C495C}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Speckle.Converters.ArcGIS3.DependencyInjection", "DUI3-DX\Converters\ArcGIS\Speckle.Converters.ArcGIS3.DependencyInjection\Speckle.Converters.ArcGIS3.DependencyInjection.csproj", "{7DFF1591-237D-499E-A767-EE37B93FB958}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ArcGIS", "ArcGIS", "{CCF48B65-33D1-4E8B-A57B-E03394730B21}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Speckle.Converters.Common.DependencyInjection", "DUI3-DX\Sdk\Speckle.Converters.Common.DependencyInjection\Speckle.Converters.Common.DependencyInjection.csproj", "{11F7D41B-AFCA-4D29-BC08-285A14BF3A3B}" EndProject @@ -2640,6 +2650,54 @@ Global {9C1ECA1D-DE98-4FB7-92D0-FC45BB308E5D}.Release|Any CPU.Build.0 = Release|Any CPU {9C1ECA1D-DE98-4FB7-92D0-FC45BB308E5D}.Release|x64.ActiveCfg = Release|Any CPU {9C1ECA1D-DE98-4FB7-92D0-FC45BB308E5D}.Release|x64.Build.0 = Release|Any CPU + {A97F7177-86C7-4B38-A6ED-DA51BF762471}.Debug Mac|Any CPU.ActiveCfg = Debug|Any CPU + {A97F7177-86C7-4B38-A6ED-DA51BF762471}.Debug Mac|Any CPU.Build.0 = Debug|Any CPU + {A97F7177-86C7-4B38-A6ED-DA51BF762471}.Debug Mac|x64.ActiveCfg = Debug|Any CPU + {A97F7177-86C7-4B38-A6ED-DA51BF762471}.Debug Mac|x64.Build.0 = Debug|Any CPU + {A97F7177-86C7-4B38-A6ED-DA51BF762471}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A97F7177-86C7-4B38-A6ED-DA51BF762471}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A97F7177-86C7-4B38-A6ED-DA51BF762471}.Debug|x64.ActiveCfg = Debug|Any CPU + {A97F7177-86C7-4B38-A6ED-DA51BF762471}.Debug|x64.Build.0 = Debug|Any CPU + {A97F7177-86C7-4B38-A6ED-DA51BF762471}.Release Mac|Any CPU.ActiveCfg = Release|Any CPU + {A97F7177-86C7-4B38-A6ED-DA51BF762471}.Release Mac|Any CPU.Build.0 = Release|Any CPU + {A97F7177-86C7-4B38-A6ED-DA51BF762471}.Release Mac|x64.ActiveCfg = Release|Any CPU + {A97F7177-86C7-4B38-A6ED-DA51BF762471}.Release Mac|x64.Build.0 = Release|Any CPU + {A97F7177-86C7-4B38-A6ED-DA51BF762471}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A97F7177-86C7-4B38-A6ED-DA51BF762471}.Release|Any CPU.Build.0 = Release|Any CPU + {A97F7177-86C7-4B38-A6ED-DA51BF762471}.Release|x64.ActiveCfg = Release|Any CPU + {A97F7177-86C7-4B38-A6ED-DA51BF762471}.Release|x64.Build.0 = Release|Any CPU + {139F7A79-69E4-4B8A-B2A5-6A30A66C495C}.Debug Mac|Any CPU.ActiveCfg = Debug|Any CPU + {139F7A79-69E4-4B8A-B2A5-6A30A66C495C}.Debug Mac|Any CPU.Build.0 = Debug|Any CPU + {139F7A79-69E4-4B8A-B2A5-6A30A66C495C}.Debug Mac|x64.ActiveCfg = Debug|Any CPU + {139F7A79-69E4-4B8A-B2A5-6A30A66C495C}.Debug Mac|x64.Build.0 = Debug|Any CPU + {139F7A79-69E4-4B8A-B2A5-6A30A66C495C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {139F7A79-69E4-4B8A-B2A5-6A30A66C495C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {139F7A79-69E4-4B8A-B2A5-6A30A66C495C}.Debug|x64.ActiveCfg = Debug|Any CPU + {139F7A79-69E4-4B8A-B2A5-6A30A66C495C}.Debug|x64.Build.0 = Debug|Any CPU + {139F7A79-69E4-4B8A-B2A5-6A30A66C495C}.Release Mac|Any CPU.ActiveCfg = Release|Any CPU + {139F7A79-69E4-4B8A-B2A5-6A30A66C495C}.Release Mac|Any CPU.Build.0 = Release|Any CPU + {139F7A79-69E4-4B8A-B2A5-6A30A66C495C}.Release Mac|x64.ActiveCfg = Release|Any CPU + {139F7A79-69E4-4B8A-B2A5-6A30A66C495C}.Release Mac|x64.Build.0 = Release|Any CPU + {139F7A79-69E4-4B8A-B2A5-6A30A66C495C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {139F7A79-69E4-4B8A-B2A5-6A30A66C495C}.Release|Any CPU.Build.0 = Release|Any CPU + {139F7A79-69E4-4B8A-B2A5-6A30A66C495C}.Release|x64.ActiveCfg = Release|Any CPU + {139F7A79-69E4-4B8A-B2A5-6A30A66C495C}.Release|x64.Build.0 = Release|Any CPU + {7DFF1591-237D-499E-A767-EE37B93FB958}.Debug Mac|Any CPU.ActiveCfg = Debug|Any CPU + {7DFF1591-237D-499E-A767-EE37B93FB958}.Debug Mac|Any CPU.Build.0 = Debug|Any CPU + {7DFF1591-237D-499E-A767-EE37B93FB958}.Debug Mac|x64.ActiveCfg = Debug|Any CPU + {7DFF1591-237D-499E-A767-EE37B93FB958}.Debug Mac|x64.Build.0 = Debug|Any CPU + {7DFF1591-237D-499E-A767-EE37B93FB958}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7DFF1591-237D-499E-A767-EE37B93FB958}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7DFF1591-237D-499E-A767-EE37B93FB958}.Debug|x64.ActiveCfg = Debug|Any CPU + {7DFF1591-237D-499E-A767-EE37B93FB958}.Debug|x64.Build.0 = Debug|Any CPU + {7DFF1591-237D-499E-A767-EE37B93FB958}.Release Mac|Any CPU.ActiveCfg = Release|Any CPU + {7DFF1591-237D-499E-A767-EE37B93FB958}.Release Mac|Any CPU.Build.0 = Release|Any CPU + {7DFF1591-237D-499E-A767-EE37B93FB958}.Release Mac|x64.ActiveCfg = Release|Any CPU + {7DFF1591-237D-499E-A767-EE37B93FB958}.Release Mac|x64.Build.0 = Release|Any CPU + {7DFF1591-237D-499E-A767-EE37B93FB958}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7DFF1591-237D-499E-A767-EE37B93FB958}.Release|Any CPU.Build.0 = Release|Any CPU + {7DFF1591-237D-499E-A767-EE37B93FB958}.Release|x64.ActiveCfg = Release|Any CPU + {7DFF1591-237D-499E-A767-EE37B93FB958}.Release|x64.Build.0 = Release|Any CPU {11F7D41B-AFCA-4D29-BC08-285A14BF3A3B}.Debug Mac|Any CPU.ActiveCfg = Debug|Any CPU {11F7D41B-AFCA-4D29-BC08-285A14BF3A3B}.Debug Mac|Any CPU.Build.0 = Debug|Any CPU {11F7D41B-AFCA-4D29-BC08-285A14BF3A3B}.Debug Mac|x64.ActiveCfg = Debug|Any CPU @@ -2860,6 +2918,11 @@ Global {34C2C062-E43F-4FB5-B839-64BC044CCEF3} = {1FE3C60E-7865-40A5-9794-55ECB64F6489} {65A2F556-F14A-49F3-8A92-7F2E1E7ED3B5} = {34C2C062-E43F-4FB5-B839-64BC044CCEF3} {9C1ECA1D-DE98-4FB7-92D0-FC45BB308E5D} = {34C2C062-E43F-4FB5-B839-64BC044CCEF3} + {A97F7177-86C7-4B38-A6ED-DA51BF762471} = {CE4B899D-9C0A-4B5D-B91A-CE62D2327695} + {CE4B899D-9C0A-4B5D-B91A-CE62D2327695} = {33D19E88-F3AE-4D28-B588-D91CCF9E3BA8} + {139F7A79-69E4-4B8A-B2A5-6A30A66C495C} = {CCF48B65-33D1-4E8B-A57B-E03394730B21} + {7DFF1591-237D-499E-A767-EE37B93FB958} = {CCF48B65-33D1-4E8B-A57B-E03394730B21} + {CCF48B65-33D1-4E8B-A57B-E03394730B21} = {1FE3C60E-7865-40A5-9794-55ECB64F6489} {11F7D41B-AFCA-4D29-BC08-285A14BF3A3B} = {2E00592E-558D-492D-88F9-3ECEE4C0C7DA} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution diff --git a/Core/Core/Kits/Applications.cs b/Core/Core/Kits/Applications.cs index 3f06c824e2..ea3ccb0179 100644 --- a/Core/Core/Kits/Applications.cs +++ b/Core/Core/Kits/Applications.cs @@ -5,6 +5,7 @@ namespace Speckle.Core.Kits; public enum HostAppVersion { v, + v3, v6, v7, v8, diff --git a/DUI3-DX.slnf b/DUI3-DX.slnf index ef95d0d660..b527b2a984 100644 --- a/DUI3-DX.slnf +++ b/DUI3-DX.slnf @@ -7,6 +7,7 @@ "Core\\Tests\\Speckle.Core.Tests.Performance\\Speckle.Core.Tests.Performance.csproj", "Core\\Tests\\Speckle.Core.Tests.Unit\\Speckle.Core.Tests.Unit.csproj", "Core\\Transports\\DiskTransport\\DiskTransport.csproj", + "DUI3-DX\\Connectors\\ArcGIS\\Speckle.Connectors.ArcGIS3\\Speckle.Connectors.ArcGIS3.csproj", "DUI3-DX\\Connectors\\Revit\\Speckle.Connectors.Revit2023\\Speckle.Connectors.Revit2023.csproj", "DUI3-DX\\Connectors\\Revit\\Speckle.Connectors.RevitShared\\Speckle.Connectors.RevitShared.shproj", "DUI3-DX\\Connectors\\Rhino\\Speckle.Connectors.Rhino7\\Speckle.Connectors.Rhino7.csproj", @@ -15,6 +16,8 @@ "DUI3-DX\\Converters\\Revit\\Speckle.Converters.RevitShared\\Speckle.Converters.RevitShared.shproj", "DUI3-DX\\Converters\\Rhino\\Speckle.Converters.Rhino7.DependencyInjection\\Speckle.Converters.Rhino7.DependencyInjection.csproj", "DUI3-DX\\Converters\\Rhino\\Speckle.Converters.Rhino7\\Speckle.Converters.Rhino7.csproj", + "DUI3-DX\\Converters\\ArcGIS\\Speckle.Converters.ArcGIS3.DependencyInjection\\Speckle.Converters.ArcGIS3.DependencyInjection.csproj", + "DUI3-DX\\Converters\\ArcGIS\\Speckle.Converters.ArcGIS3\\Speckle.Converters.ArcGIS3.csproj", "DUI3-DX\\DUI3\\Speckle.Connectors.DUI\\Speckle.Connectors.DUI.csproj", "DUI3-DX\\Objects\\Speckle.Objects.Common\\Speckle.Objects.Common.csproj", "DUI3-DX\\Objects\\Speckle.Objects.Revit\\Speckle.Objects.Revit.csproj", diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISSendBinding.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISSendBinding.cs new file mode 100644 index 0000000000..7f26370e0e --- /dev/null +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISSendBinding.cs @@ -0,0 +1,309 @@ +using System.Diagnostics.CodeAnalysis; +using Speckle.Autofac.DependencyInjection; +using Speckle.Core.Credentials; +using Speckle.Core.Models; +using Speckle.Core.Transports; +using Speckle.Connectors.DUI.Bindings; +using Speckle.Connectors.DUI.Bridge; +using Speckle.Connectors.DUI.Models.Card; +using Speckle.Connectors.DUI.Utils; +using Speckle.Connectors.ArcGIS.Filters; +using Speckle.Connectors.ArcGIS.HostApp; +using Speckle.Connectors.Utils.Cancellation; +using Speckle.Connectors.Utils.Operations; +using Speckle.Converters.Common; +using Speckle.Core.Api; +using Speckle.Core.Logging; +using ICancelable = System.Reactive.Disposables.ICancelable; +using Speckle.Connectors.ArcGIS.Utils; + +namespace Speckle.Connectors.ArcGIS.Bindings; + +public sealed class ArcGISSendBinding : ISendBinding, ICancelable +{ + public string Name { get; } = "sendBinding"; + public SendBindingUICommands Commands { get; } + public IBridge Parent { get; set; } + + private readonly ArcGISDocumentStore _store; + private readonly ArcGISSettings _arcgisSettings; + private readonly IBasicConnectorBinding _basicConnectorBinding; + private readonly IScopedFactory _speckleConverterToSpeckleFactory; + + // private readonly ArcGISIdleManager _idleManager; + // private readonly ArcGISContext _arcgisContext; + + public CancellationManager CancellationManager { get; } = new(); + + /// + /// Used internally to aggregate the changed objects' id. + /// + private HashSet ChangedObjectIds { get; set; } = new(); + + /// + /// Keeps track of previously converted objects as a dictionary of (applicationId, object reference). + /// + private readonly Dictionary _convertedObjectReferences = new(); + + public ArcGISSendBinding( + ArcGISDocumentStore store, + // ArcGISIdleManager idleManager, + ArcGISSettings arcgisSettings, + IBridge parent, + IBasicConnectorBinding basicConnectorBinding, + IScopedFactory speckleConverterToSpeckleFactory + // ArcGISContext arcgisContext + ) + { + _store = store; + // _idleManager = idleManager; + _arcgisSettings = arcgisSettings; + _basicConnectorBinding = basicConnectorBinding; + _speckleConverterToSpeckleFactory = speckleConverterToSpeckleFactory; + // _arcgisContext = arcgisContext; + + Parent = parent; + Commands = new SendBindingUICommands(parent); + } + + public List GetSendFilters() + { + return new List + { + new ArcGISEverythingFilter(), + new ArcGISSelectionFilter { IsDefault = true } + }; + } + + public List GetSendSettings() + { + return new List + { + new() + { + Id = "includeAttributes", + Title = "Include Attributes", + Value = true, + Type = "boolean" + }, + }; + } + + [SuppressMessage( + "Maintainability", + "CA1506:Avoid excessive class coupling", + Justification = "Being refactored on in parallel, muting this issue so CI can pass initially." + )] + public async Task Send(string modelCardId) + { + try + { + // 0 - Init cancellation token source -> Manager also cancel it if exist before + CancellationTokenSource cts = CancellationManager.InitCancellationTokenSource(modelCardId); + + // 1 - Get model + + if (_store.GetModelById(modelCardId) is not SenderModelCard modelCard) + { + throw new InvalidOperationException("No publish model card was found."); + } + + // 2 - Check account exist + // TODO: FETCHING ACCOUNTS BY ID ONLY IS UNSAFE + Account account = + AccountManager.GetAccounts().FirstOrDefault(acc => acc.id == modelCard.AccountId) + ?? throw new SpeckleAccountManagerException(); + + // 3 - Get elements to convert, throw early if nothing is selected: TODO + List arcgisObjects = new() { "object1", "object2" }; + + if (arcgisObjects.Count == 0) + { + throw new InvalidOperationException("No objects were found. Please update your send filter!"); + } + + var converter = _speckleConverterToSpeckleFactory.ResolveScopedInstance(); + // 5 - Convert objects + Base commitObject = ConvertObjects(arcgisObjects, converter, modelCard, cts); + + if (cts.IsCancellationRequested) + { + throw new OperationCanceledException(cts.Token); + } + + // 7 - Serialize and Send objects + _basicConnectorBinding.Commands.SetModelProgress(modelCardId, new ModelCardProgress { Status = "Uploading..." }); + + var transport = new ServerTransport(account, modelCard.ProjectId); + var sendResult = await SendHelper.Send(commitObject, transport, true, null, cts.Token).ConfigureAwait(true); + + // Store the converted references in memory for future send operations, overwriting the existing values for the given application id. + foreach (var kvp in sendResult.convertedReferences) + { + // TODO: Bug in here, we need to encapsulate cache not only by app id, but also by project id, + // TODO: as otherwise we assume incorrectly that an object exists for a given project (e.g, send box to project 1, send same unchanged box to project 2) + _convertedObjectReferences[kvp.Key + modelCard.ProjectId] = kvp.Value; + } + // It's important to reset the model card's list of changed obj ids so as to ensure we accurately keep track of changes between send operations. + // NOTE: ChangedObjectIds is currently JsonIgnored, but could actually be useful for highlighting changes in host app. + //modelCard.ChangedObjectIds = new(); + + _basicConnectorBinding.Commands.SetModelProgress( + modelCardId, + new ModelCardProgress { Status = "Linking version to model..." } + ); + + // 8 - Create the version (commit) + var apiClient = new Client(account); + string versionId = await apiClient + .CommitCreate( + new CommitCreateInput + { + streamId = modelCard.ProjectId, + branchName = modelCard.ModelId, + sourceApplication = "ArcGIS", + objectId = sendResult.rootObjId + }, + cts.Token + ) + .ConfigureAwait(true); + + Commands.SetModelCreatedVersionId(modelCardId, versionId); + apiClient.Dispose(); + } + catch (OperationCanceledException) + { + return; + } + catch (Exception e) when (!e.IsFatal()) // All exceptions should be handled here if possible, otherwise we enter "crashing the host app" territory. + { + _basicConnectorBinding.Commands.SetModelError(modelCardId, e); + } + } + + public void CancelSend(string modelCardId) => CancellationManager.CancelOperation(modelCardId); + + private Base ConvertObjects( + List arcgisObjects, + ISpeckleConverterToSpeckle converter, + SenderModelCard modelCard, + CancellationTokenSource cts + ) + { + var rootObjectCollection = new Collection { name = "Unnamed document" }; // { name = ArcGISDoc.ActiveDoc.Name ?? "Unnamed document" }; + int count = 0; + + Dictionary layerCollectionCache = new(); + // TODO: Handle blocks. + + foreach (string arcgisObject in arcgisObjects) // switch to ArcgisObject + { + if (cts.IsCancellationRequested) + { + throw new OperationCanceledException(cts.Token); + } + + // 1. get object layer: TODO + // var layer = ArcGISDoc.ActiveDoc.Layers[arcgisObject.Attributes.LayerIndex]; + + // 2. get or create a nested collection for it + var collectionHost = GetHostObjectCollection(layerCollectionCache, rootObjectCollection); + // var applicationId = arcgisObject.Id.ToString(); + + // 3. get from cache or convert: + // What we actually do here is check if the object has been previously converted AND has not changed. + // If that's the case, we insert in the host collection just its object reference which has been saved from the prior conversion. + /*Base converted; + if ( + !modelCard.ChangedObjectIds.Contains(applicationId) + && _convertedObjectReferences.TryGetValue(applicationId + modelCard.ProjectId, out ObjectReference value) + ) + { + converted = value; + } + else + { + converted = converter.ConvertToSpeckle(arcgisObject); + converted.applicationId = applicationId; + }*/ + + var converted = converter.Convert(arcgisObject); + // converted.applicationId = applicationId; + + // 4. add to host + collectionHost.elements.Add(converted); + _basicConnectorBinding.Commands.SetModelProgress( + modelCard.ModelCardId, + new ModelCardProgress { Status = "Converting", Progress = (double)++count / 2 } // / arcgisObjects.Count } + ); + + // NOTE: useful for testing ui states, pls keep for now so we can easily uncomment + // Thread.Sleep(550); + } + + // 5. profit + return rootObjectCollection; + } + + /// + /// Returns the host collection based on the provided layer. If it's not found, it will be created and hosted within the the rootObjectCollection. + /// + /// + /// + /// + private Collection GetHostObjectCollection( + Dictionary layerCollectionCache, + // Layer layer, + Collection rootObjectCollection + ) + { + var names = new List { "name1" }; // layer.FullPath.Split(new[] { Layer.PathSeparator }, StringSplitOptions.None); + var index = 0; + var previousCollection = rootObjectCollection; + foreach (var layerName in names) + { + var existingLayerIndex = 0; // ArcGISDoc.ActiveDoc.Layers.FindByFullPath(path, -1); + Collection? childCollection = null; + + childCollection = new Collection(layerName, "layer"); + previousCollection.elements.Add(childCollection); + layerCollectionCache[existingLayerIndex] = childCollection; + + previousCollection = childCollection; + + index++; + } + + layerCollectionCache[0] = previousCollection; + return previousCollection; + } + + /// + /// Checks if any sender model cards contain any of the changed objects. If so, also updates the changed objects hashset for each model card - this last part is important for on send change detection. + /// + private void RunExpirationChecks() + { + List senders = _store.GetSenders(); + List expiredSenderIds = new(); + + foreach (var sender in senders) + { + bool isExpired = sender.SendFilter.CheckExpiry(ChangedObjectIds.ToArray()); + if (isExpired) + { + expiredSenderIds.Add(sender.ModelCardId); + } + } + + Commands.SetModelsExpired(expiredSenderIds); + ChangedObjectIds = new HashSet(); + } + + public void Dispose() + { + IsDisposed = true; + _speckleConverterToSpeckleFactory.Dispose(); + } + + public bool IsDisposed { get; private set; } +} diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/BasicConnectorBinding.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/BasicConnectorBinding.cs new file mode 100644 index 0000000000..0c46403fda --- /dev/null +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/BasicConnectorBinding.cs @@ -0,0 +1,66 @@ +using System.Reflection; +using Speckle.Connectors.ArcGIS.HostApp; +using Speckle.Connectors.ArcGIS.Utils; +using Speckle.Connectors.DUI.Bindings; +using Speckle.Connectors.DUI.Bridge; +using Speckle.Connectors.DUI.Models; +using Speckle.Connectors.DUI.Models.Card; +using Speckle.Connectors.Utils.Reflection; + +namespace Speckle.Connectors.ArcGIS.Bindings; + +public class BasicConnectorBinding : IBasicConnectorBinding +{ + public string Name { get; set; } = "baseBinding"; + public IBridge Parent { get; set; } + + public BasicConnectorBindingCommands Commands { get; } + private readonly ArcGISDocumentStore _store; + private readonly ArcGISSettings _settings; + + public BasicConnectorBinding(ArcGISDocumentStore store, ArcGISSettings settings, IBridge parent) + { + _store = store; + _settings = settings; + Parent = parent; + Commands = new BasicConnectorBindingCommands(parent); + + _store.DocumentChanged += (_, _) => + { + Commands.NotifyDocumentChanged(); + }; + } + + public string GetSourceApplicationName() => _settings.HostAppInfo.Slug; + + public string GetSourceApplicationVersion() => _settings.HostAppInfo.GetVersion(_settings.HostAppVersion); + + public string GetConnectorVersion() => Assembly.GetAssembly(GetType())!.GetVersion(); + + // TODO + public DocumentInfo GetDocumentInfo() => + new() + { + Location = "", + Name = "", + Id = "" + }; + + public DocumentModelStore GetDocumentState() => _store; + + public void AddModel(ModelCard model) => _store.Models.Add(model); + + public void UpdateModel(ModelCard model) + { + int idx = _store.Models.FindIndex(m => model.ModelCardId == m.ModelCardId); + _store.Models[idx] = model; + } + + public void RemoveModel(ModelCard model) + { + int index = _store.Models.FindIndex(m => m.ModelCardId == model.ModelCardId); + _store.Models.RemoveAt(index); + } + + public void HighlightModel(string modelCardId) => throw new System.NotImplementedException(); +} diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Config.daml b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Config.daml new file mode 100644 index 0000000000..58429098d3 --- /dev/null +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Config.daml @@ -0,0 +1,69 @@ + + + + + Speckle + Speckle connector for ArcGIS + Images\AddinDesktop32.png + Speckle Systems + Speckle Systems + 8/5/2021 12:24:21 PM + Framework + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/DarkImages/AddInDesktop16.png b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/DarkImages/AddInDesktop16.png new file mode 100644 index 0000000000000000000000000000000000000000..0118942a923d37745dced41536d71172f7517deb GIT binary patch literal 1314 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`k|nMYCBgY=CFO}lsSJ)O`AMk? zp1FzXsX?iUDV2pMQ*9U+m^Cs(B1$5BeXNr6bM+EIYV;~{3xK*A7;Nk-3KEmEQ%e+* zQqwc@Y?a>c-mj#PnPRIHZt82`Ti~3Uk?B!Ylp0*+7m{3+ootz+WN)WnQ(*-(AUCxn zQK2F?C$HG5!d3}vt`(3C64qBz04piUwpD^SD#ABF!8yMuRl!uxOgGuU%v{0TQqR!T z+}y-mN5ROz&{W^RSl`${*T~q)#K6kLNC66zfVLH-q*(>IxIyg#@@$ndN=gc>^!3Zj z%k|2Q_413-^$jg8E%gnI^o@*kfhu&1EAvVcD|GXUm0>2hq!uR^WfqiV=I1GZOiWD5 zFD$Tv3bSNU;+l1ennz|zM-B0$V)JVzP|XC=H|jx7ncO3BHWAB;NpiyW)Z+ZoqGVvir744~DzI`cN=+=uFAB-e&w+(vKt_H^esM;Afr7I$IMft0d=ry1 z^FV@{U|qhxR-SpqC5d^-sh%#jNbn4Gmq*EQ}4@91Trf z9F2`FOx&CdV0vBhlS^|`^GaZPQ-FG%U0huajGRnx>IEf;+ybD@E~!PCWvMA{Mftf3 zV2@j6;&zJxPV=C8Q?R%N>JLMldi8;h(Fa8@Qgp+FfN2QCgeP7g2cG;>^MGl-2$;A{ z^UHoRFfdN=ba4!+xHV_eSudtQk>mf3ADc`I;N%lh@rhWMHCaSu#|rTc+b*73D_z|f zchKzJnb0k|)r|_C3qu72JFMDTIvVAZpRQPZcJC7h=Cdqs6d>g;Fd(<~UJ81^dm+<(73@IuqYmV0m9+Os7i{i0=el#xWp=L=ll zcWrlNR9(*{VE_OC literal 0 HcmV?d00001 diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/DarkImages/AddInDesktop32.png b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/DarkImages/AddInDesktop32.png new file mode 100644 index 0000000000000000000000000000000000000000..9713e3b1548cc2ee78c60ad4ffb3a46566609b2b GIT binary patch literal 1744 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdz$r9IylHmNblJdl&R0hYC{G?O` z&)mfH)S%SFl*+=BsWuD@%o>>?5hW46K32*3xq68pHF_1f1wh>l3^w)^1&PVosU-?Y zsp*+{wo31J?^jaDOtDo8H}y5}EpSfF$n>ZxN)4{^3rViZPPR-@vbR&PsjvbXkegbP zs8ErclUHn2VXFi-*9yo63F|8hm3bwJ6}oxF$}kgLQj3#|G7CyF^YauyCMG83 zmzLNn0bL65LT&-v*t}wBFaZNhzap_f-%!s0*lEl2^R8JRMC7?NanVBh8&MvO521ZWi7A`KPhK8g6oCT>m!FugAM$)&lec_lEtDG0q5IQ4=OL~a4lW|!2W%(B!Jx1#)91+d4hGI6`b z6sLJmy(zfeVun+%KF~4xpy)-4ZkP}-4S|^O#0%uWlYeR+FwGYM6ZcJlSNy;{W9RAO z7*cU-Pq?qYaH7Dxw|Vt6-sL_XG#dCA=nEb^pfQtK4{2?@f5-Yn6Pn-PZZfE9Y0HrEx1H z9!!{UoHf^M-t)%bq7T3S{`vE#W^-XsO7HozXLCLFraX~2kgXt)p=H#>-|A#wX*ttK zsyEz0fq7Ti0YpasWR z+$R{k6EQaQOgubCjeVsOtlnOk{w`C6b(O-k z!?%v*K6AM`eR77=`V*;bYYY>29(i2Y;i6QsaMQ#fQ$;238P%!+a}++v7ICVt;*4J- z(t7o6^o7?q*{10_e_A1~bF=-!5qqwE6AORrn%yeg8+zd1YNnkg1x*k3n|IH?7GcRX zm5aSBol`57Z&RkUjQpL}K6dR7mnSsJ-QzxQ+bj^ZpL1#Y`=~J1hg`^%fgqBz3;E zypY`VWYg}1goK7Hr>$HfCJm_;pKI;?o2*r3d5-OQQhbGzDPtR#z=0d{_h&}7^PSf8 zb>5gD)M&Ftrs?+EygIQdKZL&Ay+5huW~Qg(^y=;BTJBYZU1$4y=WKYiF?T?MgwEt` zT`TsR|L}eiBb-#bV0KB@XNO?X7m|OEe!um$R*<1vcj3z0E6+0PZcey)bXUf@iL7he zsyA4hS#t{wI^H6T7(3Ke0lyCJVujWX{t((u~qp@l3TlWoH zzfI9w__aZNhOnDxgV^fc$14>N2duI-*SXET!S?cG;RSYO0%GFg(Vy;~h>>%(s=VC@S26m4%0k2Q>`~uZ6p00i_ I>zopr0LdSn0ssI2 literal 0 HcmV?d00001 diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/DependencyInjection/AutofacArcGISModule.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/DependencyInjection/AutofacArcGISModule.cs new file mode 100644 index 0000000000..ac140e5dfd --- /dev/null +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/DependencyInjection/AutofacArcGISModule.cs @@ -0,0 +1,71 @@ +using Autofac; +using Microsoft.Extensions.Logging; +using Serilog; +using Speckle.Autofac.DependencyInjection; +using Speckle.Connectors.ArcGIS.Bindings; +using Speckle.Connectors.ArcGIS.HostApp; +using Speckle.Connectors.DUI.Bindings; +using Speckle.Connectors.DUI.Bridge; +using Speckle.Connectors.DUI.Utils; +using Speckle.Converters.Common; +using Speckle.Newtonsoft.Json; +using Speckle.Newtonsoft.Json.Serialization; +using Speckle.Connectors.ArcGIS.Utils; + +namespace Speckle.Connectors.ArcGIS.DependencyInjection; + +public class AutofacArcGISModule : Module +{ + protected override void Load(ContainerBuilder builder) + { + RegisterLoggerFactory(builder); + + // Register DUI3 related stuff + builder.RegisterInstance(GetJsonSerializerSettings()).SingleInstance(); + builder.RegisterType().As().InstancePerDependency(); //TODO: Verify why we need one bridge instance per dependency. + + builder.RegisterType().SingleInstance(); + builder.RegisterType().SingleInstance(); + + // Register bindings + builder.RegisterType().As().SingleInstance(); + builder.RegisterType().As().As().SingleInstance(); + builder.RegisterType().As().SingleInstance(); + + // Register converter factory + builder + .RegisterType>() + .As>() + .InstancePerLifetimeScope(); + } + + private static JsonSerializerSettings GetJsonSerializerSettings() + { + // Register WebView2 panel stuff + JsonSerializerSettings settings = + new() + { + Error = (_, args) => + { + Console.WriteLine("*** JSON ERROR: " + args.ErrorContext); + }, + ContractResolver = new CamelCasePropertyNamesContractResolver(), + NullValueHandling = NullValueHandling.Ignore, + ReferenceLoopHandling = ReferenceLoopHandling.Ignore, + DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate, + Converters = { new DiscriminatedObjectConverter(), new AbstractConverter() } + }; + return settings; + } + + private static void RegisterLoggerFactory(ContainerBuilder builder) + { + var serilogLogger = new LoggerConfiguration().MinimumLevel + .Debug() + .WriteTo.File("log.txt", rollingInterval: RollingInterval.Day) + .CreateLogger(); + + ILoggerFactory loggerFactory = new LoggerFactory().AddSerilog(serilogLogger); + builder.RegisterInstance(loggerFactory).As().SingleInstance(); + } +} diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Filters/ArcGISEverythingFilter.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Filters/ArcGISEverythingFilter.cs new file mode 100644 index 0000000000..67c6edb591 --- /dev/null +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Filters/ArcGISEverythingFilter.cs @@ -0,0 +1,10 @@ +using Speckle.Connectors.DUI.Bindings; + +namespace Speckle.Connectors.ArcGIS.Filters; + +public class ArcGISEverythingFilter : EverythingSendFilter +{ + public override List GetObjectIds() => new(); // TODO + + public override bool CheckExpiry(string[] changedObjectIds) => true; +} diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Filters/ArcGISSelectionFilter.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Filters/ArcGISSelectionFilter.cs new file mode 100644 index 0000000000..97247d1b5b --- /dev/null +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Filters/ArcGISSelectionFilter.cs @@ -0,0 +1,10 @@ +using Speckle.Connectors.DUI.Bindings; + +namespace Speckle.Connectors.ArcGIS.Filters; + +public class ArcGISSelectionFilter : DirectSelectionSendFilter +{ + public override List GetObjectIds() => SelectedObjectIds; + + public override bool CheckExpiry(string[] changedObjectIds) => SelectedObjectIds.Intersect(changedObjectIds).Any(); +} diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/HostApp/ArcGISSettings.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/HostApp/ArcGISSettings.cs new file mode 100644 index 0000000000..910e15c72e --- /dev/null +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/HostApp/ArcGISSettings.cs @@ -0,0 +1,19 @@ +using System.IO; +using Speckle.Core.Kits; + +namespace Speckle.Connectors.ArcGIS.HostApp; + +public class ArcGISSettings +{ + public ArcGISSettings(HostApplication hostAppInfo, HostAppVersion hostAppVersion) + { + HostAppInfo = hostAppInfo; + HostAppVersion = hostAppVersion; + Modules = new[] { new DirectoryInfo(typeof(ArcGISSettings).Assembly.Location).Parent!.FullName }; + } + + public HostApplication HostAppInfo { get; private set; } + public HostAppVersion HostAppVersion { get; private set; } + + public IReadOnlyList Modules { get; private set; } +} diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/HostApp/SpeckleDUI3.xaml b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/HostApp/SpeckleDUI3.xaml new file mode 100644 index 0000000000..bcf6c07331 --- /dev/null +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/HostApp/SpeckleDUI3.xaml @@ -0,0 +1,23 @@ + + + + + + + + diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/HostApp/SpeckleDUI3.xaml.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/HostApp/SpeckleDUI3.xaml.cs new file mode 100644 index 0000000000..b329359ec3 --- /dev/null +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/HostApp/SpeckleDUI3.xaml.cs @@ -0,0 +1,46 @@ +using System.Windows.Controls; +using System.Windows.Threading; +using Microsoft.Web.WebView2.Core; +using Speckle.Connectors.DUI.Bindings; +using Speckle.Core.Logging; + +namespace Speckle.Connectors.ArcGIS.HostApp; + +/// +/// Interaction logic for WebViewBrowserView.xaml +/// +public partial class SpeckleDUI3 : UserControl +{ + private readonly IEnumerable> _bindings; + + public SpeckleDUI3(IEnumerable> bindings) + { + _bindings = bindings; + InitializeComponent(); + Browser.CoreWebView2InitializationCompleted += OnInitialized; + } + + private void ShowDevToolsMethod() => Browser.CoreWebView2.OpenDevToolsWindow(); + + private void ExecuteScriptAsyncMethod(string script) + { + if (!Browser.IsInitialized) + { + throw new SpeckleException("Failed to execute script, Webview2 is not initialized yet."); + } + + Browser.Dispatcher.Invoke(() => Browser.ExecuteScriptAsync(script), DispatcherPriority.Background); + } + + private void OnInitialized(object? sender, CoreWebView2InitializationCompletedEventArgs e) + { + //TODO: Pass bindings to browser bridge here! + foreach (Lazy lazyBinding in _bindings) + { + var binding = lazyBinding.Value; + binding.Parent.AssociateWithBinding(binding, ExecuteScriptAsyncMethod, Browser); + Console.WriteLine(); + Browser.CoreWebView2.AddHostObjectToScript(binding.Name, binding.Parent); + } + } +} diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/HostApp/SpeckleDUI3ViewModel.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/HostApp/SpeckleDUI3ViewModel.cs new file mode 100644 index 0000000000..49a9f9f807 --- /dev/null +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/HostApp/SpeckleDUI3ViewModel.cs @@ -0,0 +1,42 @@ +using ArcGIS.Desktop.Framework; +using ArcGIS.Desktop.Framework.Contracts; + +namespace Speckle.Connectors.ArcGIS.HostApp; + +internal class SpeckleDUI3ViewModel : DockPane +{ + private const string DOCKPANE_ID = "SpeckleDUI3_SpeckleDUI3"; + + internal static void Create() + { + var pane = FrameworkApplication.DockPaneManager.Find(DOCKPANE_ID); + pane?.Activate(); + } + + /// + /// Called when the pane is initialized. + /// + protected override async Task InitializeAsync() + { + await base.InitializeAsync().ConfigureAwait(false); + } + + /// + /// Called when the pane is uninitialized. + /// + protected override async Task UninitializeAsync() + { + await base.UninitializeAsync().ConfigureAwait(false); + } +} + +/// +/// Button implementation to create a new instance of the pane and activate it. +/// +internal class SpeckleDUI3OpenButton : Button +{ + protected override void OnClick() + { + SpeckleDUI3ViewModel.Create(); + } +} diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/HostApp/SpeckleDUI3Wrapper.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/HostApp/SpeckleDUI3Wrapper.cs new file mode 100644 index 0000000000..18d9d8a048 --- /dev/null +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/HostApp/SpeckleDUI3Wrapper.cs @@ -0,0 +1,16 @@ +using System.Windows.Controls; + +namespace Speckle.Connectors.ArcGIS.HostApp; + +public class SpeckleDUI3Wrapper : UserControl +{ + public SpeckleDUI3Wrapper() + { + Initialize(); + } + + private void Initialize() + { + Content = SpeckleModule.Container.Resolve(); + } +} diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/HostApp/SpeckleModule.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/HostApp/SpeckleModule.cs new file mode 100644 index 0000000000..d6c33dc4c0 --- /dev/null +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/HostApp/SpeckleModule.cs @@ -0,0 +1,84 @@ +using System.IO; +using System.Reflection; +using ArcGIS.Desktop.Framework; +using Autofac; +using Speckle.Autofac.DependencyInjection; +using Speckle.Autofac.Files; +using Speckle.Connectors.ArcGIS.DependencyInjection; +using Speckle.Converters.Common.Objects; +using Speckle.Core.Kits; +using Speckle.Converters.Common.DependencyInjection; +using Module = ArcGIS.Desktop.Framework.Contracts.Module; + +namespace Speckle.Connectors.ArcGIS.HostApp; + +/// +/// This sample shows how to implement pane that contains an Edge WebView2 control using the built-in ArcGIS Pro SDK's WebBrowser control. For details on how to utilize the WebBrowser control in an add-in see here: https://github.com/Esri/arcgis-pro-sdk/wiki/ProConcepts-Framework#webbrowser For details on how to utilize the Microsoft Edge web browser control in an add-in see here: https://github.com/Esri/arcgis-pro-sdk/wiki/ProConcepts-Framework#webbrowser-control +/// +internal class SpeckleModule : Module +{ + private static SpeckleModule? s_this; + + /// + /// Retrieve the singleton instance to this module here + /// + public static SpeckleModule Current => + s_this ??= (SpeckleModule)FrameworkApplication.FindModule("ConnectorArcGIS_Module"); + + public static AutofacContainer Container { get; private set; } + + /// + /// Called by Framework when ArcGIS Pro is closing + /// + /// False to prevent Pro from closing, otherwise True + protected override bool CanUnload() + { + //TODO - add your business logic + //return false to ~cancel~ Application close + return true; + } + + protected override bool Initialize() + { + AppDomain.CurrentDomain.AssemblyResolve += OnAssemblyResolve; + + Container = new AutofacContainer(new StorageInfo()); + Container.PreBuildEvent += Container_PreBuildEvent; + + // Register Settings + var arcgisSettings = new ArcGISSettings(HostApplications.ArcGIS, HostAppVersion.v3); + + Container + .AddModule(new AutofacArcGISModule()) + .LoadAutofacModules(arcgisSettings.Modules) + .AddSingletonInstance(arcgisSettings) + .Build(); + + return base.Initialize(); + } + + private void Container_PreBuildEvent(object? sender, ContainerBuilder containerBuilder) + { + containerBuilder.InjectNamedTypes(); + } + + private Assembly? OnAssemblyResolve(object? sender, ResolveEventArgs args) + { + // POC: tight binding to files + Assembly? assembly = null; + string name = args.Name.Split(',')[0]; + string? path = Path.GetDirectoryName(typeof(SpeckleModule).Assembly.Location); + + if (path != null) + { + string assemblyFile = Path.Combine(path, name + ".dll"); + + if (File.Exists(assemblyFile)) + { + assembly = Assembly.LoadFrom(assemblyFile); + } + } + + return assembly; + } +} diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Images/AddInDesktop16.png b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Images/AddInDesktop16.png new file mode 100644 index 0000000000000000000000000000000000000000..5910bbf3dcd0cb09139b0c9926e00f96131d4757 GIT binary patch literal 524 zcmV+n0`vWeP)#SV*!XQdtWo`zW)u3-ITZ)bVS)1Hr@Kl zz{$$UaP`DN21cm=1AtUN5Gz1JiI2g=(Ssq}!4R(tz+M1pW@cqxuV5w1AS5Nuz{e%d z@ciLDhV#4Ef^E~*)jrVX(1?VK7tH?T6 zV6mVetE9oe&dLMU{OQ|Eumra#H^Zy{AHiV&j|FE@unXFbz5|BS4@5LRd2^9LP1=Fs z?(<^|fByc0Yxw-(Jy;XE3zP*}8B8QO7*;|Jc<}h%4F!2wFfb;P zxhYzAxw&0+>vq3KuWs}H(rta=aCh(dp7Z^j&-d3E1qyPfy+g$3^PX-BvM8b`0+z$sEF<`iyY2Ae<*Q&c8r=f|8OVVw3&**j?e;Ck zVzCTK2dhb)&pH4-5R^=}QQ41M&;^P5et#gz9sk7zdQ8wtsg|iA)B@4{v}Z_qW$A36 zS|g1a!az2SYcVJTJ5US^%!I)ois|a14(e*jz5%?O4nZ^~0%zAJ4|Px%*Qkl&E^=T> z6egvpHz0tI--L%3oLe-0T-F58R?EQ6YCCj}{U&QYu6$zv)bbcNKmd3m+_>vfks-#) zS+kcvH2!lU0R_CwMvf`X*4FLOL@5)Jax6; z@zjyXMoRSp5m`dtYk{B>43|ldep^vNO<~0$sBgFmzQ8Al#W%p^tOAj@!pP@Q82B&( z?xq{SRhAgbf_ZT#W>f)e8~?(cDQ3_(ZOVn^KRz(!*X6hUv&46xLfHSK4s) z{cGSW+o5wJma#18FFSjjaa9}vYo3#w*qX9np;VV%hI1#I$w)f=d;}b3hh_~hDsnr%?w?u=t}mEXYC)KkXZhqyUjxwE z(wvcdBbC~Wuqt9 + + + net6.0-windows + true + x64 + Speckle.Connectors.ArcGIS + true + enable + enable + + + + true + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Utils/ArcGisDocumentStore.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Utils/ArcGisDocumentStore.cs new file mode 100644 index 0000000000..77cc766786 --- /dev/null +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Utils/ArcGisDocumentStore.cs @@ -0,0 +1,23 @@ +using Speckle.Connectors.DUI.Models; +using Speckle.Newtonsoft.Json; + +namespace Speckle.Connectors.ArcGIS.Utils; + +public class ArcGISDocumentStore : DocumentModelStore +{ + public ArcGISDocumentStore(JsonSerializerSettings serializerOption) + : base(serializerOption) + { + // Subscribe here document related events like OnSave, OnClose, OnOpen etc... + } + + public override void WriteToFile() + { + // Implement the logic to save it to file + } + + public override void ReadFromFile() + { + // Implement the logic to read it from file + } +} diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Properties/launchSettings.json b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Properties/launchSettings.json index 2594cdac28..6a541028e4 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Properties/launchSettings.json +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Properties/launchSettings.json @@ -3,7 +3,7 @@ "Speckle.Connectors.Rhino7": { "commandName": "Executable", "executablePath": "C:\\Program Files\\Rhino 7\\System\\Rhino.exe", - "commandLineArgs": "$(TargetPath)" + "commandLineArgs": "\"$(TargetPath)\"" } } } diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3.DependencyInjection/AutofacArcGIS3ConverterModule.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3.DependencyInjection/AutofacArcGIS3ConverterModule.cs new file mode 100644 index 0000000000..68f507e6b2 --- /dev/null +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3.DependencyInjection/AutofacArcGIS3ConverterModule.cs @@ -0,0 +1,22 @@ +// POC: not sure we should have this here as it attaches us to autofac, maybe a bit prematurely... + +using Autofac; +using Speckle.Autofac.DependencyInjection; +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; + +namespace Speckle.Converters.ArcGIS3.DependencyInjection; + +public class AutofacArcGISConverterModule : Module +{ + protected override void Load(ContainerBuilder builder) + { + // most things should be InstancePerLifetimeScope so we get one per operation + builder.RegisterType().As(); + + // factory for conversions + builder + .RegisterType>() + .As>(); + } +} diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3.DependencyInjection/Speckle.Converters.ArcGIS3.DependencyInjection.csproj b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3.DependencyInjection/Speckle.Converters.ArcGIS3.DependencyInjection.csproj new file mode 100644 index 0000000000..96bd4d531e --- /dev/null +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3.DependencyInjection/Speckle.Converters.ArcGIS3.DependencyInjection.csproj @@ -0,0 +1,13 @@ + + + + net6.0 + enable + enable + + + + + + + diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ArcGISConverterToSpeckle.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ArcGISConverterToSpeckle.cs new file mode 100644 index 0000000000..c0c7ad1405 --- /dev/null +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ArcGISConverterToSpeckle.cs @@ -0,0 +1,40 @@ +using Speckle.Autofac.DependencyInjection; +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; +using Speckle.Core.Models; + +namespace Speckle.Converters.ArcGIS3; + +public class ArcGISConverterToSpeckle : ISpeckleConverterToSpeckle +{ + private readonly IFactory _toSpeckle; + + public ArcGISConverterToSpeckle(IFactory toSpeckle) + { + _toSpeckle = toSpeckle; + } + + public Base Convert(object target) + { + Type type = typeof(String); + + try + { + var objectConverter = _toSpeckle.ResolveInstance(type.Name); + + if (objectConverter == null) + { + throw new NotSupportedException($"No conversion found for {target.GetType().Name}"); + } + + var convertedObject = objectConverter.Convert("Teststt"); + + return convertedObject; + } + catch (SpeckleConversionException e) + { + Console.WriteLine(e); + throw; // Just rethrowing for now, Logs may be needed here. + } + } +} diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/FakeConversion.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/FakeConversion.cs new file mode 100644 index 0000000000..c920467276 --- /dev/null +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/FakeConversion.cs @@ -0,0 +1,17 @@ +using Objects.Geometry; +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; +using Speckle.Core.Models; + +namespace Speckle.Converters.ArcGIS3; + +[NameAndRankValue(nameof(String), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +public class FakeConversion : IHostObjectToSpeckleConversion, IRawConversion +{ + public Base Convert(object target) => RawConvert((String)target); + + public Point RawConvert(String target) + { + return new Point(0, 0, 100) { ["customText"] = target }; + } +} diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Speckle.Converters.ArcGIS3.csproj b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Speckle.Converters.ArcGIS3.csproj new file mode 100644 index 0000000000..76841eb9fe --- /dev/null +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Speckle.Converters.ArcGIS3.csproj @@ -0,0 +1,14 @@ + + + + net6.0 + enable + enable + + + + + + + + diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Speckle.Converters.Rhino7.csproj b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Speckle.Converters.Rhino7.csproj index b0b071e7ae..8247c3480a 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Speckle.Converters.Rhino7.csproj +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Speckle.Converters.Rhino7.csproj @@ -9,7 +9,6 @@ - diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/Speckle.Converters.Common.DependencyInjection.csproj b/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/Speckle.Converters.Common.DependencyInjection.csproj index 261381b8fe..51381f8c41 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/Speckle.Converters.Common.DependencyInjection.csproj +++ b/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/Speckle.Converters.Common.DependencyInjection.csproj @@ -1,4 +1,4 @@ - + netstandard2.0 @@ -11,7 +11,6 @@ - From d4435449fbd611651f47736fe1c52f43907b4c87 Mon Sep 17 00:00:00 2001 From: Jedd Morgan <45512892+JR-Morgan@users.noreply.github.com> Date: Tue, 26 Mar 2024 12:38:38 +0000 Subject: [PATCH 015/261] [CNX-9165] update arq gis with fix for progress reporting on send (#3247) * Updated send bindings commands * injected cancellation manager * formatting --- .../Bindings/ArcGISSendBinding.cs | 36 +++++++------------ .../Bindings/BasicConnectorBinding.cs | 4 +-- .../AutofacArcGISModule.cs | 4 +++ .../Utils/ArcGisDocumentStore.cs | 2 +- .../Bridge/BrowserBridge.cs | 2 +- 5 files changed, 20 insertions(+), 28 deletions(-) diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISSendBinding.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISSendBinding.cs index 7f26370e0e..3aa215f409 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISSendBinding.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISSendBinding.cs @@ -21,19 +21,14 @@ namespace Speckle.Connectors.ArcGIS.Bindings; public sealed class ArcGISSendBinding : ISendBinding, ICancelable { - public string Name { get; } = "sendBinding"; + public string Name => "sendBinding"; public SendBindingUICommands Commands { get; } - public IBridge Parent { get; set; } + public IBridge Parent { get; } private readonly ArcGISDocumentStore _store; private readonly ArcGISSettings _arcgisSettings; - private readonly IBasicConnectorBinding _basicConnectorBinding; private readonly IScopedFactory _speckleConverterToSpeckleFactory; - - // private readonly ArcGISIdleManager _idleManager; - // private readonly ArcGISContext _arcgisContext; - - public CancellationManager CancellationManager { get; } = new(); + private readonly CancellationManager _cancellationManager; /// /// Used internally to aggregate the changed objects' id. @@ -47,20 +42,16 @@ public sealed class ArcGISSendBinding : ISendBinding, ICancelable public ArcGISSendBinding( ArcGISDocumentStore store, - // ArcGISIdleManager idleManager, ArcGISSettings arcgisSettings, IBridge parent, - IBasicConnectorBinding basicConnectorBinding, - IScopedFactory speckleConverterToSpeckleFactory - // ArcGISContext arcgisContext + IScopedFactory speckleConverterToSpeckleFactory, + CancellationManager cancellationManager ) { _store = store; - // _idleManager = idleManager; _arcgisSettings = arcgisSettings; - _basicConnectorBinding = basicConnectorBinding; _speckleConverterToSpeckleFactory = speckleConverterToSpeckleFactory; - // _arcgisContext = arcgisContext; + _cancellationManager = cancellationManager; Parent = parent; Commands = new SendBindingUICommands(parent); @@ -99,7 +90,7 @@ public async Task Send(string modelCardId) try { // 0 - Init cancellation token source -> Manager also cancel it if exist before - CancellationTokenSource cts = CancellationManager.InitCancellationTokenSource(modelCardId); + CancellationTokenSource cts = _cancellationManager.InitCancellationTokenSource(modelCardId); // 1 - Get model @@ -132,7 +123,7 @@ public async Task Send(string modelCardId) } // 7 - Serialize and Send objects - _basicConnectorBinding.Commands.SetModelProgress(modelCardId, new ModelCardProgress { Status = "Uploading..." }); + Commands.SetModelProgress(modelCardId, new ModelCardProgress { Status = "Uploading..." }); var transport = new ServerTransport(account, modelCard.ProjectId); var sendResult = await SendHelper.Send(commitObject, transport, true, null, cts.Token).ConfigureAwait(true); @@ -148,10 +139,7 @@ public async Task Send(string modelCardId) // NOTE: ChangedObjectIds is currently JsonIgnored, but could actually be useful for highlighting changes in host app. //modelCard.ChangedObjectIds = new(); - _basicConnectorBinding.Commands.SetModelProgress( - modelCardId, - new ModelCardProgress { Status = "Linking version to model..." } - ); + Commands.SetModelProgress(modelCardId, new ModelCardProgress { Status = "Linking version to model..." }); // 8 - Create the version (commit) var apiClient = new Client(account); @@ -177,11 +165,11 @@ public async Task Send(string modelCardId) } catch (Exception e) when (!e.IsFatal()) // All exceptions should be handled here if possible, otherwise we enter "crashing the host app" territory. { - _basicConnectorBinding.Commands.SetModelError(modelCardId, e); + Commands.SetModelError(modelCardId, e); } } - public void CancelSend(string modelCardId) => CancellationManager.CancelOperation(modelCardId); + public void CancelSend(string modelCardId) => _cancellationManager.CancelOperation(modelCardId); private Base ConvertObjects( List arcgisObjects, @@ -232,7 +220,7 @@ CancellationTokenSource cts // 4. add to host collectionHost.elements.Add(converted); - _basicConnectorBinding.Commands.SetModelProgress( + Commands.SetModelProgress( modelCard.ModelCardId, new ModelCardProgress { Status = "Converting", Progress = (double)++count / 2 } // / arcgisObjects.Count } ); diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/BasicConnectorBinding.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/BasicConnectorBinding.cs index 0c46403fda..46fde8ad11 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/BasicConnectorBinding.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/BasicConnectorBinding.cs @@ -11,8 +11,8 @@ namespace Speckle.Connectors.ArcGIS.Bindings; public class BasicConnectorBinding : IBasicConnectorBinding { - public string Name { get; set; } = "baseBinding"; - public IBridge Parent { get; set; } + public string Name => "baseBinding"; + public IBridge Parent { get; } public BasicConnectorBindingCommands Commands { get; } private readonly ArcGISDocumentStore _store; diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/DependencyInjection/AutofacArcGISModule.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/DependencyInjection/AutofacArcGISModule.cs index ac140e5dfd..2386831b56 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/DependencyInjection/AutofacArcGISModule.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/DependencyInjection/AutofacArcGISModule.cs @@ -11,6 +11,7 @@ using Speckle.Newtonsoft.Json; using Speckle.Newtonsoft.Json.Serialization; using Speckle.Connectors.ArcGIS.Utils; +using Speckle.Connectors.Utils.Cancellation; namespace Speckle.Connectors.ArcGIS.DependencyInjection; @@ -32,6 +33,9 @@ protected override void Load(ContainerBuilder builder) builder.RegisterType().As().As().SingleInstance(); builder.RegisterType().As().SingleInstance(); + // binding dependencies + builder.RegisterType().InstancePerDependency(); + // Register converter factory builder .RegisterType>() diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Utils/ArcGisDocumentStore.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Utils/ArcGisDocumentStore.cs index 77cc766786..0870acaa08 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Utils/ArcGisDocumentStore.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Utils/ArcGisDocumentStore.cs @@ -8,7 +8,7 @@ public class ArcGISDocumentStore : DocumentModelStore public ArcGISDocumentStore(JsonSerializerSettings serializerOption) : base(serializerOption) { - // Subscribe here document related events like OnSave, OnClose, OnOpen etc... + // POC: Subscribe here document related events like OnSave, OnClose, OnOpen etc... } public override void WriteToFile() diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/BrowserBridge.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/BrowserBridge.cs index c927af7c5e..c0812756e3 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/BrowserBridge.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/BrowserBridge.cs @@ -275,7 +275,7 @@ public void ShowDevTools() public void OpenUrl(string url) { - Process.Start(url); + Process.Start(new ProcessStartInfo { FileName = url, UseShellExecute = true }); } public void Send(string eventName) From 5c105ec70ca46d38c031fec386be9042e15c1397 Mon Sep 17 00:00:00 2001 From: Jedd Morgan <45512892+JR-Morgan@users.noreply.github.com> Date: Tue, 26 Mar 2024 17:53:18 +0000 Subject: [PATCH 016/261] Enforced CS8618 (#3248) * Enforced CS8618 * Suppressed Rhino Warnings * Fixed warnings * Update Directory.Build.props --- .../Speckle.Automate.Sdk.csproj | 2 +- ...ckle.Automate.Sdk.Tests.Integration.csproj | 3 +- .../SpeckleAutomate.cs | 2 +- Core/Core/Core.csproj | 2 +- .../Api/Operations/ReceiveFromSQLite.cs | 4 +-- .../Speckle.Core.Tests.Performance.csproj | 2 +- .../GraphTraversal/TraversalMockObjects.cs | 3 +- .../HostApp/SpeckleDUI3Wrapper.cs | 2 +- .../HostApp/SpeckleModule.cs | 30 +++++++++---------- .../Speckle.Connectors.Rhino7.csproj | 7 +++++ .../Geometry/PolyCurveToSpeckleConverter.cs | 4 +-- .../Speckle.Converters.Rhino7.csproj | 8 +++++ .../DependencyInjection/AutofacContainer.cs | 12 ++++++-- Directory.Build.props | 2 -- Objects/Objects/Objects.csproj | 2 +- 15 files changed, 50 insertions(+), 35 deletions(-) diff --git a/Automate/Speckle.Automate.Sdk/Speckle.Automate.Sdk.csproj b/Automate/Speckle.Automate.Sdk/Speckle.Automate.Sdk.csproj index 23712d34b6..e1e0d8969d 100644 --- a/Automate/Speckle.Automate.Sdk/Speckle.Automate.Sdk.csproj +++ b/Automate/Speckle.Automate.Sdk/Speckle.Automate.Sdk.csproj @@ -13,7 +13,7 @@ true - $(WarningsNotAsErrors);NU5104 + $(WarningsNotAsErrors);NU5104;CS8618 diff --git a/Automate/Tests/Speckle.Automate.Sdk.Tests.Integration/Speckle.Automate.Sdk.Tests.Integration.csproj b/Automate/Tests/Speckle.Automate.Sdk.Tests.Integration/Speckle.Automate.Sdk.Tests.Integration.csproj index f71e7df6fa..53a7ff66c0 100644 --- a/Automate/Tests/Speckle.Automate.Sdk.Tests.Integration/Speckle.Automate.Sdk.Tests.Integration.csproj +++ b/Automate/Tests/Speckle.Automate.Sdk.Tests.Integration/Speckle.Automate.Sdk.Tests.Integration.csproj @@ -3,8 +3,7 @@ net7.0 enable - enable - + disable false true diff --git a/Automate/Tests/Speckle.Automate.Sdk.Tests.Integration/SpeckleAutomate.cs b/Automate/Tests/Speckle.Automate.Sdk.Tests.Integration/SpeckleAutomate.cs index 06888f5c34..d7eaf78fb5 100644 --- a/Automate/Tests/Speckle.Automate.Sdk.Tests.Integration/SpeckleAutomate.cs +++ b/Automate/Tests/Speckle.Automate.Sdk.Tests.Integration/SpeckleAutomate.cs @@ -102,7 +102,7 @@ public void TestParseInputData() FunctionRunData functionRunData = new() { FunctionInputs = testFunctionInputs }; string serializedFunctionRunData = JsonConvert.SerializeObject(functionRunData); File.WriteAllText("./inputData.json", serializedFunctionRunData); - FunctionRunData? data = FunctionRunDataParser.FromPath("./inputData.json"); + FunctionRunData data = FunctionRunDataParser.FromPath("./inputData.json"); Assert.AreEqual("Base", data.FunctionInputs.ForbiddenSpeckleType); } diff --git a/Core/Core/Core.csproj b/Core/Core/Core.csproj index 2b74ff5528..33510411b4 100644 --- a/Core/Core/Core.csproj +++ b/Core/Core/Core.csproj @@ -23,7 +23,7 @@ CA1502; CA1506; CA1708; CA1710; CA1711; CA1716; CA1720; CA1721; CA1724; CA1816; CA1851; CA1861; - CA2201; + CA2201; CS8618; CS0419; CS0618; CS0659; CS0809; CS8600; CS8602; CS8603; CS8604; IDE0032; IDE0059; IDE0130; IDE1006; diff --git a/Core/Tests/Speckle.Core.Tests.Performance/Api/Operations/ReceiveFromSQLite.cs b/Core/Tests/Speckle.Core.Tests.Performance/Api/Operations/ReceiveFromSQLite.cs index 8a42ce5b69..311bb71e1f 100644 --- a/Core/Tests/Speckle.Core.Tests.Performance/Api/Operations/ReceiveFromSQLite.cs +++ b/Core/Tests/Speckle.Core.Tests.Performance/Api/Operations/ReceiveFromSQLite.cs @@ -21,9 +21,9 @@ public async Task Setup() } [Benchmark] - public async Task Receive_FromSQLite() + public async Task Receive_FromSQLite() { - Base? b = await Speckle.Core.Api.Operations + Base b = await Speckle.Core.Api.Operations .Receive(_dataSource.ObjectId, null, _dataSource.Transport) .ConfigureAwait(false); diff --git a/Core/Tests/Speckle.Core.Tests.Performance/Speckle.Core.Tests.Performance.csproj b/Core/Tests/Speckle.Core.Tests.Performance/Speckle.Core.Tests.Performance.csproj index 653be577bd..8b53d9d4a8 100644 --- a/Core/Tests/Speckle.Core.Tests.Performance/Speckle.Core.Tests.Performance.csproj +++ b/Core/Tests/Speckle.Core.Tests.Performance/Speckle.Core.Tests.Performance.csproj @@ -3,7 +3,7 @@ net481 enable - enable + disable exe true diff --git a/Core/Tests/Speckle.Core.Tests.Unit/Models/GraphTraversal/TraversalMockObjects.cs b/Core/Tests/Speckle.Core.Tests.Unit/Models/GraphTraversal/TraversalMockObjects.cs index e28b57810a..799fd24994 100644 --- a/Core/Tests/Speckle.Core.Tests.Unit/Models/GraphTraversal/TraversalMockObjects.cs +++ b/Core/Tests/Speckle.Core.Tests.Unit/Models/GraphTraversal/TraversalMockObjects.cs @@ -1,11 +1,10 @@ -#nullable enable using Speckle.Core.Models; namespace Speckle.Core.Tests.Unit.Models.GraphTraversal; public class TraversalMock : Base { - public Base? Child { get; set; } + public Base Child { get; set; } public object ObjectChild { get; set; } diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/HostApp/SpeckleDUI3Wrapper.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/HostApp/SpeckleDUI3Wrapper.cs index 18d9d8a048..4035b640cb 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/HostApp/SpeckleDUI3Wrapper.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/HostApp/SpeckleDUI3Wrapper.cs @@ -11,6 +11,6 @@ public SpeckleDUI3Wrapper() private void Initialize() { - Content = SpeckleModule.Container.Resolve(); + Content = SpeckleModule.Current.Container.Resolve(); } } diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/HostApp/SpeckleModule.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/HostApp/SpeckleModule.cs index d6c33dc4c0..9ac01ef648 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/HostApp/SpeckleModule.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/HostApp/SpeckleModule.cs @@ -25,20 +25,9 @@ internal class SpeckleModule : Module public static SpeckleModule Current => s_this ??= (SpeckleModule)FrameworkApplication.FindModule("ConnectorArcGIS_Module"); - public static AutofacContainer Container { get; private set; } + public AutofacContainer Container { get; } - /// - /// Called by Framework when ArcGIS Pro is closing - /// - /// False to prevent Pro from closing, otherwise True - protected override bool CanUnload() - { - //TODO - add your business logic - //return false to ~cancel~ Application close - return true; - } - - protected override bool Initialize() + public SpeckleModule() { AppDomain.CurrentDomain.AssemblyResolve += OnAssemblyResolve; @@ -53,16 +42,25 @@ protected override bool Initialize() .LoadAutofacModules(arcgisSettings.Modules) .AddSingletonInstance(arcgisSettings) .Build(); + } - return base.Initialize(); + /// + /// Called by Framework when ArcGIS Pro is closing + /// + /// False to prevent Pro from closing, otherwise True + protected override bool CanUnload() + { + //TODO - add your business logic + //return false to ~cancel~ Application close + return true; } - private void Container_PreBuildEvent(object? sender, ContainerBuilder containerBuilder) + private static void Container_PreBuildEvent(object? sender, ContainerBuilder containerBuilder) { containerBuilder.InjectNamedTypes(); } - private Assembly? OnAssemblyResolve(object? sender, ResolveEventArgs args) + private static Assembly? OnAssemblyResolve(object? sender, ResolveEventArgs args) { // POC: tight binding to files Assembly? assembly = null; diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Speckle.Connectors.Rhino7.csproj b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Speckle.Connectors.Rhino7.csproj index 1ac710a149..9d948cf72a 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Speckle.Connectors.Rhino7.csproj +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Speckle.Connectors.Rhino7.csproj @@ -7,6 +7,13 @@ true + + + $(WarningsNotAsErrors); + CS8618; + + + diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Geometry/PolyCurveToSpeckleConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Geometry/PolyCurveToSpeckleConverter.cs index 2670553a53..bb7f4a7edc 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Geometry/PolyCurveToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Geometry/PolyCurveToSpeckleConverter.cs @@ -9,7 +9,7 @@ namespace Speckle.Converters.Rhino7.Geometry; [NameAndRankValue(nameof(RG.PolyCurve), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] public class PolyCurveToSpeckleConverter : IHostObjectToSpeckleConversion, IRawConversion { - public IRawConversion CurveConverter { get; set; } // This created a circular dependency on the constructor, making it a property allows for the container to resolve it correctly + public IRawConversion? CurveConverter { get; set; } // This created a circular dependency on the constructor, making it a property allows for the container to resolve it correctly private readonly IRawConversion _intervalConverter; private readonly IRawConversion _boxConverter; private readonly IConversionContextStack _contextStack; @@ -38,7 +38,7 @@ public SOG.Polycurve RawConvert(RG.PolyCurve target) domain = _intervalConverter.RawConvert(target.Domain), length = target.GetLength(), bbox = _boxConverter.RawConvert(new RG.Box(target.GetBoundingBox(true))), - segments = segments.Select(CurveConverter.RawConvert).ToList(), + segments = segments.Select(CurveConverter!.RawConvert).ToList(), units = _contextStack.Current.SpeckleUnits }; return myPoly; diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Speckle.Converters.Rhino7.csproj b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Speckle.Converters.Rhino7.csproj index 8247c3480a..ce14684cee 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Speckle.Converters.Rhino7.csproj +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Speckle.Converters.Rhino7.csproj @@ -5,6 +5,14 @@ enable enable + + + + $(WarningsNotAsErrors); + CS8618; + + + diff --git a/DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/AutofacContainer.cs b/DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/AutofacContainer.cs index 2819954750..235ea7ae60 100644 --- a/DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/AutofacContainer.cs +++ b/DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/AutofacContainer.cs @@ -14,12 +14,12 @@ namespace Speckle.Autofac.DependencyInjection; public class AutofacContainer { // Declare the event. - public event EventHandler PreBuildEvent; + public event EventHandler? PreBuildEvent; private readonly ContainerBuilder _builder; private readonly IStorageInfo _storageInfo; - private IContainer _container; + private IContainer? _container; public AutofacContainer(IStorageInfo storageInfo) { @@ -98,7 +98,13 @@ public AutofacContainer Build() public T Resolve() where T : class { - // POC: resolve null check with a check and throw perhaps? + if (_container == null) + { + throw new InvalidOperationException( + $"Container was not initialized, {nameof(Build)} must be called before calling {nameof(Resolve)}" + ); + } + return _container.Resolve(); } } diff --git a/Directory.Build.props b/Directory.Build.props index 6287e38f60..2740e70ee9 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -34,8 +34,6 @@ CA5399;CA1862; CS1591;CS1573; - - CS8618; CA1303;CA1304;CA1305;CA1307;CA1308;CA1309;CA1310;CA1311;CA2101; NU1701; diff --git a/Objects/Objects/Objects.csproj b/Objects/Objects/Objects.csproj index 77a9ad6bbd..b406e0d89e 100644 --- a/Objects/Objects/Objects.csproj +++ b/Objects/Objects/Objects.csproj @@ -19,7 +19,7 @@ $(WarningsNotAsErrors); CA1008; CA1024; CA1034; CA1065; CA1708; CA1711; CA1716; CA1724; CA1725; - CA1819; + CA1819; CS8618; CA2201; CA2225; CS0659; CS0661; CS0728; IDE0041; IDE0060; IDE1006; From d54dce4ec74298b9235e7d8cd5adc5f2091c3757 Mon Sep 17 00:00:00 2001 From: Claire Kuang Date: Thu, 28 Mar 2024 12:38:43 +0000 Subject: [PATCH 017/261] feat(autocad): CNX-9132 dui3 dx autocad create baseline project and bring up to include di (#3246) * Autocad DI implementation - as a first pass it is working * Comments * Change source url from preview to dui3 netlify branch * Update AutocadDocumentManager.cs * send and selection binding wip * adds converter projects * adds point and line conversions * enables units conversion * Update SpeckleCommand.cs * adds global usings and reduces warns * merge refactoring * minor send binding changes * Update DUI3-DX.slnf * Update AutocadSendBinding.cs * Resolves some warnings and formatting in the connector * suppresses disposable warn on TransactionContext * more formatting changes * Update AutocadDocumentManager.cs * final comments addressed * Update AutocadCommand.cs * Update AutocadCommand.cs --------- Co-authored-by: oguzhankoral --- All.sln | 60 +++- DUI3-DX.slnf | 4 + .../Speckle.Connectors.Autocad2023.csproj | 26 ++ .../Bindings/AutocadBasicConnectorBinding.cs | 131 ++++++++ .../Bindings/AutocadSelectionBinding.cs | 77 +++++ .../Bindings/AutocadSendBinding.cs | 291 ++++++++++++++++++ .../AutofacAutocadModule.cs | 93 ++++++ .../Filters/AutocadSelectionFilter.cs | 10 + .../GlobalUsings.cs | 2 + .../HostApp/AutocadContext.cs | 6 + .../HostApp/AutocadDocumentManager.cs | 143 +++++++++ .../HostApp/AutocadDocumentModelStore.cs | 92 ++++++ .../HostApp/AutocadIdleManager.cs | 38 +++ .../HostApp/AutocadSettings.cs | 19 ++ .../HostApp/DUI3PanelWebView.xaml | 20 ++ .../HostApp/DUI3PanelWebView.xaml.cs | 40 +++ .../HostApp/Extensions/EditorExtensions.cs | 29 ++ .../HostApp/TransactionContext.cs | 32 ++ .../Interfaces/IAutocadPlugin.cs | 7 + .../Plugin/AutocadCommand.cs | 74 +++++ .../Plugin/AutocadExtensionApplication.cs | 28 ++ .../Plugin/AutocadPlugin.cs | 22 ++ ...Speckle.Connectors.AutocadShared.projitems | 40 +++ .../Speckle.Connectors.AutocadShared.shproj | 12 + .../Speckle.Connectors.AutocadShared/Utils.cs | 33 ++ .../Speckle.Converters.Autocad2023.csproj | 20 ++ .../AutocadConversionContextStack.cs | 21 ++ .../AutocadConverterToSpeckle.cs | 54 ++++ .../AutocadToSpeckleUnitConverter.cs | 37 +++ .../AutofacAutocadConverterModule.cs | 30 ++ .../Geometry/BoxToSpeckleConverter.cs | 42 +++ .../Geometry/IntervalToSpeckleConverter.cs | 13 + .../Geometry/LineToSpeckleConverter.cs | 39 +++ .../Geometry/PlaneToSpeckleConverter.cs | 36 +++ .../Geometry/PointToSpeckleConverter.cs | 42 +++ .../Geometry/VectorToSpeckleConverter.cs | 22 ++ .../GlobalUsings.cs | 6 + ...Speckle.Converters.AutocadShared.projitems | 24 ++ .../Speckle.Converters.AutocadShared.shproj | 13 + .../Bindings/ISendBinding.cs | 4 + 40 files changed, 1729 insertions(+), 3 deletions(-) create mode 100644 DUI3-DX/Connectors/Autocad/Speckle.Connectors.Autocad2023/Speckle.Connectors.Autocad2023.csproj create mode 100644 DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadBasicConnectorBinding.cs create mode 100644 DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadSelectionBinding.cs create mode 100644 DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadSendBinding.cs create mode 100644 DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/DependencyInjection/AutofacAutocadModule.cs create mode 100644 DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Filters/AutocadSelectionFilter.cs create mode 100644 DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/GlobalUsings.cs create mode 100644 DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/AutocadContext.cs create mode 100644 DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/AutocadDocumentManager.cs create mode 100644 DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/AutocadDocumentModelStore.cs create mode 100644 DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/AutocadIdleManager.cs create mode 100644 DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/AutocadSettings.cs create mode 100644 DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/DUI3PanelWebView.xaml create mode 100644 DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/DUI3PanelWebView.xaml.cs create mode 100644 DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/Extensions/EditorExtensions.cs create mode 100644 DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/TransactionContext.cs create mode 100644 DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Interfaces/IAutocadPlugin.cs create mode 100644 DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Plugin/AutocadCommand.cs create mode 100644 DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Plugin/AutocadExtensionApplication.cs create mode 100644 DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Plugin/AutocadPlugin.cs create mode 100644 DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Speckle.Connectors.AutocadShared.projitems create mode 100644 DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Speckle.Connectors.AutocadShared.shproj create mode 100644 DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Utils.cs create mode 100644 DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2023/Speckle.Converters.Autocad2023.csproj create mode 100644 DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/AutocadConversionContextStack.cs create mode 100644 DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/AutocadConverterToSpeckle.cs create mode 100644 DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/AutocadToSpeckleUnitConverter.cs create mode 100644 DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/DependencyInjection/AutofacAutocadConverterModule.cs create mode 100644 DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/Geometry/BoxToSpeckleConverter.cs create mode 100644 DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/Geometry/IntervalToSpeckleConverter.cs create mode 100644 DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/Geometry/LineToSpeckleConverter.cs create mode 100644 DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/Geometry/PlaneToSpeckleConverter.cs create mode 100644 DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/Geometry/PointToSpeckleConverter.cs create mode 100644 DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/Geometry/VectorToSpeckleConverter.cs create mode 100644 DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/GlobalUsings.cs create mode 100644 DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/Speckle.Converters.AutocadShared.projitems create mode 100644 DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/Speckle.Converters.AutocadShared.shproj diff --git a/All.sln b/All.sln index b38151a060..c1b7acf5ba 100644 --- a/All.sln +++ b/All.sln @@ -172,8 +172,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "CSI", "CSI", "{11C013F3-258 EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConnectorCSIBridge", "ConnectorCSI\ConnectorCSIBridge\ConnectorCSIBridge.csproj", "{23BE6E54-96C1-4373-89F3-E18A1C9807FD}" ProjectSection(ProjectDependencies) = postProject - {60BE029E-1F31-4473-8B68-A745A43AF179} = {60BE029E-1F31-4473-8B68-A745A43AF179} {21223BA5-C6E8-405D-B581-106C4726EDC0} = {21223BA5-C6E8-405D-B581-106C4726EDC0} + {60BE029E-1F31-4473-8B68-A745A43AF179} = {60BE029E-1F31-4473-8B68-A745A43AF179} EndProjectSection EndProject Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "ConnectorCSIShared", "ConnectorCSI\ConnectorCSIShared\ConnectorCSIShared.shproj", "{61374CD0-E774-4DCD-BFAB-6356B0931283}" @@ -186,8 +186,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConnectorETABS", "Connector EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConnectorSAFE", "ConnectorCSI\ConnectorSAFE\ConnectorSAFE.csproj", "{9D188843-8841-4A76-A844-EFBE8E32EE05}" ProjectSection(ProjectDependencies) = postProject - {60BE029E-1F31-4473-8B68-A745A43AF179} = {60BE029E-1F31-4473-8B68-A745A43AF179} {442116F3-0F4A-4136-894E-FF5F4295500B} = {442116F3-0F4A-4136-894E-FF5F4295500B} + {60BE029E-1F31-4473-8B68-A745A43AF179} = {60BE029E-1F31-4473-8B68-A745A43AF179} EndProjectSection EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConnectorSAP2000", "ConnectorCSI\ConnectorSAP2000\ConnectorSAP2000.csproj", "{31E0C098-6813-4571-AB96-A245E0FC1C23}" @@ -542,7 +542,19 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Speckle.Converters.ArcGIS3. EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ArcGIS", "ArcGIS", "{CCF48B65-33D1-4E8B-A57B-E03394730B21}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Speckle.Converters.Common.DependencyInjection", "DUI3-DX\Sdk\Speckle.Converters.Common.DependencyInjection\Speckle.Converters.Common.DependencyInjection.csproj", "{11F7D41B-AFCA-4D29-BC08-285A14BF3A3B}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Autocad", "Autocad", "{743489BF-1941-43D5-8AF9-35C56D0DCC34}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Speckle.Connectors.Autocad2023", "DUI3-DX\Connectors\Autocad\Speckle.Connectors.Autocad2023\Speckle.Connectors.Autocad2023.csproj", "{89C4CBC7-1606-40DE-B6DA-FBE3AAC98395}" +EndProject +Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Speckle.Connectors.AutocadShared", "DUI3-DX\Connectors\Autocad\Speckle.Connectors.AutocadShared\Speckle.Connectors.AutocadShared.shproj", "{41BC679F-887F-44CF-971D-A5502EE87DB0}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Speckle.Converters.Common.DependencyInjection", "DUI3-DX\Sdk\Speckle.Converters.Common.DependencyInjection\Speckle.Converters.Common.DependencyInjection.csproj", "{11F7D41B-AFCA-4D29-BC08-285A14BF3A3B}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Autocad", "Autocad", "{804E065F-914C-414A-AF84-009312C3CFF6}" +EndProject +Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Speckle.Converters.AutocadShared", "DUI3-DX\Converters\Autocad\Speckle.Converters.AutocadShared\Speckle.Converters.AutocadShared.shproj", "{9ADD1B7A-6401-4202-8613-F668E2FBC0A4}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Speckle.Converters.Autocad2023", "DUI3-DX\Converters\Autocad\Speckle.Converters.Autocad2023\Speckle.Converters.Autocad2023.csproj", "{631C295A-7CCF-4B42-8686-7034E31469E7}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -2650,6 +2662,22 @@ Global {9C1ECA1D-DE98-4FB7-92D0-FC45BB308E5D}.Release|Any CPU.Build.0 = Release|Any CPU {9C1ECA1D-DE98-4FB7-92D0-FC45BB308E5D}.Release|x64.ActiveCfg = Release|Any CPU {9C1ECA1D-DE98-4FB7-92D0-FC45BB308E5D}.Release|x64.Build.0 = Release|Any CPU + {89C4CBC7-1606-40DE-B6DA-FBE3AAC98395}.Debug Mac|Any CPU.ActiveCfg = Debug|Any CPU + {89C4CBC7-1606-40DE-B6DA-FBE3AAC98395}.Debug Mac|Any CPU.Build.0 = Debug|Any CPU + {89C4CBC7-1606-40DE-B6DA-FBE3AAC98395}.Debug Mac|x64.ActiveCfg = Debug|Any CPU + {89C4CBC7-1606-40DE-B6DA-FBE3AAC98395}.Debug Mac|x64.Build.0 = Debug|Any CPU + {89C4CBC7-1606-40DE-B6DA-FBE3AAC98395}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {89C4CBC7-1606-40DE-B6DA-FBE3AAC98395}.Debug|Any CPU.Build.0 = Debug|Any CPU + {89C4CBC7-1606-40DE-B6DA-FBE3AAC98395}.Debug|x64.ActiveCfg = Debug|Any CPU + {89C4CBC7-1606-40DE-B6DA-FBE3AAC98395}.Debug|x64.Build.0 = Debug|Any CPU + {89C4CBC7-1606-40DE-B6DA-FBE3AAC98395}.Release Mac|Any CPU.ActiveCfg = Debug|Any CPU + {89C4CBC7-1606-40DE-B6DA-FBE3AAC98395}.Release Mac|Any CPU.Build.0 = Debug|Any CPU + {89C4CBC7-1606-40DE-B6DA-FBE3AAC98395}.Release Mac|x64.ActiveCfg = Debug|Any CPU + {89C4CBC7-1606-40DE-B6DA-FBE3AAC98395}.Release Mac|x64.Build.0 = Debug|Any CPU + {89C4CBC7-1606-40DE-B6DA-FBE3AAC98395}.Release|Any CPU.ActiveCfg = Release|Any CPU + {89C4CBC7-1606-40DE-B6DA-FBE3AAC98395}.Release|Any CPU.Build.0 = Release|Any CPU + {89C4CBC7-1606-40DE-B6DA-FBE3AAC98395}.Release|x64.ActiveCfg = Release|Any CPU + {89C4CBC7-1606-40DE-B6DA-FBE3AAC98395}.Release|x64.Build.0 = Release|Any CPU {A97F7177-86C7-4B38-A6ED-DA51BF762471}.Debug Mac|Any CPU.ActiveCfg = Debug|Any CPU {A97F7177-86C7-4B38-A6ED-DA51BF762471}.Debug Mac|Any CPU.Build.0 = Debug|Any CPU {A97F7177-86C7-4B38-A6ED-DA51BF762471}.Debug Mac|x64.ActiveCfg = Debug|Any CPU @@ -2714,6 +2742,22 @@ Global {11F7D41B-AFCA-4D29-BC08-285A14BF3A3B}.Release|Any CPU.Build.0 = Release|Any CPU {11F7D41B-AFCA-4D29-BC08-285A14BF3A3B}.Release|x64.ActiveCfg = Release|Any CPU {11F7D41B-AFCA-4D29-BC08-285A14BF3A3B}.Release|x64.Build.0 = Release|Any CPU + {631C295A-7CCF-4B42-8686-7034E31469E7}.Debug Mac|Any CPU.ActiveCfg = Debug|Any CPU + {631C295A-7CCF-4B42-8686-7034E31469E7}.Debug Mac|Any CPU.Build.0 = Debug|Any CPU + {631C295A-7CCF-4B42-8686-7034E31469E7}.Debug Mac|x64.ActiveCfg = Debug|Any CPU + {631C295A-7CCF-4B42-8686-7034E31469E7}.Debug Mac|x64.Build.0 = Debug|Any CPU + {631C295A-7CCF-4B42-8686-7034E31469E7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {631C295A-7CCF-4B42-8686-7034E31469E7}.Debug|Any CPU.Build.0 = Debug|Any CPU + {631C295A-7CCF-4B42-8686-7034E31469E7}.Debug|x64.ActiveCfg = Debug|Any CPU + {631C295A-7CCF-4B42-8686-7034E31469E7}.Debug|x64.Build.0 = Debug|Any CPU + {631C295A-7CCF-4B42-8686-7034E31469E7}.Release Mac|Any CPU.ActiveCfg = Release|Any CPU + {631C295A-7CCF-4B42-8686-7034E31469E7}.Release Mac|Any CPU.Build.0 = Release|Any CPU + {631C295A-7CCF-4B42-8686-7034E31469E7}.Release Mac|x64.ActiveCfg = Release|Any CPU + {631C295A-7CCF-4B42-8686-7034E31469E7}.Release Mac|x64.Build.0 = Release|Any CPU + {631C295A-7CCF-4B42-8686-7034E31469E7}.Release|Any CPU.ActiveCfg = Release|Any CPU + {631C295A-7CCF-4B42-8686-7034E31469E7}.Release|Any CPU.Build.0 = Release|Any CPU + {631C295A-7CCF-4B42-8686-7034E31469E7}.Release|x64.ActiveCfg = Release|Any CPU + {631C295A-7CCF-4B42-8686-7034E31469E7}.Release|x64.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -2918,12 +2962,18 @@ Global {34C2C062-E43F-4FB5-B839-64BC044CCEF3} = {1FE3C60E-7865-40A5-9794-55ECB64F6489} {65A2F556-F14A-49F3-8A92-7F2E1E7ED3B5} = {34C2C062-E43F-4FB5-B839-64BC044CCEF3} {9C1ECA1D-DE98-4FB7-92D0-FC45BB308E5D} = {34C2C062-E43F-4FB5-B839-64BC044CCEF3} + {743489BF-1941-43D5-8AF9-35C56D0DCC34} = {33D19E88-F3AE-4D28-B588-D91CCF9E3BA8} + {89C4CBC7-1606-40DE-B6DA-FBE3AAC98395} = {743489BF-1941-43D5-8AF9-35C56D0DCC34} + {41BC679F-887F-44CF-971D-A5502EE87DB0} = {743489BF-1941-43D5-8AF9-35C56D0DCC34} {A97F7177-86C7-4B38-A6ED-DA51BF762471} = {CE4B899D-9C0A-4B5D-B91A-CE62D2327695} {CE4B899D-9C0A-4B5D-B91A-CE62D2327695} = {33D19E88-F3AE-4D28-B588-D91CCF9E3BA8} {139F7A79-69E4-4B8A-B2A5-6A30A66C495C} = {CCF48B65-33D1-4E8B-A57B-E03394730B21} {7DFF1591-237D-499E-A767-EE37B93FB958} = {CCF48B65-33D1-4E8B-A57B-E03394730B21} {CCF48B65-33D1-4E8B-A57B-E03394730B21} = {1FE3C60E-7865-40A5-9794-55ECB64F6489} {11F7D41B-AFCA-4D29-BC08-285A14BF3A3B} = {2E00592E-558D-492D-88F9-3ECEE4C0C7DA} + {804E065F-914C-414A-AF84-009312C3CFF6} = {1FE3C60E-7865-40A5-9794-55ECB64F6489} + {9ADD1B7A-6401-4202-8613-F668E2FBC0A4} = {804E065F-914C-414A-AF84-009312C3CFF6} + {631C295A-7CCF-4B42-8686-7034E31469E7} = {804E065F-914C-414A-AF84-009312C3CFF6} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {1D43D91B-4F01-4A78-8250-CC6F9BD93A14} @@ -2958,6 +3008,7 @@ Global ConnectorRevit\RevitDUI3\RevitDUI3Shared\RevitDUI3Shared.projitems*{3d7f0278-6cf2-4588-a101-4027abb8b87f}*SharedItemsImports = 13 Objects\Converters\ConverterDynamo\ConverterDynamoShared\ConverterDynamoShared.projitems*{3df12639-78b6-41b3-a046-a675035369be}*SharedItemsImports = 5 ConnectorAutocadCivil\ConnectorAutocadCivil\ConnectorAutocadCivilShared.projitems*{3e30d170-3cb4-4728-97d5-887c5019da9b}*SharedItemsImports = 5 + DUI3-DX\Connectors\Autocad\Speckle.Connectors.AutocadShared\Speckle.Connectors.AutocadShared.projitems*{41bc679f-887f-44cf-971d-a5502ee87db0}*SharedItemsImports = 13 Objects\Converters\ConverterBentley\ConverterBentleyShared\ConverterBentleyShared.projitems*{425f0d00-6608-4bd2-a1e0-2730c9f2bfd3}*SharedItemsImports = 13 Objects\Converters\ConverterCSI\ConverterCSIShared\ConverterCSIShared.projitems*{442116f3-0f4a-4136-894e-ff5f4295500b}*SharedItemsImports = 5 ConnectorAutocadCivil\ConnectorAutocadCivil\ConnectorAutocadCivilShared.projitems*{464f2220-d7d9-4d8c-bb3d-b93a1c603469}*SharedItemsImports = 5 @@ -2979,6 +3030,7 @@ Global ConnectorRevit\ConnectorRevit\ConnectorRevit.projitems*{5fd0d810-03e9-4fd2-93e4-b1b51e5d82c5}*SharedItemsImports = 13 ConnectorCSI\ConnectorCSIShared\ConnectorCSIShared.projitems*{61374cd0-e774-4dcd-bfab-6356b0931283}*SharedItemsImports = 13 ConnectorRevit\RevitSharedResources\RevitSharedResources.projitems*{61c1304b-ed48-456b-ab90-a89066187952}*SharedItemsImports = 5 + DUI3-DX\Converters\Autocad\Speckle.Converters.AutocadShared\Speckle.Converters.AutocadShared.projitems*{631c295a-7ccf-4b42-8686-7034e31469e7}*SharedItemsImports = 5 ConnectorAutocadCivil\ConnectorAutocadCivil\ConnectorAutocadCivilShared.projitems*{658de496-5177-4cd5-a949-fe59e47109b6}*SharedItemsImports = 5 ConnectorTeklaStructures\ConnectorTeklaStructuresShared\ConnectorTeklaStructuresShared.projitems*{67157264-aaa5-46a8-a38b-16254b49b892}*SharedItemsImports = 5 Objects\Converters\ConverterDynamo\ConverterDynamoShared\ConverterDynamoShared.projitems*{67a463d3-e98b-4b16-b069-d7bbb05386a1}*SharedItemsImports = 5 @@ -2996,6 +3048,7 @@ Global ConnectorGrasshopper\ConnectorGrasshopperShared\ConnectorGrasshopperShared.projitems*{86920221-416e-4a66-a601-3418207e2401}*SharedItemsImports = 5 Objects\Converters\ConverterAutocadCivil\ConverterAutocadCivilShared\ConverterAutocadCivilShared.projitems*{88a24c40-74c8-4e20-9051-6be9e6adecfd}*SharedItemsImports = 5 Objects\Converters\ConverterRhinoGh\ConverterRhinoGhShared\ConverterRhinoGhShared.projitems*{89996067-3233-410a-a6a1-39e2f11f0626}*SharedItemsImports = 5 + DUI3-DX\Connectors\Autocad\Speckle.Connectors.AutocadShared\Speckle.Connectors.AutocadShared.projitems*{89c4cbc7-1606-40de-b6da-fbe3aac98395}*SharedItemsImports = 5 ConnectorRevit\ConnectorRevit\ConnectorRevit.projitems*{8a53b084-20d8-48f6-9591-9d53cfa74130}*SharedItemsImports = 5 ConnectorRevit\RevitSharedResources\RevitSharedResources.projitems*{8ad2ea4f-14fb-4bb6-94cd-932630dfed9c}*SharedItemsImports = 5 Objects\Converters\ConverterNavisworks\ConverterNavisworks\ConverterNavisworksShared.projitems*{8b467ff4-6a6c-4071-87a7-0dd7b9822251}*SharedItemsImports = 5 @@ -3004,6 +3057,7 @@ Global Objects\Converters\ConverterBentley\ConverterBentleyShared\ConverterBentleyShared.projitems*{931fc9a8-18b4-4ac5-81d9-14c48499bfb5}*SharedItemsImports = 5 ConnectorRevit\ConnectorRevit\ConnectorRevit.projitems*{9a1e899a-f821-4519-aad1-0789a4e9ccb3}*SharedItemsImports = 5 ConnectorNavisworks\ConnectorNavisworks\ConnectorNavisworks.Shared.projitems*{9a7d7f9a-4fe1-4053-950b-50b43bc81087}*SharedItemsImports = 5 + DUI3-DX\Converters\Autocad\Speckle.Converters.AutocadShared\Speckle.Converters.AutocadShared.projitems*{9add1b7a-6401-4202-8613-f668e2fbc0a4}*SharedItemsImports = 13 ConnectorCSI\ConnectorCSIShared\ConnectorCSIShared.projitems*{9d188843-8841-4a76-a844-efbe8e32ee05}*SharedItemsImports = 5 ConnectorRevit\RevitDUI3\RevitDUI3Shared\RevitDUI3Shared.projitems*{a364b196-38a3-45ab-a54a-f04d17c0b2da}*SharedItemsImports = 5 ConnectorBentley\ConnectorBentleyShared\ConnectorBentleyShared.projitems*{a3a0ee09-6055-4009-ab8e-13fbc1a403a9}*SharedItemsImports = 5 diff --git a/DUI3-DX.slnf b/DUI3-DX.slnf index b527b2a984..fb7bbc4866 100644 --- a/DUI3-DX.slnf +++ b/DUI3-DX.slnf @@ -7,10 +7,14 @@ "Core\\Tests\\Speckle.Core.Tests.Performance\\Speckle.Core.Tests.Performance.csproj", "Core\\Tests\\Speckle.Core.Tests.Unit\\Speckle.Core.Tests.Unit.csproj", "Core\\Transports\\DiskTransport\\DiskTransport.csproj", + "DUI3-DX\\Connectors\\Autocad\\Speckle.Connectors.Autocad2023\\Speckle.Connectors.Autocad2023.csproj", + "DUI3-DX\\Connectors\\Autocad\\Speckle.Connectors.AutocadShared\\Speckle.Connectors.AutocadShared.shproj", "DUI3-DX\\Connectors\\ArcGIS\\Speckle.Connectors.ArcGIS3\\Speckle.Connectors.ArcGIS3.csproj", "DUI3-DX\\Connectors\\Revit\\Speckle.Connectors.Revit2023\\Speckle.Connectors.Revit2023.csproj", "DUI3-DX\\Connectors\\Revit\\Speckle.Connectors.RevitShared\\Speckle.Connectors.RevitShared.shproj", "DUI3-DX\\Connectors\\Rhino\\Speckle.Connectors.Rhino7\\Speckle.Connectors.Rhino7.csproj", + "DUI3-DX\\Converters\\Autocad\\Speckle.Converters.Autocad2023\\Speckle.Converters.Autocad2023.csproj", + "DUI3-DX\\Converters\\Autocad\\Speckle.Converters.AutocadShared\\Speckle.Converters.AutocadShared.shproj", "DUI3-DX\\Converters\\Revit\\Speckle.Converters.Revit2023.DependencyInjection\\Speckle.Converters.Revit2023.DependencyInjection.csproj", "DUI3-DX\\Converters\\Revit\\Speckle.Converters.Revit2023\\Speckle.Converters.Revit2023.csproj", "DUI3-DX\\Converters\\Revit\\Speckle.Converters.RevitShared\\Speckle.Converters.RevitShared.shproj", diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.Autocad2023/Speckle.Connectors.Autocad2023.csproj b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.Autocad2023/Speckle.Connectors.Autocad2023.csproj new file mode 100644 index 0000000000..c95ea8729b --- /dev/null +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.Autocad2023/Speckle.Connectors.Autocad2023.csproj @@ -0,0 +1,26 @@ + + + Speckle.Connectors.Autocad + net48 + x64 + enable + true + Program + $(ProgramW6432)\Autodesk\AutoCAD 2023\acad.exe + + + + + + + + + + + + + + + + + diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadBasicConnectorBinding.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadBasicConnectorBinding.cs new file mode 100644 index 0000000000..749132577c --- /dev/null +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadBasicConnectorBinding.cs @@ -0,0 +1,131 @@ +using Autodesk.AutoCAD.DatabaseServices; +using Sentry.Reflection; +using Speckle.Connectors.Autocad.HostApp; +using Speckle.Connectors.DUI.Bindings; +using Speckle.Connectors.DUI.Bridge; +using Speckle.Connectors.DUI.Models; +using Speckle.Connectors.DUI.Models.Card; +using Speckle.Core.Credentials; +using Speckle.Connectors.Autocad.HostApp.Extensions; + +namespace Speckle.Connectors.Autocad.Bindings; + +public class AutocadBasicConnectorBinding : IBasicConnectorBinding +{ + public string Name { get; set; } = "baseBinding"; + public IBridge Parent { get; } + + private readonly DocumentModelStore _store; + private readonly AutocadSettings _settings; + + public BasicConnectorBindingCommands Commands { get; } + + public AutocadBasicConnectorBinding(DocumentModelStore store, AutocadSettings settings, IBridge parent) + { + _store = store; + _settings = settings; + Parent = parent; + Commands = new BasicConnectorBindingCommands(parent); + _store.DocumentChanged += (_, _) => + { + Commands.NotifyDocumentChanged(); + }; + } + + public string GetConnectorVersion() => + typeof(AutocadBasicConnectorBinding).Assembly.GetNameAndVersion().Version ?? "No version"; + + public string GetSourceApplicationName() => _settings.HostAppInfo.Slug; + + public string GetSourceApplicationVersion() => _settings.HostAppVersion.ToString(); + + public Account[] GetAccounts() => AccountManager.GetAccounts().ToArray(); + + public DocumentInfo GetDocumentInfo() + { + var doc = Application.DocumentManager.MdiActiveDocument; + + if (doc == null) + { + return new DocumentInfo(); + } + + string name = doc.Name.Split(System.IO.Path.PathSeparator).Reverse().First(); + return new DocumentInfo() + { + Name = name, + Id = doc.Name, + Location = doc.Name + }; + } + + public DocumentModelStore GetDocumentState() => _store; + + public void AddModel(ModelCard model) => _store.Models.Add(model); + + public void UpdateModel(ModelCard model) + { + int idx = _store.Models.FindIndex(m => model.ModelCardId == m.ModelCardId); + _store.Models[idx] = model; + } + + public void RemoveModel(ModelCard model) + { + int index = _store.Models.FindIndex(m => m.ModelCardId == model.ModelCardId); + _store.Models.RemoveAt(index); + } + + public void HighlightModel(string modelCardId) + { + var doc = Application.DocumentManager.MdiActiveDocument; + + if (doc == null) + { + return; + } + + var objectIds = Array.Empty(); + + var model = _store.GetModelById(modelCardId); + if (model == null) + { + return; + } + + if (model is SenderModelCard senderModelCard) + { + List<(DBObject obj, string applicationId)> dbObjects = doc.GetObjects(senderModelCard.SendFilter.GetObjectIds()); + + objectIds = dbObjects.Select(tuple => tuple.obj.Id).ToArray(); + } + + if (objectIds.Length == 0) + { + Commands.SetModelError(modelCardId, new OperationCanceledException("No objects found to highlight.")); + return; + } + + Parent.RunOnMainThread(() => + { + doc.Editor.SetImpliedSelection(Array.Empty()); // Deselects + doc.Editor.SetImpliedSelection(objectIds); // Selects + doc.Editor.UpdateScreen(); + + Extents3d selectedExtents = new(); + + var tr = doc.TransactionManager.StartTransaction(); + foreach (ObjectId objectId in objectIds) + { + var entity = (Entity)tr.GetObject(objectId, OpenMode.ForRead); + if (entity != null) + { + selectedExtents.AddExtents(entity.GeometricExtents); + } + } + + doc.Editor.Zoom(selectedExtents); + tr.Commit(); + Autodesk.AutoCAD.Internal.Utils.FlushGraphics(); + }); + } +} diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadSelectionBinding.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadSelectionBinding.cs new file mode 100644 index 0000000000..987852bda0 --- /dev/null +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadSelectionBinding.cs @@ -0,0 +1,77 @@ +using Autodesk.AutoCAD.DatabaseServices; +using Speckle.Connectors.DUI.Bindings; +using Speckle.Connectors.DUI.Bridge; +using Autodesk.AutoCAD.EditorInput; + +namespace Speckle.Connectors.Autocad.Bindings; + +public class AutocadSelectionBinding : ISelectionBinding +{ + private const string SELECTION_EVENT = "setSelection"; + + private readonly List _visitedDocuments = new(); + + public string Name { get; set; } = "selectionBinding"; + + public IBridge Parent { get; } + + public AutocadSelectionBinding(IBridge parent) + { + Parent = parent; + + Application.DocumentManager.DocumentActivated += (sender, e) => OnDocumentChanged(e.Document); + } + + private void OnDocumentChanged(Document document) + { + if (document == null) + { + return; + } + + if (!_visitedDocuments.Contains(document)) + { + document.ImpliedSelectionChanged += (_, _) => + { + Parent.RunOnMainThread(OnSelectionChanged); + }; + + _visitedDocuments.Add(document); + } + } + + private void OnSelectionChanged() + { + SelectionInfo selInfo = GetSelection(); + Parent?.Send(SELECTION_EVENT, selInfo); + } + + public SelectionInfo GetSelection() + { + Document doc = Application.DocumentManager.MdiActiveDocument; + List objs = new(); + if (doc != null) + { + PromptSelectionResult selection = doc.Editor.SelectImplied(); + if (selection.Status == PromptStatus.OK) + { + using var tr = doc.TransactionManager.StartTransaction(); + foreach (SelectedObject obj in selection.Value) + { + var dbObject = tr.GetObject(obj.ObjectId, OpenMode.ForRead); + if (dbObject == null) + { + continue; + } + + var handleString = dbObject.Handle.Value.ToString(); + objs.Add(handleString); + } + + tr.Commit(); + tr.Dispose(); + } + } + return new SelectionInfo { SelectedObjectIds = objs, Summary = $"{objs.Count} objects" }; + } +} diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadSendBinding.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadSendBinding.cs new file mode 100644 index 0000000000..655306de27 --- /dev/null +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadSendBinding.cs @@ -0,0 +1,291 @@ +using Autodesk.AutoCAD.DatabaseServices; +using Speckle.Connectors.Autocad.HostApp; +using Speckle.Connectors.DUI.Bindings; +using Speckle.Connectors.DUI.Bridge; +using Speckle.Connectors.DUI.Models; +using Speckle.Connectors.DUI.Models.Card; +using Speckle.Connectors.Utils.Cancellation; +using Speckle.Core.Credentials; +using Speckle.Core.Logging; +using Speckle.Autofac.DependencyInjection; +using Speckle.Converters.Common; +using Speckle.Core.Transports; +using Speckle.Connectors.Utils.Operations; +using Speckle.Core.Api; +using Speckle.Core.Models; +using System.Diagnostics; +using ICancelable = System.Reactive.Disposables.ICancelable; + +namespace Speckle.Connectors.Autocad.Bindings; + +public sealed class AutocadSendBinding : ISendBinding, ICancelable +{ + public string Name { get; } = "sendBinding"; + public SendBindingUICommands Commands { get; } + public IBridge Parent { get; } + + private readonly DocumentModelStore _store; + private readonly AutocadIdleManager _idleManager; + private readonly List _sendFilters; + private readonly CancellationManager _cancellationManager; + private readonly IScopedFactory _speckleConverterToSpeckleFactory; + + /// + /// Used internally to aggregate the changed objects' id. + /// + private HashSet ChangedObjectIds { get; set; } = new(); + + /// + /// Keeps track of previously converted objects as a dictionary of (applicationId, object reference). + /// + private readonly Dictionary _convertedObjectReferences = new(); + + public AutocadSendBinding( + DocumentModelStore store, + AutocadIdleManager idleManager, + IBridge parent, + IEnumerable sendFilters, + CancellationManager cancellationManager, + IScopedFactory speckleConverterToSpeckleFactory + ) + { + _store = store; + _idleManager = idleManager; + _speckleConverterToSpeckleFactory = speckleConverterToSpeckleFactory; + _cancellationManager = cancellationManager; + _sendFilters = sendFilters.ToList(); + + Parent = parent; + Commands = new SendBindingUICommands(parent); + + Application.DocumentManager.DocumentActivated += (sender, args) => SubscribeToObjectChanges(args.Document); + if (Application.DocumentManager.CurrentDocument != null) + { + // catches the case when autocad just opens up with a blank new doc + SubscribeToObjectChanges(Application.DocumentManager.CurrentDocument); + } + } + + private readonly List _docSubsTracker = new(); + + private void SubscribeToObjectChanges(Document doc) + { + if (doc == null || doc.Database == null || _docSubsTracker.Contains(doc.Name)) + { + return; + } + + _docSubsTracker.Add(doc.Name); + doc.Database.ObjectAppended += (_, e) => OnChangeChangedObjectIds(e.DBObject); + doc.Database.ObjectErased += (_, e) => OnChangeChangedObjectIds(e.DBObject); + doc.Database.ObjectModified += (_, e) => OnChangeChangedObjectIds(e.DBObject); + } + + private void OnChangeChangedObjectIds(DBObject dBObject) + { + ChangedObjectIds.Add(dBObject.Handle.Value.ToString()); + _idleManager.SubscribeToIdle(RunExpirationChecks); + } + + private void RunExpirationChecks() + { + List senders = _store.GetSenders(); + string[] objectIdsList = ChangedObjectIds.ToArray(); + List expiredSenderIds = new(); + + foreach (SenderModelCard modelCard in senders) + { + var intersection = modelCard.SendFilter.GetObjectIds().Intersect(objectIdsList).ToList(); + bool isExpired = intersection.Count != 0; + if (isExpired) + { + expiredSenderIds.Add(modelCard.ModelCardId); + modelCard.ChangedObjectIds.UnionWith(intersection); + } + } + + Commands.SetModelsExpired(expiredSenderIds); + ChangedObjectIds = new HashSet(); + } + + public List GetSendFilters() => _sendFilters; + + public Task Send(string modelCardId) + { + Parent.RunOnMainThread(async () => await SendInternal(modelCardId).ConfigureAwait(false)); + return Task.CompletedTask; + } + + private async Task SendInternal(string modelCardId) + { + try + { + // 0 - Init cancellation token source -> Manager also cancel it if exist before + CancellationTokenSource cts = _cancellationManager.InitCancellationTokenSource(modelCardId); + + // 1 - Get model + if (_store.GetModelById(modelCardId) is not SenderModelCard modelCard) + { + throw new InvalidOperationException("No publish model card was found."); + } + + // 2 - Check account exist + Account account = + AccountManager.GetAccounts().FirstOrDefault(acc => acc.id == modelCard.AccountId) + ?? throw new SpeckleAccountManagerException(); + + // 3 - Get elements to convert + List<(DBObject obj, string applicationId)> autocadObjects = + Application.DocumentManager.CurrentDocument.GetObjects(modelCard.SendFilter.GetObjectIds()); + if (autocadObjects.Count == 0) + { + throw new InvalidOperationException("No objects were found. Please update your send filter!"); + } + + // 4 - Convert objects + Base commitObject = ConvertObjects(autocadObjects, modelCard, cts.Token); + + cts.Token.ThrowIfCancellationRequested(); + + // 5 - Serialize and Send objects + Commands.SetModelProgress(modelCardId, new ModelCardProgress { Status = "Uploading..." }); + + var transport = new ServerTransport(account, modelCard.ProjectId); + var sendResult = await SendHelper.Send(commitObject, transport, true, null, cts.Token).ConfigureAwait(true); + + // Store the converted references in memory for future send operations, overwriting the existing values for the given application id. + foreach (var kvp in sendResult.convertedReferences) + { + _convertedObjectReferences[kvp.Key + modelCard.ProjectId] = kvp.Value; + } + + // It's important to reset the model card's list of changed obj ids so as to ensure we accurately keep track of changes between send operations. + modelCard.ChangedObjectIds = new(); + + // 6 - Create Version + Commands.SetModelProgress(modelCardId, new ModelCardProgress { Status = "Linking version to model..." }); + + // 7 - Create the version (commit) + Client apiClient = new(account); + string versionId = await apiClient + .CommitCreate( + new CommitCreateInput + { + streamId = modelCard.ProjectId, + branchName = modelCard.ModelId, + sourceApplication = "Autocad", + objectId = sendResult.rootObjId + }, + cts.Token + ) + .ConfigureAwait(true); + + Commands.SetModelCreatedVersionId(modelCardId, versionId); + apiClient.Dispose(); + } + catch (OperationCanceledException) + { + return; + } + catch (Exception e) when (!e.IsFatal()) // All exceptions should be handled here if possible, otherwise we enter "crashing the host app" territory. + { + Commands.SetModelError(modelCardId, e); + } + } + + private Base ConvertObjects( + List<(DBObject obj, string applicationId)> dbObjects, + SenderModelCard modelCard, + CancellationToken cancellationToken + ) + { + ISpeckleConverterToSpeckle converter = _speckleConverterToSpeckleFactory.ResolveScopedInstance(); + Collection modelWithLayers = + new() + { + name = Application.DocumentManager.CurrentDocument.Name + .Split(s_separator, StringSplitOptions.None) + .Reverse() + .First(), + collectionType = "root" + }; + + Dictionary collectionCache = new(); + int count = 0; + + foreach ((DBObject obj, string applicationId) tuple in dbObjects) + { + cancellationToken.ThrowIfCancellationRequested(); + + var dbObject = tuple.obj; + var applicationId = tuple.applicationId; + + try + { + Base converted; + if ( + !modelCard.ChangedObjectIds.Contains(applicationId) + && _convertedObjectReferences.TryGetValue(applicationId + modelCard.ProjectId, out ObjectReference value) + ) + { + converted = value; + } + else + { + converted = converter.Convert(dbObject); + + if (converted == null) + { + continue; + } + + converted.applicationId = applicationId; + } + + // Create and add a collection for each layer if not done so already. + if ((tuple.obj as Entity)?.Layer is string layer) + { + if (!collectionCache.TryGetValue(layer, out Collection? collection)) + { + collection = new Collection() { name = layer, collectionType = "layer" }; + collectionCache[layer] = collection; + modelWithLayers.elements.Add(collectionCache[layer]); + } + + collection.elements.Add(converted); + } + + Commands.SetModelProgress( + modelCard.ModelCardId, + new ModelCardProgress() { Status = "Converting", Progress = (double)++count / dbObjects.Count } + ); + } + catch (SpeckleConversionException e) + { + Console.WriteLine(e); + } + catch (NotSupportedException e) + { + Console.WriteLine(e); + } + catch (Exception e) when (!e.IsFatal()) + { + Debug.WriteLine(e.Message); + } + } + + return modelWithLayers; + } + + public void CancelSend(string modelCardId) => _cancellationManager.CancelOperation(modelCardId); + + public void Dispose() + { + IsDisposed = true; + _speckleConverterToSpeckleFactory.Dispose(); + } + + public bool IsDisposed { get; private set; } + + private static readonly string[] s_separator = new[] { "\\" }; +} diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/DependencyInjection/AutofacAutocadModule.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/DependencyInjection/AutofacAutocadModule.cs new file mode 100644 index 0000000000..aedb576737 --- /dev/null +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/DependencyInjection/AutofacAutocadModule.cs @@ -0,0 +1,93 @@ +using Autodesk.AutoCAD.DatabaseServices; +using Autofac; +using Microsoft.Extensions.Logging; +using Serilog; +using Speckle.Autofac.DependencyInjection; +using Speckle.Connectors.Autocad.Bindings; +using Speckle.Connectors.Autocad.HostApp; +using Speckle.Connectors.Autocad.Plugin; +using Speckle.Connectors.DUI.Bindings; +using Speckle.Connectors.DUI.Bridge; +using Speckle.Connectors.DUI.Models; +using Speckle.Connectors.DUI.Utils; +using Speckle.Converters.Common; +using Speckle.Converters.Autocad; +using Speckle.Newtonsoft.Json; +using Speckle.Newtonsoft.Json.Serialization; +using Speckle.Connectors.Autocad.Interfaces; +using Speckle.Connectors.Utils.Cancellation; +using Speckle.Connectors.Autocad.Filters; + +namespace Speckle.Connectors.Autocad.DependencyInjection; + +public class AutofacAutocadModule : Module +{ + protected override void Load(ContainerBuilder builder) + { + RegisterLoggerFactory(builder); + + // Register DUI3 related stuff + builder.RegisterInstance(GetJsonSerializerSettings()).SingleInstance(); + builder.RegisterType().SingleInstance(); + builder.RegisterType().As().InstancePerDependency(); // POC: Each binding should have it's own bridge instance + + // Register other connector specific types + builder.RegisterType().As().SingleInstance(); + builder.RegisterType().InstancePerDependency(); + builder.RegisterInstance(new AutocadDocumentManager()); // TODO: Dependent to TransactionContext, can be moved to AutocadContext + builder.RegisterType().As().SingleInstance(); + builder.RegisterType().SingleInstance(); + + // Register bindings + builder.RegisterType().As().SingleInstance(); + builder.RegisterType().As().As().SingleInstance(); + builder.RegisterType().As().SingleInstance(); + builder.RegisterType().As().SingleInstance(); + builder + .RegisterType() + .As>() + .SingleInstance(); + + // binding dependencies + builder.RegisterType().InstancePerDependency(); + + // register send filters + builder.RegisterType().As().InstancePerDependency(); + + // Register converter factory + builder + .RegisterType>() + .As>() + .InstancePerLifetimeScope(); + } + + private static JsonSerializerSettings GetJsonSerializerSettings() + { + // Register WebView2 panel stuff + JsonSerializerSettings settings = + new() + { + Error = (_, args) => + { + Console.WriteLine("*** JSON ERROR: " + args.ErrorContext); + }, + ContractResolver = new CamelCasePropertyNamesContractResolver(), + NullValueHandling = NullValueHandling.Ignore, + ReferenceLoopHandling = ReferenceLoopHandling.Ignore, + DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate, + Converters = { new DiscriminatedObjectConverter(), new AbstractConverter() } + }; + return settings; + } + + private static void RegisterLoggerFactory(ContainerBuilder builder) + { + var serilogLogger = new LoggerConfiguration().MinimumLevel + .Debug() + .WriteTo.File("log.txt", rollingInterval: RollingInterval.Day) + .CreateLogger(); + + ILoggerFactory loggerFactory = new LoggerFactory().AddSerilog(serilogLogger); + builder.RegisterInstance(loggerFactory).As().SingleInstance(); + } +} diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Filters/AutocadSelectionFilter.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Filters/AutocadSelectionFilter.cs new file mode 100644 index 0000000000..93e21af46d --- /dev/null +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Filters/AutocadSelectionFilter.cs @@ -0,0 +1,10 @@ +using Speckle.Connectors.DUI.Bindings; + +namespace Speckle.Connectors.Autocad.Filters; + +public class AutocadSelectionFilter : DirectSelectionSendFilter +{ + public override List GetObjectIds() => SelectedObjectIds; + + public override bool CheckExpiry(string[] changedObjectIds) => SelectedObjectIds.Intersect(changedObjectIds).Any(); +} diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/GlobalUsings.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/GlobalUsings.cs new file mode 100644 index 0000000000..3d7268d128 --- /dev/null +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/GlobalUsings.cs @@ -0,0 +1,2 @@ +global using Document = Autodesk.AutoCAD.ApplicationServices.Document; +global using Application = Autodesk.AutoCAD.ApplicationServices.Core.Application; diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/AutocadContext.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/AutocadContext.cs new file mode 100644 index 0000000000..ac1a462227 --- /dev/null +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/AutocadContext.cs @@ -0,0 +1,6 @@ +namespace Speckle.Connectors.Autocad.HostApp; + +public class AutocadContext +{ + // POC: we may want to inject this autocadcontext with the active doc? +} diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/AutocadDocumentManager.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/AutocadDocumentManager.cs new file mode 100644 index 0000000000..c1e3f03ac0 --- /dev/null +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/AutocadDocumentManager.cs @@ -0,0 +1,143 @@ +using System.Diagnostics; +using System.Text; +using Autodesk.AutoCAD.DatabaseServices; + +namespace Speckle.Connectors.Autocad.HostApp; + +public class AutocadDocumentManager +{ + private const string SPECKLE_KEY = "Speckle_DUI3"; + private const string SPECKLE_MODEL_CARDS_KEY = "Speckle_DUI3_Model_Cards"; + + /// + /// Returns all the speckle model cards present in the current document. + /// + /// + /// + public string? ReadModelCards(Document doc) + { + using (TransactionContext.StartTransaction(doc)) + { + Transaction tr = doc.Database.TransactionManager.TopTransaction; + + var nod = (DBDictionary)tr.GetObject(doc.Database.NamedObjectsDictionaryId, OpenMode.ForRead); + if (!nod.Contains(SPECKLE_KEY)) + { + return null; + } + + var speckleDict = (DBDictionary)tr.GetObject(nod.GetAt(SPECKLE_KEY), OpenMode.ForRead); + if (speckleDict.Count == 0) + { + return null; + } + + ObjectId id = speckleDict.GetAt(SPECKLE_MODEL_CARDS_KEY); + if (id == ObjectId.Null) + { + return null; + } + + var record = (Xrecord)tr.GetObject(id, OpenMode.ForRead); + string value = GetXrecordData(record); + + try + { + //Try to decode here because there is old data + return Base64Decode(value); + } + catch (ApplicationException e) + { + Debug.WriteLine(e); + return null; + } + } + } + + /// + /// Writes the model cards to the current document. + /// + /// + public void WriteModelCards(Document doc, string modelCardsString) + { + if (doc == null) + { + return; + } + + using (TransactionContext.StartTransaction(doc)) + { + Transaction tr = doc.Database.TransactionManager.TopTransaction; + + var nod = (DBDictionary)tr.GetObject(doc.Database.NamedObjectsDictionaryId, OpenMode.ForRead); + DBDictionary speckleDict; + if (nod.Contains(SPECKLE_KEY)) + { + speckleDict = (DBDictionary)tr.GetObject(nod.GetAt(SPECKLE_KEY), OpenMode.ForWrite); + } + else + { + speckleDict = new DBDictionary(); + nod.UpgradeOpen(); + nod.SetAt(SPECKLE_KEY, speckleDict); + tr.AddNewlyCreatedDBObject(speckleDict, true); + } + + Xrecord xRec = new() { Data = CreateResultBuffer(modelCardsString) }; + + speckleDict.SetAt(SPECKLE_MODEL_CARDS_KEY, xRec); + tr.AddNewlyCreatedDBObject(xRec, true); + } + } + + private ResultBuffer CreateResultBuffer(string value) + { + int size = 1024; + var valueEncoded = Base64Encode(value); + var valueEncodedList = SplitString(valueEncoded, size); + + ResultBuffer rb = new(); + + foreach (string valueEncodedSplit in valueEncodedList) + { + rb.Add(new TypedValue((int)DxfCode.Text, valueEncodedSplit)); + } + + return rb; + } + + private string GetXrecordData(Xrecord pXrecord) + { + StringBuilder valueEncoded = new(); + foreach (TypedValue typedValue in pXrecord.Data) + { + if (typedValue.TypeCode == (int)DxfCode.Text) + { + valueEncoded.Append(typedValue.Value.ToString()); + } + } + + return valueEncoded.ToString(); + } + + private string Base64Encode(string plainText) + { + var plainTextBytes = Encoding.UTF8.GetBytes(plainText); + return Convert.ToBase64String(plainTextBytes); + } + + private string Base64Decode(string base64EncodedData) + { + var base64EncodedBytes = Convert.FromBase64String(base64EncodedData); + return Encoding.UTF8.GetString(base64EncodedBytes); + } + + private IEnumerable SplitString(string text, int chunkSize) + { + for (int offset = 0; offset < text.Length; offset += chunkSize) + { + int size = Math.Min(chunkSize, text.Length - offset); + yield return text.Substring(offset, size); + } + } +} diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/AutocadDocumentModelStore.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/AutocadDocumentModelStore.cs new file mode 100644 index 0000000000..dd4c073a5d --- /dev/null +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/AutocadDocumentModelStore.cs @@ -0,0 +1,92 @@ +using Speckle.Connectors.DUI.Models; +using Speckle.Connectors.DUI.Models.Card; +using Speckle.Newtonsoft.Json; + +namespace Speckle.Connectors.Autocad.HostApp; + +public class AutocadDocumentStore : DocumentModelStore +{ + private readonly string _nullDocumentName = "Null Doc"; + private string _previousDocName; + private readonly AutocadDocumentManager _autocadDocumentManager; + + public AutocadDocumentStore( + JsonSerializerSettings jsonSerializerSettings, + AutocadDocumentManager autocadDocumentManager + ) + : base(jsonSerializerSettings) + { + _autocadDocumentManager = autocadDocumentManager; + _previousDocName = _nullDocumentName; + + if (Application.DocumentManager.MdiActiveDocument != null) + { + IsDocumentInit = true; + } + + Application.DocumentManager.DocumentToBeDestroyed += (_, _) => WriteToFile(); + Application.DocumentManager.DocumentActivated += (_, e) => OnDocChangeInternal(e.Document); + Autodesk.AutoCAD.ApplicationServices.Application.DocumentWindowCollection.DocumentWindowActivated += (_, args) => + OnDocChangeInternal((Document)args.DocumentWindow.Document); + } + + /// + /// Tracks whether the doc has been subscribed to save events. + /// POC: two separate docs can have the same name, this is a brittle implementation - should be correlated with file location. + /// + private readonly List _saveToDocSubTracker = new(); + + private void OnDocChangeInternal(Document doc) + { + var currentDocName = doc != null ? doc.Name : _nullDocumentName; + if (_previousDocName == currentDocName) + { + return; + } + + _previousDocName = doc != null ? doc.Name : _nullDocumentName; + + if (doc != null && !_saveToDocSubTracker.Contains(doc.Name)) + { + doc.BeginDocumentClose += (_, _) => WriteToFile(); + doc.Database.BeginSave += (_, _) => WriteToFile(); + _saveToDocSubTracker.Add(doc.Name); + } + + ReadFromFile(); + OnDocumentChanged(); + } + + public override void ReadFromFile() + { + Models = new List(); + + Document doc = Application.DocumentManager.MdiActiveDocument; + + if (doc == null) + { + return; + } + + string? serializedModelCards = _autocadDocumentManager.ReadModelCards(doc); + if (serializedModelCards == null) + { + return; + } + + Models = Deserialize(serializedModelCards); + } + + public override void WriteToFile() + { + Document doc = Application.DocumentManager.MdiActiveDocument; + + if (doc == null) + { + return; + } + + string modelCardsString = Serialize(); + _autocadDocumentManager.WriteModelCards(doc, modelCardsString); + } +} diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/AutocadIdleManager.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/AutocadIdleManager.cs new file mode 100644 index 0000000000..ef2a4bb0db --- /dev/null +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/AutocadIdleManager.cs @@ -0,0 +1,38 @@ +using System.Collections.Concurrent; + +namespace Speckle.Connectors.Autocad.HostApp; + +public class AutocadIdleManager +{ + private readonly ConcurrentDictionary _sCalls = new(); + private bool _hasSubscribed; + + /// + /// Subscribe deferred action to AutocadIdle event to run it whenever Autocad become idle. + /// + /// Action to call whenever Autocad become Idle. + public void SubscribeToIdle(Action action) + { + _sCalls[action.Method.Name] = action; + + if (_hasSubscribed) + { + return; + } + + _hasSubscribed = true; + Application.Idle += OnIdleHandler; + } + + private void OnIdleHandler(object sender, EventArgs e) + { + foreach (var kvp in _sCalls) + { + kvp.Value(); + } + + _sCalls.Clear(); + _hasSubscribed = false; + Application.Idle -= OnIdleHandler; + } +} diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/AutocadSettings.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/AutocadSettings.cs new file mode 100644 index 0000000000..465b4a0d15 --- /dev/null +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/AutocadSettings.cs @@ -0,0 +1,19 @@ +using System.IO; +using Speckle.Core.Kits; + +namespace Speckle.Connectors.Autocad.HostApp; + +public class AutocadSettings +{ + public AutocadSettings(HostApplication hostAppInfo, HostAppVersion hostAppVersion) + { + HostAppInfo = hostAppInfo; + HostAppVersion = hostAppVersion; + Modules = new[] { new DirectoryInfo(typeof(AutocadSettings).Assembly.ToString()).Parent.FullName }; + } + + public HostApplication HostAppInfo { get; private set; } + public HostAppVersion HostAppVersion { get; private set; } + + public IReadOnlyList Modules { get; private set; } +} diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/DUI3PanelWebView.xaml b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/DUI3PanelWebView.xaml new file mode 100644 index 0000000000..984c1fb015 --- /dev/null +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/DUI3PanelWebView.xaml @@ -0,0 +1,20 @@ + + + + + + + + + diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/DUI3PanelWebView.xaml.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/DUI3PanelWebView.xaml.cs new file mode 100644 index 0000000000..13de7fea03 --- /dev/null +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/DUI3PanelWebView.xaml.cs @@ -0,0 +1,40 @@ +using System.Windows.Controls; +using System.Windows.Threading; +using Speckle.Connectors.DUI.Bindings; +using Speckle.Core.Logging; +using Microsoft.Web.WebView2.Core; + +namespace Speckle.Connectors.Autocad.HostApp; + +public partial class Dui3PanelWebView : UserControl +{ + private readonly IEnumerable> _bindings; + + public Dui3PanelWebView(IEnumerable> bindings) + { + _bindings = bindings; + InitializeComponent(); + Browser.CoreWebView2InitializationCompleted += Browser_Initialized_Completed; + } + + private void ShowDevToolsMethod() => Browser.CoreWebView2.OpenDevToolsWindow(); + + private void ExecuteScriptAsyncMethod(string script) + { + if (!Browser.IsInitialized) + { + throw new SpeckleException("Failed to execute script, Webview2 is not initialized yet."); + } + Browser.Dispatcher.Invoke(() => Browser.ExecuteScriptAsync(script), DispatcherPriority.Background); + } + + private void Browser_Initialized_Completed(object sender, CoreWebView2InitializationCompletedEventArgs e) + { + foreach (Lazy lazyBinding in _bindings) + { + var binding = lazyBinding.Value; + binding.Parent.AssociateWithBinding(binding, ExecuteScriptAsyncMethod, Browser); + Browser.CoreWebView2.AddHostObjectToScript(binding.Name, binding.Parent); + } + } +} diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/Extensions/EditorExtensions.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/Extensions/EditorExtensions.cs new file mode 100644 index 0000000000..5f61677369 --- /dev/null +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/Extensions/EditorExtensions.cs @@ -0,0 +1,29 @@ +using Autodesk.AutoCAD.DatabaseServices; +using Autodesk.AutoCAD.EditorInput; +using Autodesk.AutoCAD.Geometry; + +namespace Speckle.Connectors.Autocad.HostApp.Extensions; + +public static class EditorExtensions +{ + public static void Zoom(this Editor editor, Extents3d ext) + { + if (editor == null) + { + throw new ArgumentNullException(nameof(editor)); + } + + using ViewTableRecord view = editor.GetCurrentView(); + + Matrix3d worldToEye = + Matrix3d.WorldToPlane(view.ViewDirection) + * Matrix3d.Displacement(Point3d.Origin - view.Target) + * Matrix3d.Rotation(view.ViewTwist, view.ViewDirection, view.Target); + + ext.TransformBy(worldToEye); + view.Width = ext.MaxPoint.X - ext.MinPoint.X; + view.Height = ext.MaxPoint.Y - ext.MinPoint.Y; + view.CenterPoint = new Point2d((ext.MaxPoint.X + ext.MinPoint.X) / 2.0, (ext.MaxPoint.Y + ext.MinPoint.Y) / 2.0); + editor.SetCurrentView(view); + } +} diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/TransactionContext.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/TransactionContext.cs new file mode 100644 index 0000000000..8c6e97f041 --- /dev/null +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/TransactionContext.cs @@ -0,0 +1,32 @@ +using Autodesk.AutoCAD.ApplicationServices; +using Autodesk.AutoCAD.DatabaseServices; + +namespace Speckle.Connectors.Autocad.HostApp; + +[System.Diagnostics.CodeAnalysis.SuppressMessage( + "Usage", + "CA2213:Disposable fields should be disposed", + Justification = "Analyzer false positive with Autocad classes" +)] +public sealed class TransactionContext : IDisposable +{ + private DocumentLock? _documentLock; + private Transaction? _transaction; + + public static TransactionContext StartTransaction(Document document) => new(document); + + private TransactionContext(Document document) + { + _documentLock = document.LockDocument(); + _transaction = document.Database.TransactionManager.StartTransaction(); + } + + public void Dispose() + { + _transaction?.Commit(); + _transaction = null; + + _documentLock?.Dispose(); + _documentLock = null; + } +} diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Interfaces/IAutocadPlugin.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Interfaces/IAutocadPlugin.cs new file mode 100644 index 0000000000..43ce46dcef --- /dev/null +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Interfaces/IAutocadPlugin.cs @@ -0,0 +1,7 @@ +namespace Speckle.Connectors.Autocad.Interfaces; + +internal interface IAutocadPlugin +{ + void Initialise(); + void Shutdown(); +} diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Plugin/AutocadCommand.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Plugin/AutocadCommand.cs new file mode 100644 index 0000000000..343ac1471e --- /dev/null +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Plugin/AutocadCommand.cs @@ -0,0 +1,74 @@ +using System.Drawing; +using Autodesk.AutoCAD.Runtime; +using Autodesk.AutoCAD.Windows; +using Autofac; +using Speckle.Autofac.DependencyInjection; +using Speckle.Autofac.Files; +using Speckle.Connectors.Autocad.DependencyInjection; +using Speckle.Connectors.Autocad.HostApp; +using Speckle.Converters.Common.Objects; +using Speckle.Core.Kits; +using Speckle.Converters.Common.DependencyInjection; +using Speckle.Connectors.Autocad.Interfaces; + +namespace Speckle.Connectors.Autocad.Plugin; + +public class AutocadCommand +{ + private static PaletteSet? PaletteSet { get; set; } + private static readonly Guid s_id = new("3223E594-1B09-4E54-B3DD-8EA0BECE7BA5"); + private IAutocadPlugin? _autocadPlugin; + + public AutofacContainer? Container { get; private set; } + + [CommandMethod("SpeckleDUI3DX")] + public void Command() + { + if (PaletteSet != null) + { + FocusPalette(); + return; + } + + PaletteSet = new PaletteSet("Speckle DUI3", s_id) + { + Size = new Size(400, 500), + DockEnabled = (DockSides)((int)DockSides.Left + (int)DockSides.Right) + }; + + Container = new AutofacContainer(new StorageInfo()); + Container.PreBuildEvent += ContainerPreBuildEvent; + + var autocadSettings = new AutocadSettings(HostApplications.AutoCAD, HostAppVersion.v2023); + + Container + .AddModule(new AutofacAutocadModule()) + .LoadAutofacModules(autocadSettings.Modules) + .AddSingletonInstance(autocadSettings) + .Build(); + + // Resolve root plugin object and initialise. + _autocadPlugin = Container.Resolve(); + _autocadPlugin.Initialise(); + + var panelWebView = Container.Resolve(); + + PaletteSet.AddVisual("Speckle DUI3 WebView", panelWebView); + + FocusPalette(); + } + + private void FocusPalette() + { + if (PaletteSet != null) + { + PaletteSet.KeepFocus = true; + PaletteSet.Visible = true; + } + } + + private void ContainerPreBuildEvent(object sender, ContainerBuilder containerBuilder) + { + containerBuilder.InjectNamedTypes(); + } +} diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Plugin/AutocadExtensionApplication.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Plugin/AutocadExtensionApplication.cs new file mode 100644 index 0000000000..e2598b1d73 --- /dev/null +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Plugin/AutocadExtensionApplication.cs @@ -0,0 +1,28 @@ +using System.IO; +using System.Reflection; +using Autodesk.AutoCAD.Runtime; + +namespace Speckle.Connectors.Autocad.Plugin; + +public class AutocadExtensionApplication : IExtensionApplication +{ + public void Initialize() => AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(OnAssemblyResolve); + + public void Terminate() { } + + private Assembly? OnAssemblyResolve(object sender, ResolveEventArgs args) + { + Assembly? a = null; + string name = args.Name.Split(',')[0]; + string path = Path.GetDirectoryName(typeof(AutocadExtensionApplication).Assembly.Location); + + string assemblyFile = Path.Combine(path, name + ".dll"); + + if (File.Exists(assemblyFile)) + { + a = Assembly.LoadFrom(assemblyFile); + } + + return a; + } +} diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Plugin/AutocadPlugin.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Plugin/AutocadPlugin.cs new file mode 100644 index 0000000000..16a2a77455 --- /dev/null +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Plugin/AutocadPlugin.cs @@ -0,0 +1,22 @@ +using Speckle.Connectors.Autocad.HostApp; +using Speckle.Connectors.Autocad.Interfaces; + +namespace Speckle.Connectors.Autocad.Plugin; + +public class AutocadPlugin : IAutocadPlugin +{ + private readonly AutocadIdleManager _idleManager; + private readonly Dui3PanelWebView _panel; + private readonly AutocadSettings _settings; + + public AutocadPlugin(Dui3PanelWebView panel, AutocadSettings settings, AutocadIdleManager idleManager) + { + _panel = panel; + _settings = settings; + _idleManager = idleManager; + } + + public void Initialise() { } + + public void Shutdown() { } +} diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Speckle.Connectors.AutocadShared.projitems b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Speckle.Connectors.AutocadShared.projitems new file mode 100644 index 0000000000..0ba9506a19 --- /dev/null +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Speckle.Connectors.AutocadShared.projitems @@ -0,0 +1,40 @@ + + + + $(MSBuildAllProjects);$(MSBuildThisFileFullPath) + true + 55E65D72-2FE8-4E61-891C-16A4D551CCF7 + + + Speckle.Connectors.AutocadShared + + + + + + + + + + + + + + + + + DUI3PanelWebView.xaml + + + + + + + + + + + + + + \ No newline at end of file diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Speckle.Connectors.AutocadShared.shproj b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Speckle.Connectors.AutocadShared.shproj new file mode 100644 index 0000000000..afec409d7a --- /dev/null +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Speckle.Connectors.AutocadShared.shproj @@ -0,0 +1,12 @@ + + + + {41BC679F-887F-44CF-971D-A5502EE87DB0} + + + + + + + diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Utils.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Utils.cs new file mode 100644 index 0000000000..e9111d8601 --- /dev/null +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Utils.cs @@ -0,0 +1,33 @@ +using Autodesk.AutoCAD.DatabaseServices; +using Speckle.Connectors.Autocad.HostApp; + +namespace Speckle.Connectors.Autocad; + +public static class DocumentExtensions +{ + public static List<(DBObject, string)> GetObjects(this Document doc, IEnumerable objectIds) + { + List<(DBObject, string)> objects = new(); + using (TransactionContext.StartTransaction(doc)) + { + Transaction tr = doc.Database.TransactionManager.TopTransaction; + + foreach (string objectIdHandle in objectIds) + { + if (long.TryParse(objectIdHandle, out long parsedId)) + { + Handle handle = new(parsedId); + if (doc.Database.TryGetObjectId(handle, out ObjectId myObjectId)) + { + if (tr.GetObject(myObjectId, OpenMode.ForRead) is DBObject dbObject) + { + objects.Add((dbObject, objectIdHandle)); + } + } + } + } + } + + return objects; + } +} diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2023/Speckle.Converters.Autocad2023.csproj b/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2023/Speckle.Converters.Autocad2023.csproj new file mode 100644 index 0000000000..e9128b633d --- /dev/null +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2023/Speckle.Converters.Autocad2023.csproj @@ -0,0 +1,20 @@ + + + + netstandard2.0 + x64 + + + + + + + + + + + + + + + diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/AutocadConversionContextStack.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/AutocadConversionContextStack.cs new file mode 100644 index 0000000000..1e08b6596a --- /dev/null +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/AutocadConversionContextStack.cs @@ -0,0 +1,21 @@ +using System.Diagnostics.CodeAnalysis; +using Autodesk.AutoCAD.DatabaseServices; +using Speckle.Converters.Common; + +namespace Speckle.Converters.Autocad; + +// POC: Suppressed naming warning for now, but we should evaluate if we should follow this or disable it. +[SuppressMessage( + "Naming", + "CA1711:Identifiers should not have incorrect suffix", + Justification = "Name ends in Stack but it is in fact a Stack, just not inheriting from `System.Collections.Stack`" +)] +public class AutocadConversionContextStack : ConversionContextStack +{ + public AutocadConversionContextStack(IHostToSpeckleUnitConverter unitConverter) + : base( + Application.DocumentManager.CurrentDocument, + Application.DocumentManager.CurrentDocument.Database.Insunits, + unitConverter + ) { } +} diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/AutocadConverterToSpeckle.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/AutocadConverterToSpeckle.cs new file mode 100644 index 0000000000..947d33df81 --- /dev/null +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/AutocadConverterToSpeckle.cs @@ -0,0 +1,54 @@ +using System; +using Autodesk.AutoCAD.DatabaseServices; +using Speckle.Autofac.DependencyInjection; +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; +using Speckle.Core.Models; + +namespace Speckle.Converters.Autocad; + +public class AutocadConverterToSpeckle : ISpeckleConverterToSpeckle +{ + private readonly IFactory _toSpeckle; + private readonly IHostToSpeckleUnitConverter _unitConverter; + + public AutocadConverterToSpeckle( + IFactory toSpeckle, + IHostToSpeckleUnitConverter unitConverter + ) + { + _toSpeckle = toSpeckle; + _unitConverter = unitConverter; + } + + public Base Convert(object target) + { + if (target is not DBObject dbObject) + { + throw new NotSupportedException( + $"Conversion of {target.GetType().Name} to Speckle is not supported. Only objects that inherit from DBObject are." + ); + } + + Type type = dbObject.GetType(); + + try + { + var objectConverter = _toSpeckle.ResolveInstance(type.Name); + + if (objectConverter == null) + { + throw new NotSupportedException($"No conversion found for {target.GetType().Name}"); + } + + var convertedObject = objectConverter.Convert(dbObject); + + return convertedObject; + } + catch (SpeckleConversionException e) + { + Console.WriteLine(e); + throw; // Just rethrowing for now, Logs may be needed here. + } + } +} diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/AutocadToSpeckleUnitConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/AutocadToSpeckleUnitConverter.cs new file mode 100644 index 0000000000..15e92ef90c --- /dev/null +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/AutocadToSpeckleUnitConverter.cs @@ -0,0 +1,37 @@ +using System.Collections.Generic; +using Autodesk.AutoCAD.DatabaseServices; +using Speckle.Converters.Common; +using Speckle.Core.Kits; +using Speckle.Core.Logging; // POC: boy do I think this is the wrong place for SpeckleException! + +namespace Speckle.Converters.Autocad; + +public class AutocadToSpeckleUnitConverter : IHostToSpeckleUnitConverter +{ + private readonly Dictionary _unitMapping = new(); + + public AutocadToSpeckleUnitConverter() + { + // POC: we should have a unit test to confirm these are as expected and don't change + _unitMapping[UnitsValue.Undefined] = Units.Meters; + _unitMapping[UnitsValue.Millimeters] = Units.Millimeters; + _unitMapping[UnitsValue.Centimeters] = Units.Centimeters; + _unitMapping[UnitsValue.Meters] = Units.Meters; + _unitMapping[UnitsValue.Kilometers] = Units.Kilometers; + _unitMapping[UnitsValue.Inches] = Units.Inches; + _unitMapping[UnitsValue.Feet] = Units.Feet; + _unitMapping[UnitsValue.Yards] = Units.Yards; + _unitMapping[UnitsValue.Miles] = Units.Miles; + } + + public string ConvertOrThrow(UnitsValue hostUnit) + { + if (_unitMapping.TryGetValue(hostUnit, out string value)) + { + return value; + } + + // POC: probably would prefer something more specific + throw new SpeckleException($"The Unit System \"{hostUnit}\" is unsupported."); + } +} diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/DependencyInjection/AutofacAutocadConverterModule.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/DependencyInjection/AutofacAutocadConverterModule.cs new file mode 100644 index 0000000000..e71b1f34fe --- /dev/null +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/DependencyInjection/AutofacAutocadConverterModule.cs @@ -0,0 +1,30 @@ +using Autofac; +using Speckle.Autofac.DependencyInjection; +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; +using Autodesk.AutoCAD.DatabaseServices; + +namespace Speckle.Converters.Autocad.DependencyInjection; + +public class AutofacAutocadConverterModule : Module +{ + protected override void Load(ContainerBuilder builder) + { + // POC: below comment maybe incorrect (sorry if I wrote that!) stateless services + // can be injected as Singleton(), only where we have state we wish to wrap in a unit of work + // should be InstancePerLifetimeScope + // most things should be InstancePerLifetimeScope so we get one per operation + builder.RegisterType().As().SingleInstance(); + + // single stack per conversion + builder + .RegisterType() + .As>() + .InstancePerLifetimeScope(); + + // factory for conversions + builder + .RegisterType>() + .As>(); + } +} diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/Geometry/BoxToSpeckleConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/Geometry/BoxToSpeckleConverter.cs new file mode 100644 index 0000000000..dc4411ae2f --- /dev/null +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/Geometry/BoxToSpeckleConverter.cs @@ -0,0 +1,42 @@ +using Autodesk.AutoCAD.DatabaseServices; +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; +using Speckle.Core.Models; + +namespace Speckle.Converters.Autocad.Geometry; + +[NameAndRankValue(nameof(Extents3d), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +public class DBBoxToSpeckleConverter : IHostObjectToSpeckleConversion, IRawConversion +{ + private readonly IRawConversion _planeConverter; + private readonly IConversionContextStack _contextStack; + + public DBBoxToSpeckleConverter( + IRawConversion planeConverter, + IConversionContextStack contextStack + ) + { + _planeConverter = planeConverter; + _contextStack = contextStack; + } + + public Base Convert(object target) => RawConvert((Extents3d)target); + + public SOG.Box RawConvert(Extents3d target) + { + // get dimension intervals and volume + SOP.Interval xSize = new(target.MinPoint.X, target.MaxPoint.X); + SOP.Interval ySize = new(target.MinPoint.Y, target.MaxPoint.Y); + SOP.Interval zSize = new(target.MinPoint.Z, target.MaxPoint.Z); + double volume = xSize.Length * ySize.Length * zSize.Length; + + // get the base plane of the bounding box from extents and current UCS + var ucs = Application.DocumentManager.CurrentDocument.Editor.CurrentUserCoordinateSystem.CoordinateSystem3d; + AG.Plane acadPlane = new(target.MinPoint, ucs.Xaxis, ucs.Yaxis); + SOG.Plane plane = _planeConverter.RawConvert(acadPlane); + + SOG.Box box = new(plane, xSize, ySize, zSize, _contextStack.Current.SpeckleUnits) { volume = volume }; + + return box; + } +} diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/Geometry/IntervalToSpeckleConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/Geometry/IntervalToSpeckleConverter.cs new file mode 100644 index 0000000000..eb58a0f986 --- /dev/null +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/Geometry/IntervalToSpeckleConverter.cs @@ -0,0 +1,13 @@ +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; +using Speckle.Core.Models; + +namespace Speckle.Converters.Autocad.Geometry; + +[NameAndRankValue(nameof(AG.Interval), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +public class IntervalToSpeckleConverter : IHostObjectToSpeckleConversion, IRawConversion +{ + public Base Convert(object target) => RawConvert((AG.Interval)target); + + public SOP.Interval RawConvert(AG.Interval target) => new(target.LowerBound, target.UpperBound); +} diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/Geometry/LineToSpeckleConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/Geometry/LineToSpeckleConverter.cs new file mode 100644 index 0000000000..ce3ad741f3 --- /dev/null +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/Geometry/LineToSpeckleConverter.cs @@ -0,0 +1,39 @@ +using Autodesk.AutoCAD.DatabaseServices; +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; +using Speckle.Core.Models; + +namespace Speckle.Converters.Autocad.Geometry; + +[NameAndRankValue(nameof(ADB.Line), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +public class LineToSpeckleConverter : IHostObjectToSpeckleConversion, IRawConversion +{ + private readonly IRawConversion _pointConverter; + private readonly IRawConversion _boxConverter; + private readonly IConversionContextStack _contextStack; + + public LineToSpeckleConverter( + IRawConversion pointConverter, + IRawConversion boxConverter, + IConversionContextStack contextStack + ) + { + _pointConverter = pointConverter; + _boxConverter = boxConverter; + _contextStack = contextStack; + } + + public Base Convert(object target) => RawConvert((ADB.Line)target); + + public SOG.Line RawConvert(ADB.Line target) => + new( + _pointConverter.RawConvert(target.StartPoint), + _pointConverter.RawConvert(target.EndPoint), + _contextStack.Current.SpeckleUnits + ) + { + length = target.Length, + domain = new SOP.Interval(0, target.Length), + bbox = _boxConverter.RawConvert(target.GeometricExtents) + }; +} diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/Geometry/PlaneToSpeckleConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/Geometry/PlaneToSpeckleConverter.cs new file mode 100644 index 0000000000..972c14f438 --- /dev/null +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/Geometry/PlaneToSpeckleConverter.cs @@ -0,0 +1,36 @@ +using Autodesk.AutoCAD.DatabaseServices; +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; +using Speckle.Core.Models; + +namespace Speckle.Converters.Autocad.Geometry; + +[NameAndRankValue(nameof(AG.Plane), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +public class PlaneToSpeckleConverter : IHostObjectToSpeckleConversion, IRawConversion +{ + private readonly IRawConversion _vectorConverter; + private readonly IRawConversion _pointConverter; + private readonly IConversionContextStack _contextStack; + + public PlaneToSpeckleConverter( + IRawConversion vectorConverter, + IRawConversion pointConverter, + IConversionContextStack contextStack + ) + { + _vectorConverter = vectorConverter; + _pointConverter = pointConverter; + _contextStack = contextStack; + } + + public Base Convert(object target) => RawConvert((AG.Plane)target); + + public SOG.Plane RawConvert(AG.Plane target) => + new( + _pointConverter.RawConvert(target.PointOnPlane), + _vectorConverter.RawConvert(target.Normal), + _vectorConverter.RawConvert(target.GetCoordinateSystem().Xaxis), + _vectorConverter.RawConvert(target.GetCoordinateSystem().Yaxis), + _contextStack.Current.SpeckleUnits + ); +} diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/Geometry/PointToSpeckleConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/Geometry/PointToSpeckleConverter.cs new file mode 100644 index 0000000000..739ca3ebf6 --- /dev/null +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/Geometry/PointToSpeckleConverter.cs @@ -0,0 +1,42 @@ +using Speckle.Converters.Common.Objects; +using Speckle.Converters.Common; +using Speckle.Core.Models; +using Autodesk.AutoCAD.DatabaseServices; + +namespace Speckle.Converters.Autocad.Geometry; + +[NameAndRankValue(nameof(DBPoint), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +public class DBPointToSpeckleConverter : IHostObjectToSpeckleConversion, IRawConversion +{ + private readonly IRawConversion _pointConverter; + private readonly IConversionContextStack _contextStack; + + public DBPointToSpeckleConverter( + IRawConversion pointConverter, + IConversionContextStack contextStack + ) + { + _pointConverter = pointConverter; + _contextStack = contextStack; + } + + public Base Convert(object target) => RawConvert((DBPoint)target); + + public SOG.Point RawConvert(DBPoint target) => _pointConverter.RawConvert(target.Position); +} + +[NameAndRankValue(nameof(AG.Point3d), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +public class PointToSpeckleConverter : IHostObjectToSpeckleConversion, IRawConversion +{ + private readonly IConversionContextStack _contextStack; + + public PointToSpeckleConverter(IConversionContextStack contextStack) + { + _contextStack = contextStack; + } + + public Base Convert(object target) => RawConvert((AG.Point3d)target); + + public SOG.Point RawConvert(AG.Point3d target) => + new(target.X, target.Y, target.Z, _contextStack.Current.SpeckleUnits); +} diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/Geometry/VectorToSpeckleConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/Geometry/VectorToSpeckleConverter.cs new file mode 100644 index 0000000000..cbd8b6b974 --- /dev/null +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/Geometry/VectorToSpeckleConverter.cs @@ -0,0 +1,22 @@ +using Autodesk.AutoCAD.DatabaseServices; +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; +using Speckle.Core.Models; + +namespace Speckle.Converters.Autocad.Geometry; + +[Common.NameAndRankValue(nameof(AG.Vector3d), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +public class VectorToSpeckleConverter : IHostObjectToSpeckleConversion, IRawConversion +{ + private readonly IConversionContextStack _contextStack; + + public VectorToSpeckleConverter(IConversionContextStack contextStack) + { + _contextStack = contextStack; + } + + public Base Convert(object target) => RawConvert((AG.Vector3d)target); + + public SOG.Vector RawConvert(AG.Vector3d target) => + new(target.X, target.Y, target.Z, _contextStack.Current.SpeckleUnits); +} diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/GlobalUsings.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/GlobalUsings.cs new file mode 100644 index 0000000000..9c48f198aa --- /dev/null +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/GlobalUsings.cs @@ -0,0 +1,6 @@ +global using ADB = Autodesk.AutoCAD.DatabaseServices; +global using AG = Autodesk.AutoCAD.Geometry; +global using SOG = Objects.Geometry; +global using SOP = Objects.Primitive; +global using Document = Autodesk.AutoCAD.ApplicationServices.Document; +global using Application = Autodesk.AutoCAD.ApplicationServices.Core.Application; diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/Speckle.Converters.AutocadShared.projitems b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/Speckle.Converters.AutocadShared.projitems new file mode 100644 index 0000000000..f9a4c6f919 --- /dev/null +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/Speckle.Converters.AutocadShared.projitems @@ -0,0 +1,24 @@ + + + + $(MSBuildAllProjects);$(MSBuildThisFileFullPath) + true + 9add1b7a-6401-4202-8613-f668e2fbc0a4 + + + Speckle.Converters.AutocadShared + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/Speckle.Converters.AutocadShared.shproj b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/Speckle.Converters.AutocadShared.shproj new file mode 100644 index 0000000000..5001bbd32b --- /dev/null +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/Speckle.Converters.AutocadShared.shproj @@ -0,0 +1,13 @@ + + + + 9add1b7a-6401-4202-8613-f668e2fbc0a4 + 14.0 + + + + + + + + diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/ISendBinding.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/ISendBinding.cs index 9c413bb7e7..45a4b1f6ba 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/ISendBinding.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/ISendBinding.cs @@ -2,6 +2,7 @@ using System.Threading.Tasks; using Speckle.Connectors.DUI.Models.Card; using Speckle.Connectors.DUI.Utils; +using Speckle.Newtonsoft.Json; namespace Speckle.Connectors.DUI.Bindings; @@ -27,6 +28,9 @@ public interface ISendBinding : IBinding public class SenderModelCard : ModelCard { public ISendFilter SendFilter { get; set; } + + [JsonIgnore] + public HashSet ChangedObjectIds { get; set; } = new(); } public interface ISendFilter From 96f5ad8e4122b72debd4b4165f70609b4d6fa843 Mon Sep 17 00:00:00 2001 From: connorivy <43247197+connorivy@users.noreply.github.com> Date: Wed, 3 Apr 2024 11:34:00 -0500 Subject: [PATCH 018/261] CNX-9159 POC of Revit DI Converters (#3253) * create revit slnf * wall conversion somewhat working * wall levels working * adding displayValue converter * switch to injecting types * fix mesh conversion * simplify type conversion * add hosted element conversions * wall conversion works for most cases * use column conversion * constructor inject send selection * fix warnings * fix more warnings * address some comments * add back type parameters * make variable constant * Adding POC comments Adding POC comments for future us * OOps, phat finger mistake OOps, phat finger mistake * Using directive Using directive * Other usings Other usings --------- Co-authored-by: Connor Ivy Co-authored-by: Ian Hawley --- Core/Core/Kits/Exceptions.cs | 2 +- DUI3-DX-REVIT.slnf | 20 ++ .../Properties/launchSettings.json | 8 + ...eckle - Backup.Connectors.Revit2023.csproj | 65 ++++ .../Speckle.Connectors.Revit2023.csproj | 2 + .../Bindings/BasicConnectorBindingRevit.cs | 9 +- .../Bindings/ReceiveBinding.cs | 2 +- .../Bindings/RevitBaseBinding.cs | 33 +- .../Bindings/SelectionBinding.cs | 1 + .../Bindings/SendBinding.cs | 70 ++-- .../DependencyInjection/AutofacUIModule.cs | 24 +- .../HostApp/RevitDocumentStore.cs | 2 +- .../Operations/Send/IRootObjectSender.cs | 23 ++ .../Operations/Send/RootObjectBuilder.cs | 55 ++++ .../Operations/Send/RootObjectSender.cs | 67 ++++ .../Operations/Send/SendOperation.cs | 52 +++ .../Plugin/RevitExternalApplication.cs | 16 +- .../Plugin/RevitIdleManager.cs | 1 + .../Plugin/RevitPlugin.cs | 1 + .../Speckle.Connectors.RevitShared.projitems | 5 +- .../AutofacRevitConverterModule.cs | 16 + .../Speckle.Converters.Revit2023.csproj | 2 +- .../Extensions/CategoryExtensions.cs | 11 + .../Extensions/DefinitionExtensions.cs | 16 + .../Extensions/ForgeTypeIdExtensions.cs | 27 ++ .../Extensions/ParameterExtensions.cs | 36 +++ .../GlobalUsings.cs | 4 + .../Helpers/DisplayValueExtractor.cs | 304 ++++++++++++++++++ .../Helpers/MeshBuildHelper.cs | 94 ++++++ .../Helpers/MeshDataTriangulator.cs | 44 +++ .../Helpers/ParameterObjectAssigner.cs | 77 +++++ .../Helpers/ParameterObjectBuilder.cs | 50 +++ .../Helpers/ParameterValueExtractor.cs | 181 +++++++++++ .../Helpers/RevitCategories.cs | 152 +++++++++ .../Helpers/RevitCategoryInfo.cs | 68 ++++ .../Helpers}/RevitContext.cs | 2 +- .../Helpers/RevitConversionContextStack.cs | 28 ++ .../Helpers/SendSelection.cs | 20 ++ .../Helpers/ToSpeckleConvertedObjectsCache.cs | 21 ++ .../RevitConverterToSpeckle.cs | 62 +++- .../Services/CachingService.cs | 89 +++++ .../Services/ICachingService.cs | 12 + .../Services/RevitToSpeckleUnitConverter.cs | 32 ++ .../Services/ToSpeckleScalingService.cs | 35 ++ .../Speckle.Converters.RevitShared.projitems | 37 +++ .../ToSpeckle/BaseConversionToSpeckle.cs | 37 +++ .../ToSpeckle/BeamConversionToSpeckle.cs | 64 ++++ .../ToSpeckle/ColumnConversionToSpeckle.cs | 115 +++++++ .../CurveArrayConversionToSpeckle.cs | 43 +++ .../ToSpeckle/CurveConversionToSpeckle.cs | 48 +++ .../ToSpeckle/ElementConversionToSpeckle.cs | 67 ++++ .../FamilyInstanceConversionToSpeckle.cs | 145 +++++++++ .../HostedElementConversionToSpeckle.cs | 73 +++++ .../ToSpeckle/LevelConversionToSpeckle.cs | 39 +++ .../ToSpeckle/LineConversionToSpeckle.cs | 39 +++ .../ToSpeckle/LocationConversionToSpeckle.cs | 32 ++ .../ToSpeckle/MeshConversionToSpeckle.cs | 41 +++ .../ToSpeckle/ParameterConversionToSpeckle.cs | 94 ++++++ .../ToSpeckle/PointConversionToSpeckle.cs | 21 ++ .../ToSpeckle/SolidsConversionToSpeckle.cs | 84 +++++ .../ToSpeckle/WallConversionToSpeckle.cs | 143 ++++++++ .../ToSpeckle/XyzConversionToPoint.cs | 29 ++ .../DependencyInjection/ScopedFactory.cs | 5 + .../Speckle.Connectors.Utils.csproj | 4 + .../SpeckleTopLevelExceptionHandler.cs | 7 +- .../RawConversionRegisterer.cs | 57 ++++ .../Objects/IRawConversion.cs | 11 +- global.json | 4 +- 68 files changed, 2985 insertions(+), 95 deletions(-) create mode 100644 DUI3-DX-REVIT.slnf create mode 100644 DUI3-DX/Connectors/Revit/Speckle.Connectors.Revit2023/Properties/launchSettings.json create mode 100644 DUI3-DX/Connectors/Revit/Speckle.Connectors.Revit2023/Speckle - Backup.Connectors.Revit2023.csproj create mode 100644 DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/IRootObjectSender.cs create mode 100644 DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RootObjectBuilder.cs create mode 100644 DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RootObjectSender.cs create mode 100644 DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/SendOperation.cs create mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Extensions/CategoryExtensions.cs create mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Extensions/DefinitionExtensions.cs create mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Extensions/ForgeTypeIdExtensions.cs create mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Extensions/ParameterExtensions.cs create mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/GlobalUsings.cs create mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/DisplayValueExtractor.cs create mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/MeshBuildHelper.cs create mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/MeshDataTriangulator.cs create mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/ParameterObjectAssigner.cs create mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/ParameterObjectBuilder.cs create mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/ParameterValueExtractor.cs create mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/RevitCategories.cs create mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/RevitCategoryInfo.cs rename DUI3-DX/{Connectors/Revit/Speckle.Connectors.RevitShared/Plugin => Converters/Revit/Speckle.Converters.RevitShared/Helpers}/RevitContext.cs (87%) create mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/RevitConversionContextStack.cs create mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/SendSelection.cs create mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/ToSpeckleConvertedObjectsCache.cs create mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Services/CachingService.cs create mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Services/ICachingService.cs create mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Services/RevitToSpeckleUnitConverter.cs create mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Services/ToSpeckleScalingService.cs create mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/BaseConversionToSpeckle.cs create mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/BeamConversionToSpeckle.cs create mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/ColumnConversionToSpeckle.cs create mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/CurveArrayConversionToSpeckle.cs create mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/CurveConversionToSpeckle.cs create mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/ElementConversionToSpeckle.cs create mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/FamilyInstanceConversionToSpeckle.cs create mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/HostedElementConversionToSpeckle.cs create mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/LevelConversionToSpeckle.cs create mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/LineConversionToSpeckle.cs create mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/LocationConversionToSpeckle.cs create mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/MeshConversionToSpeckle.cs create mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/ParameterConversionToSpeckle.cs create mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/PointConversionToSpeckle.cs create mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/SolidsConversionToSpeckle.cs create mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/WallConversionToSpeckle.cs create mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/XyzConversionToPoint.cs create mode 100644 DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/RawConversionRegisterer.cs diff --git a/Core/Core/Kits/Exceptions.cs b/Core/Core/Kits/Exceptions.cs index 39cf3e08f0..6e3c4d4daf 100644 --- a/Core/Core/Kits/Exceptions.cs +++ b/Core/Core/Kits/Exceptions.cs @@ -46,7 +46,7 @@ public class ConversionException : SpeckleException public ConversionException(string? message, object? objectToConvert, Exception? innerException = null) : base(message, innerException) { - this.ObjectThatFailed = objectToConvert; + ObjectThatFailed = objectToConvert; } public ConversionException(string? message, Exception? innerException) diff --git a/DUI3-DX-REVIT.slnf b/DUI3-DX-REVIT.slnf new file mode 100644 index 0000000000..d24183d03f --- /dev/null +++ b/DUI3-DX-REVIT.slnf @@ -0,0 +1,20 @@ +{ + "solution": { + "path": "All.sln", + "projects": [ + "Core\\Core\\Core.csproj", + "DUI3-DX\\Connectors\\Revit\\Speckle.Connectors.Revit2023\\Speckle.Connectors.Revit2023.csproj", + "DUI3-DX\\Connectors\\Revit\\Speckle.Connectors.RevitShared\\Speckle.Connectors.RevitShared.shproj", + "DUI3-DX\\Converters\\Revit\\Speckle.Converters.Revit2023.DependencyInjection\\Speckle.Converters.Revit2023.DependencyInjection.csproj", + "DUI3-DX\\Converters\\Revit\\Speckle.Converters.Revit2023\\Speckle.Converters.Revit2023.csproj", + "DUI3-DX\\Converters\\Revit\\Speckle.Converters.RevitShared\\Speckle.Converters.RevitShared.shproj", + "DUI3-DX\\DUI3\\Speckle.Connectors.DUI\\Speckle.Connectors.DUI.csproj", + "DUI3-DX\\Objects\\Speckle.Objects.Common\\Speckle.Objects.Common.csproj", + "DUI3-DX\\Sdk\\Speckle.Autofac\\Speckle.Autofac.csproj", + "DUI3-DX\\Sdk\\Speckle.Connectors.Utils\\Speckle.Connectors.Utils.csproj", + "DUI3-DX\\Sdk\\Speckle.Converters.Common.DependencyInjection\\Speckle.Converters.Common.DependencyInjection.csproj", + "DUI3-DX\\Sdk\\Speckle.Converters.Common\\Speckle.Converters.Common.csproj", + "Objects\\Objects\\Objects.csproj" + ] + } +} \ No newline at end of file diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.Revit2023/Properties/launchSettings.json b/DUI3-DX/Connectors/Revit/Speckle.Connectors.Revit2023/Properties/launchSettings.json new file mode 100644 index 0000000000..30c960cb70 --- /dev/null +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.Revit2023/Properties/launchSettings.json @@ -0,0 +1,8 @@ +{ + "profiles": { + "ConnectorRevit2023": { + "commandName": "Executable", + "executablePath": "C:\\Program Files\\Autodesk\\Revit 2023\\Revit.exe" + } + } +} diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.Revit2023/Speckle - Backup.Connectors.Revit2023.csproj b/DUI3-DX/Connectors/Revit/Speckle.Connectors.Revit2023/Speckle - Backup.Connectors.Revit2023.csproj new file mode 100644 index 0000000000..1f521c09cc --- /dev/null +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.Revit2023/Speckle - Backup.Connectors.Revit2023.csproj @@ -0,0 +1,65 @@ + + + net48 + x64 + win-x64 + true + enable + + + + + + false + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.Revit2023/Speckle.Connectors.Revit2023.csproj b/DUI3-DX/Connectors/Revit/Speckle.Connectors.Revit2023/Speckle.Connectors.Revit2023.csproj index 4e4ff963e6..8c583a1c9e 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.Revit2023/Speckle.Connectors.Revit2023.csproj +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.Revit2023/Speckle.Connectors.Revit2023.csproj @@ -25,6 +25,8 @@ + + diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/BasicConnectorBindingRevit.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/BasicConnectorBindingRevit.cs index 230408c2ed..3b697e2b30 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/BasicConnectorBindingRevit.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/BasicConnectorBindingRevit.cs @@ -9,6 +9,8 @@ using Speckle.Connectors.DUI.Models.Card; using Speckle.Connectors.Revit.Plugin; using Speckle.Connectors.Revit.HostApp; +using Speckle.Converters.RevitShared.Helpers; +using Speckle.Core.Logging; namespace Speckle.Connectors.DUI.Bindings; @@ -95,11 +97,12 @@ public void RemoveModel(ModelCard model) public void HighlightModel(string modelCardId) { // POC: don't know if we can rely on storing the ActiveUIDocument, hence getting it each time - var activeUIDoc = _revitContext.UIApplication.ActiveUIDocument; + var activeUIDoc = + _revitContext.UIApplication?.ActiveUIDocument + ?? throw new SpeckleException("Unable to retrieve active UI document"); var doc = _revitContext.UIApplication.ActiveUIDocument.Document; - // POC: as sendermodelcard, surely we should cast here? better to have invalidcast which is the real reason than NRE - SenderModelCard model = _store.GetModelById(modelCardId) as SenderModelCard; + SenderModelCard model = (SenderModelCard)_store.GetModelById(modelCardId); List objectsIds = model.SendFilter.GetObjectIds(); // POC: GetElementsFromDocument could be interfaced out, extension is cleaner diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/ReceiveBinding.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/ReceiveBinding.cs index 6aa4c4a6e8..f0276817ed 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/ReceiveBinding.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/ReceiveBinding.cs @@ -1,8 +1,8 @@ using System; using Speckle.Connectors.DUI.Bridge; using Speckle.Connectors.Revit.HostApp; -using Speckle.Connectors.Revit.Plugin; using Speckle.Connectors.Utils.Cancellation; +using Speckle.Converters.RevitShared.Helpers; using Speckle.Core.Logging; namespace Speckle.Connectors.Revit.Bindings; diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/RevitBaseBinding.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/RevitBaseBinding.cs index 4dc979d457..c12492bb2d 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/RevitBaseBinding.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/RevitBaseBinding.cs @@ -1,19 +1,16 @@ -using System; using Speckle.Connectors.DUI.Bindings; using Speckle.Connectors.DUI.Bridge; using Speckle.Connectors.Revit.HostApp; -using Speckle.Connectors.Revit.Plugin; +using Speckle.Converters.RevitShared.Helpers; namespace Speckle.Connectors.Revit.Bindings; -internal abstract class RevitBaseBinding : IBinding, IDisposable +internal abstract class RevitBaseBinding : IBinding { // POC: name and bridge might be better for them to be protected props? public string Name { get; protected set; } public IBridge Parent { get; protected set; } - private bool _disposed = false; - protected readonly RevitDocumentStore _store; protected readonly RevitContext _revitContext; @@ -24,30 +21,4 @@ public RevitBaseBinding(string name, RevitDocumentStore store, IBridge bridge, R _store = store; _revitContext = revitContext; } - - public void Dispose() - { - Dispose(true); - GC.SuppressFinalize(this); - } - - protected virtual void Dispose(bool disposing) - { - if (disposing && !_disposed) - { - // give subclasses the chance to dispose - Disposing(disposing, _disposed); - - _disposed = true; - } - } - - protected virtual void Disposing(bool isDipsosing, bool disposedState) { } - - // might be needed in future... - ~RevitBaseBinding() - { - // POC: is there anything janky about calling virtuals during finalizer? :thinking-face - Dispose(false); - } } diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SelectionBinding.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SelectionBinding.cs index d867cd254a..9d2f138aa6 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SelectionBinding.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SelectionBinding.cs @@ -5,6 +5,7 @@ using Speckle.Connectors.DUI.Bridge; using Speckle.Connectors.Revit.HostApp; using Speckle.Connectors.Revit.Plugin; +using Speckle.Converters.RevitShared.Helpers; namespace Speckle.Connectors.Revit.Bindings; diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SendBinding.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SendBinding.cs index ebdf72707e..4f898b9907 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SendBinding.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SendBinding.cs @@ -9,9 +9,11 @@ using Speckle.Connectors.Revit.Plugin; using Speckle.Core.Logging; using Speckle.Connectors.Utils; -using Speckle.Autofac.DependencyInjection; -using Speckle.Converters.Common; using System.Threading.Tasks; +using System.Threading; +using Speckle.Converters.RevitShared.Helpers; +using Speckle.Connectors.Revit.Operations.Send; +using Speckle.Connectors.DUI.Models.Card; namespace Speckle.Connectors.Revit.Bindings; @@ -23,24 +25,25 @@ internal class SendBinding : RevitBaseBinding, ICancelable, ISendBinding // POC: does it need injecting? private HashSet ChangedObjectIds { get; set; } = new(); + // POC: update SendOperation to be interfaced out and could be shared implementation + // could be abstract implementation // In the context of the SEND operation, we're only ever expecting ONE conversion - private readonly IScopedFactory _speckleConverterToSpeckleFactory; - private readonly ISpeckleConverterToSpeckle _speckleConverterToSpeckle; + private readonly SendOperation _sendOperation; private readonly IRevitIdleManager _idleManager; public SendBinding( - IScopedFactory speckleConverterToSpeckleFactory, IRevitIdleManager idleManager, RevitContext revitContext, RevitDocumentStore store, - IBridge bridge + IBridge bridge, + SendOperation sendOperation ) : base("sendBinding", store, bridge, revitContext) { - _speckleConverterToSpeckleFactory = speckleConverterToSpeckleFactory; - _speckleConverterToSpeckle = _speckleConverterToSpeckleFactory.ResolveScopedInstance(); _idleManager = idleManager; Commands = new SendBindingUICommands(bridge); + _sendOperation = sendOperation; + // TODO expiry events // TODO filters need refresh events revitContext.UIApplication.Application.DocumentChanged += (_, e) => DocChangeHandler(e); @@ -51,16 +54,11 @@ public List GetSendFilters() return new List { new RevitEverythingFilter(), new RevitSelectionFilter() }; } - public Task Send(string modelCardId) + public async Task Send(string modelCardId) { - SpeckleTopLevelExceptionHandler.Run( - () => HandleSend(modelCardId), - HandleSpeckleException, - HandleUnexpectedException, - HandleFatalException - ); - - return Task.CompletedTask; + await SpeckleTopLevelExceptionHandler + .Run(() => HandleSend(modelCardId), HandleSpeckleException, HandleUnexpectedException, HandleFatalException) + .ConfigureAwait(false); } public void CancelSend(string modelCardId) @@ -70,9 +68,35 @@ public void CancelSend(string modelCardId) public SendBindingUICommands Commands { get; } - private void HandleSend(string modelCardId) + private async Task HandleSend(string modelCardId) + { + // POC this is where we need to begin UoW + // i.e. we resolve the UoW + + CancellationTokenSource cts = CancellationManager.InitCancellationTokenSource(modelCardId); + + if (_store.GetModelById(modelCardId) is not SenderModelCard modelCard) + { + throw new InvalidOperationException("No publish model card was found."); + } + + string versionId = await _sendOperation + .Execute( + modelCard.SendFilter, + modelCard.AccountId, + modelCard.ProjectId, + modelCard.ModelId, + (status, progress) => OnSendOperationProgress(modelCardId, status, progress), + cts.Token + ) + .ConfigureAwait(false); + + Commands.SetModelCreatedVersionId(modelCardId, versionId); + } + + private void OnSendOperationProgress(string modelCardId, string status, double? progress) { - _speckleConverterToSpeckle.Convert(null); + Commands.SetModelProgress(modelCardId, new ModelCardProgress { Status = status, Progress = progress }); } private bool HandleSpeckleException(SpeckleException spex) @@ -143,12 +167,4 @@ private void RunExpirationChecks() Commands.SetModelsExpired(expiredSenderIds); ChangedObjectIds = new HashSet(); } - - protected override void Disposing(bool isDipsosing, bool disposedState) - { - if (isDipsosing && !disposedState) - { - _speckleConverterToSpeckleFactory.Dispose(); - } - } } diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/AutofacUIModule.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/AutofacUIModule.cs index c55dd4efb2..498629494a 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/AutofacUIModule.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/AutofacUIModule.cs @@ -4,14 +4,15 @@ using CefSharp; using Microsoft.Extensions.Logging; using Serilog; -using Speckle.Autofac.DependencyInjection; using Speckle.Connectors.DUI.Bindings; using Speckle.Connectors.DUI.Bridge; using Speckle.Connectors.DUI.Utils; using Speckle.Connectors.Revit.Bindings; using Speckle.Connectors.Revit.HostApp; +using Speckle.Connectors.Revit.Operations.Send; using Speckle.Connectors.Revit.Plugin; -using Speckle.Converters.Common; +using Speckle.Converters.RevitShared.Helpers; +using Speckle.Core.Transports; using Speckle.Newtonsoft.Json; using Speckle.Newtonsoft.Json.Serialization; @@ -52,6 +53,8 @@ protected override void Load(ContainerBuilder builder) builder.RegisterType().As().SingleInstance(); builder.RegisterType().As().InstancePerDependency(); + // POC: we need to review the scopes and create a document on what the policy is + // and where the UoW should be // register UI bindings builder.RegisterType().As().SingleInstance(); builder.RegisterType().As().SingleInstance(); @@ -60,13 +63,22 @@ protected override void Load(ContainerBuilder builder) builder.RegisterType().As().SingleInstance(); builder.RegisterType().As().SingleInstance(); + // send operation and dependencies + builder.RegisterType().AsSelf().SingleInstance(); + builder.RegisterType().AsSelf().InstancePerLifetimeScope(); + builder.RegisterType().AsSelf().InstancePerLifetimeScope(); + builder.RegisterType().AsSelf().InstancePerLifetimeScope(); + builder.RegisterType().As().InstancePerDependency(); + builder.RegisterType().As().SingleInstance(); + // register builder.RegisterType().SingleInstance(); - builder - .RegisterType>() - .As>() - .InstancePerLifetimeScope(); + // POC: this needs to considering, and should either be re-instated/fixed and relates to where the UoW is. + //builder + // .RegisterType>() + // .As>() + // .InstancePerLifetimeScope(); // POC: logging factory couldn't be added, which is the recommendation, due to janky dependencies // having a SpeckleLogging service, might be interesting, if a service can listen on a local port or use named pipes diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/RevitDocumentStore.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/RevitDocumentStore.cs index a96156e9fa..c8d49967cb 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/RevitDocumentStore.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/RevitDocumentStore.cs @@ -6,7 +6,7 @@ using Revit.Async; using Speckle.Connectors.DUI.Models; using Speckle.Connectors.DUI.Models.Card; -using Speckle.Connectors.Revit.Plugin; +using Speckle.Converters.RevitShared.Helpers; using Speckle.Core.Logging; using Speckle.Newtonsoft.Json; diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/IRootObjectSender.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/IRootObjectSender.cs new file mode 100644 index 0000000000..28611e51b7 --- /dev/null +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/IRootObjectSender.cs @@ -0,0 +1,23 @@ +using System; +using Speckle.Core.Models; +using System.Threading.Tasks; +using System.Threading; + +namespace Speckle.Connectors.Revit.Operations.Send; + +/// +/// Contract for the send operation that handles an assembled object. +/// In production, this will send to a server. +/// In testing, this could send to a sqlite db or just save to a dictionary. +/// +public interface IRootObjectSender +{ + public Task Send( + Base commitObject, + string accountId, + string projectId, + string modelId, + Action? onOperationProgressed = null, + CancellationToken ct = default + ); +} diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RootObjectBuilder.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RootObjectBuilder.cs new file mode 100644 index 0000000000..9ec03b3634 --- /dev/null +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RootObjectBuilder.cs @@ -0,0 +1,55 @@ +using System; +using System.Collections.Generic; +using Speckle.Connectors.DUI.Bindings; +using Speckle.Converters.Common; +using Speckle.Core.Models; +using System.Threading; +using Autodesk.Revit.DB; +using Speckle.Converters.RevitShared.Helpers; +using Speckle.Connectors.Revit.HostApp; +using System.Linq; + +namespace Speckle.Connectors.Revit.Operations.Send; + +public class RootObjectBuilder +{ + // POC: SendSelection and RevitConversionContextStack should be interfaces, former needs interfaces + private readonly SendSelection _sendSelection; + private readonly ISpeckleConverterToSpeckle _converter; + private readonly ToSpeckleConvertedObjectsCache _convertedObjectsCache; + private readonly RevitConversionContextStack _contextStack; + + public RootObjectBuilder( + ISendFilter sendFilter, + // POC: need to resolve where the UoW should be and whether this is with the SpeckleConverterToSpeckle or something else + ISpeckleConverterToSpeckle converter, + ToSpeckleConvertedObjectsCache convertedObjectsCache, + RevitConversionContextStack contextStack + ) + { + _sendSelection = new(sendFilter.GetObjectIds()); + _converter = converter; + // POC: needs considering if this is something to add now or needs refactoring + _convertedObjectsCache = convertedObjectsCache; + _contextStack = contextStack; + } + + public Base Build(Action? onOperationProgressed = null, CancellationToken ct = default) + { + List objects = _contextStack.Current.Document.Document.GetElements(_sendSelection.SelectedItems).ToList(); + + Base commitObject = new(); + + foreach (Element obj in objects) + { + if (_convertedObjectsCache.ContainsBaseConvertedFromId(obj.UniqueId)) + { + continue; + } + + commitObject[obj.UniqueId] = _converter.Convert(obj); + } + + return commitObject; + } +} diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RootObjectSender.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RootObjectSender.cs new file mode 100644 index 0000000000..f4c51d7470 --- /dev/null +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RootObjectSender.cs @@ -0,0 +1,67 @@ +using System; +using System.Linq; +using Speckle.Connectors.Utils.Operations; +using Speckle.Core.Api; +using System.Threading.Tasks; +using System.Threading; +using Speckle.Core.Credentials; +using Speckle.Core.Models; +using Speckle.Core.Transports; + +namespace Speckle.Connectors.Revit.Operations.Send; + +/// +/// Default implementation of the which takes a and sends +/// it to a server described by the parameters in the method +/// +internal class RootObjectSender : IRootObjectSender +{ + private readonly Func _transportFactory; + + public RootObjectSender(Func transportFactory) + { + _transportFactory = transportFactory; + } + + public async Task Send( + Base commitObject, + string accountId, + string projectId, + string modelId, + Action? onOperationProgressed = null, + CancellationToken ct = default + ) + { + ct.ThrowIfCancellationRequested(); + + onOperationProgressed?.Invoke("Uploading...", null); + + // POC: FETCHING ACCOUNTS BY ID ONLY IS UNSAFE, we should filter by server first, but the server info is not stored on the ModelCard + Account account = + AccountManager.GetAccounts().FirstOrDefault(acc => acc.id == accountId) + ?? throw new SpeckleAccountManagerException(); + + ITransport transport = _transportFactory(account, projectId); + var sendResult = await SendHelper.Send(commitObject, transport, true, null, ct).ConfigureAwait(false); + + ct.ThrowIfCancellationRequested(); + + onOperationProgressed?.Invoke("Linking version to model...", null); + + using var apiClient = new Client(account); + string versionId = await apiClient + .CommitCreate( + new CommitCreateInput + { + streamId = projectId, + branchName = modelId, + sourceApplication = "Rhino", + objectId = sendResult.rootObjId + }, + ct + ) + .ConfigureAwait(true); + + return versionId; + } +} diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/SendOperation.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/SendOperation.cs new file mode 100644 index 0000000000..d223a0df61 --- /dev/null +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/SendOperation.cs @@ -0,0 +1,52 @@ +using System; +using Speckle.Connectors.DUI.Bindings; +using Speckle.Core.Models; +using System.Threading.Tasks; +using System.Threading; +using Autofac; + +namespace Speckle.Connectors.Revit.Operations.Send; + +public sealed class SendOperation +{ + // POC: need to consider + private readonly ILifetimeScope _scope; + private readonly IRootObjectSender _rootObjectSender; + + public SendOperation(ILifetimeScope scope, IRootObjectSender rootObjectSender) + { + _scope = scope; + _rootObjectSender = rootObjectSender; + } + + /// + /// Executes a send operation given information about the host objects and the destination account. + /// + /// + /// + /// + /// + /// + /// + /// + public async Task Execute( + ISendFilter sendFilter, + string accountId, + string projectId, + string modelId, + Action? onOperationProgressed = null, + CancellationToken ct = default + ) + { + Base commitObject; + using (var scope = _scope.BeginLifetimeScope()) + { + RootObjectBuilder rootObjectBuilder = scope.Resolve>()(sendFilter); + commitObject = rootObjectBuilder.Build(onOperationProgressed, ct); + } + + return await _rootObjectSender + .Send(commitObject, accountId, projectId, modelId, onOperationProgressed, ct) + .ConfigureAwait(true); + } +} diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitExternalApplication.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitExternalApplication.cs index b3f8488a54..389dda0d4f 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitExternalApplication.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitExternalApplication.cs @@ -6,15 +6,14 @@ using System.IO; using Autofac; using Speckle.Converters.Common.DependencyInjection; -using Speckle.Converters.Common.Objects; using Speckle.Core.Logging; namespace Speckle.Connectors.Revit.Plugin; internal class RevitExternalApplication : IExternalApplication { - private IRevitPlugin? _revitPlugin = null; - private AutofacContainer? _container = null; + private IRevitPlugin? _revitPlugin; + private AutofacContainer? _container; // POC: this is getting hard coded - need a way of injecting it // I am beginning to think the shared project is not the way @@ -36,10 +35,7 @@ public RevitExternalApplication() RevitVersionName = "2023", RevitButtonName = "Speckle DUI3 (DI)", RevitButtonText = "Revit Connector", - ModuleFolders = new string[] - { - "C:\\Users\\imhaw\\AppData\\Roaming\\Autodesk\\REVIT\\Addins\\2023\\Speckle.Connectors.Revit2023" - } + ModuleFolders = new string[] { Path.GetDirectoryName(typeof(RevitExternalApplication).Assembly.Location) } }; } @@ -74,7 +70,11 @@ public Result OnStartup(UIControlledApplication application) private void _container_PreBuildEvent(object sender, ContainerBuilder containerBuilder) { - containerBuilder.InjectNamedTypes(); + // POC: refactor the conversions to be simper, this method could be the basis for this + // tbe event can probably go + // IRawConversions should be separately injectable (and not Require an IHostObject... or NameAndRank attribute) + // Name and Rank can become ConversionRank or something and be optional (otherwise it is rank 0) + containerBuilder.RegisterRawConversions(); } public Result OnShutdown(UIControlledApplication application) diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitIdleManager.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitIdleManager.cs index 1b7f858702..6e147d1409 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitIdleManager.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitIdleManager.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using Autodesk.Revit.UI; using Autodesk.Revit.UI.Events; +using Speckle.Converters.RevitShared.Helpers; namespace Speckle.Connectors.Revit.Plugin; diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitPlugin.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitPlugin.cs index 9df09e1b24..9aef8c0f83 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitPlugin.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitPlugin.cs @@ -8,6 +8,7 @@ using Speckle.Connectors.DUI.Bridge; using Speckle.Connectors.DUI.Bindings; using System.Diagnostics; +using Speckle.Converters.RevitShared.Helpers; namespace Speckle.Connectors.Revit.Plugin; diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Speckle.Connectors.RevitShared.projitems b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Speckle.Connectors.RevitShared.projitems index a6c8ec36a2..ec05d77242 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Speckle.Connectors.RevitShared.projitems +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Speckle.Connectors.RevitShared.projitems @@ -23,12 +23,15 @@ + + + + CefSharpPanel.xaml - diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/AutofacRevitConverterModule.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/AutofacRevitConverterModule.cs index d9d19585e6..591b56bbc6 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/AutofacRevitConverterModule.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/AutofacRevitConverterModule.cs @@ -5,6 +5,9 @@ using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; using Speckle.Converters.RevitShared; +using Speckle.Converters.RevitShared.Helpers; +using Speckle.Converters.RevitShared.Services; +using Speckle.Converters.RevitShared.ToSpeckle; namespace Speckle.Converters.Revit2023.DependencyInjection; @@ -19,5 +22,18 @@ protected override void Load(ContainerBuilder builder) builder .RegisterType>() .As>(); + + // POC: do we need ToSpeckleScalingService as is, do we need to interface it out? + builder.RegisterType().AsSelf().InstancePerLifetimeScope(); + builder.RegisterType().AsSelf().InstancePerLifetimeScope(); + + // POC: check with CI speckler but this AsImplementedInterfaces() seems wrong or non-specific here + builder.RegisterType().AsImplementedInterfaces().SingleInstance(); + builder.RegisterType().AsSelf().InstancePerLifetimeScope(); + builder.RegisterType().AsSelf().InstancePerLifetimeScope(); + builder.RegisterType().AsSelf().InstancePerLifetimeScope(); + builder.RegisterType().AsSelf().InstancePerLifetimeScope(); + builder.RegisterType().AsSelf().InstancePerLifetimeScope(); + builder.RegisterType().AsSelf().InstancePerLifetimeScope(); } } diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023/Speckle.Converters.Revit2023.csproj b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023/Speckle.Converters.Revit2023.csproj index bace94bae5..a647f5a224 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023/Speckle.Converters.Revit2023.csproj +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023/Speckle.Converters.Revit2023.csproj @@ -9,7 +9,7 @@ - + diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Extensions/CategoryExtensions.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Extensions/CategoryExtensions.cs new file mode 100644 index 0000000000..1ecc9754e6 --- /dev/null +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Extensions/CategoryExtensions.cs @@ -0,0 +1,11 @@ +using Autodesk.Revit.DB; + +namespace Speckle.Converters.RevitShared.Extensions; + +public static class CategoryExtensions +{ + public static BuiltInCategory GetBuiltInCategory(this Category category) + { + return (BuiltInCategory)category.Id.IntegerValue; + } +} diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Extensions/DefinitionExtensions.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Extensions/DefinitionExtensions.cs new file mode 100644 index 0000000000..77aff9d11b --- /dev/null +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Extensions/DefinitionExtensions.cs @@ -0,0 +1,16 @@ +using Autodesk.Revit.DB; + +namespace Speckle.Converters.RevitShared.Extensions; + +public static class DefinitionExtensions +{ + // POC: can we just interface these specialisations out and thereby avoid this kind of BS :D + public static string GetUnitTypeString(this Definition definition) + { +#if REVIT2020 || REVIT2021 + return definition.UnitType.ToString(); +#else + return definition.GetDataType().TypeId; +#endif + } +} diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Extensions/ForgeTypeIdExtensions.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Extensions/ForgeTypeIdExtensions.cs new file mode 100644 index 0000000000..9dbec0f54e --- /dev/null +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Extensions/ForgeTypeIdExtensions.cs @@ -0,0 +1,27 @@ +using System.Linq; +using Autodesk.Revit.DB; + +namespace Speckle.Converters.RevitShared.Extensions; + +public static class ForgeTypeIdExtensions +{ + public static string? GetSymbol(this ForgeTypeId forgeTypeId) + { + if (!FormatOptions.CanHaveSymbol(forgeTypeId)) + { + return null; + } + var validSymbols = FormatOptions.GetValidSymbols(forgeTypeId); + var typeId = validSymbols.Where(x => !x.Empty()); + foreach (DB.ForgeTypeId symbolId in typeId) + { + return LabelUtils.GetLabelForSymbol(symbolId); + } + return null; + } + + public static string ToUniqueString(this ForgeTypeId forgeTypeId) + { + return forgeTypeId.TypeId; + } +} diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Extensions/ParameterExtensions.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Extensions/ParameterExtensions.cs new file mode 100644 index 0000000000..c8ac6f92e8 --- /dev/null +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Extensions/ParameterExtensions.cs @@ -0,0 +1,36 @@ +using Autodesk.Revit.DB; + +namespace Speckle.Converters.RevitShared.Extensions; + +public static class ParameterExtensions +{ + /// + /// Shared parameters use a GUID to be uniquely identified + /// Other parameters use a BuiltInParameter enum + /// + /// + /// + public static string GetInternalName(this DB.Parameter rp) + { + if (rp.IsShared) + { + return rp.GUID.ToString(); + } + else + { + var def = (InternalDefinition)rp.Definition; + if (def.BuiltInParameter == BuiltInParameter.INVALID) + { + return def.Name; + } + + return def.BuiltInParameter.ToString(); + } + } + + public static BuiltInParameter? GetBuiltInParameter(this Parameter rp) + { + var def = rp.Definition as InternalDefinition; + return def?.BuiltInParameter; + } +} diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/GlobalUsings.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/GlobalUsings.cs new file mode 100644 index 0000000000..be6d833eb9 --- /dev/null +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/GlobalUsings.cs @@ -0,0 +1,4 @@ +global using DB = Autodesk.Revit.DB; +global using UI = Autodesk.Revit.UI; +global using SOG = Objects.Geometry; +global using SOBR = Objects.BuiltElements.Revit; diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/DisplayValueExtractor.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/DisplayValueExtractor.cs new file mode 100644 index 0000000000..6f63a852d8 --- /dev/null +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/DisplayValueExtractor.cs @@ -0,0 +1,304 @@ +using System; +using System.Collections.Generic; +using Autodesk.Revit.DB; +using Speckle.Converters.Common.Objects; +using Speckle.Core.Logging; +using Mesh = Objects.Geometry.Mesh; + +namespace Speckle.Converters.RevitShared.Helpers; + +// POC: class is kind of big and could do with breaking down +public sealed class DisplayValueExtractor +{ + private readonly IRawConversion, List> _solidsConversion; + private readonly IRawConversion, List> _meshConversion; + + public DisplayValueExtractor( + IRawConversion, List> solidsConversion, + IRawConversion, List> meshConversion + ) + { + _solidsConversion = solidsConversion; + _meshConversion = meshConversion; + } + + public List GetDisplayValue( + DB.Element element, + DB.Options? options = null, + bool isConvertedAsInstance = false, + // POC: should this be part of the context? + DB.Transform? transform = null + ) + { + var displayMeshes = new List(); + + // test if the element is a group first + if (element is Group g) + { + foreach (var id in g.GetMemberIds()) + { + var groupMeshes = GetElementDisplayValue(element.Document.GetElement(id), options, isConvertedAsInstance); + displayMeshes.AddRange(groupMeshes); + } + return displayMeshes; + } + + var (solids, meshes) = GetSolidsAndMeshesFromElement(element, options, transform); + + // convert meshes and solids + displayMeshes.AddRange(_meshConversion.RawConvert(meshes)); + displayMeshes.AddRange(_solidsConversion.RawConvert(solids)); + + return displayMeshes; + } + + /// + /// Retreives the meshes on an element to use as the speckle displayvalue + /// + /// + /// Some FamilyInstance elements are treated as proper Instance objects, while others are not. For those being converted as Instance objects, retrieve their display value untransformed by the instance transform or by the selected document reference point. + /// + /// + /// See https://www.revitapidocs.com/2023/e0f15010-0e19-6216-e2f0-ab7978145daa.htm for a full Geometry Object inheritance + /// + private List GetElementDisplayValue( + DB.Element element, + Options? options = null, + bool isConvertedAsInstance = false, + DB.Transform? transform = null + ) + { + var displayMeshes = new List(); + + // test if the element is a group first + if (element is Group g) + { + foreach (var id in g.GetMemberIds()) + { + var groupMeshes = GetElementDisplayValue(element.Document.GetElement(id), options, isConvertedAsInstance); + displayMeshes.AddRange(groupMeshes); + } + return displayMeshes; + } + + var (solids, meshes) = GetSolidsAndMeshesFromElement(element, options, transform); + + // convert meshes and solids + displayMeshes.AddRange(_meshConversion.RawConvert(meshes)); + displayMeshes.AddRange(_solidsConversion.RawConvert(solids)); + + return displayMeshes; + } + + private (List, List) GetSolidsAndMeshesFromElement( + Element element, + Options? options, + Transform? transform = null + ) + { + //options = ViewSpecificOptions ?? options ?? new Options() { DetailLevel = DetailLevelSetting }; + options ??= new Options() { DetailLevel = ViewDetailLevel.Fine }; + + GeometryElement geom; + try + { + geom = element.get_Geometry(options); + } + // POC: should we be trying to continue? + catch (Autodesk.Revit.Exceptions.ArgumentException) + { + options.ComputeReferences = false; + geom = element.get_Geometry(options); + } + + var solids = new List(); + var meshes = new List(); + + if (geom != null) + { + // retrieves all meshes and solids from a geometry element + SortGeometry(element, solids, meshes, geom, transform?.Inverse); + } + + return (solids, meshes); + } + + /// + /// According to the remarks on the GeometryInstance class in the RevitAPIDocs, + /// https://www.revitapidocs.com/2024/fe25b14f-5866-ca0f-a660-c157484c3a56.htm, + /// a family instance geometryElement should have a top-level geometry instance when the symbol + /// does not have modified geometry (the docs say that modified geometry will not have a geom instance, + /// however in my experience, all family instances have a top-level geom instance, but if the family instance + /// is modified, then the geom instance won't contain any geometry.) + /// + /// This remark also leads me to think that a family instance will not have top-level solids and geom instances. + /// We are logging cases where this is not true. + /// + /// + /// + /// + /// + private void SortGeometry( + Element element, + List solids, + List meshes, + GeometryElement geom, + Transform? inverseTransform = null + ) + { + var topLevelSolidsCount = 0; + var topLevelMeshesCount = 0; + var topLevelGeomElementCount = 0; + var topLevelGeomInstanceCount = 0; + bool hasSymbolGeometry = false; + + foreach (GeometryObject geomObj in geom) + { + // POC: switch could possibly become factory and IIndex<,> pattern and move conversions to + // separate IComeConversionInterfaces + switch (geomObj) + { + case Solid solid: + // skip invalid solid + if ( + solid.Faces.Size == 0 + || Math.Abs(solid.SurfaceArea) == 0 + || IsSkippableGraphicStyle(solid.GraphicsStyleId, element.Document) + ) + { + continue; + } + + if (inverseTransform != null) + { + topLevelSolidsCount++; + solid = SolidUtils.CreateTransformed(solid, inverseTransform); + } + + solids.Add(solid); + break; + case DB.Mesh mesh: + if (IsSkippableGraphicStyle(mesh.GraphicsStyleId, element.Document)) + { + continue; + } + + if (inverseTransform != null) + { + topLevelMeshesCount++; + mesh = mesh.get_Transformed(inverseTransform); + } + + meshes.Add(mesh); + break; + case GeometryInstance instance: + // element transforms should not be carried down into nested geometryInstances. + // Nested geomInstances should have their geom retreived with GetInstanceGeom, not GetSymbolGeom + if (inverseTransform != null) + { + topLevelGeomInstanceCount++; + SortGeometry(element, solids, meshes, instance.GetSymbolGeometry()); + if (meshes.Count > 0 || solids.Count > 0) + { + hasSymbolGeometry = true; + } + } + else + { + SortGeometry(element, solids, meshes, instance.GetInstanceGeometry()); + } + break; + case GeometryElement geometryElement: + if (inverseTransform != null) + { + topLevelGeomElementCount++; + } + SortGeometry(element, solids, meshes, geometryElement); + break; + } + } + + if (inverseTransform != null) + { + LogInstanceMeshRetrievalWarnings( + element, + topLevelSolidsCount, + topLevelMeshesCount, + topLevelGeomElementCount, + hasSymbolGeometry + ); + } + } + + // POC: should be hoovered up with the new reporting, logging, exception philosophy + private static void LogInstanceMeshRetrievalWarnings( + Element element, + int topLevelSolidsCount, + int topLevelMeshesCount, + int topLevelGeomElementCount, + bool hasSymbolGeom + ) + { + if (hasSymbolGeom) + { + if (topLevelSolidsCount > 0) + { + SpeckleLog.Logger.Warning( + "Element of type {elementType} with uniqueId {uniqueId} has valid symbol geometry and {numSolids} top level solids. See comment on method SortInstanceGeometry for link to RevitAPI docs that leads us to believe this shouldn't happen", + element.GetType(), + element.UniqueId, + topLevelSolidsCount + ); + } + if (topLevelMeshesCount > 0) + { + SpeckleLog.Logger.Warning( + "Element of type {elementType} with uniqueId {uniqueId} has valid symbol geometry and {numMeshes} top level meshes. See comment on method SortInstanceGeometry for link to RevitAPI docs that leads us to believe this shouldn't happen", + element.GetType(), + element.UniqueId, + topLevelMeshesCount + ); + } + if (topLevelGeomElementCount > 0) + { + SpeckleLog.Logger.Warning( + "Element of type {elementType} with uniqueId {uniqueId} has valid symbol geometry and {numGeomElements} top level geometry elements. See comment on method SortInstanceGeometry for link to RevitAPI docs that leads us to believe this shouldn't happen", + element.GetType(), + element.UniqueId, + topLevelGeomElementCount + ); + } + } + } + + /// + /// We're caching a dictionary of graphic styles and their ids as it can be a costly operation doing Document.GetElement(solid.GraphicsStyleId) for every solid + /// + private readonly Dictionary _graphicStyleCache = new(); + + /// + /// Exclude light source cones and potentially other geometries by their graphic style + /// + /// + /// + /// + private bool IsSkippableGraphicStyle(ElementId id, Document doc) + { + if (!_graphicStyleCache.ContainsKey(id.ToString())) + { + _graphicStyleCache.Add(id.ToString(), (GraphicsStyle)doc.GetElement(id)); + } + + var graphicStyle = _graphicStyleCache[id.ToString()]; + + if ( + graphicStyle != null + && graphicStyle.GraphicsStyleCategory.Id.IntegerValue == (int)BuiltInCategory.OST_LightingFixtureSource + ) + { + return true; + } + + return false; + } +} diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/MeshBuildHelper.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/MeshBuildHelper.cs new file mode 100644 index 0000000000..fbd7b13dde --- /dev/null +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/MeshBuildHelper.cs @@ -0,0 +1,94 @@ +using System.Collections.Generic; +using System.Linq; +using Objects.Geometry; +using Objects.Other; + +namespace Speckle.Converters.RevitShared.Helpers; + +// POC: probably interface out +public sealed class MeshBuildHelper +{ + //Lazy initialised Dictionary of Revit material (hash) -> Speckle material + private readonly Dictionary _materialMap = new(); + + public RenderMaterial? GetOrCreateMaterial(DB.Material revitMaterial) + { + int hash = Hash(revitMaterial); //Key using the hash as we may be given several instances with identical material properties + if (_materialMap.TryGetValue(hash, out RenderMaterial? m)) + { + return m; + } + + var material = RenderMaterialToSpeckle(revitMaterial); + _materialMap.Add(hash, material); + return material; + } + + // POC: cannot see how the hash is guaranteed to be unique + // surely we could store hash as a unsigned long and use bit shifting + // Extension method preferred + private static int Hash(DB.Material mat) => + mat.Transparency ^ mat.Color.Red ^ mat.Color.Green ^ mat.Color.Blue ^ mat.Smoothness ^ mat.Shininess; + + //Lazy initialised Dictionary of revit material (hash) -> Speckle Mesh + private readonly Dictionary _meshMap = new(); + + // POC: nullability needs checking + // what is this meant to be doing? + // what is the empty mesh and the material hash? + // feels like we should be caching materials but... + // why did we choose to cache this material? + // what is the relevance of the units here? + // probably we should have some IMaterialCache + public Mesh GetOrCreateMesh(DB.Material mat, string units) + { + if (mat == null) + { + return new Mesh { units = units }; + } + + int materialHash = Hash(mat); + if (_meshMap.TryGetValue(materialHash, out Mesh m)) + { + return m; + } + + var mesh = new Mesh { ["renderMaterial"] = GetOrCreateMaterial(mat), units = units }; + _meshMap.Add(materialHash, mesh); + return mesh; + } + + public List GetAllMeshes() + { + List meshes = _meshMap.Values?.ToList() ?? new List(); + + return meshes; + } + + public List GetAllValidMeshes() => GetAllMeshes().FindAll(m => m.vertices.Count > 0 && m.faces.Count > 0); + + public static RenderMaterial? RenderMaterialToSpeckle(DB.Material? revitMaterial) + { + if (revitMaterial == null) + { + return null; + } + + // POC: not sure we should be pulling in System.Drawing - + // maybe this isn't a problem as it's part of the netstandard Fwk + // ideally we'd have serialiser of our own colour class, i.e. to serialise to an uint + RenderMaterial material = + new() + { + name = revitMaterial.Name, + opacity = 1 - revitMaterial.Transparency / 100d, + //metalness = revitMaterial.Shininess / 128d, //Looks like these are not valid conversions + //roughness = 1 - (revitMaterial.Smoothness / 100d), + diffuse = System.Drawing.Color + .FromArgb(revitMaterial.Color.Red, revitMaterial.Color.Green, revitMaterial.Color.Blue) + .ToArgb() + }; + + return material; + } +} diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/MeshDataTriangulator.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/MeshDataTriangulator.cs new file mode 100644 index 0000000000..69da1c60b7 --- /dev/null +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/MeshDataTriangulator.cs @@ -0,0 +1,44 @@ +using System.Collections.Generic; +using Objects.Geometry; +using Speckle.Converters.Common.Objects; + +namespace Speckle.Converters.RevitShared.Helpers; + +public sealed class MeshDataTriangulator +{ + private readonly IRawConversion _xyzToPointConverter; + + public MeshDataTriangulator(IRawConversion xyzToPointConverter) + { + _xyzToPointConverter = xyzToPointConverter; + } + + /// + /// Given , will convert and add triangle data to and + /// + /// The revit mesh to convert + /// The faces list to add to + /// The vertices list to add to + public void Triangulate(DB.Mesh mesh, List faces, List vertices) + { + int faceIndexOffset = vertices.Count / 3; + + foreach (var vert in mesh.Vertices) + { + var (x, y, z) = _xyzToPointConverter.RawConvert(vert); + vertices.Add(x); + vertices.Add(y); + vertices.Add(z); + } + + for (int i = 0; i < mesh.NumTriangles; i++) + { + var triangle = mesh.get_Triangle(i); + + faces.Add(3); // TRIANGLE flag + faces.Add((int)triangle.get_Index(0) + faceIndexOffset); + faces.Add((int)triangle.get_Index(1) + faceIndexOffset); + faces.Add((int)triangle.get_Index(2) + faceIndexOffset); + } + } +} diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/ParameterObjectAssigner.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/ParameterObjectAssigner.cs new file mode 100644 index 0000000000..a2f2026e61 --- /dev/null +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/ParameterObjectAssigner.cs @@ -0,0 +1,77 @@ +using System.Collections.Generic; +using System.Linq; +using Autodesk.Revit.DB; +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; +using Speckle.Core.Logging; +using Speckle.Core.Models; + +namespace Speckle.Converters.RevitShared.Helpers; + +// POC: rationalise whether this and ParameterObjectBuilder are sufficiently different?? +// did it go away? +public sealed class ParameterObjectAssigner +{ + private readonly IRawConversion _paramConverter; + private readonly ParameterValueExtractor _parameterValueExtractor; + + public ParameterObjectAssigner( + IRawConversion paramConverter, + ParameterValueExtractor parameterValueExtractor + ) + { + _paramConverter = paramConverter; + _parameterValueExtractor = parameterValueExtractor; + } + + public void AssignParametersToBase(Element target, Base @base) + { + Dictionary instanceParameters = _parameterValueExtractor.GetAllRemainingParams(target); + var elementType = target.Document.GetElement(target.GetTypeId()); + + Base paramBase = new(); + AssignSpeckleParamToBaseObject(instanceParameters, paramBase); + + if (target is not Level) //ignore type props of levels..! + { + // I don't think we should be adding the type parameters to the object like this + Dictionary typeParameters = _parameterValueExtractor.GetAllRemainingParams(elementType); + AssignSpeckleParamToBaseObject(typeParameters, paramBase, true); + } + + if (paramBase.GetMembers(DynamicBaseMemberType.Dynamic).Count > 0) + { + @base["parameters"] = paramBase; + } + } + + private void AssignSpeckleParamToBaseObject( + IEnumerable> parameters, + Base paramBase, + bool isTypeParameter = false + ) + { + //sort by key + foreach (var kv in parameters.OrderBy(x => x.Key)) + { + try + { + SOBR.Parameter speckleParam = _paramConverter.RawConvert(kv.Value); + speckleParam.isTypeParameter = isTypeParameter; + paramBase[kv.Key] = speckleParam; + } + // POC swallow and continue seems bad? + // maybe hoover these into one exception or into our reporting strategy + catch (InvalidPropNameException) + { + //ignore + } + // POC swallow and continue seems bad? + // maybe hoover these into one exception or into our reporting strategy + catch (SpeckleConversionException ex) + { + SpeckleLog.Logger.Warning(ex, "Error thrown when trying to set property named {propName}", kv.Key); + } + } + } +} diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/ParameterObjectBuilder.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/ParameterObjectBuilder.cs new file mode 100644 index 0000000000..71cf930224 --- /dev/null +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/ParameterObjectBuilder.cs @@ -0,0 +1,50 @@ +using System.Collections.Generic; +using System.Linq; +using Autodesk.Revit.DB; +using Speckle.Converters.Common.Objects; +using Speckle.Core.Logging; +using Speckle.Core.Models; + +namespace Speckle.Converters.RevitShared.Helpers; + +public sealed class ParameterObjectAssigner +{ + private readonly IRawConversion _paramConverter; + private readonly ParameterValueExtractor _parameterValueExtractor; + + public ParameterObjectAssigner( + IRawConversion paramConverter, + ParameterValueExtractor parameterValueExtractor + ) + { + _paramConverter = paramConverter; + _parameterValueExtractor = parameterValueExtractor; + } + + public void AssignParametersToBase(Element target, Base @base) + { + Dictionary allParams = _parameterValueExtractor.GetAllRemainingParams(target); + Base paramBase = new(); + //sort by key + foreach (var kv in allParams.OrderBy(x => x.Key)) + { + try + { + paramBase[kv.Key] = _paramConverter.RawConvert(kv.Value); + } + catch (InvalidPropNameException) + { + //ignore + } + catch (SpeckleException ex) + { + SpeckleLog.Logger.Warning(ex, "Error thrown when trying to set property named {propName}", kv.Key); + } + } + + if (paramBase.GetMembers(DynamicBaseMemberType.Dynamic).Count > 0) + { + @base["parameters"] = paramBase; + } + } +} diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/ParameterValueExtractor.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/ParameterValueExtractor.cs new file mode 100644 index 0000000000..b76b158ecb --- /dev/null +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/ParameterValueExtractor.cs @@ -0,0 +1,181 @@ +using System; +using System.Collections.Generic; +using Autodesk.Revit.DB; +using Speckle.Converters.Common; +using Speckle.Converters.RevitShared.Extensions; +using Speckle.Converters.RevitShared.Services; + +namespace Speckle.Converters.RevitShared.Helpers; + +// POC: needs reviewing, it may be fine, not sure how open/closed it is +// really if we have to edit a switch statement... +// maybe also better as an extension method, but maybe is fine? +public class ParameterValueExtractor +{ + private readonly ToSpeckleScalingService _scalingService; + private readonly Dictionary> _uniqueIdToUsedParameterSetMap = new(); + + public ParameterValueExtractor(ToSpeckleScalingService scalingService) + { + _scalingService = scalingService; + } + + public object? GetValue(Parameter parameter) + { + return parameter.StorageType switch + { + StorageType.Double => GetValueAsDouble(parameter), + StorageType.Integer => GetValueAsInt(parameter), + StorageType.String => GetValueAsString(parameter), + StorageType.ElementId => GetValueAsElementId(parameter)?.ToString(), + StorageType.None + or _ + => throw new SpeckleConversionException($"Unsupported parameter storage type {parameter.StorageType}") + }; + } + + public double? GetValueAsDouble(Element element, BuiltInParameter builtInParameter) + { + return GetValueGeneric( + element, + builtInParameter, + StorageType.Double, + (parameter) => _scalingService.Scale(parameter.AsDouble(), parameter.GetUnitTypeId()) + ); + } + + private double? GetValueAsDouble(Parameter parameter) + { + return GetValueGeneric( + parameter, + StorageType.Double, + (parameter) => _scalingService.Scale(parameter.AsDouble(), parameter.GetUnitTypeId()) + ); + } + + public int? GetValueAsInt(Element element, BuiltInParameter builtInParameter) + { + return GetValueGeneric(element, builtInParameter, StorageType.Integer, (parameter) => parameter.AsInteger()); + } + + private int? GetValueAsInt(Parameter parameter) + { + return GetValueGeneric(parameter, StorageType.Integer, (parameter) => parameter.AsInteger()); + } + + public bool? GetValueAsBool(Element element, BuiltInParameter builtInParameter) + { + var intVal = GetValueGeneric( + element, + builtInParameter, + StorageType.Integer, + (parameter) => parameter.AsInteger() + ); + + return intVal.HasValue ? Convert.ToBoolean(intVal.Value) : null; + } + + public string? GetValueAsString(Element element, BuiltInParameter builtInParameter) + { + return GetValueGeneric(element, builtInParameter, StorageType.String, (parameter) => parameter.AsString()); + } + + private string? GetValueAsString(Parameter parameter) + { + return GetValueGeneric(parameter, StorageType.String, (parameter) => parameter.AsString()); + } + + public ElementId? GetValueAsElementId(Element element, BuiltInParameter builtInParameter) + { + return GetValueGeneric(element, builtInParameter, StorageType.ElementId, (parameter) => parameter.AsElementId()); + } + + public ElementId? GetValueAsElementId(Parameter parameter) + { + return GetValueGeneric(parameter, StorageType.ElementId, (parameter) => parameter.AsElementId()); + } + + public T GetValueAsDocumentObject(Element element, BuiltInParameter builtInParameter) + where T : class + { + ElementId? elementId = GetValueAsElementId(element, builtInParameter); + Element paramElement = element.Document.GetElement(elementId); + return paramElement as T + ?? throw new SpeckleConversionException( + $"Unable to cast retrieved element of type {paramElement.GetType()} to an element of type {typeof(T)}" + ); + } + + private TResult? GetValueGeneric( + Element element, + BuiltInParameter builtInParameter, + StorageType expectedStorageType, + Func getParamValue + ) + { + if (!_uniqueIdToUsedParameterSetMap.TryGetValue(element.UniqueId, out HashSet usedParameters)) + { + usedParameters = new(); + _uniqueIdToUsedParameterSetMap[element.UniqueId] = usedParameters; + } + usedParameters.Add(builtInParameter); + var parameter = element.get_Parameter(builtInParameter); + return GetValueGeneric(parameter, expectedStorageType, getParamValue); + } + + private TResult? GetValueGeneric( + Parameter parameter, + StorageType expectedStorageType, + Func getParamValue + ) + { + if (parameter == null || !parameter.HasValue) + { + return default; + } + + if (parameter.StorageType != expectedStorageType) + { + throw new SpeckleConversionException( + $"Expected parameter of storage type {expectedStorageType} but got parameter of storage type {parameter.StorageType}" + ); + } + + return getParamValue(parameter); + } + + public Dictionary GetAllRemainingParams(DB.Element revitElement) + { + var allParams = new Dictionary(); + AddElementParamsToDict(revitElement, allParams); + + return allParams; + } + + private void AddElementParamsToDict(DB.Element element, Dictionary paramDict) + { + _uniqueIdToUsedParameterSetMap.TryGetValue(element.UniqueId, out HashSet? usedParameters); + + using var parameters = element.Parameters; + foreach (DB.Parameter param in parameters) + { + var internalName = param.GetInternalName(); + if (paramDict.ContainsKey(internalName)) + { + continue; + } + + if (param.GetBuiltInParameter() is BuiltInParameter bip && (usedParameters?.Contains(bip) ?? false)) + { + continue; + } + + paramDict[internalName] = param; + } + } + + public void RemoveUniqueId(string uniqueId) + { + _uniqueIdToUsedParameterSetMap.Remove(uniqueId); + } +} diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/RevitCategories.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/RevitCategories.cs new file mode 100644 index 0000000000..2cdf1044bb --- /dev/null +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/RevitCategories.cs @@ -0,0 +1,152 @@ +using System; +using System.Collections.Generic; +using Autodesk.Revit.DB; + +namespace Speckle.Converters.RevitShared.Helpers; + +/// +/// Contains predefined categories of revit objects as well as the types that make up the elements +/// in that category +/// +/// +// POC: is quite a messy looking thing, need some review +// might be legit or maybe a bette/cleaner pattern rather than the dictionary of pain, but maybe not +// some whitespace between each at the least! +public static class RevitCategories +{ + public static Dictionary All { get; } + + static RevitCategories() + { + All = new(StringComparer.OrdinalIgnoreCase) + { + { nameof(CableTray), CableTray }, + { nameof(Ceiling), Ceiling }, + { nameof(Column), Column }, + { nameof(Conduit), Conduit }, + { nameof(Door), Door }, + { nameof(Duct), Duct }, + { nameof(FamilyInstance), FamilyInstance }, + { nameof(Floor), Floor }, + { nameof(Furniture), Furniture }, + { nameof(Pipe), Pipe }, + { nameof(PlumbingFixture), PlumbingFixture }, + { nameof(Roof), Roof }, + { nameof(Railing), Railing }, + { nameof(StructuralFraming), StructuralFraming }, + { nameof(Wall), Wall }, + { nameof(Window), Window }, + { nameof(Wire), Wire }, + { nameof(Undefined), Undefined }, + }; + } + + public static RevitCategoryInfo CableTray { get; } = + new( + nameof(CableTray), + typeof(DB.Electrical.CableTray), + typeof(DB.Electrical.CableTrayType), + new List() + ); + public static RevitCategoryInfo Ceiling { get; } = + new(nameof(Ceiling), typeof(DB.Ceiling), typeof(CeilingType), new List()); + public static RevitCategoryInfo Column { get; } = + new( + nameof(Column), + typeof(FamilyInstance), + typeof(FamilySymbol), + new List { BuiltInCategory.OST_Columns, BuiltInCategory.OST_StructuralColumns } + ); + public static RevitCategoryInfo Conduit { get; } = + new(nameof(Conduit), typeof(DB.Electrical.Conduit), typeof(DB.Electrical.ConduitType), new List()); + public static RevitCategoryInfo Door { get; } = + new( + nameof(Door), + typeof(DB.FamilyInstance), + typeof(DB.FamilySymbol), + new List { BuiltInCategory.OST_Doors } + ); + public static RevitCategoryInfo Duct { get; } = + new( + nameof(Duct), + typeof(DB.Mechanical.Duct), + typeof(DB.MEPCurveType), + new List { BuiltInCategory.OST_DuctCurves, BuiltInCategory.OST_FlexDuctCurves } + ); + public static RevitCategoryInfo FamilyInstance { get; } = + new(nameof(FamilyInstance), typeof(DB.FamilyInstance), typeof(DB.FamilySymbol), new List()); + public static RevitCategoryInfo Floor { get; } = + new( + nameof(Floor), + typeof(DB.Floor), + typeof(DB.FloorType), + new List { BuiltInCategory.OST_Floors } + ); + public static RevitCategoryInfo Furniture { get; } = + new( + nameof(Furniture), + typeof(DB.FamilyInstance), + typeof(DB.FamilySymbol), + new List { BuiltInCategory.OST_Furniture } + ); + + //public static RevitCategoryInfo Material { get; } = new( + // nameof(Material), + // typeof(DB.Material), + // null, + // new List + // { + // BuiltInCategory.OST_Materials, + // BuiltInCategory.OST_PipeMaterials, + // BuiltInCategory.OST_WireMaterials + // }); + public static RevitCategoryInfo Pipe { get; } = + new( + nameof(Pipe), + typeof(DB.Plumbing.Pipe), + typeof(DB.MEPCurveType), + new List { BuiltInCategory.OST_PipeCurves, BuiltInCategory.OST_FlexPipeCurves } + ); + public static RevitCategoryInfo PlumbingFixture { get; } = + new( + nameof(PlumbingFixture), + typeof(DB.FamilyInstance), + typeof(DB.FamilySymbol), + new List { BuiltInCategory.OST_PlumbingFixtures } + ); + public static RevitCategoryInfo Roof { get; } = + new( + nameof(Roof), + typeof(DB.RoofBase), + typeof(DB.RoofType), + new List { BuiltInCategory.OST_Roofs, } + ); + public static RevitCategoryInfo Railing { get; } = + new( + nameof(Railing), + typeof(DB.Architecture.Railing), + typeof(DB.Architecture.RailingType), + new List() + ); + public static RevitCategoryInfo StructuralFraming { get; } = + new( + nameof(StructuralFraming), + typeof(DB.FamilyInstance), + typeof(DB.FamilySymbol), + new List { BuiltInCategory.OST_StructuralFraming }, + new List { "beam", "brace", "framing" } + ); + public static RevitCategoryInfo Wall { get; } = + new(nameof(Wall), typeof(DB.Wall), typeof(DB.WallType), new List { BuiltInCategory.OST_Walls }); + public static RevitCategoryInfo Window { get; } = + new( + nameof(Window), + typeof(DB.FamilyInstance), + typeof(DB.FamilySymbol), + new List { BuiltInCategory.OST_Windows } + ); + public static RevitCategoryInfo Wire { get; } = + new(nameof(Wire), typeof(DB.Electrical.Wire), typeof(DB.Electrical.WireType), new List()); + public static RevitCategoryInfo Undefined { get; } = + new(nameof(Undefined), typeof(RevitCategoryInfo), typeof(RevitCategoryInfo), new List()); +} diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/RevitCategoryInfo.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/RevitCategoryInfo.cs new file mode 100644 index 0000000000..82a6b9ff2a --- /dev/null +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/RevitCategoryInfo.cs @@ -0,0 +1,68 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using Autodesk.Revit.DB; + +namespace Speckle.Converters.RevitShared.Helpers; + +// review, maybe it doesn't need injecting, or maybe we inject a factory? +public class RevitCategoryInfo +{ + public RevitCategoryInfo( + string name, + Type instanceType, + Type familyType, + List categories, + List? categoryAliases = null + ) + { + CategoryName = name; + ElementInstanceType = instanceType; + ElementTypeType = familyType; + BuiltInCategories = categories; + CategoryAliases = categoryAliases ?? new List(); + } + + public string CategoryName { get; } + public Type ElementInstanceType { get; } + public Type ElementTypeType { get; } + public ICollection BuiltInCategories { get; } + public List CategoryAliases { get; } + + public bool ContainsRevitCategory(Category category) + { + return BuiltInCategories.Select(x => (int)x).Contains(category.Id.IntegerValue); + } + + public List GetElementTypes(Document document) + { + return GetElementTypes(document); + } + + public List GetElementTypes(Document document) + where T : ElementType + { + // POC: why is this disabled? surely a using statement is golden here? +#pragma warning disable CA2000 // Dispose objects before losing scope + var collector = new FilteredElementCollector(document); +#pragma warning restore CA2000 // Dispose objects before losing scope + + if (BuiltInCategories.Count > 0) + { + using var filter = new ElementMulticategoryFilter(BuiltInCategories); + collector = collector.WherePasses(filter); + } + if (ElementTypeType != null) + { + collector = collector.OfClass(ElementTypeType); + } + var elementTypes = collector.WhereElementIsElementType().Cast().ToList(); + collector.Dispose(); + return elementTypes; + } + + public string GetCategorySpecificTypeName(string typeName) + { + return CategoryName + "_" + typeName; + } +} diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitContext.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/RevitContext.cs similarity index 87% rename from DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitContext.cs rename to DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/RevitContext.cs index e2fbab964d..a167d40d70 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitContext.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/RevitContext.cs @@ -1,7 +1,7 @@ using System; using Autodesk.Revit.UI; -namespace Speckle.Connectors.Revit.Plugin; +namespace Speckle.Converters.RevitShared.Helpers; public class RevitContext { diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/RevitConversionContextStack.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/RevitConversionContextStack.cs new file mode 100644 index 0000000000..45f9de91e0 --- /dev/null +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/RevitConversionContextStack.cs @@ -0,0 +1,28 @@ +using Autodesk.Revit.DB; +using Speckle.Converters.Common; + +namespace Speckle.Converters.RevitShared.Helpers; + +[System.Diagnostics.CodeAnalysis.SuppressMessage( + "Naming", + "CA1711:Identifiers should not have incorrect suffix", + Justification = "See base class justification" +)] +// POC: so this should *probably* be Document and NOT UI.UIDocument, the former is Conversion centric +// and the latter is more for connector +public class RevitConversionContextStack : ConversionContextStack +{ + public const double TOLERANCE = 0.0164042; // 5mm in ft + + public RevitConversionContextStack(RevitContext context, IHostToSpeckleUnitConverter unitConverter) + : base( + // POC: we probably should not get here without a valid document + // so should this perpetuate or do we assume this is valid? + // relting on the context.UIApplication?.ActiveUIDocument is not right + // this should be some IActiveDocument I suspect? + context.UIApplication?.ActiveUIDocument + ?? throw new SpeckleConversionException("Active UI document could not be determined"), + context.UIApplication.ActiveUIDocument.Document.GetUnits().GetFormatOptions(SpecTypeId.Length).GetUnitTypeId(), + unitConverter + ) { } +} diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/SendSelection.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/SendSelection.cs new file mode 100644 index 0000000000..80c6625a83 --- /dev/null +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/SendSelection.cs @@ -0,0 +1,20 @@ +using System.Collections.Generic; +using System.Linq; + +namespace Speckle.Converters.RevitShared.Helpers; + +// POC: why do we need this send selection? +// why does conversion need to know about selection in this way? +public class SendSelection +{ + private readonly HashSet _selectedItemIds; + + public SendSelection(IEnumerable selectedItemIds) + { + _selectedItemIds = new HashSet(selectedItemIds); + } + + public bool Contains(string uniqueId) => _selectedItemIds.Contains(uniqueId); + + public IReadOnlyCollection SelectedItems => _selectedItemIds.ToList().AsReadOnly(); +} diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/ToSpeckleConvertedObjectsCache.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/ToSpeckleConvertedObjectsCache.cs new file mode 100644 index 0000000000..5c24d5dae5 --- /dev/null +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/ToSpeckleConvertedObjectsCache.cs @@ -0,0 +1,21 @@ +using System.Collections.Generic; +using Speckle.Core.Models; + +namespace Speckle.Converters.RevitShared.Helpers; + +// POC: review the cache? should this be a common class? +// Does caching work this way everywhere, i.e, string key and base value? +public sealed class ToSpeckleConvertedObjectsCache +{ + private readonly Dictionary _uniqueIdToConvertedBaseDict = new(); + + public void AddConvertedBase(string revitUniqueId, Base b) + { + _uniqueIdToConvertedBaseDict.Add(revitUniqueId, b); + } + + public bool ContainsBaseConvertedFromId(string revitUniqueId) + { + return _uniqueIdToConvertedBaseDict.ContainsKey(revitUniqueId); + } +} diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/RevitConverterToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/RevitConverterToSpeckle.cs index 1c6a975165..341ca1201f 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/RevitConverterToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/RevitConverterToSpeckle.cs @@ -1,26 +1,72 @@ -using Autodesk.Revit.DB; -using Speckle.Autofac.DependencyInjection; +using Autofac.Features.Indexed; +using System; using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; using Speckle.Core.Models; +using Autodesk.Revit.DB; +using Speckle.Converters.RevitShared.Helpers; namespace Speckle.Converters.RevitShared; // POC: maybe possible to restrict the access so this cannot be created directly? public class RevitConverterToSpeckle : ISpeckleConverterToSpeckle { - private readonly IFactory _toSpeckle; + private readonly IIndex _hostObjectConversions; + private readonly ToSpeckleConvertedObjectsCache _convertedObjectsCache; + private readonly ParameterValueExtractor _parameterValueExtractor; - public RevitConverterToSpeckle(IFactory toSpeckle) + public RevitConverterToSpeckle( + IIndex hostObjectConversions, + ToSpeckleConvertedObjectsCache convertedObjectsCache, + ParameterValueExtractor parameterValueExtractor + ) { - _toSpeckle = toSpeckle; + _hostObjectConversions = hostObjectConversions; + _convertedObjectsCache = convertedObjectsCache; + _parameterValueExtractor = parameterValueExtractor; } + // POC: our assumption here is target is valid for conversion + // if it cannot be converted then we should throw public Base Convert(object target) { - var objectConverter = _toSpeckle.ResolveInstance(nameof(Floor)); + var objectConverter = + RetrieveObjectConversion(target.GetType()) + ?? throw new SpeckleConversionException($"Could not find conversion for object of type {target.GetType()}"); + + Base result = + objectConverter.Convert(target) + ?? throw new SpeckleConversionException($"Conversion of object with type {target.GetType()} returned null"); + + // POC : where should logic common to most objects go? + if (target is Element element) + { + _convertedObjectsCache.AddConvertedBase(element.UniqueId, result); + _parameterValueExtractor.RemoveUniqueId(element.UniqueId); + } + + return result; + } + + // POC: we should try to de-couple raw object conversion and paramater scraping so they can happen.. + // "yeah, I'm wondering if we can make conversion "pipelines" or something + // like that where we could add all the Wall properties like length and height + // and then continue passing the object down to more generic conversions that + // could add more generic info like parameters or display value." + // + // We need to look for the commonality... + // "I think it's achievable and makes more sense than having to add parameters on every conversion" + private IHostObjectToSpeckleConversion? RetrieveObjectConversion(Type objectType) + { + if (_hostObjectConversions.TryGetValue(objectType, out var conversion)) + { + return conversion; + } - return objectConverter?.Convert(target) - ?? throw new SpeckleConversionException("No converter or conversion returned null"); + if (objectType.BaseType == typeof(object)) + { + return null; + } + return RetrieveObjectConversion(objectType.BaseType); } } diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Services/CachingService.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Services/CachingService.cs new file mode 100644 index 0000000000..0ce34837a5 --- /dev/null +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Services/CachingService.cs @@ -0,0 +1,89 @@ +using System; +using System.Collections.Generic; +using System.Collections; + +namespace Speckle.Converters.RevitShared.Services; + +// POC: not sure where or how this caching is working and why it has this Func pattern +// we might want to take this out and restore caching in more structured places in a sensible way +// ideally being DRY about HOW we do this, using preferably generic caching patterns +public class CachingService : ICachingService +{ + private readonly Dictionary _objectTypeCaches = new(); + + public void AddMany(IEnumerable elements, Func keyFactory) + { + if (!_objectTypeCaches.TryGetValue(typeof(T), out var objectCache)) + { + objectCache = new Dictionary(); + _objectTypeCaches[typeof(T)] = objectCache; + } + + Dictionary typedObjectCache = (Dictionary)objectCache; + foreach (T element in elements) + { + typedObjectCache[keyFactory(element)] = element; + } + } + + public T GetOrAdd(string key, Func valueFactory) + { + return GetOrAdd(key, (_) => valueFactory(), out _); + } + + public T GetOrAdd(string key, Func valueFactory) + { + return GetOrAdd(key, valueFactory, out _); + } + + public T GetOrAdd(string key, Func valueFactory, out bool isExistingValue) + { + return GetOrAdd(key, (_) => valueFactory(), out isExistingValue); + } + + public T GetOrAdd(string key, Func valueFactory, out bool isExistingValue) + { + isExistingValue = false; + T cachedObject; + + if (!_objectTypeCaches.TryGetValue(typeof(T), out var objectCache)) + { + cachedObject = valueFactory(key); + objectCache = new Dictionary() { { key, cachedObject } }; + _objectTypeCaches[typeof(T)] = objectCache; + return cachedObject; + } + + Dictionary typedObjectCache = (Dictionary)objectCache; + if (!typedObjectCache.TryGetValue(key, out cachedObject)) + { + cachedObject = valueFactory(key); + typedObjectCache.Add(key, cachedObject); + return cachedObject; + } + + isExistingValue = true; + return cachedObject; + } + + public bool TryGet(string key, out T? cachedObject) + { + cachedObject = default; + if (!_objectTypeCaches.TryGetValue(typeof(T), out var objectCache)) + { + return false; + } + + return ((Dictionary)objectCache).TryGetValue(key, out cachedObject); + } + + public void Invalidate() + { + _objectTypeCaches.Remove(typeof(T)); + } + + public void InvalidateAll() + { + _objectTypeCaches.Clear(); + } +} diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Services/ICachingService.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Services/ICachingService.cs new file mode 100644 index 0000000000..e17b6d2f11 --- /dev/null +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Services/ICachingService.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; + +namespace Speckle.Converters.RevitShared.Services; + +internal interface ICachingService +{ + public T GetOrAdd(string key, Func valueFactory); + public T GetOrAdd(string key, Func valueFactory, out bool isExistingValue); + public bool TryGet(string key, out T? cachedObject); + void AddMany(IEnumerable elements, Func keyFactory); +} diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Services/RevitToSpeckleUnitConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Services/RevitToSpeckleUnitConverter.cs new file mode 100644 index 0000000000..3215cc2890 --- /dev/null +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Services/RevitToSpeckleUnitConverter.cs @@ -0,0 +1,32 @@ +using System.Collections.Generic; +using Speckle.Converters.Common; +using Speckle.Core.Kits; +using Speckle.Core.Logging; + +namespace Speckle.Converters.RevitShared.Services; + +public sealed class RevitToSpeckleUnitConverter : IHostToSpeckleUnitConverter +{ + private readonly Dictionary _unitMapping = new(); + + public RevitToSpeckleUnitConverter() + { + _unitMapping[DB.UnitTypeId.Millimeters] = Units.Millimeters; + _unitMapping[DB.UnitTypeId.Centimeters] = Units.Centimeters; + _unitMapping[DB.UnitTypeId.Meters] = Units.Meters; + _unitMapping[DB.UnitTypeId.Inches] = Units.Inches; + _unitMapping[DB.UnitTypeId.Feet] = Units.Feet; + } + + // POC: maybe just convert, it's not a Try method + public string ConvertOrThrow(DB.ForgeTypeId hostUnit) + { + if (_unitMapping.TryGetValue(hostUnit, out string value)) + { + return value; + } + + // POC: probably would prefer something more specific + throw new SpeckleException($"The Unit System \"{hostUnit}\" is unsupported."); + } +} diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Services/ToSpeckleScalingService.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Services/ToSpeckleScalingService.cs new file mode 100644 index 0000000000..50b1cb3dca --- /dev/null +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Services/ToSpeckleScalingService.cs @@ -0,0 +1,35 @@ +using Autodesk.Revit.DB; +using Speckle.Converters.RevitShared.Helpers; + +namespace Speckle.Converters.RevitShared.Services; + +// POC: feels like this is a context thing and we should be calculating this occasionally? +// needs some thought as to how it could be be done, could leave as is for now +public sealed class ToSpeckleScalingService +{ + private readonly double _defaultLengthConversionFactor; + + // POC: this seems like the reverse relationship + public ToSpeckleScalingService(RevitConversionContextStack contextStack) + { + // POC: this is accurate for the current context stack + Units documentUnits = contextStack.Current.Document.Document.GetUnits(); + FormatOptions formatOptions = documentUnits.GetFormatOptions(SpecTypeId.Length); + var lengthUnitsTypeId = formatOptions.GetUnitTypeId(); + _defaultLengthConversionFactor = ScaleStatic(1, lengthUnitsTypeId); + } + + public double ScaleLength(double length) => length * _defaultLengthConversionFactor; + + // POC: not sure about this??? + public double Scale(double value, ForgeTypeId forgeTypeId) + { + return ScaleStatic(value, forgeTypeId); + } + + // POC: not sure why this is needed??? + private static double ScaleStatic(double value, ForgeTypeId forgeTypeId) + { + return UnitUtils.ConvertFromInternalUnits(value, forgeTypeId); + } +} diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Speckle.Converters.RevitShared.projitems b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Speckle.Converters.RevitShared.projitems index 78bfc3eb0b..1a453a15c7 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Speckle.Converters.RevitShared.projitems +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Speckle.Converters.RevitShared.projitems @@ -9,7 +9,44 @@ Speckle.Converters.RevitShared + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/BaseConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/BaseConversionToSpeckle.cs new file mode 100644 index 0000000000..63ac32e849 --- /dev/null +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/BaseConversionToSpeckle.cs @@ -0,0 +1,37 @@ +using System.Collections.Generic; +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; +using Speckle.Core.Models; + +namespace Speckle.Converters.RevitShared.ToSpeckle; + +// POC: maybe but could be generic abstract Converters.Common? +public abstract class BaseConversionToSpeckle + : IHostObjectToSpeckleConversion, + IRawConversion, + IRawConversion + where TSpeckle : notnull +{ + public Base Convert(object target) + { + return ConvertToBase((THost)target); + } + + public Base ConvertToBase(THost target) + { + TSpeckle conversionResult = RawConvert(target); + return conversionResult as Base + ?? throw new SpeckleConversionException($"Unable to cast conversion result of type {conversionResult.GetType()}"); + } + + public abstract TSpeckle RawConvert(THost target); + + // POC: this isn't even used, needs review, not sure we need it atm? + public IEnumerable RawConvertMany(IEnumerable target) + { + foreach (var targetItem in target) + { + yield return RawConvert(targetItem); + } + } +} diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/BeamConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/BeamConversionToSpeckle.cs new file mode 100644 index 0000000000..f52cd492a2 --- /dev/null +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/BeamConversionToSpeckle.cs @@ -0,0 +1,64 @@ +using Autodesk.Revit.DB; +using Objects; +using Objects.BuiltElements.Revit; +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; +using Speckle.Converters.RevitShared.Helpers; + +namespace Speckle.Converters.RevitShared.ToSpeckle; + +public class BeamConversionToSpeckle : IRawConversion +{ + private readonly IRawConversion _locationConverter; + private readonly IRawConversion _levelConverter; + private readonly ParameterValueExtractor _parameterValueExtractor; + private readonly DisplayValueExtractor _displayValueExtractor; + private readonly ParameterObjectAssigner _parameterObjectAssigner; + + public BeamConversionToSpeckle( + IRawConversion locationConverter, + IRawConversion levelConverter, + ParameterValueExtractor parameterValueExtractor, + DisplayValueExtractor displayValueExtractor, + ParameterObjectAssigner parameterObjectAssigner + ) + { + _locationConverter = locationConverter; + _levelConverter = levelConverter; + _parameterValueExtractor = parameterValueExtractor; + _displayValueExtractor = displayValueExtractor; + _parameterObjectAssigner = parameterObjectAssigner; + } + + public RevitBeam RawConvert(DB.FamilyInstance target) + { + var baseGeometry = _locationConverter.ConvertToBase(target.Location); + if (baseGeometry is not ICurve baseCurve) + { + throw new SpeckleConversionException( + $"Beam location conversion did not yield an ICurve, instead it yielded an object of type {baseGeometry.GetType()}" + ); + } + var symbol = (FamilySymbol)target.Document.GetElement(target.GetTypeId()); + + RevitBeam speckleBeam = + new() + { + family = symbol.FamilyName, + type = target.Document.GetElement(target.GetTypeId()).Name, + baseLine = baseCurve + }; + + var level = _parameterValueExtractor.GetValueAsDocumentObject( + target, + BuiltInParameter.INSTANCE_REFERENCE_LEVEL_PARAM + ); + speckleBeam.level = _levelConverter.RawConvert(level); + + speckleBeam.displayValue = _displayValueExtractor.GetDisplayValue(target); + + _parameterObjectAssigner.AssignParametersToBase(target, speckleBeam); + + return speckleBeam; + } +} diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/ColumnConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/ColumnConversionToSpeckle.cs new file mode 100644 index 0000000000..dcdb98d71b --- /dev/null +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/ColumnConversionToSpeckle.cs @@ -0,0 +1,115 @@ +using Autodesk.Revit.DB; +using Objects; +using Objects.BuiltElements.Revit; +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; +using Speckle.Converters.RevitShared.Helpers; +using Line = Objects.Geometry.Line; +using Point = Objects.Geometry.Point; + +namespace Speckle.Converters.RevitShared.ToSpeckle; + +public class ColumnConversionToSpeckle : IRawConversion +{ + private readonly IRawConversion _locationConverter; + private readonly IRawConversion _levelConverter; + private readonly ParameterValueExtractor _parameterValueExtractor; + private readonly DisplayValueExtractor _displayValueExtractor; + private readonly RevitConversionContextStack _contextStack; + private readonly ParameterObjectAssigner _parameterObjectAssigner; + + // POC: could be broken down more granular, maybe injected, maybe even if methods + // GetParameters() + // GetGeometry() + // etc... + public ColumnConversionToSpeckle( + IRawConversion locationConverter, + IRawConversion levelConverter, + ParameterValueExtractor parameterValueExtractor, + DisplayValueExtractor displayValueExtractor, + RevitConversionContextStack contextStack, + ParameterObjectAssigner parameterObjectAssigner + ) + { + _locationConverter = locationConverter; + _levelConverter = levelConverter; + _parameterValueExtractor = parameterValueExtractor; + _displayValueExtractor = displayValueExtractor; + _contextStack = contextStack; + _parameterObjectAssigner = parameterObjectAssigner; + } + + public RevitColumn RawConvert(DB.FamilyInstance target) + { + var symbol = (FamilySymbol)target.Document.GetElement(target.GetTypeId()); + + var speckleColumn = new RevitColumn + { + family = symbol.FamilyName, + type = target.Document.GetElement(target.GetTypeId()).Name + }; + + var level = _parameterValueExtractor.GetValueAsDocumentObject( + target, + BuiltInParameter.FAMILY_BASE_LEVEL_PARAM + ); + speckleColumn.level = _levelConverter.RawConvert(level); + + var topLevel = _parameterValueExtractor.GetValueAsDocumentObject( + target, + BuiltInParameter.FAMILY_TOP_LEVEL_PARAM + ); + speckleColumn.topLevel = _levelConverter.RawConvert(topLevel); + speckleColumn.baseOffset = + _parameterValueExtractor.GetValueAsDouble(target, BuiltInParameter.FAMILY_BASE_LEVEL_OFFSET_PARAM) ?? 0; + speckleColumn.topOffset = + _parameterValueExtractor.GetValueAsDouble(target, BuiltInParameter.FAMILY_TOP_LEVEL_OFFSET_PARAM) ?? 0; + speckleColumn.facingFlipped = target.FacingFlipped; + speckleColumn.handFlipped = target.HandFlipped; + speckleColumn.isSlanted = target.IsSlantedColumn; + //speckleColumn.structural = revitColumn.StructuralType == StructuralType.Column; + + //geometry + var baseGeometry = _locationConverter.ConvertToBase(target.Location); + var baseLine = baseGeometry as ICurve; + + //make line from point and height + if (baseLine == null && baseGeometry is Point basePoint) + { + if ( + symbol.Family.FamilyPlacementType == FamilyPlacementType.OneLevelBased + || symbol.Family.FamilyPlacementType == FamilyPlacementType.WorkPlaneBased + ) + { + //return RevitInstanceToSpeckle(revitColumn, out notes, null); + throw new SpeckleConversionException(); + } + + var elevation = speckleColumn.topLevel.elevation; + baseLine = new Line( + basePoint, + new Point(basePoint.x, basePoint.y, elevation + speckleColumn.topOffset, _contextStack.Current.SpeckleUnits), + _contextStack.Current.SpeckleUnits + ); + } + + if (baseLine == null) + { + // return RevitElementToSpeckle(revitColumn, out notes); + throw new SpeckleConversionException(); + } + + speckleColumn.baseLine = baseLine; //all speckle columns should be line based + + _parameterObjectAssigner.AssignParametersToBase(target, speckleColumn); + + if (target.Location is LocationPoint locationPoint) + { + speckleColumn.rotation = locationPoint.Rotation; + } + + speckleColumn.displayValue = _displayValueExtractor.GetDisplayValue(target); + + return speckleColumn; + } +} diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/CurveArrayConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/CurveArrayConversionToSpeckle.cs new file mode 100644 index 0000000000..8957beb5f7 --- /dev/null +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/CurveArrayConversionToSpeckle.cs @@ -0,0 +1,43 @@ +using System.Collections.Generic; +using System.Linq; +using Autodesk.Revit.DB; +using Objects; +using Objects.Geometry; +using Speckle.Converters.Common.Objects; +using Speckle.Converters.RevitShared.Helpers; +using Speckle.Converters.RevitShared.Services; + +namespace Speckle.Converters.RevitShared.ToSpeckle; + +public sealed class CurveArrayConversionToSpeckle : BaseConversionToSpeckle +{ + private readonly RevitConversionContextStack _contextStack; + private readonly ToSpeckleScalingService _scalingService; + private readonly IRawConversion _curveConverter; + + public CurveArrayConversionToSpeckle( + RevitConversionContextStack contextStack, + ToSpeckleScalingService scalingService, + IRawConversion curveConverter + ) + { + _contextStack = contextStack; + _scalingService = scalingService; + _curveConverter = curveConverter; + } + + public override Polycurve RawConvert(CurveArray target) + { + Polycurve polycurve = new(); + + List curves = target.Cast().ToList(); + + polycurve.units = _contextStack.Current.SpeckleUnits; + polycurve.closed = + curves.First().GetEndPoint(0).DistanceTo(curves.Last().GetEndPoint(1)) < RevitConversionContextStack.TOLERANCE; + polycurve.length = _scalingService.ScaleLength(curves.Sum(x => x.Length)); + + polycurve.segments.AddRange(curves.Select(x => _curveConverter.RawConvert(x))); + return polycurve; + } +} diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/CurveConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/CurveConversionToSpeckle.cs new file mode 100644 index 0000000000..e53bc774a7 --- /dev/null +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/CurveConversionToSpeckle.cs @@ -0,0 +1,48 @@ +using Speckle.Converters.Common.Objects; +using Speckle.Converters.Common; +using Objects; + +namespace Speckle.Converters.RevitShared.ToSpeckle; + +[NameAndRankValue(nameof(DB.Curve), 0)] +public class CurveConversionToSpeckle : BaseConversionToSpeckle +{ + // POC: can we do this sort of thing? + // Can this converter be made generic to make a ConverterFetcher? and be used + // whenever we have some ambiguity as to the specific converter we need to call? + // IIndex> _curveConverters; + + private readonly IRawConversion _lineConverter; + + //private readonly IRawConversion _arcConverter; + //private readonly IRawConversion _ellipseConverter; + //private readonly IRawConversion _nurbsConverter; + //private readonly IRawConversion _hermiteConverter; + + public CurveConversionToSpeckle(IRawConversion lineConverter) + { + _lineConverter = lineConverter; + } + + public override ICurve RawConvert(DB.Curve target) + { + // POC: and then here: + // if (_curveConverters.TryGetValue(target.GetType().Name, out IRawConversion converter)) + // { + // return converter.RawConvert(target); + // } + // + // throw ... + + return target switch + { + DB.Line line => _lineConverter.RawConvert(line), + // POC: these conversions are "coming soon" can we use IIndex with variance with nice injection + //DB.Arc arc => _arcConverter.RawConvert(arc), + //DB.Ellipse ellipse => _ellipseConverter.RawConvert(ellipse), + //DB.NurbSpline nurbs => _nurbsConverter.RawConvert(nurbs), + //DB.HermiteSpline hermite => _hermiteConverter.RawConvert(hermite), + _ => throw new SpeckleConversionException($"Unsupported curve type {target.GetType()}") + }; + } +} diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/ElementConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/ElementConversionToSpeckle.cs new file mode 100644 index 0000000000..2a76d5b978 --- /dev/null +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/ElementConversionToSpeckle.cs @@ -0,0 +1,67 @@ +using Autodesk.Revit.DB; +using Speckle.Converters.Common; +using Objects.BuiltElements.Revit; +using Speckle.Converters.RevitShared.Helpers; + +namespace Speckle.Converters.RevitShared.ToSpeckle; + +// POC: not currently used? clearly some missing pieces +[NameAndRankValue(nameof(Element), 0)] +public class ElementConversionToSpeckle : BaseConversionToSpeckle +{ + private readonly DisplayValueExtractor _displayValueExtractor; + + public ElementConversionToSpeckle(DisplayValueExtractor displayValueExtractor) + { + _displayValueExtractor = displayValueExtractor; + } + + public override RevitElement RawConvert(Element target) + { + RevitElement speckleElement = new(); + + if (target.Document.GetElement(target.GetTypeId()) is FamilySymbol symbol) + { + speckleElement.family = symbol.FamilyName; + speckleElement.type = symbol.Name; + } + else + { + speckleElement.type = target.Name; + } + speckleElement.type = target.Name; + + //var baseGeometry = LocationToSpeckle(target); + //if (baseGeometry is Geometry.Point point) + //{ + // speckleElement["basePoint"] = point; + //} + //else if (baseGeometry is Geometry.Line line) + //{ + // speckleElement["baseLine"] = line; + //} + + speckleElement.category = target.Category.Name; + + speckleElement.displayValue = _displayValueExtractor.GetDisplayValue(target); + + //GetHostedElements(speckleElement, target, out notes); + + //var displayValue = GetElementDisplayValue(target); + + //if (!displayValue.Any()) + //{ + // notes.Add( + // "Element does not have visible geometry. It will be sent to Speckle but won't be visible in the viewer." + // ); + //} + //else + //{ + // speckleElement.displayValue = displayValue; + //} + + //GetAllRevitParamsAndIds(speckleElement, target); + + return speckleElement; + } +} diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/FamilyInstanceConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/FamilyInstanceConversionToSpeckle.cs new file mode 100644 index 0000000000..b2cfea05ad --- /dev/null +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/FamilyInstanceConversionToSpeckle.cs @@ -0,0 +1,145 @@ +using Autodesk.Revit.DB; +using Autodesk.Revit.DB.Structure; +using Speckle.Converters.Common.Objects; +using Speckle.Converters.RevitShared.Extensions; +using Speckle.Converters.RevitShared.Helpers; +using Speckle.Core.Models; + +namespace Speckle.Converters.RevitShared.ToSpeckle; + +// POC: bin for now? This is also a parent child relationship and may need a pattern for this +// so we don't end up with some god FamilyInstanceConversionToSpeckle converter +public sealed class FamilyInstanceConversionToSpeckle : BaseConversionToSpeckle +{ + private readonly IRawConversion _elementConverter; + private readonly IRawConversion _beamConverter; + private readonly IRawConversion _columnConverter; + + public FamilyInstanceConversionToSpeckle( + IRawConversion elementConverter, + IRawConversion beamConverter, + IRawConversion columnConverter + ) + { + _elementConverter = elementConverter; + _beamConverter = beamConverter; + _columnConverter = columnConverter; + } + + public override Base RawConvert(FamilyInstance target) + { + Base? @base = null; + + ////adaptive components + //if (AdaptiveComponentInstanceUtils.IsAdaptiveComponentInstance(target)) + //{ + // @base = AdaptiveComponentToSpeckle(target); + //} + + ////these elements come when the curtain wall is generated + ////if they are contained in 'subelements' then they have already been accounted for from a wall + ////else if they are mullions then convert them as a generic family instance but add a isUGridLine prop + //bool? isUGridLine = null; + //if ( + // @base == null + // && ( + // target.Category.Id.IntegerValue == (int)BuiltInCategory.OST_CurtainWallMullions + // || target.Category.Id.IntegerValue == (int)BuiltInCategory.OST_CurtainWallPanels + // ) + //) + //{ + // if (_convertedObjectsCache.ContainsBaseConvertedFromId(target.UniqueId)) + // { + // return null; + // } + // else if (target is Mullion mullion) + // { + // if (mullion.LocationCurve is DB.Line locationLine && locationLine.Direction != null) + // { + // var direction = locationLine.Direction; + // // TODO: add support for more severly sloped mullions. This isn't very robust at the moment + // isUGridLine = Math.Abs(direction.X) > Math.Abs(direction.Y); + // } + // } + // else + // { + // //TODO: sort these so we consistently get sub-elements from the wall element in case also sub-elements are sent + // //SubelementIds.Add(target.Id); + // } + //} + + //beams & braces + if (RevitCategories.StructuralFraming.BuiltInCategories.Contains(target.Category.GetBuiltInCategory())) + { + if (target.StructuralType == StructuralType.Beam) + { + @base = _beamConverter.RawConvert(target); + } + else if (target.StructuralType == StructuralType.Brace) + { + //@base = BraceToSpeckle(target, out notes); + } + } + + ////columns + if ( + @base == null + && RevitCategories.StructuralFraming.BuiltInCategories.Contains(target.Category.GetBuiltInCategory()) + || target.StructuralType == StructuralType.Column + ) + { + @base = _columnConverter.RawConvert(target); + } + + //// MEP elements + //if (target.MEPModel?.ConnectorManager?.Connectors?.Size > 0) + //{ + // @base = MEPFamilyInstanceToSpeckle(target); + //} + + //// curtain panels + //if (target is DB.Panel panel) + //{ + // @base = PanelToSpeckle(panel); + //} + + //// elements + //var baseGeometry = LocationToSpeckle(target); + //var basePoint = baseGeometry as Point; + //if (@base == null && basePoint == null) + //{ + // @base = RevitElementToSpeckle(target, out notes); + //} + + //// point based, convert these as revit instances + //if (@base == null) + //{ + // @base = RevitInstanceToSpeckle(target, out notes, null); + //} + + @base ??= _elementConverter.ConvertToBase(target); + + //// add additional props to base object + //if (isUGridLine.HasValue) + //{ + // @base["isUGridLine"] = isUGridLine.Value; + //} + + //if (target.Room != null) + //{ + // @base["roomId"] = target.Room.Id.ToString(); + //} + + //if (target.ToRoom != null) + //{ + // @base["toRoomId"] = target.ToRoom.Id.ToString(); + //} + + //if (target.FromRoom != null) + //{ + // @base["fromRoomId"] = target.FromRoom.Id.ToString(); + //} + + return @base; + } +} diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/HostedElementConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/HostedElementConversionToSpeckle.cs new file mode 100644 index 0000000000..89bed3586e --- /dev/null +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/HostedElementConversionToSpeckle.cs @@ -0,0 +1,73 @@ +using System.Collections.Generic; +using Autodesk.Revit.DB; +using Speckle.Converters.Common; +using Speckle.Converters.RevitShared.Helpers; +using Speckle.Core.Models; + +namespace Speckle.Converters.RevitShared.ToSpeckle; + +// POC: do we need to see the blocks investigation outcome? Does the current logic hold? +// opportunity to rethink or confirm hosted element handling? Should this be a connector responsibiliy? +// No interfacing out however... +public class HostedElementConversionToSpeckle +{ + private readonly ToSpeckleConvertedObjectsCache _convertedObjectsCache; + private readonly ISpeckleConverterToSpeckle _converter; + + public HostedElementConversionToSpeckle( + ToSpeckleConvertedObjectsCache convertedObjectsCache, + ISpeckleConverterToSpeckle converter + ) + { + _convertedObjectsCache = convertedObjectsCache; + _converter = converter; + } + + public List GetHostedElementsConverted(Element host) + { + var convertedHostedElements = new List(); + + var hostedElementIds = GetHostedElementIds(host); + + foreach (var elemId in hostedElementIds) + { + var element = host.Document.GetElement(elemId); + if (_convertedObjectsCache.ContainsBaseConvertedFromId(element.UniqueId)) + { + continue; + } + + convertedHostedElements.Add(_converter.Convert(element)); + } + + return convertedHostedElements; + } + + private static IList GetHostedElementIds(Element host) + { + IList ids; + if (host is HostObject hostObject) + { + ids = hostObject.FindInserts(true, false, false, false); + } + else + { + var typeFilter = new ElementIsElementTypeFilter(true); + var categoryFilter = new ElementMulticategoryFilter( + new List() + { + BuiltInCategory.OST_CLines, + BuiltInCategory.OST_SketchLines, + BuiltInCategory.OST_WeakDims + }, + true + ); + ids = host.GetDependentElements(new LogicalAndFilter(typeFilter, categoryFilter)); + } + + // dont include host elementId + ids.Remove(host.Id); + + return ids; + } +} diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/LevelConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/LevelConversionToSpeckle.cs new file mode 100644 index 0000000000..91cdc50c77 --- /dev/null +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/LevelConversionToSpeckle.cs @@ -0,0 +1,39 @@ +using Objects.BuiltElements.Revit; +using Speckle.Converters.Common; +using Speckle.Converters.RevitShared.Services; + +namespace Speckle.Converters.RevitShared.ToSpeckle; + +public class LevelConverter { } + +[NameAndRankValue(nameof(DB.Level), 0)] +public class LevelConversionToSpeckle : BaseConversionToSpeckle +{ + private readonly CachingService _cachingService; + private readonly ToSpeckleScalingService _scalingService; + + public LevelConversionToSpeckle(CachingService cachingService, ToSpeckleScalingService scalingService) + { + _cachingService = cachingService; + _scalingService = scalingService; + } + + public override RevitLevel RawConvert(DB.Level target) + { + return _cachingService.GetOrAdd(target.UniqueId, () => CreateSpeckleRevitLevel(target)); + } + + private RevitLevel CreateSpeckleRevitLevel(DB.Level level) + { + var speckleLevel = new RevitLevel + { + elevation = _scalingService.ScaleLength(level.Elevation), + name = level.Name, + createView = true + }; + + // GetAllRevitParamsAndIds(speckleLevel, revitLevel); + + return speckleLevel; + } +} diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/LineConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/LineConversionToSpeckle.cs new file mode 100644 index 0000000000..dbb642295d --- /dev/null +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/LineConversionToSpeckle.cs @@ -0,0 +1,39 @@ +using Autodesk.Revit.DB; +using Objects.Primitive; +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; +using Speckle.Converters.RevitShared.Helpers; +using Speckle.Converters.RevitShared.Services; + +namespace Speckle.Converters.RevitShared.ToSpeckle; + +[NameAndRankValue(nameof(DB.Line), 0)] +public class LineConversionToSpeckle : BaseConversionToSpeckle +{ + private readonly RevitConversionContextStack _contextStack; + private readonly IRawConversion _xyzToPointConverter; + private readonly ToSpeckleScalingService _scalingService; + + public LineConversionToSpeckle( + RevitConversionContextStack contextStack, + IRawConversion xyzToPointConverter, + ToSpeckleScalingService scalingService + ) + { + _contextStack = contextStack; + _xyzToPointConverter = xyzToPointConverter; + _scalingService = scalingService; + } + + public override SOG.Line RawConvert(DB.Line target) + { + return new() + { + units = _contextStack.Current.SpeckleUnits, + start = _xyzToPointConverter.RawConvert(target.GetEndPoint(0)), + end = _xyzToPointConverter.RawConvert(target.GetEndPoint(1)), + domain = new Interval(target.GetEndParameter(0), target.GetEndParameter(1)), + length = _scalingService.ScaleLength(target.Length) + }; + } +} diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/LocationConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/LocationConversionToSpeckle.cs new file mode 100644 index 0000000000..8d300806d1 --- /dev/null +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/LocationConversionToSpeckle.cs @@ -0,0 +1,32 @@ +using Autodesk.Revit.DB; +using Speckle.Converters.Common.Objects; +using Speckle.Converters.Common; +using Speckle.Core.Models; + +namespace Speckle.Converters.RevitShared.ToSpeckle; + +[NameAndRankValue(nameof(DB.Location), 0)] +public class LocationConversionToSpeckle : BaseConversionToSpeckle +{ + private readonly IRawConversion _curveConverter; + private readonly IRawConversion _xyzConverter; + + // POC: review IRawConversion which always returns a Base, this is ToSpeckle, so... this breaks + // the meaning of IRawConversion, it could be IToSpeckleRawConversion + // also a factory type + public LocationConversionToSpeckle(IRawConversion curveConverter, IRawConversion xyzConverter) + { + _curveConverter = curveConverter; + _xyzConverter = xyzConverter; + } + + public override Base RawConvert(DB.Location target) + { + return target switch + { + LocationCurve curve => _curveConverter.ConvertToBase(curve.Curve), + LocationPoint point => _xyzConverter.RawConvert(point.Point), + _ => throw new SpeckleConversionException($"Unexpected location type {target.GetType()}") + }; + } +} diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/MeshConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/MeshConversionToSpeckle.cs new file mode 100644 index 0000000000..546f7b6bfd --- /dev/null +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/MeshConversionToSpeckle.cs @@ -0,0 +1,41 @@ +using System.Collections.Generic; +using Objects.Geometry; +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; +using Speckle.Converters.RevitShared.Helpers; + +namespace Speckle.Converters.RevitShared.ToSpeckle; + +[NameAndRankValue(nameof(List), 0)] +public class MeshConversionToSpeckle : BaseConversionToSpeckle, List> +{ + private readonly RevitConversionContextStack _contextStack; + private readonly IRawConversion _xyzToPointConverter; + private readonly MeshDataTriangulator _meshDataTriangulator; + + public MeshConversionToSpeckle( + RevitConversionContextStack contextStack, + IRawConversion xyzToPointConverter, + MeshDataTriangulator meshDataTriangulator + ) + { + _contextStack = contextStack; + _xyzToPointConverter = xyzToPointConverter; + _meshDataTriangulator = meshDataTriangulator; + } + + public override List RawConvert(List target) + { + // POC: should be injected + MeshBuildHelper buildHelper = new(); + + foreach (var mesh in target) + { + var revitMaterial = (DB.Material)_contextStack.Current.Document.Document.GetElement(mesh.MaterialElementId); + Mesh speckleMesh = buildHelper.GetOrCreateMesh(revitMaterial, _contextStack.Current.SpeckleUnits); + _meshDataTriangulator.Triangulate(mesh, speckleMesh.faces, speckleMesh.vertices); + } + + return buildHelper.GetAllValidMeshes(); + } +} diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/ParameterConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/ParameterConversionToSpeckle.cs new file mode 100644 index 0000000000..b2435eb057 --- /dev/null +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/ParameterConversionToSpeckle.cs @@ -0,0 +1,94 @@ +using Autodesk.Revit.DB; +using Speckle.Converters.Common; +using Speckle.Converters.RevitShared.Extensions; +using Speckle.Converters.RevitShared.Helpers; +using Speckle.Converters.RevitShared.Services; + +namespace Speckle.Converters.RevitShared.ToSpeckle; + +[NameAndRankValue(nameof(Parameter), 0)] +public class ParameterConversionToSpeckle : BaseConversionToSpeckle +{ + private readonly ToSpeckleScalingService _scalingService; + private readonly ParameterValueExtractor _valueExtractor; + private readonly CachingService _cachingService; + + public ParameterConversionToSpeckle( + ToSpeckleScalingService scalingService, + ParameterValueExtractor valueExtractor, + CachingService cachingService + ) + { + _scalingService = scalingService; + _valueExtractor = valueExtractor; + _cachingService = cachingService; + } + + public override SOBR.Parameter RawConvert(DB.Parameter target) + { + string internalName = target.GetInternalName(); + ParameterToSpeckleData toSpeckleData = _cachingService.GetOrAdd( + internalName, + paramInternalName => ExtractParameterDataFromDocument(paramInternalName, target) + ); + + return toSpeckleData.GetParameterObjectWithValue(_valueExtractor.GetValue(target)); + } + + // POC: naming, I don't know if we need FromDocument, even if it is using it (but maybe it is not) + private ParameterToSpeckleData ExtractParameterDataFromDocument(string paramInternalName, DB.Parameter parameter) + { + var definition = parameter.Definition; + var newParamData = new ParameterToSpeckleData() + { + Definition = definition, + InternalName = paramInternalName, + IsReadOnly = parameter.IsReadOnly, + IsShared = parameter.IsShared, + Name = definition.Name, + UnitType = definition.GetUnitTypeString(), + }; + + // POC: why is this specialisation needed? Could there be more? + if (parameter.StorageType == StorageType.Double) + { + ForgeTypeId unitTypeId = parameter.GetUnitTypeId(); + newParamData.UnitsSymbol = unitTypeId.GetSymbol(); + newParamData.ApplicationUnits = unitTypeId.ToUniqueString(); + } + + return newParamData; + } +} + +/// +/// This struct is used when caching parameter definitions upon sending to avoid having to deep clone the parameter object +/// This is done because all the fields except the parameter value will change +/// +/// +// POC: needed for caching but should it be a struct? We should have it in it's own file +internal struct ParameterToSpeckleData +{ + public string ApplicationUnits; + public DB.Definition Definition; + public string InternalName; + public bool IsReadOnly; + public bool IsShared; + public string Name; + public string? UnitsSymbol; + public string UnitType; + + public readonly SOBR.Parameter GetParameterObjectWithValue(object? value) + { + return new SOBR.Parameter() + { + applicationInternalName = InternalName, + applicationUnit = ApplicationUnits, + isShared = IsShared, + isReadOnly = IsReadOnly, + name = Name, + units = UnitsSymbol ?? "None", + value = value + }; + } +} diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/PointConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/PointConversionToSpeckle.cs new file mode 100644 index 0000000000..90a655418f --- /dev/null +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/PointConversionToSpeckle.cs @@ -0,0 +1,21 @@ +using Speckle.Converters.Common; +using Autodesk.Revit.DB; +using Speckle.Converters.Common.Objects; + +namespace Speckle.Converters.RevitShared.ToSpeckle; + +[NameAndRankValue(nameof(DB.Point), 0)] +public class PointConversionToSpeckle : BaseConversionToSpeckle +{ + private readonly IRawConversion _xyzToPointConverter; + + public PointConversionToSpeckle(IRawConversion xyzToPointConverter) + { + _xyzToPointConverter = xyzToPointConverter; + } + + public override SOG.Point RawConvert(Point target) + { + return _xyzToPointConverter.RawConvert(target.Coord); + } +} diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/SolidsConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/SolidsConversionToSpeckle.cs new file mode 100644 index 0000000000..e60d651890 --- /dev/null +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/SolidsConversionToSpeckle.cs @@ -0,0 +1,84 @@ +using System.Collections.Generic; +using Autodesk.Revit.DB; +using Speckle.Converters.Common; +using Speckle.Converters.RevitShared.Helpers; +using Mesh = Objects.Geometry.Mesh; + +namespace Speckle.Converters.RevitShared.ToSpeckle; + +// POC: do we need to have this atm? +// why do we need a List, do we encounter these in the converter logic? +// it looks wrong here or perhaps the List is coming from the connector? +[NameAndRankValue(nameof(List), 0)] +public class SolidsConversionToSpeckle : BaseConversionToSpeckle, List> +{ + private readonly RevitConversionContextStack _contextStack; + private readonly MeshDataTriangulator _meshDataTriangulator; + + public SolidsConversionToSpeckle(RevitConversionContextStack contextStack, MeshDataTriangulator meshDataTriangulator) + { + _contextStack = contextStack; + _meshDataTriangulator = meshDataTriangulator; + } + + // POC: this is converting and caching and using the cache and some of it is a bit questionable + public override List RawConvert(List target) + { + MeshBuildHelper meshBuildHelper = new(); + + var meshMap = new Dictionary>(); + foreach (Solid solid in target) + { + foreach (Face face in solid.Faces) + { + // POC: throwing here? Just review. Is it necessary armouring against Revit APU weirdness? + // do direct cast (DB.Material) instead of as and then no need to throw, it will throw naturally + // of course if we need to do this then maybe it's valid. So hence, just review. + DB.Material faceMaterial = + _contextStack.Current.Document.Document.GetElement(face.MaterialElementId) as DB.Material + ?? throw new SpeckleConversionException("Unable to cast face's materialElementId element to DB.Material"); + + // POC: this logic, relationship between material and mesh, seems wrong + Mesh m = meshBuildHelper.GetOrCreateMesh(faceMaterial, _contextStack.Current.SpeckleUnits); + if (!meshMap.TryGetValue(m, out List? value)) + { + value = new List(); + meshMap.Add(m, value); + } + + value.Add(face.Triangulate()); + } + } + + foreach (var meshData in meshMap) + { + //It's cheaper to resize lists manually, since we would otherwise be resizing a lot! + int numberOfVertices = 0; + int numberOfFaces = 0; + foreach (DB.Mesh mesh in meshData.Value) + { + if (mesh == null) + { + continue; + } + + numberOfVertices += mesh.Vertices.Count * 3; + numberOfFaces += mesh.NumTriangles * 4; + } + + meshData.Key.faces.Capacity = numberOfFaces; + meshData.Key.vertices.Capacity = numberOfVertices; + foreach (DB.Mesh mesh in meshData.Value) + { + if (mesh == null) + { + continue; + } + + _meshDataTriangulator.Triangulate(mesh, meshData.Key.faces, meshData.Key.vertices); + } + } + + return meshBuildHelper.GetAllValidMeshes(); + } +} diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/WallConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/WallConversionToSpeckle.cs new file mode 100644 index 0000000000..03c6823a67 --- /dev/null +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/WallConversionToSpeckle.cs @@ -0,0 +1,143 @@ +using Speckle.Converters.Common.Objects; +using Speckle.Converters.Common; +using Objects.BuiltElements.Revit; +using Autodesk.Revit.DB; +using Objects; +using Speckle.Converters.RevitShared.Helpers; +using System.Collections.Generic; +using System.Linq; +using Objects.Geometry; +using Speckle.Core.Models; +using Speckle.Core.Models.Extensions; + +namespace Speckle.Converters.RevitShared.ToSpeckle; + +// POC: needs review feels, BIG, feels like it could be broken down.. +// i.e. GetParams(), GetGeom()? feels like it's doing too much +[NameAndRankValue(nameof(DB.Wall), 0)] +public class WallConversionToSpeckle : BaseConversionToSpeckle +{ + private readonly IRawConversion _curveConverter; + private readonly IRawConversion _levelConverter; + private readonly IRawConversion _curveArrayConverter; + private readonly ParameterValueExtractor _parameterValueExtractor; + private readonly RevitConversionContextStack _contextStack; + private readonly DisplayValueExtractor _displayValueExtractor; + private readonly HostedElementConversionToSpeckle _hostedElementConverter; + private readonly ParameterObjectAssigner _parameterObjectAssigner; + + public WallConversionToSpeckle( + IRawConversion curveConverter, + IRawConversion levelConverter, + RevitConversionContextStack contextStack, + ParameterValueExtractor parameterValueExtractor, + DisplayValueExtractor displayValueExtractor, + IRawConversion curveArrayConverter, + HostedElementConversionToSpeckle hostedElementConverter, + ParameterObjectAssigner parameterObjectAssigner + ) + { + _curveConverter = curveConverter; + _levelConverter = levelConverter; + _contextStack = contextStack; + _parameterValueExtractor = parameterValueExtractor; + _displayValueExtractor = displayValueExtractor; + _curveArrayConverter = curveArrayConverter; + _hostedElementConverter = hostedElementConverter; + _parameterObjectAssigner = parameterObjectAssigner; + } + + public override RevitWall RawConvert(DB.Wall target) + { + RevitWall speckleWall = new() { family = target.WallType.FamilyName.ToString(), type = target.WallType.Name }; + + if (target.Location is not LocationCurve locationCurve) + { + throw new SpeckleConversionException( + "Incorrect assumption was made that all Revit Wall location properties would be of type \"LocationCurve\"" + ); + } + + speckleWall.baseLine = _curveConverter.RawConvert(locationCurve.Curve); + + var level = _parameterValueExtractor.GetValueAsDocumentObject( + target, + BuiltInParameter.WALL_BASE_CONSTRAINT + ); + speckleWall.level = _levelConverter.RawConvert(level); + + var topLevel = _parameterValueExtractor.GetValueAsDocumentObject( + target, + BuiltInParameter.WALL_BASE_CONSTRAINT + ); + speckleWall.topLevel = _levelConverter.RawConvert(topLevel); + + // POC : what to do if these parameters are unset (instead of assigning default) + speckleWall.height = + _parameterValueExtractor.GetValueAsDouble(target, BuiltInParameter.WALL_USER_HEIGHT_PARAM) ?? 0; + speckleWall.baseOffset = _parameterValueExtractor.GetValueAsDouble(target, BuiltInParameter.WALL_BASE_OFFSET) ?? 0; + speckleWall.topOffset = _parameterValueExtractor.GetValueAsDouble(target, BuiltInParameter.WALL_TOP_OFFSET) ?? 0; + speckleWall.structural = + _parameterValueExtractor.GetValueAsBool(target, BuiltInParameter.WALL_STRUCTURAL_SIGNIFICANT) ?? false; + speckleWall.flipped = target.Flipped; + + speckleWall.displayValue = _displayValueExtractor.GetDisplayValue(target); + + AssignVoids(target, speckleWall); + AssignHostedElements(target, speckleWall); + + _parameterObjectAssigner.AssignParametersToBase(target, speckleWall); + + return speckleWall; + } + + // POC: not sure + private void AssignHostedElements(Wall target, RevitWall speckleWall) + { + List hostedObjects = _hostedElementConverter.GetHostedElementsConverted(target); + if (hostedObjects.Count > 0) + { + if (speckleWall.GetDetachedProp("elements") is List elements) + { + elements.AddRange(hostedObjects); + } + else + { + speckleWall.SetDetachedProp("elements", hostedObjects); + } + } + } + + private void AssignVoids(Wall target, RevitWall speckleWall) + { + List voids = GetWallVoids(target); + List polycurves = voids.Select(v => _curveArrayConverter.RawConvert(v)).ToList(); + + if (polycurves.Count > 0) + { + speckleWall["voids"] = polycurves; + } + } + + private List GetWallVoids(Wall wall) + { + List curveArrays = new(); + var profile = ((Sketch)_contextStack.Current.Document.Document.GetElement(wall.SketchId))?.Profile; + + if (profile == null) + { + return curveArrays; + } + + for (var i = 1; i < profile.Size; i++) + { + var segments = profile.get_Item(i); + if (segments.Cast().Count() > 2) + { + curveArrays.Add(segments); + } + } + + return curveArrays; + } +} diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/XyzConversionToPoint.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/XyzConversionToPoint.cs new file mode 100644 index 0000000000..a19ab64642 --- /dev/null +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/XyzConversionToPoint.cs @@ -0,0 +1,29 @@ +using Speckle.Converters.Common; +using Speckle.Converters.RevitShared.Helpers; +using Speckle.Converters.RevitShared.Services; + +namespace Speckle.Converters.RevitShared.ToSpeckle; + +[NameAndRankValue(nameof(DB.XYZ), 0)] +public class XyzConversionToPoint : BaseConversionToSpeckle +{ + private readonly ToSpeckleScalingService _toSpeckleScalingService; + private readonly RevitConversionContextStack _contextStack; + + public XyzConversionToPoint(ToSpeckleScalingService toSpeckleScalingService, RevitConversionContextStack contextStack) + { + _toSpeckleScalingService = toSpeckleScalingService; + _contextStack = contextStack; + } + + public override SOG.Point RawConvert(DB.XYZ target) + { + var pointToSpeckle = new SOG.Point( + _toSpeckleScalingService.ScaleLength(target.X), + _toSpeckleScalingService.ScaleLength(target.Y), + _toSpeckleScalingService.ScaleLength(target.Z), + _contextStack.Current.SpeckleUnits + ); + return pointToSpeckle; + } +} diff --git a/DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/ScopedFactory.cs b/DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/ScopedFactory.cs index 50f6247309..e4827548c2 100644 --- a/DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/ScopedFactory.cs +++ b/DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/ScopedFactory.cs @@ -11,11 +11,16 @@ public class ScopedFactory : IScopedFactory public ScopedFactory(ILifetimeScope parentScope) { + // POC: do I need a new lifetime each time I do the resolve. + // move this to ResolveScopedInstance() and rename this to UnitOfWork() + // look at the disposal lifecycle, what we might need to return is a UoW object + // we need a document to explain how this works and how to pick where to do it _lifetimeScope = parentScope.BeginLifetimeScope(); } public T ResolveScopedInstance() { + // POC: do I need a new lifetime each time I do the resolve return _lifetimeScope.Resolve(); } diff --git a/DUI3-DX/Sdk/Speckle.Connectors.Utils/Speckle.Connectors.Utils.csproj b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Speckle.Connectors.Utils.csproj index 1582a2b5e4..30518ea302 100644 --- a/DUI3-DX/Sdk/Speckle.Connectors.Utils/Speckle.Connectors.Utils.csproj +++ b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Speckle.Connectors.Utils.csproj @@ -9,4 +9,8 @@ + + + + diff --git a/DUI3-DX/Sdk/Speckle.Connectors.Utils/SpeckleTopLevelExceptionHandler.cs b/DUI3-DX/Sdk/Speckle.Connectors.Utils/SpeckleTopLevelExceptionHandler.cs index f74c866e77..c93d61af5e 100644 --- a/DUI3-DX/Sdk/Speckle.Connectors.Utils/SpeckleTopLevelExceptionHandler.cs +++ b/DUI3-DX/Sdk/Speckle.Connectors.Utils/SpeckleTopLevelExceptionHandler.cs @@ -1,4 +1,5 @@ using System; +using System.Threading.Tasks; using Speckle.Core.Logging; namespace Speckle.Connectors.Utils; @@ -8,8 +9,8 @@ public static class SpeckleTopLevelExceptionHandler { // POC: async/await? // handlers for - public static void Run( - Action run, + public static async Task Run( + Func run, Func? speckleError = null, Func? unexpectedError = null, Func? fatalError = null @@ -18,7 +19,7 @@ public static void Run( // POC: TL-handler try { - run(); + await run().ConfigureAwait(false); } catch (SpeckleException spex) { diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/RawConversionRegisterer.cs b/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/RawConversionRegisterer.cs new file mode 100644 index 0000000000..05bdda19b4 --- /dev/null +++ b/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/RawConversionRegisterer.cs @@ -0,0 +1,57 @@ +using Autofac; +using Speckle.Converters.Common.Objects; + +namespace Speckle.Converters.Common.DependencyInjection; + +// POC: review and see if it can be made more generic, related to the +// NameAndRankAttribute work that needs doing +public static class RawConversionRegisterer +{ + public static ContainerBuilder RegisterRawConversions(this ContainerBuilder containerBuilder) + { + // POC: hard-coding speckle... :/ + foreach (var asm in AppDomain.CurrentDomain.GetAssemblies().Where(x => x.GetName().Name.StartsWith("Speckle"))) + { + foreach (var type in asm.GetTypes().Where(t => t.IsClass && !t.IsAbstract)) + { + if (GetImplementedRawConversionType(type) is not Type interfaceType) + { + continue; + } + + var registrationBuilder = containerBuilder.RegisterType(type).As(interfaceType); + + Type firstGenericType = interfaceType.GenericTypeArguments[0]; + var singleParamRawConversionType = typeof(IRawConversion<>).MakeGenericType(firstGenericType); + if (singleParamRawConversionType.IsAssignableFrom(type)) + { + registrationBuilder = registrationBuilder.As(singleParamRawConversionType); + } + + if (typeof(IHostObjectToSpeckleConversion).IsAssignableFrom(type)) + { + registrationBuilder = registrationBuilder + .As() + .Keyed(firstGenericType); + } + + registrationBuilder.InstancePerLifetimeScope(); + } + } + + return containerBuilder; + } + + public static Type? GetImplementedRawConversionType(Type givenType) + { + foreach (var it in givenType.GetInterfaces()) + { + if (it.IsGenericType && it.GetGenericTypeDefinition() == typeof(IRawConversion<,>)) + { + return it; + } + } + + return null; + } +} diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common/Objects/IRawConversion.cs b/DUI3-DX/Sdk/Speckle.Converters.Common/Objects/IRawConversion.cs index a9d11843e1..dafea22be7 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common/Objects/IRawConversion.cs +++ b/DUI3-DX/Sdk/Speckle.Converters.Common/Objects/IRawConversion.cs @@ -1,6 +1,15 @@ -namespace Speckle.Converters.Common.Objects; +using Speckle.Core.Models; + +namespace Speckle.Converters.Common.Objects; public interface IRawConversion { TOut RawConvert(TIn target); } + +// POC: this breaks the concept of IRawConversion be +// if we had this we would probably rename the interface as this is now a IToSpeckleRawConversion +public interface IRawConversion +{ + Base ConvertToBase(TIn target); +} diff --git a/global.json b/global.json index 36e1a9e95f..3cb4f9622d 100644 --- a/global.json +++ b/global.json @@ -1,7 +1,7 @@ { "sdk": { "version": "7.0.0", - "rollForward": "latestMajor", + "rollForward": "latestMinor", "allowPrerelease": false } -} \ No newline at end of file +} From 4cc535b8691cf6e993bebed3d583409e0353570d Mon Sep 17 00:00:00 2001 From: Jedd Morgan <45512892+JR-Morgan@users.noreply.github.com> Date: Thu, 4 Apr 2024 22:26:50 +0200 Subject: [PATCH 019/261] CNX-9175 Initial ArcGIS sending operation and filters (#3252) * add specklepy classes * add constructors * Selection based on mapmembers * point feature layer converter * Selection * Fix target framework * Name and rank value * Fixed warnings * Update PolyCurveToSpeckleConverter.cs * Update ConverterETABS.csproj * Update ConverterETABS.csproj * Fixed empty objects constructors * fix scope * create converter ourside of for-loop * fix(arcgis): Removed unnecessary using statement * Revert "fix(arcgis): Removed unnecessary using statement" This reverts commit 033e5b45c06d45ed8a3463e23e33ffe0a554e14d. * fix(arcgis): Lower IDE0063 to suggestion * fix: Resolved comments to get this merged ASAP --------- Co-authored-by: KatKatKateryna Co-authored-by: KatKatKateryna <89912278+KatKatKateryna@users.noreply.github.com> Co-authored-by: Alan Rynne --- .editorconfig | 1 + All.sln.DotSettings | 1 + .../Bindings/BasicConnectorBinding.cs | 3 +- .../Bindings/ArcGISSendBinding.cs | 191 ++---------------- .../Bindings/BasicConnectorBinding.cs | 1 + .../AutofacArcGISModule.cs | 11 + .../Filters/ArcGISSelectionFilter.cs | 1 + .../HostApp/ArcGISSettings.cs | 3 +- .../HostApp/SpeckleDUI3.xaml.cs | 2 + .../HostApp/SpeckleModule.cs | 1 + .../Operations/Send/IRootObjectSender.cs | 22 ++ .../Operations/Send/RootObjectBuilder.cs | 109 ++++++++++ .../Operations/Send/RootObjectSender.cs | 77 +++++++ .../Operations/Send/SendOperation.cs | 44 ++++ .../Speckle.Connectors.ArcGIS3.csproj | 6 +- .../AutofacArcGIS3ConverterModule.cs | 2 +- ...verters.ArcGIS3.DependencyInjection.csproj | 3 +- .../ArcGISConverterToSpeckle.cs | 10 +- .../PointElementToSpeckleConverter.cs | 36 ++++ .../Geometry/PointToSpeckleConverter.cs | 15 ++ .../Layers/VectorLayerToSpeckleConverter.cs | 67 ++++++ .../Speckle.Converters.ArcGIS3.csproj | 17 +- .../ConverterETABS/ConverterETABS.csproj | 2 +- Objects/Objects/GIS/CRS.cs | 14 ++ Objects/Objects/GIS/GisTopography.cs | 16 +- Objects/Objects/GIS/LineElement.cs | 10 + Objects/Objects/GIS/NonGeometryElement.cs | 8 + Objects/Objects/GIS/PointElement.cs | 11 + Objects/Objects/GIS/RasterElement.cs | 21 ++ Objects/Objects/GIS/RasterLayer.cs | 18 ++ Objects/Objects/GIS/VectorLayer.cs | 18 ++ 31 files changed, 534 insertions(+), 207 deletions(-) create mode 100644 DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Send/IRootObjectSender.cs create mode 100644 DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Send/RootObjectBuilder.cs create mode 100644 DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Send/RootObjectSender.cs create mode 100644 DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Send/SendOperation.cs create mode 100644 DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/PointElementToSpeckleConverter.cs create mode 100644 DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/PointToSpeckleConverter.cs create mode 100644 DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/VectorLayerToSpeckleConverter.cs create mode 100644 Objects/Objects/GIS/CRS.cs create mode 100644 Objects/Objects/GIS/LineElement.cs create mode 100644 Objects/Objects/GIS/NonGeometryElement.cs create mode 100644 Objects/Objects/GIS/PointElement.cs create mode 100644 Objects/Objects/GIS/RasterElement.cs create mode 100644 Objects/Objects/GIS/RasterLayer.cs create mode 100644 Objects/Objects/GIS/VectorLayer.cs diff --git a/.editorconfig b/.editorconfig index a226d40036..a139b3f4d0 100644 --- a/.editorconfig +++ b/.editorconfig @@ -219,6 +219,7 @@ dotnet_diagnostic.ide0078.severity = suggestion # Use pattern matching: Subjecti dotnet_diagnostic.ide0260.severity = suggestion # Use pattern matching: Subjective dotnet_diagnostic.ide0022.severity = suggestion # Use expression body for method: Subjective dotnet_diagnostic.ide0061.severity = suggestion # Use expression body for local functions: Subjective +dotnet_diagnostic.ide0063.severity = suggestion # Using directive can be simplified dotnet_diagnostic.ide0029.severity = suggestion # Null check can be simplified: Subjective dotnet_diagnostic.ide0030.severity = suggestion # Null check can be simplified: Subjective dotnet_diagnostic.ide0270.severity = suggestion # Null check can be simplified: Subjective diff --git a/All.sln.DotSettings b/All.sln.DotSettings index 047cb5195c..4d2ed20707 100644 --- a/All.sln.DotSettings +++ b/All.sln.DotSettings @@ -616,6 +616,7 @@ Speckle:Cleanup CCW + CRS CSI DUI GQL diff --git a/ConnectorArcGIS/Bindings/BasicConnectorBinding.cs b/ConnectorArcGIS/Bindings/BasicConnectorBinding.cs index ff598acd77..9c93e75973 100644 --- a/ConnectorArcGIS/Bindings/BasicConnectorBinding.cs +++ b/ConnectorArcGIS/Bindings/BasicConnectorBinding.cs @@ -23,7 +23,8 @@ public BasicConnectorBinding(ArcGisDocumentStore store) public string GetSourceApplicationVersion() => "3"; - public string GetConnectorVersion() => Assembly.GetAssembly(GetType()).GetNameAndVersion().Version; + public string GetConnectorVersion() => + typeof(BasicConnectorBinding).Assembly.GetNameAndVersion().Version ?? "No version"; // TODO public DocumentInfo GetDocumentInfo() => diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISSendBinding.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISSendBinding.cs index 3aa215f409..22c2568fa2 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISSendBinding.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISSendBinding.cs @@ -1,21 +1,16 @@ using System.Diagnostics.CodeAnalysis; using Speckle.Autofac.DependencyInjection; -using Speckle.Core.Credentials; -using Speckle.Core.Models; -using Speckle.Core.Transports; using Speckle.Connectors.DUI.Bindings; using Speckle.Connectors.DUI.Bridge; -using Speckle.Connectors.DUI.Models.Card; using Speckle.Connectors.DUI.Utils; using Speckle.Connectors.ArcGIS.Filters; -using Speckle.Connectors.ArcGIS.HostApp; +using Speckle.Connectors.ArcGis.Operations.Send; using Speckle.Connectors.Utils.Cancellation; -using Speckle.Connectors.Utils.Operations; using Speckle.Converters.Common; -using Speckle.Core.Api; using Speckle.Core.Logging; using ICancelable = System.Reactive.Disposables.ICancelable; using Speckle.Connectors.ArcGIS.Utils; +using Speckle.Connectors.DUI.Models.Card; namespace Speckle.Connectors.ArcGIS.Bindings; @@ -26,31 +21,26 @@ public sealed class ArcGISSendBinding : ISendBinding, ICancelable public IBridge Parent { get; } private readonly ArcGISDocumentStore _store; - private readonly ArcGISSettings _arcgisSettings; private readonly IScopedFactory _speckleConverterToSpeckleFactory; private readonly CancellationManager _cancellationManager; + private readonly SendOperation _sendOperation; /// /// Used internally to aggregate the changed objects' id. /// private HashSet ChangedObjectIds { get; set; } = new(); - /// - /// Keeps track of previously converted objects as a dictionary of (applicationId, object reference). - /// - private readonly Dictionary _convertedObjectReferences = new(); - public ArcGISSendBinding( ArcGISDocumentStore store, - ArcGISSettings arcgisSettings, IBridge parent, IScopedFactory speckleConverterToSpeckleFactory, + SendOperation sendOperation, CancellationManager cancellationManager ) { _store = store; - _arcgisSettings = arcgisSettings; _speckleConverterToSpeckleFactory = speckleConverterToSpeckleFactory; + _sendOperation = sendOperation; _cancellationManager = cancellationManager; Parent = parent; @@ -59,11 +49,7 @@ CancellationManager cancellationManager public List GetSendFilters() { - return new List - { - new ArcGISEverythingFilter(), - new ArcGISSelectionFilter { IsDefault = true } - }; + return new List { new ArcGISSelectionFilter { IsDefault = true } }; } public List GetSendSettings() @@ -87,77 +73,30 @@ public List GetSendSettings() )] public async Task Send(string modelCardId) { + //poc: dupe code between connectors try { // 0 - Init cancellation token source -> Manager also cancel it if exist before CancellationTokenSource cts = _cancellationManager.InitCancellationTokenSource(modelCardId); // 1 - Get model - if (_store.GetModelById(modelCardId) is not SenderModelCard modelCard) { throw new InvalidOperationException("No publish model card was found."); } - // 2 - Check account exist - // TODO: FETCHING ACCOUNTS BY ID ONLY IS UNSAFE - Account account = - AccountManager.GetAccounts().FirstOrDefault(acc => acc.id == modelCard.AccountId) - ?? throw new SpeckleAccountManagerException(); - - // 3 - Get elements to convert, throw early if nothing is selected: TODO - List arcgisObjects = new() { "object1", "object2" }; - - if (arcgisObjects.Count == 0) - { - throw new InvalidOperationException("No objects were found. Please update your send filter!"); - } - - var converter = _speckleConverterToSpeckleFactory.ResolveScopedInstance(); - // 5 - Convert objects - Base commitObject = ConvertObjects(arcgisObjects, converter, modelCard, cts); - - if (cts.IsCancellationRequested) - { - throw new OperationCanceledException(cts.Token); - } - - // 7 - Serialize and Send objects - Commands.SetModelProgress(modelCardId, new ModelCardProgress { Status = "Uploading..." }); - - var transport = new ServerTransport(account, modelCard.ProjectId); - var sendResult = await SendHelper.Send(commitObject, transport, true, null, cts.Token).ConfigureAwait(true); - - // Store the converted references in memory for future send operations, overwriting the existing values for the given application id. - foreach (var kvp in sendResult.convertedReferences) - { - // TODO: Bug in here, we need to encapsulate cache not only by app id, but also by project id, - // TODO: as otherwise we assume incorrectly that an object exists for a given project (e.g, send box to project 1, send same unchanged box to project 2) - _convertedObjectReferences[kvp.Key + modelCard.ProjectId] = kvp.Value; - } - // It's important to reset the model card's list of changed obj ids so as to ensure we accurately keep track of changes between send operations. - // NOTE: ChangedObjectIds is currently JsonIgnored, but could actually be useful for highlighting changes in host app. - //modelCard.ChangedObjectIds = new(); - - Commands.SetModelProgress(modelCardId, new ModelCardProgress { Status = "Linking version to model..." }); - - // 8 - Create the version (commit) - var apiClient = new Client(account); - string versionId = await apiClient - .CommitCreate( - new CommitCreateInput - { - streamId = modelCard.ProjectId, - branchName = modelCard.ModelId, - sourceApplication = "ArcGIS", - objectId = sendResult.rootObjId - }, + string versionId = await _sendOperation + .Execute( + //modelCard.SendFilter, + modelCard.AccountId, + modelCard.ProjectId, + modelCard.ModelId, + (status, progress) => OnSendOperationProgress(modelCardId, status, progress), cts.Token ) - .ConfigureAwait(true); + .ConfigureAwait(false); Commands.SetModelCreatedVersionId(modelCardId, versionId); - apiClient.Dispose(); } catch (OperationCanceledException) { @@ -171,101 +110,6 @@ public async Task Send(string modelCardId) public void CancelSend(string modelCardId) => _cancellationManager.CancelOperation(modelCardId); - private Base ConvertObjects( - List arcgisObjects, - ISpeckleConverterToSpeckle converter, - SenderModelCard modelCard, - CancellationTokenSource cts - ) - { - var rootObjectCollection = new Collection { name = "Unnamed document" }; // { name = ArcGISDoc.ActiveDoc.Name ?? "Unnamed document" }; - int count = 0; - - Dictionary layerCollectionCache = new(); - // TODO: Handle blocks. - - foreach (string arcgisObject in arcgisObjects) // switch to ArcgisObject - { - if (cts.IsCancellationRequested) - { - throw new OperationCanceledException(cts.Token); - } - - // 1. get object layer: TODO - // var layer = ArcGISDoc.ActiveDoc.Layers[arcgisObject.Attributes.LayerIndex]; - - // 2. get or create a nested collection for it - var collectionHost = GetHostObjectCollection(layerCollectionCache, rootObjectCollection); - // var applicationId = arcgisObject.Id.ToString(); - - // 3. get from cache or convert: - // What we actually do here is check if the object has been previously converted AND has not changed. - // If that's the case, we insert in the host collection just its object reference which has been saved from the prior conversion. - /*Base converted; - if ( - !modelCard.ChangedObjectIds.Contains(applicationId) - && _convertedObjectReferences.TryGetValue(applicationId + modelCard.ProjectId, out ObjectReference value) - ) - { - converted = value; - } - else - { - converted = converter.ConvertToSpeckle(arcgisObject); - converted.applicationId = applicationId; - }*/ - - var converted = converter.Convert(arcgisObject); - // converted.applicationId = applicationId; - - // 4. add to host - collectionHost.elements.Add(converted); - Commands.SetModelProgress( - modelCard.ModelCardId, - new ModelCardProgress { Status = "Converting", Progress = (double)++count / 2 } // / arcgisObjects.Count } - ); - - // NOTE: useful for testing ui states, pls keep for now so we can easily uncomment - // Thread.Sleep(550); - } - - // 5. profit - return rootObjectCollection; - } - - /// - /// Returns the host collection based on the provided layer. If it's not found, it will be created and hosted within the the rootObjectCollection. - /// - /// - /// - /// - private Collection GetHostObjectCollection( - Dictionary layerCollectionCache, - // Layer layer, - Collection rootObjectCollection - ) - { - var names = new List { "name1" }; // layer.FullPath.Split(new[] { Layer.PathSeparator }, StringSplitOptions.None); - var index = 0; - var previousCollection = rootObjectCollection; - foreach (var layerName in names) - { - var existingLayerIndex = 0; // ArcGISDoc.ActiveDoc.Layers.FindByFullPath(path, -1); - Collection? childCollection = null; - - childCollection = new Collection(layerName, "layer"); - previousCollection.elements.Add(childCollection); - layerCollectionCache[existingLayerIndex] = childCollection; - - previousCollection = childCollection; - - index++; - } - - layerCollectionCache[0] = previousCollection; - return previousCollection; - } - /// /// Checks if any sender model cards contain any of the changed objects. If so, also updates the changed objects hashset for each model card - this last part is important for on send change detection. /// @@ -287,6 +131,11 @@ private void RunExpirationChecks() ChangedObjectIds = new HashSet(); } + private void OnSendOperationProgress(string modelCardId, string status, double? progress) + { + Commands.SetModelProgress(modelCardId, new ModelCardProgress { Status = status, Progress = progress }); + } + public void Dispose() { IsDisposed = true; diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/BasicConnectorBinding.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/BasicConnectorBinding.cs index 46fde8ad11..77d6a073ad 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/BasicConnectorBinding.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/BasicConnectorBinding.cs @@ -9,6 +9,7 @@ namespace Speckle.Connectors.ArcGIS.Bindings; +//poc: dupe code between connectors public class BasicConnectorBinding : IBasicConnectorBinding { public string Name => "baseBinding"; diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/DependencyInjection/AutofacArcGISModule.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/DependencyInjection/AutofacArcGISModule.cs index 2386831b56..5971305a4f 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/DependencyInjection/AutofacArcGISModule.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/DependencyInjection/AutofacArcGISModule.cs @@ -4,6 +4,7 @@ using Speckle.Autofac.DependencyInjection; using Speckle.Connectors.ArcGIS.Bindings; using Speckle.Connectors.ArcGIS.HostApp; +using Speckle.Connectors.ArcGis.Operations.Send; using Speckle.Connectors.DUI.Bindings; using Speckle.Connectors.DUI.Bridge; using Speckle.Connectors.DUI.Utils; @@ -12,6 +13,7 @@ using Speckle.Newtonsoft.Json.Serialization; using Speckle.Connectors.ArcGIS.Utils; using Speckle.Connectors.Utils.Cancellation; +using Speckle.Core.Transports; namespace Speckle.Connectors.ArcGIS.DependencyInjection; @@ -36,6 +38,14 @@ protected override void Load(ContainerBuilder builder) // binding dependencies builder.RegisterType().InstancePerDependency(); + // register send operation and dependencies + builder.RegisterType().SingleInstance(); + builder.RegisterType().SingleInstance(); + builder.RegisterType().As().SingleInstance(); + + //POC: how tf does this work? + builder.RegisterType().As().SingleInstance(); + // Register converter factory builder .RegisterType>() @@ -43,6 +53,7 @@ protected override void Load(ContainerBuilder builder) .InstancePerLifetimeScope(); } + //poc: dupe code private static JsonSerializerSettings GetJsonSerializerSettings() { // Register WebView2 panel stuff diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Filters/ArcGISSelectionFilter.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Filters/ArcGISSelectionFilter.cs index 97247d1b5b..cea5405f8c 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Filters/ArcGISSelectionFilter.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Filters/ArcGISSelectionFilter.cs @@ -2,6 +2,7 @@ namespace Speckle.Connectors.ArcGIS.Filters; +//poc: dupe code public class ArcGISSelectionFilter : DirectSelectionSendFilter { public override List GetObjectIds() => SelectedObjectIds; diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/HostApp/ArcGISSettings.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/HostApp/ArcGISSettings.cs index 910e15c72e..480a49426f 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/HostApp/ArcGISSettings.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/HostApp/ArcGISSettings.cs @@ -3,13 +3,14 @@ namespace Speckle.Connectors.ArcGIS.HostApp; +//poc: dupe code bewtween connectors public class ArcGISSettings { public ArcGISSettings(HostApplication hostAppInfo, HostAppVersion hostAppVersion) { HostAppInfo = hostAppInfo; HostAppVersion = hostAppVersion; - Modules = new[] { new DirectoryInfo(typeof(ArcGISSettings).Assembly.Location).Parent!.FullName }; + Modules = new[] { new DirectoryInfo(typeof(ArcGISSettings).Assembly.Location).Parent!.FullName }; //poc: Net6 requires us to use this `location` property rather than ToString, should we use this everywhere? } public HostApplication HostAppInfo { get; private set; } diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/HostApp/SpeckleDUI3.xaml.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/HostApp/SpeckleDUI3.xaml.cs index b329359ec3..ce12751e83 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/HostApp/SpeckleDUI3.xaml.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/HostApp/SpeckleDUI3.xaml.cs @@ -6,6 +6,8 @@ namespace Speckle.Connectors.ArcGIS.HostApp; +//poc: dupe code + /// /// Interaction logic for WebViewBrowserView.xaml /// diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/HostApp/SpeckleModule.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/HostApp/SpeckleModule.cs index 9ac01ef648..2de11012ea 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/HostApp/SpeckleModule.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/HostApp/SpeckleModule.cs @@ -62,6 +62,7 @@ private static void Container_PreBuildEvent(object? sender, ContainerBuilder con private static Assembly? OnAssemblyResolve(object? sender, ResolveEventArgs args) { + // POC: dupe code // POC: tight binding to files Assembly? assembly = null; string name = args.Name.Split(',')[0]; diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Send/IRootObjectSender.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Send/IRootObjectSender.cs new file mode 100644 index 0000000000..5acb5eab38 --- /dev/null +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Send/IRootObjectSender.cs @@ -0,0 +1,22 @@ +using Speckle.Core.Models; + +namespace Speckle.Connectors.ArcGis.Operations.Send; + +//poc: duped from rhino + +/// +/// Contract for the send operation that handles an assembled object. +/// In production, this will send to a server. +/// In testing, this could send to a sqlite db or just save to a dictionary. +/// +public interface IRootObjectSender +{ + public Task Send( + Base commitObject, + string accountId, + string projectId, + string modelId, + Action? onOperationProgressed = null, + CancellationToken ct = default + ); +} diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Send/RootObjectBuilder.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Send/RootObjectBuilder.cs new file mode 100644 index 0000000000..daade14483 --- /dev/null +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Send/RootObjectBuilder.cs @@ -0,0 +1,109 @@ +using ArcGIS.Desktop.Mapping; +using Speckle.Connectors.DUI.Bindings; +using Speckle.Core.Models; +using Speckle.Autofac.DependencyInjection; +using Speckle.Converters.Common; +using Speckle.Core.Logging; + +namespace Speckle.Connectors.ArcGis.Operations.Send; + +/// +/// Stateless builder object to turn an into a object +/// +public class RootObjectBuilder +{ + private readonly IScopedFactory _converterFactory; + + public RootObjectBuilder(IScopedFactory converterFactory) + { + _converterFactory = converterFactory; + } + + public Base Build( + //ISendFilter sendFilter, + Action? onOperationProgressed = null, + CancellationToken ct = default + ) + { + if (MapView.Active == null) + { + throw new SpeckleException("No Map currently open"); + } + var selectedObjects = GetSelection(MapView.Active.Map); + + // if (selectedObjects.Count == 0) + // { + // throw new InvalidOperationException("No objects were found. Please update your send filter!"); + // } + + Base commitObject = ConvertObjects(selectedObjects, onOperationProgressed, ct); + + return commitObject; + } + + /// + /// This method must be called on the MCT. Use QueuedTask. Run. + /// + private Dictionary> GetSelection(Map map) + { + // var allMembers = map.GetMapMembersAsFlattenedList(); + + //POC: Right now, we're not using the send filter + // We're still undecided how we handle MapMember vs objectId when converting + // + the ArcGIS api breaks some assumptions we've made + // e.g. + // - There isn't a single type of ID to uniquely identify objects + // - MapMembers are identifiable by uri, but objects on a MapMember have an objectId which is their index in the MapMember + // - plus, some MapMembers work differently (raster layers, voxel layers, pointclound layers) etc. + // - getting selection is an async operation, needs to be done on the main thread, and returns the full object, not just an ID + + var selectedMemberUrls = map.GetSelection().ToDictionary(); + + return selectedMemberUrls; + } + + //poc: semi dupe + private Collection ConvertObjects( + IReadOnlyDictionary> mapMembers, + Action? onOperationProgressed = null, + CancellationToken cancellationToken = default + ) + { + // var rootObjectCollection = new Collection { name = RhinoDoc.ActiveDoc.Name ?? "Unnamed document" }; + int count = 0; + + Collection rootObjectCollection = new(); //TODO: Collections + ISpeckleConverterToSpeckle converter = _converterFactory.ResolveScopedInstance(); + + foreach ((MapMember mapMember, List objectIds) in mapMembers) + { + cancellationToken.ThrowIfCancellationRequested(); + + var collectionHost = rootObjectCollection; + var applicationId = mapMember.ToString(); + + try + { + Base converted = converter.Convert(mapMember); + converted.applicationId = applicationId; + + // add to host + collectionHost.elements.Add(converted); + onOperationProgressed?.Invoke("Converting", (double)++count / mapMembers.Count); + } + // POC: Exception handling on conversion logic must be revisited after several connectors have working conversions + catch (SpeckleConversionException e) + { + // POC: DO something with the exception + Console.WriteLine(e); + } + catch (NotSupportedException e) + { + // POC: DO something with the exception + Console.WriteLine(e); + } + } + + return rootObjectCollection; + } +} diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Send/RootObjectSender.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Send/RootObjectSender.cs new file mode 100644 index 0000000000..a8aa59639c --- /dev/null +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Send/RootObjectSender.cs @@ -0,0 +1,77 @@ +using Speckle.Connectors.Utils.Operations; +using Speckle.Core.Api; +using Speckle.Core.Credentials; +using Speckle.Core.Models; +using Speckle.Core.Transports; + +namespace Speckle.Connectors.ArcGis.Operations.Send; + +//poc: this class is a file paste from rhino + +/// +/// Default implementation of the which takes a and sends +/// it to a server described by the parameters in the method +/// +internal sealed class RootObjectSender : IRootObjectSender +{ + // POC: Revisit this factory pattern, I think we could solve this higher up by injecting a scoped factory for `SendOperation` in the SendBinding + private readonly Func _transportFactory; + + public RootObjectSender(Func transportFactory) + { + _transportFactory = transportFactory; + } + + public async Task Send( + Base commitObject, + string accountId, + string projectId, + string modelId, + Action? onOperationProgressed = null, + CancellationToken ct = default + ) + { + ct.ThrowIfCancellationRequested(); + + onOperationProgressed?.Invoke("Uploading...", null); + + // POC: FETCHING ACCOUNTS BY ID ONLY IS UNSAFE, we should filter by server first, but the server info is not stored on the ModelCard + Account account = + AccountManager.GetAccounts().FirstOrDefault(acc => acc.id == accountId) + ?? throw new SpeckleAccountManagerException(); + + ITransport transport = _transportFactory(account, projectId); + var sendResult = await SendHelper.Send(commitObject, transport, true, null, ct).ConfigureAwait(false); + + ct.ThrowIfCancellationRequested(); + //// Store the converted references in memory for future send operations, overwriting the existing values for the given application id. + //foreach (var kvp in sendResult.ConvertedReferences) + //{ + // // TODO: Bug in here, we need to encapsulate cache not only by app id, but also by project id, + // // TODO: as otherwise we assume incorrectly that an object exists for a given project (e.g, send box to project 1, send same unchanged box to project 2) + // _convertedObjectReferences[kvp.Key + projectId] = kvp.Value; + //} + // It's important to reset the model card's list of changed obj ids so as to ensure we accurately keep track of changes between send operations. + // NOTE: ChangedObjectIds is currently JsonIgnored, but could actually be useful for highlighting changes in host app. + //modelCard.ChangedObjectIds = new(); + + onOperationProgressed?.Invoke("Linking version to model...", null); + + // 8 - Create the version (commit) + using var apiClient = new Client(account); + string versionId = await apiClient + .CommitCreate( + new CommitCreateInput + { + streamId = projectId, + branchName = modelId, + sourceApplication = "ArcGIS", + objectId = sendResult.rootObjId + }, + ct + ) + .ConfigureAwait(true); + + return versionId; + } +} diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Send/SendOperation.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Send/SendOperation.cs new file mode 100644 index 0000000000..db8de913d1 --- /dev/null +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Send/SendOperation.cs @@ -0,0 +1,44 @@ +using ArcGIS.Desktop.Framework.Threading.Tasks; +using Speckle.Core.Models; + +namespace Speckle.Connectors.ArcGis.Operations.Send; + +//POC: This file is a copy-paste from Rhino + +/// +/// Stateless send operation orchestrator. +/// +public sealed class SendOperation +{ + private readonly RootObjectBuilder _baseBuilder; + private readonly IRootObjectSender _baseObjectSender; + + public SendOperation(RootObjectBuilder baseBuilder, IRootObjectSender baseObjectSender) + { + _baseBuilder = baseBuilder; + _baseObjectSender = baseObjectSender; + } + + /// + /// Executes a send operation given information about the host objects and the destination account. + /// + public async Task Execute( + //ISendFilter sendFilter, + string accountId, + string projectId, + string modelId, + Action? onOperationProgressed = null, + CancellationToken ct = default + ) + { + Base commitObject = await QueuedTask.Run(() => _baseBuilder.Build(onOperationProgressed, ct)).ConfigureAwait(false); + + // base object handler is separated so we can do some testing on non-production databases + // exact interface may want to be tweaked when we implement this + string versionId = await _baseObjectSender + .Send(commitObject, accountId, projectId, modelId, onOperationProgressed, ct) + .ConfigureAwait(false); + + return versionId; + } +} diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Speckle.Connectors.ArcGIS3.csproj b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Speckle.Connectors.ArcGIS3.csproj index 9fdb11a9e9..86038a66ee 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Speckle.Connectors.ArcGIS3.csproj +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Speckle.Connectors.ArcGIS3.csproj @@ -9,11 +9,7 @@ enable enable - - - true - - + diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3.DependencyInjection/AutofacArcGIS3ConverterModule.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3.DependencyInjection/AutofacArcGIS3ConverterModule.cs index 68f507e6b2..af28489156 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3.DependencyInjection/AutofacArcGIS3ConverterModule.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3.DependencyInjection/AutofacArcGIS3ConverterModule.cs @@ -12,7 +12,7 @@ public class AutofacArcGISConverterModule : Module protected override void Load(ContainerBuilder builder) { // most things should be InstancePerLifetimeScope so we get one per operation - builder.RegisterType().As(); + builder.RegisterType().As().SingleInstance(); // factory for conversions builder diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3.DependencyInjection/Speckle.Converters.ArcGIS3.DependencyInjection.csproj b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3.DependencyInjection/Speckle.Converters.ArcGIS3.DependencyInjection.csproj index 96bd4d531e..a9485faf13 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3.DependencyInjection/Speckle.Converters.ArcGIS3.DependencyInjection.csproj +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3.DependencyInjection/Speckle.Converters.ArcGIS3.DependencyInjection.csproj @@ -1,9 +1,10 @@ - net6.0 + net6.0-windows enable enable + x64 diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ArcGISConverterToSpeckle.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ArcGISConverterToSpeckle.cs index c0c7ad1405..bc7673b5c9 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ArcGISConverterToSpeckle.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ArcGISConverterToSpeckle.cs @@ -5,6 +5,7 @@ namespace Speckle.Converters.ArcGIS3; +//poc: dupe code from rhino public class ArcGISConverterToSpeckle : ISpeckleConverterToSpeckle { private readonly IFactory _toSpeckle; @@ -16,18 +17,17 @@ public ArcGISConverterToSpeckle(IFactory public Base Convert(object target) { - Type type = typeof(String); + Type type = target.GetType(); try { - var objectConverter = _toSpeckle.ResolveInstance(type.Name); + var objectConverter = _toSpeckle.ResolveInstance(type.Name); //poc: would be nice to have supertypes resolve if (objectConverter == null) { - throw new NotSupportedException($"No conversion found for {target.GetType().Name}"); + throw new NotSupportedException($"No conversion found for {type.Name}"); } - - var convertedObject = objectConverter.Convert("Teststt"); + var convertedObject = objectConverter.Convert(target); return convertedObject; } diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/PointElementToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/PointElementToSpeckleConverter.cs new file mode 100644 index 0000000000..80033512e5 --- /dev/null +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/PointElementToSpeckleConverter.cs @@ -0,0 +1,36 @@ +using ArcGIS.Core.Geometry; +using Speckle.Converters.Common.Objects; +using Speckle.Core.Models; +using Objects.Geometry; +using Objects.GIS; +using ArcGIS.Core.Data; +using Speckle.Converters.Common; + +namespace Speckle.Converters.ArcGIS3.Features; + +[NameAndRankValue(nameof(Row), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +public class PointElementToSpeckleConverter : IHostObjectToSpeckleConversion, IRawConversion +{ + private readonly IRawConversion _pointConverter; + + public PointElementToSpeckleConverter(IRawConversion pointConverter) + { + _pointConverter = pointConverter; + } + + public Base Convert(object target) => RawConvert((Row)target); + + public PointElement RawConvert(Row target) + { + var geometry = new List(); + MapPoint shape = (MapPoint)target["SHAPE"]; + var pt = _pointConverter.RawConvert(shape); + geometry.Add(pt); + + // get attributes + var attributes = new Base(); + // IReadOnlyList fields = target.GetFields(); + + return new PointElement { geometry = geometry, attributes = attributes }; + } +} diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/PointToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/PointToSpeckleConverter.cs new file mode 100644 index 0000000000..5d28dca03a --- /dev/null +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/PointToSpeckleConverter.cs @@ -0,0 +1,15 @@ +using ArcGIS.Core.Geometry; +using Speckle.Converters.Common.Objects; +using Speckle.Core.Models; +using Objects.Geometry; +using Speckle.Converters.Common; + +namespace Speckle.Converters.ArcGIS3.Geometry; + +[NameAndRankValue(nameof(MapPoint), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +internal class PointToSpeckleConverter : IHostObjectToSpeckleConversion, IRawConversion +{ + public Base Convert(object target) => RawConvert((MapPoint)target); + + public Point RawConvert(MapPoint target) => new(target.X, target.Y, target.Z, "m"); +} diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/VectorLayerToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/VectorLayerToSpeckleConverter.cs new file mode 100644 index 0000000000..5f870caee0 --- /dev/null +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/VectorLayerToSpeckleConverter.cs @@ -0,0 +1,67 @@ +using Speckle.Converters.Common.Objects; +using Speckle.Core.Models; +using Objects.GIS; +using Speckle.Converters.Common; +using ArcGIS.Desktop.Mapping; +using ArcGIS.Core.Data; + +namespace Speckle.Converters.ArcGIS3.Layers; + +[NameAndRankValue(nameof(FeatureLayer), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +public class VectorLayerToSpeckleConverter : IHostObjectToSpeckleConversion, IRawConversion +{ + private readonly IRawConversion _pointElementConverter; + + public VectorLayerToSpeckleConverter(IRawConversion pointElementConverter) + { + _pointElementConverter = pointElementConverter; + } + + public Base Convert(object target) + { + return RawConvert((FeatureLayer)target); + } + + public VectorLayer RawConvert(FeatureLayer target) + { + var speckleLayer = new VectorLayer(); + var spatialRef = target.GetSpatialReference(); + speckleLayer.crs = new CRS + { + wkt = spatialRef.Wkt, + name = spatialRef.Name, + units_native = spatialRef.Unit.ToString(), + }; + speckleLayer.name = target.Name; + + //Get the layer's definition + // var lyrDefn = target.GetFeatureClass().GetDefinition(); + //Get the shape field of the feature class + // string shapeField = lyrDefn.GetShapeField(); + //Index of the shape field + // var shapeIndex = lyrDefn.FindField(shapeField); + //Original geometry of the modified row + // .GetOriginalValue(shapeIndex) + + + // search the rows + + // 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 (RowCursor rowCursor = target.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 (Row row = rowCursor.Current) + { + var element = _pointElementConverter.RawConvert(row); + speckleLayer.elements.Add(element); + } + } + + return speckleLayer; + } + } +} diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Speckle.Converters.ArcGIS3.csproj b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Speckle.Converters.ArcGIS3.csproj index 76841eb9fe..ae9ca4baeb 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Speckle.Converters.ArcGIS3.csproj +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Speckle.Converters.ArcGIS3.csproj @@ -1,11 +1,16 @@ - + - - net6.0 - enable - enable - + + net6.0-windows + enable + enable + x64 + + + + + diff --git a/Objects/Converters/ConverterCSI/ConverterETABS/ConverterETABS.csproj b/Objects/Converters/ConverterCSI/ConverterETABS/ConverterETABS.csproj index c075b65c5c..b1db40aaef 100644 --- a/Objects/Converters/ConverterCSI/ConverterETABS/ConverterETABS.csproj +++ b/Objects/Converters/ConverterCSI/ConverterETABS/ConverterETABS.csproj @@ -38,4 +38,4 @@ - \ No newline at end of file + diff --git a/Objects/Objects/GIS/CRS.cs b/Objects/Objects/GIS/CRS.cs new file mode 100644 index 0000000000..39f9e0b327 --- /dev/null +++ b/Objects/Objects/GIS/CRS.cs @@ -0,0 +1,14 @@ +using Speckle.Core.Models; + +namespace Objects.GIS; + +public class CRS : Base +{ + public string? name { get; set; } + public string? authority_id { get; set; } + public string? wkt { get; set; } + public string? units_native { get; set; } + public float? offset_x { get; set; } + public float? offset_y { get; set; } + public float? rotation { get; set; } +} diff --git a/Objects/Objects/GIS/GisTopography.cs b/Objects/Objects/GIS/GisTopography.cs index 37ac571883..8a34ac706a 100644 --- a/Objects/Objects/GIS/GisTopography.cs +++ b/Objects/Objects/GIS/GisTopography.cs @@ -1,17 +1,3 @@ -using System.Collections.Generic; -using Objects.BuiltElements; - namespace Objects.GIS; -public class GisTopography : Topography -{ - public int band_count { get; set; } - public List band_names { get; set; } - public float x_origin { get; set; } - public float y_origin { get; set; } - public int x_size { get; set; } - public int y_size { get; set; } - public float x_resolution { get; set; } - public float y_resolution { get; set; } - public List noDataValue { get; set; } -} +public class GisTopography : RasterElement { } diff --git a/Objects/Objects/GIS/LineElement.cs b/Objects/Objects/GIS/LineElement.cs new file mode 100644 index 0000000000..78af514bfe --- /dev/null +++ b/Objects/Objects/GIS/LineElement.cs @@ -0,0 +1,10 @@ +using System.Collections.Generic; +using Speckle.Core.Models; + +namespace Objects.GIS; + +public class LineElement : Base +{ + public List? geometry { get; set; } + public Base? attributes { get; set; } +} diff --git a/Objects/Objects/GIS/NonGeometryElement.cs b/Objects/Objects/GIS/NonGeometryElement.cs new file mode 100644 index 0000000000..edb67af566 --- /dev/null +++ b/Objects/Objects/GIS/NonGeometryElement.cs @@ -0,0 +1,8 @@ +using Speckle.Core.Models; + +namespace Objects.GIS; + +public class NonGeometryElement : Base +{ + public Base? attributes { get; set; } +} diff --git a/Objects/Objects/GIS/PointElement.cs b/Objects/Objects/GIS/PointElement.cs new file mode 100644 index 0000000000..cb7ffac456 --- /dev/null +++ b/Objects/Objects/GIS/PointElement.cs @@ -0,0 +1,11 @@ +using System.Collections.Generic; +using Objects.Geometry; +using Speckle.Core.Models; + +namespace Objects.GIS; + +public class PointElement : Base +{ + public List? geometry { get; set; } + public Base? attributes { get; set; } +} diff --git a/Objects/Objects/GIS/RasterElement.cs b/Objects/Objects/GIS/RasterElement.cs new file mode 100644 index 0000000000..a47eba0928 --- /dev/null +++ b/Objects/Objects/GIS/RasterElement.cs @@ -0,0 +1,21 @@ +using System.Collections.Generic; +using Objects.Geometry; +using Speckle.Core.Models; + +namespace Objects.GIS; + +public class RasterElement : Base +{ + public int? band_count { get; set; } + public List? band_names { get; set; } + public float? x_origin { get; set; } + public float? y_origin { get; set; } + public int? x_size { get; set; } + public int? y_size { get; set; } + public float? x_resolution { get; set; } + public float? y_resolution { get; set; } + public List? noDataValue { get; set; } + + [DetachProperty] + public List displayValue { get; set; } +} diff --git a/Objects/Objects/GIS/RasterLayer.cs b/Objects/Objects/GIS/RasterLayer.cs new file mode 100644 index 0000000000..b7330d4986 --- /dev/null +++ b/Objects/Objects/GIS/RasterLayer.cs @@ -0,0 +1,18 @@ +using System.Collections.Generic; +using Speckle.Core.Models; + +namespace Objects.GIS; + +public class RasterLayer : Collection +{ + public CRS? crs { get; set; } + public string? units { get; set; } + public CRS? rasterCrs { get; set; } + public string? geomType { get; set; } + public Dictionary? renderer { get; set; } + + public RasterLayer() + { + collectionType = "RasterLayer"; + } +} diff --git a/Objects/Objects/GIS/VectorLayer.cs b/Objects/Objects/GIS/VectorLayer.cs new file mode 100644 index 0000000000..93468d85eb --- /dev/null +++ b/Objects/Objects/GIS/VectorLayer.cs @@ -0,0 +1,18 @@ +using System.Collections.Generic; +using Speckle.Core.Models; + +namespace Objects.GIS; + +public class VectorLayer : Collection +{ + public CRS? crs { get; set; } + public string? units { get; set; } + public Base? attributes { get; set; } + public string? geomType { get; set; } + public Dictionary? renderer { get; set; } + + public VectorLayer() + { + collectionType = "VectorLayer"; + } +} From 3704926a3b5570b2ff3c3a26aed00106ff5df7c9 Mon Sep 17 00:00:00 2001 From: Alan Rynne Date: Fri, 5 Apr 2024 12:41:14 +0200 Subject: [PATCH 020/261] Rework IRawConversion changes in Revit and Common projects (#3259) * fix: RawConversion registration rework * fix: Minor conversion tweaks to get it working again * fix: Relocate raw conversions to their own folder * fix: Warnings regarding using statements * fix: Remove unnecessary using left-over --- .../Plugin/RevitExternalApplication.cs | 3 +- .../Speckle.Converters.Revit2023.csproj | 1 + .../Extensions/ForgeTypeIdExtensions.cs | 1 - .../Helpers/DisplayValueExtractor.cs | 2 - .../Helpers/MeshBuildHelper.cs | 2 - .../Helpers/MeshDataTriangulator.cs | 1 - .../Helpers/ParameterObjectAssigner.cs | 2 - .../Helpers/ParameterValueExtractor.cs | 2 - .../Helpers/RevitCategories.cs | 2 - .../Helpers/RevitCategoryInfo.cs | 3 -- .../Helpers/RevitContext.cs | 1 - .../Helpers/SendSelection.cs | 3 -- .../Helpers/ToSpeckleConvertedObjectsCache.cs | 1 - .../BeamConversionToSpeckle.cs | 24 +++++----- .../ColumnConversionToSpeckle.cs | 48 ++++++++++--------- .../CurveArrayConversionToSpeckle.cs | 6 +-- .../Geometry}/CurveConversionToSpeckle.cs | 7 ++- .../Geometry}/LineConversionToSpeckle.cs | 9 ++-- .../Geometry}/MeshConversionToSpeckle.cs | 18 ++----- .../Raw/Geometry/PointConversionToSpeckle.cs | 18 +++++++ .../Geometry}/SolidsConversionToSpeckle.cs | 17 +++---- .../Geometry}/XyzConversionToPoint.cs | 7 ++- .../LevelConversionToSpeckle.cs | 14 ++---- .../LocationConversionToSpeckle.cs | 18 +++---- .../ParameterConversionToSpeckle.cs | 20 +++----- .../RevitConverterToSpeckle.cs | 40 ++++------------ .../Services/CachingService.cs | 2 - .../Services/ICachingService.cs | 3 -- .../Services/RevitToSpeckleUnitConverter.cs | 1 - .../Speckle.Converters.RevitShared.projitems | 34 ++++++------- .../ToSpeckle/BaseConversionToSpeckle.cs | 28 ++++------- .../ToSpeckle/ElementConversionToSpeckle.cs | 7 ++- .../FamilyInstanceConversionToSpeckle.cs | 24 +++++----- .../ToSpeckle/FloorConversionToSpeckle.cs | 5 +- .../HostedElementConversionToSpeckle.cs | 1 - .../ToSpeckle/PointConversionToSpeckle.cs | 21 -------- .../ToSpeckle/WallConversionToSpeckle.cs | 46 ++++++++---------- .../RawConversionRegisterer.cs | 42 +++++----------- .../Objects/IRawConversion.cs | 9 ---- 39 files changed, 189 insertions(+), 304 deletions(-) rename DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/{ToSpeckle => Raw}/BeamConversionToSpeckle.cs (64%) rename DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/{ToSpeckle => Raw}/ColumnConversionToSpeckle.cs (64%) rename DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/{ToSpeckle => Raw/Geometry}/CurveArrayConversionToSpeckle.cs (85%) rename DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/{ToSpeckle => Raw/Geometry}/CurveConversionToSpeckle.cs (90%) rename DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/{ToSpeckle => Raw/Geometry}/LineConversionToSpeckle.cs (78%) rename DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/{ToSpeckle => Raw/Geometry}/MeshConversionToSpeckle.cs (51%) create mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/PointConversionToSpeckle.cs rename DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/{ToSpeckle => Raw/Geometry}/SolidsConversionToSpeckle.cs (82%) rename DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/{ToSpeckle => Raw/Geometry}/XyzConversionToPoint.cs (79%) rename DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/{ToSpeckle => Raw}/LevelConversionToSpeckle.cs (65%) rename DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/{ToSpeckle => Raw}/LocationConversionToSpeckle.cs (51%) rename DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/{ToSpeckle => Raw}/ParameterConversionToSpeckle.cs (79%) delete mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/PointConversionToSpeckle.cs diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitExternalApplication.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitExternalApplication.cs index 389dda0d4f..94085e2bd6 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitExternalApplication.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitExternalApplication.cs @@ -6,6 +6,7 @@ using System.IO; using Autofac; using Speckle.Converters.Common.DependencyInjection; +using Speckle.Converters.Common.Objects; using Speckle.Core.Logging; namespace Speckle.Connectors.Revit.Plugin; @@ -74,7 +75,7 @@ private void _container_PreBuildEvent(object sender, ContainerBuilder containerB // tbe event can probably go // IRawConversions should be separately injectable (and not Require an IHostObject... or NameAndRank attribute) // Name and Rank can become ConversionRank or something and be optional (otherwise it is rank 0) - containerBuilder.RegisterRawConversions(); + containerBuilder.RegisterRawConversions().InjectNamedTypes(); } public Result OnShutdown(UIControlledApplication application) diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023/Speckle.Converters.Revit2023.csproj b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023/Speckle.Converters.Revit2023.csproj index a647f5a224..b556944923 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023/Speckle.Converters.Revit2023.csproj +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023/Speckle.Converters.Revit2023.csproj @@ -4,6 +4,7 @@ netstandard2.0 x64 enable + enable diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Extensions/ForgeTypeIdExtensions.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Extensions/ForgeTypeIdExtensions.cs index 9dbec0f54e..790e92a07a 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Extensions/ForgeTypeIdExtensions.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Extensions/ForgeTypeIdExtensions.cs @@ -1,4 +1,3 @@ -using System.Linq; using Autodesk.Revit.DB; namespace Speckle.Converters.RevitShared.Extensions; diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/DisplayValueExtractor.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/DisplayValueExtractor.cs index 6f63a852d8..2350dbeef7 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/DisplayValueExtractor.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/DisplayValueExtractor.cs @@ -1,5 +1,3 @@ -using System; -using System.Collections.Generic; using Autodesk.Revit.DB; using Speckle.Converters.Common.Objects; using Speckle.Core.Logging; diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/MeshBuildHelper.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/MeshBuildHelper.cs index fbd7b13dde..05593c36dd 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/MeshBuildHelper.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/MeshBuildHelper.cs @@ -1,5 +1,3 @@ -using System.Collections.Generic; -using System.Linq; using Objects.Geometry; using Objects.Other; diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/MeshDataTriangulator.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/MeshDataTriangulator.cs index 69da1c60b7..c113aa6be4 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/MeshDataTriangulator.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/MeshDataTriangulator.cs @@ -1,4 +1,3 @@ -using System.Collections.Generic; using Objects.Geometry; using Speckle.Converters.Common.Objects; diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/ParameterObjectAssigner.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/ParameterObjectAssigner.cs index a2f2026e61..1f18fd5223 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/ParameterObjectAssigner.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/ParameterObjectAssigner.cs @@ -1,5 +1,3 @@ -using System.Collections.Generic; -using System.Linq; using Autodesk.Revit.DB; using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/ParameterValueExtractor.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/ParameterValueExtractor.cs index b76b158ecb..a6491782b5 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/ParameterValueExtractor.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/ParameterValueExtractor.cs @@ -1,5 +1,3 @@ -using System; -using System.Collections.Generic; using Autodesk.Revit.DB; using Speckle.Converters.Common; using Speckle.Converters.RevitShared.Extensions; diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/RevitCategories.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/RevitCategories.cs index 2cdf1044bb..13e898c47d 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/RevitCategories.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/RevitCategories.cs @@ -1,5 +1,3 @@ -using System; -using System.Collections.Generic; using Autodesk.Revit.DB; namespace Speckle.Converters.RevitShared.Helpers; diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/RevitCategoryInfo.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/RevitCategoryInfo.cs index 82a6b9ff2a..26c13adb66 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/RevitCategoryInfo.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/RevitCategoryInfo.cs @@ -1,6 +1,3 @@ -using System; -using System.Collections.Generic; -using System.Linq; using Autodesk.Revit.DB; namespace Speckle.Converters.RevitShared.Helpers; diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/RevitContext.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/RevitContext.cs index a167d40d70..59c3892a75 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/RevitContext.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/RevitContext.cs @@ -1,4 +1,3 @@ -using System; using Autodesk.Revit.UI; namespace Speckle.Converters.RevitShared.Helpers; diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/SendSelection.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/SendSelection.cs index 80c6625a83..4ed6136418 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/SendSelection.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/SendSelection.cs @@ -1,6 +1,3 @@ -using System.Collections.Generic; -using System.Linq; - namespace Speckle.Converters.RevitShared.Helpers; // POC: why do we need this send selection? diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/ToSpeckleConvertedObjectsCache.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/ToSpeckleConvertedObjectsCache.cs index 5c24d5dae5..bf8a54a384 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/ToSpeckleConvertedObjectsCache.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/ToSpeckleConvertedObjectsCache.cs @@ -1,4 +1,3 @@ -using System.Collections.Generic; using Speckle.Core.Models; namespace Speckle.Converters.RevitShared.Helpers; diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/BeamConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/BeamConversionToSpeckle.cs similarity index 64% rename from DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/BeamConversionToSpeckle.cs rename to DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/BeamConversionToSpeckle.cs index f52cd492a2..a72f9764a5 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/BeamConversionToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/BeamConversionToSpeckle.cs @@ -1,23 +1,25 @@ -using Autodesk.Revit.DB; using Objects; -using Objects.BuiltElements.Revit; using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; using Speckle.Converters.RevitShared.Helpers; +using Speckle.Core.Models; namespace Speckle.Converters.RevitShared.ToSpeckle; +// POC: There is no validation on this converter to prevent conversion from "not a Revit Beam" to a Speckle Beam. +// This will definitely explode if we tried. Goes back to the `CanConvert` functionality conversation. +// As-is, what we are saying is that it can take "any Family Instance" and turn it into a Speckle.RevitBeam, which is far from correct. public class BeamConversionToSpeckle : IRawConversion { - private readonly IRawConversion _locationConverter; - private readonly IRawConversion _levelConverter; + private readonly IRawConversion _locationConverter; + private readonly IRawConversion _levelConverter; private readonly ParameterValueExtractor _parameterValueExtractor; private readonly DisplayValueExtractor _displayValueExtractor; private readonly ParameterObjectAssigner _parameterObjectAssigner; public BeamConversionToSpeckle( - IRawConversion locationConverter, - IRawConversion levelConverter, + IRawConversion locationConverter, + IRawConversion levelConverter, ParameterValueExtractor parameterValueExtractor, DisplayValueExtractor displayValueExtractor, ParameterObjectAssigner parameterObjectAssigner @@ -30,18 +32,18 @@ ParameterObjectAssigner parameterObjectAssigner _parameterObjectAssigner = parameterObjectAssigner; } - public RevitBeam RawConvert(DB.FamilyInstance target) + public SOBR.RevitBeam RawConvert(DB.FamilyInstance target) { - var baseGeometry = _locationConverter.ConvertToBase(target.Location); + var baseGeometry = _locationConverter.RawConvert(target.Location); if (baseGeometry is not ICurve baseCurve) { throw new SpeckleConversionException( $"Beam location conversion did not yield an ICurve, instead it yielded an object of type {baseGeometry.GetType()}" ); } - var symbol = (FamilySymbol)target.Document.GetElement(target.GetTypeId()); + var symbol = (DB.FamilySymbol)target.Document.GetElement(target.GetTypeId()); - RevitBeam speckleBeam = + SOBR.RevitBeam speckleBeam = new() { family = symbol.FamilyName, @@ -51,7 +53,7 @@ public RevitBeam RawConvert(DB.FamilyInstance target) var level = _parameterValueExtractor.GetValueAsDocumentObject( target, - BuiltInParameter.INSTANCE_REFERENCE_LEVEL_PARAM + DB.BuiltInParameter.INSTANCE_REFERENCE_LEVEL_PARAM ); speckleBeam.level = _levelConverter.RawConvert(level); diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/ColumnConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ColumnConversionToSpeckle.cs similarity index 64% rename from DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/ColumnConversionToSpeckle.cs rename to DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ColumnConversionToSpeckle.cs index dcdb98d71b..26a0c48f55 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/ColumnConversionToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ColumnConversionToSpeckle.cs @@ -1,18 +1,17 @@ -using Autodesk.Revit.DB; using Objects; -using Objects.BuiltElements.Revit; using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; using Speckle.Converters.RevitShared.Helpers; -using Line = Objects.Geometry.Line; -using Point = Objects.Geometry.Point; +using Speckle.Core.Models; namespace Speckle.Converters.RevitShared.ToSpeckle; +// POC: There is no validation on this converter to prevent conversion from "not a Revit Beam" to a Speckle Beam. +// This will definitely explode if we tried. Goes back to the `CanConvert` functionality conversation. public class ColumnConversionToSpeckle : IRawConversion { - private readonly IRawConversion _locationConverter; - private readonly IRawConversion _levelConverter; + private readonly IRawConversion _locationConverter; + private readonly IRawConversion _levelConverter; private readonly ParameterValueExtractor _parameterValueExtractor; private readonly DisplayValueExtractor _displayValueExtractor; private readonly RevitConversionContextStack _contextStack; @@ -23,8 +22,8 @@ public class ColumnConversionToSpeckle : IRawConversion locationConverter, - IRawConversion levelConverter, + IRawConversion locationConverter, + IRawConversion levelConverter, ParameterValueExtractor parameterValueExtractor, DisplayValueExtractor displayValueExtractor, RevitConversionContextStack contextStack, @@ -39,11 +38,11 @@ ParameterObjectAssigner parameterObjectAssigner _parameterObjectAssigner = parameterObjectAssigner; } - public RevitColumn RawConvert(DB.FamilyInstance target) + public SOBR.RevitColumn RawConvert(DB.FamilyInstance target) { - var symbol = (FamilySymbol)target.Document.GetElement(target.GetTypeId()); + var symbol = (DB.FamilySymbol)target.Document.GetElement(target.GetTypeId()); - var speckleColumn = new RevitColumn + var speckleColumn = new SOBR.RevitColumn { family = symbol.FamilyName, type = target.Document.GetElement(target.GetTypeId()).Name @@ -51,34 +50,34 @@ public RevitColumn RawConvert(DB.FamilyInstance target) var level = _parameterValueExtractor.GetValueAsDocumentObject( target, - BuiltInParameter.FAMILY_BASE_LEVEL_PARAM + DB.BuiltInParameter.FAMILY_BASE_LEVEL_PARAM ); speckleColumn.level = _levelConverter.RawConvert(level); var topLevel = _parameterValueExtractor.GetValueAsDocumentObject( target, - BuiltInParameter.FAMILY_TOP_LEVEL_PARAM + DB.BuiltInParameter.FAMILY_TOP_LEVEL_PARAM ); speckleColumn.topLevel = _levelConverter.RawConvert(topLevel); speckleColumn.baseOffset = - _parameterValueExtractor.GetValueAsDouble(target, BuiltInParameter.FAMILY_BASE_LEVEL_OFFSET_PARAM) ?? 0; + _parameterValueExtractor.GetValueAsDouble(target, DB.BuiltInParameter.FAMILY_BASE_LEVEL_OFFSET_PARAM) ?? 0; speckleColumn.topOffset = - _parameterValueExtractor.GetValueAsDouble(target, BuiltInParameter.FAMILY_TOP_LEVEL_OFFSET_PARAM) ?? 0; + _parameterValueExtractor.GetValueAsDouble(target, DB.BuiltInParameter.FAMILY_TOP_LEVEL_OFFSET_PARAM) ?? 0; speckleColumn.facingFlipped = target.FacingFlipped; speckleColumn.handFlipped = target.HandFlipped; speckleColumn.isSlanted = target.IsSlantedColumn; //speckleColumn.structural = revitColumn.StructuralType == StructuralType.Column; //geometry - var baseGeometry = _locationConverter.ConvertToBase(target.Location); + var baseGeometry = _locationConverter.RawConvert(target.Location); var baseLine = baseGeometry as ICurve; //make line from point and height - if (baseLine == null && baseGeometry is Point basePoint) + if (baseLine == null && baseGeometry is SOG.Point basePoint) { if ( - symbol.Family.FamilyPlacementType == FamilyPlacementType.OneLevelBased - || symbol.Family.FamilyPlacementType == FamilyPlacementType.WorkPlaneBased + symbol.Family.FamilyPlacementType == DB.FamilyPlacementType.OneLevelBased + || symbol.Family.FamilyPlacementType == DB.FamilyPlacementType.WorkPlaneBased ) { //return RevitInstanceToSpeckle(revitColumn, out notes, null); @@ -86,9 +85,14 @@ public RevitColumn RawConvert(DB.FamilyInstance target) } var elevation = speckleColumn.topLevel.elevation; - baseLine = new Line( + baseLine = new SOG.Line( basePoint, - new Point(basePoint.x, basePoint.y, elevation + speckleColumn.topOffset, _contextStack.Current.SpeckleUnits), + new SOG.Point( + basePoint.x, + basePoint.y, + elevation + speckleColumn.topOffset, + _contextStack.Current.SpeckleUnits + ), _contextStack.Current.SpeckleUnits ); } @@ -103,7 +107,7 @@ public RevitColumn RawConvert(DB.FamilyInstance target) _parameterObjectAssigner.AssignParametersToBase(target, speckleColumn); - if (target.Location is LocationPoint locationPoint) + if (target.Location is DB.LocationPoint locationPoint) { speckleColumn.rotation = locationPoint.Rotation; } diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/CurveArrayConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/CurveArrayConversionToSpeckle.cs similarity index 85% rename from DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/CurveArrayConversionToSpeckle.cs rename to DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/CurveArrayConversionToSpeckle.cs index 8957beb5f7..dd79511d59 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/CurveArrayConversionToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/CurveArrayConversionToSpeckle.cs @@ -1,5 +1,3 @@ -using System.Collections.Generic; -using System.Linq; using Autodesk.Revit.DB; using Objects; using Objects.Geometry; @@ -9,7 +7,7 @@ namespace Speckle.Converters.RevitShared.ToSpeckle; -public sealed class CurveArrayConversionToSpeckle : BaseConversionToSpeckle +public sealed class CurveArrayConversionToSpeckle : IRawConversion { private readonly RevitConversionContextStack _contextStack; private readonly ToSpeckleScalingService _scalingService; @@ -26,7 +24,7 @@ public CurveArrayConversionToSpeckle( _curveConverter = curveConverter; } - public override Polycurve RawConvert(CurveArray target) + public Polycurve RawConvert(CurveArray target) { Polycurve polycurve = new(); diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/CurveConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/CurveConversionToSpeckle.cs similarity index 90% rename from DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/CurveConversionToSpeckle.cs rename to DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/CurveConversionToSpeckle.cs index e53bc774a7..44900b6208 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/CurveConversionToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/CurveConversionToSpeckle.cs @@ -1,11 +1,10 @@ +using Objects; using Speckle.Converters.Common.Objects; using Speckle.Converters.Common; -using Objects; namespace Speckle.Converters.RevitShared.ToSpeckle; -[NameAndRankValue(nameof(DB.Curve), 0)] -public class CurveConversionToSpeckle : BaseConversionToSpeckle +public class CurveConversionToSpeckle : IRawConversion { // POC: can we do this sort of thing? // Can this converter be made generic to make a ConverterFetcher? and be used @@ -24,7 +23,7 @@ public CurveConversionToSpeckle(IRawConversion lineConverter) _lineConverter = lineConverter; } - public override ICurve RawConvert(DB.Curve target) + public ICurve RawConvert(DB.Curve target) { // POC: and then here: // if (_curveConverters.TryGetValue(target.GetType().Name, out IRawConversion converter)) diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/LineConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/LineConversionToSpeckle.cs similarity index 78% rename from DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/LineConversionToSpeckle.cs rename to DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/LineConversionToSpeckle.cs index dbb642295d..e920ab5632 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/LineConversionToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/LineConversionToSpeckle.cs @@ -1,14 +1,11 @@ -using Autodesk.Revit.DB; using Objects.Primitive; -using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; using Speckle.Converters.RevitShared.Helpers; using Speckle.Converters.RevitShared.Services; namespace Speckle.Converters.RevitShared.ToSpeckle; -[NameAndRankValue(nameof(DB.Line), 0)] -public class LineConversionToSpeckle : BaseConversionToSpeckle +public class LineConversionToSpeckle : IRawConversion { private readonly RevitConversionContextStack _contextStack; private readonly IRawConversion _xyzToPointConverter; @@ -16,7 +13,7 @@ public class LineConversionToSpeckle : BaseConversionToSpeckle xyzToPointConverter, + IRawConversion xyzToPointConverter, ToSpeckleScalingService scalingService ) { @@ -25,7 +22,7 @@ ToSpeckleScalingService scalingService _scalingService = scalingService; } - public override SOG.Line RawConvert(DB.Line target) + public SOG.Line RawConvert(DB.Line target) { return new() { diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/MeshConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/MeshConversionToSpeckle.cs similarity index 51% rename from DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/MeshConversionToSpeckle.cs rename to DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/MeshConversionToSpeckle.cs index 546f7b6bfd..a9cb34effc 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/MeshConversionToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/MeshConversionToSpeckle.cs @@ -1,30 +1,20 @@ -using System.Collections.Generic; -using Objects.Geometry; -using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; using Speckle.Converters.RevitShared.Helpers; namespace Speckle.Converters.RevitShared.ToSpeckle; -[NameAndRankValue(nameof(List), 0)] -public class MeshConversionToSpeckle : BaseConversionToSpeckle, List> +public class MeshConversionToSpeckle : IRawConversion, List> { private readonly RevitConversionContextStack _contextStack; - private readonly IRawConversion _xyzToPointConverter; private readonly MeshDataTriangulator _meshDataTriangulator; - public MeshConversionToSpeckle( - RevitConversionContextStack contextStack, - IRawConversion xyzToPointConverter, - MeshDataTriangulator meshDataTriangulator - ) + public MeshConversionToSpeckle(RevitConversionContextStack contextStack, MeshDataTriangulator meshDataTriangulator) { _contextStack = contextStack; - _xyzToPointConverter = xyzToPointConverter; _meshDataTriangulator = meshDataTriangulator; } - public override List RawConvert(List target) + public List RawConvert(List target) { // POC: should be injected MeshBuildHelper buildHelper = new(); @@ -32,7 +22,7 @@ MeshDataTriangulator meshDataTriangulator foreach (var mesh in target) { var revitMaterial = (DB.Material)_contextStack.Current.Document.Document.GetElement(mesh.MaterialElementId); - Mesh speckleMesh = buildHelper.GetOrCreateMesh(revitMaterial, _contextStack.Current.SpeckleUnits); + SOG.Mesh speckleMesh = buildHelper.GetOrCreateMesh(revitMaterial, _contextStack.Current.SpeckleUnits); _meshDataTriangulator.Triangulate(mesh, speckleMesh.faces, speckleMesh.vertices); } diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/PointConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/PointConversionToSpeckle.cs new file mode 100644 index 0000000000..4e9c4efe6e --- /dev/null +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/PointConversionToSpeckle.cs @@ -0,0 +1,18 @@ +using Speckle.Converters.Common.Objects; + +namespace Speckle.Converters.RevitShared.ToSpeckle; + +public class PointConversionToSpeckle : IRawConversion +{ + private readonly IRawConversion _xyzToPointConverter; + + public PointConversionToSpeckle(IRawConversion xyzToPointConverter) + { + _xyzToPointConverter = xyzToPointConverter; + } + + public SOG.Point RawConvert(DB.Point target) + { + return _xyzToPointConverter.RawConvert(target.Coord); + } +} diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/SolidsConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/SolidsConversionToSpeckle.cs similarity index 82% rename from DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/SolidsConversionToSpeckle.cs rename to DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/SolidsConversionToSpeckle.cs index e60d651890..48b30339df 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/SolidsConversionToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/SolidsConversionToSpeckle.cs @@ -1,16 +1,13 @@ -using System.Collections.Generic; -using Autodesk.Revit.DB; using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; using Speckle.Converters.RevitShared.Helpers; -using Mesh = Objects.Geometry.Mesh; namespace Speckle.Converters.RevitShared.ToSpeckle; // POC: do we need to have this atm? // why do we need a List, do we encounter these in the converter logic? // it looks wrong here or perhaps the List is coming from the connector? -[NameAndRankValue(nameof(List), 0)] -public class SolidsConversionToSpeckle : BaseConversionToSpeckle, List> +public class SolidsConversionToSpeckle : IRawConversion, List> { private readonly RevitConversionContextStack _contextStack; private readonly MeshDataTriangulator _meshDataTriangulator; @@ -22,14 +19,14 @@ public SolidsConversionToSpeckle(RevitConversionContextStack contextStack, MeshD } // POC: this is converting and caching and using the cache and some of it is a bit questionable - public override List RawConvert(List target) + public List RawConvert(List target) { MeshBuildHelper meshBuildHelper = new(); - var meshMap = new Dictionary>(); - foreach (Solid solid in target) + var meshMap = new Dictionary>(); + foreach (DB.Solid solid in target) { - foreach (Face face in solid.Faces) + foreach (DB.Face face in solid.Faces) { // POC: throwing here? Just review. Is it necessary armouring against Revit APU weirdness? // do direct cast (DB.Material) instead of as and then no need to throw, it will throw naturally @@ -39,7 +36,7 @@ public override List RawConvert(List target) ?? throw new SpeckleConversionException("Unable to cast face's materialElementId element to DB.Material"); // POC: this logic, relationship between material and mesh, seems wrong - Mesh m = meshBuildHelper.GetOrCreateMesh(faceMaterial, _contextStack.Current.SpeckleUnits); + SOG.Mesh m = meshBuildHelper.GetOrCreateMesh(faceMaterial, _contextStack.Current.SpeckleUnits); if (!meshMap.TryGetValue(m, out List? value)) { value = new List(); diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/XyzConversionToPoint.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/XyzConversionToPoint.cs similarity index 79% rename from DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/XyzConversionToPoint.cs rename to DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/XyzConversionToPoint.cs index a19ab64642..1dd5b7185c 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/XyzConversionToPoint.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/XyzConversionToPoint.cs @@ -1,11 +1,10 @@ -using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; using Speckle.Converters.RevitShared.Helpers; using Speckle.Converters.RevitShared.Services; namespace Speckle.Converters.RevitShared.ToSpeckle; -[NameAndRankValue(nameof(DB.XYZ), 0)] -public class XyzConversionToPoint : BaseConversionToSpeckle +public class XyzConversionToPoint : IRawConversion { private readonly ToSpeckleScalingService _toSpeckleScalingService; private readonly RevitConversionContextStack _contextStack; @@ -16,7 +15,7 @@ public XyzConversionToPoint(ToSpeckleScalingService toSpeckleScalingService, Rev _contextStack = contextStack; } - public override SOG.Point RawConvert(DB.XYZ target) + public SOG.Point RawConvert(DB.XYZ target) { var pointToSpeckle = new SOG.Point( _toSpeckleScalingService.ScaleLength(target.X), diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/LevelConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/LevelConversionToSpeckle.cs similarity index 65% rename from DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/LevelConversionToSpeckle.cs rename to DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/LevelConversionToSpeckle.cs index 91cdc50c77..79449c0956 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/LevelConversionToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/LevelConversionToSpeckle.cs @@ -1,13 +1,9 @@ -using Objects.BuiltElements.Revit; -using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; using Speckle.Converters.RevitShared.Services; namespace Speckle.Converters.RevitShared.ToSpeckle; -public class LevelConverter { } - -[NameAndRankValue(nameof(DB.Level), 0)] -public class LevelConversionToSpeckle : BaseConversionToSpeckle +public class LevelConversionToSpeckle : IRawConversion { private readonly CachingService _cachingService; private readonly ToSpeckleScalingService _scalingService; @@ -18,14 +14,14 @@ public LevelConversionToSpeckle(CachingService cachingService, ToSpeckleScalingS _scalingService = scalingService; } - public override RevitLevel RawConvert(DB.Level target) + public SOBR.RevitLevel RawConvert(DB.Level target) { return _cachingService.GetOrAdd(target.UniqueId, () => CreateSpeckleRevitLevel(target)); } - private RevitLevel CreateSpeckleRevitLevel(DB.Level level) + private SOBR.RevitLevel CreateSpeckleRevitLevel(DB.Level level) { - var speckleLevel = new RevitLevel + var speckleLevel = new SOBR.RevitLevel { elevation = _scalingService.ScaleLength(level.Elevation), name = level.Name, diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/LocationConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/LocationConversionToSpeckle.cs similarity index 51% rename from DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/LocationConversionToSpeckle.cs rename to DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/LocationConversionToSpeckle.cs index 8d300806d1..65692ed677 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/LocationConversionToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/LocationConversionToSpeckle.cs @@ -1,31 +1,33 @@ -using Autodesk.Revit.DB; +using Objects; using Speckle.Converters.Common.Objects; using Speckle.Converters.Common; using Speckle.Core.Models; namespace Speckle.Converters.RevitShared.ToSpeckle; -[NameAndRankValue(nameof(DB.Location), 0)] -public class LocationConversionToSpeckle : BaseConversionToSpeckle +public class LocationConversionToSpeckle : IRawConversion { - private readonly IRawConversion _curveConverter; + private readonly IRawConversion _curveConverter; private readonly IRawConversion _xyzConverter; // POC: review IRawConversion which always returns a Base, this is ToSpeckle, so... this breaks // the meaning of IRawConversion, it could be IToSpeckleRawConversion // also a factory type - public LocationConversionToSpeckle(IRawConversion curveConverter, IRawConversion xyzConverter) + public LocationConversionToSpeckle( + IRawConversion curveConverter, + IRawConversion xyzConverter + ) { _curveConverter = curveConverter; _xyzConverter = xyzConverter; } - public override Base RawConvert(DB.Location target) + public Base RawConvert(DB.Location target) { return target switch { - LocationCurve curve => _curveConverter.ConvertToBase(curve.Curve), - LocationPoint point => _xyzConverter.RawConvert(point.Point), + DB.LocationCurve curve => (_curveConverter.RawConvert(curve.Curve) as Base)!, // POC: ICurve and Base are not related but we know they must be, had to soft cast and then !. + DB.LocationPoint point => _xyzConverter.RawConvert(point.Point), _ => throw new SpeckleConversionException($"Unexpected location type {target.GetType()}") }; } diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/ParameterConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ParameterConversionToSpeckle.cs similarity index 79% rename from DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/ParameterConversionToSpeckle.cs rename to DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ParameterConversionToSpeckle.cs index b2435eb057..77a4cd1b4a 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/ParameterConversionToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ParameterConversionToSpeckle.cs @@ -1,30 +1,22 @@ -using Autodesk.Revit.DB; -using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; using Speckle.Converters.RevitShared.Extensions; using Speckle.Converters.RevitShared.Helpers; using Speckle.Converters.RevitShared.Services; namespace Speckle.Converters.RevitShared.ToSpeckle; -[NameAndRankValue(nameof(Parameter), 0)] -public class ParameterConversionToSpeckle : BaseConversionToSpeckle +public class ParameterConversionToSpeckle : IRawConversion { - private readonly ToSpeckleScalingService _scalingService; private readonly ParameterValueExtractor _valueExtractor; private readonly CachingService _cachingService; - public ParameterConversionToSpeckle( - ToSpeckleScalingService scalingService, - ParameterValueExtractor valueExtractor, - CachingService cachingService - ) + public ParameterConversionToSpeckle(ParameterValueExtractor valueExtractor, CachingService cachingService) { - _scalingService = scalingService; _valueExtractor = valueExtractor; _cachingService = cachingService; } - public override SOBR.Parameter RawConvert(DB.Parameter target) + public SOBR.Parameter RawConvert(DB.Parameter target) { string internalName = target.GetInternalName(); ParameterToSpeckleData toSpeckleData = _cachingService.GetOrAdd( @@ -50,9 +42,9 @@ private ParameterToSpeckleData ExtractParameterDataFromDocument(string paramInte }; // POC: why is this specialisation needed? Could there be more? - if (parameter.StorageType == StorageType.Double) + if (parameter.StorageType == DB.StorageType.Double) { - ForgeTypeId unitTypeId = parameter.GetUnitTypeId(); + DB.ForgeTypeId unitTypeId = parameter.GetUnitTypeId(); newParamData.UnitsSymbol = unitTypeId.GetSymbol(); newParamData.ApplicationUnits = unitTypeId.ToUniqueString(); } diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/RevitConverterToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/RevitConverterToSpeckle.cs index 341ca1201f..413a3ac2a3 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/RevitConverterToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/RevitConverterToSpeckle.cs @@ -1,9 +1,8 @@ -using Autofac.Features.Indexed; -using System; using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; using Speckle.Core.Models; using Autodesk.Revit.DB; +using Speckle.Autofac.DependencyInjection; using Speckle.Converters.RevitShared.Helpers; namespace Speckle.Converters.RevitShared; @@ -11,17 +10,17 @@ namespace Speckle.Converters.RevitShared; // POC: maybe possible to restrict the access so this cannot be created directly? public class RevitConverterToSpeckle : ISpeckleConverterToSpeckle { - private readonly IIndex _hostObjectConversions; + private readonly IFactory _toSpeckle; private readonly ToSpeckleConvertedObjectsCache _convertedObjectsCache; private readonly ParameterValueExtractor _parameterValueExtractor; public RevitConverterToSpeckle( - IIndex hostObjectConversions, + IFactory toSpeckle, ToSpeckleConvertedObjectsCache convertedObjectsCache, ParameterValueExtractor parameterValueExtractor ) { - _hostObjectConversions = hostObjectConversions; + _toSpeckle = toSpeckle; _convertedObjectsCache = convertedObjectsCache; _parameterValueExtractor = parameterValueExtractor; } @@ -30,9 +29,12 @@ ParameterValueExtractor parameterValueExtractor // if it cannot be converted then we should throw public Base Convert(object target) { - var objectConverter = - RetrieveObjectConversion(target.GetType()) - ?? throw new SpeckleConversionException($"Could not find conversion for object of type {target.GetType()}"); + var objectConverter = _toSpeckle.ResolveInstance(target.GetType().Name); + + if (objectConverter == null) + { + throw new NotSupportedException($"No conversion found for {target.GetType().Name}"); + } Base result = objectConverter.Convert(target) @@ -47,26 +49,4 @@ public Base Convert(object target) return result; } - - // POC: we should try to de-couple raw object conversion and paramater scraping so they can happen.. - // "yeah, I'm wondering if we can make conversion "pipelines" or something - // like that where we could add all the Wall properties like length and height - // and then continue passing the object down to more generic conversions that - // could add more generic info like parameters or display value." - // - // We need to look for the commonality... - // "I think it's achievable and makes more sense than having to add parameters on every conversion" - private IHostObjectToSpeckleConversion? RetrieveObjectConversion(Type objectType) - { - if (_hostObjectConversions.TryGetValue(objectType, out var conversion)) - { - return conversion; - } - - if (objectType.BaseType == typeof(object)) - { - return null; - } - return RetrieveObjectConversion(objectType.BaseType); - } } diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Services/CachingService.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Services/CachingService.cs index 0ce34837a5..812d0073ac 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Services/CachingService.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Services/CachingService.cs @@ -1,5 +1,3 @@ -using System; -using System.Collections.Generic; using System.Collections; namespace Speckle.Converters.RevitShared.Services; diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Services/ICachingService.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Services/ICachingService.cs index e17b6d2f11..86f14cd4ea 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Services/ICachingService.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Services/ICachingService.cs @@ -1,6 +1,3 @@ -using System; -using System.Collections.Generic; - namespace Speckle.Converters.RevitShared.Services; internal interface ICachingService diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Services/RevitToSpeckleUnitConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Services/RevitToSpeckleUnitConverter.cs index 3215cc2890..6fe01ccbaf 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Services/RevitToSpeckleUnitConverter.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Services/RevitToSpeckleUnitConverter.cs @@ -1,4 +1,3 @@ -using System.Collections.Generic; using Speckle.Converters.Common; using Speckle.Core.Kits; using Speckle.Core.Logging; diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Speckle.Converters.RevitShared.projitems b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Speckle.Converters.RevitShared.projitems index 1a453a15c7..06aa00ddca 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Speckle.Converters.RevitShared.projitems +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Speckle.Converters.RevitShared.projitems @@ -17,36 +17,36 @@ - + + + + + + + + + + + + + + - - - - + - + - - - - - - - - - - - \ No newline at end of file + diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/BaseConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/BaseConversionToSpeckle.cs index 63ac32e849..afe0706ae2 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/BaseConversionToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/BaseConversionToSpeckle.cs @@ -1,4 +1,3 @@ -using System.Collections.Generic; using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; using Speckle.Core.Models; @@ -8,30 +7,21 @@ namespace Speckle.Converters.RevitShared.ToSpeckle; // POC: maybe but could be generic abstract Converters.Common? public abstract class BaseConversionToSpeckle : IHostObjectToSpeckleConversion, - IRawConversion, IRawConversion - where TSpeckle : notnull + where TSpeckle : Base { public Base Convert(object target) { - return ConvertToBase((THost)target); - } + var result = RawConvert((THost)target); + if (result is not Base @base) + { + throw new SpeckleConversionException( + $"Expected resulting object to be {typeof(Base)} but was {result.GetType()}" + ); + } - public Base ConvertToBase(THost target) - { - TSpeckle conversionResult = RawConvert(target); - return conversionResult as Base - ?? throw new SpeckleConversionException($"Unable to cast conversion result of type {conversionResult.GetType()}"); + return @base; } public abstract TSpeckle RawConvert(THost target); - - // POC: this isn't even used, needs review, not sure we need it atm? - public IEnumerable RawConvertMany(IEnumerable target) - { - foreach (var targetItem in target) - { - yield return RawConvert(targetItem); - } - } } diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/ElementConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/ElementConversionToSpeckle.cs index 2a76d5b978..ac3a9fd795 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/ElementConversionToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/ElementConversionToSpeckle.cs @@ -1,4 +1,3 @@ -using Autodesk.Revit.DB; using Speckle.Converters.Common; using Objects.BuiltElements.Revit; using Speckle.Converters.RevitShared.Helpers; @@ -6,7 +5,7 @@ namespace Speckle.Converters.RevitShared.ToSpeckle; // POC: not currently used? clearly some missing pieces -[NameAndRankValue(nameof(Element), 0)] +[NameAndRankValue(nameof(DB.Element), 0)] public class ElementConversionToSpeckle : BaseConversionToSpeckle { private readonly DisplayValueExtractor _displayValueExtractor; @@ -16,11 +15,11 @@ public ElementConversionToSpeckle(DisplayValueExtractor displayValueExtractor) _displayValueExtractor = displayValueExtractor; } - public override RevitElement RawConvert(Element target) + public override RevitElement RawConvert(DB.Element target) { RevitElement speckleElement = new(); - if (target.Document.GetElement(target.GetTypeId()) is FamilySymbol symbol) + if (target.Document.GetElement(target.GetTypeId()) is DB.FamilySymbol symbol) { speckleElement.family = symbol.FamilyName; speckleElement.type = symbol.Name; diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/FamilyInstanceConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/FamilyInstanceConversionToSpeckle.cs index b2cfea05ad..466e95fa39 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/FamilyInstanceConversionToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/FamilyInstanceConversionToSpeckle.cs @@ -1,24 +1,24 @@ -using Autodesk.Revit.DB; -using Autodesk.Revit.DB.Structure; +using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; -using Speckle.Converters.RevitShared.Extensions; using Speckle.Converters.RevitShared.Helpers; using Speckle.Core.Models; +using Speckle.Converters.RevitShared.Extensions; namespace Speckle.Converters.RevitShared.ToSpeckle; // POC: bin for now? This is also a parent child relationship and may need a pattern for this // so we don't end up with some god FamilyInstanceConversionToSpeckle converter +[NameAndRankValue(nameof(DB.FamilyInstance), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] public sealed class FamilyInstanceConversionToSpeckle : BaseConversionToSpeckle { - private readonly IRawConversion _elementConverter; + private readonly IRawConversion _elementConverter; private readonly IRawConversion _beamConverter; private readonly IRawConversion _columnConverter; public FamilyInstanceConversionToSpeckle( - IRawConversion elementConverter, - IRawConversion beamConverter, - IRawConversion columnConverter + IRawConversion elementConverter, + IRawConversion beamConverter, + IRawConversion columnConverter ) { _elementConverter = elementConverter; @@ -26,7 +26,7 @@ public FamilyInstanceConversionToSpeckle( _columnConverter = columnConverter; } - public override Base RawConvert(FamilyInstance target) + public override Base RawConvert(DB.FamilyInstance target) { Base? @base = null; @@ -71,11 +71,11 @@ public override Base RawConvert(FamilyInstance target) //beams & braces if (RevitCategories.StructuralFraming.BuiltInCategories.Contains(target.Category.GetBuiltInCategory())) { - if (target.StructuralType == StructuralType.Beam) + if (target.StructuralType == DB.Structure.StructuralType.Beam) { @base = _beamConverter.RawConvert(target); } - else if (target.StructuralType == StructuralType.Brace) + else if (target.StructuralType == DB.Structure.StructuralType.Brace) { //@base = BraceToSpeckle(target, out notes); } @@ -85,7 +85,7 @@ public override Base RawConvert(FamilyInstance target) if ( @base == null && RevitCategories.StructuralFraming.BuiltInCategories.Contains(target.Category.GetBuiltInCategory()) - || target.StructuralType == StructuralType.Column + || target.StructuralType == DB.Structure.StructuralType.Column ) { @base = _columnConverter.RawConvert(target); @@ -117,7 +117,7 @@ public override Base RawConvert(FamilyInstance target) // @base = RevitInstanceToSpeckle(target, out notes, null); //} - @base ??= _elementConverter.ConvertToBase(target); + @base ??= _elementConverter.RawConvert(target); //// add additional props to base object //if (isUGridLine.HasValue) diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/FloorConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/FloorConversionToSpeckle.cs index a22fb5034b..93699c65e8 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/FloorConversionToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/FloorConversionToSpeckle.cs @@ -1,4 +1,3 @@ -using Autodesk.Revit.DB; using Speckle.Converters.Common.Objects; using Speckle.Core.Models; @@ -9,8 +8,8 @@ namespace Speckle.Converters.Common; // having a lack of interfaces or large interfaces is a bit like lacking structure, when all of your stuff, your classes & methods // clould be anywhere or all in once place - rooting through box 274 for something you need, when said box has a miriad different // and unrelated items, is no fun. Plus when you need that item, you end up bringing out the whole box/ -[NameAndRankValue(nameof(Floor), 0)] +[NameAndRankValue(nameof(DB.Floor), 0)] public class FloorConversionToSpeckle : IHostObjectToSpeckleConversion { - public Base Convert(object target) => throw new System.NotImplementedException(); + public Base Convert(object target) => throw new NotImplementedException(); } diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/HostedElementConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/HostedElementConversionToSpeckle.cs index 89bed3586e..7d2b61fe15 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/HostedElementConversionToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/HostedElementConversionToSpeckle.cs @@ -1,4 +1,3 @@ -using System.Collections.Generic; using Autodesk.Revit.DB; using Speckle.Converters.Common; using Speckle.Converters.RevitShared.Helpers; diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/PointConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/PointConversionToSpeckle.cs deleted file mode 100644 index 90a655418f..0000000000 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/PointConversionToSpeckle.cs +++ /dev/null @@ -1,21 +0,0 @@ -using Speckle.Converters.Common; -using Autodesk.Revit.DB; -using Speckle.Converters.Common.Objects; - -namespace Speckle.Converters.RevitShared.ToSpeckle; - -[NameAndRankValue(nameof(DB.Point), 0)] -public class PointConversionToSpeckle : BaseConversionToSpeckle -{ - private readonly IRawConversion _xyzToPointConverter; - - public PointConversionToSpeckle(IRawConversion xyzToPointConverter) - { - _xyzToPointConverter = xyzToPointConverter; - } - - public override SOG.Point RawConvert(Point target) - { - return _xyzToPointConverter.RawConvert(target.Coord); - } -} diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/WallConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/WallConversionToSpeckle.cs index 03c6823a67..69411511e3 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/WallConversionToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/WallConversionToSpeckle.cs @@ -1,12 +1,7 @@ using Speckle.Converters.Common.Objects; using Speckle.Converters.Common; -using Objects.BuiltElements.Revit; -using Autodesk.Revit.DB; using Objects; using Speckle.Converters.RevitShared.Helpers; -using System.Collections.Generic; -using System.Linq; -using Objects.Geometry; using Speckle.Core.Models; using Speckle.Core.Models.Extensions; @@ -15,10 +10,10 @@ namespace Speckle.Converters.RevitShared.ToSpeckle; // POC: needs review feels, BIG, feels like it could be broken down.. // i.e. GetParams(), GetGeom()? feels like it's doing too much [NameAndRankValue(nameof(DB.Wall), 0)] -public class WallConversionToSpeckle : BaseConversionToSpeckle +public class WallConversionToSpeckle : BaseConversionToSpeckle { private readonly IRawConversion _curveConverter; - private readonly IRawConversion _levelConverter; + private readonly IRawConversion _levelConverter; private readonly IRawConversion _curveArrayConverter; private readonly ParameterValueExtractor _parameterValueExtractor; private readonly RevitConversionContextStack _contextStack; @@ -28,11 +23,11 @@ public class WallConversionToSpeckle : BaseConversionToSpeckle curveConverter, - IRawConversion levelConverter, + IRawConversion levelConverter, RevitConversionContextStack contextStack, ParameterValueExtractor parameterValueExtractor, DisplayValueExtractor displayValueExtractor, - IRawConversion curveArrayConverter, + IRawConversion curveArrayConverter, HostedElementConversionToSpeckle hostedElementConverter, ParameterObjectAssigner parameterObjectAssigner ) @@ -47,11 +42,11 @@ ParameterObjectAssigner parameterObjectAssigner _parameterObjectAssigner = parameterObjectAssigner; } - public override RevitWall RawConvert(DB.Wall target) + public override SOBR.RevitWall RawConvert(DB.Wall target) { - RevitWall speckleWall = new() { family = target.WallType.FamilyName.ToString(), type = target.WallType.Name }; + SOBR.RevitWall speckleWall = new() { family = target.WallType.FamilyName.ToString(), type = target.WallType.Name }; - if (target.Location is not LocationCurve locationCurve) + if (target.Location is not DB.LocationCurve locationCurve) { throw new SpeckleConversionException( "Incorrect assumption was made that all Revit Wall location properties would be of type \"LocationCurve\"" @@ -62,23 +57,24 @@ public override RevitWall RawConvert(DB.Wall target) var level = _parameterValueExtractor.GetValueAsDocumentObject( target, - BuiltInParameter.WALL_BASE_CONSTRAINT + DB.BuiltInParameter.WALL_BASE_CONSTRAINT ); speckleWall.level = _levelConverter.RawConvert(level); var topLevel = _parameterValueExtractor.GetValueAsDocumentObject( target, - BuiltInParameter.WALL_BASE_CONSTRAINT + DB.BuiltInParameter.WALL_BASE_CONSTRAINT ); speckleWall.topLevel = _levelConverter.RawConvert(topLevel); // POC : what to do if these parameters are unset (instead of assigning default) speckleWall.height = - _parameterValueExtractor.GetValueAsDouble(target, BuiltInParameter.WALL_USER_HEIGHT_PARAM) ?? 0; - speckleWall.baseOffset = _parameterValueExtractor.GetValueAsDouble(target, BuiltInParameter.WALL_BASE_OFFSET) ?? 0; - speckleWall.topOffset = _parameterValueExtractor.GetValueAsDouble(target, BuiltInParameter.WALL_TOP_OFFSET) ?? 0; + _parameterValueExtractor.GetValueAsDouble(target, DB.BuiltInParameter.WALL_USER_HEIGHT_PARAM) ?? 0; + speckleWall.baseOffset = + _parameterValueExtractor.GetValueAsDouble(target, DB.BuiltInParameter.WALL_BASE_OFFSET) ?? 0; + speckleWall.topOffset = _parameterValueExtractor.GetValueAsDouble(target, DB.BuiltInParameter.WALL_TOP_OFFSET) ?? 0; speckleWall.structural = - _parameterValueExtractor.GetValueAsBool(target, BuiltInParameter.WALL_STRUCTURAL_SIGNIFICANT) ?? false; + _parameterValueExtractor.GetValueAsBool(target, DB.BuiltInParameter.WALL_STRUCTURAL_SIGNIFICANT) ?? false; speckleWall.flipped = target.Flipped; speckleWall.displayValue = _displayValueExtractor.GetDisplayValue(target); @@ -92,7 +88,7 @@ public override RevitWall RawConvert(DB.Wall target) } // POC: not sure - private void AssignHostedElements(Wall target, RevitWall speckleWall) + private void AssignHostedElements(DB.Wall target, SOBR.RevitWall speckleWall) { List hostedObjects = _hostedElementConverter.GetHostedElementsConverted(target); if (hostedObjects.Count > 0) @@ -108,10 +104,10 @@ private void AssignHostedElements(Wall target, RevitWall speckleWall) } } - private void AssignVoids(Wall target, RevitWall speckleWall) + private void AssignVoids(DB.Wall target, SOBR.RevitWall speckleWall) { - List voids = GetWallVoids(target); - List polycurves = voids.Select(v => _curveArrayConverter.RawConvert(v)).ToList(); + List voids = GetWallVoids(target); + List polycurves = voids.Select(v => _curveArrayConverter.RawConvert(v)).ToList(); if (polycurves.Count > 0) { @@ -119,10 +115,10 @@ private void AssignVoids(Wall target, RevitWall speckleWall) } } - private List GetWallVoids(Wall wall) + private List GetWallVoids(DB.Wall wall) { - List curveArrays = new(); - var profile = ((Sketch)_contextStack.Current.Document.Document.GetElement(wall.SketchId))?.Profile; + List curveArrays = new(); + var profile = ((DB.Sketch)_contextStack.Current.Document.Document.GetElement(wall.SketchId))?.Profile; if (profile == null) { diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/RawConversionRegisterer.cs b/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/RawConversionRegisterer.cs index 05bdda19b4..9b07c65a97 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/RawConversionRegisterer.cs +++ b/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/RawConversionRegisterer.cs @@ -12,46 +12,28 @@ public static ContainerBuilder RegisterRawConversions(this ContainerBuilder cont // POC: hard-coding speckle... :/ foreach (var asm in AppDomain.CurrentDomain.GetAssemblies().Where(x => x.GetName().Name.StartsWith("Speckle"))) { - foreach (var type in asm.GetTypes().Where(t => t.IsClass && !t.IsAbstract)) + foreach (var type in asm.GetTypes()) { - if (GetImplementedRawConversionType(type) is not Type interfaceType) - { - continue; - } - - var registrationBuilder = containerBuilder.RegisterType(type).As(interfaceType); - - Type firstGenericType = interfaceType.GenericTypeArguments[0]; - var singleParamRawConversionType = typeof(IRawConversion<>).MakeGenericType(firstGenericType); - if (singleParamRawConversionType.IsAssignableFrom(type)) - { - registrationBuilder = registrationBuilder.As(singleParamRawConversionType); - } - - if (typeof(IHostObjectToSpeckleConversion).IsAssignableFrom(type)) - { - registrationBuilder = registrationBuilder - .As() - .Keyed(firstGenericType); - } - - registrationBuilder.InstancePerLifetimeScope(); + RegisterRawConversionsForType(containerBuilder, type); } } return containerBuilder; } - public static Type? GetImplementedRawConversionType(Type givenType) + private static void RegisterRawConversionsForType(ContainerBuilder containerBuilder, Type type) { - foreach (var it in givenType.GetInterfaces()) + if (!type.IsClass || type.IsAbstract) { - if (it.IsGenericType && it.GetGenericTypeDefinition() == typeof(IRawConversion<,>)) - { - return it; - } + return; } - return null; + var rawConversionInterfaces = type.GetInterfaces() + .Where(it => it.IsGenericType && it.GetGenericTypeDefinition() == typeof(IRawConversion<,>)); + + foreach (var conversionInterface in rawConversionInterfaces) + { + containerBuilder.RegisterType(type).As(conversionInterface).InstancePerLifetimeScope(); + } } } diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common/Objects/IRawConversion.cs b/DUI3-DX/Sdk/Speckle.Converters.Common/Objects/IRawConversion.cs index dafea22be7..0b2060e8c1 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common/Objects/IRawConversion.cs +++ b/DUI3-DX/Sdk/Speckle.Converters.Common/Objects/IRawConversion.cs @@ -1,15 +1,6 @@ -using Speckle.Core.Models; - namespace Speckle.Converters.Common.Objects; public interface IRawConversion { TOut RawConvert(TIn target); } - -// POC: this breaks the concept of IRawConversion be -// if we had this we would probably rename the interface as this is now a IToSpeckleRawConversion -public interface IRawConversion -{ - Base ConvertToBase(TIn target); -} From 16e5f23ec15922d1699719173d0a300f7d91fd23 Mon Sep 17 00:00:00 2001 From: KatKatKateryna <89912278+KatKatKateryna@users.noreply.github.com> Date: Fri, 5 Apr 2024 19:47:15 +0800 Subject: [PATCH 021/261] ArcGIS Send conversions (#3258) * add context stack per dependency scope; convert map units * move to generic GisFeature * add prop with geomType * add attributes to GisFeature * get attributes even with empty feature layers * IFactory for feature conversion, polylines converters * arc segments * bezier, arc, multipoint * proper geometry projection; TODO: contextStack scope; multiPart geoms; selectionFilter * multi-geometry converter issue resolved * half way through separate raw converter for multiple geometries * make high-level converters return a List * polygons * polygons correct * polygons with simple meshes * remove meshes * fix build * high level conversions hard-coded * Fix build errors --------- Co-authored-by: Alan Rynne Co-authored-by: oguzhankoral --- .../AutofacArcGISModule.cs | 3 + .../Operations/Send/RootObjectBuilder.cs | 7 +- .../Speckle.Connectors.ArcGIS3.csproj | 2 + .../AutofacArcGIS3ConverterModule.cs | 8 ++ .../ArcGISConversionContextStack.cs | 18 +++++ .../ArcGISToSpeckleUnitConverter.cs | 40 ++++++++++ .../Features/GeometryToSpeckleBase.cs | 77 +++++++++++++++++++ .../Features/GisFeatureToSpeckleConverter.cs | 44 +++++++++++ .../MultipatchFeatureToSpeckleConverter.cs | 17 ++++ .../MultipointFeatureToSpeckleConverter.cs | 37 +++++++++ .../PointElementToSpeckleConverter.cs | 36 --------- .../PointFeatureToSpeckleConverter.cs | 37 +++++++++ .../PolygonFeatureToSpeckleConverter.cs | 62 +++++++++++++++ .../PolylineFeatureToSpeckleConverter.cs | 40 ++++++++++ .../BezierSegmentToSpeckleConverter.cs | 66 ++++++++++++++++ .../EllipticArcSegmentToSpeckleConverter.cs | 75 ++++++++++++++++++ .../Geometry/PointToSpeckleConverter.cs | 30 ++++++-- .../SegmentCollectionToSpeckleConverter.cs | 68 ++++++++++++++++ .../GlobalUsings.cs | 2 + .../Layers/VectorLayerToSpeckleConverter.cs | 31 ++++---- Objects/Objects/GIS/GisFeature.cs | 29 +++++++ Objects/Objects/GIS/GisPolygonGeometry.cs | 11 +++ Objects/Objects/GIS/LineElement.cs | 10 --- Objects/Objects/GIS/PointElement.cs | 11 --- Objects/Objects/GIS/PolygonElement.cs | 11 --- Objects/Objects/GIS/VectorLayer.cs | 4 +- 26 files changed, 688 insertions(+), 88 deletions(-) create mode 100644 DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ArcGISConversionContextStack.cs create mode 100644 DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ArcGISToSpeckleUnitConverter.cs create mode 100644 DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GeometryToSpeckleBase.cs create mode 100644 DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GisFeatureToSpeckleConverter.cs create mode 100644 DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/MultipatchFeatureToSpeckleConverter.cs create mode 100644 DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/MultipointFeatureToSpeckleConverter.cs delete mode 100644 DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/PointElementToSpeckleConverter.cs create mode 100644 DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/PointFeatureToSpeckleConverter.cs create mode 100644 DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/PolygonFeatureToSpeckleConverter.cs create mode 100644 DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/PolylineFeatureToSpeckleConverter.cs create mode 100644 DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/BezierSegmentToSpeckleConverter.cs create mode 100644 DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/EllipticArcSegmentToSpeckleConverter.cs create mode 100644 DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/SegmentCollectionToSpeckleConverter.cs create mode 100644 DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/GlobalUsings.cs create mode 100644 Objects/Objects/GIS/GisFeature.cs create mode 100644 Objects/Objects/GIS/GisPolygonGeometry.cs delete mode 100644 Objects/Objects/GIS/LineElement.cs delete mode 100644 Objects/Objects/GIS/PointElement.cs delete mode 100644 Objects/Objects/GIS/PolygonElement.cs diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/DependencyInjection/AutofacArcGISModule.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/DependencyInjection/AutofacArcGISModule.cs index 5971305a4f..3c199932c5 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/DependencyInjection/AutofacArcGISModule.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/DependencyInjection/AutofacArcGISModule.cs @@ -13,7 +13,9 @@ using Speckle.Newtonsoft.Json.Serialization; using Speckle.Connectors.ArcGIS.Utils; using Speckle.Connectors.Utils.Cancellation; +using Speckle.Converters.ArcGIS3; using Speckle.Core.Transports; +using ArcGIS.Core.Geometry; namespace Speckle.Connectors.ArcGIS.DependencyInjection; @@ -34,6 +36,7 @@ protected override void Load(ContainerBuilder builder) builder.RegisterType().As().SingleInstance(); builder.RegisterType().As().As().SingleInstance(); builder.RegisterType().As().SingleInstance(); + builder.RegisterType().As>().SingleInstance(); // binding dependencies builder.RegisterType().InstancePerDependency(); diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Send/RootObjectBuilder.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Send/RootObjectBuilder.cs index daade14483..bec447a5c7 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Send/RootObjectBuilder.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Send/RootObjectBuilder.cs @@ -27,7 +27,7 @@ public Base Build( { if (MapView.Active == null) { - throw new SpeckleException("No Map currently open"); + throw new SpeckleException("No Map currently active"); } var selectedObjects = GetSelection(MapView.Active.Map); @@ -59,6 +59,11 @@ private Dictionary> GetSelection(Map map) var selectedMemberUrls = map.GetSelection().ToDictionary(); + if (selectedMemberUrls.Count == 0) + { + throw new SpeckleException("No data to send"); + } + return selectedMemberUrls; } diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Speckle.Connectors.ArcGIS3.csproj b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Speckle.Connectors.ArcGIS3.csproj index 86038a66ee..17443d8505 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Speckle.Connectors.ArcGIS3.csproj +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Speckle.Connectors.ArcGIS3.csproj @@ -4,6 +4,7 @@ net6.0-windows true x64 + win-x64 Speckle.Connectors.ArcGIS true enable @@ -27,6 +28,7 @@ + diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3.DependencyInjection/AutofacArcGIS3ConverterModule.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3.DependencyInjection/AutofacArcGIS3ConverterModule.cs index af28489156..8d3af993d1 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3.DependencyInjection/AutofacArcGIS3ConverterModule.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3.DependencyInjection/AutofacArcGIS3ConverterModule.cs @@ -1,5 +1,7 @@ // POC: not sure we should have this here as it attaches us to autofac, maybe a bit prematurely... +using ArcGIS.Core.Geometry; +using ArcGIS.Desktop.Mapping; using Autofac; using Speckle.Autofac.DependencyInjection; using Speckle.Converters.Common; @@ -14,6 +16,12 @@ protected override void Load(ContainerBuilder builder) // most things should be InstancePerLifetimeScope so we get one per operation builder.RegisterType().As().SingleInstance(); + // single stack per conversion + builder + .RegisterType() + .As>() + .InstancePerLifetimeScope(); + // factory for conversions builder .RegisterType>() diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ArcGISConversionContextStack.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ArcGISConversionContextStack.cs new file mode 100644 index 0000000000..6290242235 --- /dev/null +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ArcGISConversionContextStack.cs @@ -0,0 +1,18 @@ +using System.Diagnostics.CodeAnalysis; +using ArcGIS.Core.Geometry; +using ArcGIS.Desktop.Mapping; +using Speckle.Converters.Common; + +namespace Speckle.Converters.ArcGIS3; + +// POC: Suppressed naming warning for now, but we should evaluate if we should follow this or disable it. +[SuppressMessage( + "Naming", + "CA1711:Identifiers should not have incorrect suffix", + Justification = "Name ends in Stack but it is in fact a Stack, just not inheriting from `System.Collections.Stack`" +)] +public class ArcGISConversionContextStack : ConversionContextStack +{ + public ArcGISConversionContextStack(IHostToSpeckleUnitConverter unitConverter) + : base(MapView.Active.Map, MapView.Active.Map.SpatialReference.Unit, unitConverter) { } +} diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ArcGISToSpeckleUnitConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ArcGISToSpeckleUnitConverter.cs new file mode 100644 index 0000000000..be2c0e835b --- /dev/null +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ArcGISToSpeckleUnitConverter.cs @@ -0,0 +1,40 @@ +using ArcGIS.Core.Geometry; +using Speckle.Converters.Common; +using Speckle.Core.Kits; +using Speckle.Core.Logging; // POC: boy do I think this is the wrong place for SpeckleException! + +namespace Speckle.Converters.ArcGIS3; + +public class ArcGISToSpeckleUnitConverter : IHostToSpeckleUnitConverter +{ + private readonly Dictionary _unitMapping = new(); + + public ArcGISToSpeckleUnitConverter() + { + // POC: we should have a unit test to confirm these are as expected and don't change + //_unitMapping[LinearUnit.] = Units.Meters; + _unitMapping[LinearUnit.Millimeters.Name] = Units.Millimeters; + _unitMapping[LinearUnit.Centimeters.Name] = Units.Centimeters; + _unitMapping[LinearUnit.Meters.Name] = Units.Meters; + _unitMapping[LinearUnit.Kilometers.Name] = Units.Kilometers; + _unitMapping[LinearUnit.Inches.Name] = Units.Inches; + _unitMapping[LinearUnit.Feet.Name] = Units.Feet; + _unitMapping[LinearUnit.Yards.Name] = Units.Yards; + _unitMapping[LinearUnit.Miles.Name] = Units.Miles; + //_unitMapping[LinearUnit.Decimeters] = Units.; + //_unitMapping[LinearUnit.NauticalMiles] = Units.; + } + + public string ConvertOrThrow(Unit hostUnit) + { + var linearUnit = LinearUnit.CreateLinearUnit(hostUnit.Wkt).Name; + + if (_unitMapping.TryGetValue(linearUnit, out string? value)) + { + return value; + } + + // POC: probably would prefer something more specific + throw new SpeckleException($"The Unit System \"{hostUnit}\" is unsupported."); + } +} diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GeometryToSpeckleBase.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GeometryToSpeckleBase.cs new file mode 100644 index 0000000000..6c31e454e5 --- /dev/null +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GeometryToSpeckleBase.cs @@ -0,0 +1,77 @@ +using ArcGIS.Core.Geometry; +using Speckle.Autofac.DependencyInjection; +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; +using Speckle.Core.Models; + +namespace Speckle.Converters.ArcGIS3.Features; + +[NameAndRankValue(nameof(ArcGIS.Core.Geometry.Geometry), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +public class GeometryToSpeckleBaseList + : IHostObjectToSpeckleConversion, + IRawConversion +{ + private readonly IFactory _toSpeckle; + private readonly IRawConversion _pointFeatureConverter; + private readonly IRawConversion _multiPointFeatureConverter; + private readonly IRawConversion _polylineFeatureConverter; + private readonly IRawConversion _polygonFeatureConverter; + + public GeometryToSpeckleBaseList( + IFactory toSpeckle, + IRawConversion pointFeatureConverter, + IRawConversion multiPointFeatureConverter, + IRawConversion polylineFeatureConverter, + IRawConversion polygonFeatureConverter + ) + { + _toSpeckle = toSpeckle; + _pointFeatureConverter = pointFeatureConverter; + _multiPointFeatureConverter = multiPointFeatureConverter; + _polylineFeatureConverter = polylineFeatureConverter; + _polygonFeatureConverter = polygonFeatureConverter; + } + + public Base Convert(object target) => RawConvert((ArcGIS.Core.Geometry.Geometry)target); + + public Base RawConvert(ArcGIS.Core.Geometry.Geometry target) + { + List convertedList = new(); + + Type type = target.GetType(); + try + { + Base newGeometry = new(); // objectConverter.Convert(target); + if (target is MapPoint) + { + newGeometry = _pointFeatureConverter.RawConvert((MapPoint)target); + convertedList.Add(newGeometry); + return convertedList[0]; + } + if (target is Multipoint) + { + newGeometry = _multiPointFeatureConverter.RawConvert((Multipoint)target); + convertedList.Add(newGeometry); + return convertedList[0]; + } + if (target is Polyline) + { + newGeometry = _polylineFeatureConverter.RawConvert((Polyline)target); + convertedList.Add(newGeometry); + return convertedList[0]; + } + if (target is Polygon) + { + newGeometry = _polygonFeatureConverter.RawConvert((Polygon)target); + convertedList.Add(newGeometry); + return convertedList[0]; + } + throw new NotSupportedException($"No conversion found for {type.Name}"); + } + catch (SpeckleConversionException e) + { + Console.WriteLine(e); + throw; // Just rethrowing for now, Logs may be needed here. + } + } +} diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GisFeatureToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GisFeatureToSpeckleConverter.cs new file mode 100644 index 0000000000..f2ad04ca6c --- /dev/null +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GisFeatureToSpeckleConverter.cs @@ -0,0 +1,44 @@ +using Speckle.Converters.Common.Objects; +using Speckle.Core.Models; +using Objects.GIS; +using ArcGIS.Core.Data; +using Speckle.Converters.Common; + +namespace Speckle.Converters.ArcGIS3.Features; + +[NameAndRankValue(nameof(Row), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +public class GisFeatureToSpeckleConverter : IHostObjectToSpeckleConversion, IRawConversion +{ + private readonly IRawConversion _geometryConverter; + + public GisFeatureToSpeckleConverter(IRawConversion geometryConverter) + { + _geometryConverter = geometryConverter; + } + + public Base Convert(object target) => RawConvert((Row)target); + + public GisFeature RawConvert(Row target) + { + var shape = (ArcGIS.Core.Geometry.Geometry)target["Shape"]; + var speckleShapes = new List() { _geometryConverter.RawConvert(shape) }; + + // get attributes + var attributes = new Base(); + IReadOnlyList fields = target.GetFields(); + int i = 0; + foreach (Field field in fields) + { + string name = field.Name; + + // breaks on Raster Field type + if (name != "Shape" && field.FieldType.ToString() != "Raster") + { + var value = target.GetOriginalValue(i); // can be null + attributes[name] = value; + } + i++; + } + return new GisFeature(speckleShapes, attributes); + } +} diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/MultipatchFeatureToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/MultipatchFeatureToSpeckleConverter.cs new file mode 100644 index 0000000000..5ee943c092 --- /dev/null +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/MultipatchFeatureToSpeckleConverter.cs @@ -0,0 +1,17 @@ +namespace Speckle.Converters.ArcGIS3.Features; +/* +[NameAndRankValue(nameof(MapPoint), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +public class PointToSpeckleConverter : IHostObjectToSpeckleConversion, IRawConversion +{ + private readonly IConversionContextStack _contextStack; + + public PointToSpeckleConverter(IConversionContextStack contextStack) + { + _contextStack = contextStack; + } + + public Base Convert(object target) => RawConvert((MapPoint)target); + + public Point RawConvert(MapPoint target) => new(target.X, target.Y, target.Z, _contextStack.Current.SpeckleUnits); +} +*/ diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/MultipointFeatureToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/MultipointFeatureToSpeckleConverter.cs new file mode 100644 index 0000000000..89927564a5 --- /dev/null +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/MultipointFeatureToSpeckleConverter.cs @@ -0,0 +1,37 @@ +using ArcGIS.Core.Geometry; +using Speckle.Converters.Common.Objects; +using Speckle.Core.Models; +using Speckle.Converters.Common; +using ArcGIS.Desktop.Mapping; +using ArcMapPoint = ArcGIS.Core.Geometry.MapPoint; + +namespace Speckle.Converters.ArcGIS3.Features; + +[NameAndRankValue(nameof(Multipoint), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +public class MultipointFeatureToSpeckleConverter : IHostObjectToSpeckleConversion, IRawConversion +{ + private readonly IConversionContextStack _contextStack; + private readonly IRawConversion _pointConverter; + + public MultipointFeatureToSpeckleConverter( + IConversionContextStack contextStack, + IRawConversion pointConverter + ) + { + _contextStack = contextStack; + _pointConverter = pointConverter; + } + + public Base Convert(object target) => RawConvert((Multipoint)target); + + public Base RawConvert(Multipoint target) + { + List multipoint = new(); + foreach (ArcMapPoint point in target.Points) + { + multipoint.Add(_pointConverter.RawConvert(point)); + } + + return multipoint[0]; + } +} diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/PointElementToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/PointElementToSpeckleConverter.cs deleted file mode 100644 index 80033512e5..0000000000 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/PointElementToSpeckleConverter.cs +++ /dev/null @@ -1,36 +0,0 @@ -using ArcGIS.Core.Geometry; -using Speckle.Converters.Common.Objects; -using Speckle.Core.Models; -using Objects.Geometry; -using Objects.GIS; -using ArcGIS.Core.Data; -using Speckle.Converters.Common; - -namespace Speckle.Converters.ArcGIS3.Features; - -[NameAndRankValue(nameof(Row), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class PointElementToSpeckleConverter : IHostObjectToSpeckleConversion, IRawConversion -{ - private readonly IRawConversion _pointConverter; - - public PointElementToSpeckleConverter(IRawConversion pointConverter) - { - _pointConverter = pointConverter; - } - - public Base Convert(object target) => RawConvert((Row)target); - - public PointElement RawConvert(Row target) - { - var geometry = new List(); - MapPoint shape = (MapPoint)target["SHAPE"]; - var pt = _pointConverter.RawConvert(shape); - geometry.Add(pt); - - // get attributes - var attributes = new Base(); - // IReadOnlyList fields = target.GetFields(); - - return new PointElement { geometry = geometry, attributes = attributes }; - } -} diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/PointFeatureToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/PointFeatureToSpeckleConverter.cs new file mode 100644 index 0000000000..5bee034ca4 --- /dev/null +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/PointFeatureToSpeckleConverter.cs @@ -0,0 +1,37 @@ +using ArcGIS.Core.Geometry; +using Speckle.Converters.Common.Objects; +using Speckle.Core.Models; +using Speckle.Converters.Common; +using ArcGIS.Desktop.Mapping; + +namespace Speckle.Converters.ArcGIS3.Features; + +[NameAndRankValue(nameof(MapPoint), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +public class PointFeatureToSpeckleConverter : IHostObjectToSpeckleConversion, IRawConversion +{ + private readonly IConversionContextStack _contextStack; + + public PointFeatureToSpeckleConverter(IConversionContextStack contextStack) + { + _contextStack = contextStack; + } + + public Base Convert(object target) => RawConvert((MapPoint)target); + + public Base RawConvert(MapPoint target) + { + if ( + GeometryEngine.Instance.Project(target, _contextStack.Current.Document.SpatialReference) + is not MapPoint reprojectedPt + ) + { + throw new SpeckleConversionException( + $"Conversion to Spatial Reference {_contextStack.Current.Document.SpatialReference} failed" + ); + } + List geometry = + new() { new SOG.Point(reprojectedPt.X, reprojectedPt.Y, reprojectedPt.Z, _contextStack.Current.SpeckleUnits) }; + + return geometry[0]; + } +} diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/PolygonFeatureToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/PolygonFeatureToSpeckleConverter.cs new file mode 100644 index 0000000000..0684ad8ebf --- /dev/null +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/PolygonFeatureToSpeckleConverter.cs @@ -0,0 +1,62 @@ +using ArcGIS.Core.Geometry; +using Speckle.Converters.Common.Objects; +using Speckle.Core.Models; +using Speckle.Converters.Common; +using ArcGIS.Desktop.Mapping; +using ArcMapPoint = ArcGIS.Core.Geometry.MapPoint; +using Objects.GIS; + +namespace Speckle.Converters.ArcGIS3.Features; + +[NameAndRankValue(nameof(Polygon), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +public class PolygonFeatureToSpeckleConverter : IHostObjectToSpeckleConversion, IRawConversion +{ + private readonly IConversionContextStack _contextStack; + private readonly IRawConversion _pointConverter; + private readonly IRawConversion _segmentConverter; + + public PolygonFeatureToSpeckleConverter( + IConversionContextStack contextStack, + IRawConversion pointConverter, + IRawConversion segmentConverter + ) + { + _contextStack = contextStack; + _pointConverter = pointConverter; + _segmentConverter = segmentConverter; + } + + public Base Convert(object target) => RawConvert((Polygon)target); + + public Base RawConvert(Polygon target) + { + // https://pro.arcgis.com/en/pro-app/latest/sdk/api-reference/topic30235.html + List polygonList = new(); + int partCount = target.PartCount; + + GisPolygonGeometry polygon = new() { voids = new List() }; + // test each part for "exterior ring" + for (int idx = 0; idx < partCount; idx++) + { + ReadOnlySegmentCollection segmentCollection = target.Parts[idx]; + SOG.Polyline polyline = _segmentConverter.RawConvert(segmentCollection); + + bool isExteriorRing = target.IsExteriorRing(idx); + if (isExteriorRing is true) + { + if (polygonList.Count > 0) + { + polygonList.Add(polygon); + } + polygon = new() { voids = new List(), boundary = polyline }; + } + else + { + polygon.voids.Add(polyline); + } + } + polygonList.Add(polygon); + + return polygonList[0]; + } +} diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/PolylineFeatureToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/PolylineFeatureToSpeckleConverter.cs new file mode 100644 index 0000000000..bdff001976 --- /dev/null +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/PolylineFeatureToSpeckleConverter.cs @@ -0,0 +1,40 @@ +using ArcGIS.Core.Geometry; +using Speckle.Converters.Common.Objects; +using Speckle.Core.Models; +using Speckle.Converters.Common; +using ArcGIS.Desktop.Mapping; +using ArcMapPoint = ArcGIS.Core.Geometry.MapPoint; + +namespace Speckle.Converters.ArcGIS3.Features; + +[NameAndRankValue(nameof(Polyline), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +public class PolyineFeatureToSpeckleConverter : IHostObjectToSpeckleConversion, IRawConversion +{ + private readonly IConversionContextStack _contextStack; + private readonly IRawConversion _pointConverter; + private readonly IRawConversion _segmentConverter; + + public PolyineFeatureToSpeckleConverter( + IConversionContextStack contextStack, + IRawConversion pointConverter, + IRawConversion segmentConverter + ) + { + _contextStack = contextStack; + _pointConverter = pointConverter; + _segmentConverter = segmentConverter; + } + + public Base Convert(object target) => RawConvert((Polyline)target); + + public Base RawConvert(Polyline target) + { + // https://pro.arcgis.com/en/pro-app/latest/sdk/api-reference/topic8480.html + List polylineList = new(); + foreach (var segmentCollection in target.Parts) + { + polylineList.Add(_segmentConverter.RawConvert(segmentCollection)); + } + return polylineList[0]; + } +} diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/BezierSegmentToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/BezierSegmentToSpeckleConverter.cs new file mode 100644 index 0000000000..0fd602b544 --- /dev/null +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/BezierSegmentToSpeckleConverter.cs @@ -0,0 +1,66 @@ +using ArcGIS.Core.Geometry; +using Speckle.Converters.Common.Objects; +using Speckle.Core.Models; +using Speckle.Converters.Common; +using ArcGIS.Desktop.Mapping; +using ArcMapPoint = ArcGIS.Core.Geometry.MapPoint; + +namespace Speckle.Converters.ArcGIS3.Geometry; + +[NameAndRankValue(nameof(CubicBezierSegment), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +public class BezierSegmentToSpeckleConverter + : IHostObjectToSpeckleConversion, + IRawConversion +{ + private readonly IConversionContextStack _contextStack; + private readonly IRawConversion _pointConverter; + + public BezierSegmentToSpeckleConverter( + IConversionContextStack contextStack, + IRawConversion pointConverter + ) + { + _contextStack = contextStack; + _pointConverter = pointConverter; + } + + public Base Convert(object target) => RawConvert((CubicBezierSegment)target); + + public SOG.Polyline RawConvert(CubicBezierSegment target) + { + // Determine the number of vertices to create along the arc + int numVertices = Math.Max((int)target.Length, 3); // Determine based on desired segment length or other criteria + List points = new(); + + // Calculate the vertices along the curve + for (int i = 0; i <= numVertices; i++) + { + double t = i / (double)numVertices; + + // Calculate the point using the cubic Bezier formula + double x = + (1 - t) * (1 - t) * (1 - t) * target.StartPoint.X + + 3 * (1 - t) * (1 - t) * t * target.ControlPoint1.X + + 3 * (1 - t) * t * t * target.ControlPoint2.X + + t * t * t * target.EndPoint.X; + + double y = + (1 - t) * (1 - t) * (1 - t) * target.StartPoint.Y + + 3 * (1 - t) * (1 - t) * t * target.ControlPoint1.Y + + 3 * (1 - t) * t * t * target.ControlPoint2.Y + + t * t * t * target.EndPoint.Y; + + ArcMapPoint pointOnCurve = MapPointBuilderEx.CreateMapPoint(x, y, target.SpatialReference); + points.Add(_pointConverter.RawConvert(pointOnCurve)); + } + + // create Speckle Polyline + SOG.Polyline polyline = + new(points.SelectMany(pt => new[] { pt.x, pt.y, pt.z }).ToList(), _contextStack.Current.SpeckleUnits) + { + // bbox = box, + length = target.Length + }; + return polyline; + } +} diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/EllipticArcSegmentToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/EllipticArcSegmentToSpeckleConverter.cs new file mode 100644 index 0000000000..cdf17d6dd5 --- /dev/null +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/EllipticArcSegmentToSpeckleConverter.cs @@ -0,0 +1,75 @@ +using ArcGIS.Core.Geometry; +using Speckle.Converters.Common.Objects; +using Speckle.Core.Models; +using Speckle.Converters.Common; +using ArcGIS.Desktop.Mapping; +using ArcMapPoint = ArcGIS.Core.Geometry.MapPoint; + +namespace Speckle.Converters.ArcGIS3.Geometry; + +[NameAndRankValue(nameof(EllipticArcSegment), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +public class EllipticArcToSpeckleConverter + : IHostObjectToSpeckleConversion, + IRawConversion +{ + private readonly IConversionContextStack _contextStack; + private readonly IRawConversion _pointConverter; + + public EllipticArcToSpeckleConverter( + IConversionContextStack contextStack, + IRawConversion pointConverter + ) + { + _contextStack = contextStack; + _pointConverter = pointConverter; + } + + public Base Convert(object target) => RawConvert((EllipticArcSegment)target); + + public SOG.Polyline RawConvert(EllipticArcSegment target) + { + // Determine the number of vertices to create along the arc + int numVertices = Math.Max((int)target.Length, 3); // Determine based on desired segment length or other criteria + List points = new(); + + // get correct direction + int coeff = 1; + double fullAngle = target.EndAngle - target.StartAngle; + double angleStart = target.StartAngle; + + // define the direction + if ( + !((target.IsCounterClockwise is false || fullAngle >= 0) && (target.IsCounterClockwise is true || fullAngle < 0)) + ) + { + fullAngle = Math.PI * 2 - Math.Abs(fullAngle); + if (target.IsCounterClockwise is false) + { + coeff = -1; + } + } + + // Calculate the vertices along the arc + for (int i = 0; i <= numVertices; i++) + { + // Calculate the point along the arc + double angle = angleStart + coeff * fullAngle * (i / (double)numVertices); + ArcMapPoint pointOnArc = MapPointBuilderEx.CreateMapPoint( + target.CenterPoint.X + target.SemiMajorAxis * Math.Cos(angle), + target.CenterPoint.Y + target.SemiMinorAxis * Math.Sin(angle), + target.SpatialReference + ); + + points.Add(_pointConverter.RawConvert(pointOnArc)); + } + + // create Speckle Polyline + SOG.Polyline polyline = + new(points.SelectMany(pt => new[] { pt.x, pt.y, pt.z }).ToList(), _contextStack.Current.SpeckleUnits) + { + // bbox = box, + length = target.Length + }; + return polyline; + } +} diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/PointToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/PointToSpeckleConverter.cs index 5d28dca03a..2f3cc5e6a5 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/PointToSpeckleConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/PointToSpeckleConverter.cs @@ -1,15 +1,35 @@ using ArcGIS.Core.Geometry; +using ArcMapPoint = ArcGIS.Core.Geometry.MapPoint; using Speckle.Converters.Common.Objects; using Speckle.Core.Models; -using Objects.Geometry; using Speckle.Converters.Common; +using ArcGIS.Desktop.Mapping; namespace Speckle.Converters.ArcGIS3.Geometry; -[NameAndRankValue(nameof(MapPoint), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -internal class PointToSpeckleConverter : IHostObjectToSpeckleConversion, IRawConversion +[NameAndRankValue(nameof(ArcMapPoint), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +public class PointToSpeckleConverter : IHostObjectToSpeckleConversion, IRawConversion { - public Base Convert(object target) => RawConvert((MapPoint)target); + private readonly IConversionContextStack _contextStack; - public Point RawConvert(MapPoint target) => new(target.X, target.Y, target.Z, "m"); + public PointToSpeckleConverter(IConversionContextStack contextStack) + { + _contextStack = contextStack; + } + + public Base Convert(object target) => RawConvert((ArcMapPoint)target); + + public SOG.Point RawConvert(ArcMapPoint target) + { + if ( + GeometryEngine.Instance.Project(target, _contextStack.Current.Document.SpatialReference) + is not ArcMapPoint reprojectedPt + ) + { + throw new SpeckleConversionException( + $"Conversion to Spatial Reference {_contextStack.Current.Document.SpatialReference} failed" + ); + } + return new(reprojectedPt.X, reprojectedPt.Y, reprojectedPt.Z, _contextStack.Current.SpeckleUnits); + } } diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/SegmentCollectionToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/SegmentCollectionToSpeckleConverter.cs new file mode 100644 index 0000000000..fb7c237a70 --- /dev/null +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/SegmentCollectionToSpeckleConverter.cs @@ -0,0 +1,68 @@ +using ArcGIS.Core.Geometry; +using ArcGIS.Desktop.Mapping; +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; +using Speckle.Core.Models; +using ArcMapPoint = ArcGIS.Core.Geometry.MapPoint; + +namespace Speckle.Converters.ArcGIS3.Geometry; + +[NameAndRankValue(nameof(ReadOnlySegmentCollection), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +public class SegmentCollectionToSpeckleConverter + : IHostObjectToSpeckleConversion, + IRawConversion +{ + private readonly IConversionContextStack _contextStack; + private readonly IRawConversion _pointConverter; + private readonly IRawConversion _arcConverter; + private readonly IRawConversion _bezierConverter; + + public SegmentCollectionToSpeckleConverter( + IConversionContextStack contextStack, + IRawConversion pointConverter, + IRawConversion arcConverter, + IRawConversion bezierConverter + ) + { + _contextStack = contextStack; + _pointConverter = pointConverter; + _arcConverter = arcConverter; + _bezierConverter = bezierConverter; + } + + public Base Convert(object target) => RawConvert((ReadOnlySegmentCollection)target); + + public SOG.Polyline RawConvert(ReadOnlySegmentCollection target) + { + // https://pro.arcgis.com/en/pro-app/latest/sdk/api-reference/topic8480.html + double len = 0; + + List points = new(); + foreach (var segment in target) + { + len += segment.Length; + + // do something specific per segment type + switch (segment.SegmentType) + { + case SegmentType.Line: + points.Add(_pointConverter.RawConvert(segment.StartPoint)); + points.Add(_pointConverter.RawConvert(segment.EndPoint)); + break; + case SegmentType.Bezier: + var segmentBezier = (CubicBezierSegment)segment; + points.AddRange(_bezierConverter.RawConvert(segmentBezier).GetPoints()); + break; + case SegmentType.EllipticArc: + var segmentElliptic = (EllipticArcSegment)segment; + points.AddRange(_arcConverter.RawConvert(segmentElliptic).GetPoints()); + break; + } + } + // var box = _boxConverter.RawConvert(target.Extent); + SOG.Polyline polyline = + new(points.SelectMany(pt => new[] { pt.x, pt.y, pt.z }).ToList(), _contextStack.Current.SpeckleUnits) { }; + + return polyline; + } +} diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/GlobalUsings.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/GlobalUsings.cs new file mode 100644 index 0000000000..8638404840 --- /dev/null +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/GlobalUsings.cs @@ -0,0 +1,2 @@ +global using SOG = Objects.Geometry; +// global using SOP = Objects.Primitive; diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/VectorLayerToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/VectorLayerToSpeckleConverter.cs index 5f870caee0..957d568c51 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/VectorLayerToSpeckleConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/VectorLayerToSpeckleConverter.cs @@ -10,11 +10,11 @@ namespace Speckle.Converters.ArcGIS3.Layers; [NameAndRankValue(nameof(FeatureLayer), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] public class VectorLayerToSpeckleConverter : IHostObjectToSpeckleConversion, IRawConversion { - private readonly IRawConversion _pointElementConverter; + private readonly IRawConversion _gisFeatureConverter; - public VectorLayerToSpeckleConverter(IRawConversion pointElementConverter) + public VectorLayerToSpeckleConverter(IRawConversion gisFeatureConverter) { - _pointElementConverter = pointElementConverter; + _gisFeatureConverter = gisFeatureConverter; } public Base Convert(object target) @@ -34,15 +34,20 @@ public VectorLayer RawConvert(FeatureLayer target) }; speckleLayer.name = target.Name; - //Get the layer's definition - // var lyrDefn = target.GetFeatureClass().GetDefinition(); - //Get the shape field of the feature class - // string shapeField = lyrDefn.GetShapeField(); - //Index of the shape field - // var shapeIndex = lyrDefn.FindField(shapeField); - //Original geometry of the modified row - // .GetOriginalValue(shapeIndex) - + // get feature class fields + var attributes = new Base(); + IReadOnlyList fields = target.GetTable().GetDefinition().GetFields(); + foreach (Field field in fields) + { + string name = field.Name; + // breaks on Raster Field type when assigning indiv. GisFeature values + if (name != "Shape" && field.FieldType.ToString() != "Raster") + { + attributes[name] = field.FieldType; + } + } + speckleLayer.attributes = attributes; + speckleLayer.nativeGeomType = target.ShapeType.ToString(); // search the rows @@ -56,7 +61,7 @@ public VectorLayer RawConvert(FeatureLayer target) // Same IDisposable issue appears to happen on Row class too. Docs say it should always be disposed of manually by the caller. using (Row row = rowCursor.Current) { - var element = _pointElementConverter.RawConvert(row); + var element = _gisFeatureConverter.RawConvert(row); speckleLayer.elements.Add(element); } } diff --git a/Objects/Objects/GIS/GisFeature.cs b/Objects/Objects/GIS/GisFeature.cs new file mode 100644 index 0000000000..2dc79c6eb8 --- /dev/null +++ b/Objects/Objects/GIS/GisFeature.cs @@ -0,0 +1,29 @@ +using System.Collections.Generic; +using Speckle.Core.Models; + +namespace Objects.GIS; + +public class GisFeature : Base +{ + public GisFeature() { } + + public GisFeature(List geometry, Base attributes) + { + this.geometry = geometry; + this.attributes = attributes; + } + + public GisFeature(List geometry, Base attributes, List displayValue) + { + this.geometry = geometry; + this.attributes = attributes; + this.displayValue = displayValue; + } + + [DetachProperty] + public List? geometry { get; set; } + + [DetachProperty] + public List? displayValue { get; set; } + public Base? attributes { get; set; } +} diff --git a/Objects/Objects/GIS/GisPolygonGeometry.cs b/Objects/Objects/GIS/GisPolygonGeometry.cs new file mode 100644 index 0000000000..6c48f2165b --- /dev/null +++ b/Objects/Objects/GIS/GisPolygonGeometry.cs @@ -0,0 +1,11 @@ +using System.Collections.Generic; +using Objects.Geometry; +using Speckle.Core.Models; + +namespace Objects.GIS; + +public class GisPolygonGeometry : Base +{ + public Polyline boundary { get; set; } + public List? voids { get; set; } +} diff --git a/Objects/Objects/GIS/LineElement.cs b/Objects/Objects/GIS/LineElement.cs deleted file mode 100644 index 78af514bfe..0000000000 --- a/Objects/Objects/GIS/LineElement.cs +++ /dev/null @@ -1,10 +0,0 @@ -using System.Collections.Generic; -using Speckle.Core.Models; - -namespace Objects.GIS; - -public class LineElement : Base -{ - public List? geometry { get; set; } - public Base? attributes { get; set; } -} diff --git a/Objects/Objects/GIS/PointElement.cs b/Objects/Objects/GIS/PointElement.cs deleted file mode 100644 index cb7ffac456..0000000000 --- a/Objects/Objects/GIS/PointElement.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System.Collections.Generic; -using Objects.Geometry; -using Speckle.Core.Models; - -namespace Objects.GIS; - -public class PointElement : Base -{ - public List? geometry { get; set; } - public Base? attributes { get; set; } -} diff --git a/Objects/Objects/GIS/PolygonElement.cs b/Objects/Objects/GIS/PolygonElement.cs deleted file mode 100644 index 54b63601b3..0000000000 --- a/Objects/Objects/GIS/PolygonElement.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System.Collections.Generic; -using Speckle.Core.Models; - -namespace Objects.GIS; - -public class PolygonElement : Base -{ - [DetachProperty] - public List geometry { get; set; } - public Base attributes { get; set; } -} diff --git a/Objects/Objects/GIS/VectorLayer.cs b/Objects/Objects/GIS/VectorLayer.cs index 93468d85eb..618f95d870 100644 --- a/Objects/Objects/GIS/VectorLayer.cs +++ b/Objects/Objects/GIS/VectorLayer.cs @@ -7,12 +7,14 @@ public class VectorLayer : Collection { public CRS? crs { get; set; } public string? units { get; set; } - public Base? attributes { get; set; } + public Base attributes { get; set; } public string? geomType { get; set; } + public string? nativeGeomType { get; set; } public Dictionary? renderer { get; set; } public VectorLayer() { collectionType = "VectorLayer"; + attributes = new Base(); } } From fcdea64d794b6d4e83872a1c7cb88fb77981c14d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?O=C4=9Fuzhan=20Koral?= <45078678+oguzhankoral@users.noreply.github.com> Date: Fri, 5 Apr 2024 15:57:02 +0300 Subject: [PATCH 022/261] CNX-9182 receive binding for autocad (#3254) * adds send binding file * receives commit base in binding * Update AutocadReceiveBinding.cs * Align and inject receive binding * adds converter to host files and point to host conversion * adds converters to receive binding * Receive with layers WIP * Register ISpeckleConverterToHost * Start transaction for layer creation * Lock document * Wrap up receive binding * Self review notes/changes * Remove IDE0005 for BaseExtension attempt before * Remove various IDE0005 * Receive catch when it is not fatal * Addressing PR comments vol 1 * Fix csharpier warnings * Add unit test for TraverseWithPath * POC comments for Doc usage * Update PointToHostConverter.cs * fixes raw point conversion registration * fixes revit send filter error * more revit send interfaces fixed * removes unecessary unitconverter from tohost and tospeckle converter * Create HostObjectBuilder and simplify ReceiveBinding * Fix errors * POC comment for CreateLayerFilter * fix: Resolve CI build errors --------- Co-authored-by: Claire Kuang Co-authored-by: Alan Rynne --- Core/Core/Models/Extensions/BaseExtensions.cs | 66 ++++++++++ Core/Core/Models/Utilities.cs | 33 +++++ .../Models/Extensions/BaseExtensionsTests.cs | 24 ++++ .../Models/UtilitiesTests.cs | 21 ++++ .../Bindings/ArcGISSendBinding.cs | 1 + .../AutofacArcGISModule.cs | 1 + .../Filters/ArcGISEverythingFilter.cs | 2 +- .../Filters/ArcGISSelectionFilter.cs | 2 +- .../Operations/Send/RootObjectBuilder.cs | 3 +- .../Bindings/AutocadBasicConnectorBinding.cs | 2 + .../Bindings/AutocadReceiveBinding.cs | 98 +++++++++++++++ .../Bindings/AutocadSelectionBinding.cs | 1 + .../Bindings/AutocadSendBinding.cs | 2 + .../AutofacAutocadModule.cs | 18 +++ .../Filters/AutocadSelectionFilter.cs | 2 +- .../HostApp/AutocadContext.cs | 13 ++ .../HostApp/AutocadDocumentModelStore.cs | 3 + .../HostApp/AutocadLayerManager.cs | 117 ++++++++++++++++++ .../HostApp/Extensions/DatabaseExtensions.cs | 15 +++ .../Extensions/DocumentExtensions.cs} | 5 +- .../HostApp/Extensions/EntityExtensions.cs | 45 +++++++ .../Operations/Receive/HostObjectBuilder.cs | 114 +++++++++++++++++ .../Plugin/AutocadCommand.cs | 2 + ...Speckle.Connectors.AutocadShared.projitems | 7 +- .../Bindings/Filters.cs | 2 +- .../Bindings/SendBinding.cs | 3 +- .../DependencyInjection/AutofacUIModule.cs | 1 + .../Operations/Send/RootObjectBuilder.cs | 2 +- .../Operations/Send/SendOperation.cs | 2 +- .../Bindings/RhinoSendBinding.cs | 1 + .../DependencyInjection/AutofacRhinoModule.cs | 1 + .../Filters/RhinoEverythingFilter.cs | 2 +- .../Filters/RhinoSelectionFilter.cs | 2 +- .../Operations/Send/RootObjectBuilder.cs | 2 +- .../Operations/Send/SendOperation.cs | 2 +- .../AutocadConverterToHost.cs | 41 ++++++ .../AutocadConverterToSpeckle.cs | 7 +- .../AutofacAutocadConverterModule.cs | 4 + .../Geometry/PointToHostConverter.cs | 52 ++++++++ .../Geometry/PointToSpeckleConverter.cs | 3 +- ...Speckle.Converters.AutocadShared.projitems | 2 + .../Bindings/IReceiveBinding.cs | 14 +-- .../Bindings/ISendBinding.cs | 57 +-------- .../Bindings/ReceiveBindingUICommands.cs | 25 ++++ .../Models/Card/CreateVersionArgs.cs | 7 ++ .../Models/Card/ReceiveResult.cs | 9 ++ .../Models/Card/ReceiverModelCard.cs | 9 ++ .../Models/Card/ReceiverModelCardResult.cs | 7 ++ .../SendFilter/DirectSelectionSendFilter.cs | 14 +++ .../Card/SendFilter/EverythingSendFilter.cs | 13 ++ .../Models/Card/SendFilter/ISendFilter.cs | 23 ++++ .../Models/Card/SenderModelCard.cs | 13 ++ .../Models/DocumentModelStore.cs | 1 - .../Speckle.Connectors.DUI.csproj | 5 + .../Builders/IHostObjectBuilder.cs | 29 +++++ .../Operations/ReceiveOperation.cs | 60 +++++++++ .../ISpeckleConverterToHost.cs | 4 +- .../Objects/ISpeckleObjectToHostConversion.cs | 6 +- 58 files changed, 925 insertions(+), 97 deletions(-) create mode 100644 DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadReceiveBinding.cs create mode 100644 DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/AutocadLayerManager.cs create mode 100644 DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/Extensions/DatabaseExtensions.cs rename DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/{Utils.cs => HostApp/Extensions/DocumentExtensions.cs} (87%) create mode 100644 DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/Extensions/EntityExtensions.cs create mode 100644 DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Operations/Receive/HostObjectBuilder.cs create mode 100644 DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/AutocadConverterToHost.cs create mode 100644 DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/Geometry/PointToHostConverter.cs create mode 100644 DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/ReceiveBindingUICommands.cs create mode 100644 DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/CreateVersionArgs.cs create mode 100644 DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/ReceiveResult.cs create mode 100644 DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/ReceiverModelCard.cs create mode 100644 DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/ReceiverModelCardResult.cs create mode 100644 DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/SendFilter/DirectSelectionSendFilter.cs create mode 100644 DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/SendFilter/EverythingSendFilter.cs create mode 100644 DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/SendFilter/ISendFilter.cs create mode 100644 DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/SenderModelCard.cs create mode 100644 DUI3-DX/Sdk/Speckle.Connectors.Utils/Builders/IHostObjectBuilder.cs create mode 100644 DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/ReceiveOperation.cs diff --git a/Core/Core/Models/Extensions/BaseExtensions.cs b/Core/Core/Models/Extensions/BaseExtensions.cs index 1eb00ef442..aba338b602 100644 --- a/Core/Core/Models/Extensions/BaseExtensions.cs +++ b/Core/Core/Models/Extensions/BaseExtensions.cs @@ -226,4 +226,70 @@ public static bool IsDisplayableObject(this Base speckleObject) { return TryGetParameters(obj); } + + /// + /// A variation of the OG Traversal extension from Alan, but with tracking the object path as well. + /// + /// Delegate condition to stop traverse. + /// List of base objects with their collection path. + public static IEnumerable<(List, Base)> TraverseWithPath( + this Base root, + BaseRecursionBreaker recursionBreaker + ) + { + var stack = new Stack<(List, Base)>(); + stack.Push((new List(), root)); + + while (stack.Count > 0) + { + (List path, Base current) = stack.Pop(); + yield return (path, current); + + if (recursionBreaker(current)) + { + continue; + } + + foreach (string child in current.GetDynamicMemberNames()) + { + // NOTE: we can store collections rather than just path names. Where we have an actual collection, use that, where not, create a mock one based on the prop name + var localPathFragment = child; + if (current is Collection { name: { } } c) + { + localPathFragment = c.name; + } + + var newPath = new List(path) { localPathFragment }; + switch (current[child]) + { + case Base o: + stack.Push((newPath, o)); + break; + case IDictionary dictionary: + { + foreach (object obj in dictionary.Keys) + { + if (obj is Base b) + { + stack.Push((newPath, b)); + } + } + + break; + } + case IList collection: + { + foreach (object obj in collection) + { + if (obj is Base b) + { + stack.Push((newPath, b)); + } + } + break; + } + } + } + } + } } diff --git a/Core/Core/Models/Utilities.cs b/Core/Core/Models/Utilities.cs index 7f7a93c011..461eca7a45 100644 --- a/Core/Core/Models/Utilities.cs +++ b/Core/Core/Models/Utilities.cs @@ -1,4 +1,5 @@ using System; +using System.Collections; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.Diagnostics.Contracts; @@ -211,4 +212,36 @@ public static IEnumerable> SplitList(List list, int chunkSize = 50 yield return list.GetRange(i, Math.Min(chunkSize, list.Count - i)); } } + + /// + /// Utility function to flatten a conversion result that might have nested lists of objects. + /// This happens, for example, in the case of multiple display value fallbacks for a given object. + /// + /// Object to flatten + /// Flattened objects after to native. + public static List FlattenToNativeConversionResult(object item) + { + List convertedList = new(); + Stack stack = new(); + stack.Push(item); + + while (stack.Count > 0) + { + object current = stack.Pop(); + + if (current is IEnumerable list) + { + foreach (object subItem in list) + { + stack.Push(subItem); + } + } + else + { + convertedList.Add(current); + } + } + + return convertedList; + } } diff --git a/Core/Tests/Speckle.Core.Tests.Unit/Models/Extensions/BaseExtensionsTests.cs b/Core/Tests/Speckle.Core.Tests.Unit/Models/Extensions/BaseExtensionsTests.cs index 09907b108a..c3c1af34ae 100644 --- a/Core/Tests/Speckle.Core.Tests.Unit/Models/Extensions/BaseExtensionsTests.cs +++ b/Core/Tests/Speckle.Core.Tests.Unit/Models/Extensions/BaseExtensionsTests.cs @@ -31,6 +31,30 @@ public void GetDetachedPropName_Instance(string propertyName) Assert.That(result, Is.EqualTo(propertyName)); } + [Test] + public void TraverseWithPath() + { + var collection = new Collection() { name = "collection" }; + var subCollection = new Collection { name = "subCollection" }; + collection.elements.Add(subCollection); + var data1 = new Base(); + subCollection.elements.Add(data1); + + var basePaths = collection.TraverseWithPath((obj => obj is not Collection)).ToList(); + + Assert.That(basePaths.Count, Is.EqualTo(3)); + Assert.That(basePaths[0].Item2.speckle_type, Is.EqualTo("Speckle.Core.Models.Collection")); + Assert.That(basePaths[0].Item2["name"], Is.EqualTo("collection")); + Assert.That(basePaths[0].Item1, Is.EqualTo(new List())); + + Assert.That(basePaths[1].Item2.speckle_type, Is.EqualTo("Speckle.Core.Models.Collection")); + Assert.That(basePaths[1].Item2["name"], Is.EqualTo("subCollection")); + Assert.That(basePaths[1].Item1, Is.EqualTo(new List() { "collection" })); + + Assert.That(basePaths[2].Item2.speckle_type, Is.EqualTo("Base")); + Assert.That(basePaths[2].Item1, Is.EqualTo(new List() { "collection", "subCollection" })); + } + public class TestBase : Base { public string myProperty { get; set; } diff --git a/Core/Tests/Speckle.Core.Tests.Unit/Models/UtilitiesTests.cs b/Core/Tests/Speckle.Core.Tests.Unit/Models/UtilitiesTests.cs index 00c2e37d72..de34e463c1 100644 --- a/Core/Tests/Speckle.Core.Tests.Unit/Models/UtilitiesTests.cs +++ b/Core/Tests/Speckle.Core.Tests.Unit/Models/UtilitiesTests.cs @@ -28,4 +28,25 @@ public void Sha256(string input, string expected) Assert.That(lower, Is.EqualTo(expected.ToLower())); Assert.That(upper, Is.EqualTo(expected.ToUpper())); } + + [Test] + public void FlattenToNativeConversion() + { + var singleObject = new object(); + var nestedObjects = new List() + { + new List() + { + new(), // obj 1 + new() // obj 2 + }, + new() // obj 3 + }; + + var singleObjectFlattened = Core.Models.Utilities.FlattenToNativeConversionResult(singleObject); + var nestedObjectsFlattened = Core.Models.Utilities.FlattenToNativeConversionResult(nestedObjects); + + Assert.That(singleObjectFlattened.Count, Is.EqualTo(1)); + Assert.That(nestedObjectsFlattened.Count, Is.EqualTo(3)); + } } diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISSendBinding.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISSendBinding.cs index 22c2568fa2..ede5d5644a 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISSendBinding.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISSendBinding.cs @@ -11,6 +11,7 @@ using ICancelable = System.Reactive.Disposables.ICancelable; using Speckle.Connectors.ArcGIS.Utils; using Speckle.Connectors.DUI.Models.Card; +using Speckle.Connectors.DUI.Models.Card.SendFilter; namespace Speckle.Connectors.ArcGIS.Bindings; diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/DependencyInjection/AutofacArcGISModule.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/DependencyInjection/AutofacArcGISModule.cs index 3c199932c5..f7fd4d6f57 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/DependencyInjection/AutofacArcGISModule.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/DependencyInjection/AutofacArcGISModule.cs @@ -16,6 +16,7 @@ using Speckle.Converters.ArcGIS3; using Speckle.Core.Transports; using ArcGIS.Core.Geometry; +using Speckle.Connectors.DUI.Models.Card.SendFilter; namespace Speckle.Connectors.ArcGIS.DependencyInjection; diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Filters/ArcGISEverythingFilter.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Filters/ArcGISEverythingFilter.cs index 67c6edb591..082f0baa1e 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Filters/ArcGISEverythingFilter.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Filters/ArcGISEverythingFilter.cs @@ -1,4 +1,4 @@ -using Speckle.Connectors.DUI.Bindings; +using Speckle.Connectors.DUI.Models.Card.SendFilter; namespace Speckle.Connectors.ArcGIS.Filters; diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Filters/ArcGISSelectionFilter.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Filters/ArcGISSelectionFilter.cs index cea5405f8c..ec71eba13c 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Filters/ArcGISSelectionFilter.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Filters/ArcGISSelectionFilter.cs @@ -1,4 +1,4 @@ -using Speckle.Connectors.DUI.Bindings; +using Speckle.Connectors.DUI.Models.Card.SendFilter; namespace Speckle.Connectors.ArcGIS.Filters; diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Send/RootObjectBuilder.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Send/RootObjectBuilder.cs index bec447a5c7..ac3295b0cc 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Send/RootObjectBuilder.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Send/RootObjectBuilder.cs @@ -1,5 +1,4 @@ using ArcGIS.Desktop.Mapping; -using Speckle.Connectors.DUI.Bindings; using Speckle.Core.Models; using Speckle.Autofac.DependencyInjection; using Speckle.Converters.Common; @@ -8,7 +7,7 @@ namespace Speckle.Connectors.ArcGis.Operations.Send; /// -/// Stateless builder object to turn an into a object +/// Stateless builder object to turn an ISendFilter into a object /// public class RootObjectBuilder { diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadBasicConnectorBinding.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadBasicConnectorBinding.cs index 749132577c..338ade0a59 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadBasicConnectorBinding.cs +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadBasicConnectorBinding.cs @@ -43,6 +43,7 @@ public string GetConnectorVersion() => public DocumentInfo GetDocumentInfo() { + // POC: Will be addressed to move it into AutocadContext! var doc = Application.DocumentManager.MdiActiveDocument; if (doc == null) @@ -77,6 +78,7 @@ public void RemoveModel(ModelCard model) public void HighlightModel(string modelCardId) { + // POC: Will be addressed to move it into AutocadContext! var doc = Application.DocumentManager.MdiActiveDocument; if (doc == null) diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadReceiveBinding.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadReceiveBinding.cs new file mode 100644 index 0000000000..cd4b1390df --- /dev/null +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadReceiveBinding.cs @@ -0,0 +1,98 @@ +using Speckle.Connectors.DUI.Bindings; +using Speckle.Connectors.DUI.Bridge; +using Speckle.Connectors.DUI.Models; +using Speckle.Connectors.Utils.Cancellation; +using Speckle.Connectors.DUI.Models.Card; +using Speckle.Connectors.Utils.Operations; +using Speckle.Core.Logging; +using ICancelable = System.Reactive.Disposables.ICancelable; + +namespace Speckle.Connectors.Autocad.Bindings; + +public sealed class AutocadReceiveBinding : IReceiveBinding, ICancelable +{ + public string Name { get; } = "receiveBinding"; + public IBridge Parent { get; } + + private readonly DocumentModelStore _store; + private readonly CancellationManager _cancellationManager; + + public ReceiveBindingUICommands Commands { get; } + + private readonly ReceiveOperation _receiveOperation; + + public AutocadReceiveBinding( + DocumentModelStore store, + IBridge parent, + ReceiveOperation receiveOperation, + CancellationManager cancellationManager + ) + { + _store = store; + _cancellationManager = cancellationManager; + _receiveOperation = receiveOperation; + Parent = parent; + Commands = new ReceiveBindingUICommands(parent); + } + + public void CancelReceive(string modelCardId) => _cancellationManager.CancelOperation(modelCardId); + + public Task Receive(string modelCardId) + { + Parent.RunOnMainThread(async () => await ReceiveInternal(modelCardId).ConfigureAwait(false)); + return Task.CompletedTask; + } + + private async Task ReceiveInternal(string modelCardId) + { + try + { + // Init cancellation token source -> Manager also cancel it if exist before + CancellationTokenSource cts = _cancellationManager.InitCancellationTokenSource(modelCardId); + + // Get receiver card + if (_store.GetModelById(modelCardId) is not ReceiverModelCard modelCard) + { + throw new InvalidOperationException("No download model card was found."); + } + + // Receive host objects + IEnumerable receivedObjectIds = await _receiveOperation + .Execute( + modelCard.AccountId, // POC: I hear -you are saying why we're passing them separately. Not sure pass the DUI3-> Connectors.DUI project dependency to the SDK-> Connector.Utils + modelCard.ProjectId, + modelCard.ProjectName, + modelCard.ModelName, + modelCard.SelectedVersionId, + cts, + (status, progress) => OnSendOperationProgress(modelCardId, status, progress) + ) + .ConfigureAwait(false); + + Commands.SetModelReceiveResult(modelCardId, receivedObjectIds.ToList()); + } + catch (OperationCanceledException) + { + // POC: not sure here need to handle anything. UI already aware it cancelled operation visually. + return; + } + catch (Exception e) when (!e.IsFatal()) // All exceptions should be handled here if possible, otherwise we enter "crashing the host app" territory. + { + Commands.SetModelError(modelCardId, e); + } + } + + private void OnSendOperationProgress(string modelCardId, string status, double? progress) + { + Commands.SetModelProgress(modelCardId, new ModelCardProgress { Status = status, Progress = progress }); + } + + public void CancelSend(string modelCardId) => _cancellationManager.CancelOperation(modelCardId); + + public void Dispose() + { + IsDisposed = true; + } + + public bool IsDisposed { get; private set; } +} diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadSelectionBinding.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadSelectionBinding.cs index 987852bda0..0848172b75 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadSelectionBinding.cs +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadSelectionBinding.cs @@ -48,6 +48,7 @@ private void OnSelectionChanged() public SelectionInfo GetSelection() { + // POC: Will be addressed to move it into AutocadContext! Document doc = Application.DocumentManager.MdiActiveDocument; List objs = new(); if (doc != null) diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadSendBinding.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadSendBinding.cs index 655306de27..578510051a 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadSendBinding.cs +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadSendBinding.cs @@ -1,5 +1,6 @@ using Autodesk.AutoCAD.DatabaseServices; using Speckle.Connectors.Autocad.HostApp; +using Speckle.Connectors.Autocad.HostApp.Extensions; using Speckle.Connectors.DUI.Bindings; using Speckle.Connectors.DUI.Bridge; using Speckle.Connectors.DUI.Models; @@ -15,6 +16,7 @@ using Speckle.Core.Models; using System.Diagnostics; using ICancelable = System.Reactive.Disposables.ICancelable; +using Speckle.Connectors.DUI.Models.Card.SendFilter; namespace Speckle.Connectors.Autocad.Bindings; diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/DependencyInjection/AutofacAutocadModule.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/DependencyInjection/AutofacAutocadModule.cs index aedb576737..2c8d58cacf 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/DependencyInjection/AutofacAutocadModule.cs +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/DependencyInjection/AutofacAutocadModule.cs @@ -17,6 +17,10 @@ using Speckle.Connectors.Autocad.Interfaces; using Speckle.Connectors.Utils.Cancellation; using Speckle.Connectors.Autocad.Filters; +using Speckle.Connectors.Autocad.Operations.Receive; +using Speckle.Connectors.DUI.Models.Card.SendFilter; +using Speckle.Connectors.Utils.Builders; +using Speckle.Connectors.Utils.Operations; namespace Speckle.Connectors.Autocad.DependencyInjection; @@ -36,13 +40,23 @@ protected override void Load(ContainerBuilder builder) builder.RegisterType().InstancePerDependency(); builder.RegisterInstance(new AutocadDocumentManager()); // TODO: Dependent to TransactionContext, can be moved to AutocadContext builder.RegisterType().As().SingleInstance(); + builder.RegisterType().SingleInstance(); + builder.RegisterType().SingleInstance(); builder.RegisterType().SingleInstance(); + // Operations + builder.RegisterType().AsSelf().SingleInstance(); + + // Object Builders + builder.RegisterType().As().InstancePerDependency(); + // POC: Register here also RootObjectBuilder as IRootObjectBuilder + // Register bindings builder.RegisterType().As().SingleInstance(); builder.RegisterType().As().As().SingleInstance(); builder.RegisterType().As().SingleInstance(); builder.RegisterType().As().SingleInstance(); + builder.RegisterType().As().SingleInstance(); builder .RegisterType() .As>() @@ -59,6 +73,10 @@ protected override void Load(ContainerBuilder builder) .RegisterType>() .As>() .InstancePerLifetimeScope(); + builder + .RegisterType>() + .As>() + .InstancePerLifetimeScope(); } private static JsonSerializerSettings GetJsonSerializerSettings() diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Filters/AutocadSelectionFilter.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Filters/AutocadSelectionFilter.cs index 93e21af46d..7b74ce1688 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Filters/AutocadSelectionFilter.cs +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Filters/AutocadSelectionFilter.cs @@ -1,4 +1,4 @@ -using Speckle.Connectors.DUI.Bindings; +using Speckle.Connectors.DUI.Models.Card.SendFilter; namespace Speckle.Connectors.Autocad.Filters; diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/AutocadContext.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/AutocadContext.cs index ac1a462227..644217d522 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/AutocadContext.cs +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/AutocadContext.cs @@ -3,4 +3,17 @@ namespace Speckle.Connectors.Autocad.HostApp; public class AutocadContext { // POC: we may want to inject this autocadcontext with the active doc? + + private const string INVALID_CHARS = @"<>/\:;""?*|=,‘"; + + // POC: we can move this function into more relevant/general place. Not sure other connectors need similar functionality like this. + public string RemoveInvalidChars(string str) + { + foreach (char c in INVALID_CHARS) + { + str = str.Replace(c.ToString(), string.Empty); + } + + return str; + } } diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/AutocadDocumentModelStore.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/AutocadDocumentModelStore.cs index dd4c073a5d..a90bc169cc 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/AutocadDocumentModelStore.cs +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/AutocadDocumentModelStore.cs @@ -19,6 +19,7 @@ AutocadDocumentManager autocadDocumentManager _autocadDocumentManager = autocadDocumentManager; _previousDocName = _nullDocumentName; + // POC: Will be addressed to move it into AutocadContext! if (Application.DocumentManager.MdiActiveDocument != null) { IsDocumentInit = true; @@ -61,6 +62,7 @@ public override void ReadFromFile() { Models = new List(); + // POC: Will be addressed to move it into AutocadContext! Document doc = Application.DocumentManager.MdiActiveDocument; if (doc == null) @@ -79,6 +81,7 @@ public override void ReadFromFile() public override void WriteToFile() { + // POC: Will be addressed to move it into AutocadContext! Document doc = Application.DocumentManager.MdiActiveDocument; if (doc == null) diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/AutocadLayerManager.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/AutocadLayerManager.cs new file mode 100644 index 0000000000..7fb81ccd82 --- /dev/null +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/AutocadLayerManager.cs @@ -0,0 +1,117 @@ +using Autodesk.AutoCAD.DatabaseServices; +using Autodesk.AutoCAD.EditorInput; +using Autodesk.AutoCAD.LayerManager; + +namespace Speckle.Connectors.Autocad.HostApp; + +public class AutocadLayerManager +{ + private readonly AutocadContext _autocadContext; + private readonly string _layerFilterName = "Speckle"; + + // POC: Will be addressed to move it into AutocadContext! + private Document Doc => Autodesk.AutoCAD.ApplicationServices.Core.Application.DocumentManager.MdiActiveDocument; + + public AutocadLayerManager(AutocadContext autocadContext) + { + _autocadContext = autocadContext; + } + + /// + /// Constructs layer name with prefix and valid characters. + /// + /// Prefix to add layer name. + /// list of entries to concat with hyphen. + /// Full layer name with provided prefix and path. + public string LayerFullName(string baseLayerPrefix, string path) + { + var layerFullName = baseLayerPrefix + string.Join("-", path); + return _autocadContext.RemoveInvalidChars(layerFullName); + } + + /// + /// Will create a layer with the provided name, or, if it finds an existing one, will "purge" all objects from it. + /// This ensures we're creating the new objects we've just received rather than overlaying them. + /// + /// Name to search layer for purge and create. + public void CreateLayerOrPurge(string layerName) + { + // POC: Will be addressed to move it into AutocadContext! + Document doc = Application.DocumentManager.MdiActiveDocument; + doc.LockDocument(); + using Transaction transaction = doc.TransactionManager.StartTransaction(); + + LayerTable? layerTable = + transaction.TransactionManager.GetObject(doc.Database.LayerTableId, OpenMode.ForRead) as LayerTable; + LayerTableRecord layerTableRecord = new() { Name = layerName }; + + bool hasLayer = layerTable != null && layerTable.Has(layerName); + if (hasLayer) + { + TypedValue[] tvs = { new((int)DxfCode.LayerName, layerName) }; + SelectionFilter selectionFilter = new(tvs); + SelectionSet selectionResult = doc.Editor.SelectAll(selectionFilter).Value; + if (selectionResult == null) + { + return; + } + foreach (SelectedObject selectedObject in selectionResult) + { + transaction.GetObject(selectedObject.ObjectId, OpenMode.ForWrite).Erase(); + } + + return; + } + + layerTable?.UpgradeOpen(); + layerTable?.Add(layerTableRecord); + transaction.AddNewlyCreatedDBObject(layerTableRecord, true); + transaction.Commit(); + } + + // POC: Consider to extract somehow in factory or service! + /// + /// Creates a layer filter for the just received model, grouped under a top level filter "Speckle". Note: manual close and open of the layer properties panel required (it's an acad thing). + /// This comes in handy to quickly access the layers created for this specific model. + /// + /// + /// + public void CreateLayerFilter(string projectName, string modelName) + { + using var docLock = Doc.LockDocument(); + string filterName = _autocadContext.RemoveInvalidChars($@"{projectName}-{modelName}"); + LayerFilterTree layerFilterTree = Doc.Database.LayerFilters; + LayerFilterCollection? layerFilterCollection = layerFilterTree.Root.NestedFilters; + LayerFilter? groupFilter = null; + + // Find existing layer filter if exists + foreach (LayerFilter existingFilter in layerFilterCollection) + { + if (existingFilter.Name == _layerFilterName) + { + groupFilter = existingFilter; + break; + } + } + + // Create new one unless exists + if (groupFilter == null) + { + groupFilter = new LayerFilter() { Name = "Speckle", FilterExpression = $"NAME==\"SPK-*\"" }; + layerFilterCollection.Add(groupFilter); + } + + string layerFilterExpression = $"NAME==\"SPK-{filterName}*\""; + foreach (LayerFilter lf in groupFilter.NestedFilters) + { + if (lf.Name == filterName) + { + lf.FilterExpression = layerFilterExpression; + return; + } + } + var layerFilter = new LayerFilter() { Name = filterName, FilterExpression = layerFilterExpression }; + groupFilter.NestedFilters.Add(layerFilter); + Doc.Database.LayerFilters = layerFilterTree; + } +} diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/Extensions/DatabaseExtensions.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/Extensions/DatabaseExtensions.cs new file mode 100644 index 0000000000..a763aa9eab --- /dev/null +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/Extensions/DatabaseExtensions.cs @@ -0,0 +1,15 @@ +using Autodesk.AutoCAD.DatabaseServices; + +namespace Speckle.Connectors.Autocad.HostApp.Extensions; + +public static class DatabaseExtensions +{ + /// + /// Gets the document model space + /// + /// + /// + /// + public static BlockTableRecord GetModelSpace(this Database db, OpenMode mode = OpenMode.ForRead) => + (BlockTableRecord)SymbolUtilityServices.GetBlockModelSpaceId(db).GetObject(mode); +} diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Utils.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/Extensions/DocumentExtensions.cs similarity index 87% rename from DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Utils.cs rename to DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/Extensions/DocumentExtensions.cs index e9111d8601..5462c67269 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Utils.cs +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/Extensions/DocumentExtensions.cs @@ -1,7 +1,6 @@ -using Autodesk.AutoCAD.DatabaseServices; -using Speckle.Connectors.Autocad.HostApp; +using Autodesk.AutoCAD.DatabaseServices; -namespace Speckle.Connectors.Autocad; +namespace Speckle.Connectors.Autocad.HostApp.Extensions; public static class DocumentExtensions { diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/Extensions/EntityExtensions.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/Extensions/EntityExtensions.cs new file mode 100644 index 0000000000..1ddc70d912 --- /dev/null +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/Extensions/EntityExtensions.cs @@ -0,0 +1,45 @@ +using Autodesk.AutoCAD.DatabaseServices; + +namespace Speckle.Connectors.Autocad.HostApp.Extensions; + +public static class EntityExtensions +{ + /// + /// Adds an entity to the autocad database model space record + /// + /// Entity to add into database. + /// Layer to append object. + /// Throws when there is no top transaction in the document. + public static ObjectId Append(this Entity entity, string? layer = null) + { + // POC: Will be addressed to move it into AutocadContext! + var db = entity.Database ?? Application.DocumentManager.MdiActiveDocument.Database; + Transaction tr = db.TransactionManager.TopTransaction; + if (tr == null) + { + throw new InvalidOperationException($"Document does not have a top transaction."); + } + + BlockTableRecord btr = db.GetModelSpace(OpenMode.ForWrite); + if (entity.IsNewObject) + { + if (layer != null) + { + entity.Layer = layer; + } + + var id = btr.AppendEntity(entity); + tr.AddNewlyCreatedDBObject(entity, true); + return id; + } + else + { + if (layer != null) + { + entity.Layer = layer; + } + + return entity.Id; + } + } +} diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Operations/Receive/HostObjectBuilder.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Operations/Receive/HostObjectBuilder.cs new file mode 100644 index 0000000000..5b9c2463fe --- /dev/null +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Operations/Receive/HostObjectBuilder.cs @@ -0,0 +1,114 @@ +using System.Diagnostics; +using Autodesk.AutoCAD.DatabaseServices; +using Speckle.Autofac.DependencyInjection; +using Speckle.Connectors.Autocad.HostApp; +using Speckle.Connectors.Autocad.HostApp.Extensions; +using Speckle.Core.Models; +using Speckle.Connectors.Utils.Builders; +using Speckle.Converters.Common; +using Speckle.Core.Logging; +using Speckle.Core.Models.Extensions; + +namespace Speckle.Connectors.Autocad.Operations.Receive; + +public class HostObjectBuilder : IHostObjectBuilder +{ + private readonly IScopedFactory _speckleConverterToHostFactory; + private readonly AutocadLayerManager _autocadLayerManager; + + public HostObjectBuilder( + IScopedFactory speckleConverterToHostFactory, + AutocadLayerManager autocadLayerManager + ) + { + _speckleConverterToHostFactory = speckleConverterToHostFactory; + _autocadLayerManager = autocadLayerManager; + } + + private List<(List, Base)> GetBaseWithPath(Base commitObject, CancellationTokenSource cts) + { + List<(List, Base)> objectsToConvert = new(); + foreach ((List objPath, Base obj) in commitObject.TraverseWithPath((obj) => obj is not Collection)) + { + if (cts.IsCancellationRequested) + { + throw new OperationCanceledException(cts.Token); + } + + if (obj is not Collection) // POC: equivalent of converter.CanConvertToNative(obj) ? + { + objectsToConvert.Add((objPath, obj)); + } + } + + return objectsToConvert; + } + + public IEnumerable Build( + Base rootObject, + string projectName, + string modelName, + Action? onOperationProgressed, + CancellationTokenSource cts + ) + { + // Prompt the UI conversion started. Progress bar will swoosh. + onOperationProgressed?.Invoke("Converting", null); + + ISpeckleConverterToHost converter = _speckleConverterToHostFactory.ResolveScopedInstance(); + + // Layer filter for received commit with project and model name + _autocadLayerManager.CreateLayerFilter(projectName, modelName); + List<(List, Base)> objectsWithPath = GetBaseWithPath(rootObject, cts); + string baseLayerPrefix = $"SPK-{projectName}-{modelName}-"; + + HashSet uniqueLayerNames = new(); + List handleValues = new(); + int count = 0; + + // POC: Will be addressed to move it into AutocadContext! + using (TransactionContext.StartTransaction(Application.DocumentManager.MdiActiveDocument)) + { + foreach ((List path, Base obj) in objectsWithPath) + { + if (cts.IsCancellationRequested) + { + throw new OperationCanceledException(cts.Token); + } + + try + { + string layerFullName = _autocadLayerManager.LayerFullName(baseLayerPrefix, string.Join("-", path)); + + if (uniqueLayerNames.Add(layerFullName)) + { + _autocadLayerManager.CreateLayerOrPurge(layerFullName); + } + + object converted = converter.Convert(obj); + List flattened = Core.Models.Utilities.FlattenToNativeConversionResult(converted); + + foreach (Entity conversionResult in flattened.Cast()) + { + if (conversionResult == null) + { + continue; + } + + conversionResult.Append(layerFullName); + + handleValues.Add(conversionResult.Handle.Value.ToString()); + } + + onOperationProgressed?.Invoke("Converting", (double)++count / objectsWithPath.Count); + } + catch (Exception e) when (!e.IsFatal()) // DO NOT CATCH SPECIFIC STUFF, conversion errors should be recoverable + { + // POC: report, etc. + Debug.WriteLine("conversion error happened."); + } + } + } + return handleValues; + } +} diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Plugin/AutocadCommand.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Plugin/AutocadCommand.cs index 343ac1471e..db5afd50fa 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Plugin/AutocadCommand.cs +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Plugin/AutocadCommand.cs @@ -69,6 +69,8 @@ private void FocusPalette() private void ContainerPreBuildEvent(object sender, ContainerBuilder containerBuilder) { + containerBuilder.RegisterRawConversions(); containerBuilder.InjectNamedTypes(); + containerBuilder.InjectNamedTypes(); } } diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Speckle.Connectors.AutocadShared.projitems b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Speckle.Connectors.AutocadShared.projitems index 0ba9506a19..7fbcdb3f92 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Speckle.Connectors.AutocadShared.projitems +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Speckle.Connectors.AutocadShared.projitems @@ -13,6 +13,7 @@ + @@ -21,18 +22,22 @@ + DUI3PanelWebView.xaml + + + + - diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/Filters.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/Filters.cs index 99675c5032..7d9a5133fe 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/Filters.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/Filters.cs @@ -1,6 +1,6 @@ using System.Collections.Generic; using System.Linq; -using Speckle.Connectors.DUI.Bindings; +using Speckle.Connectors.DUI.Models.Card.SendFilter; namespace Speckle.Connectors.Revit.Bindings; diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SendBinding.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SendBinding.cs index 4f898b9907..8cc0020f59 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SendBinding.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SendBinding.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using System.Linq; using Autodesk.Revit.DB; -using Speckle.Connectors.DUI.Bindings; +using Speckle.Connectors.DUI.Models.Card.SendFilter; using Speckle.Connectors.Utils.Cancellation; using Speckle.Connectors.DUI.Bridge; using Speckle.Connectors.Revit.HostApp; @@ -14,6 +14,7 @@ using Speckle.Converters.RevitShared.Helpers; using Speckle.Connectors.Revit.Operations.Send; using Speckle.Connectors.DUI.Models.Card; +using Speckle.Connectors.DUI.Bindings; namespace Speckle.Connectors.Revit.Bindings; diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/AutofacUIModule.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/AutofacUIModule.cs index 498629494a..b3cd9c20f6 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/AutofacUIModule.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/AutofacUIModule.cs @@ -6,6 +6,7 @@ using Serilog; using Speckle.Connectors.DUI.Bindings; using Speckle.Connectors.DUI.Bridge; +using Speckle.Connectors.DUI.Models.Card.SendFilter; using Speckle.Connectors.DUI.Utils; using Speckle.Connectors.Revit.Bindings; using Speckle.Connectors.Revit.HostApp; diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RootObjectBuilder.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RootObjectBuilder.cs index 9ec03b3634..75decd30e6 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RootObjectBuilder.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RootObjectBuilder.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using Speckle.Connectors.DUI.Bindings; using Speckle.Converters.Common; using Speckle.Core.Models; using System.Threading; @@ -8,6 +7,7 @@ using Speckle.Converters.RevitShared.Helpers; using Speckle.Connectors.Revit.HostApp; using System.Linq; +using Speckle.Connectors.DUI.Models.Card.SendFilter; namespace Speckle.Connectors.Revit.Operations.Send; diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/SendOperation.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/SendOperation.cs index d223a0df61..ba96aacd6e 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/SendOperation.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/SendOperation.cs @@ -1,9 +1,9 @@ using System; -using Speckle.Connectors.DUI.Bindings; using Speckle.Core.Models; using System.Threading.Tasks; using System.Threading; using Autofac; +using Speckle.Connectors.DUI.Models.Card.SendFilter; namespace Speckle.Connectors.Revit.Operations.Send; diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSendBinding.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSendBinding.cs index deafbc25fd..fd55a7ffbd 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSendBinding.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSendBinding.cs @@ -15,6 +15,7 @@ using ICancelable = System.Reactive.Disposables.ICancelable; using System.Threading.Tasks; using Speckle.Connectors.Rhino7.Operations.Send; +using Speckle.Connectors.DUI.Models.Card.SendFilter; namespace Speckle.Connectors.Rhino7.Bindings; diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/AutofacRhinoModule.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/AutofacRhinoModule.cs index 5222a889bf..5be40620ff 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/AutofacRhinoModule.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/AutofacRhinoModule.cs @@ -22,6 +22,7 @@ using Speckle.Converters.Rhino7; using Speckle.Newtonsoft.Json; using Speckle.Newtonsoft.Json.Serialization; +using Speckle.Connectors.DUI.Models.Card.SendFilter; namespace Speckle.Connectors.Rhino7.DependencyInjection; diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Filters/RhinoEverythingFilter.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Filters/RhinoEverythingFilter.cs index fefb2acf0d..1bd052be6b 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Filters/RhinoEverythingFilter.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Filters/RhinoEverythingFilter.cs @@ -1,5 +1,5 @@ using System.Collections.Generic; -using Speckle.Connectors.DUI.Bindings; +using Speckle.Connectors.DUI.Models.Card.SendFilter; namespace Speckle.Connectors.Rhino7.Filters; diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Filters/RhinoSelectionFilter.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Filters/RhinoSelectionFilter.cs index 7a9db8a5d0..d103620d66 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Filters/RhinoSelectionFilter.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Filters/RhinoSelectionFilter.cs @@ -1,6 +1,6 @@ using System.Collections.Generic; using System.Linq; -using Speckle.Connectors.DUI.Bindings; +using Speckle.Connectors.DUI.Models.Card.SendFilter; namespace Speckle.Connectors.Rhino7.Filters; diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Send/RootObjectBuilder.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Send/RootObjectBuilder.cs index d47cb8f345..02400cd722 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Send/RootObjectBuilder.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Send/RootObjectBuilder.cs @@ -3,11 +3,11 @@ using System.Linq; using Rhino.DocObjects; using Rhino; -using Speckle.Connectors.DUI.Bindings; using Speckle.Core.Models; using System.Threading; using Speckle.Autofac.DependencyInjection; using Speckle.Converters.Common; +using Speckle.Connectors.DUI.Models.Card.SendFilter; namespace Speckle.Connectors.Rhino7.Operations.Send; diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Send/SendOperation.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Send/SendOperation.cs index 96860d4dfd..bcaf356954 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Send/SendOperation.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Send/SendOperation.cs @@ -1,7 +1,7 @@ using System; using System.Threading; using System.Threading.Tasks; -using Speckle.Connectors.DUI.Bindings; +using Speckle.Connectors.DUI.Models.Card.SendFilter; using Speckle.Core.Models; namespace Speckle.Connectors.Rhino7.Operations.Send; diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/AutocadConverterToHost.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/AutocadConverterToHost.cs new file mode 100644 index 0000000000..d856376a88 --- /dev/null +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/AutocadConverterToHost.cs @@ -0,0 +1,41 @@ +using System; +using Speckle.Autofac.DependencyInjection; +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; +using Speckle.Core.Models; + +namespace Speckle.Converters.Autocad; + +public class AutocadConverterToHost : ISpeckleConverterToHost +{ + private readonly IFactory _toHost; + + public AutocadConverterToHost(IFactory toHost) + { + _toHost = toHost; + } + + public object Convert(Base target) + { + Type type = target.GetType(); + + try + { + var objectConverter = _toHost.ResolveInstance(type.Name); + + if (objectConverter == null) + { + throw new NotSupportedException($"No conversion found for {target.GetType().Name}"); + } + + var convertedObject = objectConverter.Convert(target); + + return convertedObject; + } + catch (SpeckleConversionException e) + { + Console.WriteLine(e); + throw; // POC: Just rethrowing for now, Logs may be needed here. + } + } +} diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/AutocadConverterToSpeckle.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/AutocadConverterToSpeckle.cs index 947d33df81..a70a3ac898 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/AutocadConverterToSpeckle.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/AutocadConverterToSpeckle.cs @@ -10,15 +10,10 @@ namespace Speckle.Converters.Autocad; public class AutocadConverterToSpeckle : ISpeckleConverterToSpeckle { private readonly IFactory _toSpeckle; - private readonly IHostToSpeckleUnitConverter _unitConverter; - public AutocadConverterToSpeckle( - IFactory toSpeckle, - IHostToSpeckleUnitConverter unitConverter - ) + public AutocadConverterToSpeckle(IFactory toSpeckle) { _toSpeckle = toSpeckle; - _unitConverter = unitConverter; } public Base Convert(object target) diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/DependencyInjection/AutofacAutocadConverterModule.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/DependencyInjection/AutofacAutocadConverterModule.cs index e71b1f34fe..371792b9e2 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/DependencyInjection/AutofacAutocadConverterModule.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/DependencyInjection/AutofacAutocadConverterModule.cs @@ -15,6 +15,7 @@ protected override void Load(ContainerBuilder builder) // should be InstancePerLifetimeScope // most things should be InstancePerLifetimeScope so we get one per operation builder.RegisterType().As().SingleInstance(); + builder.RegisterType().As().SingleInstance(); // single stack per conversion builder @@ -26,5 +27,8 @@ protected override void Load(ContainerBuilder builder) builder .RegisterType>() .As>(); + builder + .RegisterType>() + .As>(); } } diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/Geometry/PointToHostConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/Geometry/PointToHostConverter.cs new file mode 100644 index 0000000000..90075dbfca --- /dev/null +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/Geometry/PointToHostConverter.cs @@ -0,0 +1,52 @@ +using Speckle.Converters.Common.Objects; +using Speckle.Converters.Common; +using Speckle.Core.Models; +using Autodesk.AutoCAD.DatabaseServices; +using Speckle.Core.Kits; + +namespace Speckle.Converters.Autocad.Geometry; + +[NameAndRankValue(nameof(SOG.Point), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +public class DBPointToHostConverter : ISpeckleObjectToHostConversion, IRawConversion +{ + private readonly IRawConversion _pointConverter; + private readonly IConversionContextStack _contextStack; + + public DBPointToHostConverter( + IRawConversion pointConverter, + IConversionContextStack contextStack + ) + { + _pointConverter = pointConverter; + _contextStack = contextStack; + } + + public object Convert(Base target) => RawConvert((SOG.Point)target); + + public DBPoint RawConvert(SOG.Point target) + { + double f = Units.GetConversionFactor(target.units, _contextStack.Current.SpeckleUnits); + AG.Point3d point = new(target.x * f, target.y * f, target.z * f); + return new(point); + } +} + +public class PointToHostConverter : IRawConversion +{ + private readonly IConversionContextStack _contextStack; + + public PointToHostConverter(IConversionContextStack contextStack) + { + _contextStack = contextStack; + } + + public object Convert(Base target) => RawConvert((SOG.Point)target); + + public AG.Point3d RawConvert(SOG.Point target) + { + double f = Units.GetConversionFactor(target.units, _contextStack.Current.SpeckleUnits); + AG.Point3d point = new(target.x * f, target.y * f, target.z * f); + + return point; + } +} diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/Geometry/PointToSpeckleConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/Geometry/PointToSpeckleConverter.cs index 739ca3ebf6..80d94b9efe 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/Geometry/PointToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/Geometry/PointToSpeckleConverter.cs @@ -25,8 +25,7 @@ IConversionContextStack contextStack public SOG.Point RawConvert(DBPoint target) => _pointConverter.RawConvert(target.Position); } -[NameAndRankValue(nameof(AG.Point3d), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class PointToSpeckleConverter : IHostObjectToSpeckleConversion, IRawConversion +public class PointToSpeckleConverter : IRawConversion { private readonly IConversionContextStack _contextStack; diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/Speckle.Converters.AutocadShared.projitems b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/Speckle.Converters.AutocadShared.projitems index f9a4c6f919..b0f45481bf 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/Speckle.Converters.AutocadShared.projitems +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/Speckle.Converters.AutocadShared.projitems @@ -9,6 +9,7 @@ Speckle.Converters.AutocadShared + @@ -17,6 +18,7 @@ + diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/IReceiveBinding.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/IReceiveBinding.cs index afd6eb4fa0..136c55e310 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/IReceiveBinding.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/IReceiveBinding.cs @@ -1,4 +1,4 @@ -using Speckle.Connectors.DUI.Models.Card; +using System.Threading.Tasks; namespace Speckle.Connectors.DUI.Bindings; @@ -8,8 +8,7 @@ public interface IReceiveBinding : IBinding /// Instructs the host app to start receiving this model version. /// /// Model card id - /// Version id to receive - public void Receive(string modelCardId, string versionId); + public Task Receive(string modelCardId); /// /// Instructs the host app to cancel the receiving for a given model. @@ -17,12 +16,3 @@ public interface IReceiveBinding : IBinding /// public void CancelReceive(string modelCardId); } - -public static class ReceiveBindingEvents -{ - public const string RECEIVERS_EXPIRED = "receiversExpired"; - public const string RECEIVERS_PROGRESS = "receiverProgress"; - public const string NOTIFY = "notify"; -} - -public class ReceiverModelCard : ModelCard { } diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/ISendBinding.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/ISendBinding.cs index 45a4b1f6ba..75f54eb6e0 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/ISendBinding.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/ISendBinding.cs @@ -1,8 +1,6 @@ using System.Collections.Generic; using System.Threading.Tasks; -using Speckle.Connectors.DUI.Models.Card; -using Speckle.Connectors.DUI.Utils; -using Speckle.Newtonsoft.Json; +using Speckle.Connectors.DUI.Models.Card.SendFilter; namespace Speckle.Connectors.DUI.Bindings; @@ -24,56 +22,3 @@ public interface ISendBinding : IBinding public SendBindingUICommands Commands { get; } } - -public class SenderModelCard : ModelCard -{ - public ISendFilter SendFilter { get; set; } - - [JsonIgnore] - public HashSet ChangedObjectIds { get; set; } = new(); -} - -public interface ISendFilter -{ - public string Name { get; set; } - public string Summary { get; set; } - public bool IsDefault { get; set; } - - /// - /// Gets the ids of the objects targeted by the filter from the host application. - /// - /// - public List GetObjectIds(); - - /// - /// Checks whether any of the targeted objects are affected by changes from the host application. - /// - /// - /// - public bool CheckExpiry(string[] changedObjectIds); -} - -public abstract class EverythingSendFilter : DiscriminatedObject, ISendFilter -{ - public string Name { get; set; } = "Everything"; - public string Summary { get; set; } = "All supported objects in the file."; - public bool IsDefault { get; set; } - public abstract List GetObjectIds(); - public abstract bool CheckExpiry(string[] changedObjectIds); -} - -public abstract class DirectSelectionSendFilter : DiscriminatedObject, ISendFilter -{ - public string Name { get; set; } = "Selection"; - public string Summary { get; set; } - public bool IsDefault { get; set; } - public List SelectedObjectIds { get; set; } = new List(); - public abstract List GetObjectIds(); - public abstract bool CheckExpiry(string[] changedObjectIds); -} - -public class CreateVersionArgs -{ - public string ModelCardId { get; set; } - public string ObjectId { get; set; } -} diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/ReceiveBindingUICommands.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/ReceiveBindingUICommands.cs new file mode 100644 index 0000000000..6b9bde8b02 --- /dev/null +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/ReceiveBindingUICommands.cs @@ -0,0 +1,25 @@ +using System.Collections.Generic; +using Speckle.Connectors.DUI.Bridge; +using Speckle.Connectors.DUI.Models.Card; + +namespace Speckle.Connectors.DUI.Bindings; + +public class ReceiveBindingUICommands : BasicConnectorBindingCommands +{ + // POC: put here events once we needed for receive specific + private const string SET_MODEL_RECEIVE_RESULT_UI_COMMAND_NAME = "setModelReceiveResult"; + + public ReceiveBindingUICommands(IBridge bridge) + : base(bridge) { } + + public void SetModelReceiveResult(string modelCardId, List bakedObjectIds) + { + ReceiverModelCardResult res = + new() + { + ModelCardId = modelCardId, + ReceiveResult = new ReceiveResult() { BakedObjectIds = bakedObjectIds } + }; + Bridge.Send(SET_MODEL_RECEIVE_RESULT_UI_COMMAND_NAME, res); + } +} diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/CreateVersionArgs.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/CreateVersionArgs.cs new file mode 100644 index 0000000000..7a71b2d071 --- /dev/null +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/CreateVersionArgs.cs @@ -0,0 +1,7 @@ +namespace Speckle.Connectors.DUI.Models.Card; + +public class CreateVersionArgs +{ + public string ModelCardId { get; set; } + public string ObjectId { get; set; } +} diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/ReceiveResult.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/ReceiveResult.cs new file mode 100644 index 0000000000..78d0e23aca --- /dev/null +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/ReceiveResult.cs @@ -0,0 +1,9 @@ +using System.Collections.Generic; + +namespace Speckle.Connectors.DUI.Models.Card; + +public class ReceiveResult +{ + public List BakedObjectIds { get; set; } + public bool Display { get; set; } +} diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/ReceiverModelCard.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/ReceiverModelCard.cs new file mode 100644 index 0000000000..f2c563ea33 --- /dev/null +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/ReceiverModelCard.cs @@ -0,0 +1,9 @@ +namespace Speckle.Connectors.DUI.Models.Card; + +public class ReceiverModelCard : ModelCard +{ + public string ProjectName { get; set; } + public string ModelName { get; set; } + public string SelectedVersionId { get; set; } + public string LatestVersionId { get; set; } +} diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/ReceiverModelCardResult.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/ReceiverModelCardResult.cs new file mode 100644 index 0000000000..aae9f9b67f --- /dev/null +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/ReceiverModelCardResult.cs @@ -0,0 +1,7 @@ +namespace Speckle.Connectors.DUI.Models.Card; + +public class ReceiverModelCardResult +{ + public string ModelCardId { get; set; } + public ReceiveResult ReceiveResult { get; set; } +} diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/SendFilter/DirectSelectionSendFilter.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/SendFilter/DirectSelectionSendFilter.cs new file mode 100644 index 0000000000..eee7c6a5f6 --- /dev/null +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/SendFilter/DirectSelectionSendFilter.cs @@ -0,0 +1,14 @@ +using System.Collections.Generic; +using Speckle.Connectors.DUI.Utils; + +namespace Speckle.Connectors.DUI.Models.Card.SendFilter; + +public abstract class DirectSelectionSendFilter : DiscriminatedObject, ISendFilter +{ + public string Name { get; set; } = "Selection"; + public string Summary { get; set; } + public bool IsDefault { get; set; } + public List SelectedObjectIds { get; set; } = new List(); + public abstract List GetObjectIds(); + public abstract bool CheckExpiry(string[] changedObjectIds); +} diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/SendFilter/EverythingSendFilter.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/SendFilter/EverythingSendFilter.cs new file mode 100644 index 0000000000..adc5151503 --- /dev/null +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/SendFilter/EverythingSendFilter.cs @@ -0,0 +1,13 @@ +using System.Collections.Generic; +using Speckle.Connectors.DUI.Utils; + +namespace Speckle.Connectors.DUI.Models.Card.SendFilter; + +public abstract class EverythingSendFilter : DiscriminatedObject, ISendFilter +{ + public string Name { get; set; } = "Everything"; + public string Summary { get; set; } = "All supported objects in the file."; + public bool IsDefault { get; set; } + public abstract List GetObjectIds(); + public abstract bool CheckExpiry(string[] changedObjectIds); +} diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/SendFilter/ISendFilter.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/SendFilter/ISendFilter.cs new file mode 100644 index 0000000000..0b7d1a745c --- /dev/null +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/SendFilter/ISendFilter.cs @@ -0,0 +1,23 @@ +using System.Collections.Generic; + +namespace Speckle.Connectors.DUI.Models.Card.SendFilter; + +public interface ISendFilter +{ + public string Name { get; set; } + public string Summary { get; set; } + public bool IsDefault { get; set; } + + /// + /// Gets the ids of the objects targeted by the filter from the host application. + /// + /// + public List GetObjectIds(); + + /// + /// Checks whether any of the targeted objects are affected by changes from the host application. + /// + /// + /// + public bool CheckExpiry(string[] changedObjectIds); +} diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/SenderModelCard.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/SenderModelCard.cs new file mode 100644 index 0000000000..3d8376b037 --- /dev/null +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/SenderModelCard.cs @@ -0,0 +1,13 @@ +using System.Collections.Generic; +using Speckle.Connectors.DUI.Models.Card.SendFilter; +using Speckle.Newtonsoft.Json; + +namespace Speckle.Connectors.DUI.Models.Card; + +public class SenderModelCard : ModelCard +{ + public ISendFilter SendFilter { get; set; } + + [JsonIgnore] + public HashSet ChangedObjectIds { get; set; } = new(); +} diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/DocumentModelStore.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/DocumentModelStore.cs index 1c35fe52fe..e692aad5aa 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/DocumentModelStore.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/DocumentModelStore.cs @@ -4,7 +4,6 @@ using Speckle.Connectors.DUI.Utils; using Speckle.Connectors.DUI.Objects; using Speckle.Newtonsoft.Json; -using Speckle.Connectors.DUI.Bindings; using Speckle.Connectors.DUI.Models.Card; namespace Speckle.Connectors.DUI.Models; diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Speckle.Connectors.DUI.csproj b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Speckle.Connectors.DUI.csproj index b85049117f..083ee37f8d 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Speckle.Connectors.DUI.csproj +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Speckle.Connectors.DUI.csproj @@ -16,6 +16,11 @@ + + + + + diff --git a/DUI3-DX/Sdk/Speckle.Connectors.Utils/Builders/IHostObjectBuilder.cs b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Builders/IHostObjectBuilder.cs new file mode 100644 index 0000000000..94d5f9ae7c --- /dev/null +++ b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Builders/IHostObjectBuilder.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.Threading; +using Speckle.Core.Models; + +namespace Speckle.Connectors.Utils.Builders; + +// POC: We might consider to put also IRootObjectBuilder interface here in same folder and create concrete classes from it in per connector. +public interface IHostObjectBuilder +{ + /// + /// Build host application objects from root commit object. + /// + /// Commit object that received from server. + /// Project of the model. + /// Name of the model. + /// Action to update UI progress bar. + /// Cancellation token that passed from top -> ReceiveBinding. + /// List of application ids. // POC: Where we will return these ids will matter later when we target to also cache received application ids. + /// Project and model name are needed for now to construct host app objects into related layers or filters. + /// POC: we might consider later to have HostObjectBuilderContext? that might hold all possible data we will need. + IEnumerable Build( + Base rootObject, + string projectName, + string modelName, + Action? onOperationProgressed, + CancellationTokenSource cts + ); +} diff --git a/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/ReceiveOperation.cs b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/ReceiveOperation.cs new file mode 100644 index 0000000000..a3edbb7690 --- /dev/null +++ b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/ReceiveOperation.cs @@ -0,0 +1,60 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using Speckle.Connectors.Utils.Builders; +using Speckle.Core.Api; +using Speckle.Core.Credentials; +using Speckle.Core.Logging; +using Speckle.Core.Models; +using Speckle.Core.Transports; + +namespace Speckle.Connectors.Utils.Operations; + +public sealed class ReceiveOperation +{ + private readonly IHostObjectBuilder _hostObjectBuilder; + + public ReceiveOperation(IHostObjectBuilder hostObjectBuilder) + { + _hostObjectBuilder = hostObjectBuilder; + } + + public async Task> Execute( + string accountId, // POC: all these string arguments exists in ModelCard but not sure to pass this dependency here, TBD! + string projectId, + string projectName, + string modelName, + string versionId, + CancellationTokenSource cts, + Action? onOperationProgressed = null + ) + { + // 2 - Check account exist + Account account = + AccountManager.GetAccounts().FirstOrDefault(acc => acc.id == accountId) + ?? throw new SpeckleAccountManagerException(); + + // 3 - Get commit object from server + Client apiClient = new(account); + ServerTransport transport = new(account, projectId); + Commit? version = + await apiClient.CommitGet(projectId, versionId, cts.Token).ConfigureAwait(false) + ?? throw new SpeckleException($"Failed to receive commit: {versionId} from server)"); + + Base? commitObject = + await Speckle.Core.Api.Operations + .Receive(version.referencedObject, cancellationToken: cts.Token, remoteTransport: transport) + .ConfigureAwait(false) + ?? throw new SpeckleException( + $"Failed to receive commit: {version.id} objects from server: {nameof(Operations)} returned null" + ); + + apiClient.Dispose(); + cts.Token.ThrowIfCancellationRequested(); + + // 4 - Convert objects + return _hostObjectBuilder.Build(commitObject, projectName, modelName, onOperationProgressed, cts); + } +} diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common/ISpeckleConverterToHost.cs b/DUI3-DX/Sdk/Speckle.Converters.Common/ISpeckleConverterToHost.cs index 4f50dd644e..e24e1ddebe 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common/ISpeckleConverterToHost.cs +++ b/DUI3-DX/Sdk/Speckle.Converters.Common/ISpeckleConverterToHost.cs @@ -1,6 +1,8 @@ +using Speckle.Core.Models; + namespace Speckle.Converters.Common; public interface ISpeckleConverterToHost { - void Convert(); + object Convert(Base target); } diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common/Objects/ISpeckleObjectToHostConversion.cs b/DUI3-DX/Sdk/Speckle.Converters.Common/Objects/ISpeckleObjectToHostConversion.cs index 0bdbbf648a..ffb203143f 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common/Objects/ISpeckleObjectToHostConversion.cs +++ b/DUI3-DX/Sdk/Speckle.Converters.Common/Objects/ISpeckleObjectToHostConversion.cs @@ -1,10 +1,12 @@ +using Speckle.Core.Models; + namespace Speckle.Converters.Common.Objects; // POC: NEXT UP // * begin scope: https://stackoverflow.com/questions/49595198/autofac-resolving-through-factory-methods // Interceptors? -public interface IHostToSpeckleConverter +public interface ISpeckleObjectToHostConversion { - void Convert(); + object Convert(Base target); } From 1741b8492ce9930967ed93af7e0521ea3fe81e28 Mon Sep 17 00:00:00 2001 From: Alan Rynne Date: Tue, 9 Apr 2024 11:42:48 +0200 Subject: [PATCH 023/261] CNX-9142 DUI3-DX Rhino Receive connector structure with no conversions (#3262) * feat: Receive operation in Rhino WIP Plus improvements in token cancellation, converter/connector separation and module cleanup * fix: Move RhinoConverter to native * fix: Renamed RhinoConverterToNative to ToHost * fix: Build warnigns on CI * chore: Add POC comments where necessary based on PR comments * fix: missing using --- DUI3-DX.slnf | 7 +- .../Bindings/AutocadReceiveBinding.cs | 2 +- .../Operations/Receive/HostObjectBuilder.cs | 16 +-- .../Bindings/RhinoReceiveBinding.cs | 93 ++++++++++++ .../DependencyInjection/AutofacRhinoModule.cs | 19 ++- .../HostApp/SpeckleRhinoPanel.xaml.cs | 1 - .../Receive/RhinoHostObjectBuilder.cs | 134 ++++++++++++++++++ .../Plugin/Speckle.Connectors.Rhino7Plugin.cs | 14 +- .../Speckle.Connectors.Rhino7.csproj | 17 +-- .../AutofacRhinoConverterModule.cs | 36 ++++- ...nverters.Rhino7.DependencyInjection.csproj | 27 ++-- .../Speckle.Converters.Rhino7.csproj | 4 +- .../ToHost/RhinoConverterToHost.cs | 9 ++ .../Speckle.Connectors.DUI.csproj | 4 - .../Builders/IHostObjectBuilder.cs | 4 +- .../Operations/ReceiveOperation.cs | 10 +- 16 files changed, 320 insertions(+), 77 deletions(-) create mode 100644 DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoReceiveBinding.cs create mode 100644 DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Receive/RhinoHostObjectBuilder.cs create mode 100644 DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/RhinoConverterToHost.cs diff --git a/DUI3-DX.slnf b/DUI3-DX.slnf index fb7bbc4866..58980d735f 100644 --- a/DUI3-DX.slnf +++ b/DUI3-DX.slnf @@ -7,12 +7,14 @@ "Core\\Tests\\Speckle.Core.Tests.Performance\\Speckle.Core.Tests.Performance.csproj", "Core\\Tests\\Speckle.Core.Tests.Unit\\Speckle.Core.Tests.Unit.csproj", "Core\\Transports\\DiskTransport\\DiskTransport.csproj", + "DUI3-DX\\Connectors\\ArcGIS\\Speckle.Connectors.ArcGIS3\\Speckle.Connectors.ArcGIS3.csproj", "DUI3-DX\\Connectors\\Autocad\\Speckle.Connectors.Autocad2023\\Speckle.Connectors.Autocad2023.csproj", "DUI3-DX\\Connectors\\Autocad\\Speckle.Connectors.AutocadShared\\Speckle.Connectors.AutocadShared.shproj", - "DUI3-DX\\Connectors\\ArcGIS\\Speckle.Connectors.ArcGIS3\\Speckle.Connectors.ArcGIS3.csproj", "DUI3-DX\\Connectors\\Revit\\Speckle.Connectors.Revit2023\\Speckle.Connectors.Revit2023.csproj", "DUI3-DX\\Connectors\\Revit\\Speckle.Connectors.RevitShared\\Speckle.Connectors.RevitShared.shproj", "DUI3-DX\\Connectors\\Rhino\\Speckle.Connectors.Rhino7\\Speckle.Connectors.Rhino7.csproj", + "DUI3-DX\\Converters\\ArcGIS\\Speckle.Converters.ArcGIS3.DependencyInjection\\Speckle.Converters.ArcGIS3.DependencyInjection.csproj", + "DUI3-DX\\Converters\\ArcGIS\\Speckle.Converters.ArcGIS3\\Speckle.Converters.ArcGIS3.csproj", "DUI3-DX\\Converters\\Autocad\\Speckle.Converters.Autocad2023\\Speckle.Converters.Autocad2023.csproj", "DUI3-DX\\Converters\\Autocad\\Speckle.Converters.AutocadShared\\Speckle.Converters.AutocadShared.shproj", "DUI3-DX\\Converters\\Revit\\Speckle.Converters.Revit2023.DependencyInjection\\Speckle.Converters.Revit2023.DependencyInjection.csproj", @@ -20,8 +22,6 @@ "DUI3-DX\\Converters\\Revit\\Speckle.Converters.RevitShared\\Speckle.Converters.RevitShared.shproj", "DUI3-DX\\Converters\\Rhino\\Speckle.Converters.Rhino7.DependencyInjection\\Speckle.Converters.Rhino7.DependencyInjection.csproj", "DUI3-DX\\Converters\\Rhino\\Speckle.Converters.Rhino7\\Speckle.Converters.Rhino7.csproj", - "DUI3-DX\\Converters\\ArcGIS\\Speckle.Converters.ArcGIS3.DependencyInjection\\Speckle.Converters.ArcGIS3.DependencyInjection.csproj", - "DUI3-DX\\Converters\\ArcGIS\\Speckle.Converters.ArcGIS3\\Speckle.Converters.ArcGIS3.csproj", "DUI3-DX\\DUI3\\Speckle.Connectors.DUI\\Speckle.Connectors.DUI.csproj", "DUI3-DX\\Objects\\Speckle.Objects.Common\\Speckle.Objects.Common.csproj", "DUI3-DX\\Objects\\Speckle.Objects.Revit\\Speckle.Objects.Revit.csproj", @@ -29,7 +29,6 @@ "DUI3-DX\\Sdk\\Speckle.Connectors.Utils\\Speckle.Connectors.Utils.csproj", "DUI3-DX\\Sdk\\Speckle.Converters.Common.DependencyInjection\\Speckle.Converters.Common.DependencyInjection.csproj", "DUI3-DX\\Sdk\\Speckle.Converters.Common\\Speckle.Converters.Common.csproj", - "Objects\\Converters\\ConverterRhinoGh\\ConverterRhinoGhShared\\ConverterRhinoGhShared.shproj", "Objects\\Objects\\Objects.csproj", "Objects\\Tests\\Objects.Tests.Unit\\Objects.Tests.Unit.csproj" ] diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadReceiveBinding.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadReceiveBinding.cs index cd4b1390df..e55b1c9d57 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadReceiveBinding.cs +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadReceiveBinding.cs @@ -64,7 +64,7 @@ private async Task ReceiveInternal(string modelCardId) modelCard.ProjectName, modelCard.ModelName, modelCard.SelectedVersionId, - cts, + cts.Token, (status, progress) => OnSendOperationProgress(modelCardId, status, progress) ) .ConfigureAwait(false); diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Operations/Receive/HostObjectBuilder.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Operations/Receive/HostObjectBuilder.cs index 5b9c2463fe..d2f5f65043 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Operations/Receive/HostObjectBuilder.cs +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Operations/Receive/HostObjectBuilder.cs @@ -25,15 +25,12 @@ AutocadLayerManager autocadLayerManager _autocadLayerManager = autocadLayerManager; } - private List<(List, Base)> GetBaseWithPath(Base commitObject, CancellationTokenSource cts) + private List<(List, Base)> GetBaseWithPath(Base commitObject, CancellationToken cancellationToken) { List<(List, Base)> objectsToConvert = new(); foreach ((List objPath, Base obj) in commitObject.TraverseWithPath((obj) => obj is not Collection)) { - if (cts.IsCancellationRequested) - { - throw new OperationCanceledException(cts.Token); - } + cancellationToken.ThrowIfCancellationRequested(); if (obj is not Collection) // POC: equivalent of converter.CanConvertToNative(obj) ? { @@ -49,7 +46,7 @@ public IEnumerable Build( string projectName, string modelName, Action? onOperationProgressed, - CancellationTokenSource cts + CancellationToken cancellationToken ) { // Prompt the UI conversion started. Progress bar will swoosh. @@ -59,7 +56,7 @@ CancellationTokenSource cts // Layer filter for received commit with project and model name _autocadLayerManager.CreateLayerFilter(projectName, modelName); - List<(List, Base)> objectsWithPath = GetBaseWithPath(rootObject, cts); + List<(List, Base)> objectsWithPath = GetBaseWithPath(rootObject, cancellationToken); string baseLayerPrefix = $"SPK-{projectName}-{modelName}-"; HashSet uniqueLayerNames = new(); @@ -71,10 +68,7 @@ CancellationTokenSource cts { foreach ((List path, Base obj) in objectsWithPath) { - if (cts.IsCancellationRequested) - { - throw new OperationCanceledException(cts.Token); - } + cancellationToken.ThrowIfCancellationRequested(); try { diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoReceiveBinding.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoReceiveBinding.cs new file mode 100644 index 0000000000..a558da0d6e --- /dev/null +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoReceiveBinding.cs @@ -0,0 +1,93 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using Speckle.Connectors.DUI.Bindings; +using Speckle.Connectors.DUI.Bridge; +using Speckle.Connectors.DUI.Models; +using Speckle.Connectors.DUI.Models.Card; +using Speckle.Connectors.Utils.Cancellation; +using Speckle.Connectors.Utils.Operations; +using Speckle.Core.Logging; + +namespace Speckle.Connectors.Rhino7.Bindings; + +public class RhinoReceiveBinding : IReceiveBinding, ICancelable +{ + public string Name { get; set; } = "receiveBinding"; + public IBridge Parent { get; set; } + public CancellationManager CancellationManager { get; set; } + + private readonly DocumentModelStore _store; + private readonly ReceiveOperation _receiveOperation; + public ReceiveBindingUICommands Commands { get; } + + public RhinoReceiveBinding( + DocumentModelStore store, + CancellationManager cancellationManager, + IBridge parent, + ReceiveOperation receiveOperation + ) + { + Parent = parent; + _store = store; + CancellationManager = cancellationManager; + _receiveOperation = receiveOperation; + Commands = new ReceiveBindingUICommands(parent); + } + + public void CancelReceive(string modelCardId) => CancellationManager.CancelOperation(modelCardId); + + public async Task Receive(string modelCardId) + { + try + { + // Init cancellation token source -> Manager also cancel it if exist before + CancellationTokenSource cts = CancellationManager.InitCancellationTokenSource(modelCardId); + + // Get receiver card + if (_store.GetModelById(modelCardId) is not ReceiverModelCard modelCard) + { + throw new InvalidOperationException("No download model card was found."); + } + + // Receive host objects + IEnumerable receivedObjectIds = await _receiveOperation + .Execute( + modelCard.AccountId, // POC: I hear -you are saying why we're passing them separately. Not sure pass the DUI3-> Connectors.DUI project dependency to the SDK-> Connector.Utils + modelCard.ProjectId, + modelCard.ProjectName, + modelCard.ModelName, + modelCard.SelectedVersionId, + cts.Token, + (status, progress) => OnSendOperationProgress(modelCardId, status, progress) + ) + .ConfigureAwait(false); + + Commands.SetModelReceiveResult(modelCardId, receivedObjectIds.ToList()); + } + catch (OperationCanceledException) + { + // POC: not sure here need to handle anything. UI already aware it cancelled operation visually. + } + catch (Exception e) when (!e.IsFatal()) // All exceptions should be handled here if possible, otherwise we enter "crashing the host app" territory. + { + Commands.SetModelError(modelCardId, e); + } + } + + private void OnSendOperationProgress(string modelCardId, string status, double? progress) + { + Commands.SetModelProgress(modelCardId, new ModelCardProgress { Status = status, Progress = progress }); + } + + public void CancelSend(string modelCardId) => CancellationManager.CancelOperation(modelCardId); + + public void Dispose() + { + IsDisposed = true; + } + + public bool IsDisposed { get; private set; } +} diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/AutofacRhinoModule.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/AutofacRhinoModule.cs index 5be40620ff..9dadc15463 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/AutofacRhinoModule.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/AutofacRhinoModule.cs @@ -1,11 +1,9 @@ using System; using Autofac; using Microsoft.Extensions.Logging; -using Rhino; using Rhino.Commands; using Rhino.PlugIns; using Serilog; -using Speckle.Autofac.DependencyInjection; using Speckle.Connectors.DUI.Bindings; using Speckle.Connectors.DUI.Bridge; using Speckle.Connectors.DUI.Models; @@ -18,11 +16,12 @@ using Speckle.Connectors.Rhino7.Plugin; using Speckle.Connectors.Utils.Cancellation; using Speckle.Core.Transports; -using Speckle.Converters.Common; -using Speckle.Converters.Rhino7; using Speckle.Newtonsoft.Json; using Speckle.Newtonsoft.Json.Serialization; using Speckle.Connectors.DUI.Models.Card.SendFilter; +using Speckle.Connectors.Rhino7.Operations.Receive; +using Speckle.Connectors.Utils.Builders; +using Speckle.Connectors.Utils.Operations; namespace Speckle.Connectors.Rhino7.DependencyInjection; @@ -51,7 +50,7 @@ protected override void Load(ContainerBuilder builder) builder.RegisterType().As().As().SingleInstance(); builder.RegisterType().As().SingleInstance(); builder.RegisterType().As().SingleInstance(); - builder.RegisterType().As>().SingleInstance(); + builder.RegisterType().As().SingleInstance(); // binding dependencies builder.RegisterType().InstancePerDependency(); @@ -62,14 +61,14 @@ protected override void Load(ContainerBuilder builder) // register send operation and dependencies builder.RegisterType().SingleInstance(); + builder.RegisterType().SingleInstance(); + + builder.RegisterType().As().SingleInstance(); + builder.RegisterType().SingleInstance(); builder.RegisterType().As().SingleInstance(); - builder.RegisterType().As().InstancePerDependency(); - builder - .RegisterType>() - .As>() - .InstancePerLifetimeScope(); + builder.RegisterType().As().InstancePerDependency(); } private static JsonSerializerSettings GetJsonSerializerSettings() diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/SpeckleRhinoPanel.xaml.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/SpeckleRhinoPanel.xaml.cs index 849cbfd0e6..adbc7ed8b4 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/SpeckleRhinoPanel.xaml.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/SpeckleRhinoPanel.xaml.cs @@ -38,7 +38,6 @@ private void OnInitialized(object sender, CoreWebView2InitializationCompletedEve { var binding = lazyBinding.Value; binding.Parent.AssociateWithBinding(binding, ExecuteScriptAsyncMethod, Browser); - Console.WriteLine(); Browser.CoreWebView2.AddHostObjectToScript(binding.Name, binding.Parent); } } diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Receive/RhinoHostObjectBuilder.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Receive/RhinoHostObjectBuilder.cs new file mode 100644 index 0000000000..11a6fee493 --- /dev/null +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Receive/RhinoHostObjectBuilder.cs @@ -0,0 +1,134 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading; +using Rhino; +using Rhino.DocObjects; +using Rhino.Geometry; +using Speckle.Connectors.Utils.Builders; +using Speckle.Converters.Common; +using Speckle.Core.Logging; +using Speckle.Core.Models; +using Speckle.Core.Models.Extensions; + +namespace Speckle.Connectors.Rhino7.Operations.Receive; + +public class RhinoHostObjectBuilder : IHostObjectBuilder +{ + private readonly ISpeckleConverterToHost _toHostConverter; + private readonly IConversionContextStack _contextStack; + + public RhinoHostObjectBuilder( + ISpeckleConverterToHost toHostConverter, + IConversionContextStack contextStack + ) + { + _toHostConverter = toHostConverter; + _contextStack = contextStack; + } + + public IEnumerable Build( + Base rootObject, + string projectName, + string modelName, + Action? onOperationProgressed, + CancellationToken cancellationToken + ) + { + var baseLayerName = $"Project {projectName}: Model {modelName}"; + + var objectsToConvert = rootObject.TraverseWithPath(obj => obj is not Collection); + + var convertedIds = BakeObjects(objectsToConvert, baseLayerName, onOperationProgressed, cancellationToken); + + _contextStack.Current.Document.Views.Redraw(); + + return convertedIds; + } + + // POC: Potentially refactor out into an IObjectBaker. + private List BakeObjects( + IEnumerable<(List, Base)> objects, + string baseLayerName, + Action? onOperationProgressed, + CancellationToken cancellationToken + ) + { + var rootLayerName = baseLayerName; + // POC: This Find method was flagged as obsolete and I found no obvious way to work around it. + // Silencing it for now but we should find a way to fix this. +#pragma warning disable CS0618 // Type or member is obsolete + var rootLayerIndex = _contextStack.Current.Document.Layers.Find(rootLayerName, true); +#pragma warning restore CS0618 // Type or member is obsolete + + if (rootLayerIndex >= 0) + { + foreach (var layer in _contextStack.Current.Document.Layers[rootLayerIndex].GetChildren()) + { + // Cleans up any previously received objects + _contextStack.Current.Document.Layers.Purge(layer.Index, false); + } + } + + var cache = new Dictionary(); + rootLayerIndex = _contextStack.Current.Document.Layers.Add(new Layer { Name = rootLayerName }); + cache.Add(rootLayerName, rootLayerIndex); + + var newObjectIds = new List(); + var count = 0; + var listObjects = objects.ToList(); + foreach ((List path, Base baseObj) in objects) + { + cancellationToken.ThrowIfCancellationRequested(); + + var fullLayerName = string.Join("::", path); + var layerIndex = cache.TryGetValue(fullLayerName, out int value) + ? value + : GetAndCreateLayerFromPath(path, rootLayerName, cache); + + onOperationProgressed?.Invoke("Converting & creating objects", (double)++count / listObjects.Count); + + var converted = _toHostConverter.Convert(baseObj); + if (converted is GeometryBase newObject) + { + var newObjectGuid = _contextStack.Current.Document.Objects.Add( + newObject, + new ObjectAttributes { LayerIndex = layerIndex } + ); + newObjectIds.Add(newObjectGuid.ToString()); + } + + // POC: else something weird happened? a block maybe? also, blocks are treated like $$$ now tbh so i won't dive into them + throw new SpeckleException( + $"Unexpected result from conversion: Expected {nameof(GeometryBase)} but instead got {converted.GetType().Name}" + ); + } + + return newObjectIds; + } + + // POC: This is the original DUI3 function, this will grow over time as we add more conversions that are missing, so it should be refactored out into an ILayerManager or some sort of service. + private int GetAndCreateLayerFromPath(List path, string baseLayerName, Dictionary cache) + { + var currentLayerName = baseLayerName; + RhinoDoc currentDocument = _contextStack.Current.Document; + + var previousLayer = currentDocument.Layers.FindName(currentLayerName); + foreach (var layerName in path) + { + currentLayerName = baseLayerName + Layer.PathSeparator + layerName; + currentLayerName = currentLayerName.Replace("{", "").Replace("}", ""); // Rhino specific cleanup for gh (see RemoveInvalidRhinoChars) + if (cache.TryGetValue(currentLayerName, out int value)) + { + previousLayer = currentDocument.Layers.FindIndex(value); + continue; + } + var cleanNewLayerName = layerName.Replace("{", "").Replace("}", ""); + var newLayer = new Layer { Name = cleanNewLayerName, ParentLayerId = previousLayer.Id }; + var index = currentDocument.Layers.Add(newLayer); + cache.Add(currentLayerName, index); + previousLayer = currentDocument.Layers.FindIndex(index); // note we need to get the correct id out, hence why we're double calling this + } + return previousLayer.Index; + } +} diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Plugin/Speckle.Connectors.Rhino7Plugin.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Plugin/Speckle.Connectors.Rhino7Plugin.cs index 515413ace0..7c22fb836d 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Plugin/Speckle.Connectors.Rhino7Plugin.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Plugin/Speckle.Connectors.Rhino7Plugin.cs @@ -1,16 +1,12 @@ using System; - using System.IO; using System.Reflection; -using Autofac; using Rhino.PlugIns; using Speckle.Autofac.DependencyInjection; using Speckle.Autofac.Files; using Speckle.Connectors.Rhino7.DependencyInjection; using Speckle.Connectors.Rhino7.HostApp; using Speckle.Connectors.Rhino7.Interfaces; -using Speckle.Converters.Common.DependencyInjection; -using Speckle.Converters.Common.Objects; using Speckle.Core.Kits; using Speckle.Core.Logging; using Speckle.Core.Models.Extensions; @@ -50,11 +46,12 @@ protected override LoadReturnCode OnLoad(ref string errorMessage) AppDomain.CurrentDomain.AssemblyResolve += OnAssemblyResolve; Container = new AutofacContainer(new StorageInfo()); - Container.PreBuildEvent += ContainerPreBuildEvent; // Register Settings var rhinoSettings = new RhinoSettings(HostApplications.Rhino, HostAppVersion.v7); + // POC: We must load the Rhino connector module manually because we only search for DLL files when calling `LoadAutofacModules`, + // but the Rhino connector has `.rhp` as it's extension. Container .AddModule(new AutofacRhinoModule()) .LoadAutofacModules(rhinoSettings.Modules) @@ -70,7 +67,7 @@ protected override LoadReturnCode OnLoad(ref string errorMessage) catch (Exception e) when (!e.IsFatal()) { errorMessage = e.ToFormattedString(); - return LoadReturnCode.ErrorNoDialog; + return LoadReturnCode.ErrorShowDialog; } } @@ -99,9 +96,4 @@ protected override void OnShutdown() return assembly; } - - private void ContainerPreBuildEvent(object sender, ContainerBuilder containerBuilder) - { - containerBuilder.InjectNamedTypes(); - } } diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Speckle.Connectors.Rhino7.csproj b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Speckle.Connectors.Rhino7.csproj index 9d948cf72a..98cd414b1a 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Speckle.Connectors.Rhino7.csproj +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Speckle.Connectors.Rhino7.csproj @@ -13,28 +13,25 @@ CS8618; - + - + - + - - - - - - + + + - + diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/AutofacRhinoConverterModule.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/AutofacRhinoConverterModule.cs index 3ea12f35fb..ca73ab5dd3 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/AutofacRhinoConverterModule.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/AutofacRhinoConverterModule.cs @@ -3,6 +3,8 @@ using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; using Rhino; +using Speckle.Converters.Common.DependencyInjection; +using Speckle.Converters.Rhino7.ToHost; namespace Speckle.Converters.Rhino7.DependencyInjection; @@ -14,7 +16,6 @@ protected override void Load(ContainerBuilder builder) // can be injected as Singleton(), only where we have state we wish to wrap in a unit of work // should be InstancePerLifetimeScope // most things should be InstancePerLifetimeScope so we get one per operation - builder.RegisterType().As().SingleInstance(); // single stack per conversion builder @@ -22,9 +23,40 @@ protected override void Load(ContainerBuilder builder) .As>() .InstancePerLifetimeScope(); - // factory for conversions + builder.RegisterRawConversions(); + + // To Speckle + builder.RegisterType().As>().SingleInstance(); + builder.RegisterType().As().SingleInstance(); + builder + .RegisterType>() + .As>() + .InstancePerLifetimeScope(); + + /* + POC: Moved the Injection of converters into the converter module. Not sure if this is 100% right, as this doesn't just register the conversions within this converter, but any conversions found in any Speckle.*.dll file. + This will require consolidating across other connectors. + */ + builder.InjectNamedTypes(); builder .RegisterType>() .As>(); + + // To Host + // POC: Missing Unit converter + builder.RegisterType().As().SingleInstance(); + builder + .RegisterType>() + .As>() + .InstancePerLifetimeScope(); + + /* + POC: Moved the Injection of converters into the converter module. Not sure if this is 100% right, as this doesn't just register the conversions within this converter, but any conversions found in any Speckle.*.dll file. + This will require consolidating across other connectors. + */ + builder.InjectNamedTypes(); + builder + .RegisterType>() + .As>(); } } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/Speckle.Converters.Rhino7.DependencyInjection.csproj b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/Speckle.Converters.Rhino7.DependencyInjection.csproj index b098e1e7c4..9a3eea3b1b 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/Speckle.Converters.Rhino7.DependencyInjection.csproj +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/Speckle.Converters.Rhino7.DependencyInjection.csproj @@ -1,19 +1,18 @@ + + net48 + enable + enable + false - - net48 - enable - enable - + - - - - - - - - - + + + + + + + diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Speckle.Converters.Rhino7.csproj b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Speckle.Converters.Rhino7.csproj index ce14684cee..589068a1bb 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Speckle.Converters.Rhino7.csproj +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Speckle.Converters.Rhino7.csproj @@ -17,8 +17,8 @@ - - + + diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/RhinoConverterToHost.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/RhinoConverterToHost.cs new file mode 100644 index 0000000000..3effa9bb7e --- /dev/null +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/RhinoConverterToHost.cs @@ -0,0 +1,9 @@ +using Speckle.Converters.Common; +using Speckle.Core.Models; + +namespace Speckle.Converters.Rhino7.ToHost; + +public class RhinoConverterToHost : ISpeckleConverterToHost +{ + public object Convert(Base target) => throw new NotImplementedException(); +} diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Speckle.Connectors.DUI.csproj b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Speckle.Connectors.DUI.csproj index 083ee37f8d..d94af257c9 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Speckle.Connectors.DUI.csproj +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Speckle.Connectors.DUI.csproj @@ -18,9 +18,5 @@ - - - - diff --git a/DUI3-DX/Sdk/Speckle.Connectors.Utils/Builders/IHostObjectBuilder.cs b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Builders/IHostObjectBuilder.cs index 94d5f9ae7c..1c3fb1d89b 100644 --- a/DUI3-DX/Sdk/Speckle.Connectors.Utils/Builders/IHostObjectBuilder.cs +++ b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Builders/IHostObjectBuilder.cs @@ -15,7 +15,7 @@ public interface IHostObjectBuilder /// Project of the model. /// Name of the model. /// Action to update UI progress bar. - /// Cancellation token that passed from top -> ReceiveBinding. + /// Cancellation token that passed from top -> ReceiveBinding. /// List of application ids. // POC: Where we will return these ids will matter later when we target to also cache received application ids. /// Project and model name are needed for now to construct host app objects into related layers or filters. /// POC: we might consider later to have HostObjectBuilderContext? that might hold all possible data we will need. @@ -24,6 +24,6 @@ IEnumerable Build( string projectName, string modelName, Action? onOperationProgressed, - CancellationTokenSource cts + CancellationToken cancellationToken ); } diff --git a/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/ReceiveOperation.cs b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/ReceiveOperation.cs index a3edbb7690..4c51c64d77 100644 --- a/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/ReceiveOperation.cs +++ b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/ReceiveOperation.cs @@ -27,7 +27,7 @@ public async Task> Execute( string projectName, string modelName, string versionId, - CancellationTokenSource cts, + CancellationToken cancellationToken, Action? onOperationProgressed = null ) { @@ -40,21 +40,21 @@ public async Task> Execute( Client apiClient = new(account); ServerTransport transport = new(account, projectId); Commit? version = - await apiClient.CommitGet(projectId, versionId, cts.Token).ConfigureAwait(false) + await apiClient.CommitGet(projectId, versionId, cancellationToken).ConfigureAwait(false) ?? throw new SpeckleException($"Failed to receive commit: {versionId} from server)"); Base? commitObject = await Speckle.Core.Api.Operations - .Receive(version.referencedObject, cancellationToken: cts.Token, remoteTransport: transport) + .Receive(version.referencedObject, cancellationToken: cancellationToken, remoteTransport: transport) .ConfigureAwait(false) ?? throw new SpeckleException( $"Failed to receive commit: {version.id} objects from server: {nameof(Operations)} returned null" ); apiClient.Dispose(); - cts.Token.ThrowIfCancellationRequested(); + cancellationToken.ThrowIfCancellationRequested(); // 4 - Convert objects - return _hostObjectBuilder.Build(commitObject, projectName, modelName, onOperationProgressed, cts); + return _hostObjectBuilder.Build(commitObject, projectName, modelName, onOperationProgressed, cancellationToken); } } From 0114233b7b69d6b82caceacf9af774eb19dc4bda Mon Sep 17 00:00:00 2001 From: Alan Rynne Date: Fri, 12 Apr 2024 13:15:12 +0200 Subject: [PATCH 024/261] CNX-9142 DUI3-DX Rhino Basic Receive Conversions (#3272) * feat: Initial simple raw converters * feat: Working Rhino receive conversions with simple unit scaling * fix: MIssing NameAndRank * Change UI url from preview to exact one * fix: inject correct raw conversion * fix: Remove unused contexts * feat: Accumulate conversion exceptions and throw at the end * chore: Address PR comments and POCs for later * fix: Unnecessary usings --------- Co-authored-by: oguzhankoral --- .editorconfig | 2 + .../HostApp/SpeckleRhinoPanel.xaml | 2 +- .../Receive/RhinoHostObjectBuilder.cs | 80 ++++++++++------ .../Raw/FlatPointListRawToHostConversion.cs | 25 +++++ .../Raw/SpeckleArcRawToHostConversion.cs | 43 +++++++++ .../Raw/SpeckleIntervalRawToHostConversion.cs | 17 ++++ .../Raw/SpeckleLineRawToHostConversion.cs | 18 ++++ .../Raw/SpeckleMeshRawToHostConversion.cs | 96 +++++++++++++++++++ .../Raw/SpecklePlaneRawToHostConversion.cs | 26 +++++ .../Raw/SpecklePointRawToHostConversion.cs | 15 +++ .../Raw/SpecklePolylineRawToHostConversion.cs | 49 ++++++++++ .../Raw/SpeckleVectorRawToHostConversion.cs | 8 ++ .../ToHost/RhinoConverterToHost.cs | 26 ++++- .../SpeckleArcToHostArcCurveConversion.cs | 14 +++ .../SpeckleLineToHostLineCurveConversion.cs | 15 +++ .../SpeckleMeshToHostMeshConversion.cs | 15 +++ .../SpecklePointToHostPointConversion.cs | 15 +++ ...lePolylineToHostPolylineCurveConversion.cs | 16 ++++ .../SpeckleToHostGeometryBaseConversion.cs | 44 +++++++++ 19 files changed, 494 insertions(+), 32 deletions(-) create mode 100644 DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/FlatPointListRawToHostConversion.cs create mode 100644 DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpeckleArcRawToHostConversion.cs create mode 100644 DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpeckleIntervalRawToHostConversion.cs create mode 100644 DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpeckleLineRawToHostConversion.cs create mode 100644 DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpeckleMeshRawToHostConversion.cs create mode 100644 DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpecklePlaneRawToHostConversion.cs create mode 100644 DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpecklePointRawToHostConversion.cs create mode 100644 DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpecklePolylineRawToHostConversion.cs create mode 100644 DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpeckleVectorRawToHostConversion.cs create mode 100644 DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/SpeckleArcToHostArcCurveConversion.cs create mode 100644 DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/SpeckleLineToHostLineCurveConversion.cs create mode 100644 DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/SpeckleMeshToHostMeshConversion.cs create mode 100644 DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/SpecklePointToHostPointConversion.cs create mode 100644 DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/SpecklePolylineToHostPolylineCurveConversion.cs create mode 100644 DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/SpeckleToHostGeometryBaseConversion.cs diff --git a/.editorconfig b/.editorconfig index a139b3f4d0..36de039b9a 100644 --- a/.editorconfig +++ b/.editorconfig @@ -220,6 +220,7 @@ dotnet_diagnostic.ide0260.severity = suggestion # Use pattern matching: Subjecti dotnet_diagnostic.ide0022.severity = suggestion # Use expression body for method: Subjective dotnet_diagnostic.ide0061.severity = suggestion # Use expression body for local functions: Subjective dotnet_diagnostic.ide0063.severity = suggestion # Using directive can be simplified +dotnet_diagnostic.ide0066.severity = suggestion # Use switch expression: Subjective dotnet_diagnostic.ide0029.severity = suggestion # Null check can be simplified: Subjective dotnet_diagnostic.ide0030.severity = suggestion # Null check can be simplified: Subjective dotnet_diagnostic.ide0270.severity = suggestion # Null check can be simplified: Subjective @@ -230,6 +231,7 @@ dotnet_diagnostic.ide0030.severity = suggestion # Null check can be simplified: dotnet_diagnostic.ide0270.severity = suggestion # Null check can be simplified: Subjective dotnet_diagnostic.ide0042.severity = suggestion # Deconstruct variable declaration: Subjective dotnet_diagnostic.ide0028.severity = suggestion # Use collection initializers: Subjective +dotnet_diagnostic.ide0072.severity = suggestion # Populate switch statement: Subjective dotnet_diagnostic.ide0074.severity = suggestion # Use compound assignment: Subjective # Maintainability rules diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/SpeckleRhinoPanel.xaml b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/SpeckleRhinoPanel.xaml index 14d79465ad..3647b9e64f 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/SpeckleRhinoPanel.xaml +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/SpeckleRhinoPanel.xaml @@ -13,6 +13,6 @@ + Name="Browser" Grid.Row="0" Source="https://dui3--boisterous-douhua-e3cefb.netlify.app/" /> diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Receive/RhinoHostObjectBuilder.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Receive/RhinoHostObjectBuilder.cs index 11a6fee493..a8cabd6eec 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Receive/RhinoHostObjectBuilder.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Receive/RhinoHostObjectBuilder.cs @@ -35,9 +35,12 @@ public IEnumerable Build( CancellationToken cancellationToken ) { + // POC: This is where the top level base-layer name is set. Could be abstracted or injected in the context? var baseLayerName = $"Project {projectName}: Model {modelName}"; - var objectsToConvert = rootObject.TraverseWithPath(obj => obj is not Collection); + var objectsToConvert = rootObject + .TraverseWithPath(obj => obj is not Collection) + .Where(obj => obj.Item2 is not Collection); var convertedIds = BakeObjects(objectsToConvert, baseLayerName, onOperationProgressed, cancellationToken); @@ -54,54 +57,73 @@ private List BakeObjects( CancellationToken cancellationToken ) { - var rootLayerName = baseLayerName; - // POC: This Find method was flagged as obsolete and I found no obvious way to work around it. - // Silencing it for now but we should find a way to fix this. -#pragma warning disable CS0618 // Type or member is obsolete - var rootLayerIndex = _contextStack.Current.Document.Layers.Find(rootLayerName, true); -#pragma warning restore CS0618 // Type or member is obsolete + RhinoDoc doc = _contextStack.Current.Document; + var rootLayerIndex = doc.Layers.Find(Guid.Empty, baseLayerName, RhinoMath.UnsetIntIndex); + + // Cleans up any previously received objects + // POC: We could move this out into a separate service for testing and re-use. if (rootLayerIndex >= 0) { - foreach (var layer in _contextStack.Current.Document.Layers[rootLayerIndex].GetChildren()) + Layer documentLayer = doc.Layers[rootLayerIndex]; + Layer[]? childLayers = documentLayer.GetChildren(); + if (childLayers != null) { - // Cleans up any previously received objects - _contextStack.Current.Document.Layers.Purge(layer.Index, false); + foreach (var layer in childLayers) + { + doc.Layers.Purge(layer.Index, false); + } } } var cache = new Dictionary(); - rootLayerIndex = _contextStack.Current.Document.Layers.Add(new Layer { Name = rootLayerName }); - cache.Add(rootLayerName, rootLayerIndex); + rootLayerIndex = doc.Layers.Add(new Layer { Name = baseLayerName }); + cache.Add(baseLayerName, rootLayerIndex); var newObjectIds = new List(); var count = 0; var listObjects = objects.ToList(); + + // POC: We delay throwing conversion exceptions until the end of the conversion loop, then throw all within an aggregate exception if something happened. + var conversionExceptions = new List(); + foreach ((List path, Base baseObj) in objects) { - cancellationToken.ThrowIfCancellationRequested(); + try + { + cancellationToken.ThrowIfCancellationRequested(); - var fullLayerName = string.Join("::", path); - var layerIndex = cache.TryGetValue(fullLayerName, out int value) - ? value - : GetAndCreateLayerFromPath(path, rootLayerName, cache); + var fullLayerName = string.Join("::", path); + var layerIndex = cache.TryGetValue(fullLayerName, out int value) + ? value + : GetAndCreateLayerFromPath(path, baseLayerName, cache); - onOperationProgressed?.Invoke("Converting & creating objects", (double)++count / listObjects.Count); + onOperationProgressed?.Invoke("Converting & creating objects", (double)++count / listObjects.Count); - var converted = _toHostConverter.Convert(baseObj); - if (converted is GeometryBase newObject) - { - var newObjectGuid = _contextStack.Current.Document.Objects.Add( - newObject, - new ObjectAttributes { LayerIndex = layerIndex } + var converted = _toHostConverter.Convert(baseObj); + + if (converted is GeometryBase newObject) + { + var newObjectGuid = doc.Objects.Add(newObject, new ObjectAttributes { LayerIndex = layerIndex }); + newObjectIds.Add(newObjectGuid.ToString()); + continue; + } + + // POC: else something weird happened? a block maybe? We should stop on our tracks if we reach this. + throw new SpeckleException( + $"Unexpected result from conversion: Expected {nameof(GeometryBase)} but instead got {converted.GetType().Name}" ); - newObjectIds.Add(newObjectGuid.ToString()); } + catch (Exception e) when (!e.IsFatal()) + { + conversionExceptions.Add(e); + } + } - // POC: else something weird happened? a block maybe? also, blocks are treated like $$$ now tbh so i won't dive into them - throw new SpeckleException( - $"Unexpected result from conversion: Expected {nameof(GeometryBase)} but instead got {converted.GetType().Name}" - ); + if (conversionExceptions.Count != 0) + { + // POC: Both the message and the handling of this should be engineered taking into account error reporting in DUI becoming better. + throw new AggregateException("Some conversions failed. Please check inner exceptions.", conversionExceptions); } return newObjectIds; diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/FlatPointListRawToHostConversion.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/FlatPointListRawToHostConversion.cs new file mode 100644 index 0000000000..b7b49cc2c2 --- /dev/null +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/FlatPointListRawToHostConversion.cs @@ -0,0 +1,25 @@ +using Rhino.Collections; +using Speckle.Converters.Common.Objects; +using Speckle.Core.Logging; + +namespace Speckle.Converters.Rhino7.ToHost.Raw; + +public class FlatPointListRawToHostConversion : IRawConversion, Point3dList> +{ + public Point3dList RawConvert(IList target) + { + if (target.Count % 3 != 0) + { + throw new SpeckleException("Array malformed: length%3 != 0."); + } + + var points = new List(target.Count / 3); + + for (int i = 2; i < target.Count; i += 3) + { + points.Add(new RG.Point3d(target[i - 2], target[i - 1], target[i])); + } + + return new Point3dList(points); + } +} diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpeckleArcRawToHostConversion.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpeckleArcRawToHostConversion.cs new file mode 100644 index 0000000000..4728b14ae1 --- /dev/null +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpeckleArcRawToHostConversion.cs @@ -0,0 +1,43 @@ +using Speckle.Converters.Common.Objects; + +namespace Speckle.Converters.Rhino7.ToHost.Raw; + +public class SpeckleArcRawToHostConversion : IRawConversion, IRawConversion +{ + private readonly IRawConversion _pointConverter; + private readonly IRawConversion _intervalConverter; + + public SpeckleArcRawToHostConversion( + IRawConversion pointConverter, + IRawConversion intervalConverter + ) + { + _pointConverter = pointConverter; + this._intervalConverter = intervalConverter; + } + + public RG.Arc RawConvert(SOG.Arc target) + { + var rhinoArc = new RG.Arc( + _pointConverter.RawConvert(target.startPoint), + _pointConverter.RawConvert(target.midPoint), + _pointConverter.RawConvert(target.endPoint) + ); + return rhinoArc; + } + + // POC: Potential code-smell by directly implementing the interface. We should discuss this further but + // since we're using the interfaces instead of the direct type, this may not be an issue. + RG.ArcCurve IRawConversion.RawConvert(SOG.Arc target) + { + var rhinoArc = RawConvert(target); + var arcCurve = new RG.ArcCurve(rhinoArc); + + if (target.domain != null) + { + arcCurve.Domain = _intervalConverter.RawConvert(target.domain); + } + + return arcCurve; + } +} diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpeckleIntervalRawToHostConversion.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpeckleIntervalRawToHostConversion.cs new file mode 100644 index 0000000000..956602e9e1 --- /dev/null +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpeckleIntervalRawToHostConversion.cs @@ -0,0 +1,17 @@ +using Speckle.Converters.Common.Objects; + +namespace Speckle.Converters.Rhino7.ToHost.Raw; + +public class SpeckleIntervalRawToHostConversion : IRawConversion +{ + public RG.Interval RawConvert(SOP.Interval target) + { + if (!target.start.HasValue || !target.end.HasValue) // POC: I hate interval start/end being nullable. Makes no sense. + { + throw new ArgumentException("Interval start/end cannot be null"); + } + + // POC: Interval conversions used to have a unit input, but it was only used in `Box` so we can deal with that on the parent. + return new RG.Interval(target.start.Value, target.end.Value); + } +} diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpeckleLineRawToHostConversion.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpeckleLineRawToHostConversion.cs new file mode 100644 index 0000000000..1428e928fc --- /dev/null +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpeckleLineRawToHostConversion.cs @@ -0,0 +1,18 @@ +using Speckle.Converters.Common.Objects; + +namespace Speckle.Converters.Rhino7.ToHost.Raw; + +public class SpeckleLineRawToHostConversion : IRawConversion, IRawConversion +{ + private readonly IRawConversion _pointConverter; + + public SpeckleLineRawToHostConversion(IRawConversion pointConverter) + { + _pointConverter = pointConverter; + } + + public RG.Line RawConvert(SOG.Line target) => + new(_pointConverter.RawConvert(target.start), _pointConverter.RawConvert(target.end)); + + RG.LineCurve IRawConversion.RawConvert(SOG.Line target) => new(RawConvert(target)); +} diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpeckleMeshRawToHostConversion.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpeckleMeshRawToHostConversion.cs new file mode 100644 index 0000000000..6657f7f0e5 --- /dev/null +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpeckleMeshRawToHostConversion.cs @@ -0,0 +1,96 @@ +using System.Drawing; +using Objects.Utils; +using Rhino.Collections; +using Speckle.Converters.Common.Objects; + +namespace Speckle.Converters.Rhino7.ToHost.Raw; + +public class SpeckleMeshRawToHostConversion : IRawConversion +{ + private readonly IRawConversion, Point3dList> _pointListConverter; + + public SpeckleMeshRawToHostConversion(IRawConversion, Point3dList> pointListConverter) + { + _pointListConverter = pointListConverter; + } + + public RG.Mesh RawConvert(SOG.Mesh target) + { + target.AlignVerticesWithTexCoordsByIndex(); + + RG.Mesh m = new(); + + var vertices = _pointListConverter.RawConvert(target.vertices); + var colors = target.colors.Select(Color.FromArgb).ToArray(); + + m.Vertices.AddVertices(vertices); + m.VertexColors.SetColors(colors); + + AssignMeshFaces(target, m); + AssignTextureCoordinates(target, m); + + // POC: There was a piece of code here about Merging co-planar faces that I've removed for now as this setting does not exist yet. + + return m; + } + + // POC: We should abstract this into the `Mesh` class, or some utility class adjacent to it + // All converters need to do this so it's going to be a source of repetition + // and it is directly tied to how we serialise the data in the mesh. + private void AssignMeshFaces(SOG.Mesh target, RG.Mesh m) + { + int i = 0; + while (i < target.faces.Count) + { + int n = target.faces[i]; + // For backwards compatibility. Old meshes will have "0" for triangle face, "1" for quad face. + // Newer meshes have "3" for triangle face, "4" for quad" face and "5...n" for n-gon face. + if (n < 3) + { + n += 3; // 0 -> 3, 1 -> 4 + } + + if (n == 3) + { + // triangle + m.Faces.AddFace(new RG.MeshFace(target.faces[i + 1], target.faces[i + 2], target.faces[i + 3])); + } + else if (n == 4) + { + // quad + m.Faces.AddFace( + new RG.MeshFace(target.faces[i + 1], target.faces[i + 2], target.faces[i + 3], target.faces[i + 4]) + ); + } + else + { + // n-gon + var triangles = MeshTriangulationHelper.TriangulateFace(i, target, false); + + var faceIndices = new List(triangles.Count); + for (int t = 0; t < triangles.Count; t += 3) + { + var face = new RG.MeshFace(triangles[t], triangles[t + 1], triangles[t + 2]); + faceIndices.Add(m.Faces.AddFace(face)); + } + + RG.MeshNgon ngon = RG.MeshNgon.Create(target.faces.GetRange(i + 1, n), faceIndices); + m.Ngons.AddNgon(ngon); + } + + i += n + 1; + } + m.Faces.CullDegenerateFaces(); + } + + private void AssignTextureCoordinates(SOG.Mesh target, RG.Mesh m) + { + var textureCoordinates = new RG.Point2f[target.TextureCoordinatesCount]; + for (int ti = 0; ti < target.TextureCoordinatesCount; ti++) + { + var (u, v) = target.GetTextureCoordinate(ti); + textureCoordinates[ti] = new RG.Point2f(u, v); + } + m.TextureCoordinates.SetTextureCoordinates(textureCoordinates); + } +} diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpecklePlaneRawToHostConversion.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpecklePlaneRawToHostConversion.cs new file mode 100644 index 0000000000..6d38bb2cfe --- /dev/null +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpecklePlaneRawToHostConversion.cs @@ -0,0 +1,26 @@ +using Speckle.Converters.Common.Objects; + +namespace Speckle.Converters.Rhino7.ToHost.Raw; + +public class SpecklePlaneRawToHostConversion : IRawConversion +{ + private readonly IRawConversion _pointConverter; + private readonly IRawConversion _vectorConverter; + + public SpecklePlaneRawToHostConversion( + IRawConversion pointConverter, + IRawConversion vectorConverter + ) + { + _pointConverter = pointConverter; + _vectorConverter = vectorConverter; + } + + // POC: Super simplified, must check original conversion + public RG.Plane RawConvert(SOG.Plane target) => + new( + _pointConverter.RawConvert(target.origin), + _vectorConverter.RawConvert(target.xdir), + _vectorConverter.RawConvert(target.ydir) + ); +} diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpecklePointRawToHostConversion.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpecklePointRawToHostConversion.cs new file mode 100644 index 0000000000..146d7f4008 --- /dev/null +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpecklePointRawToHostConversion.cs @@ -0,0 +1,15 @@ +using Speckle.Converters.Common.Objects; + +namespace Speckle.Converters.Rhino7.ToHost.Raw; + +public class SpecklePointRawToHostConversion + : IRawConversion, + IRawConversion +{ + public RG.Point3d RawConvert(SOG.Point target) + { + return new RG.Point3d(target.x, target.y, target.z); + } + + RG.Point IRawConversion.RawConvert(SOG.Point target) => new(RawConvert(target)); +} diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpecklePolylineRawToHostConversion.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpecklePolylineRawToHostConversion.cs new file mode 100644 index 0000000000..c68888780e --- /dev/null +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpecklePolylineRawToHostConversion.cs @@ -0,0 +1,49 @@ +using Rhino.Collections; +using Speckle.Converters.Common.Objects; + +namespace Speckle.Converters.Rhino7.ToHost.Raw; + +public class SpecklePolylineRawToHostConversion + : IRawConversion, + IRawConversion +{ + private readonly IRawConversion, Point3dList> _pointListConverter; + private readonly IRawConversion _intervalConverter; + + public SpecklePolylineRawToHostConversion( + IRawConversion, Point3dList> pointListConverter, + IRawConversion intervalConverter + ) + { + _pointListConverter = pointListConverter; + _intervalConverter = intervalConverter; + } + + public RG.Polyline RawConvert(SOG.Polyline target) + { + var points = _pointListConverter.RawConvert(target.value); + + if (target.closed) + { + points.Add(points[0]); + } + + var poly = new RG.Polyline(points); + + return poly; + } + + // POC: Potential code-smell by directly implementing the interface. We should discuss this further but + // since we're using the interfaces instead of the direct type, this may not be an issue. + RG.PolylineCurve IRawConversion.RawConvert(SOG.Polyline target) + { + var poly = RawConvert(target).ToPolylineCurve(); + + if (target.domain != null) + { + poly.Domain = _intervalConverter.RawConvert(target.domain); + } + + return poly; + } +} diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpeckleVectorRawToHostConversion.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpeckleVectorRawToHostConversion.cs new file mode 100644 index 0000000000..463d58437d --- /dev/null +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpeckleVectorRawToHostConversion.cs @@ -0,0 +1,8 @@ +using Speckle.Converters.Common.Objects; + +namespace Speckle.Converters.Rhino7.ToHost.Raw; + +public class SpeckleVectorRawToHostConversion : IRawConversion +{ + public RG.Vector3d RawConvert(SOG.Vector target) => new(target.x, target.y, target.z); +} diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/RhinoConverterToHost.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/RhinoConverterToHost.cs index 3effa9bb7e..aa66d09d2a 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/RhinoConverterToHost.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/RhinoConverterToHost.cs @@ -1,9 +1,31 @@ -using Speckle.Converters.Common; +using Speckle.Autofac.DependencyInjection; +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; using Speckle.Core.Models; namespace Speckle.Converters.Rhino7.ToHost; public class RhinoConverterToHost : ISpeckleConverterToHost { - public object Convert(Base target) => throw new NotImplementedException(); + private readonly IFactory _toHost; + + public RhinoConverterToHost(IFactory toHost) + { + _toHost = toHost; + } + + public object Convert(Base target) + { + var typeName = target.GetType().Name; + var objectConverter = _toHost.ResolveInstance(typeName); + + if (objectConverter == null) + { + throw new NotSupportedException($"No conversion found for {typeName}"); + } + + var convertedObject = objectConverter.Convert(target); + + return convertedObject; + } } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/SpeckleArcToHostArcCurveConversion.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/SpeckleArcToHostArcCurveConversion.cs new file mode 100644 index 0000000000..a937919143 --- /dev/null +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/SpeckleArcToHostArcCurveConversion.cs @@ -0,0 +1,14 @@ +using Rhino; +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; + +namespace Speckle.Converters.Rhino7.ToHost.TopLevel; + +public class SpeckleArcToHostArcCurveConversion : SpeckleToHostGeometryBaseConversion +{ + public SpeckleArcToHostArcCurveConversion( + IConversionContextStack contextStack, + IRawConversion geometryBaseConverter + ) + : base(contextStack, geometryBaseConverter) { } +} diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/SpeckleLineToHostLineCurveConversion.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/SpeckleLineToHostLineCurveConversion.cs new file mode 100644 index 0000000000..377d21a5e5 --- /dev/null +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/SpeckleLineToHostLineCurveConversion.cs @@ -0,0 +1,15 @@ +using Rhino; +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; + +namespace Speckle.Converters.Rhino7.ToHost.TopLevel; + +[NameAndRankValue(nameof(SOG.Line), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +public class SpeckleLineToHostLineCurveConversion : SpeckleToHostGeometryBaseConversion +{ + public SpeckleLineToHostLineCurveConversion( + IConversionContextStack contextStack, + IRawConversion geometryBaseConverter + ) + : base(contextStack, geometryBaseConverter) { } +} diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/SpeckleMeshToHostMeshConversion.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/SpeckleMeshToHostMeshConversion.cs new file mode 100644 index 0000000000..3d30039a3d --- /dev/null +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/SpeckleMeshToHostMeshConversion.cs @@ -0,0 +1,15 @@ +using Rhino; +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; + +namespace Speckle.Converters.Rhino7.ToHost.TopLevel; + +[NameAndRankValue(nameof(SOG.Mesh), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +public class SpeckleMeshToHostMeshConversion : SpeckleToHostGeometryBaseConversion +{ + public SpeckleMeshToHostMeshConversion( + IConversionContextStack contextStack, + IRawConversion geometryBaseConverter + ) + : base(contextStack, geometryBaseConverter) { } +} diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/SpecklePointToHostPointConversion.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/SpecklePointToHostPointConversion.cs new file mode 100644 index 0000000000..1c5ab2447f --- /dev/null +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/SpecklePointToHostPointConversion.cs @@ -0,0 +1,15 @@ +using Rhino; +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; + +namespace Speckle.Converters.Rhino7.ToHost.TopLevel; + +[NameAndRankValue(nameof(SOG.Point), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +public class SpecklePointToHostPointConversion : SpeckleToHostGeometryBaseConversion +{ + public SpecklePointToHostPointConversion( + IConversionContextStack contextStack, + IRawConversion geometryBaseConverter + ) + : base(contextStack, geometryBaseConverter) { } +} diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/SpecklePolylineToHostPolylineCurveConversion.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/SpecklePolylineToHostPolylineCurveConversion.cs new file mode 100644 index 0000000000..7f5daf4bdc --- /dev/null +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/SpecklePolylineToHostPolylineCurveConversion.cs @@ -0,0 +1,16 @@ +using Rhino; +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; + +namespace Speckle.Converters.Rhino7.ToHost.TopLevel; + +[NameAndRankValue(nameof(SOG.Polyline), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +public class SpecklePolylineToHostPolylineCurveConversion + : SpeckleToHostGeometryBaseConversion +{ + public SpecklePolylineToHostPolylineCurveConversion( + IConversionContextStack contextStack, + IRawConversion geometryBaseConverter + ) + : base(contextStack, geometryBaseConverter) { } +} diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/SpeckleToHostGeometryBaseConversion.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/SpeckleToHostGeometryBaseConversion.cs new file mode 100644 index 0000000000..276303375f --- /dev/null +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/SpeckleToHostGeometryBaseConversion.cs @@ -0,0 +1,44 @@ +using Rhino; +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; +using Speckle.Core.Kits; +using Speckle.Core.Models; + +namespace Speckle.Converters.Rhino7.ToHost.TopLevel; + +public abstract class SpeckleToHostGeometryBaseConversion : ISpeckleObjectToHostConversion + where TIn : Base + where TOut : RG.GeometryBase +{ + protected IConversionContextStack ContextStack { get; private set; } + private readonly IRawConversion _geometryBaseConverter; + + protected SpeckleToHostGeometryBaseConversion( + IConversionContextStack contextStack, + IRawConversion geometryBaseConverter + ) + { + ContextStack = contextStack; + _geometryBaseConverter = geometryBaseConverter; + } + + public object Convert(Base target) + { + var castedBase = (TIn)target; + var result = _geometryBaseConverter.RawConvert(castedBase); + + /* + * POC: Looking at a simpler, more performant way of doing unit scaling on `ToNative` + * by fully relying on the transform capabilities of the HostApp, and only transforming top-level stuff. + * This may not hold when adding more complex conversions, but it works for now! + */ + if (castedBase["units"] is string units) + { + var scaleFactor = Units.GetConversionFactor(units, ContextStack.Current.SpeckleUnits); + var scale = RG.Transform.Scale(RG.Point3d.Origin, scaleFactor); + result.Transform(scale); + } + + return result; + } +} From c9978de39daddfb376eb5beaff3de973e5b6a77e Mon Sep 17 00:00:00 2001 From: KatKatKateryna <89912278+KatKatKateryna@users.noreply.github.com> Date: Mon, 15 Apr 2024 19:28:09 +0800 Subject: [PATCH 025/261] clean conversion interfaces; add lists as return type; move renaming hack (#3271) * clean conversion interfaces; add lists as return type; move renaming hack to least used code * optimized * simplified type checks * more specific types in Lists * optimized types * removing import --- .../HostApp/SpeckleModule.cs | 2 + .../Features/GeometryToSpeckleBase.cs | 67 ++++++------------- .../Features/GisFeatureToSpeckleConverter.cs | 10 ++- .../MultipointFeatureToSpeckleConverter.cs | 26 ++----- .../PointFeatureToSpeckleConverter.cs | 37 ---------- .../PolygonFeatureToSpeckleConverter.cs | 25 ++----- .../PolylineFeatureToSpeckleConverter.cs | 25 ++----- .../BezierSegmentToSpeckleConverter.cs | 15 ++--- .../EllipticArcSegmentToSpeckleConverter.cs | 15 ++--- .../Geometry/PointToSpeckleConverter.cs | 11 +-- .../SegmentCollectionToSpeckleConverter.cs | 13 +--- 11 files changed, 56 insertions(+), 190 deletions(-) delete mode 100644 DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/PointFeatureToSpeckleConverter.cs diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/HostApp/SpeckleModule.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/HostApp/SpeckleModule.cs index 2de11012ea..cb8fc8b54c 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/HostApp/SpeckleModule.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/HostApp/SpeckleModule.cs @@ -57,7 +57,9 @@ protected override bool CanUnload() private static void Container_PreBuildEvent(object? sender, ContainerBuilder containerBuilder) { + containerBuilder.RegisterRawConversions(); containerBuilder.InjectNamedTypes(); + containerBuilder.InjectNamedTypes(); } private static Assembly? OnAssemblyResolve(object? sender, ResolveEventArgs args) diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GeometryToSpeckleBase.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GeometryToSpeckleBase.cs index 6c31e454e5..4d16cd60b3 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GeometryToSpeckleBase.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GeometryToSpeckleBase.cs @@ -1,72 +1,43 @@ using ArcGIS.Core.Geometry; -using Speckle.Autofac.DependencyInjection; +using Objects.GIS; using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; using Speckle.Core.Models; namespace Speckle.Converters.ArcGIS3.Features; -[NameAndRankValue(nameof(ArcGIS.Core.Geometry.Geometry), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class GeometryToSpeckleBaseList - : IHostObjectToSpeckleConversion, - IRawConversion +public class GeometryToSpeckleBaseList : IRawConversion> { - private readonly IFactory _toSpeckle; - private readonly IRawConversion _pointFeatureConverter; - private readonly IRawConversion _multiPointFeatureConverter; - private readonly IRawConversion _polylineFeatureConverter; - private readonly IRawConversion _polygonFeatureConverter; + private readonly IRawConversion _pointToSpeckleConverter; + private readonly IRawConversion> _multiPointFeatureConverter; + private readonly IRawConversion> _polylineFeatureConverter; + private readonly IRawConversion> _polygonFeatureConverter; public GeometryToSpeckleBaseList( - IFactory toSpeckle, - IRawConversion pointFeatureConverter, - IRawConversion multiPointFeatureConverter, - IRawConversion polylineFeatureConverter, - IRawConversion polygonFeatureConverter + IRawConversion pointToSpeckleConverter, + IRawConversion> multiPointFeatureConverter, + IRawConversion> polylineFeatureConverter, + IRawConversion> polygonFeatureConverter ) { - _toSpeckle = toSpeckle; - _pointFeatureConverter = pointFeatureConverter; + _pointToSpeckleConverter = pointToSpeckleConverter; _multiPointFeatureConverter = multiPointFeatureConverter; _polylineFeatureConverter = polylineFeatureConverter; _polygonFeatureConverter = polygonFeatureConverter; } - public Base Convert(object target) => RawConvert((ArcGIS.Core.Geometry.Geometry)target); - - public Base RawConvert(ArcGIS.Core.Geometry.Geometry target) + public IReadOnlyList RawConvert(ArcGIS.Core.Geometry.Geometry target) { - List convertedList = new(); - - Type type = target.GetType(); try { - Base newGeometry = new(); // objectConverter.Convert(target); - if (target is MapPoint) - { - newGeometry = _pointFeatureConverter.RawConvert((MapPoint)target); - convertedList.Add(newGeometry); - return convertedList[0]; - } - if (target is Multipoint) - { - newGeometry = _multiPointFeatureConverter.RawConvert((Multipoint)target); - convertedList.Add(newGeometry); - return convertedList[0]; - } - if (target is Polyline) - { - newGeometry = _polylineFeatureConverter.RawConvert((Polyline)target); - convertedList.Add(newGeometry); - return convertedList[0]; - } - if (target is Polygon) + return target switch { - newGeometry = _polygonFeatureConverter.RawConvert((Polygon)target); - convertedList.Add(newGeometry); - return convertedList[0]; - } - throw new NotSupportedException($"No conversion found for {type.Name}"); + MapPoint point => new List() { _pointToSpeckleConverter.RawConvert(point) }, + Multipoint multipoint => _multiPointFeatureConverter.RawConvert(multipoint), + Polyline polyline => _polylineFeatureConverter.RawConvert(polyline), + Polygon polygon => _polygonFeatureConverter.RawConvert(polygon), + _ => throw new NotSupportedException($"No conversion found for {target.GetType().Name}"), + }; } catch (SpeckleConversionException e) { diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GisFeatureToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GisFeatureToSpeckleConverter.cs index f2ad04ca6c..8c57d24351 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GisFeatureToSpeckleConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GisFeatureToSpeckleConverter.cs @@ -2,16 +2,14 @@ using Speckle.Core.Models; using Objects.GIS; using ArcGIS.Core.Data; -using Speckle.Converters.Common; namespace Speckle.Converters.ArcGIS3.Features; -[NameAndRankValue(nameof(Row), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class GisFeatureToSpeckleConverter : IHostObjectToSpeckleConversion, IRawConversion +public class GisFeatureToSpeckleConverter : IRawConversion { - private readonly IRawConversion _geometryConverter; + private readonly IRawConversion> _geometryConverter; - public GisFeatureToSpeckleConverter(IRawConversion geometryConverter) + public GisFeatureToSpeckleConverter(IRawConversion> geometryConverter) { _geometryConverter = geometryConverter; } @@ -21,7 +19,7 @@ public GisFeatureToSpeckleConverter(IRawConversion() { _geometryConverter.RawConvert(shape) }; + var speckleShapes = _geometryConverter.RawConvert(shape); // get attributes var attributes = new Base(); diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/MultipointFeatureToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/MultipointFeatureToSpeckleConverter.cs index 89927564a5..8fa34a7939 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/MultipointFeatureToSpeckleConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/MultipointFeatureToSpeckleConverter.cs @@ -1,37 +1,25 @@ using ArcGIS.Core.Geometry; using Speckle.Converters.Common.Objects; -using Speckle.Core.Models; -using Speckle.Converters.Common; -using ArcGIS.Desktop.Mapping; -using ArcMapPoint = ArcGIS.Core.Geometry.MapPoint; namespace Speckle.Converters.ArcGIS3.Features; -[NameAndRankValue(nameof(Multipoint), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class MultipointFeatureToSpeckleConverter : IHostObjectToSpeckleConversion, IRawConversion +public class MultipointFeatureToSpeckleConverter : IRawConversion> { - private readonly IConversionContextStack _contextStack; - private readonly IRawConversion _pointConverter; + private readonly IRawConversion _pointConverter; - public MultipointFeatureToSpeckleConverter( - IConversionContextStack contextStack, - IRawConversion pointConverter - ) + public MultipointFeatureToSpeckleConverter(IRawConversion pointConverter) { - _contextStack = contextStack; _pointConverter = pointConverter; } - public Base Convert(object target) => RawConvert((Multipoint)target); - - public Base RawConvert(Multipoint target) + public IReadOnlyList RawConvert(Multipoint target) { - List multipoint = new(); - foreach (ArcMapPoint point in target.Points) + List multipoint = new(); + foreach (MapPoint point in target.Points) { multipoint.Add(_pointConverter.RawConvert(point)); } - return multipoint[0]; + return multipoint; } } diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/PointFeatureToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/PointFeatureToSpeckleConverter.cs deleted file mode 100644 index 5bee034ca4..0000000000 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/PointFeatureToSpeckleConverter.cs +++ /dev/null @@ -1,37 +0,0 @@ -using ArcGIS.Core.Geometry; -using Speckle.Converters.Common.Objects; -using Speckle.Core.Models; -using Speckle.Converters.Common; -using ArcGIS.Desktop.Mapping; - -namespace Speckle.Converters.ArcGIS3.Features; - -[NameAndRankValue(nameof(MapPoint), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class PointFeatureToSpeckleConverter : IHostObjectToSpeckleConversion, IRawConversion -{ - private readonly IConversionContextStack _contextStack; - - public PointFeatureToSpeckleConverter(IConversionContextStack contextStack) - { - _contextStack = contextStack; - } - - public Base Convert(object target) => RawConvert((MapPoint)target); - - public Base RawConvert(MapPoint target) - { - if ( - GeometryEngine.Instance.Project(target, _contextStack.Current.Document.SpatialReference) - is not MapPoint reprojectedPt - ) - { - throw new SpeckleConversionException( - $"Conversion to Spatial Reference {_contextStack.Current.Document.SpatialReference} failed" - ); - } - List geometry = - new() { new SOG.Point(reprojectedPt.X, reprojectedPt.Y, reprojectedPt.Z, _contextStack.Current.SpeckleUnits) }; - - return geometry[0]; - } -} diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/PolygonFeatureToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/PolygonFeatureToSpeckleConverter.cs index 0684ad8ebf..e312bd16ad 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/PolygonFeatureToSpeckleConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/PolygonFeatureToSpeckleConverter.cs @@ -1,37 +1,22 @@ using ArcGIS.Core.Geometry; using Speckle.Converters.Common.Objects; -using Speckle.Core.Models; -using Speckle.Converters.Common; -using ArcGIS.Desktop.Mapping; -using ArcMapPoint = ArcGIS.Core.Geometry.MapPoint; using Objects.GIS; namespace Speckle.Converters.ArcGIS3.Features; -[NameAndRankValue(nameof(Polygon), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class PolygonFeatureToSpeckleConverter : IHostObjectToSpeckleConversion, IRawConversion +public class PolygonFeatureToSpeckleConverter : IRawConversion> { - private readonly IConversionContextStack _contextStack; - private readonly IRawConversion _pointConverter; private readonly IRawConversion _segmentConverter; - public PolygonFeatureToSpeckleConverter( - IConversionContextStack contextStack, - IRawConversion pointConverter, - IRawConversion segmentConverter - ) + public PolygonFeatureToSpeckleConverter(IRawConversion segmentConverter) { - _contextStack = contextStack; - _pointConverter = pointConverter; _segmentConverter = segmentConverter; } - public Base Convert(object target) => RawConvert((Polygon)target); - - public Base RawConvert(Polygon target) + public IReadOnlyList RawConvert(Polygon target) { // https://pro.arcgis.com/en/pro-app/latest/sdk/api-reference/topic30235.html - List polygonList = new(); + List polygonList = new(); int partCount = target.PartCount; GisPolygonGeometry polygon = new() { voids = new List() }; @@ -57,6 +42,6 @@ public Base RawConvert(Polygon target) } polygonList.Add(polygon); - return polygonList[0]; + return polygonList; } } diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/PolylineFeatureToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/PolylineFeatureToSpeckleConverter.cs index bdff001976..96c7e35574 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/PolylineFeatureToSpeckleConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/PolylineFeatureToSpeckleConverter.cs @@ -1,40 +1,25 @@ using ArcGIS.Core.Geometry; using Speckle.Converters.Common.Objects; -using Speckle.Core.Models; -using Speckle.Converters.Common; -using ArcGIS.Desktop.Mapping; -using ArcMapPoint = ArcGIS.Core.Geometry.MapPoint; namespace Speckle.Converters.ArcGIS3.Features; -[NameAndRankValue(nameof(Polyline), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class PolyineFeatureToSpeckleConverter : IHostObjectToSpeckleConversion, IRawConversion +public class PolyineFeatureToSpeckleConverter : IRawConversion> { - private readonly IConversionContextStack _contextStack; - private readonly IRawConversion _pointConverter; private readonly IRawConversion _segmentConverter; - public PolyineFeatureToSpeckleConverter( - IConversionContextStack contextStack, - IRawConversion pointConverter, - IRawConversion segmentConverter - ) + public PolyineFeatureToSpeckleConverter(IRawConversion segmentConverter) { - _contextStack = contextStack; - _pointConverter = pointConverter; _segmentConverter = segmentConverter; } - public Base Convert(object target) => RawConvert((Polyline)target); - - public Base RawConvert(Polyline target) + public IReadOnlyList RawConvert(Polyline target) { // https://pro.arcgis.com/en/pro-app/latest/sdk/api-reference/topic8480.html - List polylineList = new(); + List polylineList = new(); foreach (var segmentCollection in target.Parts) { polylineList.Add(_segmentConverter.RawConvert(segmentCollection)); } - return polylineList[0]; + return polylineList; } } diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/BezierSegmentToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/BezierSegmentToSpeckleConverter.cs index 0fd602b544..3bd981ce71 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/BezierSegmentToSpeckleConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/BezierSegmentToSpeckleConverter.cs @@ -1,31 +1,24 @@ using ArcGIS.Core.Geometry; using Speckle.Converters.Common.Objects; -using Speckle.Core.Models; using Speckle.Converters.Common; using ArcGIS.Desktop.Mapping; -using ArcMapPoint = ArcGIS.Core.Geometry.MapPoint; namespace Speckle.Converters.ArcGIS3.Geometry; -[NameAndRankValue(nameof(CubicBezierSegment), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class BezierSegmentToSpeckleConverter - : IHostObjectToSpeckleConversion, - IRawConversion +public class BezierSegmentToSpeckleConverter : IRawConversion { private readonly IConversionContextStack _contextStack; - private readonly IRawConversion _pointConverter; + private readonly IRawConversion _pointConverter; public BezierSegmentToSpeckleConverter( IConversionContextStack contextStack, - IRawConversion pointConverter + IRawConversion pointConverter ) { _contextStack = contextStack; _pointConverter = pointConverter; } - public Base Convert(object target) => RawConvert((CubicBezierSegment)target); - public SOG.Polyline RawConvert(CubicBezierSegment target) { // Determine the number of vertices to create along the arc @@ -50,7 +43,7 @@ public SOG.Polyline RawConvert(CubicBezierSegment target) + 3 * (1 - t) * t * t * target.ControlPoint2.Y + t * t * t * target.EndPoint.Y; - ArcMapPoint pointOnCurve = MapPointBuilderEx.CreateMapPoint(x, y, target.SpatialReference); + MapPoint pointOnCurve = MapPointBuilderEx.CreateMapPoint(x, y, target.SpatialReference); points.Add(_pointConverter.RawConvert(pointOnCurve)); } diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/EllipticArcSegmentToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/EllipticArcSegmentToSpeckleConverter.cs index cdf17d6dd5..44f3d2ffbc 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/EllipticArcSegmentToSpeckleConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/EllipticArcSegmentToSpeckleConverter.cs @@ -1,31 +1,24 @@ using ArcGIS.Core.Geometry; using Speckle.Converters.Common.Objects; -using Speckle.Core.Models; using Speckle.Converters.Common; using ArcGIS.Desktop.Mapping; -using ArcMapPoint = ArcGIS.Core.Geometry.MapPoint; namespace Speckle.Converters.ArcGIS3.Geometry; -[NameAndRankValue(nameof(EllipticArcSegment), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class EllipticArcToSpeckleConverter - : IHostObjectToSpeckleConversion, - IRawConversion +public class EllipticArcToSpeckleConverter : IRawConversion { private readonly IConversionContextStack _contextStack; - private readonly IRawConversion _pointConverter; + private readonly IRawConversion _pointConverter; public EllipticArcToSpeckleConverter( IConversionContextStack contextStack, - IRawConversion pointConverter + IRawConversion pointConverter ) { _contextStack = contextStack; _pointConverter = pointConverter; } - public Base Convert(object target) => RawConvert((EllipticArcSegment)target); - public SOG.Polyline RawConvert(EllipticArcSegment target) { // Determine the number of vertices to create along the arc @@ -54,7 +47,7 @@ public SOG.Polyline RawConvert(EllipticArcSegment target) { // Calculate the point along the arc double angle = angleStart + coeff * fullAngle * (i / (double)numVertices); - ArcMapPoint pointOnArc = MapPointBuilderEx.CreateMapPoint( + MapPoint pointOnArc = MapPointBuilderEx.CreateMapPoint( target.CenterPoint.X + target.SemiMajorAxis * Math.Cos(angle), target.CenterPoint.Y + target.SemiMinorAxis * Math.Sin(angle), target.SpatialReference diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/PointToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/PointToSpeckleConverter.cs index 2f3cc5e6a5..5a43fd40b4 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/PointToSpeckleConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/PointToSpeckleConverter.cs @@ -1,14 +1,11 @@ using ArcGIS.Core.Geometry; -using ArcMapPoint = ArcGIS.Core.Geometry.MapPoint; using Speckle.Converters.Common.Objects; -using Speckle.Core.Models; using Speckle.Converters.Common; using ArcGIS.Desktop.Mapping; namespace Speckle.Converters.ArcGIS3.Geometry; -[NameAndRankValue(nameof(ArcMapPoint), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class PointToSpeckleConverter : IHostObjectToSpeckleConversion, IRawConversion +public class PointToSpeckleConverter : IRawConversion { private readonly IConversionContextStack _contextStack; @@ -17,13 +14,11 @@ public PointToSpeckleConverter(IConversionContextStack contextStack) _contextStack = contextStack; } - public Base Convert(object target) => RawConvert((ArcMapPoint)target); - - public SOG.Point RawConvert(ArcMapPoint target) + public SOG.Point RawConvert(MapPoint target) { if ( GeometryEngine.Instance.Project(target, _contextStack.Current.Document.SpatialReference) - is not ArcMapPoint reprojectedPt + is not MapPoint reprojectedPt ) { throw new SpeckleConversionException( diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/SegmentCollectionToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/SegmentCollectionToSpeckleConverter.cs index fb7c237a70..72dff64b19 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/SegmentCollectionToSpeckleConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/SegmentCollectionToSpeckleConverter.cs @@ -2,24 +2,19 @@ using ArcGIS.Desktop.Mapping; using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; -using Speckle.Core.Models; -using ArcMapPoint = ArcGIS.Core.Geometry.MapPoint; namespace Speckle.Converters.ArcGIS3.Geometry; -[NameAndRankValue(nameof(ReadOnlySegmentCollection), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class SegmentCollectionToSpeckleConverter - : IHostObjectToSpeckleConversion, - IRawConversion +public class SegmentCollectionToSpeckleConverter : IRawConversion { private readonly IConversionContextStack _contextStack; - private readonly IRawConversion _pointConverter; + private readonly IRawConversion _pointConverter; private readonly IRawConversion _arcConverter; private readonly IRawConversion _bezierConverter; public SegmentCollectionToSpeckleConverter( IConversionContextStack contextStack, - IRawConversion pointConverter, + IRawConversion pointConverter, IRawConversion arcConverter, IRawConversion bezierConverter ) @@ -30,8 +25,6 @@ public SegmentCollectionToSpeckleConverter( _bezierConverter = bezierConverter; } - public Base Convert(object target) => RawConvert((ReadOnlySegmentCollection)target); - public SOG.Polyline RawConvert(ReadOnlySegmentCollection target) { // https://pro.arcgis.com/en/pro-app/latest/sdk/api-reference/topic8480.html From 826331865a6cdcb9e609776857aa8fcfb5889570 Mon Sep 17 00:00:00 2001 From: Dimitrie Stefanescu Date: Tue, 16 Apr 2024 11:30:29 +0100 Subject: [PATCH 026/261] chore(dui3): adds test bindings + a poc simple config binding --- .../AutofacArcGISModule.cs | 2 + .../AutofacAutocadModule.cs | 2 + .../DependencyInjection/AutofacUIModule.cs | 2 + .../DependencyInjection/AutofacRhinoModule.cs | 4 +- .../Bindings/AccountBinding.cs | 14 +--- .../Bindings/ConfigBinding.cs | 77 +++++++++++++++++++ .../Bindings/TestBinding.cs | 57 ++++++++++++++ .../Bridge/BrowserBridge.cs | 4 +- .../Models/DocumentModelStore.cs | 4 +- 9 files changed, 149 insertions(+), 17 deletions(-) create mode 100644 DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/ConfigBinding.cs create mode 100644 DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/TestBinding.cs diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/DependencyInjection/AutofacArcGISModule.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/DependencyInjection/AutofacArcGISModule.cs index f7fd4d6f57..9a4b03a51e 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/DependencyInjection/AutofacArcGISModule.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/DependencyInjection/AutofacArcGISModule.cs @@ -34,6 +34,8 @@ protected override void Load(ContainerBuilder builder) builder.RegisterType().SingleInstance(); // Register bindings + builder.RegisterType().As().SingleInstance(); + builder.RegisterType().As().SingleInstance().WithParameter("connectorName", "ArcGIS"); // POC: Easier like this for now, should be cleaned up later builder.RegisterType().As().SingleInstance(); builder.RegisterType().As().As().SingleInstance(); builder.RegisterType().As().SingleInstance(); diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/DependencyInjection/AutofacAutocadModule.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/DependencyInjection/AutofacAutocadModule.cs index 2c8d58cacf..ff841b3ff3 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/DependencyInjection/AutofacAutocadModule.cs +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/DependencyInjection/AutofacAutocadModule.cs @@ -52,6 +52,8 @@ protected override void Load(ContainerBuilder builder) // POC: Register here also RootObjectBuilder as IRootObjectBuilder // Register bindings + builder.RegisterType().As().SingleInstance(); + builder.RegisterType().As().SingleInstance().WithParameter("connectorName", "Autocad"); // POC: Easier like this for now, should be cleaned up later builder.RegisterType().As().SingleInstance(); builder.RegisterType().As().As().SingleInstance(); builder.RegisterType().As().SingleInstance(); diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/AutofacUIModule.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/AutofacUIModule.cs index b3cd9c20f6..2427646521 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/AutofacUIModule.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/AutofacUIModule.cs @@ -57,6 +57,8 @@ protected override void Load(ContainerBuilder builder) // POC: we need to review the scopes and create a document on what the policy is // and where the UoW should be // register UI bindings + builder.RegisterType().As().SingleInstance(); + builder.RegisterType().As().SingleInstance().WithParameter("connectorName", "Revit"); // POC: Easier like this for now, should be cleaned up later builder.RegisterType().As().SingleInstance(); builder.RegisterType().As().SingleInstance(); builder.RegisterType().As().SingleInstance(); diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/AutofacRhinoModule.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/AutofacRhinoModule.cs index 9dadc15463..22a1b4b421 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/AutofacRhinoModule.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/AutofacRhinoModule.cs @@ -34,7 +34,7 @@ protected override void Load(ContainerBuilder builder) // Register instances initialised by Rhino builder.RegisterInstance(SpeckleConnectorsRhino7Plugin.Instance); builder.RegisterInstance(SpeckleConnectorsRhino7Command.Instance); - + // Register DUI3 related stuff builder.RegisterInstance(GetJsonSerializerSettings()).SingleInstance(); builder.RegisterType().SingleInstance(); @@ -46,6 +46,8 @@ protected override void Load(ContainerBuilder builder) builder.RegisterType().SingleInstance(); // Register bindings + builder.RegisterType().As().SingleInstance(); + builder.RegisterType().As().SingleInstance().WithParameter("connectorName", "Rhino"); // POC: Easier like this for now, should be cleaned up later builder.RegisterType().As().SingleInstance(); builder.RegisterType().As().As().SingleInstance(); builder.RegisterType().As().SingleInstance(); diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/AccountBinding.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/AccountBinding.cs index 08d66d19ec..a6cd90ba79 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/AccountBinding.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/AccountBinding.cs @@ -4,8 +4,6 @@ namespace Speckle.Connectors.DUI.Bindings; -// TODO: this needs splitting into different files - public class AccountBinding : IBinding { public string Name { get; set; } = "accountsBinding"; @@ -16,15 +14,5 @@ public AccountBinding(IBridge bridge) Parent = bridge; } - public Account[] GetAccounts() - { - return AccountManager.GetAccounts().ToArray(); - // NOTE: removing the avatars is no longer needed as we've resolved the issue described below via the bridge implementation. - // .Select( - // a => - // { - // a.userInfo.avatar = null; // removing this as the get accounts call was a too large string to do "executeScriptAsync" with (this was not happening if this was a direct return from a binding call). - // return a; - // }).ToArray(); - } + public Account[] GetAccounts() => AccountManager.GetAccounts().ToArray(); } diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/ConfigBinding.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/ConfigBinding.cs new file mode 100644 index 0000000000..13a1055df8 --- /dev/null +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/ConfigBinding.cs @@ -0,0 +1,77 @@ +using System; +using System.Runtime.Serialization; +using Speckle.Connectors.DUI.Bridge; +using Speckle.Core.Transports; +using Speckle.Newtonsoft.Json; + +namespace Speckle.Connectors.DUI.Bindings; + +/// +/// POC: Simple config binding, as it was driving Dim nuts he couldn't swap to a dark theme. +/// How does it store configs? In a sqlite db called 'DUI3Config', we create a row for each host application: +/// [ hash, contents ] +/// ['Rhino', serialised config] +/// ['Revit', serialised config] +/// +public class ConfigBinding : IBinding +{ + public string Name => "configBinding"; + public IBridge Parent { get; } + private SQLiteTransport ConfigStorage { get; } + private readonly string _connectorName; + private readonly JsonSerializerSettings _serializerOptions; + + + public ConfigBinding(IBridge bridge, JsonSerializerSettings serializerOptions, string connectorName) + { + Parent = bridge; + ConfigStorage = new SQLiteTransport(scope: "DUI3Config"); + _connectorName = connectorName; + _serializerOptions = serializerOptions; + } + + public ConnectorConfig GetConfig() + { + var rawConfig = ConfigStorage.GetObject(_connectorName); + if (rawConfig is null) + { + return SeedConfig(); + } + + try + { + var config = JsonConvert.DeserializeObject(rawConfig, _serializerOptions); + if (config is null) + { + throw new SerializationException("Failed to deserialize config"); + } + + return config; + } + catch (SerializationException) + { + return SeedConfig(); + } + } + + private ConnectorConfig SeedConfig() + { + var cfg = new ConnectorConfig(); + UpdateConfig(cfg); + return cfg; + } + public void UpdateConfig(ConnectorConfig config) + { + var str = JsonConvert.SerializeObject(config, _serializerOptions); + ConfigStorage.UpdateObject(_connectorName, str); + } + +} + +/// +/// POC: A simple POCO for keeping track of settings. I see this as extensible in the future by each host application if and when we will need global per-app connector settings. +/// +public class ConnectorConfig +{ + public bool DarkTheme { get; set; } = true; +} diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/TestBinding.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/TestBinding.cs new file mode 100644 index 0000000000..0d95e57eda --- /dev/null +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/TestBinding.cs @@ -0,0 +1,57 @@ +using System; +using System.Diagnostics; +using Speckle.Connectors.DUI.Bridge; +using Speckle.Core.Logging; + +namespace Speckle.Connectors.DUI.Bindings; + +public class TestBinding : IBinding +{ + public string Name { get; set; } = "testBinding"; + public IBridge Parent { get; private set; } + + public TestBinding(IBridge bridge) + { + Parent = bridge; + } + + public string SayHi(string name, int count, bool sayHelloNotHi) + { + var baseGreeting = $"{(sayHelloNotHi ? "Hello" : "Hi")} {name}!"; + var finalGreeting = ""; + for (int i = 0; i < Math.Max(1, Math.Abs(count)); i++) + { + finalGreeting += baseGreeting + Environment.NewLine; + } + + return finalGreeting; + } + + public void ShouldThrow() => throw new SpeckleException("I am supposed to throw."); + + public void GoAway() => Debug.WriteLine("Okay, going away."); + + public object GetComplexType() => new { Id = GetHashCode().ToString() + " - I am a string", count = GetHashCode(), thisIsABoolean = false }; + + public void TriggerEvent(string eventName) + { + switch (eventName) + { + case "emptyTestEvent": + Parent.Send("emptyTestEvent"); + break; + case "testEvent": + default: + Parent.Send( + "testEvent", + new + { + IsOk = true, + Name = "foo", + Count = 42 + } + ); + break; + } + } +} diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/BrowserBridge.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/BrowserBridge.cs index c0812756e3..e74b852e6f 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/BrowserBridge.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/BrowserBridge.cs @@ -40,7 +40,9 @@ public class BrowserBridge : IBridge private readonly ILogger _logger; - // POC: what is this excatly? + /// + /// Action that opens up the developer tools of the respective browser we're using. While webview2 allows for "right click, inspect", cefsharp does not - hence the need for this. + /// public Action ShowDevToolsAction { get; set; } public string FrontendBoundName { get; private set; } diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/DocumentModelStore.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/DocumentModelStore.cs index e692aad5aa..4a84af29d8 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/DocumentModelStore.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/DocumentModelStore.cs @@ -19,9 +19,9 @@ public abstract class DocumentModelStore : DiscriminatedObject private readonly JsonSerializerSettings _serializerOptions; - protected DocumentModelStore(JsonSerializerSettings serializerOption) + protected DocumentModelStore(JsonSerializerSettings serializerOptions) { - _serializerOptions = serializerOption; + _serializerOptions = serializerOptions; } /// From f683222757e436703c728132fe5a59bb2ec4a937 Mon Sep 17 00:00:00 2001 From: Dimitrie Stefanescu Date: Tue, 16 Apr 2024 11:35:19 +0100 Subject: [PATCH 027/261] chore(dui3): adds comment to test bindings + formatting --- .../Speckle.Connectors.DUI/Bindings/TestBinding.cs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/TestBinding.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/TestBinding.cs index 0d95e57eda..0e1152f266 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/TestBinding.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/TestBinding.cs @@ -5,6 +5,9 @@ namespace Speckle.Connectors.DUI.Bindings; +/// +/// POC: This is a class that sanity checks basic bridge functionality. It is required by the frontend's tests page. +/// public class TestBinding : IBinding { public string Name { get; set; } = "testBinding"; @@ -14,7 +17,7 @@ public TestBinding(IBridge bridge) { Parent = bridge; } - + public string SayHi(string name, int count, bool sayHelloNotHi) { var baseGreeting = $"{(sayHelloNotHi ? "Hello" : "Hi")} {name}!"; @@ -31,7 +34,13 @@ public string SayHi(string name, int count, bool sayHelloNotHi) public void GoAway() => Debug.WriteLine("Okay, going away."); - public object GetComplexType() => new { Id = GetHashCode().ToString() + " - I am a string", count = GetHashCode(), thisIsABoolean = false }; + public object GetComplexType() => + new + { + Id = GetHashCode().ToString() + " - I am a string", + count = GetHashCode(), + thisIsABoolean = false + }; public void TriggerEvent(string eventName) { From d4018974f45b568410b2ea3b4af26027ad4612e4 Mon Sep 17 00:00:00 2001 From: Dimitrie Stefanescu Date: Tue, 16 Apr 2024 11:42:04 +0100 Subject: [PATCH 028/261] chore(dui3): formatting MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (why didn't this happen on save before 🙃) --- .../DependencyInjection/AutofacRhinoModule.cs | 2 +- .../DUI3/Speckle.Connectors.DUI/Bindings/ConfigBinding.cs | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/AutofacRhinoModule.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/AutofacRhinoModule.cs index 22a1b4b421..46a657a391 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/AutofacRhinoModule.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/AutofacRhinoModule.cs @@ -34,7 +34,7 @@ protected override void Load(ContainerBuilder builder) // Register instances initialised by Rhino builder.RegisterInstance(SpeckleConnectorsRhino7Plugin.Instance); builder.RegisterInstance(SpeckleConnectorsRhino7Command.Instance); - + // Register DUI3 related stuff builder.RegisterInstance(GetJsonSerializerSettings()).SingleInstance(); builder.RegisterType().SingleInstance(); diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/ConfigBinding.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/ConfigBinding.cs index 13a1055df8..246b80e956 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/ConfigBinding.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/ConfigBinding.cs @@ -21,7 +21,6 @@ public class ConfigBinding : IBinding private readonly string _connectorName; private readonly JsonSerializerSettings _serializerOptions; - public ConfigBinding(IBridge bridge, JsonSerializerSettings serializerOptions, string connectorName) { Parent = bridge; @@ -55,17 +54,17 @@ public ConnectorConfig GetConfig() } private ConnectorConfig SeedConfig() - { - var cfg = new ConnectorConfig(); + { + var cfg = new ConnectorConfig(); UpdateConfig(cfg); return cfg; } + public void UpdateConfig(ConnectorConfig config) { var str = JsonConvert.SerializeObject(config, _serializerOptions); ConfigStorage.UpdateObject(_connectorName, str); } - } /// From 6e719bb89c923facf23ad921bba951f58484bbf0 Mon Sep 17 00:00:00 2001 From: BovineOx <73857041+BovineOx@users.noreply.github.com> Date: Tue, 16 Apr 2024 20:40:27 +0100 Subject: [PATCH 029/261] Cnx 9241 define a unit of work pattern for our dependency injection related to scoped factory (#3276) * UnitOfWork changes Initial put of UoW interfaces * Initial Push Unit of Work An initial put of the work * Fixing some PR comments Removing dead class and unintentional log addition :!? * Reinstate Specklelog Init Reinstate Speckle loginit * Now I think I fixed the PR comments? Now I think I fixed the PR comments? * Removed POC comment Removed POC comment * Fixed missing usings Fixed missing usings --- .../Bindings/ArcGISSendBinding.cs | 8 ++-- .../AutofacArcGISModule.cs | 5 +- .../Operations/Send/RootObjectBuilder.cs | 12 +++-- .../Bindings/AutocadSendBinding.cs | 13 +++-- .../AutofacAutocadModule.cs | 9 +--- .../Operations/Receive/HostObjectBuilder.cs | 14 +++--- .../Bindings/SendBinding.cs | 5 +- .../DependencyInjection/AutofacUIModule.cs | 11 +++-- .../Operations/Send/RootObjectBuilder.cs | 12 ++--- .../Operations/Send/SendOperation.cs | 24 ++++++---- .../Plugin/RevitExternalApplication.cs | 4 +- .../DependencyInjection/AutofacRhinoModule.cs | 2 + .../Operations/Send/RootObjectBuilder.cs | 12 +++-- .../AutofacRevitConverterModule.cs | 5 +- .../AutofacRhinoConverterModule.cs | 9 +--- .../Bridge/BrowserBridge.cs | 1 + .../DependencyInjection/IScopedFactory.cs | 9 ---- .../DependencyInjection/IUnitOfWork.cs | 9 ++++ .../DependencyInjection/IUnitOfWorkFactory.cs | 9 ++++ .../DependencyInjection/ScopedFactory.cs | 48 ------------------- .../DependencyInjection/UnitOfWork.cs | 29 +++++++++++ .../DependencyInjection/UnitOfWorkFactory.cs | 36 ++++++++++++++ 22 files changed, 160 insertions(+), 126 deletions(-) delete mode 100644 DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/IScopedFactory.cs create mode 100644 DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/IUnitOfWork.cs create mode 100644 DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/IUnitOfWorkFactory.cs delete mode 100644 DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/ScopedFactory.cs create mode 100644 DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/UnitOfWork.cs create mode 100644 DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/UnitOfWorkFactory.cs diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISSendBinding.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISSendBinding.cs index ede5d5644a..aaf665b413 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISSendBinding.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISSendBinding.cs @@ -6,7 +6,6 @@ using Speckle.Connectors.ArcGIS.Filters; using Speckle.Connectors.ArcGis.Operations.Send; using Speckle.Connectors.Utils.Cancellation; -using Speckle.Converters.Common; using Speckle.Core.Logging; using ICancelable = System.Reactive.Disposables.ICancelable; using Speckle.Connectors.ArcGIS.Utils; @@ -22,7 +21,7 @@ public sealed class ArcGISSendBinding : ISendBinding, ICancelable public IBridge Parent { get; } private readonly ArcGISDocumentStore _store; - private readonly IScopedFactory _speckleConverterToSpeckleFactory; + private readonly IUnitOfWorkFactory _unitOfWorkFactory; // POC: unused? :D private readonly CancellationManager _cancellationManager; private readonly SendOperation _sendOperation; @@ -34,13 +33,13 @@ public sealed class ArcGISSendBinding : ISendBinding, ICancelable public ArcGISSendBinding( ArcGISDocumentStore store, IBridge parent, - IScopedFactory speckleConverterToSpeckleFactory, + IUnitOfWorkFactory unitOfWorkFactory, SendOperation sendOperation, CancellationManager cancellationManager ) { _store = store; - _speckleConverterToSpeckleFactory = speckleConverterToSpeckleFactory; + _unitOfWorkFactory = unitOfWorkFactory; _sendOperation = sendOperation; _cancellationManager = cancellationManager; @@ -140,7 +139,6 @@ private void OnSendOperationProgress(string modelCardId, string status, double? public void Dispose() { IsDisposed = true; - _speckleConverterToSpeckleFactory.Dispose(); } public bool IsDisposed { get; private set; } diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/DependencyInjection/AutofacArcGISModule.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/DependencyInjection/AutofacArcGISModule.cs index f7fd4d6f57..4e4d55609b 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/DependencyInjection/AutofacArcGISModule.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/DependencyInjection/AutofacArcGISModule.cs @@ -51,10 +51,7 @@ protected override void Load(ContainerBuilder builder) builder.RegisterType().As().SingleInstance(); // Register converter factory - builder - .RegisterType>() - .As>() - .InstancePerLifetimeScope(); + builder.RegisterType().As().InstancePerLifetimeScope(); } //poc: dupe code diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Send/RootObjectBuilder.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Send/RootObjectBuilder.cs index ac3295b0cc..9bd865f9f1 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Send/RootObjectBuilder.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Send/RootObjectBuilder.cs @@ -11,11 +11,11 @@ namespace Speckle.Connectors.ArcGis.Operations.Send; /// public class RootObjectBuilder { - private readonly IScopedFactory _converterFactory; + private readonly IUnitOfWorkFactory _unitOfWorkFactory; - public RootObjectBuilder(IScopedFactory converterFactory) + public RootObjectBuilder(IUnitOfWorkFactory unitOfWorkFactory) { - _converterFactory = converterFactory; + _unitOfWorkFactory = unitOfWorkFactory; } public Base Build( @@ -73,11 +73,15 @@ private Collection ConvertObjects( CancellationToken cancellationToken = default ) { + // POC: does this feel like the right place? I am wondering if this should be called from within send/rcv? + // begin the unit of work + using var uow = _unitOfWorkFactory.Resolve(); + var converter = uow.Service; + // var rootObjectCollection = new Collection { name = RhinoDoc.ActiveDoc.Name ?? "Unnamed document" }; int count = 0; Collection rootObjectCollection = new(); //TODO: Collections - ISpeckleConverterToSpeckle converter = _converterFactory.ResolveScopedInstance(); foreach ((MapMember mapMember, List objectIds) in mapMembers) { diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadSendBinding.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadSendBinding.cs index 578510051a..7498cb1895 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadSendBinding.cs +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadSendBinding.cs @@ -30,7 +30,7 @@ public sealed class AutocadSendBinding : ISendBinding, ICancelable private readonly AutocadIdleManager _idleManager; private readonly List _sendFilters; private readonly CancellationManager _cancellationManager; - private readonly IScopedFactory _speckleConverterToSpeckleFactory; + private readonly IUnitOfWorkFactory _unitOfWorkFactory; /// /// Used internally to aggregate the changed objects' id. @@ -48,12 +48,12 @@ public AutocadSendBinding( IBridge parent, IEnumerable sendFilters, CancellationManager cancellationManager, - IScopedFactory speckleConverterToSpeckleFactory + IUnitOfWorkFactory unitOfWorkFactory ) { _store = store; _idleManager = idleManager; - _speckleConverterToSpeckleFactory = speckleConverterToSpeckleFactory; + _unitOfWorkFactory = unitOfWorkFactory; _cancellationManager = cancellationManager; _sendFilters = sendFilters.ToList(); @@ -201,7 +201,11 @@ private Base ConvertObjects( CancellationToken cancellationToken ) { - ISpeckleConverterToSpeckle converter = _speckleConverterToSpeckleFactory.ResolveScopedInstance(); + // POC: does this feel like the right place? I am wondering if this should be called from within send/rcv? + // begin the unit of work + using var uow = _unitOfWorkFactory.Resolve(); + var converter = uow.Service; + Collection modelWithLayers = new() { @@ -284,7 +288,6 @@ CancellationToken cancellationToken public void Dispose() { IsDisposed = true; - _speckleConverterToSpeckleFactory.Dispose(); } public bool IsDisposed { get; private set; } diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/DependencyInjection/AutofacAutocadModule.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/DependencyInjection/AutofacAutocadModule.cs index 2c8d58cacf..609a1754dc 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/DependencyInjection/AutofacAutocadModule.cs +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/DependencyInjection/AutofacAutocadModule.cs @@ -69,14 +69,7 @@ protected override void Load(ContainerBuilder builder) builder.RegisterType().As().InstancePerDependency(); // Register converter factory - builder - .RegisterType>() - .As>() - .InstancePerLifetimeScope(); - builder - .RegisterType>() - .As>() - .InstancePerLifetimeScope(); + builder.RegisterType().As().InstancePerLifetimeScope(); } private static JsonSerializerSettings GetJsonSerializerSettings() diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Operations/Receive/HostObjectBuilder.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Operations/Receive/HostObjectBuilder.cs index d2f5f65043..e72318f7e3 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Operations/Receive/HostObjectBuilder.cs +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Operations/Receive/HostObjectBuilder.cs @@ -13,15 +13,12 @@ namespace Speckle.Connectors.Autocad.Operations.Receive; public class HostObjectBuilder : IHostObjectBuilder { - private readonly IScopedFactory _speckleConverterToHostFactory; + private readonly IUnitOfWorkFactory _unitOfWorkFactory; private readonly AutocadLayerManager _autocadLayerManager; - public HostObjectBuilder( - IScopedFactory speckleConverterToHostFactory, - AutocadLayerManager autocadLayerManager - ) + public HostObjectBuilder(IUnitOfWorkFactory unitOfWorkFactory, AutocadLayerManager autocadLayerManager) { - _speckleConverterToHostFactory = speckleConverterToHostFactory; + _unitOfWorkFactory = unitOfWorkFactory; _autocadLayerManager = autocadLayerManager; } @@ -52,7 +49,10 @@ CancellationToken cancellationToken // Prompt the UI conversion started. Progress bar will swoosh. onOperationProgressed?.Invoke("Converting", null); - ISpeckleConverterToHost converter = _speckleConverterToHostFactory.ResolveScopedInstance(); + // POC: does this feel like the right place? I am wondering if this should be called from within send/rcv? + // begin the unit of work + using var uow = _unitOfWorkFactory.Resolve(); + var converter = uow.Service; // Layer filter for received commit with project and model name _autocadLayerManager.CreateLayerFilter(projectName, modelName); diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SendBinding.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SendBinding.cs index 8cc0020f59..d4e68c1ee0 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SendBinding.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SendBinding.cs @@ -71,9 +71,10 @@ public void CancelSend(string modelCardId) private async Task HandleSend(string modelCardId) { - // POC this is where we need to begin UoW - // i.e. we resolve the UoW + // POC: should THIS be where we begin the UoW + // POC: probably the CTS SHOULD be injected as InstancePerLifetimeScope and then + // it can be injected where needed instead of passing it around like a bomb :D CancellationTokenSource cts = CancellationManager.InitCancellationTokenSource(modelCardId); if (_store.GetModelById(modelCardId) is not SenderModelCard modelCard) diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/AutofacUIModule.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/AutofacUIModule.cs index b3cd9c20f6..9c2ea24885 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/AutofacUIModule.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/AutofacUIModule.cs @@ -4,6 +4,7 @@ using CefSharp; using Microsoft.Extensions.Logging; using Serilog; +using Speckle.Autofac.DependencyInjection; using Speckle.Connectors.DUI.Bindings; using Speckle.Connectors.DUI.Bridge; using Speckle.Connectors.DUI.Models.Card.SendFilter; @@ -75,11 +76,11 @@ protected override void Load(ContainerBuilder builder) // register builder.RegisterType().SingleInstance(); - // POC: this needs to considering, and should either be re-instated/fixed and relates to where the UoW is. - //builder - // .RegisterType>() - // .As>() - // .InstancePerLifetimeScope(); + // POC: needs interafacing out + builder.RegisterType().InstancePerLifetimeScope(); + + // POC: this can be injected in maybe a common place, perhaps a module in Speckle.Converters.Common.DependencyInjection + builder.RegisterType().As().InstancePerLifetimeScope(); // POC: logging factory couldn't be added, which is the recommendation, due to janky dependencies // having a SpeckleLogging service, might be interesting, if a service can listen on a local port or use named pipes diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RootObjectBuilder.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RootObjectBuilder.cs index 75decd30e6..f29b4ac93f 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RootObjectBuilder.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RootObjectBuilder.cs @@ -7,36 +7,36 @@ using Speckle.Converters.RevitShared.Helpers; using Speckle.Connectors.Revit.HostApp; using System.Linq; -using Speckle.Connectors.DUI.Models.Card.SendFilter; namespace Speckle.Connectors.Revit.Operations.Send; public class RootObjectBuilder { // POC: SendSelection and RevitConversionContextStack should be interfaces, former needs interfaces - private readonly SendSelection _sendSelection; private readonly ISpeckleConverterToSpeckle _converter; private readonly ToSpeckleConvertedObjectsCache _convertedObjectsCache; private readonly RevitConversionContextStack _contextStack; public RootObjectBuilder( - ISendFilter sendFilter, // POC: need to resolve where the UoW should be and whether this is with the SpeckleConverterToSpeckle or something else ISpeckleConverterToSpeckle converter, ToSpeckleConvertedObjectsCache convertedObjectsCache, RevitConversionContextStack contextStack ) { - _sendSelection = new(sendFilter.GetObjectIds()); _converter = converter; // POC: needs considering if this is something to add now or needs refactoring _convertedObjectsCache = convertedObjectsCache; _contextStack = contextStack; } - public Base Build(Action? onOperationProgressed = null, CancellationToken ct = default) + public Base Build( + SendSelection sendSelection, + Action? onOperationProgressed = null, + CancellationToken ct = default + ) { - List objects = _contextStack.Current.Document.Document.GetElements(_sendSelection.SelectedItems).ToList(); + List objects = _contextStack.Current.Document.Document.GetElements(sendSelection.SelectedItems).ToList(); Base commitObject = new(); diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/SendOperation.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/SendOperation.cs index ba96aacd6e..176be23a48 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/SendOperation.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/SendOperation.cs @@ -2,20 +2,21 @@ using Speckle.Core.Models; using System.Threading.Tasks; using System.Threading; -using Autofac; +using Speckle.Autofac.DependencyInjection; using Speckle.Connectors.DUI.Models.Card.SendFilter; +using Speckle.Converters.RevitShared.Helpers; namespace Speckle.Connectors.Revit.Operations.Send; public sealed class SendOperation { - // POC: need to consider - private readonly ILifetimeScope _scope; + // POC: this now feels like a layer of nothing and the caller should be instantiating the things it needs, maybe... + private readonly IUnitOfWorkFactory _unitOfWorkFactory; private readonly IRootObjectSender _rootObjectSender; - public SendOperation(ILifetimeScope scope, IRootObjectSender rootObjectSender) + public SendOperation(IUnitOfWorkFactory unitOfWorkFactory, IRootObjectSender rootObjectSender) { - _scope = scope; + _unitOfWorkFactory = unitOfWorkFactory; _rootObjectSender = rootObjectSender; } @@ -39,10 +40,17 @@ public async Task Execute( ) { Base commitObject; - using (var scope = _scope.BeginLifetimeScope()) + using (var rootObjectBuilder = _unitOfWorkFactory.Resolve()) { - RootObjectBuilder rootObjectBuilder = scope.Resolve>()(sendFilter); - commitObject = rootObjectBuilder.Build(onOperationProgressed, ct); + // POC: have changed this as I don't understand the injecting of the ISendFilter when we can just use it here + // it begs the question whether ISendFilter should just be injected into the roo object builder and whether this function needs it at all? + // this class is now so thing I wonder if it should exist at all? + // everything is being passed in from the caller? It feels like the caller should be instantiating the UoW + commitObject = rootObjectBuilder.Service.Build( + new SendSelection(sendFilter.GetObjectIds()), + onOperationProgressed, + ct + ); } return await _rootObjectSender diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitExternalApplication.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitExternalApplication.cs index 94085e2bd6..b18e6615d6 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitExternalApplication.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitExternalApplication.cs @@ -14,7 +14,9 @@ namespace Speckle.Connectors.Revit.Plugin; internal class RevitExternalApplication : IExternalApplication { private IRevitPlugin? _revitPlugin; - private AutofacContainer? _container; + + // POC: temp change to test + public static AutofacContainer? _container; // POC: this is getting hard coded - need a way of injecting it // I am beginning to think the shared project is not the way diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/AutofacRhinoModule.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/AutofacRhinoModule.cs index 9dadc15463..c67179842b 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/AutofacRhinoModule.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/AutofacRhinoModule.cs @@ -79,6 +79,7 @@ private static JsonSerializerSettings GetJsonSerializerSettings() { Error = (_, args) => { + // POC: we should probably do a bit more than just swallowing this! Console.WriteLine("*** JSON ERROR: " + args.ErrorContext); }, ContractResolver = new CamelCasePropertyNamesContractResolver(), @@ -92,6 +93,7 @@ private static JsonSerializerSettings GetJsonSerializerSettings() private static void RegisterLoggerFactory(ContainerBuilder builder) { + // POC: will likely need refactoring with our reporting pattern. var serilogLogger = new LoggerConfiguration().MinimumLevel .Debug() .WriteTo.File("log.txt", rollingInterval: RollingInterval.Day) diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Send/RootObjectBuilder.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Send/RootObjectBuilder.cs index 02400cd722..726ed5c1d2 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Send/RootObjectBuilder.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Send/RootObjectBuilder.cs @@ -16,11 +16,11 @@ namespace Speckle.Connectors.Rhino7.Operations.Send; /// public class RootObjectBuilder { - private readonly IScopedFactory _converterFactory; + private readonly IUnitOfWorkFactory _unitOfWorkFactory; - public RootObjectBuilder(IScopedFactory converterFactory) + public RootObjectBuilder(IUnitOfWorkFactory unitOfWorkFactory) { - _converterFactory = converterFactory; + _unitOfWorkFactory = unitOfWorkFactory; } public Base Build( @@ -51,6 +51,11 @@ private Collection ConvertObjects( CancellationToken cancellationToken = default ) { + // POC: does this feel like the right place? I am wondering if this should be called from within send/rcv? + // begin the unit of work + using var uow = _unitOfWorkFactory.Resolve(); + var converter = uow.Service; + var rootObjectCollection = new Collection { name = RhinoDoc.ActiveDoc.Name ?? "Unnamed document" }; int count = 0; @@ -86,7 +91,6 @@ private Collection ConvertObjects( }*/ try { - var converter = _converterFactory.ResolveScopedInstance(); Base converted = converter.Convert(rhinoObject); converted.applicationId = applicationId; diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/AutofacRevitConverterModule.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/AutofacRevitConverterModule.cs index 591b56bbc6..83e29548b8 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/AutofacRevitConverterModule.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/AutofacRevitConverterModule.cs @@ -16,12 +16,13 @@ public class AutofacRevitConverterModule : Module protected override void Load(ContainerBuilder builder) { // most things should be InstancePerLifetimeScope so we get one per operation - builder.RegisterType().As(); + builder.RegisterType().As().InstancePerLifetimeScope(); // factory for conversions builder .RegisterType>() - .As>(); + .As>() + .SingleInstance(); // POC: do we need ToSpeckleScalingService as is, do we need to interface it out? builder.RegisterType().AsSelf().InstancePerLifetimeScope(); diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/AutofacRhinoConverterModule.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/AutofacRhinoConverterModule.cs index ca73ab5dd3..e649049fa2 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/AutofacRhinoConverterModule.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/AutofacRhinoConverterModule.cs @@ -28,10 +28,7 @@ protected override void Load(ContainerBuilder builder) // To Speckle builder.RegisterType().As>().SingleInstance(); builder.RegisterType().As().SingleInstance(); - builder - .RegisterType>() - .As>() - .InstancePerLifetimeScope(); + builder.RegisterType().As().InstancePerLifetimeScope(); /* POC: Moved the Injection of converters into the converter module. Not sure if this is 100% right, as this doesn't just register the conversions within this converter, but any conversions found in any Speckle.*.dll file. @@ -45,10 +42,6 @@ This will require consolidating across other connectors. // To Host // POC: Missing Unit converter builder.RegisterType().As().SingleInstance(); - builder - .RegisterType>() - .As>() - .InstancePerLifetimeScope(); /* POC: Moved the Injection of converters into the converter module. Not sure if this is 100% right, as this doesn't just register the conversions within this converter, but any conversions found in any Speckle.*.dll file. diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/BrowserBridge.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/BrowserBridge.cs index c0812756e3..8186afe4d5 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/BrowserBridge.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/BrowserBridge.cs @@ -101,6 +101,7 @@ public void AssociateWithBinding(IBinding binding, Action scriptMethod, // Whenever the ui will call run method inside .net, it will post a message to this action block. // This conveniently executes the code outside the UI thread and does not block during long operations (such as sending). + // POC: I wonder if TL exception handler should be living here... _actionBlock = new ActionBlock( args => ExecuteMethod(args.MethodName, args.RequestId, args.MethodArgs), new ExecutionDataflowBlockOptions diff --git a/DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/IScopedFactory.cs b/DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/IScopedFactory.cs deleted file mode 100644 index 4a3cab3d37..0000000000 --- a/DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/IScopedFactory.cs +++ /dev/null @@ -1,9 +0,0 @@ -using System; - -namespace Speckle.Autofac.DependencyInjection; - -public interface IScopedFactory : IDisposable - where T : class -{ - T ResolveScopedInstance(); -} diff --git a/DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/IUnitOfWork.cs b/DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/IUnitOfWork.cs new file mode 100644 index 0000000000..886483db73 --- /dev/null +++ b/DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/IUnitOfWork.cs @@ -0,0 +1,9 @@ +using System; + +namespace Speckle.Autofac.DependencyInjection; + +public interface IUnitOfWork : IDisposable + where TService : class +{ + TService Service { get; } +} diff --git a/DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/IUnitOfWorkFactory.cs b/DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/IUnitOfWorkFactory.cs new file mode 100644 index 0000000000..020af4151c --- /dev/null +++ b/DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/IUnitOfWorkFactory.cs @@ -0,0 +1,9 @@ +namespace Speckle.Autofac.DependencyInjection; + +public interface IUnitOfWorkFactory +{ + // POC: this takes a TService but I wonder if the resolution could be in the + // Resolve method + IUnitOfWork Resolve() + where TService : class; +} diff --git a/DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/ScopedFactory.cs b/DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/ScopedFactory.cs deleted file mode 100644 index e4827548c2..0000000000 --- a/DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/ScopedFactory.cs +++ /dev/null @@ -1,48 +0,0 @@ -using System; -using Autofac; - -namespace Speckle.Autofac.DependencyInjection; - -public class ScopedFactory : IScopedFactory - where T : class -{ - private readonly ILifetimeScope _lifetimeScope; - private bool _disposed = false; - - public ScopedFactory(ILifetimeScope parentScope) - { - // POC: do I need a new lifetime each time I do the resolve. - // move this to ResolveScopedInstance() and rename this to UnitOfWork() - // look at the disposal lifecycle, what we might need to return is a UoW object - // we need a document to explain how this works and how to pick where to do it - _lifetimeScope = parentScope.BeginLifetimeScope(); - } - - public T ResolveScopedInstance() - { - // POC: do I need a new lifetime each time I do the resolve - return _lifetimeScope.Resolve(); - } - - public void Dispose() - { - Dispose(true); - GC.SuppressFinalize(this); - } - - protected virtual void Dispose(bool disposing) - { - if (disposing && !_disposed) - { - // POC: check: but I think dispose will end the scope - _lifetimeScope.Dispose(); - _disposed = true; - } - } - - // might be needed in future... - ~ScopedFactory() - { - Dispose(false); - } -} diff --git a/DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/UnitOfWork.cs b/DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/UnitOfWork.cs new file mode 100644 index 0000000000..650e8b3296 --- /dev/null +++ b/DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/UnitOfWork.cs @@ -0,0 +1,29 @@ +using Autofac; + +namespace Speckle.Autofac.DependencyInjection; + +public sealed class UnitOfWork : IUnitOfWork + where TService : class +{ + private readonly ILifetimeScope _unitOfWorkScope; + private bool _notDisposed = true; + + public UnitOfWork(ILifetimeScope unitOfWorkScope, TService service) + { + _unitOfWorkScope = unitOfWorkScope; + Service = service; + } + + public TService Service { get; private set; } + + public void Dispose() => Disposing(true); + + private void Disposing(bool fromDispose) + { + if (_notDisposed && fromDispose) + { + _unitOfWorkScope.Dispose(); + _notDisposed = false; + } + } +} diff --git a/DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/UnitOfWorkFactory.cs b/DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/UnitOfWorkFactory.cs new file mode 100644 index 0000000000..94603a2264 --- /dev/null +++ b/DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/UnitOfWorkFactory.cs @@ -0,0 +1,36 @@ +using Autofac; +using Autofac.Core; +using Speckle.Core.Logging; + +namespace Speckle.Autofac.DependencyInjection; + +public class UnitOfWorkFactory : IUnitOfWorkFactory +{ + private readonly ILifetimeScope _parentScope; + + public UnitOfWorkFactory(ILifetimeScope parentScope) + { + _parentScope = parentScope; + } + + public IUnitOfWork Resolve() + where TService : class + { + ILifetimeScope? childScope = null; + + try + { + childScope = _parentScope.BeginLifetimeScope(); + var service = childScope.Resolve(); + + return new UnitOfWork(childScope, service); + } + catch (DependencyResolutionException dre) + { + childScope?.Dispose(); + + // POC: check exception and how to pass this further up + throw new SpeckleException($"Dependency error resolving {typeof(TService)} within UnitOfWorkFactory", dre); + } + } +} From ff3b92ed1052a1834ff154bca5eca01a0ee77942 Mon Sep 17 00:00:00 2001 From: Dimitrie Stefanescu Date: Thu, 18 Apr 2024 11:52:56 +0100 Subject: [PATCH 030/261] chore(dui3): adds poc comment --- DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/ConfigBinding.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/ConfigBinding.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/ConfigBinding.cs index 246b80e956..7fbccd3db7 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/ConfigBinding.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/ConfigBinding.cs @@ -24,7 +24,7 @@ public class ConfigBinding : IBinding public ConfigBinding(IBridge bridge, JsonSerializerSettings serializerOptions, string connectorName) { Parent = bridge; - ConfigStorage = new SQLiteTransport(scope: "DUI3Config"); + ConfigStorage = new SQLiteTransport(scope: "DUI3Config"); // POC: maybe inject? (if we ever want to use a different storage for configs later down the line) _connectorName = connectorName; _serializerOptions = serializerOptions; } From f95c049eaf8c244c288953581b7477128c8712e6 Mon Sep 17 00:00:00 2001 From: connorivy <43247197+connorivy@users.noreply.github.com> Date: Thu, 18 Apr 2024 08:11:05 -0500 Subject: [PATCH 031/261] Fix Revit connector build (#3288) * fix build * add back deprecated polygonElement class * remove line * more specific reason --------- Co-authored-by: Connor Ivy --- .../Speckle.Converters.RevitShared.projitems | 2 +- Objects/Objects/GIS/PolygonElement.cs | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 Objects/Objects/GIS/PolygonElement.cs diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Speckle.Converters.RevitShared.projitems b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Speckle.Converters.RevitShared.projitems index 06aa00ddca..7b012b5df0 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Speckle.Converters.RevitShared.projitems +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Speckle.Converters.RevitShared.projitems @@ -49,4 +49,4 @@ - + \ No newline at end of file diff --git a/Objects/Objects/GIS/PolygonElement.cs b/Objects/Objects/GIS/PolygonElement.cs new file mode 100644 index 0000000000..8905a7cf5d --- /dev/null +++ b/Objects/Objects/GIS/PolygonElement.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using Speckle.Core.Models; + +namespace Objects.GIS; + +[Obsolete("PolygonElement was replaced by a more generic class, \"GisFeature\", which contains more information")] +public class PolygonElement : Base +{ + [DetachProperty] + public List geometry { get; set; } + public Base attributes { get; set; } +} From b3d923983822e243defcf540473259b04e9cb0c6 Mon Sep 17 00:00:00 2001 From: Dimitrie Stefanescu Date: Thu, 18 Apr 2024 14:51:04 +0100 Subject: [PATCH 032/261] fix(dui3): removes unnecessary using statement thx alan for the sharp eyes!!! --- DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/ConfigBinding.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/ConfigBinding.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/ConfigBinding.cs index 7fbccd3db7..ca2aed10fe 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/ConfigBinding.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/ConfigBinding.cs @@ -1,4 +1,3 @@ -using System; using System.Runtime.Serialization; using Speckle.Connectors.DUI.Bridge; using Speckle.Core.Transports; From 77ffc3a4055e0c930e476fabc237dcecbbb3d0ef Mon Sep 17 00:00:00 2001 From: Jedd Morgan <45512892+JR-Morgan@users.noreply.github.com> Date: Thu, 18 Apr 2024 19:43:52 +0100 Subject: [PATCH 033/261] Get Account by id improvement (#3290) * Get Account by id improvement * Fix warnings * Added unit test --------- Co-authored-by: Alan Rynne --- Core/Core/Credentials/Account.cs | 9 ++++-- Core/Core/Credentials/AccountManager.cs | 13 ++++++-- .../Credentials/Accounts.cs | 14 +++++++++ .../Operations/Send/RootObjectSender.cs | 5 +-- .../Bindings/AutocadSendBinding.cs | 4 +-- .../Operations/Send/RootObjectSender.cs | 6 +--- .../Operations/Send/RootObjectSender.cs | 6 +--- .../Operations/ReceiveOperation.cs | 31 ++++++------------- 8 files changed, 44 insertions(+), 44 deletions(-) diff --git a/Core/Core/Credentials/Account.cs b/Core/Core/Credentials/Account.cs index 160602dfeb..2774a7a40d 100644 --- a/Core/Core/Credentials/Account.cs +++ b/Core/Core/Credentials/Account.cs @@ -4,7 +4,6 @@ using System.Threading.Tasks; using Speckle.Core.Api; using Speckle.Core.Helpers; -using Speckle.Core.Logging; namespace Speckle.Core.Credentials; @@ -12,8 +11,12 @@ namespace Speckle.Core.Credentials; [ComVisible(true)] public class Account : IEquatable { - private string _id { get; set; } + private string _id; + /// + /// The account id is unique to user and server url. + /// + /// Account object invalid: missing required info public string id { get @@ -22,7 +25,7 @@ public string id { if (serverInfo == null || userInfo == null) { - throw new SpeckleException("Incomplete account info: cannot generate id."); + throw new InvalidOperationException("Incomplete account info: cannot generate id."); } _id = Crypt.Md5(userInfo.email + serverInfo.url, "X2"); diff --git a/Core/Core/Credentials/AccountManager.cs b/Core/Core/Credentials/AccountManager.cs index b304aaa573..0f9138825f 100644 --- a/Core/Core/Credentials/AccountManager.cs +++ b/Core/Core/Credentials/AccountManager.cs @@ -234,15 +234,22 @@ public static string GetDefaultServerUrl() return serverUrl; } + /// The Id of the account to fetch + /// + /// Account with was not found + public static Account GetAccount(string id) + { + return GetAccounts().FirstOrDefault(acc => acc.id == id) + ?? throw new SpeckleAccountManagerException($"Account {id} not found"); + } + /// /// Upgrades an account from the account.serverInfo.movedFrom account to the account.serverInfo.movedTo account /// /// Id of the account to upgrade public static async Task UpgradeAccount(string id) { - var account = - GetAccounts().FirstOrDefault(acc => acc.id == id) - ?? throw new SpeckleAccountManagerException($"Account {id} not found"); + Account account = GetAccount(id); if (account.serverInfo.migration.movedTo is not Uri upgradeUri) { diff --git a/Core/Tests/Speckle.Core.Tests.Unit/Credentials/Accounts.cs b/Core/Tests/Speckle.Core.Tests.Unit/Credentials/Accounts.cs index ba0b1aec09..7c86a66f65 100644 --- a/Core/Tests/Speckle.Core.Tests.Unit/Credentials/Accounts.cs +++ b/Core/Tests/Speckle.Core.Tests.Unit/Credentials/Accounts.cs @@ -62,6 +62,20 @@ public void GetAllAccounts() Assert.That(accs, Has.Count.GreaterThanOrEqualTo(3)); // Tests are adding three accounts, you might have extra accounts on your machine when testing :D } + [Test] + public void GetAccount_ById() + { + var result = AccountManager.GetAccount(s_testAccount1.id); + + Assert.That(result, Is.EqualTo(s_testAccount1)); + } + + [Test] + public void GetAccount_ById_ThrowsWhenNotFound() + { + Assert.Throws(() => AccountManager.GetAccount("Non_existent_id")); + } + public static IEnumerable TestCases() { SetUp(); diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Send/RootObjectSender.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Send/RootObjectSender.cs index a8aa59639c..b2fd72c1c7 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Send/RootObjectSender.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Send/RootObjectSender.cs @@ -35,10 +35,7 @@ public async Task Send( onOperationProgressed?.Invoke("Uploading...", null); - // POC: FETCHING ACCOUNTS BY ID ONLY IS UNSAFE, we should filter by server first, but the server info is not stored on the ModelCard - Account account = - AccountManager.GetAccounts().FirstOrDefault(acc => acc.id == accountId) - ?? throw new SpeckleAccountManagerException(); + Account account = AccountManager.GetAccount(accountId); ITransport transport = _transportFactory(account, projectId); var sendResult = await SendHelper.Send(commitObject, transport, true, null, ct).ConfigureAwait(false); diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadSendBinding.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadSendBinding.cs index 7498cb1895..1683280e23 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadSendBinding.cs +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadSendBinding.cs @@ -132,9 +132,7 @@ private async Task SendInternal(string modelCardId) } // 2 - Check account exist - Account account = - AccountManager.GetAccounts().FirstOrDefault(acc => acc.id == modelCard.AccountId) - ?? throw new SpeckleAccountManagerException(); + Account account = AccountManager.GetAccount(modelCard.AccountId); // 3 - Get elements to convert List<(DBObject obj, string applicationId)> autocadObjects = diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RootObjectSender.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RootObjectSender.cs index f4c51d7470..fe1560834d 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RootObjectSender.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RootObjectSender.cs @@ -1,5 +1,4 @@ using System; -using System.Linq; using Speckle.Connectors.Utils.Operations; using Speckle.Core.Api; using System.Threading.Tasks; @@ -36,10 +35,7 @@ public async Task Send( onOperationProgressed?.Invoke("Uploading...", null); - // POC: FETCHING ACCOUNTS BY ID ONLY IS UNSAFE, we should filter by server first, but the server info is not stored on the ModelCard - Account account = - AccountManager.GetAccounts().FirstOrDefault(acc => acc.id == accountId) - ?? throw new SpeckleAccountManagerException(); + Account account = AccountManager.GetAccount(accountId); ITransport transport = _transportFactory(account, projectId); var sendResult = await SendHelper.Send(commitObject, transport, true, null, ct).ConfigureAwait(false); diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Send/RootObjectSender.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Send/RootObjectSender.cs index 763871da21..27b847e608 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Send/RootObjectSender.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Send/RootObjectSender.cs @@ -1,5 +1,4 @@ using System; -using System.Linq; using System.Threading; using System.Threading.Tasks; using Speckle.Connectors.Utils.Operations; @@ -37,10 +36,7 @@ public async Task Send( onOperationProgressed?.Invoke("Uploading...", null); - // POC: FETCHING ACCOUNTS BY ID ONLY IS UNSAFE, we should filter by server first, but the server info is not stored on the ModelCard - Account account = - AccountManager.GetAccounts().FirstOrDefault(acc => acc.id == accountId) - ?? throw new SpeckleAccountManagerException(); + Account account = AccountManager.GetAccount(accountId); ITransport transport = _transportFactory(account, projectId); var sendResult = await SendHelper.Send(commitObject, transport, true, null, ct).ConfigureAwait(false); diff --git a/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/ReceiveOperation.cs b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/ReceiveOperation.cs index 4c51c64d77..5f1da05cf8 100644 --- a/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/ReceiveOperation.cs +++ b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/ReceiveOperation.cs @@ -1,12 +1,10 @@ -using System; +using System; using System.Collections.Generic; -using System.Linq; using System.Threading; using System.Threading.Tasks; using Speckle.Connectors.Utils.Builders; using Speckle.Core.Api; using Speckle.Core.Credentials; -using Speckle.Core.Logging; using Speckle.Core.Models; using Speckle.Core.Transports; @@ -32,26 +30,17 @@ public async Task> Execute( ) { // 2 - Check account exist - Account account = - AccountManager.GetAccounts().FirstOrDefault(acc => acc.id == accountId) - ?? throw new SpeckleAccountManagerException(); + Account account = AccountManager.GetAccount(accountId); // 3 - Get commit object from server - Client apiClient = new(account); - ServerTransport transport = new(account, projectId); - Commit? version = - await apiClient.CommitGet(projectId, versionId, cancellationToken).ConfigureAwait(false) - ?? throw new SpeckleException($"Failed to receive commit: {versionId} from server)"); - - Base? commitObject = - await Speckle.Core.Api.Operations - .Receive(version.referencedObject, cancellationToken: cancellationToken, remoteTransport: transport) - .ConfigureAwait(false) - ?? throw new SpeckleException( - $"Failed to receive commit: {version.id} objects from server: {nameof(Operations)} returned null" - ); - - apiClient.Dispose(); + using Client apiClient = new(account); + Commit version = await apiClient.CommitGet(projectId, versionId, cancellationToken).ConfigureAwait(false); + + using ServerTransport transport = new(account, projectId); + Base commitObject = await Speckle.Core.Api.Operations + .Receive(version.referencedObject, transport, cancellationToken: cancellationToken) + .ConfigureAwait(false); + cancellationToken.ThrowIfCancellationRequested(); // 4 - Convert objects From 19587d8d781f82f8c1a98637a00c753b21e29e2d Mon Sep 17 00:00:00 2001 From: Alan Rynne Date: Fri, 19 Apr 2024 13:00:23 +0200 Subject: [PATCH 034/261] CNX-9214 Rhino - Send Geometry Conversions (#3280) * chore: Moved toSpeckle conversions into subfolder * chore: Removed unused unit converter * feat: Separate raw conversions * fix: Namespace cleanup and removed unused methods * feat: Fully reorganised toSpeckle converters * fix: Registration for ToSpeckle was missing attribute and circular dependency setting * revert: Add attributes to receive converters back * feat: Added jira issue codes to all Connector POC comments * fix: Remove unnecessary using * fix: Rename incorrectly named file * feat: Added PointCloud to speckle conversion * fix import on nurbs conversion * feat: Organised top-level converters for RhinoObjects * fix: end base name in Conversion not Converter * fix: Updated from comments by Ian * fix: Removed unused class * fix: XML comments for every raw conversion --- .../Receive/RhinoHostObjectBuilder.cs | 9 +- .../Operations/Send/RootObjectBuilder.cs | 59 -------- .../AutofacRhinoConverterModule.cs | 15 +- .../Geometry/CurveToSpeckleConverter.cs | 96 ------------ .../Geometry/IntervalToSpeckleConverter.cs | 13 -- .../Geometry/PointToSpeckleConverter.cs | 23 --- .../Geometry/PolyCurveToSpeckleConverter.cs | 137 ------------------ .../Geometry/PolylineToSpeckleConverter.cs | 49 ------- .../RhinoConversionContextStack.cs | 2 +- .../RhinoConverterToSpeckle.cs | 54 ------- .../RhinoToSpeckleUnitConverter.cs | 6 +- .../SpeckleToHostGeometryBaseConversion.cs | 4 +- .../Raw/SpeckleArcRawToHostConversion.cs | 2 +- .../Raw/SpeckleIntervalRawToHostConversion.cs | 2 +- .../Raw/SpeckleMeshRawToHostConversion.cs | 4 +- .../Raw/SpecklePlaneRawToHostConversion.cs | 1 - .../Raw/SpecklePolylineRawToHostConversion.cs | 2 +- .../SpeckleArcToHostArcCurveConversion.cs | 1 + .../Raw/ArcCurveToSpeckleConverter.cs | 61 ++++++++ .../Raw}/ArcToSpeckleConverter.cs | 16 +- .../Raw}/BoxToSpeckleConverter.cs | 13 +- .../Raw}/BrepToSpeckleConverter.cs | 17 ++- .../Raw}/CircleToSpeckleConverter.cs | 13 +- .../Raw}/ControlPointToSpeckleConverter.cs | 12 +- .../ToSpeckle/Raw/CurveToSpeckleConverter.cs | 51 +++++++ .../Raw}/EllipseToSpeckleConverter.cs | 16 +- .../Raw/IntervalToSpeckleConverter.cs | 13 ++ .../Raw}/LineToSpeckleConverter.cs | 18 ++- .../Raw}/MeshToSpeckleConverter.cs | 15 +- .../Raw}/NurbsCurveConverter.cs | 23 ++- .../Raw}/NurbsSurfaceToSpeckleConverter.cs | 18 +-- .../Raw}/PlaneToSpeckleConverter.cs | 14 +- .../ToSpeckle/Raw/PointToSpeckleConverter.cs | 25 ++++ .../Raw/PolyCurveToSpeckleConverter.cs | 48 ++++++ .../Raw/PolylineToSpeckleConverter.cs | 68 +++++++++ .../ToSpeckle/Raw/RawPointCloudToSpeckle.cs | 34 +++++ .../Raw}/VectorToSpeckleConverter.cs | 13 +- .../ToSpeckle/RhinoConverterToSpeckle.cs | 29 ++++ .../RhinoBrepObjectToSpeckleConversion.cs | 24 +++ .../RhinoCurveObjectToSpeckleConversion.cs | 15 ++ .../RhinoMeshObjectToSpeckleConversion.cs | 14 ++ .../RhinoObjectToSpeckleConversion.cs | 33 +++++ ...hinoPointCloudObjectToSpeckleConversion.cs | 15 ++ .../RhinoPointObjectToSpeckleConversion.cs | 14 ++ .../RawConversionRegisterer.cs | 6 +- 45 files changed, 583 insertions(+), 534 deletions(-) delete mode 100644 DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Geometry/CurveToSpeckleConverter.cs delete mode 100644 DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Geometry/IntervalToSpeckleConverter.cs delete mode 100644 DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Geometry/PointToSpeckleConverter.cs delete mode 100644 DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Geometry/PolyCurveToSpeckleConverter.cs delete mode 100644 DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Geometry/PolylineToSpeckleConverter.cs delete mode 100644 DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/RhinoConverterToSpeckle.cs rename DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/{ToHost/TopLevel => }/SpeckleToHostGeometryBaseConversion.cs (90%) create mode 100644 DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/ArcCurveToSpeckleConverter.cs rename DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/{Geometry => ToSpeckle/Raw}/ArcToSpeckleConverter.cs (72%) rename DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/{Geometry => ToSpeckle/Raw}/BoxToSpeckleConverter.cs (75%) rename DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/{Geometry => ToSpeckle/Raw}/BrepToSpeckleConverter.cs (92%) rename DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/{Geometry => ToSpeckle/Raw}/CircleToSpeckleConverter.cs (61%) rename DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/{Geometry => ToSpeckle/Raw}/ControlPointToSpeckleConverter.cs (60%) create mode 100644 DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/CurveToSpeckleConverter.cs rename DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/{Geometry => ToSpeckle/Raw}/EllipseToSpeckleConverter.cs (68%) create mode 100644 DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/IntervalToSpeckleConverter.cs rename DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/{Geometry => ToSpeckle/Raw}/LineToSpeckleConverter.cs (59%) rename DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/{Geometry => ToSpeckle/Raw}/MeshToSpeckleConverter.cs (81%) rename DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/{Geometry => ToSpeckle/Raw}/NurbsCurveConverter.cs (74%) rename DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/{Geometry => ToSpeckle/Raw}/NurbsSurfaceToSpeckleConverter.cs (79%) rename DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/{Geometry => ToSpeckle/Raw}/PlaneToSpeckleConverter.cs (70%) create mode 100644 DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/PointToSpeckleConverter.cs create mode 100644 DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/PolyCurveToSpeckleConverter.cs create mode 100644 DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/PolylineToSpeckleConverter.cs create mode 100644 DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/RawPointCloudToSpeckle.cs rename DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/{Geometry => ToSpeckle/Raw}/VectorToSpeckleConverter.cs (54%) create mode 100644 DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/RhinoConverterToSpeckle.cs create mode 100644 DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/RhinoBrepObjectToSpeckleConversion.cs create mode 100644 DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/RhinoCurveObjectToSpeckleConversion.cs create mode 100644 DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/RhinoMeshObjectToSpeckleConversion.cs create mode 100644 DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/RhinoObjectToSpeckleConversion.cs create mode 100644 DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/RhinoPointCloudObjectToSpeckleConversion.cs create mode 100644 DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/RhinoPointObjectToSpeckleConversion.cs diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Receive/RhinoHostObjectBuilder.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Receive/RhinoHostObjectBuilder.cs index a8cabd6eec..75ba981d3a 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Receive/RhinoHostObjectBuilder.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Receive/RhinoHostObjectBuilder.cs @@ -58,12 +58,11 @@ CancellationToken cancellationToken ) { RhinoDoc doc = _contextStack.Current.Document; + var rootLayerIndex = _contextStack.Current.Document.Layers.Find(Guid.Empty, baseLayerName, RhinoMath.UnsetIntIndex); - var rootLayerIndex = doc.Layers.Find(Guid.Empty, baseLayerName, RhinoMath.UnsetIntIndex); - - // Cleans up any previously received objects // POC: We could move this out into a separate service for testing and re-use. - if (rootLayerIndex >= 0) + // Cleans up any previously received objects + if (rootLayerIndex == RhinoMath.UnsetIntIndex) { Layer documentLayer = doc.Layers[rootLayerIndex]; Layer[]? childLayers = documentLayer.GetChildren(); @@ -122,7 +121,6 @@ CancellationToken cancellationToken if (conversionExceptions.Count != 0) { - // POC: Both the message and the handling of this should be engineered taking into account error reporting in DUI becoming better. throw new AggregateException("Some conversions failed. Please check inner exceptions.", conversionExceptions); } @@ -145,6 +143,7 @@ private int GetAndCreateLayerFromPath(List path, string baseLayerName, D previousLayer = currentDocument.Layers.FindIndex(value); continue; } + var cleanNewLayerName = layerName.Replace("{", "").Replace("}", ""); var newLayer = new Layer { Name = cleanNewLayerName, ParentLayerId = previousLayer.Id }; var index = currentDocument.Layers.Add(newLayer); diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Send/RootObjectBuilder.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Send/RootObjectBuilder.cs index 726ed5c1d2..f938bf2063 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Send/RootObjectBuilder.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Send/RootObjectBuilder.cs @@ -171,63 +171,4 @@ Collection rootObjectCollection layerCollectionCache[layer.Index] = previousCollection; return previousCollection; } - - //private static Collection ConvertObjects( - // List rhinoObjects, - // ISpeckleConverterToSpeckle converter, - // Action? onOperationProgressed = null, - // CancellationToken ct = default - //) - //{ - // var rootObjectCollection = new Collection { name = RhinoDoc.ActiveDoc.Name ?? "Unnamed document" }; - // int count = 0; - - // Dictionary layerCollectionCache = new(); - // // TODO: Handle blocks. - // foreach (RhinoObject rhinoObject in rhinoObjects) - // { - // ct.ThrowIfCancellationRequested(); - - // // 1. get object layer - // var layer = RhinoDoc.ActiveDoc.Layers[rhinoObject.Attributes.LayerIndex]; - - // // 2. get or create a nested collection for it - // var collectionHost = GetHostObjectCollection(layerCollectionCache, layer, rootObjectCollection); - // var applicationId = rhinoObject.Id.ToString(); - - // // 3. get from cache or convert: - // // What we actually do here is check if the object has been previously converted AND has not changed. - // // If that's the case, we insert in the host collection just its object reference which has been saved from the prior conversion. - // /*Base converted; - // if ( - // !modelCard.ChangedObjectIds.Contains(applicationId) - // && _convertedObjectReferences.TryGetValue(applicationId + modelCard.ProjectId, out ObjectReference value) - // ) - // { - // converted = value; - // } - // else - // { - // converted = converter.ConvertToSpeckle(rhinoObject); - // converted.applicationId = applicationId; - // }*/ - - // var converted = converter.ConvertToSpeckle(rhinoObject); - // converted.applicationId = applicationId; - - // // 4. add to host - // collectionHost.elements.Add(converted); - // //_basicConnectorBinding.Commands.SetModelProgress( - // // modelCard.ModelCardId, - // // new ModelCardProgress { Status = "Converting", Progress = (double)++count / rhinoObjects.Count } - // //); - // onOperationProgressed?.Invoke("Converting", (double)++count / rhinoObjects.Count); - - // // NOTE: useful for testing ui states, pls keep for now so we can easily uncomment - // // Thread.Sleep(550); - // } - - // // 5. profit - // return rootObjectCollection; - //} } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/AutofacRhinoConverterModule.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/AutofacRhinoConverterModule.cs index e649049fa2..dfba0e2ae4 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/AutofacRhinoConverterModule.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/AutofacRhinoConverterModule.cs @@ -5,6 +5,7 @@ using Rhino; using Speckle.Converters.Common.DependencyInjection; using Speckle.Converters.Rhino7.ToHost; +using Speckle.Converters.Rhino7.ToSpeckle; namespace Speckle.Converters.Rhino7.DependencyInjection; @@ -12,11 +13,6 @@ public class AutofacRhinoConverterModule : Module { protected override void Load(ContainerBuilder builder) { - // POC: below comment maybe incorrect (sorry if I wrote that!) stateless services - // can be injected as Singleton(), only where we have state we wish to wrap in a unit of work - // should be InstancePerLifetimeScope - // most things should be InstancePerLifetimeScope so we get one per operation - // single stack per conversion builder .RegisterType() @@ -31,20 +27,19 @@ protected override void Load(ContainerBuilder builder) builder.RegisterType().As().InstancePerLifetimeScope(); /* - POC: Moved the Injection of converters into the converter module. Not sure if this is 100% right, as this doesn't just register the conversions within this converter, but any conversions found in any Speckle.*.dll file. + POC: CNX-9267 Moved the Injection of converters into the converter module. Not sure if this is 100% right, as this doesn't just register the conversions within this converter, but any conversions found in any Speckle.*.dll file. This will require consolidating across other connectors. */ builder.InjectNamedTypes(); builder .RegisterType>() - .As>(); + .As>() + .InstancePerLifetimeScope(); - // To Host - // POC: Missing Unit converter builder.RegisterType().As().SingleInstance(); /* - POC: Moved the Injection of converters into the converter module. Not sure if this is 100% right, as this doesn't just register the conversions within this converter, but any conversions found in any Speckle.*.dll file. + POC: CNX-9267 Moved the Injection of converters into the converter module. Not sure if this is 100% right, as this doesn't just register the conversions within this converter, but any conversions found in any Speckle.*.dll file. This will require consolidating across other connectors. */ builder.InjectNamedTypes(); diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Geometry/CurveToSpeckleConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Geometry/CurveToSpeckleConverter.cs deleted file mode 100644 index 8cb2cc9171..0000000000 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Geometry/CurveToSpeckleConverter.cs +++ /dev/null @@ -1,96 +0,0 @@ -using Objects; -using Rhino; -using Speckle.Converters.Common; -using Speckle.Converters.Common.Objects; -using Speckle.Core.Models; - -namespace Speckle.Converters.Rhino7.Geometry; - -[NameAndRankValue(nameof(RG.Curve), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class CurveToSpeckleConverter : IHostObjectToSpeckleConversion, IRawConversion -{ - private readonly IRawConversion _polyCurveConverter; - private readonly IRawConversion _circleConverter; - private readonly IRawConversion _arcConverter; - private readonly IRawConversion _ellipseConverter; - private readonly IRawConversion _polylineConverter; - private readonly IRawConversion _nurbsCurveConverter; - private readonly IRawConversion _intervalConverter; - private readonly IConversionContextStack _contextStack; - - public CurveToSpeckleConverter( - IRawConversion polyCurveConverter, - IRawConversion circleConverter, - IRawConversion arcConverter, - IRawConversion ellipseConverter, - IRawConversion polylineConverter, - IRawConversion nurbsCurveConverter, - IRawConversion intervalConverter, - IConversionContextStack contextStack - ) - { - _polyCurveConverter = polyCurveConverter; - _circleConverter = circleConverter; - _arcConverter = arcConverter; - _ellipseConverter = ellipseConverter; - _polylineConverter = polylineConverter; - _nurbsCurveConverter = nurbsCurveConverter; - _intervalConverter = intervalConverter; - _contextStack = contextStack; - } - - public Base Convert(object target) => (Base)RawConvert((RG.Curve)target); // POC: ICurve and Base are not related so we need to cast here. - - public ICurve RawConvert(RG.Curve target) - { - var tolerance = _contextStack.Current.Document.ModelAbsoluteTolerance; - - if (target is RG.PolyCurve polyCurve) - { - return _polyCurveConverter.RawConvert(polyCurve); - } - - if (target.IsCircle(tolerance) && target.IsClosed) - { - if (target.TryGetCircle(out var getObj, tolerance)) - { - var cir = _circleConverter.RawConvert(getObj); - cir.domain = _intervalConverter.RawConvert(target.Domain); - return cir; - } - } - - if (target.IsArc(tolerance)) - { - if (target.TryGetArc(out var getObj, tolerance)) - { - var arc = _arcConverter.RawConvert(getObj); - arc.domain = _intervalConverter.RawConvert(target.Domain); - return arc; - } - } - - if (target.IsEllipse(tolerance) && target.IsClosed) - { - target.TryGetPlane(out RG.Plane pln, tolerance); - if (target.TryGetEllipse(pln, out var getObj, tolerance)) - { - var ellipse = _ellipseConverter.RawConvert(getObj); - ellipse.domain = _intervalConverter.RawConvert(target.Domain); - return ellipse; - } - } - - if (target.IsLinear(tolerance) || target.IsPolyline()) - { - if (target.TryGetPolyline(out var getObj)) - { - var polyline = _polylineConverter.RawConvert(getObj); - polyline.domain = _intervalConverter.RawConvert(target.Domain); - return polyline; - } - } - - return _nurbsCurveConverter.RawConvert(target.ToNurbsCurve()); - } -} diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Geometry/IntervalToSpeckleConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Geometry/IntervalToSpeckleConverter.cs deleted file mode 100644 index 4f32124367..0000000000 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Geometry/IntervalToSpeckleConverter.cs +++ /dev/null @@ -1,13 +0,0 @@ -using Speckle.Converters.Common; -using Speckle.Converters.Common.Objects; -using Speckle.Core.Models; - -namespace Speckle.Converters.Rhino7.Geometry; - -[NameAndRankValue(nameof(RG.Interval), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class IntervalToSpeckleConverter : IHostObjectToSpeckleConversion, IRawConversion -{ - public Base Convert(object target) => RawConvert((RG.Interval)target); - - public SOP.Interval RawConvert(RG.Interval target) => new(target.T0, target.T1); -} diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Geometry/PointToSpeckleConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Geometry/PointToSpeckleConverter.cs deleted file mode 100644 index 3ef512e84b..0000000000 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Geometry/PointToSpeckleConverter.cs +++ /dev/null @@ -1,23 +0,0 @@ -using Rhino; -using Speckle.Converters.Common.Objects; -using Speckle.Converters.Common; -using Speckle.Core.Models; - -namespace Speckle.Converters.Rhino7.Geometry; - -// POC: not sure I like the place of the default rank -[NameAndRankValue(nameof(RG.Point3d), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class PointToSpeckleConverter : IHostObjectToSpeckleConversion, IRawConversion -{ - private readonly IConversionContextStack _contextStack; - - public PointToSpeckleConverter(IConversionContextStack contextStack) - { - _contextStack = contextStack; - } - - public Base Convert(object target) => RawConvert((RG.Point3d)target); - - public SOG.Point RawConvert(RG.Point3d target) => - new(target.X, target.Y, target.Z, _contextStack.Current.SpeckleUnits); -} diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Geometry/PolyCurveToSpeckleConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Geometry/PolyCurveToSpeckleConverter.cs deleted file mode 100644 index bb7f4a7edc..0000000000 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Geometry/PolyCurveToSpeckleConverter.cs +++ /dev/null @@ -1,137 +0,0 @@ -using Objects; -using Rhino; -using Speckle.Converters.Common; -using Speckle.Converters.Common.Objects; -using Speckle.Core.Models; - -namespace Speckle.Converters.Rhino7.Geometry; - -[NameAndRankValue(nameof(RG.PolyCurve), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class PolyCurveToSpeckleConverter : IHostObjectToSpeckleConversion, IRawConversion -{ - public IRawConversion? CurveConverter { get; set; } // This created a circular dependency on the constructor, making it a property allows for the container to resolve it correctly - private readonly IRawConversion _intervalConverter; - private readonly IRawConversion _boxConverter; - private readonly IConversionContextStack _contextStack; - - public PolyCurveToSpeckleConverter( - IRawConversion intervalConverter, - IRawConversion boxConverter, - IConversionContextStack contextStack - ) - { - _intervalConverter = intervalConverter; - _boxConverter = boxConverter; - _contextStack = contextStack; - } - - public Base Convert(object target) => RawConvert((RG.PolyCurve)target); - - public SOG.Polycurve RawConvert(RG.PolyCurve target) - { - var segments = new List(); - CurveSegments(segments, target, true); - - var myPoly = new SOG.Polycurve - { - closed = target.IsClosed, - domain = _intervalConverter.RawConvert(target.Domain), - length = target.GetLength(), - bbox = _boxConverter.RawConvert(new RG.Box(target.GetBoundingBox(true))), - segments = segments.Select(CurveConverter!.RawConvert).ToList(), - units = _contextStack.Current.SpeckleUnits - }; - return myPoly; - } - - // Proper explosion of polycurves: - // (C) The Rutten David https://www.grasshopper3d.com/forum/topics/explode-closed-planar-curve-using-rhinocommon - private bool CurveSegments(List curveList, RG.Curve crv, bool recursive) - { - if (crv == null) - { - return false; - } - - if (crv is RG.PolyCurve polyCurve) - { - if (recursive) - { - polyCurve.RemoveNesting(); - } - - RG.Curve[] segments = polyCurve.Explode(); - - if (segments == null) - { - return false; - } - - if (segments.Length == 0) - { - return false; - } - - if (recursive) - { - foreach (RG.Curve s in segments) - { - CurveSegments(curveList, s, recursive); - } - } - else - { - foreach (RG.Curve s in segments) - { - var dup = (RG.Curve)s.DuplicateShallow(); - curveList.Add(dup); - } - } - - return true; - } - - //Nothing else worked, lets assume it's a nurbs curve and go from there... - var nurbs = crv.ToNurbsCurve(); - if (nurbs == null) - { - return false; - } - - double t0 = nurbs.Domain.Min; - double t1 = nurbs.Domain.Max; - - int ln = curveList.Count; - - do - { - if (!nurbs.GetNextDiscontinuity(RG.Continuity.C1_locus_continuous, t0, t1, out double t)) - { - break; - } - - var trim = new RG.Interval(t0, t); - if (trim.Length < 1e-10) - { - t0 = t; - continue; - } - - var m = nurbs.DuplicateCurve(); - m = m.Trim(trim); - if (m.IsValid) - { - curveList.Add(m); - } - - t0 = t; - } while (true); - - if (curveList.Count == ln) - { - curveList.Add(nurbs); - } - - return true; - } -} diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Geometry/PolylineToSpeckleConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Geometry/PolylineToSpeckleConverter.cs deleted file mode 100644 index bcdba2faa8..0000000000 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Geometry/PolylineToSpeckleConverter.cs +++ /dev/null @@ -1,49 +0,0 @@ -using Rhino; -using Speckle.Converters.Common; -using Speckle.Converters.Common.Objects; -using Speckle.Core.Models; - -namespace Speckle.Converters.Rhino7.Geometry; - -[NameAndRankValue(nameof(RG.Polyline), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class PolylineToSpeckleConverter : IHostObjectToSpeckleConversion, IRawConversion -{ - private readonly IRawConversion _pointConverter; - private readonly IRawConversion _boxConverter; - private readonly IConversionContextStack _contextStack; - - public PolylineToSpeckleConverter( - IRawConversion pointConverter, - IRawConversion boxConverter, - IConversionContextStack contextStack - ) - { - _pointConverter = pointConverter; - _boxConverter = boxConverter; - _contextStack = contextStack; - } - - public Base Convert(object target) => RawConvert((RG.Polyline)target); - - public SOG.Polyline RawConvert(RG.Polyline target) - { - // POC: Original polyline conversion had a domain as input, as well as the side-effect of returning a `Line` if the polyline had 2 points only. - - var box = _boxConverter.RawConvert(new RG.Box(target.BoundingBox)); - var points = target.Select(pt => _pointConverter.RawConvert(pt)).ToList(); - - if (target.IsClosed) - { - points.RemoveAt(points.Count - 1); - } - - return new SOG.Polyline( - points.SelectMany(pt => new[] { pt.x, pt.y, pt.z }).ToList(), - _contextStack.Current.SpeckleUnits - ) - { - bbox = box, - length = target.Length - }; - } -} diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/RhinoConversionContextStack.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/RhinoConversionContextStack.cs index 081332e022..79ac2f77a4 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/RhinoConversionContextStack.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/RhinoConversionContextStack.cs @@ -4,7 +4,7 @@ namespace Speckle.Converters.Rhino7; -// POC: Suppressed naming warning for now, but we should evaluate if we should follow this or disable it. +// POC: CNX-9268 Suppressed naming warning for now, but we should evaluate if we should follow this or disable it. [SuppressMessage( "Naming", "CA1711:Identifiers should not have incorrect suffix", diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/RhinoConverterToSpeckle.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/RhinoConverterToSpeckle.cs deleted file mode 100644 index 16620086ea..0000000000 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/RhinoConverterToSpeckle.cs +++ /dev/null @@ -1,54 +0,0 @@ -using Rhino; -using Rhino.DocObjects; -using Speckle.Autofac.DependencyInjection; -using Speckle.Converters.Common; -using Speckle.Converters.Common.Objects; -using Speckle.Core.Models; - -namespace Speckle.Converters.Rhino7; - -public class RhinoConverterToSpeckle : ISpeckleConverterToSpeckle -{ - private readonly IFactory _toSpeckle; - private readonly IHostToSpeckleUnitConverter _unitConverter; - - public RhinoConverterToSpeckle( - IFactory toSpeckle, - IHostToSpeckleUnitConverter unitConverter - ) - { - _toSpeckle = toSpeckle; - _unitConverter = unitConverter; - } - - public Base Convert(object target) - { - if (target is not RhinoObject rhinoObject) - { - throw new NotSupportedException( - $"Conversion of {target.GetType().Name} to Speckle is not supported. Only objects that inherit from RhinoObject are." - ); - } - - Type type = rhinoObject.Geometry.GetType(); - - try - { - var objectConverter = _toSpeckle.ResolveInstance(type.Name); - - if (objectConverter == null) - { - throw new NotSupportedException($"No conversion found for {target.GetType().Name}"); - } - - var convertedObject = objectConverter.Convert(rhinoObject.Geometry); - - return convertedObject; - } - catch (SpeckleConversionException e) - { - Console.WriteLine(e); - throw; // Just rethrowing for now, Logs may be needed here. - } - } -} diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/RhinoToSpeckleUnitConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/RhinoToSpeckleUnitConverter.cs index 6af3c49551..4f4f9c77e4 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/RhinoToSpeckleUnitConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/RhinoToSpeckleUnitConverter.cs @@ -1,7 +1,6 @@ using Rhino; using Speckle.Converters.Common; using Speckle.Core.Kits; -using Speckle.Core.Logging; // POC: boy do I think this is the wrong place for SpeckleException! namespace Speckle.Converters.Rhino7; @@ -11,7 +10,7 @@ public class RhinoToSpeckleUnitConverter : IHostToSpeckleUnitConverter : ISpeckleObjectToHostConversion where TIn : Base @@ -28,7 +28,7 @@ public object Convert(Base target) var result = _geometryBaseConverter.RawConvert(castedBase); /* - * POC: Looking at a simpler, more performant way of doing unit scaling on `ToNative` + * POC: CNX-9270 Looking at a simpler, more performant way of doing unit scaling on `ToNative` * by fully relying on the transform capabilities of the HostApp, and only transforming top-level stuff. * This may not hold when adding more complex conversions, but it works for now! */ diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpeckleArcRawToHostConversion.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpeckleArcRawToHostConversion.cs index 4728b14ae1..c50618057d 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpeckleArcRawToHostConversion.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpeckleArcRawToHostConversion.cs @@ -26,7 +26,7 @@ public RG.Arc RawConvert(SOG.Arc target) return rhinoArc; } - // POC: Potential code-smell by directly implementing the interface. We should discuss this further but + // POC: CNX-9271 Potential code-smell by directly implementing the interface. We should discuss this further but // since we're using the interfaces instead of the direct type, this may not be an issue. RG.ArcCurve IRawConversion.RawConvert(SOG.Arc target) { diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpeckleIntervalRawToHostConversion.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpeckleIntervalRawToHostConversion.cs index 956602e9e1..60a838f507 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpeckleIntervalRawToHostConversion.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpeckleIntervalRawToHostConversion.cs @@ -6,7 +6,7 @@ public class SpeckleIntervalRawToHostConversion : IRawConversion new( _pointConverter.RawConvert(target.origin), diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpecklePolylineRawToHostConversion.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpecklePolylineRawToHostConversion.cs index c68888780e..48acb8e897 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpecklePolylineRawToHostConversion.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpecklePolylineRawToHostConversion.cs @@ -33,7 +33,7 @@ public RG.Polyline RawConvert(SOG.Polyline target) return poly; } - // POC: Potential code-smell by directly implementing the interface. We should discuss this further but + // POC: CNX-9271 Potential code-smell by directly implementing the interface. We should discuss this further but // since we're using the interfaces instead of the direct type, this may not be an issue. RG.PolylineCurve IRawConversion.RawConvert(SOG.Polyline target) { diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/SpeckleArcToHostArcCurveConversion.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/SpeckleArcToHostArcCurveConversion.cs index a937919143..75aff43838 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/SpeckleArcToHostArcCurveConversion.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/SpeckleArcToHostArcCurveConversion.cs @@ -4,6 +4,7 @@ namespace Speckle.Converters.Rhino7.ToHost.TopLevel; +[NameAndRankValue(nameof(SOG.Arc), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] public class SpeckleArcToHostArcCurveConversion : SpeckleToHostGeometryBaseConversion { public SpeckleArcToHostArcCurveConversion( diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/ArcCurveToSpeckleConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/ArcCurveToSpeckleConverter.cs new file mode 100644 index 0000000000..d40330cba6 --- /dev/null +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/ArcCurveToSpeckleConverter.cs @@ -0,0 +1,61 @@ +using Objects; +using Rhino; +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; +using Speckle.Core.Models; + +namespace Speckle.Converters.Rhino7.ToSpeckle.Raw; + +public class ArcCurveToSpeckleConverter : IRawConversion, IRawConversion +{ + private readonly IRawConversion _circleConverter; + private readonly IRawConversion _arcConverter; + private readonly IRawConversion _intervalConverter; + private readonly IConversionContextStack _contextStack; + + public ArcCurveToSpeckleConverter( + IRawConversion circleConverter, + IRawConversion arcConverter, + IRawConversion intervalConverter, + IConversionContextStack contextStack + ) + { + _circleConverter = circleConverter; + _arcConverter = arcConverter; + _intervalConverter = intervalConverter; + _contextStack = contextStack; + } + + /// + /// Converts an RG.ArcCurve to an ICurve. + /// + /// The RG.ArcCurve to convert. + /// The converted ICurve. + /// + /// ⚠️ If the provided ArcCurve is a complete circle, a Speckle Circle will be returned. + /// Otherwise, the output will be a Speckle Arc.
+ /// ✅ This method preserves the domain of the original ArcCurve.
+ ///
+ public ICurve RawConvert(RG.ArcCurve target) + { + var tolerance = _contextStack.Current.Document.ModelAbsoluteTolerance; + + if (target.IsCompleteCircle) + { + target.TryGetCircle(out var getObj, tolerance); + var cir = _circleConverter.RawConvert(getObj); + cir.domain = _intervalConverter.RawConvert(target.Domain); + return cir; + } + + var arc = _arcConverter.RawConvert(target.Arc); + arc.domain = _intervalConverter.RawConvert(target.Domain); + return arc; + } + + // POC: CNX-9275 Need to implement this because ICurve and Base are not related, this one is needed at the top-level, the other is for better typed experience. + // This also causes us to have to force cast ICurve to Base as a result, which is expected to always succeed but not nice. + /// + /// The converted ICurve with a cast to object + Base IRawConversion.RawConvert(RG.ArcCurve target) => (Base)RawConvert(target); +} diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Geometry/ArcToSpeckleConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/ArcToSpeckleConverter.cs similarity index 72% rename from DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Geometry/ArcToSpeckleConverter.cs rename to DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/ArcToSpeckleConverter.cs index d1da861e90..b96049f613 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Geometry/ArcToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/ArcToSpeckleConverter.cs @@ -1,12 +1,10 @@ using Rhino; using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; -using Speckle.Core.Models; -namespace Speckle.Converters.Rhino7.Geometry; +namespace Speckle.Converters.Rhino7.ToSpeckle.Raw; -[NameAndRankValue(nameof(RG.Arc), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class ArcToSpeckleConverter : IHostObjectToSpeckleConversion, IRawConversion +public class ArcToSpeckleConverter : IRawConversion { private readonly IRawConversion _pointConverter; private readonly IRawConversion _planeConverter; @@ -26,8 +24,14 @@ IConversionContextStack contextStack _contextStack = contextStack; } - public Base Convert(object target) => RawConvert((RG.Arc)target); - + /// + /// Converts a Rhino Arc object to a Speckle Arc object. + /// + /// The Rhino Arc object to convert. + /// The converted Speckle Arc object. + /// + /// This method assumes the domain of the arc is (0,1) as Arc types in Rhino do not have domain. You may want to request a conversion from ArcCurve instead. + /// public SOG.Arc RawConvert(RG.Arc target) => new( _planeConverter.RawConvert(target.Plane), diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Geometry/BoxToSpeckleConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/BoxToSpeckleConverter.cs similarity index 75% rename from DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Geometry/BoxToSpeckleConverter.cs rename to DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/BoxToSpeckleConverter.cs index d3bc116f10..6c1526f83d 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Geometry/BoxToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/BoxToSpeckleConverter.cs @@ -1,12 +1,10 @@ using Rhino; using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; -using Speckle.Core.Models; -namespace Speckle.Converters.Rhino7.Geometry; +namespace Speckle.Converters.Rhino7.ToSpeckle.Raw; -[NameAndRankValue(nameof(RG.Box), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class BoxToSpeckleConverter : IHostObjectToSpeckleConversion, IRawConversion +public class BoxToSpeckleConverter : IRawConversion { private readonly IRawConversion _planeConverter; private readonly IRawConversion _intervalConverter; @@ -23,8 +21,11 @@ IConversionContextStack contextStack _contextStack = contextStack; } - public Base Convert(object target) => RawConvert((RG.Box)target); - + /// + /// Converts a Rhino Box object to a Speckle Box object. + /// + /// The Rhino Box object to convert. + /// The converted Speckle Box object. public SOG.Box RawConvert(RG.Box target) => new( _planeConverter.RawConvert(target.Plane), diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Geometry/BrepToSpeckleConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/BrepToSpeckleConverter.cs similarity index 92% rename from DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Geometry/BrepToSpeckleConverter.cs rename to DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/BrepToSpeckleConverter.cs index 56fd0e5b46..0c0c84fd83 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Geometry/BrepToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/BrepToSpeckleConverter.cs @@ -4,12 +4,10 @@ using Speckle.Converters.Common.Objects; using Speckle.Core.Kits; using Speckle.Core.Logging; -using Speckle.Core.Models; -namespace Speckle.Converters.Rhino7.Geometry; +namespace Speckle.Converters.Rhino7.ToSpeckle.Raw; -[NameAndRankValue(nameof(RG.Brep), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class BrepToSpeckleConverter : IHostObjectToSpeckleConversion, IRawConversion +public class BrepToSpeckleConverter : IRawConversion { private readonly IRawConversion _pointConverter; private readonly IRawConversion _curveConverter; @@ -38,14 +36,17 @@ IConversionContextStack contextStack _contextStack = contextStack; } - public Base Convert(object target) => RawConvert((RG.Brep)target); - + /// + /// Converts a Brep object to a Speckle Brep object. + /// + /// The Brep object to convert. + /// The converted Speckle Brep object. public SOG.Brep RawConvert(RG.Brep target) { var tol = _contextStack.Current.Document.ModelAbsoluteTolerance; target.Repair(tol); - // POC: This should come as part of the user settings in the context object. + // POC: CNX-9276 This should come as part of the user settings in the context object. // if (PreprocessGeometry) // { // brep = BrepEncoder.ToRawBrep(brep, 1.0, Doc.ModelAngleToleranceRadians, Doc.ModelRelativeTolerance); @@ -59,7 +60,7 @@ public SOG.Brep RawConvert(RG.Brep target) displayValue.Add(_meshConverter.RawConvert(displayMesh)); } - // POC: Swap input material for something coming from the context. + // POC: CNX-9277 Swap input material for something coming from the context. // if (displayValue != null && mat != null) // { // displayValue["renderMaterial"] = mat; diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Geometry/CircleToSpeckleConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/CircleToSpeckleConverter.cs similarity index 61% rename from DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Geometry/CircleToSpeckleConverter.cs rename to DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/CircleToSpeckleConverter.cs index 8481810404..efb03701b5 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Geometry/CircleToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/CircleToSpeckleConverter.cs @@ -3,10 +3,9 @@ using Speckle.Converters.Common.Objects; using Speckle.Core.Models; -namespace Speckle.Converters.Rhino7.Geometry; +namespace Speckle.Converters.Rhino7.ToSpeckle.Raw; -[NameAndRankValue(nameof(RG.Circle), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class CircleToSpeckleConverter : IHostObjectToSpeckleConversion, IRawConversion +public class CircleToSpeckleConverter : IRawConversion { private readonly IRawConversion _planeConverter; private readonly IConversionContextStack _contextStack; @@ -22,6 +21,14 @@ IConversionContextStack contextStack public Base Convert(object target) => RawConvert((RG.Circle)target); + /// + /// Converts a RG.Circle object to a SOG.Circle object. + /// + /// The RG.Circle object to convert. + /// The converted SOG.Circle object. + /// + /// ⚠️ This conversion assumes the domain of a circle is (0,1) as Rhino Circle types do not have a domain. If you want to preserve the domain use ArcCurve conversion instead. + /// public SOG.Circle RawConvert(RG.Circle target) => new(_planeConverter.RawConvert(target.Plane), target.Radius, _contextStack.Current.SpeckleUnits) { diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Geometry/ControlPointToSpeckleConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/ControlPointToSpeckleConverter.cs similarity index 60% rename from DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Geometry/ControlPointToSpeckleConverter.cs rename to DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/ControlPointToSpeckleConverter.cs index 98d83e32ea..f06ea34ed7 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Geometry/ControlPointToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/ControlPointToSpeckleConverter.cs @@ -3,12 +3,9 @@ using Speckle.Converters.Common.Objects; using Speckle.Core.Models; -namespace Speckle.Converters.Rhino7.Geometry; +namespace Speckle.Converters.Rhino7.ToSpeckle.Raw; -[NameAndRankValue(nameof(RG.ControlPoint), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class ControlPointToSpeckleConverter - : IHostObjectToSpeckleConversion, - IRawConversion +public class ControlPointToSpeckleConverter : IRawConversion { private readonly IConversionContextStack _contextStack; @@ -17,6 +14,11 @@ public ControlPointToSpeckleConverter(IConversionContextStack + /// Converts a ControlPoint object to a Speckle ControlPoint object. + /// + /// The ControlPoint object to convert. + /// The converted Speckle ControlPoint object. public SOG.ControlPoint RawConvert(RG.ControlPoint target) => new(target.Location.X, target.Location.Y, target.Location.Z, target.Weight, _contextStack.Current.SpeckleUnits); diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/CurveToSpeckleConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/CurveToSpeckleConverter.cs new file mode 100644 index 0000000000..c842b0d31a --- /dev/null +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/CurveToSpeckleConverter.cs @@ -0,0 +1,51 @@ +using Objects; +using Speckle.Converters.Common.Objects; +using Speckle.Core.Models; + +namespace Speckle.Converters.Rhino7.ToSpeckle.Raw; + +// POC: CNX-9278 This converter decides which specific curve conversion to use. IIndex may be a better choice. +public class CurveToSpeckleConverter : IRawConversion, IRawConversion +{ + private readonly IRawConversion _polyCurveConverter; + private readonly IRawConversion _arcCurveConverter; + private readonly IRawConversion _polylineConverter; + private readonly IRawConversion _nurbsCurveConverter; + private readonly IRawConversion _lineCurveConverter; + + public CurveToSpeckleConverter( + IRawConversion polyCurveConverter, + IRawConversion arcCurveConverter, + IRawConversion polylineConverter, + IRawConversion nurbsCurveConverter, + IRawConversion lineCurveConverter + ) + { + _polyCurveConverter = polyCurveConverter; + _arcCurveConverter = arcCurveConverter; + _polylineConverter = polylineConverter; + _nurbsCurveConverter = nurbsCurveConverter; + _lineCurveConverter = lineCurveConverter; + } + + /// + /// Converts a Rhino curve to a Speckle ICurve. + /// + /// The Rhino curve to convert. + /// The Speckle curve. + /// + /// This is the main converter when the type of curve you input or output does not matter to the caller.
+ /// ⚠️ If an unsupported type of Curve is input, it will be converted to NURBS. + ///
+ public ICurve RawConvert(RG.Curve target) => + target switch + { + RG.PolyCurve polyCurve => _polyCurveConverter.RawConvert(polyCurve), + RG.ArcCurve arcCurve => _arcCurveConverter.RawConvert(arcCurve), + RG.PolylineCurve polylineCurve => _polylineConverter.RawConvert(polylineCurve), + RG.LineCurve lineCurve => _lineCurveConverter.RawConvert(lineCurve), + _ => _nurbsCurveConverter.RawConvert(target.ToNurbsCurve()) + }; + + Base IRawConversion.RawConvert(RG.Curve target) => (Base)RawConvert(target); +} diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Geometry/EllipseToSpeckleConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/EllipseToSpeckleConverter.cs similarity index 68% rename from DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Geometry/EllipseToSpeckleConverter.cs rename to DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/EllipseToSpeckleConverter.cs index 33fb1d7243..d0d0d6b467 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Geometry/EllipseToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/EllipseToSpeckleConverter.cs @@ -1,12 +1,10 @@ using Rhino; using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; -using Speckle.Core.Models; -namespace Speckle.Converters.Rhino7.Geometry; +namespace Speckle.Converters.Rhino7.ToSpeckle.Raw; -[NameAndRankValue(nameof(RG.Ellipse), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class EllipseToSpeckleConverter : IHostObjectToSpeckleConversion, IRawConversion +public class EllipseToSpeckleConverter : IRawConversion { private readonly IRawConversion _planeConverter; private readonly IRawConversion _boxConverter; @@ -23,8 +21,14 @@ IConversionContextStack contextStack _contextStack = contextStack; } - public Base Convert(object target) => RawConvert((RG.Ellipse)target); - + /// + /// Converts a Rhino Ellipse to a Speckle Ellipse. + /// + /// The Rhino Ellipse to convert. + /// The converted Speckle Ellipse. + /// + /// ⚠️ Rhino ellipses are not curves. The result is a mathematical representation of an ellipse that can be converted into NURBS for display. + /// public SOG.Ellipse RawConvert(RG.Ellipse target) { var nurbsCurve = target.ToNurbsCurve(); diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/IntervalToSpeckleConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/IntervalToSpeckleConverter.cs new file mode 100644 index 0000000000..8bda6f9f1e --- /dev/null +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/IntervalToSpeckleConverter.cs @@ -0,0 +1,13 @@ +using Speckle.Converters.Common.Objects; + +namespace Speckle.Converters.Rhino7.ToSpeckle.Raw; + +public class IntervalToSpeckleConverter : IRawConversion +{ + /// + /// Converts a Rhino Interval object to a Speckle Interval object. + /// + /// The Rhino Interval object to be converted. + /// The converted Speckle Interval object. + public SOP.Interval RawConvert(RG.Interval target) => new(target.T0, target.T1); +} diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Geometry/LineToSpeckleConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/LineToSpeckleConverter.cs similarity index 59% rename from DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Geometry/LineToSpeckleConverter.cs rename to DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/LineToSpeckleConverter.cs index bb412df60c..54daf38549 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Geometry/LineToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/LineToSpeckleConverter.cs @@ -1,12 +1,10 @@ using Rhino; using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; -using Speckle.Core.Models; -namespace Speckle.Converters.Rhino7.Geometry; +namespace Speckle.Converters.Rhino7.ToSpeckle.Raw; -[NameAndRankValue(nameof(RG.Line), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class LineToSpeckleConverter : IHostObjectToSpeckleConversion, IRawConversion +public class LineToSpeckleConverter : IRawConversion, IRawConversion { private readonly IRawConversion _pointConverter; private readonly IRawConversion _boxConverter; @@ -23,8 +21,14 @@ IConversionContextStack contextStack _contextStack = contextStack; } - public Base Convert(object target) => RawConvert((RG.Line)target); - + /// + /// Converts a Rhino Line object to a Speckle Line object. + /// + /// The Rhino Line object to convert. + /// The converted Speckle Line object. + /// + /// ⚠️ This conversion assumes the domain of a line is (0, LENGTH), as Rhino Lines do not have domain. If you want the domain preserved use LineCurve conversions instead. + /// public SOG.Line RawConvert(RG.Line target) => new( _pointConverter.RawConvert(target.From), @@ -36,4 +40,6 @@ public SOG.Line RawConvert(RG.Line target) => domain = new SOP.Interval(0, target.Length), bbox = _boxConverter.RawConvert(new RG.Box(target.BoundingBox)) }; + + public SOG.Line RawConvert(RG.LineCurve target) => RawConvert(target.Line); } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Geometry/MeshToSpeckleConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/MeshToSpeckleConverter.cs similarity index 81% rename from DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Geometry/MeshToSpeckleConverter.cs rename to DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/MeshToSpeckleConverter.cs index 9056c86f62..5d116a78c4 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Geometry/MeshToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/MeshToSpeckleConverter.cs @@ -1,12 +1,11 @@ using Rhino; using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; -using Speckle.Core.Models; -namespace Speckle.Converters.Rhino7.Geometry; +namespace Speckle.Converters.Rhino7.ToSpeckle.Raw; [NameAndRankValue(nameof(RG.Mesh), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class MeshToSpeckleConverter : IHostObjectToSpeckleConversion, IRawConversion +public class MeshToSpeckleConverter : IRawConversion { private readonly IRawConversion _pointConverter; private readonly IRawConversion _boxConverter; @@ -23,8 +22,12 @@ IConversionContextStack contextStack _contextStack = contextStack; } - public Base Convert(object target) => RawConvert((RG.Mesh)target); - + /// + /// Converts a Rhino Mesh to a Speckle Mesh. + /// + /// The Rhino Mesh to be converted. + /// The converted Speckle Mesh. + /// Thrown when the Rhino Mesh has 0 vertices or faces. public SOG.Mesh RawConvert(RG.Mesh target) { if (target.Vertices.Count == 0 || target.Faces.Count == 0) @@ -52,7 +55,7 @@ public SOG.Mesh RawConvert(RG.Mesh target) var colors = target.VertexColors.Select(cl => cl.ToArgb()).ToList(); var volume = target.IsClosed ? target.Volume() : 0; - var bbox = _boxConverter.RawConvert(new RG.Box(target.GetBoundingBox(true))); // POC: Why do we use accurate BBox? it's slower. + var bbox = _boxConverter.RawConvert(new RG.Box(target.GetBoundingBox(false))); return new SOG.Mesh(vertexCoordinates, faces, colors, textureCoordinates, _contextStack.Current.SpeckleUnits) { diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Geometry/NurbsCurveConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/NurbsCurveConverter.cs similarity index 74% rename from DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Geometry/NurbsCurveConverter.cs rename to DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/NurbsCurveConverter.cs index 34c7af2b37..b720ca6100 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Geometry/NurbsCurveConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/NurbsCurveConverter.cs @@ -1,12 +1,10 @@ using Rhino; using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; -using Speckle.Core.Models; -namespace Speckle.Converters.Rhino7.Geometry; +namespace Speckle.Converters.Rhino7.ToSpeckle.Raw; -[NameAndRankValue(nameof(RG.NurbsCurve), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class NurbsCurveConverter : IHostObjectToSpeckleConversion, IRawConversion +public class NurbsCurveConverter : IRawConversion { private readonly IRawConversion _polylineConverter; private readonly IRawConversion _intervalConverter; @@ -26,11 +24,24 @@ IConversionContextStack contextStack _contextStack = contextStack; } - public Base Convert(object target) => RawConvert((RG.NurbsCurve)target); - + /// + /// Converts a NurbsCurve object to a Speckle Curve object. + /// + /// The NurbsCurve object to convert. + /// The converted Speckle Curve object. + /// + /// ⚠️ This conversion does not respect Rhino knot vector structure. + /// It adds 1 extra knot at the start and end of the vector by repeating the first and last value. + /// This is because Rhino's standard of (controlPoints + degree + 1) wasn't followed on other software. + /// public SOG.Curve RawConvert(RG.NurbsCurve target) { target.ToPolyline(0, 1, 0, 0, 0, 0.1, 0, 0, true).TryGetPolyline(out var poly); + if (target.IsClosed) + { + poly.Add(poly[0]); + } + SOG.Polyline displayValue = _polylineConverter.RawConvert(poly); var nurbsCurve = target.ToNurbsCurve(); diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Geometry/NurbsSurfaceToSpeckleConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/NurbsSurfaceToSpeckleConverter.cs similarity index 79% rename from DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Geometry/NurbsSurfaceToSpeckleConverter.cs rename to DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/NurbsSurfaceToSpeckleConverter.cs index 6d13308f96..d9dd19b64d 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Geometry/NurbsSurfaceToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/NurbsSurfaceToSpeckleConverter.cs @@ -1,14 +1,11 @@ using Rhino; +using Rhino.Geometry.Collections; using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; -using Speckle.Core.Models; -namespace Speckle.Converters.Rhino7.Geometry; +namespace Speckle.Converters.Rhino7.ToSpeckle.Raw; -[NameAndRankValue(nameof(RG.NurbsSurface), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class NurbsSurfaceToSpeckleConverter - : IHostObjectToSpeckleConversion, - IRawConversion +public class NurbsSurfaceToSpeckleConverter : IRawConversion { private readonly IRawConversion _boxConverter; private readonly IRawConversion _intervalConverter; @@ -28,8 +25,11 @@ IConversionContextStack contextStack _contextStack = contextStack; } - public Base Convert(object target) => RawConvert((RG.NurbsSurface)target); - + /// + /// Converts a NurbsSurface object to a Surface object. + /// + /// The NurbsSurface object to convert. + /// A Surface object representing the converted NurbsSurface. public SOG.Surface RawConvert(RG.NurbsSurface target) { var result = new SOG.Surface @@ -52,7 +52,7 @@ public SOG.Surface RawConvert(RG.NurbsSurface target) return result; } - public List> ControlPointsToSpeckle(RG.Collections.NurbsSurfacePointList controlPoints) + private List> ControlPointsToSpeckle(NurbsSurfacePointList controlPoints) { var points = new List>(); for (var i = 0; i < controlPoints.CountU; i++) diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Geometry/PlaneToSpeckleConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/PlaneToSpeckleConverter.cs similarity index 70% rename from DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Geometry/PlaneToSpeckleConverter.cs rename to DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/PlaneToSpeckleConverter.cs index 92f40b38f9..f9f973c5cb 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Geometry/PlaneToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/PlaneToSpeckleConverter.cs @@ -1,13 +1,10 @@ using Rhino; using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; -using Speckle.Core.Models; -namespace Speckle.Converters.Rhino7.Geometry; +namespace Speckle.Converters.Rhino7.ToSpeckle.Raw; -// POC: not sure I like the place of the default rank -[NameAndRankValue(nameof(Rhino.Geometry.Plane), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class PlaneToSpeckleConverter : IHostObjectToSpeckleConversion, IRawConversion +public class PlaneToSpeckleConverter : IRawConversion { private readonly IRawConversion _vectorConverter; private readonly IRawConversion _pointConverter; @@ -24,8 +21,11 @@ IConversionContextStack contextStack _contextStack = contextStack; } - public Base Convert(object target) => RawConvert((RG.Plane)target); - + /// + /// Converts an instance of Rhino Plane to Speckle Plane. + /// + /// The instance of Rhino Plane to convert. + /// The converted instance of Speckle Plane. public SOG.Plane RawConvert(RG.Plane target) => new( _pointConverter.RawConvert(target.Origin), diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/PointToSpeckleConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/PointToSpeckleConverter.cs new file mode 100644 index 0000000000..54c08d6ea5 --- /dev/null +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/PointToSpeckleConverter.cs @@ -0,0 +1,25 @@ +using Rhino; +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; + +namespace Speckle.Converters.Rhino7.ToSpeckle.Raw; + +public class PointToSpeckleConverter : IRawConversion, IRawConversion +{ + private readonly IConversionContextStack _contextStack; + + public PointToSpeckleConverter(IConversionContextStack contextStack) + { + _contextStack = contextStack; + } + + /// + /// Converts a Rhino 3D point to a Speckle point. + /// + /// The Rhino 3D point to convert. + /// The converted Speckle point. + public SOG.Point RawConvert(RG.Point3d target) => + new(target.X, target.Y, target.Z, _contextStack.Current.SpeckleUnits); + + public SOG.Point RawConvert(RG.Point target) => RawConvert(target.Location); +} diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/PolyCurveToSpeckleConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/PolyCurveToSpeckleConverter.cs new file mode 100644 index 0000000000..b576f3065d --- /dev/null +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/PolyCurveToSpeckleConverter.cs @@ -0,0 +1,48 @@ +using Objects; +using Rhino; +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; + +namespace Speckle.Converters.Rhino7.ToSpeckle.Raw; + +public class PolyCurveToSpeckleConverter : IRawConversion +{ + public IRawConversion? CurveConverter { get; set; } // POC: CNX-9279 This created a circular dependency on the constructor, making it a property allows for the container to resolve it correctly + private readonly IRawConversion _intervalConverter; + private readonly IRawConversion _boxConverter; + private readonly IConversionContextStack _contextStack; + + public PolyCurveToSpeckleConverter( + IRawConversion intervalConverter, + IRawConversion boxConverter, + IConversionContextStack contextStack + ) + { + _intervalConverter = intervalConverter; + _boxConverter = boxConverter; + _contextStack = contextStack; + } + + /// + /// Converts a Rhino PolyCurve to a Speckle Polycurve. + /// + /// The Rhino PolyCurve to convert. + /// The converted Speckle Polycurve. + /// + /// This method removes the nesting of the PolyCurve by duplicating the segments at a granular level. + /// All PolyLIne, PolyCurve and NURBS curves with G1 discontinuities will be broken down. + /// + public SOG.Polycurve RawConvert(RG.PolyCurve target) + { + var myPoly = new SOG.Polycurve + { + closed = target.IsClosed, + domain = _intervalConverter.RawConvert(target.Domain), + length = target.GetLength(), + bbox = _boxConverter.RawConvert(new RG.Box(target.GetBoundingBox(true))), + segments = target.DuplicateSegments().Select(CurveConverter!.RawConvert).ToList(), + units = _contextStack.Current.SpeckleUnits + }; + return myPoly; + } +} diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/PolylineToSpeckleConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/PolylineToSpeckleConverter.cs new file mode 100644 index 0000000000..ff890db496 --- /dev/null +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/PolylineToSpeckleConverter.cs @@ -0,0 +1,68 @@ +using Rhino; +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; + +namespace Speckle.Converters.Rhino7.ToSpeckle.Raw; + +public class PolylineToSpeckleConverter + : IRawConversion, + IRawConversion +{ + private readonly IRawConversion _pointConverter; + private readonly IRawConversion _boxConverter; + private readonly IRawConversion _intervalConverter; + private readonly IConversionContextStack _contextStack; + + public PolylineToSpeckleConverter( + IRawConversion pointConverter, + IRawConversion boxConverter, + IConversionContextStack contextStack, + IRawConversion intervalConverter + ) + { + _pointConverter = pointConverter; + _boxConverter = boxConverter; + _contextStack = contextStack; + _intervalConverter = intervalConverter; + } + + /// + /// Converts the given Rhino polyline to a Speckle polyline. + /// + /// The Rhino polyline to be converted. + /// The converted Speckle polyline. + /// ⚠️ This conversion assumes domain interval is (0,LENGTH) as Rhino Polylines have no domain. If needed, you may want to use PolylineCurve conversion instead. + public SOG.Polyline RawConvert(RG.Polyline target) + { + var box = _boxConverter.RawConvert(new RG.Box(target.BoundingBox)); + var points = target.Select(pt => _pointConverter.RawConvert(pt)).ToList(); + + if (target.IsClosed) + { + points.RemoveAt(points.Count - 1); + } + + return new SOG.Polyline( + points.SelectMany(pt => new[] { pt.x, pt.y, pt.z }).ToList(), + _contextStack.Current.SpeckleUnits + ) + { + bbox = box, + length = target.Length, + domain = new(0, target.Length) + }; + } + + /// + /// Converts the given Rhino PolylineCurve to a Speckle polyline. + /// + /// The Rhino PolylineCurve to be converted. + /// The converted Speckle polyline. + /// ✅ This conversion respects the domain of the original PolylineCurve + public SOG.Polyline RawConvert(RG.PolylineCurve target) + { + var result = RawConvert(target.ToPolyline()); + result.domain = _intervalConverter.RawConvert(target.Domain); + return result; + } +} diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/RawPointCloudToSpeckle.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/RawPointCloudToSpeckle.cs new file mode 100644 index 0000000000..0acf866e3c --- /dev/null +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/RawPointCloudToSpeckle.cs @@ -0,0 +1,34 @@ +using Rhino; +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; + +namespace Speckle.Converters.Rhino7.ToSpeckle.Raw; + +public class RawPointCloudToSpeckle : IRawConversion +{ + private readonly IConversionContextStack _contextStack; + private readonly IRawConversion _boxConverter; + + public RawPointCloudToSpeckle( + IConversionContextStack contextStack, + IRawConversion boxConverter + ) + { + _contextStack = contextStack; + _boxConverter = boxConverter; + } + + /// + /// Converts a Rhino PointCloud object to a Speckle Pointcloud object. + /// + /// The Rhino PointCloud object to convert. + /// The converted Speckle Pointcloud object. + public SOG.Pointcloud RawConvert(RG.PointCloud target) => + new() + { + points = target.GetPoints().SelectMany(pt => new[] { pt.X, pt.Y, pt.Z }).ToList(), + colors = target.GetColors().Select(o => o.ToArgb()).ToList(), + bbox = _boxConverter.RawConvert(new RG.Box(target.GetBoundingBox(true))), + units = _contextStack.Current.SpeckleUnits + }; +} diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Geometry/VectorToSpeckleConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/VectorToSpeckleConverter.cs similarity index 54% rename from DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Geometry/VectorToSpeckleConverter.cs rename to DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/VectorToSpeckleConverter.cs index e675e7f931..6237826d35 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Geometry/VectorToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/VectorToSpeckleConverter.cs @@ -1,12 +1,10 @@ using Rhino; using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; -using Speckle.Core.Models; -namespace Speckle.Converters.Rhino7.Geometry; +namespace Speckle.Converters.Rhino7.ToSpeckle.Raw; -[Common.NameAndRankValue(nameof(RG.Vector3d), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class VectorToSpeckleConverter : IHostObjectToSpeckleConversion, IRawConversion +public class VectorToSpeckleConverter : IRawConversion { private readonly IConversionContextStack _contextStack; @@ -15,8 +13,11 @@ public VectorToSpeckleConverter(IConversionContextStack co _contextStack = contextStack; } - public Base Convert(object target) => RawConvert((RG.Vector3d)target); - + /// + /// Converts a Rhino Vector3d object to a Speckle Vector object. + /// + /// The Rhino Vector3d object to convert. + /// The converted Speckle Vector object. public SOG.Vector RawConvert(RG.Vector3d target) => new(target.X, target.Y, target.Z, _contextStack.Current.SpeckleUnits); } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/RhinoConverterToSpeckle.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/RhinoConverterToSpeckle.cs new file mode 100644 index 0000000000..d581c438e8 --- /dev/null +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/RhinoConverterToSpeckle.cs @@ -0,0 +1,29 @@ +using Speckle.Autofac.DependencyInjection; +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; +using Speckle.Core.Models; + +namespace Speckle.Converters.Rhino7.ToSpeckle; + +public class RhinoConverterToSpeckle : ISpeckleConverterToSpeckle +{ + private readonly IFactory _toSpeckle; + + public RhinoConverterToSpeckle(IFactory toSpeckle) + { + _toSpeckle = toSpeckle; + } + + public Base Convert(object target) + { + var type = target.GetType(); + var objectConverter = _toSpeckle.ResolveInstance(type.Name); + + if (objectConverter == null) + { + throw new NotSupportedException($"No conversion found for {type.Name}"); + } + + return objectConverter.Convert(target); + } +} diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/RhinoBrepObjectToSpeckleConversion.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/RhinoBrepObjectToSpeckleConversion.cs new file mode 100644 index 0000000000..ee66c10b10 --- /dev/null +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/RhinoBrepObjectToSpeckleConversion.cs @@ -0,0 +1,24 @@ +using Rhino.DocObjects; +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; +using Speckle.Core.Models; + +namespace Speckle.Converters.Rhino7.ToSpeckle.TopLevel; + +[NameAndRankValue(nameof(BrepObject), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +public class RhinoBrepObjectToSpeckleConversion : IHostObjectToSpeckleConversion +{ + private readonly IRawConversion _curveConverter; + + public RhinoBrepObjectToSpeckleConversion(IRawConversion curveConverter) + { + _curveConverter = curveConverter; + } + + public Base Convert(object target) + { + var curveObject = (BrepObject)target; + var speckleCurve = _curveConverter.RawConvert(curveObject.BrepGeometry); + return speckleCurve; + } +} diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/RhinoCurveObjectToSpeckleConversion.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/RhinoCurveObjectToSpeckleConversion.cs new file mode 100644 index 0000000000..626c82c409 --- /dev/null +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/RhinoCurveObjectToSpeckleConversion.cs @@ -0,0 +1,15 @@ +using Rhino.DocObjects; +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; +using Speckle.Core.Models; + +namespace Speckle.Converters.Rhino7.ToSpeckle.TopLevel; + +[NameAndRankValue(nameof(CurveObject), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +public class RhinoCurveObjectToSpeckleConversion : RhinoObjectToSpeckleConversion +{ + public RhinoCurveObjectToSpeckleConversion(IRawConversion conversion) + : base(conversion) { } + + protected override RG.Curve GetTypedGeometry(CurveObject input) => input.CurveGeometry; +} diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/RhinoMeshObjectToSpeckleConversion.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/RhinoMeshObjectToSpeckleConversion.cs new file mode 100644 index 0000000000..2cf0813132 --- /dev/null +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/RhinoMeshObjectToSpeckleConversion.cs @@ -0,0 +1,14 @@ +using Rhino.DocObjects; +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; + +namespace Speckle.Converters.Rhino7.ToSpeckle.TopLevel; + +[NameAndRankValue(nameof(MeshObject), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +public class RhinoMeshObjectToSpeckleConversion : RhinoObjectToSpeckleConversion +{ + public RhinoMeshObjectToSpeckleConversion(IRawConversion conversion) + : base(conversion) { } + + protected override RG.Mesh GetTypedGeometry(MeshObject input) => input.MeshGeometry; +} diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/RhinoObjectToSpeckleConversion.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/RhinoObjectToSpeckleConversion.cs new file mode 100644 index 0000000000..f2e4f0ab8b --- /dev/null +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/RhinoObjectToSpeckleConversion.cs @@ -0,0 +1,33 @@ +using Speckle.Converters.Common.Objects; +using Speckle.Core.Models; + +namespace Speckle.Converters.Rhino7.ToSpeckle.TopLevel; + +public abstract class RhinoObjectToSpeckleConversion : IHostObjectToSpeckleConversion + where TTopLevelIn : Rhino.DocObjects.RhinoObject + where TInRaw : RG.GeometryBase + where TOutRaw : Base +{ + public IRawConversion Conversion { get; } + + protected RhinoObjectToSpeckleConversion(IRawConversion conversion) + { + Conversion = conversion; + } + + // POC: IIndex would fix this as I would just request the type from `RhinoObject.Geometry` directly. + protected abstract TInRaw GetTypedGeometry(TTopLevelIn input); + + public virtual Base Convert(object target) + { + var typedTarget = (TTopLevelIn)target; + var typedGeometry = GetTypedGeometry(typedTarget); + + var result = Conversion.RawConvert(typedGeometry); + + // POC: Any common operations for all RhinoObjects should be done here, not on the specific implementer + // Things like user-dictionaries and other user-defined metadata. + + return result; + } +} diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/RhinoPointCloudObjectToSpeckleConversion.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/RhinoPointCloudObjectToSpeckleConversion.cs new file mode 100644 index 0000000000..1dcf153c3c --- /dev/null +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/RhinoPointCloudObjectToSpeckleConversion.cs @@ -0,0 +1,15 @@ +using Rhino.DocObjects; +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; + +namespace Speckle.Converters.Rhino7.ToSpeckle.TopLevel; + +[NameAndRankValue(nameof(PointCloudObject), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +public class RhinoPointCloudObjectToSpeckleConversion + : RhinoObjectToSpeckleConversion +{ + public RhinoPointCloudObjectToSpeckleConversion(IRawConversion conversion) + : base(conversion) { } + + protected override RG.PointCloud GetTypedGeometry(PointCloudObject input) => input.PointCloudGeometry; +} diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/RhinoPointObjectToSpeckleConversion.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/RhinoPointObjectToSpeckleConversion.cs new file mode 100644 index 0000000000..03678a7dc7 --- /dev/null +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/RhinoPointObjectToSpeckleConversion.cs @@ -0,0 +1,14 @@ +using Rhino.DocObjects; +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; + +namespace Speckle.Converters.Rhino7.ToSpeckle.TopLevel; + +[NameAndRankValue(nameof(PointObject), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +public class RhinoPointObjectToSpeckleConversion : RhinoObjectToSpeckleConversion +{ + public RhinoPointObjectToSpeckleConversion(IRawConversion conversion) + : base(conversion) { } + + protected override RG.Point GetTypedGeometry(PointObject input) => input.PointGeometry; +} diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/RawConversionRegisterer.cs b/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/RawConversionRegisterer.cs index 9b07c65a97..2158eecb66 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/RawConversionRegisterer.cs +++ b/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/RawConversionRegisterer.cs @@ -33,7 +33,11 @@ private static void RegisterRawConversionsForType(ContainerBuilder containerBuil foreach (var conversionInterface in rawConversionInterfaces) { - containerBuilder.RegisterType(type).As(conversionInterface).InstancePerLifetimeScope(); + containerBuilder + .RegisterType(type) + .As(conversionInterface) + .PropertiesAutowired(PropertyWiringOptions.AllowCircularDependencies) + .InstancePerLifetimeScope(); } } } From 191a0973189a6f8a46b782cd4422967a976ab8cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?O=C4=9Fuzhan=20Koral?= <45078678+oguzhankoral@users.noreply.github.com> Date: Fri, 19 Apr 2024 15:41:50 +0300 Subject: [PATCH 035/261] CNX-9217 receive autocad geometry conversions (#3281) * Port and split arc, circle, ellipse, line, mesh, point, polyline * Add curve conversions * Add polycurve as polyline * Add polycurve as spline to host conversion * Add comments to polycurve conversions * Do not flatten native objects if they inherited from IEnumerable * Enable mesh converter and add POC comment * Put ticket link to mesh POC comment * POC comment * Fix build errors and add more comments for errors * Remove unnecessary directive * Fix type check * Make ignoredTypes as enumerable and optional * Simplify FlattenToHostConversionResult function with IList * Remove unused context and add POC comment * Jedds fixes (#3287) * Jedds fixes * ReceiveOperation tweaks * fix warnings * POC: syncing to main thread * Rhino bindings * Fix file path * Remove file on locally exists * Remove POC comment for random crash * Fix various --------- Co-authored-by: Jedd Morgan <45512892+JR-Morgan@users.noreply.github.com> --- All.sln | 19 +++ Core/Core/Models/Utilities.cs | 10 +- Core/Core/Transports/SQLite.cs | 6 +- .../Models/UtilitiesTests.cs | 26 +++- .../Transports/SQLiteTransportTests.cs | 30 +++++ DUI3-DX.slnf | 1 + .../Speckle.Connectors.Autocad2023.csproj | 2 +- .../Bindings/AutocadReceiveBinding.cs | 12 +- .../AutofacAutocadModule.cs | 1 + .../HostApp/AutocadSettings.cs | 2 +- .../Operations/Receive/HostObjectBuilder.cs | 5 +- .../DependencyInjection/AutofacRhinoModule.cs | 1 + .../AutofacAutocadConverterModule.cs | 6 +- ...ers.Autocad2023.DependencyInjection.csproj | 17 +++ .../AutocadConverterToHost.cs | 24 ++-- .../Geometry/PointToHostConverter.cs | 52 -------- ...Speckle.Converters.AutocadShared.projitems | 21 +++- .../ToHost/Geometry/ArcToHostConverter.cs | 41 ++++++ .../ToHost/Geometry/CircleToHostConverter.cs | 43 +++++++ .../ToHost/Geometry/CurveToHostConverter.cs | 20 +++ .../ToHost/Geometry/EllipseToHostConverter.cs | 47 +++++++ .../ToHost/Geometry/LineToHostConverter.cs | 21 ++++ .../ToHost/Geometry/MeshToHostConverter.cs | 117 ++++++++++++++++++ .../ToHost/Geometry/PointToHostConverter.cs | 20 +++ .../Geometry/PolycurveToHostConverter.cs | 95 ++++++++++++++ .../Geometry/PolylineToHostConverter.cs | 25 ++++ .../ToHost/Raw/ArcToHostRawConverter.cs | 42 +++++++ .../ToHost/Raw/CurveToHostRawConverter.cs | 76 ++++++++++++ .../ToHost/Raw/IntervalToHostRawConverter.cs | 19 +++ .../ToHost/Raw/PlaneToHostRawConverter.cs | 24 ++++ .../ToHost/Raw/PointToHostRawConverter.cs | 22 ++++ .../PolycurveToHostPolylineRawConverter.cs | 99 +++++++++++++++ .../Raw/PolycurveToHostSplineRawConverter.cs | 58 +++++++++ .../ToHost/Raw/VectorToHostRawConverter.cs | 24 ++++ .../Bridge/SyncToUIThread.cs | 28 +++++ .../Operations/ISyncToMainThread.cs | 9 ++ .../Operations/ReceiveOperation.cs | 11 +- 37 files changed, 989 insertions(+), 87 deletions(-) rename DUI3-DX/Converters/Autocad/{Speckle.Converters.AutocadShared/DependencyInjection => Speckle.Converters.Autocad2023.DependencyInjection}/AutofacAutocadConverterModule.cs (90%) create mode 100644 DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2023.DependencyInjection/Speckle.Converters.Autocad2023.DependencyInjection.csproj delete mode 100644 DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/Geometry/PointToHostConverter.cs create mode 100644 DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/ArcToHostConverter.cs create mode 100644 DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/CircleToHostConverter.cs create mode 100644 DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/CurveToHostConverter.cs create mode 100644 DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/EllipseToHostConverter.cs create mode 100644 DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/LineToHostConverter.cs create mode 100644 DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/MeshToHostConverter.cs create mode 100644 DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/PointToHostConverter.cs create mode 100644 DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/PolycurveToHostConverter.cs create mode 100644 DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/PolylineToHostConverter.cs create mode 100644 DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/ArcToHostRawConverter.cs create mode 100644 DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/CurveToHostRawConverter.cs create mode 100644 DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/IntervalToHostRawConverter.cs create mode 100644 DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/PlaneToHostRawConverter.cs create mode 100644 DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/PointToHostRawConverter.cs create mode 100644 DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/PolycurveToHostPolylineRawConverter.cs create mode 100644 DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/PolycurveToHostSplineRawConverter.cs create mode 100644 DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/VectorToHostRawConverter.cs create mode 100644 DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/SyncToUIThread.cs create mode 100644 DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/ISyncToMainThread.cs diff --git a/All.sln b/All.sln index 928091bf85..f472ea0ae3 100644 --- a/All.sln +++ b/All.sln @@ -560,6 +560,8 @@ Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Speckle.Converters.AutocadS EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Speckle.Converters.Autocad2023", "DUI3-DX\Converters\Autocad\Speckle.Converters.Autocad2023\Speckle.Converters.Autocad2023.csproj", "{631C295A-7CCF-4B42-8686-7034E31469E7}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Speckle.Converters.Autocad2023.DependencyInjection", "DUI3-DX\Converters\Autocad\Speckle.Converters.Autocad2023.DependencyInjection\Speckle.Converters.Autocad2023.DependencyInjection.csproj", "{D940853C-003A-482C-BDB0-665367F274A0}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug Mac|Any CPU = Debug Mac|Any CPU @@ -2794,6 +2796,22 @@ Global {631C295A-7CCF-4B42-8686-7034E31469E7}.Release|Any CPU.Build.0 = Release|Any CPU {631C295A-7CCF-4B42-8686-7034E31469E7}.Release|x64.ActiveCfg = Release|Any CPU {631C295A-7CCF-4B42-8686-7034E31469E7}.Release|x64.Build.0 = Release|Any CPU + {D940853C-003A-482C-BDB0-665367F274A0}.Debug Mac|Any CPU.ActiveCfg = Debug|Any CPU + {D940853C-003A-482C-BDB0-665367F274A0}.Debug Mac|Any CPU.Build.0 = Debug|Any CPU + {D940853C-003A-482C-BDB0-665367F274A0}.Debug Mac|x64.ActiveCfg = Debug|Any CPU + {D940853C-003A-482C-BDB0-665367F274A0}.Debug Mac|x64.Build.0 = Debug|Any CPU + {D940853C-003A-482C-BDB0-665367F274A0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D940853C-003A-482C-BDB0-665367F274A0}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D940853C-003A-482C-BDB0-665367F274A0}.Debug|x64.ActiveCfg = Debug|Any CPU + {D940853C-003A-482C-BDB0-665367F274A0}.Debug|x64.Build.0 = Debug|Any CPU + {D940853C-003A-482C-BDB0-665367F274A0}.Release Mac|Any CPU.ActiveCfg = Debug|Any CPU + {D940853C-003A-482C-BDB0-665367F274A0}.Release Mac|Any CPU.Build.0 = Debug|Any CPU + {D940853C-003A-482C-BDB0-665367F274A0}.Release Mac|x64.ActiveCfg = Debug|Any CPU + {D940853C-003A-482C-BDB0-665367F274A0}.Release Mac|x64.Build.0 = Debug|Any CPU + {D940853C-003A-482C-BDB0-665367F274A0}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D940853C-003A-482C-BDB0-665367F274A0}.Release|Any CPU.Build.0 = Release|Any CPU + {D940853C-003A-482C-BDB0-665367F274A0}.Release|x64.ActiveCfg = Release|Any CPU + {D940853C-003A-482C-BDB0-665367F274A0}.Release|x64.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -3012,6 +3030,7 @@ Global {804E065F-914C-414A-AF84-009312C3CFF6} = {1FE3C60E-7865-40A5-9794-55ECB64F6489} {9ADD1B7A-6401-4202-8613-F668E2FBC0A4} = {804E065F-914C-414A-AF84-009312C3CFF6} {631C295A-7CCF-4B42-8686-7034E31469E7} = {804E065F-914C-414A-AF84-009312C3CFF6} + {D940853C-003A-482C-BDB0-665367F274A0} = {804E065F-914C-414A-AF84-009312C3CFF6} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {1D43D91B-4F01-4A78-8250-CC6F9BD93A14} diff --git a/Core/Core/Models/Utilities.cs b/Core/Core/Models/Utilities.cs index 461eca7a45..19e478f3bc 100644 --- a/Core/Core/Models/Utilities.cs +++ b/Core/Core/Models/Utilities.cs @@ -217,9 +217,12 @@ public static IEnumerable> SplitList(List list, int chunkSize = 50 /// Utility function to flatten a conversion result that might have nested lists of objects. /// This happens, for example, in the case of multiple display value fallbacks for a given object. /// + /// + /// Assuming native objects are not inherited from IList. + /// /// Object to flatten - /// Flattened objects after to native. - public static List FlattenToNativeConversionResult(object item) + /// Flattened objects after to host. + public static List FlattenToHostConversionResult(object item) { List convertedList = new(); Stack stack = new(); @@ -228,8 +231,7 @@ public static List FlattenToNativeConversionResult(object item) while (stack.Count > 0) { object current = stack.Pop(); - - if (current is IEnumerable list) + if (current is IList list) { foreach (object subItem in list) { diff --git a/Core/Core/Transports/SQLite.cs b/Core/Core/Transports/SQLite.cs index 5b3f4f9b72..06e21b3e9f 100644 --- a/Core/Core/Transports/SQLite.cs +++ b/Core/Core/Transports/SQLite.cs @@ -221,11 +221,15 @@ content TEXT /// Returns all the objects in the store. Note: do not use for large collections. /// /// + /// This function uses a separate so is safe to call concurrently (unlike most other transport functions) internal IEnumerable GetAllObjects() { CancellationToken.ThrowIfCancellationRequested(); - using var command = new SqliteCommand("SELECT * FROM objects", Connection); + using SqliteConnection connection = new(_connectionString); + connection.Open(); + + using var command = new SqliteCommand("SELECT * FROM objects", connection); using var reader = command.ExecuteReader(); while (reader.Read()) diff --git a/Core/Tests/Speckle.Core.Tests.Unit/Models/UtilitiesTests.cs b/Core/Tests/Speckle.Core.Tests.Unit/Models/UtilitiesTests.cs index de34e463c1..ffa5bce998 100644 --- a/Core/Tests/Speckle.Core.Tests.Unit/Models/UtilitiesTests.cs +++ b/Core/Tests/Speckle.Core.Tests.Unit/Models/UtilitiesTests.cs @@ -1,4 +1,5 @@ -using NUnit.Framework; +using System.Collections; +using NUnit.Framework; using Speckle.Core.Helpers; namespace Speckle.Core.Tests.Unit.Models; @@ -43,10 +44,29 @@ public void FlattenToNativeConversion() new() // obj 3 }; - var singleObjectFlattened = Core.Models.Utilities.FlattenToNativeConversionResult(singleObject); - var nestedObjectsFlattened = Core.Models.Utilities.FlattenToNativeConversionResult(nestedObjects); + var testEnum = new List() { new(), new() }.Select(o => o); + var nestedObjectsWithEnumerableInherited = new List() + { + new List() + { + new(), // obj 1 + new(), // obj 2 + testEnum // obj 3 + }, + new() // obj 4 + }; + + var parentTestEnumFlattened = Core.Models.Utilities.FlattenToHostConversionResult(testEnum); + var singleObjectFlattened = Core.Models.Utilities.FlattenToHostConversionResult(singleObject); + var nestedObjectsFlattened = Core.Models.Utilities.FlattenToHostConversionResult(nestedObjects); + var nestedObjectsWithEnumerableInheritedFlattened = Core.Models.Utilities.FlattenToHostConversionResult( + nestedObjectsWithEnumerableInherited + ); + + Assert.That(parentTestEnumFlattened.Count, Is.EqualTo(1)); Assert.That(singleObjectFlattened.Count, Is.EqualTo(1)); Assert.That(nestedObjectsFlattened.Count, Is.EqualTo(3)); + Assert.That(nestedObjectsWithEnumerableInheritedFlattened.Count, Is.EqualTo(4)); } } diff --git a/Core/Tests/Speckle.Core.Tests.Unit/Transports/SQLiteTransportTests.cs b/Core/Tests/Speckle.Core.Tests.Unit/Transports/SQLiteTransportTests.cs index a36135de23..95504f0d03 100644 --- a/Core/Tests/Speckle.Core.Tests.Unit/Transports/SQLiteTransportTests.cs +++ b/Core/Tests/Speckle.Core.Tests.Unit/Transports/SQLiteTransportTests.cs @@ -1,5 +1,6 @@ using Microsoft.Data.Sqlite; using NUnit.Framework; +using NUnit.Framework.Constraints; using Speckle.Core.Transports; namespace Speckle.Core.Tests.Unit.Transports; @@ -128,6 +129,35 @@ public void UpdateObject_WhileEnumerating() Assert.That(_sqlite.GetAllObjects().ToList(), Has.All.Length.EqualTo(length + UPDATE_STRING.Length)); } + [Test] + [Repeat(10)] + [TestCase(6, 32)] + [Description( + $"Tests that the {nameof(SQLiteTransport.GetAllObjects)} function can be called concurrently from multiple threads" + )] + public void GetAllObjects_IsThreadSafe(int dataSize, int parallelism) + { + foreach (int i in Enumerable.Range(0, dataSize)) + { + _sqlite.SaveObjectSync(i.ToString(), Guid.NewGuid().ToString()); + } + + List[] results = new List[parallelism]; + Parallel.ForEach( + Enumerable.Range(0, parallelism), + i => + { + results[i] = _sqlite.GetAllObjects().ToList(); + } + ); + + foreach (var result in results) + { + Assert.That(result, Is.EquivalentTo(results[0])); + Assert.That(result, Has.Count.EqualTo(dataSize)); + } + } + public void Dispose() { _sqlite?.Dispose(); diff --git a/DUI3-DX.slnf b/DUI3-DX.slnf index 58980d735f..e9bbc060d2 100644 --- a/DUI3-DX.slnf +++ b/DUI3-DX.slnf @@ -15,6 +15,7 @@ "DUI3-DX\\Connectors\\Rhino\\Speckle.Connectors.Rhino7\\Speckle.Connectors.Rhino7.csproj", "DUI3-DX\\Converters\\ArcGIS\\Speckle.Converters.ArcGIS3.DependencyInjection\\Speckle.Converters.ArcGIS3.DependencyInjection.csproj", "DUI3-DX\\Converters\\ArcGIS\\Speckle.Converters.ArcGIS3\\Speckle.Converters.ArcGIS3.csproj", + "DUI3-DX\\Converters\\Autocad\\Speckle.Converters.Autocad2023.DependencyInjection\\Speckle.Converters.Autocad2023.DependencyInjection.csproj", "DUI3-DX\\Converters\\Autocad\\Speckle.Converters.Autocad2023\\Speckle.Converters.Autocad2023.csproj", "DUI3-DX\\Converters\\Autocad\\Speckle.Converters.AutocadShared\\Speckle.Converters.AutocadShared.shproj", "DUI3-DX\\Converters\\Revit\\Speckle.Converters.Revit2023.DependencyInjection\\Speckle.Converters.Revit2023.DependencyInjection.csproj", diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.Autocad2023/Speckle.Connectors.Autocad2023.csproj b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.Autocad2023/Speckle.Connectors.Autocad2023.csproj index c95ea8729b..d576d46a1a 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.Autocad2023/Speckle.Connectors.Autocad2023.csproj +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.Autocad2023/Speckle.Connectors.Autocad2023.csproj @@ -9,7 +9,7 @@ $(ProgramW6432)\Autodesk\AutoCAD 2023\acad.exe - + diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadReceiveBinding.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadReceiveBinding.cs index e55b1c9d57..335588929f 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadReceiveBinding.cs +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadReceiveBinding.cs @@ -37,13 +37,7 @@ CancellationManager cancellationManager public void CancelReceive(string modelCardId) => _cancellationManager.CancelOperation(modelCardId); - public Task Receive(string modelCardId) - { - Parent.RunOnMainThread(async () => await ReceiveInternal(modelCardId).ConfigureAwait(false)); - return Task.CompletedTask; - } - - private async Task ReceiveInternal(string modelCardId) + public async Task Receive(string modelCardId) { try { @@ -65,7 +59,7 @@ private async Task ReceiveInternal(string modelCardId) modelCard.ModelName, modelCard.SelectedVersionId, cts.Token, - (status, progress) => OnSendOperationProgress(modelCardId, status, progress) + onOperationProgressed: (status, progress) => OnSendOperationProgress(modelCardId, status, progress) ) .ConfigureAwait(false); @@ -74,6 +68,8 @@ private async Task ReceiveInternal(string modelCardId) catch (OperationCanceledException) { // POC: not sure here need to handle anything. UI already aware it cancelled operation visually. + // POC: JEDD: We should not update the UI until this exception is caught, we don't want to show the UI as cancelled + // until the actual operation is cancelled (thrown exception). return; } catch (Exception e) when (!e.IsFatal()) // All exceptions should be handled here if possible, otherwise we enter "crashing the host app" territory. diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/DependencyInjection/AutofacAutocadModule.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/DependencyInjection/AutofacAutocadModule.cs index 1f502526fb..cf2317ba8b 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/DependencyInjection/AutofacAutocadModule.cs +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/DependencyInjection/AutofacAutocadModule.cs @@ -46,6 +46,7 @@ protected override void Load(ContainerBuilder builder) // Operations builder.RegisterType().AsSelf().SingleInstance(); + builder.RegisterType().As().SingleInstance(); // Object Builders builder.RegisterType().As().InstancePerDependency(); diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/AutocadSettings.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/AutocadSettings.cs index 465b4a0d15..a8dd0266d6 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/AutocadSettings.cs +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/AutocadSettings.cs @@ -9,7 +9,7 @@ public AutocadSettings(HostApplication hostAppInfo, HostAppVersion hostAppVersio { HostAppInfo = hostAppInfo; HostAppVersion = hostAppVersion; - Modules = new[] { new DirectoryInfo(typeof(AutocadSettings).Assembly.ToString()).Parent.FullName }; + Modules = new[] { new DirectoryInfo(typeof(AutocadSettings).Assembly.Location).Parent.FullName }; } public HostApplication HostAppInfo { get; private set; } diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Operations/Receive/HostObjectBuilder.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Operations/Receive/HostObjectBuilder.cs index e72318f7e3..c9cc82d58d 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Operations/Receive/HostObjectBuilder.cs +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Operations/Receive/HostObjectBuilder.cs @@ -1,4 +1,4 @@ -using System.Diagnostics; +using System.Diagnostics; using Autodesk.AutoCAD.DatabaseServices; using Speckle.Autofac.DependencyInjection; using Speckle.Connectors.Autocad.HostApp; @@ -80,12 +80,13 @@ CancellationToken cancellationToken } object converted = converter.Convert(obj); - List flattened = Core.Models.Utilities.FlattenToNativeConversionResult(converted); + List flattened = Utilities.FlattenToHostConversionResult(converted); foreach (Entity conversionResult in flattened.Cast()) { if (conversionResult == null) { + // POC: This needed to be double checked why we check null and continue continue; } diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/AutofacRhinoModule.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/AutofacRhinoModule.cs index 57baeab2c5..827603f580 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/AutofacRhinoModule.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/AutofacRhinoModule.cs @@ -64,6 +64,7 @@ protected override void Load(ContainerBuilder builder) // register send operation and dependencies builder.RegisterType().SingleInstance(); builder.RegisterType().SingleInstance(); + builder.RegisterType().As().SingleInstance(); builder.RegisterType().As().SingleInstance(); diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/DependencyInjection/AutofacAutocadConverterModule.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2023.DependencyInjection/AutofacAutocadConverterModule.cs similarity index 90% rename from DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/DependencyInjection/AutofacAutocadConverterModule.cs rename to DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2023.DependencyInjection/AutofacAutocadConverterModule.cs index 371792b9e2..f06cd57bcb 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/DependencyInjection/AutofacAutocadConverterModule.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2023.DependencyInjection/AutofacAutocadConverterModule.cs @@ -1,10 +1,12 @@ +using Autodesk.AutoCAD.ApplicationServices; +using Autodesk.AutoCAD.DatabaseServices; using Autofac; using Speckle.Autofac.DependencyInjection; +using Speckle.Converters.Autocad; using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; -using Autodesk.AutoCAD.DatabaseServices; -namespace Speckle.Converters.Autocad.DependencyInjection; +namespace Speckle.Converters.Autocad2023.DependencyInjection; public class AutofacAutocadConverterModule : Module { diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2023.DependencyInjection/Speckle.Converters.Autocad2023.DependencyInjection.csproj b/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2023.DependencyInjection/Speckle.Converters.Autocad2023.DependencyInjection.csproj new file mode 100644 index 0000000000..ab0fc41461 --- /dev/null +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2023.DependencyInjection/Speckle.Converters.Autocad2023.DependencyInjection.csproj @@ -0,0 +1,17 @@ + + + + netstandard2.0 + x64 + + + + + + + + + + + + diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/AutocadConverterToHost.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/AutocadConverterToHost.cs index d856376a88..fc4876e9dd 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/AutocadConverterToHost.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/AutocadConverterToHost.cs @@ -9,10 +9,15 @@ namespace Speckle.Converters.Autocad; public class AutocadConverterToHost : ISpeckleConverterToHost { private readonly IFactory _toHost; + private readonly IConversionContextStack _contextStack; - public AutocadConverterToHost(IFactory toHost) + public AutocadConverterToHost( + IFactory toHost, + IConversionContextStack contextStack + ) { _toHost = toHost; + _contextStack = contextStack; } public object Convert(Base target) @@ -21,16 +26,19 @@ public object Convert(Base target) try { - var objectConverter = _toHost.ResolveInstance(type.Name); - - if (objectConverter == null) + using (var tr = _contextStack.Current.Document.Database.TransactionManager.StartTransaction()) { - throw new NotSupportedException($"No conversion found for {target.GetType().Name}"); - } + var objectConverter = _toHost.ResolveInstance(type.Name); - var convertedObject = objectConverter.Convert(target); + if (objectConverter == null) + { + throw new NotSupportedException($"No conversion found for {target.GetType().Name}"); + } - return convertedObject; + var convertedObject = objectConverter.Convert(target); + tr.Commit(); + return convertedObject; + } } catch (SpeckleConversionException e) { diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/Geometry/PointToHostConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/Geometry/PointToHostConverter.cs deleted file mode 100644 index 90075dbfca..0000000000 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/Geometry/PointToHostConverter.cs +++ /dev/null @@ -1,52 +0,0 @@ -using Speckle.Converters.Common.Objects; -using Speckle.Converters.Common; -using Speckle.Core.Models; -using Autodesk.AutoCAD.DatabaseServices; -using Speckle.Core.Kits; - -namespace Speckle.Converters.Autocad.Geometry; - -[NameAndRankValue(nameof(SOG.Point), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class DBPointToHostConverter : ISpeckleObjectToHostConversion, IRawConversion -{ - private readonly IRawConversion _pointConverter; - private readonly IConversionContextStack _contextStack; - - public DBPointToHostConverter( - IRawConversion pointConverter, - IConversionContextStack contextStack - ) - { - _pointConverter = pointConverter; - _contextStack = contextStack; - } - - public object Convert(Base target) => RawConvert((SOG.Point)target); - - public DBPoint RawConvert(SOG.Point target) - { - double f = Units.GetConversionFactor(target.units, _contextStack.Current.SpeckleUnits); - AG.Point3d point = new(target.x * f, target.y * f, target.z * f); - return new(point); - } -} - -public class PointToHostConverter : IRawConversion -{ - private readonly IConversionContextStack _contextStack; - - public PointToHostConverter(IConversionContextStack contextStack) - { - _contextStack = contextStack; - } - - public object Convert(Base target) => RawConvert((SOG.Point)target); - - public AG.Point3d RawConvert(SOG.Point target) - { - double f = Units.GetConversionFactor(target.units, _contextStack.Current.SpeckleUnits); - AG.Point3d point = new(target.x * f, target.y * f, target.z * f); - - return point; - } -} diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/Speckle.Converters.AutocadShared.projitems b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/Speckle.Converters.AutocadShared.projitems index b0f45481bf..40aeab640b 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/Speckle.Converters.AutocadShared.projitems +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/Speckle.Converters.AutocadShared.projitems @@ -13,14 +13,29 @@ - + + + + + + + + + + + - + + + + + + - \ No newline at end of file + diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/ArcToHostConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/ArcToHostConverter.cs new file mode 100644 index 0000000000..d5653a7eb1 --- /dev/null +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/ArcToHostConverter.cs @@ -0,0 +1,41 @@ +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; +using Speckle.Core.Models; + +namespace Speckle.Converters.Autocad.ToHost.Geometry; + +[NameAndRankValue(nameof(SOG.Arc), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +public class ArcToHostConverter : ISpeckleObjectToHostConversion, IRawConversion +{ + private readonly IRawConversion _arcConverter; + private readonly IRawConversion _planeConverter; + private readonly IConversionContextStack _contextStack; + + public ArcToHostConverter( + IRawConversion arcConverter, + IRawConversion planeConverter, + IConversionContextStack contextStack + ) + { + _arcConverter = arcConverter; + _planeConverter = planeConverter; + _contextStack = contextStack; + } + + public object Convert(Base target) => RawConvert((SOG.Arc)target); + + public ADB.Arc RawConvert(SOG.Arc target) + { + // the most reliable method to convert to autocad convention is to calculate from start, end, and midpoint + // because of different plane & start/end angle conventions + AG.CircularArc3d circularArc = _arcConverter.RawConvert(target); + + // calculate adjusted start and end angles from circularArc reference + AG.Plane plane = _planeConverter.RawConvert(target.plane); + double angle = circularArc.ReferenceVector.AngleOnPlane(plane); + double startAngle = circularArc.StartAngle + angle; + double endAngle = circularArc.EndAngle + angle; + + return new(circularArc.Center, circularArc.Normal, circularArc.Radius, startAngle, endAngle); + } +} diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/CircleToHostConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/CircleToHostConverter.cs new file mode 100644 index 0000000000..b1f1604fec --- /dev/null +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/CircleToHostConverter.cs @@ -0,0 +1,43 @@ +using System; +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; +using Speckle.Core.Kits; +using Speckle.Core.Models; + +namespace Speckle.Converters.Autocad.ToHost.Geometry; + +[NameAndRankValue(nameof(SOG.Circle), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +public class CircleToHostConverter : ISpeckleObjectToHostConversion, IRawConversion +{ + private readonly IRawConversion _pointConverter; + private readonly IRawConversion _vectorConverter; + private readonly IConversionContextStack _contextStack; + + public CircleToHostConverter( + IRawConversion pointConverter, + IRawConversion vectorConverter, + IConversionContextStack contextStack + ) + { + _pointConverter = pointConverter; + _vectorConverter = vectorConverter; + _contextStack = contextStack; + } + + public object Convert(Base target) => RawConvert((SOG.Circle)target); + + public ADB.Circle RawConvert(SOG.Circle target) + { + AG.Vector3d normal = _vectorConverter.RawConvert(target.plane.normal); + AG.Point3d origin = _pointConverter.RawConvert(target.plane.origin); + double f = Units.GetConversionFactor(target.units, _contextStack.Current.SpeckleUnits); + + if (target.radius is null) + { + throw new ArgumentNullException(nameof(target), "Cannot convert circle without radius value."); + } + + var radius = f * (double)target.radius; + return new(origin, normal, radius); + } +} diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/CurveToHostConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/CurveToHostConverter.cs new file mode 100644 index 0000000000..cc25a40304 --- /dev/null +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/CurveToHostConverter.cs @@ -0,0 +1,20 @@ +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; +using Speckle.Core.Models; + +namespace Speckle.Converters.AutocadShared.ToHost.Geometry; + +[NameAndRankValue(nameof(SOG.Curve), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +public class CurveToHostConverter : ISpeckleObjectToHostConversion, IRawConversion +{ + private readonly IRawConversion _curveConverter; + + public CurveToHostConverter(IRawConversion curveConverter) + { + _curveConverter = curveConverter; + } + + public object Convert(Base target) => RawConvert((SOG.Curve)target); + + public ADB.Curve RawConvert(SOG.Curve target) => ADB.Curve.CreateFromGeCurve(_curveConverter.RawConvert(target)); +} diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/EllipseToHostConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/EllipseToHostConverter.cs new file mode 100644 index 0000000000..824959fbd8 --- /dev/null +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/EllipseToHostConverter.cs @@ -0,0 +1,47 @@ +using System; +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; +using Speckle.Core.Kits; +using Speckle.Core.Models; + +namespace Speckle.Converters.Autocad.ToHost.Geometry; + +[NameAndRankValue(nameof(SOG.Ellipse), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +public class EllipseToHostConverter : ISpeckleObjectToHostConversion, IRawConversion +{ + private readonly IRawConversion _pointConverter; + private readonly IRawConversion _vectorConverter; + private readonly IConversionContextStack _contextStack; + + public EllipseToHostConverter( + IRawConversion pointConverter, + IRawConversion vectorConverter, + IConversionContextStack contextStack + ) + { + _pointConverter = pointConverter; + _vectorConverter = vectorConverter; + _contextStack = contextStack; + } + + public object Convert(Base target) => RawConvert((SOG.Ellipse)target); + + /// Throws if any ellipse radius value is null. + public ADB.Ellipse RawConvert(SOG.Ellipse target) + { + double f = Units.GetConversionFactor(target.units, _contextStack.Current.SpeckleUnits); + AG.Point3d origin = _pointConverter.RawConvert(target.plane.origin); + AG.Vector3d normal = _vectorConverter.RawConvert(target.plane.normal); + AG.Vector3d xAxis = _vectorConverter.RawConvert(target.plane.xdir); + + // POC: how possibly we might have firstRadius and secondRadius is possibly null? + if (target.firstRadius is null || target.secondRadius is null) + { + throw new ArgumentNullException(nameof(target), "Cannot convert ellipse without radius values."); + } + + AG.Vector3d majorAxis = f * (double)target.firstRadius * xAxis.GetNormal(); + double radiusRatio = (double)target.secondRadius / (double)target.firstRadius; + return new(origin, normal, majorAxis, radiusRatio, 0, 2 * Math.PI); + } +} diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/LineToHostConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/LineToHostConverter.cs new file mode 100644 index 0000000000..b07a33c594 --- /dev/null +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/LineToHostConverter.cs @@ -0,0 +1,21 @@ +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; +using Speckle.Core.Models; + +namespace Speckle.Converters.Autocad.ToHost.Geometry; + +[NameAndRankValue(nameof(SOG.Line), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +public class LineToHostConverter : ISpeckleObjectToHostConversion, IRawConversion +{ + private readonly IRawConversion _pointConverter; + + public LineToHostConverter(IRawConversion pointConverter) + { + _pointConverter = pointConverter; + } + + public object Convert(Base target) => RawConvert((SOG.Line)target); + + public ADB.Line RawConvert(SOG.Line target) => + new(_pointConverter.RawConvert(target.start), _pointConverter.RawConvert(target.end)); +} diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/MeshToHostConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/MeshToHostConverter.cs new file mode 100644 index 0000000000..4f97cc973b --- /dev/null +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/MeshToHostConverter.cs @@ -0,0 +1,117 @@ +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; +using Speckle.Core.Models; +using Objects.Utils; +using System.Linq; +using Speckle.Core.Logging; +using System.Collections.Generic; + +namespace Speckle.Converters.Autocad.Geometry; + +[NameAndRankValue(nameof(SOG.Mesh), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +public class MeshToHostConverter : ISpeckleObjectToHostConversion, IRawConversion +{ + private readonly IRawConversion _pointConverter; + private readonly IConversionContextStack _contextStack; + + public MeshToHostConverter( + IRawConversion pointConverter, + IConversionContextStack contextStack + ) + { + _pointConverter = pointConverter; + _contextStack = contextStack; + } + + public object Convert(Base target) => RawConvert((SOG.Mesh)target); + + /// + /// Mesh conversion requires transaction since it's vertices needed to be added into database in advance.. + /// + public ADB.PolyFaceMesh RawConvert(SOG.Mesh target) + { + target.TriangulateMesh(true); + + // get vertex points + using AG.Point3dCollection vertices = new(); + List points = target.GetPoints().Select(o => _pointConverter.RawConvert(o)).ToList(); + foreach (var point in points) + { + vertices.Add(point); + } + + ADB.PolyFaceMesh mesh = new(); + + ADB.Transaction tr = _contextStack.Current.Document.TransactionManager.TopTransaction; + + mesh.SetDatabaseDefaults(); + + // append mesh to blocktable record - necessary before adding vertices and faces + var btr = (ADB.BlockTableRecord) + tr.GetObject(_contextStack.Current.Document.Database.CurrentSpaceId, ADB.OpenMode.ForWrite); + btr.AppendEntity(mesh); + tr.AddNewlyCreatedDBObject(mesh, true); + + // add polyfacemesh vertices + for (int i = 0; i < vertices.Count; i++) + { + var vertex = new ADB.PolyFaceMeshVertex(points[i]); + if (i < target.colors.Count) + { + try + { + if (System.Drawing.Color.FromArgb(target.colors[i]) is System.Drawing.Color color) + { + vertex.Color = Autodesk.AutoCAD.Colors.Color.FromRgb(color.R, color.G, color.B); + } + } + catch (System.Exception e) when (!e.IsFatal()) + { + // POC: should we warn user? + // Couldn't set vertex color, but this should not prevent conversion. + } + } + + if (vertex.IsNewObject) + { + mesh.AppendVertex(vertex); + tr.AddNewlyCreatedDBObject(vertex, true); + } + } + + // add polyfacemesh faces. vertex index starts at 1 sigh + int j = 0; + while (j < target.faces.Count) + { + ADB.FaceRecord face; + if (target.faces[j] == 3) // triangle + { + face = new ADB.FaceRecord( + (short)(target.faces[j + 1] + 1), + (short)(target.faces[j + 2] + 1), + (short)(target.faces[j + 3] + 1), + 0 + ); + j += 4; + } + else // quad + { + face = new ADB.FaceRecord( + (short)(target.faces[j + 1] + 1), + (short)(target.faces[j + 2] + 1), + (short)(target.faces[j + 3] + 1), + (short)(target.faces[j + 4] + 1) + ); + j += 5; + } + + if (face.IsNewObject) + { + mesh.AppendFaceRecord(face); + tr.AddNewlyCreatedDBObject(face, true); + } + } + + return mesh; + } +} diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/PointToHostConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/PointToHostConverter.cs new file mode 100644 index 0000000000..177a5f7808 --- /dev/null +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/PointToHostConverter.cs @@ -0,0 +1,20 @@ +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; +using Speckle.Core.Models; + +namespace Speckle.Converters.Autocad.ToHost.Geometry; + +[NameAndRankValue(nameof(SOG.Point), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +public class PointToHostConverter : ISpeckleObjectToHostConversion, IRawConversion +{ + private readonly IRawConversion _pointConverter; + + public PointToHostConverter(IRawConversion pointConverter) + { + _pointConverter = pointConverter; + } + + public object Convert(Base target) => RawConvert((SOG.Point)target); + + public ADB.DBPoint RawConvert(SOG.Point target) => new(_pointConverter.RawConvert(target)); +} diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/PolycurveToHostConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/PolycurveToHostConverter.cs new file mode 100644 index 0000000000..73e87bbd76 --- /dev/null +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/PolycurveToHostConverter.cs @@ -0,0 +1,95 @@ +using System.Collections.Generic; +using System.Linq; +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; +using Speckle.Core.Models; + +namespace Speckle.Converters.AutocadShared.ToHost.Geometry; + +/// +/// A polycurve has segments as list and it can contain different kind of ICurve objects like Arc, Line, Polyline, Curve etc.. +/// If polycurve segments is consist of only with Arcs and Lines, it can be represented as Polyline in Autucad. +/// Otherwise we convert it as spline (list of ADB.Entity) that switch cases according to each segment type. +/// +[NameAndRankValue(nameof(SOG.Polycurve), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +public class PolycurveToHostConverter : ISpeckleObjectToHostConversion +{ + private readonly IRawConversion _polylineConverter; + private readonly IRawConversion> _splineConverter; + + public PolycurveToHostConverter( + IRawConversion polylineConverter, + IRawConversion> splineConverter + ) + { + _polylineConverter = polylineConverter; + _splineConverter = splineConverter; + } + + public object Convert(Base target) + { + SOG.Polycurve polycurve = (SOG.Polycurve)target; + bool convertAsSpline = polycurve.segments.Any(s => s is not SOG.Line and not SOG.Arc); + bool isPlanar = IsPolycurvePlanar(polycurve); + + if (convertAsSpline || !isPlanar) + { + return _splineConverter.RawConvert(polycurve); + } + else + { + return _polylineConverter.RawConvert(polycurve); + } + } + + private bool IsPolycurvePlanar(SOG.Polycurve polycurve) + { + double? z = null; + foreach (var segment in polycurve.segments) + { + switch (segment) + { + case SOG.Line o: + z ??= o.start.z; + + if (o.start.z != z || o.end.z != z) + { + return false; + } + + break; + case SOG.Arc o: + z ??= o.startPoint.z; + + if (o.startPoint.z != z || o.midPoint.z != z || o.endPoint.z != z) + { + return false; + } + + break; + case SOG.Curve o: + z ??= o.points[2]; + + for (int i = 2; i < o.points.Count; i += 3) + { + if (o.points[i] != z) + { + return false; + } + } + + break; + case SOG.Spiral o: + z ??= o.startPoint.z; + + if (o.startPoint.z != z || o.endPoint.z != z) + { + return false; + } + + break; + } + } + return true; + } +} diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/PolylineToHostConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/PolylineToHostConverter.cs new file mode 100644 index 0000000000..bf5fa03bf8 --- /dev/null +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/PolylineToHostConverter.cs @@ -0,0 +1,25 @@ +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; +using Speckle.Core.Models; + +namespace Speckle.Converters.Autocad.ToHost.Geometry; + +[NameAndRankValue(nameof(SOG.Polyline), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +public class PolylineToHostConverter : ISpeckleObjectToHostConversion, IRawConversion +{ + private readonly IRawConversion _pointConverter; + + public PolylineToHostConverter(IRawConversion pointConverter) + { + _pointConverter = pointConverter; + } + + public object Convert(Base target) => RawConvert((SOG.Polyline)target); + + public ADB.Polyline3d RawConvert(SOG.Polyline target) + { + AG.Point3dCollection vertices = new(); + target.GetPoints().ForEach(o => vertices.Add(_pointConverter.RawConvert(o))); + return new(ADB.Poly3dType.SimplePoly, vertices, target.closed); + } +} diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/ArcToHostRawConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/ArcToHostRawConverter.cs new file mode 100644 index 0000000000..c305245a7b --- /dev/null +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/ArcToHostRawConverter.cs @@ -0,0 +1,42 @@ +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; +using Speckle.Core.Models; + +namespace Speckle.Converters.Autocad.ToHost.Raw; + +[NameAndRankValue(nameof(SOG.Arc), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +public class ArcToHostRowConverter : IRawConversion +{ + private readonly IRawConversion _pointConverter; + private readonly IRawConversion _vectorConverter; + + public ArcToHostRowConverter( + IRawConversion pointConverter, + IRawConversion vectorConverter + ) + { + _pointConverter = pointConverter; + _vectorConverter = vectorConverter; + } + + public object Convert(Base target) => RawConvert((SOG.Arc)target); + + public AG.CircularArc3d RawConvert(SOG.Arc target) + { + AG.Point3d start = _pointConverter.RawConvert(target.startPoint); + AG.Point3d end = _pointConverter.RawConvert(target.endPoint); + AG.Point3d mid = _pointConverter.RawConvert(target.midPoint); + AG.CircularArc3d arc = new(start, mid, end); + + AG.Vector3d normal = _vectorConverter.RawConvert(target.plane.normal); + AG.Vector3d xdir = _vectorConverter.RawConvert(target.plane.xdir); + arc.SetAxes(normal, xdir); + + if (target.startAngle is double startAngle && target.endAngle is double endAngle) + { + arc.SetAngles(startAngle, endAngle); + } + + return arc; + } +} diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/CurveToHostRawConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/CurveToHostRawConverter.cs new file mode 100644 index 0000000000..b7fb4bff8f --- /dev/null +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/CurveToHostRawConverter.cs @@ -0,0 +1,76 @@ +using System.Collections.Generic; +using System.Linq; +using Speckle.Converters.Common.Objects; + +namespace Speckle.Converters.AutocadShared.ToHost.Raw; + +public class CurveToHostRawConverter : IRawConversion +{ + private readonly IRawConversion _pointConverter; + private readonly IRawConversion _intervalConverter; + + public CurveToHostRawConverter( + IRawConversion pointConverter, + IRawConversion intervalConverter + ) + { + _pointConverter = pointConverter; + _intervalConverter = intervalConverter; + } + + public AG.NurbCurve3d RawConvert(SOG.Curve target) + { + var points = target.GetPoints().Select(p => _pointConverter.RawConvert(p)).ToList(); + if (target.closed && target.periodic) + { + points = points.GetRange(0, points.Count - target.degree); + } + + var pointCollection = new AG.Point3dCollection(points.ToArray()); + + // process knots + // NOTE: Autocad defines spline knots as a vector of size # control points + degree + 1. (# at start and end should match degree) + // Conversions for autocad need to make sure this is satisfied, otherwise will cause protected mem crash. + // NOTE: for **closed periodic** curves that have "n" control pts, # of knots should be n + 1. Remove degree = 3 knots from start and end. + List knotList = target.knots; + if (target.knots.Count == points.Count + target.degree - 1) // handles rhino format curves + { + knotList.Insert(0, knotList[0]); + knotList.Insert(knotList.Count - 1, knotList[knotList.Count - 1]); + } + if (target.closed && target.periodic) // handles closed periodic curves + { + knotList = knotList.GetRange(target.degree, knotList.Count - target.degree * 2); + } + + var knots = new AG.KnotCollection(); + foreach (var knot in knotList) + { + knots.Add(knot); + } + + // process weights + // NOTE: if all weights are the same, autocad convention is to pass an empty list (this will assign them a value of -1) + var weightsList = target.weights; + if (target.closed && target.periodic) // handles closed periodic curves + { + weightsList = target.weights.GetRange(0, points.Count); + } + + AG.DoubleCollection weights; + weights = + (weightsList.Distinct().Count() == 1) + ? new AG.DoubleCollection() + : new AG.DoubleCollection(weightsList.ToArray()); + + AG.NurbCurve3d curve = new(target.degree, knots, pointCollection, weights, target.periodic); + if (target.closed) + { + curve.MakeClosed(); + } + + curve.SetInterval(_intervalConverter.RawConvert(target.domain)); + + return curve; + } +} diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/IntervalToHostRawConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/IntervalToHostRawConverter.cs new file mode 100644 index 0000000000..e9136438bd --- /dev/null +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/IntervalToHostRawConverter.cs @@ -0,0 +1,19 @@ +using System; +using Speckle.Converters.Common.Objects; + +namespace Speckle.Converters.AutocadShared.ToHost.Raw; + +public class IntervalToHostRawConverter : IRawConversion +{ + /// Throws if target start or end value is null. + public AG.Interval RawConvert(SOP.Interval target) + { + // POC: the tolerance might be in some settings or in some context? + if (target.start is null || target.end is null) + { + throw new ArgumentNullException(nameof(target), "Cannot convert interval without start or end values."); + } + + return new((double)target.start, (double)target.end, 0.000); + } +} diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/PlaneToHostRawConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/PlaneToHostRawConverter.cs new file mode 100644 index 0000000000..4928988e81 --- /dev/null +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/PlaneToHostRawConverter.cs @@ -0,0 +1,24 @@ +using Speckle.Converters.Common.Objects; +using Speckle.Core.Models; + +namespace Speckle.Converters.Autocad.ToHost.Raw; + +public class PlaneToHostRawConverter : IRawConversion +{ + private readonly IRawConversion _pointConverter; + private readonly IRawConversion _vectorConverter; + + public PlaneToHostRawConverter( + IRawConversion pointConverter, + IRawConversion vectorConverter + ) + { + _pointConverter = pointConverter; + _vectorConverter = vectorConverter; + } + + public object Convert(Base target) => RawConvert((SOG.Plane)target); + + public AG.Plane RawConvert(SOG.Plane target) => + new(_pointConverter.RawConvert(target.origin), _vectorConverter.RawConvert(target.normal)); +} diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/PointToHostRawConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/PointToHostRawConverter.cs new file mode 100644 index 0000000000..26be7f9334 --- /dev/null +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/PointToHostRawConverter.cs @@ -0,0 +1,22 @@ +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; +using Speckle.Core.Kits; + +namespace Speckle.Converters.Autocad.ToHost.Raw; + +public class PointToHostRawConverter : IRawConversion +{ + private readonly IConversionContextStack _contextStack; + + public PointToHostRawConverter(IConversionContextStack contextStack) + { + _contextStack = contextStack; + } + + public AG.Point3d RawConvert(SOG.Point target) + { + double f = Units.GetConversionFactor(target.units, _contextStack.Current.SpeckleUnits); + AG.Point3d point = new(target.x * f, target.y * f, target.z * f); + return point; + } +} diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/PolycurveToHostPolylineRawConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/PolycurveToHostPolylineRawConverter.cs new file mode 100644 index 0000000000..1bbe733549 --- /dev/null +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/PolycurveToHostPolylineRawConverter.cs @@ -0,0 +1,99 @@ +using System; +using System.Linq; +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; + +namespace Speckle.Converters.AutocadShared.ToHost.Raw; + +/// +/// If polycurve segments consist of only with Line and Arc, we convert it as ADB.Polyline. +/// +public class PolycurveToHostPolylineRawConverter : IRawConversion +{ + private readonly IConversionContextStack _contextStack; + private readonly IRawConversion _pointConverter; + + public PolycurveToHostPolylineRawConverter( + IConversionContextStack contextStack, + IRawConversion pointConverter + ) + { + _contextStack = contextStack; + _pointConverter = pointConverter; + } + + public ADB.Polyline RawConvert(SOG.Polycurve target) + { + ADB.Polyline polyline = new() { Closed = target.closed }; + var plane = new AG.Plane( + AG.Point3d.Origin, + AG.Vector3d.ZAxis.TransformBy(_contextStack.Current.Document.Editor.CurrentUserCoordinateSystem) + ); + + int count = 0; + foreach (var segment in target.segments) + { + switch (segment) + { + case SOG.Line o: + polyline.AddVertexAt(count, _pointConverter.RawConvert(o.start).Convert2d(plane), 0, 0, 0); + if (!target.closed && count == target.segments.Count - 1) + { + polyline.AddVertexAt(count + 1, _pointConverter.RawConvert(o.end).Convert2d(plane), 0, 0, 0); + } + + count++; + break; + case SOG.Arc arc: + // POC: possibly endAngle and startAngle null? + var angle = arc.endAngle - arc.startAngle; + angle = angle < 0 ? angle + 2 * Math.PI : angle; + if (angle is null) + { + throw new ArgumentNullException(nameof(arc), "Cannot convert arc without angle value."); + } + var bulge = Math.Tan((double)angle / 4) * BulgeDirection(arc.startPoint, arc.midPoint, arc.endPoint); + polyline.AddVertexAt(count, _pointConverter.RawConvert(arc.startPoint).Convert2d(plane), bulge, 0, 0); + if (!target.closed && count == target.segments.Count - 1) + { + polyline.AddVertexAt(count + 1, _pointConverter.RawConvert(arc.endPoint).Convert2d(plane), 0, 0, 0); + } + + count++; + break; + case SOG.Spiral o: + var vertices = o.displayValue.GetPoints().Select(_pointConverter.RawConvert).ToList(); + foreach (var vertex in vertices) + { + polyline.AddVertexAt(count, vertex.Convert2d(plane), 0, 0, 0); + count++; + } + break; + default: + break; + } + } + + return polyline; + } + + // calculates bulge direction: (-) clockwise, (+) counterclockwise + private int BulgeDirection(SOG.Point start, SOG.Point mid, SOG.Point end) + { + // get vectors from points + double[] v1 = new double[] { end.x - start.x, end.y - start.y, end.z - start.z }; // vector from start to end point + double[] v2 = new double[] { mid.x - start.x, mid.y - start.y, mid.z - start.z }; // vector from start to mid point + + // calculate cross product z direction + double z = v1[0] * v2[1] - v2[0] * v1[1]; + + if (z > 0) + { + return -1; + } + else + { + return 1; + } + } +} diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/PolycurveToHostSplineRawConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/PolycurveToHostSplineRawConverter.cs new file mode 100644 index 0000000000..e9f7c38549 --- /dev/null +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/PolycurveToHostSplineRawConverter.cs @@ -0,0 +1,58 @@ +using System.Collections.Generic; +using Speckle.Converters.Common.Objects; + +namespace Speckle.Converters.AutocadShared.ToHost.Raw; + +/// +/// Polycurve segments might appear in different ICurve types which requires to handle separately for each segment. +/// +public class PolycurveToHostSplineRawConverter : IRawConversion> +{ + private readonly IRawConversion _lineConverter; + private readonly IRawConversion _polylineConverter; + private readonly IRawConversion _arcConverter; + private readonly IRawConversion _curveConverter; + + public PolycurveToHostSplineRawConverter( + IRawConversion lineConverter, + IRawConversion polylineConverter, + IRawConversion arcConverter, + IRawConversion curveConverter + ) + { + _lineConverter = lineConverter; + _polylineConverter = polylineConverter; + _arcConverter = arcConverter; + _curveConverter = curveConverter; + } + + public List RawConvert(SOG.Polycurve target) + { + // POC: We can improve this once we have IIndex of raw converters and we can get rid of case converters? + // POC: Should we join entities? + var list = new List(); + + foreach (var segment in target.segments) + { + switch (segment) + { + case SOG.Arc arc: + list.Add(_arcConverter.RawConvert(arc)); + break; + case SOG.Line line: + list.Add(_lineConverter.RawConvert(line)); + break; + case SOG.Polyline polyline: + list.Add(_polylineConverter.RawConvert(polyline)); + break; + case SOG.Curve curve: + list.Add(_curveConverter.RawConvert(curve)); + break; + default: + break; + } + } + + return list; + } +} diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/VectorToHostRawConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/VectorToHostRawConverter.cs new file mode 100644 index 0000000000..3c44da75f2 --- /dev/null +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/VectorToHostRawConverter.cs @@ -0,0 +1,24 @@ +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; +using Speckle.Core.Kits; +using Speckle.Core.Models; + +namespace Speckle.Converters.Autocad.ToHost.Raw; + +public class VectorToHostRawConverter : IRawConversion +{ + private readonly IConversionContextStack _contextStack; + + public VectorToHostRawConverter(IConversionContextStack contextStack) + { + _contextStack = contextStack; + } + + public object Convert(Base target) => RawConvert((SOG.Vector)target); + + public AG.Vector3d RawConvert(SOG.Vector target) + { + double f = Units.GetConversionFactor(target.units, _contextStack.Current.SpeckleUnits); + return new(target.x * f, target.y * f, target.z * f); + } +} diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/SyncToUIThread.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/SyncToUIThread.cs new file mode 100644 index 0000000000..9eb30b2168 --- /dev/null +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/SyncToUIThread.cs @@ -0,0 +1,28 @@ +using System; +using System.Threading.Tasks; +using Speckle.Connectors.Utils.Operations; + +namespace Speckle.Connectors.DUI.Bridge; + +public class SyncToUIThread : ISyncToMainThread +{ + private readonly IBridge _bridge; + + public SyncToUIThread(IBridge bridge) + { + _bridge = bridge; + } + + public Task RunOnThread(Func func) + { + TaskCompletionSource tcs = new(); + + _bridge.RunOnMainThread(() => + { + T result = func.Invoke(); + tcs.SetResult(result); + }); + + return tcs.Task; + } +} diff --git a/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/ISyncToMainThread.cs b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/ISyncToMainThread.cs new file mode 100644 index 0000000000..533ee8f838 --- /dev/null +++ b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/ISyncToMainThread.cs @@ -0,0 +1,9 @@ +using System; +using System.Threading.Tasks; + +namespace Speckle.Connectors.Utils.Operations; + +public interface ISyncToMainThread +{ + public Task RunOnThread(Func func); +} diff --git a/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/ReceiveOperation.cs b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/ReceiveOperation.cs index 5f1da05cf8..4ca52c9a30 100644 --- a/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/ReceiveOperation.cs +++ b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/ReceiveOperation.cs @@ -13,10 +13,12 @@ namespace Speckle.Connectors.Utils.Operations; public sealed class ReceiveOperation { private readonly IHostObjectBuilder _hostObjectBuilder; + private readonly ISyncToMainThread _syncToMainThread; - public ReceiveOperation(IHostObjectBuilder hostObjectBuilder) + public ReceiveOperation(IHostObjectBuilder hostObjectBuilder, ISyncToMainThread syncToMainThread) { _hostObjectBuilder = hostObjectBuilder; + _syncToMainThread = syncToMainThread; } public async Task> Execute( @@ -44,6 +46,11 @@ public async Task> Execute( cancellationToken.ThrowIfCancellationRequested(); // 4 - Convert objects - return _hostObjectBuilder.Build(commitObject, projectName, modelName, onOperationProgressed, cancellationToken); + return await _syncToMainThread + .RunOnThread(() => + { + return _hostObjectBuilder.Build(commitObject, projectName, modelName, onOperationProgressed, cancellationToken); + }) + .ConfigureAwait(false); } } From 4d432e5f4751ec42c7b114879efd2fbc9d78fb6e Mon Sep 17 00:00:00 2001 From: Alan Rynne Date: Mon, 22 Apr 2024 09:55:30 +0200 Subject: [PATCH 036/261] CNX-9290 Apply Unit of Work for Rhino (#3294) * feat: Apply unit of work to send/receive binding Updates all dependencies to instancePerLifetimeScope or lower. * fix: Registration fixes --- .../Bindings/RhinoReceiveBinding.cs | 10 ++++++---- .../Bindings/RhinoSendBinding.cs | 10 ++++++---- .../DependencyInjection/AutofacRhinoModule.cs | 15 ++++++++------- .../HostApp/SpeckleRhinoPanel.xaml.cs | 13 ++++++++++--- .../AutofacRhinoConverterModule.cs | 13 ++++++++----- 5 files changed, 38 insertions(+), 23 deletions(-) diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoReceiveBinding.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoReceiveBinding.cs index a558da0d6e..dea667feb0 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoReceiveBinding.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoReceiveBinding.cs @@ -3,6 +3,7 @@ using System.Linq; using System.Threading; using System.Threading.Tasks; +using Speckle.Autofac.DependencyInjection; using Speckle.Connectors.DUI.Bindings; using Speckle.Connectors.DUI.Bridge; using Speckle.Connectors.DUI.Models; @@ -20,20 +21,20 @@ public class RhinoReceiveBinding : IReceiveBinding, ICancelable public CancellationManager CancellationManager { get; set; } private readonly DocumentModelStore _store; - private readonly ReceiveOperation _receiveOperation; + private readonly IUnitOfWorkFactory _unitOfWorkFactory; public ReceiveBindingUICommands Commands { get; } public RhinoReceiveBinding( DocumentModelStore store, CancellationManager cancellationManager, IBridge parent, - ReceiveOperation receiveOperation + IUnitOfWorkFactory unitOfWorkFactory ) { Parent = parent; _store = store; + _unitOfWorkFactory = unitOfWorkFactory; CancellationManager = cancellationManager; - _receiveOperation = receiveOperation; Commands = new ReceiveBindingUICommands(parent); } @@ -41,6 +42,7 @@ ReceiveOperation receiveOperation public async Task Receive(string modelCardId) { + using var unitOfWork = _unitOfWorkFactory.Resolve(); try { // Init cancellation token source -> Manager also cancel it if exist before @@ -53,7 +55,7 @@ public async Task Receive(string modelCardId) } // Receive host objects - IEnumerable receivedObjectIds = await _receiveOperation + IEnumerable receivedObjectIds = await unitOfWork.Service .Execute( modelCard.AccountId, // POC: I hear -you are saying why we're passing them separately. Not sure pass the DUI3-> Connectors.DUI project dependency to the SDK-> Connector.Utils modelCard.ProjectId, diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSendBinding.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSendBinding.cs index fd55a7ffbd..2bb26949fe 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSendBinding.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSendBinding.cs @@ -14,6 +14,7 @@ using Speckle.Core.Logging; using ICancelable = System.Reactive.Disposables.ICancelable; using System.Threading.Tasks; +using Speckle.Autofac.DependencyInjection; using Speckle.Connectors.Rhino7.Operations.Send; using Speckle.Connectors.DUI.Models.Card.SendFilter; @@ -27,8 +28,8 @@ public sealed class RhinoSendBinding : ISendBinding, ICancelable private readonly DocumentModelStore _store; private readonly RhinoIdleManager _idleManager; + private readonly IUnitOfWorkFactory _unitOfWorkFactory; private readonly List _sendFilters; - private readonly SendOperation _sendOperation; private readonly CancellationManager _cancellationManager; /// @@ -47,14 +48,14 @@ public RhinoSendBinding( RhinoIdleManager idleManager, IBridge parent, IEnumerable sendFilters, - SendOperation sendOperation, + IUnitOfWorkFactory unitOfWorkFactory, CancellationManager cancellationManager ) { _store = store; _idleManager = idleManager; + _unitOfWorkFactory = unitOfWorkFactory; _sendFilters = sendFilters.ToList(); - _sendOperation = sendOperation; _cancellationManager = cancellationManager; Parent = parent; Commands = new SendBindingUICommands(parent); // POC: Commands are tightly coupled with their bindings, at least for now, saves us injecting a factory. @@ -130,6 +131,7 @@ public List GetSendSettings() )] public async Task Send(string modelCardId) { + using var unitOfWork = _unitOfWorkFactory.Resolve(); try { // 0 - Init cancellation token source -> Manager also cancel it if exist before @@ -141,7 +143,7 @@ public async Task Send(string modelCardId) throw new InvalidOperationException("No publish model card was found."); } - string versionId = await _sendOperation + string versionId = await unitOfWork.Service .Execute( modelCard.SendFilter, modelCard.AccountId, diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/AutofacRhinoModule.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/AutofacRhinoModule.cs index 827603f580..221d65b24e 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/AutofacRhinoModule.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/AutofacRhinoModule.cs @@ -4,6 +4,7 @@ using Rhino.Commands; using Rhino.PlugIns; using Serilog; +using Speckle.Autofac.DependencyInjection; using Speckle.Connectors.DUI.Bindings; using Speckle.Connectors.DUI.Bridge; using Speckle.Connectors.DUI.Models; @@ -56,22 +57,22 @@ protected override void Load(ContainerBuilder builder) // binding dependencies builder.RegisterType().InstancePerDependency(); + builder.RegisterType().As().InstancePerDependency(); // register send filters builder.RegisterType().As().InstancePerDependency(); builder.RegisterType().As().InstancePerDependency(); // register send operation and dependencies - builder.RegisterType().SingleInstance(); - builder.RegisterType().SingleInstance(); + builder.RegisterType().As().InstancePerLifetimeScope(); + builder.RegisterType().InstancePerLifetimeScope(); + builder.RegisterType().InstancePerLifetimeScope(); builder.RegisterType().As().SingleInstance(); - builder.RegisterType().As().SingleInstance(); - - builder.RegisterType().SingleInstance(); - builder.RegisterType().As().SingleInstance(); + builder.RegisterType().As().InstancePerLifetimeScope(); - builder.RegisterType().As().InstancePerDependency(); + builder.RegisterType().InstancePerLifetimeScope(); + builder.RegisterType().As().InstancePerLifetimeScope(); } private static JsonSerializerSettings GetJsonSerializerSettings() diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/SpeckleRhinoPanel.xaml.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/SpeckleRhinoPanel.xaml.cs index adbc7ed8b4..3647e6a22c 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/SpeckleRhinoPanel.xaml.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/SpeckleRhinoPanel.xaml.cs @@ -36,9 +36,16 @@ private void OnInitialized(object sender, CoreWebView2InitializationCompletedEve //TODO: Pass bindings to browser bridge here! foreach (Lazy lazyBinding in _bindings) { - var binding = lazyBinding.Value; - binding.Parent.AssociateWithBinding(binding, ExecuteScriptAsyncMethod, Browser); - Browser.CoreWebView2.AddHostObjectToScript(binding.Name, binding.Parent); + try + { + var binding = lazyBinding.Value; + binding.Parent.AssociateWithBinding(binding, ExecuteScriptAsyncMethod, Browser); + Browser.CoreWebView2.AddHostObjectToScript(binding.Name, binding.Parent); + } + catch (Exception exception) when (!exception.IsFatal()) + { + Console.Error.WriteLine(exception); // POC: If something throws here, it get's lost in the ether and DUI fails to initialise completely. + } } } } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/AutofacRhinoConverterModule.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/AutofacRhinoConverterModule.cs index dfba0e2ae4..a7340d4bbc 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/AutofacRhinoConverterModule.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/AutofacRhinoConverterModule.cs @@ -22,9 +22,11 @@ protected override void Load(ContainerBuilder builder) builder.RegisterRawConversions(); // To Speckle - builder.RegisterType().As>().SingleInstance(); - builder.RegisterType().As().SingleInstance(); - builder.RegisterType().As().InstancePerLifetimeScope(); + builder + .RegisterType() + .As>() + .InstancePerLifetimeScope(); + builder.RegisterType().As().InstancePerLifetimeScope(); /* POC: CNX-9267 Moved the Injection of converters into the converter module. Not sure if this is 100% right, as this doesn't just register the conversions within this converter, but any conversions found in any Speckle.*.dll file. @@ -36,7 +38,7 @@ This will require consolidating across other connectors. .As>() .InstancePerLifetimeScope(); - builder.RegisterType().As().SingleInstance(); + builder.RegisterType().As().InstancePerLifetimeScope(); /* POC: CNX-9267 Moved the Injection of converters into the converter module. Not sure if this is 100% right, as this doesn't just register the conversions within this converter, but any conversions found in any Speckle.*.dll file. @@ -45,6 +47,7 @@ This will require consolidating across other connectors. builder.InjectNamedTypes(); builder .RegisterType>() - .As>(); + .As>() + .InstancePerLifetimeScope(); } } From 4ab31f5d9082ee9ad003e3d3c44535d9cd7d7a6b Mon Sep 17 00:00:00 2001 From: Alan Rynne Date: Mon, 22 Apr 2024 14:10:27 +0200 Subject: [PATCH 037/261] fix(rhino): CNX-9309 Mix fixes reported by Dim (#3297) * fix: Wrong boolean check on RhinoMath.UnsetIndexInt * feat: Added extrusion -> Brep top level conversion * fix: Missing `IsClosed` flag in polyline conversion * fix: Receive SyncToMainThread should just do Task.Run * fix: Use .FromResult as it will run on current thread for sure Kudos to Jedd for this --- .../DependencyInjection/AutofacRhinoModule.cs | 2 +- .../Receive/RhinoHostObjectBuilder.cs | 2 +- .../Raw/PolylineToSpeckleConverter.cs | 3 ++- ...RhinoExtrusionObjectToSpeckleConversion.cs | 24 +++++++++++++++++++ .../Bridge/SyncToCurrentThread.cs | 19 +++++++++++++++ 5 files changed, 47 insertions(+), 3 deletions(-) create mode 100644 DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/RhinoExtrusionObjectToSpeckleConversion.cs create mode 100644 DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/SyncToCurrentThread.cs diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/AutofacRhinoModule.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/AutofacRhinoModule.cs index 221d65b24e..2a7a75658a 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/AutofacRhinoModule.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/AutofacRhinoModule.cs @@ -67,7 +67,7 @@ protected override void Load(ContainerBuilder builder) builder.RegisterType().As().InstancePerLifetimeScope(); builder.RegisterType().InstancePerLifetimeScope(); builder.RegisterType().InstancePerLifetimeScope(); - builder.RegisterType().As().SingleInstance(); + builder.RegisterType().As().SingleInstance(); builder.RegisterType().As().InstancePerLifetimeScope(); diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Receive/RhinoHostObjectBuilder.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Receive/RhinoHostObjectBuilder.cs index 75ba981d3a..9c467b5c50 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Receive/RhinoHostObjectBuilder.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Receive/RhinoHostObjectBuilder.cs @@ -62,7 +62,7 @@ CancellationToken cancellationToken // POC: We could move this out into a separate service for testing and re-use. // Cleans up any previously received objects - if (rootLayerIndex == RhinoMath.UnsetIntIndex) + if (rootLayerIndex != RhinoMath.UnsetIntIndex) { Layer documentLayer = doc.Layers[rootLayerIndex]; Layer[]? childLayers = documentLayer.GetChildren(); diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/PolylineToSpeckleConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/PolylineToSpeckleConverter.cs index ff890db496..ad202ff632 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/PolylineToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/PolylineToSpeckleConverter.cs @@ -49,7 +49,8 @@ public SOG.Polyline RawConvert(RG.Polyline target) { bbox = box, length = target.Length, - domain = new(0, target.Length) + domain = new(0, target.Length), + closed = target.IsClosed }; } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/RhinoExtrusionObjectToSpeckleConversion.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/RhinoExtrusionObjectToSpeckleConversion.cs new file mode 100644 index 0000000000..2d5cd4c884 --- /dev/null +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/RhinoExtrusionObjectToSpeckleConversion.cs @@ -0,0 +1,24 @@ +using Rhino.DocObjects; +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; +using Speckle.Core.Models; + +namespace Speckle.Converters.Rhino7.ToSpeckle.TopLevel; + +[NameAndRankValue(nameof(ExtrusionObject), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +public class RhinoExtrusionObjectToSpeckleConversion : IHostObjectToSpeckleConversion +{ + private readonly IRawConversion _curveConverter; + + public RhinoExtrusionObjectToSpeckleConversion(IRawConversion curveConverter) + { + _curveConverter = curveConverter; + } + + public Base Convert(object target) + { + var curveObject = (ExtrusionObject)target; + var speckleCurve = _curveConverter.RawConvert(curveObject.ExtrusionGeometry.ToBrep()); + return speckleCurve; + } +} diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/SyncToCurrentThread.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/SyncToCurrentThread.cs new file mode 100644 index 0000000000..723d9c6168 --- /dev/null +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/SyncToCurrentThread.cs @@ -0,0 +1,19 @@ +using System; +using System.Threading.Tasks; +using Speckle.Connectors.Utils.Operations; + +namespace Speckle.Connectors.DUI.Bridge; + +/// +/// Implements the ISyncToMainThread interface and runs a given function on the current thread using Task.Run. +/// +public class SyncToCurrentThread : ISyncToMainThread +{ + /// + /// Executes a given function on the current thread using Task.Run. + /// + /// The return type of the function. + /// The function to execute. + /// A Task object representing the asynchronous operation. + public Task RunOnThread(Func func) => Task.FromResult(func.Invoke()); +} From da12f568f8e8839887c47a469bea127861dc09d6 Mon Sep 17 00:00:00 2001 From: Alan Rynne Date: Mon, 22 Apr 2024 15:21:55 +0200 Subject: [PATCH 038/261] CNX-9216 Receive - Rhino Geometry Conversions (#3292) * feat: Added ToHost conversions for brep and more curves * feat: More receive conversions * feat: Ellipse conversion + other minor tweaks * feat: Top-level ellipse conversion + nameandrank for arcs Brep surface converter resolution too * feat: PointCloud top-level conversion + IReadOnlyList tweaks * feat: Exclude obvious non-convertible items (for now) from flattened list * feat: XML comments * feat: XML docs for all RawConversion methods * feat: Every POC comment now has a ticket in converter * fix: Added pragma to unfixable warning in necessary part of code * fix: Fix brep and nurbs curve send --- .../Receive/RhinoHostObjectBuilder.cs | 19 +- .../Raw/FlatPointListRawToHostConversion.cs | 17 +- .../Raw/SpeckleArcRawToHostConversion.cs | 25 ++- .../Raw/SpeckleBrepRawToHostConversion.cs | 163 ++++++++++++++++++ .../Raw/SpeckleCircleRawToHostConversion.cs | 60 +++++++ .../Raw/SpeckleEllipseRawToHostConversion.cs | 63 +++++++ .../Raw/SpeckleICurveRawToHostConversion.cs | 58 +++++++ .../Raw/SpeckleIntervalRawToHostConversion.cs | 8 +- .../Raw/SpeckleLineRawToHostConversion.cs | 16 ++ .../Raw/SpeckleMeshRawToHostConversion.cs | 10 +- .../Raw/SpeckleNurbsCurveToHostConversion.cs | 63 +++++++ .../Raw/SpecklePlaneRawToHostConversion.cs | 6 + .../SpecklePointCloudRawToHostConversion.cs | 37 ++++ .../Raw/SpecklePointRawToHostConversion.cs | 17 +- .../SpecklePolyCurveRawToHostConversion.cs | 37 ++++ .../Raw/SpecklePolylineRawToHostConversion.cs | 28 ++- .../Raw/SpeckleSpiralRawToHostConversion.cs | 31 ++++ .../Raw/SpeckleSurfaceRawToHostConversion.cs | 66 +++++++ .../Raw/SpeckleVectorRawToHostConversion.cs | 6 + .../SpeckleBrepToHostBrepConversion.cs | 15 ++ .../SpeckleCircleToHostArcCurveConversion.cs | 15 ++ ...peckleEllipseToHostNurbsCurveConversion.cs | 15 ++ ...kleNurbsCurveToHostNurbsCurveConversion.cs | 15 ++ ...klePointCloudToHostPointCloudConversion.cs | 16 ++ ...ecklePolycurveToHostPolycurveConversion.cs | 16 ++ .../ToSpeckle/Raw/BrepToSpeckleConverter.cs | 4 + .../ToSpeckle/Raw/NurbsCurveConverter.cs | 4 +- 27 files changed, 793 insertions(+), 37 deletions(-) create mode 100644 DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpeckleBrepRawToHostConversion.cs create mode 100644 DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpeckleCircleRawToHostConversion.cs create mode 100644 DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpeckleEllipseRawToHostConversion.cs create mode 100644 DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpeckleICurveRawToHostConversion.cs create mode 100644 DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpeckleNurbsCurveToHostConversion.cs create mode 100644 DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpecklePointCloudRawToHostConversion.cs create mode 100644 DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpecklePolyCurveRawToHostConversion.cs create mode 100644 DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpeckleSpiralRawToHostConversion.cs create mode 100644 DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpeckleSurfaceRawToHostConversion.cs create mode 100644 DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/SpeckleBrepToHostBrepConversion.cs create mode 100644 DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/SpeckleCircleToHostArcCurveConversion.cs create mode 100644 DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/SpeckleEllipseToHostNurbsCurveConversion.cs create mode 100644 DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/SpeckleNurbsCurveToHostNurbsCurveConversion.cs create mode 100644 DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/SpecklePointCloudToHostPointCloudConversion.cs create mode 100644 DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/SpecklePolycurveToHostPolycurveConversion.cs diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Receive/RhinoHostObjectBuilder.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Receive/RhinoHostObjectBuilder.cs index 9c467b5c50..56608f58b5 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Receive/RhinoHostObjectBuilder.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Receive/RhinoHostObjectBuilder.cs @@ -1,7 +1,8 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Threading; +using Objects.Other; using Rhino; using Rhino.DocObjects; using Rhino.Geometry; @@ -40,7 +41,7 @@ CancellationToken cancellationToken var objectsToConvert = rootObject .TraverseWithPath(obj => obj is not Collection) - .Where(obj => obj.Item2 is not Collection); + .Where(obj => obj.Item2 is not Collection && obj.Item2 is not DisplayStyle && obj.Item2 is not RenderMaterial); var convertedIds = BakeObjects(objectsToConvert, baseLayerName, onOperationProgressed, cancellationToken); @@ -101,17 +102,15 @@ CancellationToken cancellationToken var converted = _toHostConverter.Convert(baseObj); - if (converted is GeometryBase newObject) + if (converted is not GeometryBase newObject) { - var newObjectGuid = doc.Objects.Add(newObject, new ObjectAttributes { LayerIndex = layerIndex }); - newObjectIds.Add(newObjectGuid.ToString()); - continue; + throw new SpeckleConversionException( + $"Unexpected result from conversion: Expected {nameof(GeometryBase)} but instead got {converted.GetType().Name}" + ); } - // POC: else something weird happened? a block maybe? We should stop on our tracks if we reach this. - throw new SpeckleException( - $"Unexpected result from conversion: Expected {nameof(GeometryBase)} but instead got {converted.GetType().Name}" - ); + var newObjectGuid = doc.Objects.Add(newObject, new ObjectAttributes { LayerIndex = layerIndex }); + newObjectIds.Add(newObjectGuid.ToString()); } catch (Exception e) when (!e.IsFatal()) { diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/FlatPointListRawToHostConversion.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/FlatPointListRawToHostConversion.cs index b7b49cc2c2..24a344b6b3 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/FlatPointListRawToHostConversion.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/FlatPointListRawToHostConversion.cs @@ -4,9 +4,22 @@ namespace Speckle.Converters.Rhino7.ToHost.Raw; -public class FlatPointListRawToHostConversion : IRawConversion, Point3dList> +/// +/// Converts a flat list of raw double values to a Point3dList. +/// +public class FlatPointListRawToHostConversion : IRawConversion, Point3dList> { - public Point3dList RawConvert(IList target) + /// + /// Converts a flat list of raw double values to a Point3dList. + /// + /// The flat list of raw double values + /// A Point3dList object that represents the converted points + /// + /// Assumes that the amount of numbers contained on the list is a multiple of 3, + /// with the numbers being coordinates of each point in the format {x1, y1, z1, x2, y2, z2, ..., xN, yN, zN} + /// + /// Throws when the input list count is not a multiple of 3. + public Point3dList RawConvert(IReadOnlyList target) { if (target.Count % 3 != 0) { diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpeckleArcRawToHostConversion.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpeckleArcRawToHostConversion.cs index c50618057d..f9f341ec7a 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpeckleArcRawToHostConversion.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpeckleArcRawToHostConversion.cs @@ -2,6 +2,9 @@ namespace Speckle.Converters.Rhino7.ToHost.Raw; +/// +/// Converts a SpeckleArcRaw object to a Rhino.Geometry.Arc object or Rhino.Geometry.ArcCurve object. +/// public class SpeckleArcRawToHostConversion : IRawConversion, IRawConversion { private readonly IRawConversion _pointConverter; @@ -16,6 +19,13 @@ public SpeckleArcRawToHostConversion( this._intervalConverter = intervalConverter; } + /// + /// Converts a object to a object. + /// + /// The Speckle Arc object to convert. + /// The converted object. + /// ⚠️ This conversion does NOT perform scaling. + ///
⚠️ This method does not preserve the original curve domain
public RG.Arc RawConvert(SOG.Arc target) { var rhinoArc = new RG.Arc( @@ -28,16 +38,17 @@ public RG.Arc RawConvert(SOG.Arc target) // POC: CNX-9271 Potential code-smell by directly implementing the interface. We should discuss this further but // since we're using the interfaces instead of the direct type, this may not be an issue. + /// + /// Converts a object to a object. + /// + /// The object to convert. + /// The converted object. + /// ⚠️ This conversion does NOT perform scaling. + ///
⚠️ Converting to instead of preserves the domain of the curve.
RG.ArcCurve IRawConversion.RawConvert(SOG.Arc target) { var rhinoArc = RawConvert(target); - var arcCurve = new RG.ArcCurve(rhinoArc); - - if (target.domain != null) - { - arcCurve.Domain = _intervalConverter.RawConvert(target.domain); - } - + var arcCurve = new RG.ArcCurve(rhinoArc) { Domain = _intervalConverter.RawConvert(target.domain) }; return arcCurve; } } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpeckleBrepRawToHostConversion.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpeckleBrepRawToHostConversion.cs new file mode 100644 index 0000000000..397b554872 --- /dev/null +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpeckleBrepRawToHostConversion.cs @@ -0,0 +1,163 @@ +using Objects; +using Rhino; +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; + +namespace Speckle.Converters.Rhino7.ToHost.Raw; + +public class SpeckleBrepRawToHostConversion : IRawConversion +{ + private readonly IConversionContextStack _contextStack; + private readonly IRawConversion _curveConverter; + private readonly IRawConversion _surfaceConverter; + private readonly IRawConversion _pointConverter; + private readonly IRawConversion _intervalConverter; + + public SpeckleBrepRawToHostConversion( + IConversionContextStack contextStack, + IRawConversion curveConverter, + IRawConversion surfaceConverter, + IRawConversion pointConverter, + IRawConversion intervalConverter + ) + { + _contextStack = contextStack; + _curveConverter = curveConverter; + _surfaceConverter = surfaceConverter; + _pointConverter = pointConverter; + _intervalConverter = intervalConverter; + } + + /// + /// Converts a Speckle to a Rhino . + /// + /// + /// This method converts a Speckle Brep object to its equivalent Rhino Brep representation. + /// The conversion process includes converting individual curves, trims, surfaces, and vertices. + /// The resulting Rhino Brep is returned. + /// Note that the conversion does not cover all edge cases in Brep structures, therefore it is recommended to review the resulting Brep for robustness improvement. + /// + /// The Speckle Brep object to be converted. + /// The equivalent Rhino Brep object. + /// ⚠️ This conversion does NOT perform scaling. + public RG.Brep RawConvert(SOG.Brep target) + { + var tolerance = _contextStack.Current.Document.ModelAbsoluteTolerance; + + var rhinoBrep = new RG.Brep(); + + // Geometry goes in first, always. Order doesn't matter. + target.Curve3D.ForEach(curve => rhinoBrep.AddEdgeCurve(_curveConverter.RawConvert(curve))); + target.Curve2D.ForEach(curve => rhinoBrep.AddTrimCurve(_curveConverter.RawConvert(curve))); + target.Surfaces.ForEach(surface => rhinoBrep.AddSurface(_surfaceConverter.RawConvert(surface))); + target.Vertices.ForEach(vertex => rhinoBrep.Vertices.Add(_pointConverter.RawConvert(vertex), tolerance)); + + // Order matters, first edges, then faces, finally loops. + target.Edges.ForEach(edge => ConvertSpeckleBrepEdge(rhinoBrep, edge, tolerance)); + target.Faces.ForEach(face => ConvertSpeckleBrepFace(rhinoBrep, face)); + target.Loops.ForEach(loop => ConvertSpeckleBrepLoop(rhinoBrep, loop, tolerance)); + + rhinoBrep.Repair(tolerance); // Repair fixes tolerance issues with the Brep if the scaling lead to some rounding error. + + return rhinoBrep; + } + + /// + /// Converts a Speckle to a Rhino and adds it to the provided . + /// + /// + /// A consists of individual trims. There are special cases for singular trims and trims with defined edge indices. + /// Note that edge cases in Brep structures are not fully covered by this method and should be reviewed for robustness improvement. + /// This operation alters the state of the provided by adding a new loop. + /// + /// The where the new loop will be added. + /// The to be converted and added to . + /// The tolerance factor used when adding trims and setting their tolerances. + private void ConvertSpeckleBrepLoop(RG.Brep rhinoBrep, SOG.BrepLoop speckleLoop, double tol) + { + var f = rhinoBrep.Faces[speckleLoop.FaceIndex]; + + rhinoBrep.Loops.Add((RG.BrepLoopType)speckleLoop.Type, f); + + // POC: This works but it doesn't fully cover all Brep edge cases and could be the cause of some of our failed Rhino->Rhino breps. + // We should check Rhino.Inside as they have similar code structure. + speckleLoop.Trims + .ToList() + .ForEach(trim => + { + RG.BrepTrim rhTrim; + if (trim.EdgeIndex != -1) + { + rhTrim = rhinoBrep.Trims.Add( + rhinoBrep.Edges[trim.EdgeIndex], + trim.IsReversed, + rhinoBrep.Loops[trim.LoopIndex], + trim.CurveIndex + ); + } + else if (trim.TrimType == SOG.BrepTrimType.Singular) + { + rhTrim = rhinoBrep.Trims.AddSingularTrim( + rhinoBrep.Vertices[trim.EndIndex], + rhinoBrep.Loops[trim.LoopIndex], + (RG.IsoStatus)trim.IsoStatus, + trim.CurveIndex + ); + } + else + { + rhTrim = rhinoBrep.Trims.Add(trim.IsReversed, rhinoBrep.Loops[trim.LoopIndex], trim.CurveIndex); + } + + rhTrim.IsoStatus = (RG.IsoStatus)trim.IsoStatus; + rhTrim.TrimType = (RG.BrepTrimType)trim.TrimType; + rhTrim.SetTolerances(tol, tol); + }); + } + + /// + /// Converts a Speckle BrepEdge into a Rhino BrepEdge within a Rhino Brep. + /// + /// The Rhino Brep to which the converted BrepEdge will be added. + /// The Speckle BrepEdge to convert. + /// The tolerance for the conversion. + /// + /// If the domain of the Speckle BrepEdge is null or matches the curve's domain, it is assumed that the edge + /// is untrimmed, and hence added directly as a reference to the curve it points to. + /// If the edge is trimmed, it is added based on vertices and subdomain using the supplied tolerance + /// + private void ConvertSpeckleBrepEdge(RG.Brep rhinoBrep, SOG.BrepEdge speckleEdge, double tolerance) + { + if ( + speckleEdge.Domain == null + || speckleEdge.Domain.start == speckleEdge.Curve.domain.start + && speckleEdge.Domain.end == speckleEdge.Curve.domain.end + ) + { + // The edge is untrimmed, we can add it directly as a reference to the curve it points to. + rhinoBrep.Edges.Add(speckleEdge.Curve3dIndex); + } + else + { + // The edge is trimmed, must be added based on vertices and subdomain + rhinoBrep.Edges.Add( + speckleEdge.StartIndex, + speckleEdge.EndIndex, + speckleEdge.Curve3dIndex, + _intervalConverter.RawConvert(speckleEdge.Domain), + tolerance + ); + } + } + + /// + /// Converts a into a and adds it to the provided . + /// + /// The Rhinoceros brep geometry to which the converted face is added. + /// The Speckle brep face to be converted and added. + private void ConvertSpeckleBrepFace(RG.Brep rhinoBrep, SOG.BrepFace speckleFace) + { + var f = rhinoBrep.Faces.Add(speckleFace.SurfaceIndex); + f.OrientationIsReversed = speckleFace.OrientationReversed; + } +} diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpeckleCircleRawToHostConversion.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpeckleCircleRawToHostConversion.cs new file mode 100644 index 0000000000..33c796f9aa --- /dev/null +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpeckleCircleRawToHostConversion.cs @@ -0,0 +1,60 @@ +using Speckle.Converters.Common.Objects; + +namespace Speckle.Converters.Rhino7.ToHost.Raw; + +/// +/// This class is responsible for converting a into and objects. +/// Implements the interface, +/// providing implementation for to and conversion. +/// +public class SpeckleCircleRawToHostConversion + : IRawConversion, + IRawConversion +{ + private readonly IRawConversion _planeConverter; + private readonly IRawConversion _intervalConverter; + + /// + /// Constructs a new instance of the class. + /// + /// + /// An implementation of used to convert into . + /// + /// + /// An implementation of used to convert into . + /// + public SpeckleCircleRawToHostConversion( + IRawConversion intervalConverter, + IRawConversion planeConverter + ) + { + _intervalConverter = intervalConverter; + _planeConverter = planeConverter; + } + + /// + /// Converts the given object into a object. + /// + /// The object to convert. + /// The resulting object. + /// + /// Thrown when the radius of the given object is null. + /// + /// ⚠️ This conversion does NOT perform scaling. + ///
⚠️ This conversion does not preserve the curve domain. If you need it preserved you must request a conversion to conversion instead
+ public RG.Circle RawConvert(SOG.Circle target) + { + if (target.radius == null) + { + // POC: CNX-9272 Circle radius being nullable makes no sense + throw new ArgumentNullException(nameof(target), "Circle radius cannot be null"); + } + + var plane = _planeConverter.RawConvert(target.plane); + var radius = target.radius.Value; + return new RG.Circle(plane, radius); + } + + RG.ArcCurve IRawConversion.RawConvert(SOG.Circle target) => + new(RawConvert(target)) { Domain = _intervalConverter.RawConvert(target.domain) }; +} diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpeckleEllipseRawToHostConversion.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpeckleEllipseRawToHostConversion.cs new file mode 100644 index 0000000000..1435c4f2ef --- /dev/null +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpeckleEllipseRawToHostConversion.cs @@ -0,0 +1,63 @@ +using Speckle.Converters.Common.Objects; + +namespace Speckle.Converters.Rhino7.ToHost.Raw; + +public class SpeckleEllipseRawToHostConversion + : IRawConversion, + IRawConversion +{ + private readonly IRawConversion _planeConverter; + private readonly IRawConversion _intervalConverter; + + public SpeckleEllipseRawToHostConversion( + IRawConversion planeConverter, + IRawConversion intervalConverter + ) + { + _planeConverter = planeConverter; + _intervalConverter = intervalConverter; + } + + /// + /// Converts an instance of to an while preserving geometric properties. + /// + /// The instance to be converted. + /// The resulting after conversion. + /// Thrown when or properties are null. + /// ⚠️ This conversion does NOT perform scaling. + ///
⚠️ This conversion does not preserve the curve domain. If you need it preserved you must request a conversion to conversion instead
+ public RG.Ellipse RawConvert(SOG.Ellipse target) + { + if (!target.firstRadius.HasValue || !target.secondRadius.HasValue) + { + throw new InvalidOperationException($"Ellipses cannot have null radii"); + } + + return new RG.Ellipse( + _planeConverter.RawConvert(target.plane), + target.firstRadius.Value, + target.secondRadius.Value + ); + } + + /// + /// Converts the provided into a representation. + /// + /// The to convert. + /// + /// A that represents the provided . + /// + RG.NurbsCurve IRawConversion.RawConvert(SOG.Ellipse target) + { + var rhinoEllipse = RawConvert(target); + var rhinoNurbsEllipse = rhinoEllipse.ToNurbsCurve(); + rhinoNurbsEllipse.Domain = _intervalConverter.RawConvert(target.domain); + + if (target.trimDomain != null) + { + rhinoNurbsEllipse = rhinoNurbsEllipse.Trim(_intervalConverter.RawConvert(target.trimDomain)).ToNurbsCurve(); + } + + return rhinoNurbsEllipse; + } +} diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpeckleICurveRawToHostConversion.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpeckleICurveRawToHostConversion.cs new file mode 100644 index 0000000000..fda7dc8fb0 --- /dev/null +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpeckleICurveRawToHostConversion.cs @@ -0,0 +1,58 @@ +using Objects; +using Speckle.Converters.Common.Objects; + +namespace Speckle.Converters.Rhino7.ToHost.Raw; + +public class SpeckleICurveRawToHostConversion : IRawConversion +{ + private readonly IRawConversion _lineConverter; + private readonly IRawConversion _arcConverter; + private readonly IRawConversion _ellipseConverter; + private readonly IRawConversion _spiralConverter; + private readonly IRawConversion _circleConverter; + private readonly IRawConversion _polylineConverter; + private readonly IRawConversion _polyCurveConverter; + private readonly IRawConversion _nurbsCurveConverter; + + public SpeckleICurveRawToHostConversion( + IRawConversion lineConverter, + IRawConversion arcConverter, + IRawConversion ellipseConverter, + IRawConversion spiralConverter, + IRawConversion circleConverter, + IRawConversion polylineConverter, + IRawConversion polyCurveConverter, + IRawConversion nurbsCurveConverter + ) + { + _lineConverter = lineConverter; + _arcConverter = arcConverter; + _ellipseConverter = ellipseConverter; + _spiralConverter = spiralConverter; + _circleConverter = circleConverter; + _polylineConverter = polylineConverter; + _polyCurveConverter = polyCurveConverter; + _nurbsCurveConverter = nurbsCurveConverter; + } + + /// + /// Converts a given ICurve object to an RG.Curve object. + /// + /// The ICurve object to convert. + /// The converted RG.Curve object. + /// Thrown when the conversion is not supported for the given type of curve. + /// ⚠️ This conversion does NOT perform scaling. + public RG.Curve RawConvert(ICurve target) => + target switch + { + SOG.Line line => _lineConverter.RawConvert(line), + SOG.Arc arc => _arcConverter.RawConvert(arc), + SOG.Circle circle => _circleConverter.RawConvert(circle), + SOG.Ellipse ellipse => _ellipseConverter.RawConvert(ellipse), + SOG.Spiral spiral => _spiralConverter.RawConvert(spiral), + SOG.Polyline polyline => _polylineConverter.RawConvert(polyline), + SOG.Curve curve => _nurbsCurveConverter.RawConvert(curve), + SOG.Polycurve polyCurve => _polyCurveConverter.RawConvert(polyCurve), + _ => throw new NotSupportedException($"Unable to convert curves of type {target.GetType().Name}") + }; +} diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpeckleIntervalRawToHostConversion.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpeckleIntervalRawToHostConversion.cs index 60a838f507..fa5f34acf1 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpeckleIntervalRawToHostConversion.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpeckleIntervalRawToHostConversion.cs @@ -4,6 +4,13 @@ namespace Speckle.Converters.Rhino7.ToHost.Raw; public class SpeckleIntervalRawToHostConversion : IRawConversion { + /// + /// Converts a Speckle Interval object to a Rhino.Geometry.Interval object. + /// + /// The Speckle Interval to convert. + /// The converted Rhino.Geometry.Interval object. + /// Thrown when the start or end value of the Interval is null. + /// ⚠️ This conversion does NOT perform scaling. public RG.Interval RawConvert(SOP.Interval target) { if (!target.start.HasValue || !target.end.HasValue) // POC: CNX-9272 Interval start and end being nullable makes no sense. @@ -11,7 +18,6 @@ public RG.Interval RawConvert(SOP.Interval target) throw new ArgumentException("Interval start/end cannot be null"); } - // POC: Interval conversions used to have a unit input, but it was only used in `Box` so we can deal with that on the parent. return new RG.Interval(target.start.Value, target.end.Value); } } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpeckleLineRawToHostConversion.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpeckleLineRawToHostConversion.cs index 1428e928fc..d5aa8a950f 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpeckleLineRawToHostConversion.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpeckleLineRawToHostConversion.cs @@ -11,8 +11,24 @@ public SpeckleLineRawToHostConversion(IRawConversion poin _pointConverter = pointConverter; } + /// + /// Converts a Speckle Line object to a Rhino Line object. + /// + /// The Speckle Line object to convert. + /// Returns the resulting Rhino Line object. + /// ⚠️ This conversion does NOT perform scaling. + /// + ///
⚠️ This conversion does not preserve the curve domain. + /// If you need it preserved you must request a conversion to + /// conversion instead + ///
public RG.Line RawConvert(SOG.Line target) => new(_pointConverter.RawConvert(target.start), _pointConverter.RawConvert(target.end)); + /// + /// Converts a Speckle Line object to a Rhino LineCurve object. + /// + /// The Speckle Line object to convert. + /// Returns the resulting Rhino LineCurve object. RG.LineCurve IRawConversion.RawConvert(SOG.Line target) => new(RawConvert(target)); } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpeckleMeshRawToHostConversion.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpeckleMeshRawToHostConversion.cs index 4b39a78fea..8012c6f33d 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpeckleMeshRawToHostConversion.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpeckleMeshRawToHostConversion.cs @@ -7,13 +7,19 @@ namespace Speckle.Converters.Rhino7.ToHost.Raw; public class SpeckleMeshRawToHostConversion : IRawConversion { - private readonly IRawConversion, Point3dList> _pointListConverter; + private readonly IRawConversion, Point3dList> _pointListConverter; - public SpeckleMeshRawToHostConversion(IRawConversion, Point3dList> pointListConverter) + public SpeckleMeshRawToHostConversion(IRawConversion, Point3dList> pointListConverter) { _pointListConverter = pointListConverter; } + /// + /// Converts a Speckle mesh object to a Rhino mesh object. + /// + /// The Speckle mesh object to convert. + /// A Rhino mesh object converted from the Speckle mesh. + /// ⚠️ This conversion does NOT perform scaling. public RG.Mesh RawConvert(SOG.Mesh target) { target.AlignVerticesWithTexCoordsByIndex(); diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpeckleNurbsCurveToHostConversion.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpeckleNurbsCurveToHostConversion.cs new file mode 100644 index 0000000000..6d72519ba7 --- /dev/null +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpeckleNurbsCurveToHostConversion.cs @@ -0,0 +1,63 @@ +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; + +namespace Speckle.Converters.Rhino7.ToHost.Raw; + +public class SpeckleNurbsCurveToHostConversion : IRawConversion +{ + private readonly IRawConversion _pointConverter; + private readonly IRawConversion _intervalConverter; + + public SpeckleNurbsCurveToHostConversion( + IRawConversion pointConverter, + IRawConversion intervalConverter + ) + { + _pointConverter = pointConverter; + _intervalConverter = intervalConverter; + } + + /// + /// Converts a Speckle NurbsCurve object to a Rhino NurbsCurve object. + /// + /// The Speckle NurbsCurve object to be converted. + /// The converted Rhino NurbsCurve object. + /// Thrown when the conversion fails. + /// ⚠️ This conversion does NOT perform scaling. + public RG.NurbsCurve RawConvert(SOG.Curve target) + { + var rhinoPoints = target.GetPoints().Select(o => _pointConverter.RawConvert(o)).ToList(); + + RG.NurbsCurve? nurbsCurve = RG.NurbsCurve.Create(false, target.degree, rhinoPoints); + +#pragma warning disable CA1508 + if (nurbsCurve == null) // POC: CNX-9272 Nullability is wrong here, cannot remove this warning but code is required. +#pragma warning restore CA1508 + { + throw new SpeckleConversionException("Attempt to create Nurbs Curve failed with no explanation from Rhino"); + } + + for (int j = 0; j < nurbsCurve.Points.Count; j++) + { + nurbsCurve.Points.SetPoint(j, rhinoPoints[j], target.weights[j]); + } + + // check knot multiplicity to match Rhino's standard of (# control points + degree - 1) + // skip extra knots at start & end if knot multiplicity is (# control points + degree + 1) + int extraKnots = target.knots.Count - nurbsCurve.Knots.Count; + for (int j = 0; j < nurbsCurve.Knots.Count; j++) + { + if (extraKnots == 2) + { + nurbsCurve.Knots[j] = target.knots[j + 1]; + } + else + { + nurbsCurve.Knots[j] = target.knots[j]; + } + } + + nurbsCurve.Domain = _intervalConverter.RawConvert(target.domain); + return nurbsCurve; + } +} diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpecklePlaneRawToHostConversion.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpecklePlaneRawToHostConversion.cs index 04195b8cb4..fa2d4b55e9 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpecklePlaneRawToHostConversion.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpecklePlaneRawToHostConversion.cs @@ -16,6 +16,12 @@ public SpecklePlaneRawToHostConversion( _vectorConverter = vectorConverter; } + /// + /// Converts a Speckle Plane object to a Rhino Plane object. + /// + /// The Speckle Plane object to be converted. + /// The converted Rhino Plane object. + /// ⚠️ This conversion does NOT perform scaling. public RG.Plane RawConvert(SOG.Plane target) => new( _pointConverter.RawConvert(target.origin), diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpecklePointCloudRawToHostConversion.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpecklePointCloudRawToHostConversion.cs new file mode 100644 index 0000000000..a56a940343 --- /dev/null +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpecklePointCloudRawToHostConversion.cs @@ -0,0 +1,37 @@ +using System.Drawing; +using Rhino.Collections; +using Speckle.Converters.Common.Objects; + +namespace Speckle.Converters.Rhino7.ToHost.Raw; + +public class SpecklePointCloudRawToHostConversion : IRawConversion +{ + private readonly IRawConversion, Point3dList> _pointListConverter; + + public SpecklePointCloudRawToHostConversion(IRawConversion, Point3dList> pointListConverter) + { + _pointListConverter = pointListConverter; + } + + /// + /// Converts raw Speckle point cloud data to Rhino PointCloud object. + /// + /// The raw Speckle Pointcloud object to convert. + /// The converted Rhino PointCloud object. + /// ⚠️ This conversion does NOT perform scaling. + public RG.PointCloud RawConvert(SOG.Pointcloud target) + { + var rhinoPoints = _pointListConverter.RawConvert(target.points); + var rhinoPointCloud = new RG.PointCloud(rhinoPoints); + + if (target.colors.Count == rhinoPoints.Count) + { + for (int i = 0; i < rhinoPoints.Count; i++) + { + rhinoPointCloud[i].Color = Color.FromArgb(target.colors[i]); + } + } + + return rhinoPointCloud; + } +} diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpecklePointRawToHostConversion.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpecklePointRawToHostConversion.cs index 146d7f4008..74115b2080 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpecklePointRawToHostConversion.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpecklePointRawToHostConversion.cs @@ -6,10 +6,19 @@ public class SpecklePointRawToHostConversion : IRawConversion, IRawConversion { - public RG.Point3d RawConvert(SOG.Point target) - { - return new RG.Point3d(target.x, target.y, target.z); - } + /// + /// Converts a Speckle Point object to a Rhino Point3d object. + /// + /// The Speckle Point object to convert. + /// The converted Rhino Point3d object. + /// ⚠️ This conversion does NOT perform scaling. + public RG.Point3d RawConvert(SOG.Point target) => new(target.x, target.y, target.z); + /// + /// Converts a Speckle Point object to a Rhino Point object. + /// + /// The Speckle Point object to convert. + /// The converted Rhino Point object. + /// ⚠️ This conversion does NOT perform scaling. RG.Point IRawConversion.RawConvert(SOG.Point target) => new(RawConvert(target)); } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpecklePolyCurveRawToHostConversion.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpecklePolyCurveRawToHostConversion.cs new file mode 100644 index 0000000000..1ef9619270 --- /dev/null +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpecklePolyCurveRawToHostConversion.cs @@ -0,0 +1,37 @@ +using Objects; +using Speckle.Converters.Common.Objects; + +namespace Speckle.Converters.Rhino7.ToHost.Raw; + +public class SpecklePolyCurveRawToHostConversion : IRawConversion +{ + public IRawConversion? CurveConverter { get; set; } // POC: CNX-9311 Circular dependency injected by the container using property. + + private readonly IRawConversion _intervalConverter; + + public SpecklePolyCurveRawToHostConversion(IRawConversion intervalConverter) + { + _intervalConverter = intervalConverter; + } + + /// + /// Converts a SpecklePolyCurve object to a Rhino PolyCurve object. + /// + /// The SpecklePolyCurve object to convert. + /// The converted Rhino PolyCurve object. + /// ⚠️ This conversion does NOT perform scaling. + public RG.PolyCurve RawConvert(SOG.Polycurve target) + { + RG.PolyCurve result = new(); + + foreach (var segment in target.segments) + { + var childCurve = CurveConverter!.RawConvert(segment); + result.Append(childCurve); + } + + result.Domain = _intervalConverter.RawConvert(target.domain); + + return result; + } +} diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpecklePolylineRawToHostConversion.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpecklePolylineRawToHostConversion.cs index 48acb8e897..1305a7ac1c 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpecklePolylineRawToHostConversion.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpecklePolylineRawToHostConversion.cs @@ -7,11 +7,11 @@ public class SpecklePolylineRawToHostConversion : IRawConversion, IRawConversion { - private readonly IRawConversion, Point3dList> _pointListConverter; + private readonly IRawConversion, Point3dList> _pointListConverter; private readonly IRawConversion _intervalConverter; public SpecklePolylineRawToHostConversion( - IRawConversion, Point3dList> pointListConverter, + IRawConversion, Point3dList> pointListConverter, IRawConversion intervalConverter ) { @@ -19,6 +19,17 @@ public SpecklePolylineRawToHostConversion( _intervalConverter = intervalConverter; } + /// + /// Converts a Speckle polyline object to a Rhino Polyline object. + /// + /// The Speckle polyline object to be converted. + /// The converted Rhino Polyline object. + /// ⚠️ This conversion does NOT perform scaling. + /// + ///
⚠️ This conversion does not preserve the curve domain. + /// If you need it preserved you must request a conversion to + /// conversion instead + ///
public RG.Polyline RawConvert(SOG.Polyline target) { var points = _pointListConverter.RawConvert(target.value); @@ -35,15 +46,16 @@ public RG.Polyline RawConvert(SOG.Polyline target) // POC: CNX-9271 Potential code-smell by directly implementing the interface. We should discuss this further but // since we're using the interfaces instead of the direct type, this may not be an issue. + /// + /// Converts a Speckle polyline object to a Rhino Polyline object. + /// + /// The Speckle polyline object to be converted. + /// The converted Rhino Polyline object. + /// ⚠️ This conversion does NOT perform scaling. RG.PolylineCurve IRawConversion.RawConvert(SOG.Polyline target) { var poly = RawConvert(target).ToPolylineCurve(); - - if (target.domain != null) - { - poly.Domain = _intervalConverter.RawConvert(target.domain); - } - + poly.Domain = _intervalConverter.RawConvert(target.domain); return poly; } } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpeckleSpiralRawToHostConversion.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpeckleSpiralRawToHostConversion.cs new file mode 100644 index 0000000000..6756bf73c3 --- /dev/null +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpeckleSpiralRawToHostConversion.cs @@ -0,0 +1,31 @@ +using Speckle.Converters.Common.Objects; + +namespace Speckle.Converters.Rhino7.ToHost.Raw; + +public class SpeckleSpiralRawToHostConversion : IRawConversion +{ + private readonly IRawConversion _polylineConverter; + private readonly IRawConversion _intervalConverter; + + public SpeckleSpiralRawToHostConversion( + IRawConversion polylineConverter, + IRawConversion intervalConverter + ) + { + _polylineConverter = polylineConverter; + _intervalConverter = intervalConverter; + } + + /// + /// Converts a Speckle Spiral object to a Rhino PolylineCurve object. + /// + /// The Speckle Spiral object to be converted. + /// A Rhino PolylineCurve object. + /// ⚠️ This conversion does NOT perform scaling. + public RG.PolylineCurve RawConvert(SOG.Spiral target) + { + var result = _polylineConverter.RawConvert(target.displayValue); + result.Domain = _intervalConverter.RawConvert(target.domain); + return result; + } +} diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpeckleSurfaceRawToHostConversion.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpeckleSurfaceRawToHostConversion.cs new file mode 100644 index 0000000000..184941d13d --- /dev/null +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpeckleSurfaceRawToHostConversion.cs @@ -0,0 +1,66 @@ +using Speckle.Converters.Common.Objects; + +namespace Speckle.Converters.Rhino7.ToHost.Raw; + +public class SpeckleSurfaceRawToHostConversion : IRawConversion +{ + /// + /// Converts a raw Speckle surface to a Rhino NURBS surface. + /// + /// The raw Speckle surface to convert. + /// The converted Rhino NURBS surface. + /// ⚠️ This conversion does NOT perform scaling. + public RG.NurbsSurface RawConvert(SOG.Surface target) + { + // Create rhino surface + var points = target.GetControlPoints().ToList(); + + var result = RG.NurbsSurface.Create( + 3, + target.rational, + target.degreeU + 1, + target.degreeV + 1, + points.Count, + points[0].Count + ); + + // Set knot vectors + var correctUKnots = GetCorrectKnots(target.knotsU, target.countU, target.degreeU); + for (int i = 0; i < correctUKnots.Count; i++) + { + result.KnotsU[i] = correctUKnots[i]; + } + + var correctVKnots = GetCorrectKnots(target.knotsV, target.countV, target.degreeV); + for (int i = 0; i < correctVKnots.Count; i++) + { + result.KnotsV[i] = correctVKnots[i]; + } + + // Set control points + for (var i = 0; i < points.Count; i++) + { + for (var j = 0; j < points[i].Count; j++) + { + var pt = points[i][j]; + result.Points.SetPoint(i, j, pt.x * pt.weight, pt.y * pt.weight, pt.z * pt.weight); + result.Points.SetWeight(i, j, pt.weight); + } + } + + // Return surface + return result; + } + + private List GetCorrectKnots(List knots, int controlPointCount, int degree) + { + var correctKnots = knots; + if (knots.Count == controlPointCount + degree + 1) + { + correctKnots.RemoveAt(0); + correctKnots.RemoveAt(correctKnots.Count - 1); + } + + return correctKnots; + } +} diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpeckleVectorRawToHostConversion.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpeckleVectorRawToHostConversion.cs index 463d58437d..7042850fe1 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpeckleVectorRawToHostConversion.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpeckleVectorRawToHostConversion.cs @@ -4,5 +4,11 @@ namespace Speckle.Converters.Rhino7.ToHost.Raw; public class SpeckleVectorRawToHostConversion : IRawConversion { + /// + /// Converts a Speckle.Vector object to a Rhino Vector3d object. + /// + /// The Speckle.Vector to be converted. + /// The converted Rhino Vector3d object. + /// ⚠️ This conversion does NOT perform scaling. public RG.Vector3d RawConvert(SOG.Vector target) => new(target.x, target.y, target.z); } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/SpeckleBrepToHostBrepConversion.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/SpeckleBrepToHostBrepConversion.cs new file mode 100644 index 0000000000..f386b76533 --- /dev/null +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/SpeckleBrepToHostBrepConversion.cs @@ -0,0 +1,15 @@ +using Rhino; +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; + +namespace Speckle.Converters.Rhino7.ToHost.TopLevel; + +[NameAndRankValue(nameof(SOG.Brep), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +public class SpeckleBrepToHostBrepConversion : SpeckleToHostGeometryBaseConversion +{ + public SpeckleBrepToHostBrepConversion( + IConversionContextStack contextStack, + IRawConversion geometryBaseConverter + ) + : base(contextStack, geometryBaseConverter) { } +} diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/SpeckleCircleToHostArcCurveConversion.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/SpeckleCircleToHostArcCurveConversion.cs new file mode 100644 index 0000000000..7d02393663 --- /dev/null +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/SpeckleCircleToHostArcCurveConversion.cs @@ -0,0 +1,15 @@ +using Rhino; +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; + +namespace Speckle.Converters.Rhino7.ToHost.TopLevel; + +[NameAndRankValue(nameof(SOG.Circle), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +public class SpeckleCircleToHostArcCurveConversion : SpeckleToHostGeometryBaseConversion +{ + public SpeckleCircleToHostArcCurveConversion( + IConversionContextStack contextStack, + IRawConversion geometryBaseConverter + ) + : base(contextStack, geometryBaseConverter) { } +} diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/SpeckleEllipseToHostNurbsCurveConversion.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/SpeckleEllipseToHostNurbsCurveConversion.cs new file mode 100644 index 0000000000..a917ae22a1 --- /dev/null +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/SpeckleEllipseToHostNurbsCurveConversion.cs @@ -0,0 +1,15 @@ +using Rhino; +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; + +namespace Speckle.Converters.Rhino7.ToHost.TopLevel; + +[NameAndRankValue(nameof(SOG.Ellipse), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +public class SpeckleEllipseToHostNurbsCurveConversion : SpeckleToHostGeometryBaseConversion +{ + public SpeckleEllipseToHostNurbsCurveConversion( + IConversionContextStack contextStack, + IRawConversion geometryBaseConverter + ) + : base(contextStack, geometryBaseConverter) { } +} diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/SpeckleNurbsCurveToHostNurbsCurveConversion.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/SpeckleNurbsCurveToHostNurbsCurveConversion.cs new file mode 100644 index 0000000000..3cc0b733be --- /dev/null +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/SpeckleNurbsCurveToHostNurbsCurveConversion.cs @@ -0,0 +1,15 @@ +using Rhino; +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; + +namespace Speckle.Converters.Rhino7.ToHost.TopLevel; + +[NameAndRankValue(nameof(SOG.Curve), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +public class SpeckleNurbsCurveToHostNurbsCurveConversion : SpeckleToHostGeometryBaseConversion +{ + public SpeckleNurbsCurveToHostNurbsCurveConversion( + IConversionContextStack contextStack, + IRawConversion geometryBaseConverter + ) + : base(contextStack, geometryBaseConverter) { } +} diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/SpecklePointCloudToHostPointCloudConversion.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/SpecklePointCloudToHostPointCloudConversion.cs new file mode 100644 index 0000000000..874166b5ef --- /dev/null +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/SpecklePointCloudToHostPointCloudConversion.cs @@ -0,0 +1,16 @@ +using Rhino; +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; + +namespace Speckle.Converters.Rhino7.ToHost.TopLevel; + +[NameAndRankValue(nameof(SOG.Pointcloud), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +public class SpecklePointCloudToHostPointCloudConversion + : SpeckleToHostGeometryBaseConversion +{ + public SpecklePointCloudToHostPointCloudConversion( + IConversionContextStack contextStack, + IRawConversion geometryBaseConverter + ) + : base(contextStack, geometryBaseConverter) { } +} diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/SpecklePolycurveToHostPolycurveConversion.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/SpecklePolycurveToHostPolycurveConversion.cs new file mode 100644 index 0000000000..9b1f29c9d1 --- /dev/null +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/SpecklePolycurveToHostPolycurveConversion.cs @@ -0,0 +1,16 @@ +using Rhino; +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; + +namespace Speckle.Converters.Rhino7.ToHost.TopLevel; + +[NameAndRankValue(nameof(SOG.Polycurve), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +public class SpecklePolycurveToHostPolycurveConversion + : SpeckleToHostGeometryBaseConversion +{ + public SpecklePolycurveToHostPolycurveConversion( + IConversionContextStack contextStack, + IRawConversion geometryBaseConverter + ) + : base(contextStack, geometryBaseConverter) { } +} diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/BrepToSpeckleConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/BrepToSpeckleConverter.cs index 0c0c84fd83..ef5e607bc2 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/BrepToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/BrepToSpeckleConverter.cs @@ -99,6 +99,10 @@ public SOG.Brep RawConvert(RG.Brep target) var loops = ConvertBrepLoops(target, speckleBrep); var trims = ConvertBrepTrims(target, speckleBrep); + speckleBrep.Faces = faces; + speckleBrep.Edges = edges; + speckleBrep.Loops = loops; + speckleBrep.Trims = trims; return speckleBrep; } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/NurbsCurveConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/NurbsCurveConverter.cs index b720ca6100..64ffaecc6f 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/NurbsCurveConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/NurbsCurveConverter.cs @@ -55,9 +55,7 @@ public SOG.Curve RawConvert(RG.NurbsCurve target) var myCurve = new SOG.Curve(displayValue, _contextStack.Current.SpeckleUnits) { weights = nurbsCurve.Points.Select(ctp => ctp.Weight).ToList(), - points = nurbsCurve.Points - .SelectMany(ctp => new[] { ctp.Location.X, ctp.Location.Y, ctp.Location.Z, ctp.Weight }) - .ToList(), + points = nurbsCurve.Points.SelectMany(ctp => new[] { ctp.Location.X, ctp.Location.Y, ctp.Location.Z }).ToList(), knots = knots, degree = nurbsCurve.Degree, periodic = nurbsCurve.IsPeriodic, From 2a4c98d711399caac9b2e230078763e7a9b9fddd Mon Sep 17 00:00:00 2001 From: connorivy <43247197+connorivy@users.noreply.github.com> Date: Mon, 22 Apr 2024 14:51:31 -0500 Subject: [PATCH 039/261] CNX-9289 apply unit of work for revit send binding (#3295) * move unit of work to send binding * change to singleton to scoped --------- Co-authored-by: Connor Ivy --- .../Bindings/SendBinding.cs | 16 +++++----- .../DependencyInjection/AutofacUIModule.cs | 5 +--- .../Operations/Send/RootObjectBuilder.cs | 2 +- .../Operations/Send/SendOperation.cs | 29 +++++++------------ .../AutofacRevitConverterModule.cs | 7 +++-- 5 files changed, 25 insertions(+), 34 deletions(-) diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SendBinding.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SendBinding.cs index d4e68c1ee0..b2d778f7ad 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SendBinding.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SendBinding.cs @@ -15,6 +15,7 @@ using Speckle.Connectors.Revit.Operations.Send; using Speckle.Connectors.DUI.Models.Card; using Speckle.Connectors.DUI.Bindings; +using Speckle.Autofac.DependencyInjection; namespace Speckle.Connectors.Revit.Bindings; @@ -26,24 +27,21 @@ internal class SendBinding : RevitBaseBinding, ICancelable, ISendBinding // POC: does it need injecting? private HashSet ChangedObjectIds { get; set; } = new(); - // POC: update SendOperation to be interfaced out and could be shared implementation - // could be abstract implementation - // In the context of the SEND operation, we're only ever expecting ONE conversion - private readonly SendOperation _sendOperation; private readonly IRevitIdleManager _idleManager; + private readonly IUnitOfWorkFactory _unitOfWorkFactory; public SendBinding( IRevitIdleManager idleManager, RevitContext revitContext, RevitDocumentStore store, IBridge bridge, - SendOperation sendOperation + IUnitOfWorkFactory unitOfWorkFactory ) : base("sendBinding", store, bridge, revitContext) { _idleManager = idleManager; + _unitOfWorkFactory = unitOfWorkFactory; Commands = new SendBindingUICommands(bridge); - _sendOperation = sendOperation; // TODO expiry events // TODO filters need refresh events @@ -71,8 +69,6 @@ public void CancelSend(string modelCardId) private async Task HandleSend(string modelCardId) { - // POC: should THIS be where we begin the UoW - // POC: probably the CTS SHOULD be injected as InstancePerLifetimeScope and then // it can be injected where needed instead of passing it around like a bomb :D CancellationTokenSource cts = CancellationManager.InitCancellationTokenSource(modelCardId); @@ -82,7 +78,9 @@ private async Task HandleSend(string modelCardId) throw new InvalidOperationException("No publish model card was found."); } - string versionId = await _sendOperation + using IUnitOfWork sendOperation = _unitOfWorkFactory.Resolve(); + + string versionId = await sendOperation.Service .Execute( modelCard.SendFilter, modelCard.AccountId, diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/AutofacUIModule.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/AutofacUIModule.cs index 503cfcf3e4..bb8c923f64 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/AutofacUIModule.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/AutofacUIModule.cs @@ -68,7 +68,7 @@ protected override void Load(ContainerBuilder builder) builder.RegisterType().As().SingleInstance(); // send operation and dependencies - builder.RegisterType().AsSelf().SingleInstance(); + builder.RegisterType().AsSelf().InstancePerLifetimeScope(); builder.RegisterType().AsSelf().InstancePerLifetimeScope(); builder.RegisterType().AsSelf().InstancePerLifetimeScope(); builder.RegisterType().AsSelf().InstancePerLifetimeScope(); @@ -78,9 +78,6 @@ protected override void Load(ContainerBuilder builder) // register builder.RegisterType().SingleInstance(); - // POC: needs interafacing out - builder.RegisterType().InstancePerLifetimeScope(); - // POC: this can be injected in maybe a common place, perhaps a module in Speckle.Converters.Common.DependencyInjection builder.RegisterType().As().InstancePerLifetimeScope(); diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RootObjectBuilder.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RootObjectBuilder.cs index f29b4ac93f..0045b7a7e4 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RootObjectBuilder.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RootObjectBuilder.cs @@ -18,7 +18,6 @@ public class RootObjectBuilder private readonly RevitConversionContextStack _contextStack; public RootObjectBuilder( - // POC: need to resolve where the UoW should be and whether this is with the SpeckleConverterToSpeckle or something else ISpeckleConverterToSpeckle converter, ToSpeckleConvertedObjectsCache convertedObjectsCache, RevitConversionContextStack contextStack @@ -42,6 +41,7 @@ public Base Build( foreach (Element obj in objects) { + ct.ThrowIfCancellationRequested(); if (_convertedObjectsCache.ContainsBaseConvertedFromId(obj.UniqueId)) { continue; diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/SendOperation.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/SendOperation.cs index 176be23a48..7db122223f 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/SendOperation.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/SendOperation.cs @@ -2,7 +2,6 @@ using Speckle.Core.Models; using System.Threading.Tasks; using System.Threading; -using Speckle.Autofac.DependencyInjection; using Speckle.Connectors.DUI.Models.Card.SendFilter; using Speckle.Converters.RevitShared.Helpers; @@ -10,13 +9,12 @@ namespace Speckle.Connectors.Revit.Operations.Send; public sealed class SendOperation { - // POC: this now feels like a layer of nothing and the caller should be instantiating the things it needs, maybe... - private readonly IUnitOfWorkFactory _unitOfWorkFactory; + private readonly RootObjectBuilder _rootObjectBuilder; private readonly IRootObjectSender _rootObjectSender; - public SendOperation(IUnitOfWorkFactory unitOfWorkFactory, IRootObjectSender rootObjectSender) + public SendOperation(RootObjectBuilder rootObjectBuilder, IRootObjectSender rootObjectSender) { - _unitOfWorkFactory = unitOfWorkFactory; + _rootObjectBuilder = rootObjectBuilder; _rootObjectSender = rootObjectSender; } @@ -39,19 +37,14 @@ public async Task Execute( CancellationToken ct = default ) { - Base commitObject; - using (var rootObjectBuilder = _unitOfWorkFactory.Resolve()) - { - // POC: have changed this as I don't understand the injecting of the ISendFilter when we can just use it here - // it begs the question whether ISendFilter should just be injected into the roo object builder and whether this function needs it at all? - // this class is now so thing I wonder if it should exist at all? - // everything is being passed in from the caller? It feels like the caller should be instantiating the UoW - commitObject = rootObjectBuilder.Service.Build( - new SendSelection(sendFilter.GetObjectIds()), - onOperationProgressed, - ct - ); - } + // POC: have changed this as I don't understand the injecting of the ISendFilter when we can just use it here + // it begs the question whether ISendFilter should just be injected into the roo object builder and whether this function needs it at all? + // this class is now so thing I wonder if it should exist at all? + Base commitObject = _rootObjectBuilder.Build( + new SendSelection(sendFilter.GetObjectIds()), + onOperationProgressed, + ct + ); return await _rootObjectSender .Send(commitObject, accountId, projectId, modelId, onOperationProgressed, ct) diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/AutofacRevitConverterModule.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/AutofacRevitConverterModule.cs index 83e29548b8..b9e2625532 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/AutofacRevitConverterModule.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/AutofacRevitConverterModule.cs @@ -1,5 +1,6 @@ // POC: not sure we should have this here as it attaches us to autofac, maybe a bit prematurely... +using Autodesk.Revit.DB; using Autofac; using Speckle.Autofac.DependencyInjection; using Speckle.Converters.Common; @@ -28,8 +29,10 @@ protected override void Load(ContainerBuilder builder) builder.RegisterType().AsSelf().InstancePerLifetimeScope(); builder.RegisterType().AsSelf().InstancePerLifetimeScope(); - // POC: check with CI speckler but this AsImplementedInterfaces() seems wrong or non-specific here - builder.RegisterType().AsImplementedInterfaces().SingleInstance(); + builder + .RegisterType() + .As>() + .InstancePerLifetimeScope(); builder.RegisterType().AsSelf().InstancePerLifetimeScope(); builder.RegisterType().AsSelf().InstancePerLifetimeScope(); builder.RegisterType().AsSelf().InstancePerLifetimeScope(); From 44e434b253b5ad3c4bfa7988b0cb9b5f8d6ed8f1 Mon Sep 17 00:00:00 2001 From: connorivy <43247197+connorivy@users.noreply.github.com> Date: Mon, 22 Apr 2024 14:52:46 -0500 Subject: [PATCH 040/261] simplify parameter conversion to Speckle (#3289) * simplify parameter conversion to Speckle * rename scalingService * modify projitems --------- Co-authored-by: Connor Ivy --- .../AutofacRevitConverterModule.cs | 3 +- .../Helpers/ParameterValueExtractor.cs | 9 +- .../Geometry/CurveArrayConversionToSpeckle.cs | 4 +- .../Raw/Geometry/LineConversionToSpeckle.cs | 4 +- .../Raw/Geometry/XyzConversionToPoint.cs | 4 +- .../Raw/LevelConversionToSpeckle.cs | 28 +- .../Raw/ParameterConversionToSpeckle.cs | 80 +-- .../Services/CachingService.cs | 87 --- .../Services/ICachingService.cs | 9 - ...gService.cs => ScalingServiceToSpeckle.cs} | 4 +- .../Speckle.Converters.RevitShared.projitems | 4 +- .../GeneratedTests.g.cs | 528 ++++++++++++++++++ 12 files changed, 572 insertions(+), 192 deletions(-) delete mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Services/CachingService.cs delete mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Services/ICachingService.cs rename DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Services/{ToSpeckleScalingService.cs => ScalingServiceToSpeckle.cs} (91%) diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/AutofacRevitConverterModule.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/AutofacRevitConverterModule.cs index b9e2625532..dabdadf2df 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/AutofacRevitConverterModule.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/AutofacRevitConverterModule.cs @@ -26,7 +26,7 @@ protected override void Load(ContainerBuilder builder) .SingleInstance(); // POC: do we need ToSpeckleScalingService as is, do we need to interface it out? - builder.RegisterType().AsSelf().InstancePerLifetimeScope(); + builder.RegisterType().AsSelf().InstancePerLifetimeScope(); builder.RegisterType().AsSelf().InstancePerLifetimeScope(); builder @@ -35,7 +35,6 @@ protected override void Load(ContainerBuilder builder) .InstancePerLifetimeScope(); builder.RegisterType().AsSelf().InstancePerLifetimeScope(); builder.RegisterType().AsSelf().InstancePerLifetimeScope(); - builder.RegisterType().AsSelf().InstancePerLifetimeScope(); builder.RegisterType().AsSelf().InstancePerLifetimeScope(); builder.RegisterType().AsSelf().InstancePerLifetimeScope(); builder.RegisterType().AsSelf().InstancePerLifetimeScope(); diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/ParameterValueExtractor.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/ParameterValueExtractor.cs index a6491782b5..ee2cab49d3 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/ParameterValueExtractor.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/ParameterValueExtractor.cs @@ -10,16 +10,21 @@ namespace Speckle.Converters.RevitShared.Helpers; // maybe also better as an extension method, but maybe is fine? public class ParameterValueExtractor { - private readonly ToSpeckleScalingService _scalingService; + private readonly ScalingServiceToSpeckle _scalingService; private readonly Dictionary> _uniqueIdToUsedParameterSetMap = new(); - public ParameterValueExtractor(ToSpeckleScalingService scalingService) + public ParameterValueExtractor(ScalingServiceToSpeckle scalingService) { _scalingService = scalingService; } public object? GetValue(Parameter parameter) { + if (!parameter.HasValue) + { + return null; + } + return parameter.StorageType switch { StorageType.Double => GetValueAsDouble(parameter), diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/CurveArrayConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/CurveArrayConversionToSpeckle.cs index dd79511d59..f286e47828 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/CurveArrayConversionToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/CurveArrayConversionToSpeckle.cs @@ -10,12 +10,12 @@ namespace Speckle.Converters.RevitShared.ToSpeckle; public sealed class CurveArrayConversionToSpeckle : IRawConversion { private readonly RevitConversionContextStack _contextStack; - private readonly ToSpeckleScalingService _scalingService; + private readonly ScalingServiceToSpeckle _scalingService; private readonly IRawConversion _curveConverter; public CurveArrayConversionToSpeckle( RevitConversionContextStack contextStack, - ToSpeckleScalingService scalingService, + ScalingServiceToSpeckle scalingService, IRawConversion curveConverter ) { diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/LineConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/LineConversionToSpeckle.cs index e920ab5632..f568f1ea08 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/LineConversionToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/LineConversionToSpeckle.cs @@ -9,12 +9,12 @@ public class LineConversionToSpeckle : IRawConversion { private readonly RevitConversionContextStack _contextStack; private readonly IRawConversion _xyzToPointConverter; - private readonly ToSpeckleScalingService _scalingService; + private readonly ScalingServiceToSpeckle _scalingService; public LineConversionToSpeckle( RevitConversionContextStack contextStack, IRawConversion xyzToPointConverter, - ToSpeckleScalingService scalingService + ScalingServiceToSpeckle scalingService ) { _contextStack = contextStack; diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/XyzConversionToPoint.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/XyzConversionToPoint.cs index 1dd5b7185c..c4e0268611 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/XyzConversionToPoint.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/XyzConversionToPoint.cs @@ -6,10 +6,10 @@ namespace Speckle.Converters.RevitShared.ToSpeckle; public class XyzConversionToPoint : IRawConversion { - private readonly ToSpeckleScalingService _toSpeckleScalingService; + private readonly ScalingServiceToSpeckle _toSpeckleScalingService; private readonly RevitConversionContextStack _contextStack; - public XyzConversionToPoint(ToSpeckleScalingService toSpeckleScalingService, RevitConversionContextStack contextStack) + public XyzConversionToPoint(ScalingServiceToSpeckle toSpeckleScalingService, RevitConversionContextStack contextStack) { _toSpeckleScalingService = toSpeckleScalingService; _contextStack = contextStack; diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/LevelConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/LevelConversionToSpeckle.cs index 79449c0956..a47d7d6ee3 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/LevelConversionToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/LevelConversionToSpeckle.cs @@ -5,31 +5,23 @@ namespace Speckle.Converters.RevitShared.ToSpeckle; public class LevelConversionToSpeckle : IRawConversion { - private readonly CachingService _cachingService; - private readonly ToSpeckleScalingService _scalingService; + private readonly ScalingServiceToSpeckle _scalingService; - public LevelConversionToSpeckle(CachingService cachingService, ToSpeckleScalingService scalingService) + public LevelConversionToSpeckle(ScalingServiceToSpeckle scalingService) { - _cachingService = cachingService; _scalingService = scalingService; } public SOBR.RevitLevel RawConvert(DB.Level target) { - return _cachingService.GetOrAdd(target.UniqueId, () => CreateSpeckleRevitLevel(target)); - } - - private SOBR.RevitLevel CreateSpeckleRevitLevel(DB.Level level) - { - var speckleLevel = new SOBR.RevitLevel - { - elevation = _scalingService.ScaleLength(level.Elevation), - name = level.Name, - createView = true - }; - - // GetAllRevitParamsAndIds(speckleLevel, revitLevel); + SOBR.RevitLevel level = + new() + { + elevation = _scalingService.ScaleLength(target.Elevation), + name = target.Name, + createView = true + }; - return speckleLevel; + return level; } } diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ParameterConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ParameterConversionToSpeckle.cs index 77a4cd1b4a..4f58e6234b 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ParameterConversionToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ParameterConversionToSpeckle.cs @@ -1,86 +1,40 @@ +using Autodesk.Revit.DB; using Speckle.Converters.Common.Objects; using Speckle.Converters.RevitShared.Extensions; using Speckle.Converters.RevitShared.Helpers; -using Speckle.Converters.RevitShared.Services; namespace Speckle.Converters.RevitShared.ToSpeckle; -public class ParameterConversionToSpeckle : IRawConversion +public class ParameterConversionToSpeckle : IRawConversion { private readonly ParameterValueExtractor _valueExtractor; - private readonly CachingService _cachingService; - public ParameterConversionToSpeckle(ParameterValueExtractor valueExtractor, CachingService cachingService) + public ParameterConversionToSpeckle(ParameterValueExtractor valueExtractor) { _valueExtractor = valueExtractor; - _cachingService = cachingService; } - public SOBR.Parameter RawConvert(DB.Parameter target) + public SOBR.Parameter RawConvert(Parameter target) { string internalName = target.GetInternalName(); - ParameterToSpeckleData toSpeckleData = _cachingService.GetOrAdd( - internalName, - paramInternalName => ExtractParameterDataFromDocument(paramInternalName, target) - ); - - return toSpeckleData.GetParameterObjectWithValue(_valueExtractor.GetValue(target)); - } - - // POC: naming, I don't know if we need FromDocument, even if it is using it (but maybe it is not) - private ParameterToSpeckleData ExtractParameterDataFromDocument(string paramInternalName, DB.Parameter parameter) - { - var definition = parameter.Definition; - var newParamData = new ParameterToSpeckleData() - { - Definition = definition, - InternalName = paramInternalName, - IsReadOnly = parameter.IsReadOnly, - IsShared = parameter.IsShared, - Name = definition.Name, - UnitType = definition.GetUnitTypeString(), - }; - - // POC: why is this specialisation needed? Could there be more? - if (parameter.StorageType == DB.StorageType.Double) + ForgeTypeId? unitTypeId = null; + if (target.StorageType is StorageType.Double) { - DB.ForgeTypeId unitTypeId = parameter.GetUnitTypeId(); - newParamData.UnitsSymbol = unitTypeId.GetSymbol(); - newParamData.ApplicationUnits = unitTypeId.ToUniqueString(); + // according to the api documentation, this method will throw if the storage type is not a VALUE type + // however, I've found that it will still throw if StorageType == StorageType.Integer + unitTypeId = target.GetUnitTypeId(); } + Definition definition = target.Definition; - return newParamData; - } -} - -/// -/// This struct is used when caching parameter definitions upon sending to avoid having to deep clone the parameter object -/// This is done because all the fields except the parameter value will change -/// -/// -// POC: needed for caching but should it be a struct? We should have it in it's own file -internal struct ParameterToSpeckleData -{ - public string ApplicationUnits; - public DB.Definition Definition; - public string InternalName; - public bool IsReadOnly; - public bool IsShared; - public string Name; - public string? UnitsSymbol; - public string UnitType; - - public readonly SOBR.Parameter GetParameterObjectWithValue(object? value) - { return new SOBR.Parameter() { - applicationInternalName = InternalName, - applicationUnit = ApplicationUnits, - isShared = IsShared, - isReadOnly = IsReadOnly, - name = Name, - units = UnitsSymbol ?? "None", - value = value + applicationInternalName = internalName, + applicationUnit = unitTypeId?.ToUniqueString() ?? "None", + isShared = target.IsShared, + isReadOnly = target.IsReadOnly, + name = definition.Name, + units = unitTypeId?.GetSymbol() ?? "None", + value = _valueExtractor.GetValue(target) }; } } diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Services/CachingService.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Services/CachingService.cs deleted file mode 100644 index 812d0073ac..0000000000 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Services/CachingService.cs +++ /dev/null @@ -1,87 +0,0 @@ -using System.Collections; - -namespace Speckle.Converters.RevitShared.Services; - -// POC: not sure where or how this caching is working and why it has this Func pattern -// we might want to take this out and restore caching in more structured places in a sensible way -// ideally being DRY about HOW we do this, using preferably generic caching patterns -public class CachingService : ICachingService -{ - private readonly Dictionary _objectTypeCaches = new(); - - public void AddMany(IEnumerable elements, Func keyFactory) - { - if (!_objectTypeCaches.TryGetValue(typeof(T), out var objectCache)) - { - objectCache = new Dictionary(); - _objectTypeCaches[typeof(T)] = objectCache; - } - - Dictionary typedObjectCache = (Dictionary)objectCache; - foreach (T element in elements) - { - typedObjectCache[keyFactory(element)] = element; - } - } - - public T GetOrAdd(string key, Func valueFactory) - { - return GetOrAdd(key, (_) => valueFactory(), out _); - } - - public T GetOrAdd(string key, Func valueFactory) - { - return GetOrAdd(key, valueFactory, out _); - } - - public T GetOrAdd(string key, Func valueFactory, out bool isExistingValue) - { - return GetOrAdd(key, (_) => valueFactory(), out isExistingValue); - } - - public T GetOrAdd(string key, Func valueFactory, out bool isExistingValue) - { - isExistingValue = false; - T cachedObject; - - if (!_objectTypeCaches.TryGetValue(typeof(T), out var objectCache)) - { - cachedObject = valueFactory(key); - objectCache = new Dictionary() { { key, cachedObject } }; - _objectTypeCaches[typeof(T)] = objectCache; - return cachedObject; - } - - Dictionary typedObjectCache = (Dictionary)objectCache; - if (!typedObjectCache.TryGetValue(key, out cachedObject)) - { - cachedObject = valueFactory(key); - typedObjectCache.Add(key, cachedObject); - return cachedObject; - } - - isExistingValue = true; - return cachedObject; - } - - public bool TryGet(string key, out T? cachedObject) - { - cachedObject = default; - if (!_objectTypeCaches.TryGetValue(typeof(T), out var objectCache)) - { - return false; - } - - return ((Dictionary)objectCache).TryGetValue(key, out cachedObject); - } - - public void Invalidate() - { - _objectTypeCaches.Remove(typeof(T)); - } - - public void InvalidateAll() - { - _objectTypeCaches.Clear(); - } -} diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Services/ICachingService.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Services/ICachingService.cs deleted file mode 100644 index 86f14cd4ea..0000000000 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Services/ICachingService.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace Speckle.Converters.RevitShared.Services; - -internal interface ICachingService -{ - public T GetOrAdd(string key, Func valueFactory); - public T GetOrAdd(string key, Func valueFactory, out bool isExistingValue); - public bool TryGet(string key, out T? cachedObject); - void AddMany(IEnumerable elements, Func keyFactory); -} diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Services/ToSpeckleScalingService.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Services/ScalingServiceToSpeckle.cs similarity index 91% rename from DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Services/ToSpeckleScalingService.cs rename to DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Services/ScalingServiceToSpeckle.cs index 50b1cb3dca..f8fd48d46e 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Services/ToSpeckleScalingService.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Services/ScalingServiceToSpeckle.cs @@ -5,12 +5,12 @@ namespace Speckle.Converters.RevitShared.Services; // POC: feels like this is a context thing and we should be calculating this occasionally? // needs some thought as to how it could be be done, could leave as is for now -public sealed class ToSpeckleScalingService +public sealed class ScalingServiceToSpeckle { private readonly double _defaultLengthConversionFactor; // POC: this seems like the reverse relationship - public ToSpeckleScalingService(RevitConversionContextStack contextStack) + public ScalingServiceToSpeckle(RevitConversionContextStack contextStack) { // POC: this is accurate for the current context stack Units documentUnits = contextStack.Current.Document.Document.GetUnits(); diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Speckle.Converters.RevitShared.projitems b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Speckle.Converters.RevitShared.projitems index 7b012b5df0..e353303cf4 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Speckle.Converters.RevitShared.projitems +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Speckle.Converters.RevitShared.projitems @@ -29,6 +29,7 @@ + @@ -39,10 +40,7 @@ - - - diff --git a/Objects/Converters/ConverterRevit/ConverterRevitTests/ConverterRevitTestsShared/Generated/REVIT2023/TestGenerator/TestGenerator.Generator/GeneratedTests.g.cs b/Objects/Converters/ConverterRevit/ConverterRevitTests/ConverterRevitTestsShared/Generated/REVIT2023/TestGenerator/TestGenerator.Generator/GeneratedTests.g.cs index f4caac162a..3a0b767ca6 100644 --- a/Objects/Converters/ConverterRevit/ConverterRevitTests/ConverterRevitTestsShared/Generated/REVIT2023/TestGenerator/TestGenerator.Generator/GeneratedTests.g.cs +++ b/Objects/Converters/ConverterRevit/ConverterRevitTests/ConverterRevitTestsShared/Generated/REVIT2023/TestGenerator/TestGenerator.Generator/GeneratedTests.g.cs @@ -6,4 +6,532 @@ namespace ConverterRevitTests { + public class AdaptiveComponentAdaptiveComponentFixture : SpeckleConversionFixture + { + public override string Category => "AdaptiveComponent"; + public override string TestName => "AdaptiveComponent"; + + public AdaptiveComponentAdaptiveComponentFixture() : base() + { + } + } + + public class AdaptiveComponentAdaptiveComponentTests : SpeckleConversionTest, IClassFixture + { + public AdaptiveComponentAdaptiveComponentTests(AdaptiveComponentAdaptiveComponentFixture fixture) : base(fixture) + { + } + + [Fact] + [Trait("AdaptiveComponent", "AdaptiveComponentToSpeckle")] + public async Task AdaptiveComponentAdaptiveComponentToSpeckle() + { + await NativeToSpeckle(); + } + + [Fact] + [Trait("AdaptiveComponent", "AdaptiveComponentToNative")] + public async Task AdaptiveComponentAdaptiveComponentToNative() + { + await SpeckleToNative(AssertUtils.AdaptiveComponentEqual, null); + } + + [Fact] + [Trait("AdaptiveComponent", "AdaptiveComponentSelection")] + public async Task AdaptiveComponentAdaptiveComponentSelectionToNative() + { + await SelectionToNative(AssertUtils.AdaptiveComponentEqual, null); + } + + } + + public class BeamBeamFixture : SpeckleConversionFixture + { + public override string Category => "Beam"; + public override string TestName => "Beam"; + + public BeamBeamFixture() : base() + { + } + } + + public class BeamBeamTests : SpeckleConversionTest, IClassFixture + { + public BeamBeamTests(BeamBeamFixture fixture) : base(fixture) + { + } + + [Fact] + [Trait("Beam", "BeamToSpeckle")] + public async Task BeamBeamToSpeckle() + { + await NativeToSpeckle(); + } + + [Fact] + [Trait("Beam", "BeamToNative")] + public async Task BeamBeamToNative() + { + await SpeckleToNative(AssertUtils.FamilyInstanceEqual, null); + } + + [Fact] + [Trait("Beam", "BeamSelection")] + public async Task BeamBeamSelectionToNative() + { + await SelectionToNative(AssertUtils.FamilyInstanceEqual, null); + } + + [Fact] + [Trait("Beam", "BeamToNativeUpdates")] + public async Task BeamBeamToNativeUpdates() + { + await SpeckleToNativeUpdates(AssertUtils.FamilyInstanceEqual, null); + } + + } + + public class ColumnColumnFixture : SpeckleConversionFixture + { + public override string Category => "Column"; + public override string TestName => "Column"; + + public ColumnColumnFixture() : base() + { + } + } + + public class ColumnColumnTests : SpeckleConversionTest, IClassFixture + { + public ColumnColumnTests(ColumnColumnFixture fixture) : base(fixture) + { + } + + [Fact] + [Trait("Column", "ColumnToSpeckle")] + public async Task ColumnColumnToSpeckle() + { + await NativeToSpeckle(); + } + + [Fact] + [Trait("Column", "ColumnToNative")] + public async Task ColumnColumnToNative() + { + await SpeckleToNative(AssertUtils.FamilyInstanceEqual, null); + } + + [Fact] + [Trait("Column", "ColumnSelection")] + public async Task ColumnColumnSelectionToNative() + { + await SelectionToNative(AssertUtils.FamilyInstanceEqual, null); + } + + [Fact] + [Trait("Column", "ColumnToNativeUpdates")] + public async Task ColumnColumnToNativeUpdates() + { + await SpeckleToNativeUpdates(AssertUtils.FamilyInstanceEqual, null); + } + + } + + public class CurveCurveFixture : SpeckleConversionFixture + { + public override string Category => "Curve"; + public override string TestName => "Curve"; + + public CurveCurveFixture() : base() + { + } + } + + public class CurveCurveTests : SpeckleConversionTest, IClassFixture + { + public CurveCurveTests(CurveCurveFixture fixture) : base(fixture) + { + } + + [Fact] + [Trait("Curve", "CurveToSpeckle")] + public async Task CurveCurveToSpeckle() + { + await NativeToSpeckle(); + } + + [Fact] + [Trait("Curve", "CurveToNative")] + public async Task CurveCurveToNative() + { + await SpeckleToNative(AssertUtils.CurveEqual, null); + } + + [Fact] + [Trait("Curve", "CurveSelection")] + public async Task CurveCurveSelectionToNative() + { + await SelectionToNative(AssertUtils.CurveEqual, null); + } + + } + + public class DirectShapeDirectShapeFixture : SpeckleConversionFixture + { + public override string Category => "DirectShape"; + public override string TestName => "DirectShape"; + + public DirectShapeDirectShapeFixture() : base() + { + } + } + + public class DirectShapeDirectShapeTests : SpeckleConversionTest, IClassFixture + { + public DirectShapeDirectShapeTests(DirectShapeDirectShapeFixture fixture) : base(fixture) + { + } + + [Fact] + [Trait("DirectShape", "DirectShapeToSpeckle")] + public async Task DirectShapeDirectShapeToSpeckle() + { + await NativeToSpeckle(); + } + + [Fact] + [Trait("DirectShape", "DirectShapeToNative")] + public async Task DirectShapeDirectShapeToNative() + { + await SpeckleToNative(AssertUtils.DirectShapeEqual, null); + } + + [Fact] + [Trait("DirectShape", "DirectShapeSelection")] + public async Task DirectShapeDirectShapeSelectionToNative() + { + await SelectionToNative(AssertUtils.DirectShapeEqual, null); + } + + } + + public class FamilyInstanceFamilyInstanceFixture : SpeckleConversionFixture + { + public override string Category => "FamilyInstance"; + public override string TestName => "FamilyInstance"; + + public FamilyInstanceFamilyInstanceFixture() : base() + { + } + } + + public class FamilyInstanceFamilyInstanceTests : SpeckleConversionTest, IClassFixture + { + public FamilyInstanceFamilyInstanceTests(FamilyInstanceFamilyInstanceFixture fixture) : base(fixture) + { + } + + [Fact] + [Trait("FamilyInstance", "FamilyInstanceToSpeckle")] + public async Task FamilyInstanceFamilyInstanceToSpeckle() + { + await NativeToSpeckle(); + } + + [Fact] + [Trait("FamilyInstance", "FamilyInstanceToNative")] + public async Task FamilyInstanceFamilyInstanceToNative() + { + await SpeckleToNative(AssertUtils.NestedEqual, null); + } + + [Fact] + [Trait("FamilyInstance", "FamilyInstanceSelection")] + public async Task FamilyInstanceFamilyInstanceSelectionToNative() + { + await SelectionToNative(AssertUtils.NestedEqual, null); + } + + [Fact] + [Trait("FamilyInstance", "FamilyInstanceToNativeUpdates")] + public async Task FamilyInstanceFamilyInstanceToNativeUpdates() + { + await SpeckleToNativeUpdates(AssertUtils.NestedEqual, null); + } + + } + + public class FloorFloorFixture : SpeckleConversionFixture + { + public override string Category => "Floor"; + public override string TestName => "Floor"; + + public FloorFloorFixture() : base() + { + } + } + + public class FloorFloorTests : SpeckleConversionTest, IClassFixture + { + public FloorFloorTests(FloorFloorFixture fixture) : base(fixture) + { + } + + [Fact] + [Trait("Floor", "FloorToSpeckle")] + public async Task FloorFloorToSpeckle() + { + await NativeToSpeckle(); + } + + [Fact] + [Trait("Floor", "FloorToNative")] + public async Task FloorFloorToNative() + { + await SpeckleToNative(null, AssertUtils.FloorEqual); + } + + [Fact] + [Trait("Floor", "FloorSelection")] + public async Task FloorFloorSelectionToNative() + { + await SelectionToNative(null, AssertUtils.FloorEqual); + } + + } + + public class OpeningOpeningFixture : SpeckleConversionFixture + { + public override string Category => "Opening"; + public override string TestName => "Opening"; + + public OpeningOpeningFixture() : base() + { + } + } + + public class OpeningOpeningTests : SpeckleConversionTest, IClassFixture + { + public OpeningOpeningTests(OpeningOpeningFixture fixture) : base(fixture) + { + } + + [Fact] + [Trait("Opening", "OpeningToSpeckle")] + public async Task OpeningOpeningToSpeckle() + { + await NativeToSpeckle(); + } + + [Fact] + [Trait("Opening", "OpeningToNative")] + public async Task OpeningOpeningToNative() + { + await SpeckleToNative(AssertUtils.OpeningEqual, null); + } + + [Fact] + [Trait("Opening", "OpeningSelection")] + public async Task OpeningOpeningSelectionToNative() + { + await SelectionToNative(AssertUtils.OpeningEqual, null); + } + + } + + public class RoofRoofFixture : SpeckleConversionFixture + { + public override string Category => "Roof"; + public override string TestName => "Roof"; + + public RoofRoofFixture() : base() + { + } + } + + public class RoofRoofTests : SpeckleConversionTest, IClassFixture + { + public RoofRoofTests(RoofRoofFixture fixture) : base(fixture) + { + } + + [Fact] + [Trait("Roof", "RoofToSpeckle")] + public async Task RoofRoofToSpeckle() + { + await NativeToSpeckle(); + } + + [Fact] + [Trait("Roof", "RoofToNative")] + public async Task RoofRoofToNative() + { + await SpeckleToNative(AssertUtils.RoofEqual, null); + } + + [Fact] + [Trait("Roof", "RoofSelection")] + public async Task RoofRoofSelectionToNative() + { + await SelectionToNative(AssertUtils.RoofEqual, null); + } + + } + + public class RoomRoomFixture : SpeckleConversionFixture + { + public override string Category => "Room"; + public override string TestName => "Room"; + + public RoomRoomFixture() : base() + { + } + } + + public class RoomRoomTests : SpeckleConversionTest, IClassFixture + { + public RoomRoomTests(RoomRoomFixture fixture) : base(fixture) + { + } + + [Fact] + [Trait("Room", "RoomToSpeckle")] + public async Task RoomRoomToSpeckle() + { + await NativeToSpeckle(); + } + + } + + public class ScheduleScheduleFixture : SpeckleConversionFixture + { + public override string Category => "Schedule"; + public override string TestName => "Schedule"; + + public ScheduleScheduleFixture() : base() + { + } + } + + public class ScheduleScheduleTests : SpeckleConversionTest, IClassFixture + { + public ScheduleScheduleTests(ScheduleScheduleFixture fixture) : base(fixture) + { + } + + [Fact] + [Trait("Schedule", "ScheduleToSpeckle")] + public async Task ScheduleScheduleToSpeckle() + { + await NativeToSpeckle(); + } + + [Fact] + [Trait("Schedule", "ScheduleToNative")] + public async Task ScheduleScheduleToNative() + { + await SpeckleToNative(null, AssertUtils.ScheduleEqual); + } + + [Fact] + [Trait("Schedule", "ScheduleSelection")] + public async Task ScheduleScheduleSelectionToNative() + { + await SelectionToNative(null, AssertUtils.ScheduleEqual); + } + + [Fact] + [Trait("Schedule", "ScheduleToNativeUpdates")] + public async Task ScheduleScheduleToNativeUpdates() + { + await SpeckleToNativeUpdates(null, AssertUtils.ScheduleEqual); + } + + } + + public class WallWallFixture : SpeckleConversionFixture + { + public override string Category => "Wall"; + public override string TestName => "Wall"; + + public WallWallFixture() : base() + { + } + } + + public class WallWallTests : SpeckleConversionTest, IClassFixture + { + public WallWallTests(WallWallFixture fixture) : base(fixture) + { + } + + [Fact] + [Trait("Wall", "WallToSpeckle")] + public async Task WallWallToSpeckle() + { + await NativeToSpeckle(); + } + + [Fact] + [Trait("Wall", "WallToNative")] + public async Task WallWallToNative() + { + await SpeckleToNative(AssertUtils.WallEqual, null); + } + + [Fact] + [Trait("Wall", "WallSelection")] + public async Task WallWallSelectionToNative() + { + await SelectionToNative(AssertUtils.WallEqual, null); + } + + [Fact] + [Trait("Wall", "WallToNativeUpdates")] + public async Task WallWallToNativeUpdates() + { + await SpeckleToNativeUpdates(AssertUtils.WallEqual, null); + } + + } + + public class WireWireFixture : SpeckleConversionFixture + { + public override string Category => "Wire"; + public override string TestName => "Wire"; + + public WireWireFixture() : base() + { + } + } + + public class WireWireTests : SpeckleConversionTest, IClassFixture + { + public WireWireTests(WireWireFixture fixture) : base(fixture) + { + } + + [Fact] + [Trait("Wire", "WireToSpeckle")] + public async Task WireWireToSpeckle() + { + await NativeToSpeckle(); + } + + [Fact] + [Trait("Wire", "WireToNative")] + public async Task WireWireToNative() + { + await SpeckleToNative(AssertUtils.WireEqual, null); + } + + [Fact] + [Trait("Wire", "WireSelection")] + public async Task WireWireSelectionToNative() + { + await SelectionToNative(AssertUtils.WireEqual, null); + } + + } + } From 7e05750e238285d5bce682ae89a6149d2bcaa18f Mon Sep 17 00:00:00 2001 From: KatKatKateryna <89912278+KatKatKateryna@users.noreply.github.com> Date: Tue, 23 Apr 2024 20:02:53 +0800 Subject: [PATCH 041/261] CNX-9243 ArcGIS selection filter (#3301) * MOVE TO SELECTION FILTER * selection binding * exit if layer conversion failed; fix IReadOnly lists * minor change --- .../Bindings/ArcGISSelectionBinding.cs | 53 +++++++++++++ .../Bindings/ArcGISSendBinding.cs | 17 ++--- .../AutofacArcGISModule.cs | 5 ++ .../Filters/ArcGISSelectionFilter.cs | 1 - .../Operations/Send/RootObjectBuilder.cs | 74 ++++++++----------- .../Operations/Send/SendOperation.cs | 9 ++- .../Features/GeometryToSpeckleBase.cs | 12 +-- .../Features/GisFeatureToSpeckleConverter.cs | 8 +- 8 files changed, 113 insertions(+), 66 deletions(-) create mode 100644 DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISSelectionBinding.cs diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISSelectionBinding.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISSelectionBinding.cs new file mode 100644 index 0000000000..932223ae9f --- /dev/null +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISSelectionBinding.cs @@ -0,0 +1,53 @@ +using Speckle.Connectors.DUI.Bindings; +using Speckle.Connectors.DUI.Bridge; +using ArcGIS.Desktop.Mapping.Events; +using ArcGIS.Desktop.Mapping; +using Speckle.Core.Logging; + +namespace Speckle.Connectors.ArcGIS.Bindings; + +public class ArcGISSelectionBinding : ISelectionBinding +{ + private const string SELECTION_EVENT = "setSelection"; + + public string Name { get; } = "selectionBinding"; + public IBridge Parent { get; set; } + + public ArcGISSelectionBinding(IBridge parent) + { + Parent = parent; + + // example: https://github.com/Esri/arcgis-pro-sdk-community-samples/blob/master/Map-Authoring/QueryBuilderControl/DefinitionQueryDockPaneViewModel.cs + MapViewEventArgs args = new(MapView.Active); + TOCSelectionChangedEvent.Subscribe(OnSelectionChanged, true); + } + + private void OnSelectionChanged(MapViewEventArgs args) + { + SelectionInfo selInfo = GetSelection(); + Parent?.Send(SELECTION_EVENT, selInfo); + } + + public SelectionInfo GetSelection() + { + MapView mapView = MapView.Active; + List selectedMembers = new(); + selectedMembers.AddRange(mapView.GetSelectedLayers()); + selectedMembers.AddRange(mapView.GetSelectedStandaloneTables()); + + if (selectedMembers.Count == 0) + { + throw new SpeckleException("No data to send"); + } + + List objectTypes = selectedMembers + .Select(o => o.GetType().ToString().Split(".").Last()) + .Distinct() + .ToList(); + return new SelectionInfo + { + SelectedObjectIds = selectedMembers.Select(x => x.URI).ToList(), + Summary = $"{selectedMembers.Count} layers ({string.Join(", ", objectTypes)})" + }; + } +} diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISSendBinding.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISSendBinding.cs index aaf665b413..e9ff997ecc 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISSendBinding.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISSendBinding.cs @@ -3,7 +3,6 @@ using Speckle.Connectors.DUI.Bindings; using Speckle.Connectors.DUI.Bridge; using Speckle.Connectors.DUI.Utils; -using Speckle.Connectors.ArcGIS.Filters; using Speckle.Connectors.ArcGis.Operations.Send; using Speckle.Connectors.Utils.Cancellation; using Speckle.Core.Logging; @@ -22,8 +21,8 @@ public sealed class ArcGISSendBinding : ISendBinding, ICancelable private readonly ArcGISDocumentStore _store; private readonly IUnitOfWorkFactory _unitOfWorkFactory; // POC: unused? :D + private readonly List _sendFilters; private readonly CancellationManager _cancellationManager; - private readonly SendOperation _sendOperation; /// /// Used internally to aggregate the changed objects' id. @@ -33,24 +32,21 @@ public sealed class ArcGISSendBinding : ISendBinding, ICancelable public ArcGISSendBinding( ArcGISDocumentStore store, IBridge parent, + IEnumerable sendFilters, IUnitOfWorkFactory unitOfWorkFactory, - SendOperation sendOperation, CancellationManager cancellationManager ) { _store = store; _unitOfWorkFactory = unitOfWorkFactory; - _sendOperation = sendOperation; + _sendFilters = sendFilters.ToList(); _cancellationManager = cancellationManager; Parent = parent; Commands = new SendBindingUICommands(parent); } - public List GetSendFilters() - { - return new List { new ArcGISSelectionFilter { IsDefault = true } }; - } + public List GetSendFilters() => _sendFilters; public List GetSendSettings() { @@ -74,6 +70,7 @@ public List GetSendSettings() public async Task Send(string modelCardId) { //poc: dupe code between connectors + using var unitOfWork = _unitOfWorkFactory.Resolve(); try { // 0 - Init cancellation token source -> Manager also cancel it if exist before @@ -85,9 +82,9 @@ public async Task Send(string modelCardId) throw new InvalidOperationException("No publish model card was found."); } - string versionId = await _sendOperation + string versionId = await unitOfWork.Service .Execute( - //modelCard.SendFilter, + modelCard.SendFilter, modelCard.AccountId, modelCard.ProjectId, modelCard.ModelId, diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/DependencyInjection/AutofacArcGISModule.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/DependencyInjection/AutofacArcGISModule.cs index 186be20c36..2d924e53bc 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/DependencyInjection/AutofacArcGISModule.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/DependencyInjection/AutofacArcGISModule.cs @@ -17,6 +17,7 @@ using Speckle.Core.Transports; using ArcGIS.Core.Geometry; using Speckle.Connectors.DUI.Models.Card.SendFilter; +using Speckle.Connectors.ArcGIS.Filters; namespace Speckle.Connectors.ArcGIS.DependencyInjection; @@ -38,12 +39,16 @@ protected override void Load(ContainerBuilder builder) builder.RegisterType().As().SingleInstance().WithParameter("connectorName", "ArcGIS"); // POC: Easier like this for now, should be cleaned up later builder.RegisterType().As().SingleInstance(); builder.RegisterType().As().As().SingleInstance(); + builder.RegisterType().As().SingleInstance(); builder.RegisterType().As().SingleInstance(); builder.RegisterType().As>().SingleInstance(); // binding dependencies builder.RegisterType().InstancePerDependency(); + // register send filters + builder.RegisterType().As().InstancePerDependency(); + // register send operation and dependencies builder.RegisterType().SingleInstance(); builder.RegisterType().SingleInstance(); diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Filters/ArcGISSelectionFilter.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Filters/ArcGISSelectionFilter.cs index ec71eba13c..8b203dc18c 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Filters/ArcGISSelectionFilter.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Filters/ArcGISSelectionFilter.cs @@ -2,7 +2,6 @@ namespace Speckle.Connectors.ArcGIS.Filters; -//poc: dupe code public class ArcGISSelectionFilter : DirectSelectionSendFilter { public override List GetObjectIds() => SelectedObjectIds; diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Send/RootObjectBuilder.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Send/RootObjectBuilder.cs index 9bd865f9f1..f6ff7824b1 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Send/RootObjectBuilder.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Send/RootObjectBuilder.cs @@ -1,8 +1,9 @@ using ArcGIS.Desktop.Mapping; -using Speckle.Core.Models; using Speckle.Autofac.DependencyInjection; +using Speckle.Connectors.DUI.Models.Card.SendFilter; using Speckle.Converters.Common; using Speckle.Core.Logging; +using Speckle.Core.Models; namespace Speckle.Connectors.ArcGis.Operations.Send; @@ -19,7 +20,7 @@ public RootObjectBuilder(IUnitOfWorkFactory unitOfWorkFactory) } public Base Build( - //ISendFilter sendFilter, + ISendFilter sendFilter, Action? onOperationProgressed = null, CancellationToken ct = default ) @@ -28,47 +29,21 @@ public Base Build( { throw new SpeckleException("No Map currently active"); } - var selectedObjects = GetSelection(MapView.Active.Map); - - // if (selectedObjects.Count == 0) - // { - // throw new InvalidOperationException("No objects were found. Please update your send filter!"); - // } - - Base commitObject = ConvertObjects(selectedObjects, onOperationProgressed, ct); - - return commitObject; - } - - /// - /// This method must be called on the MCT. Use QueuedTask. Run. - /// - private Dictionary> GetSelection(Map map) - { - // var allMembers = map.GetMapMembersAsFlattenedList(); - - //POC: Right now, we're not using the send filter - // We're still undecided how we handle MapMember vs objectId when converting - // + the ArcGIS api breaks some assumptions we've made - // e.g. - // - There isn't a single type of ID to uniquely identify objects - // - MapMembers are identifiable by uri, but objects on a MapMember have an objectId which is their index in the MapMember - // - plus, some MapMembers work differently (raster layers, voxel layers, pointclound layers) etc. - // - getting selection is an async operation, needs to be done on the main thread, and returns the full object, not just an ID - var selectedMemberUrls = map.GetSelection().ToDictionary(); + List selectedObjects = sendFilter.GetObjectIds().Where(obj => obj != null).ToList(); - if (selectedMemberUrls.Count == 0) + if (selectedObjects.Count == 0) { - throw new SpeckleException("No data to send"); + throw new InvalidOperationException("No layers were found. Please update your send filter!"); } - return selectedMemberUrls; + Base commitObject = ConvertObjects(selectedObjects, onOperationProgressed, ct); + return commitObject; } //poc: semi dupe private Collection ConvertObjects( - IReadOnlyDictionary> mapMembers, + IReadOnlyList uriList, Action? onOperationProgressed = null, CancellationToken cancellationToken = default ) @@ -83,33 +58,46 @@ private Collection ConvertObjects( Collection rootObjectCollection = new(); //TODO: Collections - foreach ((MapMember mapMember, List objectIds) in mapMembers) + foreach (string uri in uriList) { cancellationToken.ThrowIfCancellationRequested(); - var collectionHost = rootObjectCollection; - var applicationId = mapMember.ToString(); + var applicationId = uri; - try + Base converted = new(); + + MapMember mapMember = MapView.Active.Map.FindLayer(uri); + if (mapMember is null) { - Base converted = converter.Convert(mapMember); - converted.applicationId = applicationId; + mapMember = MapView.Active.Map.FindStandaloneTable(uri); + } + if (mapMember is null) + { + continue; + } - // add to host - collectionHost.elements.Add(converted); - onOperationProgressed?.Invoke("Converting", (double)++count / mapMembers.Count); + try + { + converted = converter.Convert(mapMember); } // POC: Exception handling on conversion logic must be revisited after several connectors have working conversions catch (SpeckleConversionException e) { // POC: DO something with the exception Console.WriteLine(e); + continue; } catch (NotSupportedException e) { // POC: DO something with the exception Console.WriteLine(e); + continue; } + + converted.applicationId = applicationId; + // add to host + collectionHost.elements.Add(converted); + onOperationProgressed?.Invoke("Converting", (double)++count / uriList.Count); } return rootObjectCollection; diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Send/SendOperation.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Send/SendOperation.cs index db8de913d1..9daacfd3ba 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Send/SendOperation.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Send/SendOperation.cs @@ -1,5 +1,6 @@ -using ArcGIS.Desktop.Framework.Threading.Tasks; +using ArcGIS.Desktop.Framework.Threading.Tasks; using Speckle.Core.Models; +using Speckle.Connectors.DUI.Models.Card.SendFilter; namespace Speckle.Connectors.ArcGis.Operations.Send; @@ -23,7 +24,7 @@ public SendOperation(RootObjectBuilder baseBuilder, IRootObjectSender baseObject /// Executes a send operation given information about the host objects and the destination account. /// public async Task Execute( - //ISendFilter sendFilter, + ISendFilter sendFilter, string accountId, string projectId, string modelId, @@ -31,7 +32,9 @@ public async Task Execute( CancellationToken ct = default ) { - Base commitObject = await QueuedTask.Run(() => _baseBuilder.Build(onOperationProgressed, ct)).ConfigureAwait(false); + Base commitObject = await QueuedTask + .Run(() => _baseBuilder.Build(sendFilter, onOperationProgressed, ct)) + .ConfigureAwait(false); // base object handler is separated so we can do some testing on non-production databases // exact interface may want to be tweaked when we implement this diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GeometryToSpeckleBase.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GeometryToSpeckleBase.cs index 4d16cd60b3..2ef8379ebd 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GeometryToSpeckleBase.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GeometryToSpeckleBase.cs @@ -9,15 +9,15 @@ namespace Speckle.Converters.ArcGIS3.Features; public class GeometryToSpeckleBaseList : IRawConversion> { private readonly IRawConversion _pointToSpeckleConverter; - private readonly IRawConversion> _multiPointFeatureConverter; - private readonly IRawConversion> _polylineFeatureConverter; - private readonly IRawConversion> _polygonFeatureConverter; + private readonly IRawConversion> _multiPointFeatureConverter; + private readonly IRawConversion> _polylineFeatureConverter; + private readonly IRawConversion> _polygonFeatureConverter; public GeometryToSpeckleBaseList( IRawConversion pointToSpeckleConverter, - IRawConversion> multiPointFeatureConverter, - IRawConversion> polylineFeatureConverter, - IRawConversion> polygonFeatureConverter + IRawConversion> multiPointFeatureConverter, + IRawConversion> polylineFeatureConverter, + IRawConversion> polygonFeatureConverter ) { _pointToSpeckleConverter = pointToSpeckleConverter; diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GisFeatureToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GisFeatureToSpeckleConverter.cs index 8c57d24351..1d73a30ec1 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GisFeatureToSpeckleConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GisFeatureToSpeckleConverter.cs @@ -7,9 +7,11 @@ namespace Speckle.Converters.ArcGIS3.Features; public class GisFeatureToSpeckleConverter : IRawConversion { - private readonly IRawConversion> _geometryConverter; + private readonly IRawConversion> _geometryConverter; - public GisFeatureToSpeckleConverter(IRawConversion> geometryConverter) + public GisFeatureToSpeckleConverter( + IRawConversion> geometryConverter + ) { _geometryConverter = geometryConverter; } @@ -19,7 +21,7 @@ public GisFeatureToSpeckleConverter(IRawConversion Date: Tue, 23 Apr 2024 07:15:40 -0500 Subject: [PATCH 042/261] CNX-9223 revit beam (#3296) * try different means of getting to beam conversion * reference send converter * remove conditional conversion * revert generated test changes --------- Co-authored-by: Connor Ivy --- .../Plugin/RevitExternalApplication.cs | 8 +- .../Raw/BeamConversionToSpeckle.cs | 1 + .../FamilyInstanceConversionToSpeckle.cs | 129 ++---------------- .../RawConversionRegisterer.cs | 24 ++++ 4 files changed, 45 insertions(+), 117 deletions(-) diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitExternalApplication.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitExternalApplication.cs index b18e6615d6..4dbbd2b182 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitExternalApplication.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitExternalApplication.cs @@ -8,6 +8,7 @@ using Speckle.Converters.Common.DependencyInjection; using Speckle.Converters.Common.Objects; using Speckle.Core.Logging; +using Speckle.Converters.RevitShared; namespace Speckle.Connectors.Revit.Plugin; @@ -77,7 +78,12 @@ private void _container_PreBuildEvent(object sender, ContainerBuilder containerB // tbe event can probably go // IRawConversions should be separately injectable (and not Require an IHostObject... or NameAndRank attribute) // Name and Rank can become ConversionRank or something and be optional (otherwise it is rank 0) - containerBuilder.RegisterRawConversions().InjectNamedTypes(); + containerBuilder.RegisterTypesInAssemblyAsInterface( + typeof(RevitConverterToSpeckle).Assembly, + typeof(IRawConversion<,>) + ); + containerBuilder.InjectNamedTypes(); + containerBuilder.InjectNamedTypes(); } public Result OnShutdown(UIControlledApplication application) diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/BeamConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/BeamConversionToSpeckle.cs index a72f9764a5..1bc69a941b 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/BeamConversionToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/BeamConversionToSpeckle.cs @@ -9,6 +9,7 @@ namespace Speckle.Converters.RevitShared.ToSpeckle; // POC: There is no validation on this converter to prevent conversion from "not a Revit Beam" to a Speckle Beam. // This will definitely explode if we tried. Goes back to the `CanConvert` functionality conversation. // As-is, what we are saying is that it can take "any Family Instance" and turn it into a Speckle.RevitBeam, which is far from correct. +// CNX-9312 public class BeamConversionToSpeckle : IRawConversion { private readonly IRawConversion _locationConverter; diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/FamilyInstanceConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/FamilyInstanceConversionToSpeckle.cs index 466e95fa39..ccc54723b8 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/FamilyInstanceConversionToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/FamilyInstanceConversionToSpeckle.cs @@ -1,8 +1,7 @@ using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; -using Speckle.Converters.RevitShared.Helpers; -using Speckle.Core.Models; using Speckle.Converters.RevitShared.Extensions; +using Speckle.Core.Models; namespace Speckle.Converters.RevitShared.ToSpeckle; @@ -12,134 +11,32 @@ namespace Speckle.Converters.RevitShared.ToSpeckle; public sealed class FamilyInstanceConversionToSpeckle : BaseConversionToSpeckle { private readonly IRawConversion _elementConverter; - private readonly IRawConversion _beamConverter; - private readonly IRawConversion _columnConverter; + private readonly IRawConversion _beamConversion; public FamilyInstanceConversionToSpeckle( IRawConversion elementConverter, - IRawConversion beamConverter, - IRawConversion columnConverter + IRawConversion beamConversion ) { _elementConverter = elementConverter; - _beamConverter = beamConverter; - _columnConverter = columnConverter; + _beamConversion = beamConversion; } public override Base RawConvert(DB.FamilyInstance target) { - Base? @base = null; - - ////adaptive components - //if (AdaptiveComponentInstanceUtils.IsAdaptiveComponentInstance(target)) - //{ - // @base = AdaptiveComponentToSpeckle(target); - //} - - ////these elements come when the curtain wall is generated - ////if they are contained in 'subelements' then they have already been accounted for from a wall - ////else if they are mullions then convert them as a generic family instance but add a isUGridLine prop - //bool? isUGridLine = null; - //if ( - // @base == null - // && ( - // target.Category.Id.IntegerValue == (int)BuiltInCategory.OST_CurtainWallMullions - // || target.Category.Id.IntegerValue == (int)BuiltInCategory.OST_CurtainWallPanels - // ) - //) - //{ - // if (_convertedObjectsCache.ContainsBaseConvertedFromId(target.UniqueId)) - // { - // return null; - // } - // else if (target is Mullion mullion) - // { - // if (mullion.LocationCurve is DB.Line locationLine && locationLine.Direction != null) - // { - // var direction = locationLine.Direction; - // // TODO: add support for more severly sloped mullions. This isn't very robust at the moment - // isUGridLine = Math.Abs(direction.X) > Math.Abs(direction.Y); - // } - // } - // else - // { - // //TODO: sort these so we consistently get sub-elements from the wall element in case also sub-elements are sent - // //SubelementIds.Add(target.Id); - // } - //} - - //beams & braces - if (RevitCategories.StructuralFraming.BuiltInCategories.Contains(target.Category.GetBuiltInCategory())) - { - if (target.StructuralType == DB.Structure.StructuralType.Beam) - { - @base = _beamConverter.RawConvert(target); - } - else if (target.StructuralType == DB.Structure.StructuralType.Brace) - { - //@base = BraceToSpeckle(target, out notes); - } - } - - ////columns if ( - @base == null - && RevitCategories.StructuralFraming.BuiltInCategories.Contains(target.Category.GetBuiltInCategory()) - || target.StructuralType == DB.Structure.StructuralType.Column + target.Category.GetBuiltInCategory() == DB.BuiltInCategory.OST_StructuralFraming + && target.StructuralType == DB.Structure.StructuralType.Beam ) { - @base = _columnConverter.RawConvert(target); + return _beamConversion.RawConvert(target); } - //// MEP elements - //if (target.MEPModel?.ConnectorManager?.Connectors?.Size > 0) - //{ - // @base = MEPFamilyInstanceToSpeckle(target); - //} - - //// curtain panels - //if (target is DB.Panel panel) - //{ - // @base = PanelToSpeckle(panel); - //} - - //// elements - //var baseGeometry = LocationToSpeckle(target); - //var basePoint = baseGeometry as Point; - //if (@base == null && basePoint == null) - //{ - // @base = RevitElementToSpeckle(target, out notes); - //} - - //// point based, convert these as revit instances - //if (@base == null) - //{ - // @base = RevitInstanceToSpeckle(target, out notes, null); - //} - - @base ??= _elementConverter.RawConvert(target); - - //// add additional props to base object - //if (isUGridLine.HasValue) - //{ - // @base["isUGridLine"] = isUGridLine.Value; - //} - - //if (target.Room != null) - //{ - // @base["roomId"] = target.Room.Id.ToString(); - //} - - //if (target.ToRoom != null) - //{ - // @base["toRoomId"] = target.ToRoom.Id.ToString(); - //} - - //if (target.FromRoom != null) - //{ - // @base["fromRoomId"] = target.FromRoom.Id.ToString(); - //} - - return @base; + // POC: return generic element conversion or throw? + // + //throw new SpeckleConversionException( + // $"No conditional converters registered that could convert object of type {target.GetType()}" + //); + return _elementConverter.RawConvert(target); } } diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/RawConversionRegisterer.cs b/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/RawConversionRegisterer.cs index 2158eecb66..3b212a16c4 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/RawConversionRegisterer.cs +++ b/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/RawConversionRegisterer.cs @@ -1,3 +1,4 @@ +using System.Reflection; using Autofac; using Speckle.Converters.Common.Objects; @@ -40,4 +41,27 @@ private static void RegisterRawConversionsForType(ContainerBuilder containerBuil .InstancePerLifetimeScope(); } } + + public static ContainerBuilder RegisterTypesInAssemblyAsInterface( + this ContainerBuilder containerBuilder, + Assembly assembly, + Type interfaceType + ) + { + bool isGeneric = interfaceType.IsGenericType; + foreach (var type in assembly.GetTypes().Where(type => type.IsClass && !type.IsAbstract)) + { + IEnumerable interfaceTypes = type.GetInterfaces(); + interfaceTypes = isGeneric + ? interfaceTypes.Where(it => it.IsGenericType && it.GetGenericTypeDefinition() == interfaceType) + : interfaceTypes.Where(it => it == interfaceType); + + foreach (var iterfaceTypeMatch in interfaceTypes) + { + containerBuilder.RegisterType(type).As(iterfaceTypeMatch).InstancePerLifetimeScope(); + } + } + + return containerBuilder; + } } From 113b5f86267f15f85e8510702fd5f4fd857f4e7d Mon Sep 17 00:00:00 2001 From: Jedd Morgan <45512892+JR-Morgan@users.noreply.github.com> Date: Tue, 23 Apr 2024 13:16:26 +0100 Subject: [PATCH 043/261] CNX-9315 resolve warning singular in arc gis d ui3 dx connector (#3303) Aligned default namespace in daml file to the default namespace defined in the csproj --- .../Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Config.daml | 2 +- .../{HostApp => }/SpeckleDUI3ViewModel.cs | 2 +- .../{HostApp => }/SpeckleDUI3Wrapper.cs | 3 ++- .../Speckle.Connectors.ArcGIS3/{HostApp => }/SpeckleModule.cs | 3 ++- 4 files changed, 6 insertions(+), 4 deletions(-) rename DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/{HostApp => }/SpeckleDUI3ViewModel.cs (95%) rename DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/{HostApp => }/SpeckleDUI3Wrapper.cs (75%) rename DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/{HostApp => }/SpeckleModule.cs (97%) diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Config.daml b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Config.daml index 58429098d3..d4fa8aa1f2 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Config.daml +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Config.daml @@ -17,7 +17,7 @@ limitations under the License. --> - + Speckle Speckle connector for ArcGIS diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/HostApp/SpeckleDUI3ViewModel.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/SpeckleDUI3ViewModel.cs similarity index 95% rename from DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/HostApp/SpeckleDUI3ViewModel.cs rename to DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/SpeckleDUI3ViewModel.cs index 49a9f9f807..f410120342 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/HostApp/SpeckleDUI3ViewModel.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/SpeckleDUI3ViewModel.cs @@ -1,7 +1,7 @@ using ArcGIS.Desktop.Framework; using ArcGIS.Desktop.Framework.Contracts; -namespace Speckle.Connectors.ArcGIS.HostApp; +namespace Speckle.Connectors.ArcGIS; internal class SpeckleDUI3ViewModel : DockPane { diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/HostApp/SpeckleDUI3Wrapper.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/SpeckleDUI3Wrapper.cs similarity index 75% rename from DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/HostApp/SpeckleDUI3Wrapper.cs rename to DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/SpeckleDUI3Wrapper.cs index 4035b640cb..83bb7f39b6 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/HostApp/SpeckleDUI3Wrapper.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/SpeckleDUI3Wrapper.cs @@ -1,6 +1,7 @@ using System.Windows.Controls; +using Speckle.Connectors.ArcGIS.HostApp; -namespace Speckle.Connectors.ArcGIS.HostApp; +namespace Speckle.Connectors.ArcGIS; public class SpeckleDUI3Wrapper : UserControl { diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/HostApp/SpeckleModule.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/SpeckleModule.cs similarity index 97% rename from DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/HostApp/SpeckleModule.cs rename to DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/SpeckleModule.cs index cb8fc8b54c..28e90ebc95 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/HostApp/SpeckleModule.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/SpeckleModule.cs @@ -5,12 +5,13 @@ using Speckle.Autofac.DependencyInjection; using Speckle.Autofac.Files; using Speckle.Connectors.ArcGIS.DependencyInjection; +using Speckle.Connectors.ArcGIS.HostApp; using Speckle.Converters.Common.Objects; using Speckle.Core.Kits; using Speckle.Converters.Common.DependencyInjection; using Module = ArcGIS.Desktop.Framework.Contracts.Module; -namespace Speckle.Connectors.ArcGIS.HostApp; +namespace Speckle.Connectors.ArcGIS; /// /// This sample shows how to implement pane that contains an Edge WebView2 control using the built-in ArcGIS Pro SDK's WebBrowser control. For details on how to utilize the WebBrowser control in an add-in see here: https://github.com/Esri/arcgis-pro-sdk/wiki/ProConcepts-Framework#webbrowser For details on how to utilize the Microsoft Edge web browser control in an add-in see here: https://github.com/Esri/arcgis-pro-sdk/wiki/ProConcepts-Framework#webbrowser-control From b6b43da5f2fd1344b2a63f9f6ee632f0a59747e5 Mon Sep 17 00:00:00 2001 From: KatKatKateryna <89912278+KatKatKateryna@users.noreply.github.com> Date: Tue, 23 Apr 2024 21:28:34 +0800 Subject: [PATCH 044/261] CNX-9144 dui3 arcgis basic receive (#3283) * Implement receive binding and host object builder * Initial receive attempt (WIP) * convert to host vector layer; create a new database * create and add database connection to project * receiving point layer, add to Map * clear the table before re-receiving; catch invalid layer names * formatting * more formatting * PR comments * fixes after merging * injecting interfaces; POC comments; Exceptons handling * post-merge fixes * latest change --------- Co-authored-by: oguzhankoral --- .../Bindings/ArcGISReceiveBinding.cs | 87 +++++++++++++ .../AutofacArcGISModule.cs | 14 +- .../Operations/Receive/HostObjectBuilder.cs | 96 ++++++++++++++ .../AutofacArcGIS3ConverterModule.cs | 13 +- .../ArcGISConverterToHost.cs | 40 ++++++ .../Features/GeometryToSpeckleBase.cs | 25 ++-- .../Features/GisFeatureToHostConverter.cs | 51 ++++++++ .../Features/GisFeatureToSpeckleConverter.cs | 8 +- .../MultipointFeatureToSpeckleConverter.cs | 11 +- .../PointFeatureToSpeckleConverter.cs | 36 +++++ .../PolygonFeatureToSpeckleConverter.cs | 11 +- .../PolylineFeatureToSpeckleConverter.cs | 9 +- .../BezierSegmentToSpeckleConverter.cs | 15 +-- .../EllipticArcSegmentToSpeckleConverter.cs | 15 +-- .../Geometry/PointToHostConverter.cs | 14 ++ .../Geometry/PolygonToHostConverter.cs | 23 ++++ .../Geometry/PolylineToHostConverter.cs | 63 +++++++++ .../SegmentCollectionToSpeckleConverter.cs | 31 +++-- .../GlobalUsings.cs | 1 + .../Layers/VectorLayerToHostConverter.cs | 123 ++++++++++++++++++ .../Speckle.Converters.ArcGIS3.csproj | 2 +- .../Utils/ArcGISProjectUtils.cs | 80 ++++++++++++ .../Utils/FeatureClassUtils.cs | 94 +++++++++++++ .../Utils/IArcGISProjectUtils.cs | 7 + .../Utils/IFeatureClassUtils.cs | 18 +++ 25 files changed, 816 insertions(+), 71 deletions(-) create mode 100644 DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISReceiveBinding.cs create mode 100644 DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Receive/HostObjectBuilder.cs create mode 100644 DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ArcGISConverterToHost.cs create mode 100644 DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GisFeatureToHostConverter.cs create mode 100644 DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/PointFeatureToSpeckleConverter.cs create mode 100644 DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/PointToHostConverter.cs create mode 100644 DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/PolygonToHostConverter.cs create mode 100644 DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/PolylineToHostConverter.cs create mode 100644 DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/VectorLayerToHostConverter.cs create mode 100644 DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/ArcGISProjectUtils.cs create mode 100644 DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/FeatureClassUtils.cs create mode 100644 DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/IArcGISProjectUtils.cs create mode 100644 DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/IFeatureClassUtils.cs diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISReceiveBinding.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISReceiveBinding.cs new file mode 100644 index 0000000000..3b143a972f --- /dev/null +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISReceiveBinding.cs @@ -0,0 +1,87 @@ +using Speckle.Connectors.ArcGIS.Utils; +using Speckle.Connectors.DUI.Bindings; +using Speckle.Connectors.DUI.Bridge; +using Speckle.Connectors.DUI.Models.Card; +using Speckle.Connectors.Utils.Cancellation; +using Speckle.Connectors.Utils.Operations; +using Speckle.Core.Logging; +using ICancelable = System.Reactive.Disposables.ICancelable; + +namespace Speckle.Connectors.ArcGIS.Bindings; + +public sealed class ArcGISReceiveBinding : IReceiveBinding, ICancelable +{ + public string Name { get; } = "receiveBinding"; + private readonly CancellationManager _cancellationManager; + private readonly ArcGISDocumentStore _store; + private readonly ReceiveOperation _receiveOperation; + public ReceiveBindingUICommands Commands { get; } + public IBridge Parent { get; } + + public ArcGISReceiveBinding( + ArcGISDocumentStore store, + IBridge parent, + ReceiveOperation receiveOperation, + CancellationManager cancellationManager + ) + { + _store = store; + _cancellationManager = cancellationManager; + _receiveOperation = receiveOperation; + Parent = parent; + Commands = new ReceiveBindingUICommands(parent); + } + + public async Task Receive(string modelCardId) + { + try + { + // Init cancellation token source -> Manager also cancel it if exist before + CancellationTokenSource cts = _cancellationManager.InitCancellationTokenSource(modelCardId); + + // Get receiver card + if (_store.GetModelById(modelCardId) is not ReceiverModelCard modelCard) + { + throw new InvalidOperationException("No download model card was found."); + } + + // Receive host objects + IEnumerable receivedObjectIds = await _receiveOperation + .Execute( + modelCard.AccountId, // POC: I hear -you are saying why we're passing them separately. Not sure pass the DUI3-> Connectors.DUI project dependency to the SDK-> Connector.Utils + modelCard.ProjectId, + modelCard.ProjectName, + modelCard.ModelName, + modelCard.SelectedVersionId, + cts.Token, + (status, progress) => OnSendOperationProgress(modelCardId, status, progress) + ) + .ConfigureAwait(false); + + Commands.SetModelReceiveResult(modelCardId, receivedObjectIds.ToList()); + } + catch (OperationCanceledException) + { + // POC: not sure here need to handle anything. UI already aware it cancelled operation visually. + return; + } + catch (Exception e) when (!e.IsFatal()) // All exceptions should be handled here if possible, otherwise we enter "crashing the host app" territory. + { + Commands.SetModelError(modelCardId, e); + } + } + + private void OnSendOperationProgress(string modelCardId, string status, double? progress) + { + Commands.SetModelProgress(modelCardId, new ModelCardProgress { Status = status, Progress = progress }); + } + + public void CancelReceive(string modelCardId) => _cancellationManager.CancelOperation(modelCardId); + + public void Dispose() + { + IsDisposed = true; + } + + public bool IsDisposed { get; private set; } +} diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/DependencyInjection/AutofacArcGISModule.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/DependencyInjection/AutofacArcGISModule.cs index 2d924e53bc..7306371176 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/DependencyInjection/AutofacArcGISModule.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/DependencyInjection/AutofacArcGISModule.cs @@ -15,8 +15,11 @@ using Speckle.Connectors.Utils.Cancellation; using Speckle.Converters.ArcGIS3; using Speckle.Core.Transports; -using ArcGIS.Core.Geometry; +using Speckle.Connectors.ArcGIS.Operations.Receive; using Speckle.Connectors.DUI.Models.Card.SendFilter; +using Speckle.Connectors.Utils.Builders; +using Speckle.Connectors.Utils.Operations; +using ArcGIS.Core.Geometry; using Speckle.Connectors.ArcGIS.Filters; namespace Speckle.Connectors.ArcGIS.DependencyInjection; @@ -41,8 +44,17 @@ protected override void Load(ContainerBuilder builder) builder.RegisterType().As().As().SingleInstance(); builder.RegisterType().As().SingleInstance(); builder.RegisterType().As().SingleInstance(); + builder.RegisterType().As().SingleInstance(); builder.RegisterType().As>().SingleInstance(); + // Operations + builder.RegisterType().AsSelf().InstancePerLifetimeScope(); + builder.RegisterType().As().SingleInstance(); + + // Object Builders + builder.RegisterType().As().InstancePerDependency(); + // POC: Register here also RootObjectBuilder as IRootObjectBuilder + // binding dependencies builder.RegisterType().InstancePerDependency(); diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Receive/HostObjectBuilder.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Receive/HostObjectBuilder.cs new file mode 100644 index 0000000000..9f5f60c8a6 --- /dev/null +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Receive/HostObjectBuilder.cs @@ -0,0 +1,96 @@ +using System.Diagnostics; +using ArcGIS.Desktop.Mapping; +using Speckle.Connectors.Utils.Builders; +using Speckle.Converters.Common; +using Speckle.Core.Logging; +using Speckle.Core.Models; +using Speckle.Core.Models.Extensions; +using ArcGIS.Desktop.Framework.Threading.Tasks; +using Speckle.Converters.ArcGIS3.Utils; + +namespace Speckle.Connectors.ArcGIS.Operations.Receive; + +public class HostObjectBuilder : IHostObjectBuilder +{ + private readonly ISpeckleConverterToHost _toHostConverter; + private readonly IArcGISProjectUtils _arcGISProjectUtils; + + // POC: figure out the correct scope to only initialize on Receive + // private readonly IConversionContextStack _contextStack; + + public HostObjectBuilder( + ISpeckleConverterToHost toHostConverter, + IArcGISProjectUtils arcGISProjectUtils + // IConversionContextStack contextStack + ) + { + _toHostConverter = toHostConverter; + _arcGISProjectUtils = arcGISProjectUtils; + // _contextStack = contextStack; + } + + public IEnumerable Build( + Base rootObject, + string projectName, + string modelName, + Action? onOperationProgressed, + CancellationToken cancellationToken + ) + { + // Prompt the UI conversion started. Progress bar will swoosh. + onOperationProgressed?.Invoke("Converting", null); + + // create and add Geodatabase to a project + + string databasePath = _arcGISProjectUtils.GetDatabasePath(); + _arcGISProjectUtils.AddDatabaseToProject(databasePath); + + // POC: This is where we will define our receive strategy, or maybe later somewhere else according to some setting pass from UI? + IEnumerable<(List, Base)> objectsWithPath = rootObject.TraverseWithPath((obj) => obj is not Collection); + + List objectIds = new(); + int count = 0; + foreach ((List path, Base obj) in objectsWithPath) + { + if (cancellationToken.IsCancellationRequested) + { + throw new OperationCanceledException(cancellationToken); + } + + try + { + // BAKE OBJECTS HERE + + // POC: QueuedTask + QueuedTask.Run(() => + { + try + { + var converted = _toHostConverter.Convert(obj); + if (converted is string uri) + { + objectIds.Add(obj.id); + // TODO: get map from contextStack instead + LayerFactory.Instance.CreateLayer(new Uri($"{databasePath}\\{uri}"), MapView.Active.Map); + } + } + catch (ArgumentException) + { + // for the layers with "invalid" names + // doesn't do anything actually, but needs to be logged + throw; + } + }); + + onOperationProgressed?.Invoke("Converting", (double)++count / objectsWithPath.Count()); + } + catch (Exception e) when (!e.IsFatal()) // DO NOT CATCH SPECIFIC STUFF, conversion errors should be recoverable + { + // POC: report, etc. + Debug.WriteLine("conversion error happened."); + } + } + + return objectIds; + } +} diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3.DependencyInjection/AutofacArcGIS3ConverterModule.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3.DependencyInjection/AutofacArcGIS3ConverterModule.cs index 8d3af993d1..471d214270 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3.DependencyInjection/AutofacArcGIS3ConverterModule.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3.DependencyInjection/AutofacArcGIS3ConverterModule.cs @@ -4,6 +4,7 @@ using ArcGIS.Desktop.Mapping; using Autofac; using Speckle.Autofac.DependencyInjection; +using Speckle.Converters.ArcGIS3.Utils; using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; @@ -14,7 +15,10 @@ public class AutofacArcGISConverterModule : Module protected override void Load(ContainerBuilder builder) { // most things should be InstancePerLifetimeScope so we get one per operation - builder.RegisterType().As().SingleInstance(); + builder.RegisterType().As().InstancePerLifetimeScope(); + builder.RegisterType().As().InstancePerLifetimeScope(); + builder.RegisterType().As().InstancePerLifetimeScope(); + builder.RegisterType().As().InstancePerLifetimeScope(); // single stack per conversion builder @@ -25,6 +29,11 @@ protected override void Load(ContainerBuilder builder) // factory for conversions builder .RegisterType>() - .As>(); + .As>() + .InstancePerLifetimeScope(); + builder + .RegisterType>() + .As>() + .InstancePerLifetimeScope(); } } diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ArcGISConverterToHost.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ArcGISConverterToHost.cs new file mode 100644 index 0000000000..20fe58a278 --- /dev/null +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ArcGISConverterToHost.cs @@ -0,0 +1,40 @@ +using Speckle.Autofac.DependencyInjection; +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; +using Speckle.Core.Models; + +namespace Speckle.Converters.ArcGIS3; + +public class ArcGISConverterToHost : ISpeckleConverterToHost +{ + private readonly IFactory _toHost; + + public ArcGISConverterToHost(IFactory toHost) + { + _toHost = toHost; + } + + public object Convert(Base target) + { + Type type = target.GetType(); + + try + { + var objectConverter = _toHost.ResolveInstance(type.Name); + + if (objectConverter == null) + { + throw new NotSupportedException($"No conversion found for {target.GetType().Name}"); + } + + var convertedObject = objectConverter.Convert(target); + + return convertedObject; + } + catch (SpeckleConversionException e) + { + Console.WriteLine(e); + throw; // POC: Just rethrowing for now, Logs may be needed here. + } + } +} diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GeometryToSpeckleBase.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GeometryToSpeckleBase.cs index 2ef8379ebd..83a8dd3020 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GeometryToSpeckleBase.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GeometryToSpeckleBase.cs @@ -1,4 +1,3 @@ -using ArcGIS.Core.Geometry; using Objects.GIS; using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; @@ -8,16 +7,16 @@ namespace Speckle.Converters.ArcGIS3.Features; public class GeometryToSpeckleBaseList : IRawConversion> { - private readonly IRawConversion _pointToSpeckleConverter; - private readonly IRawConversion> _multiPointFeatureConverter; - private readonly IRawConversion> _polylineFeatureConverter; - private readonly IRawConversion> _polygonFeatureConverter; + private readonly IRawConversion _pointToSpeckleConverter; + private readonly IRawConversion> _multiPointFeatureConverter; + private readonly IRawConversion> _polylineFeatureConverter; + private readonly IRawConversion> _polygonFeatureConverter; public GeometryToSpeckleBaseList( - IRawConversion pointToSpeckleConverter, - IRawConversion> multiPointFeatureConverter, - IRawConversion> polylineFeatureConverter, - IRawConversion> polygonFeatureConverter + IRawConversion pointToSpeckleConverter, + IRawConversion> multiPointFeatureConverter, + IRawConversion> polylineFeatureConverter, + IRawConversion> polygonFeatureConverter ) { _pointToSpeckleConverter = pointToSpeckleConverter; @@ -32,10 +31,10 @@ public IReadOnlyList RawConvert(ArcGIS.Core.Geometry.Geometry target) { return target switch { - MapPoint point => new List() { _pointToSpeckleConverter.RawConvert(point) }, - Multipoint multipoint => _multiPointFeatureConverter.RawConvert(multipoint), - Polyline polyline => _polylineFeatureConverter.RawConvert(polyline), - Polygon polygon => _polygonFeatureConverter.RawConvert(polygon), + ACG.MapPoint point => new List() { _pointToSpeckleConverter.RawConvert(point) }, + ACG.Multipoint multipoint => _multiPointFeatureConverter.RawConvert(multipoint), + ACG.Polyline polyline => _polylineFeatureConverter.RawConvert(polyline), + ACG.Polygon polygon => _polygonFeatureConverter.RawConvert(polygon), _ => throw new NotSupportedException($"No conversion found for {target.GetType().Name}"), }; } diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GisFeatureToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GisFeatureToHostConverter.cs new file mode 100644 index 0000000000..1c79a990a8 --- /dev/null +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GisFeatureToHostConverter.cs @@ -0,0 +1,51 @@ +using ArcGIS.Desktop.Mapping; +using Objects.GIS; +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; +using Speckle.Core.Models; + +namespace Speckle.Converters.ArcGIS3.Features; + +public class GisFeatureToHostConverter : IRawConversion +{ + private readonly IConversionContextStack _contextStack; + private readonly IRawConversion _polylineConverter; + private readonly IRawConversion _pointConverter; + private readonly IRawConversion _polygonConverter; + + public GisFeatureToHostConverter( + IConversionContextStack contextStack, + IRawConversion polylineConverter, + IRawConversion pointConverter, + IRawConversion polygonConverter + ) + { + _contextStack = contextStack; + _polylineConverter = polylineConverter; + _pointConverter = pointConverter; + _polygonConverter = polygonConverter; + } + + public ACG.Geometry RawConvert(Base target) + { + if (target.speckle_type.ToLower().Contains("point")) + { + return _pointConverter.RawConvert((SOG.Point)target); + } + else if (target.speckle_type.ToLower().Contains("polyline")) + { + // POC: TODO + } + else if (target.speckle_type.ToLower().Contains("polygon")) + { + // POC: TODO + } + else + { + throw new SpeckleConversionException($"Unknown geometry type {target.speckle_type}"); + } + throw new SpeckleConversionException($"Conversion of geometry {target} failed"); + } + // POC: TODO: Add case for NonGeometry Feature (table entry) + // IF geometry layer, but no geometry found: throw new SpeckleConversionException($"Feature {target} contains no geometry"); +} diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GisFeatureToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GisFeatureToSpeckleConverter.cs index 1d73a30ec1..aa0c709ebc 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GisFeatureToSpeckleConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GisFeatureToSpeckleConverter.cs @@ -7,11 +7,9 @@ namespace Speckle.Converters.ArcGIS3.Features; public class GisFeatureToSpeckleConverter : IRawConversion { - private readonly IRawConversion> _geometryConverter; + private readonly IRawConversion> _geometryConverter; - public GisFeatureToSpeckleConverter( - IRawConversion> geometryConverter - ) + public GisFeatureToSpeckleConverter(IRawConversion> geometryConverter) { _geometryConverter = geometryConverter; } @@ -20,7 +18,7 @@ public GisFeatureToSpeckleConverter( public GisFeature RawConvert(Row target) { - var shape = (ArcGIS.Core.Geometry.Geometry)target["Shape"]; + var shape = (ACG.Geometry)target["Shape"]; var speckleShapes = _geometryConverter.RawConvert(shape).ToList(); // get attributes diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/MultipointFeatureToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/MultipointFeatureToSpeckleConverter.cs index 8fa34a7939..6d7abbab9a 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/MultipointFeatureToSpeckleConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/MultipointFeatureToSpeckleConverter.cs @@ -1,21 +1,20 @@ -using ArcGIS.Core.Geometry; using Speckle.Converters.Common.Objects; namespace Speckle.Converters.ArcGIS3.Features; -public class MultipointFeatureToSpeckleConverter : IRawConversion> +public class MultipointFeatureToSpeckleConverter : IRawConversion> { - private readonly IRawConversion _pointConverter; + private readonly IRawConversion _pointConverter; - public MultipointFeatureToSpeckleConverter(IRawConversion pointConverter) + public MultipointFeatureToSpeckleConverter(IRawConversion pointConverter) { _pointConverter = pointConverter; } - public IReadOnlyList RawConvert(Multipoint target) + public IReadOnlyList RawConvert(ACG.Multipoint target) { List multipoint = new(); - foreach (MapPoint point in target.Points) + foreach (ACG.MapPoint point in target.Points) { multipoint.Add(_pointConverter.RawConvert(point)); } diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/PointFeatureToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/PointFeatureToSpeckleConverter.cs new file mode 100644 index 0000000000..7f26b81371 --- /dev/null +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/PointFeatureToSpeckleConverter.cs @@ -0,0 +1,36 @@ +using Speckle.Converters.Common.Objects; +using Speckle.Core.Models; +using Speckle.Converters.Common; +using ArcGIS.Desktop.Mapping; + +namespace Speckle.Converters.ArcGIS3.Features; + +[NameAndRankValue(nameof(ACG.MapPoint), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +public class PointFeatureToSpeckleConverter : IHostObjectToSpeckleConversion, IRawConversion +{ + private readonly IConversionContextStack _contextStack; + + public PointFeatureToSpeckleConverter(IConversionContextStack contextStack) + { + _contextStack = contextStack; + } + + public Base Convert(object target) => RawConvert((ACG.MapPoint)target); + + public Base RawConvert(ACG.MapPoint target) + { + if ( + ACG.GeometryEngine.Instance.Project(target, _contextStack.Current.Document.SpatialReference) + is not ACG.MapPoint reprojectedPt + ) + { + throw new SpeckleConversionException( + $"Conversion to Spatial Reference {_contextStack.Current.Document.SpatialReference} failed" + ); + } + List geometry = + new() { new SOG.Point(reprojectedPt.X, reprojectedPt.Y, reprojectedPt.Z, _contextStack.Current.SpeckleUnits) }; + + return geometry[0]; + } +} diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/PolygonFeatureToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/PolygonFeatureToSpeckleConverter.cs index e312bd16ad..1017b1f480 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/PolygonFeatureToSpeckleConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/PolygonFeatureToSpeckleConverter.cs @@ -1,19 +1,18 @@ -using ArcGIS.Core.Geometry; using Speckle.Converters.Common.Objects; using Objects.GIS; namespace Speckle.Converters.ArcGIS3.Features; -public class PolygonFeatureToSpeckleConverter : IRawConversion> +public class PolygonFeatureToSpeckleConverter : IRawConversion> { - private readonly IRawConversion _segmentConverter; + private readonly IRawConversion _segmentConverter; - public PolygonFeatureToSpeckleConverter(IRawConversion segmentConverter) + public PolygonFeatureToSpeckleConverter(IRawConversion segmentConverter) { _segmentConverter = segmentConverter; } - public IReadOnlyList RawConvert(Polygon target) + public IReadOnlyList RawConvert(ACG.Polygon target) { // https://pro.arcgis.com/en/pro-app/latest/sdk/api-reference/topic30235.html List polygonList = new(); @@ -23,7 +22,7 @@ public IReadOnlyList RawConvert(Polygon target) // test each part for "exterior ring" for (int idx = 0; idx < partCount; idx++) { - ReadOnlySegmentCollection segmentCollection = target.Parts[idx]; + ACG.ReadOnlySegmentCollection segmentCollection = target.Parts[idx]; SOG.Polyline polyline = _segmentConverter.RawConvert(segmentCollection); bool isExteriorRing = target.IsExteriorRing(idx); diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/PolylineFeatureToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/PolylineFeatureToSpeckleConverter.cs index 96c7e35574..e9bd50001e 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/PolylineFeatureToSpeckleConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/PolylineFeatureToSpeckleConverter.cs @@ -1,18 +1,17 @@ -using ArcGIS.Core.Geometry; using Speckle.Converters.Common.Objects; namespace Speckle.Converters.ArcGIS3.Features; -public class PolyineFeatureToSpeckleConverter : IRawConversion> +public class PolyineFeatureToSpeckleConverter : IRawConversion> { - private readonly IRawConversion _segmentConverter; + private readonly IRawConversion _segmentConverter; - public PolyineFeatureToSpeckleConverter(IRawConversion segmentConverter) + public PolyineFeatureToSpeckleConverter(IRawConversion segmentConverter) { _segmentConverter = segmentConverter; } - public IReadOnlyList RawConvert(Polyline target) + public IReadOnlyList RawConvert(ACG.Polyline target) { // https://pro.arcgis.com/en/pro-app/latest/sdk/api-reference/topic8480.html List polylineList = new(); diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/BezierSegmentToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/BezierSegmentToSpeckleConverter.cs index 3bd981ce71..71638333da 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/BezierSegmentToSpeckleConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/BezierSegmentToSpeckleConverter.cs @@ -1,25 +1,24 @@ -using ArcGIS.Core.Geometry; using Speckle.Converters.Common.Objects; using Speckle.Converters.Common; using ArcGIS.Desktop.Mapping; namespace Speckle.Converters.ArcGIS3.Geometry; -public class BezierSegmentToSpeckleConverter : IRawConversion +public class BezierSegmentToSpeckleConverter : IRawConversion { - private readonly IConversionContextStack _contextStack; - private readonly IRawConversion _pointConverter; + private readonly IConversionContextStack _contextStack; + private readonly IRawConversion _pointConverter; public BezierSegmentToSpeckleConverter( - IConversionContextStack contextStack, - IRawConversion pointConverter + IConversionContextStack contextStack, + IRawConversion pointConverter ) { _contextStack = contextStack; _pointConverter = pointConverter; } - public SOG.Polyline RawConvert(CubicBezierSegment target) + public SOG.Polyline RawConvert(ACG.CubicBezierSegment target) { // Determine the number of vertices to create along the arc int numVertices = Math.Max((int)target.Length, 3); // Determine based on desired segment length or other criteria @@ -43,7 +42,7 @@ public SOG.Polyline RawConvert(CubicBezierSegment target) + 3 * (1 - t) * t * t * target.ControlPoint2.Y + t * t * t * target.EndPoint.Y; - MapPoint pointOnCurve = MapPointBuilderEx.CreateMapPoint(x, y, target.SpatialReference); + ACG.MapPoint pointOnCurve = ACG.MapPointBuilderEx.CreateMapPoint(x, y, target.SpatialReference); points.Add(_pointConverter.RawConvert(pointOnCurve)); } diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/EllipticArcSegmentToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/EllipticArcSegmentToSpeckleConverter.cs index 44f3d2ffbc..11905f94a8 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/EllipticArcSegmentToSpeckleConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/EllipticArcSegmentToSpeckleConverter.cs @@ -1,25 +1,24 @@ -using ArcGIS.Core.Geometry; using Speckle.Converters.Common.Objects; using Speckle.Converters.Common; using ArcGIS.Desktop.Mapping; namespace Speckle.Converters.ArcGIS3.Geometry; -public class EllipticArcToSpeckleConverter : IRawConversion +public class EllipticArcToSpeckleConverter : IRawConversion { - private readonly IConversionContextStack _contextStack; - private readonly IRawConversion _pointConverter; + private readonly IConversionContextStack _contextStack; + private readonly IRawConversion _pointConverter; public EllipticArcToSpeckleConverter( - IConversionContextStack contextStack, - IRawConversion pointConverter + IConversionContextStack contextStack, + IRawConversion pointConverter ) { _contextStack = contextStack; _pointConverter = pointConverter; } - public SOG.Polyline RawConvert(EllipticArcSegment target) + public SOG.Polyline RawConvert(ACG.EllipticArcSegment target) { // Determine the number of vertices to create along the arc int numVertices = Math.Max((int)target.Length, 3); // Determine based on desired segment length or other criteria @@ -47,7 +46,7 @@ public SOG.Polyline RawConvert(EllipticArcSegment target) { // Calculate the point along the arc double angle = angleStart + coeff * fullAngle * (i / (double)numVertices); - MapPoint pointOnArc = MapPointBuilderEx.CreateMapPoint( + ACG.MapPoint pointOnArc = ACG.MapPointBuilderEx.CreateMapPoint( target.CenterPoint.X + target.SemiMajorAxis * Math.Cos(angle), target.CenterPoint.Y + target.SemiMinorAxis * Math.Sin(angle), target.SpatialReference diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/PointToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/PointToHostConverter.cs new file mode 100644 index 0000000000..90c37090d4 --- /dev/null +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/PointToHostConverter.cs @@ -0,0 +1,14 @@ +using Speckle.Converters.Common.Objects; +using Speckle.Converters.Common; + +namespace Speckle.Converters.ArcGIS3.Geometry; + +[NameAndRankValue(nameof(ACG.MapPoint), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +public class PointToHostConverter : IRawConversion +{ + public ACG.Multipoint RawConvert(SOG.Point target) + { + ACG.MapPoint mapPoint = new ACG.MapPointBuilderEx(target.x, target.y, target.z).ToGeometry(); + return new ACG.MultipointBuilderEx(mapPoint).ToGeometry(); + } +} diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/PolygonToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/PolygonToHostConverter.cs new file mode 100644 index 0000000000..1aacac96ca --- /dev/null +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/PolygonToHostConverter.cs @@ -0,0 +1,23 @@ +using Speckle.Converters.Common.Objects; +using Speckle.Converters.Common; +using Objects.GIS; + +namespace Speckle.Converters.ArcGIS3.Geometry; + +[NameAndRankValue(nameof(GisPolygonGeometry), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +public class PolygonToHostConverter : IRawConversion +{ + public ACG.Polygon RawConvert(GisPolygonGeometry target) + { + // POC: TODO: To replace with actual geometry + List newCoordinates = + new() + { + new ACG.Coordinate2D(1021570, 1880583), + new ACG.Coordinate2D(1028730, 1880994), + new ACG.Coordinate2D(1029718, 1875644), + new ACG.Coordinate2D(1021405, 1875397) + }; + return new ACG.PolygonBuilderEx(newCoordinates).ToGeometry(); + } +} diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/PolylineToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/PolylineToHostConverter.cs new file mode 100644 index 0000000000..9bbc899c19 --- /dev/null +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/PolylineToHostConverter.cs @@ -0,0 +1,63 @@ +using ArcGIS.Core.Internal.Geometry; +using ArcGIS.Desktop.Mapping; +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; +using Speckle.Core.Kits; +using Speckle.Core.Models; + +namespace Speckle.Converters.ArcGIS3.Geometry; + +[NameAndRankValue(nameof(SOG.Polyline), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +public class PolylineToHostConverter : ISpeckleObjectToHostConversion, IRawConversion +{ + private readonly IConversionContextStack _contextStack; + + public PolylineToHostConverter(IConversionContextStack contextStack) + { + _contextStack = contextStack; + } + + public object Convert(Base target) => RawConvert((SOG.Polyline)target); + + public ACG.Polyline RawConvert(SOG.Polyline target) + { + // TODO: leave the units as received and assign received CRS at layer level as well + double f = Units.GetConversionFactor(target.units, _contextStack.Current.SpeckleUnits); + List coordinates = target.value; + + // POC: retrieve here exact wkt. Not hard coded! + string wkt = + "PROJCS[\"WGS_1984_Web_Mercator_Auxiliary_Sphere\",GEOGCS[\"GCS_WGS_1984\",DATUM[\"D_WGS_1984\",SPHEROID[\"WGS_1984\",6378137.0,298.257223563]],PRIMEM[\"Greenwich\",0.0],UNIT[\"Degree\",0.0174532925199433]],PROJECTION[\"Mercator_Auxiliary_Sphere\"],PARAMETER[\"False_Easting\",0.0],PARAMETER[\"False_Northing\",0.0],PARAMETER[\"Central_Meridian\",0.0],PARAMETER[\"Standard_Parallel_1\",0.0],PARAMETER[\"Auxiliary_Sphere_Type\",0.0],UNIT[\"Meter\",1.0]]\n"; + + ACG.SpatialReference spatialReference = ACG.SpatialReferenceBuilder.CreateSpatialReference(wkt); + + var points = coordinates + .Select((value, index) => new { value, index }) + .GroupBy(x => x.index / 3) + .Select( + group => + MapPointBuilder.CreateMapPoint( + group.ElementAt(0).value * f, // X + group.ElementAt(1).value * f, // Y + group.ElementAt(2).value * f, // Z + spatialReference + ) + ) + .ToList(); + + PolylineBuilder polylineBuilder = new(points.First().SpatialReference); + + var startPoint = points.First(); + for (int i = 1; i < points.Count; i++) + { + var lineSegment = LineBuilder.CreateLineSegment(startPoint, points[i]); + polylineBuilder.AddSegment(lineSegment); + startPoint = points[i]; + } + + ACG.Polyline polyline = polylineBuilder.ToGeometry(); + + polylineBuilder.Dispose(); + return polyline; + } +} diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/SegmentCollectionToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/SegmentCollectionToSpeckleConverter.cs index 72dff64b19..1aabe1e188 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/SegmentCollectionToSpeckleConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/SegmentCollectionToSpeckleConverter.cs @@ -1,22 +1,21 @@ -using ArcGIS.Core.Geometry; using ArcGIS.Desktop.Mapping; using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; namespace Speckle.Converters.ArcGIS3.Geometry; -public class SegmentCollectionToSpeckleConverter : IRawConversion +public class SegmentCollectionToSpeckleConverter : IRawConversion { - private readonly IConversionContextStack _contextStack; - private readonly IRawConversion _pointConverter; - private readonly IRawConversion _arcConverter; - private readonly IRawConversion _bezierConverter; + private readonly IConversionContextStack _contextStack; + private readonly IRawConversion _pointConverter; + private readonly IRawConversion _arcConverter; + private readonly IRawConversion _bezierConverter; public SegmentCollectionToSpeckleConverter( - IConversionContextStack contextStack, - IRawConversion pointConverter, - IRawConversion arcConverter, - IRawConversion bezierConverter + IConversionContextStack contextStack, + IRawConversion pointConverter, + IRawConversion arcConverter, + IRawConversion bezierConverter ) { _contextStack = contextStack; @@ -25,7 +24,7 @@ public SegmentCollectionToSpeckleConverter( _bezierConverter = bezierConverter; } - public SOG.Polyline RawConvert(ReadOnlySegmentCollection target) + public SOG.Polyline RawConvert(ACG.ReadOnlySegmentCollection target) { // https://pro.arcgis.com/en/pro-app/latest/sdk/api-reference/topic8480.html double len = 0; @@ -38,16 +37,16 @@ public SOG.Polyline RawConvert(ReadOnlySegmentCollection target) // do something specific per segment type switch (segment.SegmentType) { - case SegmentType.Line: + case ACG.SegmentType.Line: points.Add(_pointConverter.RawConvert(segment.StartPoint)); points.Add(_pointConverter.RawConvert(segment.EndPoint)); break; - case SegmentType.Bezier: - var segmentBezier = (CubicBezierSegment)segment; + case ACG.SegmentType.Bezier: + var segmentBezier = (ACG.CubicBezierSegment)segment; points.AddRange(_bezierConverter.RawConvert(segmentBezier).GetPoints()); break; - case SegmentType.EllipticArc: - var segmentElliptic = (EllipticArcSegment)segment; + case ACG.SegmentType.EllipticArc: + var segmentElliptic = (ACG.EllipticArcSegment)segment; points.AddRange(_arcConverter.RawConvert(segmentElliptic).GetPoints()); break; } diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/GlobalUsings.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/GlobalUsings.cs index 8638404840..0f5d9556a6 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/GlobalUsings.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/GlobalUsings.cs @@ -1,2 +1,3 @@ global using SOG = Objects.Geometry; // global using SOP = Objects.Primitive; +global using ACG = ArcGIS.Core.Geometry; diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/VectorLayerToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/VectorLayerToHostConverter.cs new file mode 100644 index 0000000000..05dd3033a4 --- /dev/null +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/VectorLayerToHostConverter.cs @@ -0,0 +1,123 @@ +using ArcGIS.Core.Data; +using ArcGIS.Core.Data.DDL; +using ArcGIS.Core.Data.Exceptions; +using ArcGIS.Core.Geometry; +using ArcGIS.Desktop.Framework.Threading.Tasks; +using ArcGIS.Desktop.Mapping; +using Objects.GIS; +using Speckle.Converters.ArcGIS3.Utils; +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; +using Speckle.Core.Models; +using FieldDescription = ArcGIS.Core.Data.DDL.FieldDescription; + +namespace Speckle.Converters.ArcGIS3.Layers; + +[NameAndRankValue(nameof(VectorLayer), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +public class VectorLayerToHostConverter : ISpeckleObjectToHostConversion, IRawConversion +{ + private readonly IConversionContextStack _contextStack; + private readonly IRawConversion _gisGeometryConverter; + private readonly IFeatureClassUtils _featureClassUtils; + private readonly IArcGISProjectUtils _arcGISProjectUtils; + + public VectorLayerToHostConverter( + IConversionContextStack contextStack, + IRawConversion gisGeometryConverter, + IFeatureClassUtils featureClassUtils, + IArcGISProjectUtils arcGISProjectUtils + ) + { + _contextStack = contextStack; + _gisGeometryConverter = gisGeometryConverter; + _featureClassUtils = featureClassUtils; + _arcGISProjectUtils = arcGISProjectUtils; + } + + public object Convert(Base target) => RawConvert((VectorLayer)target); + + private const string FID_FIELD_NAME = "OBJECTID"; + + public string RawConvert(VectorLayer target) + { + try + { + // POC: define the best place to start QueuedTask (entire receive or per converter) + return QueuedTask + .Run(() => + { + string databasePath = _arcGISProjectUtils.GetDatabasePath(); + FileGeodatabaseConnectionPath fileGeodatabaseConnectionPath = new(new Uri(databasePath)); + Geodatabase geodatabase = new(fileGeodatabaseConnectionPath); + SchemaBuilder schemaBuilder = new(geodatabase); + + // getting rid of forbidden symbols in the class name: + // https://pro.arcgis.com/en/pro-app/3.1/tool-reference/tool-errors-and-warnings/001001-010000/tool-errors-and-warnings-00001-00025-000020.htm + string featureClassName = target.id; + // $"{target.id}___{target.name.Replace(" ", "_").Replace("%", "_").Replace("*", "_")}"; + + string wktString = string.Empty; + if (target.crs is not null && target.crs.wkt is not null) + { + wktString = target.crs.wkt.ToString(); + } + SpatialReference spatialRef = SpatialReferenceBuilder.CreateSpatialReference(wktString); + + GeometryType geomType = _featureClassUtils.GetLayerGeometryType(target); + + // Create FeatureClass + List fields = new(); + List fieldAdded = new(); + foreach (var field in target.attributes.GetMembers(DynamicBaseMemberType.Dynamic)) + { + if (!fieldAdded.Contains(field.Key) && field.Key != FID_FIELD_NAME) + { + // POC: TODO: choose the right type for Field + // TODO check for the forbidden characters/combinations: https://support.esri.com/en-us/knowledge-base/what-characters-should-not-be-used-in-arcgis-for-field--000005588 + + // POC: assemble constants in a shared place + // fields.Add(new FieldDescription(field, FieldType.Integer)); + fields.Add(FieldDescription.CreateStringField(field.Key, 255)); // (int)(long)target.attributes[field.Value])); + fieldAdded.Add(field.Key); + } + } + try + { + FeatureClassDescription featureClassDescription = + new(featureClassName, fields, new ShapeDescription(geomType, spatialRef)); + FeatureClassToken featureClassToken = schemaBuilder.Create(featureClassDescription); + } + catch (ArgumentException ex) + { + // if name has invalid characters/combinations + throw new ArgumentException($"{ex.Message}: {featureClassName}"); + } + + bool buildStatus = schemaBuilder.Build(); + if (!buildStatus) + { + // POC: log somewhere the error in building the feature class + IReadOnlyList errors = schemaBuilder.ErrorMessages; + } + + // Add features to the FeatureClass + FeatureClass newFeatureClass = geodatabase.OpenDataset(featureClassName); + // TODO: repeat for other geometry types + if (geomType == GeometryType.Multipoint) + { + geodatabase.ApplyEdits(() => + { + _featureClassUtils.AddFeaturesToFeatureClass(newFeatureClass, target, fieldAdded, _gisGeometryConverter); + }); + } + return featureClassName; + }) + .Result; + } + catch (GeodatabaseException exObj) + { + // POC: review the exception + throw new InvalidOperationException($"Something went wrong: {exObj.Message}"); + } + } +} diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Speckle.Converters.ArcGIS3.csproj b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Speckle.Converters.ArcGIS3.csproj index ae9ca4baeb..6df0a13dae 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Speckle.Converters.ArcGIS3.csproj +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Speckle.Converters.ArcGIS3.csproj @@ -8,7 +8,7 @@ - + diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/ArcGISProjectUtils.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/ArcGISProjectUtils.cs new file mode 100644 index 0000000000..9432955656 --- /dev/null +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/ArcGISProjectUtils.cs @@ -0,0 +1,80 @@ +using ArcGIS.Core.Data; +using ArcGIS.Core.Data.DDL; +using ArcGIS.Desktop.Core; +using ArcGIS.Desktop.Framework.Threading.Tasks; + +namespace Speckle.Converters.ArcGIS3.Utils; + +public class ArcGISProjectUtils : IArcGISProjectUtils +{ + private const string FGDB_NAME = "Speckle.gdb"; + + public string GetDatabasePath() + { + string fGdbPath; + try + { + var parentDirectory = Directory.GetParent(Project.Current.URI); + if (parentDirectory == null) + { + throw new ArgumentException($"Project directory {Project.Current.URI} not found"); + } + fGdbPath = parentDirectory.ToString(); + } + catch (Exception ex) + when (ex + is IOException + or UnauthorizedAccessException + or ArgumentException + or NotSupportedException + or System.Security.SecurityException + ) + { + throw; + } + + return $"{fGdbPath}\\{FGDB_NAME}"; + } + + public string AddDatabaseToProject(string databasePath) + { + // Create a FileGeodatabaseConnectionPath with the name of the file geodatabase you wish to create + FileGeodatabaseConnectionPath fileGeodatabaseConnectionPath = new(new Uri(databasePath)); + // Create actual database in the specified Path unless already exists + try + { + Geodatabase geodatabase = SchemaBuilder.CreateGeodatabase(fileGeodatabaseConnectionPath); + geodatabase.Dispose(); + } + catch (ArcGIS.Core.Data.Exceptions.GeodatabaseWorkspaceException) + { + // geodatabase already exists, do nothing + } + + // Add a folder connection to a project + var parentFolder = Directory.GetParent(databasePath); + if (parentFolder == null) + { + // POC: customize the exception type + throw new ArgumentException($"Invalid path: {databasePath}"); + } + + string parentFolderPath = parentFolder.ToString(); + var fGdbName = databasePath.Replace(parentFolderPath + "\\", ""); + + string fGdbPath = parentFolder.ToString(); + Item folderToAdd = ItemFactory.Instance.Create(fGdbPath); + // POC: QueuedTask + QueuedTask.Run(() => Project.Current.AddItem(folderToAdd as IProjectItem)); + + // Add a file geodatabase or a SQLite or enterprise database connection to a project + var gdbToAdd = folderToAdd.GetItems().FirstOrDefault(folderItem => folderItem.Name.Equals(fGdbName)); + if (gdbToAdd is not null) + { + // POC: QueuedTask + var addedGeodatabase = QueuedTask.Run(() => Project.Current.AddItem(gdbToAdd as IProjectItem)); + } + + return fGdbName; + } +} diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/FeatureClassUtils.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/FeatureClassUtils.cs new file mode 100644 index 0000000000..c2ef80e124 --- /dev/null +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/FeatureClassUtils.cs @@ -0,0 +1,94 @@ +using ArcGIS.Core.Data; +using ArcGIS.Core.Data.Exceptions; +using Objects.GIS; +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; +using Speckle.Core.Models; + +namespace Speckle.Converters.ArcGIS3.Utils; + +public class FeatureClassUtils : IFeatureClassUtils +{ + public void AddFeaturesToFeatureClass( + FeatureClass newFeatureClass, + VectorLayer target, + List fieldAdded, + IRawConversion gisGeometryConverter + ) + { + newFeatureClass.DeleteRows(new QueryFilter()); + foreach (GisFeature feat in target.elements.Cast()) + { + using (RowBuffer rowBuffer = newFeatureClass.CreateRowBuffer()) + { + foreach (string field in fieldAdded) + { + // try to assign values to writeable fields + try + { + if (feat.attributes is not null) + { + var value = feat.attributes[field]; + if (value is not null) + { + rowBuffer[field] = value.ToString(); + } + else + { + rowBuffer[field] = null; + } + } + } + catch (GeodatabaseFieldException) + { + // non-editable Field, do nothing + } + } + + if (feat.geometry != null) + { + foreach (var geometryPart in feat.geometry) + { + // POC: TODO: repeat for all geometries, add as Multipart + ACG.Geometry nativeShape = gisGeometryConverter.RawConvert(geometryPart); + rowBuffer[newFeatureClass.GetDefinition().GetShapeField()] = nativeShape; + break; + } + } + // POC: TODO add option for non-geometry features + newFeatureClass.CreateRow(rowBuffer).Dispose(); + } + } + } + + public ACG.GeometryType GetLayerGeometryType(VectorLayer target) + { + ACG.GeometryType geomType = new(); + if (target.nativeGeomType == null) + { + throw new SpeckleConversionException($"Unknown geometry type for layer {target.name}"); + } + else + { + // POC: find better pattern + if (target.nativeGeomType.ToLower().Contains("point")) + { + geomType = ACG.GeometryType.Multipoint; + } + else if (target.nativeGeomType.ToLower().Contains("polyline")) + { + geomType = ACG.GeometryType.Polyline; + } + else if (target.nativeGeomType.ToLower().Contains("polygon")) + { + geomType = ACG.GeometryType.Polygon; + } + else if (target.nativeGeomType.ToLower().Contains("multipatch")) + { + geomType = ACG.GeometryType.Multipatch; + } + // throw + } + return geomType; + } +} diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/IArcGISProjectUtils.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/IArcGISProjectUtils.cs new file mode 100644 index 0000000000..c86e271073 --- /dev/null +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/IArcGISProjectUtils.cs @@ -0,0 +1,7 @@ +namespace Speckle.Converters.ArcGIS3.Utils; + +public interface IArcGISProjectUtils +{ + string GetDatabasePath(); + string AddDatabaseToProject(string databasePath); +} diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/IFeatureClassUtils.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/IFeatureClassUtils.cs new file mode 100644 index 0000000000..8e252d60ad --- /dev/null +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/IFeatureClassUtils.cs @@ -0,0 +1,18 @@ +using ArcGIS.Core.Data; +using Objects.GIS; +using Speckle.Converters.Common.Objects; +using Speckle.Core.Models; + +namespace Speckle.Converters.ArcGIS3.Utils; + +public interface IFeatureClassUtils +{ + void AddFeaturesToFeatureClass( + FeatureClass newFeatureClass, + VectorLayer target, + List fieldAdded, + IRawConversion gisGeometryConverter + ); + + ACG.GeometryType GetLayerGeometryType(VectorLayer target); +} From 891a4f62e17ba28c2ff228eb16aaed48b66539c9 Mon Sep 17 00:00:00 2001 From: Jedd Morgan <45512892+JR-Morgan@users.noreply.github.com> Date: Tue, 23 Apr 2024 17:57:08 +0100 Subject: [PATCH 045/261] Fixed Double registration of modules in Autocad and ArcGIS projects (#3306) * fixed double registration * fix unused usings --- .../ArcGIS/Speckle.Connectors.ArcGIS3/SpeckleModule.cs | 7 +------ .../Plugin/AutocadCommand.cs | 7 +------ 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/SpeckleModule.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/SpeckleModule.cs index 28e90ebc95..ad9bd5bc05 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/SpeckleModule.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/SpeckleModule.cs @@ -4,7 +4,6 @@ using Autofac; using Speckle.Autofac.DependencyInjection; using Speckle.Autofac.Files; -using Speckle.Connectors.ArcGIS.DependencyInjection; using Speckle.Connectors.ArcGIS.HostApp; using Speckle.Converters.Common.Objects; using Speckle.Core.Kits; @@ -38,11 +37,7 @@ public SpeckleModule() // Register Settings var arcgisSettings = new ArcGISSettings(HostApplications.ArcGIS, HostAppVersion.v3); - Container - .AddModule(new AutofacArcGISModule()) - .LoadAutofacModules(arcgisSettings.Modules) - .AddSingletonInstance(arcgisSettings) - .Build(); + Container.LoadAutofacModules(arcgisSettings.Modules).AddSingletonInstance(arcgisSettings).Build(); } /// diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Plugin/AutocadCommand.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Plugin/AutocadCommand.cs index db5afd50fa..eafe7a4b69 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Plugin/AutocadCommand.cs +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Plugin/AutocadCommand.cs @@ -4,7 +4,6 @@ using Autofac; using Speckle.Autofac.DependencyInjection; using Speckle.Autofac.Files; -using Speckle.Connectors.Autocad.DependencyInjection; using Speckle.Connectors.Autocad.HostApp; using Speckle.Converters.Common.Objects; using Speckle.Core.Kits; @@ -41,11 +40,7 @@ public void Command() var autocadSettings = new AutocadSettings(HostApplications.AutoCAD, HostAppVersion.v2023); - Container - .AddModule(new AutofacAutocadModule()) - .LoadAutofacModules(autocadSettings.Modules) - .AddSingletonInstance(autocadSettings) - .Build(); + Container.LoadAutofacModules(autocadSettings.Modules).AddSingletonInstance(autocadSettings).Build(); // Resolve root plugin object and initialise. _autocadPlugin = Container.Resolve(); From e5887d59bd1a41c0e8eebf440f096cb5d2f80074 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?O=C4=9Fuzhan=20Koral?= <45078678+oguzhankoral@users.noreply.github.com> Date: Thu, 25 Apr 2024 14:42:44 +0300 Subject: [PATCH 046/261] CNX-9215 AutoCAD send geometry conversions (#3302) * reorganizes converter folder structure and names * Adds arc, circle, ellipse, mesh, polyline, and polyline2d conversions also introduces a new AutocadPolycurve class * adds spline and polyline converters * Extend selection info * Use Location for Assembly * Send Polyline * Wrap each converter with transaction * Do not convert control vertices - Polyline3d doesn't have area so won't send * Clean to host from send * Polyline2d segments * Fix usings * Fix null errors * Refactor RootObjectBuilder - Send cache is on - Code simplifed on autocad send binding - Rhino aligned * Fix UI message after send * Fix commit source application * Revert unitOfWork for Rhino send operation * Remove unnecessary disposing * Addresing PR comments * Simplify list extension function * Use IReadonlyList instead IEnumerable --------- Co-authored-by: Claire Kuang --- .../Bindings/AutocadSelectionBinding.cs | 12 +- .../Bindings/AutocadSendBinding.cs | 153 +++--------- .../AutofacAutocadModule.cs | 13 +- .../HostApp/AutocadSettings.cs | 2 +- .../Operations/Send/RootObjectBuilder.cs | 108 ++++++++ ...Speckle.Connectors.AutocadShared.projitems | 1 + .../Bindings/RhinoSendBinding.cs | 59 ++++- .../DependencyInjection/AutofacRhinoModule.cs | 9 +- .../Operations/Send/RootObjectBuilder.cs | 57 ++--- .../Operations/Send/SendOperation.cs | 52 ---- .../AutocadConverterToSpeckle.cs | 29 ++- .../Extensions/EntityExtensions.cs | 57 +++++ .../Extensions/ListExtensions.cs | 17 ++ .../Geometry/IntervalToSpeckleConverter.cs | 13 - .../Geometry/PointToSpeckleConverter.cs | 41 --- .../Geometry/VectorToSpeckleConverter.cs | 22 -- ...Speckle.Converters.AutocadShared.projitems | 26 +- .../Geometry/ArcToSpeckleConverter.cs | 59 +++++ .../Geometry/CircleToSpeckleConverter.cs | 36 +++ .../Geometry/EllipseToSpeckleConverter.cs | 42 ++++ .../Geometry/LineToSpeckleConverter.cs | 11 +- .../Geometry/PointToSpeckleConverter.cs | 20 ++ .../PolyfaceMeshToSpeckleConverter.cs | 106 ++++++++ .../Geometry/Polyline2dToSpeckleConverter.cs | 234 ++++++++++++++++++ .../Geometry/Polyline3dToSpeckleConverter.cs | 135 ++++++++++ .../Geometry/PolylineToSpeckleConverter.cs | 94 +++++++ .../Geometry/SplineToSpeckleConverter.cs | 158 ++++++++++++ .../Geometry/SubDMeshToSpeckleConverter.cs | 78 ++++++ .../Raw/BoxToSpeckleRawConverter.cs} | 18 +- .../Raw/CircularArc3dToSpeckleConverter.cs | 50 ++++ .../Raw/IntervalToSpeckleRawConverter.cs | 11 + .../Raw/LineSegment3dToSpeckleRawConverter.cs | 30 +++ .../Raw/PlaneToSpeckleRawConverter.cs} | 12 +- .../Raw/PointToSpeckleRawConverter.cs | 17 ++ .../Raw/VectorToSpeckleRawConverter.cs | 17 ++ .../Builders/IRootObjectBuilder.cs | 17 ++ .../Operations}/IRootObjectSender.cs | 9 +- .../Operations}/RootObjectSender.cs | 34 +-- .../Operations/SendInfo.cs | 14 ++ .../Operations/SendOperation.cs | 40 +++ .../Geometry/Autocad/AutocadPolycurve.cs | 82 ++++++ 41 files changed, 1624 insertions(+), 371 deletions(-) create mode 100644 DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Operations/Send/RootObjectBuilder.cs delete mode 100644 DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Send/SendOperation.cs create mode 100644 DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/Extensions/EntityExtensions.cs create mode 100644 DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/Extensions/ListExtensions.cs delete mode 100644 DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/Geometry/IntervalToSpeckleConverter.cs delete mode 100644 DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/Geometry/PointToSpeckleConverter.cs delete mode 100644 DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/Geometry/VectorToSpeckleConverter.cs create mode 100644 DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/ArcToSpeckleConverter.cs create mode 100644 DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/CircleToSpeckleConverter.cs create mode 100644 DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/EllipseToSpeckleConverter.cs rename DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/{ => ToSpeckle}/Geometry/LineToSpeckleConverter.cs (74%) create mode 100644 DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/PointToSpeckleConverter.cs create mode 100644 DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/PolyfaceMeshToSpeckleConverter.cs create mode 100644 DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/Polyline2dToSpeckleConverter.cs create mode 100644 DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/Polyline3dToSpeckleConverter.cs create mode 100644 DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/PolylineToSpeckleConverter.cs create mode 100644 DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/SplineToSpeckleConverter.cs create mode 100644 DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/SubDMeshToSpeckleConverter.cs rename DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/{Geometry/BoxToSpeckleConverter.cs => ToSpeckle/Raw/BoxToSpeckleRawConverter.cs} (58%) create mode 100644 DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Raw/CircularArc3dToSpeckleConverter.cs create mode 100644 DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Raw/IntervalToSpeckleRawConverter.cs create mode 100644 DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Raw/LineSegment3dToSpeckleRawConverter.cs rename DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/{Geometry/PlaneToSpeckleConverter.cs => ToSpeckle/Raw/PlaneToSpeckleRawConverter.cs} (67%) create mode 100644 DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Raw/PointToSpeckleRawConverter.cs create mode 100644 DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Raw/VectorToSpeckleRawConverter.cs create mode 100644 DUI3-DX/Sdk/Speckle.Connectors.Utils/Builders/IRootObjectBuilder.cs rename DUI3-DX/{Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Send => Sdk/Speckle.Connectors.Utils/Operations}/IRootObjectSender.cs (71%) rename DUI3-DX/{Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Send => Sdk/Speckle.Connectors.Utils/Operations}/RootObjectSender.cs (52%) create mode 100644 DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/SendInfo.cs create mode 100644 DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/SendOperation.cs create mode 100644 Objects/Objects/Geometry/Autocad/AutocadPolycurve.cs diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadSelectionBinding.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadSelectionBinding.cs index 0848172b75..667451b20e 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadSelectionBinding.cs +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadSelectionBinding.cs @@ -48,9 +48,10 @@ private void OnSelectionChanged() public SelectionInfo GetSelection() { - // POC: Will be addressed to move it into AutocadContext! + // POC: Will be addressed to move it into AutocadContext! https://spockle.atlassian.net/browse/CNX-9319 Document doc = Application.DocumentManager.MdiActiveDocument; List objs = new(); + List objectTypes = new(); if (doc != null) { PromptSelectionResult selection = doc.Editor.SelectImplied(); @@ -66,13 +67,18 @@ public SelectionInfo GetSelection() } var handleString = dbObject.Handle.Value.ToString(); + objectTypes.Add(dbObject.GetType().Name); objs.Add(handleString); } tr.Commit(); - tr.Dispose(); } } - return new SelectionInfo { SelectedObjectIds = objs, Summary = $"{objs.Count} objects" }; + List flatObjectTypes = objectTypes.Select(o => o).Distinct().ToList(); + return new SelectionInfo + { + SelectedObjectIds = objs, + Summary = $"{objs.Count} objects ({string.Join(", ", flatObjectTypes)})" + }; } } diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadSendBinding.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadSendBinding.cs index 1683280e23..13585bde5e 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadSendBinding.cs +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadSendBinding.cs @@ -6,15 +6,10 @@ using Speckle.Connectors.DUI.Models; using Speckle.Connectors.DUI.Models.Card; using Speckle.Connectors.Utils.Cancellation; -using Speckle.Core.Credentials; using Speckle.Core.Logging; using Speckle.Autofac.DependencyInjection; -using Speckle.Converters.Common; -using Speckle.Core.Transports; using Speckle.Connectors.Utils.Operations; -using Speckle.Core.Api; using Speckle.Core.Models; -using System.Diagnostics; using ICancelable = System.Reactive.Disposables.ICancelable; using Speckle.Connectors.DUI.Models.Card.SendFilter; @@ -31,6 +26,8 @@ public sealed class AutocadSendBinding : ISendBinding, ICancelable private readonly List _sendFilters; private readonly CancellationManager _cancellationManager; private readonly IUnitOfWorkFactory _unitOfWorkFactory; + private readonly AutocadSettings _autocadSettings; + private readonly SendOperation<(DBObject obj, string applicationId)> _sendOperation; /// /// Used internally to aggregate the changed objects' id. @@ -48,12 +45,16 @@ public AutocadSendBinding( IBridge parent, IEnumerable sendFilters, CancellationManager cancellationManager, + AutocadSettings autocadSettings, + SendOperation<(DBObject obj, string applicationId)> sendOperation, IUnitOfWorkFactory unitOfWorkFactory ) { _store = store; _idleManager = idleManager; _unitOfWorkFactory = unitOfWorkFactory; + _sendOperation = sendOperation; + _autocadSettings = autocadSettings; _cancellationManager = cancellationManager; _sendFilters = sendFilters.ToList(); @@ -122,6 +123,7 @@ private async Task SendInternal(string modelCardId) { try { + using var uow = _unitOfWorkFactory.Resolve>(); // 0 - Init cancellation token source -> Manager also cancel it if exist before CancellationTokenSource cts = _cancellationManager.InitCancellationTokenSource(modelCardId); @@ -131,10 +133,7 @@ private async Task SendInternal(string modelCardId) throw new InvalidOperationException("No publish model card was found."); } - // 2 - Check account exist - Account account = AccountManager.GetAccount(modelCard.AccountId); - - // 3 - Get elements to convert + // Get elements to convert List<(DBObject obj, string applicationId)> autocadObjects = Application.DocumentManager.CurrentDocument.GetObjects(modelCard.SendFilter.GetObjectIds()); if (autocadObjects.Count == 0) @@ -142,16 +141,24 @@ private async Task SendInternal(string modelCardId) throw new InvalidOperationException("No objects were found. Please update your send filter!"); } - // 4 - Convert objects - Base commitObject = ConvertObjects(autocadObjects, modelCard, cts.Token); - - cts.Token.ThrowIfCancellationRequested(); - - // 5 - Serialize and Send objects - Commands.SetModelProgress(modelCardId, new ModelCardProgress { Status = "Uploading..." }); + var sendInfo = new SendInfo() + { + AccountId = modelCard.AccountId, + ProjectId = modelCard.ProjectId, + ModelId = modelCard.ModelId, + ConvertedObjects = _convertedObjectReferences, + ChangedObjectIds = modelCard.ChangedObjectIds, + SourceApplication = _autocadSettings.HostAppInfo.Name + }; - var transport = new ServerTransport(account, modelCard.ProjectId); - var sendResult = await SendHelper.Send(commitObject, transport, true, null, cts.Token).ConfigureAwait(true); + var sendResult = await uow.Service + .Execute( + autocadObjects, + sendInfo, + (status, progress) => OnSendOperationProgress(modelCardId, status, progress), + cts.Token + ) + .ConfigureAwait(false); // Store the converted references in memory for future send operations, overwriting the existing values for the given application id. foreach (var kvp in sendResult.convertedReferences) @@ -162,26 +169,7 @@ private async Task SendInternal(string modelCardId) // It's important to reset the model card's list of changed obj ids so as to ensure we accurately keep track of changes between send operations. modelCard.ChangedObjectIds = new(); - // 6 - Create Version - Commands.SetModelProgress(modelCardId, new ModelCardProgress { Status = "Linking version to model..." }); - - // 7 - Create the version (commit) - Client apiClient = new(account); - string versionId = await apiClient - .CommitCreate( - new CommitCreateInput - { - streamId = modelCard.ProjectId, - branchName = modelCard.ModelId, - sourceApplication = "Autocad", - objectId = sendResult.rootObjId - }, - cts.Token - ) - .ConfigureAwait(true); - - Commands.SetModelCreatedVersionId(modelCardId, versionId); - apiClient.Dispose(); + Commands.SetModelCreatedVersionId(modelCardId, sendResult.rootObjId); } catch (OperationCanceledException) { @@ -193,92 +181,9 @@ private async Task SendInternal(string modelCardId) } } - private Base ConvertObjects( - List<(DBObject obj, string applicationId)> dbObjects, - SenderModelCard modelCard, - CancellationToken cancellationToken - ) + private void OnSendOperationProgress(string modelCardId, string status, double? progress) { - // POC: does this feel like the right place? I am wondering if this should be called from within send/rcv? - // begin the unit of work - using var uow = _unitOfWorkFactory.Resolve(); - var converter = uow.Service; - - Collection modelWithLayers = - new() - { - name = Application.DocumentManager.CurrentDocument.Name - .Split(s_separator, StringSplitOptions.None) - .Reverse() - .First(), - collectionType = "root" - }; - - Dictionary collectionCache = new(); - int count = 0; - - foreach ((DBObject obj, string applicationId) tuple in dbObjects) - { - cancellationToken.ThrowIfCancellationRequested(); - - var dbObject = tuple.obj; - var applicationId = tuple.applicationId; - - try - { - Base converted; - if ( - !modelCard.ChangedObjectIds.Contains(applicationId) - && _convertedObjectReferences.TryGetValue(applicationId + modelCard.ProjectId, out ObjectReference value) - ) - { - converted = value; - } - else - { - converted = converter.Convert(dbObject); - - if (converted == null) - { - continue; - } - - converted.applicationId = applicationId; - } - - // Create and add a collection for each layer if not done so already. - if ((tuple.obj as Entity)?.Layer is string layer) - { - if (!collectionCache.TryGetValue(layer, out Collection? collection)) - { - collection = new Collection() { name = layer, collectionType = "layer" }; - collectionCache[layer] = collection; - modelWithLayers.elements.Add(collectionCache[layer]); - } - - collection.elements.Add(converted); - } - - Commands.SetModelProgress( - modelCard.ModelCardId, - new ModelCardProgress() { Status = "Converting", Progress = (double)++count / dbObjects.Count } - ); - } - catch (SpeckleConversionException e) - { - Console.WriteLine(e); - } - catch (NotSupportedException e) - { - Console.WriteLine(e); - } - catch (Exception e) when (!e.IsFatal()) - { - Debug.WriteLine(e.Message); - } - } - - return modelWithLayers; + Commands.SetModelProgress(modelCardId, new ModelCardProgress { Status = status, Progress = progress }); } public void CancelSend(string modelCardId) => _cancellationManager.CancelOperation(modelCardId); @@ -289,6 +194,4 @@ public void Dispose() } public bool IsDisposed { get; private set; } - - private static readonly string[] s_separator = new[] { "\\" }; } diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/DependencyInjection/AutofacAutocadModule.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/DependencyInjection/AutofacAutocadModule.cs index cf2317ba8b..7d734be9f7 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/DependencyInjection/AutofacAutocadModule.cs +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/DependencyInjection/AutofacAutocadModule.cs @@ -18,9 +18,11 @@ using Speckle.Connectors.Utils.Cancellation; using Speckle.Connectors.Autocad.Filters; using Speckle.Connectors.Autocad.Operations.Receive; +using Speckle.Connectors.Autocad.Operations.Send; using Speckle.Connectors.DUI.Models.Card.SendFilter; using Speckle.Connectors.Utils.Builders; using Speckle.Connectors.Utils.Operations; +using Speckle.Core.Transports; namespace Speckle.Connectors.Autocad.DependencyInjection; @@ -45,12 +47,17 @@ protected override void Load(ContainerBuilder builder) builder.RegisterType().SingleInstance(); // Operations - builder.RegisterType().AsSelf().SingleInstance(); + builder.RegisterType>().InstancePerLifetimeScope(); + builder.RegisterType().SingleInstance(); builder.RegisterType().As().SingleInstance(); // Object Builders builder.RegisterType().As().InstancePerDependency(); - // POC: Register here also RootObjectBuilder as IRootObjectBuilder + builder + .RegisterType() + .As>() + .SingleInstance(); + builder.RegisterType().As().SingleInstance(); // Register bindings builder.RegisterType().As().SingleInstance(); @@ -73,6 +80,8 @@ protected override void Load(ContainerBuilder builder) // Register converter factory builder.RegisterType().As().InstancePerLifetimeScope(); + + builder.RegisterType().As().InstancePerDependency(); } private static JsonSerializerSettings GetJsonSerializerSettings() diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/AutocadSettings.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/AutocadSettings.cs index a8dd0266d6..4d90418b83 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/AutocadSettings.cs +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/AutocadSettings.cs @@ -1,5 +1,5 @@ using System.IO; -using Speckle.Core.Kits; +using Speckle.Core.Kits; // POC: Must go https://spockle.atlassian.net/browse/CNX-9325 namespace Speckle.Connectors.Autocad.HostApp; diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Operations/Send/RootObjectBuilder.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Operations/Send/RootObjectBuilder.cs new file mode 100644 index 0000000000..0f1b81cd36 --- /dev/null +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Operations/Send/RootObjectBuilder.cs @@ -0,0 +1,108 @@ +using System.Diagnostics; +using Autodesk.AutoCAD.DatabaseServices; +using Speckle.Autofac.DependencyInjection; +using Speckle.Connectors.Utils.Builders; +using Speckle.Connectors.Utils.Operations; +using Speckle.Converters.Common; +using Speckle.Core.Logging; +using Speckle.Core.Models; + +namespace Speckle.Connectors.Autocad.Operations.Send; + +public class RootObjectBuilder : IRootObjectBuilder<(DBObject obj, string applicationId)> +{ + private readonly IUnitOfWorkFactory _unitOfWorkFactory; + private readonly string[] _documentPathSeparator = { "\\" }; + + public RootObjectBuilder(IUnitOfWorkFactory unitOfWorkFactory) + { + _unitOfWorkFactory = unitOfWorkFactory; + } + + public Base Build( + IReadOnlyList<(DBObject obj, string applicationId)> objects, + SendInfo sendInfo, + Action? onOperationProgressed = null, + CancellationToken ct = default + ) + { + // POC: does this feel like the right place? I am wondering if this should be called from within send/rcv? + // begin the unit of work + using var uow = _unitOfWorkFactory.Resolve(); + var converter = uow.Service; + + Collection modelWithLayers = + new() + { + name = Application.DocumentManager.CurrentDocument.Name // POC: https://spockle.atlassian.net/browse/CNX-9319 + .Split(_documentPathSeparator, StringSplitOptions.None) + .Reverse() + .First(), + collectionType = "root" + }; + + // Cached dictionary to create Collection for autocad entity layers. We first look if collection exists. If so use it otherwise create new one for that layer. + Dictionary collectionCache = new(); + int count = 0; + + foreach ((DBObject obj, string applicationId) tuple in objects) + { + ct.ThrowIfCancellationRequested(); + + var dbObject = tuple.obj; + var applicationId = tuple.applicationId; + + try + { + Base converted; + if ( + !sendInfo.ChangedObjectIds.Contains(applicationId) + && sendInfo.ConvertedObjects.TryGetValue(applicationId + sendInfo.ProjectId, out ObjectReference value) // POC: Interface out constructing keys here to use it otherplaces with a same code. -> https://spockle.atlassian.net/browse/CNX-9313 + ) + { + converted = value; + } + else + { + converted = converter.Convert(dbObject); + + if (converted == null) + { + continue; + } + + converted.applicationId = applicationId; + } + + // Create and add a collection for each layer if not done so already. + if ((tuple.obj as Entity)?.Layer is string layer) + { + if (!collectionCache.TryGetValue(layer, out Collection? collection)) + { + collection = new Collection() { name = layer, collectionType = "layer" }; + collectionCache[layer] = collection; + modelWithLayers.elements.Add(collectionCache[layer]); + } + + collection.elements.Add(converted); + } + + onOperationProgressed?.Invoke("Converting", (double)++count / objects.Count); + } + catch (SpeckleConversionException e) + { + Console.WriteLine(e); + } + catch (NotSupportedException e) + { + Console.WriteLine(e); + } + catch (Exception e) when (!e.IsFatal()) + { + Debug.WriteLine(e.Message); + } + } + + return modelWithLayers; + } +} diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Speckle.Connectors.AutocadShared.projitems b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Speckle.Connectors.AutocadShared.projitems index 7fbcdb3f92..999cd856bc 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Speckle.Connectors.AutocadShared.projitems +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Speckle.Connectors.AutocadShared.projitems @@ -33,6 +33,7 @@ + diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSendBinding.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSendBinding.cs index 2bb26949fe..7295f999d8 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSendBinding.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSendBinding.cs @@ -15,8 +15,10 @@ using ICancelable = System.Reactive.Disposables.ICancelable; using System.Threading.Tasks; using Speckle.Autofac.DependencyInjection; -using Speckle.Connectors.Rhino7.Operations.Send; +using Rhino.DocObjects; using Speckle.Connectors.DUI.Models.Card.SendFilter; +using Speckle.Connectors.Utils.Operations; +using Speckle.Core.Models; namespace Speckle.Connectors.Rhino7.Bindings; @@ -30,7 +32,9 @@ public sealed class RhinoSendBinding : ISendBinding, ICancelable private readonly RhinoIdleManager _idleManager; private readonly IUnitOfWorkFactory _unitOfWorkFactory; private readonly List _sendFilters; + private readonly SendOperation _sendOperation; private readonly CancellationManager _cancellationManager; + private readonly RhinoSettings _rhinoSettings; /// /// Used internally to aggregate the changed objects' id. @@ -40,22 +44,25 @@ public sealed class RhinoSendBinding : ISendBinding, ICancelable /// /// Keeps track of previously converted objects as a dictionary of (applicationId, object reference). /// - /// POC: Commented out this for now, relates to change tracking feature - // private readonly Dictionary _convertedObjectReferences = new(); + private readonly Dictionary _convertedObjectReferences = new(); public RhinoSendBinding( DocumentModelStore store, RhinoIdleManager idleManager, IBridge parent, IEnumerable sendFilters, + SendOperation sendOperation, IUnitOfWorkFactory unitOfWorkFactory, + RhinoSettings rhinoSettings, CancellationManager cancellationManager ) { _store = store; _idleManager = idleManager; _unitOfWorkFactory = unitOfWorkFactory; + _sendOperation = sendOperation; _sendFilters = sendFilters.ToList(); + _rhinoSettings = rhinoSettings; _cancellationManager = cancellationManager; Parent = parent; Commands = new SendBindingUICommands(parent); // POC: Commands are tightly coupled with their bindings, at least for now, saves us injecting a factory. @@ -131,7 +138,7 @@ public List GetSendSettings() )] public async Task Send(string modelCardId) { - using var unitOfWork = _unitOfWorkFactory.Resolve(); + using var unitOfWork = _unitOfWorkFactory.Resolve>(); try { // 0 - Init cancellation token source -> Manager also cancel it if exist before @@ -143,18 +150,41 @@ public async Task Send(string modelCardId) throw new InvalidOperationException("No publish model card was found."); } - string versionId = await unitOfWork.Service + List rhinoObjects = modelCard.SendFilter + .GetObjectIds() + .Select(id => RhinoDoc.ActiveDoc.Objects.FindId(new Guid(id))) + .Where(obj => obj != null) + .ToList(); + + var sendInfo = new SendInfo() + { + AccountId = modelCard.AccountId, + ProjectId = modelCard.ProjectId, + ModelId = modelCard.ModelId, + ConvertedObjects = _convertedObjectReferences, + ChangedObjectIds = modelCard.ChangedObjectIds, + SourceApplication = _rhinoSettings.HostAppInfo.Name + }; + + var sendResult = await unitOfWork.Service .Execute( - modelCard.SendFilter, - modelCard.AccountId, - modelCard.ProjectId, - modelCard.ModelId, + rhinoObjects, + sendInfo, (status, progress) => OnSendOperationProgress(modelCardId, status, progress), cts.Token ) .ConfigureAwait(false); - Commands.SetModelCreatedVersionId(modelCardId, versionId); + // Store the converted references in memory for future send operations, overwriting the existing values for the given application id. + foreach (var kvp in sendResult.convertedReferences) + { + _convertedObjectReferences[kvp.Key + modelCard.ProjectId] = kvp.Value; + } + + // It's important to reset the model card's list of changed obj ids so as to ensure we accurately keep track of changes between send operations. + modelCard.ChangedObjectIds = new(); + + Commands.SetModelCreatedVersionId(modelCardId, sendResult.rootObjId); } catch (OperationCanceledException) { @@ -179,14 +209,17 @@ private void OnSendOperationProgress(string modelCardId, string status, double? private void RunExpirationChecks() { List senders = _store.GetSenders(); + string[] objectIdsList = ChangedObjectIds.ToArray(); List expiredSenderIds = new(); - foreach (var sender in senders) + foreach (SenderModelCard modelCard in senders) { - bool isExpired = sender.SendFilter.CheckExpiry(ChangedObjectIds.ToArray()); + var intersection = modelCard.SendFilter.GetObjectIds().Intersect(objectIdsList).ToList(); + bool isExpired = modelCard.SendFilter.CheckExpiry(ChangedObjectIds.ToArray()); if (isExpired) { - expiredSenderIds.Add(sender.ModelCardId); + expiredSenderIds.Add(modelCard.ModelCardId); + modelCard.ChangedObjectIds.UnionWith(intersection); } } diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/AutofacRhinoModule.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/AutofacRhinoModule.cs index 2a7a75658a..5b769226e4 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/AutofacRhinoModule.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/AutofacRhinoModule.cs @@ -2,6 +2,7 @@ using Autofac; using Microsoft.Extensions.Logging; using Rhino.Commands; +using Rhino.DocObjects; using Rhino.PlugIns; using Serilog; using Speckle.Autofac.DependencyInjection; @@ -65,14 +66,16 @@ protected override void Load(ContainerBuilder builder) // register send operation and dependencies builder.RegisterType().As().InstancePerLifetimeScope(); - builder.RegisterType().InstancePerLifetimeScope(); + builder.RegisterType>().InstancePerLifetimeScope(); builder.RegisterType().InstancePerLifetimeScope(); builder.RegisterType().As().SingleInstance(); builder.RegisterType().As().InstancePerLifetimeScope(); - builder.RegisterType().InstancePerLifetimeScope(); - builder.RegisterType().As().InstancePerLifetimeScope(); + builder.RegisterType().As>().SingleInstance(); + builder.RegisterType().As().SingleInstance(); + + builder.RegisterType().As().InstancePerDependency(); } private static JsonSerializerSettings GetJsonSerializerSettings() diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Send/RootObjectBuilder.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Send/RootObjectBuilder.cs index f938bf2063..c6b372800a 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Send/RootObjectBuilder.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Send/RootObjectBuilder.cs @@ -8,13 +8,15 @@ using Speckle.Autofac.DependencyInjection; using Speckle.Converters.Common; using Speckle.Connectors.DUI.Models.Card.SendFilter; +using Speckle.Connectors.Utils.Builders; +using Speckle.Connectors.Utils.Operations; namespace Speckle.Connectors.Rhino7.Operations.Send; /// /// Stateless builder object to turn an into a object /// -public class RootObjectBuilder +public class RootObjectBuilder : IRootObjectBuilder { private readonly IUnitOfWorkFactory _unitOfWorkFactory; @@ -24,29 +26,26 @@ public RootObjectBuilder(IUnitOfWorkFactory unitOfWorkFactory) } public Base Build( - ISendFilter sendFilter, + IReadOnlyList objects, + SendInfo sendInfo, Action? onOperationProgressed = null, CancellationToken ct = default ) { - List rhinoObjects = sendFilter - .GetObjectIds() - .Select(id => RhinoDoc.ActiveDoc.Objects.FindId(new Guid(id))) - .Where(obj => obj != null) - .ToList(); - - if (rhinoObjects.Count == 0) + if (!objects.Any()) { + // POC: not sure if we would want to throw in here? throw new InvalidOperationException("No objects were found. Please update your send filter!"); } - Base commitObject = ConvertObjects(rhinoObjects, onOperationProgressed, ct); + Base commitObject = ConvertObjects(objects, sendInfo, onOperationProgressed, ct); return commitObject; } private Collection ConvertObjects( - List rhinoObjects, + IReadOnlyList rhinoObjects, + SendInfo sendInfo, Action? onOperationProgressed = null, CancellationToken cancellationToken = default ) @@ -72,27 +71,25 @@ private Collection ConvertObjects( var collectionHost = GetHostObjectCollection(layerCollectionCache, layer, rootObjectCollection); var applicationId = rhinoObject.Id.ToString(); - // get from cache or convert: - // POC: We're not using the cache here yet but should once the POC is working. - // What we actually do here is check if the object has been previously converted AND has not changed. - // If that's the case, we insert in the host collection just its object reference which has been saved from the prior conversion. - /*Base converted; - if ( - !modelCard.ChangedObjectIds.Contains(applicationId) - && _convertedObjectReferences.TryGetValue(applicationId + modelCard.ProjectId, out ObjectReference value) - ) - { - converted = value; - } - else - { - converted = converter.ConvertToSpeckle(rhinoObject); - converted.applicationId = applicationId; - }*/ try { - Base converted = converter.Convert(rhinoObject); - converted.applicationId = applicationId; + // get from cache or convert: + // POC: We're not using the cache here yet but should once the POC is working. + // What we actually do here is check if the object has been previously converted AND has not changed. + // If that's the case, we insert in the host collection just its object reference which has been saved from the prior conversion. + Base converted; + if ( + !sendInfo.ChangedObjectIds.Contains(applicationId) + && sendInfo.ConvertedObjects.TryGetValue(applicationId + sendInfo.ProjectId, out ObjectReference value) + ) + { + converted = value; + } + else + { + converted = converter.Convert(rhinoObject); + converted.applicationId = applicationId; + } // add to host collectionHost.elements.Add(converted); diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Send/SendOperation.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Send/SendOperation.cs deleted file mode 100644 index bcaf356954..0000000000 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Send/SendOperation.cs +++ /dev/null @@ -1,52 +0,0 @@ -using System; -using System.Threading; -using System.Threading.Tasks; -using Speckle.Connectors.DUI.Models.Card.SendFilter; -using Speckle.Core.Models; - -namespace Speckle.Connectors.Rhino7.Operations.Send; - -/// -/// Stateless send operation orchestrator. -/// -public sealed class SendOperation -{ - private readonly RootObjectBuilder _baseBuilder; - private readonly IRootObjectSender _baseObjectSender; - - public SendOperation(RootObjectBuilder baseBuilder, IRootObjectSender baseObjectSender) - { - _baseBuilder = baseBuilder; - _baseObjectSender = baseObjectSender; - } - - /// - /// Executes a send operation given information about the host objects and the destination account. - /// - /// - /// - /// - /// - /// - /// - /// - public async Task Execute( - ISendFilter sendFilter, - string accountId, - string projectId, - string modelId, - Action? onOperationProgressed = null, - CancellationToken ct = default - ) - { - Base commitObject = _baseBuilder.Build(sendFilter, onOperationProgressed, ct); - - // base object handler is separated so we can do some testing on non-production databases - // exact interface may want to be tweaked when we implement this - string versionId = await _baseObjectSender - .Send(commitObject, accountId, projectId, modelId, onOperationProgressed, ct) - .ConfigureAwait(false); - - return versionId; - } -} diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/AutocadConverterToSpeckle.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/AutocadConverterToSpeckle.cs index a70a3ac898..12eb5acf65 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/AutocadConverterToSpeckle.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/AutocadConverterToSpeckle.cs @@ -10,10 +10,15 @@ namespace Speckle.Converters.Autocad; public class AutocadConverterToSpeckle : ISpeckleConverterToSpeckle { private readonly IFactory _toSpeckle; + private readonly IConversionContextStack _contextStack; - public AutocadConverterToSpeckle(IFactory toSpeckle) + public AutocadConverterToSpeckle( + IFactory toSpeckle, + IConversionContextStack contextStack + ) { _toSpeckle = toSpeckle; + _contextStack = contextStack; } public Base Convert(object target) @@ -29,16 +34,22 @@ public Base Convert(object target) try { - var objectConverter = _toSpeckle.ResolveInstance(type.Name); - - if (objectConverter == null) + using (var l = _contextStack.Current.Document.LockDocument()) { - throw new NotSupportedException($"No conversion found for {target.GetType().Name}"); + using (var tr = _contextStack.Current.Document.Database.TransactionManager.StartTransaction()) + { + var objectConverter = _toSpeckle.ResolveInstance(type.Name); + + if (objectConverter == null) + { + throw new NotSupportedException($"No conversion found for {target.GetType().Name}"); + } + + var convertedObject = objectConverter.Convert(dbObject); + tr.Commit(); + return convertedObject; + } } - - var convertedObject = objectConverter.Convert(dbObject); - - return convertedObject; } catch (SpeckleConversionException e) { diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/Extensions/EntityExtensions.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/Extensions/EntityExtensions.cs new file mode 100644 index 0000000000..6c8515e461 --- /dev/null +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/Extensions/EntityExtensions.cs @@ -0,0 +1,57 @@ +using Autodesk.AutoCAD.DatabaseServices; +using System.Collections; +using System.Collections.Generic; + +namespace Speckle.Converters.Autocad.Extensions; + +public static class EntityExtensions +{ + /// + /// Worker for enumeration of IEnumerable entities that return differently typed subentities depending on the database-residency of the entity. + /// + /// + /// Database-resident entities which are enumerable will return ObjectIds of subentities when enumerated, and requires a transaction. + /// Non database-resident entities (eg polyline2ds from exploded blocks) will return the typed subentities, are also not database-resident. + /// Can be used for retrieving in , + /// in and in , + /// in and in . + /// + /// Thrown when source arg is null and owner entity was not of type IEnumerable. + /// Thrown when input transaction is null and owner database has no active top transaction. + public static IEnumerable GetSubEntities( + this Entity owner, + OpenMode mode = OpenMode.ForRead, + Transaction? trans = null, + IEnumerable? source = null, + bool forceOpenOnLockedLayer = false + ) + where T : Entity + { + if ((source ?? owner as IEnumerable) is not IEnumerable enumerable) + { + throw new System.ArgumentException("IEnumerable source is null and owner Entity is not of type IEnumerable."); + } + + if (owner.Database is Database db) + { + if ((trans ?? db.TransactionManager.TopTransaction) is not Transaction tr) + { + throw new System.InvalidOperationException( + "Transaction is null and the owner database has no active top transaction." + ); + } + + foreach (ObjectId id in enumerable) + { + yield return (T)tr.GetObject(id, mode, false, forceOpenOnLockedLayer); + } + } + else + { + foreach (T entity in enumerable) + { + yield return entity; + } + } + } +} diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/Extensions/ListExtensions.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/Extensions/ListExtensions.cs new file mode 100644 index 0000000000..e38c372c62 --- /dev/null +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/Extensions/ListExtensions.cs @@ -0,0 +1,17 @@ +using System.Collections.Generic; + +namespace Speckle.Converters.Autocad.Extensions; + +public static class ListExtensions +{ + public static SOG.Polyline ConvertToSpecklePolyline(this List pointList, string speckleUnits) + { + // throw if list is malformed + if (pointList.Count % 3 != 0) + { + throw new System.ArgumentException("Point list of xyz values is malformed."); + } + + return new(pointList, speckleUnits); + } +} diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/Geometry/IntervalToSpeckleConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/Geometry/IntervalToSpeckleConverter.cs deleted file mode 100644 index eb58a0f986..0000000000 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/Geometry/IntervalToSpeckleConverter.cs +++ /dev/null @@ -1,13 +0,0 @@ -using Speckle.Converters.Common; -using Speckle.Converters.Common.Objects; -using Speckle.Core.Models; - -namespace Speckle.Converters.Autocad.Geometry; - -[NameAndRankValue(nameof(AG.Interval), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class IntervalToSpeckleConverter : IHostObjectToSpeckleConversion, IRawConversion -{ - public Base Convert(object target) => RawConvert((AG.Interval)target); - - public SOP.Interval RawConvert(AG.Interval target) => new(target.LowerBound, target.UpperBound); -} diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/Geometry/PointToSpeckleConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/Geometry/PointToSpeckleConverter.cs deleted file mode 100644 index 80d94b9efe..0000000000 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/Geometry/PointToSpeckleConverter.cs +++ /dev/null @@ -1,41 +0,0 @@ -using Speckle.Converters.Common.Objects; -using Speckle.Converters.Common; -using Speckle.Core.Models; -using Autodesk.AutoCAD.DatabaseServices; - -namespace Speckle.Converters.Autocad.Geometry; - -[NameAndRankValue(nameof(DBPoint), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class DBPointToSpeckleConverter : IHostObjectToSpeckleConversion, IRawConversion -{ - private readonly IRawConversion _pointConverter; - private readonly IConversionContextStack _contextStack; - - public DBPointToSpeckleConverter( - IRawConversion pointConverter, - IConversionContextStack contextStack - ) - { - _pointConverter = pointConverter; - _contextStack = contextStack; - } - - public Base Convert(object target) => RawConvert((DBPoint)target); - - public SOG.Point RawConvert(DBPoint target) => _pointConverter.RawConvert(target.Position); -} - -public class PointToSpeckleConverter : IRawConversion -{ - private readonly IConversionContextStack _contextStack; - - public PointToSpeckleConverter(IConversionContextStack contextStack) - { - _contextStack = contextStack; - } - - public Base Convert(object target) => RawConvert((AG.Point3d)target); - - public SOG.Point RawConvert(AG.Point3d target) => - new(target.X, target.Y, target.Z, _contextStack.Current.SpeckleUnits); -} diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/Geometry/VectorToSpeckleConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/Geometry/VectorToSpeckleConverter.cs deleted file mode 100644 index cbd8b6b974..0000000000 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/Geometry/VectorToSpeckleConverter.cs +++ /dev/null @@ -1,22 +0,0 @@ -using Autodesk.AutoCAD.DatabaseServices; -using Speckle.Converters.Common; -using Speckle.Converters.Common.Objects; -using Speckle.Core.Models; - -namespace Speckle.Converters.Autocad.Geometry; - -[Common.NameAndRankValue(nameof(AG.Vector3d), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class VectorToSpeckleConverter : IHostObjectToSpeckleConversion, IRawConversion -{ - private readonly IConversionContextStack _contextStack; - - public VectorToSpeckleConverter(IConversionContextStack contextStack) - { - _contextStack = contextStack; - } - - public Base Convert(object target) => RawConvert((AG.Vector3d)target); - - public SOG.Vector RawConvert(AG.Vector3d target) => - new(target.X, target.Y, target.Z, _contextStack.Current.SpeckleUnits); -} diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/Speckle.Converters.AutocadShared.projitems b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/Speckle.Converters.AutocadShared.projitems index 40aeab640b..08d2ce1f0b 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/Speckle.Converters.AutocadShared.projitems +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/Speckle.Converters.AutocadShared.projitems @@ -13,29 +13,43 @@ - + + - - - - - + + + + + + + + + + + + + + + + + + diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/ArcToSpeckleConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/ArcToSpeckleConverter.cs new file mode 100644 index 0000000000..39a60873f0 --- /dev/null +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/ArcToSpeckleConverter.cs @@ -0,0 +1,59 @@ +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; +using Speckle.Core.Models; + +namespace Speckle.Converters.Autocad.ToSpeckle.Geometry; + +[NameAndRankValue(nameof(ADB.Arc), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +public class DBArcToSpeckleConverter : IHostObjectToSpeckleConversion, IRawConversion +{ + private readonly IRawConversion _pointConverter; + private readonly IRawConversion _planeConverter; + private readonly IRawConversion _boxConverter; + private readonly IConversionContextStack _contextStack; + + public DBArcToSpeckleConverter( + IRawConversion pointConverter, + IRawConversion planeConverter, + IRawConversion boxConverter, + IConversionContextStack contextStack + ) + { + _pointConverter = pointConverter; + _planeConverter = planeConverter; + _boxConverter = boxConverter; + _contextStack = contextStack; + } + + public Base Convert(object target) => RawConvert((ADB.Arc)target); + + public SOG.Arc RawConvert(ADB.Arc target) + { + SOG.Plane plane = _planeConverter.RawConvert(target.GetPlane()); + SOG.Point start = _pointConverter.RawConvert(target.StartPoint); + SOG.Point end = _pointConverter.RawConvert(target.EndPoint); + SOG.Point mid = _pointConverter.RawConvert(target.GetPointAtDist(target.Length / 2.0)); + SOP.Interval domain = new(target.StartParam, target.EndParam); + SOG.Box bbox = _boxConverter.RawConvert(target.GeometricExtents); + + SOG.Arc arc = + new( + plane, + target.Radius, + target.StartAngle, + target.EndAngle, + target.TotalAngle, + _contextStack.Current.SpeckleUnits + ) + { + startPoint = start, + endPoint = end, + midPoint = mid, + domain = domain, + length = target.Length, + bbox = bbox + }; + + return arc; + } +} diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/CircleToSpeckleConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/CircleToSpeckleConverter.cs new file mode 100644 index 0000000000..3bdfb3cf95 --- /dev/null +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/CircleToSpeckleConverter.cs @@ -0,0 +1,36 @@ +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; +using Speckle.Core.Models; + +namespace Speckle.Converters.Autocad.ToSpeckle.Geometry; + +[NameAndRankValue(nameof(ADB.Circle), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +public class DBCircleToSpeckleConverter : IHostObjectToSpeckleConversion +{ + private readonly IRawConversion _planeConverter; + private readonly IRawConversion _boxConverter; + private readonly IConversionContextStack _contextStack; + + public DBCircleToSpeckleConverter( + IRawConversion planeConverter, + IRawConversion boxConverter, + IConversionContextStack contextStack + ) + { + _planeConverter = planeConverter; + _boxConverter = boxConverter; + _contextStack = contextStack; + } + + public Base Convert(object target) => RawConvert((ADB.Circle)target); + + public SOG.Circle RawConvert(ADB.Circle target) + { + SOG.Plane plane = _planeConverter.RawConvert(target.GetPlane()); + SOG.Box bbox = _boxConverter.RawConvert(target.GeometricExtents); + SOG.Circle circle = + new(plane, target.Radius, _contextStack.Current.SpeckleUnits) { length = target.Circumference, bbox = bbox }; + + return circle; + } +} diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/EllipseToSpeckleConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/EllipseToSpeckleConverter.cs new file mode 100644 index 0000000000..de51e2ad5d --- /dev/null +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/EllipseToSpeckleConverter.cs @@ -0,0 +1,42 @@ +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; +using Speckle.Core.Models; + +namespace Speckle.Converters.Autocad.ToSpeckle.Geometry; + +[NameAndRankValue(nameof(ADB.Ellipse), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +public class DBEllipseToSpeckleConverter : IHostObjectToSpeckleConversion +{ + private readonly IRawConversion _planeConverter; + private readonly IRawConversion _boxConverter; + private readonly IConversionContextStack _contextStack; + + public DBEllipseToSpeckleConverter( + IRawConversion planeConverter, + IRawConversion boxConverter, + IConversionContextStack contextStack + ) + { + _planeConverter = planeConverter; + _boxConverter = boxConverter; + _contextStack = contextStack; + } + + public Base Convert(object target) => RawConvert((ADB.Ellipse)target); + + public SOG.Ellipse RawConvert(ADB.Ellipse target) + { + SOG.Plane plane = _planeConverter.RawConvert(new AG.Plane(target.Center, target.MajorAxis, target.MinorAxis)); + SOG.Box bbox = _boxConverter.RawConvert(target.GeometricExtents); + + SOG.Ellipse ellipse = + new(plane, target.MajorRadius, target.MinorRadius, _contextStack.Current.SpeckleUnits) + { + domain = new SOP.Interval(target.StartParam, target.EndParam), + length = target.GetDistanceAtParameter(target.EndParam), + bbox = bbox + }; + + return ellipse; + } +} diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/Geometry/LineToSpeckleConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/LineToSpeckleConverter.cs similarity index 74% rename from DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/Geometry/LineToSpeckleConverter.cs rename to DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/LineToSpeckleConverter.cs index ce3ad741f3..f68c1b5ba1 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/Geometry/LineToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/LineToSpeckleConverter.cs @@ -1,21 +1,20 @@ -using Autodesk.AutoCAD.DatabaseServices; using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; using Speckle.Core.Models; -namespace Speckle.Converters.Autocad.Geometry; +namespace Speckle.Converters.Autocad.ToSpeckle.Geometry; [NameAndRankValue(nameof(ADB.Line), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] public class LineToSpeckleConverter : IHostObjectToSpeckleConversion, IRawConversion { private readonly IRawConversion _pointConverter; - private readonly IRawConversion _boxConverter; - private readonly IConversionContextStack _contextStack; + private readonly IRawConversion _boxConverter; + private readonly IConversionContextStack _contextStack; public LineToSpeckleConverter( IRawConversion pointConverter, - IRawConversion boxConverter, - IConversionContextStack contextStack + IRawConversion boxConverter, + IConversionContextStack contextStack ) { _pointConverter = pointConverter; diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/PointToSpeckleConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/PointToSpeckleConverter.cs new file mode 100644 index 0000000000..f22f60ef34 --- /dev/null +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/PointToSpeckleConverter.cs @@ -0,0 +1,20 @@ +using Speckle.Converters.Common.Objects; +using Speckle.Converters.Common; +using Speckle.Core.Models; + +namespace Speckle.Converters.Autocad.ToSpeckle.Geometry; + +[NameAndRankValue(nameof(ADB.DBPoint), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +public class PointToSpeckleConverter : IHostObjectToSpeckleConversion +{ + private readonly IRawConversion _pointConverter; + + public PointToSpeckleConverter(IRawConversion pointConverter) + { + _pointConverter = pointConverter; + } + + public Base Convert(object target) => RawConvert((ADB.DBPoint)target); + + public SOG.Point RawConvert(ADB.DBPoint target) => _pointConverter.RawConvert(target.Position); +} diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/PolyfaceMeshToSpeckleConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/PolyfaceMeshToSpeckleConverter.cs new file mode 100644 index 0000000000..545a430c51 --- /dev/null +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/PolyfaceMeshToSpeckleConverter.cs @@ -0,0 +1,106 @@ +using System; +using System.Collections.Generic; +using Autodesk.AutoCAD.Geometry; +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; +using Speckle.Core.Models; + +namespace Speckle.Converters.Autocad.Geometry; + +/// +/// The class converter. Converts to . +/// +/// +/// The IHostObjectToSpeckleConversion inheritance should only expect database-resident objects. IRawConversion inheritance can expect non database-resident objects, when generated from other converters. +/// +[NameAndRankValue(nameof(ADB.PolyFaceMesh), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +public class DBPolyfaceMeshToSpeckleConverter : IHostObjectToSpeckleConversion +{ + private readonly IRawConversion _pointConverter; + private readonly IRawConversion _boxConverter; + private readonly IConversionContextStack _contextStack; + + public DBPolyfaceMeshToSpeckleConverter( + IRawConversion pointConverter, + IRawConversion boxConverter, + IConversionContextStack contextStack + ) + { + _pointConverter = pointConverter; + _boxConverter = boxConverter; + _contextStack = contextStack; + } + + public Base Convert(object target) => RawConvert((ADB.PolyFaceMesh)target); + + public SOG.Mesh RawConvert(ADB.PolyFaceMesh target) + { + List dbVertices = new(); + List faces = new(); + List faceVisibility = new(); + List colors = new(); + using (ADB.Transaction tr = _contextStack.Current.Document.Database.TransactionManager.StartTransaction()) + { + foreach (ADB.ObjectId id in target) + { + ADB.DBObject obj = tr.GetObject(id, ADB.OpenMode.ForRead); + switch (obj) + { + case ADB.PolyFaceMeshVertex o: + dbVertices.Add(o.Position); + colors.Add(o.Color.ColorValue.ToArgb()); + break; + case ADB.FaceRecord o: + List indices = new(); + List hidden = new(); + for (short i = 0; i < 4; i++) + { + short index = o.GetVertexAt(i); + if (index == 0) + { + continue; + } + + // vertices are 1 indexed, and can be negative (hidden) + int adjustedIndex = index > 0 ? index - 1 : Math.Abs(index) - 1; + indices.Add(adjustedIndex); + + // 0 indicates hidden vertex on the face: 1 indicates a visible vertex + hidden.Add(index < 0 ? 0 : 1); + } + + if (indices.Count == 4) + { + faces.AddRange(new List { 4, indices[0], indices[1], indices[2], indices[3] }); + faceVisibility.AddRange(new List { 4, hidden[0], hidden[1], hidden[2], hidden[3] }); + } + else + { + faces.AddRange(new List { 3, indices[0], indices[1], indices[2] }); + faceVisibility.AddRange(new List { 3, hidden[0], hidden[1], hidden[2] }); + } + + break; + } + } + tr.Commit(); + } + + List vertices = new(dbVertices.Count * 3); + foreach (Point3d vert in dbVertices) + { + vertices.AddRange(_pointConverter.RawConvert(vert).ToList()); + } + + SOG.Box bbox = _boxConverter.RawConvert(target.GeometricExtents); + + SOG.Mesh speckleMesh = + new(vertices, faces, colors, null, _contextStack.Current.SpeckleUnits) + { + bbox = bbox, + ["faceVisibility"] = faceVisibility + }; + + return speckleMesh; + } +} diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/Polyline2dToSpeckleConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/Polyline2dToSpeckleConverter.cs new file mode 100644 index 0000000000..889018234b --- /dev/null +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/Polyline2dToSpeckleConverter.cs @@ -0,0 +1,234 @@ +using System.Collections.Generic; +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; +using Speckle.Core.Models; +using Speckle.Converters.Autocad.Extensions; +using System.Linq; + +namespace Speckle.Converters.Autocad.Geometry; + +/// +/// The class converter. Converts to . +/// of type will be converted as . +/// +/// +/// of type will have only s and s in . +/// of type , and will have only one in . +/// The IHostObjectToSpeckleConversion inheritance should only expect database-resident objects. IRawConversion inheritance can expect non database-resident objects, when generated from other converters. +/// +[NameAndRankValue(nameof(ADB.Polyline2d), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +public class Polyline2dToSpeckleConverter : IHostObjectToSpeckleConversion +{ + private readonly IRawConversion _arcConverter; + private readonly IRawConversion _lineConverter; + private readonly IRawConversion _splineConverter; + private readonly IRawConversion _planeConverter; + private readonly IRawConversion _boxConverter; + private readonly IConversionContextStack _contextStack; + + public Polyline2dToSpeckleConverter( + IRawConversion arcConverter, + IRawConversion lineConverter, + IRawConversion splineConverter, + IRawConversion planeConverter, + IRawConversion boxConverter, + IConversionContextStack contextStack + ) + { + _arcConverter = arcConverter; + _lineConverter = lineConverter; + _splineConverter = splineConverter; + _planeConverter = planeConverter; + _boxConverter = boxConverter; + _contextStack = contextStack; + } + + public Base Convert(object target) => RawConvert((ADB.Polyline2d)target); + + public SOG.Autocad.AutocadPolycurve RawConvert(ADB.Polyline2d target) + { + // POC: Below check complicate things, and it is a destructive process. Why not we send it just as is? + // if this is a simple polyline2d, convert it is a lightweight polyline + // if (target.PolyType is Poly2dType.SimplePoly) + // { + // using (ADB.Polyline poly = new ADB.Polyline()) + // { + // poly.ConvertFrom(target, true); + // return _polylineConverter.RawConvert(poly); + // } + // } + + // get the poly type + var polyType = SOG.Autocad.AutocadPolyType.Unknown; + switch (target.PolyType) + { + case ADB.Poly2dType.SimplePoly: + polyType = SOG.Autocad.AutocadPolyType.Simple2d; + break; + case ADB.Poly2dType.FitCurvePoly: + polyType = SOG.Autocad.AutocadPolyType.FitCurve2d; + break; + case ADB.Poly2dType.CubicSplinePoly: + polyType = SOG.Autocad.AutocadPolyType.CubicSpline2d; + break; + case ADB.Poly2dType.QuadSplinePoly: + polyType = SOG.Autocad.AutocadPolyType.QuadSpline2d; + break; + } + + // get all vertex data + List value = new(); + List bulges = new(); + List tangents = new(); + List vertices = target + .GetSubEntities( + ADB.OpenMode.ForRead, + _contextStack.Current.Document.TransactionManager.TopTransaction + ) + .ToList(); + + for (int i = 0; i < vertices.Count; i++) + { + ADB.Vertex2d vertex = vertices[i]; + + // get vertex value in the Global Coordinate System (GCS). + value.AddRange(vertex.Position.ToArray()); + + // get the bulge and tangent, and 3d point for displayvalue + bulges.Add(vertex.Bulge); + tangents.Add(vertex.Tangent); + + // POC: check this data is necessary on receive! + // construct the spline curve segment + // switch (vertex.VertexType) + // { + // case Vertex2dType.CurveFitVertex: + // break; + // case Vertex2dType.SplineFitVertex: + // break; + // case Vertex2dType.SplineControlVertex: + // break; + // } + } + + List segments = new(); + + // POC: retrieve spline display value here for database-resident polylines by connecting all vertex points + if (target.Database is not null) + { + var exploded = new ADB.DBObjectCollection(); + target.Explode(exploded); + AG.Point3d previousPoint = new(); + for (int i = 0; i < exploded.Count; i++) + { + var segment = exploded[i] as ADB.Curve; + + if (segment == null) + { + continue; + } + + if (i == 0 && exploded.Count > 1) + { + // get the connection point to the next segment - this is necessary since imported polycurves might have segments in different directions + var nextSegment = exploded[i + 1] as ADB.Curve; + if (nextSegment == null) + { + continue; + } + AG.Point3d connectionPoint = + nextSegment.StartPoint.IsEqualTo(segment.StartPoint) || nextSegment.StartPoint.IsEqualTo(segment.EndPoint) + ? nextSegment.StartPoint + : nextSegment.EndPoint; + + previousPoint = connectionPoint; + segment = GetCorrectSegmentDirection(segment, connectionPoint, true, out AG.Point3d _); + } + else + { + segment = GetCorrectSegmentDirection(segment, previousPoint, false, out previousPoint); + } + + switch (segment) + { + case ADB.Arc arc: + segments.Add(_arcConverter.RawConvert(arc)); + break; + case ADB.Line line: + segments.Add(_lineConverter.RawConvert(line)); + break; + case ADB.Spline spl: + segments.Add(_splineConverter.RawConvert(spl)); + break; + } + } + } + + // get the spline curve segment + // TODO: need to confirm that this retrieves the correct spline. We may need to construct the spline curve manually from vertex enumeration + // SOG.Curve spline = _splineConverter.RawConvert(target.Spline); + // spline.displayValue = value.ConvertToSpecklePolyline(_contextStack); + + SOG.Plane plane = _planeConverter.RawConvert(target.GetPlane()); + SOG.Box bbox = _boxConverter.RawConvert(target.GeometricExtents); + + SOG.Autocad.AutocadPolycurve polycurve = + new() + { + segments = segments, + value = value, + bulges = bulges, + tangents = tangents, + plane = plane, + polyType = polyType, + closed = target.Closed, + length = target.Length, + area = target.Area, + bbox = bbox, + units = _contextStack.Current.SpeckleUnits + }; + + return polycurve; + } + + private ADB.Curve GetCorrectSegmentDirection( + ADB.Curve segment, + AG.Point3d connectionPoint, + bool isFirstSegment, + out AG.Point3d nextPoint + ) // note sometimes curve3d may not have endpoints + { + nextPoint = segment.EndPoint; + + // POC: will be reconsidered when we started back and forth testing on AutocadPolycurve https://spockle.atlassian.net/browse/CNX-9327 + if (connectionPoint == null) + { + return segment; + } + + bool reverseDirection; + if (isFirstSegment) + { + reverseDirection = segment.StartPoint.IsEqualTo(connectionPoint); + if (reverseDirection) + { + nextPoint = segment.StartPoint; + } + } + else + { + reverseDirection = !segment.StartPoint.IsEqualTo(connectionPoint); + if (reverseDirection) + { + nextPoint = segment.StartPoint; + } + } + + if (reverseDirection) + { + segment.ReverseCurve(); + } + + return segment; + } +} diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/Polyline3dToSpeckleConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/Polyline3dToSpeckleConverter.cs new file mode 100644 index 0000000000..39150ed55a --- /dev/null +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/Polyline3dToSpeckleConverter.cs @@ -0,0 +1,135 @@ +using System.Collections.Generic; +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; +using Speckle.Core.Models; +using Speckle.Converters.Autocad.Extensions; +using System.Linq; +using Autodesk.AutoCAD.Geometry; + +namespace Speckle.Converters.Autocad.Geometry; + +/// +/// The class converter. Converts to . +/// +/// +/// of type will have only s in . +/// of type and will have only one in . +/// The IHostObjectToSpeckleConversion inheritance should only expect database-resident Polyline2d objects. IRawConversion inheritance can expect non database-resident objects, when generated from other converters. +/// +[NameAndRankValue(nameof(ADB.Polyline3d), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +public class Polyline3dToSpeckleConverter : IHostObjectToSpeckleConversion +{ + private readonly IRawConversion _pointConverter; + private readonly IRawConversion _splineConverter; + private readonly IRawConversion _boxConverter; + private readonly IConversionContextStack _contextStack; + + public Polyline3dToSpeckleConverter( + IRawConversion pointConverter, + IRawConversion splineConverter, + IRawConversion boxConverter, + IConversionContextStack contextStack + ) + { + _pointConverter = pointConverter; + _splineConverter = splineConverter; + _boxConverter = boxConverter; + _contextStack = contextStack; + } + + public Base Convert(object target) => RawConvert((ADB.Polyline3d)target); + + public SOG.Autocad.AutocadPolycurve RawConvert(ADB.Polyline3d target) + { + // get the poly type + var polyType = SOG.Autocad.AutocadPolyType.Unknown; + switch (target.PolyType) + { + case ADB.Poly3dType.SimplePoly: + polyType = SOG.Autocad.AutocadPolyType.Simple3d; + break; + case ADB.Poly3dType.CubicSplinePoly: + polyType = SOG.Autocad.AutocadPolyType.CubicSpline3d; + break; + case ADB.Poly3dType.QuadSplinePoly: + polyType = SOG.Autocad.AutocadPolyType.QuadSpline3d; + break; + } + + // get all vertex data except control vertices + List value = new(); + List vertices = target + .GetSubEntities( + ADB.OpenMode.ForRead, + _contextStack.Current.Document.TransactionManager.TopTransaction + ) + .Where(e => e.VertexType != ADB.Vertex3dType.ControlVertex) // Do not collect control points + .ToList(); + + List segments = new(); + for (int i = 0; i < vertices.Count; i++) + { + Point3d vertex = vertices[i].Position; + + // get vertex value in the Global Coordinate System (GCS). + value.AddRange(vertex.ToArray()); + + // construct the segment lines if this is a simple poly + if (i < vertices.Count - 1) + { + if (polyType is SOG.Autocad.AutocadPolyType.Simple3d) + { + var nextVertex = vertices[i + 1].Position; + SOG.Point start = _pointConverter.RawConvert(vertex); + SOG.Point end = _pointConverter.RawConvert(nextVertex); + + SOG.Line segment = new(start, end, _contextStack.Current.SpeckleUnits); + segments.Add(segment); + } + } + } + + // get the spline curve segment if this is a spline polyline3d + // TODO: need to confirm that this retrieves the correct spline. We may need to construct the spline curve manually from vertex enumeration + if (polyType is not SOG.Autocad.AutocadPolyType.Simple3d) + { + // add first 3 coordinate to last for display value polyline for spline + if (target.Closed) + { + var firstPoint = value.Take(3).ToList(); + value.AddRange(firstPoint); + } + + SOG.Curve spline = _splineConverter.RawConvert(target.Spline); + spline.displayValue = value.ConvertToSpecklePolyline(_contextStack.Current.SpeckleUnits); + + segments.Add(spline); + } + else + { + if (target.Closed) + { + SOG.Point start = _pointConverter.RawConvert(vertices.First().Position); + SOG.Point end = _pointConverter.RawConvert(vertices.Last().Position); + segments.Add(new SOG.Line(start, end, _contextStack.Current.SpeckleUnits)); + } + } + + SOG.Box bbox = _boxConverter.RawConvert(target.GeometricExtents); + + SOG.Autocad.AutocadPolycurve polycurve = + new() + { + segments = segments, + value = value, + polyType = polyType, + closed = target.Closed, + length = target.Length, + // area = target.Area, // POC: Polyline3d throws runtime error for get_Area() for sure + bbox = bbox, + units = _contextStack.Current.SpeckleUnits + }; + + return polycurve; + } +} diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/PolylineToSpeckleConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/PolylineToSpeckleConverter.cs new file mode 100644 index 0000000000..7ab614023c --- /dev/null +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/PolylineToSpeckleConverter.cs @@ -0,0 +1,94 @@ +using System.Collections.Generic; +using Autodesk.AutoCAD.DatabaseServices; +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; +using Speckle.Core.Models; + +namespace Speckle.Converters.Autocad.Geometry; + +/// +/// The class converter. Converts to . +/// +/// +/// is of type and will have only s and s in . +/// +[NameAndRankValue(nameof(ADB.Polyline), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +public class PolylineToSpeckleConverter + : IHostObjectToSpeckleConversion, + IRawConversion +{ + private readonly IRawConversion _lineConverter; + private readonly IRawConversion _arcConverter; + private readonly IRawConversion _planeConverter; + private readonly IRawConversion _boxConverter; + private readonly IConversionContextStack _contextStack; + + public PolylineToSpeckleConverter( + IRawConversion lineConverter, + IRawConversion arcConverter, + IRawConversion planeConverter, + IRawConversion boxConverter, + IConversionContextStack contextStack + ) + { + _lineConverter = lineConverter; + _arcConverter = arcConverter; + _planeConverter = planeConverter; + _boxConverter = boxConverter; + _contextStack = contextStack; + } + + public Base Convert(object target) => RawConvert((ADB.Polyline)target); + + public SOG.Autocad.AutocadPolycurve RawConvert(ADB.Polyline target) + { + List value = new(target.NumberOfVertices * 3); + List bulges = new(target.NumberOfVertices); + List segments = new(); + + for (int i = 0; i < target.NumberOfVertices; i++) + { + // get vertex value in the Object Coordinate System (OCS) + AG.Point2d vertex = target.GetPoint2dAt(i); + value.AddRange(vertex.ToArray()); + + // get the bulge + bulges.Add(target.GetBulgeAt(i)); + + // get segment in the Global Coordinate System (GCS) + SegmentType type = target.GetSegmentType(i); + switch (type) + { + case SegmentType.Line: + segments.Add(_lineConverter.RawConvert(target.GetLineSegmentAt(i))); + break; + case SegmentType.Arc: + segments.Add(_arcConverter.RawConvert(target.GetArcSegmentAt(i))); + break; + // POC: commented out claire's exception here because it breaks the conversion seems unnecessarily.. TBD + // default: + // throw new InvalidOperationException("Polyline had an invalid segment of type Empty, Point, or Coincident."); + } + } + + SOG.Plane plane = _planeConverter.RawConvert(target.GetPlane()); + SOG.Box bbox = _boxConverter.RawConvert(target.GeometricExtents); + + SOG.Autocad.AutocadPolycurve polycurve = + new() + { + segments = segments, + value = value, + bulges = bulges, + plane = plane, + polyType = SOG.Autocad.AutocadPolyType.Light, + closed = target.Closed, + length = target.Length, + area = target.Area, + bbox = bbox, + units = _contextStack.Current.SpeckleUnits + }; + + return polycurve; + } +} diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/SplineToSpeckleConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/SplineToSpeckleConverter.cs new file mode 100644 index 0000000000..69953152f7 --- /dev/null +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/SplineToSpeckleConverter.cs @@ -0,0 +1,158 @@ +using System.Collections.Generic; +using System.Linq; +using Autodesk.AutoCAD.Geometry; +using Speckle.Converters.Autocad.Extensions; +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; +using Speckle.Core.Models; + +namespace Speckle.Converters.Autocad.ToSpeckle.Geometry; + +[NameAndRankValue(nameof(ADB.Spline), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +public class SplineToSpeckleConverter : IHostObjectToSpeckleConversion, IRawConversion +{ + private readonly IRawConversion _intervalConverter; + private readonly IRawConversion _boxConverter; + private readonly IConversionContextStack _contextStack; + + public SplineToSpeckleConverter( + IRawConversion intervalConverter, + IRawConversion boxConverter, + IConversionContextStack contextStack + ) + { + _intervalConverter = intervalConverter; + _boxConverter = boxConverter; + _contextStack = contextStack; + } + + public Base Convert(object target) => RawConvert((ADB.Spline)target); + + public SOG.Curve RawConvert(ADB.Spline target) + { + // get nurbs and geo data + ADB.NurbsData data = target.NurbsData; + + // POC: HACK: check for incorrectly closed periodic curves (this seems like acad bug, has resulted from receiving rhino curves) + bool periodicClosed = false; + double length = 0; + SOP.Interval domain = new(); + if (target.GetGeCurve() is NurbCurve3d nurbs) + { + length = nurbs.GetLength(nurbs.StartParameter, nurbs.EndParameter, 0.001); + domain = _intervalConverter.RawConvert(nurbs.GetInterval()); + if (nurbs.Knots.Count < nurbs.NumberOfControlPoints + nurbs.Degree + 1 && target.IsPeriodic) + { + periodicClosed = true; + } + } + + // get points + List points = new(); + foreach (Point3d point in data.GetControlPoints().OfType()) + { + points.Add(point); + } + + // NOTE: for closed periodic splines, autocad does not track last #degree points. + // Add the first #degree control points to the list if so. + if (periodicClosed) + { + points.AddRange(points.GetRange(0, target.Degree)); + } + + // get knots + // NOTE: for closed periodic splines, autocad has #control points + 1 knots. + // Add #degree extra knots to beginning and end with #degree - 1 multiplicity for first and last + var knots = data.GetKnots().OfType().ToList(); + if (periodicClosed) + { + double interval = knots[1] - knots[0]; //knot interval + + for (int i = 0; i < data.Degree; i++) + { + if (i < 2) + { + knots.Insert(knots.Count, knots[knots.Count - 1] + interval); + knots.Insert(0, knots[0] - interval); + } + else + { + knots.Insert(knots.Count, knots[knots.Count - 1]); + knots.Insert(0, knots[0]); + } + } + } + + // get weights + // NOTE: autocad assigns unweighted points a value of -1, and will return an empty list in the spline's nurbsdata if no points are weighted + // NOTE: for closed periodic splines, autocad does not track last #degree points. Add the first #degree weights to the list if so. + List weights = new(); + for (int i = 0; i < target.NumControlPoints; i++) + { + double weight = target.WeightAt(i); + weights.Add(weight <= 0 ? 1 : weight); + } + + if (periodicClosed) + { + weights.AddRange(weights.GetRange(0, target.Degree)); + } + + // set nurbs curve info + var curve = new SOG.Curve + { + points = points.SelectMany(o => o.ToArray()).ToList(), + knots = knots, + weights = weights, + degree = target.Degree, + periodic = target.IsPeriodic, + rational = target.IsRational, + closed = periodicClosed || target.Closed, + length = length, + domain = domain, + bbox = _boxConverter.RawConvert(target.GeometricExtents), + units = _contextStack.Current.SpeckleUnits + }; + + // POC: get display value if this is a database-resident spline + // POC: if this is called by another converter that has created a spline, assumes the display value is set by that converter + if (target.Database is not null) + { + curve.displayValue = GetDisplayValue(target); + } + + return curve; + } + + // POC: we might have DisplayValue converter/mapper? + private SOG.Polyline GetDisplayValue(ADB.Spline spline) + { + ADB.Curve polySpline = spline.ToPolylineWithPrecision(10, false, false); + List verticesList = new(); + switch (polySpline) + { + case ADB.Polyline2d o: + verticesList = o.GetSubEntities( + ADB.OpenMode.ForRead, + _contextStack.Current.Document.TransactionManager.TopTransaction + ) + .Where(e => e.VertexType != ADB.Vertex2dType.SplineControlVertex) // POC: not validated yet! + .SelectMany(o => o.Position.ToArray()) + .ToList(); + + break; + case ADB.Polyline3d o: + verticesList = o.GetSubEntities( + ADB.OpenMode.ForRead, + _contextStack.Current.Document.TransactionManager.TopTransaction + ) + .Where(e => e.VertexType != ADB.Vertex3dType.ControlVertex) + .SelectMany(o => o.Position.ToArray()) + .ToList(); + break; + } + + return verticesList.ConvertToSpecklePolyline(_contextStack.Current.SpeckleUnits); + } +} diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/SubDMeshToSpeckleConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/SubDMeshToSpeckleConverter.cs new file mode 100644 index 0000000000..5242265388 --- /dev/null +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/SubDMeshToSpeckleConverter.cs @@ -0,0 +1,78 @@ +using System.Collections.Generic; +using System.Linq; +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; +using Speckle.Core.Models; + +namespace Speckle.Converters.Autocad.Geometry; + +[NameAndRankValue(nameof(ADB.SubDMesh), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +public class DBSubDMeshToSpeckleConverter : IHostObjectToSpeckleConversion +{ + private readonly IRawConversion _pointConverter; + private readonly IRawConversion _boxConverter; + private readonly IConversionContextStack _contextStack; + + public DBSubDMeshToSpeckleConverter( + IRawConversion pointConverter, + IRawConversion boxConverter, + IConversionContextStack contextStack + ) + { + _pointConverter = pointConverter; + _boxConverter = boxConverter; + _contextStack = contextStack; + } + + public Base Convert(object target) => RawConvert((ADB.SubDMesh)target); + + public SOG.Mesh RawConvert(ADB.SubDMesh target) + { + //vertices + var vertices = new List(target.Vertices.Count * 3); + foreach (AG.Point3d vert in target.Vertices) + { + vertices.AddRange(_pointConverter.RawConvert(vert).ToList()); + } + + // faces + var faces = new List(); + int[] faceArr = target.FaceArray.ToArray(); // contains vertex indices + int edgeCount = 0; + for (int i = 0; i < faceArr.Length; i = i + edgeCount + 1) + { + List faceVertices = new(); + edgeCount = faceArr[i]; + for (int j = i + 1; j <= i + edgeCount; j++) + { + faceVertices.Add(faceArr[j]); + } + + if (edgeCount == 4) // quad face + { + faces.AddRange(new List { 4, faceVertices[0], faceVertices[1], faceVertices[2], faceVertices[3] }); + } + else // triangle face + { + faces.AddRange(new List { 3, faceVertices[0], faceVertices[1], faceVertices[2] }); + } + } + + // colors + var colors = target.VertexColorArray + .Select( + o => + System.Drawing.Color + .FromArgb(System.Convert.ToInt32(o.Red), System.Convert.ToInt32(o.Green), System.Convert.ToInt32(o.Blue)) + .ToArgb() + ) + .ToList(); + + // bbox + SOG.Box bbox = _boxConverter.RawConvert(target.GeometricExtents); + + SOG.Mesh speckleMesh = new(vertices, faces, colors, null, _contextStack.Current.SpeckleUnits) { bbox = bbox }; + + return speckleMesh; + } +} diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/Geometry/BoxToSpeckleConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Raw/BoxToSpeckleRawConverter.cs similarity index 58% rename from DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/Geometry/BoxToSpeckleConverter.cs rename to DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Raw/BoxToSpeckleRawConverter.cs index dc4411ae2f..62f798ae11 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/Geometry/BoxToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Raw/BoxToSpeckleRawConverter.cs @@ -1,28 +1,26 @@ -using Autodesk.AutoCAD.DatabaseServices; using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; using Speckle.Core.Models; -namespace Speckle.Converters.Autocad.Geometry; +namespace Speckle.Converters.Autocad.ToSpeckle.Raw; -[NameAndRankValue(nameof(Extents3d), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class DBBoxToSpeckleConverter : IHostObjectToSpeckleConversion, IRawConversion +public class BoxToSpeckleRawConverter : IRawConversion { private readonly IRawConversion _planeConverter; - private readonly IConversionContextStack _contextStack; + private readonly IConversionContextStack _contextStack; - public DBBoxToSpeckleConverter( + public BoxToSpeckleRawConverter( IRawConversion planeConverter, - IConversionContextStack contextStack + IConversionContextStack contextStack ) { _planeConverter = planeConverter; _contextStack = contextStack; } - public Base Convert(object target) => RawConvert((Extents3d)target); + public Base Convert(object target) => RawConvert((ADB.Extents3d)target); - public SOG.Box RawConvert(Extents3d target) + public SOG.Box RawConvert(ADB.Extents3d target) { // get dimension intervals and volume SOP.Interval xSize = new(target.MinPoint.X, target.MaxPoint.X); @@ -31,7 +29,7 @@ public SOG.Box RawConvert(Extents3d target) double volume = xSize.Length * ySize.Length * zSize.Length; // get the base plane of the bounding box from extents and current UCS - var ucs = Application.DocumentManager.CurrentDocument.Editor.CurrentUserCoordinateSystem.CoordinateSystem3d; + var ucs = _contextStack.Current.Document.Editor.CurrentUserCoordinateSystem.CoordinateSystem3d; AG.Plane acadPlane = new(target.MinPoint, ucs.Xaxis, ucs.Yaxis); SOG.Plane plane = _planeConverter.RawConvert(acadPlane); diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Raw/CircularArc3dToSpeckleConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Raw/CircularArc3dToSpeckleConverter.cs new file mode 100644 index 0000000000..5979f9d7aa --- /dev/null +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Raw/CircularArc3dToSpeckleConverter.cs @@ -0,0 +1,50 @@ +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; + +namespace Speckle.Converters.Autocad.ToSpeckle.Raw; + +public class CircularArc3dToSpeckleConverter : IRawConversion +{ + private readonly IRawConversion _pointConverter; + private readonly IRawConversion _planeConverter; + private readonly IConversionContextStack _contextStack; + + public CircularArc3dToSpeckleConverter( + IRawConversion pointConverter, + IRawConversion planeConverter, + IConversionContextStack contextStack + ) + { + _pointConverter = pointConverter; + _planeConverter = planeConverter; + _contextStack = contextStack; + } + + public SOG.Arc RawConvert(AG.CircularArc3d target) + { + SOG.Plane plane = _planeConverter.RawConvert(target.GetPlane()); + SOG.Point start = _pointConverter.RawConvert(target.StartPoint); + SOG.Point end = _pointConverter.RawConvert(target.EndPoint); + SOG.Point mid = _pointConverter.RawConvert(target.EvaluatePoint(0.5)); // POC: testing, unsure + SOP.Interval domain = new(target.GetInterval().LowerBound, target.GetInterval().UpperBound); + + SOG.Arc arc = + new( + plane, + target.Radius, + target.StartAngle, + target.EndAngle, + target.EndAngle - target.StartAngle, // POC: testing, unsure + _contextStack.Current.SpeckleUnits + ) + { + startPoint = start, + endPoint = end, + midPoint = mid, + domain = domain, + length = target.GetLength(0, 1, 0.000) + }; + + return arc; + } +} diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Raw/IntervalToSpeckleRawConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Raw/IntervalToSpeckleRawConverter.cs new file mode 100644 index 0000000000..77613f996d --- /dev/null +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Raw/IntervalToSpeckleRawConverter.cs @@ -0,0 +1,11 @@ +using Speckle.Converters.Common.Objects; +using Speckle.Core.Models; + +namespace Speckle.Converters.Autocad.ToSpeckle.Raw; + +public class IntervalToSpeckleConverter : IRawConversion +{ + public Base Convert(object target) => RawConvert((AG.Interval)target); + + public SOP.Interval RawConvert(AG.Interval target) => new(target.LowerBound, target.UpperBound); +} diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Raw/LineSegment3dToSpeckleRawConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Raw/LineSegment3dToSpeckleRawConverter.cs new file mode 100644 index 0000000000..f1bc383664 --- /dev/null +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Raw/LineSegment3dToSpeckleRawConverter.cs @@ -0,0 +1,30 @@ +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; + +namespace Speckle.Converters.Autocad.ToSpeckle.Raw; + +public class LineSegment3dToSpeckleRawConverter : IRawConversion +{ + private readonly IRawConversion _pointConverter; + private readonly IConversionContextStack _contextStack; + + public LineSegment3dToSpeckleRawConverter( + IRawConversion pointConverter, + IConversionContextStack contextStack + ) + { + _pointConverter = pointConverter; + _contextStack = contextStack; + } + + public SOG.Line RawConvert(AG.LineSegment3d target) => + new( + _pointConverter.RawConvert(target.StartPoint), + _pointConverter.RawConvert(target.EndPoint), + _contextStack.Current.SpeckleUnits + ) + { + length = target.Length, + domain = new SOP.Interval(0, target.Length), + }; +} diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/Geometry/PlaneToSpeckleConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Raw/PlaneToSpeckleRawConverter.cs similarity index 67% rename from DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/Geometry/PlaneToSpeckleConverter.cs rename to DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Raw/PlaneToSpeckleRawConverter.cs index 972c14f438..86ac812497 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/Geometry/PlaneToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Raw/PlaneToSpeckleRawConverter.cs @@ -1,21 +1,19 @@ -using Autodesk.AutoCAD.DatabaseServices; using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; using Speckle.Core.Models; -namespace Speckle.Converters.Autocad.Geometry; +namespace Speckle.Converters.Autocad.ToSpeckle.Raw; -[NameAndRankValue(nameof(AG.Plane), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class PlaneToSpeckleConverter : IHostObjectToSpeckleConversion, IRawConversion +public class PlaneToSpeckleRawConverter : IHostObjectToSpeckleConversion, IRawConversion { private readonly IRawConversion _vectorConverter; private readonly IRawConversion _pointConverter; - private readonly IConversionContextStack _contextStack; + private readonly IConversionContextStack _contextStack; - public PlaneToSpeckleConverter( + public PlaneToSpeckleRawConverter( IRawConversion vectorConverter, IRawConversion pointConverter, - IConversionContextStack contextStack + IConversionContextStack contextStack ) { _vectorConverter = vectorConverter; diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Raw/PointToSpeckleRawConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Raw/PointToSpeckleRawConverter.cs new file mode 100644 index 0000000000..5dc90c63ca --- /dev/null +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Raw/PointToSpeckleRawConverter.cs @@ -0,0 +1,17 @@ +using Speckle.Converters.Common.Objects; +using Speckle.Converters.Common; + +namespace Speckle.Converters.Autocad.ToSpeckle.Raw; + +public class PointToSpeckleRawConverter : IRawConversion +{ + private readonly IConversionContextStack _contextStack; + + public PointToSpeckleRawConverter(IConversionContextStack contextStack) + { + _contextStack = contextStack; + } + + public SOG.Point RawConvert(AG.Point3d target) => + new(target.X, target.Y, target.Z, _contextStack.Current.SpeckleUnits); +} diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Raw/VectorToSpeckleRawConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Raw/VectorToSpeckleRawConverter.cs new file mode 100644 index 0000000000..770e24cf69 --- /dev/null +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Raw/VectorToSpeckleRawConverter.cs @@ -0,0 +1,17 @@ +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; + +namespace Speckle.Converters.Autocad.ToSpeckle.Raw; + +public class VectorToSpeckleRawConverter : IRawConversion +{ + private readonly IConversionContextStack _contextStack; + + public VectorToSpeckleRawConverter(IConversionContextStack contextStack) + { + _contextStack = contextStack; + } + + public SOG.Vector RawConvert(AG.Vector3d target) => + new(target.X, target.Y, target.Z, _contextStack.Current.SpeckleUnits); +} diff --git a/DUI3-DX/Sdk/Speckle.Connectors.Utils/Builders/IRootObjectBuilder.cs b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Builders/IRootObjectBuilder.cs new file mode 100644 index 0000000000..2572a158eb --- /dev/null +++ b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Builders/IRootObjectBuilder.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Threading; +using Speckle.Connectors.Utils.Operations; +using Speckle.Core.Models; + +namespace Speckle.Connectors.Utils.Builders; + +public interface IRootObjectBuilder +{ + public Base Build( + IReadOnlyList objects, + SendInfo sendInfo, + Action? onOperationProgressed = null, + CancellationToken ct = default + ); +} diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Send/IRootObjectSender.cs b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/IRootObjectSender.cs similarity index 71% rename from DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Send/IRootObjectSender.cs rename to DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/IRootObjectSender.cs index c0226c2f63..5ebc3c585e 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Send/IRootObjectSender.cs +++ b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/IRootObjectSender.cs @@ -1,9 +1,10 @@ using System; +using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; using Speckle.Core.Models; -namespace Speckle.Connectors.Rhino7.Operations.Send; +namespace Speckle.Connectors.Utils.Operations; /// /// Contract for the send operation that handles an assembled object. @@ -12,11 +13,9 @@ namespace Speckle.Connectors.Rhino7.Operations.Send; /// public interface IRootObjectSender { - public Task Send( + public Task<(string rootObjId, Dictionary convertedReferences)> Send( Base commitObject, - string accountId, - string projectId, - string modelId, + SendInfo sendInfo, Action? onOperationProgressed = null, CancellationToken ct = default ); diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Send/RootObjectSender.cs b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/RootObjectSender.cs similarity index 52% rename from DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Send/RootObjectSender.cs rename to DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/RootObjectSender.cs index 27b847e608..576a83a71c 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Send/RootObjectSender.cs +++ b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/RootObjectSender.cs @@ -1,19 +1,19 @@ using System; +using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; -using Speckle.Connectors.Utils.Operations; using Speckle.Core.Api; using Speckle.Core.Credentials; using Speckle.Core.Models; using Speckle.Core.Transports; -namespace Speckle.Connectors.Rhino7.Operations.Send; +namespace Speckle.Connectors.Utils.Operations; /// /// Default implementation of the which takes a and sends /// it to a server described by the parameters in the method /// -internal sealed class RootObjectSender : IRootObjectSender +public sealed class RootObjectSender : IRootObjectSender { // POC: Revisit this factory pattern, I think we could solve this higher up by injecting a scoped factory for `SendOperation` in the SendBinding private readonly Func _transportFactory; @@ -23,11 +23,9 @@ public RootObjectSender(Func transportFactory) _transportFactory = transportFactory; } - public async Task Send( + public async Task<(string rootObjId, Dictionary convertedReferences)> Send( Base commitObject, - string accountId, - string projectId, - string modelId, + SendInfo sendInfo, Action? onOperationProgressed = null, CancellationToken ct = default ) @@ -36,22 +34,12 @@ public async Task Send( onOperationProgressed?.Invoke("Uploading...", null); - Account account = AccountManager.GetAccount(accountId); + Account account = AccountManager.GetAccount(sendInfo.AccountId); - ITransport transport = _transportFactory(account, projectId); + ITransport transport = _transportFactory(account, sendInfo.ProjectId); var sendResult = await SendHelper.Send(commitObject, transport, true, null, ct).ConfigureAwait(false); ct.ThrowIfCancellationRequested(); - //// Store the converted references in memory for future send operations, overwriting the existing values for the given application id. - //foreach (var kvp in sendResult.ConvertedReferences) - //{ - // // TODO: Bug in here, we need to encapsulate cache not only by app id, but also by project id, - // // TODO: as otherwise we assume incorrectly that an object exists for a given project (e.g, send box to project 1, send same unchanged box to project 2) - // _convertedObjectReferences[kvp.Key + projectId] = kvp.Value; - //} - // It's important to reset the model card's list of changed obj ids so as to ensure we accurately keep track of changes between send operations. - // NOTE: ChangedObjectIds is currently JsonIgnored, but could actually be useful for highlighting changes in host app. - //modelCard.ChangedObjectIds = new(); onOperationProgressed?.Invoke("Linking version to model...", null); @@ -61,15 +49,15 @@ public async Task Send( .CommitCreate( new CommitCreateInput { - streamId = projectId, - branchName = modelId, - sourceApplication = "Rhino", + streamId = sendInfo.ProjectId, + branchName = sendInfo.ModelId, + sourceApplication = sendInfo.SourceApplication, objectId = sendResult.rootObjId }, ct ) .ConfigureAwait(true); - return versionId; + return sendResult; } } diff --git a/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/SendInfo.cs b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/SendInfo.cs new file mode 100644 index 0000000000..82b80722b9 --- /dev/null +++ b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/SendInfo.cs @@ -0,0 +1,14 @@ +using System.Collections.Generic; +using Speckle.Core.Models; + +namespace Speckle.Connectors.Utils.Operations; + +public struct SendInfo +{ + public string AccountId { get; set; } + public string ProjectId { get; set; } + public string ModelId { get; set; } + public string SourceApplication { get; set; } + public Dictionary ConvertedObjects { get; set; } + public HashSet ChangedObjectIds { get; set; } +} diff --git a/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/SendOperation.cs b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/SendOperation.cs new file mode 100644 index 0000000000..6fa7c7b881 --- /dev/null +++ b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/SendOperation.cs @@ -0,0 +1,40 @@ +using System; +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; +using Speckle.Connectors.Utils.Builders; +using Speckle.Core.Models; + +namespace Speckle.Connectors.Utils.Operations; + +public sealed class SendOperation +{ + private readonly IRootObjectBuilder _rootObjectBuilder; + private readonly IRootObjectSender _baseObjectSender; + private readonly ISyncToMainThread _syncToMainThread; + + public SendOperation( + IRootObjectBuilder rootObjectBuilder, + IRootObjectSender baseObjectSender, + ISyncToMainThread syncToMainThread + ) + { + _rootObjectBuilder = rootObjectBuilder; + _baseObjectSender = baseObjectSender; + _syncToMainThread = syncToMainThread; + } + + public async Task<(string rootObjId, Dictionary convertedReferences)> Execute( + IReadOnlyList objects, + SendInfo sendInfo, + Action? onOperationProgressed = null, + CancellationToken ct = default + ) + { + Base commitObject = _rootObjectBuilder.Build(objects, sendInfo, onOperationProgressed, ct); + + // base object handler is separated so we can do some testing on non-production databases + // exact interface may want to be tweaked when we implement this + return await _baseObjectSender.Send(commitObject, sendInfo, onOperationProgressed, ct).ConfigureAwait(false); + } +} diff --git a/Objects/Objects/Geometry/Autocad/AutocadPolycurve.cs b/Objects/Objects/Geometry/Autocad/AutocadPolycurve.cs new file mode 100644 index 0000000000..c7a741fc0b --- /dev/null +++ b/Objects/Objects/Geometry/Autocad/AutocadPolycurve.cs @@ -0,0 +1,82 @@ +using System.Collections.Generic; +using Speckle.Core.Models; + +namespace Objects.Geometry.Autocad; + +/// +/// A curve that is comprised of line, arc and/or curve segments, representing the Autocad Polyline, Polyline2d, and Polyline3d classes. +/// +/// +/// will have only s and s in . +/// type will have only s in . +/// type will only have s in . +/// , , , and types will have only a single s in . +/// +public class AutocadPolycurve : Polycurve +{ + /// + /// Constructs a new empty instance. + /// + public AutocadPolycurve() { } + + /// + /// Gets or sets the raw coordinates of the vertices. + /// + /// + /// For Polylines, these are xy coordinates in the Object Coordinate System (OCS) of the . + /// For Polyline2d and Polyline3d types, these are xyz coordinates in the Global Coordinate System. fml. + /// + [DetachProperty, Chunkable(31250)] + public List value { get; set; } = new(); + + /// + /// The bulge factor at each vertex. Should be null for Polyline3d. + /// + /// + /// The bulge factor is used to indicate how much of an arc segment is present at this vertex. + /// The bulge factor is the tangent of one fourth the included angle for an arc segment, + /// made negative if the arc goes clockwise from the start point to the endpoint. + /// A bulge of 0 indicates a straight segment, and a bulge of 1 is a semicircle. + /// + public List? bulges { get; set; } + + /// + /// The tangent in radians at each vertex. Should be null for Polyline and Polyline3d. + /// + public List? tangents { get; set; } + + /// + /// The plane of the Autocad Polyline or Polyline2d. Should be null for Polyline3d. + /// + /// + public Plane? plane { get; set; } + + public AutocadPolyType polyType { get; set; } +} + +/// +/// Represents the type of a Autocad Polyline. +/// +public enum AutocadPolyType +{ + /// Polyline type is not known + Unknown, + + /// Polyline type is the Autocad Polyline class + Light, + + Simple2d, + + Simple3d, + + /// The Autocad Polyline2d fit curve poly type. Constructed with pairs of arcs with continuous tangents. + FitCurve2d, + + CubicSpline2d, + + CubicSpline3d, + + QuadSpline2d, + + QuadSpline3d, +} From f11bb5e841b9a711d9bac2aad286d98e5cfa5f31 Mon Sep 17 00:00:00 2001 From: KatKatKateryna <89912278+KatKatKateryna@users.noreply.github.com> Date: Thu, 25 Apr 2024 20:52:26 +0800 Subject: [PATCH 047/261] CNX-9291 Implement Unit of Work for ArcGIS Send and Receive bindings (#3309) * implement uow for Send and Receive bindings * add unit converter * fix: Revert cancellation manager to intance per dependency --------- Co-authored-by: Alan Rynne --- .../Bindings/ArcGISReceiveBinding.cs | 14 +++++++++----- .../Bindings/ArcGISSendBinding.cs | 2 +- .../DependencyInjection/AutofacArcGISModule.cs | 17 ++++++++++------- .../AutofacArcGIS3ConverterModule.cs | 5 +++++ 4 files changed, 25 insertions(+), 13 deletions(-) diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISReceiveBinding.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISReceiveBinding.cs index 3b143a972f..2e303c641a 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISReceiveBinding.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISReceiveBinding.cs @@ -1,3 +1,4 @@ +using Speckle.Autofac.DependencyInjection; using Speckle.Connectors.ArcGIS.Utils; using Speckle.Connectors.DUI.Bindings; using Speckle.Connectors.DUI.Bridge; @@ -14,22 +15,23 @@ public sealed class ArcGISReceiveBinding : IReceiveBinding, ICancelable public string Name { get; } = "receiveBinding"; private readonly CancellationManager _cancellationManager; private readonly ArcGISDocumentStore _store; - private readonly ReceiveOperation _receiveOperation; + private readonly IUnitOfWorkFactory _unitOfWorkFactory; + public ReceiveBindingUICommands Commands { get; } public IBridge Parent { get; } public ArcGISReceiveBinding( ArcGISDocumentStore store, IBridge parent, - ReceiveOperation receiveOperation, - CancellationManager cancellationManager + CancellationManager cancellationManager, + IUnitOfWorkFactory unitOfWorkFactory ) { _store = store; _cancellationManager = cancellationManager; - _receiveOperation = receiveOperation; Parent = parent; Commands = new ReceiveBindingUICommands(parent); + _unitOfWorkFactory = unitOfWorkFactory; } public async Task Receive(string modelCardId) @@ -45,8 +47,10 @@ public async Task Receive(string modelCardId) throw new InvalidOperationException("No download model card was found."); } + using IUnitOfWork unitOfWork = _unitOfWorkFactory.Resolve(); + // Receive host objects - IEnumerable receivedObjectIds = await _receiveOperation + IEnumerable receivedObjectIds = await unitOfWork.Service .Execute( modelCard.AccountId, // POC: I hear -you are saying why we're passing them separately. Not sure pass the DUI3-> Connectors.DUI project dependency to the SDK-> Connector.Utils modelCard.ProjectId, diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISSendBinding.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISSendBinding.cs index e9ff997ecc..a48f407afc 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISSendBinding.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISSendBinding.cs @@ -70,7 +70,7 @@ public List GetSendSettings() public async Task Send(string modelCardId) { //poc: dupe code between connectors - using var unitOfWork = _unitOfWorkFactory.Resolve(); + using IUnitOfWork unitOfWork = _unitOfWorkFactory.Resolve(); try { // 0 - Init cancellation token source -> Manager also cancel it if exist before diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/DependencyInjection/AutofacArcGISModule.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/DependencyInjection/AutofacArcGISModule.cs index 7306371176..0ae7866b71 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/DependencyInjection/AutofacArcGISModule.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/DependencyInjection/AutofacArcGISModule.cs @@ -45,26 +45,29 @@ protected override void Load(ContainerBuilder builder) builder.RegisterType().As().SingleInstance(); builder.RegisterType().As().SingleInstance(); builder.RegisterType().As().SingleInstance(); - builder.RegisterType().As>().SingleInstance(); + builder + .RegisterType() + .As>() + .InstancePerLifetimeScope(); // Operations builder.RegisterType().AsSelf().InstancePerLifetimeScope(); - builder.RegisterType().As().SingleInstance(); + builder.RegisterType().As().InstancePerLifetimeScope(); // Object Builders - builder.RegisterType().As().InstancePerDependency(); + builder.RegisterType().As().InstancePerLifetimeScope(); // POC: Register here also RootObjectBuilder as IRootObjectBuilder // binding dependencies builder.RegisterType().InstancePerDependency(); // register send filters - builder.RegisterType().As().InstancePerDependency(); + builder.RegisterType().As().InstancePerLifetimeScope(); // register send operation and dependencies - builder.RegisterType().SingleInstance(); - builder.RegisterType().SingleInstance(); - builder.RegisterType().As().SingleInstance(); + builder.RegisterType().InstancePerLifetimeScope(); + builder.RegisterType().InstancePerLifetimeScope(); + builder.RegisterType().As().InstancePerLifetimeScope(); //POC: how tf does this work? builder.RegisterType().As().SingleInstance(); diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3.DependencyInjection/AutofacArcGIS3ConverterModule.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3.DependencyInjection/AutofacArcGIS3ConverterModule.cs index 471d214270..fb0c2e3d4a 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3.DependencyInjection/AutofacArcGIS3ConverterModule.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3.DependencyInjection/AutofacArcGIS3ConverterModule.cs @@ -20,6 +20,11 @@ protected override void Load(ContainerBuilder builder) builder.RegisterType().As().InstancePerLifetimeScope(); builder.RegisterType().As().InstancePerLifetimeScope(); + builder + .RegisterType() + .As>() + .InstancePerLifetimeScope(); + // single stack per conversion builder .RegisterType() From d73f331108e7d154d1264db873f1710928875bff Mon Sep 17 00:00:00 2001 From: Jedd Morgan <45512892+JR-Morgan@users.noreply.github.com> Date: Thu, 25 Apr 2024 13:52:58 +0100 Subject: [PATCH 048/261] CNX-9320 resolve duplication of webview xaml control (#3307) * Proposed web view project * DUI3ControlWebView * exception type * Fixed usings * removed redundant project reference --- All.sln | 19 +++++++ DUI3-DX.slnf | 1 + .../AutofacArcGISModule.cs | 4 +- .../HostApp/SpeckleDUI3.xaml | 23 --------- .../Speckle.Connectors.ArcGIS3.csproj | 3 +- .../SpeckleDUI3Wrapper.cs | 4 +- .../Speckle.Connectors.Autocad2023.csproj | 3 +- .../AutofacAutocadModule.cs | 3 +- .../HostApp/DUI3PanelWebView.xaml | 20 -------- .../HostApp/DUI3PanelWebView.xaml.cs | 40 --------------- .../Plugin/AutocadCommand.cs | 3 +- .../Plugin/AutocadPlugin.cs | 5 +- ...Speckle.Connectors.AutocadShared.projitems | 6 --- .../DependencyInjection/AutofacRhinoModule.cs | 3 +- .../DependencyInjection/RhinoPlugin.cs | 5 +- .../HostApp/SpeckleRhinoPanel.xaml.cs | 51 ------------------- .../HostApp/SpeckleRhinoPanelHost.cs | 3 +- .../Speckle.Connectors.Rhino7.csproj | 3 +- .../DUI3ControlWebView.xaml} | 8 +-- .../DUI3ControlWebView.xaml.cs} | 23 +++------ .../Speckle.Connectors.DUI.WebView.csproj | 17 +++++++ 21 files changed, 70 insertions(+), 177 deletions(-) delete mode 100644 DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/HostApp/SpeckleDUI3.xaml delete mode 100644 DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/DUI3PanelWebView.xaml delete mode 100644 DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/DUI3PanelWebView.xaml.cs delete mode 100644 DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/SpeckleRhinoPanel.xaml.cs rename DUI3-DX/{Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/SpeckleRhinoPanel.xaml => DUI3/Speckle.Connectors.DUI.WebView/DUI3ControlWebView.xaml} (86%) rename DUI3-DX/{Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/HostApp/SpeckleDUI3.xaml.cs => DUI3/Speckle.Connectors.DUI.WebView/DUI3ControlWebView.xaml.cs} (58%) create mode 100644 DUI3-DX/DUI3/Speckle.Connectors.DUI.WebView/Speckle.Connectors.DUI.WebView.csproj diff --git a/All.sln b/All.sln index f472ea0ae3..8714f6c232 100644 --- a/All.sln +++ b/All.sln @@ -562,6 +562,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Speckle.Converters.Autocad2 EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Speckle.Converters.Autocad2023.DependencyInjection", "DUI3-DX\Converters\Autocad\Speckle.Converters.Autocad2023.DependencyInjection\Speckle.Converters.Autocad2023.DependencyInjection.csproj", "{D940853C-003A-482C-BDB0-665367F274A0}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Speckle.Connectors.DUI.WebView", "DUI3-DX\DUI3\Speckle.Connectors.DUI.WebView\Speckle.Connectors.DUI.WebView.csproj", "{7420652C-3046-4F38-BE64-9B9E69D76FA2}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug Mac|Any CPU = Debug Mac|Any CPU @@ -2812,6 +2814,22 @@ Global {D940853C-003A-482C-BDB0-665367F274A0}.Release|Any CPU.Build.0 = Release|Any CPU {D940853C-003A-482C-BDB0-665367F274A0}.Release|x64.ActiveCfg = Release|Any CPU {D940853C-003A-482C-BDB0-665367F274A0}.Release|x64.Build.0 = Release|Any CPU + {7420652C-3046-4F38-BE64-9B9E69D76FA2}.Debug Mac|Any CPU.ActiveCfg = Debug|Any CPU + {7420652C-3046-4F38-BE64-9B9E69D76FA2}.Debug Mac|Any CPU.Build.0 = Debug|Any CPU + {7420652C-3046-4F38-BE64-9B9E69D76FA2}.Debug Mac|x64.ActiveCfg = Debug|Any CPU + {7420652C-3046-4F38-BE64-9B9E69D76FA2}.Debug Mac|x64.Build.0 = Debug|Any CPU + {7420652C-3046-4F38-BE64-9B9E69D76FA2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7420652C-3046-4F38-BE64-9B9E69D76FA2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7420652C-3046-4F38-BE64-9B9E69D76FA2}.Debug|x64.ActiveCfg = Debug|Any CPU + {7420652C-3046-4F38-BE64-9B9E69D76FA2}.Debug|x64.Build.0 = Debug|Any CPU + {7420652C-3046-4F38-BE64-9B9E69D76FA2}.Release Mac|Any CPU.ActiveCfg = Debug|Any CPU + {7420652C-3046-4F38-BE64-9B9E69D76FA2}.Release Mac|Any CPU.Build.0 = Debug|Any CPU + {7420652C-3046-4F38-BE64-9B9E69D76FA2}.Release Mac|x64.ActiveCfg = Debug|Any CPU + {7420652C-3046-4F38-BE64-9B9E69D76FA2}.Release Mac|x64.Build.0 = Debug|Any CPU + {7420652C-3046-4F38-BE64-9B9E69D76FA2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7420652C-3046-4F38-BE64-9B9E69D76FA2}.Release|Any CPU.Build.0 = Release|Any CPU + {7420652C-3046-4F38-BE64-9B9E69D76FA2}.Release|x64.ActiveCfg = Release|Any CPU + {7420652C-3046-4F38-BE64-9B9E69D76FA2}.Release|x64.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -3031,6 +3049,7 @@ Global {9ADD1B7A-6401-4202-8613-F668E2FBC0A4} = {804E065F-914C-414A-AF84-009312C3CFF6} {631C295A-7CCF-4B42-8686-7034E31469E7} = {804E065F-914C-414A-AF84-009312C3CFF6} {D940853C-003A-482C-BDB0-665367F274A0} = {804E065F-914C-414A-AF84-009312C3CFF6} + {7420652C-3046-4F38-BE64-9B9E69D76FA2} = {FD4D6594-D81E-456F-8F2E-35B09E04A755} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {1D43D91B-4F01-4A78-8250-CC6F9BD93A14} diff --git a/DUI3-DX.slnf b/DUI3-DX.slnf index e9bbc060d2..282d1fb349 100644 --- a/DUI3-DX.slnf +++ b/DUI3-DX.slnf @@ -23,6 +23,7 @@ "DUI3-DX\\Converters\\Revit\\Speckle.Converters.RevitShared\\Speckle.Converters.RevitShared.shproj", "DUI3-DX\\Converters\\Rhino\\Speckle.Converters.Rhino7.DependencyInjection\\Speckle.Converters.Rhino7.DependencyInjection.csproj", "DUI3-DX\\Converters\\Rhino\\Speckle.Converters.Rhino7\\Speckle.Converters.Rhino7.csproj", + "DUI3-DX\\DUI3\\Speckle.Connectors.DUI.WebView\\Speckle.Connectors.DUI.WebView.csproj", "DUI3-DX\\DUI3\\Speckle.Connectors.DUI\\Speckle.Connectors.DUI.csproj", "DUI3-DX\\Objects\\Speckle.Objects.Common\\Speckle.Objects.Common.csproj", "DUI3-DX\\Objects\\Speckle.Objects.Revit\\Speckle.Objects.Revit.csproj", diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/DependencyInjection/AutofacArcGISModule.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/DependencyInjection/AutofacArcGISModule.cs index 0ae7866b71..2525b0f56d 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/DependencyInjection/AutofacArcGISModule.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/DependencyInjection/AutofacArcGISModule.cs @@ -3,7 +3,6 @@ using Serilog; using Speckle.Autofac.DependencyInjection; using Speckle.Connectors.ArcGIS.Bindings; -using Speckle.Connectors.ArcGIS.HostApp; using Speckle.Connectors.ArcGis.Operations.Send; using Speckle.Connectors.DUI.Bindings; using Speckle.Connectors.DUI.Bridge; @@ -17,6 +16,7 @@ using Speckle.Core.Transports; using Speckle.Connectors.ArcGIS.Operations.Receive; using Speckle.Connectors.DUI.Models.Card.SendFilter; +using Speckle.Connectors.DUI.WebView; using Speckle.Connectors.Utils.Builders; using Speckle.Connectors.Utils.Operations; using ArcGIS.Core.Geometry; @@ -34,7 +34,7 @@ protected override void Load(ContainerBuilder builder) builder.RegisterInstance(GetJsonSerializerSettings()).SingleInstance(); builder.RegisterType().As().InstancePerDependency(); //TODO: Verify why we need one bridge instance per dependency. - builder.RegisterType().SingleInstance(); + builder.RegisterType().SingleInstance(); builder.RegisterType().SingleInstance(); // Register bindings diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/HostApp/SpeckleDUI3.xaml b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/HostApp/SpeckleDUI3.xaml deleted file mode 100644 index bcf6c07331..0000000000 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/HostApp/SpeckleDUI3.xaml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Speckle.Connectors.ArcGIS3.csproj b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Speckle.Connectors.ArcGIS3.csproj index 17443d8505..f81aa0f469 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Speckle.Connectors.ArcGIS3.csproj +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Speckle.Connectors.ArcGIS3.csproj @@ -21,7 +21,6 @@ - @@ -31,7 +30,7 @@ - + diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/SpeckleDUI3Wrapper.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/SpeckleDUI3Wrapper.cs index 83bb7f39b6..2c120c765a 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/SpeckleDUI3Wrapper.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/SpeckleDUI3Wrapper.cs @@ -1,5 +1,5 @@ using System.Windows.Controls; -using Speckle.Connectors.ArcGIS.HostApp; +using Speckle.Connectors.DUI.WebView; namespace Speckle.Connectors.ArcGIS; @@ -12,6 +12,6 @@ public SpeckleDUI3Wrapper() private void Initialize() { - Content = SpeckleModule.Current.Container.Resolve(); + Content = SpeckleModule.Current.Container.Resolve(); } } diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.Autocad2023/Speckle.Connectors.Autocad2023.csproj b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.Autocad2023/Speckle.Connectors.Autocad2023.csproj index d576d46a1a..895ede52aa 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.Autocad2023/Speckle.Connectors.Autocad2023.csproj +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.Autocad2023/Speckle.Connectors.Autocad2023.csproj @@ -10,7 +10,7 @@ - + @@ -18,7 +18,6 @@ - diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/DependencyInjection/AutofacAutocadModule.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/DependencyInjection/AutofacAutocadModule.cs index 7d734be9f7..f01aa9acbe 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/DependencyInjection/AutofacAutocadModule.cs +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/DependencyInjection/AutofacAutocadModule.cs @@ -20,6 +20,7 @@ using Speckle.Connectors.Autocad.Operations.Receive; using Speckle.Connectors.Autocad.Operations.Send; using Speckle.Connectors.DUI.Models.Card.SendFilter; +using Speckle.Connectors.DUI.WebView; using Speckle.Connectors.Utils.Builders; using Speckle.Connectors.Utils.Operations; using Speckle.Core.Transports; @@ -34,7 +35,7 @@ protected override void Load(ContainerBuilder builder) // Register DUI3 related stuff builder.RegisterInstance(GetJsonSerializerSettings()).SingleInstance(); - builder.RegisterType().SingleInstance(); + builder.RegisterType().SingleInstance(); builder.RegisterType().As().InstancePerDependency(); // POC: Each binding should have it's own bridge instance // Register other connector specific types diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/DUI3PanelWebView.xaml b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/DUI3PanelWebView.xaml deleted file mode 100644 index 984c1fb015..0000000000 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/DUI3PanelWebView.xaml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/DUI3PanelWebView.xaml.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/DUI3PanelWebView.xaml.cs deleted file mode 100644 index 13de7fea03..0000000000 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/DUI3PanelWebView.xaml.cs +++ /dev/null @@ -1,40 +0,0 @@ -using System.Windows.Controls; -using System.Windows.Threading; -using Speckle.Connectors.DUI.Bindings; -using Speckle.Core.Logging; -using Microsoft.Web.WebView2.Core; - -namespace Speckle.Connectors.Autocad.HostApp; - -public partial class Dui3PanelWebView : UserControl -{ - private readonly IEnumerable> _bindings; - - public Dui3PanelWebView(IEnumerable> bindings) - { - _bindings = bindings; - InitializeComponent(); - Browser.CoreWebView2InitializationCompleted += Browser_Initialized_Completed; - } - - private void ShowDevToolsMethod() => Browser.CoreWebView2.OpenDevToolsWindow(); - - private void ExecuteScriptAsyncMethod(string script) - { - if (!Browser.IsInitialized) - { - throw new SpeckleException("Failed to execute script, Webview2 is not initialized yet."); - } - Browser.Dispatcher.Invoke(() => Browser.ExecuteScriptAsync(script), DispatcherPriority.Background); - } - - private void Browser_Initialized_Completed(object sender, CoreWebView2InitializationCompletedEventArgs e) - { - foreach (Lazy lazyBinding in _bindings) - { - var binding = lazyBinding.Value; - binding.Parent.AssociateWithBinding(binding, ExecuteScriptAsyncMethod, Browser); - Browser.CoreWebView2.AddHostObjectToScript(binding.Name, binding.Parent); - } - } -} diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Plugin/AutocadCommand.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Plugin/AutocadCommand.cs index eafe7a4b69..3619459acb 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Plugin/AutocadCommand.cs +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Plugin/AutocadCommand.cs @@ -9,6 +9,7 @@ using Speckle.Core.Kits; using Speckle.Converters.Common.DependencyInjection; using Speckle.Connectors.Autocad.Interfaces; +using Speckle.Connectors.DUI.WebView; namespace Speckle.Connectors.Autocad.Plugin; @@ -46,7 +47,7 @@ public void Command() _autocadPlugin = Container.Resolve(); _autocadPlugin.Initialise(); - var panelWebView = Container.Resolve(); + var panelWebView = Container.Resolve(); PaletteSet.AddVisual("Speckle DUI3 WebView", panelWebView); diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Plugin/AutocadPlugin.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Plugin/AutocadPlugin.cs index 16a2a77455..5307a7b531 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Plugin/AutocadPlugin.cs +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Plugin/AutocadPlugin.cs @@ -1,15 +1,16 @@ using Speckle.Connectors.Autocad.HostApp; using Speckle.Connectors.Autocad.Interfaces; +using Speckle.Connectors.DUI.WebView; namespace Speckle.Connectors.Autocad.Plugin; public class AutocadPlugin : IAutocadPlugin { private readonly AutocadIdleManager _idleManager; - private readonly Dui3PanelWebView _panel; + private readonly DUI3ControlWebView _panel; private readonly AutocadSettings _settings; - public AutocadPlugin(Dui3PanelWebView panel, AutocadSettings settings, AutocadIdleManager idleManager) + public AutocadPlugin(DUI3ControlWebView panel, AutocadSettings settings, AutocadIdleManager idleManager) { _panel = panel; _settings = settings; diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Speckle.Connectors.AutocadShared.projitems b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Speckle.Connectors.AutocadShared.projitems index 999cd856bc..7a352d9712 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Speckle.Connectors.AutocadShared.projitems +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Speckle.Connectors.AutocadShared.projitems @@ -8,9 +8,6 @@ Speckle.Connectors.AutocadShared - - - @@ -24,9 +21,6 @@ - - DUI3PanelWebView.xaml - diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/AutofacRhinoModule.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/AutofacRhinoModule.cs index 5b769226e4..4c69cb4501 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/AutofacRhinoModule.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/AutofacRhinoModule.cs @@ -21,6 +21,7 @@ using Speckle.Newtonsoft.Json; using Speckle.Newtonsoft.Json.Serialization; using Speckle.Connectors.DUI.Models.Card.SendFilter; +using Speckle.Connectors.DUI.WebView; using Speckle.Connectors.Rhino7.Operations.Receive; using Speckle.Connectors.Utils.Builders; using Speckle.Connectors.Utils.Operations; @@ -39,7 +40,7 @@ protected override void Load(ContainerBuilder builder) // Register DUI3 related stuff builder.RegisterInstance(GetJsonSerializerSettings()).SingleInstance(); - builder.RegisterType().SingleInstance(); + builder.RegisterType().SingleInstance(); builder.RegisterType().As().InstancePerDependency(); // POC: Each binding should have it's own bridge instance // Register other connector specific types diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/RhinoPlugin.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/RhinoPlugin.cs index 272816a3cc..a295f9f8b6 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/RhinoPlugin.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/RhinoPlugin.cs @@ -1,4 +1,5 @@ using Rhino; +using Speckle.Connectors.DUI.WebView; using Speckle.Connectors.Rhino7.HostApp; using Speckle.Connectors.Rhino7.Interfaces; using Speckle.Connectors.Rhino7.Plugin; @@ -8,10 +9,10 @@ namespace Speckle.Connectors.Rhino7.DependencyInjection; public class RhinoPlugin : IRhinoPlugin { private readonly RhinoIdleManager _idleManager; - private readonly SpeckleRhinoPanel _panel; + private readonly DUI3ControlWebView _panel; private readonly RhinoSettings _settings; - public RhinoPlugin(SpeckleRhinoPanel panel, RhinoSettings settings, RhinoIdleManager idleManager) + public RhinoPlugin(DUI3ControlWebView panel, RhinoSettings settings, RhinoIdleManager idleManager) { _panel = panel; _settings = settings; diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/SpeckleRhinoPanel.xaml.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/SpeckleRhinoPanel.xaml.cs deleted file mode 100644 index 3647e6a22c..0000000000 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/SpeckleRhinoPanel.xaml.cs +++ /dev/null @@ -1,51 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Windows.Controls; -using System.Windows.Threading; -using Microsoft.Web.WebView2.Core; -using Speckle.Connectors.DUI.Bindings; -using Speckle.Core.Logging; - -namespace Speckle.Connectors.Rhino7.HostApp; - -public partial class SpeckleRhinoPanel : UserControl -{ - private readonly IEnumerable> _bindings; - - public SpeckleRhinoPanel(IEnumerable> bindings) - { - _bindings = bindings; - InitializeComponent(); - Browser.CoreWebView2InitializationCompleted += OnInitialized; - } - - public void ShowDevToolsMethod() => Browser.CoreWebView2.OpenDevToolsWindow(); - - public void ExecuteScriptAsyncMethod(string script) - { - if (!Browser.IsInitialized) - { - throw new SpeckleException("Failed to execute script, Webview2 is not initialized yet."); - } - - Browser.Dispatcher.Invoke(() => Browser.ExecuteScriptAsync(script), DispatcherPriority.Background); - } - - private void OnInitialized(object sender, CoreWebView2InitializationCompletedEventArgs e) - { - //TODO: Pass bindings to browser bridge here! - foreach (Lazy lazyBinding in _bindings) - { - try - { - var binding = lazyBinding.Value; - binding.Parent.AssociateWithBinding(binding, ExecuteScriptAsyncMethod, Browser); - Browser.CoreWebView2.AddHostObjectToScript(binding.Name, binding.Parent); - } - catch (Exception exception) when (!exception.IsFatal()) - { - Console.Error.WriteLine(exception); // POC: If something throws here, it get's lost in the ether and DUI fails to initialise completely. - } - } - } -} diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/SpeckleRhinoPanelHost.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/SpeckleRhinoPanelHost.cs index f28af83539..d906161197 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/SpeckleRhinoPanelHost.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/SpeckleRhinoPanelHost.cs @@ -1,4 +1,5 @@ using System.Runtime.InteropServices; +using Speckle.Connectors.DUI.WebView; using Speckle.Connectors.Rhino7.Plugin; namespace Speckle.Connectors.Rhino7.HostApp; @@ -9,7 +10,7 @@ public class SpeckleRhinoPanelHost : RhinoWindows.Controls.WpfElementHost private readonly uint _docSn; public SpeckleRhinoPanelHost(uint docSn) - : base(SpeckleConnectorsRhino7Plugin.Instance.Container?.Resolve(), null) + : base(SpeckleConnectorsRhino7Plugin.Instance.Container?.Resolve(), null) { _docSn = docSn; } diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Speckle.Connectors.Rhino7.csproj b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Speckle.Connectors.Rhino7.csproj index 98cd414b1a..263b217393 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Speckle.Connectors.Rhino7.csproj +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Speckle.Connectors.Rhino7.csproj @@ -22,7 +22,6 @@ - @@ -31,7 +30,7 @@ - + diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/SpeckleRhinoPanel.xaml b/DUI3-DX/DUI3/Speckle.Connectors.DUI.WebView/DUI3ControlWebView.xaml similarity index 86% rename from DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/SpeckleRhinoPanel.xaml rename to DUI3-DX/DUI3/Speckle.Connectors.DUI.WebView/DUI3ControlWebView.xaml index 3647b9e64f..eb2d4acddd 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/SpeckleRhinoPanel.xaml +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI.WebView/DUI3ControlWebView.xaml @@ -1,10 +1,10 @@ - diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/HostApp/SpeckleDUI3.xaml.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI.WebView/DUI3ControlWebView.xaml.cs similarity index 58% rename from DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/HostApp/SpeckleDUI3.xaml.cs rename to DUI3-DX/DUI3/Speckle.Connectors.DUI.WebView/DUI3ControlWebView.xaml.cs index ce12751e83..ac2d17e51f 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/HostApp/SpeckleDUI3.xaml.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI.WebView/DUI3ControlWebView.xaml.cs @@ -1,21 +1,17 @@ +using System; +using System.Collections.Generic; using System.Windows.Controls; using System.Windows.Threading; using Microsoft.Web.WebView2.Core; using Speckle.Connectors.DUI.Bindings; -using Speckle.Core.Logging; -namespace Speckle.Connectors.ArcGIS.HostApp; +namespace Speckle.Connectors.DUI.WebView; -//poc: dupe code - -/// -/// Interaction logic for WebViewBrowserView.xaml -/// -public partial class SpeckleDUI3 : UserControl +public sealed partial class DUI3ControlWebView : UserControl { - private readonly IEnumerable> _bindings; + private readonly IReadOnlyCollection _bindings; - public SpeckleDUI3(IEnumerable> bindings) + public DUI3ControlWebView(IReadOnlyCollection bindings) { _bindings = bindings; InitializeComponent(); @@ -28,7 +24,7 @@ private void ExecuteScriptAsyncMethod(string script) { if (!Browser.IsInitialized) { - throw new SpeckleException("Failed to execute script, Webview2 is not initialized yet."); + throw new InvalidOperationException("Failed to execute script, Webview2 is not initialized yet."); } Browser.Dispatcher.Invoke(() => Browser.ExecuteScriptAsync(script), DispatcherPriority.Background); @@ -36,12 +32,9 @@ private void ExecuteScriptAsyncMethod(string script) private void OnInitialized(object? sender, CoreWebView2InitializationCompletedEventArgs e) { - //TODO: Pass bindings to browser bridge here! - foreach (Lazy lazyBinding in _bindings) + foreach (IBinding binding in _bindings) { - var binding = lazyBinding.Value; binding.Parent.AssociateWithBinding(binding, ExecuteScriptAsyncMethod, Browser); - Console.WriteLine(); Browser.CoreWebView2.AddHostObjectToScript(binding.Name, binding.Parent); } } diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI.WebView/Speckle.Connectors.DUI.WebView.csproj b/DUI3-DX/DUI3/Speckle.Connectors.DUI.WebView/Speckle.Connectors.DUI.WebView.csproj new file mode 100644 index 0000000000..3992947dc0 --- /dev/null +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI.WebView/Speckle.Connectors.DUI.WebView.csproj @@ -0,0 +1,17 @@ + + + + net4.8;net6.0-windows + enable + true + Speckle.Connectors.DUI.WebView + + + + + + + + + + From 51c8a757b60a13ee7c866e9f0291eaec8bdab544 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?O=C4=9Fuzhan=20Koral?= <45078678+oguzhankoral@users.noreply.github.com> Date: Thu, 25 Apr 2024 16:48:10 +0300 Subject: [PATCH 049/261] Fix (autocad): CNX-9346 autocad document states are broken (#3312) Fix first doc registration issue --- .../DependencyInjection/AutofacArcGISModule.cs | 5 +++++ .../Bindings/AutocadSelectionBinding.cs | 8 +++++++- .../HostApp/AutocadDocumentModelStore.cs | 6 ++++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/DependencyInjection/AutofacArcGISModule.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/DependencyInjection/AutofacArcGISModule.cs index 2525b0f56d..b292184dd9 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/DependencyInjection/AutofacArcGISModule.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/DependencyInjection/AutofacArcGISModule.cs @@ -22,6 +22,11 @@ using ArcGIS.Core.Geometry; using Speckle.Connectors.ArcGIS.Filters; +// POC: This is a temp reference to root object senders to tweak CI failing after having generic interfaces into common project. +// This should go whenever it is aligned. +using IRootObjectSender = Speckle.Connectors.ArcGis.Operations.Send.IRootObjectSender; +using RootObjectSender = Speckle.Connectors.ArcGis.Operations.Send.RootObjectSender; + namespace Speckle.Connectors.ArcGIS.DependencyInjection; public class AutofacArcGISModule : Module diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadSelectionBinding.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadSelectionBinding.cs index 667451b20e..5e2188d4cf 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadSelectionBinding.cs +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadSelectionBinding.cs @@ -19,10 +19,16 @@ public AutocadSelectionBinding(IBridge parent) { Parent = parent; + // POC: Use here Context for doc. In converters it's OK but we are still lacking to use context into bindings. + // It is with the case of if binding created with already a document + // This is valid when user opens acad file directly double clicking + TryRegisterDocumentForSelection(Application.DocumentManager.MdiActiveDocument); Application.DocumentManager.DocumentActivated += (sender, e) => OnDocumentChanged(e.Document); } - private void OnDocumentChanged(Document document) + private void OnDocumentChanged(Document document) => TryRegisterDocumentForSelection(document); + + private void TryRegisterDocumentForSelection(Document document) { if (document == null) { diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/AutocadDocumentModelStore.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/AutocadDocumentModelStore.cs index a90bc169cc..b301760e9d 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/AutocadDocumentModelStore.cs +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/AutocadDocumentModelStore.cs @@ -23,6 +23,12 @@ AutocadDocumentManager autocadDocumentManager if (Application.DocumentManager.MdiActiveDocument != null) { IsDocumentInit = true; + // POC: this logic might go when we have document management in context + // It is with the case of if binding created with already a document + // This is valid when user opens acad file directly double clicking + _previousDocName = Application.DocumentManager.MdiActiveDocument.Name; + _saveToDocSubTracker.Add(Application.DocumentManager.MdiActiveDocument.Name); + OnDocumentChanged(); } Application.DocumentManager.DocumentToBeDestroyed += (_, _) => WriteToFile(); From bb7ac42060a2b303dee154e476ed5f632956c13d Mon Sep 17 00:00:00 2001 From: Alan Rynne Date: Fri, 26 Apr 2024 12:24:27 +0200 Subject: [PATCH 050/261] Fix warnings in DLL Conflict checker --- .../EventEmitter/DllConflictEventEmitter.cs | 6 +++--- Directory.Build.props | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ConnectorCore/DllConflictManagement/EventEmitter/DllConflictEventEmitter.cs b/ConnectorCore/DllConflictManagement/EventEmitter/DllConflictEventEmitter.cs index 3c7ffdb69b..7feda8a3b8 100644 --- a/ConnectorCore/DllConflictManagement/EventEmitter/DllConflictEventEmitter.cs +++ b/ConnectorCore/DllConflictManagement/EventEmitter/DllConflictEventEmitter.cs @@ -9,9 +9,9 @@ namespace Speckle.DllConflictManagement.EventEmitter; /// public class DllConflictEventEmitter { - public event EventHandler OnError; - public event EventHandler OnInfo; - public event EventHandler OnAction; + public event EventHandler? OnError; + public event EventHandler? OnInfo; + public event EventHandler? OnAction; private bool _shouldEmitEvents; private readonly List _savedErrorEvents = new(); diff --git a/Directory.Build.props b/Directory.Build.props index 2740e70ee9..186b4c439e 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -38,7 +38,7 @@ CA1303;CA1304;CA1305;CA1307;CA1308;CA1309;CA1310;CA1311;CA2101; NU1701; - CA1815;CA1054;CA1852;CA1812;CA1003;$(NoWarn) + CA1815;CA1054;CA1852;CA1812;CA1003;CA2109;$(NoWarn) From b8d19257caeb98598217b5105811c7aa393f8569 Mon Sep 17 00:00:00 2001 From: KatKatKateryna <89912278+KatKatKateryna@users.noreply.github.com> Date: Sat, 27 Apr 2024 00:47:37 +0800 Subject: [PATCH 051/261] Arcgis document info hotfix (#3316) * DocumentInfo hotfix * CI fix --- .../Bindings/BasicConnectorBinding.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/BasicConnectorBinding.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/BasicConnectorBinding.cs index 77d6a073ad..262afbd18c 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/BasicConnectorBinding.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/BasicConnectorBinding.cs @@ -1,4 +1,5 @@ using System.Reflection; +using ArcGIS.Desktop.Core; using Speckle.Connectors.ArcGIS.HostApp; using Speckle.Connectors.ArcGIS.Utils; using Speckle.Connectors.DUI.Bindings; @@ -42,9 +43,9 @@ public BasicConnectorBinding(ArcGISDocumentStore store, ArcGISSettings settings, public DocumentInfo GetDocumentInfo() => new() { - Location = "", - Name = "", - Id = "" + Location = Project.Current.URI, + Name = Project.Current.Name, + Id = Project.Current.Name, }; public DocumentModelStore GetDocumentState() => _store; From a9d6892ee1de5518cd0814c92d2e127021bbe265 Mon Sep 17 00:00:00 2001 From: KatKatKateryna <89912278+KatKatKateryna@users.noreply.github.com> Date: Mon, 29 Apr 2024 15:55:10 +0800 Subject: [PATCH 052/261] Arcgis send conversions (#3305) * fixed IReadOnlyList; displayValue moved to Mesh; added multipatch * sending Multipatch, no attributes, no materials * no-geom Feature constructor; layer geom type; mark multipatch as Polygon when RingType; proper field values * formatting * basis for Raster send * raster (placeholder for Mesh) * MOVE TO SELECTION FILTER * mesh for raster display - draft * sending proper raster mesh * sync data structure with QGIS * send pointclouds * ptcloud colored via classification * Revert "MOVE TO SELECTION FILTER" This reverts commit 49f8dcd36c1ec3d17a46d9f2c0867ca8b96d2984. * tables handling * reshape polygons * fixes * interfacing utils; getting polygon orientation; fixing table fields * unify getting layer fields * revert ToHost changes * CI fix * add pt values for Pointcloud * intermediate resolution of comments * interface to static; unify field visibility * field types to Int; simpligy GisFeature converter * simplified multipatch converter; remove confusions of displayVals; remove extra Queued task * fixes * simplify raster and pointcloud * remove Using * remove using2 * move out display value assignment * final fixes --- .../Bindings/ArcGISSendBinding.cs | 1 + .../Operations/Send/SendOperation.cs | 1 + .../Features/GeometryToSpeckleBase.cs | 13 +- .../Features/GisFeatureToSpeckleConverter.cs | 98 +++++++-- .../Features/GisRasterToSpeckleConverter.cs | 187 ++++++++++++++++++ .../MultipatchFeatureToSpeckleConverter.cs | 121 +++++++++++- .../PolygonFeatureToSpeckleConverter.cs | 4 +- .../Geometry/EnvelopBoxToSpeckleConverter.cs | 56 ++++++ .../Geometry/GeometryExtension.cs | 157 +++++++++++++++ .../GlobalUsings.cs | 1 + .../PointcloudLayerToSpeckleConverter.cs | 126 ++++++++++++ .../Layers/RasterLayerToSpeckleConverter.cs | 71 +++++++ .../Layers/TableToSpeckleConverter.cs | 78 ++++++++ .../Layers/VectorLayerToSpeckleConverter.cs | 81 ++++++-- Objects/Objects/GIS/GisFeature.cs | 18 +- Objects/Objects/GIS/GisMultipatchGeometry.cs | 18 ++ Objects/Objects/GIS/GisPolygonGeometry.cs | 8 +- Objects/Objects/GIS/GisPolygonGeometry3d.cs | 3 + Objects/Objects/GIS/NonGeometryElement.cs | 2 + Objects/Objects/GIS/RasterElement.cs | 49 ++++- 20 files changed, 1037 insertions(+), 56 deletions(-) create mode 100644 DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GisRasterToSpeckleConverter.cs create mode 100644 DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/EnvelopBoxToSpeckleConverter.cs create mode 100644 DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GeometryExtension.cs create mode 100644 DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/PointcloudLayerToSpeckleConverter.cs create mode 100644 DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/RasterLayerToSpeckleConverter.cs create mode 100644 DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/TableToSpeckleConverter.cs create mode 100644 Objects/Objects/GIS/GisMultipatchGeometry.cs create mode 100644 Objects/Objects/GIS/GisPolygonGeometry3d.cs diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISSendBinding.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISSendBinding.cs index a48f407afc..79d393375a 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISSendBinding.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISSendBinding.cs @@ -48,6 +48,7 @@ CancellationManager cancellationManager public List GetSendFilters() => _sendFilters; + // POC: delete this public List GetSendSettings() { return new List diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Send/SendOperation.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Send/SendOperation.cs index 9daacfd3ba..03bddea6a9 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Send/SendOperation.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Send/SendOperation.cs @@ -32,6 +32,7 @@ public async Task Execute( CancellationToken ct = default ) { + // POC: decide where to push operations to MCT Base commitObject = await QueuedTask .Run(() => _baseBuilder.Build(sendFilter, onOperationProgressed, ct)) .ConfigureAwait(false); diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GeometryToSpeckleBase.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GeometryToSpeckleBase.cs index 83a8dd3020..ab36eef195 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GeometryToSpeckleBase.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GeometryToSpeckleBase.cs @@ -1,31 +1,33 @@ -using Objects.GIS; using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; using Speckle.Core.Models; namespace Speckle.Converters.ArcGIS3.Features; -public class GeometryToSpeckleBaseList : IRawConversion> +public class GeometryToSpeckleBaseList : IRawConversion> { private readonly IRawConversion _pointToSpeckleConverter; private readonly IRawConversion> _multiPointFeatureConverter; private readonly IRawConversion> _polylineFeatureConverter; - private readonly IRawConversion> _polygonFeatureConverter; + private readonly IRawConversion> _polygonFeatureConverter; + private readonly IRawConversion> _multipatchFeatureConverter; public GeometryToSpeckleBaseList( IRawConversion pointToSpeckleConverter, IRawConversion> multiPointFeatureConverter, IRawConversion> polylineFeatureConverter, - IRawConversion> polygonFeatureConverter + IRawConversion> polygonFeatureConverter, + IRawConversion> multipatchFeatureConverter ) { _pointToSpeckleConverter = pointToSpeckleConverter; _multiPointFeatureConverter = multiPointFeatureConverter; _polylineFeatureConverter = polylineFeatureConverter; _polygonFeatureConverter = polygonFeatureConverter; + _multipatchFeatureConverter = multipatchFeatureConverter; } - public IReadOnlyList RawConvert(ArcGIS.Core.Geometry.Geometry target) + public IReadOnlyList RawConvert(ACG.Geometry target) { try { @@ -35,6 +37,7 @@ public IReadOnlyList RawConvert(ArcGIS.Core.Geometry.Geometry target) ACG.Multipoint multipoint => _multiPointFeatureConverter.RawConvert(multipoint), ACG.Polyline polyline => _polylineFeatureConverter.RawConvert(polyline), ACG.Polygon polygon => _polygonFeatureConverter.RawConvert(polygon), + ACG.Multipatch multipatch => _multipatchFeatureConverter.RawConvert(multipatch), // GisMultipatchGeometry or GisPolygonGeometry3d _ => throw new NotSupportedException($"No conversion found for {target.GetType().Name}"), }; } diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GisFeatureToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GisFeatureToSpeckleConverter.cs index aa0c709ebc..faeb610a67 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GisFeatureToSpeckleConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GisFeatureToSpeckleConverter.cs @@ -1,11 +1,12 @@ using Speckle.Converters.Common.Objects; using Speckle.Core.Models; -using Objects.GIS; using ArcGIS.Core.Data; +using Speckle.Converters.ArcGIS3.Geometry; +using Speckle.Converters.Common; namespace Speckle.Converters.ArcGIS3.Features; -public class GisFeatureToSpeckleConverter : IRawConversion +public class GisFeatureToSpeckleConverter : IRawConversion { private readonly IRawConversion> _geometryConverter; @@ -14,29 +15,98 @@ public GisFeatureToSpeckleConverter(IRawConversion RawConvert((Row)target); - - public GisFeature RawConvert(Row target) + private List GenerateFeatureDisplayValueList(List speckleShapes) { - var shape = (ACG.Geometry)target["Shape"]; - var speckleShapes = _geometryConverter.RawConvert(shape).ToList(); + List displayVal = new(); + foreach (var shp in speckleShapes) + { + if (shp is SGIS.GisPolygonGeometry polygon) // also will be valid for Polygon3d, as it inherits from Polygon + { + try + { + SOG.Mesh displayMesh = polygon.CreateDisplayMeshForPolygon(); + displayVal.Add(displayMesh); + } + catch (SpeckleConversionException) + { + break; + } + } + else if (shp is SGIS.GisMultipatchGeometry multipatch) + { + try + { + SOG.Mesh displayMesh = multipatch.CreateDisplayMeshForMultipatch(); + displayVal.Add(displayMesh); + } + catch (SpeckleConversionException) + { + break; + } + } + } + return displayVal; + } + public SGIS.GisFeature RawConvert(Row target) + { // get attributes var attributes = new Base(); + bool hasGeometry = false; IReadOnlyList fields = target.GetFields(); - int i = 0; foreach (Field field in fields) { string name = field.Name; + if (name != "Shape") // ignore the field with geometry itself + { + try + { + object? value = target[name]; + attributes[name] = value; + } + catch (ArgumentException) + { + // TODO: log in the conversion errors list + attributes[name] = null; + } + } + else + { + hasGeometry = true; + } + } + + // return GisFeatures that don't have geometry + if (!hasGeometry) + { + return new SGIS.GisFeature(attributes); + } + else + { + var shape = (ACG.Geometry)target["Shape"]; + var speckleShapes = _geometryConverter.RawConvert(shape).ToList(); - // breaks on Raster Field type - if (name != "Shape" && field.FieldType.ToString() != "Raster") + // if geometry is primitive + if ( + speckleShapes.Count > 0 + && speckleShapes[0] is not SGIS.GisPolygonGeometry + && speckleShapes[0] is not SGIS.GisMultipatchGeometry + ) + { + return new SGIS.GisFeature(speckleShapes, attributes); + } + // if geometry is Polygon or Multipatch, add DisplayValue to the feature + else { - var value = target.GetOriginalValue(i); // can be null - attributes[name] = value; + List displayVal = GenerateFeatureDisplayValueList(speckleShapes); + // add display value ONLY if meshes were generates for all geometry parts + // otherwise those without displayValue will be lost both in Viewer and in fallback Receive conversions + if (speckleShapes.Count == displayVal.Count) + { + return new SGIS.GisFeature(speckleShapes, attributes, displayVal); + } + return new SGIS.GisFeature(speckleShapes, attributes); } - i++; } - return new GisFeature(speckleShapes, attributes); } } diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GisRasterToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GisRasterToSpeckleConverter.cs new file mode 100644 index 0000000000..a223c1713b --- /dev/null +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GisRasterToSpeckleConverter.cs @@ -0,0 +1,187 @@ +using Speckle.Converters.Common.Objects; +using Speckle.Core.Models; +using Objects.GIS; +using ArcGIS.Core.Data.Raster; +using Speckle.Converters.Common; +using ArcGIS.Desktop.Mapping; +using ArcGIS.Core.Geometry; + +namespace Speckle.Converters.ArcGIS3.Features; + +public class GisRasterToSpeckleConverter : IRawConversion +{ + private readonly IRawConversion> _geometryConverter; + private readonly IConversionContextStack _contextStack; + + public GisRasterToSpeckleConverter( + IRawConversion> geometryConverter, + IConversionContextStack contextStack + ) + { + _geometryConverter = geometryConverter; + _contextStack = contextStack; + } + + public Base Convert(object target) => RawConvert((Raster)target); + + private List GetRasterMeshCoords(Raster target, List> pixelValsPerBand) + { + List pixelsList = pixelValsPerBand[^1]; + var extent = target.GetExtent(); + var cellSize = target.GetMeanCellSize(); + + int bandCount = target.GetBandCount(); + float xOrigin = (float)extent.XMin; + float yOrigin = (float)extent.YMax; + int xSize = target.GetWidth(); + int ySize = target.GetHeight(); + float xResolution = (float)cellSize.Item1; + float yResolution = -1 * (float)cellSize.Item2; + + List newCoords = pixelsList + .SelectMany( + (_, ind) => + new List() + { + xOrigin + xResolution * (int)Math.Floor((double)ind / ySize), + yOrigin + yResolution * (ind % ySize), + 0, + xOrigin + xResolution * ((int)Math.Floor((double)ind / ySize) + 1), + yOrigin + yResolution * (ind % ySize), + 0, + xOrigin + xResolution * (int)Math.Floor((double)ind / ySize + 1), + yOrigin + yResolution * (ind % ySize + 1), + 0, + xOrigin + xResolution * (int)Math.Floor((double)ind / ySize), + yOrigin + yResolution * (ind % ySize + 1), + 0 + } + ) + .ToList(); + return newCoords; + } + + private List GetRasterColors(int bandCount, List> pixelValsPerBand) + { + List newColors = new(); + List pixelsList = pixelValsPerBand[^1]; + if (bandCount == 3 || bandCount == 4) // RGB + { + var pixMin0 = pixelValsPerBand[0].Min(); + var pixMax0 = pixelValsPerBand[0].Max(); + var pixMin1 = pixelValsPerBand[1].Min(); + var pixMax1 = pixelValsPerBand[1].Max(); + var pixMin2 = pixelValsPerBand[2].Min(); + var pixMax2 = pixelValsPerBand[2].Max(); + newColors = pixelsList + .Select( + (_, ind) => + (255 << 24) + | (255 * (pixelValsPerBand[0][ind] - pixMin0) / (pixMax0 - pixMin0) << 16) + | (255 * (pixelValsPerBand[1][ind] - pixMin1) / (pixMax1 - pixMin1) << 8) + | 255 * (pixelValsPerBand[2][ind] - pixMin2) / (pixMax2 - pixMin2) + ) + .SelectMany(x => new List() { x, x, x, x }) + .ToList(); + } + else // greyscale + { + var pixMin = pixelValsPerBand[0].Min(); + var pixMax = pixelValsPerBand[0].Max(); + newColors = pixelsList + .Select( + (_, ind) => + (255 << 24) + | (255 * (pixelValsPerBand[0][ind] - pixMin) / (pixMax - pixMin) << 16) + | (255 * (pixelValsPerBand[0][ind] - pixMin) / (pixMax - pixMin) << 8) + | 255 * (pixelValsPerBand[0][ind] - pixMin) / (pixMax - pixMin) + ) + .SelectMany(x => new List() { x, x, x, x }) + .ToList(); + } + return newColors; + } + + public RasterElement RawConvert(Raster target) + { + // assisting variables + var extent = target.GetExtent(); + var cellSize = target.GetMeanCellSize(); + + // variables to assign + int bandCount = target.GetBandCount(); + float xOrigin = (float)extent.XMin; + float yOrigin = (float)extent.YMax; + int xSize = target.GetWidth(); + int ySize = target.GetHeight(); + float xResolution = (float)cellSize.Item1; + float yResolution = -1 * (float)cellSize.Item2; + + var pixelType = target.GetPixelType(); // e.g. UCHAR + var xyOrigin = target.PixelToMap(0, 0); + + RasterElement rasterElement = + new(bandCount, new List(), xOrigin, yOrigin, xSize, ySize, xResolution, yResolution, new List()); + + // prepare to construct a mesh + List newCoords = new(); + List newFaces = new(); + List newColors = new(); + + // store band values for renderer + List> pixelValsPerBand = new(); + + for (int i = 0; i < bandCount; i++) + { + // Get a pixel block for quicker reading and read from pixel top left pixel + PixelBlock block = target.CreatePixelBlock(target.GetWidth(), target.GetHeight()); + target.Read(0, 0, block); + + RasterBandDefinition bandDef = target.GetBand(i).GetDefinition(); + string bandName = bandDef.GetName(); + rasterElement.band_names.Add(bandName); + + // Read 2-dimensional pixel values into 1-dimensional byte array + // TODO: format to list of float + Array pixels2D = block.GetPixelData(i, false); + List pixelsList = pixels2D.Cast().ToList(); + pixelValsPerBand.Add(pixelsList); + + // transpose to match QGIS data structure + var transposedPixelList = Enumerable + .Range(0, ySize) + .SelectMany((_, ind) => Enumerable.Range(0, xSize).Select(x => pixels2D.GetValue(x, ind))) + .ToArray(); + + rasterElement[$"@(10000){bandName}_values"] = transposedPixelList; + + // null or float for noDataValue + float? noDataVal = null; + var noDataValOriginal = bandDef.GetNoDataValue(); + if (noDataValOriginal != null) + { + noDataVal = (float)noDataValOriginal; + } + rasterElement.noDataValue.Add(noDataVal); + + // construct mesh + newFaces = pixelsList + .SelectMany((_, ind) => new List() { 4, 4 * ind, 4 * ind + 1, 4 * ind + 2, 4 * ind + 3 }) + .ToList(); + + newCoords = GetRasterMeshCoords(target, pixelValsPerBand); + + // Construct colors only once, when i=last band index + // ATM, RGB for 3 or 4 bands, greyscale from 1st band for anything else + if (i == bandCount - 1) + { + newColors = GetRasterColors(bandCount, pixelValsPerBand); + } + } + + SOG.Mesh mesh = new(newCoords, newFaces, newColors, null, _contextStack.Current.SpeckleUnits, null) { }; + rasterElement.displayValue = new List() { mesh }; + + return rasterElement; + } +} diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/MultipatchFeatureToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/MultipatchFeatureToSpeckleConverter.cs index 5ee943c092..2322f87ae1 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/MultipatchFeatureToSpeckleConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/MultipatchFeatureToSpeckleConverter.cs @@ -1,17 +1,122 @@ +using Speckle.Converters.Common.Objects; +using Speckle.Converters.Common; +using ArcGIS.Desktop.Mapping; +using Speckle.Core.Models; +using Speckle.Converters.ArcGIS3.Geometry; + namespace Speckle.Converters.ArcGIS3.Features; -/* -[NameAndRankValue(nameof(MapPoint), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class PointToSpeckleConverter : IHostObjectToSpeckleConversion, IRawConversion + +public class MultipatchFeatureToSpeckleConverter : IRawConversion> { - private readonly IConversionContextStack _contextStack; + private readonly IConversionContextStack _contextStack; + private readonly IRawConversion _pointConverter; - public PointToSpeckleConverter(IConversionContextStack contextStack) + public MultipatchFeatureToSpeckleConverter( + IConversionContextStack contextStack, + IRawConversion pointConverter + ) { _contextStack = contextStack; + _pointConverter = pointConverter; } - public Base Convert(object target) => RawConvert((MapPoint)target); + public IReadOnlyList RawConvert(ACG.Multipatch target) + { + List converted = new(); + // placeholder, needs to be declared in order to be used in the Ring patch type + SGIS.GisPolygonGeometry3d polygonGeom = new() { }; + + // convert and store all multipatch points per Part + List> allPoints = new(); + for (int idx = 0; idx < target.PartCount; idx++) + { + List pointList = new(); + int ptStartIndex = target.GetPatchStartPointIndex(idx); + int ptCount = target.GetPatchPointCount(idx); + for (int ptIdx = ptStartIndex; ptIdx < ptStartIndex + ptCount; ptIdx++) + { + pointList.Add(_pointConverter.RawConvert(target.Points[ptIdx])); + } + allPoints.Add(pointList); + } + + for (int idx = 0; idx < target.PartCount; idx++) + { + // get the patch type to get the point arrangement in the mesh + // https://pro.arcgis.com/en/pro-app/latest/sdk/api-reference/topic27403.html + ACG.PatchType patchType = target.GetPatchType(idx); + int ptCount = target.GetPatchPointCount(idx); - public Point RawConvert(MapPoint target) => new(target.X, target.Y, target.Z, _contextStack.Current.SpeckleUnits); + if (patchType == ACG.PatchType.TriangleStrip) + { + SGIS.GisMultipatchGeometry multipatch = target.CompleteMultipatchTriangleStrip(allPoints, idx); + multipatch.units = _contextStack.Current.SpeckleUnits; + converted.Add(multipatch); + } + else if (patchType == ACG.PatchType.Triangles) + { + SGIS.GisMultipatchGeometry multipatch = target.CompleteMultipatchTriangles(allPoints, idx); + multipatch.units = _contextStack.Current.SpeckleUnits; + converted.Add(multipatch); + } + else if (patchType == ACG.PatchType.TriangleFan) + { + SGIS.GisMultipatchGeometry multipatch = target.CompleteMultipatchTriangleFan(allPoints, idx); + multipatch.units = _contextStack.Current.SpeckleUnits; + converted.Add(multipatch); + } + // in case of RingMultipatch - return GisPolygonGeometry3d + // the following Patch Parts cannot be pushed to external method, as they will possibly, add voids/rings to the same GisPolygon + else if (patchType == ACG.PatchType.FirstRing) + { + // chech if there were already Polygons, add them to list + if (polygonGeom.boundary != null) + { + converted.Add(polygonGeom); + } + + // first ring means a start of a new GisPolygonGeometry3d + polygonGeom = new() { voids = new List() }; + List pointCoords = allPoints[idx].SelectMany(x => new List() { x.x, x.y, x.z }).ToList(); + + SOG.Polyline polyline = new(pointCoords, _contextStack.Current.SpeckleUnits) { }; + polygonGeom.boundary = polyline; + + // if it's already the last part, add to list + if (idx == target.PartCount - 1) + { + converted.Add(polygonGeom); + } + } + else if (patchType == ACG.PatchType.Ring) + { + List pointCoords = allPoints[idx].SelectMany(x => new List() { x.x, x.y, x.z }).ToList(); + SOG.Polyline polyline = new(pointCoords, _contextStack.Current.SpeckleUnits) { }; + + // every outer ring is oriented clockwise + bool isClockwise = polyline.IsClockwisePolygon(); + if (!isClockwise) + { + // add void to existing polygon + polygonGeom.voids.Add(polyline); + } + else + { + // add existing polygon to list, start a new polygon with a boundary + converted.Add(polygonGeom); + polygonGeom = new() { voids = new List(), boundary = polyline }; + } + // if it's already the last part, add to list + if (idx == target.PartCount - 1) + { + converted.Add(polygonGeom); + } + } + else + { + throw new NotSupportedException($"Patch type {patchType} is not supported"); + } + } + return converted; + } } -*/ diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/PolygonFeatureToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/PolygonFeatureToSpeckleConverter.cs index 1017b1f480..808aa037cf 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/PolygonFeatureToSpeckleConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/PolygonFeatureToSpeckleConverter.cs @@ -18,7 +18,7 @@ public IReadOnlyList RawConvert(ACG.Polygon target) List polygonList = new(); int partCount = target.PartCount; - GisPolygonGeometry polygon = new() { voids = new List() }; + GisPolygonGeometry polygon = new() { }; // test each part for "exterior ring" for (int idx = 0; idx < partCount; idx++) { @@ -32,7 +32,7 @@ public IReadOnlyList RawConvert(ACG.Polygon target) { polygonList.Add(polygon); } - polygon = new() { voids = new List(), boundary = polyline }; + polygon = new() { boundary = polyline, voids = new List() }; } else { diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/EnvelopBoxToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/EnvelopBoxToSpeckleConverter.cs new file mode 100644 index 0000000000..68d74e968f --- /dev/null +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/EnvelopBoxToSpeckleConverter.cs @@ -0,0 +1,56 @@ +using ArcGIS.Core.Geometry; +using Speckle.Converters.Common.Objects; +using Speckle.Converters.Common; +using ArcGIS.Desktop.Mapping; +using Objects.Primitive; + +namespace Speckle.Converters.ArcGIS3.Geometry; + +public class EnvelopToSpeckleConverter : IRawConversion +{ + private readonly IConversionContextStack _contextStack; + private readonly IRawConversion _pointConverter; + + public EnvelopToSpeckleConverter( + IConversionContextStack contextStack, + IRawConversion pointConverter + ) + { + _contextStack = contextStack; + _pointConverter = pointConverter; + } + + public SOG.Box RawConvert(Envelope target) + { + MapPoint pointMin = new MapPointBuilderEx( + target.XMin, + target.YMin, + target.ZMin, + _contextStack.Current.Document.SpatialReference + ).ToGeometry(); + MapPoint pointMax = new MapPointBuilderEx( + target.XMax, + target.YMax, + target.ZMax, + _contextStack.Current.Document.SpatialReference + ).ToGeometry(); + SOG.Point minPtSpeckle = _pointConverter.RawConvert(pointMin); + SOG.Point maxPtSpeckle = _pointConverter.RawConvert(pointMax); + + var units = _contextStack.Current.SpeckleUnits; + + return new( + new SOG.Plane( + minPtSpeckle, + new SOG.Vector(0, 0, 1, units), + new SOG.Vector(1, 0, 0, units), + new SOG.Vector(0, 1, 0, units), + units + ), + new Interval(minPtSpeckle.x, maxPtSpeckle.x), + new Interval(minPtSpeckle.y, maxPtSpeckle.y), + new Interval(minPtSpeckle.z, maxPtSpeckle.z), + _contextStack.Current.SpeckleUnits + ); + } +} diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GeometryExtension.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GeometryExtension.cs new file mode 100644 index 0000000000..36673fe1ee --- /dev/null +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GeometryExtension.cs @@ -0,0 +1,157 @@ +using ArcGIS.Core.CIM; +using Speckle.Converters.Common; + +namespace Speckle.Converters.ArcGIS3.Geometry; + +public static class GeometryUtils +{ + public static bool ValidateMesh(this SOG.Mesh mesh) + { + if (mesh.vertices.Count < 3) + { + return false; + } + else if (mesh.faces.Count < 4) + { + return false; + } + return true; + } + + public static int RGBToInt(this CIMRGBColor color) + { + return (255 << 24) | ((int)Math.Round(color.R) << 16) | ((int)Math.Round(color.G) << 8) | (int)Math.Round(color.B); + } + + public static int CIMColorToInt(this CIMColor color) + { + return (255 << 24) + | ((int)Math.Round(color.Values[0]) << 16) + | ((int)Math.Round(color.Values[1]) << 8) + | (int)Math.Round(color.Values[2]); + } + + public static bool IsClockwisePolygon(this SOG.Polyline polyline) + { + bool isClockwise; + double sum = 0; + + List points = polyline.GetPoints(); + + if (points.Count < 3) + { + throw new ArgumentException("Not enough points for polygon orientation check"); + } + if (points[0] != points[^1]) + { + points.Add(points[0]); + } + + for (int i = 0; i < points.Count - 1; i++) + { + sum += (points[i + 1].x - points[i].x) * (points[i + 1].y + points[i].y); + } + isClockwise = sum > 0; + return isClockwise; + } + + public static SOG.Mesh CreateDisplayMeshForPolygon(this SGIS.GisPolygonGeometry polygon) + { + if (polygon.voids.Count == 0) + { + // ensure counter-clockwise orientation for up-facing mesh faces + bool isClockwise = polygon.boundary.IsClockwisePolygon(); + List boundaryPts = polygon.boundary.GetPoints(); + if (isClockwise) + { + boundaryPts.Reverse(); + } + + // generate Mesh + int ptCount = boundaryPts.Count; + List faces = new() { ptCount }; + faces.AddRange(Enumerable.Range(0, ptCount).ToList()); + + return new SOG.Mesh(boundaryPts.SelectMany(x => new List { x.x, x.y, x.z }).ToList(), faces); + } + else + { + throw new SpeckleConversionException("Cannot generate display value for polygons with voids"); + } + } + + public static SOG.Mesh CreateDisplayMeshForMultipatch(this SGIS.GisMultipatchGeometry multipatch) + { + return new SOG.Mesh(multipatch.vertices, multipatch.faces); + } + + public static SGIS.GisMultipatchGeometry CompleteMultipatchTriangleStrip( + this ACG.Multipatch target, + List> allPoints, + int idx + ) + { + SGIS.GisMultipatchGeometry multipatch = new(); + List pointCoords = allPoints[idx].SelectMany(x => new List() { x.x, x.y, x.z }).ToList(); + + // get data for this multipatch part + int ptCount = target.GetPatchPointCount(idx); + + for (int ptIdx = 0; ptIdx < ptCount; ptIdx++) + { + if (ptIdx >= 2) // every new point adds a triangle + { + multipatch.faces.AddRange(new List() { 3, ptIdx - 2, ptIdx - 1, ptIdx }); + multipatch.vertices.AddRange(pointCoords.GetRange(3 * (ptIdx - 2), 9).ToList()); + } + } + return multipatch; + } + + public static SGIS.GisMultipatchGeometry CompleteMultipatchTriangles( + this ACG.Multipatch target, + List> allPoints, + int idx + ) + { + SGIS.GisMultipatchGeometry multipatch = new(); + List pointCoords = allPoints[idx].SelectMany(x => new List() { x.x, x.y, x.z }).ToList(); + + // get data for this multipatch part + int ptCount = target.GetPatchPointCount(idx); + for (int ptIdx = 0; ptIdx < ptCount; ptIdx++) + { + var convertedPt = allPoints[idx][ptIdx]; + if (ptIdx >= 2 && (ptIdx + 1) % 3 == 0) // every 3 new points is a new triangle + { + multipatch.faces.AddRange(new List() { 3, ptIdx - 2, ptIdx - 1, ptIdx }); + multipatch.vertices.AddRange(pointCoords.GetRange(3 * (ptIdx - 2), 9).ToList()); + } + } + return multipatch; + } + + public static SGIS.GisMultipatchGeometry CompleteMultipatchTriangleFan( + this ACG.Multipatch target, + List> allPoints, + int idx + ) + { + SGIS.GisMultipatchGeometry multipatch = new(); + List pointCoords = allPoints[idx].SelectMany(x => new List() { x.x, x.y, x.z }).ToList(); + + // get data for this multipatch part + int ptCount = target.GetPatchPointCount(idx); + + for (int ptIdx = 0; ptIdx < ptCount; ptIdx++) + { + var convertedPt = allPoints[idx][ptIdx]; + if (ptIdx >= 2) // every new point adds a triangle (originates from 0) + { + multipatch.faces.AddRange(new List() { 3, 0, ptIdx - 1, ptIdx }); + multipatch.vertices.AddRange(pointCoords.GetRange(2 * (ptIdx - 2), 6).ToList()); + } + } + return multipatch; + } +} diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/GlobalUsings.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/GlobalUsings.cs index 0f5d9556a6..3bdba69b4f 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/GlobalUsings.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/GlobalUsings.cs @@ -1,3 +1,4 @@ global using SOG = Objects.Geometry; +global using SGIS = Objects.GIS; // global using SOP = Objects.Primitive; global using ACG = ArcGIS.Core.Geometry; diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/PointcloudLayerToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/PointcloudLayerToSpeckleConverter.cs new file mode 100644 index 0000000000..6cb1ee7899 --- /dev/null +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/PointcloudLayerToSpeckleConverter.cs @@ -0,0 +1,126 @@ +using Speckle.Converters.Common.Objects; +using Speckle.Core.Models; +using Speckle.Converters.Common; +using ArcGIS.Desktop.Mapping; +using ArcGIS.Core.Data.Analyst3D; +using ArcGIS.Core.CIM; +using Speckle.Converters.ArcGIS3.Geometry; + +namespace Speckle.Converters.ArcGIS3.Layers; + +[NameAndRankValue(nameof(LasDatasetLayer), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +public class PointCloudToSpeckleConverter + : IHostObjectToSpeckleConversion, + IRawConversion +{ + private readonly IRawConversion _pointConverter; + private readonly IRawConversion _boxConverter; + private readonly IConversionContextStack _contextStack; + + public PointCloudToSpeckleConverter( + IRawConversion pointConverter, + IRawConversion boxConverter, + IConversionContextStack contextStack + ) + { + _pointConverter = pointConverter; + _boxConverter = boxConverter; + _contextStack = contextStack; + } + + public Base Convert(object target) + { + return RawConvert((LasDatasetLayer)target); + } + + private int GetPointColor(LasPoint pt, object renderer) + { + // get color + int color = 0; + string classCode = pt.ClassCode.ToString(); + if (renderer is CIMTinUniqueValueRenderer uniqueRenderer) + { + foreach (CIMUniqueValueGroup group in uniqueRenderer.Groups) + { + if (color != 0) + { + break; + } + foreach (CIMUniqueValueClass groupClass in group.Classes) + { + if (color != 0) + { + break; + } + for (int i = 0; i < groupClass.Values.Length; i++) + { + if (classCode == groupClass.Values[i].FieldValues[0]) + { + CIMColor symbolColor = groupClass.Symbol.Symbol.GetColor(); + color = symbolColor.CIMColorToInt(); + break; + } + } + } + } + } + else + { + color = pt.RGBColor.RGBToInt(); + } + return color; + } + + public SGIS.VectorLayer RawConvert(LasDatasetLayer target) + { + SGIS.VectorLayer speckleLayer = new(); + + // get document CRS (for writing geometry coords) + var spatialRef = _contextStack.Current.Document.SpatialReference; + speckleLayer.crs = new SGIS.CRS + { + wkt = spatialRef.Wkt, + name = spatialRef.Name, + units_native = spatialRef.Unit.ToString(), + }; + + // other properties + speckleLayer.name = target.Name; + speckleLayer.units = _contextStack.Current.SpeckleUnits; + speckleLayer.nativeGeomType = target.MapLayerType.ToString(); + speckleLayer.geomType = "Pointcloud"; + + // prepare data for pointcloud + List specklePts = new(); + List values = new(); + List speckleColors = new(); + var renderer = target.GetRenderers()[0]; + + using (LasPointCursor ptCursor = target.SearchPoints(new LasPointFilter())) + { + while (ptCursor.MoveNext()) + { + using (LasPoint pt = ptCursor.Current) + { + specklePts.Add(_pointConverter.RawConvert(pt.ToMapPoint())); + values.Add(pt.ClassCode); + int color = GetPointColor(pt, renderer); + speckleColors.Add(color); + } + } + } + + SOG.Pointcloud cloud = + new() + { + points = specklePts.SelectMany(pt => new List() { pt.x, pt.y, pt.z }).ToList(), + colors = speckleColors, + sizes = values, + bbox = _boxConverter.RawConvert(target.QueryExtent()), + units = _contextStack.Current.SpeckleUnits + }; + + speckleLayer.elements.Add(cloud); + return speckleLayer; + } +} diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/RasterLayerToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/RasterLayerToSpeckleConverter.cs new file mode 100644 index 0000000000..76302858a1 --- /dev/null +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/RasterLayerToSpeckleConverter.cs @@ -0,0 +1,71 @@ +using Speckle.Converters.Common.Objects; +using Speckle.Core.Models; +using Objects.GIS; +using Speckle.Converters.Common; +using ArcGIS.Desktop.Mapping; +using ArcGIS.Core.Geometry; +using RasterLayer = ArcGIS.Desktop.Mapping.RasterLayer; +using ArcGIS.Core.Data.Raster; + +namespace Speckle.Converters.ArcGIS3.Layers; + +[NameAndRankValue(nameof(RasterLayer), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +public class RasterLayerToSpeckleConverter + : IHostObjectToSpeckleConversion, + IRawConversion +{ + private readonly IRawConversion _gisRasterConverter; + private readonly IConversionContextStack _contextStack; + + public RasterLayerToSpeckleConverter( + IRawConversion gisRasterConverter, + IConversionContextStack contextStack + ) + { + _gisRasterConverter = gisRasterConverter; + _contextStack = contextStack; + } + + public Base Convert(object target) + { + return RawConvert((RasterLayer)target); + } + + public SGIS.RasterLayer RawConvert(RasterLayer target) + { + var speckleLayer = new SGIS.RasterLayer(); + + // get document CRS (for writing geometry coords) + var spatialRef = _contextStack.Current.Document.SpatialReference; + speckleLayer.crs = new CRS + { + wkt = spatialRef.Wkt, + name = spatialRef.Name, + units_native = spatialRef.Unit.ToString(), + }; + + // layer native crs (for writing properties e.g. resolution, origin etc.) + var spatialRefRaster = target.GetSpatialReference(); + // get active map CRS if layer CRS is empty + if (spatialRefRaster.Unit is null) + { + spatialRefRaster = _contextStack.Current.Document.SpatialReference; + } + speckleLayer.rasterCrs = new CRS + { + wkt = spatialRefRaster.Wkt, + name = spatialRefRaster.Name, + units_native = spatialRefRaster.Unit.ToString(), + }; + + // other properties + speckleLayer.name = target.Name; + speckleLayer.units = _contextStack.Current.SpeckleUnits; + + // write details about the Raster + RasterElement element = _gisRasterConverter.RawConvert(target.GetRaster()); + speckleLayer.elements.Add(element); + + return speckleLayer; + } +} diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/TableToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/TableToSpeckleConverter.cs new file mode 100644 index 0000000000..8f88a2df31 --- /dev/null +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/TableToSpeckleConverter.cs @@ -0,0 +1,78 @@ +using Speckle.Converters.Common.Objects; +using Speckle.Core.Models; +using Objects.GIS; +using Speckle.Converters.Common; +using ArcGIS.Desktop.Mapping; +using ArcGIS.Core.Data; +using ArcGIS.Core.Geometry; + +namespace Speckle.Converters.ArcGIS3.Layers; + +[NameAndRankValue(nameof(StandaloneTable), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +public class StandaloneTableToSpeckleConverter + : IHostObjectToSpeckleConversion, + IRawConversion +{ + private readonly IRawConversion _gisFeatureConverter; + private readonly IConversionContextStack _contextStack; + + public StandaloneTableToSpeckleConverter( + IRawConversion gisFeatureConverter, + IConversionContextStack contextStack + ) + { + _gisFeatureConverter = gisFeatureConverter; + _contextStack = contextStack; + } + + public Base Convert(object target) + { + return RawConvert((StandaloneTable)target); + } + + public VectorLayer RawConvert(StandaloneTable target) + { + VectorLayer speckleLayer = new() { name = target.Name, }; + + // get feature class fields + var attributes = new Base(); + var dispayTable = target as IDisplayTable; + var fieldDescriptions = dispayTable.GetFieldDescriptions(); + foreach (var field in fieldDescriptions) + { + if (field.IsVisible) + { + string name = field.Name; + attributes[name] = (int)field.Type; + } + } + + speckleLayer.attributes = attributes; + string spekleGeometryType = "None"; + + using (RowCursor rowCursor = dispayTable.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 (Row row = rowCursor.Current) + { + GisFeature element = _gisFeatureConverter.RawConvert(row); + + // replace "attributes", to remove non-visible layer attributes + Base elementAttributes = new(); + foreach (FieldDescription field in fieldDescriptions) + { + elementAttributes[field.Name] = element.attributes[field.Name]; + } + element.attributes = elementAttributes; + + speckleLayer.elements.Add(element); + } + } + } + + speckleLayer.geomType = spekleGeometryType; + return speckleLayer; + } +} diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/VectorLayerToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/VectorLayerToSpeckleConverter.cs index 957d568c51..716c0dd04f 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/VectorLayerToSpeckleConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/VectorLayerToSpeckleConverter.cs @@ -4,6 +4,7 @@ using Speckle.Converters.Common; using ArcGIS.Desktop.Mapping; using ArcGIS.Core.Data; +using ArcGIS.Core.Geometry; namespace Speckle.Converters.ArcGIS3.Layers; @@ -11,10 +12,15 @@ namespace Speckle.Converters.ArcGIS3.Layers; public class VectorLayerToSpeckleConverter : IHostObjectToSpeckleConversion, IRawConversion { private readonly IRawConversion _gisFeatureConverter; + private readonly IConversionContextStack _contextStack; - public VectorLayerToSpeckleConverter(IRawConversion gisFeatureConverter) + public VectorLayerToSpeckleConverter( + IRawConversion gisFeatureConverter, + IConversionContextStack contextStack + ) { _gisFeatureConverter = gisFeatureConverter; + _contextStack = contextStack; } public Base Convert(object target) @@ -22,35 +28,69 @@ public Base Convert(object target) return RawConvert((FeatureLayer)target); } + private string SpeckleGeometryType(string nativeGeometryType) + { + string spekleGeometryType = "None"; + if (nativeGeometryType.ToLower().Contains("point")) + { + spekleGeometryType = "Point"; + } + else if (nativeGeometryType.ToLower().Contains("polyline")) + { + spekleGeometryType = "Polyline"; + } + else if (nativeGeometryType.ToLower().Contains("polygon")) + { + spekleGeometryType = "Polygon"; + } + else if (nativeGeometryType.ToLower().Contains("multipatch")) + { + spekleGeometryType = "Multipatch"; + } + return spekleGeometryType; + } + public VectorLayer RawConvert(FeatureLayer target) { - var speckleLayer = new VectorLayer(); - var spatialRef = target.GetSpatialReference(); + VectorLayer speckleLayer = new(); + + // get document CRS (for writing geometry coords) + var spatialRef = _contextStack.Current.Document.SpatialReference; speckleLayer.crs = new CRS { wkt = spatialRef.Wkt, name = spatialRef.Name, units_native = spatialRef.Unit.ToString(), }; + + // other properties speckleLayer.name = target.Name; + speckleLayer.units = _contextStack.Current.SpeckleUnits; // get feature class fields - var attributes = new Base(); - IReadOnlyList fields = target.GetTable().GetDefinition().GetFields(); - foreach (Field field in fields) + var allLayerAttributes = new Base(); + var dispayTable = target as IDisplayTable; + IReadOnlyList fieldDescriptions = dispayTable.GetFieldDescriptions(); + foreach (FieldDescription field in fieldDescriptions) { - string name = field.Name; - // breaks on Raster Field type when assigning indiv. GisFeature values - if (name != "Shape" && field.FieldType.ToString() != "Raster") + if (field.IsVisible) { - attributes[name] = field.FieldType; + string name = field.Name; + if (name == "Shape") + { + continue; + } + allLayerAttributes[name] = (int)field.Type; } } - speckleLayer.attributes = attributes; + speckleLayer.attributes = allLayerAttributes; speckleLayer.nativeGeomType = target.ShapeType.ToString(); - // search the rows + // get a simple geometry type + string spekleGeometryType = SpeckleGeometryType(speckleLayer.nativeGeomType); + speckleLayer.geomType = spekleGeometryType; + // search the rows // 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 @@ -61,12 +101,23 @@ public VectorLayer RawConvert(FeatureLayer target) // Same IDisposable issue appears to happen on Row class too. Docs say it should always be disposed of manually by the caller. using (Row row = rowCursor.Current) { - var element = _gisFeatureConverter.RawConvert(row); + GisFeature element = _gisFeatureConverter.RawConvert(row); + + // replace element "attributes", to remove those non-visible on Layer level + Base elementAttributes = new(); + foreach (FieldDescription field in fieldDescriptions) + { + if (field.IsVisible) + { + elementAttributes[field.Name] = element.attributes[field.Name]; + } + } + element.attributes = elementAttributes; speckleLayer.elements.Add(element); } } - - return speckleLayer; } + + return speckleLayer; } } diff --git a/Objects/Objects/GIS/GisFeature.cs b/Objects/Objects/GIS/GisFeature.cs index 2dc79c6eb8..1a5f4dc5ac 100644 --- a/Objects/Objects/GIS/GisFeature.cs +++ b/Objects/Objects/GIS/GisFeature.cs @@ -5,7 +5,15 @@ namespace Objects.GIS; public class GisFeature : Base { - public GisFeature() { } + public GisFeature() + { + attributes = new Base(); + } + + public GisFeature(Base attributes) + { + this.attributes = attributes; + } public GisFeature(List geometry, Base attributes) { @@ -13,6 +21,12 @@ public GisFeature(List geometry, Base attributes) this.attributes = attributes; } + public GisFeature(Base attributes, List displayValue) + { + this.attributes = attributes; + this.displayValue = displayValue; + } + public GisFeature(List geometry, Base attributes, List displayValue) { this.geometry = geometry; @@ -25,5 +39,5 @@ public GisFeature(List geometry, Base attributes, List displayValue) [DetachProperty] public List? displayValue { get; set; } - public Base? attributes { get; set; } + public Base attributes { get; set; } } diff --git a/Objects/Objects/GIS/GisMultipatchGeometry.cs b/Objects/Objects/GIS/GisMultipatchGeometry.cs new file mode 100644 index 0000000000..3833785e9d --- /dev/null +++ b/Objects/Objects/GIS/GisMultipatchGeometry.cs @@ -0,0 +1,18 @@ +using System.Collections.Generic; +using Speckle.Core.Models; + +namespace Objects.GIS; + +public class GisMultipatchGeometry : Base +{ + public string units { get; set; } + public List faces { get; set; } + public List vertices { get; set; } + public List? colors { get; set; } + + public GisMultipatchGeometry() + { + faces = new List(); + vertices = new List(); + } +} diff --git a/Objects/Objects/GIS/GisPolygonGeometry.cs b/Objects/Objects/GIS/GisPolygonGeometry.cs index 6c48f2165b..fc4d7d50c0 100644 --- a/Objects/Objects/GIS/GisPolygonGeometry.cs +++ b/Objects/Objects/GIS/GisPolygonGeometry.cs @@ -6,6 +6,12 @@ namespace Objects.GIS; public class GisPolygonGeometry : Base { + public string units { get; set; } public Polyline boundary { get; set; } - public List? voids { get; set; } + public List voids { get; set; } + + public GisPolygonGeometry() + { + voids = new List(); + } } diff --git a/Objects/Objects/GIS/GisPolygonGeometry3d.cs b/Objects/Objects/GIS/GisPolygonGeometry3d.cs new file mode 100644 index 0000000000..9e525323a7 --- /dev/null +++ b/Objects/Objects/GIS/GisPolygonGeometry3d.cs @@ -0,0 +1,3 @@ +namespace Objects.GIS; + +public class GisPolygonGeometry3d : GisPolygonGeometry { } diff --git a/Objects/Objects/GIS/NonGeometryElement.cs b/Objects/Objects/GIS/NonGeometryElement.cs index edb67af566..c5e0dc5714 100644 --- a/Objects/Objects/GIS/NonGeometryElement.cs +++ b/Objects/Objects/GIS/NonGeometryElement.cs @@ -1,7 +1,9 @@ +using System; using Speckle.Core.Models; namespace Objects.GIS; +[Obsolete("NonGeometryElement was replaced by a more generic class, \"GisFeature\", which contains more information")] public class NonGeometryElement : Base { public Base? attributes { get; set; } diff --git a/Objects/Objects/GIS/RasterElement.cs b/Objects/Objects/GIS/RasterElement.cs index a47eba0928..63befed1ac 100644 --- a/Objects/Objects/GIS/RasterElement.cs +++ b/Objects/Objects/GIS/RasterElement.cs @@ -6,16 +6,47 @@ namespace Objects.GIS; public class RasterElement : Base { - public int? band_count { get; set; } - public List? band_names { get; set; } - public float? x_origin { get; set; } - public float? y_origin { get; set; } - public int? x_size { get; set; } - public int? y_size { get; set; } - public float? x_resolution { get; set; } - public float? y_resolution { get; set; } - public List? noDataValue { get; set; } + public int band_count { get; set; } + public List band_names { get; set; } + public float x_origin { get; set; } + public float y_origin { get; set; } + public int x_size { get; set; } + public int y_size { get; set; } + public float x_resolution { get; set; } + public float y_resolution { get; set; } + public List noDataValue { get; set; } [DetachProperty] public List displayValue { get; set; } + + public RasterElement() + { + displayValue = new List(); + band_names = new List(); + noDataValue = new List(); + } + + public RasterElement( + int bandCount, + List bandNames, + float xOrigin, + float yOrigin, + int xSize, + int ySize, + float xResolution, + float yResolution, + List noDataValue + ) + { + displayValue = new List(); + band_count = bandCount; + band_names = bandNames; + x_origin = xOrigin; + y_origin = yOrigin; + x_size = xSize; + y_size = ySize; + x_resolution = xResolution; + y_resolution = yResolution; + this.noDataValue = noDataValue; + } } From f20ba9acf6f5f66ec3cb0c8d6838fe6e2f0b0a42 Mon Sep 17 00:00:00 2001 From: connorivy <43247197+connorivy@users.noreply.github.com> Date: Mon, 29 Apr 2024 03:02:58 -0500 Subject: [PATCH 053/261] CNX-9226 revit column to Speckle (#3308) * column conversion * fix column ci --------- Co-authored-by: Connor Ivy Co-authored-by: Alan Rynne --- .../Operations/Send/RootObjectBuilder.cs | 9 +- .../Raw/ColumnConversionToSpeckle.cs | 114 +++++++++--------- .../RevitConverterToSpeckle.cs | 2 +- .../FamilyInstanceConversionToSpeckle.cs | 16 ++- .../ToSpeckle/FloorConversionToSpeckle.cs | 2 +- 5 files changed, 74 insertions(+), 69 deletions(-) diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RootObjectBuilder.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RootObjectBuilder.cs index 0045b7a7e4..59b6a2f2da 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RootObjectBuilder.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RootObjectBuilder.cs @@ -47,7 +47,14 @@ public Base Build( continue; } - commitObject[obj.UniqueId] = _converter.Convert(obj); + try + { + commitObject[obj.UniqueId] = _converter.Convert(obj); + } + catch (SpeckleConversionException ex) + { + // POC: logging + } } return commitObject; diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ColumnConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ColumnConversionToSpeckle.cs index 26a0c48f55..01e75da8c5 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ColumnConversionToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ColumnConversionToSpeckle.cs @@ -1,4 +1,6 @@ +using Autodesk.Revit.DB; using Objects; +using Objects.BuiltElements.Revit; using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; using Speckle.Converters.RevitShared.Helpers; @@ -8,22 +10,18 @@ namespace Speckle.Converters.RevitShared.ToSpeckle; // POC: There is no validation on this converter to prevent conversion from "not a Revit Beam" to a Speckle Beam. // This will definitely explode if we tried. Goes back to the `CanConvert` functionality conversation. -public class ColumnConversionToSpeckle : IRawConversion +public class ColumnConversionToSpeckle : IRawConversion { - private readonly IRawConversion _locationConverter; - private readonly IRawConversion _levelConverter; + private readonly IRawConversion _locationConverter; + private readonly IRawConversion _levelConverter; private readonly ParameterValueExtractor _parameterValueExtractor; private readonly DisplayValueExtractor _displayValueExtractor; private readonly RevitConversionContextStack _contextStack; private readonly ParameterObjectAssigner _parameterObjectAssigner; - // POC: could be broken down more granular, maybe injected, maybe even if methods - // GetParameters() - // GetGeometry() - // etc... public ColumnConversionToSpeckle( - IRawConversion locationConverter, - IRawConversion levelConverter, + IRawConversion locationConverter, + IRawConversion levelConverter, ParameterValueExtractor parameterValueExtractor, DisplayValueExtractor displayValueExtractor, RevitConversionContextStack contextStack, @@ -38,82 +36,78 @@ ParameterObjectAssigner parameterObjectAssigner _parameterObjectAssigner = parameterObjectAssigner; } - public SOBR.RevitColumn RawConvert(DB.FamilyInstance target) + public RevitColumn RawConvert(DB.FamilyInstance target) { - var symbol = (DB.FamilySymbol)target.Document.GetElement(target.GetTypeId()); + FamilySymbol symbol = (FamilySymbol)target.Document.GetElement(target.GetTypeId()); - var speckleColumn = new SOBR.RevitColumn - { - family = symbol.FamilyName, - type = target.Document.GetElement(target.GetTypeId()).Name - }; + RevitColumn speckleColumn = + new() { family = symbol.FamilyName, type = target.Document.GetElement(target.GetTypeId()).Name }; - var level = _parameterValueExtractor.GetValueAsDocumentObject( + Level level = _parameterValueExtractor.GetValueAsDocumentObject( target, - DB.BuiltInParameter.FAMILY_BASE_LEVEL_PARAM + BuiltInParameter.FAMILY_BASE_LEVEL_PARAM ); speckleColumn.level = _levelConverter.RawConvert(level); - var topLevel = _parameterValueExtractor.GetValueAsDocumentObject( + Level topLevel = _parameterValueExtractor.GetValueAsDocumentObject( target, - DB.BuiltInParameter.FAMILY_TOP_LEVEL_PARAM + BuiltInParameter.FAMILY_TOP_LEVEL_PARAM ); + + // POC : what to do instead of falling back to default value speckleColumn.topLevel = _levelConverter.RawConvert(topLevel); speckleColumn.baseOffset = - _parameterValueExtractor.GetValueAsDouble(target, DB.BuiltInParameter.FAMILY_BASE_LEVEL_OFFSET_PARAM) ?? 0; + _parameterValueExtractor.GetValueAsDouble(target, BuiltInParameter.FAMILY_BASE_LEVEL_OFFSET_PARAM) ?? 0; speckleColumn.topOffset = - _parameterValueExtractor.GetValueAsDouble(target, DB.BuiltInParameter.FAMILY_TOP_LEVEL_OFFSET_PARAM) ?? 0; + _parameterValueExtractor.GetValueAsDouble(target, BuiltInParameter.FAMILY_TOP_LEVEL_OFFSET_PARAM) ?? 0; speckleColumn.facingFlipped = target.FacingFlipped; speckleColumn.handFlipped = target.HandFlipped; speckleColumn.isSlanted = target.IsSlantedColumn; - //speckleColumn.structural = revitColumn.StructuralType == StructuralType.Column; - - //geometry - var baseGeometry = _locationConverter.RawConvert(target.Location); - var baseLine = baseGeometry as ICurve; - //make line from point and height - if (baseLine == null && baseGeometry is SOG.Point basePoint) + if (target.Location is LocationPoint locationPoint) { - if ( - symbol.Family.FamilyPlacementType == DB.FamilyPlacementType.OneLevelBased - || symbol.Family.FamilyPlacementType == DB.FamilyPlacementType.WorkPlaneBased - ) - { - //return RevitInstanceToSpeckle(revitColumn, out notes, null); - throw new SpeckleConversionException(); - } - - var elevation = speckleColumn.topLevel.elevation; - baseLine = new SOG.Line( - basePoint, - new SOG.Point( - basePoint.x, - basePoint.y, - elevation + speckleColumn.topOffset, - _contextStack.Current.SpeckleUnits - ), - _contextStack.Current.SpeckleUnits - ); + speckleColumn.rotation = locationPoint.Rotation; } - if (baseLine == null) - { - // return RevitElementToSpeckle(revitColumn, out notes); - throw new SpeckleConversionException(); - } + speckleColumn.baseLine = + GetBaseCurve(target, speckleColumn.topLevel.elevation, speckleColumn.topOffset) + ?? throw new SpeckleConversionException("Unable to find a valid baseCurve for column"); - speckleColumn.baseLine = baseLine; //all speckle columns should be line based + speckleColumn.displayValue = _displayValueExtractor.GetDisplayValue(target); _parameterObjectAssigner.AssignParametersToBase(target, speckleColumn); - if (target.Location is DB.LocationPoint locationPoint) + return speckleColumn; + } + + private ICurve? GetBaseCurve(DB.FamilyInstance target, double topLevelElevation, double topLevelOffset) + { + Base baseGeometry = _locationConverter.RawConvert(target.Location); + ICurve? baseCurve = baseGeometry as ICurve; + + if (baseGeometry is ICurve) { - speckleColumn.rotation = locationPoint.Rotation; + return baseCurve; + } + else if (baseGeometry is SOG.Point basePoint) + { + // POC: in existing connector, we are sending column as Revit Instance instead of Column with the following if. + // I am not sure why. I think this if is checking if the column has a fixed height + //if ( + // symbol.Family.FamilyPlacementType == FamilyPlacementType.OneLevelBased + // || symbol.Family.FamilyPlacementType == FamilyPlacementType.WorkPlaneBased + //) + //{ + // return RevitInstanceToSpeckle(revitColumn, out notes, null); + //} + + return new SOG.Line( + basePoint, + new SOG.Point(basePoint.x, basePoint.y, topLevelElevation + topLevelOffset, _contextStack.Current.SpeckleUnits), + _contextStack.Current.SpeckleUnits + ); } - speckleColumn.displayValue = _displayValueExtractor.GetDisplayValue(target); - - return speckleColumn; + return null; } } diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/RevitConverterToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/RevitConverterToSpeckle.cs index 413a3ac2a3..735fd5e4e8 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/RevitConverterToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/RevitConverterToSpeckle.cs @@ -33,7 +33,7 @@ public Base Convert(object target) if (objectConverter == null) { - throw new NotSupportedException($"No conversion found for {target.GetType().Name}"); + throw new SpeckleConversionException($"No conversion found for {target.GetType().Name}"); } Base result = diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/FamilyInstanceConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/FamilyInstanceConversionToSpeckle.cs index ccc54723b8..e8a64885ea 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/FamilyInstanceConversionToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/FamilyInstanceConversionToSpeckle.cs @@ -1,6 +1,5 @@ using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; -using Speckle.Converters.RevitShared.Extensions; using Speckle.Core.Models; namespace Speckle.Converters.RevitShared.ToSpeckle; @@ -12,26 +11,31 @@ public sealed class FamilyInstanceConversionToSpeckle : BaseConversionToSpeckle< { private readonly IRawConversion _elementConverter; private readonly IRawConversion _beamConversion; + private readonly IRawConversion _columnConversion; public FamilyInstanceConversionToSpeckle( IRawConversion elementConverter, - IRawConversion beamConversion + IRawConversion beamConversion, + IRawConversion columnConversion ) { _elementConverter = elementConverter; _beamConversion = beamConversion; + _columnConversion = columnConversion; } public override Base RawConvert(DB.FamilyInstance target) { - if ( - target.Category.GetBuiltInCategory() == DB.BuiltInCategory.OST_StructuralFraming - && target.StructuralType == DB.Structure.StructuralType.Beam - ) + if (target.StructuralType == DB.Structure.StructuralType.Beam) { return _beamConversion.RawConvert(target); } + if (target.StructuralType == DB.Structure.StructuralType.Column) + { + return _columnConversion.RawConvert(target); + } + // POC: return generic element conversion or throw? // //throw new SpeckleConversionException( diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/FloorConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/FloorConversionToSpeckle.cs index 93699c65e8..9b2ebefe92 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/FloorConversionToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/FloorConversionToSpeckle.cs @@ -11,5 +11,5 @@ namespace Speckle.Converters.Common; [NameAndRankValue(nameof(DB.Floor), 0)] public class FloorConversionToSpeckle : IHostObjectToSpeckleConversion { - public Base Convert(object target) => throw new NotImplementedException(); + public Base Convert(object target) => throw new SpeckleConversionException(); } From 018a77d7344d897f49cfb866929c701f14e19fa2 Mon Sep 17 00:00:00 2001 From: Alan Rynne Date: Mon, 29 Apr 2024 10:05:12 +0200 Subject: [PATCH 054/261] CNX-9221 DUI3-DX DirectShape conversion to Speckle (#3304) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat(rvt): Adds DirectShape conversion to Speckle * Renamed existing mesh conversion to MultiMeshConversionToSpeckle * fix: Align class with file rename * I went down a rabbit hole and ended up killing some stuff * Back to `MeshConversionToSpeckle` * fix: Unnecessary using PITA 🙂 * fix: Rollback to previous displayValue extractor behaviour, but with new converter * fix: Unify DirectShape conversion to use displayValue extractor This only holds because we don't support Solids as of now. * fix: unnecessary using 🚀 --- .../AutofacRevitConverterModule.cs | 1 - .../Extensions/CategoryExtensions.cs | 31 +++++ .../Helpers/DisplayValueExtractor.cs | 118 ++++++++---------- .../Helpers/MeshBuildHelper.cs | 92 -------------- .../Helpers/MeshDataTriangulator.cs | 43 ------- .../Helpers/ParameterObjectAssigner.cs | 6 +- .../MeshByMaterialDictionaryToSpeckle.cs | 114 +++++++++++++++++ .../Raw/Geometry/MeshConversionToSpeckle.cs | 77 ++++++++++-- .../Raw/Geometry/SolidConversionToSpeckle.cs | 55 ++++++++ .../Raw/Geometry/SolidsConversionToSpeckle.cs | 81 ------------ .../Raw/MaterialConversionToSpeckle.cs | 20 +++ .../Speckle.Converters.RevitShared.projitems | 7 +- .../DirectShapeConversionToSpeckle.cs | 48 +++++++ 13 files changed, 394 insertions(+), 299 deletions(-) delete mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/MeshBuildHelper.cs delete mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/MeshDataTriangulator.cs create mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/MeshByMaterialDictionaryToSpeckle.cs create mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/SolidConversionToSpeckle.cs delete mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/SolidsConversionToSpeckle.cs create mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/MaterialConversionToSpeckle.cs create mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/DirectShapeConversionToSpeckle.cs diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/AutofacRevitConverterModule.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/AutofacRevitConverterModule.cs index dabdadf2df..96468d1eba 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/AutofacRevitConverterModule.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/AutofacRevitConverterModule.cs @@ -35,7 +35,6 @@ protected override void Load(ContainerBuilder builder) .InstancePerLifetimeScope(); builder.RegisterType().AsSelf().InstancePerLifetimeScope(); builder.RegisterType().AsSelf().InstancePerLifetimeScope(); - builder.RegisterType().AsSelf().InstancePerLifetimeScope(); builder.RegisterType().AsSelf().InstancePerLifetimeScope(); builder.RegisterType().AsSelf().InstancePerLifetimeScope(); } diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Extensions/CategoryExtensions.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Extensions/CategoryExtensions.cs index 1ecc9754e6..9083375a2e 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Extensions/CategoryExtensions.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Extensions/CategoryExtensions.cs @@ -4,8 +4,39 @@ namespace Speckle.Converters.RevitShared.Extensions; public static class CategoryExtensions { + public static SOBR.RevitCategory GetSchemaBuilderCategoryFromBuiltIn(this DB.BuiltInCategory builtInCategory) + { + // Clean up built-in name "OST_Walls" to be just "WALLS" + var cleanName = builtInCategory + .ToString() + .Replace("OST_IOS", "") //for OST_IOSModelGroups + .Replace("OST_MEP", "") //for OST_MEPSpaces + .Replace("OST_", "") //for any other OST_blablabla + .Replace("_", " "); + + var res = Enum.TryParse(cleanName, out SOBR.RevitCategory cat); + if (!res) + { + throw new NotSupportedException($"Built-in category {builtInCategory} is not supported."); + } + + return cat; + } + public static BuiltInCategory GetBuiltInCategory(this Category category) { return (BuiltInCategory)category.Id.IntegerValue; } + + public static string GetBuiltInFromSchemaBuilderCategory(this SOBR.RevitCategory c) + { + var name = Enum.GetName(typeof(SOBR.RevitCategory), c); + return $"OST_{name}"; + } + + public static string GetBuiltInFromSchemaBuilderCategory(this SOBR.RevitFamilyCategory c) + { + var name = Enum.GetName(typeof(SOBR.RevitFamilyCategory), c); + return $"OST_{name}"; + } } diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/DisplayValueExtractor.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/DisplayValueExtractor.cs index 2350dbeef7..be2e60bb52 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/DisplayValueExtractor.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/DisplayValueExtractor.cs @@ -1,41 +1,35 @@ -using Autodesk.Revit.DB; using Speckle.Converters.Common.Objects; using Speckle.Core.Logging; -using Mesh = Objects.Geometry.Mesh; namespace Speckle.Converters.RevitShared.Helpers; // POC: class is kind of big and could do with breaking down public sealed class DisplayValueExtractor { - private readonly IRawConversion, List> _solidsConversion; - private readonly IRawConversion, List> _meshConversion; + private readonly IRawConversion>, List> _meshByMaterialConverter; public DisplayValueExtractor( - IRawConversion, List> solidsConversion, - IRawConversion, List> meshConversion + IRawConversion>, List> meshByMaterialConverter ) { - _solidsConversion = solidsConversion; - _meshConversion = meshConversion; + _meshByMaterialConverter = meshByMaterialConverter; } - public List GetDisplayValue( + public List GetDisplayValue( DB.Element element, DB.Options? options = null, - bool isConvertedAsInstance = false, // POC: should this be part of the context? DB.Transform? transform = null ) { - var displayMeshes = new List(); + var displayMeshes = new List(); // test if the element is a group first - if (element is Group g) + if (element is DB.Group g) { foreach (var id in g.GetMemberIds()) { - var groupMeshes = GetElementDisplayValue(element.Document.GetElement(id), options, isConvertedAsInstance); + var groupMeshes = GetDisplayValue(element.Document.GetElement(id), options); displayMeshes.AddRange(groupMeshes); } return displayMeshes; @@ -43,61 +37,55 @@ public List GetDisplayValue( var (solids, meshes) = GetSolidsAndMeshesFromElement(element, options, transform); - // convert meshes and solids - displayMeshes.AddRange(_meshConversion.RawConvert(meshes)); - displayMeshes.AddRange(_solidsConversion.RawConvert(solids)); + var meshesByMaterial = GetMeshesByMaterial(meshes, solids); - return displayMeshes; + return _meshByMaterialConverter.RawConvert(meshesByMaterial); } - /// - /// Retreives the meshes on an element to use as the speckle displayvalue - /// - /// - /// Some FamilyInstance elements are treated as proper Instance objects, while others are not. For those being converted as Instance objects, retrieve their display value untransformed by the instance transform or by the selected document reference point. - /// - /// - /// See https://www.revitapidocs.com/2023/e0f15010-0e19-6216-e2f0-ab7978145daa.htm for a full Geometry Object inheritance - /// - private List GetElementDisplayValue( - DB.Element element, - Options? options = null, - bool isConvertedAsInstance = false, - DB.Transform? transform = null + private static Dictionary> GetMeshesByMaterial( + List meshes, + List solids ) { - var displayMeshes = new List(); - - // test if the element is a group first - if (element is Group g) + var meshesByMaterial = new Dictionary>(); + foreach (var mesh in meshes) { - foreach (var id in g.GetMemberIds()) + var materialId = mesh.MaterialElementId; + if (!meshesByMaterial.ContainsKey(materialId)) { - var groupMeshes = GetElementDisplayValue(element.Document.GetElement(id), options, isConvertedAsInstance); - displayMeshes.AddRange(groupMeshes); + meshesByMaterial[materialId] = new List(); } - return displayMeshes; + + meshesByMaterial[materialId].Add(mesh); } - var (solids, meshes) = GetSolidsAndMeshesFromElement(element, options, transform); + foreach (var solid in solids) + { + foreach (DB.Face face in solid.Faces) + { + var materialId = face.MaterialElementId; + if (!meshesByMaterial.ContainsKey(materialId)) + { + meshesByMaterial[materialId] = new List(); + } - // convert meshes and solids - displayMeshes.AddRange(_meshConversion.RawConvert(meshes)); - displayMeshes.AddRange(_solidsConversion.RawConvert(solids)); + meshesByMaterial[materialId].Add(face.Triangulate()); + } + } - return displayMeshes; + return meshesByMaterial; } - private (List, List) GetSolidsAndMeshesFromElement( - Element element, - Options? options, - Transform? transform = null + private (List, List) GetSolidsAndMeshesFromElement( + DB.Element element, + DB.Options? options, + DB.Transform? transform = null ) { //options = ViewSpecificOptions ?? options ?? new Options() { DetailLevel = DetailLevelSetting }; - options ??= new Options() { DetailLevel = ViewDetailLevel.Fine }; + options ??= new DB.Options { DetailLevel = DB.ViewDetailLevel.Fine }; - GeometryElement geom; + DB.GeometryElement geom; try { geom = element.get_Geometry(options); @@ -109,7 +97,7 @@ private List GetElementDisplayValue( geom = element.get_Geometry(options); } - var solids = new List(); + var solids = new List(); var meshes = new List(); if (geom != null) @@ -137,11 +125,11 @@ private List GetElementDisplayValue( /// /// private void SortGeometry( - Element element, - List solids, + DB.Element element, + List solids, List meshes, - GeometryElement geom, - Transform? inverseTransform = null + DB.GeometryElement geom, + DB.Transform? inverseTransform = null ) { var topLevelSolidsCount = 0; @@ -150,13 +138,13 @@ private void SortGeometry( var topLevelGeomInstanceCount = 0; bool hasSymbolGeometry = false; - foreach (GeometryObject geomObj in geom) + foreach (DB.GeometryObject geomObj in geom) { // POC: switch could possibly become factory and IIndex<,> pattern and move conversions to // separate IComeConversionInterfaces switch (geomObj) { - case Solid solid: + case DB.Solid solid: // skip invalid solid if ( solid.Faces.Size == 0 @@ -170,7 +158,7 @@ private void SortGeometry( if (inverseTransform != null) { topLevelSolidsCount++; - solid = SolidUtils.CreateTransformed(solid, inverseTransform); + solid = DB.SolidUtils.CreateTransformed(solid, inverseTransform); } solids.Add(solid); @@ -189,7 +177,7 @@ private void SortGeometry( meshes.Add(mesh); break; - case GeometryInstance instance: + case DB.GeometryInstance instance: // element transforms should not be carried down into nested geometryInstances. // Nested geomInstances should have their geom retreived with GetInstanceGeom, not GetSymbolGeom if (inverseTransform != null) @@ -206,7 +194,7 @@ private void SortGeometry( SortGeometry(element, solids, meshes, instance.GetInstanceGeometry()); } break; - case GeometryElement geometryElement: + case DB.GeometryElement geometryElement: if (inverseTransform != null) { topLevelGeomElementCount++; @@ -230,7 +218,7 @@ private void SortGeometry( // POC: should be hoovered up with the new reporting, logging, exception philosophy private static void LogInstanceMeshRetrievalWarnings( - Element element, + DB.Element element, int topLevelSolidsCount, int topLevelMeshesCount, int topLevelGeomElementCount, @@ -272,7 +260,7 @@ bool hasSymbolGeom /// /// We're caching a dictionary of graphic styles and their ids as it can be a costly operation doing Document.GetElement(solid.GraphicsStyleId) for every solid /// - private readonly Dictionary _graphicStyleCache = new(); + private readonly Dictionary _graphicStyleCache = new(); /// /// Exclude light source cones and potentially other geometries by their graphic style @@ -280,18 +268,18 @@ bool hasSymbolGeom /// /// /// - private bool IsSkippableGraphicStyle(ElementId id, Document doc) + private bool IsSkippableGraphicStyle(DB.ElementId id, DB.Document doc) { if (!_graphicStyleCache.ContainsKey(id.ToString())) { - _graphicStyleCache.Add(id.ToString(), (GraphicsStyle)doc.GetElement(id)); + _graphicStyleCache.Add(id.ToString(), (DB.GraphicsStyle)doc.GetElement(id)); } var graphicStyle = _graphicStyleCache[id.ToString()]; if ( graphicStyle != null - && graphicStyle.GraphicsStyleCategory.Id.IntegerValue == (int)BuiltInCategory.OST_LightingFixtureSource + && graphicStyle.GraphicsStyleCategory.Id.IntegerValue == (int)DB.BuiltInCategory.OST_LightingFixtureSource ) { return true; diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/MeshBuildHelper.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/MeshBuildHelper.cs deleted file mode 100644 index 05593c36dd..0000000000 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/MeshBuildHelper.cs +++ /dev/null @@ -1,92 +0,0 @@ -using Objects.Geometry; -using Objects.Other; - -namespace Speckle.Converters.RevitShared.Helpers; - -// POC: probably interface out -public sealed class MeshBuildHelper -{ - //Lazy initialised Dictionary of Revit material (hash) -> Speckle material - private readonly Dictionary _materialMap = new(); - - public RenderMaterial? GetOrCreateMaterial(DB.Material revitMaterial) - { - int hash = Hash(revitMaterial); //Key using the hash as we may be given several instances with identical material properties - if (_materialMap.TryGetValue(hash, out RenderMaterial? m)) - { - return m; - } - - var material = RenderMaterialToSpeckle(revitMaterial); - _materialMap.Add(hash, material); - return material; - } - - // POC: cannot see how the hash is guaranteed to be unique - // surely we could store hash as a unsigned long and use bit shifting - // Extension method preferred - private static int Hash(DB.Material mat) => - mat.Transparency ^ mat.Color.Red ^ mat.Color.Green ^ mat.Color.Blue ^ mat.Smoothness ^ mat.Shininess; - - //Lazy initialised Dictionary of revit material (hash) -> Speckle Mesh - private readonly Dictionary _meshMap = new(); - - // POC: nullability needs checking - // what is this meant to be doing? - // what is the empty mesh and the material hash? - // feels like we should be caching materials but... - // why did we choose to cache this material? - // what is the relevance of the units here? - // probably we should have some IMaterialCache - public Mesh GetOrCreateMesh(DB.Material mat, string units) - { - if (mat == null) - { - return new Mesh { units = units }; - } - - int materialHash = Hash(mat); - if (_meshMap.TryGetValue(materialHash, out Mesh m)) - { - return m; - } - - var mesh = new Mesh { ["renderMaterial"] = GetOrCreateMaterial(mat), units = units }; - _meshMap.Add(materialHash, mesh); - return mesh; - } - - public List GetAllMeshes() - { - List meshes = _meshMap.Values?.ToList() ?? new List(); - - return meshes; - } - - public List GetAllValidMeshes() => GetAllMeshes().FindAll(m => m.vertices.Count > 0 && m.faces.Count > 0); - - public static RenderMaterial? RenderMaterialToSpeckle(DB.Material? revitMaterial) - { - if (revitMaterial == null) - { - return null; - } - - // POC: not sure we should be pulling in System.Drawing - - // maybe this isn't a problem as it's part of the netstandard Fwk - // ideally we'd have serialiser of our own colour class, i.e. to serialise to an uint - RenderMaterial material = - new() - { - name = revitMaterial.Name, - opacity = 1 - revitMaterial.Transparency / 100d, - //metalness = revitMaterial.Shininess / 128d, //Looks like these are not valid conversions - //roughness = 1 - (revitMaterial.Smoothness / 100d), - diffuse = System.Drawing.Color - .FromArgb(revitMaterial.Color.Red, revitMaterial.Color.Green, revitMaterial.Color.Blue) - .ToArgb() - }; - - return material; - } -} diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/MeshDataTriangulator.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/MeshDataTriangulator.cs deleted file mode 100644 index c113aa6be4..0000000000 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/MeshDataTriangulator.cs +++ /dev/null @@ -1,43 +0,0 @@ -using Objects.Geometry; -using Speckle.Converters.Common.Objects; - -namespace Speckle.Converters.RevitShared.Helpers; - -public sealed class MeshDataTriangulator -{ - private readonly IRawConversion _xyzToPointConverter; - - public MeshDataTriangulator(IRawConversion xyzToPointConverter) - { - _xyzToPointConverter = xyzToPointConverter; - } - - /// - /// Given , will convert and add triangle data to and - /// - /// The revit mesh to convert - /// The faces list to add to - /// The vertices list to add to - public void Triangulate(DB.Mesh mesh, List faces, List vertices) - { - int faceIndexOffset = vertices.Count / 3; - - foreach (var vert in mesh.Vertices) - { - var (x, y, z) = _xyzToPointConverter.RawConvert(vert); - vertices.Add(x); - vertices.Add(y); - vertices.Add(z); - } - - for (int i = 0; i < mesh.NumTriangles; i++) - { - var triangle = mesh.get_Triangle(i); - - faces.Add(3); // TRIANGLE flag - faces.Add((int)triangle.get_Index(0) + faceIndexOffset); - faces.Add((int)triangle.get_Index(1) + faceIndexOffset); - faces.Add((int)triangle.get_Index(2) + faceIndexOffset); - } - } -} diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/ParameterObjectAssigner.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/ParameterObjectAssigner.cs index 1f18fd5223..e5fa30d136 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/ParameterObjectAssigner.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/ParameterObjectAssigner.cs @@ -25,13 +25,15 @@ ParameterValueExtractor parameterValueExtractor public void AssignParametersToBase(Element target, Base @base) { Dictionary instanceParameters = _parameterValueExtractor.GetAllRemainingParams(target); - var elementType = target.Document.GetElement(target.GetTypeId()); + ElementId elementId = target.GetTypeId(); Base paramBase = new(); AssignSpeckleParamToBaseObject(instanceParameters, paramBase); - if (target is not Level) //ignore type props of levels..! + // POC: Some elements can have an invalid element type ID, I don't think we want to continue here. + if (elementId != ElementId.InvalidElementId && target is not Level) //ignore type props of levels..! { + var elementType = target.Document.GetElement(elementId); // I don't think we should be adding the type parameters to the object like this Dictionary typeParameters = _parameterValueExtractor.GetAllRemainingParams(elementType); AssignSpeckleParamToBaseObject(typeParameters, paramBase, true); diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/MeshByMaterialDictionaryToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/MeshByMaterialDictionaryToSpeckle.cs new file mode 100644 index 0000000000..2a1e71adf8 --- /dev/null +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/MeshByMaterialDictionaryToSpeckle.cs @@ -0,0 +1,114 @@ +using Objects.Other; +using Speckle.Converters.Common.Objects; +using Speckle.Converters.RevitShared.Helpers; + +namespace Speckle.Converters.RevitShared.ToSpeckle; + +public class MeshByMaterialDictionaryToSpeckle : IRawConversion>, List> +{ + private readonly RevitConversionContextStack _contextStack; + private readonly IRawConversion _xyzToPointConverter; + private readonly IRawConversion _materialConverter; + + public MeshByMaterialDictionaryToSpeckle( + IRawConversion materialConverter, + RevitConversionContextStack contextStack, + IRawConversion xyzToPointConverter + ) + { + _materialConverter = materialConverter; + _contextStack = contextStack; + _xyzToPointConverter = xyzToPointConverter; + } + + /// + /// Converts a dictionary of Revit meshes, where key is MaterialId, into a list of Speckle meshes. + /// + /// A dictionary with DB.ElementId keys and List of DB.Mesh values. + /// + /// Returns a list of objects where each mesh represents one unique material in the input dictionary. + /// + /// + /// Be aware that this method internally creates a new instance of for each unique material in the input dictionary. + /// These meshes are created with an initial capacity based on the size of the vertex and face arrays to avoid unnecessary resizing. + /// Also note that, for each unique material, the method tries to retrieve the related DB.Material from the current document and convert it. If the conversion is successful, + /// the material is added to the corresponding Speckle mesh. If the conversion fails, the operation simply continues without the material. + /// + public List RawConvert(Dictionary> target) + { + var result = new List(target.Keys.Count); + + foreach (var meshData in target) + { + DB.ElementId materialId = meshData.Key; + List meshes = meshData.Value; + + // We compute the final size of the arrays to prevent unnecessary resizing. + (int verticesSize, int facesSize) = GetVertexAndFaceListSize(meshes); + + // Initialise a new empty mesh with units and material + var speckleMesh = new SOG.Mesh( + new List(verticesSize), + new List(facesSize), + units: _contextStack.Current.SpeckleUnits + ); + + var doc = _contextStack.Current.Document.Document; + if (doc.GetElement(materialId) is DB.Material material) + { + speckleMesh["renderMaterial"] = _materialConverter.RawConvert(material); + } + + // Append the revit mesh data to the speckle mesh + foreach (var mesh in meshes) + { + AppendToSpeckleMesh(mesh, speckleMesh); + } + + result.Add(speckleMesh); + } + + return result; + } + + private void AppendToSpeckleMesh(DB.Mesh mesh, SOG.Mesh speckleMesh) + { + int faceIndexOffset = speckleMesh.vertices.Count / 3; + + foreach (var vert in mesh.Vertices) + { + var (x, y, z) = _xyzToPointConverter.RawConvert(vert); + speckleMesh.vertices.Add(x); + speckleMesh.vertices.Add(y); + speckleMesh.vertices.Add(z); + } + + for (int i = 0; i < mesh.NumTriangles; i++) + { + var triangle = mesh.get_Triangle(i); + + speckleMesh.faces.Add(3); // TRIANGLE flag + speckleMesh.faces.Add((int)triangle.get_Index(0) + faceIndexOffset); + speckleMesh.faces.Add((int)triangle.get_Index(1) + faceIndexOffset); + speckleMesh.faces.Add((int)triangle.get_Index(2) + faceIndexOffset); + } + } + + private static (int vertexCount, int) GetVertexAndFaceListSize(List meshes) + { + int numberOfVertices = 0; + int numberOfFaces = 0; + foreach (var mesh in meshes) + { + if (mesh == null) + { + continue; + } + + numberOfVertices += mesh.Vertices.Count * 3; + numberOfFaces += mesh.NumTriangles * 4; + } + + return (numberOfVertices, numberOfFaces); + } +} diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/MeshConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/MeshConversionToSpeckle.cs index a9cb34effc..55ef357c86 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/MeshConversionToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/MeshConversionToSpeckle.cs @@ -1,31 +1,84 @@ +using Objects.Other; using Speckle.Converters.Common.Objects; using Speckle.Converters.RevitShared.Helpers; namespace Speckle.Converters.RevitShared.ToSpeckle; -public class MeshConversionToSpeckle : IRawConversion, List> +public class MeshConversionToSpeckle : IRawConversion { + private readonly IRawConversion _xyzToPointConverter; + private readonly IRawConversion _materialConverter; private readonly RevitConversionContextStack _contextStack; - private readonly MeshDataTriangulator _meshDataTriangulator; - public MeshConversionToSpeckle(RevitConversionContextStack contextStack, MeshDataTriangulator meshDataTriangulator) + public MeshConversionToSpeckle( + RevitConversionContextStack contextStack, + IRawConversion xyzToPointConverter, + IRawConversion materialConverter + ) { _contextStack = contextStack; - _meshDataTriangulator = meshDataTriangulator; + _xyzToPointConverter = xyzToPointConverter; + _materialConverter = materialConverter; } - public List RawConvert(List target) + public SOG.Mesh RawConvert(DB.Mesh target) { - // POC: should be injected - MeshBuildHelper buildHelper = new(); + var doc = _contextStack.Current.Document.Document; - foreach (var mesh in target) + List vertices = GetSpeckleMeshVertexData(target); + List faces = GetSpeckleMeshFaceData(target); + + RenderMaterial? speckleMaterial = null; + if (doc.GetElement(target.MaterialElementId) is DB.Material revitMaterial) + { + speckleMaterial = _materialConverter.RawConvert(revitMaterial); + } + + return new SOG.Mesh(vertices, faces, units: _contextStack.Current.SpeckleUnits) + { + ["renderMaterial"] = speckleMaterial + }; + } + + private List GetSpeckleMeshVertexData(DB.Mesh target) + { + var vertices = new List(target.Vertices.Count * 3); + + foreach (var vert in target.Vertices) { - var revitMaterial = (DB.Material)_contextStack.Current.Document.Document.GetElement(mesh.MaterialElementId); - SOG.Mesh speckleMesh = buildHelper.GetOrCreateMesh(revitMaterial, _contextStack.Current.SpeckleUnits); - _meshDataTriangulator.Triangulate(mesh, speckleMesh.faces, speckleMesh.vertices); + vertices.AddRange(_xyzToPointConverter.RawConvert(vert).ToList()); } - return buildHelper.GetAllValidMeshes(); + return vertices; } + + private List GetSpeckleMeshFaceData(DB.Mesh target) + { + var faces = new List(target.NumTriangles * 4); + for (int i = 0; i < target.NumTriangles; i++) + { + var triangle = target.get_Triangle(i); + faces.AddRange(GetMeshTriangleData(triangle)); + } + + return faces; + } + + /// + /// Retrieves the triangle data of a mesh to be stored in a Speckle Mesh faces property. + /// + /// The mesh triangle object. + /// A list of integers representing the triangle data. + /// + /// Output format is a 4 item list with format [3, v1, v2, v3]; where the first item is the triangle flag (for speckle) + /// and the 3 following numbers are the indices of each vertex in the vertex list. + /// + private IReadOnlyList GetMeshTriangleData(DB.MeshTriangle triangle) => + new[] + { + 3, // The TRIANGLE flag in speckle + (int)triangle.get_Index(0), + (int)triangle.get_Index(1), + (int)triangle.get_Index(2) + }; } diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/SolidConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/SolidConversionToSpeckle.cs new file mode 100644 index 0000000000..e848d3a843 --- /dev/null +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/SolidConversionToSpeckle.cs @@ -0,0 +1,55 @@ +using Speckle.Converters.Common.Objects; +using Speckle.Converters.RevitShared.Helpers; + +namespace Speckle.Converters.RevitShared.ToSpeckle; + +/// +/// Solid conversion is a one->many. For each material used in the solid, a mesh will be returned to reduce the amount of instances created. +/// +public class SolidConversionToSpeckle : IRawConversion> +{ + private readonly RevitConversionContextStack _contextStack; + private readonly IRawConversion>, List> _meshByMaterialConverter; + + public SolidConversionToSpeckle( + RevitConversionContextStack contextStack, + IRawConversion>, List> meshByMaterialConverter + ) + { + _contextStack = contextStack; + _meshByMaterialConverter = meshByMaterialConverter; + } + + /// + /// Converts the input object into a list of . + /// + /// The input object to be converted. + /// + /// A list of objects that represent the input object. Each mesh in the list corresponds to a different material in the original solid. + /// + /// + /// This conversion process first triangulates the input solid by material, and then converts the result to raw meshes individually. + /// Be aware that this operation might be computationally intensive for complex solids, due to the need for triangulation. + /// + public List RawConvert(DB.Solid target) + { + var meshesByMaterial = GetTriangulatedMeshesFromSolidByMaterial(target); + return _meshByMaterialConverter.RawConvert(meshesByMaterial); + } + + private Dictionary> GetTriangulatedMeshesFromSolidByMaterial(DB.Solid solid) + { + var result = new Dictionary>(); + foreach (DB.Face face in solid.Faces) + { + if (!result.ContainsKey(face.MaterialElementId)) + { + result[face.MaterialElementId] = new List(); + } + + result[face.MaterialElementId].Add(face.Triangulate()); + } + + return result; + } +} diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/SolidsConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/SolidsConversionToSpeckle.cs deleted file mode 100644 index 48b30339df..0000000000 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/SolidsConversionToSpeckle.cs +++ /dev/null @@ -1,81 +0,0 @@ -using Speckle.Converters.Common; -using Speckle.Converters.Common.Objects; -using Speckle.Converters.RevitShared.Helpers; - -namespace Speckle.Converters.RevitShared.ToSpeckle; - -// POC: do we need to have this atm? -// why do we need a List, do we encounter these in the converter logic? -// it looks wrong here or perhaps the List is coming from the connector? -public class SolidsConversionToSpeckle : IRawConversion, List> -{ - private readonly RevitConversionContextStack _contextStack; - private readonly MeshDataTriangulator _meshDataTriangulator; - - public SolidsConversionToSpeckle(RevitConversionContextStack contextStack, MeshDataTriangulator meshDataTriangulator) - { - _contextStack = contextStack; - _meshDataTriangulator = meshDataTriangulator; - } - - // POC: this is converting and caching and using the cache and some of it is a bit questionable - public List RawConvert(List target) - { - MeshBuildHelper meshBuildHelper = new(); - - var meshMap = new Dictionary>(); - foreach (DB.Solid solid in target) - { - foreach (DB.Face face in solid.Faces) - { - // POC: throwing here? Just review. Is it necessary armouring against Revit APU weirdness? - // do direct cast (DB.Material) instead of as and then no need to throw, it will throw naturally - // of course if we need to do this then maybe it's valid. So hence, just review. - DB.Material faceMaterial = - _contextStack.Current.Document.Document.GetElement(face.MaterialElementId) as DB.Material - ?? throw new SpeckleConversionException("Unable to cast face's materialElementId element to DB.Material"); - - // POC: this logic, relationship between material and mesh, seems wrong - SOG.Mesh m = meshBuildHelper.GetOrCreateMesh(faceMaterial, _contextStack.Current.SpeckleUnits); - if (!meshMap.TryGetValue(m, out List? value)) - { - value = new List(); - meshMap.Add(m, value); - } - - value.Add(face.Triangulate()); - } - } - - foreach (var meshData in meshMap) - { - //It's cheaper to resize lists manually, since we would otherwise be resizing a lot! - int numberOfVertices = 0; - int numberOfFaces = 0; - foreach (DB.Mesh mesh in meshData.Value) - { - if (mesh == null) - { - continue; - } - - numberOfVertices += mesh.Vertices.Count * 3; - numberOfFaces += mesh.NumTriangles * 4; - } - - meshData.Key.faces.Capacity = numberOfFaces; - meshData.Key.vertices.Capacity = numberOfVertices; - foreach (DB.Mesh mesh in meshData.Value) - { - if (mesh == null) - { - continue; - } - - _meshDataTriangulator.Triangulate(mesh, meshData.Key.faces, meshData.Key.vertices); - } - } - - return meshBuildHelper.GetAllValidMeshes(); - } -} diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/MaterialConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/MaterialConversionToSpeckle.cs new file mode 100644 index 0000000000..5547c028d6 --- /dev/null +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/MaterialConversionToSpeckle.cs @@ -0,0 +1,20 @@ +using Objects.Other; +using Speckle.Converters.Common.Objects; + +namespace Speckle.Converters.RevitShared.ToSpeckle; + +public class MaterialConversionToSpeckle : IRawConversion +{ + public RenderMaterial RawConvert(DB.Material target) => + // POC: not sure we should be pulling in System.Drawing - + // maybe this isn't a problem as it's part of the netstandard Fwk + // ideally we'd have serialiser of our own colour class, i.e. to serialise to an uint + new() + { + name = target.Name, + opacity = 1 - target.Transparency / 100d, + diffuse = System.Drawing.Color.FromArgb(target.Color.Red, target.Color.Green, target.Color.Blue).ToArgb() + //metalness = revitMaterial.Shininess / 128d, //Looks like these are not valid conversions + //roughness = 1 - (revitMaterial.Smoothness / 100d) + }; +} diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Speckle.Converters.RevitShared.projitems b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Speckle.Converters.RevitShared.projitems index e353303cf4..894e9a9289 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Speckle.Converters.RevitShared.projitems +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Speckle.Converters.RevitShared.projitems @@ -15,21 +15,22 @@ - - + - + + + diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/DirectShapeConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/DirectShapeConversionToSpeckle.cs new file mode 100644 index 0000000000..35bf7b2a94 --- /dev/null +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/DirectShapeConversionToSpeckle.cs @@ -0,0 +1,48 @@ +using Speckle.Converters.Common; +using Speckle.Converters.RevitShared.Extensions; +using Speckle.Converters.RevitShared.Helpers; +using Speckle.Converters.RevitShared.ToSpeckle; +using Speckle.Core.Models; + +namespace Speckle.Converters.Revit2023.ToSpeckle; + +[NameAndRankValue(nameof(DB.DirectShape), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +public class DirectShapeConversionToSpeckle : BaseConversionToSpeckle +{ + private readonly RevitConversionContextStack _contextStack; + private readonly ParameterObjectAssigner _parameterObjectAssigner; + private readonly DisplayValueExtractor _displayValueExtractor; + + public DirectShapeConversionToSpeckle( + ParameterObjectAssigner parameterObjectAssigner, + RevitConversionContextStack contextStack, + DisplayValueExtractor displayValueExtractor + ) + { + _parameterObjectAssigner = parameterObjectAssigner; + _contextStack = contextStack; + _displayValueExtractor = displayValueExtractor; + } + + public override SOBR.DirectShape RawConvert(DB.DirectShape target) + { + var category = target.Category.GetBuiltInCategory().GetSchemaBuilderCategoryFromBuiltIn(); + + // POC: Making the analogy that the DisplayValue is the same as the Geometries is only valid while we don't support Solids on send. + var geometries = _displayValueExtractor.GetDisplayValue(target).Cast().ToList(); + + SOBR.DirectShape result = + new(target.Name, category, geometries) + { + displayValue = geometries, + units = _contextStack.Current.SpeckleUnits, + elementId = target.Id.ToString() + }; + + _parameterObjectAssigner.AssignParametersToBase(target, result); + + result["type"] = target.Name; + + return result; + } +} From ef6c3b33ec9ec3283b7ccf4b7453f01402c0d40b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?O=C4=9Fuzhan=20Koral?= <45078678+oguzhankoral@users.noreply.github.com> Date: Mon, 29 Apr 2024 21:06:56 +0300 Subject: [PATCH 055/261] CNX-9358 Fix write to file with DocumentToBeDeactivated event (#3319) Fix write to file with DocumentToBeDeactivated event --- .../HostApp/AutocadDocumentModelStore.cs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/AutocadDocumentModelStore.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/AutocadDocumentModelStore.cs index b301760e9d..f2d2f00bfc 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/AutocadDocumentModelStore.cs +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/AutocadDocumentModelStore.cs @@ -26,15 +26,17 @@ AutocadDocumentManager autocadDocumentManager // POC: this logic might go when we have document management in context // It is with the case of if binding created with already a document // This is valid when user opens acad file directly double clicking - _previousDocName = Application.DocumentManager.MdiActiveDocument.Name; - _saveToDocSubTracker.Add(Application.DocumentManager.MdiActiveDocument.Name); - OnDocumentChanged(); + OnDocChangeInternal(Application.DocumentManager.MdiActiveDocument); } + // Whenever we switch document, it will be triggered for existing one + Application.DocumentManager.DocumentToBeDeactivated += (_, _) => WriteToFile(); Application.DocumentManager.DocumentToBeDestroyed += (_, _) => WriteToFile(); Application.DocumentManager.DocumentActivated += (_, e) => OnDocChangeInternal(e.Document); - Autodesk.AutoCAD.ApplicationServices.Application.DocumentWindowCollection.DocumentWindowActivated += (_, args) => - OnDocChangeInternal((Document)args.DocumentWindow.Document); + + // since below event triggered as secondary, it breaks the logic in OnDocChangeInternal function, leaving it here for now. + // Autodesk.AutoCAD.ApplicationServices.Application.DocumentWindowCollection.DocumentWindowActivated += (_, args) => + // OnDocChangeInternal((Document)args.DocumentWindow.Document); } /// From 6e72de2b18d049533a3cc347f58c486c9ad29b7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?O=C4=9Fuzhan=20Koral?= <45078678+oguzhankoral@users.noreply.github.com> Date: Tue, 30 Apr 2024 13:18:49 +0300 Subject: [PATCH 056/261] CNX-9364 revit connector UI not up to date (#3323) * Fix netlify url in Revit * Extract URL into one place and reference for all usage --- .../Plugin/CefSharpPanel.xaml | 3 ++- .../Plugin/RevitPlugin.cs | 4 +++- .../DUI3ControlWebView.xaml | 3 ++- DUI3-DX/DUI3/Speckle.Connectors.DUI/Url.cs | 21 +++++++++++++++++++ 4 files changed, 28 insertions(+), 3 deletions(-) create mode 100644 DUI3-DX/DUI3/Speckle.Connectors.DUI/Url.cs diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/CefSharpPanel.xaml b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/CefSharpPanel.xaml index 822ed7514e..d49e7abc30 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/CefSharpPanel.xaml +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/CefSharpPanel.xaml @@ -4,6 +4,7 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:cefSharp="clr-namespace:CefSharp.Wpf;assembly=CefSharp.Wpf" + xmlns:local="clr-namespace:Speckle.Connectors.DUI;assembly=Speckle.Connectors.DUI" mc:Ignorable="d" Title="Panel" Height="450" Width="800"> @@ -11,7 +12,7 @@ + Address="{x:Static local:Url.NetlifyString}" /> diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitPlugin.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitPlugin.cs index 9aef8c0f83..575454b5c3 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitPlugin.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitPlugin.cs @@ -122,7 +122,9 @@ private void RegisterPanelAndInitializePlugin() ); } - _cefSharpPanel.Browser.Load("https://deploy-preview-2076--boisterous-douhua-e3cefb.netlify.app/"); + // POC: Below line seems unneccesary but not removing just in case we did it like this? Maybe check it later + // with some other revit connectors again since CefSharp version is different + // _cefSharpPanel.Browser.Load("https://boisterous-douhua-e3cefb.netlify.app/"); // POC: not sure where this comes from #if REVIT2020 diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI.WebView/DUI3ControlWebView.xaml b/DUI3-DX/DUI3/Speckle.Connectors.DUI.WebView/DUI3ControlWebView.xaml index eb2d4acddd..c2a5e9354e 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI.WebView/DUI3ControlWebView.xaml +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI.WebView/DUI3ControlWebView.xaml @@ -4,6 +4,7 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:wv2="clr-namespace:Microsoft.Web.WebView2.Wpf;assembly=Microsoft.Web.WebView2.Wpf" + xmlns:local="clr-namespace:Speckle.Connectors.DUI;assembly=Speckle.Connectors.DUI" mc:Ignorable="d" d:DesignHeight="450" d:DesignWidth="800"> @@ -13,6 +14,6 @@ + Name="Browser" Grid.Row="0" Source="{x:Static local:Url.Netlify}" /> diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Url.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Url.cs new file mode 100644 index 0000000000..4f63cfff78 --- /dev/null +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Url.cs @@ -0,0 +1,21 @@ +using System; + +namespace Speckle.Connectors.DUI; + +// POC: XAML file accept Static only, but later we can search more is it possible to inject this? or necessary?? + +/// +/// Only place that we reference to URLs to connector UIs. +/// +/// +/// If we are on 'work in progress' branch on UI repo, +/// we can replace the netlify url with 'preview' one which is provided within each PR. +/// sample url produced by PR on `dui3` branch on `speckle-server` -> deploy-preview-2076--boisterous-douhua-e3cefb.netlify.app +/// +public static class Url +{ + public static readonly Uri Netlify = new("https://boisterous-douhua-e3cefb.netlify.app/"); + + // In CefSharp XAML file we cannot call ToString() function over URI + public static readonly string NetlifyString = Netlify.ToString(); +} From 1c91754123fdd39ea2c07507f3b27b3e833c8dca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?O=C4=9Fuzhan=20Koral?= <45078678+oguzhankoral@users.noreply.github.com> Date: Tue, 30 Apr 2024 15:19:18 +0300 Subject: [PATCH 057/261] CNX-9292 apply unit of work for auto cad (#3321) Implement UoW for autocad --- .../Bindings/AutocadReceiveBinding.cs | 13 +++++++------ .../Bindings/AutocadSendBinding.cs | 3 --- .../DependencyInjection/AutofacAutocadModule.cs | 2 +- .../Operations/Receive/HostObjectBuilder.cs | 14 ++++---------- .../Operations/Send/RootObjectBuilder.cs | 14 ++++---------- 5 files changed, 16 insertions(+), 30 deletions(-) diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadReceiveBinding.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadReceiveBinding.cs index 335588929f..c21f38148c 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadReceiveBinding.cs +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadReceiveBinding.cs @@ -1,3 +1,4 @@ +using Speckle.Autofac.DependencyInjection; using Speckle.Connectors.DUI.Bindings; using Speckle.Connectors.DUI.Bridge; using Speckle.Connectors.DUI.Models; @@ -16,21 +17,20 @@ public sealed class AutocadReceiveBinding : IReceiveBinding, ICancelable private readonly DocumentModelStore _store; private readonly CancellationManager _cancellationManager; + private readonly IUnitOfWorkFactory _unitOfWorkFactory; public ReceiveBindingUICommands Commands { get; } - private readonly ReceiveOperation _receiveOperation; - public AutocadReceiveBinding( DocumentModelStore store, IBridge parent, - ReceiveOperation receiveOperation, - CancellationManager cancellationManager + CancellationManager cancellationManager, + IUnitOfWorkFactory unitOfWorkFactory ) { _store = store; _cancellationManager = cancellationManager; - _receiveOperation = receiveOperation; + _unitOfWorkFactory = unitOfWorkFactory; Parent = parent; Commands = new ReceiveBindingUICommands(parent); } @@ -39,6 +39,7 @@ CancellationManager cancellationManager public async Task Receive(string modelCardId) { + using var unitOfWork = _unitOfWorkFactory.Resolve(); try { // Init cancellation token source -> Manager also cancel it if exist before @@ -51,7 +52,7 @@ public async Task Receive(string modelCardId) } // Receive host objects - IEnumerable receivedObjectIds = await _receiveOperation + IEnumerable receivedObjectIds = await unitOfWork.Service .Execute( modelCard.AccountId, // POC: I hear -you are saying why we're passing them separately. Not sure pass the DUI3-> Connectors.DUI project dependency to the SDK-> Connector.Utils modelCard.ProjectId, diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadSendBinding.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadSendBinding.cs index 13585bde5e..dab413d79f 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadSendBinding.cs +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadSendBinding.cs @@ -27,7 +27,6 @@ public sealed class AutocadSendBinding : ISendBinding, ICancelable private readonly CancellationManager _cancellationManager; private readonly IUnitOfWorkFactory _unitOfWorkFactory; private readonly AutocadSettings _autocadSettings; - private readonly SendOperation<(DBObject obj, string applicationId)> _sendOperation; /// /// Used internally to aggregate the changed objects' id. @@ -46,14 +45,12 @@ public AutocadSendBinding( IEnumerable sendFilters, CancellationManager cancellationManager, AutocadSettings autocadSettings, - SendOperation<(DBObject obj, string applicationId)> sendOperation, IUnitOfWorkFactory unitOfWorkFactory ) { _store = store; _idleManager = idleManager; _unitOfWorkFactory = unitOfWorkFactory; - _sendOperation = sendOperation; _autocadSettings = autocadSettings; _cancellationManager = cancellationManager; _sendFilters = sendFilters.ToList(); diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/DependencyInjection/AutofacAutocadModule.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/DependencyInjection/AutofacAutocadModule.cs index f01aa9acbe..412982465e 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/DependencyInjection/AutofacAutocadModule.cs +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/DependencyInjection/AutofacAutocadModule.cs @@ -50,7 +50,7 @@ protected override void Load(ContainerBuilder builder) // Operations builder.RegisterType>().InstancePerLifetimeScope(); builder.RegisterType().SingleInstance(); - builder.RegisterType().As().SingleInstance(); + builder.RegisterType().As().SingleInstance().AutoActivate(); // Auto activation makes SynchronizationContext available right after building. Otherwise we were missing it in UoWs. // Object Builders builder.RegisterType().As().InstancePerDependency(); diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Operations/Receive/HostObjectBuilder.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Operations/Receive/HostObjectBuilder.cs index c9cc82d58d..178c791c05 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Operations/Receive/HostObjectBuilder.cs +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Operations/Receive/HostObjectBuilder.cs @@ -1,6 +1,5 @@ using System.Diagnostics; using Autodesk.AutoCAD.DatabaseServices; -using Speckle.Autofac.DependencyInjection; using Speckle.Connectors.Autocad.HostApp; using Speckle.Connectors.Autocad.HostApp.Extensions; using Speckle.Core.Models; @@ -13,12 +12,12 @@ namespace Speckle.Connectors.Autocad.Operations.Receive; public class HostObjectBuilder : IHostObjectBuilder { - private readonly IUnitOfWorkFactory _unitOfWorkFactory; + private readonly ISpeckleConverterToHost _converter; private readonly AutocadLayerManager _autocadLayerManager; - public HostObjectBuilder(IUnitOfWorkFactory unitOfWorkFactory, AutocadLayerManager autocadLayerManager) + public HostObjectBuilder(ISpeckleConverterToHost converter, AutocadLayerManager autocadLayerManager) { - _unitOfWorkFactory = unitOfWorkFactory; + _converter = converter; _autocadLayerManager = autocadLayerManager; } @@ -49,11 +48,6 @@ CancellationToken cancellationToken // Prompt the UI conversion started. Progress bar will swoosh. onOperationProgressed?.Invoke("Converting", null); - // POC: does this feel like the right place? I am wondering if this should be called from within send/rcv? - // begin the unit of work - using var uow = _unitOfWorkFactory.Resolve(); - var converter = uow.Service; - // Layer filter for received commit with project and model name _autocadLayerManager.CreateLayerFilter(projectName, modelName); List<(List, Base)> objectsWithPath = GetBaseWithPath(rootObject, cancellationToken); @@ -79,7 +73,7 @@ CancellationToken cancellationToken _autocadLayerManager.CreateLayerOrPurge(layerFullName); } - object converted = converter.Convert(obj); + object converted = _converter.Convert(obj); List flattened = Utilities.FlattenToHostConversionResult(converted); foreach (Entity conversionResult in flattened.Cast()) diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Operations/Send/RootObjectBuilder.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Operations/Send/RootObjectBuilder.cs index 0f1b81cd36..621979f9bb 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Operations/Send/RootObjectBuilder.cs +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Operations/Send/RootObjectBuilder.cs @@ -1,6 +1,5 @@ using System.Diagnostics; using Autodesk.AutoCAD.DatabaseServices; -using Speckle.Autofac.DependencyInjection; using Speckle.Connectors.Utils.Builders; using Speckle.Connectors.Utils.Operations; using Speckle.Converters.Common; @@ -11,12 +10,12 @@ namespace Speckle.Connectors.Autocad.Operations.Send; public class RootObjectBuilder : IRootObjectBuilder<(DBObject obj, string applicationId)> { - private readonly IUnitOfWorkFactory _unitOfWorkFactory; + private readonly ISpeckleConverterToSpeckle _converter; private readonly string[] _documentPathSeparator = { "\\" }; - public RootObjectBuilder(IUnitOfWorkFactory unitOfWorkFactory) + public RootObjectBuilder(ISpeckleConverterToSpeckle converter) { - _unitOfWorkFactory = unitOfWorkFactory; + _converter = converter; } public Base Build( @@ -26,11 +25,6 @@ public Base Build( CancellationToken ct = default ) { - // POC: does this feel like the right place? I am wondering if this should be called from within send/rcv? - // begin the unit of work - using var uow = _unitOfWorkFactory.Resolve(); - var converter = uow.Service; - Collection modelWithLayers = new() { @@ -64,7 +58,7 @@ public Base Build( } else { - converted = converter.Convert(dbObject); + converted = _converter.Convert(dbObject); if (converted == null) { From 91d3fa46932dfba916e2eed0b22d3c0e8afb5311 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?O=C4=9Fuzhan=20Koral?= <45078678+oguzhankoral@users.noreply.github.com> Date: Tue, 30 Apr 2024 15:39:08 +0300 Subject: [PATCH 058/261] CNX-9373 saved model cards doesn t show correct state on latest version state (#3325) Implement missing flag for saved receiver model card state --- .../DUI3/Speckle.Connectors.DUI/Models/Card/ReceiverModelCard.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/ReceiverModelCard.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/ReceiverModelCard.cs index f2c563ea33..8a2ab0fbd1 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/ReceiverModelCard.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/ReceiverModelCard.cs @@ -6,4 +6,5 @@ public class ReceiverModelCard : ModelCard public string ModelName { get; set; } public string SelectedVersionId { get; set; } public string LatestVersionId { get; set; } + public bool HasDismissedUpdateWarning { get; set; } } From 745969df75bc37c3a9208bc1c7bc34c137e93d55 Mon Sep 17 00:00:00 2001 From: oguzhankoral Date: Tue, 30 Apr 2024 18:59:02 +0300 Subject: [PATCH 059/261] WIP --- .../DependencyInjection/AutofacUIModule.cs | 13 +- .../HostApp/DocumentModelStorageSchema.cs | 23 +++ .../HostApp/IStorageSchema.cs | 8 + .../HostApp/IdStorageSchema.cs | 23 +++ .../HostApp/RevitDocumentStore.cs | 140 +++++++++++------- .../Speckle.Connectors.RevitShared.projitems | 3 + 6 files changed, 158 insertions(+), 52 deletions(-) create mode 100644 DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/DocumentModelStorageSchema.cs create mode 100644 DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/IStorageSchema.cs create mode 100644 DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/IdStorageSchema.cs diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/AutofacUIModule.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/AutofacUIModule.cs index bb8c923f64..bdbb185eeb 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/AutofacUIModule.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/AutofacUIModule.cs @@ -7,16 +7,20 @@ using Speckle.Autofac.DependencyInjection; using Speckle.Connectors.DUI.Bindings; using Speckle.Connectors.DUI.Bridge; +using Speckle.Connectors.DUI.Models; using Speckle.Connectors.DUI.Models.Card.SendFilter; using Speckle.Connectors.DUI.Utils; using Speckle.Connectors.Revit.Bindings; using Speckle.Connectors.Revit.HostApp; using Speckle.Connectors.Revit.Operations.Send; using Speckle.Connectors.Revit.Plugin; +using Speckle.Connectors.Utils.Operations; using Speckle.Converters.RevitShared.Helpers; using Speckle.Core.Transports; using Speckle.Newtonsoft.Json; using Speckle.Newtonsoft.Json.Serialization; +using IRootObjectSender = Speckle.Connectors.Revit.Operations.Send.IRootObjectSender; +using RootObjectSender = Speckle.Connectors.Revit.Operations.Send.RootObjectSender; namespace Speckle.Connectors.Revit.DependencyInjection; @@ -55,6 +59,10 @@ protected override void Load(ContainerBuilder builder) builder.RegisterType().As().SingleInstance(); builder.RegisterType().As().InstancePerDependency(); + // Storage Schema + builder.RegisterType().AsSelf().InstancePerLifetimeScope(); + builder.RegisterType().AsSelf().InstancePerLifetimeScope(); + // POC: we need to review the scopes and create a document on what the policy is // and where the UoW should be // register UI bindings @@ -64,10 +72,11 @@ protected override void Load(ContainerBuilder builder) builder.RegisterType().As().SingleInstance(); builder.RegisterType().As().SingleInstance(); builder.RegisterType().As().SingleInstance(); - builder.RegisterType().As().SingleInstance(); + // builder.RegisterType().As().SingleInstance(); // POC: commenting it out is enough to hide the Load button on UI - enable it later builder.RegisterType().As().SingleInstance(); // send operation and dependencies + builder.RegisterType().As().SingleInstance().AutoActivate(); builder.RegisterType().AsSelf().InstancePerLifetimeScope(); builder.RegisterType().AsSelf().InstancePerLifetimeScope(); builder.RegisterType().AsSelf().InstancePerLifetimeScope(); @@ -76,7 +85,7 @@ protected override void Load(ContainerBuilder builder) builder.RegisterType().As().SingleInstance(); // register - builder.RegisterType().SingleInstance(); + builder.RegisterType().As().SingleInstance().AsSelf(); // POC: this can be injected in maybe a common place, perhaps a module in Speckle.Converters.Common.DependencyInjection builder.RegisterType().As().InstancePerLifetimeScope(); diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/DocumentModelStorageSchema.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/DocumentModelStorageSchema.cs new file mode 100644 index 0000000000..788b8dae4a --- /dev/null +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/DocumentModelStorageSchema.cs @@ -0,0 +1,23 @@ +using System; +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/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/IStorageSchema.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/IStorageSchema.cs new file mode 100644 index 0000000000..4a1a68274b --- /dev/null +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/IStorageSchema.cs @@ -0,0 +1,8 @@ +using Autodesk.Revit.DB.ExtensibleStorage; + +namespace Speckle.Connectors.Revit.HostApp; + +public interface IStorageSchema +{ + Schema GetSchema(); +} diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/IdStorageSchema.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/IdStorageSchema.cs new file mode 100644 index 0000000000..cd7cd8147c --- /dev/null +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/IdStorageSchema.cs @@ -0,0 +1,23 @@ +using System; +using Autodesk.Revit.DB.ExtensibleStorage; + +namespace Speckle.Connectors.Revit.HostApp; + +public class IdStorageSchema : IStorageSchema +{ + private readonly Guid _schemaGuid = new("D0E2AD18-0DE0-41CF-A2B7-5384267061D7"); + + public Schema GetSchema() + { + Schema schema = Schema.Lookup(_schemaGuid); + if (schema != null) + { + return schema; + } + + using SchemaBuilder builder = new(_schemaGuid); + builder.SetSchemaName("DataStorageUniqueId"); + builder.AddSimpleField("Id", typeof(Guid)); + return builder.Finish(); + } +} diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/RevitDocumentStore.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/RevitDocumentStore.cs index c8d49967cb..9bdb6cda3f 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/RevitDocumentStore.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/RevitDocumentStore.cs @@ -1,11 +1,13 @@ using System; using System.Collections.Generic; +using System.Threading.Tasks; using Autodesk.Revit.DB; using Autodesk.Revit.DB.ExtensibleStorage; using Autodesk.Revit.UI; using Revit.Async; using Speckle.Connectors.DUI.Models; using Speckle.Connectors.DUI.Models.Card; +using Speckle.Connectors.Utils.Operations; using Speckle.Converters.RevitShared.Helpers; using Speckle.Core.Logging; using Speckle.Newtonsoft.Json; @@ -19,11 +21,23 @@ internal class RevitDocumentStore : DocumentModelStore private static readonly Guid s_revitDocumentStoreId = new("D35B3695-EDC9-4E15-B62A-D3FC2CB83FA3"); private readonly RevitContext _revitContext; - - public RevitDocumentStore(RevitContext revitContext, JsonSerializerSettings serializerSettings) + private readonly ISyncToMainThread _syncToMainThread; + private readonly DocumentModelStorageSchema _documentModelStorageSchema; + private readonly IdStorageSchema _idStorageSchema; + + public RevitDocumentStore( + RevitContext revitContext, + JsonSerializerSettings serializerSettings, + ISyncToMainThread syncToMainThread, + DocumentModelStorageSchema documentModelStorageSchema, + IdStorageSchema idStorageSchema + ) : base(serializerSettings) { _revitContext = revitContext; + _syncToMainThread = syncToMainThread; + _documentModelStorageSchema = documentModelStorageSchema; + _idStorageSchema = idStorageSchema; UIApplication uiApplication = _revitContext.UIApplication; @@ -63,23 +77,47 @@ public override void WriteToFile() return; } - RevitTask.RunAsync(() => { - // POC: re-instate - //using Transaction t = new(doc.Document, "Speckle Write State"); - //t.Start(); - //using DataStorage ds = GetSettingsDataStorage(doc.Document) ?? DataStorage.Create(doc.Document); + /*_syncToMainThread + .RunOnThread(() => + { + // POC: re-instate + using Transaction t = new(doc.Document, "Speckle Write State"); + t.Start(); + using DataStorage ds = GetSettingsDataStorage(doc.Document) ?? DataStorage.Create(doc.Document); + + using Entity stateEntity = new(_documentModelStorageSchema.GetSchema()); + string serializedModels = Serialize(); + stateEntity.Set("contents", serializedModels); + + using Entity idEntity = new(_idStorageSchema.GetSchema()); + idEntity.Set("Id", s_revitDocumentStoreId); - //using Entity stateEntity = new(DocumentModelStoreSchema.GetSchema()); - //string serializedModels = Serialize(); - //stateEntity.Set("contents", serializedModels); + ds.SetEntity(idEntity); + ds.SetEntity(stateEntity); + t.Commit(); + + return Task.CompletedTask; + }) + .ConfigureAwait(false);*/ + + // POC: previously we were calling below code + // RevitTask.RunAsync(() => { + // POC: re-instate + //using Transaction t = new(doc.Document, "Speckle Write State"); + //t.Start(); + //using DataStorage ds = GetSettingsDataStorage(doc.Document) ?? DataStorage.Create(doc.Document); - //using Entity idEntity = new(IdStorageSchema.GetSchema()); - //idEntity.Set("Id", s_revitDocumentStoreId); + //using Entity stateEntity = new(DocumentModelStoreSchema.GetSchema()); + //string serializedModels = Serialize(); + //stateEntity.Set("contents", serializedModels); - //ds.SetEntity(idEntity); - //ds.SetEntity(stateEntity); - //t.Commit(); - }); + //using Entity idEntity = new(IdStorageSchema.GetSchema()); + //idEntity.Set("Id", s_revitDocumentStoreId); + + //ds.SetEntity(idEntity); + //ds.SetEntity(stateEntity); + //t.Commit(); + // }); } public override void ReadFromFile() @@ -106,46 +144,48 @@ public override void ReadFromFile() private DataStorage GetSettingsDataStorage(Document doc) { // POC: re-instate - //using FilteredElementCollector collector = new(doc); - //FilteredElementCollector dataStorages = collector.OfClass(typeof(DataStorage)); - - //foreach (Element element in dataStorages) - //{ - // DataStorage dataStorage = (DataStorage)element; - // Entity settingIdEntity = dataStorage.GetEntity(IdStorageSchema.GetSchema()); - // if (!settingIdEntity.IsValid()) - // { - // continue; - // } - - // Guid id = settingIdEntity.Get("Id"); - // if (!id.Equals(s_revitDocumentStoreId)) - // { - // continue; - // } - - // return dataStorage; - //} + using FilteredElementCollector collector = new(doc); + FilteredElementCollector dataStorages = collector.OfClass(typeof(DataStorage)); + + foreach (Element element in dataStorages) + { + DataStorage dataStorage = (DataStorage)element; + Entity settingIdEntity = dataStorage.GetEntity(_idStorageSchema.GetSchema()); + if (!settingIdEntity.IsValid()) + { + continue; + } + + Guid id = settingIdEntity.Get("Id"); + if (!id.Equals(s_revitDocumentStoreId)) + { + continue; + } + + return dataStorage; + } + return null; } private Entity GetSpeckleEntity(Document doc) { // POC: re-instate - //using FilteredElementCollector collector = new(doc); - - //FilteredElementCollector dataStorages = collector.OfClass(typeof(DataStorage)); - //foreach (Element element in dataStorages) - //{ - // DataStorage dataStorage = (DataStorage)element; - // Entity settingEntity = dataStorage.GetEntity(DocumentModelStoreSchema.GetSchema()); - // if (!settingEntity.IsValid()) - // { - // continue; - // } - - // return settingEntity; - //} + 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/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Speckle.Connectors.RevitShared.projitems b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Speckle.Connectors.RevitShared.projitems index ec05d77242..25aa1128b9 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Speckle.Connectors.RevitShared.projitems +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Speckle.Connectors.RevitShared.projitems @@ -20,7 +20,10 @@ + + + From 8261f2fccc1e495e21b28b8175214722b0159f51 Mon Sep 17 00:00:00 2001 From: Jedd Morgan <45512892+JR-Morgan@users.noreply.github.com> Date: Tue, 30 Apr 2024 18:03:03 +0100 Subject: [PATCH 060/261] Cleaned up connector dependencies (#3326) csproj-cleanup --- .../Speckle.Connectors.ArcGIS3.csproj | 6 +----- .../Speckle.Converters.ArcGIS3.DependencyInjection.csproj | 5 +++++ .../Speckle.Converters.ArcGIS3.csproj | 1 - ...ckle.Converters.Autocad2023.DependencyInjection.csproj | 8 ++++---- .../Speckle.Converters.Autocad2023.csproj | 2 -- ...peckle.Converters.Revit2023.DependencyInjection.csproj | 6 ++++-- .../Speckle.Converters.Revit2023.csproj | 1 - .../Speckle.Converters.Rhino7.DependencyInjection.csproj | 1 + .../Speckle.Converters.Rhino7.csproj | 1 - DUI3-DX/Sdk/Speckle.Autofac/Speckle.Autofac.csproj | 2 +- .../Speckle.Converters.Common.DependencyInjection.csproj | 6 +++--- .../Speckle.Converters.Common.csproj | 1 + 12 files changed, 20 insertions(+), 20 deletions(-) diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Speckle.Connectors.ArcGIS3.csproj b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Speckle.Connectors.ArcGIS3.csproj index f81aa0f469..4887f7ffc9 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Speckle.Connectors.ArcGIS3.csproj +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Speckle.Connectors.ArcGIS3.csproj @@ -26,12 +26,8 @@ - - - - + - diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3.DependencyInjection/Speckle.Converters.ArcGIS3.DependencyInjection.csproj b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3.DependencyInjection/Speckle.Converters.ArcGIS3.DependencyInjection.csproj index a9485faf13..42ed102e6e 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3.DependencyInjection/Speckle.Converters.ArcGIS3.DependencyInjection.csproj +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3.DependencyInjection/Speckle.Converters.ArcGIS3.DependencyInjection.csproj @@ -8,7 +8,12 @@ + + + + + diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Speckle.Converters.ArcGIS3.csproj b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Speckle.Converters.ArcGIS3.csproj index 6df0a13dae..8227edcfd6 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Speckle.Converters.ArcGIS3.csproj +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Speckle.Converters.ArcGIS3.csproj @@ -12,7 +12,6 @@ - diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2023.DependencyInjection/Speckle.Converters.Autocad2023.DependencyInjection.csproj b/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2023.DependencyInjection/Speckle.Converters.Autocad2023.DependencyInjection.csproj index ab0fc41461..9a107c64a2 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2023.DependencyInjection/Speckle.Converters.Autocad2023.DependencyInjection.csproj +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2023.DependencyInjection/Speckle.Converters.Autocad2023.DependencyInjection.csproj @@ -6,12 +6,12 @@ - - - - + + + + diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2023/Speckle.Converters.Autocad2023.csproj b/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2023/Speckle.Converters.Autocad2023.csproj index e9128b633d..f60b494008 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2023/Speckle.Converters.Autocad2023.csproj +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2023/Speckle.Converters.Autocad2023.csproj @@ -10,8 +10,6 @@ - - diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/Speckle.Converters.Revit2023.DependencyInjection.csproj b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/Speckle.Converters.Revit2023.DependencyInjection.csproj index bbaea7cde3..3969078db5 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/Speckle.Converters.Revit2023.DependencyInjection.csproj +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/Speckle.Converters.Revit2023.DependencyInjection.csproj @@ -7,12 +7,14 @@ - - True + + + + diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023/Speckle.Converters.Revit2023.csproj b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023/Speckle.Converters.Revit2023.csproj index b556944923..50e0c1f3c3 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023/Speckle.Converters.Revit2023.csproj +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023/Speckle.Converters.Revit2023.csproj @@ -14,7 +14,6 @@ - diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/Speckle.Converters.Rhino7.DependencyInjection.csproj b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/Speckle.Converters.Rhino7.DependencyInjection.csproj index 9a3eea3b1b..468bb44e2a 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/Speckle.Converters.Rhino7.DependencyInjection.csproj +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/Speckle.Converters.Rhino7.DependencyInjection.csproj @@ -13,6 +13,7 @@ + diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Speckle.Converters.Rhino7.csproj b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Speckle.Converters.Rhino7.csproj index 589068a1bb..983d8dd791 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Speckle.Converters.Rhino7.csproj +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Speckle.Converters.Rhino7.csproj @@ -17,7 +17,6 @@ - diff --git a/DUI3-DX/Sdk/Speckle.Autofac/Speckle.Autofac.csproj b/DUI3-DX/Sdk/Speckle.Autofac/Speckle.Autofac.csproj index 4458fe63f7..876b654ae0 100644 --- a/DUI3-DX/Sdk/Speckle.Autofac/Speckle.Autofac.csproj +++ b/DUI3-DX/Sdk/Speckle.Autofac/Speckle.Autofac.csproj @@ -7,7 +7,7 @@ - + diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/Speckle.Converters.Common.DependencyInjection.csproj b/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/Speckle.Converters.Common.DependencyInjection.csproj index 51381f8c41..91a6988198 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/Speckle.Converters.Common.DependencyInjection.csproj +++ b/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/Speckle.Converters.Common.DependencyInjection.csproj @@ -5,11 +5,11 @@ enable enable - + - + - + diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common/Speckle.Converters.Common.csproj b/DUI3-DX/Sdk/Speckle.Converters.Common/Speckle.Converters.Common.csproj index a375df49cf..313a26cd6a 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common/Speckle.Converters.Common.csproj +++ b/DUI3-DX/Sdk/Speckle.Converters.Common/Speckle.Converters.Common.csproj @@ -6,6 +6,7 @@ + From 56747f8b80fbe1943868842c3fd118bd9aa64526 Mon Sep 17 00:00:00 2001 From: Jedd Morgan <45512892+JR-Morgan@users.noreply.github.com> Date: Tue, 30 Apr 2024 21:09:56 +0100 Subject: [PATCH 061/261] CNX-9173 resolve warning singular in rhino d ui3 dx connector (#3328) Made singleton pattern in null oblivious context --- .../Plugin/Speckle.Connectors.Rhino7Command.cs | 3 +++ .../Plugin/Speckle.Connectors.Rhino7Plugin.cs | 2 ++ .../Speckle.Connectors.Rhino7.csproj | 9 +-------- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Plugin/Speckle.Connectors.Rhino7Command.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Plugin/Speckle.Connectors.Rhino7Command.cs index 1a8e18fba9..6bfe6166a9 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Plugin/Speckle.Connectors.Rhino7Command.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Plugin/Speckle.Connectors.Rhino7Command.cs @@ -23,9 +23,12 @@ public SpeckleConnectorsRhino7Command() ); } +#nullable disable ///The only instance of this command. public static SpeckleConnectorsRhino7Command Instance { get; private set; } +#nullable enable + ///The command name as it appears on the Rhino command line. public override string EnglishName => "SpeckleNewUI"; diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Plugin/Speckle.Connectors.Rhino7Plugin.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Plugin/Speckle.Connectors.Rhino7Plugin.cs index 7c22fb836d..0fcc3e9121 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Plugin/Speckle.Connectors.Rhino7Plugin.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Plugin/Speckle.Connectors.Rhino7Plugin.cs @@ -32,9 +32,11 @@ public SpeckleConnectorsRhino7Plugin() Instance = this; } +#nullable disable ///Gets the only instance of the Speckle_Connectors_Rhino7Plugin plug-in. public static SpeckleConnectorsRhino7Plugin Instance { get; private set; } +#nullable enable // You can override methods here to change the plug-in behavior on // loading and shut down, add options pages to the Rhino _Option command // and maintain plug-in wide options in a document. diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Speckle.Connectors.Rhino7.csproj b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Speckle.Connectors.Rhino7.csproj index 263b217393..e7808a9f45 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Speckle.Connectors.Rhino7.csproj +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Speckle.Connectors.Rhino7.csproj @@ -6,14 +6,7 @@ true true - - - - $(WarningsNotAsErrors); - CS8618; - - - + From 0165b1b7fa83c90f1b8fcb4bb9e99fb0abbcfc3b Mon Sep 17 00:00:00 2001 From: Mucahit Bilal GOKER <51519350+bimgeek@users.noreply.github.com> Date: Wed, 1 May 2024 11:43:40 +0300 Subject: [PATCH 062/261] CNX-9375 remove load button from connector UI rvt (#3331) * Hide Load button Hid load button as Revit connector is publish only for the open alpha. * added POC at the beginning of comment --- .../DependencyInjection/AutofacUIModule.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/AutofacUIModule.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/AutofacUIModule.cs index bb8c923f64..877c842c4f 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/AutofacUIModule.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/AutofacUIModule.cs @@ -64,7 +64,8 @@ protected override void Load(ContainerBuilder builder) builder.RegisterType().As().SingleInstance(); builder.RegisterType().As().SingleInstance(); builder.RegisterType().As().SingleInstance(); - builder.RegisterType().As().SingleInstance(); + // POC: Hide Load button as Revit connector is publish only for the open alpha. + //builder.RegisterType().As().SingleInstance(); builder.RegisterType().As().SingleInstance(); // send operation and dependencies From 2e4ab392623c9868a5720ecc17251a99dea0ce31 Mon Sep 17 00:00:00 2001 From: Dimitrie Stefanescu Date: Wed, 1 May 2024 12:08:48 +0100 Subject: [PATCH 063/261] fix(dui3): removes rhino everything filter --- .../DependencyInjection/AutofacRhinoModule.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/AutofacRhinoModule.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/AutofacRhinoModule.cs index 4c69cb4501..84393bc84e 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/AutofacRhinoModule.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/AutofacRhinoModule.cs @@ -63,7 +63,6 @@ protected override void Load(ContainerBuilder builder) // register send filters builder.RegisterType().As().InstancePerDependency(); - builder.RegisterType().As().InstancePerDependency(); // register send operation and dependencies builder.RegisterType().As().InstancePerLifetimeScope(); From e2e56379431c660ba5e450de280c49fd46f0652c Mon Sep 17 00:00:00 2001 From: Dimitrie Stefanescu Date: Wed, 1 May 2024 12:22:52 +0100 Subject: [PATCH 064/261] fix(dui3): removes revit everything filter --- .../Speckle.Connectors.RevitShared/Bindings/SendBinding.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SendBinding.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SendBinding.cs index b2d778f7ad..2a092b79e5 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SendBinding.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SendBinding.cs @@ -50,7 +50,7 @@ IUnitOfWorkFactory unitOfWorkFactory public List GetSendFilters() { - return new List { new RevitEverythingFilter(), new RevitSelectionFilter() }; + return new List { new RevitSelectionFilter() { IsDefault = true } }; } public async Task Send(string modelCardId) From 3298e14167d28137b5a3065b9ff10254978ef422 Mon Sep 17 00:00:00 2001 From: Claire Kuang Date: Wed, 1 May 2024 06:09:34 -0700 Subject: [PATCH 065/261] feat(autocad): CNX 9327 autocad polycurve receive separate converters (#3329) * Separated autocad polycurve conversions * fixes polyline sending and receiving * adds polyline2d and polyline3d to host conversions * removes unnecessary segment direction code * Create lists with capacity * Throw first for polyline to host conversion * Fix ci --------- Co-authored-by: oguzhankoral --- .../Extensions/ListExtensions.cs | 40 +++++ ...Speckle.Converters.AutocadShared.projitems | 4 + .../AutocadPolycurveToHostConverter.cs | 49 +++++ ...adPolycurveToHostPolyline2dRawConverter.cs | 101 +++++++++++ ...adPolycurveToHostPolyline3dRawConverter.cs | 61 +++++++ ...ocadPolycurveToHostPolylineRawConverter.cs | 51 ++++++ .../Geometry/Polyline2dToSpeckleConverter.cs | 167 ++++++------------ .../Geometry/Polyline3dToSpeckleConverter.cs | 4 +- .../Geometry/PolylineToSpeckleConverter.cs | 17 +- .../Geometry/Autocad/AutocadPolycurve.cs | 14 +- 10 files changed, 376 insertions(+), 132 deletions(-) create mode 100644 DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/AutocadPolycurveToHostConverter.cs create mode 100644 DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/AutocadPolycurveToHostPolyline2dRawConverter.cs create mode 100644 DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/AutocadPolycurveToHostPolyline3dRawConverter.cs create mode 100644 DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/AutocadPolycurveToHostPolylineRawConverter.cs diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/Extensions/ListExtensions.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/Extensions/ListExtensions.cs index e38c372c62..6731f8f7fa 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/Extensions/ListExtensions.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/Extensions/ListExtensions.cs @@ -14,4 +14,44 @@ public static SOG.Polyline ConvertToSpecklePolyline(this List pointList, return new(pointList, speckleUnits); } + + public static List ConvertToPoint2d(this List pointList, double conversionFactor = 1) + { + // throw if list is malformed + if (pointList.Count % 2 != 0) + { + throw new System.ArgumentException("Point list of xy values is malformed."); + } + + List points2d = new(pointList.Count / 2); + for (int i = 1; i < pointList.Count; i += 2) + { + points2d.Add(new AG.Point2d(pointList[i - 1] * conversionFactor, pointList[i] * conversionFactor)); + } + + return points2d; + } + + public static List ConvertToPoint3d(this List pointList, double conversionFactor = 1) + { + // throw if list is malformed + if (pointList.Count % 3 != 0) + { + throw new System.ArgumentException("Point list of xyz values is malformed."); + } + + List points3d = new(pointList.Count / 3); + for (int i = 2; i < pointList.Count; i += 3) + { + points3d.Add( + new AG.Point3d( + pointList[i - 2] * conversionFactor, + pointList[i - 1] * conversionFactor, + pointList[i] * conversionFactor + ) + ); + } + + return points3d; + } } diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/Speckle.Converters.AutocadShared.projitems b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/Speckle.Converters.AutocadShared.projitems index 08d2ce1f0b..230a119880 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/Speckle.Converters.AutocadShared.projitems +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/Speckle.Converters.AutocadShared.projitems @@ -15,7 +15,11 @@ + + + + diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/AutocadPolycurveToHostConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/AutocadPolycurveToHostConverter.cs new file mode 100644 index 0000000000..fa7b5e3c58 --- /dev/null +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/AutocadPolycurveToHostConverter.cs @@ -0,0 +1,49 @@ +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; +using Speckle.Core.Models; + +namespace Speckle.Converters.Autocad2023.ToHost.Geometry; + +[NameAndRankValue(nameof(SOG.Autocad.AutocadPolycurve), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +public class AutocadPolycurveToHostConverter : ISpeckleObjectToHostConversion +{ + private readonly IRawConversion _polylineConverter; + private readonly IRawConversion _polyline2dConverter; + private readonly IRawConversion _polyline3dConverter; + + public AutocadPolycurveToHostConverter( + IRawConversion polylineConverter, + IRawConversion polyline2dConverter, + IRawConversion polyline3dConverter + ) + { + _polylineConverter = polylineConverter; + _polyline2dConverter = polyline2dConverter; + _polyline3dConverter = polyline3dConverter; + } + + public object Convert(Base target) + { + SOG.Autocad.AutocadPolycurve polycurve = (SOG.Autocad.AutocadPolycurve)target; + + switch (polycurve.polyType) + { + case SOG.Autocad.AutocadPolyType.Light: + return _polylineConverter.RawConvert(polycurve); + + case SOG.Autocad.AutocadPolyType.Simple2d: + case SOG.Autocad.AutocadPolyType.FitCurve2d: + case SOG.Autocad.AutocadPolyType.CubicSpline2d: + case SOG.Autocad.AutocadPolyType.QuadSpline2d: + return _polyline2dConverter.RawConvert(polycurve); + + case SOG.Autocad.AutocadPolyType.Simple3d: + case SOG.Autocad.AutocadPolyType.CubicSpline3d: + case SOG.Autocad.AutocadPolyType.QuadSpline3d: + return _polyline3dConverter.RawConvert(polycurve); + + default: + throw new SpeckleConversionException("Unknown poly type for AutocadPolycurve"); + } + } +} diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/AutocadPolycurveToHostPolyline2dRawConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/AutocadPolycurveToHostPolyline2dRawConverter.cs new file mode 100644 index 0000000000..718f20a9fa --- /dev/null +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/AutocadPolycurveToHostPolyline2dRawConverter.cs @@ -0,0 +1,101 @@ +using System.Collections.Generic; +using Speckle.Converters.Autocad.Extensions; +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; +using Speckle.Core.Kits; + +namespace Speckle.Converters.Autocad2023.ToHost.Raw; + +public class AutocadPolycurveToHostPolyline2dRawConverter : IRawConversion +{ + private readonly IRawConversion _vectorConverter; + private readonly IConversionContextStack _contextStack; + + public AutocadPolycurveToHostPolyline2dRawConverter( + IRawConversion vectorConverter, + IConversionContextStack contextStack + ) + { + _vectorConverter = vectorConverter; + _contextStack = contextStack; + } + + public ADB.Polyline2d RawConvert(SOG.Autocad.AutocadPolycurve target) + { + // check for normal + if (target.normal is not SOG.Vector normal) + { + throw new System.ArgumentException($"Autocad polycurve of type {target.polyType} did not have a normal"); + } + + // check for elevation + if (target.elevation is not double elevation) + { + throw new System.ArgumentException($"Autocad polycurve of type {target.polyType} did not have an elevation"); + } + + // get vertices + double f = Units.GetConversionFactor(target.units, _contextStack.Current.SpeckleUnits); + List points = target.value.ConvertToPoint3d(f); + + // check for invalid bulges + if (target.bulges is null || target.bulges.Count < points.Count) + { + throw new System.ArgumentException($"Autocad polycurve of type {target.polyType} had null or malformed bulges"); + } + + // check for invalid tangents + if (target.tangents is null || target.tangents.Count < points.Count) + { + throw new System.ArgumentException($"Autocad polycurve of type {target.polyType} had null or malformed tangents"); + } + + // create the polyline2d using the empty constructor + AG.Vector3d convertedNormal = _vectorConverter.RawConvert(normal); + double convertedElevation = elevation * f; + ADB.Polyline2d polyline = + new() + { + Elevation = convertedElevation, + Normal = convertedNormal, + Closed = target.closed + }; + + // add polyline2d to document + ADB.Transaction tr = _contextStack.Current.Document.TransactionManager.TopTransaction; + var btr = (ADB.BlockTableRecord) + tr.GetObject(_contextStack.Current.Document.Database.CurrentSpaceId, ADB.OpenMode.ForWrite); + btr.AppendEntity(polyline); + tr.AddNewlyCreatedDBObject(polyline, true); + + // append vertices + for (int i = 0; i < points.Count; i++) + { + ADB.Vertex2d vertex = new(points[i], target.bulges[i], 0, 0, target.tangents[i]); + polyline.AppendVertex(vertex); + tr.AddNewlyCreatedDBObject(vertex, true); + } + + // convert to polytype + ADB.Poly2dType polyType = ADB.Poly2dType.SimplePoly; + switch (target.polyType) + { + case SOG.Autocad.AutocadPolyType.FitCurve2d: + polyType = ADB.Poly2dType.FitCurvePoly; + break; + case SOG.Autocad.AutocadPolyType.CubicSpline2d: + polyType = ADB.Poly2dType.CubicSplinePoly; + break; + case SOG.Autocad.AutocadPolyType.QuadSpline2d: + polyType = ADB.Poly2dType.QuadSplinePoly; + break; + } + + if (polyType is not ADB.Poly2dType.SimplePoly) + { + polyline.ConvertToPolyType(polyType); + } + + return polyline; + } +} diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/AutocadPolycurveToHostPolyline3dRawConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/AutocadPolycurveToHostPolyline3dRawConverter.cs new file mode 100644 index 0000000000..95b0406006 --- /dev/null +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/AutocadPolycurveToHostPolyline3dRawConverter.cs @@ -0,0 +1,61 @@ +using Speckle.Converters.Autocad.Extensions; +using System.Collections.Generic; +using Speckle.Converters.Common.Objects; +using Speckle.Core.Kits; +using Speckle.Converters.Common; + +namespace Speckle.Converters.Autocad2023.ToHost.Raw; + +public class AutocadPolycurveToHostPolyline3dRawConverter : IRawConversion +{ + private readonly IConversionContextStack _contextStack; + + public AutocadPolycurveToHostPolyline3dRawConverter(IConversionContextStack contextStack) + { + _contextStack = contextStack; + } + + public ADB.Polyline3d RawConvert(SOG.Autocad.AutocadPolycurve target) + { + // get vertices + double f = Units.GetConversionFactor(target.units, _contextStack.Current.SpeckleUnits); + List points = target.value.ConvertToPoint3d(f); + + // create the polyline3d using the empty constructor + ADB.Polyline3d polyline = new() { Closed = target.closed }; + + // add polyline3d to document + ADB.Transaction tr = _contextStack.Current.Document.TransactionManager.TopTransaction; + var btr = (ADB.BlockTableRecord) + tr.GetObject(_contextStack.Current.Document.Database.CurrentSpaceId, ADB.OpenMode.ForWrite); + btr.AppendEntity(polyline); + tr.AddNewlyCreatedDBObject(polyline, true); + + // append vertices + for (int i = 0; i < points.Count; i++) + { + ADB.PolylineVertex3d vertex = new(points[i]); + polyline.AppendVertex(vertex); + tr.AddNewlyCreatedDBObject(vertex, true); + } + + // convert to polytype + ADB.Poly3dType polyType = ADB.Poly3dType.SimplePoly; + switch (target.polyType) + { + case SOG.Autocad.AutocadPolyType.CubicSpline3d: + polyType = ADB.Poly3dType.CubicSplinePoly; + break; + case SOG.Autocad.AutocadPolyType.QuadSpline3d: + polyType = ADB.Poly3dType.QuadSplinePoly; + break; + } + + if (polyType is not ADB.Poly3dType.SimplePoly) + { + polyline.ConvertToPolyType(polyType); + } + + return polyline; + } +} diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/AutocadPolycurveToHostPolylineRawConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/AutocadPolycurveToHostPolylineRawConverter.cs new file mode 100644 index 0000000000..e1b42e61cf --- /dev/null +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/AutocadPolycurveToHostPolylineRawConverter.cs @@ -0,0 +1,51 @@ +using System.Collections.Generic; +using Speckle.Converters.Autocad.Extensions; +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; +using Speckle.Core.Kits; + +namespace Speckle.Converters.Autocad2023.ToHost.Raw; + +public class AutocadPolycurveToHostPolylineRawConverter : IRawConversion +{ + private readonly IRawConversion _vectorConverter; + private readonly IConversionContextStack _contextStack; + + public AutocadPolycurveToHostPolylineRawConverter( + IRawConversion vectorConverter, + IConversionContextStack contextStack + ) + { + _vectorConverter = vectorConverter; + _contextStack = contextStack; + } + + public ADB.Polyline RawConvert(SOG.Autocad.AutocadPolycurve target) + { + if (target.normal is null || target.elevation is null) + { + throw new System.ArgumentException( + "Autocad polycurve of type light did not have a valid normal and/or elevation" + ); + } + + double f = Units.GetConversionFactor(target.units, _contextStack.Current.SpeckleUnits); + List points2d = target.value.ConvertToPoint2d(f); + + ADB.Polyline polyline = + new() + { + Normal = _vectorConverter.RawConvert(target.normal), + Elevation = (double)target.elevation * f, + Closed = target.closed + }; + + for (int i = 0; i < points2d.Count; i++) + { + var bulge = target.bulges is null ? 0 : target.bulges[i]; + polyline.AddVertexAt(i, points2d[i], bulge, 0, 0); + } + + return polyline; + } +} diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/Polyline2dToSpeckleConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/Polyline2dToSpeckleConverter.cs index 889018234b..e798ffa91f 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/Polyline2dToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/Polyline2dToSpeckleConverter.cs @@ -9,11 +9,11 @@ namespace Speckle.Converters.Autocad.Geometry; /// /// The class converter. Converts to . -/// of type will be converted as . /// /// /// of type will have only s and s in . -/// of type , and will have only one in . +/// of type will have only s in . +/// of type and will have only one in . /// The IHostObjectToSpeckleConversion inheritance should only expect database-resident objects. IRawConversion inheritance can expect non database-resident objects, when generated from other converters. /// [NameAndRankValue(nameof(ADB.Polyline2d), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] @@ -21,24 +21,27 @@ public class Polyline2dToSpeckleConverter : IHostObjectToSpeckleConversion { private readonly IRawConversion _arcConverter; private readonly IRawConversion _lineConverter; + private readonly IRawConversion _polylineConverter; private readonly IRawConversion _splineConverter; - private readonly IRawConversion _planeConverter; + private readonly IRawConversion _vectorConverter; private readonly IRawConversion _boxConverter; private readonly IConversionContextStack _contextStack; public Polyline2dToSpeckleConverter( IRawConversion arcConverter, IRawConversion lineConverter, + IRawConversion polylineConverter, IRawConversion splineConverter, - IRawConversion planeConverter, + IRawConversion vectorConverter, IRawConversion boxConverter, IConversionContextStack contextStack ) { _arcConverter = arcConverter; _lineConverter = lineConverter; + _polylineConverter = polylineConverter; _splineConverter = splineConverter; - _planeConverter = planeConverter; + _vectorConverter = vectorConverter; _boxConverter = boxConverter; _contextStack = contextStack; } @@ -47,19 +50,9 @@ public Polyline2dToSpeckleConverter( public SOG.Autocad.AutocadPolycurve RawConvert(ADB.Polyline2d target) { - // POC: Below check complicate things, and it is a destructive process. Why not we send it just as is? - // if this is a simple polyline2d, convert it is a lightweight polyline - // if (target.PolyType is Poly2dType.SimplePoly) - // { - // using (ADB.Polyline poly = new ADB.Polyline()) - // { - // poly.ConvertFrom(target, true); - // return _polylineConverter.RawConvert(poly); - // } - // } - // get the poly type var polyType = SOG.Autocad.AutocadPolyType.Unknown; + bool isSpline = false; switch (target.PolyType) { case ADB.Poly2dType.SimplePoly: @@ -70,9 +63,11 @@ public SOG.Autocad.AutocadPolycurve RawConvert(ADB.Polyline2d target) break; case ADB.Poly2dType.CubicSplinePoly: polyType = SOG.Autocad.AutocadPolyType.CubicSpline2d; + isSpline = true; break; case ADB.Poly2dType.QuadSplinePoly: polyType = SOG.Autocad.AutocadPolyType.QuadSpline2d; + isSpline = true; break; } @@ -85,6 +80,7 @@ public SOG.Autocad.AutocadPolycurve RawConvert(ADB.Polyline2d target) ADB.OpenMode.ForRead, _contextStack.Current.Document.TransactionManager.TopTransaction ) + .Where(e => e.VertexType != ADB.Vertex2dType.CurveFitVertex && e.VertexType != ADB.Vertex2dType.SplineFitVertex) // Do not collect fit vertex points, they are not used for creation .ToList(); for (int i = 0; i < vertices.Count; i++) @@ -94,84 +90,63 @@ public SOG.Autocad.AutocadPolycurve RawConvert(ADB.Polyline2d target) // get vertex value in the Global Coordinate System (GCS). value.AddRange(vertex.Position.ToArray()); - // get the bulge and tangent, and 3d point for displayvalue + // get the bulge and tangent bulges.Add(vertex.Bulge); tangents.Add(vertex.Tangent); - - // POC: check this data is necessary on receive! - // construct the spline curve segment - // switch (vertex.VertexType) - // { - // case Vertex2dType.CurveFitVertex: - // break; - // case Vertex2dType.SplineFitVertex: - // break; - // case Vertex2dType.SplineControlVertex: - // break; - // } } + // explode the polyline + // exploded segments will be the polyecurve segments for non-spline poly2ds, and the displayvalue for spline poly2ds + // NOTE: exploded segments may not be in order or in the correct direction List segments = new(); + List segmentValues = new(); + ADB.DBObjectCollection exploded = new(); + target.Explode(exploded); - // POC: retrieve spline display value here for database-resident polylines by connecting all vertex points - if (target.Database is not null) + for (int i = 0; i < exploded.Count; i++) { - var exploded = new ADB.DBObjectCollection(); - target.Explode(exploded); - AG.Point3d previousPoint = new(); - for (int i = 0; i < exploded.Count; i++) + if (exploded[i] is ADB.Curve segment) { - var segment = exploded[i] as ADB.Curve; - - if (segment == null) - { - continue; - } - - if (i == 0 && exploded.Count > 1) + // for splines, just store point values for display value creation + if (isSpline) { - // get the connection point to the next segment - this is necessary since imported polycurves might have segments in different directions - var nextSegment = exploded[i + 1] as ADB.Curve; - if (nextSegment == null) + segmentValues.AddRange(segment.StartPoint.ToArray()); + if (i == exploded.Count - 1) { - continue; + segmentValues.AddRange(segment.EndPoint.ToArray()); } - AG.Point3d connectionPoint = - nextSegment.StartPoint.IsEqualTo(segment.StartPoint) || nextSegment.StartPoint.IsEqualTo(segment.EndPoint) - ? nextSegment.StartPoint - : nextSegment.EndPoint; - - previousPoint = connectionPoint; - segment = GetCorrectSegmentDirection(segment, connectionPoint, true, out AG.Point3d _); } + // for non-splines, convert the curve and add to segments list else { - segment = GetCorrectSegmentDirection(segment, previousPoint, false, out previousPoint); - } - - switch (segment) - { - case ADB.Arc arc: - segments.Add(_arcConverter.RawConvert(arc)); - break; - case ADB.Line line: - segments.Add(_lineConverter.RawConvert(line)); - break; - case ADB.Spline spl: - segments.Add(_splineConverter.RawConvert(spl)); - break; + switch (segment) + { + case ADB.Arc arc: + segments.Add(_arcConverter.RawConvert(arc)); + break; + case ADB.Line line: + segments.Add(_lineConverter.RawConvert(line)); + break; + } } } } - // get the spline curve segment - // TODO: need to confirm that this retrieves the correct spline. We may need to construct the spline curve manually from vertex enumeration - // SOG.Curve spline = _splineConverter.RawConvert(target.Spline); - // spline.displayValue = value.ConvertToSpecklePolyline(_contextStack); + // for splines, convert the spline curve and display value and add to the segments list and + if (isSpline) + { + SOG.Curve spline = _splineConverter.RawConvert(target.Spline); + SOG.Polyline displayValue = segmentValues.ConvertToSpecklePolyline(_contextStack.Current.SpeckleUnits); + if (displayValue != null) + { + spline.displayValue = displayValue; + } - SOG.Plane plane = _planeConverter.RawConvert(target.GetPlane()); - SOG.Box bbox = _boxConverter.RawConvert(target.GeometricExtents); + segments.Add(spline); + } + SOG.Vector normal = _vectorConverter.RawConvert(target.Normal); + SOG.Box bbox = _boxConverter.RawConvert(target.GeometricExtents); SOG.Autocad.AutocadPolycurve polycurve = new() { @@ -179,7 +154,8 @@ public SOG.Autocad.AutocadPolycurve RawConvert(ADB.Polyline2d target) value = value, bulges = bulges, tangents = tangents, - plane = plane, + normal = normal, + elevation = target.Elevation, polyType = polyType, closed = target.Closed, length = target.Length, @@ -190,45 +166,4 @@ public SOG.Autocad.AutocadPolycurve RawConvert(ADB.Polyline2d target) return polycurve; } - - private ADB.Curve GetCorrectSegmentDirection( - ADB.Curve segment, - AG.Point3d connectionPoint, - bool isFirstSegment, - out AG.Point3d nextPoint - ) // note sometimes curve3d may not have endpoints - { - nextPoint = segment.EndPoint; - - // POC: will be reconsidered when we started back and forth testing on AutocadPolycurve https://spockle.atlassian.net/browse/CNX-9327 - if (connectionPoint == null) - { - return segment; - } - - bool reverseDirection; - if (isFirstSegment) - { - reverseDirection = segment.StartPoint.IsEqualTo(connectionPoint); - if (reverseDirection) - { - nextPoint = segment.StartPoint; - } - } - else - { - reverseDirection = !segment.StartPoint.IsEqualTo(connectionPoint); - if (reverseDirection) - { - nextPoint = segment.StartPoint; - } - } - - if (reverseDirection) - { - segment.ReverseCurve(); - } - - return segment; - } } diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/Polyline3dToSpeckleConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/Polyline3dToSpeckleConverter.cs index 39150ed55a..346a6f2729 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/Polyline3dToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/Polyline3dToSpeckleConverter.cs @@ -63,7 +63,7 @@ public SOG.Autocad.AutocadPolycurve RawConvert(ADB.Polyline3d target) ADB.OpenMode.ForRead, _contextStack.Current.Document.TransactionManager.TopTransaction ) - .Where(e => e.VertexType != ADB.Vertex3dType.ControlVertex) // Do not collect control points + .Where(e => e.VertexType != ADB.Vertex3dType.FitVertex) // Do not collect fit vertex points, they are not used for creation .ToList(); List segments = new(); @@ -90,7 +90,6 @@ public SOG.Autocad.AutocadPolycurve RawConvert(ADB.Polyline3d target) } // get the spline curve segment if this is a spline polyline3d - // TODO: need to confirm that this retrieves the correct spline. We may need to construct the spline curve manually from vertex enumeration if (polyType is not SOG.Autocad.AutocadPolyType.Simple3d) { // add first 3 coordinate to last for display value polyline for spline @@ -125,7 +124,6 @@ public SOG.Autocad.AutocadPolycurve RawConvert(ADB.Polyline3d target) polyType = polyType, closed = target.Closed, length = target.Length, - // area = target.Area, // POC: Polyline3d throws runtime error for get_Area() for sure bbox = bbox, units = _contextStack.Current.SpeckleUnits }; diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/PolylineToSpeckleConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/PolylineToSpeckleConverter.cs index 7ab614023c..472c47ae86 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/PolylineToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/PolylineToSpeckleConverter.cs @@ -19,21 +19,21 @@ public class PolylineToSpeckleConverter { private readonly IRawConversion _lineConverter; private readonly IRawConversion _arcConverter; - private readonly IRawConversion _planeConverter; + private readonly IRawConversion _vectorConverter; private readonly IRawConversion _boxConverter; private readonly IConversionContextStack _contextStack; public PolylineToSpeckleConverter( IRawConversion lineConverter, IRawConversion arcConverter, - IRawConversion planeConverter, + IRawConversion vectorConverter, IRawConversion boxConverter, IConversionContextStack contextStack ) { _lineConverter = lineConverter; _arcConverter = arcConverter; - _planeConverter = planeConverter; + _vectorConverter = vectorConverter; _boxConverter = boxConverter; _contextStack = contextStack; } @@ -65,13 +65,13 @@ public SOG.Autocad.AutocadPolycurve RawConvert(ADB.Polyline target) case SegmentType.Arc: segments.Add(_arcConverter.RawConvert(target.GetArcSegmentAt(i))); break; - // POC: commented out claire's exception here because it breaks the conversion seems unnecessarily.. TBD - // default: - // throw new InvalidOperationException("Polyline had an invalid segment of type Empty, Point, or Coincident."); + default: + // we are skipping segments of type Empty, Point, and Coincident + break; } } - SOG.Plane plane = _planeConverter.RawConvert(target.GetPlane()); + SOG.Vector normal = _vectorConverter.RawConvert(target.Normal); SOG.Box bbox = _boxConverter.RawConvert(target.GeometricExtents); SOG.Autocad.AutocadPolycurve polycurve = @@ -80,7 +80,8 @@ public SOG.Autocad.AutocadPolycurve RawConvert(ADB.Polyline target) segments = segments, value = value, bulges = bulges, - plane = plane, + normal = normal, + elevation = target.Elevation, polyType = SOG.Autocad.AutocadPolyType.Light, closed = target.Closed, length = target.Length, diff --git a/Objects/Objects/Geometry/Autocad/AutocadPolycurve.cs b/Objects/Objects/Geometry/Autocad/AutocadPolycurve.cs index c7a741fc0b..10bfa24d7d 100644 --- a/Objects/Objects/Geometry/Autocad/AutocadPolycurve.cs +++ b/Objects/Objects/Geometry/Autocad/AutocadPolycurve.cs @@ -7,7 +7,7 @@ namespace Objects.Geometry.Autocad; /// A curve that is comprised of line, arc and/or curve segments, representing the Autocad Polyline, Polyline2d, and Polyline3d classes. /// /// -/// will have only s and s in . +/// and types will have only s and s in . /// type will have only s in . /// type will only have s in . /// , , , and types will have only a single s in . @@ -23,7 +23,7 @@ public AutocadPolycurve() { } /// Gets or sets the raw coordinates of the vertices. /// /// - /// For Polylines, these are xy coordinates in the Object Coordinate System (OCS) of the . + /// For Polylines, these are xy coordinates in the Object Coordinate System (OCS)/>. /// For Polyline2d and Polyline3d types, these are xyz coordinates in the Global Coordinate System. fml. /// [DetachProperty, Chunkable(31250)] @@ -46,10 +46,14 @@ public AutocadPolycurve() { } public List? tangents { get; set; } /// - /// The plane of the Autocad Polyline or Polyline2d. Should be null for Polyline3d. + /// The normal of the plane of the Autocad Polyline or Polyline2d. Should be null for Polyline3d. /// - /// - public Plane? plane { get; set; } + public Vector? normal { get; set; } + + /// + /// The distance from the plane to the origin of the Autocad Polyline or Polyline2d. Should be null for Polyline3d. + /// + public double? elevation { get; set; } public AutocadPolyType polyType { get; set; } } From 77806b62bf35c1916c9ecd7257fc3a85134efa8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?O=C4=9Fuzhan=20Koral?= <45078678+oguzhankoral@users.noreply.github.com> Date: Wed, 1 May 2024 22:42:49 +0300 Subject: [PATCH 066/261] CNX-9378 Pass source app from RevitSettings (#3334) Pass source app from RevitSettings --- .../Operations/Send/RootObjectSender.cs | 7 +++++-- .../Plugin/RevitExternalApplication.cs | 3 ++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RootObjectSender.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RootObjectSender.cs index fe1560834d..6d1a303175 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RootObjectSender.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RootObjectSender.cs @@ -3,6 +3,7 @@ using Speckle.Core.Api; using System.Threading.Tasks; using System.Threading; +using Speckle.Connectors.Revit.Plugin; using Speckle.Core.Credentials; using Speckle.Core.Models; using Speckle.Core.Transports; @@ -16,10 +17,12 @@ namespace Speckle.Connectors.Revit.Operations.Send; internal class RootObjectSender : IRootObjectSender { private readonly Func _transportFactory; + private readonly RevitSettings _revitSettings; - public RootObjectSender(Func transportFactory) + public RootObjectSender(Func transportFactory, RevitSettings revitSettings) { _transportFactory = transportFactory; + _revitSettings = revitSettings; } public async Task Send( @@ -51,7 +54,7 @@ public async Task Send( { streamId = projectId, branchName = modelId, - sourceApplication = "Rhino", + sourceApplication = _revitSettings.HostSlug, // POC: These naming is a bit? objectId = sendResult.rootObjId }, ct diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitExternalApplication.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitExternalApplication.cs index 4dbbd2b182..884ba17751 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitExternalApplication.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitExternalApplication.cs @@ -39,7 +39,8 @@ public RevitExternalApplication() RevitVersionName = "2023", RevitButtonName = "Speckle DUI3 (DI)", RevitButtonText = "Revit Connector", - ModuleFolders = new string[] { Path.GetDirectoryName(typeof(RevitExternalApplication).Assembly.Location) } + ModuleFolders = new string[] { Path.GetDirectoryName(typeof(RevitExternalApplication).Assembly.Location) }, + HostSlug = "Revit" }; } From 972aa4228b9c35409ea701ee2aa131ca9026dcfd Mon Sep 17 00:00:00 2001 From: Dimitrie Stefanescu Date: Thu, 2 May 2024 10:15:10 +0100 Subject: [PATCH 067/261] fix(dui3): implements show dev tools --- .../Plugin/RevitPlugin.cs | 11 ++++++++--- .../DUI3ControlWebView.xaml.cs | 2 +- .../Speckle.Connectors.DUI/Bridge/BrowserBridge.cs | 8 +++++++- DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/IBridge.cs | 2 +- 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitPlugin.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitPlugin.cs index 575454b5c3..83cb83f865 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitPlugin.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitPlugin.cs @@ -102,13 +102,18 @@ private void RegisterPanelAndInitializePlugin() foreach (IBinding binding in _bindings.Select(x => x.Value)) { Debug.WriteLine(binding.Name); - binding.Parent.AssociateWithBinding(binding, _cefSharpPanel.Browser.ExecuteScriptAsync, _cefSharpPanel); + binding.Parent.AssociateWithBinding( + binding, + _cefSharpPanel.Browser.ExecuteScriptAsync, + _cefSharpPanel, + _cefSharpPanel.ShowDevTools + ); } _cefSharpPanel.Browser.IsBrowserInitializedChanged += (sender, e) => { - // POC dev tools - _cefSharpPanel.ShowDevTools(); + // Not needed now, as we should be able to correctly open dev tools via user interaction + // _cefSharpPanel.ShowDevTools(); foreach (IBinding binding in _bindings.Select(x => x.Value)) { diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI.WebView/DUI3ControlWebView.xaml.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI.WebView/DUI3ControlWebView.xaml.cs index ac2d17e51f..3e72c8ff26 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI.WebView/DUI3ControlWebView.xaml.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI.WebView/DUI3ControlWebView.xaml.cs @@ -34,7 +34,7 @@ private void OnInitialized(object? sender, CoreWebView2InitializationCompletedEv { foreach (IBinding binding in _bindings) { - binding.Parent.AssociateWithBinding(binding, ExecuteScriptAsyncMethod, Browser); + binding.Parent.AssociateWithBinding(binding, ExecuteScriptAsyncMethod, Browser, ShowDevToolsMethod); Browser.CoreWebView2.AddHostObjectToScript(binding.Name, binding.Parent); } } diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/BrowserBridge.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/BrowserBridge.cs index ba2e5ea341..276556a18e 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/BrowserBridge.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/BrowserBridge.cs @@ -83,7 +83,12 @@ public BrowserBridge(JsonSerializerSettings jsonSerializerSettings, ILoggerFacto _mainThreadContext = SynchronizationContext.Current; } - public void AssociateWithBinding(IBinding binding, Action scriptMethod, object browser) + public void AssociateWithBinding( + IBinding binding, + Action scriptMethod, + object browser, + Action showDevToolsAction + ) { // set via binding property to ensure explosion if already bound Binding = binding; @@ -93,6 +98,7 @@ public void AssociateWithBinding(IBinding binding, Action scriptMethod, _bindingType = binding.GetType(); BindingMethodCache = new Dictionary(); + ShowDevToolsAction = showDevToolsAction; // Note: we need to filter out getter and setter methods here because they are not really nicely // supported across browsers, hence the !method.IsSpecialName. diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/IBridge.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/IBridge.cs index 4d7914dc5a..19830605df 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/IBridge.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/IBridge.cs @@ -13,7 +13,7 @@ public interface IBridge // POC: documnetation comments string FrontendBoundName { get; } - void AssociateWithBinding(IBinding binding, Action scriptMethod, object browser); + void AssociateWithBinding(IBinding binding, Action scriptMethod, object browser, Action showDevToolsAction); /// /// This method is called by the Frontend bridge to understand what it can actually call. It should return the method names of the bindings that this bridge wraps around. From e31a0caaa7038113cfc9a1aed41037258f852402 Mon Sep 17 00:00:00 2001 From: BovineOx <73857041+BovineOx@users.noreply.github.com> Date: Thu, 2 May 2024 10:26:31 +0100 Subject: [PATCH 068/261] Cnx 9264 revit review and augment conversions remove any added we are not using (#3318) * ArcConverson Yes, all of this required to convert a #!%$ arc apparently! :oO compiles but so far untested * RevitSettings RevitSettings not injected * Ellipse Added conversion to ellipse, needs testing * Ellipse Using in CurveConversion * Actually... Now using * NurbsSpline Added NurbsSpline and RevitVersionConversionHelper if we find we need to add more specialisations at the conversion layer * HermiteSpline Hermite Spline conversion added * BoundingBoxXYZ and namespaces Adding BoundingBoxXYZ conversion and tidied some of new converter's namespaces * PointCloud Added point cloud * Circle conversion Circle conversion, Ronseal commit * Polyline Polyline support * Namespace tidy Namespace tidy * Corrected spelling Incorrect spelling for Nurbs - missed the s * Lifetimes and naming The naming was not committed it seems and I tweaked some lifetimes * PR Comments Fixed type, added POC for Arc that might not be a circle * Review comments * Change param name to target :P * Fixed a few unused variables from copy and paste * Fixed at least one uninitialised varb * Tweaks Mostly just tweaking types so that they are DId and discovered the same way :) * Testing Curve Converters + Func factory fix Some tweaks to test curves, adding ModelCurve (slightly bogus), also spotted Revit not working outside of debugger due to bogus Func<> factory usage, replaced with delegate pattern we may need to tweak/change * Fix compiler/build warnings Inconsistent object construction, expressions, etc... * Setting ApplicationId Now being set in one place for all elements! * Fixed ApplicationId & x64 ness Fixed ApplicationId & x64 ness * PR Comments Minor comments, mostly removing testing/debug code and * Unused namespaces Unused namespaces * Removing debug code --- .gitignore | 3 + Core/Core/Transports/ServerV2.cs | 4 + .../Operations/Send/RootObjectSender.cs | 12 ++- .../Speckle.Connectors.Revit2023.csproj | 1 - .../log20240501.txt | 8 ++ .../Bindings/SelectionBinding.cs | 3 + .../Operations/Send/RootObjectSender.cs | 9 +- .../Plugin/CefSharpPanel.xaml | 2 +- .../Plugin/RevitExternalApplication.cs | 11 +- .../Plugin/RevitPlugin.cs | 5 +- .../AutofacRevitConverterModule.cs | 16 ++- ...rters.Revit2023.DependencyInjection.csproj | 3 +- .../RevitVersionConversionHelper.cs | 19 ++++ .../Speckle.Converters.Revit2023.csproj | 2 +- .../Helpers/IRevitConversionContextStack.cs | 13 +++ .../Helpers/RevitConversionContextStack.cs | 4 +- .../IReferencePointConverter.cs | 6 ++ .../IRevitVersionConversionHelper.cs | 6 ++ .../Raw/Geometry/ArcToSpeckleConverter.cs | 59 ++++++++++ .../BoundingBoxXYZToSpeckleConverter.cs | 49 +++++++++ .../Raw/Geometry/CircleToSpeckleConverter.cs | 40 +++++++ .../Geometry/CurveArrayConversionToSpeckle.cs | 17 ++- .../Raw/Geometry/CurveConversionToSpeckle.cs | 48 ++++----- .../Raw/Geometry/EllipseToSpeckleConverter.cs | 45 ++++++++ .../HermiteSplineToSpeckleConverter.cs | 19 ++++ .../Raw/Geometry/LineConversionToSpeckle.cs | 6 +- .../Geometry/NurbsSplineToSpeckleConverter.cs | 56 ++++++++++ .../Raw/Geometry/PlaneToSpeckleConverter.cs | 32 ++++++ .../Geometry/PointCloudToSpeckleConverter.cs | 47 ++++++++ .../Raw/Geometry/PointConversionToSpeckle.cs | 5 +- .../Geometry/PolylineToSpeckleConverter.cs | 25 +++++ .../Raw/Geometry/VectorToSpeckleConverter.cs | 33 ++++++ .../ReferencePointConverter.cs | 101 ++++++++++++++++++ .../RevitConversionSettings.cs | 19 ++++ .../RevitConverterToSpeckle.cs | 24 ++++- .../Services/ScalingServiceToSpeckle.cs | 4 + .../Speckle.Converters.RevitShared.projitems | 20 +++- .../ModelCurveToSpeckleTopLevelConverter.cs | 41 +++++++ .../Operations/RootObjectSender.cs | 2 + .../Speckle.Connectors.Utils.csproj | 4 - 40 files changed, 747 insertions(+), 76 deletions(-) create mode 100644 DUI3-DX/Connectors/Revit/Speckle.Connectors.Revit2023/log20240501.txt create mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023/RevitVersionConversionHelper.cs create mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/IRevitConversionContextStack.cs create mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/IReferencePointConverter.cs create mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/IRevitVersionConversionHelper.cs create mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/ArcToSpeckleConverter.cs create mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/BoundingBoxXYZToSpeckleConverter.cs create mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/CircleToSpeckleConverter.cs create mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/EllipseToSpeckleConverter.cs create mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/HermiteSplineToSpeckleConverter.cs create mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/NurbsSplineToSpeckleConverter.cs create mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/PlaneToSpeckleConverter.cs create mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/PointCloudToSpeckleConverter.cs create mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/PolylineToSpeckleConverter.cs create mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/VectorToSpeckleConverter.cs create mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ReferencePointConverter.cs create mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/RevitConversionSettings.cs create mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/ModelCurveToSpeckleTopLevelConverter.cs diff --git a/.gitignore b/.gitignore index 80e3955846..1775cb1c7d 100644 --- a/.gitignore +++ b/.gitignore @@ -341,6 +341,9 @@ ASALocalRun/ # MSBuild Binary and Structured Log *.binlog +# random logs +log*.txt + # NVidia Nsight GPU debugger configuration file *.nvuser diff --git a/Core/Core/Transports/ServerV2.cs b/Core/Core/Transports/ServerV2.cs index b949f59295..ff1baa2e76 100644 --- a/Core/Core/Transports/ServerV2.cs +++ b/Core/Core/Transports/ServerV2.cs @@ -16,6 +16,10 @@ namespace Speckle.Core.Transports; public sealed class ServerTransport : IDisposable, ICloneable, ITransport, IBlobCapableTransport { + // POC: autofac uses this to construct a factory in place if this delegate and this can then be injected and parameters passed + // this should, and I think can, come out of this class, because I think autofac does magic based on the return type + public delegate ITransport Factory(Account account, string streamId, int timeoutSeconds, string? blobStorageFolder); + private readonly object _elapsedLock = new(); private Exception? _exception; diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Send/RootObjectSender.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Send/RootObjectSender.cs index b2fd72c1c7..4d799d488d 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Send/RootObjectSender.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Send/RootObjectSender.cs @@ -14,10 +14,14 @@ namespace Speckle.Connectors.ArcGis.Operations.Send; /// internal sealed class RootObjectSender : IRootObjectSender { - // POC: Revisit this factory pattern, I think we could solve this higher up by injecting a scoped factory for `SendOperation` in the SendBinding - private readonly Func _transportFactory; + // POC: this is going off the concrete type which is not so great, though this is the example: + // see delegate factories: https://autofac.readthedocs.io/en/latest/advanced/delegate-factories.html + // I am pretty sure this delegate can be moved as I am sure Autofac looks at the return type and knows nothing + // about the class the factory is defined in + // this is binding us to the transport concrete type, so... that needs some thought + private readonly ServerTransport.Factory _transportFactory; - public RootObjectSender(Func transportFactory) + public RootObjectSender(ServerTransport.Factory transportFactory) { _transportFactory = transportFactory; } @@ -37,7 +41,7 @@ public async Task Send( Account account = AccountManager.GetAccount(accountId); - ITransport transport = _transportFactory(account, projectId); + ITransport transport = _transportFactory(account, projectId, 60, null); var sendResult = await SendHelper.Send(commitObject, transport, true, null, ct).ConfigureAwait(false); ct.ThrowIfCancellationRequested(); diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.Revit2023/Speckle.Connectors.Revit2023.csproj b/DUI3-DX/Connectors/Revit/Speckle.Connectors.Revit2023/Speckle.Connectors.Revit2023.csproj index 8c583a1c9e..23eb4324dc 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.Revit2023/Speckle.Connectors.Revit2023.csproj +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.Revit2023/Speckle.Connectors.Revit2023.csproj @@ -2,7 +2,6 @@ net48 x64 - win-x64 true enable diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.Revit2023/log20240501.txt b/DUI3-DX/Connectors/Revit/Speckle.Connectors.Revit2023/log20240501.txt new file mode 100644 index 0000000000..5fe0f44a0a --- /dev/null +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.Revit2023/log20240501.txt @@ -0,0 +1,8 @@ +2024-05-01 17:45:23.888 +01:00 [INF] Loaded assemblies: ["mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089","UIFrameworkInterop, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089","UIFramework, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","UIFrameworkServices, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","CefSharp.Wpf, Version=92.0.260.0, Culture=neutral, PublicKeyToken=40c4b6fc221f4138","CefSharp.Core, Version=92.0.260.0, Culture=neutral, PublicKeyToken=40c4b6fc221f4138","CefSharp, Version=92.0.260.0, Culture=neutral, PublicKeyToken=40c4b6fc221f4138","CefSharp.Core.Runtime, Version=92.0.260.0, Culture=neutral, PublicKeyToken=40c4b6fc221f4138","System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089","PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35","WindowsBase, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35","PresentationCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35","System.Xaml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089","System.Configuration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a","System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089","Xceed.Wpf.AvalonDock, Version=2.1.0.0, Culture=neutral, PublicKeyToken=3e4669d2f30244f4","Autodesk.UI.Themes, Version=3.0.0.0, Culture=neutral, PublicKeyToken=null","UIFrameworkRes, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","UIFrameworkRes.resources, Version=23.0.0.0, Culture=en-GB, PublicKeyToken=null","AdWindows, Version=4.0.0.6, Culture=neutral, PublicKeyToken=null","WindowsFormsIntegration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35","PresentationFramework.Aero2, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35","PresentationFramework-SystemXml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089","System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a","AdApplicationFrame, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null","AddInManagerUI, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089","System.Windows.Controls.Ribbon, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089","PresentationFramework.Aero, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35","PresentationFramework.Luna, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35","Microsoft.Expression.Interactions, Version=4.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35","UIAutomationTypes, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35","UIAutomationProvider, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35","PresentationFramework-SystemCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089","APIInterop, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","RevitAddInUtility, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","System.Xml.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089","PackageContentsParser, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null","RevitAPIFoundation, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","RevitAPIIFC, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","IntfIFCAPI, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","RevitDBAPI, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","RevitAPI, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","AddInManager, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","RevitDBCoreAPI, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","GraphicsAPI, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","UtilityAPI, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","GeomUtilAPI, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","RoomAreaPlanDBAPI, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","HostObjDBAPI, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","FamilyDBAPI, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","EssentialsDBAPI, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","ArrayElemsDBAPI, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","StructuralDBAPI, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","SculptingDBAPI, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","ElementGroupDBAPI, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","CurtainGridFamilyDBAPI, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","SiteDBAPI, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","DetailDBAPI, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","BuildingSystemsDBAPI, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","EnergyAnalysisDBAPI, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","ATFRevitCoreAPI, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","IntfATFAPI, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","MaterialDBAPI, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","InfrastructureDBAPI, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","AnalysisAppsDBAPI, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","StructuralAnalysisDBAPI, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","RebarDBAPI, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","AssemblyDBAPI, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","StairRampDBAPI, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","APIDBAPI, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","DPartDBAPI, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","PersistenceDBAPI, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","InterfaceUtilAPI, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","InterfaceAPI, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","TextEngineAPI, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","PointCloudAccessAPI, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","NumberingDBAPI, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","MassingDBAPI, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","Autodesk.ATFTranslationServer.DBApplication, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","Autodesk.CivilAlignments.DBApplication, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","Autodesk.CoordinationModelDB, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","Autodesk.Entitlement.Utilities, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","Autodesk.LightboxDB, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","Autodesk.LinkTopography.Parser, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","Autodesk.ResultsBuilder.DBApplication, Version=2023.0.0.0, Culture=neutral, PublicKeyToken=null","Autodesk.RouteAnalysis.DBApplication, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","Autodesk.SteelConnectionsDB, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","Autodesk.StructuralRibbon.Application, Version=2023.0.0.0, Culture=neutral, PublicKeyToken=null","ConnectedDesktopDB, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","KeynoteDBServer, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","Autodesk.MEP.SegmentCalculation.DBApplication, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","Autodesk.MEP.FittingCalculation.DBApplication, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","CollaborateDB, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","AXMImporter, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","RevitAPIExtData, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","Autodesk.CoordinationModel.NavisworksApplication, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null","LightboxCore, Version=2.0.12.0, Culture=neutral, PublicKeyToken=null","LightboxCoreImpl, Version=2.0.12.0, Culture=neutral, PublicKeyToken=null","Microsoft.GeneratedCode, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null","Simulex.Net, Version=2.2.0.5, Culture=neutral, PublicKeyToken=null","RevitAPISteel, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","ASSettings, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null","Microsoft.GeneratedCode, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null","StructuralAnalysisResults, Version=2.5.0.11305, Culture=neutral, PublicKeyToken=null","Autodesk.DesktopConnector.API, Version=7.4.0.296, Culture=neutral, PublicKeyToken=null","System.Runtime.Caching, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a","System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089","System.Runtime.Serialization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089","SMDiagnostics, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089","System.ServiceModel.Internals, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35","System.IdentityModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089","Autodesk.Bcg.Net, Version=8.1.3.0, Culture=neutral, PublicKeyToken=null","Microsoft.Practices.Unity, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35","System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a","Autodesk.Http, Version=14.4.0.0, Culture=neutral, PublicKeyToken=null","netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51","RSCloudClient, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","Autodesk.RevitServer.Management.Client, Version=8.1.1.0, Culture=neutral, PublicKeyToken=null","Autodesk.Bcg, Version=3.27.1.0, Culture=neutral, PublicKeyToken=null","System.Collections, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a","System.Reflection, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a","System.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a","System.Threading, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a","System.Globalization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a","System.Runtime.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a","System.Linq.Expressions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a","Microsoft.Practices.Unity.Configuration, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35","System.Reflection.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a","Anonymously Hosted DynamicMethods Assembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null","DBManagedServices, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","RSCloudClientRevitService, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","Autodesk.Bcg.Http, Version=4.1.0.0, Culture=neutral, PublicKeyToken=d672471c03b2c408","System.Net.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a","System.Net.Http.WebRequest, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a","System.Net.Http.Formatting, Version=5.2.9.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35","AddInJournaling, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","AddInJournalEngine, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","AddInJournalClient, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","FabricationPartBrowser, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","Autodesk.UI.Windows, Version=3.0.0.0, Culture=neutral, PublicKeyToken=null","RevitAPIUI, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","UserInterfaceUtility, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","Autodesk.RevitApplicationHome.Application, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","SSONET, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","CEFRevitUtils, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","CefSharp.Wpf.HwndHost, Version=92.0.260.0, Culture=neutral, PublicKeyToken=40c4b6fc221f4138","Autodesk.RevitApplicationHome.Utilities, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","APIUIAPI, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","DesktopMFCAPI, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","RevitMFCAPI, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","RevitUIAPI, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","BuildingSystemsUIAPI, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","EssentialsUIAPI, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","DetailUIAPI, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","Autodesk.CivilAlignments.Application, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","Autodesk.CoordinationModelUI, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","Autodesk.FreeFormRebar.DB, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","Autodesk.IFC.Export.UI, Version=23.3.1.0, Culture=neutral, PublicKeyToken=null","Autodesk.LightboxUI, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","Autodesk.LinkTopography.Commands.Application, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","Autodesk.LoadAutodeskFamily.Application, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","Autodesk.MemberForces.Application, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","Autodesk.Revit.Config.Client, Version=2.5.0.0, Culture=neutral, PublicKeyToken=null","Polly, Version=7.0.0.0, Culture=neutral, PublicKeyToken=c8a3ffc3f8f825cc","Autodesk.PnIDModeler.Application, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","Autodesk.PnIDModeler.Client, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","Autodesk.PnIDModeler.Application.resources, Version=23.0.0.0, Culture=en-GB, PublicKeyToken=null","Autodesk.PnIDModeler.Client.resources, Version=23.0.0.0, Culture=en-GB, PublicKeyToken=null","Autodesk.Precast.Application, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null","Autodesk.Precast.UI, Version=19.0.1.0, Culture=neutral, PublicKeyToken=null","Autodesk.Precast.RevitBase, Version=20.0.0.0, Culture=neutral, PublicKeyToken=null","Autodesk.Precast.Base, Version=20.0.0.0, Culture=neutral, PublicKeyToken=null","Autodesk.Precast.Localization, Version=20.0.0.0, Culture=neutral, PublicKeyToken=null","Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed","System.Numerics, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089","System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089","Autodesk.Precast.Localization.resources, Version=20.0.0.0, Culture=en-GB, PublicKeyToken=null","Autodesk.Precast.API, Version=20.0.0.0, Culture=neutral, PublicKeyToken=null","Autodesk.Precast.CNC, Version=20.0.0.0, Culture=neutral, PublicKeyToken=null","Autodesk.Precast.CNCExport, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null","Autodesk.Precast.Commands, Version=20.0.0.0, Culture=neutral, PublicKeyToken=null","Autodesk.Precast.Geometry, Version=20.0.0.0, Culture=neutral, PublicKeyToken=null","Autodesk.Precast.RevitGeometry, Version=20.0.0.0, Culture=neutral, PublicKeyToken=null","Autodesk.Precast.RevitUI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null","Autodesk.Precast.ShopDrawings, Version=20.0.0.0, Culture=neutral, PublicKeyToken=null","Autodesk.Precast.Slab, Version=20.0.0.0, Culture=neutral, PublicKeyToken=null","Autodesk.Precast.Wall, Version=20.0.0.0, Culture=neutral, PublicKeyToken=null","Autodesk.ReinforcementNumbering.Application, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","Autodesk.ResultsExplorer.Application, Version=2023.0.0.0, Culture=neutral, PublicKeyToken=null","Microsoft.CSharp, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a","Autodesk.RevisionsOnSheetUI, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","Autodesk.Revit.CloudRendering.Application, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","Autodesk.Revit.SharedViews.Application, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","Autodesk.RouteAnalysis.Application, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","Autodesk.SectionProperties.Application, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","Autodesk.SpaceNaming.Application, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","Autodesk.SteelConnectionsUI, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","DotNetRoots, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null","Autodesk.REX.Framework, Version=2023.0.0.0, Culture=neutral, PublicKeyToken=51e16e3b26b42eda","Autodesk.UnifiedParameters.Application, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","Autodesk.ViewSheetSetUI, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","AutoLoader, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","ConnectedDesktopUI, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","DynamoRevitVersionSelector, Version=2.16.2.9354, Culture=neutral, PublicKeyToken=null","DynamoInstallDetective, Version=2.16.2.5624, Culture=neutral, PublicKeyToken=null","DynamoRevitDS, Version=2.16.2.9354, Culture=neutral, PublicKeyToken=null","RevitServices, Version=2.16.2.9354, Culture=neutral, PublicKeyToken=null","Autodesk.DynamoPlayerForRevit.Application, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","DynamoPlayer, Version=1.0.32.0, Culture=neutral, PublicKeyToken=null","Autodesk.EnergyAnalysis.Application, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","Autodesk.MEP.FittingCalculationUI.Application, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","Autodesk.GenerativeDesignForRevit.Application, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","DynamoPlayerExtension, Version=1.0.32.0, Culture=neutral, PublicKeyToken=null","DynamoCore, Version=2.16.2.5624, Culture=neutral, PublicKeyToken=null","DynamoCoreWpf, Version=2.16.2.5624, Culture=neutral, PublicKeyToken=null","Microsoft.Practices.Prism, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35","vtortola.WebSockets.Rfc6455, Version=2.2.4.0, Culture=neutral, PublicKeyToken=7f78616efb4a208d","vtortola.WebSockets, Version=2.2.4.0, Culture=neutral, PublicKeyToken=7f78616efb4a208d","System.Threading.Tasks.Dataflow, Version=4.5.24.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a","System.Threading.Tasks, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a","System.Diagnostics.Tracing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a","KeynoteUIServer, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","PointCloudSnappingServer, Version=1.0.8640.25549, Culture=neutral, PublicKeyToken=null","Autodesk.MEP.PressureLossReport.Application, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","Autodesk.TwinmotionForRevit, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","Autodesk.BatchPrint.Application, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","Autodesk.BatchPrint.Utilities, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","Collaborate, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","CollaborateBrowser, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","SkyscraperClientHost, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","C4RNET, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","eTransmitForRevit, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","Autodesk.WorksharingMonitor.Application, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","Autodesk.WorksharingMonitor.Utilities, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","ExportViewSelectorAddin, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","FormItConverterRibbon, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","RFAToAXMAddon, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","FormItConverterRibbon.resources, Version=23.0.0.0, Culture=en-GB, PublicKeyToken=null","RhinoInside.Revit.AddIn, Version=1.16.8620.27572, Culture=neutral, PublicKeyToken=null","RhinoInside.Revit.External, Version=1.16.8620.27572, Culture=neutral, PublicKeyToken=null","RhinoInside.Revit, Version=1.16.8620.27572, Culture=neutral, PublicKeyToken=null","Microsoft.GeneratedCode, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null","Microsoft.GeneratedCode, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null","Microsoft.GeneratedCode, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null","Speckle.Connectors.Revit2023, Version=2.0.999.0, Culture=neutral, PublicKeyToken=null","Speckle.Autofac, Version=2.0.999.0, Culture=neutral, PublicKeyToken=null","Autofac, Version=5.2.0.0, Culture=neutral, PublicKeyToken=17863af14b0044da","SpeckleCore2, Version=2.0.999.0, Culture=neutral, PublicKeyToken=null","Microsoft.Bcl.AsyncInterfaces, Version=7.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51","System.Threading.Tasks.Extensions, Version=4.2.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51","Speckle.Connectors.DUI, Version=2.0.999.0, Culture=neutral, PublicKeyToken=null","Speckle.Newtonsoft.Json, Version=11.0.0.0, Culture=neutral, PublicKeyToken=null","Speckle.Connectors.Utils, Version=2.0.999.0, Culture=neutral, PublicKeyToken=null","System.ValueTuple, Version=4.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51","Speckle.Converters.Common.DependencyInjection, Version=2.0.999.0, Culture=neutral, PublicKeyToken=null","Speckle.Converters.Common, Version=2.0.999.0, Culture=neutral, PublicKeyToken=null","Speckle.Converters.Revit2023.DependencyInjection, Version=2.0.999.0, Culture=neutral, PublicKeyToken=null","Speckle.Converters.Revit2023, Version=2.0.999.0, Culture=neutral, PublicKeyToken=null","Objects, Version=2.0.999.0, Culture=neutral, PublicKeyToken=null","Speckle.Objects.Common, Version=2.0.999.0, Culture=neutral, PublicKeyToken=null","Serilog, Version=2.0.0.0, Culture=neutral, PublicKeyToken=24c2f752a8e58a10","GraphQL.Primitives, Version=6.0.0.0, Culture=neutral, PublicKeyToken=null","GraphQL.Client.Abstractions.Websocket, Version=6.0.0.0, Culture=neutral, PublicKeyToken=null","GraphQL.Client.Abstractions, Version=6.0.0.0, Culture=neutral, PublicKeyToken=null","Microsoft.Extensions.Logging.Abstractions, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60","Serilog.Sinks.File, Version=5.0.0.0, Culture=neutral, PublicKeyToken=24c2f752a8e58a10","Microsoft.Extensions.Logging, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60","Serilog.Extensions.Logging, Version=7.0.0.0, Culture=neutral, PublicKeyToken=24c2f752a8e58a10","Microsoft.Extensions.Options, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60","System.ComponentModel.Composition, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"] +2024-05-01 17:45:25.569 +01:00 [INF] Bridge bound to front end name testBinding +2024-05-01 17:45:25.927 +01:00 [INF] Bridge bound to front end name configBinding +2024-05-01 17:45:25.929 +01:00 [INF] Bridge bound to front end name accountsBinding +2024-05-01 17:45:25.932 +01:00 [INF] Bridge bound to front end name baseBinding +2024-05-01 17:45:25.935 +01:00 [INF] Bridge bound to front end name selectionBinding +2024-05-01 17:45:25.938 +01:00 [INF] Bridge bound to front end name sendBinding +2024-05-01 17:45:25.939 +01:00 [INF] Bridge bound to front end name receiveBinding diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SelectionBinding.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SelectionBinding.cs index 9d2f138aa6..6c4f9aa741 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SelectionBinding.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SelectionBinding.cs @@ -41,6 +41,9 @@ private void OnSelectionChanged() public SelectionInfo GetSelection() { + // POC: this was also being called on shutdown + // probably the bridge needs to be able to know if the plugin has been terminated + // also on termination the OnSelectionChanged event needs unwinding List els = _revitContext.UIApplication.ActiveUIDocument.Selection .GetElementIds() .Select(id => _revitContext.UIApplication.ActiveUIDocument.Document.GetElement(id)) diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RootObjectSender.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RootObjectSender.cs index 6d1a303175..40889e5d55 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RootObjectSender.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RootObjectSender.cs @@ -14,12 +14,13 @@ namespace Speckle.Connectors.Revit.Operations.Send; /// Default implementation of the which takes a and sends /// it to a server described by the parameters in the method /// -internal class RootObjectSender : IRootObjectSender +internal sealed class RootObjectSender : IRootObjectSender { - private readonly Func _transportFactory; + // POC: unsure about this factory pattern - a little weakly typed (being a Func) + private readonly ServerTransport.Factory _transportFactory; private readonly RevitSettings _revitSettings; - public RootObjectSender(Func transportFactory, RevitSettings revitSettings) + public RootObjectSender(ServerTransport.Factory transportFactory, RevitSettings revitSettings) { _transportFactory = transportFactory; _revitSettings = revitSettings; @@ -40,7 +41,7 @@ public async Task Send( Account account = AccountManager.GetAccount(accountId); - ITransport transport = _transportFactory(account, projectId); + ITransport transport = _transportFactory(account, projectId, 60, null); var sendResult = await SendHelper.Send(commitObject, transport, true, null, ct).ConfigureAwait(false); ct.ThrowIfCancellationRequested(); diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/CefSharpPanel.xaml b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/CefSharpPanel.xaml index d49e7abc30..34292d3ff8 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/CefSharpPanel.xaml +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/CefSharpPanel.xaml @@ -1,4 +1,4 @@ -) - ); + // POC: need to settle on the mechanism and location as to where we should register these services + containerBuilder.RegisterRawConversions(); containerBuilder.InjectNamedTypes(); containerBuilder.InjectNamedTypes(); } diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitPlugin.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitPlugin.cs index 575454b5c3..f8bac63a47 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitPlugin.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitPlugin.cs @@ -107,8 +107,11 @@ private void RegisterPanelAndInitializePlugin() _cefSharpPanel.Browser.IsBrowserInitializedChanged += (sender, e) => { - // POC dev tools + // POC: dev tools + // also this can be called when the panel is closing, we should exit early +#if DEBUG _cefSharpPanel.ShowDevTools(); +#endif foreach (IBinding binding in _bindings.Select(x => x.Value)) { diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/AutofacRevitConverterModule.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/AutofacRevitConverterModule.cs index 96468d1eba..a60a27a4a9 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/AutofacRevitConverterModule.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/AutofacRevitConverterModule.cs @@ -23,16 +23,28 @@ protected override void Load(ContainerBuilder builder) builder .RegisterType>() .As>() - .SingleInstance(); + .InstancePerLifetimeScope(); // POC: do we need ToSpeckleScalingService as is, do we need to interface it out? builder.RegisterType().AsSelf().InstancePerLifetimeScope(); - builder.RegisterType().AsSelf().InstancePerLifetimeScope(); + + // POC: the concrete type can come out if we remove all the reference to it + builder + .RegisterType() + .As() + .AsSelf() + .InstancePerLifetimeScope(); builder .RegisterType() .As>() .InstancePerLifetimeScope(); + + builder.RegisterType().As().InstancePerLifetimeScope(); + builder.RegisterType().AsSelf().InstancePerLifetimeScope(); + + builder.RegisterType().As().InstancePerLifetimeScope(); + builder.RegisterType().AsSelf().InstancePerLifetimeScope(); builder.RegisterType().AsSelf().InstancePerLifetimeScope(); builder.RegisterType().AsSelf().InstancePerLifetimeScope(); diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/Speckle.Converters.Revit2023.DependencyInjection.csproj b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/Speckle.Converters.Revit2023.DependencyInjection.csproj index 3969078db5..d61d522f4d 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/Speckle.Converters.Revit2023.DependencyInjection.csproj +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/Speckle.Converters.Revit2023.DependencyInjection.csproj @@ -1,9 +1,10 @@  - netstandard2.0 + net48 x64 enable + enable diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023/RevitVersionConversionHelper.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023/RevitVersionConversionHelper.cs new file mode 100644 index 0000000000..515c2e057f --- /dev/null +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023/RevitVersionConversionHelper.cs @@ -0,0 +1,19 @@ +using Speckle.Converters.RevitShared; + +namespace Speckle.Converters.Revit2023; + +public class RevitVersionConversionHelper : IRevitVersionConversionHelper +{ + public bool IsCurveClosed(DB.NurbSpline nurbsSpline) + { + try + { + return nurbsSpline.IsClosed; + } + catch (Autodesk.Revit.Exceptions.ApplicationException) + { + // POC: is this actually a good assumption? + return true; + } + } +} diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023/Speckle.Converters.Revit2023.csproj b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023/Speckle.Converters.Revit2023.csproj index 50e0c1f3c3..474fb6eadd 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023/Speckle.Converters.Revit2023.csproj +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023/Speckle.Converters.Revit2023.csproj @@ -1,7 +1,7 @@  - netstandard2.0 + net48 x64 enable enable diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/IRevitConversionContextStack.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/IRevitConversionContextStack.cs new file mode 100644 index 0000000000..af3e959715 --- /dev/null +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/IRevitConversionContextStack.cs @@ -0,0 +1,13 @@ +using Autodesk.Revit.DB; +using Speckle.Converters.Common; + +namespace Speckle.Converters.RevitShared.Helpers; + +[System.Diagnostics.CodeAnalysis.SuppressMessage( + "Naming", + "CA1711:Identifiers should not have incorrect suffix", + Justification = "See base class justification" +)] +// POC: so this should *probably* be Document and NOT UI.UIDocument, the former is Conversion centric +// and the latter is more for connector +public interface IRevitConversionContextStack : IConversionContextStack { } diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/RevitConversionContextStack.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/RevitConversionContextStack.cs index 45f9de91e0..9b20274ae0 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/RevitConversionContextStack.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/RevitConversionContextStack.cs @@ -10,7 +10,9 @@ namespace Speckle.Converters.RevitShared.Helpers; )] // POC: so this should *probably* be Document and NOT UI.UIDocument, the former is Conversion centric // and the latter is more for connector -public class RevitConversionContextStack : ConversionContextStack +public class RevitConversionContextStack + : ConversionContextStack, + IRevitConversionContextStack { public const double TOLERANCE = 0.0164042; // 5mm in ft diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/IReferencePointConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/IReferencePointConverter.cs new file mode 100644 index 0000000000..f526412336 --- /dev/null +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/IReferencePointConverter.cs @@ -0,0 +1,6 @@ +namespace Speckle.Converters.RevitShared; + +public interface IReferencePointConverter +{ + DB.XYZ ConvertToExternalCoordindates(DB.XYZ inbound, bool isPoint); +} diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/IRevitVersionConversionHelper.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/IRevitVersionConversionHelper.cs new file mode 100644 index 0000000000..18a593cbbd --- /dev/null +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/IRevitVersionConversionHelper.cs @@ -0,0 +1,6 @@ +namespace Speckle.Converters.RevitShared; + +public interface IRevitVersionConversionHelper +{ + bool IsCurveClosed(DB.NurbSpline nurbsSpline); +} diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/ArcToSpeckleConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/ArcToSpeckleConverter.cs new file mode 100644 index 0000000000..d6d1119312 --- /dev/null +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/ArcToSpeckleConverter.cs @@ -0,0 +1,59 @@ +using Objects.Primitive; +using Speckle.Converters.Common.Objects; +using Speckle.Converters.RevitShared.Helpers; +using Speckle.Converters.RevitShared.Services; + +namespace Speckle.Converters.RevitShared.ToSpeckle; + +public class ArcToSpeckleConverter : IRawConversion +{ + private readonly IRevitConversionContextStack _contextStack; + private readonly IRawConversion _xyzToPointConverter; + private readonly IRawConversion _planeConverter; + private readonly ScalingServiceToSpeckle _scalingService; + + public ArcToSpeckleConverter( + IRevitConversionContextStack contextStack, + IRawConversion xyzToPointConverter, + IRawConversion planeConverter, + ScalingServiceToSpeckle scalingService + ) + { + _contextStack = contextStack; + _xyzToPointConverter = xyzToPointConverter; + _planeConverter = planeConverter; + _scalingService = scalingService; + } + + public SOG.Arc RawConvert(DB.Arc target) + { + // see https://forums.autodesk.com/t5/revit-api-forum/how-to-retrieve-startangle-and-endangle-of-arc-object/td-p/7637128 + var arcPlane = DB.Plane.CreateByOriginAndBasis(target.Center, target.XDirection, target.YDirection); + DB.XYZ center = target.Center; + + DB.XYZ dir0 = (target.GetEndPoint(0) - center).Normalize(); + DB.XYZ dir1 = (target.GetEndPoint(1) - center).Normalize(); + + DB.XYZ start = target.Evaluate(0, true); + DB.XYZ end = target.Evaluate(1, true); + DB.XYZ mid = target.Evaluate(0.5, true); + + double startAngle = target.XDirection.AngleOnPlaneTo(dir0, target.Normal); + double endAngle = target.XDirection.AngleOnPlaneTo(dir1, target.Normal); + + return new SOG.Arc() + { + plane = _planeConverter.RawConvert(arcPlane), + radius = _scalingService.ScaleLength(target.Radius), + startAngle = startAngle, + endAngle = endAngle, + angleRadians = endAngle - startAngle, + units = _contextStack.Current.SpeckleUnits, + endPoint = _xyzToPointConverter.RawConvert(end), + startPoint = _xyzToPointConverter.RawConvert(start), + midPoint = _xyzToPointConverter.RawConvert(mid), + length = _scalingService.ScaleLength(target.Length), + domain = new Interval(target.GetEndParameter(0), target.GetEndParameter(1)) + }; + } +} diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/BoundingBoxXYZToSpeckleConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/BoundingBoxXYZToSpeckleConverter.cs new file mode 100644 index 0000000000..6117a58d45 --- /dev/null +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/BoundingBoxXYZToSpeckleConverter.cs @@ -0,0 +1,49 @@ +using Objects.Primitive; +using Speckle.Converters.Common.Objects; +using Speckle.Converters.RevitShared.Helpers; + +namespace Speckle.Converters.RevitShared.ToSpeckle; + +public class BoundingBoxXYZToSpeckleConverter : IRawConversion +{ + private readonly IRevitConversionContextStack _contextStack; + private readonly IRawConversion _xyzToPointConverter; + private readonly IRawConversion _planeConverter; + + public BoundingBoxXYZToSpeckleConverter( + IRevitConversionContextStack contextStack, + IRawConversion xyzToPointConverter, + IRawConversion planeConverter + ) + { + _contextStack = contextStack; + _xyzToPointConverter = xyzToPointConverter; + _planeConverter = planeConverter; + } + + public SOG.Box RawConvert(DB.BoundingBoxXYZ target) + { + // convert min and max pts to speckle first + var min = _xyzToPointConverter.RawConvert(target.Min); + var max = _xyzToPointConverter.RawConvert(target.Max); + + // get the base plane of the bounding box from the transform + var transform = target.Transform; + var plane = DB.Plane.CreateByOriginAndBasis( + transform.Origin, + transform.BasisX.Normalize(), + transform.BasisY.Normalize() + ); + + var box = new SOG.Box() + { + xSize = new Interval(min.x, max.x), + ySize = new Interval(min.y, max.y), + zSize = new Interval(min.z, max.z), + basePlane = _planeConverter.RawConvert(plane), + units = _contextStack.Current.SpeckleUnits + }; + + return box; + } +} diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/CircleToSpeckleConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/CircleToSpeckleConverter.cs new file mode 100644 index 0000000000..cd37f03088 --- /dev/null +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/CircleToSpeckleConverter.cs @@ -0,0 +1,40 @@ +using Speckle.Converters.Common.Objects; +using Speckle.Converters.RevitShared.Helpers; +using Speckle.Converters.RevitShared.Services; + +namespace Speckle.Converters.RevitShared.ToSpeckle; + +public class CircleToSpeckleConverter : IRawConversion +{ + private readonly IRevitConversionContextStack _contextStack; + private readonly IRawConversion _planeConverter; + private readonly ScalingServiceToSpeckle _scalingService; + + public CircleToSpeckleConverter( + IRevitConversionContextStack contextStack, + IRawConversion planeConverter, + ScalingServiceToSpeckle scalingService + ) + { + _contextStack = contextStack; + _planeConverter = planeConverter; + _scalingService = scalingService; + } + + public SOG.Circle RawConvert(DB.Arc target) + { + // POC: should we check for arc of 360 and throw? Original CircleToSpeckle did not do this. + + // see https://forums.autodesk.com/t5/revit-api-forum/how-to-retrieve-startangle-and-endangle-of-arc-object/td-p/7637128 + var arcPlane = DB.Plane.CreateByNormalAndOrigin(target.Normal, target.Center); + var c = new SOG.Circle() + { + plane = _planeConverter.RawConvert(arcPlane), + radius = _scalingService.ScaleLength(target.Radius), + units = _contextStack.Current.SpeckleUnits, + length = _scalingService.ScaleLength(target.Length) + }; + + return c; + } +} diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/CurveArrayConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/CurveArrayConversionToSpeckle.cs index f286e47828..a4d5f4fc67 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/CurveArrayConversionToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/CurveArrayConversionToSpeckle.cs @@ -26,16 +26,15 @@ public CurveArrayConversionToSpeckle( public Polycurve RawConvert(CurveArray target) { - Polycurve polycurve = new(); - List curves = target.Cast().ToList(); - polycurve.units = _contextStack.Current.SpeckleUnits; - polycurve.closed = - curves.First().GetEndPoint(0).DistanceTo(curves.Last().GetEndPoint(1)) < RevitConversionContextStack.TOLERANCE; - polycurve.length = _scalingService.ScaleLength(curves.Sum(x => x.Length)); - - polycurve.segments.AddRange(curves.Select(x => _curveConverter.RawConvert(x))); - return polycurve; + return new Polycurve() + { + units = _contextStack.Current.SpeckleUnits, + closed = + curves.First().GetEndPoint(0).DistanceTo(curves.Last().GetEndPoint(1)) < RevitConversionContextStack.TOLERANCE, + length = _scalingService.ScaleLength(curves.Sum(x => x.Length)), + segments = curves.Select(x => _curveConverter.RawConvert(x)).ToList() + }; } } diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/CurveConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/CurveConversionToSpeckle.cs index 44900b6208..ec60b6e0ac 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/CurveConversionToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/CurveConversionToSpeckle.cs @@ -6,41 +6,41 @@ namespace Speckle.Converters.RevitShared.ToSpeckle; public class CurveConversionToSpeckle : IRawConversion { - // POC: can we do this sort of thing? - // Can this converter be made generic to make a ConverterFetcher? and be used - // whenever we have some ambiguity as to the specific converter we need to call? - // IIndex> _curveConverters; - private readonly IRawConversion _lineConverter; + private readonly IRawConversion _arcConverter; + private readonly IRawConversion _circleConverter; + private readonly IRawConversion _ellipseConverter; + private readonly IRawConversion _nurbsConverter; + private readonly IRawConversion _hermiteConverter; // POC: should this be ICurve? - //private readonly IRawConversion _arcConverter; - //private readonly IRawConversion _ellipseConverter; - //private readonly IRawConversion _nurbsConverter; - //private readonly IRawConversion _hermiteConverter; - - public CurveConversionToSpeckle(IRawConversion lineConverter) + public CurveConversionToSpeckle( + IRawConversion lineConverter, + IRawConversion arcConverter, + IRawConversion circleConverter, + IRawConversion ellipseConverter, + IRawConversion nurbsConverter, + IRawConversion hermiteConverter + ) { _lineConverter = lineConverter; + _arcConverter = arcConverter; + _circleConverter = circleConverter; + _ellipseConverter = ellipseConverter; + _nurbsConverter = nurbsConverter; + _hermiteConverter = hermiteConverter; } public ICurve RawConvert(DB.Curve target) { - // POC: and then here: - // if (_curveConverters.TryGetValue(target.GetType().Name, out IRawConversion converter)) - // { - // return converter.RawConvert(target); - // } - // - // throw ... - return target switch { DB.Line line => _lineConverter.RawConvert(line), - // POC: these conversions are "coming soon" can we use IIndex with variance with nice injection - //DB.Arc arc => _arcConverter.RawConvert(arc), - //DB.Ellipse ellipse => _ellipseConverter.RawConvert(ellipse), - //DB.NurbSpline nurbs => _nurbsConverter.RawConvert(nurbs), - //DB.HermiteSpline hermite => _hermiteConverter.RawConvert(hermite), + // POC: are maybe arc.IsCyclic ? + DB.Arc arc => arc.IsClosed ? _circleConverter.RawConvert(arc) : _arcConverter.RawConvert(arc), + DB.Ellipse ellipse => _ellipseConverter.RawConvert(ellipse), + DB.NurbSpline nurbs => _nurbsConverter.RawConvert(nurbs), + DB.HermiteSpline hermite => _hermiteConverter.RawConvert(hermite), + _ => throw new SpeckleConversionException($"Unsupported curve type {target.GetType()}") }; } diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/EllipseToSpeckleConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/EllipseToSpeckleConverter.cs new file mode 100644 index 0000000000..e41d373c4e --- /dev/null +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/EllipseToSpeckleConverter.cs @@ -0,0 +1,45 @@ +using Objects.Primitive; +using Speckle.Converters.Common.Objects; +using Speckle.Converters.RevitShared.Helpers; +using Speckle.Converters.RevitShared.Services; + +namespace Speckle.Converters.RevitShared.ToSpeckle; + +public class EllipseToSpeckleConverter : IRawConversion +{ + private readonly IRevitConversionContextStack _contextStack; + private readonly IRawConversion _planeConverter; + private readonly ScalingServiceToSpeckle _scalingService; + + public EllipseToSpeckleConverter( + IRevitConversionContextStack contextStack, + IRawConversion planeConverter, + ScalingServiceToSpeckle scalingService + ) + { + _contextStack = contextStack; + _planeConverter = planeConverter; + _scalingService = scalingService; + } + + public SOG.Ellipse RawConvert(DB.Ellipse target) + { + using (DB.Plane basePlane = DB.Plane.CreateByOriginAndBasis(target.Center, target.XDirection, target.YDirection)) + { + var trim = target.IsBound ? new Interval(target.GetEndParameter(0), target.GetEndParameter(1)) : null; + + return new SOG.Ellipse() + { + plane = _planeConverter.RawConvert(basePlane), + // POC: scale length correct? seems right? + firstRadius = _scalingService.ScaleLength(target.RadiusX), + secondRadius = _scalingService.ScaleLength(target.RadiusY), + // POC: original EllipseToSpeckle() method was setting this twice + domain = new Interval(0, 1), + trimDomain = trim, + length = _scalingService.ScaleLength(target.Length), + units = _contextStack.Current.SpeckleUnits + }; + } + } +} diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/HermiteSplineToSpeckleConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/HermiteSplineToSpeckleConverter.cs new file mode 100644 index 0000000000..a25569a03e --- /dev/null +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/HermiteSplineToSpeckleConverter.cs @@ -0,0 +1,19 @@ +using Speckle.Converters.Common.Objects; + +namespace Speckle.Converters.RevitShared.ToSpeckle; + +public class HerminteSplitToSpeckleConverter : IRawConversion +{ + private readonly IRawConversion _splineConverter; + + public HerminteSplitToSpeckleConverter(IRawConversion splineConverter) + { + _splineConverter = splineConverter; + } + + public SOG.Curve RawConvert(DB.HermiteSpline target) + { + var nurbs = DB.NurbSpline.Create(target); + return _splineConverter.RawConvert(nurbs); + } +} diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/LineConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/LineConversionToSpeckle.cs index f568f1ea08..847be282a5 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/LineConversionToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/LineConversionToSpeckle.cs @@ -22,9 +22,8 @@ ScalingServiceToSpeckle scalingService _scalingService = scalingService; } - public SOG.Line RawConvert(DB.Line target) - { - return new() + public SOG.Line RawConvert(DB.Line target) => + new() { units = _contextStack.Current.SpeckleUnits, start = _xyzToPointConverter.RawConvert(target.GetEndPoint(0)), @@ -32,5 +31,4 @@ public SOG.Line RawConvert(DB.Line target) domain = new Interval(target.GetEndParameter(0), target.GetEndParameter(1)), length = _scalingService.ScaleLength(target.Length) }; - } } diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/NurbsSplineToSpeckleConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/NurbsSplineToSpeckleConverter.cs new file mode 100644 index 0000000000..8a8015b6de --- /dev/null +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/NurbsSplineToSpeckleConverter.cs @@ -0,0 +1,56 @@ +using Objects.Primitive; +using Speckle.Converters.Common.Objects; +using Speckle.Converters.RevitShared.Helpers; +using Speckle.Converters.RevitShared.Services; + +namespace Speckle.Converters.RevitShared.ToSpeckle; + +public class NurbsSplineToSpeckleConverter : IRawConversion +{ + private readonly IRevitVersionConversionHelper _conversionHelper; + private readonly IRevitConversionContextStack _contextStack; + private readonly IRawConversion _xyzToPointConverter; + private readonly ScalingServiceToSpeckle _scalingService; + + public NurbsSplineToSpeckleConverter( + IRevitVersionConversionHelper conversionHelper, + IRevitConversionContextStack contextStack, + IRawConversion xyzToPointConverter, + ScalingServiceToSpeckle scalingService + ) + { + _conversionHelper = conversionHelper; + _contextStack = contextStack; + _xyzToPointConverter = xyzToPointConverter; + _scalingService = scalingService; + } + + public SOG.Curve RawConvert(DB.NurbSpline target) + { + var units = _contextStack.Current.SpeckleUnits; + + var points = new List(); + foreach (var p in target.CtrlPoints) + { + var point = _xyzToPointConverter.RawConvert(p); + points.AddRange(new List { point.x, point.y, point.z }); + } + + var coords = target.Tessellate().SelectMany(xyz => _xyzToPointConverter.RawConvert(xyz).ToList()).ToList(); + + return new SOG.Curve() + { + weights = target.Weights.Cast().ToList(), + points = points, + knots = target.Knots.Cast().ToList(), + degree = target.Degree, + //speckleCurve.periodic = revitCurve.Period; // POC: already commented out, remove? + rational = target.isRational, + closed = _conversionHelper.IsCurveClosed(target), + units = units, + domain = new Interval(target.GetEndParameter(0), target.GetEndParameter(1)), + length = _scalingService.ScaleLength(target.Length), + displayValue = new SOG.Polyline(coords, units) + }; + } +} diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/PlaneToSpeckleConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/PlaneToSpeckleConverter.cs new file mode 100644 index 0000000000..82fb38a004 --- /dev/null +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/PlaneToSpeckleConverter.cs @@ -0,0 +1,32 @@ +using Speckle.Converters.Common.Objects; +using Speckle.Converters.RevitShared.Helpers; + +namespace Speckle.Converters.RevitShared.ToSpeckle; + +public class PlaneToSpeckleConverter : IRawConversion +{ + private readonly IRevitConversionContextStack _contextStack; + private readonly IRawConversion _xyzToPointConverter; + private readonly IRawConversion _xyzToVectorConverter; + + public PlaneToSpeckleConverter( + IRevitConversionContextStack contextStack, + IRawConversion xyzToPointConverter, + IRawConversion xyzToVectorConverter + ) + { + _contextStack = contextStack; + _xyzToPointConverter = xyzToPointConverter; + _xyzToVectorConverter = xyzToVectorConverter; + } + + public SOG.Plane RawConvert(DB.Plane target) + { + var origin = _xyzToPointConverter.RawConvert(target.Origin); + var normal = _xyzToVectorConverter.RawConvert(target.Normal); + var xdir = _xyzToVectorConverter.RawConvert(target.XVec); + var ydir = _xyzToVectorConverter.RawConvert(target.YVec); + + return new SOG.Plane(origin, normal, xdir, ydir, _contextStack.Current.SpeckleUnits); + } +} diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/PointCloudToSpeckleConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/PointCloudToSpeckleConverter.cs new file mode 100644 index 0000000000..9f20289b53 --- /dev/null +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/PointCloudToSpeckleConverter.cs @@ -0,0 +1,47 @@ +using Speckle.Converters.Common.Objects; +using Speckle.Converters.RevitShared.Helpers; + +namespace Speckle.Converters.RevitShared.ToSpeckle; + +public class PointCloudToSpeckleConverter : IRawConversion +{ + private readonly IRevitConversionContextStack _contextStack; + private readonly IRawConversion _xyzToPointConverter; + private readonly IRawConversion _boundingBoxConverter; + + public PointCloudToSpeckleConverter( + IRevitConversionContextStack contextStack, + IRawConversion xyzToPointConverter, + IRawConversion boundingBoxConverter + ) + { + _contextStack = contextStack; + _xyzToPointConverter = xyzToPointConverter; + _boundingBoxConverter = boundingBoxConverter; + } + + public SOG.Pointcloud RawConvert(DB.PointCloudInstance target) + { + var boundingBox = target.get_BoundingBox(null); + using DB.Transform transform = target.GetTransform(); + { + var minPlane = DB.Plane.CreateByNormalAndOrigin(DB.XYZ.BasisZ, transform.OfPoint(boundingBox.Min)); + var filter = DB.PointClouds.PointCloudFilterFactory.CreateMultiPlaneFilter(new List() { minPlane }); + var points = target.GetPoints(filter, 0.0001, 999999); // max limit is 1 mil but 1000000 throws error + + // POC: complaining about nullability + var specklePointCloud = new SOG.Pointcloud + { + points = points + .Select(o => _xyzToPointConverter.RawConvert(transform.OfPoint(o))) + .SelectMany(o => new List() { o.x, o.y, o.z }) + .ToList(), + colors = points.Select(o => o.Color).ToList(), + units = _contextStack.Current.SpeckleUnits, + bbox = _boundingBoxConverter.RawConvert(boundingBox) + }; + + return specklePointCloud; + } + } +} diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/PointConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/PointConversionToSpeckle.cs index 4e9c4efe6e..349383fa43 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/PointConversionToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/PointConversionToSpeckle.cs @@ -11,8 +11,5 @@ public PointConversionToSpeckle(IRawConversion xyzToPointConv _xyzToPointConverter = xyzToPointConverter; } - public SOG.Point RawConvert(DB.Point target) - { - return _xyzToPointConverter.RawConvert(target.Coord); - } + public SOG.Point RawConvert(DB.Point target) => _xyzToPointConverter.RawConvert(target.Coord); } diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/PolylineToSpeckleConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/PolylineToSpeckleConverter.cs new file mode 100644 index 0000000000..785ee1faf7 --- /dev/null +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/PolylineToSpeckleConverter.cs @@ -0,0 +1,25 @@ +using Speckle.Converters.Common.Objects; +using Speckle.Converters.RevitShared.Helpers; + +namespace Speckle.Converters.RevitShared.ToSpeckle; + +public class PolylineToSpeckleConverter : IRawConversion +{ + private readonly IRevitConversionContextStack _contextStack; + private readonly IRawConversion _xyzToPointConverter; + + public PolylineToSpeckleConverter( + IRevitConversionContextStack contextStack, + IRawConversion xyzToPointConverter + ) + { + _contextStack = contextStack; + _xyzToPointConverter = xyzToPointConverter; + } + + public SOG.Polyline RawConvert(DB.PolyLine target) + { + var coords = target.GetCoordinates().SelectMany(coord => _xyzToPointConverter.RawConvert(coord).ToList()).ToList(); + return new SOG.Polyline(coords, _contextStack.Current.SpeckleUnits); + } +} diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/VectorToSpeckleConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/VectorToSpeckleConverter.cs new file mode 100644 index 0000000000..e9b8d7e77a --- /dev/null +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/VectorToSpeckleConverter.cs @@ -0,0 +1,33 @@ +using Speckle.Converters.Common.Objects; +using Speckle.Converters.RevitShared.Services; + +namespace Speckle.Converters.RevitShared.ToSpeckle; + +public class VectorToSpeckleConverter : IRawConversion +{ + private readonly IReferencePointConverter _referencePointConverter; + private readonly ScalingServiceToSpeckle _scalingService; + + public VectorToSpeckleConverter( + IReferencePointConverter referencePointConverter, + ScalingServiceToSpeckle scalingService + ) + { + _referencePointConverter = referencePointConverter; + _scalingService = scalingService; + } + + public SOG.Vector RawConvert(DB.XYZ target) + { + // POC: originally had a concept of not transforming, but this was + // optional arg defaulting to false - removing the argument appeared to break nothing + DB.XYZ extPt = _referencePointConverter.ConvertToExternalCoordindates(target, false); + var pointToSpeckle = new SOG.Vector( + _scalingService.ScaleLength(extPt.X), + _scalingService.ScaleLength(extPt.Y), + _scalingService.ScaleLength(extPt.Z) + ); + + return pointToSpeckle; + } +} diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ReferencePointConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ReferencePointConverter.cs new file mode 100644 index 0000000000..89e4e35b80 --- /dev/null +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ReferencePointConverter.cs @@ -0,0 +1,101 @@ +using Speckle.Converters.RevitShared.Helpers; + +namespace Speckle.Converters.RevitShared; + +// POC: this could perhaps becomes some RevitDocumentService but also... +// This reference point feature needs review. We could do with knowing whether this feature is widely used. +// there's also some bogus disposal happening +// https://spockle.atlassian.net/browse/CNX-9357 +public class ReferencePointConverter : IReferencePointConverter +{ + // POC: probably not the best place for this + private const string REFPOINT_INTERNAL_ORIGIN = "Internal Origin (default)"; + private const string REFPOINT_PROJECT_BASE = "Project Base"; + private const string REFPOINT_SURVEY = "Survey"; + + private readonly RevitConversionSettings _revitSettings; + private readonly IRevitConversionContextStack _contextStack; + + private readonly Dictionary _docTransforms = new(); + + public ReferencePointConverter(IRevitConversionContextStack contextStack, RevitConversionSettings revitSettings) + { + _contextStack = contextStack; + _revitSettings = revitSettings; + } + + // POC: the original allowed for the document to be passed in + // if required, we would probably need to push the stack with a new document if the + // doc can change during the lifeycycle of the conversions. This may need some looking into + public DB.XYZ ConvertToExternalCoordindates(DB.XYZ inbound, bool isPoint) + { + var rpt = GetDocReferencePointTransform(_contextStack.Current.Document.Document); + return isPoint ? rpt.OfPoint(inbound) : rpt.OfVector(inbound); + } + + // POC: this might be better in some RevitDocumentService + // we could probably return that instance instead of the Doc from the context, maybe... + public DB.Transform GetDocReferencePointTransform(DB.Document doc) + { + //linked files are always saved to disc and will have a path name + //if the current doc is unsaved it will not, but then it'll be the only one :) + var id = doc.PathName; + + if (!_docTransforms.ContainsKey(id)) + { + // get from settings + var referencePointSetting = _revitSettings.TryGetSettingString("reference-point", out string value) + ? value + : string.Empty; + _docTransforms[id] = GetReferencePointTransform(referencePointSetting); + } + + return _docTransforms[id]; + } + + public DB.Transform GetReferencePointTransform(string referencePointSetting) + { + // first get the main doc base points and reference setting transform + var referencePointTransform = DB.Transform.Identity; + + // POC: bogus disposal below +#pragma warning disable CA2000 + var points = new DB.FilteredElementCollector(_contextStack.Current.Document.Document) + .OfClass(typeof(DB.BasePoint)) + .Cast() + .ToList(); +#pragma warning restore CA2000 + + var projectPoint = points.FirstOrDefault(o => o.IsShared == false); + var surveyPoint = points.FirstOrDefault(o => o.IsShared); + + // POC: it's not clear what support is needed for this + switch (referencePointSetting) + { + case REFPOINT_PROJECT_BASE: // note that the project base (ui) rotation is registered on the survey pt, not on the base point + referencePointTransform = DB.Transform.CreateTranslation(projectPoint.Position); + break; + + case REFPOINT_SURVEY: + // note that the project base (ui) rotation is registered on the survey pt, not on the base point + // retrieve the survey point rotation from the project point + + // POC: should a null angle resolve to 0? + var angle = projectPoint.get_Parameter(DB.BuiltInParameter.BASEPOINT_ANGLETON_PARAM)?.AsDouble() ?? 0; + + // POC: following disposed incorrectly or early or maybe a false negative? +#pragma warning disable CA2000 + referencePointTransform = DB.Transform + .CreateTranslation(surveyPoint.Position) + .Multiply(DB.Transform.CreateRotation(DB.XYZ.BasisZ, angle)); +#pragma warning restore CA2000 + + break; + + case REFPOINT_INTERNAL_ORIGIN: + break; + } + + return referencePointTransform; + } +} diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/RevitConversionSettings.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/RevitConversionSettings.cs new file mode 100644 index 0000000000..3fb4466120 --- /dev/null +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/RevitConversionSettings.cs @@ -0,0 +1,19 @@ +namespace Speckle.Converters.RevitShared; + +// POC: probably NOT the right place, probably needs passing in with the send/rcv operation +// not clear how this should get configured or if we should have it, the shape probably needs to change +// this was dragged in because it (or something like it) is required for reference point conversion. +// have made it a strongly typed thing encapsulating a dictionary so as not to rely on injecting a weak type. +// relates to https://spockle.atlassian.net/browse/CNX-9357 +public class RevitConversionSettings +{ + private Dictionary Settings { get; } = new Dictionary(); + + public bool TryGetSettingString(string key, out string value) => Settings.TryGetValue(key, out value); + + public string this[string key] + { + get => Settings[key]; + set => Settings[key] = value; + } +} diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/RevitConverterToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/RevitConverterToSpeckle.cs index 735fd5e4e8..b93623f2b9 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/RevitConverterToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/RevitConverterToSpeckle.cs @@ -1,7 +1,6 @@ using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; using Speckle.Core.Models; -using Autodesk.Revit.DB; using Speckle.Autofac.DependencyInjection; using Speckle.Converters.RevitShared.Helpers; @@ -29,7 +28,7 @@ ParameterValueExtractor parameterValueExtractor // if it cannot be converted then we should throw public Base Convert(object target) { - var objectConverter = _toSpeckle.ResolveInstance(target.GetType().Name); + var objectConverter = GetConversionForObject(target.GetType()); if (objectConverter == null) { @@ -41,12 +40,31 @@ public Base Convert(object target) ?? throw new SpeckleConversionException($"Conversion of object with type {target.GetType()} returned null"); // POC : where should logic common to most objects go? - if (target is Element element) + // shouldn't target ALWAYS be DB.Element? + if (target is DB.Element element) { _convertedObjectsCache.AddConvertedBase(element.UniqueId, result); _parameterValueExtractor.RemoveUniqueId(element.UniqueId); + + // POC: is this the right place? + result.applicationId = element.UniqueId; } return result; } + + private IHostObjectToSpeckleConversion? GetConversionForObject(Type objectType) + { + if (objectType == typeof(object)) + { + return null; + } + + if (_toSpeckle.ResolveInstance(objectType.Name) is IHostObjectToSpeckleConversion conversion) + { + return conversion; + } + + return GetConversionForObject(objectType.BaseType); + } } diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Services/ScalingServiceToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Services/ScalingServiceToSpeckle.cs index f8fd48d46e..d036ff33c5 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Services/ScalingServiceToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Services/ScalingServiceToSpeckle.cs @@ -19,6 +19,10 @@ public ScalingServiceToSpeckle(RevitConversionContextStack contextStack) _defaultLengthConversionFactor = ScaleStatic(1, lengthUnitsTypeId); } + // POC: throughout Revit conversions there's lots of comparison to check the units are valid + // atm we seem to be expecting that this is correct and that the scaling will be fixed for the duration + // of a conversion, but... I have some concerns that the units and the conversion may change, for instance, for linked documents? + // this needs to be considered and perahps scaling should be part of the context, or at least part of the IRevitConversionContextStack public double ScaleLength(double length) => length * _defaultLengthConversionFactor; // POC: not sure about this??? diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Speckle.Converters.RevitShared.projitems b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Speckle.Converters.RevitShared.projitems index 894e9a9289..e15e585274 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Speckle.Converters.RevitShared.projitems +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Speckle.Converters.RevitShared.projitems @@ -1,4 +1,4 @@ - + $(MSBuildAllProjects);$(MSBuildThisFileFullPath) @@ -9,29 +9,44 @@ Speckle.Converters.RevitShared + + + + + + + + + + + - + + + + + @@ -45,7 +60,6 @@ - \ No newline at end of file diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/ModelCurveToSpeckleTopLevelConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/ModelCurveToSpeckleTopLevelConverter.cs new file mode 100644 index 0000000000..25094cb0e9 --- /dev/null +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/ModelCurveToSpeckleTopLevelConverter.cs @@ -0,0 +1,41 @@ +using Objects; +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; +using Speckle.Converters.RevitShared.Helpers; + +namespace Speckle.Converters.RevitShared.ToSpeckle; + +// POC: ModelCurve looks a bit bogus and we may wish to revise what that is and how it inherits +// see https://spockle.atlassian.net/browse/CNX-9381 +[NameAndRankValue(nameof(DB.ModelCurve), 0)] +public class ModelCurveToSpeckleTopLevelConverter : BaseConversionToSpeckle +{ + private readonly IRawConversion _curveConverter; + private readonly IRevitConversionContextStack _conversionContext; + + public ModelCurveToSpeckleTopLevelConverter( + IRawConversion curveConverter, + IRevitConversionContextStack conversionContext + ) + { + _curveConverter = curveConverter; + _conversionContext = conversionContext; + } + + public override SOBR.Curve.ModelCurve RawConvert(DB.ModelCurve target) + { + var modelCurve = new SOBR.Curve.ModelCurve() + { + baseCurve = _curveConverter.RawConvert(target.GeometryCurve), + lineStyle = target.LineStyle.Name, + elementId = target.Id.ToString(), + units = _conversionContext.Current.SpeckleUnits + }; + + // POC: check this is not going to set the display value to anything we cannot actually display - i.e. polycurve + // also we have a class for doing this, but probably this is fine for now. see https://spockle.atlassian.net/browse/CNX-9381 + modelCurve["@displayValue"] = modelCurve.baseCurve; + + return modelCurve; + } +} diff --git a/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/RootObjectSender.cs b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/RootObjectSender.cs index 576a83a71c..cfa87c429c 100644 --- a/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/RootObjectSender.cs +++ b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/RootObjectSender.cs @@ -13,6 +13,8 @@ namespace Speckle.Connectors.Utils.Operations; /// Default implementation of the which takes a and sends /// it to a server described by the parameters in the method /// +/// POC: we have a generic RootObjectSender but we're not using it everywhere. It also appears to need some specialisation or at least +/// a way to get the application name, so RevitContext is being used in the revit version but we could probably inject that as a IHostAppContext maybe? public sealed class RootObjectSender : IRootObjectSender { // POC: Revisit this factory pattern, I think we could solve this higher up by injecting a scoped factory for `SendOperation` in the SendBinding diff --git a/DUI3-DX/Sdk/Speckle.Connectors.Utils/Speckle.Connectors.Utils.csproj b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Speckle.Connectors.Utils.csproj index 30518ea302..1582a2b5e4 100644 --- a/DUI3-DX/Sdk/Speckle.Connectors.Utils/Speckle.Connectors.Utils.csproj +++ b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Speckle.Connectors.Utils.csproj @@ -9,8 +9,4 @@ - - - - From 667ddf3296cbe42a139fb299830c81862eae87c8 Mon Sep 17 00:00:00 2001 From: Alan Rynne Date: Thu, 2 May 2024 12:22:03 +0200 Subject: [PATCH 069/261] CNX-9220 Revit Room to Speckle support (#3330) * feat: Added Revit Room to Speckle converter * fix: Addressed minor comments by Connor --- .../Raw/BoundarySegmentConversionToSpeckle.cs | 36 ++++++++++ .../Speckle.Converters.RevitShared.projitems | 2 + .../ToSpeckle/RoomConversionToSpeckle.cs | 70 +++++++++++++++++++ 3 files changed, 108 insertions(+) create mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/BoundarySegmentConversionToSpeckle.cs create mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/RoomConversionToSpeckle.cs diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/BoundarySegmentConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/BoundarySegmentConversionToSpeckle.cs new file mode 100644 index 0000000000..faebfe4a2b --- /dev/null +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/BoundarySegmentConversionToSpeckle.cs @@ -0,0 +1,36 @@ +using Objects; +using Speckle.Converters.Common.Objects; + +namespace Speckle.Converters.RevitShared.ToSpeckle; + +public class BoundarySegmentConversionToSpeckle : IRawConversion, SOG.Polycurve> +{ + private readonly IRawConversion _curveConverter; + + public BoundarySegmentConversionToSpeckle(IRawConversion curveConverter) + { + _curveConverter = curveConverter; + } + + public SOG.Polycurve RawConvert(IList target) + { + if (target.Count == 0) + { + throw new ArgumentException("Input Boundary segment list must at least have 1 segment"); + } + + var poly = new SOG.Polycurve(); + foreach (var segment in target) + { + DB.Curve revitCurve = segment.GetCurve(); + var curve = _curveConverter.RawConvert(revitCurve); + + // POC: We used to attach the `elementID` of every curve in a PolyCurve as a dynamic property. + // We've removed this as it seemed unnecessary. + + poly.segments.Add(curve); + } + + return poly; + } +} diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Speckle.Converters.RevitShared.projitems b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Speckle.Converters.RevitShared.projitems index e15e585274..accc5ce2c1 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Speckle.Converters.RevitShared.projitems +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Speckle.Converters.RevitShared.projitems @@ -19,6 +19,7 @@ + @@ -46,6 +47,7 @@ + diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/RoomConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/RoomConversionToSpeckle.cs new file mode 100644 index 0000000000..c5767f9b86 --- /dev/null +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/RoomConversionToSpeckle.cs @@ -0,0 +1,70 @@ +using Objects; +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; +using Speckle.Converters.RevitShared.Helpers; +using Speckle.Core.Models; +using DBA = Autodesk.Revit.DB.Architecture; +using SOBE = Objects.BuiltElements; + +namespace Speckle.Converters.RevitShared.ToSpeckle; + +[NameAndRankValue(nameof(DBA.Room), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +public class RoomConversionToSpeckle : BaseConversionToSpeckle +{ + private readonly DisplayValueExtractor _displayValueExtractor; + private readonly ParameterObjectAssigner _parameterObjectAssigner; + private readonly IRawConversion _levelConverter; + private readonly ParameterValueExtractor _parameterValueExtractor; + private readonly IRawConversion _locationConverter; + private readonly IRawConversion, SOG.Polycurve> _boundarySegmentConverter; + + public RoomConversionToSpeckle( + DisplayValueExtractor displayValueExtractor, + ParameterObjectAssigner parameterObjectAssigner, + IRawConversion levelConverter, + ParameterValueExtractor parameterValueExtractor, + IRawConversion locationConverter, + IRawConversion, SOG.Polycurve> boundarySegmentConverter + ) + { + _displayValueExtractor = displayValueExtractor; + _parameterObjectAssigner = parameterObjectAssigner; + _levelConverter = levelConverter; + _parameterValueExtractor = parameterValueExtractor; + _locationConverter = locationConverter; + _boundarySegmentConverter = boundarySegmentConverter; + } + + public override SOBE.Room RawConvert(DBA.Room target) + { + var number = target.Number; + var name = _parameterValueExtractor.GetValueAsString(target, DB.BuiltInParameter.ROOM_NAME); + var area = _parameterValueExtractor.GetValueAsDouble(target, DB.BuiltInParameter.ROOM_AREA); + + var displayValue = _displayValueExtractor.GetDisplayValue(target); + var basePoint = (SOG.Point)_locationConverter.RawConvert(target.Location); + var level = _levelConverter.RawConvert(target.Level); + + var profiles = target + .GetBoundarySegments(new DB.SpatialElementBoundaryOptions()) + .Select(c => (ICurve)_boundarySegmentConverter.RawConvert(c)) + .ToList(); + + var outline = profiles.First(); + var voids = profiles.Skip(1).ToList(); + + var speckleRoom = new SOBE.Room(name ?? "-", number, level, basePoint) + { + displayValue = displayValue, + area = area ?? 0, + outline = outline, + voids = voids + }; + + _parameterObjectAssigner.AssignParametersToBase(target, speckleRoom); + + // POC: Removed dynamic property `phaseCreated` as it seems the info is included in the parameters already + + return speckleRoom; + } +} From 103542ee2f0129470061d386a77da423bdaed622 Mon Sep 17 00:00:00 2001 From: Dimitrie Stefanescu Date: Thu, 2 May 2024 11:57:26 +0100 Subject: [PATCH 070/261] fix(dui3): simplifies highlight objects logic based off un-propagated changes in /dev --- .../Bindings/BasicConnectorBindingRevit.cs | 40 ------------------- 1 file changed, 40 deletions(-) diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/BasicConnectorBindingRevit.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/BasicConnectorBindingRevit.cs index 3b697e2b30..b291118c76 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/BasicConnectorBindingRevit.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/BasicConnectorBindingRevit.cs @@ -113,46 +113,6 @@ public void HighlightModel(string modelCardId) { activeUIDoc.Selection.SetElementIds(elementIds); activeUIDoc.ShowElements(elementIds); - - // Create a BoundingBoxXYZ to encompass the selected elements - BoundingBoxXYZ selectionBoundingBox = new(); - bool first = true; - - foreach (ElementId elementId in elementIds) - { - Element element = doc.GetElement(elementId); - - if (element != null) - { - BoundingBoxXYZ elementBoundingBox = element.get_BoundingBox(null); - - if (elementBoundingBox != null) - { - if (first) - { - selectionBoundingBox = elementBoundingBox; - first = false; - } - else - { - // selectionBoundingBox.Min = XYZ.Min(selectionBoundingBox.Min, elementBoundingBox.Min); - // selectionBoundingBox.Max = XYZ.Max(selectionBoundingBox.Max, elementBoundingBox.Max); - } - } - } - } - - // Zoom the view to the selection bounding box - if (!first) - { - View activeView = activeUIDoc.ActiveView; - - using Transaction tr = new(doc, "Zoom to Selection"); - tr.Start(); - activeView.CropBox = selectionBoundingBox; - doc.Regenerate(); - tr.Commit(); - } }); } From 4f661d63c6bdfe89468ba472756faf6e1118c554 Mon Sep 17 00:00:00 2001 From: Jedd Morgan <45512892+JR-Morgan@users.noreply.github.com> Date: Thu, 2 May 2024 12:14:39 +0100 Subject: [PATCH 071/261] CNX-9219 CNX-9336 CNX-9218 Traversal unification + ACAD/Rhino Fallback conversion (#3327) * Poc traversal change * first pass autocad * Layer path poc * Moved some stuff * feat: Update traversal with new `ShouldReturn` rule function This controls if an object matching a rule should be yielded back or not. * feat: change traverse with path to return fixed array * feat: GraphTraversal in Rhino Compatible with the old traversal for comparison * feat: Added fallback conversion for displayable objects in Rhino * fix: Do not redraw while baking (for now) No need to skip Collections in typesAreKing traversal WriteLine if purge layer failed for now * feat: Perf Optimisation of NurbsToHost converter * commented out brep repair call * fix: Minor fixes * Brought in Repair call again and throw if Brep is invalid. Invalid breps will not be baked, so this will be more noticable. * feat: MInor POC comment * Jedds Changes (#3313) * Jedds Changes * xml fix * Fixed erronious change * Moved displayValue fallback logic to shared place * Autocad * feat: inject graph traversal in rhino * fix: Unnecessary using * fix: Goodbye traversalComparitor * fix: Split converter into 2 classes * fix: Unnecesary using... * chore: Add POC comment in tohost converters --------- Co-authored-by: Alan Rynne --- Core/Core/Models/Extensions/BaseExtensions.cs | 13 +- .../Models/GraphTraversal/DefaultTraversal.cs | 133 +++++++++++------- .../Models/GraphTraversal/GraphTraversal.cs | 7 +- .../Models/GraphTraversal/ITraversalRule.cs | 26 ++-- .../Core/Models/GraphTraversal/RuleBuilder.cs | 32 ++++- .../TraversalContextExtensions.cs | 47 +++++++ .../TraversalContextExtensionsTests.cs | 50 +++++++ .../Operations/Receive/HostObjectBuilder.cs | 4 +- .../AutofacAutocadModule.cs | 2 + .../Operations/Receive/HostObjectBuilder.cs | 53 ++++--- .../DependencyInjection/AutofacRhinoModule.cs | 2 + .../Receive/RhinoHostObjectBuilder.cs | 93 +++++++++--- .../AutofacAutocadConverterModule.cs | 3 +- .../AutocadConverterToHost.cs | 49 ------- ...Speckle.Converters.AutocadShared.projitems | 2 +- .../SpeckleFallbackToHostConversion.cs | 48 +++++++ .../AutofacRhinoConverterModule.cs | 4 +- .../Raw/SpeckleBrepRawToHostConversion.cs | 9 +- .../Raw/SpeckleNurbsCurveToHostConversion.cs | 17 +-- .../ToHost/RhinoConverterToHost.cs | 31 ---- .../SpeckleFallbackToHostConversion.cs | 46 ++++++ ...nverters.Common.DependencyInjection.csproj | 1 + .../ToHost/ToHostConverterWithFallback.cs | 71 ++++++++++ .../ToHost/ToHostConverterWithoutFallback.cs | 41 ++++++ .../DisplayableObject.cs | 35 +++++ Objects/Objects/Interfaces.cs | 4 +- 26 files changed, 602 insertions(+), 221 deletions(-) create mode 100644 Core/Core/Models/GraphTraversal/TraversalContextExtensions.cs create mode 100644 Core/Tests/Speckle.Core.Tests.Unit/Models/GraphTraversal/TraversalContextExtensionsTests.cs delete mode 100644 DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/AutocadConverterToHost.cs create mode 100644 DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/SpeckleFallbackToHostConversion.cs delete mode 100644 DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/RhinoConverterToHost.cs create mode 100644 DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/SpeckleFallbackToHostConversion.cs create mode 100644 DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/ToHost/ToHostConverterWithFallback.cs create mode 100644 DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/ToHost/ToHostConverterWithoutFallback.cs create mode 100644 DUI3-DX/Sdk/Speckle.Converters.Common/DisplayableObject.cs diff --git a/Core/Core/Models/Extensions/BaseExtensions.cs b/Core/Core/Models/Extensions/BaseExtensions.cs index aba338b602..d919d120c5 100644 --- a/Core/Core/Models/Extensions/BaseExtensions.cs +++ b/Core/Core/Models/Extensions/BaseExtensions.cs @@ -193,19 +193,19 @@ public static bool IsDisplayableObject(this Base speckleObject) return speckleObject.TryGetDisplayValue() != null; } - public static IEnumerable? TryGetDisplayValue(this Base obj) + public static IReadOnlyList? TryGetDisplayValue(this Base obj) where T : Base { var rawDisplayValue = obj["displayValue"] ?? obj["@displayValue"]; return rawDisplayValue switch { T b => new List { b }, - IEnumerable enumerable => enumerable.OfType(), + IReadOnlyList list => list, _ => null }; } - public static IEnumerable? TryGetDisplayValue(this Base obj) + public static IReadOnlyList? TryGetDisplayValue(this Base obj) { return TryGetDisplayValue(obj); } @@ -232,10 +232,7 @@ public static bool IsDisplayableObject(this Base speckleObject) /// /// Delegate condition to stop traverse. /// List of base objects with their collection path. - public static IEnumerable<(List, Base)> TraverseWithPath( - this Base root, - BaseRecursionBreaker recursionBreaker - ) + public static IEnumerable<(string[], Base)> TraverseWithPath(this Base root, BaseRecursionBreaker recursionBreaker) { var stack = new Stack<(List, Base)>(); stack.Push((new List(), root)); @@ -243,7 +240,7 @@ BaseRecursionBreaker recursionBreaker while (stack.Count > 0) { (List path, Base current) = stack.Pop(); - yield return (path, current); + yield return (path.ToArray(), current); if (recursionBreaker(current)) { diff --git a/Core/Core/Models/GraphTraversal/DefaultTraversal.cs b/Core/Core/Models/GraphTraversal/DefaultTraversal.cs index 2b0749e41d..885b031df3 100644 --- a/Core/Core/Models/GraphTraversal/DefaultTraversal.cs +++ b/Core/Core/Models/GraphTraversal/DefaultTraversal.cs @@ -14,59 +14,15 @@ namespace Speckle.Core.Models.GraphTraversal; )] public static class DefaultTraversal { - /// - /// Default traversal rule that ideally should be used by all connectors - /// - /// - /// Treats convertable objects and objects with displayValues as "convertable" such that only elements and dynamic props will be traversed - /// - /// - /// - public static GraphTraversal CreateTraverseFunc(ISpeckleConverter converter) + public static GraphTraversal CreateTraversalFunc() { var convertableRule = TraversalRule .NewTraversalRule() - .When(converter.CanConvertToNative) + .When(b => b.GetType() != typeof(Base)) .When(HasDisplayValue) .ContinueTraversing(_ => ElementsPropAliases); - return new GraphTraversal(convertableRule, s_ignoreResultsRule, DefaultRule); - } - - /// - /// Traverses until finds a convertable object then HALTS deeper traversal - /// - /// - /// Current Revit connector does traversal, - /// so this traversal is a shallow traversal for directly convertable objects, - /// and a deep traversal for all other types - /// - /// - /// - public static GraphTraversal CreateRevitTraversalFunc(ISpeckleConverter converter) - { - var convertableRule = TraversalRule - .NewTraversalRule() - .When(converter.CanConvertToNative) - .When(HasDisplayValue) - .ContinueTraversing(None); - - return new GraphTraversal(convertableRule, s_ignoreResultsRule, DefaultRule); - } - - /// - /// Traverses until finds a convertable object (or fallback) then traverses members - /// - /// - /// - public static GraphTraversal CreateBIMTraverseFunc(ISpeckleConverter converter) - { - var bimElementRule = TraversalRule - .NewTraversalRule() - .When(converter.CanConvertToNative) - .ContinueTraversing(ElementsAliases); - - return new GraphTraversal(bimElementRule, s_ignoreResultsRule, DefaultRule); + return new GraphTraversal(convertableRule, s_ignoreResultsRule, DefaultRule.ShouldReturnToOutput(false)); } //These functions are just meant to make the syntax of defining rules less verbose, they are likely to change frequently/be restructured @@ -78,10 +34,8 @@ public static GraphTraversal CreateBIMTraverseFunc(ISpeckleConverter converter) .When(o => o.speckle_type.Contains("Objects.Structural.Results")) .ContinueTraversing(None); - public static readonly ITraversalRule DefaultRule = TraversalRule - .NewTraversalRule() - .When(_ => true) - .ContinueTraversing(Members()); + public static ITraversalBuilderReturn DefaultRule => + TraversalRule.NewTraversalRule().When(_ => true).ContinueTraversing(Members()); public static readonly IReadOnlyList ElementsPropAliases = new[] { "elements", "@elements" }; @@ -158,6 +112,8 @@ public static IEnumerable DisplayValueAndElementsAliases(Base _) #endregion + #region Legacy function varients + [Obsolete("Renamed to " + nameof(ElementsPropAliases))] [SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "Obsolete")] public static IReadOnlyList elementsPropAliases => ElementsPropAliases; @@ -178,4 +134,79 @@ public static IEnumerable DisplayValueAndElementsAliases(Base _) [SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "Obsolete")] [SuppressMessage("Performance", "CA1819:Properties should not return arrays", Justification = "Obsolete")] public static string[] displayValueAndElementsPropAliases => DisplayValueAndElementsPropAliases; + + /// + /// + /// + /// + [Obsolete($"Consider using {nameof(CreateTraversalFunc)}")] + public static GraphTraversal CreateTraverseFunc(ISpeckleConverter converter) + { + return CreateLegacyTraverseFunc(converter.CanConvertToNative); + } + + /// + /// Legacy traversal rule that was dependent on the converter + /// + /// + /// Treats convertable objects and objects with displayValues as "convertable" such that only elements and dynamic props will be traversed + /// New code should use instead. + /// + /// + /// + [Obsolete($"Consider using {nameof(CreateTraversalFunc)}")] + public static GraphTraversal CreateLegacyTraverseFunc(Func canConvertToNative) + { + var convertableRule = TraversalRule + .NewTraversalRule() + .When(b => canConvertToNative(b)) + .When(HasDisplayValue) + .ContinueTraversing(_ => ElementsPropAliases); + + return new GraphTraversal(convertableRule, s_ignoreResultsRule, DefaultRule); + } + + /// + /// Traverses until finds a convertable object then HALTS deeper traversal + /// + /// + /// The DUI2 Revit connector does traversal, + /// so this traversal is a shallow traversal for directly convertable objects, + /// and a deep traversal for all other types + /// New code should use instead. + /// + /// + /// + [Obsolete($"Consider using {nameof(CreateTraversalFunc)}")] + public static GraphTraversal CreateRevitTraversalFunc(ISpeckleConverter converter) + { + var convertableRule = TraversalRule + .NewTraversalRule() + .When(converter.CanConvertToNative) + .When(HasDisplayValue) + .ContinueTraversing(None); + + return new GraphTraversal(convertableRule, s_ignoreResultsRule, DefaultRule); + } + + /// + /// Traverses until finds a convertable object (or fallback) then traverses members + /// + /// + /// New code should use instead. + /// + /// + /// + [Obsolete($"Consider using {nameof(CreateTraversalFunc)}")] + public static GraphTraversal CreateBIMTraverseFunc(ISpeckleConverter converter) + { + var bimElementRule = TraversalRule + .NewTraversalRule() + .When(converter.CanConvertToNative) + .ContinueTraversing(ElementsAliases); + + return new GraphTraversal(bimElementRule, s_ignoreResultsRule, DefaultRule); + } + + #endregion } diff --git a/Core/Core/Models/GraphTraversal/GraphTraversal.cs b/Core/Core/Models/GraphTraversal/GraphTraversal.cs index f2fa1f5bb6..c397d292f6 100644 --- a/Core/Core/Models/GraphTraversal/GraphTraversal.cs +++ b/Core/Core/Models/GraphTraversal/GraphTraversal.cs @@ -42,11 +42,14 @@ public IEnumerable Traverse(Base root) T head = stack[headIndex]; stack.RemoveAt(headIndex); - yield return head; - Base current = head.Current; var activeRule = GetActiveRuleOrDefault(current); + if (activeRule.ShouldReturn) + { + yield return head; + } + foreach (string childProp in activeRule.MembersToTraverse(current)) { TraverseMemberToStack(stack, current[childProp], childProp, head); diff --git a/Core/Core/Models/GraphTraversal/ITraversalRule.cs b/Core/Core/Models/GraphTraversal/ITraversalRule.cs index 1695a2189b..2507271758 100644 --- a/Core/Core/Models/GraphTraversal/ITraversalRule.cs +++ b/Core/Core/Models/GraphTraversal/ITraversalRule.cs @@ -19,12 +19,24 @@ public interface ITraversalRule /// /// public bool DoesRuleHold(Base o); + + /// + /// When , + /// objects for which this rule applies, + /// will be filtered out from the traversal output + /// (but still traversed normally, as per the ) + /// + /// + /// This property was added to allow for easier filtering of the return of . + /// Without the option to set some rules as false, it was necessary to duplicate part of the rules in a + /// + public bool ShouldReturn { get; } } /// /// The "traverse none" rule that always holds true /// -public sealed class DefaultRule : ITraversalRule +internal sealed class DefaultRule : ITraversalRule { private static DefaultRule? s_instance; @@ -32,13 +44,9 @@ private DefaultRule() { } public static DefaultRule Instance => s_instance ??= new DefaultRule(); - public IEnumerable MembersToTraverse(Base b) - { - return Enumerable.Empty(); - } + public IEnumerable MembersToTraverse(Base b) => Enumerable.Empty(); + + public bool DoesRuleHold(Base o) => true; - public bool DoesRuleHold(Base o) - { - return true; - } + public bool ShouldReturn => true; } diff --git a/Core/Core/Models/GraphTraversal/RuleBuilder.cs b/Core/Core/Models/GraphTraversal/RuleBuilder.cs index c44dfc798f..2482464a62 100644 --- a/Core/Core/Models/GraphTraversal/RuleBuilder.cs +++ b/Core/Core/Models/GraphTraversal/RuleBuilder.cs @@ -8,22 +8,29 @@ namespace Speckle.Core.Models.GraphTraversal; /// Specifies what members to traverse if any provided are met. /// /// Follows the builder pattern to ensure that a rule is complete before usable, see usages -public sealed class TraversalRule : ITraversalRule, ITraversalBuilderTraverse +public sealed class TraversalRule : ITraversalBuilderReturn, ITraversalBuilderTraverse { private readonly List _conditions; - private SelectMembers _membersToTraverse; + private SelectMembers? _membersToTraverse; + public bool ShouldReturn { get; private set; } = true; private TraversalRule() { _conditions = new List(); } - public ITraversalRule ContinueTraversing(SelectMembers membersToTraverse) + public ITraversalBuilderReturn ContinueTraversing(SelectMembers membersToTraverse) { this._membersToTraverse = membersToTraverse; return this; } + public ITraversalRule ShouldReturnToOutput(bool shouldReturn = true) + { + ShouldReturn = shouldReturn; + return this; + } + public ITraversalBuilderTraverse When(WhenCondition condition) { _conditions.Add(condition); @@ -45,7 +52,7 @@ bool ITraversalRule.DoesRuleHold(Base o) IEnumerable ITraversalRule.MembersToTraverse(Base o) { - return _membersToTraverse(o).Distinct(); //TODO distinct is expensive, there may be a better way for us to avoid duplicates + return _membersToTraverse!(o).Distinct(); //TODO distinct is expensive, there may be a better way for us to avoid duplicates } /// a new Traversal Rule to be initialised using the Builder Pattern interfaces @@ -58,7 +65,7 @@ public static ITraversalBuilderWhen NewTraversalRule() public delegate bool WhenCondition(Base o); /// -/// Interface for traversal rule in a building (unusable) state +/// Builder Pattern Interface for a traversal rule in a partially built (unusable state) /// public interface ITraversalBuilderWhen { @@ -76,12 +83,23 @@ public interface ITraversalBuilderWhen public delegate IEnumerable SelectMembers(Base o); /// -/// Interface for traversal rule in a building (unusable) state +/// Builder Pattern Interface for a traversal rule in a partially built (unusable state) /// public interface ITraversalBuilderTraverse : ITraversalBuilderWhen { /// /// Function returning the members that should be traversed for objects where this rule holds /// Traversal rule in a usable state - ITraversalRule ContinueTraversing(SelectMembers membersToTraverse); + ITraversalBuilderReturn ContinueTraversing(SelectMembers membersToTraverse); +} + +/// +/// Builder Pattern Interface for a traversal rule in a usable state, with an (optional) final step to set the value of +/// +public interface ITraversalBuilderReturn : ITraversalRule +{ + /// + /// value to set + /// Traversal rule in a usable state + ITraversalRule ShouldReturnToOutput(bool shouldReturn = true); } diff --git a/Core/Core/Models/GraphTraversal/TraversalContextExtensions.cs b/Core/Core/Models/GraphTraversal/TraversalContextExtensions.cs new file mode 100644 index 0000000000..b987cb1b45 --- /dev/null +++ b/Core/Core/Models/GraphTraversal/TraversalContextExtensions.cs @@ -0,0 +1,47 @@ +using System.Collections.Generic; + +namespace Speckle.Core.Models.GraphTraversal; + +public static class TraversalContextExtensions +{ + /// + /// Walks up the tree, returning values, starting with , + /// walking up nodes + /// + /// + /// + public static IEnumerable GetPropertyPath(this TraversalContext context) + { + TraversalContext? head = context; + do + { + if (head?.PropName == null) + { + break; + } + yield return head.PropName; + + head = head.Parent; + } while (true); + } + + /// + /// Walks up the tree, returning all typed ascendant, starting the closest , + /// walking up nodes + /// + /// + /// + public static IEnumerable GetAscendantOfType(this TraversalContext context) + where T : Base + { + TraversalContext? head = context; + do + { + if (head.Current is T c) + { + yield return c; + } + head = head.Parent; + } while (head != null); + } +} diff --git a/Core/Tests/Speckle.Core.Tests.Unit/Models/GraphTraversal/TraversalContextExtensionsTests.cs b/Core/Tests/Speckle.Core.Tests.Unit/Models/GraphTraversal/TraversalContextExtensionsTests.cs new file mode 100644 index 0000000000..9686e289bb --- /dev/null +++ b/Core/Tests/Speckle.Core.Tests.Unit/Models/GraphTraversal/TraversalContextExtensionsTests.cs @@ -0,0 +1,50 @@ +using NUnit.Framework; +using Speckle.Core.Models; +using Speckle.Core.Models.GraphTraversal; + +namespace Speckle.Core.Tests.Unit.Models.GraphTraversal; + +[TestOf(typeof(TraversalContextExtensions))] +public class TraversalContextExtensionsTests +{ + public static int[] TestDepths => new[] { 1, 2, 10 }; + + private TraversalContext CreateLinkedList(int depth, Func createBaseFunc) + { + if (depth <= 0) + return null; + return new TraversalContext(createBaseFunc(depth), $"{depth}", CreateLinkedList(depth - 1, createBaseFunc)); + } + + [TestCaseSource(nameof(TestDepths))] + public void GetPropertyPath_ReturnsSequentialPath(int depth) + { + var testData = CreateLinkedList(depth, i => new()); + + var path = TraversalContextExtensions.GetPropertyPath(testData); + + var expected = Enumerable.Range(1, depth).Select(i => i.ToString()); + + Assert.That(path, Is.EquivalentTo(expected)); + } + + [TestCaseSource(nameof(TestDepths))] + public void GetAscendantOfType_AllBase(int depth) + { + var testData = CreateLinkedList(depth, i => new()); + + var all = TraversalContextExtensions.GetAscendantOfType(testData).ToArray(); + + Assert.That(all, Has.Length.EqualTo(depth)); + } + + [TestCaseSource(nameof(TestDepths))] + public void GetAscendantOfType_EveryOtherIsCollection(int depth) + { + var testData = CreateLinkedList(depth, i => i % 2 == 0 ? new Base() : new Collection()); + + var all = TraversalContextExtensions.GetAscendantOfType(testData).ToArray(); + + Assert.That(all, Has.Length.EqualTo(Math.Ceiling(depth / 2.0))); + } +} diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Receive/HostObjectBuilder.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Receive/HostObjectBuilder.cs index 9f5f60c8a6..9e367fc751 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Receive/HostObjectBuilder.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Receive/HostObjectBuilder.cs @@ -46,11 +46,11 @@ CancellationToken cancellationToken _arcGISProjectUtils.AddDatabaseToProject(databasePath); // POC: This is where we will define our receive strategy, or maybe later somewhere else according to some setting pass from UI? - IEnumerable<(List, Base)> objectsWithPath = rootObject.TraverseWithPath((obj) => obj is not Collection); + IEnumerable<(string[], Base)> objectsWithPath = rootObject.TraverseWithPath((obj) => obj is not Collection); List objectIds = new(); int count = 0; - foreach ((List path, Base obj) in objectsWithPath) + foreach ((string[] path, Base obj) in objectsWithPath) { if (cancellationToken.IsCancellationRequested) { diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/DependencyInjection/AutofacAutocadModule.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/DependencyInjection/AutofacAutocadModule.cs index 412982465e..b19d080b41 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/DependencyInjection/AutofacAutocadModule.cs +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/DependencyInjection/AutofacAutocadModule.cs @@ -23,6 +23,7 @@ using Speckle.Connectors.DUI.WebView; using Speckle.Connectors.Utils.Builders; using Speckle.Connectors.Utils.Operations; +using Speckle.Core.Models.GraphTraversal; using Speckle.Core.Transports; namespace Speckle.Connectors.Autocad.DependencyInjection; @@ -51,6 +52,7 @@ protected override void Load(ContainerBuilder builder) builder.RegisterType>().InstancePerLifetimeScope(); builder.RegisterType().SingleInstance(); builder.RegisterType().As().SingleInstance().AutoActivate(); // Auto activation makes SynchronizationContext available right after building. Otherwise we were missing it in UoWs. + builder.RegisterInstance(DefaultTraversal.CreateTraversalFunc()); // Object Builders builder.RegisterType().As().InstancePerDependency(); diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Operations/Receive/HostObjectBuilder.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Operations/Receive/HostObjectBuilder.cs index 178c791c05..edb8cfa827 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Operations/Receive/HostObjectBuilder.cs +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Operations/Receive/HostObjectBuilder.cs @@ -6,7 +6,7 @@ using Speckle.Connectors.Utils.Builders; using Speckle.Converters.Common; using Speckle.Core.Logging; -using Speckle.Core.Models.Extensions; +using Speckle.Core.Models.GraphTraversal; namespace Speckle.Connectors.Autocad.Operations.Receive; @@ -14,27 +14,17 @@ public class HostObjectBuilder : IHostObjectBuilder { private readonly ISpeckleConverterToHost _converter; private readonly AutocadLayerManager _autocadLayerManager; + private readonly GraphTraversal _traversalFunction; - public HostObjectBuilder(ISpeckleConverterToHost converter, AutocadLayerManager autocadLayerManager) + public HostObjectBuilder( + ISpeckleConverterToHost converter, + AutocadLayerManager autocadLayerManager, + GraphTraversal traversalFunction + ) { _converter = converter; _autocadLayerManager = autocadLayerManager; - } - - private List<(List, Base)> GetBaseWithPath(Base commitObject, CancellationToken cancellationToken) - { - List<(List, Base)> objectsToConvert = new(); - foreach ((List objPath, Base obj) in commitObject.TraverseWithPath((obj) => obj is not Collection)) - { - cancellationToken.ThrowIfCancellationRequested(); - - if (obj is not Collection) // POC: equivalent of converter.CanConvertToNative(obj) ? - { - objectsToConvert.Add((objPath, obj)); - } - } - - return objectsToConvert; + _traversalFunction = traversalFunction; } public IEnumerable Build( @@ -50,7 +40,8 @@ CancellationToken cancellationToken // Layer filter for received commit with project and model name _autocadLayerManager.CreateLayerFilter(projectName, modelName); - List<(List, Base)> objectsWithPath = GetBaseWithPath(rootObject, cancellationToken); + var traversalGraph = _traversalFunction.Traverse(rootObject).ToArray(); + string baseLayerPrefix = $"SPK-{projectName}-{modelName}-"; HashSet uniqueLayerNames = new(); @@ -60,20 +51,28 @@ CancellationToken cancellationToken // POC: Will be addressed to move it into AutocadContext! using (TransactionContext.StartTransaction(Application.DocumentManager.MdiActiveDocument)) { - foreach ((List path, Base obj) in objectsWithPath) + foreach (TraversalContext tc in traversalGraph) { cancellationToken.ThrowIfCancellationRequested(); try { - string layerFullName = _autocadLayerManager.LayerFullName(baseLayerPrefix, string.Join("-", path)); + string layerFullName = GetLayerPath(tc, baseLayerPrefix); if (uniqueLayerNames.Add(layerFullName)) { _autocadLayerManager.CreateLayerOrPurge(layerFullName); } - object converted = _converter.Convert(obj); + //POC: this transaction used to be called in the converter, We've moved it here to unify converter implementation + //POC: Is this transaction 100% needed? we are already inside a transaction? + object converted; + using (var tr = Application.DocumentManager.CurrentDocument.Database.TransactionManager.StartTransaction()) + { + converted = _converter.Convert(tc.Current); + tr.Commit(); + } + List flattened = Utilities.FlattenToHostConversionResult(converted); foreach (Entity conversionResult in flattened.Cast()) @@ -89,7 +88,7 @@ CancellationToken cancellationToken handleValues.Add(conversionResult.Handle.Value.ToString()); } - onOperationProgressed?.Invoke("Converting", (double)++count / objectsWithPath.Count); + onOperationProgressed?.Invoke("Converting", (double)++count / traversalGraph.Length); } catch (Exception e) when (!e.IsFatal()) // DO NOT CATCH SPECIFIC STUFF, conversion errors should be recoverable { @@ -100,4 +99,12 @@ CancellationToken cancellationToken } return handleValues; } + + private string GetLayerPath(TraversalContext context, string baseLayerPrefix) + { + string[] collectionBasedPath = context.GetAscendantOfType().Select(c => c.name).ToArray(); + string[] path = collectionBasedPath.Any() ? collectionBasedPath : context.GetPropertyPath().ToArray(); + + return _autocadLayerManager.LayerFullName(baseLayerPrefix, string.Join("-", path)); //TODO: reverse path? + } } diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/AutofacRhinoModule.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/AutofacRhinoModule.cs index 84393bc84e..d4828f0539 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/AutofacRhinoModule.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/AutofacRhinoModule.cs @@ -25,6 +25,7 @@ using Speckle.Connectors.Rhino7.Operations.Receive; using Speckle.Connectors.Utils.Builders; using Speckle.Connectors.Utils.Operations; +using Speckle.Core.Models.GraphTraversal; namespace Speckle.Connectors.Rhino7.DependencyInjection; @@ -68,6 +69,7 @@ protected override void Load(ContainerBuilder builder) builder.RegisterType().As().InstancePerLifetimeScope(); builder.RegisterType>().InstancePerLifetimeScope(); builder.RegisterType().InstancePerLifetimeScope(); + builder.RegisterInstance(DefaultTraversal.CreateTraversalFunc()); builder.RegisterType().As().SingleInstance(); builder.RegisterType().As().InstancePerLifetimeScope(); diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Receive/RhinoHostObjectBuilder.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Receive/RhinoHostObjectBuilder.cs index 56608f58b5..baf06fefce 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Receive/RhinoHostObjectBuilder.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Receive/RhinoHostObjectBuilder.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.Linq; using System.Threading; -using Objects.Other; using Rhino; using Rhino.DocObjects; using Rhino.Geometry; @@ -10,7 +9,7 @@ using Speckle.Converters.Common; using Speckle.Core.Logging; using Speckle.Core.Models; -using Speckle.Core.Models.Extensions; +using Speckle.Core.Models.GraphTraversal; namespace Speckle.Connectors.Rhino7.Operations.Receive; @@ -18,14 +17,17 @@ public class RhinoHostObjectBuilder : IHostObjectBuilder { private readonly ISpeckleConverterToHost _toHostConverter; private readonly IConversionContextStack _contextStack; + private readonly GraphTraversal _traverseFunction; public RhinoHostObjectBuilder( ISpeckleConverterToHost toHostConverter, - IConversionContextStack contextStack + IConversionContextStack contextStack, + GraphTraversal traverseFunction ) { _toHostConverter = toHostConverter; _contextStack = contextStack; + _traverseFunction = traverseFunction; } public IEnumerable Build( @@ -39,9 +41,10 @@ CancellationToken cancellationToken // POC: This is where the top level base-layer name is set. Could be abstracted or injected in the context? var baseLayerName = $"Project {projectName}: Model {modelName}"; - var objectsToConvert = rootObject - .TraverseWithPath(obj => obj is not Collection) - .Where(obj => obj.Item2 is not Collection && obj.Item2 is not DisplayStyle && obj.Item2 is not RenderMaterial); + var objectsToConvert = _traverseFunction + .Traverse(rootObject) + .Where(obj => obj.Current is not Collection) + .Select(ctx => (GetLayerPath(ctx), ctx.Current)); var convertedIds = BakeObjects(objectsToConvert, baseLayerName, onOperationProgressed, cancellationToken); @@ -52,7 +55,7 @@ CancellationToken cancellationToken // POC: Potentially refactor out into an IObjectBaker. private List BakeObjects( - IEnumerable<(List, Base)> objects, + IEnumerable<(string[], Base)> objects, string baseLayerName, Action? onOperationProgressed, CancellationToken cancellationToken @@ -69,10 +72,16 @@ CancellationToken cancellationToken Layer[]? childLayers = documentLayer.GetChildren(); if (childLayers != null) { + doc.Views.RedrawEnabled = false; foreach (var layer in childLayers) { - doc.Layers.Purge(layer.Index, false); + var purgeSuccess = doc.Layers.Purge(layer.Index, true); + if (!purgeSuccess) + { + Console.WriteLine($"Failed to purge layer: {layer}"); + } } + doc.Views.RedrawEnabled = true; } } @@ -87,36 +96,35 @@ CancellationToken cancellationToken // POC: We delay throwing conversion exceptions until the end of the conversion loop, then throw all within an aggregate exception if something happened. var conversionExceptions = new List(); - foreach ((List path, Base baseObj) in objects) + doc.Views.RedrawEnabled = false; + foreach ((string[] path, Base baseObj) in objects) { try { cancellationToken.ThrowIfCancellationRequested(); - var fullLayerName = string.Join("::", path); + var fullLayerName = string.Join(Layer.PathSeparator, path); var layerIndex = cache.TryGetValue(fullLayerName, out int value) ? value : GetAndCreateLayerFromPath(path, baseLayerName, cache); onOperationProgressed?.Invoke("Converting & creating objects", (double)++count / listObjects.Count); - var converted = _toHostConverter.Convert(baseObj); + var result = _toHostConverter.Convert(baseObj); - if (converted is not GeometryBase newObject) - { - throw new SpeckleConversionException( - $"Unexpected result from conversion: Expected {nameof(GeometryBase)} but instead got {converted.GetType().Name}" - ); - } - - var newObjectGuid = doc.Objects.Add(newObject, new ObjectAttributes { LayerIndex = layerIndex }); - newObjectIds.Add(newObjectGuid.ToString()); + var conversionIds = HandleConversionResult(result, baseObj, layerIndex); + newObjectIds.AddRange(conversionIds); + } + catch (OperationCanceledException) + { + throw; } catch (Exception e) when (!e.IsFatal()) { conversionExceptions.Add(e); } } + doc.Views.RedrawEnabled = true; if (conversionExceptions.Count != 0) { @@ -126,8 +134,44 @@ CancellationToken cancellationToken return newObjectIds; } + private IReadOnlyList HandleConversionResult(object conversionResult, Base originalObject, int layerIndex) + { + var doc = _contextStack.Current.Document; + List newObjectIds = new(); + switch (conversionResult) + { + case IEnumerable list: + { + Group group = BakeObjectsAsGroup(originalObject.id, list, layerIndex); + newObjectIds.Add(group.Id.ToString()); + break; + } + case GeometryBase newObject: + { + var newObjectGuid = doc.Objects.Add(newObject, new ObjectAttributes { LayerIndex = layerIndex }); + newObjectIds.Add(newObjectGuid.ToString()); + break; + } + default: + throw new SpeckleConversionException( + $"Unexpected result from conversion: Expected {nameof(GeometryBase)} but instead got {conversionResult.GetType().Name}" + ); + } + + return newObjectIds; + } + + private Group BakeObjectsAsGroup(string groupName, IEnumerable list, int layerIndex) + { + var doc = _contextStack.Current.Document; + var objectIds = list.Select(obj => doc.Objects.Add(obj, new ObjectAttributes { LayerIndex = layerIndex })); + var groupIndex = _contextStack.Current.Document.Groups.Add(groupName, objectIds); + var group = _contextStack.Current.Document.Groups.FindIndex(groupIndex); + return group; + } + // POC: This is the original DUI3 function, this will grow over time as we add more conversions that are missing, so it should be refactored out into an ILayerManager or some sort of service. - private int GetAndCreateLayerFromPath(List path, string baseLayerName, Dictionary cache) + private int GetAndCreateLayerFromPath(string[] path, string baseLayerName, Dictionary cache) { var currentLayerName = baseLayerName; RhinoDoc currentDocument = _contextStack.Current.Document; @@ -151,4 +195,11 @@ private int GetAndCreateLayerFromPath(List path, string baseLayerName, D } return previousLayer.Index; } + + private string[] GetLayerPath(TraversalContext context) + { + string[] collectionBasedPath = context.GetAscendantOfType().Select(c => c.name).ToArray(); + string[] reverseOrderPath = collectionBasedPath.Any() ? collectionBasedPath : context.GetPropertyPath().ToArray(); + return reverseOrderPath.Reverse().ToArray(); + } } diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2023.DependencyInjection/AutofacAutocadConverterModule.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2023.DependencyInjection/AutofacAutocadConverterModule.cs index f06cd57bcb..60a29fcda7 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2023.DependencyInjection/AutofacAutocadConverterModule.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2023.DependencyInjection/AutofacAutocadConverterModule.cs @@ -4,6 +4,7 @@ using Speckle.Autofac.DependencyInjection; using Speckle.Converters.Autocad; using Speckle.Converters.Common; +using Speckle.Converters.Common.DependencyInjection.ToHost; using Speckle.Converters.Common.Objects; namespace Speckle.Converters.Autocad2023.DependencyInjection; @@ -17,7 +18,7 @@ protected override void Load(ContainerBuilder builder) // should be InstancePerLifetimeScope // most things should be InstancePerLifetimeScope so we get one per operation builder.RegisterType().As().SingleInstance(); - builder.RegisterType().As().SingleInstance(); + builder.RegisterType().As().SingleInstance(); // single stack per conversion builder diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/AutocadConverterToHost.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/AutocadConverterToHost.cs deleted file mode 100644 index fc4876e9dd..0000000000 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/AutocadConverterToHost.cs +++ /dev/null @@ -1,49 +0,0 @@ -using System; -using Speckle.Autofac.DependencyInjection; -using Speckle.Converters.Common; -using Speckle.Converters.Common.Objects; -using Speckle.Core.Models; - -namespace Speckle.Converters.Autocad; - -public class AutocadConverterToHost : ISpeckleConverterToHost -{ - private readonly IFactory _toHost; - private readonly IConversionContextStack _contextStack; - - public AutocadConverterToHost( - IFactory toHost, - IConversionContextStack contextStack - ) - { - _toHost = toHost; - _contextStack = contextStack; - } - - public object Convert(Base target) - { - Type type = target.GetType(); - - try - { - using (var tr = _contextStack.Current.Document.Database.TransactionManager.StartTransaction()) - { - var objectConverter = _toHost.ResolveInstance(type.Name); - - if (objectConverter == null) - { - throw new NotSupportedException($"No conversion found for {target.GetType().Name}"); - } - - var convertedObject = objectConverter.Convert(target); - tr.Commit(); - return convertedObject; - } - } - catch (SpeckleConversionException e) - { - Console.WriteLine(e); - throw; // POC: Just rethrowing for now, Logs may be needed here. - } - } -} diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/Speckle.Converters.AutocadShared.projitems b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/Speckle.Converters.AutocadShared.projitems index 230a119880..355891e941 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/Speckle.Converters.AutocadShared.projitems +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/Speckle.Converters.AutocadShared.projitems @@ -9,7 +9,6 @@ Speckle.Converters.AutocadShared - @@ -17,6 +16,7 @@ + diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/SpeckleFallbackToHostConversion.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/SpeckleFallbackToHostConversion.cs new file mode 100644 index 0000000000..e09a3ce40a --- /dev/null +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/SpeckleFallbackToHostConversion.cs @@ -0,0 +1,48 @@ +using System; +using System.Collections.Generic; +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; +using Speckle.Core.Models; + +namespace Speckle.Converters.Rhino7.ToHost.TopLevel; + +[NameAndRankValue(nameof(DisplayableObject), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +public class SpeckleFallbackToAutocadConversion + : ISpeckleObjectToHostConversion, + IRawConversion> +{ + private readonly IRawConversion _lineConverter; + private readonly IRawConversion _polylineConverter; + private readonly IRawConversion _meshConverter; + + public SpeckleFallbackToAutocadConversion( + IRawConversion lineConverter, + IRawConversion polylineConverter, + IRawConversion meshConverter + ) + { + _lineConverter = lineConverter; + _polylineConverter = polylineConverter; + _meshConverter = meshConverter; + } + + public object Convert(Base target) => RawConvert((DisplayableObject)target); + + public List RawConvert(DisplayableObject target) + { + var result = new List(); + foreach (var item in target.displayValue) + { + ADB.Entity x = item switch + { + SOG.Line line => _lineConverter.RawConvert(line), + SOG.Polyline polyline => _polylineConverter.RawConvert(polyline), + SOG.Mesh mesh => _meshConverter.RawConvert(mesh), + _ => throw new NotSupportedException($"Found unsupported fallback geometry: {item.GetType()}") + }; + result.Add(x); + } + + return result; + } +} diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/AutofacRhinoConverterModule.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/AutofacRhinoConverterModule.cs index a7340d4bbc..2a97701d32 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/AutofacRhinoConverterModule.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/AutofacRhinoConverterModule.cs @@ -4,7 +4,7 @@ using Speckle.Converters.Common.Objects; using Rhino; using Speckle.Converters.Common.DependencyInjection; -using Speckle.Converters.Rhino7.ToHost; +using Speckle.Converters.Common.DependencyInjection.ToHost; using Speckle.Converters.Rhino7.ToSpeckle; namespace Speckle.Converters.Rhino7.DependencyInjection; @@ -38,7 +38,7 @@ This will require consolidating across other connectors. .As>() .InstancePerLifetimeScope(); - builder.RegisterType().As().InstancePerLifetimeScope(); + builder.RegisterType().As().InstancePerLifetimeScope(); /* POC: CNX-9267 Moved the Injection of converters into the converter module. Not sure if this is 100% right, as this doesn't just register the conversions within this converter, but any conversions found in any Speckle.*.dll file. diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpeckleBrepRawToHostConversion.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpeckleBrepRawToHostConversion.cs index 397b554872..9fd34aa678 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpeckleBrepRawToHostConversion.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpeckleBrepRawToHostConversion.cs @@ -1,4 +1,4 @@ -using Objects; +using Objects; using Rhino; using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; @@ -57,8 +57,15 @@ public RG.Brep RawConvert(SOG.Brep target) target.Faces.ForEach(face => ConvertSpeckleBrepFace(rhinoBrep, face)); target.Loops.ForEach(loop => ConvertSpeckleBrepLoop(rhinoBrep, loop, tolerance)); + // POC: Massive performance bottleneck, but a qualtiy assurance move. Fixes 99% of Brep fuckups. + rhinoBrep.Repair(tolerance); // Repair fixes tolerance issues with the Brep if the scaling lead to some rounding error. + if (!rhinoBrep.IsValidWithLog(out string reason)) + { + throw new SpeckleConversionException($"Resulting BREP was invalid: {reason}"); + } + return rhinoBrep; } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpeckleNurbsCurveToHostConversion.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpeckleNurbsCurveToHostConversion.cs index 6d72519ba7..abb8935eb2 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpeckleNurbsCurveToHostConversion.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpeckleNurbsCurveToHostConversion.cs @@ -5,15 +5,10 @@ namespace Speckle.Converters.Rhino7.ToHost.Raw; public class SpeckleNurbsCurveToHostConversion : IRawConversion { - private readonly IRawConversion _pointConverter; private readonly IRawConversion _intervalConverter; - public SpeckleNurbsCurveToHostConversion( - IRawConversion pointConverter, - IRawConversion intervalConverter - ) + public SpeckleNurbsCurveToHostConversion(IRawConversion intervalConverter) { - _pointConverter = pointConverter; _intervalConverter = intervalConverter; } @@ -26,9 +21,7 @@ public SpeckleNurbsCurveToHostConversion( /// ⚠️ This conversion does NOT perform scaling. public RG.NurbsCurve RawConvert(SOG.Curve target) { - var rhinoPoints = target.GetPoints().Select(o => _pointConverter.RawConvert(o)).ToList(); - - RG.NurbsCurve? nurbsCurve = RG.NurbsCurve.Create(false, target.degree, rhinoPoints); + RG.NurbsCurve? nurbsCurve = new(target.degree, target.points.Count / 3); #pragma warning disable CA1508 if (nurbsCurve == null) // POC: CNX-9272 Nullability is wrong here, cannot remove this warning but code is required. @@ -37,9 +30,11 @@ public RG.NurbsCurve RawConvert(SOG.Curve target) throw new SpeckleConversionException("Attempt to create Nurbs Curve failed with no explanation from Rhino"); } - for (int j = 0; j < nurbsCurve.Points.Count; j++) + // Hyper optimised curve control point conversion + for (int i = 2, j = 0; i < target.points.Count; i += 3, j++) { - nurbsCurve.Points.SetPoint(j, rhinoPoints[j], target.weights[j]); + var pt = new RG.Point3d(target.points[i - 2], target.points[i - 1], target.points[i]); // Skip the point converter for performance + nurbsCurve.Points.SetPoint(j, pt, target.weights[j]); } // check knot multiplicity to match Rhino's standard of (# control points + degree - 1) diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/RhinoConverterToHost.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/RhinoConverterToHost.cs deleted file mode 100644 index aa66d09d2a..0000000000 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/RhinoConverterToHost.cs +++ /dev/null @@ -1,31 +0,0 @@ -using Speckle.Autofac.DependencyInjection; -using Speckle.Converters.Common; -using Speckle.Converters.Common.Objects; -using Speckle.Core.Models; - -namespace Speckle.Converters.Rhino7.ToHost; - -public class RhinoConverterToHost : ISpeckleConverterToHost -{ - private readonly IFactory _toHost; - - public RhinoConverterToHost(IFactory toHost) - { - _toHost = toHost; - } - - public object Convert(Base target) - { - var typeName = target.GetType().Name; - var objectConverter = _toHost.ResolveInstance(typeName); - - if (objectConverter == null) - { - throw new NotSupportedException($"No conversion found for {typeName}"); - } - - var convertedObject = objectConverter.Convert(target); - - return convertedObject; - } -} diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/SpeckleFallbackToHostConversion.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/SpeckleFallbackToHostConversion.cs new file mode 100644 index 0000000000..dc0e6602ea --- /dev/null +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/SpeckleFallbackToHostConversion.cs @@ -0,0 +1,46 @@ +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; +using Speckle.Core.Models; + +namespace Speckle.Converters.Rhino7.ToHost.TopLevel; + +[NameAndRankValue(nameof(DisplayableObject), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +public class SpeckleFallbackToHostConversion + : ISpeckleObjectToHostConversion, + IRawConversion> +{ + private readonly IRawConversion _lineConverter; + private readonly IRawConversion _polylineConverter; + private readonly IRawConversion _meshConverter; + + public SpeckleFallbackToHostConversion( + IRawConversion lineConverter, + IRawConversion polylineConverter, + IRawConversion meshConverter + ) + { + _lineConverter = lineConverter; + _polylineConverter = polylineConverter; + _meshConverter = meshConverter; + } + + public object Convert(Base target) => RawConvert((DisplayableObject)target); + + public List RawConvert(DisplayableObject target) + { + var result = new List(); + foreach (var item in target.displayValue) + { + RG.GeometryBase x = item switch + { + SOG.Line line => _lineConverter.RawConvert(line), + SOG.Polyline polyline => _polylineConverter.RawConvert(polyline), + SOG.Mesh mesh => _meshConverter.RawConvert(mesh), + _ => throw new NotSupportedException($"Found unsupported fallback geometry: {item.GetType()}") + }; + result.Add(x); + } + + return result; + } +} diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/Speckle.Converters.Common.DependencyInjection.csproj b/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/Speckle.Converters.Common.DependencyInjection.csproj index 91a6988198..6bacb1cc56 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/Speckle.Converters.Common.DependencyInjection.csproj +++ b/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/Speckle.Converters.Common.DependencyInjection.csproj @@ -11,6 +11,7 @@ + diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/ToHost/ToHostConverterWithFallback.cs b/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/ToHost/ToHostConverterWithFallback.cs new file mode 100644 index 0000000000..6316e8de5e --- /dev/null +++ b/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/ToHost/ToHostConverterWithFallback.cs @@ -0,0 +1,71 @@ +using Speckle.Autofac.DependencyInjection; +using Speckle.Converters.Common.Objects; +using Speckle.Core.Models; +using Speckle.Core.Models.Extensions; + +namespace Speckle.Converters.Common.DependencyInjection.ToHost; + +// POC: CNX-9394 Find a better home for this outside `DependencyInjection` project +public sealed class ToHostConverterWithFallback : ISpeckleConverterToHost +{ + private readonly IFactory _toHost; + private readonly ToHostConverterWithoutFallback _baseConverter; + + public ToHostConverterWithFallback(IFactory toHost) + { + _toHost = toHost; + _baseConverter = new ToHostConverterWithoutFallback(toHost); + } + + /// + /// Converts a instance to a host object. + /// + /// The instance to convert. + /// The converted host object. + /// Fallbacks to display value if a direct conversion is not possible. + /// + /// The conversion is done in the following order of preference: + /// 1. Direct conversion using the method. + /// 2. Fallback to display value using the method, if a direct conversion is not possible. + /// + /// If the direct conversion is not available and there is no displayValue, a is thrown. + /// + /// Thrown when no conversion is found for . + public object Convert(Base target) + { + var typeName = target.GetType().Name; + + // Direct conversion if a converter is found + if (_baseConverter.TryConvert(target, out object? result)) + { + return result!; + } + + // Fallback to display value if it exists. + var displayValue = target.TryGetDisplayValue(); + if (displayValue != null) + { + return FallbackToDisplayValue(displayValue); + } + + // Throw instead of null-return! + throw new NotSupportedException($"No conversion found for {typeName}"); + } + + private object FallbackToDisplayValue(IReadOnlyList displayValue) + { + // Create a temp Displayable object that handles the displayValue. + var tempDisplayableObject = new DisplayableObject(displayValue); + + var displayableObjectConverter = _toHost.ResolveInstance(nameof(DisplayableObject)); + + // It is not guaranteed that a fallback converter has been registered in all connectors + if (displayableObjectConverter == null) + { + throw new InvalidOperationException("No converter for fallback displayable objects was found."); + } + + // Run the conversion, which will (or could?) return an `IEnumerable`. We don't care at this point, connector will. + return displayableObjectConverter.Convert(tempDisplayableObject); + } +} diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/ToHost/ToHostConverterWithoutFallback.cs b/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/ToHost/ToHostConverterWithoutFallback.cs new file mode 100644 index 0000000000..2c00a69ec5 --- /dev/null +++ b/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/ToHost/ToHostConverterWithoutFallback.cs @@ -0,0 +1,41 @@ +using Speckle.Autofac.DependencyInjection; +using Speckle.Converters.Common.Objects; +using Speckle.Core.Models; + +namespace Speckle.Converters.Common.DependencyInjection.ToHost; + +// POC: CNX-9394 Find a better home for this outside `DependencyInjection` project +public sealed class ToHostConverterWithoutFallback : ISpeckleConverterToHost +{ + private readonly IFactory _toHost; + + public ToHostConverterWithoutFallback(IFactory toHost) + { + _toHost = toHost; + } + + public object Convert(Base target) + { + if (TryConvert(target, out object? result)) + { + return result!; + } + throw new NotSupportedException($"No conversion found for {target.GetType()}"); + } + + internal bool TryConvert(Base target, out object? result) + { + var typeName = target.GetType().Name; + + // Direct conversion if a converter is found + var objectConverter = _toHost.ResolveInstance(typeName); + if (objectConverter != null) + { + result = objectConverter.Convert(target); + return true; + } + + result = null; + return false; + } +} diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common/DisplayableObject.cs b/DUI3-DX/Sdk/Speckle.Converters.Common/DisplayableObject.cs new file mode 100644 index 0000000000..aa80876c98 --- /dev/null +++ b/DUI3-DX/Sdk/Speckle.Converters.Common/DisplayableObject.cs @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using Objects; +using Objects.Geometry; +using Speckle.Core.Models; + +namespace Speckle.Converters.Common; + +// POC: This object was created with the purpose of defining a specific subtype of base type the fallback conversion. +// This will never be serialised and is just used to provide a type to register as the fallback conversion. +// We did this because providing a conversion from List seemed too generic and potentially conflicting. +// This also allows us to treat any implementation of IDisplayValue without caring about it's specific T type. + +public sealed class DisplayableObject : Base, IDisplayValue> +{ + public DisplayableObject(IReadOnlyList displayValue) + { + var invalidGeometries = displayValue + .Where(b => b is not (Line or Polyline or Mesh)) + .Select(b => b.GetType()) + .Distinct(); + + if (invalidGeometries.Any()) + { + throw new ArgumentException( + $"Displayable objects should only contain simple geometries (lines, polylines, meshes) but contained {invalidGeometries}" + ); + } + + this.displayValue = displayValue; + } + + public IReadOnlyList displayValue { get; } +} diff --git a/Objects/Objects/Interfaces.cs b/Objects/Objects/Interfaces.cs index f732d0d64f..9bd5aa4ea0 100644 --- a/Objects/Objects/Interfaces.cs +++ b/Objects/Objects/Interfaces.cs @@ -101,13 +101,13 @@ public interface ITransformable /// Expected to be either a type or a of s, /// most likely or . /// -public interface IDisplayValue +public interface IDisplayValue { /// /// (s) will be used to display this /// if a native displayable object cannot be converted. /// - T displayValue { get; set; } + T displayValue { get; } } From 37c7ec6d843d14de407d63a1ee1861e4b29e4685 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?O=C4=9Fuzhan=20Koral?= <45078678+oguzhankoral@users.noreply.github.com> Date: Thu, 2 May 2024 14:25:19 +0300 Subject: [PATCH 072/261] CNX 9372 highlighting loaded elements not working (#3339) * Add receive result into receiver model card * Enable highlighting received objects --- .../Bindings/AutocadBasicConnectorBinding.cs | 7 +++++++ .../Bindings/RhinoBasicConnectorBinding.cs | 9 ++++----- .../Bindings/RhinoReceiveBinding.cs | 1 + .../Models/Card/ReceiverModelCard.cs | 1 + 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadBasicConnectorBinding.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadBasicConnectorBinding.cs index 338ade0a59..81a9c6356b 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadBasicConnectorBinding.cs +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadBasicConnectorBinding.cs @@ -97,7 +97,14 @@ public void HighlightModel(string modelCardId) if (model is SenderModelCard senderModelCard) { List<(DBObject obj, string applicationId)> dbObjects = doc.GetObjects(senderModelCard.SendFilter.GetObjectIds()); + objectIds = dbObjects.Select(tuple => tuple.obj.Id).ToArray(); + } + if (model is ReceiverModelCard receiverModelCard) + { + List<(DBObject obj, string applicationId)> dbObjects = doc.GetObjects( + receiverModelCard.ReceiveResult.BakedObjectIds + ); objectIds = dbObjects.Select(tuple => tuple.obj.Id).ToArray(); } diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoBasicConnectorBinding.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoBasicConnectorBinding.cs index 022051adca..d9a0cbcfd6 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoBasicConnectorBinding.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoBasicConnectorBinding.cs @@ -77,11 +77,10 @@ public void HighlightModel(string modelCardId) objectIds = sender.SendFilter.GetObjectIds(); } - // TODO: Disabled receiver specifics - // if (myModel is ReceiverModelCard receiver && receiver.ReceiveResult != null) - // { - // objectIds = receiver.ReceiveResult.BakedObjectIds; - // } + if (myModel is ReceiverModelCard receiver && receiver.ReceiveResult != null) + { + objectIds = receiver.ReceiveResult.BakedObjectIds; + } if (objectIds.Count == 0) { diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoReceiveBinding.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoReceiveBinding.cs index dea667feb0..68c8c3a8ec 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoReceiveBinding.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoReceiveBinding.cs @@ -67,6 +67,7 @@ public async Task Receive(string modelCardId) ) .ConfigureAwait(false); + // POC: Here we can't set receive result if ReceiveOperation throws an error. Commands.SetModelReceiveResult(modelCardId, receivedObjectIds.ToList()); } catch (OperationCanceledException) diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/ReceiverModelCard.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/ReceiverModelCard.cs index 8a2ab0fbd1..a9fd1821df 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/ReceiverModelCard.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/ReceiverModelCard.cs @@ -7,4 +7,5 @@ public class ReceiverModelCard : ModelCard public string SelectedVersionId { get; set; } public string LatestVersionId { get; set; } public bool HasDismissedUpdateWarning { get; set; } + public ReceiveResult ReceiveResult { get; set; } } From 0da46c85cd31ce841dcd318de048f2f69018cefd Mon Sep 17 00:00:00 2001 From: Dimitrie Stefanescu Date: Thu, 2 May 2024 12:55:49 +0100 Subject: [PATCH 073/261] chore(dui3): simplifies highlight object logic brought back from /dev projects --- .../Bindings/BasicConnectorBindingRevit.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/BasicConnectorBindingRevit.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/BasicConnectorBindingRevit.cs index b291118c76..c36cbe16ee 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/BasicConnectorBindingRevit.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/BasicConnectorBindingRevit.cs @@ -1,3 +1,4 @@ +using System; using System.Collections.Generic; using System.Linq; using System.Reflection; @@ -108,6 +109,12 @@ public void HighlightModel(string modelCardId) // POC: GetElementsFromDocument could be interfaced out, extension is cleaner List elementIds = doc.GetElements(objectsIds).Select(e => e.Id).ToList(); + if (elementIds.Count == 0) + { + Commands.SetModelError(modelCardId, new InvalidOperationException("No objects found to highlight.")); + return; + } + // UiDocument operations should be wrapped into RevitTask, otherwise doesn't work on other tasks. RevitTask.RunAsync(() => { From 0c1b1c92772e0b2e08de4a6d2641c7ea7fc515f1 Mon Sep 17 00:00:00 2001 From: Dimitrie Stefanescu Date: Thu, 2 May 2024 13:39:43 +0100 Subject: [PATCH 074/261] fix(dui3/revit): throw exception if we have no objects to send --- .../Operations/Send/RootObjectBuilder.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RootObjectBuilder.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RootObjectBuilder.cs index 59b6a2f2da..fc1f2eb302 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RootObjectBuilder.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RootObjectBuilder.cs @@ -37,6 +37,11 @@ public Base Build( { List objects = _contextStack.Current.Document.Document.GetElements(sendSelection.SelectedItems).ToList(); + if (objects.Count == 0) + { + throw new InvalidOperationException("No objects were found. Please update your send filter!"); + } + Base commitObject = new(); foreach (Element obj in objects) From ca85dd10632ffffd532e10f490d8a6f4de365c91 Mon Sep 17 00:00:00 2001 From: Dimitrie Stefanescu Date: Thu, 2 May 2024 13:44:11 +0100 Subject: [PATCH 075/261] fix(dui3/revit): handles exceptions in the HandleSend call There is a semi implemented "SpeckleTopLevelExceptionHandler" above that wraps the call of this HandleSend, but it currently is not doing anything - resulting in all errors from here bubbling up to the bridge, which is not kosher. Unsure what the intentions are around the SpeckleTopLevelExceptionHandler going forward, but this plug is rather important for the release Thanks to @oguzhankoral for the guiding here :) --- .../Bindings/SendBinding.cs | 46 ++++++++++++------- 1 file changed, 30 insertions(+), 16 deletions(-) diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SendBinding.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SendBinding.cs index 2a092b79e5..553beada2f 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SendBinding.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SendBinding.cs @@ -73,25 +73,39 @@ private async Task HandleSend(string modelCardId) // it can be injected where needed instead of passing it around like a bomb :D CancellationTokenSource cts = CancellationManager.InitCancellationTokenSource(modelCardId); - if (_store.GetModelById(modelCardId) is not SenderModelCard modelCard) + // POC: this try catch pattern is coming from Rhino. I see there is a semi implemented "SpeckleTopLevelExceptionHandler" + // above that wraps the call of this HandleSend, but it currently is not doing anything - resulting in all errors from here + // bubbling up to the bridge. + try { - throw new InvalidOperationException("No publish model card was found."); - } + if (_store.GetModelById(modelCardId) is not SenderModelCard modelCard) + { + throw new InvalidOperationException("No publish model card was found."); + } - using IUnitOfWork sendOperation = _unitOfWorkFactory.Resolve(); - - string versionId = await sendOperation.Service - .Execute( - modelCard.SendFilter, - modelCard.AccountId, - modelCard.ProjectId, - modelCard.ModelId, - (status, progress) => OnSendOperationProgress(modelCardId, status, progress), - cts.Token - ) - .ConfigureAwait(false); + using IUnitOfWork sendOperation = _unitOfWorkFactory.Resolve(); + + string versionId = await sendOperation.Service + .Execute( + modelCard.SendFilter, + modelCard.AccountId, + modelCard.ProjectId, + modelCard.ModelId, + (status, progress) => OnSendOperationProgress(modelCardId, status, progress), + cts.Token + ) + .ConfigureAwait(false); - Commands.SetModelCreatedVersionId(modelCardId, versionId); + Commands.SetModelCreatedVersionId(modelCardId, versionId); + } + catch (OperationCanceledException) + { + return; + } + catch (Exception e) when (!e.IsFatal()) // All exceptions should be handled here if possible, otherwise we enter "crashing the host app" territory. + { + Commands.SetModelError(modelCardId, e); + } } private void OnSendOperationProgress(string modelCardId, string status, double? progress) From 444000e1cdc64826c69eeb1d1ac0e9dcf3b9230c Mon Sep 17 00:00:00 2001 From: connorivy <43247197+connorivy@users.noreply.github.com> Date: Thu, 2 May 2024 07:45:51 -0500 Subject: [PATCH 076/261] Fix(Revit) : add possible length units (#3337) * Add alternate feet and meters * add fractional inches --------- Co-authored-by: Connor Ivy --- .../Services/RevitToSpeckleUnitConverter.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Services/RevitToSpeckleUnitConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Services/RevitToSpeckleUnitConverter.cs index 6fe01ccbaf..e1d7a7a62b 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Services/RevitToSpeckleUnitConverter.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Services/RevitToSpeckleUnitConverter.cs @@ -13,8 +13,11 @@ public RevitToSpeckleUnitConverter() _unitMapping[DB.UnitTypeId.Millimeters] = Units.Millimeters; _unitMapping[DB.UnitTypeId.Centimeters] = Units.Centimeters; _unitMapping[DB.UnitTypeId.Meters] = Units.Meters; + _unitMapping[DB.UnitTypeId.MetersCentimeters] = Units.Meters; _unitMapping[DB.UnitTypeId.Inches] = Units.Inches; + _unitMapping[DB.UnitTypeId.FractionalInches] = Units.Inches; _unitMapping[DB.UnitTypeId.Feet] = Units.Feet; + _unitMapping[DB.UnitTypeId.FeetFractionalInches] = Units.Feet; } // POC: maybe just convert, it's not a Try method From 598dc8fe53168b9e2743d5762ba13c27b25217c2 Mon Sep 17 00:00:00 2001 From: connorivy <43247197+connorivy@users.noreply.github.com> Date: Thu, 2 May 2024 09:34:05 -0500 Subject: [PATCH 077/261] CNX-9230 Revit Wall send (#3322) * convert wall as stacked or as curtain wall * use curveArrArray converter * address PR comments --------- Co-authored-by: Connor Ivy --- .../Extensions/ElementExtensions.cs | 35 ++++++ ...urveArrArrayToSpecklePolycurveConverter.cs | 34 ++++++ .../RevitConverterToSpeckle.cs | 2 + .../Speckle.Converters.RevitShared.projitems | 2 + .../HostedElementConversionToSpeckle.cs | 38 ++---- .../ToSpeckle/WallConversionToSpeckle.cs | 113 +++++++++++------- 6 files changed, 148 insertions(+), 76 deletions(-) create mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Extensions/ElementExtensions.cs create mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/CurveArrArrayToSpecklePolycurveConverter.cs diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Extensions/ElementExtensions.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Extensions/ElementExtensions.cs new file mode 100644 index 0000000000..468a98fd0f --- /dev/null +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Extensions/ElementExtensions.cs @@ -0,0 +1,35 @@ +using Autodesk.Revit.DB; + +namespace Speckle.Converters.RevitShared.Extensions; + +public static class ElementExtensions +{ + // POC: should this be an injected service? + public static IList GetHostedElementIds(this Element host) + { + IList ids; + if (host is HostObject hostObject) + { + ids = hostObject.FindInserts(true, false, false, false); + } + else + { + var typeFilter = new ElementIsElementTypeFilter(true); + var categoryFilter = new ElementMulticategoryFilter( + new List() + { + BuiltInCategory.OST_CLines, + BuiltInCategory.OST_SketchLines, + BuiltInCategory.OST_WeakDims + }, + true + ); + ids = host.GetDependentElements(new LogicalAndFilter(typeFilter, categoryFilter)); + } + + // dont include host elementId + ids.Remove(host.Id); + + return ids; + } +} diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/CurveArrArrayToSpecklePolycurveConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/CurveArrArrayToSpecklePolycurveConverter.cs new file mode 100644 index 0000000000..95c07ece74 --- /dev/null +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/CurveArrArrayToSpecklePolycurveConverter.cs @@ -0,0 +1,34 @@ +using Autodesk.Revit.DB; +using Objects.Geometry; +using Speckle.Converters.Common.Objects; + +namespace Speckle.Converters.RevitShared.Raw; + +internal class CurveArrArrayToSpecklePolycurveConverter : IRawConversion> +{ + private readonly IRawConversion _curveArrayConverter; + + public CurveArrArrayToSpecklePolycurveConverter(IRawConversion curveArrayConverter) + { + _curveArrayConverter = curveArrayConverter; + } + + public List RawConvert(CurveArrArray target) + { + List polycurves = new(); + foreach (var curveArray in GetCurveArrays(target)) + { + polycurves.Add(_curveArrayConverter.RawConvert(curveArray)); + } + + return polycurves; + } + + private IEnumerable GetCurveArrays(DB.CurveArrArray curveArrArray) + { + for (var i = 0; i < curveArrArray.Size; i++) + { + yield return curveArrArray.get_Item(i); + } + } +} diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/RevitConverterToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/RevitConverterToSpeckle.cs index b93623f2b9..c7539aaa88 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/RevitConverterToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/RevitConverterToSpeckle.cs @@ -53,6 +53,8 @@ public Base Convert(object target) return result; } + // POC: consider making this a more accessible as a pattern to other connectors + // https://spockle.atlassian.net/browse/CNX-9397 private IHostObjectToSpeckleConversion? GetConversionForObject(Type objectType) { if (objectType == typeof(object)) diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Speckle.Converters.RevitShared.projitems b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Speckle.Converters.RevitShared.projitems index accc5ce2c1..9b2a1fc752 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Speckle.Converters.RevitShared.projitems +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Speckle.Converters.RevitShared.projitems @@ -12,6 +12,7 @@ + @@ -21,6 +22,7 @@ + diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/HostedElementConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/HostedElementConversionToSpeckle.cs index 7d2b61fe15..0af482a6f3 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/HostedElementConversionToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/HostedElementConversionToSpeckle.cs @@ -1,5 +1,6 @@ using Autodesk.Revit.DB; using Speckle.Converters.Common; +using Speckle.Converters.RevitShared.Extensions; using Speckle.Converters.RevitShared.Helpers; using Speckle.Core.Models; @@ -24,10 +25,13 @@ ISpeckleConverterToSpeckle converter public List GetHostedElementsConverted(Element host) { - var convertedHostedElements = new List(); - - var hostedElementIds = GetHostedElementIds(host); + return GetHostedElementsConvertedFromIds(host, host.GetHostedElementIds()); + } + // POC: needs to be reviewed + public List GetHostedElementsConvertedFromIds(Element host, IList hostedElementIds) + { + var convertedHostedElements = new List(); foreach (var elemId in hostedElementIds) { var element = host.Document.GetElement(elemId); @@ -41,32 +45,4 @@ public List GetHostedElementsConverted(Element host) return convertedHostedElements; } - - private static IList GetHostedElementIds(Element host) - { - IList ids; - if (host is HostObject hostObject) - { - ids = hostObject.FindInserts(true, false, false, false); - } - else - { - var typeFilter = new ElementIsElementTypeFilter(true); - var categoryFilter = new ElementMulticategoryFilter( - new List() - { - BuiltInCategory.OST_CLines, - BuiltInCategory.OST_SketchLines, - BuiltInCategory.OST_WeakDims - }, - true - ); - ids = host.GetDependentElements(new LogicalAndFilter(typeFilter, categoryFilter)); - } - - // dont include host elementId - ids.Remove(host.Id); - - return ids; - } } diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/WallConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/WallConversionToSpeckle.cs index 69411511e3..e1e78dee17 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/WallConversionToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/WallConversionToSpeckle.cs @@ -4,6 +4,8 @@ using Speckle.Converters.RevitShared.Helpers; using Speckle.Core.Models; using Speckle.Core.Models.Extensions; +using Speckle.Converters.RevitShared.Extensions; +using Objects.BuiltElements.Revit; namespace Speckle.Converters.RevitShared.ToSpeckle; @@ -14,38 +16,49 @@ public class WallConversionToSpeckle : BaseConversionToSpeckle _curveConverter; private readonly IRawConversion _levelConverter; - private readonly IRawConversion _curveArrayConverter; + private readonly IRawConversion> _curveArrArrayConverter; private readonly ParameterValueExtractor _parameterValueExtractor; private readonly RevitConversionContextStack _contextStack; private readonly DisplayValueExtractor _displayValueExtractor; - private readonly HostedElementConversionToSpeckle _hostedElementConverter; private readonly ParameterObjectAssigner _parameterObjectAssigner; + private readonly ISpeckleConverterToSpeckle _converter; public WallConversionToSpeckle( IRawConversion curveConverter, IRawConversion levelConverter, + IRawConversion> curveArrArrayConverter, RevitConversionContextStack contextStack, ParameterValueExtractor parameterValueExtractor, DisplayValueExtractor displayValueExtractor, - IRawConversion curveArrayConverter, - HostedElementConversionToSpeckle hostedElementConverter, - ParameterObjectAssigner parameterObjectAssigner + ParameterObjectAssigner parameterObjectAssigner, + ISpeckleConverterToSpeckle converter ) { _curveConverter = curveConverter; _levelConverter = levelConverter; + _curveArrArrayConverter = curveArrArrayConverter; _contextStack = contextStack; _parameterValueExtractor = parameterValueExtractor; _displayValueExtractor = displayValueExtractor; - _curveArrayConverter = curveArrayConverter; - _hostedElementConverter = hostedElementConverter; _parameterObjectAssigner = parameterObjectAssigner; + _converter = converter; } public override SOBR.RevitWall RawConvert(DB.Wall target) { SOBR.RevitWall speckleWall = new() { family = target.WallType.FamilyName.ToString(), type = target.WallType.Name }; + AssignSpecificParameters(target, speckleWall); + AssignVoids(target, speckleWall); + AssignHostedElements(speckleWall, GetChildElements(target)); + AssignDisplayValue(target, speckleWall); + _parameterObjectAssigner.AssignParametersToBase(target, speckleWall); + + return speckleWall; + } + + private void AssignSpecificParameters(DB.Wall target, RevitWall speckleWall) + { if (target.Location is not DB.LocationCurve locationCurve) { throw new SpeckleConversionException( @@ -76,64 +89,74 @@ public override SOBR.RevitWall RawConvert(DB.Wall target) speckleWall.structural = _parameterValueExtractor.GetValueAsBool(target, DB.BuiltInParameter.WALL_STRUCTURAL_SIGNIFICANT) ?? false; speckleWall.flipped = target.Flipped; - - speckleWall.displayValue = _displayValueExtractor.GetDisplayValue(target); - - AssignVoids(target, speckleWall); - AssignHostedElements(target, speckleWall); - - _parameterObjectAssigner.AssignParametersToBase(target, speckleWall); - - return speckleWall; } - // POC: not sure - private void AssignHostedElements(DB.Wall target, SOBR.RevitWall speckleWall) + private List GetChildElements(DB.Wall target) { - List hostedObjects = _hostedElementConverter.GetHostedElementsConverted(target); - if (hostedObjects.Count > 0) + List wallChildren = new(); + if (target.CurtainGrid is DB.CurtainGrid grid) + { + wallChildren.AddRange(ConvertElements(grid.GetMullionIds())); + wallChildren.AddRange(ConvertElements(grid.GetPanelIds())); + } + else if (target.IsStackedWall) { - if (speckleWall.GetDetachedProp("elements") is List elements) - { - elements.AddRange(hostedObjects); - } - else - { - speckleWall.SetDetachedProp("elements", hostedObjects); - } + wallChildren.AddRange(ConvertElements(target.GetStackedWallMemberIds())); } + wallChildren.AddRange(ConvertElements(target.GetHostedElementIds())); + return wallChildren; } - private void AssignVoids(DB.Wall target, SOBR.RevitWall speckleWall) + private IEnumerable ConvertElements(IEnumerable elementIds) { - List voids = GetWallVoids(target); - List polycurves = voids.Select(v => _curveArrayConverter.RawConvert(v)).ToList(); + foreach (DB.ElementId elementId in elementIds) + { + yield return _converter.Convert(_contextStack.Current.Document.Document.GetElement(elementId)); + } + } - if (polycurves.Count > 0) + private void AssignDisplayValue(DB.Wall target, RevitWall speckleWall) + { + if (target.CurtainGrid is null) { - speckleWall["voids"] = polycurves; + speckleWall.displayValue = _displayValueExtractor.GetDisplayValue(target); } + speckleWall.displayValue = new List(); } - private List GetWallVoids(DB.Wall wall) + private void AssignHostedElements(SOBR.RevitWall speckleWall, List hostedObjects) { - List curveArrays = new(); - var profile = ((DB.Sketch)_contextStack.Current.Document.Document.GetElement(wall.SketchId))?.Profile; + if (hostedObjects.Count == 0) + { + return; + } - if (profile == null) + if (speckleWall.GetDetachedProp("elements") is List elements) { - return curveArrays; + elements.AddRange(hostedObjects); } + else + { + speckleWall.SetDetachedProp("elements", hostedObjects); + } + } - for (var i = 1; i < profile.Size; i++) + private void AssignVoids(DB.Wall target, SOBR.RevitWall speckleWall) + { + DB.CurveArrArray? profile = ((DB.Sketch)target.Document.GetElement(target.SketchId))?.Profile; + if (profile is null) { - var segments = profile.get_Item(i); - if (segments.Cast().Count() > 2) - { - curveArrays.Add(segments); - } + return; } - return curveArrays; + List polycurves = _curveArrArrayConverter.RawConvert(profile); + + if (polycurves.Count > 1) + { + // POC: we have been assuming that the first curve is the element and the rest of the curves are openings + // this isn't always true + // https://spockle.atlassian.net/browse/CNX-9396 + speckleWall["voids"] = polycurves.Skip(1).ToList(); + } } } From 80472304456793fb4860d9dacd271f9ac811da0d Mon Sep 17 00:00:00 2001 From: oguzhankoral Date: Thu, 2 May 2024 18:32:17 +0300 Subject: [PATCH 078/261] Switch documents work with random crashes.. (WIP) --- .../Bindings/BasicConnectorBindingRevit.cs | 6 +- .../Bindings/ReceiveBinding.cs | 3 +- .../Bindings/RevitBaseBinding.cs | 5 +- .../Bindings/SelectionBinding.cs | 3 +- .../Bindings/SendBinding.cs | 3 +- .../DependencyInjection/AutofacUIModule.cs | 10 +- .../HostApp/RevitDocumentStore.cs | 92 ++++++++++--------- 7 files changed, 64 insertions(+), 58 deletions(-) diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/BasicConnectorBindingRevit.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/BasicConnectorBindingRevit.cs index c36cbe16ee..5df1b8b7d3 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/BasicConnectorBindingRevit.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/BasicConnectorBindingRevit.cs @@ -21,12 +21,12 @@ internal class BasicConnectorBindingRevit : IBasicConnectorBinding public string Name { get; private set; } public IBridge Parent { get; private set; } - protected readonly RevitDocumentStore _store; + protected readonly DocumentModelStore _store; protected readonly RevitContext _revitContext; private readonly RevitSettings _revitSettings; public BasicConnectorBindingRevit( - RevitDocumentStore store, + DocumentModelStore store, RevitSettings revitSettings, IBridge parent, RevitContext revitContext @@ -41,7 +41,7 @@ RevitContext revitContext // POC: event binding? _store.DocumentChanged += (_, _) => { - parent.Send(Name, BasicConnectorBindingEvents.DOCUMENT_CHANGED); + Commands.NotifyDocumentChanged(); }; } diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/ReceiveBinding.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/ReceiveBinding.cs index f0276817ed..973b3c8741 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/ReceiveBinding.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/ReceiveBinding.cs @@ -1,5 +1,6 @@ using System; using Speckle.Connectors.DUI.Bridge; +using Speckle.Connectors.DUI.Models; using Speckle.Connectors.Revit.HostApp; using Speckle.Connectors.Utils.Cancellation; using Speckle.Converters.RevitShared.Helpers; @@ -11,7 +12,7 @@ internal class ReceiveBinding : RevitBaseBinding, ICancelable { public CancellationManager CancellationManager { get; } = new(); - public ReceiveBinding(RevitContext revitContext, RevitDocumentStore store, IBridge bridge) + public ReceiveBinding(RevitContext revitContext, DocumentModelStore store, IBridge bridge) : base("receiveBinding", store, bridge, revitContext) { } public void CancelReceive(string modelCardId) => CancellationManager.CancelOperation(modelCardId); diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/RevitBaseBinding.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/RevitBaseBinding.cs index c12492bb2d..ff19828a48 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/RevitBaseBinding.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/RevitBaseBinding.cs @@ -1,5 +1,6 @@ using Speckle.Connectors.DUI.Bindings; using Speckle.Connectors.DUI.Bridge; +using Speckle.Connectors.DUI.Models; using Speckle.Connectors.Revit.HostApp; using Speckle.Converters.RevitShared.Helpers; @@ -11,10 +12,10 @@ internal abstract class RevitBaseBinding : IBinding public string Name { get; protected set; } public IBridge Parent { get; protected set; } - protected readonly RevitDocumentStore _store; + protected readonly DocumentModelStore _store; protected readonly RevitContext _revitContext; - public RevitBaseBinding(string name, RevitDocumentStore store, IBridge bridge, RevitContext revitContext) + public RevitBaseBinding(string name, DocumentModelStore store, IBridge bridge, RevitContext revitContext) { Name = name; Parent = bridge; diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SelectionBinding.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SelectionBinding.cs index 6c4f9aa741..d25e740029 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SelectionBinding.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SelectionBinding.cs @@ -3,6 +3,7 @@ using Autodesk.Revit.DB; using Speckle.Connectors.DUI.Bindings; using Speckle.Connectors.DUI.Bridge; +using Speckle.Connectors.DUI.Models; using Speckle.Connectors.Revit.HostApp; using Speckle.Connectors.Revit.Plugin; using Speckle.Converters.RevitShared.Helpers; @@ -16,7 +17,7 @@ internal class SelectionBinding : RevitBaseBinding, ISelectionBinding public SelectionBinding( RevitContext revitContext, - RevitDocumentStore store, + DocumentModelStore store, IRevitIdleManager idleManager, IBridge bridge ) diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SendBinding.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SendBinding.cs index 2a092b79e5..41f905a851 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SendBinding.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SendBinding.cs @@ -16,6 +16,7 @@ using Speckle.Connectors.DUI.Models.Card; using Speckle.Connectors.DUI.Bindings; using Speckle.Autofac.DependencyInjection; +using Speckle.Connectors.DUI.Models; namespace Speckle.Connectors.Revit.Bindings; @@ -33,7 +34,7 @@ internal class SendBinding : RevitBaseBinding, ICancelable, ISendBinding public SendBinding( IRevitIdleManager idleManager, RevitContext revitContext, - RevitDocumentStore store, + DocumentModelStore store, IBridge bridge, IUnitOfWorkFactory unitOfWorkFactory ) diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/AutofacUIModule.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/AutofacUIModule.cs index 1e4043563f..5fed7ce26c 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/AutofacUIModule.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/AutofacUIModule.cs @@ -59,9 +59,12 @@ protected override void Load(ContainerBuilder builder) builder.RegisterType().As().SingleInstance(); builder.RegisterType().As().InstancePerDependency(); + // register + builder.RegisterType().As().SingleInstance(); + // Storage Schema - builder.RegisterType().AsSelf().InstancePerLifetimeScope(); - builder.RegisterType().AsSelf().InstancePerLifetimeScope(); + builder.RegisterType().InstancePerLifetimeScope(); + builder.RegisterType().InstancePerLifetimeScope(); // POC: we need to review the scopes and create a document on what the policy is // and where the UoW should be @@ -85,9 +88,6 @@ protected override void Load(ContainerBuilder builder) builder.RegisterType().As().InstancePerDependency(); builder.RegisterType().As().SingleInstance(); - // register - builder.RegisterType().As().SingleInstance().AsSelf(); - // POC: this can be injected in maybe a common place, perhaps a module in Speckle.Converters.Common.DependencyInjection builder.RegisterType().As().InstancePerLifetimeScope(); diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/RevitDocumentStore.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/RevitDocumentStore.cs index 9bdb6cda3f..a223626dd9 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/RevitDocumentStore.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/RevitDocumentStore.cs @@ -43,9 +43,28 @@ IdStorageSchema idStorageSchema uiApplication.ApplicationClosing += (_, _) => WriteToFile(); - uiApplication.Application.DocumentSaving += (_, _) => WriteToFile(); - uiApplication.Application.DocumentSynchronizingWithCentral += (_, _) => WriteToFile(); + //uiApplication.Application.DocumentSaving += (_, _) => WriteToFile(); + //uiApplication.Application.DocumentSavingAs += (_, _) => WriteToFile(); + //uiApplication.Application.DocumentClosing += (_, _) => WriteToFile(); + //uiApplication.Application.DocumentSynchronizingWithCentral += (_, _) => WriteToFile(); + // This is the place where we track document switch for old document -> Responsible to Write into old + uiApplication.ViewActivating += (_, e) => + { + if (e.Document == null) + { + return; + } + + if (e.NewActiveView.Document.Equals(e.CurrentActiveView.Document)) + { + return; + } + + WriteToFile(); + }; + + // This is the place where we track document switch for new document -> Responsible to Read from new doc uiApplication.ViewActivated += (_, e) => { if (e.Document == null) @@ -53,7 +72,8 @@ IdStorageSchema idStorageSchema return; } - if (e.PreviousActiveView?.Document.PathName == e.CurrentActiveView.Document.PathName) + // Return only if we are switching views that belongs to same document + if (e.PreviousActiveView is not null && e.PreviousActiveView.Document.Equals(e.CurrentActiveView.Document)) { return; } @@ -64,7 +84,7 @@ IdStorageSchema idStorageSchema }; uiApplication.Application.DocumentOpening += (_, _) => IsDocumentInit = false; - uiApplication.Application.DocumentOpened += (_, _) => IsDocumentInit = false; + //uiApplication.Application.DocumentOpened += (_, _) => IsDocumentInit = false; } public override void WriteToFile() @@ -77,47 +97,29 @@ public override void WriteToFile() return; } - /*_syncToMainThread - .RunOnThread(() => - { - // POC: re-instate - using Transaction t = new(doc.Document, "Speckle Write State"); - t.Start(); - using DataStorage ds = GetSettingsDataStorage(doc.Document) ?? DataStorage.Create(doc.Document); - - using Entity stateEntity = new(_documentModelStorageSchema.GetSchema()); - string serializedModels = Serialize(); - stateEntity.Set("contents", serializedModels); - - using Entity idEntity = new(_idStorageSchema.GetSchema()); - idEntity.Set("Id", s_revitDocumentStoreId); - - ds.SetEntity(idEntity); - ds.SetEntity(stateEntity); - t.Commit(); - - return Task.CompletedTask; - }) - .ConfigureAwait(false);*/ + // NOTE: Document switched fixed by putting seralization outside of the RevitTask, otherwise it tries to serialize + // empty document state since we create new one per document. + string serializedModels = Serialize(); // POC: previously we were calling below code - // RevitTask.RunAsync(() => { - // POC: re-instate - //using Transaction t = new(doc.Document, "Speckle Write State"); - //t.Start(); - //using DataStorage ds = GetSettingsDataStorage(doc.Document) ?? DataStorage.Create(doc.Document); - - //using Entity stateEntity = new(DocumentModelStoreSchema.GetSchema()); - //string serializedModels = Serialize(); - //stateEntity.Set("contents", serializedModels); - - //using Entity idEntity = new(IdStorageSchema.GetSchema()); - //idEntity.Set("Id", s_revitDocumentStoreId); - - //ds.SetEntity(idEntity); - //ds.SetEntity(stateEntity); - //t.Commit(); - // }); + RevitTask.RunAsync(() => + { + // POC: re-instate + using Transaction t = new(doc.Document, "Speckle Write State"); + t.Start(); + using DataStorage ds = GetSettingsDataStorage(doc.Document) ?? DataStorage.Create(doc.Document); + + using Entity stateEntity = new(_documentModelStorageSchema.GetSchema()); + // string serializedModels = Serialize(); + stateEntity.Set("contents", serializedModels); + + using Entity idEntity = new(_idStorageSchema.GetSchema()); + idEntity.Set("Id", s_revitDocumentStoreId); + + ds.SetEntity(idEntity); + ds.SetEntity(stateEntity); + t.Commit(); + }); } public override void ReadFromFile() @@ -141,7 +143,7 @@ public override void ReadFromFile() } } - private DataStorage GetSettingsDataStorage(Document doc) + private DataStorage? GetSettingsDataStorage(Document doc) { // POC: re-instate using FilteredElementCollector collector = new(doc); @@ -168,7 +170,7 @@ private DataStorage GetSettingsDataStorage(Document doc) return null; } - private Entity GetSpeckleEntity(Document doc) + private Entity? GetSpeckleEntity(Document doc) { // POC: re-instate using FilteredElementCollector collector = new(doc); From 2bda53cb554680d15420c32f122cbd3d298ae660 Mon Sep 17 00:00:00 2001 From: BovineOx <73857041+BovineOx@users.noreply.github.com> Date: Thu, 2 May 2024 17:11:33 +0100 Subject: [PATCH 079/261] Cnx 9229 revit topography (#3338) * Topography Initial push * Comments and AssignParametersToBase() * Global using & ELementId, ApplicationId testing --- .../GlobalUsings.cs | 2 ++ .../Helpers/DisplayValueExtractor.cs | 2 +- .../Speckle.Converters.RevitShared.projitems | 1 + .../ToSpeckle/BaseConversionToSpeckle.cs | 5 +++ .../ToSpeckle/RoomConversionToSpeckle.cs | 2 -- .../TopographyConversionToSpeckle.cs | 36 +++++++++++++++++++ 6 files changed, 45 insertions(+), 3 deletions(-) create mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/TopographyConversionToSpeckle.cs diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/GlobalUsings.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/GlobalUsings.cs index be6d833eb9..4839a81393 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/GlobalUsings.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/GlobalUsings.cs @@ -1,4 +1,6 @@ global using DB = Autodesk.Revit.DB; +global using DBA = Autodesk.Revit.DB.Architecture; global using UI = Autodesk.Revit.UI; global using SOG = Objects.Geometry; global using SOBR = Objects.BuiltElements.Revit; +global using SOBE = Objects.BuiltElements; diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/DisplayValueExtractor.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/DisplayValueExtractor.cs index be2e60bb52..017b8946ff 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/DisplayValueExtractor.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/DisplayValueExtractor.cs @@ -3,7 +3,7 @@ namespace Speckle.Converters.RevitShared.Helpers; -// POC: class is kind of big and could do with breaking down +// POC: needs breaking down https://spockle.atlassian.net/browse/CNX-9354 public sealed class DisplayValueExtractor { private readonly IRawConversion>, List> _meshByMaterialConverter; diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Speckle.Converters.RevitShared.projitems b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Speckle.Converters.RevitShared.projitems index 9b2a1fc752..fb0d95d38f 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Speckle.Converters.RevitShared.projitems +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Speckle.Converters.RevitShared.projitems @@ -49,6 +49,7 @@ + diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/BaseConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/BaseConversionToSpeckle.cs index afe0706ae2..a91f949110 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/BaseConversionToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/BaseConversionToSpeckle.cs @@ -5,14 +5,19 @@ namespace Speckle.Converters.RevitShared.ToSpeckle; // POC: maybe but could be generic abstract Converters.Common? +// or maybe it's not actually doing very much now and can come out public abstract class BaseConversionToSpeckle : IHostObjectToSpeckleConversion, + // POC: why do we need to do this for each base conversion? IRawConversion where TSpeckle : Base { public Base Convert(object target) { var result = RawConvert((THost)target); + + // POC: unless I am going bonkers, we've constrained TSpeckle to Base + // so it should always BE base? if (result is not Base @base) { throw new SpeckleConversionException( diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/RoomConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/RoomConversionToSpeckle.cs index c5767f9b86..0c829ec684 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/RoomConversionToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/RoomConversionToSpeckle.cs @@ -3,8 +3,6 @@ using Speckle.Converters.Common.Objects; using Speckle.Converters.RevitShared.Helpers; using Speckle.Core.Models; -using DBA = Autodesk.Revit.DB.Architecture; -using SOBE = Objects.BuiltElements; namespace Speckle.Converters.RevitShared.ToSpeckle; diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/TopographyConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/TopographyConversionToSpeckle.cs new file mode 100644 index 0000000000..f26cbfb6a6 --- /dev/null +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/TopographyConversionToSpeckle.cs @@ -0,0 +1,36 @@ +using Speckle.Converters.Common; +using Speckle.Converters.RevitShared.Helpers; + +namespace Speckle.Converters.RevitShared.ToSpeckle; + +// POC: needs review feels, BIG, feels like it could be broken down.. +// i.e. GetParams(), GetGeom()? feels like it's doing too much +[NameAndRankValue(nameof(DBA.TopographySurface), 0)] +public class TopographyConversionToSpeckle : BaseConversionToSpeckle +{ + private readonly DisplayValueExtractor _displayValueExtractor; + private readonly ParameterObjectAssigner _parameterObjectAssigner; + + public TopographyConversionToSpeckle( + DisplayValueExtractor displayValueExtractor, + ParameterObjectAssigner parameterObjectAssigner + ) + { + _displayValueExtractor = displayValueExtractor; + _parameterObjectAssigner = parameterObjectAssigner; + } + + public override SOBR.RevitTopography RawConvert(DBA.TopographySurface target) + { + var speckleTopo = new SOBR.RevitTopography + { + displayValue = _displayValueExtractor.GetDisplayValue(target), + elementId = target.Id.ToString() + }; + + // POC: shouldn't we just do this in the RevitConverterToSpeckle ? + _parameterObjectAssigner.AssignParametersToBase(target, speckleTopo); + + return speckleTopo; + } +} From 2ee5443c434e4ee7ec66e70009b4c51ffccef7e8 Mon Sep 17 00:00:00 2001 From: oguzhankoral Date: Thu, 2 May 2024 19:57:26 +0300 Subject: [PATCH 080/261] Await task --- .../HostApp/RevitDocumentStore.cs | 37 ++++++++++--------- 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/RevitDocumentStore.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/RevitDocumentStore.cs index a223626dd9..64b04ecdaa 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/RevitDocumentStore.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/RevitDocumentStore.cs @@ -102,24 +102,25 @@ public override void WriteToFile() string serializedModels = Serialize(); // POC: previously we were calling below code - RevitTask.RunAsync(() => - { - // POC: re-instate - using Transaction t = new(doc.Document, "Speckle Write State"); - t.Start(); - using DataStorage ds = GetSettingsDataStorage(doc.Document) ?? DataStorage.Create(doc.Document); - - using Entity stateEntity = new(_documentModelStorageSchema.GetSchema()); - // string serializedModels = Serialize(); - stateEntity.Set("contents", serializedModels); - - using Entity idEntity = new(_idStorageSchema.GetSchema()); - idEntity.Set("Id", s_revitDocumentStoreId); - - ds.SetEntity(idEntity); - ds.SetEntity(stateEntity); - t.Commit(); - }); + RevitTask + .RunAsync(() => + { + using Transaction t = new(doc.Document, "Speckle Write State"); + t.Start(); + using DataStorage ds = GetSettingsDataStorage(doc.Document) ?? DataStorage.Create(doc.Document); + + using Entity stateEntity = new(_documentModelStorageSchema.GetSchema()); + // string serializedModels = Serialize(); + stateEntity.Set("contents", serializedModels); + + using Entity idEntity = new(_idStorageSchema.GetSchema()); + idEntity.Set("Id", s_revitDocumentStoreId); + + ds.SetEntity(idEntity); + ds.SetEntity(stateEntity); + t.Commit(); + }) + .ConfigureAwait(false); } public override void ReadFromFile() From cc10509fc9ccad82083a6090842f3d25da7844f2 Mon Sep 17 00:00:00 2001 From: connorivy <43247197+connorivy@users.noreply.github.com> Date: Fri, 3 May 2024 04:58:34 -0500 Subject: [PATCH 081/261] CNX-9227 send floors from Revit (#3346) * send floors * fix: Address comments by Ian * fix: Removed `as` pattern in favor of direct cast to prevent null warnings. --------- Co-authored-by: Connor Ivy Co-authored-by: Alan Rynne --- .../AutofacRevitConverterModule.cs | 1 + .../Helpers/ISlopeArrowExtractor.cs | 10 ++ .../Helpers/SlopeArrowExtractor.cs | 108 ++++++++++++++++++ .../Speckle.Converters.RevitShared.projitems | 3 + .../ToSpeckle/FloorConversionToSpeckle.cs | 96 +++++++++++++++- 5 files changed, 216 insertions(+), 2 deletions(-) create mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/ISlopeArrowExtractor.cs create mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/SlopeArrowExtractor.cs diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/AutofacRevitConverterModule.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/AutofacRevitConverterModule.cs index a60a27a4a9..edae0982a6 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/AutofacRevitConverterModule.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/AutofacRevitConverterModule.cs @@ -49,5 +49,6 @@ protected override void Load(ContainerBuilder builder) builder.RegisterType().AsSelf().InstancePerLifetimeScope(); builder.RegisterType().AsSelf().InstancePerLifetimeScope(); builder.RegisterType().AsSelf().InstancePerLifetimeScope(); + builder.RegisterType().As().InstancePerLifetimeScope(); } } diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/ISlopeArrowExtractor.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/ISlopeArrowExtractor.cs new file mode 100644 index 0000000000..750f4d1073 --- /dev/null +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/ISlopeArrowExtractor.cs @@ -0,0 +1,10 @@ +namespace Speckle.Converters.RevitShared.Helpers; + +public interface ISlopeArrowExtractor +{ + DB.ModelLine? GetSlopeArrow(DB.Element element); + SOG.Point GetSlopeArrowHead(DB.ModelLine slopeArrow); + SOG.Point GetSlopeArrowTail(DB.ModelLine slopeArrow); + double GetSlopeArrowTailOffset(DB.ModelLine slopeArrow); + double GetSlopeArrowHeadOffset(DB.ModelLine slopeArrow, double tailOffset, out double slope); +} diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/SlopeArrowExtractor.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/SlopeArrowExtractor.cs new file mode 100644 index 0000000000..6f9d759279 --- /dev/null +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/SlopeArrowExtractor.cs @@ -0,0 +1,108 @@ +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; + +namespace Speckle.Converters.RevitShared.Helpers; + +public class SlopeArrowExtractor : ISlopeArrowExtractor +{ + private readonly IRawConversion _pointConverter; + private readonly ParameterValueExtractor _parameterValueExtractor; + + public SlopeArrowExtractor( + IRawConversion pointConverter, + ParameterValueExtractor parameterValueExtractor + ) + { + _pointConverter = pointConverter; + _parameterValueExtractor = parameterValueExtractor; + } + + public DB.ModelLine? GetSlopeArrow(DB.Element element) + { + IList? elementIds = null; + if (element is DB.Floor floor) + { + elementIds = ((DB.Sketch)floor.Document.GetElement(floor.SketchId)).GetAllElements(); + } + + if (elementIds == null) + { + using var modelLineFilter = new DB.ElementCategoryFilter(DB.BuiltInCategory.OST_SketchLines); + elementIds = element.GetDependentElements(modelLineFilter); + } + + foreach (var elementId in elementIds) + { + if (element.Document.GetElement(elementId) is not DB.ModelLine line) + { + continue; + } + + var offsetAtTailParameter = line.get_Parameter(DB.BuiltInParameter.SLOPE_START_HEIGHT); + if (offsetAtTailParameter != null) + { + return line; + } + } + return null; + } + + public SOG.Point GetSlopeArrowHead(DB.ModelLine slopeArrow) + { + return _pointConverter.RawConvert(((DB.LocationCurve)slopeArrow.Location).Curve.GetEndPoint(1)); + } + + public SOG.Point GetSlopeArrowTail(DB.ModelLine slopeArrow) + { + return _pointConverter.RawConvert(((DB.LocationCurve)slopeArrow.Location).Curve.GetEndPoint(0)); + } + + public double GetSlopeArrowTailOffset(DB.ModelLine slopeArrow) + { + return _parameterValueExtractor.GetValueAsDouble(slopeArrow, DB.BuiltInParameter.SLOPE_START_HEIGHT) + ?? throw new SpeckleConversionException( + $"Unexpected null value for slope arrow property {nameof(DB.BuiltInParameter.SLOPE_START_HEIGHT)}" + ); + } + + public double GetSlopeArrowHeadOffset(DB.ModelLine slopeArrow, double tailOffset, out double slope) + { + var specifyOffset = + _parameterValueExtractor.GetValueAsInt(slopeArrow, DB.BuiltInParameter.SPECIFY_SLOPE_OR_OFFSET) + ?? throw new SpeckleConversionException( + $"Unexpected null value for slope arrow property {nameof(DB.BuiltInParameter.SPECIFY_SLOPE_OR_OFFSET)}" + ); + + var lineLength = + _parameterValueExtractor.GetValueAsDouble(slopeArrow, DB.BuiltInParameter.CURVE_ELEM_LENGTH) + ?? throw new SpeckleConversionException( + $"Unexpected null value for slope arrow property {nameof(DB.BuiltInParameter.CURVE_ELEM_LENGTH)}" + ); + + slope = 0; + double headOffset = 0; + // 1 corrosponds to the "slope" option + if (specifyOffset == 1) + { + // in this scenario, slope is returned as a percentage. Divide by 100 to get the unitless form + slope = + _parameterValueExtractor.GetValueAsDouble(slopeArrow, DB.BuiltInParameter.ROOF_SLOPE) / 100d + ?? throw new SpeckleConversionException( + $"Unexpected null value for slope arrow property {nameof(DB.BuiltInParameter.ROOF_SLOPE)}" + ); + headOffset = tailOffset + lineLength * Math.Sin(Math.Atan(slope)); + } + else if (specifyOffset == 0) // 0 corrospondes to the "height at tail" option + { + headOffset = + _parameterValueExtractor.GetValueAsDouble(slopeArrow, DB.BuiltInParameter.SLOPE_END_HEIGHT) + ?? throw new SpeckleConversionException( + $"Unexpected null value for slope arrow property {nameof(DB.BuiltInParameter.ROOF_SLOPE)}" + ); + + slope = (headOffset - tailOffset) / lineLength; + } + + return headOffset; + } +} diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Speckle.Converters.RevitShared.projitems b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Speckle.Converters.RevitShared.projitems index fb0d95d38f..94aae2d0f5 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Speckle.Converters.RevitShared.projitems +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Speckle.Converters.RevitShared.projitems @@ -9,6 +9,8 @@ Speckle.Converters.RevitShared + + @@ -49,6 +51,7 @@ + diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/FloorConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/FloorConversionToSpeckle.cs index 9b2ebefe92..7579be070d 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/FloorConversionToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/FloorConversionToSpeckle.cs @@ -1,4 +1,7 @@ +using Objects; using Speckle.Converters.Common.Objects; +using Speckle.Converters.RevitShared.Helpers; +using Speckle.Converters.RevitShared.ToSpeckle; using Speckle.Core.Models; namespace Speckle.Converters.Common; @@ -9,7 +12,96 @@ namespace Speckle.Converters.Common; // clould be anywhere or all in once place - rooting through box 274 for something you need, when said box has a miriad different // and unrelated items, is no fun. Plus when you need that item, you end up bringing out the whole box/ [NameAndRankValue(nameof(DB.Floor), 0)] -public class FloorConversionToSpeckle : IHostObjectToSpeckleConversion +public class FloorConversionToSpeckle : BaseConversionToSpeckle { - public Base Convert(object target) => throw new SpeckleConversionException(); + private readonly IRawConversion> _curveArrArrayConverter; + private readonly IRawConversion _levelConverter; + private readonly ParameterValueExtractor _parameterValueExtractor; + private readonly ParameterObjectAssigner _parameterObjectAssigner; + private readonly DisplayValueExtractor _displayValueExtractor; + private readonly SlopeArrowExtractor _slopeArrowExtractor; + + public FloorConversionToSpeckle( + IRawConversion> curveArrArrayConverter, + IRawConversion levelConverter, + ParameterValueExtractor parameterValueExtractor, + ParameterObjectAssigner parameterObjectAssigner, + DisplayValueExtractor displayValueExtractor, + SlopeArrowExtractor slopeArrowExtractor + ) + { + _curveArrArrayConverter = curveArrArrayConverter; + _levelConverter = levelConverter; + _parameterValueExtractor = parameterValueExtractor; + _parameterObjectAssigner = parameterObjectAssigner; + _displayValueExtractor = displayValueExtractor; + _slopeArrowExtractor = slopeArrowExtractor; + } + + public override SOBR.RevitFloor RawConvert(DB.Floor target) + { + SOBR.RevitFloor speckleFloor = new(); + + var sketch = (DB.Sketch)target.Document.GetElement(target.SketchId); + List profiles = _curveArrArrayConverter.RawConvert(sketch.Profile); + + DB.ElementType type = (DB.ElementType)target.Document.GetElement(target.GetTypeId()); + + speckleFloor.family = type.FamilyName; + speckleFloor.type = type.Name; + + // POC: Re-evaluate Wall sketch curve extraction, assumption of only one outline is wrong. https://spockle.atlassian.net/browse/CNX-9396 + if (profiles.Count > 0) + { + speckleFloor.outline = profiles[0]; + } + + if (profiles.Count > 1) + { + speckleFloor.voids = profiles.Skip(1).ToList(); + } + + var level = _parameterValueExtractor.GetValueAsDocumentObject(target, DB.BuiltInParameter.LEVEL_PARAM); + speckleFloor.level = _levelConverter.RawConvert(level); + speckleFloor.structural = + _parameterValueExtractor.GetValueAsBool(target, DB.BuiltInParameter.FLOOR_PARAM_IS_STRUCTURAL) ?? false; + + // Divide by 100 to convert from percentage to unitless ratio (rise over run) + var slopeParam = _parameterValueExtractor.GetValueAsDouble(target, DB.BuiltInParameter.ROOF_SLOPE) / 100; + + _parameterObjectAssigner.AssignParametersToBase(target, speckleFloor); + TryAssignSlopeFromSlopeArrow(target, speckleFloor, slopeParam); + + speckleFloor.displayValue = _displayValueExtractor.GetDisplayValue(target); + // POC: hosted elements OOS for alpha, but this exists in existing connector + //_hostedElementConverter.AssignHostedElements(target, speckleCeiling); + + return speckleFloor; + } + + private void TryAssignSlopeFromSlopeArrow(DB.Floor target, SOBR.RevitFloor speckleFloor, double? slopeParam) + { + if (_slopeArrowExtractor.GetSlopeArrow(target) is not DB.ModelLine slopeArrow) + { + return; + } + + var tail = _slopeArrowExtractor.GetSlopeArrowTail(slopeArrow); + var head = _slopeArrowExtractor.GetSlopeArrowHead(slopeArrow); + var tailOffset = _slopeArrowExtractor.GetSlopeArrowTailOffset(slopeArrow); + _ = _slopeArrowExtractor.GetSlopeArrowHeadOffset(slopeArrow, tailOffset, out var slope); + + slopeParam ??= slope; + speckleFloor.slope = (double)slopeParam; + + speckleFloor.slopeDirection = new SOG.Line(tail, head); + if ( + speckleFloor["parameters"] is Base parameters + && parameters["FLOOR_HEIGHTABOVELEVEL_PARAM"] is SOBR.Parameter offsetParam + && offsetParam.value is double offset + ) + { + offsetParam.value = offset + tailOffset; + } + } } From bcd8d5291c7d150a8e86499d9f75c56b62a4b1ed Mon Sep 17 00:00:00 2001 From: BovineOx <73857041+BovineOx@users.noreply.github.com> Date: Fri, 3 May 2024 11:23:35 +0100 Subject: [PATCH 082/261] CNX-9224 Added brace (#3345) Added brace Added brace --- .../Plugin/RevitIdleManager.cs | 2 +- .../Raw/BraceToSpeckleConverter.cs | 47 +++++++++++++++++++ .../RevitConverterToSpeckle.cs | 6 +-- .../Speckle.Converters.RevitShared.projitems | 1 + .../FamilyInstanceConversionToSpeckle.cs | 30 ++++++------ .../Objects/BuiltElements/Revit/RevitBrace.cs | 4 +- 6 files changed, 69 insertions(+), 21 deletions(-) create mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/BraceToSpeckleConverter.cs diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitIdleManager.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitIdleManager.cs index 6e147d1409..d4877b6828 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitIdleManager.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitIdleManager.cs @@ -20,7 +20,7 @@ internal class RevitIdleManager : IRevitIdleManager public RevitIdleManager(RevitContext revitContext) { - _uiApplication = revitContext.UIApplication; + _uiApplication = revitContext.UIApplication!; } /// diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/BraceToSpeckleConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/BraceToSpeckleConverter.cs new file mode 100644 index 0000000000..b82ffa2a66 --- /dev/null +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/BraceToSpeckleConverter.cs @@ -0,0 +1,47 @@ +using Speckle.Converters.Common.Objects; +using Speckle.Core.Models; + +namespace Speckle.Converters.RevitShared.ToSpeckle; + +// POC: There is no validation on this converter to prevent conversion from "not a Revit Beam" to a Speckle Beam. +// This will definitely explode if we tried. Goes back to the `CanConvert` functionality conversation. +// As-is, what we are saying is that it can take "any Family Instance" and turn it into a Speckle.RevitBeam, which is far from correct. +// CNX-9312 +public class BraceToSpeckleConverter : IRawConversion +{ + private readonly IRawConversion _beamConverter; + + public BraceToSpeckleConverter(IRawConversion beamConverter) + { + _beamConverter = beamConverter; + } + + public SOBR.RevitBrace RawConvert(DB.FamilyInstance target) + { + // POC: we might want some easy one-liner here to FamilyMatchesOrThrow(target, DB.Structure.StructuralType.Brace) or similar + // and added in each RawConvert + // POC: this and the beam lost the notes we were returning, though this seems against even the original pattern + + var beam = _beamConverter.RawConvert(target); + + var brace = new SOBR.RevitBrace() + { + applicationId = beam.applicationId, + type = beam.type, + baseLine = beam.baseLine, + level = beam.level, + family = beam.family, + parameters = beam.parameters, + displayValue = beam.displayValue, + }; + + var dynamicProps = beam.GetMembers(DynamicBaseMemberType.Dynamic); + + foreach (var dp in dynamicProps) + { + brace[dp.Key] = dp.Value; + } + + return brace; + } +} diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/RevitConverterToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/RevitConverterToSpeckle.cs index c7539aaa88..3954f1f2d8 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/RevitConverterToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/RevitConverterToSpeckle.cs @@ -43,11 +43,11 @@ public Base Convert(object target) // shouldn't target ALWAYS be DB.Element? if (target is DB.Element element) { - _convertedObjectsCache.AddConvertedBase(element.UniqueId, result); - _parameterValueExtractor.RemoveUniqueId(element.UniqueId); - // POC: is this the right place? result.applicationId = element.UniqueId; + + _convertedObjectsCache.AddConvertedBase(element.UniqueId, result); + _parameterValueExtractor.RemoveUniqueId(element.UniqueId); } return result; diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Speckle.Converters.RevitShared.projitems b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Speckle.Converters.RevitShared.projitems index 94aae2d0f5..4a50e4aebd 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Speckle.Converters.RevitShared.projitems +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Speckle.Converters.RevitShared.projitems @@ -23,6 +23,7 @@ + diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/FamilyInstanceConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/FamilyInstanceConversionToSpeckle.cs index e8a64885ea..ae7c3f9b2c 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/FamilyInstanceConversionToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/FamilyInstanceConversionToSpeckle.cs @@ -12,35 +12,35 @@ public sealed class FamilyInstanceConversionToSpeckle : BaseConversionToSpeckle< private readonly IRawConversion _elementConverter; private readonly IRawConversion _beamConversion; private readonly IRawConversion _columnConversion; + private readonly IRawConversion _braceConversion; public FamilyInstanceConversionToSpeckle( IRawConversion elementConverter, IRawConversion beamConversion, - IRawConversion columnConversion + IRawConversion columnConversion, + IRawConversion braceConversion ) { _elementConverter = elementConverter; _beamConversion = beamConversion; _columnConversion = columnConversion; + _braceConversion = braceConversion; } public override Base RawConvert(DB.FamilyInstance target) { - if (target.StructuralType == DB.Structure.StructuralType.Beam) + return target.StructuralType switch { - return _beamConversion.RawConvert(target); - } + DB.Structure.StructuralType.Beam => _beamConversion.RawConvert(target), + DB.Structure.StructuralType.Column => _columnConversion.RawConvert(target), + DB.Structure.StructuralType.Brace => _braceConversion.RawConvert(target), - if (target.StructuralType == DB.Structure.StructuralType.Column) - { - return _columnConversion.RawConvert(target); - } - - // POC: return generic element conversion or throw? - // - //throw new SpeckleConversionException( - // $"No conditional converters registered that could convert object of type {target.GetType()}" - //); - return _elementConverter.RawConvert(target); + // POC: return generic element conversion or throw? + // + //throw new SpeckleConversionException( + // $"No conditional converters registered that could convert object of type {target.GetType()}" + //); + _ => _elementConverter.RawConvert(target) + }; } } diff --git a/Objects/Objects/BuiltElements/Revit/RevitBrace.cs b/Objects/Objects/BuiltElements/Revit/RevitBrace.cs index 99499f8826..6254f5e9b8 100644 --- a/Objects/Objects/BuiltElements/Revit/RevitBrace.cs +++ b/Objects/Objects/BuiltElements/Revit/RevitBrace.cs @@ -14,7 +14,7 @@ public RevitBrace( string family, string type, [SchemaMainParam] ICurve baseLine, - Level level, + Level? level, List? parameters = null ) { @@ -29,5 +29,5 @@ public RevitBrace( public string type { get; set; } public Base? parameters { get; set; } public string elementId { get; set; } - public Level level { get; set; } + public Level? level { get; set; } } From d31756567844b7a3499309e4e36f9c337b0102b6 Mon Sep 17 00:00:00 2001 From: connorivy <43247197+connorivy@users.noreply.github.com> Date: Fri, 3 May 2024 05:24:41 -0500 Subject: [PATCH 083/261] CNX-9225 revit ceiling to speckle (#3343) ceiling to speckle Co-authored-by: Connor Ivy --- ...urveArrArrayToSpecklePolycurveConverter.cs | 0 .../Speckle.Converters.RevitShared.projitems | 3 +- .../ToSpeckle/CeilingConversionToSpeckle.cs | 72 +++++++++++++++++++ 3 files changed, 74 insertions(+), 1 deletion(-) rename DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/{ => Geometry}/CurveArrArrayToSpecklePolycurveConverter.cs (100%) create mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/CeilingConversionToSpeckle.cs diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/CurveArrArrayToSpecklePolycurveConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/CurveArrArrayToSpecklePolycurveConverter.cs similarity index 100% rename from DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/CurveArrArrayToSpecklePolycurveConverter.cs rename to DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/CurveArrArrayToSpecklePolycurveConverter.cs diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Speckle.Converters.RevitShared.projitems b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Speckle.Converters.RevitShared.projitems index 4a50e4aebd..fcd956217b 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Speckle.Converters.RevitShared.projitems +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Speckle.Converters.RevitShared.projitems @@ -25,7 +25,7 @@ - + @@ -50,6 +50,7 @@ + diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/CeilingConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/CeilingConversionToSpeckle.cs new file mode 100644 index 0000000000..e141333b7f --- /dev/null +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/CeilingConversionToSpeckle.cs @@ -0,0 +1,72 @@ +using Autodesk.Revit.DB; +using Objects; +using Objects.BuiltElements.Revit; +using Objects.Geometry; +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; +using Speckle.Converters.RevitShared.Helpers; + +namespace Speckle.Converters.RevitShared.ToSpeckle; + +[NameAndRankValue(nameof(DB.Ceiling), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +internal class CeilingConversionToSpeckle : BaseConversionToSpeckle +{ + private readonly IRawConversion> _curveArrArrayConverter; + private readonly IRawConversion _levelConverter; + private readonly ParameterValueExtractor _parameterValueExtractor; + private readonly ParameterObjectAssigner _parameterObjectAssigner; + private readonly DisplayValueExtractor _displayValueExtractor; + + //private readonly HostedElementConversionToSpeckle _hostedElementConverter; + + public CeilingConversionToSpeckle( + IRawConversion> curveArrArrayConverter, + IRawConversion levelConverter, + ParameterValueExtractor parameterValueExtractor, + ParameterObjectAssigner parameterObjectAssigner, + DisplayValueExtractor displayValueExtractor + ) + { + _curveArrArrayConverter = curveArrArrayConverter; + _levelConverter = levelConverter; + _parameterValueExtractor = parameterValueExtractor; + _parameterObjectAssigner = parameterObjectAssigner; + _displayValueExtractor = displayValueExtractor; + } + + public override RevitCeiling RawConvert(DB.Ceiling target) + { + var sketch = (Sketch)target.Document.GetElement(target.SketchId); + List profiles = _curveArrArrayConverter.RawConvert(sketch.Profile); + + var speckleCeiling = new RevitCeiling(); + + var elementType = (ElementType)target.Document.GetElement(target.GetTypeId()); + speckleCeiling.type = elementType.Name; + speckleCeiling.family = elementType.FamilyName; + + // POC: https://spockle.atlassian.net/browse/CNX-9396 + if (profiles.Count > 0) + { + speckleCeiling.outline = profiles[0]; + } + if (profiles.Count > 1) + { + speckleCeiling.voids = profiles.Skip(1).ToList(); + } + + // POC: our existing receive operation is checking the "slopeDirection" prop, + // but it is never being set. We should be setting it + + var level = _parameterValueExtractor.GetValueAsDocumentObject(target, DB.BuiltInParameter.LEVEL_PARAM); + speckleCeiling.level = _levelConverter.RawConvert(level); + + _parameterObjectAssigner.AssignParametersToBase(target, speckleCeiling); + speckleCeiling.displayValue = _displayValueExtractor.GetDisplayValue(target); + + // POC: hosted elements OOS for alpha, but this exists in existing connector + //_hostedElementConverter.AssignHostedElements(target, speckleCeiling); + + return speckleCeiling; + } +} From 7aa9df11edcc2f3646c26fe9a3f4544cee799d4d Mon Sep 17 00:00:00 2001 From: oguzhankoral Date: Fri, 3 May 2024 07:49:18 +0300 Subject: [PATCH 084/261] Tidy up document store --- .../Bindings/BasicConnectorBindingRevit.cs | 2 + .../HostApp/RevitDocumentStore.cs | 127 ++++++++++++------ 2 files changed, 88 insertions(+), 41 deletions(-) diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/BasicConnectorBindingRevit.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/BasicConnectorBindingRevit.cs index 5df1b8b7d3..5f2819b4c2 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/BasicConnectorBindingRevit.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/BasicConnectorBindingRevit.cs @@ -68,6 +68,8 @@ public DocumentInfo GetDocumentInfo() var doc = _revitContext.UIApplication.ActiveUIDocument.Document; + // POC: Notify user here if document is null. + return new DocumentInfo { Name = doc.Title, diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/RevitDocumentStore.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/RevitDocumentStore.cs index 64b04ecdaa..0cae956b67 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/RevitDocumentStore.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/RevitDocumentStore.cs @@ -1,12 +1,16 @@ using System; using System.Collections.Generic; +using System.Diagnostics; +using System.Threading; using System.Threading.Tasks; using Autodesk.Revit.DB; using Autodesk.Revit.DB.ExtensibleStorage; using Autodesk.Revit.UI; +using Autodesk.Revit.UI.Events; using Revit.Async; using Speckle.Connectors.DUI.Models; using Speckle.Connectors.DUI.Models.Card; +using Speckle.Connectors.Revit.Plugin; using Speckle.Connectors.Utils.Operations; using Speckle.Converters.RevitShared.Helpers; using Speckle.Core.Logging; @@ -21,70 +25,80 @@ internal class RevitDocumentStore : DocumentModelStore private static readonly Guid s_revitDocumentStoreId = new("D35B3695-EDC9-4E15-B62A-D3FC2CB83FA3"); private readonly RevitContext _revitContext; - private readonly ISyncToMainThread _syncToMainThread; private readonly DocumentModelStorageSchema _documentModelStorageSchema; private readonly IdStorageSchema _idStorageSchema; + private readonly IRevitIdleManager _idleManager; public RevitDocumentStore( RevitContext revitContext, JsonSerializerSettings serializerSettings, - ISyncToMainThread syncToMainThread, DocumentModelStorageSchema documentModelStorageSchema, + IRevitIdleManager idleManager, IdStorageSchema idStorageSchema ) : base(serializerSettings) { _revitContext = revitContext; - _syncToMainThread = syncToMainThread; _documentModelStorageSchema = documentModelStorageSchema; _idStorageSchema = idStorageSchema; + _idleManager = idleManager; UIApplication uiApplication = _revitContext.UIApplication; + // uiApplication.ApplicationClosing += (_, _) => WriteToFile(); // POC: Not sure why we would need it since we have save and clos events + uiApplication.Application.DocumentSaving += (_, _) => WriteToFile(); + uiApplication.Application.DocumentSavingAs += (_, _) => WriteToFile(); + uiApplication.Application.DocumentClosing += (_, _) => WriteToFile(); + // uiApplication.Application.DocumentSynchronizingWithCentral += (_, _) => WriteToFile(); // POC: Not sure why we have it - uiApplication.ApplicationClosing += (_, _) => WriteToFile(); + uiApplication.ViewActivating += OnViewActivating; + uiApplication.ViewActivated += OnViewActivated; - //uiApplication.Application.DocumentSaving += (_, _) => WriteToFile(); - //uiApplication.Application.DocumentSavingAs += (_, _) => WriteToFile(); - //uiApplication.Application.DocumentClosing += (_, _) => WriteToFile(); - //uiApplication.Application.DocumentSynchronizingWithCentral += (_, _) => WriteToFile(); + uiApplication.Application.DocumentOpening += (_, _) => IsDocumentInit = false; + uiApplication.Application.DocumentOpened += (_, _) => RunDocInitOperations(); + } - // This is the place where we track document switch for old document -> Responsible to Write into old - uiApplication.ViewActivating += (_, e) => + private void RunDocInitOperations() + { + IsDocumentInit = true; + ReadFromFile(); + _idleManager.SubscribeToIdle(OnDocumentChanged); + } + + /// + /// This is the place where we track document switch for old document -> Responsible to Write into old + /// + private void OnViewActivating(object sender, ViewActivatingEventArgs e) + { + if (e.Document == null) { - if (e.Document == null) - { - return; - } + return; + } - if (e.NewActiveView.Document.Equals(e.CurrentActiveView.Document)) - { - return; - } + if (e.NewActiveView.Document.Equals(e.CurrentActiveView.Document)) + { + return; + } - WriteToFile(); - }; + WriteToFile(); + } - // This is the place where we track document switch for new document -> Responsible to Read from new doc - uiApplication.ViewActivated += (_, e) => + /// + /// This is the place where we track document switch for new document -> Responsible to Read from new doc + /// + private void OnViewActivated(object sender, ViewActivatedEventArgs e) + { + if (e.Document == null) { - if (e.Document == null) - { - return; - } - - // Return only if we are switching views that belongs to same document - if (e.PreviousActiveView is not null && e.PreviousActiveView.Document.Equals(e.CurrentActiveView.Document)) - { - return; - } + return; + } - IsDocumentInit = true; - ReadFromFile(); - OnDocumentChanged(); - }; + // Return only if we are switching views that belongs to same document + if (e.PreviousActiveView is not null && e.PreviousActiveView.Document.Equals(e.CurrentActiveView.Document)) + { + return; + } - uiApplication.Application.DocumentOpening += (_, _) => IsDocumentInit = false; - //uiApplication.Application.DocumentOpened += (_, _) => IsDocumentInit = false; + RunDocInitOperations(); } public override void WriteToFile() @@ -102,7 +116,7 @@ public override void WriteToFile() string serializedModels = Serialize(); // POC: previously we were calling below code - RevitTask + var a = RevitTask .RunAsync(() => { using Transaction t = new(doc.Document, "Speckle Write State"); @@ -124,6 +138,35 @@ public override void WriteToFile() } public override void ReadFromFile() + { + UIDocument doc = _revitContext.UIApplication.ActiveUIDocument; + + // POC: this can happen? + if (doc == null) + { + return; + } + + RevitTask + .RunAsync(() => + { + using Transaction t = new(doc.Document, "Speckle Read State"); + t.Start(); + using Entity stateEntity = GetSpeckleEntity(_revitContext.UIApplication.ActiveUIDocument.Document); + if (stateEntity == null || !stateEntity.IsValid()) + { + Models = new List(); + return; + } + + string modelsString = stateEntity.Get("contents"); + Models = Deserialize(modelsString); + t.Commit(); + }) + .ConfigureAwait(false); + } + + public void ReadFromFile2() { try { @@ -142,11 +185,14 @@ public override void ReadFromFile() { Models = new List(); } + catch (Exception ex) when (!ex.IsFatal()) + { + Debug.WriteLine(ex.Message); // POC: !!?? + } } private DataStorage? GetSettingsDataStorage(Document doc) { - // POC: re-instate using FilteredElementCollector collector = new(doc); FilteredElementCollector dataStorages = collector.OfClass(typeof(DataStorage)); @@ -173,7 +219,6 @@ public override void ReadFromFile() private Entity? GetSpeckleEntity(Document doc) { - // POC: re-instate using FilteredElementCollector collector = new(doc); FilteredElementCollector dataStorages = collector.OfClass(typeof(DataStorage)); From c34b998638d2017b4a3726dc0b0715a16e6a86b7 Mon Sep 17 00:00:00 2001 From: oguzhankoral Date: Fri, 3 May 2024 13:33:47 +0300 Subject: [PATCH 085/261] Fix on called method on bridges --- .../Revit/Speckle.Connectors.RevitShared/Plugin/RevitPlugin.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitPlugin.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitPlugin.cs index 83cb83f865..19a9e72b38 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitPlugin.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitPlugin.cs @@ -104,7 +104,7 @@ private void RegisterPanelAndInitializePlugin() Debug.WriteLine(binding.Name); binding.Parent.AssociateWithBinding( binding, - _cefSharpPanel.Browser.ExecuteScriptAsync, + _cefSharpPanel.ExecuteScriptAsync, _cefSharpPanel, _cefSharpPanel.ShowDevTools ); From 8bd089e6dd91a75b502388e498e2a9650ad007a1 Mon Sep 17 00:00:00 2001 From: Jedd Morgan <45512892+JR-Morgan@users.noreply.github.com> Date: Fri, 3 May 2024 11:58:33 +0100 Subject: [PATCH 086/261] CNX-9382 acad polylines missings on consecutive receives in different documents (#3347) * Resolve more services as instance per lifetime scope * removed addressed comment --- .../DependencyInjection/AutofacAutocadModule.cs | 4 ++-- .../AutofacAutocadConverterModule.cs | 13 +++++++------ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/DependencyInjection/AutofacAutocadModule.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/DependencyInjection/AutofacAutocadModule.cs index b19d080b41..da0c3fb652 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/DependencyInjection/AutofacAutocadModule.cs +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/DependencyInjection/AutofacAutocadModule.cs @@ -50,12 +50,12 @@ protected override void Load(ContainerBuilder builder) // Operations builder.RegisterType>().InstancePerLifetimeScope(); - builder.RegisterType().SingleInstance(); + builder.RegisterType().InstancePerLifetimeScope(); builder.RegisterType().As().SingleInstance().AutoActivate(); // Auto activation makes SynchronizationContext available right after building. Otherwise we were missing it in UoWs. builder.RegisterInstance(DefaultTraversal.CreateTraversalFunc()); // Object Builders - builder.RegisterType().As().InstancePerDependency(); + builder.RegisterType().As().InstancePerLifetimeScope(); builder .RegisterType() .As>() diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2023.DependencyInjection/AutofacAutocadConverterModule.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2023.DependencyInjection/AutofacAutocadConverterModule.cs index 60a29fcda7..e7f3dca0b2 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2023.DependencyInjection/AutofacAutocadConverterModule.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2023.DependencyInjection/AutofacAutocadConverterModule.cs @@ -15,10 +15,8 @@ protected override void Load(ContainerBuilder builder) { // POC: below comment maybe incorrect (sorry if I wrote that!) stateless services // can be injected as Singleton(), only where we have state we wish to wrap in a unit of work - // should be InstancePerLifetimeScope - // most things should be InstancePerLifetimeScope so we get one per operation - builder.RegisterType().As().SingleInstance(); - builder.RegisterType().As().SingleInstance(); + builder.RegisterType().As().InstancePerLifetimeScope(); + builder.RegisterType().As().InstancePerLifetimeScope(); // single stack per conversion builder @@ -29,9 +27,12 @@ protected override void Load(ContainerBuilder builder) // factory for conversions builder .RegisterType>() - .As>(); + .As>() + .InstancePerLifetimeScope(); + builder .RegisterType>() - .As>(); + .As>() + .InstancePerLifetimeScope(); } } From 6e174ac92dc77069d93009a03ae889b334c83bbb Mon Sep 17 00:00:00 2001 From: oguzhankoral Date: Fri, 3 May 2024 14:02:49 +0300 Subject: [PATCH 087/261] Clean up --- .../HostApp/RevitDocumentStore.cs | 35 ++----------------- 1 file changed, 3 insertions(+), 32 deletions(-) diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/RevitDocumentStore.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/RevitDocumentStore.cs index 0cae956b67..677e46d883 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/RevitDocumentStore.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/RevitDocumentStore.cs @@ -47,7 +47,7 @@ IdStorageSchema idStorageSchema // uiApplication.ApplicationClosing += (_, _) => WriteToFile(); // POC: Not sure why we would need it since we have save and clos events uiApplication.Application.DocumentSaving += (_, _) => WriteToFile(); uiApplication.Application.DocumentSavingAs += (_, _) => WriteToFile(); - uiApplication.Application.DocumentClosing += (_, _) => WriteToFile(); + // uiApplication.Application.DocumentClosing += (_, _) => WriteToFile(); // uiApplication.Application.DocumentSynchronizingWithCentral += (_, _) => WriteToFile(); // POC: Not sure why we have it uiApplication.ViewActivating += OnViewActivating; @@ -61,7 +61,7 @@ private void RunDocInitOperations() { IsDocumentInit = true; ReadFromFile(); - _idleManager.SubscribeToIdle(OnDocumentChanged); + OnDocumentChanged(); } /// @@ -116,7 +116,7 @@ public override void WriteToFile() string serializedModels = Serialize(); // POC: previously we were calling below code - var a = RevitTask + RevitTask .RunAsync(() => { using Transaction t = new(doc.Document, "Speckle Write State"); @@ -138,35 +138,6 @@ public override void WriteToFile() } public override void ReadFromFile() - { - UIDocument doc = _revitContext.UIApplication.ActiveUIDocument; - - // POC: this can happen? - if (doc == null) - { - return; - } - - RevitTask - .RunAsync(() => - { - using Transaction t = new(doc.Document, "Speckle Read State"); - t.Start(); - using Entity stateEntity = GetSpeckleEntity(_revitContext.UIApplication.ActiveUIDocument.Document); - if (stateEntity == null || !stateEntity.IsValid()) - { - Models = new List(); - return; - } - - string modelsString = stateEntity.Get("contents"); - Models = Deserialize(modelsString); - t.Commit(); - }) - .ConfigureAwait(false); - } - - public void ReadFromFile2() { try { From 6ecd41f95643b8e93dcd70544b557af4d8f35447 Mon Sep 17 00:00:00 2001 From: oguzhankoral Date: Fri, 3 May 2024 15:58:41 +0300 Subject: [PATCH 088/261] More cleanup and fixes --- .../Bindings/ReceiveBinding.cs | 1 - .../Bindings/RevitBaseBinding.cs | 1 - .../Bindings/SelectionBinding.cs | 1 - .../Bindings/SendBinding.cs | 1 - .../HostApp/RevitDocumentStore.cs | 110 +++++++----------- 5 files changed, 39 insertions(+), 75 deletions(-) diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/ReceiveBinding.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/ReceiveBinding.cs index 973b3c8741..43d32511a5 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/ReceiveBinding.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/ReceiveBinding.cs @@ -1,7 +1,6 @@ using System; using Speckle.Connectors.DUI.Bridge; using Speckle.Connectors.DUI.Models; -using Speckle.Connectors.Revit.HostApp; using Speckle.Connectors.Utils.Cancellation; using Speckle.Converters.RevitShared.Helpers; using Speckle.Core.Logging; diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/RevitBaseBinding.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/RevitBaseBinding.cs index ff19828a48..6822f0650e 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/RevitBaseBinding.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/RevitBaseBinding.cs @@ -1,7 +1,6 @@ using Speckle.Connectors.DUI.Bindings; using Speckle.Connectors.DUI.Bridge; using Speckle.Connectors.DUI.Models; -using Speckle.Connectors.Revit.HostApp; using Speckle.Converters.RevitShared.Helpers; namespace Speckle.Connectors.Revit.Bindings; diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SelectionBinding.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SelectionBinding.cs index d25e740029..68555dcde7 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SelectionBinding.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SelectionBinding.cs @@ -4,7 +4,6 @@ using Speckle.Connectors.DUI.Bindings; using Speckle.Connectors.DUI.Bridge; using Speckle.Connectors.DUI.Models; -using Speckle.Connectors.Revit.HostApp; using Speckle.Connectors.Revit.Plugin; using Speckle.Converters.RevitShared.Helpers; diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SendBinding.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SendBinding.cs index 41f905a851..78b03b4c3d 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SendBinding.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SendBinding.cs @@ -5,7 +5,6 @@ using Speckle.Connectors.DUI.Models.Card.SendFilter; using Speckle.Connectors.Utils.Cancellation; using Speckle.Connectors.DUI.Bridge; -using Speckle.Connectors.Revit.HostApp; using Speckle.Connectors.Revit.Plugin; using Speckle.Core.Logging; using Speckle.Connectors.Utils; diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/RevitDocumentStore.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/RevitDocumentStore.cs index 677e46d883..9c2bde506d 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/RevitDocumentStore.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/RevitDocumentStore.cs @@ -1,17 +1,13 @@ using System; using System.Collections.Generic; using System.Diagnostics; -using System.Threading; -using System.Threading.Tasks; +using System.Linq; using Autodesk.Revit.DB; using Autodesk.Revit.DB.ExtensibleStorage; using Autodesk.Revit.UI; using Autodesk.Revit.UI.Events; -using Revit.Async; using Speckle.Connectors.DUI.Models; using Speckle.Connectors.DUI.Models.Card; -using Speckle.Connectors.Revit.Plugin; -using Speckle.Connectors.Utils.Operations; using Speckle.Converters.RevitShared.Helpers; using Speckle.Core.Logging; using Speckle.Newtonsoft.Json; @@ -27,13 +23,11 @@ internal class RevitDocumentStore : DocumentModelStore private readonly RevitContext _revitContext; private readonly DocumentModelStorageSchema _documentModelStorageSchema; private readonly IdStorageSchema _idStorageSchema; - private readonly IRevitIdleManager _idleManager; public RevitDocumentStore( RevitContext revitContext, JsonSerializerSettings serializerSettings, DocumentModelStorageSchema documentModelStorageSchema, - IRevitIdleManager idleManager, IdStorageSchema idStorageSchema ) : base(serializerSettings) @@ -41,107 +35,85 @@ IdStorageSchema idStorageSchema _revitContext = revitContext; _documentModelStorageSchema = documentModelStorageSchema; _idStorageSchema = idStorageSchema; - _idleManager = idleManager; UIApplication uiApplication = _revitContext.UIApplication; - // uiApplication.ApplicationClosing += (_, _) => WriteToFile(); // POC: Not sure why we would need it since we have save and clos events + uiApplication.ApplicationClosing += (_, _) => WriteToFile(); // POC: Not sure why we would need it since we have save and clos events uiApplication.Application.DocumentSaving += (_, _) => WriteToFile(); uiApplication.Application.DocumentSavingAs += (_, _) => WriteToFile(); - // uiApplication.Application.DocumentClosing += (_, _) => WriteToFile(); - // uiApplication.Application.DocumentSynchronizingWithCentral += (_, _) => WriteToFile(); // POC: Not sure why we have it + uiApplication.Application.DocumentSynchronizingWithCentral += (_, _) => WriteToFile(); // POC: Not sure why we have it - uiApplication.ViewActivating += OnViewActivating; uiApplication.ViewActivated += OnViewActivated; uiApplication.Application.DocumentOpening += (_, _) => IsDocumentInit = false; - uiApplication.Application.DocumentOpened += (_, _) => RunDocInitOperations(); - } - - private void RunDocInitOperations() - { - IsDocumentInit = true; - ReadFromFile(); - OnDocumentChanged(); + uiApplication.Application.DocumentOpened += (_, _) => IsDocumentInit = false; } /// - /// This is the place where we track document switch for old document -> Responsible to Write into old + /// This is the place where we track document switch for new document -> Responsible to Read from new doc /// - private void OnViewActivating(object sender, ViewActivatingEventArgs e) + private void OnViewActivated(object sender, ViewActivatedEventArgs e) { if (e.Document == null) { return; } - if (e.NewActiveView.Document.Equals(e.CurrentActiveView.Document)) - { - return; - } - - WriteToFile(); - } - - /// - /// This is the place where we track document switch for new document -> Responsible to Read from new doc - /// - private void OnViewActivated(object sender, ViewActivatedEventArgs e) - { - if (e.Document == null) + if (e.PreviousActiveView is not null && e.PreviousActiveView.Document is not null) { - return; + // using UIDocument doc = new(e.PreviousActiveView.Document); + WriteToFileWithDoc(e.PreviousActiveView.Document); } // Return only if we are switching views that belongs to same document - if (e.PreviousActiveView is not null && e.PreviousActiveView.Document.Equals(e.CurrentActiveView.Document)) + if (e.PreviousActiveView?.Document != null && e.PreviousActiveView.Document.Equals(e.CurrentActiveView.Document)) { return; } - RunDocInitOperations(); + IsDocumentInit = true; + ReadFromFile(); + OnDocumentChanged(); } - public override void WriteToFile() + private void WriteToFileWithDoc(Document doc) { - UIDocument doc = _revitContext.UIApplication.ActiveUIDocument; - // POC: this can happen? if (doc == null) { return; } - // NOTE: Document switched fixed by putting seralization outside of the RevitTask, otherwise it tries to serialize - // empty document state since we create new one per document. + // Don't even attempt to write anything if empty. + if (!Models.Any()) + { + return; + } + string serializedModels = Serialize(); - // POC: previously we were calling below code - RevitTask - .RunAsync(() => - { - using Transaction t = new(doc.Document, "Speckle Write State"); - t.Start(); - using DataStorage ds = GetSettingsDataStorage(doc.Document) ?? DataStorage.Create(doc.Document); - - using Entity stateEntity = new(_documentModelStorageSchema.GetSchema()); - // string serializedModels = Serialize(); - stateEntity.Set("contents", serializedModels); - - using Entity idEntity = new(_idStorageSchema.GetSchema()); - idEntity.Set("Id", s_revitDocumentStoreId); - - ds.SetEntity(idEntity); - ds.SetEntity(stateEntity); - t.Commit(); - }) - .ConfigureAwait(false); + using Transaction t = new(doc, "Speckle Write State"); + t.Start(); + using DataStorage ds = GetSettingsDataStorage(doc) ?? DataStorage.Create(doc); + + using Entity stateEntity = new(_documentModelStorageSchema.GetSchema()); + // string serializedModels = Serialize(); + stateEntity.Set("contents", serializedModels); + + using Entity idEntity = new(_idStorageSchema.GetSchema()); + idEntity.Set("Id", s_revitDocumentStoreId); + + ds.SetEntity(idEntity); + ds.SetEntity(stateEntity); + t.Commit(); } + public override void WriteToFile() => WriteToFileWithDoc(_revitContext.UIApplication.ActiveUIDocument.Document); + public override void ReadFromFile() { try { - Entity stateEntity = GetSpeckleEntity(_revitContext.UIApplication.ActiveUIDocument.Document); + Entity stateEntity = GetSpeckleEntity(_revitContext.UIApplication?.ActiveUIDocument.Document); if (stateEntity == null || !stateEntity.IsValid()) { Models = new List(); @@ -151,14 +123,10 @@ public override void ReadFromFile() string modelsString = stateEntity.Get("contents"); Models = Deserialize(modelsString); } - // POC: hmmmmm, is this valid? Do we really throw an exception if the entity does not exist? - catch (SpeckleException) - { - Models = new List(); - } catch (Exception ex) when (!ex.IsFatal()) { - Debug.WriteLine(ex.Message); // POC: !!?? + Models = new List(); + Debug.WriteLine(ex.Message); // POC: Log here error and notify UI that cards not read succesfully } } From e30a33242b5a855c89b86355b446b8d0bf022f20 Mon Sep 17 00:00:00 2001 From: oguzhankoral Date: Fri, 3 May 2024 16:07:44 +0300 Subject: [PATCH 089/261] Some simplifications --- .../HostApp/RevitDocumentStore.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/RevitDocumentStore.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/RevitDocumentStore.cs index 9c2bde506d..8356866325 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/RevitDocumentStore.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/RevitDocumentStore.cs @@ -58,9 +58,8 @@ private void OnViewActivated(object sender, ViewActivatedEventArgs e) return; } - if (e.PreviousActiveView is not null && e.PreviousActiveView.Document is not null) + if (e.PreviousActiveView?.Document != null) { - // using UIDocument doc = new(e.PreviousActiveView.Document); WriteToFileWithDoc(e.PreviousActiveView.Document); } From 0402ce7f7b08f3753c0171952291eb107f8aa9a8 Mon Sep 17 00:00:00 2001 From: Dimitrie Stefanescu Date: Fri, 3 May 2024 15:21:20 +0100 Subject: [PATCH 090/261] fix(dui3): walls with no display value --- .../ToSpeckle/WallConversionToSpeckle.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/WallConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/WallConversionToSpeckle.cs index e1e78dee17..39eda3e90a 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/WallConversionToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/WallConversionToSpeckle.cs @@ -121,7 +121,12 @@ private void AssignDisplayValue(DB.Wall target, RevitWall speckleWall) { speckleWall.displayValue = _displayValueExtractor.GetDisplayValue(target); } - speckleWall.displayValue = new List(); + else + { + // POC: I have no why previously we were setting the display value, and then unsetting it. + // Probably curtain walls need a special case/etc.? + speckleWall.displayValue = new List(); + } } private void AssignHostedElements(SOBR.RevitWall speckleWall, List hostedObjects) From 88e42640625b5763cb83980ea7ec8aeee9f607f4 Mon Sep 17 00:00:00 2001 From: Dimitrie Stefanescu Date: Fri, 3 May 2024 15:33:56 +0100 Subject: [PATCH 091/261] fix(dui3): walls with no display value (#3350) --- .../ToSpeckle/WallConversionToSpeckle.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/WallConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/WallConversionToSpeckle.cs index e1e78dee17..39eda3e90a 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/WallConversionToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/WallConversionToSpeckle.cs @@ -121,7 +121,12 @@ private void AssignDisplayValue(DB.Wall target, RevitWall speckleWall) { speckleWall.displayValue = _displayValueExtractor.GetDisplayValue(target); } - speckleWall.displayValue = new List(); + else + { + // POC: I have no why previously we were setting the display value, and then unsetting it. + // Probably curtain walls need a special case/etc.? + speckleWall.displayValue = new List(); + } } private void AssignHostedElements(SOBR.RevitWall speckleWall, List hostedObjects) From 74a1d5e943aacf30f82aa6af438941dfcef2ab84 Mon Sep 17 00:00:00 2001 From: connorivy <43247197+connorivy@users.noreply.github.com> Date: Fri, 3 May 2024 10:36:43 -0500 Subject: [PATCH 092/261] Cnx 9231 revit roof (#3336) * support roofs * add roof base * fix hosted element converter * fix: Renamed files * fix: Renamed classes and adressed some other comments * fix: Accidental slnf change * Renamed ModelCurveArrArrayToSpeckle * fix build and more explicitly deal with parameters --------- Co-authored-by: Connor Ivy Co-authored-by: Alan Rynne --- DUI3-DX.slnf | 2 +- .../Helpers/ParameterValueExtractor.cs | 56 +++++++++--- .../Helpers/SlopeArrowExtractor.cs | 30 ++----- .../Raw/ColumnConversionToSpeckle.cs | 15 ++-- .../ModelCurveArrArrayToSpeckleConverter.cs | 28 ++++++ .../Raw/ModelCurveArrayToSpeckleConverter.cs | 46 ++++++++++ .../Speckle.Converters.RevitShared.projitems | 5 ++ ...ExtrusionRoofToSpeckleTopLevelConverter.cs | 71 +++++++++++++++ ...FootPrintRoofToSpeckleTopLevelConverter.cs | 88 +++++++++++++++++++ .../HostedElementConversionToSpeckle.cs | 32 ++++--- .../RoofBaseToSpeckleTopLevelConversion.cs | 40 +++++++++ .../ToSpeckle/RoomConversionToSpeckle.cs | 2 +- .../ToSpeckle/WallConversionToSpeckle.cs | 23 +++-- 13 files changed, 377 insertions(+), 61 deletions(-) create mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ModelCurveArrArrayToSpeckleConverter.cs create mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ModelCurveArrayToSpeckleConverter.cs create mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/ExtrusionRoofToSpeckleTopLevelConverter.cs create mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/FootPrintRoofToSpeckleTopLevelConverter.cs create mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/RoofBaseToSpeckleTopLevelConversion.cs diff --git a/DUI3-DX.slnf b/DUI3-DX.slnf index 282d1fb349..9bed907dd3 100644 --- a/DUI3-DX.slnf +++ b/DUI3-DX.slnf @@ -35,4 +35,4 @@ "Objects\\Tests\\Objects.Tests.Unit\\Objects.Tests.Unit.csproj" ] } -} \ No newline at end of file +} diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/ParameterValueExtractor.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/ParameterValueExtractor.cs index ee2cab49d3..acb96d9acd 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/ParameterValueExtractor.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/ParameterValueExtractor.cs @@ -8,6 +8,7 @@ namespace Speckle.Converters.RevitShared.Helpers; // POC: needs reviewing, it may be fine, not sure how open/closed it is // really if we have to edit a switch statement... // maybe also better as an extension method, but maybe is fine? +// POC: there are a lot of public methods here. Maybe consider consolodating public class ParameterValueExtractor { private readonly ScalingServiceToSpeckle _scalingService; @@ -37,14 +38,32 @@ or _ }; } - public double? GetValueAsDouble(Element element, BuiltInParameter builtInParameter) + public double GetValueAsDouble(Element element, BuiltInParameter builtInParameter) { - return GetValueGeneric( + if (!TryGetValueAsDouble(element, builtInParameter, out double? value)) + { + throw new SpeckleConversionException($"Failed to get {builtInParameter} as double."); + } + + return value!.Value; // If TryGet returns true, we succeeded in obtaining the value, and it will not be null. + } + + public bool TryGetValueAsDouble(Element element, BuiltInParameter builtInParameter, out double? value) + { + var number = GetValueGeneric( element, builtInParameter, StorageType.Double, (parameter) => _scalingService.Scale(parameter.AsDouble(), parameter.GetUnitTypeId()) ); + if (number.HasValue) + { + value = number.Value; + return true; + } + + value = default; + return false; } private double? GetValueAsDouble(Parameter parameter) @@ -56,9 +75,12 @@ or _ ); } - public int? GetValueAsInt(Element element, BuiltInParameter builtInParameter) + public int GetValueAsInt(Element element, BuiltInParameter builtInParameter) { - return GetValueGeneric(element, builtInParameter, StorageType.Integer, (parameter) => parameter.AsInteger()); + return GetValueGeneric(element, builtInParameter, StorageType.Integer, (parameter) => parameter.AsInteger()) + ?? throw new SpeckleConversionException( + $"Expected int but got null for property {builtInParameter} on element of type {element.GetType()}" + ); } private int? GetValueAsInt(Parameter parameter) @@ -98,15 +120,29 @@ or _ return GetValueGeneric(parameter, StorageType.ElementId, (parameter) => parameter.AsElementId()); } - public T GetValueAsDocumentObject(Element element, BuiltInParameter builtInParameter) - where T : class + public bool TryGetValueAsDocumentObject(Element element, BuiltInParameter builtInParameter, out T? value) { ElementId? elementId = GetValueAsElementId(element, builtInParameter); Element paramElement = element.Document.GetElement(elementId); - return paramElement as T - ?? throw new SpeckleConversionException( - $"Unable to cast retrieved element of type {paramElement.GetType()} to an element of type {typeof(T)}" - ); + if (paramElement is T typedElement) + { + value = typedElement; + return true; + } + + value = default; + return false; + } + + public T GetValueAsDocumentObject(Element element, BuiltInParameter builtInParameter) + where T : class + { + if (!TryGetValueAsDocumentObject(element, builtInParameter, out var value)) + { + throw new SpeckleConversionException($"Failed to get {builtInParameter} as an element of type {typeof(T)}"); + } + + return value!; // If TryGet returns true, we succeeded in obtaining the value, and it will not be null. } private TResult? GetValueGeneric( diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/SlopeArrowExtractor.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/SlopeArrowExtractor.cs index 6f9d759279..cd75314874 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/SlopeArrowExtractor.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/SlopeArrowExtractor.cs @@ -1,4 +1,3 @@ -using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; namespace Speckle.Converters.RevitShared.Helpers; @@ -59,25 +58,14 @@ public SOG.Point GetSlopeArrowTail(DB.ModelLine slopeArrow) public double GetSlopeArrowTailOffset(DB.ModelLine slopeArrow) { - return _parameterValueExtractor.GetValueAsDouble(slopeArrow, DB.BuiltInParameter.SLOPE_START_HEIGHT) - ?? throw new SpeckleConversionException( - $"Unexpected null value for slope arrow property {nameof(DB.BuiltInParameter.SLOPE_START_HEIGHT)}" - ); + return _parameterValueExtractor.GetValueAsDouble(slopeArrow, DB.BuiltInParameter.SLOPE_START_HEIGHT); } public double GetSlopeArrowHeadOffset(DB.ModelLine slopeArrow, double tailOffset, out double slope) { - var specifyOffset = - _parameterValueExtractor.GetValueAsInt(slopeArrow, DB.BuiltInParameter.SPECIFY_SLOPE_OR_OFFSET) - ?? throw new SpeckleConversionException( - $"Unexpected null value for slope arrow property {nameof(DB.BuiltInParameter.SPECIFY_SLOPE_OR_OFFSET)}" - ); + var specifyOffset = _parameterValueExtractor.GetValueAsInt(slopeArrow, DB.BuiltInParameter.SPECIFY_SLOPE_OR_OFFSET); - var lineLength = - _parameterValueExtractor.GetValueAsDouble(slopeArrow, DB.BuiltInParameter.CURVE_ELEM_LENGTH) - ?? throw new SpeckleConversionException( - $"Unexpected null value for slope arrow property {nameof(DB.BuiltInParameter.CURVE_ELEM_LENGTH)}" - ); + var lineLength = _parameterValueExtractor.GetValueAsDouble(slopeArrow, DB.BuiltInParameter.CURVE_ELEM_LENGTH); slope = 0; double headOffset = 0; @@ -85,20 +73,12 @@ public double GetSlopeArrowHeadOffset(DB.ModelLine slopeArrow, double tailOffset if (specifyOffset == 1) { // in this scenario, slope is returned as a percentage. Divide by 100 to get the unitless form - slope = - _parameterValueExtractor.GetValueAsDouble(slopeArrow, DB.BuiltInParameter.ROOF_SLOPE) / 100d - ?? throw new SpeckleConversionException( - $"Unexpected null value for slope arrow property {nameof(DB.BuiltInParameter.ROOF_SLOPE)}" - ); + slope = _parameterValueExtractor.GetValueAsDouble(slopeArrow, DB.BuiltInParameter.ROOF_SLOPE) / 100d; headOffset = tailOffset + lineLength * Math.Sin(Math.Atan(slope)); } else if (specifyOffset == 0) // 0 corrospondes to the "height at tail" option { - headOffset = - _parameterValueExtractor.GetValueAsDouble(slopeArrow, DB.BuiltInParameter.SLOPE_END_HEIGHT) - ?? throw new SpeckleConversionException( - $"Unexpected null value for slope arrow property {nameof(DB.BuiltInParameter.ROOF_SLOPE)}" - ); + headOffset = _parameterValueExtractor.GetValueAsDouble(slopeArrow, DB.BuiltInParameter.SLOPE_END_HEIGHT); slope = (headOffset - tailOffset) / lineLength; } diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ColumnConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ColumnConversionToSpeckle.cs index 01e75da8c5..f9daa14b1e 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ColumnConversionToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ColumnConversionToSpeckle.cs @@ -54,12 +54,17 @@ public RevitColumn RawConvert(DB.FamilyInstance target) BuiltInParameter.FAMILY_TOP_LEVEL_PARAM ); - // POC : what to do instead of falling back to default value speckleColumn.topLevel = _levelConverter.RawConvert(topLevel); - speckleColumn.baseOffset = - _parameterValueExtractor.GetValueAsDouble(target, BuiltInParameter.FAMILY_BASE_LEVEL_OFFSET_PARAM) ?? 0; - speckleColumn.topOffset = - _parameterValueExtractor.GetValueAsDouble(target, BuiltInParameter.FAMILY_TOP_LEVEL_OFFSET_PARAM) ?? 0; + speckleColumn.baseOffset = _parameterValueExtractor.GetValueAsDouble( + target, + DB.BuiltInParameter.FAMILY_BASE_LEVEL_OFFSET_PARAM + ); + + speckleColumn.topOffset = _parameterValueExtractor.GetValueAsDouble( + target, + DB.BuiltInParameter.FAMILY_TOP_LEVEL_OFFSET_PARAM + ); + speckleColumn.facingFlipped = target.FacingFlipped; speckleColumn.handFlipped = target.HandFlipped; speckleColumn.isSlanted = target.IsSlantedColumn; diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ModelCurveArrArrayToSpeckleConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ModelCurveArrArrayToSpeckleConverter.cs new file mode 100644 index 0000000000..0790d2767e --- /dev/null +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ModelCurveArrArrayToSpeckleConverter.cs @@ -0,0 +1,28 @@ +using Autodesk.Revit.DB; +using Objects.Geometry; +using Speckle.Converters.Common.Objects; + +namespace Speckle.Converters.RevitShared.Raw; + +internal sealed class ModelCurveArrArrayConverterToSpeckle : IRawConversion +{ + private readonly IRawConversion _modelCurveArrayConverter; + + public ModelCurveArrArrayConverterToSpeckle(IRawConversion modelCurveArrayConverter) + { + _modelCurveArrayConverter = modelCurveArrayConverter; + } + + public SOG.Polycurve[] RawConvert(ModelCurveArrArray target) + { + var polycurves = new Polycurve[target.Size]; + var revitArrays = target.Cast().ToArray(); + + for (int i = 0; i < polycurves.Length; i++) + { + polycurves[i] = _modelCurveArrayConverter.RawConvert(revitArrays[i]); + } + + return polycurves; + } +} diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ModelCurveArrayToSpeckleConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ModelCurveArrayToSpeckleConverter.cs new file mode 100644 index 0000000000..b6131fd7b6 --- /dev/null +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ModelCurveArrayToSpeckleConverter.cs @@ -0,0 +1,46 @@ +using Objects; +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; +using Speckle.Converters.RevitShared.Helpers; +using Speckle.Converters.RevitShared.Services; + +namespace Speckle.Converters.RevitShared.Raw; + +internal class ModelCurveArrayToSpeckleConverter : IRawConversion +{ + private readonly RevitConversionContextStack _contextStack; + private readonly ScalingServiceToSpeckle _scalingService; + private readonly IRawConversion _curveConverter; + + public ModelCurveArrayToSpeckleConverter( + RevitConversionContextStack contextStack, + ScalingServiceToSpeckle scalingService, + IRawConversion curveConverter + ) + { + _contextStack = contextStack; + _scalingService = scalingService; + _curveConverter = curveConverter; + } + + public SOG.Polycurve RawConvert(DB.ModelCurveArray target) + { + SOG.Polycurve polycurve = new(); + var curves = target.Cast().Select(mc => mc.GeometryCurve).ToArray(); + + if (curves.Length == 0) + { + throw new SpeckleConversionException($"Expected {target} to have at least 1 curve"); + } + + var start = curves[0].GetEndPoint(0); + var end = curves[curves.Length - 1].GetEndPoint(1); + polycurve.units = _contextStack.Current.SpeckleUnits; + polycurve.closed = start.DistanceTo(end) < RevitConversionContextStack.TOLERANCE; + polycurve.length = _scalingService.ScaleLength(curves.Sum(x => x.Length)); + + polycurve.segments.AddRange(curves.Select(x => _curveConverter.RawConvert(x))); + + return polycurve; + } +} diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Speckle.Converters.RevitShared.projitems b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Speckle.Converters.RevitShared.projitems index fcd956217b..f0af693909 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Speckle.Converters.RevitShared.projitems +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Speckle.Converters.RevitShared.projitems @@ -46,6 +46,8 @@ + + @@ -53,6 +55,9 @@ + + + diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/ExtrusionRoofToSpeckleTopLevelConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/ExtrusionRoofToSpeckleTopLevelConverter.cs new file mode 100644 index 0000000000..90b05a640a --- /dev/null +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/ExtrusionRoofToSpeckleTopLevelConverter.cs @@ -0,0 +1,71 @@ +using Objects.BuiltElements.Revit.RevitRoof; +using Speckle.Converters.Common.Objects; +using Speckle.Converters.Common; +using Speckle.Converters.RevitShared.Helpers; + +using Speckle.Converters.RevitShared.Extensions; + +namespace Speckle.Converters.RevitShared.ToSpeckle; + +[NameAndRankValue(nameof(DB.ExtrusionRoof), 0)] +public class ExtrusionRoofToSpeckleTopLevelConverter : BaseConversionToSpeckle +{ + private readonly IRawConversion _levelConverter; + private readonly IRawConversion _modelCurveArrayConverter; + private readonly IRawConversion _pointConverter; + private readonly ParameterValueExtractor _parameterValueExtractor; + private readonly DisplayValueExtractor _displayValueExtractor; + private readonly HostedElementConversionToSpeckle _hostedElementConverter; + private readonly ParameterObjectAssigner _parameterObjectAssigner; + + public ExtrusionRoofToSpeckleTopLevelConverter( + IRawConversion levelConverter, + IRawConversion modelCurveArrayConverter, + IRawConversion pointConverter, + ParameterValueExtractor parameterValueExtractor, + DisplayValueExtractor displayValueExtractor, + HostedElementConversionToSpeckle hostedElementConverter, + ParameterObjectAssigner parameterObjectAssigner + ) + { + _levelConverter = levelConverter; + _modelCurveArrayConverter = modelCurveArrayConverter; + _pointConverter = pointConverter; + _parameterValueExtractor = parameterValueExtractor; + _displayValueExtractor = displayValueExtractor; + _hostedElementConverter = hostedElementConverter; + _parameterObjectAssigner = parameterObjectAssigner; + } + + public override RevitExtrusionRoof RawConvert(DB.ExtrusionRoof target) + { + var speckleExtrusionRoof = new RevitExtrusionRoof + { + start = _parameterValueExtractor.GetValueAsDouble(target, DB.BuiltInParameter.EXTRUSION_START_PARAM), + end = _parameterValueExtractor.GetValueAsDouble(target, DB.BuiltInParameter.EXTRUSION_END_PARAM) + }; + var plane = target.GetProfile().get_Item(0).SketchPlane.GetPlane(); + speckleExtrusionRoof.referenceLine = new SOG.Line( + _pointConverter.RawConvert(plane.Origin.Add(plane.XVec.Normalize().Negate())), + _pointConverter.RawConvert(plane.Origin) + ); + var level = _parameterValueExtractor.GetValueAsDocumentObject( + target, + DB.BuiltInParameter.ROOF_CONSTRAINT_LEVEL_PARAM + ); + speckleExtrusionRoof.level = _levelConverter.RawConvert(level); + speckleExtrusionRoof.outline = _modelCurveArrayConverter.RawConvert(target.GetProfile()); + + var elementType = (DB.ElementType)target.Document.GetElement(target.GetTypeId()); + speckleExtrusionRoof.type = elementType.Name; + speckleExtrusionRoof.family = elementType.FamilyName; + + _parameterObjectAssigner.AssignParametersToBase(target, speckleExtrusionRoof); + speckleExtrusionRoof.displayValue = _displayValueExtractor.GetDisplayValue(target); + speckleExtrusionRoof.elements = _hostedElementConverter + .ConvertHostedElements(target.GetHostedElementIds()) + .ToList(); + + return speckleExtrusionRoof; + } +} diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/FootPrintRoofToSpeckleTopLevelConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/FootPrintRoofToSpeckleTopLevelConverter.cs new file mode 100644 index 0000000000..c4bc3379de --- /dev/null +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/FootPrintRoofToSpeckleTopLevelConverter.cs @@ -0,0 +1,88 @@ +using Autodesk.Revit.DB; +using Objects; +using Objects.BuiltElements.Revit; +using Objects.BuiltElements.Revit.RevitRoof; +using Objects.Geometry; +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; +using Speckle.Converters.RevitShared.Extensions; +using Speckle.Converters.RevitShared.Helpers; + +namespace Speckle.Converters.RevitShared.ToSpeckle; + +[NameAndRankValue(nameof(DB.FootPrintRoof), 0)] +public class FootPrintRoofToSpeckleTopLevelConverter : BaseConversionToSpeckle +{ + private readonly IRawConversion _levelConverter; + private readonly IRawConversion _modelCurveArrArrayConverter; + private readonly ParameterValueExtractor _parameterValueExtractor; + private readonly DisplayValueExtractor _displayValueExtractor; + private readonly HostedElementConversionToSpeckle _hostedElementConverter; + private readonly ParameterObjectAssigner _parameterObjectAssigner; + + public FootPrintRoofToSpeckleTopLevelConverter( + IRawConversion levelConverter, + IRawConversion modelCurveArrArrayConverter, + ParameterValueExtractor parameterValueExtractor, + DisplayValueExtractor displayValueExtractor, + HostedElementConversionToSpeckle hostedElementConverter, + ParameterObjectAssigner parameterObjectAssigner + ) + { + _levelConverter = levelConverter; + _modelCurveArrArrayConverter = modelCurveArrArrayConverter; + _parameterValueExtractor = parameterValueExtractor; + _displayValueExtractor = displayValueExtractor; + _hostedElementConverter = hostedElementConverter; + _parameterObjectAssigner = parameterObjectAssigner; + } + + public override RevitFootprintRoof RawConvert(FootPrintRoof target) + { + var baseLevel = _parameterValueExtractor.GetValueAsDocumentObject( + target, + DB.BuiltInParameter.ROOF_BASE_LEVEL_PARAM + ); + + // We don't currently validate the success of this TryGet, it is assumed some Roofs don't have a top-level. + _parameterValueExtractor.TryGetValueAsDocumentObject( + target, + DB.BuiltInParameter.ROOF_UPTO_LEVEL_PARAM, + out var topLevel + ); + + //POC: CNX-9403 can be null if the sides have different slopes. + //We currently don't validate the success or failure of this TryGet as it's not necessary, but will be once we start the above ticket. + _parameterValueExtractor.TryGetValueAsDouble(target, DB.BuiltInParameter.ROOF_SLOPE, out var slope); + + RevitFootprintRoof speckleFootprintRoof = + new() + { + level = _levelConverter.RawConvert(baseLevel), + cutOffLevel = topLevel is not null ? _levelConverter.RawConvert(topLevel) : null, + slope = slope + }; + + // POC: CNX-9396 again with the incorrect assumption that the first profile is the floor and subsequent profiles + // are voids + // POC: CNX-9403 in current connector, we are doing serious gymnastics to get the slope of the floor as defined by + // slope arrow. The way we are doing it relies on dynamic props and only works for Revit <-> Revit + var profiles = _modelCurveArrArrayConverter.RawConvert(target.GetProfiles()); + speckleFootprintRoof.outline = profiles.FirstOrDefault(); + speckleFootprintRoof.voids = profiles.Skip(1).ToList(); + + var elementType = (ElementType)target.Document.GetElement(target.GetTypeId()); + speckleFootprintRoof.type = elementType.Name; + speckleFootprintRoof.family = elementType.FamilyName; + + // POC: we are starting to see logic that is happening in all converters. We should definitely consider some + // conversion pipeline behavior. Would probably require adding interfaces into objects kit + _parameterObjectAssigner.AssignParametersToBase(target, speckleFootprintRoof); + speckleFootprintRoof.displayValue = _displayValueExtractor.GetDisplayValue(target); + speckleFootprintRoof.elements = _hostedElementConverter + .ConvertHostedElements(target.GetHostedElementIds()) + .ToList(); + + return speckleFootprintRoof; + } +} diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/HostedElementConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/HostedElementConversionToSpeckle.cs index 0af482a6f3..a84e0b4b33 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/HostedElementConversionToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/HostedElementConversionToSpeckle.cs @@ -1,6 +1,5 @@ using Autodesk.Revit.DB; using Speckle.Converters.Common; -using Speckle.Converters.RevitShared.Extensions; using Speckle.Converters.RevitShared.Helpers; using Speckle.Core.Models; @@ -13,36 +12,41 @@ public class HostedElementConversionToSpeckle { private readonly ToSpeckleConvertedObjectsCache _convertedObjectsCache; private readonly ISpeckleConverterToSpeckle _converter; + private readonly RevitConversionContextStack _contextStack; public HostedElementConversionToSpeckle( ToSpeckleConvertedObjectsCache convertedObjectsCache, - ISpeckleConverterToSpeckle converter + ISpeckleConverterToSpeckle converter, + RevitConversionContextStack contextStack ) { _convertedObjectsCache = convertedObjectsCache; _converter = converter; + _contextStack = contextStack; } - public List GetHostedElementsConverted(Element host) + public IEnumerable ConvertHostedElements(IEnumerable hostedElementIds) { - return GetHostedElementsConvertedFromIds(host, host.GetHostedElementIds()); - } - - // POC: needs to be reviewed - public List GetHostedElementsConvertedFromIds(Element host, IList hostedElementIds) - { - var convertedHostedElements = new List(); foreach (var elemId in hostedElementIds) { - var element = host.Document.GetElement(elemId); + Element element = _contextStack.Current.Document.Document.GetElement(elemId); if (_convertedObjectsCache.ContainsBaseConvertedFromId(element.UniqueId)) { continue; } - convertedHostedElements.Add(_converter.Convert(element)); - } + Base @base; + try + { + @base = _converter.Convert(element); + } + catch (SpeckleConversionException) + { + // POC: logging + continue; + } - return convertedHostedElements; + yield return @base; + } } } diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/RoofBaseToSpeckleTopLevelConversion.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/RoofBaseToSpeckleTopLevelConversion.cs new file mode 100644 index 0000000000..464e78ba01 --- /dev/null +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/RoofBaseToSpeckleTopLevelConversion.cs @@ -0,0 +1,40 @@ +using Autodesk.Revit.DB; +using Objects.BuiltElements.Revit.RevitRoof; +using Speckle.Converters.Common; +using Speckle.Converters.RevitShared.Extensions; +using Speckle.Converters.RevitShared.Helpers; + +namespace Speckle.Converters.RevitShared.ToSpeckle; + +[NameAndRankValue(nameof(DB.RoofBase), 0)] +internal sealed class RoofBaseToSpeckleTopLevelConversion : BaseConversionToSpeckle +{ + private readonly DisplayValueExtractor _displayValueExtractor; + private readonly HostedElementConversionToSpeckle _hostedElementConverter; + private readonly ParameterObjectAssigner _parameterObjectAssigner; + + public RoofBaseToSpeckleTopLevelConversion( + DisplayValueExtractor displayValueExtractor, + HostedElementConversionToSpeckle hostedElementConverter, + ParameterObjectAssigner parameterObjectAssigner + ) + { + _displayValueExtractor = displayValueExtractor; + _hostedElementConverter = hostedElementConverter; + _parameterObjectAssigner = parameterObjectAssigner; + } + + public override RevitRoof RawConvert(RoofBase target) + { + RevitRoof revitRoof = new(); + var elementType = (ElementType)target.Document.GetElement(target.GetTypeId()); + revitRoof.type = elementType.Name; + revitRoof.family = elementType.FamilyName; + + _parameterObjectAssigner.AssignParametersToBase(target, revitRoof); + revitRoof.displayValue = _displayValueExtractor.GetDisplayValue(target); + revitRoof.elements = _hostedElementConverter.ConvertHostedElements(target.GetHostedElementIds()).ToList(); + + return revitRoof; + } +} diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/RoomConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/RoomConversionToSpeckle.cs index 0c829ec684..16a94cac1e 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/RoomConversionToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/RoomConversionToSpeckle.cs @@ -54,7 +54,7 @@ public override SOBE.Room RawConvert(DBA.Room target) var speckleRoom = new SOBE.Room(name ?? "-", number, level, basePoint) { displayValue = displayValue, - area = area ?? 0, + area = area, outline = outline, voids = voids }; diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/WallConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/WallConversionToSpeckle.cs index 39eda3e90a..9ea1acb847 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/WallConversionToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/WallConversionToSpeckle.cs @@ -81,11 +81,24 @@ private void AssignSpecificParameters(DB.Wall target, RevitWall speckleWall) speckleWall.topLevel = _levelConverter.RawConvert(topLevel); // POC : what to do if these parameters are unset (instead of assigning default) - speckleWall.height = - _parameterValueExtractor.GetValueAsDouble(target, DB.BuiltInParameter.WALL_USER_HEIGHT_PARAM) ?? 0; - speckleWall.baseOffset = - _parameterValueExtractor.GetValueAsDouble(target, DB.BuiltInParameter.WALL_BASE_OFFSET) ?? 0; - speckleWall.topOffset = _parameterValueExtractor.GetValueAsDouble(target, DB.BuiltInParameter.WALL_TOP_OFFSET) ?? 0; + _ = _parameterValueExtractor.TryGetValueAsDouble( + target, + DB.BuiltInParameter.WALL_USER_HEIGHT_PARAM, + out double? height + ); + speckleWall.height = height ?? 0; + _ = _parameterValueExtractor.TryGetValueAsDouble( + target, + DB.BuiltInParameter.WALL_BASE_OFFSET, + out double? baseOffset + ); + speckleWall.baseOffset = baseOffset ?? 0; + _ = _parameterValueExtractor.TryGetValueAsDouble( + target, + DB.BuiltInParameter.WALL_TOP_OFFSET, + out double? topOffset + ); + speckleWall.topOffset = topOffset ?? 0; speckleWall.structural = _parameterValueExtractor.GetValueAsBool(target, DB.BuiltInParameter.WALL_STRUCTURAL_SIGNIFICANT) ?? false; speckleWall.flipped = target.Flipped; From 6adfed7670ce7baf0aaa0bf8f29b2436904ddce3 Mon Sep 17 00:00:00 2001 From: Dimitrie Stefanescu Date: Fri, 3 May 2024 16:45:23 +0100 Subject: [PATCH 093/261] fix(dui3): corrects revit commit structure stops storing objects in a non-detached way & plops them in level & category based collections --- .../Operations/Send/RootObjectBuilder.cs | 71 +++++++++++++++++-- 1 file changed, 66 insertions(+), 5 deletions(-) diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RootObjectBuilder.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RootObjectBuilder.cs index fc1f2eb302..14ea35c19c 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RootObjectBuilder.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RootObjectBuilder.cs @@ -42,26 +42,87 @@ public Base Build( throw new InvalidOperationException("No objects were found. Please update your send filter!"); } - Base commitObject = new(); + var doc = _contextStack.Current.Document.Document; // POC: Document.Document is funny + var rootObject = new Collection() { name = doc.PathName.Split('\\').Reverse().First().Split('.').First() }; - foreach (Element obj in objects) + // memoize-er for the GetAndCreateObjectHostCollection calls below + // POC: if the lifetime of this builder is on a per-operation basis, we don't need this declaration here and we can + // tidy things up. In the interest of time, skipping this check. + var collectionCache = new Dictionary(); + var countProgress = 0; // because for(int i = 0; ...) loops are so last year + + foreach (Element revitElement in objects) { ct.ThrowIfCancellationRequested(); - if (_convertedObjectsCache.ContainsBaseConvertedFromId(obj.UniqueId)) + + var cat = revitElement.Category.Name; + var path = new[] { doc.GetElement(revitElement.LevelId) is not Level level ? "No level" : level.Name, cat }; + var collection = GetAndCreateObjectHostCollection(path, collectionCache, rootObject); + + if (_convertedObjectsCache.ContainsBaseConvertedFromId(revitElement.UniqueId)) { continue; } try { - commitObject[obj.UniqueId] = _converter.Convert(obj); + var convertedElement = _converter.Convert(revitElement); + convertedElement.applicationId = revitElement.Id.ToString(); + collection.elements.Add(convertedElement); } catch (SpeckleConversionException ex) { // POC: logging } + + countProgress++; + onOperationProgressed?.Invoke("Converting", (double)countProgress / objects.Count); + } + + return rootObject; + } + + /// + /// Creates and nests collections based on the provided path within the root collection provided. This will not return a new collection each time is called, but an existing one if one is found. + /// For example, you can use this to use (or re-use) a new collection for a path of (level, category) as it's currently implemented. + /// + /// + /// + /// + /// + private Collection GetAndCreateObjectHostCollection( + string[] path, + Dictionary cache, + Collection root + ) + { + string fullPathName = string.Join("", path); + if (cache.TryGetValue(fullPathName, out Collection value)) + { + return value; + } + + string flatPathName = ""; + Collection previousCollection = root; + + foreach (var pathItem in path) + { + flatPathName += pathItem; + Collection childCollection; + if (cache.ContainsKey(flatPathName)) + { + childCollection = cache[flatPathName]; + } + else + { + childCollection = new Collection(pathItem, "layer"); + previousCollection.elements.Add(childCollection); + cache[flatPathName] = childCollection; + } + + previousCollection = childCollection; } - return commitObject; + return previousCollection; } } From 24bf83a0012bb1f861484e1d14e09409d2ed8aaf Mon Sep 17 00:00:00 2001 From: Dimitrie Stefanescu Date: Fri, 3 May 2024 17:53:46 +0100 Subject: [PATCH 094/261] fix(dui3/revit): review changes --- .../Operations/Send/RootObjectBuilder.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RootObjectBuilder.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RootObjectBuilder.cs index 14ea35c19c..a4c2111d7b 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RootObjectBuilder.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RootObjectBuilder.cs @@ -43,7 +43,7 @@ public Base Build( } var doc = _contextStack.Current.Document.Document; // POC: Document.Document is funny - var rootObject = new Collection() { name = doc.PathName.Split('\\').Reverse().First().Split('.').First() }; + var rootObject = new Collection() { name = doc.PathName.Split('\\').Last().Split('.').First() }; // memoize-er for the GetAndCreateObjectHostCollection calls below // POC: if the lifetime of this builder is on a per-operation basis, we don't need this declaration here and we can @@ -96,7 +96,7 @@ private Collection GetAndCreateObjectHostCollection( Collection root ) { - string fullPathName = string.Join("", path); + string fullPathName = string.Concat(path); if (cache.TryGetValue(fullPathName, out Collection value)) { return value; From b534e279cf375dba2e6b2822abdd2349879af720 Mon Sep 17 00:00:00 2001 From: Jedd Morgan <45512892+JR-Morgan@users.noreply.github.com> Date: Fri, 3 May 2024 18:01:20 +0100 Subject: [PATCH 095/261] CNX-9397 CNX-9401 rhino does not receive autocad polylines (#3344) Converter Resolver --- .../AutofacAutocadConverterModule.cs | 4 +++ .../AutofacRevitConverterModule.cs | 4 +++ .../RevitConverterToSpeckle.cs | 24 +++-------------- .../AutofacRhinoConverterModule.cs | 5 +++- .../ToHost/ToHostConverterWithFallback.cs | 16 +++++++---- .../ToHost/ToHostConverterWithoutFallback.cs | 18 +++++++------ .../Objects/IConverterResolver.cs | 9 +++++++ .../RecursiveConveterResolver.cs | 27 +++++++++++++++++++ 8 files changed, 72 insertions(+), 35 deletions(-) create mode 100644 DUI3-DX/Sdk/Speckle.Converters.Common/Objects/IConverterResolver.cs create mode 100644 DUI3-DX/Sdk/Speckle.Converters.Common/RecursiveConveterResolver.cs diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2023.DependencyInjection/AutofacAutocadConverterModule.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2023.DependencyInjection/AutofacAutocadConverterModule.cs index e7f3dca0b2..ba5890a6bb 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2023.DependencyInjection/AutofacAutocadConverterModule.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2023.DependencyInjection/AutofacAutocadConverterModule.cs @@ -34,5 +34,9 @@ protected override void Load(ContainerBuilder builder) .RegisterType>() .As>() .InstancePerLifetimeScope(); + builder + .RegisterType>() + .As>() + .InstancePerLifetimeScope(); } } diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/AutofacRevitConverterModule.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/AutofacRevitConverterModule.cs index edae0982a6..93e4001ae2 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/AutofacRevitConverterModule.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/AutofacRevitConverterModule.cs @@ -24,6 +24,10 @@ protected override void Load(ContainerBuilder builder) .RegisterType>() .As>() .InstancePerLifetimeScope(); + builder + .RegisterType>() + .As>() + .InstancePerLifetimeScope(); // POC: do we need ToSpeckleScalingService as is, do we need to interface it out? builder.RegisterType().AsSelf().InstancePerLifetimeScope(); diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/RevitConverterToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/RevitConverterToSpeckle.cs index 3954f1f2d8..44aec8ce9d 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/RevitConverterToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/RevitConverterToSpeckle.cs @@ -1,7 +1,6 @@ using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; using Speckle.Core.Models; -using Speckle.Autofac.DependencyInjection; using Speckle.Converters.RevitShared.Helpers; namespace Speckle.Converters.RevitShared; @@ -9,12 +8,12 @@ namespace Speckle.Converters.RevitShared; // POC: maybe possible to restrict the access so this cannot be created directly? public class RevitConverterToSpeckle : ISpeckleConverterToSpeckle { - private readonly IFactory _toSpeckle; + private readonly IConverterResolver _toSpeckle; private readonly ToSpeckleConvertedObjectsCache _convertedObjectsCache; private readonly ParameterValueExtractor _parameterValueExtractor; public RevitConverterToSpeckle( - IFactory toSpeckle, + IConverterResolver toSpeckle, ToSpeckleConvertedObjectsCache convertedObjectsCache, ParameterValueExtractor parameterValueExtractor ) @@ -28,7 +27,7 @@ ParameterValueExtractor parameterValueExtractor // if it cannot be converted then we should throw public Base Convert(object target) { - var objectConverter = GetConversionForObject(target.GetType()); + var objectConverter = _toSpeckle.GetConversionForType(target.GetType()); if (objectConverter == null) { @@ -52,21 +51,4 @@ public Base Convert(object target) return result; } - - // POC: consider making this a more accessible as a pattern to other connectors - // https://spockle.atlassian.net/browse/CNX-9397 - private IHostObjectToSpeckleConversion? GetConversionForObject(Type objectType) - { - if (objectType == typeof(object)) - { - return null; - } - - if (_toSpeckle.ResolveInstance(objectType.Name) is IHostObjectToSpeckleConversion conversion) - { - return conversion; - } - - return GetConversionForObject(objectType.BaseType); - } } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/AutofacRhinoConverterModule.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/AutofacRhinoConverterModule.cs index 2a97701d32..9131d5241c 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/AutofacRhinoConverterModule.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/AutofacRhinoConverterModule.cs @@ -37,7 +37,10 @@ This will require consolidating across other connectors. .RegisterType>() .As>() .InstancePerLifetimeScope(); - + builder + .RegisterType>() + .As>() + .InstancePerLifetimeScope(); builder.RegisterType().As().InstancePerLifetimeScope(); /* diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/ToHost/ToHostConverterWithFallback.cs b/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/ToHost/ToHostConverterWithFallback.cs index 6316e8de5e..1062a9d391 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/ToHost/ToHostConverterWithFallback.cs +++ b/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/ToHost/ToHostConverterWithFallback.cs @@ -1,17 +1,23 @@ -using Speckle.Autofac.DependencyInjection; -using Speckle.Converters.Common.Objects; +using Speckle.Converters.Common.Objects; using Speckle.Core.Models; using Speckle.Core.Models.Extensions; namespace Speckle.Converters.Common.DependencyInjection.ToHost; // POC: CNX-9394 Find a better home for this outside `DependencyInjection` project +/// +/// +///
+/// If no suitable converter conversion is found, and the target object has a displayValue property +/// a converter with strong name of is resolved for. +///
+/// public sealed class ToHostConverterWithFallback : ISpeckleConverterToHost { - private readonly IFactory _toHost; + private readonly IConverterResolver _toHost; private readonly ToHostConverterWithoutFallback _baseConverter; - public ToHostConverterWithFallback(IFactory toHost) + public ToHostConverterWithFallback(IConverterResolver toHost) { _toHost = toHost; _baseConverter = new ToHostConverterWithoutFallback(toHost); @@ -57,7 +63,7 @@ private object FallbackToDisplayValue(IReadOnlyList displayValue) // Create a temp Displayable object that handles the displayValue. var tempDisplayableObject = new DisplayableObject(displayValue); - var displayableObjectConverter = _toHost.ResolveInstance(nameof(DisplayableObject)); + var displayableObjectConverter = _toHost.GetConversionForType(typeof(DisplayableObject)); // It is not guaranteed that a fallback converter has been registered in all connectors if (displayableObjectConverter == null) diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/ToHost/ToHostConverterWithoutFallback.cs b/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/ToHost/ToHostConverterWithoutFallback.cs index 2c00a69ec5..8e00677ffd 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/ToHost/ToHostConverterWithoutFallback.cs +++ b/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/ToHost/ToHostConverterWithoutFallback.cs @@ -1,17 +1,21 @@ -using Speckle.Autofac.DependencyInjection; -using Speckle.Converters.Common.Objects; +using Speckle.Converters.Common.Objects; using Speckle.Core.Models; namespace Speckle.Converters.Common.DependencyInjection.ToHost; // POC: CNX-9394 Find a better home for this outside `DependencyInjection` project +/// +/// Provides an implementation for +/// that resolves a via the injected +/// +/// public sealed class ToHostConverterWithoutFallback : ISpeckleConverterToHost { - private readonly IFactory _toHost; + private readonly IConverterResolver _toHost; - public ToHostConverterWithoutFallback(IFactory toHost) + public ToHostConverterWithoutFallback(IConverterResolver converterResolver) { - _toHost = toHost; + _toHost = converterResolver; } public object Convert(Base target) @@ -25,10 +29,8 @@ public object Convert(Base target) internal bool TryConvert(Base target, out object? result) { - var typeName = target.GetType().Name; - // Direct conversion if a converter is found - var objectConverter = _toHost.ResolveInstance(typeName); + var objectConverter = _toHost.GetConversionForType(target.GetType()); if (objectConverter != null) { result = objectConverter.Convert(target); diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common/Objects/IConverterResolver.cs b/DUI3-DX/Sdk/Speckle.Converters.Common/Objects/IConverterResolver.cs new file mode 100644 index 0000000000..f0018be82e --- /dev/null +++ b/DUI3-DX/Sdk/Speckle.Converters.Common/Objects/IConverterResolver.cs @@ -0,0 +1,9 @@ +using System; + +namespace Speckle.Converters.Common.Objects; + +public interface IConverterResolver + where TConverter : class +{ + public TConverter? GetConversionForType(Type objectType); +} diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common/RecursiveConveterResolver.cs b/DUI3-DX/Sdk/Speckle.Converters.Common/RecursiveConveterResolver.cs new file mode 100644 index 0000000000..60f78389f5 --- /dev/null +++ b/DUI3-DX/Sdk/Speckle.Converters.Common/RecursiveConveterResolver.cs @@ -0,0 +1,27 @@ +using System; +using Speckle.Autofac.DependencyInjection; +using Speckle.Converters.Common.Objects; + +namespace Speckle.Converters.Common; + +public sealed class RecursiveConverterResolver : IConverterResolver + where TConverter : class +{ + private readonly IFactory _factory; + + public RecursiveConverterResolver(IFactory factory) + { + _factory = factory; + } + + public TConverter? GetConversionForType(Type objectType) + { + if (objectType.BaseType == null) + { + //We've reached the top of the inheritance tree + return null; + } + + return _factory.ResolveInstance(objectType.Name) ?? GetConversionForType(objectType.BaseType); + } +} From 20d6ae9b814a9c22a891c298a3cad700e4b25c90 Mon Sep 17 00:00:00 2001 From: Dimitrie Stefanescu Date: Fri, 3 May 2024 18:05:36 +0100 Subject: [PATCH 096/261] cleanup(dui3): cleans up build operation since the class' lifetime is per unit of work, then we can instantiate our caches in the right places --- .../Operations/Send/RootObjectBuilder.cs | 31 +++++++++++-------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RootObjectBuilder.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RootObjectBuilder.cs index a4c2111d7b..2607010a51 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RootObjectBuilder.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RootObjectBuilder.cs @@ -16,6 +16,8 @@ public class RootObjectBuilder private readonly ISpeckleConverterToSpeckle _converter; private readonly ToSpeckleConvertedObjectsCache _convertedObjectsCache; private readonly RevitConversionContextStack _contextStack; + private readonly Dictionary _collectionCache; + private readonly Collection _rootObject; public RootObjectBuilder( ISpeckleConverterToSpeckle converter, @@ -27,6 +29,12 @@ RevitConversionContextStack contextStack // POC: needs considering if this is something to add now or needs refactoring _convertedObjectsCache = convertedObjectsCache; _contextStack = contextStack; + + _collectionCache = new Dictionary(); + _rootObject = new Collection() + { + name = _contextStack.Current.Document.Document.PathName.Split('\\').Last().Split('.').First() + }; } public Base Build( @@ -43,7 +51,7 @@ public Base Build( } var doc = _contextStack.Current.Document.Document; // POC: Document.Document is funny - var rootObject = new Collection() { name = doc.PathName.Split('\\').Last().Split('.').First() }; + // var rootObject = new Collection() { name = doc.PathName.Split('\\').Last().Split('.').First() }; // memoize-er for the GetAndCreateObjectHostCollection calls below // POC: if the lifetime of this builder is on a per-operation basis, we don't need this declaration here and we can @@ -57,7 +65,7 @@ public Base Build( var cat = revitElement.Category.Name; var path = new[] { doc.GetElement(revitElement.LevelId) is not Level level ? "No level" : level.Name, cat }; - var collection = GetAndCreateObjectHostCollection(path, collectionCache, rootObject); + var collection = GetAndCreateObjectHostCollection(path); if (_convertedObjectsCache.ContainsBaseConvertedFromId(revitElement.UniqueId)) { @@ -77,9 +85,10 @@ public Base Build( countProgress++; onOperationProgressed?.Invoke("Converting", (double)countProgress / objects.Count); + Thread.Sleep(1000); } - return rootObject; + return _rootObject; } /// @@ -90,34 +99,30 @@ public Base Build( /// /// /// - private Collection GetAndCreateObjectHostCollection( - string[] path, - Dictionary cache, - Collection root - ) + private Collection GetAndCreateObjectHostCollection(string[] path) { string fullPathName = string.Concat(path); - if (cache.TryGetValue(fullPathName, out Collection value)) + if (_collectionCache.TryGetValue(fullPathName, out Collection value)) { return value; } string flatPathName = ""; - Collection previousCollection = root; + Collection previousCollection = _rootObject; foreach (var pathItem in path) { flatPathName += pathItem; Collection childCollection; - if (cache.ContainsKey(flatPathName)) + if (_collectionCache.ContainsKey(flatPathName)) { - childCollection = cache[flatPathName]; + childCollection = _collectionCache[flatPathName]; } else { childCollection = new Collection(pathItem, "layer"); previousCollection.elements.Add(childCollection); - cache[flatPathName] = childCollection; + _collectionCache[flatPathName] = childCollection; } previousCollection = childCollection; From b6e2bda4753de9f3e2699348311b4c272659c739 Mon Sep 17 00:00:00 2001 From: Dimitrie Stefanescu Date: Fri, 3 May 2024 18:08:18 +0100 Subject: [PATCH 097/261] chore(dui3): cleanup --- .../Operations/Send/RootObjectBuilder.cs | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RootObjectBuilder.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RootObjectBuilder.cs index 2607010a51..f9e779726e 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RootObjectBuilder.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RootObjectBuilder.cs @@ -30,6 +30,7 @@ RevitConversionContextStack contextStack _convertedObjectsCache = convertedObjectsCache; _contextStack = contextStack; + // Note, this class is instantiated per unit of work (aka per send operation), so we can safely initialize what we need in here. _collectionCache = new Dictionary(); _rootObject = new Collection() { @@ -51,12 +52,6 @@ public Base Build( } var doc = _contextStack.Current.Document.Document; // POC: Document.Document is funny - // var rootObject = new Collection() { name = doc.PathName.Split('\\').Last().Split('.').First() }; - - // memoize-er for the GetAndCreateObjectHostCollection calls below - // POC: if the lifetime of this builder is on a per-operation basis, we don't need this declaration here and we can - // tidy things up. In the interest of time, skipping this check. - var collectionCache = new Dictionary(); var countProgress = 0; // because for(int i = 0; ...) loops are so last year foreach (Element revitElement in objects) @@ -96,8 +91,6 @@ public Base Build( /// For example, you can use this to use (or re-use) a new collection for a path of (level, category) as it's currently implemented. /// /// - /// - /// /// private Collection GetAndCreateObjectHostCollection(string[] path) { From 5ef4a503069f99ba32988104918ecc2814935d58 Mon Sep 17 00:00:00 2001 From: Jedd Morgan <45512892+JR-Morgan@users.noreply.github.com> Date: Fri, 3 May 2024 18:10:27 +0100 Subject: [PATCH 098/261] sync to ui thread (#3351) * sync to ui thread * supressed warning * fixed using --------- Co-authored-by: BovineOx <73857041+BovineOx@users.noreply.github.com> --- .../Speckle.Connectors.DUI/Bridge/SyncToUIThread.cs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/SyncToUIThread.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/SyncToUIThread.cs index 9eb30b2168..ac9e74086e 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/SyncToUIThread.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/SyncToUIThread.cs @@ -1,4 +1,5 @@ using System; +using System.Diagnostics.CodeAnalysis; using System.Threading.Tasks; using Speckle.Connectors.Utils.Operations; @@ -13,14 +14,22 @@ public SyncToUIThread(IBridge bridge) _bridge = bridge; } + [SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "Task Completion Source")] public Task RunOnThread(Func func) { TaskCompletionSource tcs = new(); _bridge.RunOnMainThread(() => { - T result = func.Invoke(); - tcs.SetResult(result); + try + { + T result = func.Invoke(); + tcs.SetResult(result); + } + catch (Exception ex) + { + tcs.SetException(ex); + } }); return tcs.Task; From 97d7f885522504a7946737ad2e2b4968f15d68ef Mon Sep 17 00:00:00 2001 From: Dimitrie Stefanescu Date: Fri, 3 May 2024 18:12:37 +0100 Subject: [PATCH 099/261] chore(dui3): makes revit sends 10000x faster (snark) i forgot a thread.sleep in there where i was testing multiple sends --- .../Operations/Send/RootObjectBuilder.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RootObjectBuilder.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RootObjectBuilder.cs index f9e779726e..8be94fbc3b 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RootObjectBuilder.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RootObjectBuilder.cs @@ -80,7 +80,6 @@ public Base Build( countProgress++; onOperationProgressed?.Invoke("Converting", (double)countProgress / objects.Count); - Thread.Sleep(1000); } return _rootObject; From b8d47acb7ac08bae16cb0e8bc23b4ede9640439a Mon Sep 17 00:00:00 2001 From: Dimitrie Stefanescu Date: Fri, 3 May 2024 19:04:29 +0100 Subject: [PATCH 100/261] fix(dui3/revit): change tracking centralises id operations across on element ids. note, it would be better do to do it the other way around, but the change events in revit give us plain ids rather than unique ids. --- .../Bindings/BasicConnectorBindingRevit.cs | 5 +---- .../Bindings/SelectionBinding.cs | 10 ++++------ .../Bindings/SendBinding.cs | 6 +++--- .../Operations/Send/RootObjectBuilder.cs | 11 ++++++++++- 4 files changed, 18 insertions(+), 14 deletions(-) diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/BasicConnectorBindingRevit.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/BasicConnectorBindingRevit.cs index 5f2819b4c2..d6e6537987 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/BasicConnectorBindingRevit.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/BasicConnectorBindingRevit.cs @@ -106,11 +106,8 @@ public void HighlightModel(string modelCardId) var doc = _revitContext.UIApplication.ActiveUIDocument.Document; SenderModelCard model = (SenderModelCard)_store.GetModelById(modelCardId); - List objectsIds = model.SendFilter.GetObjectIds(); - - // POC: GetElementsFromDocument could be interfaced out, extension is cleaner - List elementIds = doc.GetElements(objectsIds).Select(e => e.Id).ToList(); + var elementIds = model.SendFilter.GetObjectIds().Select(ElementId.Parse).ToList(); if (elementIds.Count == 0) { Commands.SetModelError(modelCardId, new InvalidOperationException("No objects found to highlight.")); diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SelectionBinding.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SelectionBinding.cs index 68555dcde7..b49b73077c 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SelectionBinding.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SelectionBinding.cs @@ -44,16 +44,14 @@ public SelectionInfo GetSelection() // POC: this was also being called on shutdown // probably the bridge needs to be able to know if the plugin has been terminated // also on termination the OnSelectionChanged event needs unwinding - List els = _revitContext.UIApplication.ActiveUIDocument.Selection + var selectionIds = _revitContext.UIApplication.ActiveUIDocument.Selection .GetElementIds() - .Select(id => _revitContext.UIApplication.ActiveUIDocument.Document.GetElement(id)) + .Select(id => id.ToString()) .ToList(); - List cats = els.Select(el => el.Category?.Name ?? el.Name).Distinct().ToList(); - List ids = els.Select(el => el.UniqueId.ToString()).ToList(); return new SelectionInfo() { - SelectedObjectIds = ids, - Summary = $"{els.Count} objects ({string.Join(", ", cats)})" + SelectedObjectIds = selectionIds, + Summary = $"{selectionIds.Count} objects selected." }; } } diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SendBinding.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SendBinding.cs index f582e73f79..72f91ef72c 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SendBinding.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SendBinding.cs @@ -147,17 +147,17 @@ private void DocChangeHandler(Autodesk.Revit.DB.Events.DocumentChangedEventArgs foreach (ElementId elementId in addedElementIds) { - ChangedObjectIds.Add(elementId.IntegerValue.ToString()); + ChangedObjectIds.Add(elementId.ToString()); } foreach (ElementId elementId in deletedElementIds) { - ChangedObjectIds.Add(elementId.IntegerValue.ToString()); + ChangedObjectIds.Add(elementId.ToString()); } foreach (ElementId elementId in modifiedElementIds) { - ChangedObjectIds.Add(elementId.IntegerValue.ToString()); + ChangedObjectIds.Add(elementId.ToString()); } // TODO: CHECK IF ANY OF THE ABOVE ELEMENTS NEED TO TRIGGER A FILTER REFRESH diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RootObjectBuilder.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RootObjectBuilder.cs index 8be94fbc3b..6e5d416053 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RootObjectBuilder.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RootObjectBuilder.cs @@ -44,7 +44,16 @@ public Base Build( CancellationToken ct = default ) { - List objects = _contextStack.Current.Document.Document.GetElements(sendSelection.SelectedItems).ToList(); + var objects = new List(); // = _contextStack.Current.Document.Document.GetElements(sendSelection.SelectedItems).ToList(); + + foreach (var id in sendSelection.SelectedItems) + { + var el = _contextStack.Current.Document.Document.GetElement(ElementId.Parse(id)); + if (el != null) + { + objects.Add(el); + } + } if (objects.Count == 0) { From b3b46d285d295883362614186810120c8183fb29 Mon Sep 17 00:00:00 2001 From: Dimitrie Stefanescu Date: Fri, 3 May 2024 19:39:32 +0100 Subject: [PATCH 101/261] chore(dui3/revit): cleans up unused using statements --- .../Bindings/BasicConnectorBindingRevit.cs | 2 -- .../Speckle.Connectors.RevitShared/Bindings/SelectionBinding.cs | 2 -- .../Operations/Send/RootObjectBuilder.cs | 1 - 3 files changed, 5 deletions(-) diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/BasicConnectorBindingRevit.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/BasicConnectorBindingRevit.cs index d6e6537987..15616ce6be 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/BasicConnectorBindingRevit.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/BasicConnectorBindingRevit.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using System.Linq; using System.Reflection; using Autodesk.Revit.DB; @@ -9,7 +8,6 @@ using Speckle.Connectors.DUI.Models; using Speckle.Connectors.DUI.Models.Card; using Speckle.Connectors.Revit.Plugin; -using Speckle.Connectors.Revit.HostApp; using Speckle.Converters.RevitShared.Helpers; using Speckle.Core.Logging; diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SelectionBinding.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SelectionBinding.cs index b49b73077c..3c339526d7 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SelectionBinding.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SelectionBinding.cs @@ -1,6 +1,4 @@ -using System.Collections.Generic; using System.Linq; -using Autodesk.Revit.DB; using Speckle.Connectors.DUI.Bindings; using Speckle.Connectors.DUI.Bridge; using Speckle.Connectors.DUI.Models; diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RootObjectBuilder.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RootObjectBuilder.cs index 6e5d416053..cbe02b5fcc 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RootObjectBuilder.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RootObjectBuilder.cs @@ -5,7 +5,6 @@ using System.Threading; using Autodesk.Revit.DB; using Speckle.Converters.RevitShared.Helpers; -using Speckle.Connectors.Revit.HostApp; using System.Linq; namespace Speckle.Connectors.Revit.Operations.Send; From dc643efa80e7410329bb3f8c5c67674fc80a972e Mon Sep 17 00:00:00 2001 From: Connor Ivy Date: Fri, 3 May 2024 14:29:10 -0500 Subject: [PATCH 102/261] rename parameter to reflect change in id type --- .../Speckle.Converters.RevitShared/Helpers/SendSelection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/SendSelection.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/SendSelection.cs index 4ed6136418..c6b4590a6d 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/SendSelection.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/SendSelection.cs @@ -11,7 +11,7 @@ public SendSelection(IEnumerable selectedItemIds) _selectedItemIds = new HashSet(selectedItemIds); } - public bool Contains(string uniqueId) => _selectedItemIds.Contains(uniqueId); + public bool Contains(string elementId) => _selectedItemIds.Contains(elementId); public IReadOnlyCollection SelectedItems => _selectedItemIds.ToList().AsReadOnly(); } From b3569545d047cc00a911cdc3e77f80eb63a13b15 Mon Sep 17 00:00:00 2001 From: connorivy <43247197+connorivy@users.noreply.github.com> Date: Fri, 3 May 2024 15:44:59 -0500 Subject: [PATCH 103/261] Fix(Revit): fix slope arrow injection and use nullable slope parameter (#3356) fix floor conversion Co-authored-by: Connor Ivy --- .../ToSpeckle/FloorConversionToSpeckle.cs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/FloorConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/FloorConversionToSpeckle.cs index 7579be070d..16b409f294 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/FloorConversionToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/FloorConversionToSpeckle.cs @@ -19,7 +19,7 @@ public class FloorConversionToSpeckle : BaseConversionToSpeckle> curveArrArrayConverter, @@ -27,7 +27,7 @@ public FloorConversionToSpeckle( ParameterValueExtractor parameterValueExtractor, ParameterObjectAssigner parameterObjectAssigner, DisplayValueExtractor displayValueExtractor, - SlopeArrowExtractor slopeArrowExtractor + ISlopeArrowExtractor slopeArrowExtractor ) { _curveArrArrayConverter = curveArrArrayConverter; @@ -66,8 +66,12 @@ public override SOBR.RevitFloor RawConvert(DB.Floor target) speckleFloor.structural = _parameterValueExtractor.GetValueAsBool(target, DB.BuiltInParameter.FLOOR_PARAM_IS_STRUCTURAL) ?? false; - // Divide by 100 to convert from percentage to unitless ratio (rise over run) - var slopeParam = _parameterValueExtractor.GetValueAsDouble(target, DB.BuiltInParameter.ROOF_SLOPE) / 100; + double? slopeParam = null; + if (_parameterValueExtractor.TryGetValueAsDouble(target, DB.BuiltInParameter.ROOF_SLOPE, out var slope)) + { + // Divide by 100 to convert from percentage to unitless ratio (rise over run) + slopeParam = slope / 100d; + } _parameterObjectAssigner.AssignParametersToBase(target, speckleFloor); TryAssignSlopeFromSlopeArrow(target, speckleFloor, slopeParam); From 9e28bfe58df47b3ce29e692ef658662c3b40a920 Mon Sep 17 00:00:00 2001 From: Jedd Morgan <45512892+JR-Morgan@users.noreply.github.com> Date: Fri, 3 May 2024 21:53:48 +0100 Subject: [PATCH 104/261] Remove Cancellation Swallowing and re-Lazied the binding registration (#3353) removed cancellation swallowing --- .../Bindings/ArcGISReceiveBinding.cs | 5 ----- .../Bindings/AutocadReceiveBinding.cs | 10 +++------ .../Bindings/RhinoReceiveBinding.cs | 4 ---- .../DUI3ControlWebView.xaml.cs | 22 ++++++++++++++----- 4 files changed, 20 insertions(+), 21 deletions(-) diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISReceiveBinding.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISReceiveBinding.cs index 2e303c641a..d92413b358 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISReceiveBinding.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISReceiveBinding.cs @@ -64,11 +64,6 @@ public async Task Receive(string modelCardId) Commands.SetModelReceiveResult(modelCardId, receivedObjectIds.ToList()); } - catch (OperationCanceledException) - { - // POC: not sure here need to handle anything. UI already aware it cancelled operation visually. - return; - } catch (Exception e) when (!e.IsFatal()) // All exceptions should be handled here if possible, otherwise we enter "crashing the host app" territory. { Commands.SetModelError(modelCardId, e); diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadReceiveBinding.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadReceiveBinding.cs index c21f38148c..e35dc56a8c 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadReceiveBinding.cs +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadReceiveBinding.cs @@ -66,13 +66,6 @@ public async Task Receive(string modelCardId) Commands.SetModelReceiveResult(modelCardId, receivedObjectIds.ToList()); } - catch (OperationCanceledException) - { - // POC: not sure here need to handle anything. UI already aware it cancelled operation visually. - // POC: JEDD: We should not update the UI until this exception is caught, we don't want to show the UI as cancelled - // until the actual operation is cancelled (thrown exception). - return; - } catch (Exception e) when (!e.IsFatal()) // All exceptions should be handled here if possible, otherwise we enter "crashing the host app" territory. { Commands.SetModelError(modelCardId, e); @@ -84,6 +77,9 @@ private void OnSendOperationProgress(string modelCardId, string status, double? Commands.SetModelProgress(modelCardId, new ModelCardProgress { Status = status, Progress = progress }); } + // POC: JEDD: We should not update the UI until a OperationCancelledException is caught, we don't want to show the UI as cancelled + // until the actual operation is cancelled (thrown exception). + // I think there's room for us to introduce a cancellation pattern for bindings to do this and avoid this _cancellationManager public void CancelSend(string modelCardId) => _cancellationManager.CancelOperation(modelCardId); public void Dispose() diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoReceiveBinding.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoReceiveBinding.cs index 68c8c3a8ec..4bcaf6cde4 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoReceiveBinding.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoReceiveBinding.cs @@ -70,10 +70,6 @@ public async Task Receive(string modelCardId) // POC: Here we can't set receive result if ReceiveOperation throws an error. Commands.SetModelReceiveResult(modelCardId, receivedObjectIds.ToList()); } - catch (OperationCanceledException) - { - // POC: not sure here need to handle anything. UI already aware it cancelled operation visually. - } catch (Exception e) when (!e.IsFatal()) // All exceptions should be handled here if possible, otherwise we enter "crashing the host app" territory. { Commands.SetModelError(modelCardId, e); diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI.WebView/DUI3ControlWebView.xaml.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI.WebView/DUI3ControlWebView.xaml.cs index 3e72c8ff26..64306ea1d0 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI.WebView/DUI3ControlWebView.xaml.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI.WebView/DUI3ControlWebView.xaml.cs @@ -9,9 +9,9 @@ namespace Speckle.Connectors.DUI.WebView; public sealed partial class DUI3ControlWebView : UserControl { - private readonly IReadOnlyCollection _bindings; + private readonly IEnumerable> _bindings; - public DUI3ControlWebView(IReadOnlyCollection bindings) + public DUI3ControlWebView(IEnumerable> bindings) { _bindings = bindings; InitializeComponent(); @@ -32,10 +32,22 @@ private void ExecuteScriptAsyncMethod(string script) private void OnInitialized(object? sender, CoreWebView2InitializationCompletedEventArgs e) { - foreach (IBinding binding in _bindings) + if (e.IsSuccess == false) { - binding.Parent.AssociateWithBinding(binding, ExecuteScriptAsyncMethod, Browser, ShowDevToolsMethod); - Browser.CoreWebView2.AddHostObjectToScript(binding.Name, binding.Parent); + //POC: avoid silently accepting webview failures handle... } + + // We use Lazy here to delay creating the binding until after the Browser is fully initialized. + // Otherwise the Browser cannot respond to any requests to ExecuteScriptAsyncMethod + foreach (Lazy lazyBinding in _bindings) + { + SetupBinding(lazyBinding.Value); + } + } + + private void SetupBinding(IBinding binding) + { + binding.Parent.AssociateWithBinding(binding, ExecuteScriptAsyncMethod, Browser, ShowDevToolsMethod); + Browser.CoreWebView2.AddHostObjectToScript(binding.Name, binding.Parent); } } From 4d53dfc7025ea8fb99bc2f41aa082a591e6dcbeb Mon Sep 17 00:00:00 2001 From: KatKatKateryna <89912278+KatKatKateryna@users.noreply.github.com> Date: Mon, 6 May 2024 15:42:27 +0800 Subject: [PATCH 105/261] CNX-9248 ArcGIS receive conversions (#3320) * sorting and receiving feature classes * missing conversion and fixing Field writing * receive conversions restructured * basic geometries; removed failing fields; await for each conversion * split long functions; delete feature class if it is being received again; * serializer-friendly field types; support for almost all field types on Send and Receive * add loops to polygons on receive * fix multipolygon send * receiving multipatches * receive ring multipatches * create Table on receive * add table to map * remove usings * clean polygon converter * comments * set single-geom converters as ISpeckleObjectToHostConversion * move converters to folders * namespaces * cad conversions * comments * comments2 * typo * condition on 1 polyline only * renaming interfaces * opinionated: receiving unsupported field types as Raster fields * don't send unsupported fields --- .../Operations/Receive/HostObjectBuilder.cs | 22 ++- .../AutofacArcGIS3ConverterModule.cs | 2 + .../ArcGISConverterToHost.cs | 2 +- .../Features/GeometryToHostConverter.cs | 64 ++++++++ .../Features/GisFeatureToHostConverter.cs | 51 ------- .../Features/GisFeatureToSpeckleConverter.cs | 32 ++-- .../PolygonFeatureToSpeckleConverter.cs | 21 ++- .../Geometry/GeometryExtension.cs | 18 +++ .../MultipatchToHostConverter.cs | 37 +++++ .../MultipointToHostConverter.cs | 28 ++++ .../Polygon3dToHostConverter.cs | 51 +++++++ .../PolygonToHostConverter.cs | 38 +++++ .../ArcToHostConverter.cs | 65 ++++++++ .../CircleToHostConverter.cs | 49 ++++++ .../EllipseToHostConverter.cs | 51 +++++++ .../LineToHostConverter.cs | 25 +++ .../MeshToHostConverter.cs | 37 +++++ .../PointSingleToHostConverter.cs | 16 ++ .../PolycurveToHostConverter.cs | 35 +++++ .../PolylineToHostConverter.cs | 24 +++ .../Geometry/PointToHostConverter.cs | 14 -- .../Geometry/PolygonToHostConverter.cs | 23 --- .../Geometry/PolylineToHostConverter.cs | 63 -------- .../Layers/FeatureClassToHostConverter.cs | 108 +++++++++++++ .../Layers/PointcloudLayerToHostConverter.cs | 17 +++ .../PointcloudLayerToSpeckleConverter.cs | 11 +- .../Layers/RasterLayerToHostConverter.cs | 18 +++ .../Layers/TableToHostConverter.cs | 91 +++++++++++ .../Layers/VectorLayerToHostConverter.cs | 115 +++----------- .../Layers/VectorLayerToSpeckleConverter.cs | 22 ++- .../Utils/ArcGISFieldUtils.cs | 144 ++++++++++++++++++ .../Utils/CharacterCleaner.cs | 30 ++++ .../Utils/FeatureClassUtils.cs | 122 ++++++++------- .../Utils/IArcGISFieldUtils.cs | 13 ++ .../Utils/ICharacterCleaner.cs | 6 + .../Utils/IFeatureClassUtils.cs | 11 +- ...Speckle.Converters.AutocadShared.projitems | 2 +- 37 files changed, 1136 insertions(+), 342 deletions(-) create mode 100644 DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GeometryToHostConverter.cs delete mode 100644 DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GisFeatureToHostConverter.cs create mode 100644 DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/MultipatchToHostConverter.cs create mode 100644 DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/MultipointToHostConverter.cs create mode 100644 DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/Polygon3dToHostConverter.cs create mode 100644 DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/PolygonToHostConverter.cs create mode 100644 DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/ArcToHostConverter.cs create mode 100644 DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/CircleToHostConverter.cs create mode 100644 DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/EllipseToHostConverter.cs create mode 100644 DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/LineToHostConverter.cs create mode 100644 DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/MeshToHostConverter.cs create mode 100644 DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/PointSingleToHostConverter.cs create mode 100644 DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/PolycurveToHostConverter.cs create mode 100644 DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/PolylineToHostConverter.cs delete mode 100644 DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/PointToHostConverter.cs delete mode 100644 DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/PolygonToHostConverter.cs delete mode 100644 DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/PolylineToHostConverter.cs create mode 100644 DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/FeatureClassToHostConverter.cs create mode 100644 DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/PointcloudLayerToHostConverter.cs create mode 100644 DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/RasterLayerToHostConverter.cs create mode 100644 DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/TableToHostConverter.cs create mode 100644 DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/ArcGISFieldUtils.cs create mode 100644 DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/CharacterCleaner.cs create mode 100644 DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/IArcGISFieldUtils.cs create mode 100644 DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/ICharacterCleaner.cs diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Receive/HostObjectBuilder.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Receive/HostObjectBuilder.cs index 9e367fc751..f79cd40a2a 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Receive/HostObjectBuilder.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Receive/HostObjectBuilder.cs @@ -62,7 +62,7 @@ CancellationToken cancellationToken // BAKE OBJECTS HERE // POC: QueuedTask - QueuedTask.Run(() => + var task = QueuedTask.Run(() => { try { @@ -70,8 +70,23 @@ CancellationToken cancellationToken if (converted is string uri) { objectIds.Add(obj.id); - // TODO: get map from contextStack instead - LayerFactory.Instance.CreateLayer(new Uri($"{databasePath}\\{uri}"), MapView.Active.Map); + // POC: TODO: get map from contextStack instead + try + { + LayerFactory.Instance.CreateLayer( + new Uri($"{databasePath}\\{uri}"), + MapView.Active.Map, + layerName: ((Collection)obj).name + ); + } + catch (ArgumentException) + { + StandaloneTableFactory.Instance.CreateStandaloneTable( + new Uri($"{databasePath}\\{uri}"), + MapView.Active.Map, + tableName: ((Collection)obj).name + ); + } } } catch (ArgumentException) @@ -81,6 +96,7 @@ CancellationToken cancellationToken throw; } }); + task.Wait(cancellationToken); onOperationProgressed?.Invoke("Converting", (double)++count / objectsWithPath.Count()); } diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3.DependencyInjection/AutofacArcGIS3ConverterModule.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3.DependencyInjection/AutofacArcGIS3ConverterModule.cs index fb0c2e3d4a..0e0c7268d2 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3.DependencyInjection/AutofacArcGIS3ConverterModule.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3.DependencyInjection/AutofacArcGIS3ConverterModule.cs @@ -18,6 +18,8 @@ protected override void Load(ContainerBuilder builder) builder.RegisterType().As().InstancePerLifetimeScope(); builder.RegisterType().As().InstancePerLifetimeScope(); builder.RegisterType().As().InstancePerLifetimeScope(); + builder.RegisterType().As().InstancePerLifetimeScope(); + builder.RegisterType().As().InstancePerLifetimeScope(); builder.RegisterType().As().InstancePerLifetimeScope(); builder diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ArcGISConverterToHost.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ArcGISConverterToHost.cs index 20fe58a278..1c844363eb 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ArcGISConverterToHost.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ArcGISConverterToHost.cs @@ -1,4 +1,4 @@ -using Speckle.Autofac.DependencyInjection; +using Speckle.Autofac.DependencyInjection; using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; using Speckle.Core.Models; diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GeometryToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GeometryToHostConverter.cs new file mode 100644 index 0000000000..67b55d6b69 --- /dev/null +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GeometryToHostConverter.cs @@ -0,0 +1,64 @@ +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; +using Speckle.Core.Models; + +namespace Speckle.Converters.ArcGIS3.Features; + +public class GeometryToHostConverter : IRawConversion, ACG.Geometry> +{ + private readonly IRawConversion _polylineConverter; + private readonly IRawConversion, ACG.Multipoint> _multipointConverter; + private readonly IRawConversion, ACG.Multipatch> _polygon3dConverter; + private readonly IRawConversion, ACG.Polygon> _polygonConverter; + private readonly IRawConversion, ACG.Multipatch> _multipatchConverter; + + public GeometryToHostConverter( + IRawConversion polylineConverter, + IRawConversion, ACG.Multipoint> multipointConverter, + IRawConversion, ACG.Multipatch> polygon3dConverter, + IRawConversion, ACG.Polygon> polygonConverter, + IRawConversion, ACG.Multipatch> multipatchConverter + ) + { + _polylineConverter = polylineConverter; + _multipointConverter = multipointConverter; + _polygon3dConverter = polygon3dConverter; + _polygonConverter = polygonConverter; + _multipatchConverter = multipatchConverter; + } + + public ACG.Geometry RawConvert(IReadOnlyList target) + { + try + { + if (target.Count > 0) + { + switch (target[0]) + { + case SOG.Point point: + return _multipointConverter.RawConvert(target.Cast().ToList()); + case SOG.Polyline polyline: + if (target.Count > 1) + { + throw new SpeckleConversionException("Polyline conversion only supports one polyline at a time"); + } + return _polylineConverter.RawConvert(target.Cast().ToList()[0]); + case SGIS.GisPolygonGeometry3d geometry3d: + return _polygon3dConverter.RawConvert(target.Cast().ToList()); + case SGIS.GisPolygonGeometry geometry: + return _polygonConverter.RawConvert(target.Cast().ToList()); + case SGIS.GisMultipatchGeometry mesh: + return _multipatchConverter.RawConvert(target.Cast().ToList()); + default: + throw new NotSupportedException($"No conversion found for type {target[0]}"); + } + } + throw new NotSupportedException($"Feature contains no geometry"); + } + catch (SpeckleConversionException e) + { + Console.WriteLine(e); + throw; // log errors + } + } +} diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GisFeatureToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GisFeatureToHostConverter.cs deleted file mode 100644 index 1c79a990a8..0000000000 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GisFeatureToHostConverter.cs +++ /dev/null @@ -1,51 +0,0 @@ -using ArcGIS.Desktop.Mapping; -using Objects.GIS; -using Speckle.Converters.Common; -using Speckle.Converters.Common.Objects; -using Speckle.Core.Models; - -namespace Speckle.Converters.ArcGIS3.Features; - -public class GisFeatureToHostConverter : IRawConversion -{ - private readonly IConversionContextStack _contextStack; - private readonly IRawConversion _polylineConverter; - private readonly IRawConversion _pointConverter; - private readonly IRawConversion _polygonConverter; - - public GisFeatureToHostConverter( - IConversionContextStack contextStack, - IRawConversion polylineConverter, - IRawConversion pointConverter, - IRawConversion polygonConverter - ) - { - _contextStack = contextStack; - _polylineConverter = polylineConverter; - _pointConverter = pointConverter; - _polygonConverter = polygonConverter; - } - - public ACG.Geometry RawConvert(Base target) - { - if (target.speckle_type.ToLower().Contains("point")) - { - return _pointConverter.RawConvert((SOG.Point)target); - } - else if (target.speckle_type.ToLower().Contains("polyline")) - { - // POC: TODO - } - else if (target.speckle_type.ToLower().Contains("polygon")) - { - // POC: TODO - } - else - { - throw new SpeckleConversionException($"Unknown geometry type {target.speckle_type}"); - } - throw new SpeckleConversionException($"Conversion of geometry {target} failed"); - } - // POC: TODO: Add case for NonGeometry Feature (table entry) - // IF geometry layer, but no geometry found: throw new SpeckleConversionException($"Feature {target} contains no geometry"); -} diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GisFeatureToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GisFeatureToSpeckleConverter.cs index faeb610a67..f1883f6429 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GisFeatureToSpeckleConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GisFeatureToSpeckleConverter.cs @@ -57,22 +57,30 @@ public SGIS.GisFeature RawConvert(Row target) foreach (Field field in fields) { string name = field.Name; - if (name != "Shape") // ignore the field with geometry itself + // POC: check for all possible reserved Shape names + if (field.FieldType == FieldType.Geometry) // ignore the field with geometry itself { - try - { - object? value = target[name]; - attributes[name] = value; - } - catch (ArgumentException) - { - // TODO: log in the conversion errors list - attributes[name] = null; - } + hasGeometry = true; + } + // Raster FieldType is not properly supported through API + else if ( + field.FieldType == FieldType.Raster || field.FieldType == FieldType.Blob || field.FieldType == FieldType.XML + ) + { + attributes[name] = null; + } + // to not break serializer (DateOnly) and to simplify complex types + else if ( + field.FieldType == FieldType.DateOnly + || field.FieldType == FieldType.TimeOnly + || field.FieldType == FieldType.TimestampOffset + ) + { + attributes[name] = target[name]?.ToString(); } else { - hasGeometry = true; + attributes[name] = target[name]; } } diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/PolygonFeatureToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/PolygonFeatureToSpeckleConverter.cs index 808aa037cf..b984b2e21b 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/PolygonFeatureToSpeckleConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/PolygonFeatureToSpeckleConverter.cs @@ -1,5 +1,6 @@ using Speckle.Converters.Common.Objects; using Objects.GIS; +using Speckle.Converters.Common; namespace Speckle.Converters.ArcGIS3.Features; @@ -18,7 +19,13 @@ public IReadOnlyList RawConvert(ACG.Polygon target) List polygonList = new(); int partCount = target.PartCount; - GisPolygonGeometry polygon = new() { }; + if (partCount == 0) + { + throw new SpeckleConversionException("ArcGIS Polygon contains no parts"); + } + + GisPolygonGeometry? polygon = null; + // test each part for "exterior ring" for (int idx = 0; idx < partCount; idx++) { @@ -28,18 +35,18 @@ public IReadOnlyList RawConvert(ACG.Polygon target) bool isExteriorRing = target.IsExteriorRing(idx); if (isExteriorRing is true) { - if (polygonList.Count > 0) - { - polygonList.Add(polygon); - } polygon = new() { boundary = polyline, voids = new List() }; + polygonList.Add(polygon); } - else + else // interior part { + if (polygon == null) + { + throw new SpeckleConversionException("Invalid ArcGIS Polygon. Interior part preceeding the exterior ring."); + } polygon.voids.Add(polyline); } } - polygonList.Add(polygon); return polygonList; } diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GeometryExtension.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GeometryExtension.cs index 36673fe1ee..3696822606 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GeometryExtension.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GeometryExtension.cs @@ -31,6 +31,24 @@ public static int CIMColorToInt(this CIMColor color) | (int)Math.Round(color.Values[2]); } + public static List Values(this SOG.Arc arc) + { + List coords = + new() + { + arc.startPoint.x, + arc.startPoint.y, + arc.startPoint.z, + arc.midPoint.x, + arc.midPoint.y, + arc.midPoint.z, + arc.endPoint.x, + arc.endPoint.y, + arc.endPoint.z + }; + return coords; + } + public static bool IsClockwisePolygon(this SOG.Polyline polyline) { bool isClockwise; diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/MultipatchToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/MultipatchToHostConverter.cs new file mode 100644 index 0000000000..80942d1189 --- /dev/null +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/MultipatchToHostConverter.cs @@ -0,0 +1,37 @@ +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; + +namespace Speckle.Converters.ArcGIS3.Geometry.GisFeatureGeometriesToHost; + +public class MultipatchToHostConverter : IRawConversion, ACG.Multipatch> +{ + private readonly IRawConversion _pointConverter; + + public MultipatchToHostConverter(IRawConversion pointConverter) + { + _pointConverter = pointConverter; + } + + public ACG.Multipatch RawConvert(List target) + { + if (target.Count == 0) + { + throw new SpeckleConversionException("Feature contains no geometries"); + } + ACG.MultipatchBuilderEx multipatchPart = new(); + foreach (SGIS.GisMultipatchGeometry part in target) + { + ACG.Patch newPatch = multipatchPart.MakePatch(ACG.PatchType.Triangles); + for (int i = 0; i < part.vertices.Count / 3; i++) + { + newPatch.AddPoint( + _pointConverter.RawConvert( + new SOG.Point(part.vertices[i * 3], part.vertices[i * 3 + 1], part.vertices[i * 3 + 2]) + ) + ); + } + multipatchPart.Patches.Add(newPatch); + } + return multipatchPart.ToGeometry(); + } +} diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/MultipointToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/MultipointToHostConverter.cs new file mode 100644 index 0000000000..88dc2c41ff --- /dev/null +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/MultipointToHostConverter.cs @@ -0,0 +1,28 @@ +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; + +namespace Speckle.Converters.ArcGIS3.Geometry.GisFeatureGeometriesToHost; + +public class MultipointToHostConverter : IRawConversion, ACG.Multipoint> +{ + private readonly IRawConversion _pointConverter; + + public MultipointToHostConverter(IRawConversion pointConverter) + { + _pointConverter = pointConverter; + } + + public ACG.Multipoint RawConvert(List target) + { + if (target.Count == 0) + { + throw new SpeckleConversionException("Feature contains no geometries"); + } + List pointList = new(); + foreach (SOG.Point pt in target) + { + pointList.Add(_pointConverter.RawConvert(pt)); + } + return new ACG.MultipointBuilderEx(pointList, ACG.AttributeFlags.HasZ).ToGeometry(); + } +} diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/Polygon3dToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/Polygon3dToHostConverter.cs new file mode 100644 index 0000000000..c466b00b1f --- /dev/null +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/Polygon3dToHostConverter.cs @@ -0,0 +1,51 @@ +using Speckle.Converters.Common.Objects; +using Speckle.Converters.Common; + +namespace Speckle.Converters.ArcGIS3.Geometry.GisFeatureGeometriesToHost; + +public class Polygon3dToHostConverter : IRawConversion, ACG.Multipatch> +{ + private readonly IRawConversion _pointConverter; + private readonly IRawConversion _polylineConverter; + + public Polygon3dToHostConverter( + IRawConversion pointConverter, + IRawConversion polylineConverter + ) + { + _pointConverter = pointConverter; + _polylineConverter = polylineConverter; + } + + public ACG.Multipatch RawConvert(List target) + { + if (target.Count == 0) + { + throw new SpeckleConversionException("Feature contains no geometries"); + } + + ACG.MultipatchBuilderEx multipatchPart = new(); + foreach (SGIS.GisPolygonGeometry3d part in target) + { + ACG.Patch newPatch = multipatchPart.MakePatch(ACG.PatchType.FirstRing); + List boundaryPts = part.boundary.GetPoints(); + foreach (SOG.Point pt in boundaryPts) + { + newPatch.AddPoint(_pointConverter.RawConvert(pt)); + } + multipatchPart.Patches.Add(newPatch); + + foreach (SOG.Polyline loop in part.voids) + { + ACG.Patch newLoopPatch = multipatchPart.MakePatch(ACG.PatchType.Ring); + List loopPts = loop.GetPoints(); + foreach (SOG.Point pt in loopPts) + { + newLoopPatch.AddPoint(_pointConverter.RawConvert(pt)); + } + multipatchPart.Patches.Add(newLoopPatch); + } + } + return multipatchPart.ToGeometry(); + } +} diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/PolygonToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/PolygonToHostConverter.cs new file mode 100644 index 0000000000..0520503903 --- /dev/null +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/PolygonToHostConverter.cs @@ -0,0 +1,38 @@ +using Speckle.Converters.Common.Objects; +using Speckle.Converters.Common; + +namespace Speckle.Converters.ArcGIS3.Geometry.GisFeatureGeometriesToHost; + +public class PolygonToHostConverter : IRawConversion, ACG.Polygon> +{ + private readonly IRawConversion _polylineConverter; + + public PolygonToHostConverter(IRawConversion polylineConverter) + { + _polylineConverter = polylineConverter; + } + + public ACG.Polygon RawConvert(List target) + { + if (target.Count == 0) + { + throw new SpeckleConversionException("Feature contains no geometries"); + } + List polyList = new(); + foreach (SGIS.GisPolygonGeometry poly in target) + { + ACG.Polyline boundary = _polylineConverter.RawConvert(poly.boundary); + ACG.PolygonBuilderEx polyOuterRing = new(boundary); + + foreach (SOG.Polyline loop in poly.voids) + { + // adding inner loops: https://github.com/esri/arcgis-pro-sdk/wiki/ProSnippets-Geometry#build-a-donut-polygon + ACG.Polyline loopNative = _polylineConverter.RawConvert(loop); + polyOuterRing.AddPart(loopNative.Copy3DCoordinatesToList()); + } + ACG.Polygon polygon = polyOuterRing.ToGeometry(); + polyList.Add(polygon); + } + return new ACG.PolygonBuilderEx(polyList, ACG.AttributeFlags.HasZ).ToGeometry(); + } +} diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/ArcToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/ArcToHostConverter.cs new file mode 100644 index 0000000000..fb2e637c7c --- /dev/null +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/ArcToHostConverter.cs @@ -0,0 +1,65 @@ +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; +using Speckle.Core.Models; + +namespace Speckle.Converters.ArcGIS3.Geometry.ISpeckleObjectToHost; + +[NameAndRankValue(nameof(SOG.Arc), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +public class CurveToHostConverter : ISpeckleObjectToHostConversion, IRawConversion +{ + private readonly IRawConversion _pointConverter; + + public CurveToHostConverter(IRawConversion pointConverter) + { + _pointConverter = pointConverter; + } + + public object Convert(Base target) => RawConvert((SOG.Arc)target); + + public ACG.Polyline RawConvert(SOG.Arc target) + { + // Determine the number of vertices to create along the arc + int numVertices = Math.Max((int)target.length, 3); // Determine based on desired segment length or other criteria + List pointsOriginal = new(); + + // get correct direction + int coeff = 1; + double? angleStart = target.startAngle; + double? fullAngle = target.endAngle - target.startAngle; + double? radius = target.radius; + + if (angleStart == null || fullAngle == null || radius == null) + { + throw new SpeckleConversionException("Conversion failed: Arc doesn't have start & end angle or radius"); + } + + // define the direction + bool isCounterClockwise = !new SOG.Polyline(target.Values()).IsClockwisePolygon(); + if (!((isCounterClockwise is false || fullAngle >= 0) && (isCounterClockwise is true || fullAngle < 0))) + { + fullAngle = Math.PI * 2 - Math.Abs((double)fullAngle); + if (isCounterClockwise is false) + { + coeff = -1; + } + } + + // Calculate the vertices along the arc + for (int i = 0; i <= numVertices; i++) + { + // Calculate the point along the arc + double angle = (double)angleStart + coeff * (double)fullAngle * (i / (double)numVertices); + SOG.Point pointOnArc = + new( + target.plane.origin.x + (double)radius * Math.Cos(angle), + target.plane.origin.y + (double)radius * Math.Sin(angle), + target.plane.origin.z + ); + + pointsOriginal.Add(pointOnArc); + } + + var points = pointsOriginal.Select(x => _pointConverter.RawConvert(x)); + return new ACG.PolylineBuilderEx(points, ACG.AttributeFlags.HasZ).ToGeometry(); + } +} diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/CircleToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/CircleToHostConverter.cs new file mode 100644 index 0000000000..81ccd78f35 --- /dev/null +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/CircleToHostConverter.cs @@ -0,0 +1,49 @@ +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; +using Speckle.Core.Models; + +namespace Speckle.Converters.ArcGIS3.Geometry.ISpeckleObjectToHost; + +[NameAndRankValue(nameof(SOG.Circle), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +public class CircleToHostConverter : ISpeckleObjectToHostConversion, IRawConversion +{ + private readonly IRawConversion _pointConverter; + + public CircleToHostConverter(IRawConversion pointConverter) + { + _pointConverter = pointConverter; + } + + public object Convert(Base target) => RawConvert((SOG.Circle)target); + + public ACG.Polyline RawConvert(SOG.Circle target) + { + // Determine the number of vertices to create along the cirlce + int numVertices = Math.Min((int)target.length, 100); // Determine based on desired segment length or other criteria + List pointsOriginal = new(); + + if (target.radius == null) + { + throw new SpeckleConversionException("Conversion failed: Circle doesn't have a radius"); + } + + // Calculate the vertices along the arc + for (int i = 0; i <= numVertices; i++) + { + // Calculate the point along the arc + double angle = 2 * Math.PI * (i / (double)numVertices); + SOG.Point pointOnCircle = + new( + target.plane.origin.x + (double)target.radius * Math.Cos(angle), + target.plane.origin.y + (double)target.radius * Math.Sin(angle), + target.plane.origin.z + ); + + pointsOriginal.Add(pointOnCircle); + } + pointsOriginal.Add(pointsOriginal[0]); + + var points = pointsOriginal.Select(x => _pointConverter.RawConvert(x)); + return new ACG.PolylineBuilderEx(points, ACG.AttributeFlags.HasZ).ToGeometry(); + } +} diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/EllipseToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/EllipseToHostConverter.cs new file mode 100644 index 0000000000..403c022550 --- /dev/null +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/EllipseToHostConverter.cs @@ -0,0 +1,51 @@ +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; +using Speckle.Core.Models; + +namespace Speckle.Converters.ArcGIS3.Geometry.ISpeckleObjectToHost; + +[NameAndRankValue(nameof(SOG.Ellipse), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +public class EllipseToHostConverter : ISpeckleObjectToHostConversion, IRawConversion +{ + private readonly IRawConversion _pointConverter; + + public EllipseToHostConverter(IRawConversion pointConverter) + { + _pointConverter = pointConverter; + } + + public object Convert(Base target) => RawConvert((SOG.Ellipse)target); + + public ACG.Polyline RawConvert(SOG.Ellipse target) + { + // Determine the number of vertices to create along the Ellipse + int numVertices = Math.Max((int)target.length, 3); // Determine based on desired segment length or other criteria + List pointsOriginal = new(); + + if (target.firstRadius == null || target.secondRadius == null) + { + throw new SpeckleConversionException("Conversion failed: Ellipse doesn't have 1st and 2nd radius"); + } + double maxRadius = Math.Max((double)target.firstRadius, (double)target.secondRadius); + double minRadius = Math.Min((double)target.firstRadius, (double)target.secondRadius); + + // Calculate the vertices along the arc + for (int i = 0; i <= numVertices; i++) + { + // Calculate the point along the arc + double angle = 2 * Math.PI * (i / (double)numVertices); + SOG.Point pointOnEllipse = + new( + target.plane.origin.x + maxRadius * Math.Cos(angle), + target.plane.origin.y + minRadius * Math.Sin(angle), + target.plane.origin.z + ); + + pointsOriginal.Add(pointOnEllipse); + } + pointsOriginal.Add(pointsOriginal[0]); + + var points = pointsOriginal.Select(x => _pointConverter.RawConvert(x)); + return new ACG.PolylineBuilderEx(points, ACG.AttributeFlags.HasZ).ToGeometry(); + } +} diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/LineToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/LineToHostConverter.cs new file mode 100644 index 0000000000..761b20e0b6 --- /dev/null +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/LineToHostConverter.cs @@ -0,0 +1,25 @@ +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; +using Speckle.Core.Models; + +namespace Speckle.Converters.ArcGIS3.Geometry.ISpeckleObjectToHost; + +[NameAndRankValue(nameof(SOG.Line), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +public class LineSingleToHostConverter : ISpeckleObjectToHostConversion, IRawConversion +{ + private readonly IRawConversion _pointConverter; + + public LineSingleToHostConverter(IRawConversion pointConverter) + { + _pointConverter = pointConverter; + } + + public object Convert(Base target) => RawConvert((SOG.Line)target); + + public ACG.Polyline RawConvert(SOG.Line target) + { + List originalPoints = new() { target.start, target.end }; + IEnumerable points = originalPoints.Select(x => _pointConverter.RawConvert(x)); + return new ACG.PolylineBuilderEx(points, ACG.AttributeFlags.HasZ).ToGeometry(); + } +} diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/MeshToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/MeshToHostConverter.cs new file mode 100644 index 0000000000..698bc9721a --- /dev/null +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/MeshToHostConverter.cs @@ -0,0 +1,37 @@ +using Objects.Utils; +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; +using Speckle.Core.Models; + +namespace Speckle.Converters.ArcGIS3.Geometry.ISpeckleObjectToHost; + +[NameAndRankValue(nameof(SOG.Mesh), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +public class MeshToHostConverter : ISpeckleObjectToHostConversion, IRawConversion +{ + private readonly IRawConversion _pointConverter; + + public MeshToHostConverter(IRawConversion pointConverter) + { + _pointConverter = pointConverter; + } + + public object Convert(Base target) => RawConvert((SOG.Mesh)target); + + public ACG.Multipatch RawConvert(SOG.Mesh target) + { + target.TriangulateMesh(); + ACG.MultipatchBuilderEx multipatchPart = new(); + ACG.Patch newPatch = multipatchPart.MakePatch(ACG.PatchType.Triangles); + for (int i = 0; i < target.VerticesCount; i++) + { + newPatch.AddPoint( + _pointConverter.RawConvert( + new SOG.Point(target.vertices[i * 3], target.vertices[i * 3 + 1], target.vertices[i * 3 + 2]) + ) + ); + } + multipatchPart.Patches.Add(newPatch); + + return multipatchPart.ToGeometry(); + } +} diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/PointSingleToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/PointSingleToHostConverter.cs new file mode 100644 index 0000000000..7c6f07a60b --- /dev/null +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/PointSingleToHostConverter.cs @@ -0,0 +1,16 @@ +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; +using Speckle.Core.Models; + +namespace Speckle.Converters.ArcGIS3.Geometry.ISpeckleObjectToHost; + +[NameAndRankValue(nameof(SOG.Point), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +public class PointToHostConverter : ISpeckleObjectToHostConversion, IRawConversion +{ + public object Convert(Base target) => RawConvert((SOG.Point)target); + + public ACG.MapPoint RawConvert(SOG.Point target) + { + return new ACG.MapPointBuilderEx(target.x, target.y, target.z).ToGeometry(); + } +} diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/PolycurveToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/PolycurveToHostConverter.cs new file mode 100644 index 0000000000..402394d128 --- /dev/null +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/PolycurveToHostConverter.cs @@ -0,0 +1,35 @@ +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; +using Speckle.Core.Models; + +namespace Speckle.Converters.ArcGIS3.Geometry.ISpeckleObjectToHost; + +[NameAndRankValue(nameof(SOG.Polycurve), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +public class PolycurveToHostConverter : ISpeckleObjectToHostConversion, IRawConversion +{ + private readonly IRawConversion _pointConverter; + private readonly ISpeckleConverterToHost _toHostConverter; + + public PolycurveToHostConverter( + IRawConversion pointConverter, + ISpeckleConverterToHost toHostConverter + ) + { + _pointConverter = pointConverter; + _toHostConverter = toHostConverter; + } + + public object Convert(Base target) => RawConvert((SOG.Polycurve)target); + + public ACG.Polyline RawConvert(SOG.Polycurve target) + { + List points = new(); + foreach (var segment in target.segments) + { + ACG.Polyline converted = (ACG.Polyline)_toHostConverter.Convert((Base)segment); + points.AddRange(converted.Points); + } + + return new ACG.PolylineBuilderEx(points, ACG.AttributeFlags.HasZ).ToGeometry(); + } +} diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/PolylineToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/PolylineToHostConverter.cs new file mode 100644 index 0000000000..83edbea880 --- /dev/null +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/PolylineToHostConverter.cs @@ -0,0 +1,24 @@ +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; +using Speckle.Core.Models; + +namespace Speckle.Converters.ArcGIS3.Geometry.ISpeckleObjectToHost; + +[NameAndRankValue(nameof(SOG.Polyline), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +public class PolylineToHostConverter : ISpeckleObjectToHostConversion, IRawConversion +{ + private readonly IRawConversion _pointConverter; + + public PolylineToHostConverter(IRawConversion pointConverter) + { + _pointConverter = pointConverter; + } + + public object Convert(Base target) => RawConvert((SOG.Polyline)target); + + public ACG.Polyline RawConvert(SOG.Polyline target) + { + var points = target.GetPoints().Select(x => _pointConverter.RawConvert(x)); + return new ACG.PolylineBuilderEx(points, ACG.AttributeFlags.HasZ).ToGeometry(); + } +} diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/PointToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/PointToHostConverter.cs deleted file mode 100644 index 90c37090d4..0000000000 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/PointToHostConverter.cs +++ /dev/null @@ -1,14 +0,0 @@ -using Speckle.Converters.Common.Objects; -using Speckle.Converters.Common; - -namespace Speckle.Converters.ArcGIS3.Geometry; - -[NameAndRankValue(nameof(ACG.MapPoint), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class PointToHostConverter : IRawConversion -{ - public ACG.Multipoint RawConvert(SOG.Point target) - { - ACG.MapPoint mapPoint = new ACG.MapPointBuilderEx(target.x, target.y, target.z).ToGeometry(); - return new ACG.MultipointBuilderEx(mapPoint).ToGeometry(); - } -} diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/PolygonToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/PolygonToHostConverter.cs deleted file mode 100644 index 1aacac96ca..0000000000 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/PolygonToHostConverter.cs +++ /dev/null @@ -1,23 +0,0 @@ -using Speckle.Converters.Common.Objects; -using Speckle.Converters.Common; -using Objects.GIS; - -namespace Speckle.Converters.ArcGIS3.Geometry; - -[NameAndRankValue(nameof(GisPolygonGeometry), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class PolygonToHostConverter : IRawConversion -{ - public ACG.Polygon RawConvert(GisPolygonGeometry target) - { - // POC: TODO: To replace with actual geometry - List newCoordinates = - new() - { - new ACG.Coordinate2D(1021570, 1880583), - new ACG.Coordinate2D(1028730, 1880994), - new ACG.Coordinate2D(1029718, 1875644), - new ACG.Coordinate2D(1021405, 1875397) - }; - return new ACG.PolygonBuilderEx(newCoordinates).ToGeometry(); - } -} diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/PolylineToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/PolylineToHostConverter.cs deleted file mode 100644 index 9bbc899c19..0000000000 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/PolylineToHostConverter.cs +++ /dev/null @@ -1,63 +0,0 @@ -using ArcGIS.Core.Internal.Geometry; -using ArcGIS.Desktop.Mapping; -using Speckle.Converters.Common; -using Speckle.Converters.Common.Objects; -using Speckle.Core.Kits; -using Speckle.Core.Models; - -namespace Speckle.Converters.ArcGIS3.Geometry; - -[NameAndRankValue(nameof(SOG.Polyline), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class PolylineToHostConverter : ISpeckleObjectToHostConversion, IRawConversion -{ - private readonly IConversionContextStack _contextStack; - - public PolylineToHostConverter(IConversionContextStack contextStack) - { - _contextStack = contextStack; - } - - public object Convert(Base target) => RawConvert((SOG.Polyline)target); - - public ACG.Polyline RawConvert(SOG.Polyline target) - { - // TODO: leave the units as received and assign received CRS at layer level as well - double f = Units.GetConversionFactor(target.units, _contextStack.Current.SpeckleUnits); - List coordinates = target.value; - - // POC: retrieve here exact wkt. Not hard coded! - string wkt = - "PROJCS[\"WGS_1984_Web_Mercator_Auxiliary_Sphere\",GEOGCS[\"GCS_WGS_1984\",DATUM[\"D_WGS_1984\",SPHEROID[\"WGS_1984\",6378137.0,298.257223563]],PRIMEM[\"Greenwich\",0.0],UNIT[\"Degree\",0.0174532925199433]],PROJECTION[\"Mercator_Auxiliary_Sphere\"],PARAMETER[\"False_Easting\",0.0],PARAMETER[\"False_Northing\",0.0],PARAMETER[\"Central_Meridian\",0.0],PARAMETER[\"Standard_Parallel_1\",0.0],PARAMETER[\"Auxiliary_Sphere_Type\",0.0],UNIT[\"Meter\",1.0]]\n"; - - ACG.SpatialReference spatialReference = ACG.SpatialReferenceBuilder.CreateSpatialReference(wkt); - - var points = coordinates - .Select((value, index) => new { value, index }) - .GroupBy(x => x.index / 3) - .Select( - group => - MapPointBuilder.CreateMapPoint( - group.ElementAt(0).value * f, // X - group.ElementAt(1).value * f, // Y - group.ElementAt(2).value * f, // Z - spatialReference - ) - ) - .ToList(); - - PolylineBuilder polylineBuilder = new(points.First().SpatialReference); - - var startPoint = points.First(); - for (int i = 1; i < points.Count; i++) - { - var lineSegment = LineBuilder.CreateLineSegment(startPoint, points[i]); - polylineBuilder.AddSegment(lineSegment); - startPoint = points[i]; - } - - ACG.Polyline polyline = polylineBuilder.ToGeometry(); - - polylineBuilder.Dispose(); - return polyline; - } -} diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/FeatureClassToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/FeatureClassToHostConverter.cs new file mode 100644 index 0000000000..2ec3f8ee05 --- /dev/null +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/FeatureClassToHostConverter.cs @@ -0,0 +1,108 @@ +using ArcGIS.Core.Data; +using ArcGIS.Core.Data.DDL; +using ArcGIS.Core.Data.Exceptions; +using ArcGIS.Core.Geometry; +using Objects.GIS; +using Speckle.Converters.ArcGIS3.Utils; +using Speckle.Converters.Common.Objects; +using Speckle.Core.Models; +using FieldDescription = ArcGIS.Core.Data.DDL.FieldDescription; + +namespace Speckle.Converters.ArcGIS3.Layers; + +public class FeatureClassToHostConverter : IRawConversion +{ + private readonly IRawConversion, ACG.Geometry> _gisGeometryConverter; + private readonly IFeatureClassUtils _featureClassUtils; + private readonly IArcGISFieldUtils _fieldsUtils; + private readonly IArcGISProjectUtils _arcGISProjectUtils; + + public FeatureClassToHostConverter( + IRawConversion, ACG.Geometry> gisGeometryConverter, + IFeatureClassUtils featureClassUtils, + IArcGISFieldUtils fieldsUtils, + IArcGISProjectUtils arcGISProjectUtils + ) + { + _gisGeometryConverter = gisGeometryConverter; + _featureClassUtils = featureClassUtils; + _fieldsUtils = fieldsUtils; + _arcGISProjectUtils = arcGISProjectUtils; + } + + public FeatureClass RawConvert(VectorLayer target) + { + GeometryType geomType = _featureClassUtils.GetLayerGeometryType(target); + + string databasePath = _arcGISProjectUtils.GetDatabasePath(); + FileGeodatabaseConnectionPath fileGeodatabaseConnectionPath = new(new Uri(databasePath)); + Geodatabase geodatabase = new(fileGeodatabaseConnectionPath); + SchemaBuilder schemaBuilder = new(geodatabase); + + // create Spatial Reference (i.e. Coordinate Reference System - CRS) + string wktString = string.Empty; + if (target.crs is not null && target.crs.wkt is not null) + { + wktString = target.crs.wkt.ToString(); + } + SpatialReference spatialRef = SpatialReferenceBuilder.CreateSpatialReference(wktString); + + // create Fields + List fields = _fieldsUtils.GetFieldsFromSpeckleLayer(target); + + // getting rid of forbidden symbols in the class name: adding a letter in the beginning + // https://pro.arcgis.com/en/pro-app/3.1/tool-reference/tool-errors-and-warnings/001001-010000/tool-errors-and-warnings-00001-00025-000020.htm + string featureClassName = "speckleID_" + target.id; + + // delete FeatureClass if already exists + foreach (FeatureClassDefinition fClassDefinition in geodatabase.GetDefinitions()) + { + // will cause GeodatabaseCatalogDatasetException if doesn't exist in the database + if (fClassDefinition.GetName() == featureClassName) + { + FeatureClassDescription existingDescription = new(fClassDefinition); + schemaBuilder.Delete(existingDescription); + schemaBuilder.Build(); + } + } + + // Create FeatureClass + try + { + // POC: make sure class has a valid crs + ShapeDescription shpDescription = new(geomType, spatialRef) { HasZ = true }; + FeatureClassDescription featureClassDescription = new(featureClassName, fields, shpDescription); + FeatureClassToken featureClassToken = schemaBuilder.Create(featureClassDescription); + } + catch (ArgumentException) + { + // POC: review the exception + // if name has invalid characters/combinations + throw; + } + bool buildStatus = schemaBuilder.Build(); + if (!buildStatus) + { + // POC: log somewhere the error in building the feature class + IReadOnlyList errors = schemaBuilder.ErrorMessages; + } + + try + { + FeatureClass newFeatureClass = geodatabase.OpenDataset(featureClassName); + // Add features to the FeatureClass + List gisFeatures = target.elements.Select(x => (GisFeature)x).ToList(); + geodatabase.ApplyEdits(() => + { + _featureClassUtils.AddFeaturesToFeatureClass(newFeatureClass, gisFeatures, fields, _gisGeometryConverter); + }); + + return newFeatureClass; + } + catch (GeodatabaseException) + { + // POC: review the exception + throw; + } + } +} diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/PointcloudLayerToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/PointcloudLayerToHostConverter.cs new file mode 100644 index 0000000000..28a8bdaa6f --- /dev/null +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/PointcloudLayerToHostConverter.cs @@ -0,0 +1,17 @@ +using ArcGIS.Desktop.Mapping; +using Objects.GIS; +using Speckle.Converters.Common.Objects; +using Speckle.Core.Models; + +namespace Speckle.Converters.ArcGIS3.Layers; + +public class PointcloudLayerToHostConverter : IRawConversion +{ + public object Convert(Base target) => RawConvert((VectorLayer)target); + + public LasDatasetLayer RawConvert(VectorLayer target) + { + // POC: + throw new NotImplementedException($"Receiving Pointclouds is not supported"); + } +} diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/PointcloudLayerToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/PointcloudLayerToSpeckleConverter.cs index 6cb1ee7899..b9019e5800 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/PointcloudLayerToSpeckleConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/PointcloudLayerToSpeckleConverter.cs @@ -1,5 +1,4 @@ using Speckle.Converters.Common.Objects; -using Speckle.Core.Models; using Speckle.Converters.Common; using ArcGIS.Desktop.Mapping; using ArcGIS.Core.Data.Analyst3D; @@ -8,10 +7,7 @@ namespace Speckle.Converters.ArcGIS3.Layers; -[NameAndRankValue(nameof(LasDatasetLayer), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class PointCloudToSpeckleConverter - : IHostObjectToSpeckleConversion, - IRawConversion +public class PointCloudToSpeckleConverter : IRawConversion { private readonly IRawConversion _pointConverter; private readonly IRawConversion _boxConverter; @@ -28,11 +24,6 @@ public PointCloudToSpeckleConverter( _contextStack = contextStack; } - public Base Convert(object target) - { - return RawConvert((LasDatasetLayer)target); - } - private int GetPointColor(LasPoint pt, object renderer) { // get color diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/RasterLayerToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/RasterLayerToHostConverter.cs new file mode 100644 index 0000000000..9e57a0515f --- /dev/null +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/RasterLayerToHostConverter.cs @@ -0,0 +1,18 @@ +using Objects.GIS; +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; +using Speckle.Core.Models; + +namespace Speckle.Converters.ArcGIS3.Layers; + +[NameAndRankValue(nameof(RasterLayer), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +public class RasterLayerToHostConverter : ISpeckleObjectToHostConversion, IRawConversion +{ + public object Convert(Base target) => RawConvert((RasterLayer)target); + + public string RawConvert(RasterLayer target) + { + // POC: + throw new NotImplementedException($"Receiving Rasters is not supported"); + } +} diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/TableToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/TableToHostConverter.cs new file mode 100644 index 0000000000..2b11816d2f --- /dev/null +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/TableToHostConverter.cs @@ -0,0 +1,91 @@ +using ArcGIS.Core.Data.DDL; +using ArcGIS.Core.Data.Exceptions; +using ArcGIS.Core.Data; +using Objects.GIS; +using Speckle.Converters.ArcGIS3.Utils; +using Speckle.Converters.Common.Objects; +using FieldDescription = ArcGIS.Core.Data.DDL.FieldDescription; + +namespace Speckle.Converters.ArcGIS3.Layers; + +public class TableLayerToHostConverter : IRawConversion +{ + private readonly IFeatureClassUtils _featureClassUtils; + private readonly IArcGISFieldUtils _fieldsUtils; + private readonly IArcGISProjectUtils _arcGISProjectUtils; + + public TableLayerToHostConverter( + IFeatureClassUtils featureClassUtils, + IArcGISProjectUtils arcGISProjectUtils, + IArcGISFieldUtils fieldsUtils + ) + { + _featureClassUtils = featureClassUtils; + _arcGISProjectUtils = arcGISProjectUtils; + _fieldsUtils = fieldsUtils; + } + + public Table RawConvert(VectorLayer target) + { + string databasePath = _arcGISProjectUtils.GetDatabasePath(); + FileGeodatabaseConnectionPath fileGeodatabaseConnectionPath = new(new Uri(databasePath)); + Geodatabase geodatabase = new(fileGeodatabaseConnectionPath); + SchemaBuilder schemaBuilder = new(geodatabase); + + // create Fields + List fields = _fieldsUtils.GetFieldsFromSpeckleLayer(target); + + // getting rid of forbidden symbols in the class name: adding a letter in the beginning + // https://pro.arcgis.com/en/pro-app/3.1/tool-reference/tool-errors-and-warnings/001001-010000/tool-errors-and-warnings-00001-00025-000020.htm + string featureClassName = "speckleID_" + target.id; + + // delete FeatureClass if already exists + foreach (TableDefinition fClassDefinition in geodatabase.GetDefinitions()) + { + // will cause GeodatabaseCatalogDatasetException if doesn't exist in the database + if (fClassDefinition.GetName() == featureClassName) + { + TableDescription existingDescription = new(fClassDefinition); + schemaBuilder.Delete(existingDescription); + schemaBuilder.Build(); + } + } + + // Create Table + try + { + TableDescription featureClassDescription = new(featureClassName, fields); + TableToken featureClassToken = schemaBuilder.Create(featureClassDescription); + } + catch (ArgumentException) + { + // POC: review the exception + // if name has invalid characters/combinations + throw; + } + bool buildStatus = schemaBuilder.Build(); + if (!buildStatus) + { + // POC: log somewhere the error in building the feature class + IReadOnlyList errors = schemaBuilder.ErrorMessages; + } + + try + { + Table newFeatureClass = geodatabase.OpenDataset(featureClassName); + // Add features to the FeatureClass + List gisFeatures = target.elements.Select(x => (GisFeature)x).ToList(); + geodatabase.ApplyEdits(() => + { + _featureClassUtils.AddFeaturesToTable(newFeatureClass, gisFeatures, fields); + }); + + return newFeatureClass; + } + catch (GeodatabaseException) + { + // POC: review the exception + throw; + } + } +} diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/VectorLayerToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/VectorLayerToHostConverter.cs index 05dd3033a4..3d657310f4 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/VectorLayerToHostConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/VectorLayerToHostConverter.cs @@ -1,123 +1,58 @@ using ArcGIS.Core.Data; -using ArcGIS.Core.Data.DDL; -using ArcGIS.Core.Data.Exceptions; using ArcGIS.Core.Geometry; -using ArcGIS.Desktop.Framework.Threading.Tasks; using ArcGIS.Desktop.Mapping; using Objects.GIS; using Speckle.Converters.ArcGIS3.Utils; using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; using Speckle.Core.Models; -using FieldDescription = ArcGIS.Core.Data.DDL.FieldDescription; namespace Speckle.Converters.ArcGIS3.Layers; [NameAndRankValue(nameof(VectorLayer), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] public class VectorLayerToHostConverter : ISpeckleObjectToHostConversion, IRawConversion { - private readonly IConversionContextStack _contextStack; - private readonly IRawConversion _gisGeometryConverter; + private readonly IRawConversion _featureClassConverter; + private readonly IRawConversion _tableConverter; + private readonly IRawConversion _pointcloudLayerConverter; private readonly IFeatureClassUtils _featureClassUtils; - private readonly IArcGISProjectUtils _arcGISProjectUtils; public VectorLayerToHostConverter( - IConversionContextStack contextStack, - IRawConversion gisGeometryConverter, - IFeatureClassUtils featureClassUtils, - IArcGISProjectUtils arcGISProjectUtils + IRawConversion featureClassConverter, + IRawConversion tableConverter, + IRawConversion pointcloudLayerConverter, + IFeatureClassUtils featureClassUtils ) { - _contextStack = contextStack; - _gisGeometryConverter = gisGeometryConverter; + _featureClassConverter = featureClassConverter; + _tableConverter = tableConverter; + _pointcloudLayerConverter = pointcloudLayerConverter; _featureClassUtils = featureClassUtils; - _arcGISProjectUtils = arcGISProjectUtils; } public object Convert(Base target) => RawConvert((VectorLayer)target); - private const string FID_FIELD_NAME = "OBJECTID"; - public string RawConvert(VectorLayer target) { - try + // pointcloud layers need to be checked separately, because there is no ArcGIS Geometry type + // for Pointcloud. In ArcGIS it's a completely different layer class, so "GetLayerGeometryType" + // will return "Invalid" type + if (target.geomType == "Pointcloud") { - // POC: define the best place to start QueuedTask (entire receive or per converter) - return QueuedTask - .Run(() => - { - string databasePath = _arcGISProjectUtils.GetDatabasePath(); - FileGeodatabaseConnectionPath fileGeodatabaseConnectionPath = new(new Uri(databasePath)); - Geodatabase geodatabase = new(fileGeodatabaseConnectionPath); - SchemaBuilder schemaBuilder = new(geodatabase); - - // getting rid of forbidden symbols in the class name: - // https://pro.arcgis.com/en/pro-app/3.1/tool-reference/tool-errors-and-warnings/001001-010000/tool-errors-and-warnings-00001-00025-000020.htm - string featureClassName = target.id; - // $"{target.id}___{target.name.Replace(" ", "_").Replace("%", "_").Replace("*", "_")}"; - - string wktString = string.Empty; - if (target.crs is not null && target.crs.wkt is not null) - { - wktString = target.crs.wkt.ToString(); - } - SpatialReference spatialRef = SpatialReferenceBuilder.CreateSpatialReference(wktString); - - GeometryType geomType = _featureClassUtils.GetLayerGeometryType(target); - - // Create FeatureClass - List fields = new(); - List fieldAdded = new(); - foreach (var field in target.attributes.GetMembers(DynamicBaseMemberType.Dynamic)) - { - if (!fieldAdded.Contains(field.Key) && field.Key != FID_FIELD_NAME) - { - // POC: TODO: choose the right type for Field - // TODO check for the forbidden characters/combinations: https://support.esri.com/en-us/knowledge-base/what-characters-should-not-be-used-in-arcgis-for-field--000005588 - - // POC: assemble constants in a shared place - // fields.Add(new FieldDescription(field, FieldType.Integer)); - fields.Add(FieldDescription.CreateStringField(field.Key, 255)); // (int)(long)target.attributes[field.Value])); - fieldAdded.Add(field.Key); - } - } - try - { - FeatureClassDescription featureClassDescription = - new(featureClassName, fields, new ShapeDescription(geomType, spatialRef)); - FeatureClassToken featureClassToken = schemaBuilder.Create(featureClassDescription); - } - catch (ArgumentException ex) - { - // if name has invalid characters/combinations - throw new ArgumentException($"{ex.Message}: {featureClassName}"); - } - - bool buildStatus = schemaBuilder.Build(); - if (!buildStatus) - { - // POC: log somewhere the error in building the feature class - IReadOnlyList errors = schemaBuilder.ErrorMessages; - } + return _pointcloudLayerConverter.RawConvert(target).Name; + } - // Add features to the FeatureClass - FeatureClass newFeatureClass = geodatabase.OpenDataset(featureClassName); - // TODO: repeat for other geometry types - if (geomType == GeometryType.Multipoint) - { - geodatabase.ApplyEdits(() => - { - _featureClassUtils.AddFeaturesToFeatureClass(newFeatureClass, target, fieldAdded, _gisGeometryConverter); - }); - } - return featureClassName; - }) - .Result; + // check if Speckle VectorLayer should become a FeatureClass, StandaloneTable or PointcloudLayer + GeometryType geomType = _featureClassUtils.GetLayerGeometryType(target); + if (geomType != GeometryType.Unknown) // feature class + { + return _featureClassConverter.RawConvert(target).GetName(); } - catch (GeodatabaseException exObj) + else // table { - // POC: review the exception - throw new InvalidOperationException($"Something went wrong: {exObj.Message}"); + return _tableConverter.RawConvert(target).GetName(); } + + throw new SpeckleConversionException($"Unknown geometry type for layer {target.name}"); } } diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/VectorLayerToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/VectorLayerToSpeckleConverter.cs index 716c0dd04f..26ad7e867e 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/VectorLayerToSpeckleConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/VectorLayerToSpeckleConverter.cs @@ -5,6 +5,7 @@ using ArcGIS.Desktop.Mapping; using ArcGIS.Core.Data; using ArcGIS.Core.Geometry; +using Speckle.Converters.ArcGIS3.Utils; namespace Speckle.Converters.ArcGIS3.Layers; @@ -12,14 +13,20 @@ namespace Speckle.Converters.ArcGIS3.Layers; public class VectorLayerToSpeckleConverter : IHostObjectToSpeckleConversion, IRawConversion { private readonly IRawConversion _gisFeatureConverter; + private readonly IFeatureClassUtils _featureClassUtils; + private readonly IArcGISFieldUtils _fieldsUtils; private readonly IConversionContextStack _contextStack; public VectorLayerToSpeckleConverter( IRawConversion gisFeatureConverter, + IFeatureClassUtils featureClassUtils, + IArcGISFieldUtils fieldsUtils, IConversionContextStack contextStack ) { _gisFeatureConverter = gisFeatureConverter; + _featureClassUtils = featureClassUtils; + _fieldsUtils = fieldsUtils; _contextStack = contextStack; } @@ -70,16 +77,23 @@ public VectorLayer RawConvert(FeatureLayer target) // get feature class fields var allLayerAttributes = new Base(); var dispayTable = target as IDisplayTable; - IReadOnlyList fieldDescriptions = dispayTable.GetFieldDescriptions(); - foreach (FieldDescription field in fieldDescriptions) + IReadOnlyList allFieldDescriptions = dispayTable.GetFieldDescriptions(); + List addedFieldDescriptions = new(); + foreach (FieldDescription field in allFieldDescriptions) { if (field.IsVisible) { string name = field.Name; - if (name == "Shape") + if ( + field.Type == FieldType.Geometry + || field.Type == FieldType.Raster + || field.Type == FieldType.XML + || field.Type == FieldType.Blob + ) { continue; } + addedFieldDescriptions.Add(field); allLayerAttributes[name] = (int)field.Type; } } @@ -105,7 +119,7 @@ public VectorLayer RawConvert(FeatureLayer target) // replace element "attributes", to remove those non-visible on Layer level Base elementAttributes = new(); - foreach (FieldDescription field in fieldDescriptions) + foreach (FieldDescription field in addedFieldDescriptions) { if (field.IsVisible) { diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/ArcGISFieldUtils.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/ArcGISFieldUtils.cs new file mode 100644 index 0000000000..36b2f6ca31 --- /dev/null +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/ArcGISFieldUtils.cs @@ -0,0 +1,144 @@ +using ArcGIS.Core.Data; +using ArcGIS.Core.Data.Exceptions; +using Objects.GIS; +using Speckle.Core.Models; +using FieldDescription = ArcGIS.Core.Data.DDL.FieldDescription; + +namespace Speckle.Converters.ArcGIS3.Utils; + +public class ArcGISFieldUtils : IArcGISFieldUtils +{ + private readonly ICharacterCleaner _characterCleaner; + private const string FID_FIELD_NAME = "OBJECTID"; + + public ArcGISFieldUtils(ICharacterCleaner characterCleaner) + { + _characterCleaner = characterCleaner; + } + + public object? FieldValueToNativeType(FieldType fieldType, object? value) + { + // Geometry: ignored + // Blob, Raster, TimestampOffset, XML: converted to String (field type already converted to String on Send) + switch (fieldType) + { + case FieldType.GUID: + return value; + case FieldType.OID: + return value; + } + + if (value is not null) + { + try + { + switch (fieldType) + { + case FieldType.String: + return (string)value; + case FieldType.Single: + return (float)(double)value; + case FieldType.Integer: + // need this step because sent "ints" seem to be received as "longs" + return (int)(long)value; + case FieldType.BigInteger: + return (long)value; + case FieldType.SmallInteger: + return (short)(long)value; + case FieldType.Double: + return (double)value; + case FieldType.Date: + return DateTime.Parse((string)value); + case FieldType.DateOnly: + return DateOnly.Parse((string)value); + case FieldType.TimeOnly: + return TimeOnly.Parse((string)value); + } + } + catch (InvalidCastException) + { + return value; + } + } + + return value; + } + + public RowBuffer AssignFieldValuesToRow(RowBuffer rowBuffer, List fields, GisFeature feat) + { + foreach (FieldDescription field in fields) + { + // try to assign values to writeable fields + if (feat.attributes is not null) + { + string key = field.AliasName; // use Alias, as Name is simplified to alphanumeric + FieldType fieldType = field.FieldType; + var value = feat.attributes[key]; + if (value is not null) + { + // POC: get all values in a correct format + try + { + rowBuffer[key] = FieldValueToNativeType(fieldType, value); + } + catch (GeodatabaseFeatureException) + { + //'The value type is incompatible.' + // log error! + rowBuffer[key] = null; + } + catch (GeodatabaseFieldException) + { + // non-editable Field, do nothing + } + } + else + { + rowBuffer[key] = null; + } + } + } + return rowBuffer; + } + + public FieldType GetFieldTypeFromInt(int fieldType) + { + return (FieldType)fieldType; + } + + public List GetFieldsFromSpeckleLayer(VectorLayer target) + { + List fields = new(); + List fieldAdded = new(); + + foreach (var field in target.attributes.GetMembers(DynamicBaseMemberType.Dynamic)) + { + if (!fieldAdded.Contains(field.Key) && field.Key != FID_FIELD_NAME) + { + // POC: TODO check for the forbidden characters/combinations: https://support.esri.com/en-us/knowledge-base/what-characters-should-not-be-used-in-arcgis-for-field--000005588 + try + { + if (field.Value is not null) + { + string key = field.Key; + FieldType fieldType = GetFieldTypeFromInt((int)(long)field.Value); + + FieldDescription fieldDescription = + new(_characterCleaner.CleanCharacters(key), fieldType) { AliasName = key }; + fields.Add(fieldDescription); + fieldAdded.Add(key); + } + else + { + // log missing field + } + } + catch (GeodatabaseFieldException) + { + // log missing field + } + } + } + return fields; + } +} diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/CharacterCleaner.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/CharacterCleaner.cs new file mode 100644 index 0000000000..e49709e89d --- /dev/null +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/CharacterCleaner.cs @@ -0,0 +1,30 @@ +using System.Text.RegularExpressions; + +namespace Speckle.Converters.ArcGIS3.Utils; + +public class CharacterCleaner : ICharacterCleaner +{ + public string CleanCharacters(string key) + { + Regex rg = new(@"^[a-zA-Z0-9_]*$"); + if (rg.IsMatch(key)) + { + return key; + } + + string result = ""; + foreach (char c in key) + { + Regex rg_character = new(@"^[a-zA-Z0-9_]*$"); + if (rg_character.IsMatch(c.ToString())) + { + result += c.ToString(); + } + else + { + result += "_"; + } + } + return key.Replace(" ", "_").Replace("%", "_").Replace("$", "_"); + } +} diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/FeatureClassUtils.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/FeatureClassUtils.cs index c2ef80e124..aed54e7773 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/FeatureClassUtils.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/FeatureClassUtils.cs @@ -1,94 +1,100 @@ using ArcGIS.Core.Data; -using ArcGIS.Core.Data.Exceptions; using Objects.GIS; using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; using Speckle.Core.Models; +using FieldDescription = ArcGIS.Core.Data.DDL.FieldDescription; namespace Speckle.Converters.ArcGIS3.Utils; public class FeatureClassUtils : IFeatureClassUtils { + private readonly IArcGISFieldUtils _fieldsUtils; + + public FeatureClassUtils(IArcGISFieldUtils fieldsUtils) + { + _fieldsUtils = fieldsUtils; + } + + public void AddFeaturesToTable(Table newFeatureClass, List gisFeatures, List fields) + { + foreach (GisFeature feat in gisFeatures) + { + using (RowBuffer rowBuffer = newFeatureClass.CreateRowBuffer()) + { + newFeatureClass.CreateRow(_fieldsUtils.AssignFieldValuesToRow(rowBuffer, fields, feat)).Dispose(); + } + } + } + public void AddFeaturesToFeatureClass( FeatureClass newFeatureClass, - VectorLayer target, - List fieldAdded, - IRawConversion gisGeometryConverter + List gisFeatures, + List fields, + IRawConversion, ACG.Geometry> gisGeometryConverter ) { - newFeatureClass.DeleteRows(new QueryFilter()); - foreach (GisFeature feat in target.elements.Cast()) + foreach (GisFeature feat in gisFeatures) { using (RowBuffer rowBuffer = newFeatureClass.CreateRowBuffer()) { - foreach (string field in fieldAdded) + if (feat.geometry != null) { - // try to assign values to writeable fields - try - { - if (feat.attributes is not null) - { - var value = feat.attributes[field]; - if (value is not null) - { - rowBuffer[field] = value.ToString(); - } - else - { - rowBuffer[field] = null; - } - } - } - catch (GeodatabaseFieldException) - { - // non-editable Field, do nothing - } + List geometryToConvert = feat.geometry; + ACG.Geometry nativeShape = gisGeometryConverter.RawConvert(geometryToConvert); + rowBuffer[newFeatureClass.GetDefinition().GetShapeField()] = nativeShape; } - - if (feat.geometry != null) + else { - foreach (var geometryPart in feat.geometry) - { - // POC: TODO: repeat for all geometries, add as Multipart - ACG.Geometry nativeShape = gisGeometryConverter.RawConvert(geometryPart); - rowBuffer[newFeatureClass.GetDefinition().GetShapeField()] = nativeShape; - break; - } + throw new SpeckleConversionException("No geomerty to write"); } - // POC: TODO add option for non-geometry features - newFeatureClass.CreateRow(rowBuffer).Dispose(); + + // get attributes + newFeatureClass.CreateRow(_fieldsUtils.AssignFieldValuesToRow(rowBuffer, fields, feat)).Dispose(); } } } public ACG.GeometryType GetLayerGeometryType(VectorLayer target) { - ACG.GeometryType geomType = new(); - if (target.nativeGeomType == null) + string? originalGeomType = target.geomType != null ? target.geomType : target.nativeGeomType; + ACG.GeometryType geomType; + + if (string.IsNullOrEmpty(originalGeomType)) { throw new SpeckleConversionException($"Unknown geometry type for layer {target.name}"); } + + // POC: find better pattern + if (originalGeomType.ToLower().Contains("none")) + { + geomType = ACG.GeometryType.Unknown; + } + else if (originalGeomType.ToLower().Contains("pointcloud")) + { + geomType = ACG.GeometryType.Unknown; + } + else if (originalGeomType.ToLower().Contains("point")) + { + geomType = ACG.GeometryType.Multipoint; + } + else if (originalGeomType.ToLower().Contains("polyline")) + { + geomType = ACG.GeometryType.Polyline; + } + else if (originalGeomType.ToLower().Contains("polygon")) + { + geomType = ACG.GeometryType.Polygon; + } + else if (originalGeomType.ToLower().Contains("multipatch")) + { + geomType = ACG.GeometryType.Multipatch; + } else { - // POC: find better pattern - if (target.nativeGeomType.ToLower().Contains("point")) - { - geomType = ACG.GeometryType.Multipoint; - } - else if (target.nativeGeomType.ToLower().Contains("polyline")) - { - geomType = ACG.GeometryType.Polyline; - } - else if (target.nativeGeomType.ToLower().Contains("polygon")) - { - geomType = ACG.GeometryType.Polygon; - } - else if (target.nativeGeomType.ToLower().Contains("multipatch")) - { - geomType = ACG.GeometryType.Multipatch; - } - // throw + throw new SpeckleConversionException($"Unknown geometry type for layer {target.name}"); } + return geomType; } } diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/IArcGISFieldUtils.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/IArcGISFieldUtils.cs new file mode 100644 index 0000000000..a60a980273 --- /dev/null +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/IArcGISFieldUtils.cs @@ -0,0 +1,13 @@ +using ArcGIS.Core.Data; +using Objects.GIS; +using FieldDescription = ArcGIS.Core.Data.DDL.FieldDescription; + +namespace Speckle.Converters.ArcGIS3.Utils; + +public interface IArcGISFieldUtils +{ + public RowBuffer AssignFieldValuesToRow(RowBuffer rowBuffer, List fields, GisFeature feat); + public object? FieldValueToNativeType(FieldType fieldType, object? value); + public List GetFieldsFromSpeckleLayer(VectorLayer target); + public FieldType GetFieldTypeFromInt(int fieldType); +} diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/ICharacterCleaner.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/ICharacterCleaner.cs new file mode 100644 index 0000000000..aa4c879bed --- /dev/null +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/ICharacterCleaner.cs @@ -0,0 +1,6 @@ +namespace Speckle.Converters.ArcGIS3.Utils; + +public interface ICharacterCleaner +{ + public string CleanCharacters(string key); +} diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/IFeatureClassUtils.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/IFeatureClassUtils.cs index 8e252d60ad..db8522fe1a 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/IFeatureClassUtils.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/IFeatureClassUtils.cs @@ -2,6 +2,7 @@ using Objects.GIS; using Speckle.Converters.Common.Objects; using Speckle.Core.Models; +using FieldDescription = ArcGIS.Core.Data.DDL.FieldDescription; namespace Speckle.Converters.ArcGIS3.Utils; @@ -9,10 +10,10 @@ public interface IFeatureClassUtils { void AddFeaturesToFeatureClass( FeatureClass newFeatureClass, - VectorLayer target, - List fieldAdded, - IRawConversion gisGeometryConverter + List gisFeatures, + List fields, + IRawConversion, ACG.Geometry> gisGeometryConverter ); - - ACG.GeometryType GetLayerGeometryType(VectorLayer target); + void AddFeaturesToTable(Table newFeatureClass, List gisFeatures, List fields); + public ACG.GeometryType GetLayerGeometryType(VectorLayer target); } diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/Speckle.Converters.AutocadShared.projitems b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/Speckle.Converters.AutocadShared.projitems index 355891e941..100e5186db 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/Speckle.Converters.AutocadShared.projitems +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/Speckle.Converters.AutocadShared.projitems @@ -56,4 +56,4 @@ - + \ No newline at end of file From 61389ad6c11613f4c65c59ccfe307e03e78107da Mon Sep 17 00:00:00 2001 From: Jedd Morgan <45512892+JR-Morgan@users.noreply.github.com> Date: Mon, 6 May 2024 11:07:43 +0100 Subject: [PATCH 106/261] Fix issue with leaving rhino in an undrawing state if an exception (including cancellation) occurs during conversion (#3355) * removed cancellation swallowing * Fix issue with leaving rhino in nondrawing state --- .../Operations/Receive/DisableRedrawScope.cs | 26 +++++++++++++++++++ .../Receive/RhinoHostObjectBuilder.cs | 15 +++++------ 2 files changed, 33 insertions(+), 8 deletions(-) create mode 100644 DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Receive/DisableRedrawScope.cs diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Receive/DisableRedrawScope.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Receive/DisableRedrawScope.cs new file mode 100644 index 0000000000..07edaccdc1 --- /dev/null +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Receive/DisableRedrawScope.cs @@ -0,0 +1,26 @@ +using System; +using Rhino.DocObjects.Tables; + +namespace Speckle.Connectors.Rhino7.Operations.Receive; + +/// +/// Helper class to disable within a scope +/// +public sealed class DisableRedrawScope : IDisposable +{ + private readonly ViewTable _viewTable; + private readonly bool _returnToStatus; + + public DisableRedrawScope(ViewTable viewTable, bool returnToStatus = true) + { + _viewTable = viewTable; + _returnToStatus = returnToStatus; + + _viewTable.RedrawEnabled = false; + } + + public void Dispose() + { + _viewTable.RedrawEnabled = _returnToStatus; + } +} diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Receive/RhinoHostObjectBuilder.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Receive/RhinoHostObjectBuilder.cs index baf06fefce..61c75aa048 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Receive/RhinoHostObjectBuilder.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Receive/RhinoHostObjectBuilder.cs @@ -44,7 +44,8 @@ CancellationToken cancellationToken var objectsToConvert = _traverseFunction .Traverse(rootObject) .Where(obj => obj.Current is not Collection) - .Select(ctx => (GetLayerPath(ctx), ctx.Current)); + .Select(ctx => (GetLayerPath(ctx), ctx.Current)) + .ToArray(); var convertedIds = BakeObjects(objectsToConvert, baseLayerName, onOperationProgressed, cancellationToken); @@ -55,7 +56,7 @@ CancellationToken cancellationToken // POC: Potentially refactor out into an IObjectBaker. private List BakeObjects( - IEnumerable<(string[], Base)> objects, + IReadOnlyCollection<(string[], Base)> objects, string baseLayerName, Action? onOperationProgressed, CancellationToken cancellationToken @@ -72,7 +73,7 @@ CancellationToken cancellationToken Layer[]? childLayers = documentLayer.GetChildren(); if (childLayers != null) { - doc.Views.RedrawEnabled = false; + using var layerNoDraw = new DisableRedrawScope(doc.Views); foreach (var layer in childLayers) { var purgeSuccess = doc.Layers.Purge(layer.Index, true); @@ -81,7 +82,6 @@ CancellationToken cancellationToken Console.WriteLine($"Failed to purge layer: {layer}"); } } - doc.Views.RedrawEnabled = true; } } @@ -91,12 +91,12 @@ CancellationToken cancellationToken var newObjectIds = new List(); var count = 0; - var listObjects = objects.ToList(); // POC: We delay throwing conversion exceptions until the end of the conversion loop, then throw all within an aggregate exception if something happened. var conversionExceptions = new List(); - doc.Views.RedrawEnabled = false; + using var noDraw = new DisableRedrawScope(doc.Views); + foreach ((string[] path, Base baseObj) in objects) { try @@ -108,7 +108,7 @@ CancellationToken cancellationToken ? value : GetAndCreateLayerFromPath(path, baseLayerName, cache); - onOperationProgressed?.Invoke("Converting & creating objects", (double)++count / listObjects.Count); + onOperationProgressed?.Invoke("Converting & creating objects", (double)++count / objects.Count); var result = _toHostConverter.Convert(baseObj); @@ -124,7 +124,6 @@ CancellationToken cancellationToken conversionExceptions.Add(e); } } - doc.Views.RedrawEnabled = true; if (conversionExceptions.Count != 0) { From 1decc704470c515376427c016cf9d63437480380 Mon Sep 17 00:00:00 2001 From: connorivy <43247197+connorivy@users.noreply.github.com> Date: Mon, 6 May 2024 06:12:23 -0500 Subject: [PATCH 107/261] CNX-9408 - Fix(Revit): silence exception throw by duplicate conversions (#3357) * silence error * fix: parameter extractor null warnings * chore: Added cnx code to POC comment --------- Co-authored-by: Connor Ivy Co-authored-by: Alan Rynne --- .../Helpers/ParameterValueExtractor.cs | 42 +++++++++++++++---- .../RevitConverterToSpeckle.cs | 12 +++++- .../HostedElementConversionToSpeckle.cs | 1 + 3 files changed, 46 insertions(+), 9 deletions(-) diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/ParameterValueExtractor.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/ParameterValueExtractor.cs index acb96d9acd..cdc8e69243 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/ParameterValueExtractor.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/ParameterValueExtractor.cs @@ -110,9 +110,30 @@ public int GetValueAsInt(Element element, BuiltInParameter builtInParameter) return GetValueGeneric(parameter, StorageType.String, (parameter) => parameter.AsString()); } - public ElementId? GetValueAsElementId(Element element, BuiltInParameter builtInParameter) + public ElementId GetValueAsElementId(Element element, BuiltInParameter builtInParameter) { - return GetValueGeneric(element, builtInParameter, StorageType.ElementId, (parameter) => parameter.AsElementId()); + if (TryGetValueAsElementId(element, builtInParameter, out var elementId)) + { + return elementId!; + } + throw new SpeckleConversionException( + $"Failed to get {builtInParameter} on element of type {element.GetType()} as ElementId" + ); + } + + public bool TryGetValueAsElementId(Element element, BuiltInParameter builtInParameter, out ElementId? elementId) + { + if ( + GetValueGeneric(element, builtInParameter, StorageType.ElementId, (parameter) => parameter.AsElementId()) + is ElementId elementIdNotNull + ) + { + elementId = elementIdNotNull; + return true; + } + + elementId = null; + return false; } public ElementId? GetValueAsElementId(Parameter parameter) @@ -122,16 +143,21 @@ public int GetValueAsInt(Element element, BuiltInParameter builtInParameter) public bool TryGetValueAsDocumentObject(Element element, BuiltInParameter builtInParameter, out T? value) { - ElementId? elementId = GetValueAsElementId(element, builtInParameter); + if (!TryGetValueAsElementId(element, builtInParameter, out var elementId)) + { + value = default; + return false; + } + Element paramElement = element.Document.GetElement(elementId); - if (paramElement is T typedElement) + if (paramElement is not T typedElement) { - value = typedElement; - return true; + value = default; + return false; } - value = default; - return false; + value = typedElement; + return true; } public T GetValueAsDocumentObject(Element element, BuiltInParameter builtInParameter) diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/RevitConverterToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/RevitConverterToSpeckle.cs index 44aec8ce9d..0a07f8dfba 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/RevitConverterToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/RevitConverterToSpeckle.cs @@ -45,7 +45,17 @@ public Base Convert(object target) // POC: is this the right place? result.applicationId = element.UniqueId; - _convertedObjectsCache.AddConvertedBase(element.UniqueId, result); + try + { + _convertedObjectsCache.AddConvertedBase(element.UniqueId, result); + } + catch (ArgumentException) + { + // POC: object converted multiple times + // we are doing this all the time in our current converter, and the serializer is fixing it for us. + // so for now, I am just silencing this exception + // https://spockle.atlassian.net/browse/CNX-9402 + } _parameterValueExtractor.RemoveUniqueId(element.UniqueId); } diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/HostedElementConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/HostedElementConversionToSpeckle.cs index a84e0b4b33..45388c02ee 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/HostedElementConversionToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/HostedElementConversionToSpeckle.cs @@ -8,6 +8,7 @@ namespace Speckle.Converters.RevitShared.ToSpeckle; // POC: do we need to see the blocks investigation outcome? Does the current logic hold? // opportunity to rethink or confirm hosted element handling? Should this be a connector responsibiliy? // No interfacing out however... +// CNX-9414 Re-evaluate hosted element conversions public class HostedElementConversionToSpeckle { private readonly ToSpeckleConvertedObjectsCache _convertedObjectsCache; From 96cf6748a5afe47da66dca1bb76a4fa0349675ca Mon Sep 17 00:00:00 2001 From: Claire Kuang Date: Mon, 6 May 2024 05:17:48 -0700 Subject: [PATCH 108/261] fix(autocad): CNX-9398 acad received splines are not accurate in some cases (#3358) sets tangent use to true when tangent is not 0 --- .../Raw/AutocadPolycurveToHostPolyline2dRawConverter.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/AutocadPolycurveToHostPolyline2dRawConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/AutocadPolycurveToHostPolyline2dRawConverter.cs index 718f20a9fa..040de0fd8c 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/AutocadPolycurveToHostPolyline2dRawConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/AutocadPolycurveToHostPolyline2dRawConverter.cs @@ -71,7 +71,13 @@ public ADB.Polyline2d RawConvert(SOG.Autocad.AutocadPolycurve target) // append vertices for (int i = 0; i < points.Count; i++) { - ADB.Vertex2d vertex = new(points[i], target.bulges[i], 0, 0, target.tangents[i]); + double tangent = target.tangents[i]; + ADB.Vertex2d vertex = new(points[i], target.bulges[i], 0, 0, tangent); + if (tangent != 0) + { + vertex.TangentUsed = true; + } + polyline.AppendVertex(vertex); tr.AddNewlyCreatedDBObject(vertex, true); } From 6779e68381063fc3ab5b0361a3a5fa832d886841 Mon Sep 17 00:00:00 2001 From: Jedd Morgan <45512892+JR-Morgan@users.noreply.github.com> Date: Mon, 6 May 2024 13:19:18 +0100 Subject: [PATCH 109/261] Fix Autocad to Rhino Polycurves (#3359) Rhino curve conversion to not match start points --- .../ToHost/Raw/SpecklePolyCurveRawToHostConversion.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpecklePolyCurveRawToHostConversion.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpecklePolyCurveRawToHostConversion.cs index 1ef9619270..5bb2cdc9be 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpecklePolyCurveRawToHostConversion.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpecklePolyCurveRawToHostConversion.cs @@ -1,5 +1,6 @@ using Objects; using Speckle.Converters.Common.Objects; +using Speckle.Core.Kits; namespace Speckle.Converters.Rhino7.ToHost.Raw; @@ -27,7 +28,11 @@ public RG.PolyCurve RawConvert(SOG.Polycurve target) foreach (var segment in target.segments) { var childCurve = CurveConverter!.RawConvert(segment); - result.Append(childCurve); + bool success = result.AppendSegment(childCurve); + if (!success) + { + throw new ConversionException($"Failed to append segment {segment}"); + } } result.Domain = _intervalConverter.RawConvert(target.domain); From cce67db6dba9181a81b902cab6d19e15443cf3bd Mon Sep 17 00:00:00 2001 From: Jedd Morgan <45512892+JR-Morgan@users.noreply.github.com> Date: Mon, 6 May 2024 14:08:56 +0100 Subject: [PATCH 110/261] CNX-9411 Rhino unit conversions not working on fallback conversions (#3360) Added units scaling to displayValue fallback Rhino --- .../Speckle.Converters.Rhino7.csproj | 7 ----- .../SpeckleFallbackToHostConversion.cs | 27 +++++++++++++++++-- 2 files changed, 25 insertions(+), 9 deletions(-) diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Speckle.Converters.Rhino7.csproj b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Speckle.Converters.Rhino7.csproj index 983d8dd791..752fe889d4 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Speckle.Converters.Rhino7.csproj +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Speckle.Converters.Rhino7.csproj @@ -5,13 +5,6 @@ enable enable - - - - $(WarningsNotAsErrors); - CS8618; - - diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/SpeckleFallbackToHostConversion.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/SpeckleFallbackToHostConversion.cs index dc0e6602ea..c16ae8e387 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/SpeckleFallbackToHostConversion.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/SpeckleFallbackToHostConversion.cs @@ -1,5 +1,7 @@ -using Speckle.Converters.Common; +using Rhino; +using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; +using Speckle.Core.Kits; using Speckle.Core.Models; namespace Speckle.Converters.Rhino7.ToHost.TopLevel; @@ -12,16 +14,19 @@ public class SpeckleFallbackToHostConversion private readonly IRawConversion _lineConverter; private readonly IRawConversion _polylineConverter; private readonly IRawConversion _meshConverter; + private readonly IConversionContextStack _contextStack; public SpeckleFallbackToHostConversion( IRawConversion lineConverter, IRawConversion polylineConverter, - IRawConversion meshConverter + IRawConversion meshConverter, + IConversionContextStack contextStack ) { _lineConverter = lineConverter; _polylineConverter = polylineConverter; _meshConverter = meshConverter; + _contextStack = contextStack; } public object Convert(Base target) => RawConvert((DisplayableObject)target); @@ -38,9 +43,27 @@ public SpeckleFallbackToHostConversion( SOG.Mesh mesh => _meshConverter.RawConvert(mesh), _ => throw new NotSupportedException($"Found unsupported fallback geometry: {item.GetType()}") }; + x.Transform(GetUnitsTransform(item)); result.Add(x); } return result; } + + private RG.Transform GetUnitsTransform(Base speckleObject) + { + /* + * POC: CNX-9270 Looking at a simpler, more performant way of doing unit scaling on `ToNative` + * by fully relying on the transform capabilities of the HostApp, and only transforming top-level stuff. + * This may not hold when adding more complex conversions, but it works for now! + */ + if (speckleObject["units"] is string units) + { + var scaleFactor = Units.GetConversionFactor(units, _contextStack.Current.SpeckleUnits); + var scale = RG.Transform.Scale(RG.Point3d.Origin, scaleFactor); + return scale; + } + + return RG.Transform.Identity; + } } From c0646e0ecf7f7d76cf361a9c435e13ae0c3505af Mon Sep 17 00:00:00 2001 From: BovineOx <73857041+BovineOx@users.noreply.github.com> Date: Mon, 6 May 2024 16:44:50 +0100 Subject: [PATCH 111/261] RCNX-9409 - Rhino Setting and factory delegate (#3363) Rhino Setting and factory delegate * Replaced Func<> delegate with factory for generic RootObjectSender * Replaced ToString() with Location for assembly due to incorrect path being returned :/ --- .../Speckle.Connectors.Rhino7/HostApp/RhinoSettings.cs | 2 +- .../Operations/RootObjectSender.cs | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/RhinoSettings.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/RhinoSettings.cs index 14a224a60d..bb48c8e6ac 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/RhinoSettings.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/RhinoSettings.cs @@ -10,7 +10,7 @@ public RhinoSettings(HostApplication hostAppInfo, HostAppVersion hostAppVersion) { HostAppInfo = hostAppInfo; HostAppVersion = hostAppVersion; - Modules = new[] { new DirectoryInfo(typeof(RhinoSettings).Assembly.ToString()).Parent.FullName }; + Modules = new[] { new DirectoryInfo(typeof(RhinoSettings).Assembly.Location).Parent.FullName }; } public HostApplication HostAppInfo { get; private set; } diff --git a/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/RootObjectSender.cs b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/RootObjectSender.cs index cfa87c429c..d3a54d0ba1 100644 --- a/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/RootObjectSender.cs +++ b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/RootObjectSender.cs @@ -18,9 +18,9 @@ namespace Speckle.Connectors.Utils.Operations; public sealed class RootObjectSender : IRootObjectSender { // POC: Revisit this factory pattern, I think we could solve this higher up by injecting a scoped factory for `SendOperation` in the SendBinding - private readonly Func _transportFactory; + private readonly ServerTransport.Factory _transportFactory; - public RootObjectSender(Func transportFactory) + public RootObjectSender(ServerTransport.Factory transportFactory) { _transportFactory = transportFactory; } @@ -38,7 +38,7 @@ public RootObjectSender(Func transportFactory) Account account = AccountManager.GetAccount(sendInfo.AccountId); - ITransport transport = _transportFactory(account, sendInfo.ProjectId); + ITransport transport = _transportFactory(account, sendInfo.ProjectId, 60, null); var sendResult = await SendHelper.Send(commitObject, transport, true, null, ct).ConfigureAwait(false); ct.ThrowIfCancellationRequested(); @@ -47,7 +47,7 @@ public RootObjectSender(Func transportFactory) // 8 - Create the version (commit) using var apiClient = new Client(account); - string versionId = await apiClient + _ = await apiClient .CommitCreate( new CommitCreateInput { From 7ee4ca0755d59f7f6f6ba6ff400abd32fe57ae21 Mon Sep 17 00:00:00 2001 From: BovineOx <73857041+BovineOx@users.noreply.github.com> Date: Mon, 6 May 2024 18:43:54 +0100 Subject: [PATCH 112/261] CNX-9405 rvt family environment not supported (#3367) * Prevent user interacting with Family Environment document type When loading a Family type doc the DUI3 UI does not let the user progress If a caller tries to call RootObject.Build() in Revit, if the document IsFamilyDocument() it will not work * Add message to DocumentInfo for error Add message to DocumentInfo for error --- .../Bindings/BasicConnectorBindingRevit.cs | 5 +++++ .../Operations/Send/RootObjectBuilder.cs | 9 ++++++++- .../DUI3/Speckle.Connectors.DUI/Models/DocumentInfo.cs | 2 ++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/BasicConnectorBindingRevit.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/BasicConnectorBindingRevit.cs index 15616ce6be..0452730b05 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/BasicConnectorBindingRevit.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/BasicConnectorBindingRevit.cs @@ -66,6 +66,11 @@ public DocumentInfo GetDocumentInfo() var doc = _revitContext.UIApplication.ActiveUIDocument.Document; + if (doc.IsFamilyDocument) + { + return new DocumentInfo { Message = "Family Environment files not supported by Speckle." }; + } + // POC: Notify user here if document is null. return new DocumentInfo diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RootObjectBuilder.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RootObjectBuilder.cs index cbe02b5fcc..ae7a094bc8 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RootObjectBuilder.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RootObjectBuilder.cs @@ -6,6 +6,7 @@ using Autodesk.Revit.DB; using Speckle.Converters.RevitShared.Helpers; using System.Linq; +using Speckle.Core.Logging; namespace Speckle.Connectors.Revit.Operations.Send; @@ -43,6 +44,13 @@ public Base Build( CancellationToken ct = default ) { + var doc = _contextStack.Current.Document.Document; // POC: Document.Document is funny + + if (doc.IsFamilyDocument) + { + throw new SpeckleException("Family Environment documents are not supported."); + } + var objects = new List(); // = _contextStack.Current.Document.Document.GetElements(sendSelection.SelectedItems).ToList(); foreach (var id in sendSelection.SelectedItems) @@ -59,7 +67,6 @@ public Base Build( throw new InvalidOperationException("No objects were found. Please update your send filter!"); } - var doc = _contextStack.Current.Document.Document; // POC: Document.Document is funny var countProgress = 0; // because for(int i = 0; ...) loops are so last year foreach (Element revitElement in objects) diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/DocumentInfo.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/DocumentInfo.cs index 39ac1302aa..357b286dc2 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/DocumentInfo.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/DocumentInfo.cs @@ -10,4 +10,6 @@ public class DocumentInfo public string Name { get; set; } public string Id { get; set; } + + public string? Message { get; set; } } From 9478cd79b723a1f05a5de8d4d3a36f7a486fc2d1 Mon Sep 17 00:00:00 2001 From: Alan Rynne Date: Mon, 6 May 2024 20:30:37 +0200 Subject: [PATCH 113/261] fix: Save to file even when no models exist (covers edge-case where last model was removed) (#3365) * fix: Save to file even when no models exist (covers edge-case where last model was removed) * fix: Remove linq using directive --- .../HostApp/RevitDocumentStore.cs | 7 ------- 1 file changed, 7 deletions(-) diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/RevitDocumentStore.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/RevitDocumentStore.cs index 8356866325..43141730e3 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/RevitDocumentStore.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/RevitDocumentStore.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.Diagnostics; -using System.Linq; using Autodesk.Revit.DB; using Autodesk.Revit.DB.ExtensibleStorage; using Autodesk.Revit.UI; @@ -82,12 +81,6 @@ private void WriteToFileWithDoc(Document doc) return; } - // Don't even attempt to write anything if empty. - if (!Models.Any()) - { - return; - } - string serializedModels = Serialize(); using Transaction t = new(doc, "Speckle Write State"); From ea4b4d8033b98238a6a4932924a3c35cb93c41a7 Mon Sep 17 00:00:00 2001 From: Claire Kuang Date: Mon, 6 May 2024 13:06:26 -0700 Subject: [PATCH 114/261] fix(autocad): CNX-9383 viewer sync for autocad polycurve (#3366) fixes reversed curves in autocad polyline2ds --- ...adPolycurveToHostPolyline2dRawConverter.cs | 6 ++-- .../Geometry/Polyline2dToSpeckleConverter.cs | 36 +++++++++++++++++-- .../Geometry/PolylineToSpeckleConverter.cs | 26 +++++++------- .../Geometry/Autocad/AutocadPolycurve.cs | 2 +- 4 files changed, 51 insertions(+), 19 deletions(-) diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/AutocadPolycurveToHostPolyline2dRawConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/AutocadPolycurveToHostPolyline2dRawConverter.cs index 040de0fd8c..e4c46210b0 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/AutocadPolycurveToHostPolyline2dRawConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/AutocadPolycurveToHostPolyline2dRawConverter.cs @@ -71,9 +71,9 @@ public ADB.Polyline2d RawConvert(SOG.Autocad.AutocadPolycurve target) // append vertices for (int i = 0; i < points.Count; i++) { - double tangent = target.tangents[i]; - ADB.Vertex2d vertex = new(points[i], target.bulges[i], 0, 0, tangent); - if (tangent != 0) + double? tangent = target.tangents[i]; + ADB.Vertex2d vertex = new(points[i], target.bulges[i], 0, 0, tangent ?? 0); + if (tangent is not null) { vertex.TangentUsed = true; } diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/Polyline2dToSpeckleConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/Polyline2dToSpeckleConverter.cs index e798ffa91f..9902877848 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/Polyline2dToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/Polyline2dToSpeckleConverter.cs @@ -74,7 +74,7 @@ public SOG.Autocad.AutocadPolycurve RawConvert(ADB.Polyline2d target) // get all vertex data List value = new(); List bulges = new(); - List tangents = new(); + List tangents = new(); List vertices = target .GetSubEntities( ADB.OpenMode.ForRead, @@ -88,11 +88,12 @@ public SOG.Autocad.AutocadPolycurve RawConvert(ADB.Polyline2d target) ADB.Vertex2d vertex = vertices[i]; // get vertex value in the Global Coordinate System (GCS). + // NOTE: for some reason, the z value of the position for rotated polyline2ds doesn't seem to match the exploded segment endpoint values value.AddRange(vertex.Position.ToArray()); // get the bulge and tangent bulges.Add(vertex.Bulge); - tangents.Add(vertex.Tangent); + tangents.Add(vertex.TangentUsed ? vertex.Tangent : null); } // explode the polyline @@ -102,6 +103,7 @@ public SOG.Autocad.AutocadPolycurve RawConvert(ADB.Polyline2d target) List segmentValues = new(); ADB.DBObjectCollection exploded = new(); target.Explode(exploded); + AG.Point3d previousPoint = new(); for (int i = 0; i < exploded.Count; i++) { @@ -119,13 +121,35 @@ public SOG.Autocad.AutocadPolycurve RawConvert(ADB.Polyline2d target) // for non-splines, convert the curve and add to segments list else { + // for the first segment, the only way we can correctly determine its orientation is to find the connection point to the next segment + // this is because the z value of rotated polyline2d vertices is unreliable, so we can't use the first vertex + if (i == 0 && exploded.Count > 1 && exploded[1] is ADB.Curve nextSegment) + { + previousPoint = + segment.StartPoint.IsEqualTo(nextSegment.StartPoint) || segment.StartPoint.IsEqualTo(nextSegment.EndPoint) + ? segment.EndPoint + : segment.StartPoint; + } + switch (segment) { case ADB.Arc arc: + if (ShouldReverseCurve(arc, previousPoint)) + { + arc.ReverseCurve(); + } + segments.Add(_arcConverter.RawConvert(arc)); + previousPoint = arc.EndPoint; break; case ADB.Line line: + if (ShouldReverseCurve(line, previousPoint)) + { + line.ReverseCurve(); + } + segments.Add(_lineConverter.RawConvert(line)); + previousPoint = line.EndPoint; break; } } @@ -166,4 +190,12 @@ public SOG.Autocad.AutocadPolycurve RawConvert(ADB.Polyline2d target) return polycurve; } + + /// + /// Determines if the input curve is reversed according to the input start point + /// + /// + /// Should match either the start or the end point of the curve. + /// True if the endpoint of the curve matches the startpoint, or false if it doesn't. + private bool ShouldReverseCurve(ADB.Curve curve, AG.Point3d startPoint) => curve.EndPoint.IsEqualTo(startPoint); } diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/PolylineToSpeckleConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/PolylineToSpeckleConverter.cs index 472c47ae86..44e01315d6 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/PolylineToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/PolylineToSpeckleConverter.cs @@ -1,5 +1,4 @@ using System.Collections.Generic; -using Autodesk.AutoCAD.DatabaseServices; using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; using Speckle.Core.Models; @@ -7,10 +6,10 @@ namespace Speckle.Converters.Autocad.Geometry; /// -/// The class converter. Converts to . +/// The class converter. Converts to . /// /// -/// is of type and will have only s and s in . +/// is of type and will have only s and s in . /// [NameAndRankValue(nameof(ADB.Polyline), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] public class PolylineToSpeckleConverter @@ -20,15 +19,15 @@ public class PolylineToSpeckleConverter private readonly IRawConversion _lineConverter; private readonly IRawConversion _arcConverter; private readonly IRawConversion _vectorConverter; - private readonly IRawConversion _boxConverter; - private readonly IConversionContextStack _contextStack; + private readonly IRawConversion _boxConverter; + private readonly IConversionContextStack _contextStack; public PolylineToSpeckleConverter( IRawConversion lineConverter, IRawConversion arcConverter, IRawConversion vectorConverter, - IRawConversion boxConverter, - IConversionContextStack contextStack + IRawConversion boxConverter, + IConversionContextStack contextStack ) { _lineConverter = lineConverter; @@ -45,7 +44,6 @@ public SOG.Autocad.AutocadPolycurve RawConvert(ADB.Polyline target) List value = new(target.NumberOfVertices * 3); List bulges = new(target.NumberOfVertices); List segments = new(); - for (int i = 0; i < target.NumberOfVertices; i++) { // get vertex value in the Object Coordinate System (OCS) @@ -56,14 +54,16 @@ public SOG.Autocad.AutocadPolycurve RawConvert(ADB.Polyline target) bulges.Add(target.GetBulgeAt(i)); // get segment in the Global Coordinate System (GCS) - SegmentType type = target.GetSegmentType(i); + ADB.SegmentType type = target.GetSegmentType(i); switch (type) { - case SegmentType.Line: - segments.Add(_lineConverter.RawConvert(target.GetLineSegmentAt(i))); + case ADB.SegmentType.Line: + AG.LineSegment3d line = target.GetLineSegmentAt(i); + segments.Add(_lineConverter.RawConvert(line)); break; - case SegmentType.Arc: - segments.Add(_arcConverter.RawConvert(target.GetArcSegmentAt(i))); + case ADB.SegmentType.Arc: + AG.CircularArc3d arc = target.GetArcSegmentAt(i); + segments.Add(_arcConverter.RawConvert(arc)); break; default: // we are skipping segments of type Empty, Point, and Coincident diff --git a/Objects/Objects/Geometry/Autocad/AutocadPolycurve.cs b/Objects/Objects/Geometry/Autocad/AutocadPolycurve.cs index 10bfa24d7d..a88c5147df 100644 --- a/Objects/Objects/Geometry/Autocad/AutocadPolycurve.cs +++ b/Objects/Objects/Geometry/Autocad/AutocadPolycurve.cs @@ -43,7 +43,7 @@ public AutocadPolycurve() { } /// /// The tangent in radians at each vertex. Should be null for Polyline and Polyline3d. /// - public List? tangents { get; set; } + public List? tangents { get; set; } /// /// The normal of the plane of the Autocad Polyline or Polyline2d. Should be null for Polyline3d. From b889d2f092018e5729601c9274c1c9a1610ad560 Mon Sep 17 00:00:00 2001 From: Alan Rynne Date: Mon, 6 May 2024 22:54:08 +0200 Subject: [PATCH 115/261] DUI3: Rhino converters rename (#3369) * chore: Renamed Rhino ToHost raw converters * chore: Renamed Rhino ToHost TopLevel converters * chore: Renamed Rhino ToSpeckle TopLevel converters * chore: Missing class renames --- ...kleArcRawToHostConversion.cs => ArcToHostConverter.cs} | 4 ++-- ...eBrepRawToHostConversion.cs => BrepToHostConverter.cs} | 4 ++-- ...cleRawToHostConversion.cs => CircleToHostConverter.cs} | 8 +++----- ...urveRawToHostConversion.cs => CurveToHostConverter.cs} | 4 ++-- ...seRawToHostConversion.cs => EllipseToHostConverter.cs} | 4 ++-- ...oHostConversion.cs => FlatPointListToHostConverter.cs} | 2 +- ...lRawToHostConversion.cs => IntervalToHostConverter.cs} | 2 +- ...eLineRawToHostConversion.cs => LineToHostConverter.cs} | 4 ++-- ...eMeshRawToHostConversion.cs => MeshToHostConverter.cs} | 4 ++-- ...veToHostConversion.cs => NurbsCurveToHostConverter.cs} | 4 ++-- ...laneRawToHostConversion.cs => PlaneToHostConverter.cs} | 4 ++-- ...awToHostConversion.cs => PointCloudToHostConverter.cs} | 4 ++-- ...ointRawToHostConversion.cs => PointToHostConverter.cs} | 4 +--- ...RawToHostConversion.cs => PolyCurveToHostConverter.cs} | 4 ++-- ...eRawToHostConversion.cs => PolylineToHostConverter.cs} | 4 ++-- ...ralRawToHostConversion.cs => SpiralToHostConverter.cs} | 4 ++-- ...ceRawToHostConversion.cs => SurfaceToHostConverter.cs} | 2 +- ...torRawToHostConversion.cs => VectorToHostConverter.cs} | 2 +- ...rcCurveConversion.cs => ArcToHostTopLevelConverter.cs} | 4 ++-- ...stBrepConversion.cs => BrepToHostTopLevelConverter.cs} | 4 ++-- ...urveConversion.cs => CircleToHostTopLevelConverter.cs} | 4 ++-- ...rveConversion.cs => EllipseToHostTopLevelConverter.cs} | 4 ++-- ...stConversion.cs => FallbackToHostTopLevelConverter.cs} | 4 ++-- ...eCurveConversion.cs => LineToHostTopLevelConverter.cs} | 4 ++-- ...stMeshConversion.cs => MeshToHostTopLevelConverter.cs} | 4 ++-- ...Conversion.cs => NurbsCurveToHostTopLevelConverter.cs} | 4 ++-- ...Conversion.cs => PointCloudToHostTopLevelConverter.cs} | 5 ++--- ...PointConversion.cs => PointToHostTopLevelConverter.cs} | 4 ++-- ...eConversion.cs => PolycurveToHostTopLevelConverter.cs} | 5 ++--- ...veConversion.cs => PolylineToHostTopLevelConverter.cs} | 5 ++--- ...version.cs => BrepObjectToSpeckleTopLevelConverter.cs} | 4 ++-- ...ersion.cs => CurveObjectToSpeckleTopLevelConverter.cs} | 4 ++-- ...on.cs => ExtrusionObjectToSpeckleTopLevelConverter.cs} | 4 ++-- ...version.cs => MeshObjectToSpeckleTopLevelConverter.cs} | 4 ++-- ...n.cs => PointCloudObjectToSpeckleTopLevelConverter.cs} | 6 +++--- ...ersion.cs => PointObjectToSpeckleTopLevelConverter.cs} | 5 +++-- ...ersion.cs => RhinoObjectToSpeckleTopLevelConverter.cs} | 5 +++-- 37 files changed, 73 insertions(+), 78 deletions(-) rename DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/{SpeckleArcRawToHostConversion.cs => ArcToHostConverter.cs} (93%) rename DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/{SpeckleBrepRawToHostConversion.cs => BrepToHostConverter.cs} (98%) rename DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/{SpeckleCircleRawToHostConversion.cs => CircleToHostConverter.cs} (90%) rename DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/{SpeckleICurveRawToHostConversion.cs => CurveToHostConverter.cs} (95%) rename DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/{SpeckleEllipseRawToHostConversion.cs => EllipseToHostConverter.cs} (96%) rename DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/{FlatPointListRawToHostConversion.cs => FlatPointListToHostConverter.cs} (92%) rename DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/{SpeckleIntervalRawToHostConversion.cs => IntervalToHostConverter.cs} (90%) rename DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/{SpeckleLineRawToHostConversion.cs => LineToHostConverter.cs} (85%) rename DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/{SpeckleMeshRawToHostConversion.cs => MeshToHostConverter.cs} (94%) rename DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/{SpeckleNurbsCurveToHostConversion.cs => NurbsCurveToHostConverter.cs} (91%) rename DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/{SpecklePlaneRawToHostConversion.cs => PlaneToHostConverter.cs} (88%) rename DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/{SpecklePointCloudRawToHostConversion.cs => PointCloudToHostConverter.cs} (82%) rename DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/{SpecklePointRawToHostConversion.cs => PointToHostConverter.cs} (87%) rename DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/{SpecklePolyCurveRawToHostConversion.cs => PolyCurveToHostConverter.cs} (85%) rename DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/{SpecklePolylineRawToHostConversion.cs => PolylineToHostConverter.cs} (95%) rename DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/{SpeckleSpiralRawToHostConversion.cs => SpiralToHostConverter.cs} (88%) rename DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/{SpeckleSurfaceRawToHostConversion.cs => SurfaceToHostConverter.cs} (95%) rename DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/{SpeckleVectorRawToHostConversion.cs => VectorToHostConverter.cs} (84%) rename DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/{SpeckleArcToHostArcCurveConversion.cs => ArcToHostTopLevelConverter.cs} (73%) rename DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/{SpeckleBrepToHostBrepConversion.cs => BrepToHostTopLevelConverter.cs} (74%) rename DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/{SpeckleCircleToHostArcCurveConversion.cs => CircleToHostTopLevelConverter.cs} (72%) rename DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/{SpeckleEllipseToHostNurbsCurveConversion.cs => EllipseToHostTopLevelConverter.cs} (71%) rename DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/{SpeckleFallbackToHostConversion.cs => FallbackToHostTopLevelConverter.cs} (96%) rename DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/{SpeckleLineToHostLineCurveConversion.cs => LineToHostTopLevelConverter.cs} (72%) rename DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/{SpeckleMeshToHostMeshConversion.cs => MeshToHostTopLevelConverter.cs} (74%) rename DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/{SpeckleNurbsCurveToHostNurbsCurveConversion.cs => NurbsCurveToHostTopLevelConverter.cs} (70%) rename DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/{SpecklePointCloudToHostPointCloudConversion.cs => PointCloudToHostTopLevelConverter.cs} (70%) rename DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/{SpecklePointToHostPointConversion.cs => PointToHostTopLevelConverter.cs} (73%) rename DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/{SpecklePolycurveToHostPolycurveConversion.cs => PolycurveToHostTopLevelConverter.cs} (70%) rename DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/{SpecklePolylineToHostPolylineCurveConversion.cs => PolylineToHostTopLevelConverter.cs} (69%) rename DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/{RhinoBrepObjectToSpeckleConversion.cs => BrepObjectToSpeckleTopLevelConverter.cs} (76%) rename DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/{RhinoCurveObjectToSpeckleConversion.cs => CurveObjectToSpeckleTopLevelConverter.cs} (65%) rename DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/{RhinoExtrusionObjectToSpeckleConversion.cs => ExtrusionObjectToSpeckleTopLevelConverter.cs} (76%) rename DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/{RhinoMeshObjectToSpeckleConversion.cs => MeshObjectToSpeckleTopLevelConverter.cs} (63%) rename DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/{RhinoPointCloudObjectToSpeckleConversion.cs => PointCloudObjectToSpeckleTopLevelConverter.cs} (60%) rename DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/{RhinoPointObjectToSpeckleConversion.cs => PointObjectToSpeckleTopLevelConverter.cs} (62%) rename DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/{RhinoObjectToSpeckleConversion.cs => RhinoObjectToSpeckleTopLevelConverter.cs} (80%) diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpeckleArcRawToHostConversion.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/ArcToHostConverter.cs similarity index 93% rename from DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpeckleArcRawToHostConversion.cs rename to DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/ArcToHostConverter.cs index f9f341ec7a..291395ee9e 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpeckleArcRawToHostConversion.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/ArcToHostConverter.cs @@ -5,12 +5,12 @@ namespace Speckle.Converters.Rhino7.ToHost.Raw; /// /// Converts a SpeckleArcRaw object to a Rhino.Geometry.Arc object or Rhino.Geometry.ArcCurve object. /// -public class SpeckleArcRawToHostConversion : IRawConversion, IRawConversion +public class ArcToHostConverter : IRawConversion, IRawConversion { private readonly IRawConversion _pointConverter; private readonly IRawConversion _intervalConverter; - public SpeckleArcRawToHostConversion( + public ArcToHostConverter( IRawConversion pointConverter, IRawConversion intervalConverter ) diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpeckleBrepRawToHostConversion.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/BrepToHostConverter.cs similarity index 98% rename from DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpeckleBrepRawToHostConversion.cs rename to DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/BrepToHostConverter.cs index 9fd34aa678..e27a846a1b 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpeckleBrepRawToHostConversion.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/BrepToHostConverter.cs @@ -5,7 +5,7 @@ namespace Speckle.Converters.Rhino7.ToHost.Raw; -public class SpeckleBrepRawToHostConversion : IRawConversion +public class BrepToHostConverter : IRawConversion { private readonly IConversionContextStack _contextStack; private readonly IRawConversion _curveConverter; @@ -13,7 +13,7 @@ public class SpeckleBrepRawToHostConversion : IRawConversion private readonly IRawConversion _pointConverter; private readonly IRawConversion _intervalConverter; - public SpeckleBrepRawToHostConversion( + public BrepToHostConverter( IConversionContextStack contextStack, IRawConversion curveConverter, IRawConversion surfaceConverter, diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpeckleCircleRawToHostConversion.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/CircleToHostConverter.cs similarity index 90% rename from DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpeckleCircleRawToHostConversion.cs rename to DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/CircleToHostConverter.cs index 33c796f9aa..06f31256a5 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpeckleCircleRawToHostConversion.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/CircleToHostConverter.cs @@ -7,15 +7,13 @@ namespace Speckle.Converters.Rhino7.ToHost.Raw; /// Implements the interface, /// providing implementation for to and conversion. /// -public class SpeckleCircleRawToHostConversion - : IRawConversion, - IRawConversion +public class CircleToHostConverter : IRawConversion, IRawConversion { private readonly IRawConversion _planeConverter; private readonly IRawConversion _intervalConverter; /// - /// Constructs a new instance of the class. + /// Constructs a new instance of the class. /// /// /// An implementation of used to convert into . @@ -23,7 +21,7 @@ public class SpeckleCircleRawToHostConversion /// /// An implementation of used to convert into . /// - public SpeckleCircleRawToHostConversion( + public CircleToHostConverter( IRawConversion intervalConverter, IRawConversion planeConverter ) diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpeckleICurveRawToHostConversion.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/CurveToHostConverter.cs similarity index 95% rename from DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpeckleICurveRawToHostConversion.cs rename to DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/CurveToHostConverter.cs index fda7dc8fb0..a9b13e3b76 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpeckleICurveRawToHostConversion.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/CurveToHostConverter.cs @@ -3,7 +3,7 @@ namespace Speckle.Converters.Rhino7.ToHost.Raw; -public class SpeckleICurveRawToHostConversion : IRawConversion +public class CurveToHostConverter : IRawConversion { private readonly IRawConversion _lineConverter; private readonly IRawConversion _arcConverter; @@ -14,7 +14,7 @@ public class SpeckleICurveRawToHostConversion : IRawConversion private readonly IRawConversion _polyCurveConverter; private readonly IRawConversion _nurbsCurveConverter; - public SpeckleICurveRawToHostConversion( + public CurveToHostConverter( IRawConversion lineConverter, IRawConversion arcConverter, IRawConversion ellipseConverter, diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpeckleEllipseRawToHostConversion.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/EllipseToHostConverter.cs similarity index 96% rename from DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpeckleEllipseRawToHostConversion.cs rename to DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/EllipseToHostConverter.cs index 1435c4f2ef..a394547db8 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpeckleEllipseRawToHostConversion.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/EllipseToHostConverter.cs @@ -2,14 +2,14 @@ namespace Speckle.Converters.Rhino7.ToHost.Raw; -public class SpeckleEllipseRawToHostConversion +public class EllipseToHostConverter : IRawConversion, IRawConversion { private readonly IRawConversion _planeConverter; private readonly IRawConversion _intervalConverter; - public SpeckleEllipseRawToHostConversion( + public EllipseToHostConverter( IRawConversion planeConverter, IRawConversion intervalConverter ) diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/FlatPointListRawToHostConversion.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/FlatPointListToHostConverter.cs similarity index 92% rename from DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/FlatPointListRawToHostConversion.cs rename to DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/FlatPointListToHostConverter.cs index 24a344b6b3..9865ff8c54 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/FlatPointListRawToHostConversion.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/FlatPointListToHostConverter.cs @@ -7,7 +7,7 @@ namespace Speckle.Converters.Rhino7.ToHost.Raw; /// /// Converts a flat list of raw double values to a Point3dList. /// -public class FlatPointListRawToHostConversion : IRawConversion, Point3dList> +public class FlatPointListToHostConverter : IRawConversion, Point3dList> { /// /// Converts a flat list of raw double values to a Point3dList. diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpeckleIntervalRawToHostConversion.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/IntervalToHostConverter.cs similarity index 90% rename from DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpeckleIntervalRawToHostConversion.cs rename to DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/IntervalToHostConverter.cs index fa5f34acf1..405d1b2ac3 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpeckleIntervalRawToHostConversion.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/IntervalToHostConverter.cs @@ -2,7 +2,7 @@ namespace Speckle.Converters.Rhino7.ToHost.Raw; -public class SpeckleIntervalRawToHostConversion : IRawConversion +public class IntervalToHostConverter : IRawConversion { /// /// Converts a Speckle Interval object to a Rhino.Geometry.Interval object. diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpeckleLineRawToHostConversion.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/LineToHostConverter.cs similarity index 85% rename from DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpeckleLineRawToHostConversion.cs rename to DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/LineToHostConverter.cs index d5aa8a950f..2d2846f1bf 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpeckleLineRawToHostConversion.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/LineToHostConverter.cs @@ -2,11 +2,11 @@ namespace Speckle.Converters.Rhino7.ToHost.Raw; -public class SpeckleLineRawToHostConversion : IRawConversion, IRawConversion +public class LineToHostConverter : IRawConversion, IRawConversion { private readonly IRawConversion _pointConverter; - public SpeckleLineRawToHostConversion(IRawConversion pointConverter) + public LineToHostConverter(IRawConversion pointConverter) { _pointConverter = pointConverter; } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpeckleMeshRawToHostConversion.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/MeshToHostConverter.cs similarity index 94% rename from DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpeckleMeshRawToHostConversion.cs rename to DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/MeshToHostConverter.cs index 8012c6f33d..adf67b4f8f 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpeckleMeshRawToHostConversion.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/MeshToHostConverter.cs @@ -5,11 +5,11 @@ namespace Speckle.Converters.Rhino7.ToHost.Raw; -public class SpeckleMeshRawToHostConversion : IRawConversion +public class MeshToHostConverter : IRawConversion { private readonly IRawConversion, Point3dList> _pointListConverter; - public SpeckleMeshRawToHostConversion(IRawConversion, Point3dList> pointListConverter) + public MeshToHostConverter(IRawConversion, Point3dList> pointListConverter) { _pointListConverter = pointListConverter; } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpeckleNurbsCurveToHostConversion.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/NurbsCurveToHostConverter.cs similarity index 91% rename from DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpeckleNurbsCurveToHostConversion.cs rename to DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/NurbsCurveToHostConverter.cs index abb8935eb2..41b59620f9 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpeckleNurbsCurveToHostConversion.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/NurbsCurveToHostConverter.cs @@ -3,11 +3,11 @@ namespace Speckle.Converters.Rhino7.ToHost.Raw; -public class SpeckleNurbsCurveToHostConversion : IRawConversion +public class NurbsCurveToHostConverter : IRawConversion { private readonly IRawConversion _intervalConverter; - public SpeckleNurbsCurveToHostConversion(IRawConversion intervalConverter) + public NurbsCurveToHostConverter(IRawConversion intervalConverter) { _intervalConverter = intervalConverter; } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpecklePlaneRawToHostConversion.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/PlaneToHostConverter.cs similarity index 88% rename from DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpecklePlaneRawToHostConversion.cs rename to DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/PlaneToHostConverter.cs index fa2d4b55e9..e4068eeeba 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpecklePlaneRawToHostConversion.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/PlaneToHostConverter.cs @@ -2,12 +2,12 @@ namespace Speckle.Converters.Rhino7.ToHost.Raw; -public class SpecklePlaneRawToHostConversion : IRawConversion +public class PlaneToHostConverter : IRawConversion { private readonly IRawConversion _pointConverter; private readonly IRawConversion _vectorConverter; - public SpecklePlaneRawToHostConversion( + public PlaneToHostConverter( IRawConversion pointConverter, IRawConversion vectorConverter ) diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpecklePointCloudRawToHostConversion.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/PointCloudToHostConverter.cs similarity index 82% rename from DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpecklePointCloudRawToHostConversion.cs rename to DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/PointCloudToHostConverter.cs index a56a940343..327c594cad 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpecklePointCloudRawToHostConversion.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/PointCloudToHostConverter.cs @@ -4,11 +4,11 @@ namespace Speckle.Converters.Rhino7.ToHost.Raw; -public class SpecklePointCloudRawToHostConversion : IRawConversion +public class PointCloudToHostConverter : IRawConversion { private readonly IRawConversion, Point3dList> _pointListConverter; - public SpecklePointCloudRawToHostConversion(IRawConversion, Point3dList> pointListConverter) + public PointCloudToHostConverter(IRawConversion, Point3dList> pointListConverter) { _pointListConverter = pointListConverter; } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpecklePointRawToHostConversion.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/PointToHostConverter.cs similarity index 87% rename from DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpecklePointRawToHostConversion.cs rename to DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/PointToHostConverter.cs index 74115b2080..676203ef0a 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpecklePointRawToHostConversion.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/PointToHostConverter.cs @@ -2,9 +2,7 @@ namespace Speckle.Converters.Rhino7.ToHost.Raw; -public class SpecklePointRawToHostConversion - : IRawConversion, - IRawConversion +public class PointToHostConverter : IRawConversion, IRawConversion { /// /// Converts a Speckle Point object to a Rhino Point3d object. diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpecklePolyCurveRawToHostConversion.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/PolyCurveToHostConverter.cs similarity index 85% rename from DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpecklePolyCurveRawToHostConversion.cs rename to DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/PolyCurveToHostConverter.cs index 5bb2cdc9be..9334cfba08 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpecklePolyCurveRawToHostConversion.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/PolyCurveToHostConverter.cs @@ -4,13 +4,13 @@ namespace Speckle.Converters.Rhino7.ToHost.Raw; -public class SpecklePolyCurveRawToHostConversion : IRawConversion +public class PolyCurveToHostConverter : IRawConversion { public IRawConversion? CurveConverter { get; set; } // POC: CNX-9311 Circular dependency injected by the container using property. private readonly IRawConversion _intervalConverter; - public SpecklePolyCurveRawToHostConversion(IRawConversion intervalConverter) + public PolyCurveToHostConverter(IRawConversion intervalConverter) { _intervalConverter = intervalConverter; } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpecklePolylineRawToHostConversion.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/PolylineToHostConverter.cs similarity index 95% rename from DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpecklePolylineRawToHostConversion.cs rename to DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/PolylineToHostConverter.cs index 1305a7ac1c..546becbb40 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpecklePolylineRawToHostConversion.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/PolylineToHostConverter.cs @@ -3,14 +3,14 @@ namespace Speckle.Converters.Rhino7.ToHost.Raw; -public class SpecklePolylineRawToHostConversion +public class PolylineToHostConverter : IRawConversion, IRawConversion { private readonly IRawConversion, Point3dList> _pointListConverter; private readonly IRawConversion _intervalConverter; - public SpecklePolylineRawToHostConversion( + public PolylineToHostConverter( IRawConversion, Point3dList> pointListConverter, IRawConversion intervalConverter ) diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpeckleSpiralRawToHostConversion.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpiralToHostConverter.cs similarity index 88% rename from DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpeckleSpiralRawToHostConversion.cs rename to DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpiralToHostConverter.cs index 6756bf73c3..eaaf5d92e6 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpeckleSpiralRawToHostConversion.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpiralToHostConverter.cs @@ -2,12 +2,12 @@ namespace Speckle.Converters.Rhino7.ToHost.Raw; -public class SpeckleSpiralRawToHostConversion : IRawConversion +public class SpiralToHostConverter : IRawConversion { private readonly IRawConversion _polylineConverter; private readonly IRawConversion _intervalConverter; - public SpeckleSpiralRawToHostConversion( + public SpiralToHostConverter( IRawConversion polylineConverter, IRawConversion intervalConverter ) diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpeckleSurfaceRawToHostConversion.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SurfaceToHostConverter.cs similarity index 95% rename from DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpeckleSurfaceRawToHostConversion.cs rename to DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SurfaceToHostConverter.cs index 184941d13d..0cb7e67818 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpeckleSurfaceRawToHostConversion.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SurfaceToHostConverter.cs @@ -2,7 +2,7 @@ namespace Speckle.Converters.Rhino7.ToHost.Raw; -public class SpeckleSurfaceRawToHostConversion : IRawConversion +public class SurfaceToHostConverter : IRawConversion { /// /// Converts a raw Speckle surface to a Rhino NURBS surface. diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpeckleVectorRawToHostConversion.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/VectorToHostConverter.cs similarity index 84% rename from DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpeckleVectorRawToHostConversion.cs rename to DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/VectorToHostConverter.cs index 7042850fe1..c0b4bd0b61 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpeckleVectorRawToHostConversion.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/VectorToHostConverter.cs @@ -2,7 +2,7 @@ namespace Speckle.Converters.Rhino7.ToHost.Raw; -public class SpeckleVectorRawToHostConversion : IRawConversion +public class VectorToHostConverter : IRawConversion { /// /// Converts a Speckle.Vector object to a Rhino Vector3d object. diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/SpeckleArcToHostArcCurveConversion.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/ArcToHostTopLevelConverter.cs similarity index 73% rename from DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/SpeckleArcToHostArcCurveConversion.cs rename to DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/ArcToHostTopLevelConverter.cs index 75aff43838..682ccab3e5 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/SpeckleArcToHostArcCurveConversion.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/ArcToHostTopLevelConverter.cs @@ -5,9 +5,9 @@ namespace Speckle.Converters.Rhino7.ToHost.TopLevel; [NameAndRankValue(nameof(SOG.Arc), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class SpeckleArcToHostArcCurveConversion : SpeckleToHostGeometryBaseConversion +public class ArcToHostTopLevelConverter : SpeckleToHostGeometryBaseConversion { - public SpeckleArcToHostArcCurveConversion( + public ArcToHostTopLevelConverter( IConversionContextStack contextStack, IRawConversion geometryBaseConverter ) diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/SpeckleBrepToHostBrepConversion.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/BrepToHostTopLevelConverter.cs similarity index 74% rename from DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/SpeckleBrepToHostBrepConversion.cs rename to DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/BrepToHostTopLevelConverter.cs index f386b76533..c8b963517d 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/SpeckleBrepToHostBrepConversion.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/BrepToHostTopLevelConverter.cs @@ -5,9 +5,9 @@ namespace Speckle.Converters.Rhino7.ToHost.TopLevel; [NameAndRankValue(nameof(SOG.Brep), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class SpeckleBrepToHostBrepConversion : SpeckleToHostGeometryBaseConversion +public class BrepToHostTopLevelConverter : SpeckleToHostGeometryBaseConversion { - public SpeckleBrepToHostBrepConversion( + public BrepToHostTopLevelConverter( IConversionContextStack contextStack, IRawConversion geometryBaseConverter ) diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/SpeckleCircleToHostArcCurveConversion.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/CircleToHostTopLevelConverter.cs similarity index 72% rename from DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/SpeckleCircleToHostArcCurveConversion.cs rename to DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/CircleToHostTopLevelConverter.cs index 7d02393663..d3c21b737f 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/SpeckleCircleToHostArcCurveConversion.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/CircleToHostTopLevelConverter.cs @@ -5,9 +5,9 @@ namespace Speckle.Converters.Rhino7.ToHost.TopLevel; [NameAndRankValue(nameof(SOG.Circle), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class SpeckleCircleToHostArcCurveConversion : SpeckleToHostGeometryBaseConversion +public class CircleToHostTopLevelConverter : SpeckleToHostGeometryBaseConversion { - public SpeckleCircleToHostArcCurveConversion( + public CircleToHostTopLevelConverter( IConversionContextStack contextStack, IRawConversion geometryBaseConverter ) diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/SpeckleEllipseToHostNurbsCurveConversion.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/EllipseToHostTopLevelConverter.cs similarity index 71% rename from DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/SpeckleEllipseToHostNurbsCurveConversion.cs rename to DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/EllipseToHostTopLevelConverter.cs index a917ae22a1..20040aa439 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/SpeckleEllipseToHostNurbsCurveConversion.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/EllipseToHostTopLevelConverter.cs @@ -5,9 +5,9 @@ namespace Speckle.Converters.Rhino7.ToHost.TopLevel; [NameAndRankValue(nameof(SOG.Ellipse), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class SpeckleEllipseToHostNurbsCurveConversion : SpeckleToHostGeometryBaseConversion +public class EllipseToHostTopLevelConverter : SpeckleToHostGeometryBaseConversion { - public SpeckleEllipseToHostNurbsCurveConversion( + public EllipseToHostTopLevelConverter( IConversionContextStack contextStack, IRawConversion geometryBaseConverter ) diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/SpeckleFallbackToHostConversion.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/FallbackToHostTopLevelConverter.cs similarity index 96% rename from DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/SpeckleFallbackToHostConversion.cs rename to DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/FallbackToHostTopLevelConverter.cs index c16ae8e387..be7ff4491d 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/SpeckleFallbackToHostConversion.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/FallbackToHostTopLevelConverter.cs @@ -7,7 +7,7 @@ namespace Speckle.Converters.Rhino7.ToHost.TopLevel; [NameAndRankValue(nameof(DisplayableObject), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class SpeckleFallbackToHostConversion +public class FallbackToHostTopLevelConverter : ISpeckleObjectToHostConversion, IRawConversion> { @@ -16,7 +16,7 @@ public class SpeckleFallbackToHostConversion private readonly IRawConversion _meshConverter; private readonly IConversionContextStack _contextStack; - public SpeckleFallbackToHostConversion( + public FallbackToHostTopLevelConverter( IRawConversion lineConverter, IRawConversion polylineConverter, IRawConversion meshConverter, diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/SpeckleLineToHostLineCurveConversion.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/LineToHostTopLevelConverter.cs similarity index 72% rename from DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/SpeckleLineToHostLineCurveConversion.cs rename to DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/LineToHostTopLevelConverter.cs index 377d21a5e5..28c5dbe39e 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/SpeckleLineToHostLineCurveConversion.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/LineToHostTopLevelConverter.cs @@ -5,9 +5,9 @@ namespace Speckle.Converters.Rhino7.ToHost.TopLevel; [NameAndRankValue(nameof(SOG.Line), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class SpeckleLineToHostLineCurveConversion : SpeckleToHostGeometryBaseConversion +public class LineToHostTopLevelConverter : SpeckleToHostGeometryBaseConversion { - public SpeckleLineToHostLineCurveConversion( + public LineToHostTopLevelConverter( IConversionContextStack contextStack, IRawConversion geometryBaseConverter ) diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/SpeckleMeshToHostMeshConversion.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/MeshToHostTopLevelConverter.cs similarity index 74% rename from DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/SpeckleMeshToHostMeshConversion.cs rename to DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/MeshToHostTopLevelConverter.cs index 3d30039a3d..573a401934 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/SpeckleMeshToHostMeshConversion.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/MeshToHostTopLevelConverter.cs @@ -5,9 +5,9 @@ namespace Speckle.Converters.Rhino7.ToHost.TopLevel; [NameAndRankValue(nameof(SOG.Mesh), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class SpeckleMeshToHostMeshConversion : SpeckleToHostGeometryBaseConversion +public class MeshToHostTopLevelConverter : SpeckleToHostGeometryBaseConversion { - public SpeckleMeshToHostMeshConversion( + public MeshToHostTopLevelConverter( IConversionContextStack contextStack, IRawConversion geometryBaseConverter ) diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/SpeckleNurbsCurveToHostNurbsCurveConversion.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/NurbsCurveToHostTopLevelConverter.cs similarity index 70% rename from DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/SpeckleNurbsCurveToHostNurbsCurveConversion.cs rename to DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/NurbsCurveToHostTopLevelConverter.cs index 3cc0b733be..fed264c879 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/SpeckleNurbsCurveToHostNurbsCurveConversion.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/NurbsCurveToHostTopLevelConverter.cs @@ -5,9 +5,9 @@ namespace Speckle.Converters.Rhino7.ToHost.TopLevel; [NameAndRankValue(nameof(SOG.Curve), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class SpeckleNurbsCurveToHostNurbsCurveConversion : SpeckleToHostGeometryBaseConversion +public class NurbsCurveToHostTopLevelConverter : SpeckleToHostGeometryBaseConversion { - public SpeckleNurbsCurveToHostNurbsCurveConversion( + public NurbsCurveToHostTopLevelConverter( IConversionContextStack contextStack, IRawConversion geometryBaseConverter ) diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/SpecklePointCloudToHostPointCloudConversion.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/PointCloudToHostTopLevelConverter.cs similarity index 70% rename from DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/SpecklePointCloudToHostPointCloudConversion.cs rename to DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/PointCloudToHostTopLevelConverter.cs index 874166b5ef..7a8f5c962a 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/SpecklePointCloudToHostPointCloudConversion.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/PointCloudToHostTopLevelConverter.cs @@ -5,10 +5,9 @@ namespace Speckle.Converters.Rhino7.ToHost.TopLevel; [NameAndRankValue(nameof(SOG.Pointcloud), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class SpecklePointCloudToHostPointCloudConversion - : SpeckleToHostGeometryBaseConversion +public class PointCloudToHostTopLevelConverter : SpeckleToHostGeometryBaseConversion { - public SpecklePointCloudToHostPointCloudConversion( + public PointCloudToHostTopLevelConverter( IConversionContextStack contextStack, IRawConversion geometryBaseConverter ) diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/SpecklePointToHostPointConversion.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/PointToHostTopLevelConverter.cs similarity index 73% rename from DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/SpecklePointToHostPointConversion.cs rename to DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/PointToHostTopLevelConverter.cs index 1c5ab2447f..94d3049b6f 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/SpecklePointToHostPointConversion.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/PointToHostTopLevelConverter.cs @@ -5,9 +5,9 @@ namespace Speckle.Converters.Rhino7.ToHost.TopLevel; [NameAndRankValue(nameof(SOG.Point), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class SpecklePointToHostPointConversion : SpeckleToHostGeometryBaseConversion +public class PointToHostTopLevelConverter : SpeckleToHostGeometryBaseConversion { - public SpecklePointToHostPointConversion( + public PointToHostTopLevelConverter( IConversionContextStack contextStack, IRawConversion geometryBaseConverter ) diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/SpecklePolycurveToHostPolycurveConversion.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/PolycurveToHostTopLevelConverter.cs similarity index 70% rename from DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/SpecklePolycurveToHostPolycurveConversion.cs rename to DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/PolycurveToHostTopLevelConverter.cs index 9b1f29c9d1..48f9555b3b 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/SpecklePolycurveToHostPolycurveConversion.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/PolycurveToHostTopLevelConverter.cs @@ -5,10 +5,9 @@ namespace Speckle.Converters.Rhino7.ToHost.TopLevel; [NameAndRankValue(nameof(SOG.Polycurve), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class SpecklePolycurveToHostPolycurveConversion - : SpeckleToHostGeometryBaseConversion +public class PolycurveToHostTopLevelConverter : SpeckleToHostGeometryBaseConversion { - public SpecklePolycurveToHostPolycurveConversion( + public PolycurveToHostTopLevelConverter( IConversionContextStack contextStack, IRawConversion geometryBaseConverter ) diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/SpecklePolylineToHostPolylineCurveConversion.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/PolylineToHostTopLevelConverter.cs similarity index 69% rename from DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/SpecklePolylineToHostPolylineCurveConversion.cs rename to DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/PolylineToHostTopLevelConverter.cs index 7f5daf4bdc..388cf84bc2 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/SpecklePolylineToHostPolylineCurveConversion.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/PolylineToHostTopLevelConverter.cs @@ -5,10 +5,9 @@ namespace Speckle.Converters.Rhino7.ToHost.TopLevel; [NameAndRankValue(nameof(SOG.Polyline), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class SpecklePolylineToHostPolylineCurveConversion - : SpeckleToHostGeometryBaseConversion +public class PolylineToHostTopLevelConverter : SpeckleToHostGeometryBaseConversion { - public SpecklePolylineToHostPolylineCurveConversion( + public PolylineToHostTopLevelConverter( IConversionContextStack contextStack, IRawConversion geometryBaseConverter ) diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/RhinoBrepObjectToSpeckleConversion.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/BrepObjectToSpeckleTopLevelConverter.cs similarity index 76% rename from DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/RhinoBrepObjectToSpeckleConversion.cs rename to DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/BrepObjectToSpeckleTopLevelConverter.cs index ee66c10b10..b57c8a08e5 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/RhinoBrepObjectToSpeckleConversion.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/BrepObjectToSpeckleTopLevelConverter.cs @@ -6,11 +6,11 @@ namespace Speckle.Converters.Rhino7.ToSpeckle.TopLevel; [NameAndRankValue(nameof(BrepObject), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class RhinoBrepObjectToSpeckleConversion : IHostObjectToSpeckleConversion +public class BrepObjectToSpeckleTopLevelConverter : IHostObjectToSpeckleConversion { private readonly IRawConversion _curveConverter; - public RhinoBrepObjectToSpeckleConversion(IRawConversion curveConverter) + public BrepObjectToSpeckleTopLevelConverter(IRawConversion curveConverter) { _curveConverter = curveConverter; } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/RhinoCurveObjectToSpeckleConversion.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/CurveObjectToSpeckleTopLevelConverter.cs similarity index 65% rename from DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/RhinoCurveObjectToSpeckleConversion.cs rename to DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/CurveObjectToSpeckleTopLevelConverter.cs index 626c82c409..285130be58 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/RhinoCurveObjectToSpeckleConversion.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/CurveObjectToSpeckleTopLevelConverter.cs @@ -6,9 +6,9 @@ namespace Speckle.Converters.Rhino7.ToSpeckle.TopLevel; [NameAndRankValue(nameof(CurveObject), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class RhinoCurveObjectToSpeckleConversion : RhinoObjectToSpeckleConversion +public class CurveObjectToSpeckleTopLevelConverter : RhinoObjectToSpeckleTopLevelConverter { - public RhinoCurveObjectToSpeckleConversion(IRawConversion conversion) + public CurveObjectToSpeckleTopLevelConverter(IRawConversion conversion) : base(conversion) { } protected override RG.Curve GetTypedGeometry(CurveObject input) => input.CurveGeometry; diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/RhinoExtrusionObjectToSpeckleConversion.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/ExtrusionObjectToSpeckleTopLevelConverter.cs similarity index 76% rename from DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/RhinoExtrusionObjectToSpeckleConversion.cs rename to DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/ExtrusionObjectToSpeckleTopLevelConverter.cs index 2d5cd4c884..5be77ff94c 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/RhinoExtrusionObjectToSpeckleConversion.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/ExtrusionObjectToSpeckleTopLevelConverter.cs @@ -6,11 +6,11 @@ namespace Speckle.Converters.Rhino7.ToSpeckle.TopLevel; [NameAndRankValue(nameof(ExtrusionObject), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class RhinoExtrusionObjectToSpeckleConversion : IHostObjectToSpeckleConversion +public class ExtrusionObjectToSpeckleTopLevelConverter : IHostObjectToSpeckleConversion { private readonly IRawConversion _curveConverter; - public RhinoExtrusionObjectToSpeckleConversion(IRawConversion curveConverter) + public ExtrusionObjectToSpeckleTopLevelConverter(IRawConversion curveConverter) { _curveConverter = curveConverter; } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/RhinoMeshObjectToSpeckleConversion.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/MeshObjectToSpeckleTopLevelConverter.cs similarity index 63% rename from DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/RhinoMeshObjectToSpeckleConversion.cs rename to DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/MeshObjectToSpeckleTopLevelConverter.cs index 2cf0813132..ab0debcb5c 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/RhinoMeshObjectToSpeckleConversion.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/MeshObjectToSpeckleTopLevelConverter.cs @@ -5,9 +5,9 @@ namespace Speckle.Converters.Rhino7.ToSpeckle.TopLevel; [NameAndRankValue(nameof(MeshObject), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class RhinoMeshObjectToSpeckleConversion : RhinoObjectToSpeckleConversion +public class MeshObjectToSpeckleTopLevelConverter : RhinoObjectToSpeckleTopLevelConverter { - public RhinoMeshObjectToSpeckleConversion(IRawConversion conversion) + public MeshObjectToSpeckleTopLevelConverter(IRawConversion conversion) : base(conversion) { } protected override RG.Mesh GetTypedGeometry(MeshObject input) => input.MeshGeometry; diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/RhinoPointCloudObjectToSpeckleConversion.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/PointCloudObjectToSpeckleTopLevelConverter.cs similarity index 60% rename from DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/RhinoPointCloudObjectToSpeckleConversion.cs rename to DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/PointCloudObjectToSpeckleTopLevelConverter.cs index 1dcf153c3c..6436640448 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/RhinoPointCloudObjectToSpeckleConversion.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/PointCloudObjectToSpeckleTopLevelConverter.cs @@ -5,10 +5,10 @@ namespace Speckle.Converters.Rhino7.ToSpeckle.TopLevel; [NameAndRankValue(nameof(PointCloudObject), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class RhinoPointCloudObjectToSpeckleConversion - : RhinoObjectToSpeckleConversion +public class PointCloudObjectToSpeckleTopLevelConverter + : RhinoObjectToSpeckleTopLevelConverter { - public RhinoPointCloudObjectToSpeckleConversion(IRawConversion conversion) + public PointCloudObjectToSpeckleTopLevelConverter(IRawConversion conversion) : base(conversion) { } protected override RG.PointCloud GetTypedGeometry(PointCloudObject input) => input.PointCloudGeometry; diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/RhinoPointObjectToSpeckleConversion.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/PointObjectToSpeckleTopLevelConverter.cs similarity index 62% rename from DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/RhinoPointObjectToSpeckleConversion.cs rename to DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/PointObjectToSpeckleTopLevelConverter.cs index 03678a7dc7..e73af8acbf 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/RhinoPointObjectToSpeckleConversion.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/PointObjectToSpeckleTopLevelConverter.cs @@ -5,9 +5,10 @@ namespace Speckle.Converters.Rhino7.ToSpeckle.TopLevel; [NameAndRankValue(nameof(PointObject), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class RhinoPointObjectToSpeckleConversion : RhinoObjectToSpeckleConversion +public class PointObjectToSpeckleTopLevelConverter + : RhinoObjectToSpeckleTopLevelConverter { - public RhinoPointObjectToSpeckleConversion(IRawConversion conversion) + public PointObjectToSpeckleTopLevelConverter(IRawConversion conversion) : base(conversion) { } protected override RG.Point GetTypedGeometry(PointObject input) => input.PointGeometry; diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/RhinoObjectToSpeckleConversion.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/RhinoObjectToSpeckleTopLevelConverter.cs similarity index 80% rename from DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/RhinoObjectToSpeckleConversion.cs rename to DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/RhinoObjectToSpeckleTopLevelConverter.cs index f2e4f0ab8b..3cc03f3930 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/RhinoObjectToSpeckleConversion.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/RhinoObjectToSpeckleTopLevelConverter.cs @@ -3,14 +3,15 @@ namespace Speckle.Converters.Rhino7.ToSpeckle.TopLevel; -public abstract class RhinoObjectToSpeckleConversion : IHostObjectToSpeckleConversion +public abstract class RhinoObjectToSpeckleTopLevelConverter + : IHostObjectToSpeckleConversion where TTopLevelIn : Rhino.DocObjects.RhinoObject where TInRaw : RG.GeometryBase where TOutRaw : Base { public IRawConversion Conversion { get; } - protected RhinoObjectToSpeckleConversion(IRawConversion conversion) + protected RhinoObjectToSpeckleTopLevelConverter(IRawConversion conversion) { Conversion = conversion; } From 2fbf0fd23ba359b63eb929536316e98cacca5323 Mon Sep 17 00:00:00 2001 From: connorivy <43247197+connorivy@users.noreply.github.com> Date: Tue, 7 May 2024 03:00:41 -0500 Subject: [PATCH 116/261] CNX-9413 - Add logo to Revit connector button and change language (#3368) * add logo to connector button and change language * remove unused import --------- Co-authored-by: Connor Ivy Co-authored-by: Jedd Morgan <45512892+JR-Morgan@users.noreply.github.com> --- .../Assets/logo16.png | Bin 0 -> 591 bytes .../Assets/logo32.png | Bin 0 -> 1275 bytes .../Plugin/RevitExternalApplication.cs | 6 +-- .../Plugin/RevitPlugin.cs | 45 +++++++++++++++++- .../Plugin/Speckle.Connectors.Revit2023.addin | 4 +- .../Speckle.Connectors.RevitShared.projitems | 2 + 6 files changed, 50 insertions(+), 7 deletions(-) create mode 100644 DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Assets/logo16.png create mode 100644 DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Assets/logo32.png diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Assets/logo16.png b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Assets/logo16.png new file mode 100644 index 0000000000000000000000000000000000000000..7ab056643e927d2d336b939c446ac93aca12ab47 GIT binary patch literal 591 zcmV-V0`|3J_Mk|1ai1Z|3l zKw7md!5|0(F~~A)GNT!rn>jPzyzkq>F(}HE&gPuW^E-E$NEsPR;)@2wKb|5Kts<1j z5{*`|W+u=2YCm735g|yW_FWy6eH(s(`gP*5a`s zEMWqsDPsFN<8sGIP8R~Bx8FwEk2bmChOm?k)>w3@Y;g^4wurZ^Z8=xMaSd*+XuYmR z&y~0p@RD)>blJ$z9 z5f5$k!gm+?1~rdH?eZ%)u~QMR77pCgOl2%rdps*^VPM#>*8TVoLP zL8kZzfkUlAx&XC7VS6oP3vg{nvnMWG?p9=rmfk0t>0G6PNR5;GJX5lZ0vDed0$!La zEj)w)w1LA9G*W5hmpeFnYQz1`_HeIKXaHA3rT}FFu33Nq1gwDec_?}n`Jj)KM=|g0 z-W9g5NAh=54>KFThB(<2k@1fiJJA}GsrR$?(~dfsd6Trsu1zvK@`dcd7RkR%*uv=! dRXX!j>mM&W)=aIYYOMeO002ovPDHLkV1k4E3=RMQ literal 0 HcmV?d00001 diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Assets/logo32.png b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Assets/logo32.png new file mode 100644 index 0000000000000000000000000000000000000000..68120fdabaeb3ef50919ed4ec900af89ac1cb6a8 GIT binary patch literal 1275 zcmVH5b|mi-H3P$;tOk8d~Y>}e3n3J4SzMqf=vx4vnu1{M;bs*QSwVG`wpIA#p$RP z=6?&3_LOh`$0xIMpS~k!6?;5aQX)WU(8@(PE>Z}c(;6qMkjWe#t#wvIHkC)l()hAU zyFe!6AYvK3={(lw&1^L#-pS}rdcKhdpO-{|s9OP|Zn&z2P1 zBNPEkf@Q$5E=@8It9B~dVzBKnoO{j0Ho;>+z=ode2mr{tFl&ptG_DB1)X{>qvjldp zmBXEybBPg(z+l<6+F(vqp+7k;Y(L_%VYiDKNP&^71IcXfr2#M{JT+7D^IC&3{_6x_ zNeG7oa!}JPw&Ck147`J4xpJqX@*RiS^@{FPp;ynS5WK%^U?;yS0EU3@C_&4M2Ic-j zex-mr%LS%{105Pe!b|fdZ$B*gV40*gB#5R9c|Urt?@yRkK2Z0t9H=UWz0aCNk{Uz6 z-Qxs1RvOf9a@fDlV9hSY#>J8ye`ub&M=-gp5TeKGpy7~9O-OKmxG!u+yRI<>%ce*? z20ZzN!lh8zETa$sM}cX8atoz*eWQ!hOR{o5yt+`bYI98qrEQ7o$$$Jd)sXVEG zheXg8Nxz3=drZeFgW~*HKe39SIRC?GH#T9Eh)*gL7bcbxuWxdDMi+_Wmpvx7Z9hBx zty959itTJTL~Bh*w2uqYw(FRV)RogcZH(xu4H4aXP$w4DiqzckB0Z-{q*v}#>b@GG lADAGRS1t6|z}3A|{slqH=o=vxqX7T_002ovPDHLkV1gG&PO1O^ literal 0 HcmV?d00001 diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitExternalApplication.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitExternalApplication.cs index d47d66a7dd..333ea1dda2 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitExternalApplication.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitExternalApplication.cs @@ -32,11 +32,11 @@ public RevitExternalApplication() // POC: load from JSON file? _revitSettings = new RevitSettings { - RevitPanelName = "Speckle DUI3 (DI)", + RevitPanelName = "Speckle New UI", RevitTabName = "Speckle", - RevitTabTitle = "Speckle DUI3 (DI)", + RevitTabTitle = "Speckle New UI", RevitVersionName = "2023", - RevitButtonName = "Speckle DUI3 (DI)", + RevitButtonName = "Speckle New UI", RevitButtonText = "Revit Connector", ModuleFolders = new string[] { Path.GetDirectoryName(typeof(RevitExternalApplication).Assembly.Location) }, HostSlug = "Revit" diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitPlugin.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitPlugin.cs index 19a9e72b38..83165bcdad 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitPlugin.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitPlugin.cs @@ -9,6 +9,11 @@ using Speckle.Connectors.DUI.Bindings; using System.Diagnostics; using Speckle.Converters.RevitShared.Helpers; +using Speckle.Core.Logging; +using System.Reflection; +using System.Windows.Media.Imaging; +using System.Windows.Media; +using System.IO; namespace Speckle.Connectors.Revit.Plugin; @@ -62,11 +67,12 @@ private void CreateTabAndRibbonPanel(UIControlledApplication application) } catch (ArgumentException) { - throw; + // exception occurs when the speckle tab has already been created. + // this happens when both the dui2 and the dui3 connectors are installed. Can be safely ignored. } RibbonPanel specklePanel = application.CreateRibbonPanel(_revitSettings.RevitTabName, _revitSettings.RevitTabTitle); - PushButton _ = + PushButton dui3Button = specklePanel.AddItem( new PushButtonData( _revitSettings.RevitButtonName, @@ -75,6 +81,23 @@ private void CreateTabAndRibbonPanel(UIControlledApplication application) typeof(SpeckleRevitCommand).FullName ) ) as PushButton; + + string path = typeof(RevitPlugin).Assembly.Location; + dui3Button.Image = LoadPngImgSource( + $"Speckle.Connectors.Revit{_revitSettings.RevitVersionName}.Assets.logo16.png", + path + ); + dui3Button.LargeImage = LoadPngImgSource( + $"Speckle.Connectors.Revit{_revitSettings.RevitVersionName}.Assets.logo32.png", + path + ); + dui3Button.ToolTipImage = LoadPngImgSource( + $"Speckle.Connectors.Revit{_revitSettings.RevitVersionName}.Assets.logo32.png", + path + ); + dui3Button.ToolTip = "Speckle Connector for Revit New UI"; + //dui3Button.AvailabilityClassName = typeof(CmdAvailabilityViews).FullName; + dui3Button.SetContextualHelp(new ContextualHelp(ContextualHelpType.Url, "https://speckle.systems")); } private void OnApplicationInitialized(object sender, Autodesk.Revit.DB.Events.ApplicationInitializedEventArgs e) @@ -147,4 +170,22 @@ private void RegisterPanelAndInitializePlugin() #endif }; } + + private ImageSource? LoadPngImgSource(string sourceName, string path) + { + try + { + var assembly = Assembly.LoadFrom(Path.Combine(path)); + var icon = assembly.GetManifestResourceStream(sourceName); + PngBitmapDecoder m_decoder = new(icon, BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.Default); + ImageSource m_source = m_decoder.Frames[0]; + return (m_source); + } + catch (Exception ex) when (!ex.IsFatal()) + { + // POC: logging + } + + return null; + } } diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/Speckle.Connectors.Revit2023.addin b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/Speckle.Connectors.Revit2023.addin index 17a6874f65..5e07999bbd 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/Speckle.Connectors.Revit2023.addin +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/Speckle.Connectors.Revit2023.addin @@ -1,8 +1,8 @@  - Speckle Revit Connector | DUI3 + Kits + DI - Speckle Revit Connector | DUI3 + Kits + DI + Speckle Revit Connector New UI + Speckle Revit Connector New UI Speckle.Connectors.Revit2023\Speckle.Connectors.Revit2023.dll Speckle.Connectors.Revit.Plugin.RevitExternalApplication 27ccff2c-011c-4374-bb79-b93990d0c86a diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Speckle.Connectors.RevitShared.projitems b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Speckle.Connectors.RevitShared.projitems index 25aa1128b9..d8833efcce 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Speckle.Connectors.RevitShared.projitems +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Speckle.Connectors.RevitShared.projitems @@ -9,6 +9,8 @@ Speckle.Connectors.Revit + + Always From 53ea1aa0ff2ec36eda740f851e31747ebd42946a Mon Sep 17 00:00:00 2001 From: Alan Rynne Date: Tue, 7 May 2024 11:04:24 +0200 Subject: [PATCH 117/261] CNX-9412: Update Aggregate exception error in Rhino (#3372) chore: Update Aggregate exception error --- .../Operations/Receive/RhinoHostObjectBuilder.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Receive/RhinoHostObjectBuilder.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Receive/RhinoHostObjectBuilder.cs index 61c75aa048..3e0e0d1d23 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Receive/RhinoHostObjectBuilder.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Receive/RhinoHostObjectBuilder.cs @@ -127,7 +127,7 @@ CancellationToken cancellationToken if (conversionExceptions.Count != 0) { - throw new AggregateException("Some conversions failed. Please check inner exceptions.", conversionExceptions); + throw new AggregateException("Conversion failed for some objects.", conversionExceptions); } return newObjectIds; From 43456639c8b5eac33c7bac94779243b4efa651b8 Mon Sep 17 00:00:00 2001 From: Jedd Morgan <45512892+JR-Morgan@users.noreply.github.com> Date: Tue, 7 May 2024 13:20:26 +0100 Subject: [PATCH 118/261] CNX-9410 Revit caching not working (#3364) * Revit object caching * Made SendInfo readonly --- .../Bindings/AutocadSendBinding.cs | 17 +++-- .../Bindings/SendBinding.cs | 56 ++++++++++++---- .../DependencyInjection/AutofacUIModule.cs | 8 +-- .../Operations/Send/IRootObjectSender.cs | 23 ------- .../Operations/Send/RootObjectBuilder.cs | 45 ++++++++----- .../Operations/Send/RootObjectSender.cs | 67 ------------------- .../Operations/Send/SendOperation.cs | 53 --------------- .../Speckle.Connectors.RevitShared.projitems | 3 - .../Bindings/RhinoSendBinding.cs | 17 +++-- .../Helpers/ToSpeckleConvertedObjectsCache.cs | 5 ++ .../RevitConverterToSpeckle.cs | 11 --- .../HostedElementConversionToSpeckle.cs | 4 -- .../Operations/SendInfo.cs | 32 +++++++-- .../Operations/SendOperation.cs | 4 +- 14 files changed, 125 insertions(+), 220 deletions(-) delete mode 100644 DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/IRootObjectSender.cs delete mode 100644 DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RootObjectSender.cs delete mode 100644 DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/SendOperation.cs diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadSendBinding.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadSendBinding.cs index dab413d79f..05ca5806bd 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadSendBinding.cs +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadSendBinding.cs @@ -138,15 +138,14 @@ private async Task SendInternal(string modelCardId) throw new InvalidOperationException("No objects were found. Please update your send filter!"); } - var sendInfo = new SendInfo() - { - AccountId = modelCard.AccountId, - ProjectId = modelCard.ProjectId, - ModelId = modelCard.ModelId, - ConvertedObjects = _convertedObjectReferences, - ChangedObjectIds = modelCard.ChangedObjectIds, - SourceApplication = _autocadSettings.HostAppInfo.Name - }; + var sendInfo = new SendInfo( + modelCard.AccountId, + modelCard.ProjectId, + modelCard.ModelId, + _autocadSettings.HostAppInfo.Name, + _convertedObjectReferences, + modelCard.ChangedObjectIds + ); var sendResult = await uow.Service .Execute( diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SendBinding.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SendBinding.cs index 72f91ef72c..07a5fe4950 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SendBinding.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SendBinding.cs @@ -11,11 +11,12 @@ using System.Threading.Tasks; using System.Threading; using Speckle.Converters.RevitShared.Helpers; -using Speckle.Connectors.Revit.Operations.Send; using Speckle.Connectors.DUI.Models.Card; using Speckle.Connectors.DUI.Bindings; using Speckle.Autofac.DependencyInjection; using Speckle.Connectors.DUI.Models; +using Speckle.Connectors.Utils.Operations; +using Speckle.Core.Models; namespace Speckle.Connectors.Revit.Bindings; @@ -27,6 +28,12 @@ internal class SendBinding : RevitBaseBinding, ICancelable, ISendBinding // POC: does it need injecting? private HashSet ChangedObjectIds { get; set; } = new(); + /// + /// Keeps track of previously converted objects as a dictionary of (applicationId, object reference). + /// + private readonly Dictionary _convertedObjectReferences = new(); + + private readonly RevitSettings _revitSettings; private readonly IRevitIdleManager _idleManager; private readonly IUnitOfWorkFactory _unitOfWorkFactory; @@ -35,12 +42,14 @@ public SendBinding( RevitContext revitContext, DocumentModelStore store, IBridge bridge, - IUnitOfWorkFactory unitOfWorkFactory + IUnitOfWorkFactory unitOfWorkFactory, + RevitSettings revitSettings ) : base("sendBinding", store, bridge, revitContext) { _idleManager = idleManager; _unitOfWorkFactory = unitOfWorkFactory; + _revitSettings = revitSettings; Commands = new SendBindingUICommands(bridge); // TODO expiry events @@ -83,20 +92,40 @@ private async Task HandleSend(string modelCardId) throw new InvalidOperationException("No publish model card was found."); } - using IUnitOfWork sendOperation = _unitOfWorkFactory.Resolve(); + using IUnitOfWork> sendOperation = _unitOfWorkFactory.Resolve< + SendOperation + >(); + + List revitObjects = modelCard.SendFilter.GetObjectIds().Select(id => ElementId.Parse(id)).ToList(); + + var sendInfo = new SendInfo( + modelCard.AccountId, + modelCard.ProjectId, + modelCard.ModelId, + _revitSettings.HostSlug, + _convertedObjectReferences, + modelCard.ChangedObjectIds + ); - string versionId = await sendOperation.Service + var sendResult = await sendOperation.Service .Execute( - modelCard.SendFilter, - modelCard.AccountId, - modelCard.ProjectId, - modelCard.ModelId, + revitObjects, + sendInfo, (status, progress) => OnSendOperationProgress(modelCardId, status, progress), cts.Token ) .ConfigureAwait(false); - Commands.SetModelCreatedVersionId(modelCardId, versionId); + // Store the converted references in memory for future send operations, overwriting the existing values for the given application id. + foreach (var kvp in sendResult.convertedReferences) + { + _convertedObjectReferences[kvp.Key + modelCard.ProjectId] = kvp.Value; + } + + // It's important to reset the model card's list of changed obj ids so as to ensure we accurately keep track of changes between send operations. + modelCard.ChangedObjectIds = new(); + + Commands.SetModelCreatedVersionId(modelCardId, sendResult.rootObjId); } catch (OperationCanceledException) { @@ -167,14 +196,17 @@ private void DocChangeHandler(Autodesk.Revit.DB.Events.DocumentChangedEventArgs private void RunExpirationChecks() { List senders = _store.GetSenders(); + string[] objectIdsList = ChangedObjectIds.ToArray(); List expiredSenderIds = new(); - foreach (var sender in senders) + foreach (SenderModelCard modelCard in senders) { - bool isExpired = sender.SendFilter.CheckExpiry(ChangedObjectIds.ToArray()); + var intersection = modelCard.SendFilter.GetObjectIds().Intersect(objectIdsList).ToList(); + bool isExpired = modelCard.SendFilter.CheckExpiry(ChangedObjectIds.ToArray()); if (isExpired) { - expiredSenderIds.Add(sender.ModelCardId); + expiredSenderIds.Add(modelCard.ModelCardId); + modelCard.ChangedObjectIds.UnionWith(intersection); } } diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/AutofacUIModule.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/AutofacUIModule.cs index 5fed7ce26c..57a7b04ac1 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/AutofacUIModule.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/AutofacUIModule.cs @@ -1,5 +1,6 @@ using System; using System.IO; +using Autodesk.Revit.DB; using Autofac; using CefSharp; using Microsoft.Extensions.Logging; @@ -14,13 +15,12 @@ using Speckle.Connectors.Revit.HostApp; using Speckle.Connectors.Revit.Operations.Send; using Speckle.Connectors.Revit.Plugin; +using Speckle.Connectors.Utils.Builders; using Speckle.Connectors.Utils.Operations; using Speckle.Converters.RevitShared.Helpers; using Speckle.Core.Transports; using Speckle.Newtonsoft.Json; using Speckle.Newtonsoft.Json.Serialization; -using IRootObjectSender = Speckle.Connectors.Revit.Operations.Send.IRootObjectSender; -using RootObjectSender = Speckle.Connectors.Revit.Operations.Send.RootObjectSender; namespace Speckle.Connectors.Revit.DependencyInjection; @@ -81,10 +81,10 @@ protected override void Load(ContainerBuilder builder) // send operation and dependencies builder.RegisterType().As().SingleInstance().AutoActivate(); - builder.RegisterType().AsSelf().InstancePerLifetimeScope(); + builder.RegisterType>().AsSelf().InstancePerLifetimeScope(); builder.RegisterType().AsSelf().InstancePerLifetimeScope(); builder.RegisterType().AsSelf().InstancePerLifetimeScope(); - builder.RegisterType().AsSelf().InstancePerLifetimeScope(); + builder.RegisterType().As>().InstancePerLifetimeScope(); builder.RegisterType().As().InstancePerDependency(); builder.RegisterType().As().SingleInstance(); diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/IRootObjectSender.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/IRootObjectSender.cs deleted file mode 100644 index 28611e51b7..0000000000 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/IRootObjectSender.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System; -using Speckle.Core.Models; -using System.Threading.Tasks; -using System.Threading; - -namespace Speckle.Connectors.Revit.Operations.Send; - -/// -/// Contract for the send operation that handles an assembled object. -/// In production, this will send to a server. -/// In testing, this could send to a sqlite db or just save to a dictionary. -/// -public interface IRootObjectSender -{ - public Task Send( - Base commitObject, - string accountId, - string projectId, - string modelId, - Action? onOperationProgressed = null, - CancellationToken ct = default - ); -} diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RootObjectBuilder.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RootObjectBuilder.cs index ae7a094bc8..606c23bae5 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RootObjectBuilder.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RootObjectBuilder.cs @@ -6,11 +6,13 @@ using Autodesk.Revit.DB; using Speckle.Converters.RevitShared.Helpers; using System.Linq; +using Speckle.Connectors.Utils.Builders; +using Speckle.Connectors.Utils.Operations; using Speckle.Core.Logging; namespace Speckle.Connectors.Revit.Operations.Send; -public class RootObjectBuilder +public class RootObjectBuilder : IRootObjectBuilder { // POC: SendSelection and RevitConversionContextStack should be interfaces, former needs interfaces private readonly ISpeckleConverterToSpeckle _converter; @@ -39,7 +41,8 @@ RevitConversionContextStack contextStack } public Base Build( - SendSelection sendSelection, + IReadOnlyList objects, + SendInfo sendInfo, Action? onOperationProgressed = null, CancellationToken ct = default ) @@ -51,25 +54,25 @@ public Base Build( throw new SpeckleException("Family Environment documents are not supported."); } - var objects = new List(); // = _contextStack.Current.Document.Document.GetElements(sendSelection.SelectedItems).ToList(); + var revitElements = new List(); // = _contextStack.Current.Document.Document.GetElements(sendSelection.SelectedItems).ToList(); - foreach (var id in sendSelection.SelectedItems) + foreach (var id in objects) { - var el = _contextStack.Current.Document.Document.GetElement(ElementId.Parse(id)); + var el = _contextStack.Current.Document.Document.GetElement(id); if (el != null) { - objects.Add(el); + revitElements.Add(el); } } - if (objects.Count == 0) + if (revitElements.Count == 0) { throw new InvalidOperationException("No objects were found. Please update your send filter!"); } var countProgress = 0; // because for(int i = 0; ...) loops are so last year - foreach (Element revitElement in objects) + foreach (Element revitElement in revitElements) { ct.ThrowIfCancellationRequested(); @@ -77,16 +80,24 @@ public Base Build( var path = new[] { doc.GetElement(revitElement.LevelId) is not Level level ? "No level" : level.Name, cat }; var collection = GetAndCreateObjectHostCollection(path); - if (_convertedObjectsCache.ContainsBaseConvertedFromId(revitElement.UniqueId)) - { - continue; - } - + var applicationId = revitElement.Id.ToString(); try { - var convertedElement = _converter.Convert(revitElement); - convertedElement.applicationId = revitElement.Id.ToString(); - collection.elements.Add(convertedElement); + Base converted; + if ( + !sendInfo.ChangedObjectIds.Contains(applicationId) + && sendInfo.ConvertedObjects.TryGetValue(applicationId + sendInfo.ProjectId, out ObjectReference value) + ) + { + converted = value; + } + else + { + converted = _converter.Convert(revitElement); + converted.applicationId = applicationId; + } + + collection.elements.Add(converted); } catch (SpeckleConversionException ex) { @@ -94,7 +105,7 @@ public Base Build( } countProgress++; - onOperationProgressed?.Invoke("Converting", (double)countProgress / objects.Count); + onOperationProgressed?.Invoke("Converting", (double)countProgress / revitElements.Count); } return _rootObject; diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RootObjectSender.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RootObjectSender.cs deleted file mode 100644 index 40889e5d55..0000000000 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RootObjectSender.cs +++ /dev/null @@ -1,67 +0,0 @@ -using System; -using Speckle.Connectors.Utils.Operations; -using Speckle.Core.Api; -using System.Threading.Tasks; -using System.Threading; -using Speckle.Connectors.Revit.Plugin; -using Speckle.Core.Credentials; -using Speckle.Core.Models; -using Speckle.Core.Transports; - -namespace Speckle.Connectors.Revit.Operations.Send; - -/// -/// Default implementation of the which takes a and sends -/// it to a server described by the parameters in the method -/// -internal sealed class RootObjectSender : IRootObjectSender -{ - // POC: unsure about this factory pattern - a little weakly typed (being a Func) - private readonly ServerTransport.Factory _transportFactory; - private readonly RevitSettings _revitSettings; - - public RootObjectSender(ServerTransport.Factory transportFactory, RevitSettings revitSettings) - { - _transportFactory = transportFactory; - _revitSettings = revitSettings; - } - - public async Task Send( - Base commitObject, - string accountId, - string projectId, - string modelId, - Action? onOperationProgressed = null, - CancellationToken ct = default - ) - { - ct.ThrowIfCancellationRequested(); - - onOperationProgressed?.Invoke("Uploading...", null); - - Account account = AccountManager.GetAccount(accountId); - - ITransport transport = _transportFactory(account, projectId, 60, null); - var sendResult = await SendHelper.Send(commitObject, transport, true, null, ct).ConfigureAwait(false); - - ct.ThrowIfCancellationRequested(); - - onOperationProgressed?.Invoke("Linking version to model...", null); - - using var apiClient = new Client(account); - string versionId = await apiClient - .CommitCreate( - new CommitCreateInput - { - streamId = projectId, - branchName = modelId, - sourceApplication = _revitSettings.HostSlug, // POC: These naming is a bit? - objectId = sendResult.rootObjId - }, - ct - ) - .ConfigureAwait(true); - - return versionId; - } -} diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/SendOperation.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/SendOperation.cs deleted file mode 100644 index 7db122223f..0000000000 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/SendOperation.cs +++ /dev/null @@ -1,53 +0,0 @@ -using System; -using Speckle.Core.Models; -using System.Threading.Tasks; -using System.Threading; -using Speckle.Connectors.DUI.Models.Card.SendFilter; -using Speckle.Converters.RevitShared.Helpers; - -namespace Speckle.Connectors.Revit.Operations.Send; - -public sealed class SendOperation -{ - private readonly RootObjectBuilder _rootObjectBuilder; - private readonly IRootObjectSender _rootObjectSender; - - public SendOperation(RootObjectBuilder rootObjectBuilder, IRootObjectSender rootObjectSender) - { - _rootObjectBuilder = rootObjectBuilder; - _rootObjectSender = rootObjectSender; - } - - /// - /// Executes a send operation given information about the host objects and the destination account. - /// - /// - /// - /// - /// - /// - /// - /// - public async Task Execute( - ISendFilter sendFilter, - string accountId, - string projectId, - string modelId, - Action? onOperationProgressed = null, - CancellationToken ct = default - ) - { - // POC: have changed this as I don't understand the injecting of the ISendFilter when we can just use it here - // it begs the question whether ISendFilter should just be injected into the roo object builder and whether this function needs it at all? - // this class is now so thing I wonder if it should exist at all? - Base commitObject = _rootObjectBuilder.Build( - new SendSelection(sendFilter.GetObjectIds()), - onOperationProgressed, - ct - ); - - return await _rootObjectSender - .Send(commitObject, accountId, projectId, modelId, onOperationProgressed, ct) - .ConfigureAwait(true); - } -} diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Speckle.Connectors.RevitShared.projitems b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Speckle.Connectors.RevitShared.projitems index d8833efcce..a9821c7eba 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Speckle.Connectors.RevitShared.projitems +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Speckle.Connectors.RevitShared.projitems @@ -28,10 +28,7 @@ - - - CefSharpPanel.xaml diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSendBinding.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSendBinding.cs index 7295f999d8..8d96fc64e2 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSendBinding.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSendBinding.cs @@ -156,15 +156,14 @@ public async Task Send(string modelCardId) .Where(obj => obj != null) .ToList(); - var sendInfo = new SendInfo() - { - AccountId = modelCard.AccountId, - ProjectId = modelCard.ProjectId, - ModelId = modelCard.ModelId, - ConvertedObjects = _convertedObjectReferences, - ChangedObjectIds = modelCard.ChangedObjectIds, - SourceApplication = _rhinoSettings.HostAppInfo.Name - }; + var sendInfo = new SendInfo( + modelCard.AccountId, + modelCard.ProjectId, + modelCard.ModelId, + _rhinoSettings.HostAppInfo.Name, + _convertedObjectReferences, + modelCard.ChangedObjectIds + ); var sendResult = await unitOfWork.Service .Execute( diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/ToSpeckleConvertedObjectsCache.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/ToSpeckleConvertedObjectsCache.cs index bf8a54a384..c4c91d9fb8 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/ToSpeckleConvertedObjectsCache.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/ToSpeckleConvertedObjectsCache.cs @@ -17,4 +17,9 @@ public bool ContainsBaseConvertedFromId(string revitUniqueId) { return _uniqueIdToConvertedBaseDict.ContainsKey(revitUniqueId); } + + public bool TryGetConvertedBase(string revitUniqueId, out Base? value) + { + return _uniqueIdToConvertedBaseDict.TryGetValue(revitUniqueId, out value); + } } diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/RevitConverterToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/RevitConverterToSpeckle.cs index 0a07f8dfba..540cd4ccad 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/RevitConverterToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/RevitConverterToSpeckle.cs @@ -45,17 +45,6 @@ public Base Convert(object target) // POC: is this the right place? result.applicationId = element.UniqueId; - try - { - _convertedObjectsCache.AddConvertedBase(element.UniqueId, result); - } - catch (ArgumentException) - { - // POC: object converted multiple times - // we are doing this all the time in our current converter, and the serializer is fixing it for us. - // so for now, I am just silencing this exception - // https://spockle.atlassian.net/browse/CNX-9402 - } _parameterValueExtractor.RemoveUniqueId(element.UniqueId); } diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/HostedElementConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/HostedElementConversionToSpeckle.cs index 45388c02ee..a5b7cca567 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/HostedElementConversionToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/HostedElementConversionToSpeckle.cs @@ -31,10 +31,6 @@ public IEnumerable ConvertHostedElements(IEnumerable hostedElem foreach (var elemId in hostedElementIds) { Element element = _contextStack.Current.Document.Document.GetElement(elemId); - if (_convertedObjectsCache.ContainsBaseConvertedFromId(element.UniqueId)) - { - continue; - } Base @base; try diff --git a/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/SendInfo.cs b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/SendInfo.cs index 82b80722b9..be5f595a83 100644 --- a/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/SendInfo.cs +++ b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/SendInfo.cs @@ -3,12 +3,30 @@ namespace Speckle.Connectors.Utils.Operations; -public struct SendInfo +public readonly struct SendInfo { - public string AccountId { get; set; } - public string ProjectId { get; set; } - public string ModelId { get; set; } - public string SourceApplication { get; set; } - public Dictionary ConvertedObjects { get; set; } - public HashSet ChangedObjectIds { get; set; } + public SendInfo( + string accountId, + string projectId, + string modelId, + string sourceApplication, + IReadOnlyDictionary convertedObjects, + ISet changedObjectIds + ) + { + AccountId = accountId; + ProjectId = projectId; + ModelId = modelId; + SourceApplication = sourceApplication; + ConvertedObjects = convertedObjects; + ChangedObjectIds = changedObjectIds; + } + + public string AccountId { get; } + public string ProjectId { get; } + public string ModelId { get; } + public string SourceApplication { get; } + public IReadOnlyDictionary ConvertedObjects { get; } + + public ISet ChangedObjectIds { get; } } diff --git a/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/SendOperation.cs b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/SendOperation.cs index 6fa7c7b881..b29e9c9fc0 100644 --- a/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/SendOperation.cs +++ b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/SendOperation.cs @@ -31,7 +31,9 @@ ISyncToMainThread syncToMainThread CancellationToken ct = default ) { - Base commitObject = _rootObjectBuilder.Build(objects, sendInfo, onOperationProgressed, ct); + Base commitObject = await _syncToMainThread + .RunOnThread(() => _rootObjectBuilder.Build(objects, sendInfo, onOperationProgressed, ct)) + .ConfigureAwait(false); // base object handler is separated so we can do some testing on non-production databases // exact interface may want to be tweaked when we implement this From daf2c23ca7d75d3d74dac4442325acc56a264423 Mon Sep 17 00:00:00 2001 From: Claire Kuang Date: Tue, 7 May 2024 06:31:50 -0700 Subject: [PATCH 119/261] feat(autocad): CNX-9417 ACAD align Speckle command name (#3374) changes command to "SpeckleNewUI" --- .../Plugin/AutocadCommand.cs | 2 +- .../Geometry/PolycurveToHostConverter.cs | 8 ++--- .../PolycurveToHostPolylineRawConverter.cs | 29 +++++++++---------- 3 files changed, 16 insertions(+), 23 deletions(-) diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Plugin/AutocadCommand.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Plugin/AutocadCommand.cs index 3619459acb..996dcaa90b 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Plugin/AutocadCommand.cs +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Plugin/AutocadCommand.cs @@ -21,7 +21,7 @@ public class AutocadCommand public AutofacContainer? Container { get; private set; } - [CommandMethod("SpeckleDUI3DX")] + [CommandMethod("SpeckleNewUI")] public void Command() { if (PaletteSet != null) diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/PolycurveToHostConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/PolycurveToHostConverter.cs index 73e87bbd76..6a10f2bbc5 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/PolycurveToHostConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/PolycurveToHostConverter.cs @@ -8,7 +8,7 @@ namespace Speckle.Converters.AutocadShared.ToHost.Geometry; /// /// A polycurve has segments as list and it can contain different kind of ICurve objects like Arc, Line, Polyline, Curve etc.. -/// If polycurve segments is consist of only with Arcs and Lines, it can be represented as Polyline in Autucad. +/// If polycurve segments are planar and only of type and , it can be represented as Polyline in Autocad. /// Otherwise we convert it as spline (list of ADB.Entity) that switch cases according to each segment type. /// [NameAndRankValue(nameof(SOG.Polycurve), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] @@ -45,13 +45,12 @@ public object Convert(Base target) private bool IsPolycurvePlanar(SOG.Polycurve polycurve) { double? z = null; - foreach (var segment in polycurve.segments) + foreach (Objects.ICurve segment in polycurve.segments) { switch (segment) { case SOG.Line o: z ??= o.start.z; - if (o.start.z != z || o.end.z != z) { return false; @@ -60,7 +59,6 @@ private bool IsPolycurvePlanar(SOG.Polycurve polycurve) break; case SOG.Arc o: z ??= o.startPoint.z; - if (o.startPoint.z != z || o.midPoint.z != z || o.endPoint.z != z) { return false; @@ -69,7 +67,6 @@ private bool IsPolycurvePlanar(SOG.Polycurve polycurve) break; case SOG.Curve o: z ??= o.points[2]; - for (int i = 2; i < o.points.Count; i += 3) { if (o.points[i] != z) @@ -81,7 +78,6 @@ private bool IsPolycurvePlanar(SOG.Polycurve polycurve) break; case SOG.Spiral o: z ??= o.startPoint.z; - if (o.startPoint.z != z || o.endPoint.z != z) { return false; diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/PolycurveToHostPolylineRawConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/PolycurveToHostPolylineRawConverter.cs index 1bbe733549..874feb8908 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/PolycurveToHostPolylineRawConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/PolycurveToHostPolylineRawConverter.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.Linq; using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; @@ -25,13 +26,14 @@ public PolycurveToHostPolylineRawConverter( public ADB.Polyline RawConvert(SOG.Polycurve target) { ADB.Polyline polyline = new() { Closed = target.closed }; - var plane = new AG.Plane( - AG.Point3d.Origin, - AG.Vector3d.ZAxis.TransformBy(_contextStack.Current.Document.Editor.CurrentUserCoordinateSystem) - ); + AG.Plane plane = + new( + AG.Point3d.Origin, + AG.Vector3d.ZAxis.TransformBy(_contextStack.Current.Document.Editor.CurrentUserCoordinateSystem) + ); int count = 0; - foreach (var segment in target.segments) + foreach (Objects.ICurve segment in target.segments) { switch (segment) { @@ -46,12 +48,13 @@ public ADB.Polyline RawConvert(SOG.Polycurve target) break; case SOG.Arc arc: // POC: possibly endAngle and startAngle null? - var angle = arc.endAngle - arc.startAngle; + double? angle = arc.endAngle - arc.startAngle; angle = angle < 0 ? angle + 2 * Math.PI : angle; if (angle is null) { throw new ArgumentNullException(nameof(arc), "Cannot convert arc without angle value."); } + var bulge = Math.Tan((double)angle / 4) * BulgeDirection(arc.startPoint, arc.midPoint, arc.endPoint); polyline.AddVertexAt(count, _pointConverter.RawConvert(arc.startPoint).Convert2d(plane), bulge, 0, 0); if (!target.closed && count == target.segments.Count - 1) @@ -62,12 +65,13 @@ public ADB.Polyline RawConvert(SOG.Polycurve target) count++; break; case SOG.Spiral o: - var vertices = o.displayValue.GetPoints().Select(_pointConverter.RawConvert).ToList(); - foreach (var vertex in vertices) + List vertices = o.displayValue.GetPoints().Select(_pointConverter.RawConvert).ToList(); + foreach (AG.Point3d vertex in vertices) { polyline.AddVertexAt(count, vertex.Convert2d(plane), 0, 0, 0); count++; } + break; default: break; @@ -87,13 +91,6 @@ private int BulgeDirection(SOG.Point start, SOG.Point mid, SOG.Point end) // calculate cross product z direction double z = v1[0] * v2[1] - v2[0] * v1[1]; - if (z > 0) - { - return -1; - } - else - { - return 1; - } + return z > 0 ? -1 : 1; } } From f58755438b359bbd0ce6f394b365c5cd183f0460 Mon Sep 17 00:00:00 2001 From: Mucahit Bilal GOKER <51519350+bimgeek@users.noreply.github.com> Date: Tue, 7 May 2024 16:45:16 +0300 Subject: [PATCH 120/261] replaced button icon with new icon (#3373) --- .../Assets/logo16.png | Bin 591 -> 714 bytes .../Assets/logo32.png | Bin 1275 -> 1672 bytes 2 files changed, 0 insertions(+), 0 deletions(-) diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Assets/logo16.png b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Assets/logo16.png index 7ab056643e927d2d336b939c446ac93aca12ab47..61872f0d0cc34673152721968f5b93ef13aff8b4 100644 GIT binary patch delta 691 zcmV;k0!;nS1j+@FBYyw^b5ch_0Itp)=>Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi z!vFvd!vV){sAK>D0$)i)K~y+Tm6KgaQ(+j#hi=(LS5CY!VNB>kidYw2RM5q!h#*C~ zjYbsGT}U7MaL1G8SD9L~v5(5sEMkL2geW^T1qF-NQcI;>On)rX<<=UO+c|FUzw;hx zMVmnfe!MTw^Sr*itN@ZX5SdYNW_08~=Zy@ulh1c!SG4&F^mXsoFW>W&SR&A*W|>yQML zqO&Vf;1|lKxPP>kG(~XI;mgEJ+aj4gC8xm7+2ETnO8eHQqlnM6J$y@j-xp34f4JqTn--4g!fWV09S6$J?+x zY{}h$rgH(a({`kiqvBz|cz8;Lb|J3mH%NYcjGku>C>u70oO1^1)+J26x(M>UTYQ2W zSoZ+QeylI+p&xjVsml^57y$(=k1h2)Z2cyrLRye;1=3%tkX|~9gkOVQt+OZ)^RzBY zKm!V9BY*L(Z!eNQ6;@xUu=so@*2Yx$F}xk;ZaSrl=p{J?lpPHpuwpI7oV^^?*FC6l zx^T;K9?^Tn=(C>A)NLv#X2Ym$>p&qJg|>47L9SYg@3|U)u04AO?B9YvY3ORi;vF^0 z8)tInr9X1_fk0(pO(Z5a3$c8&FfYLfZ}S;`L@dtmPvqw0eTu@&cjcRTmXcS;>+`|3J_Mk|1ai1Z|3lKw7md!5|0(F~~A)GNT!rn>jPzyzkq>F(}HE z&gPuW^E-E$NEsPR;)@2wKb|5Kts<1j5{*`|W+u=2YCmDSq>QX!{8AQZS}%;7y1S@k4EkCD>$)J5w8{w+|x{D zELVFxD{En3*s$ehnf?w%b5s}@HcJcCtO8XzrM7xO$-gK%!I;>vSFrT|-G5cEN&_y>VQt$#wg0JTA3do5%OaBWDlCoWv> zR%DBo-Y1&rT&03Yjg$L4Q?iQ!7oQmdUYIK_JcI$Xfx{0pQfcLvJ2-o4!~M?oaIaEm z09Qk%0A&NNS%3iqtbq1;D0&t7ppTSCG4Jf&6}GQO@^@1YGaJ8#IN21D@sAlh(HfJf z_p|oXjxaizd6Trsu1zvK@`dcd7RkR%*uv=!RXX!j>mM&W)=aIYYOMeO002ovPDHLk FV1k{N3labT diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Assets/logo32.png b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Assets/logo32.png index 68120fdabaeb3ef50919ed4ec900af89ac1cb6a8..2ad0c346ea7ebd9e0fbe930f269055e7964fc786 100644 GIT binary patch delta 1656 zcmV-;28a3k35X4lBYyw^b5ch_0Itp)=>Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi z!vFvd!vV){sAK>D1|3O6K~z{rwU-G@R96&+O%<%&Z9zq9i`uxfRV1w@)f!RJHfdt8 zB8_#!q@=W|+NN0R!YU|=84)N9%1*6fT~HBGs7?_VP#8cIfq%*>JHy}%$h=wJ-*abp z10$mhO})vNd*|G9&-vfG=iQqbHdxzw0S-p8;H)Pb9s=94;LrH=A|JLRi%(!|&*rZ% zwq^5D>Z=($vVrYcd^L;H8`{u3#g9%43j}9!l(PlTg8?F(=1H+SsMW0V^MXC#wrsc> z1u)!qHkoyPo`2BW_A?4#eChqrtYd$?Gl3t@^Ljkb@K}42hkGiIWk(DwP2#a2PN&By zN^4}2$iQ2>`xxP?fr$Wyw4>vg5@9T4ZInc1+|7L&y2e%rtj?arB3s{km2b-Wr zCbs2Kd1#cZf>+!n6Z@-ykFhE_-^BJL77MTm?nI&_27g?`TKshEw8@RzBR4lVgV zV^lz&-7T>I>gG*IzZrpvdz($x2v{uOrqmlf_3r3-;EL5>H@AH862cJx-nb1)Vn+V0BCeto<}- zE8h?3>PWyN>Ko8qy&vz3I`E086rDF*a3#YF4!ax7#$yb*2(A6pSS8NDjL-_KODqB} zKSs&hiB3XBI?}M?_yvp&YJ=C|RE+XhnT;bbsDFUh1G_OfREC+NR?G=+!ouh}xW-n% zBjqlNOT>V>#E=*r2DJB3R~e2UkKe}n#&J$3SZA4b)R*Vmp4Tx=#0EQLeeIy-Cg&yFVLx7$WwAbk*gsw;J zB}$lO=-F>g2GvIz)a@Zq+*yH;RKwX|j%NyBNv(X&i%b;udo(>=qqJKI} z$$lsPAW}#e6&=}i?cYIF>VnOQ$BpsK@k{|D{Wy%I6HN~r6K@7|LMd^C=AR{0;VZ$* z*3entL2Mw_gYQ@czReAqDi=JyJ`+pAa$!y4O=1yNbe;?vhzW}<23!!aTLK*h8Lfhpr2D=*b)h#eWGqv>kny zwynb?M*olZMu)v1pC7MRSxLA`foDn1EKiK__PZm2WUxR1TW}8N5Xz zG##=>d#o+m6UM;%V3^r>jDH~sSh@R8wEQ*}=faj@ZtxAGeT7&8uE-g&XCsWZ$$<}$ z9Jv8)32(#eK%CM3BtsHlO~p7qVBp;@PV@zLaVF}{Ey0WZ3XEanKk)SH4-?>TsQ`1Z zgf(%~A&Z}Y*0>394#_p^_cZkXjvPOgx;o7*l>Zk2({@#$NIV95-y zdI79CE|5An%`2=PssM}eQOk$>sB852auUV}UoNdTy`eD?6Wr^n*@8Z2b&+v_k1CO2 z<->&y_u>2*FYM$z1cv)*oEanidK?6LLqDYr8}={JV2_00^FF%(0000#Y(_;BlAz~RktucIU zab46A$G0dfLR|^UBPl()D?#~Pm7*e+A$%dD!?6rCshlX6LOb)uiv>%jil+YhMbpug zbrySmG%rh|X&tHwiBLLE=wg<#i&;v8wjPyLBA8S7a}EJR;#V45xmd2oQW{HZjNu#s zD6;5!aDslMx_?CcUR@#z0A7EywW=k;kts`SLc$R8Y82gwcnsnTYgv46HHUnbKxz$t zHOGQY4JWfIho?*r5s21jb3z7DeZ~w<9vvZ%mBWD$RJXca8Kxxp* zMK~@}2%Xa!C##Uj93HK8Rzo(GN5<0lvP!!^CgUJt8GpR#Jl5yUY&9j{n*9~WBU$@E z!>R1#)sv!W)1)VhCzjDZ0cqvpByyOsjP{|)yBa6$U?lU{j*AU=(4av8MZI5t@eUgM z0cj5QuIGHtZakdJM{F7BHys$XZ79-->q*IolkPTv+W`Le0L&X#F|>G12-@Jd5YK?C zZxMjWWq*RrOC$?w1VvWCaOXvMcb`jrlY1GEn+jlNrC{$f20p8AP70_lf%le5CYHi0 zd)xtMZYl>pS}rdcKhdpO-{|s9OP|Zn&z2P1BNPEkf@Q$5E=@8It9B~dVzBKnoO{j0 zHo;>+z=ode2mr{tFl&ptG_DB1)X{>qvjldpm4CyXnsbQ}iojsmwc21#RiQsQE^I&I zvSGK28c2bWs{_ew@1+4SB|J4#^7C4QG5+fWU`Ysv1aeT*Ew98qrEQ7o$$$Jd)sXVEGheXg8Nxz3=drZeFgW~*HKe39S zIRC?GH#T9Eh)*gL7bcbxuWxdDMqw9;+ S7NY?G0000 Date: Tue, 7 May 2024 17:22:36 +0200 Subject: [PATCH 121/261] CNX-9420 - Fix Speckle panel name and icons (#3376) * feat: Update Rhino panel, icons and plugin assembly info * fix: CI warning about NeutralResourcesLanguage --- .../Speckle.Connectors.Rhino7Command.cs | 7 +- .../Plugin/Speckle.Connectors.Rhino7Plugin.cs | 1 + .../Properties/AssemblyInfo.cs | 13 +- .../Properties/Resources.Designer.cs | 83 ++++++++++++ .../Properties/Resources.resx | 127 ++++++++++++++++++ .../Resources/logo32.png | Bin 0 -> 1698 bytes .../Resources/speckle32.ico | Bin 0 -> 4286 bytes .../Speckle.Connectors.Rhino7.csproj | 36 +++-- 8 files changed, 249 insertions(+), 18 deletions(-) create mode 100644 DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Properties/Resources.Designer.cs create mode 100644 DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Properties/Resources.resx create mode 100644 DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Resources/logo32.png create mode 100644 DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Resources/speckle32.ico diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Plugin/Speckle.Connectors.Rhino7Command.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Plugin/Speckle.Connectors.Rhino7Command.cs index 6bfe6166a9..751213cb0e 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Plugin/Speckle.Connectors.Rhino7Command.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Plugin/Speckle.Connectors.Rhino7Command.cs @@ -1,9 +1,10 @@ -using System; +using System; using Rhino; using Rhino.Commands; using Rhino.Input.Custom; using Rhino.UI; using Speckle.Connectors.Rhino7.HostApp; +using Speckle.Connectors.Rhino7.Properties; namespace Speckle.Connectors.Rhino7.Plugin; @@ -17,8 +18,8 @@ public SpeckleConnectorsRhino7Command() Panels.RegisterPanel( SpeckleConnectorsRhino7Plugin.Instance, typeof(SpeckleRhinoPanelHost), - "SpeckleRhino7DUI3", - System.Drawing.SystemIcons.Information, + "Speckle (New UI)", + Resources.speckle32, PanelType.System ); } diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Plugin/Speckle.Connectors.Rhino7Plugin.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Plugin/Speckle.Connectors.Rhino7Plugin.cs index 0fcc3e9121..a4abed8dc4 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Plugin/Speckle.Connectors.Rhino7Plugin.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Plugin/Speckle.Connectors.Rhino7Plugin.cs @@ -25,6 +25,7 @@ public class SpeckleConnectorsRhino7Plugin : PlugIn { private IRhinoPlugin? _rhinoPlugin; + protected override string LocalPlugInName => "Speckle (New UI)"; public AutofacContainer? Container { get; private set; } public SpeckleConnectorsRhino7Plugin() diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Properties/AssemblyInfo.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Properties/AssemblyInfo.cs index 88eada7ed2..abbb317629 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Properties/AssemblyInfo.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Properties/AssemblyInfo.cs @@ -1,20 +1,23 @@ -using System.Runtime.InteropServices; +using System.Resources; +using System.Runtime.InteropServices; using Rhino.PlugIns; // Plug-in Description Attributes - all of these are optional. // These will show in Rhino's option dialog, in the tab Plug-ins. [assembly: PlugInDescription(DescriptionType.Address, "")] [assembly: PlugInDescription(DescriptionType.Country, "")] -[assembly: PlugInDescription(DescriptionType.Email, "")] +[assembly: PlugInDescription(DescriptionType.Email, "hello@speckle.systems")] [assembly: PlugInDescription(DescriptionType.Phone, "")] [assembly: PlugInDescription(DescriptionType.Fax, "")] -[assembly: PlugInDescription(DescriptionType.Organization, "")] +[assembly: PlugInDescription(DescriptionType.Organization, "Speckle Systems Ltd.")] [assembly: PlugInDescription(DescriptionType.UpdateUrl, "")] -[assembly: PlugInDescription(DescriptionType.WebSite, "")] +[assembly: PlugInDescription(DescriptionType.WebSite, "https://speckle.systems")] // Icons should be Windows .ico files and contain 32-bit images in the following sizes: 16, 24, 32, 48, and 256. -[assembly: PlugInDescription(DescriptionType.Icon, "Speckle.Connectors.Rhino7.EmbeddedResources.plugin-utility.ico")] +[assembly: PlugInDescription(DescriptionType.Icon, "Speckle.Connectors.Rhino7.Resources.speckle32.ico")] // The following GUID is for the ID of the typelib if this project is exposed to COM // This will also be the Guid of the Rhino plug-in [assembly: Guid("2153799A-0CEC-40DE-BC3A-01E5055222FF")] + +[assembly: NeutralResourcesLanguage("en")] diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Properties/Resources.Designer.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Properties/Resources.Designer.cs new file mode 100644 index 0000000000..ec3cee7dbb --- /dev/null +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Properties/Resources.Designer.cs @@ -0,0 +1,83 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Speckle.Connectors.Rhino7.Properties { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Speckle.Connectors.Rhino7.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap logo32 { + get { + object obj = ResourceManager.GetObject("logo32", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Icon similar to (Icon). + /// + internal static System.Drawing.Icon speckle32 { + get { + object obj = ResourceManager.GetObject("speckle32", resourceCulture); + return ((System.Drawing.Icon)(obj)); + } + } + } +} diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Properties/Resources.resx b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Properties/Resources.resx new file mode 100644 index 0000000000..61bb1d8964 --- /dev/null +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Properties/Resources.resx @@ -0,0 +1,127 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + ..\Resources\logo32.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\speckle32.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + \ No newline at end of file diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Resources/logo32.png b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Resources/logo32.png new file mode 100644 index 0000000000000000000000000000000000000000..39074dca39a379ec5061947ccedeb255922eeb5c GIT binary patch literal 1698 zcmV;T23`4yP)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!vFvd!vV){sAK>D1|3O6K~z{rwU-G@ zR96&+O%<%&Z9zq9i`uxfRV1w@)f!RJHfdt8B8_#!q@=W|+NN0R!YU|=84)N9%1*6f zT~HBGs7?_VP#8cIfyyd7!{7|ayjkAgb7y!1BclvWy~&q*=iGD8`QN+e-J2OUSlfC5 z4o0%ztS1{D0^73S&-nEsAGRZlPhf1%=C3feW%E+%s~J18f$dp*HH*_5+R!}3k4_5< z1ZQ%TvjxwC0V15{NwGSp)vWXLf<552Y`7W)Fx+=GnRR}i(A)Mi3SfNc{m`sqf4nn+ zAI|f7JkRi0dy*T$0}w?6k?8^y*%qF%B*HKVwutpWQ970P5yVNWU3@iF=z()(BWE;HK0Y zJ@xMBdEkocxf_l4S)yj>YWD%!I`ECrSRG$xoJ*1;iegXBZdUuD8dep8~pa0my;Jw~+ByjNbl|KL`2Ub?7Q_Lt~yBmPh|> z5>H@AH862cJx-nb1)Vn+V0BCeto<}-E8h?3>PWyN>Ko8qy&vz3I`E086rDF*a3#YF z4!ax7#$yb*2(A6pSS8NDjL-_KODqB}KSs&hiB3XBI?}M?_yvp&YJ=C|RE+XhnT;bb zsDRf4yD>RbhMA&P%n5J8!st4<##X>1)YG608OoObmnBYKUs`dqDo>P*Z_+RYjm(vKW*0JhV&zV`4}PawNg%d?12K zaTz*w9=&EM1-?TG?hzygDDbG#-8s?HNolx;*-=2nakmJNt)kpPAj z;e8|>O@$udnnQq|6SUXqB!sRW$4*&O$OCR8r1C}P~2I8kW|CjV2)=BU`eff z)kc_YNn{CR1VnOQ$BpsK@k{|D{Wy%I z6HN~r6K@7|LMd^C=AR{0;VZ$**3entL2Mw_gYQ@czReAqDi=JyJ`+pAa$!y4O=1yN zbe;?vhzW}<23!!aTLuc)~K;)jkHB`lpP`uZo-&= zR=hzcX8x6LFk4g(n*bTSMItmEvPXNYE!q>t!24jB*?5d030S%NPqh3t7U#m2VQ%mZ zqkV-~0p+~*{v<;ZU`@q1K49S8E>83XcX1}_&Mm=< z{R)g><3I59>kkv)Z>a!tu!J>n(;-RMD|Bf6#mAX33EtLNk0n>I> zph!F$#o~`4rQS32>95-ydI79CE|5An%`2=PssM}eQOk$>sB852auUV}UoNdTy`eD? z6Wr^n*@8Z2b&+v_k1CO2<->&y_u>2*FYM$z1cv)*oEanidK?6LLqDYr8}={JV2_00 s^FF%(000hUSV?A0O#mtY000O800000007cclK=n!07*qoM6N<$g7TOXV*mgE literal 0 HcmV?d00001 diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Resources/speckle32.ico b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Resources/speckle32.ico new file mode 100644 index 0000000000000000000000000000000000000000..87c4f4210757dfcae5269ad2ce896e11edf294fd GIT binary patch literal 4286 zcmcha3s6*57{}M}(bKd*MKVzvAC(WLbSBLK6|I?O91XNFUpNz!HK{dWe2AU64L=@6Z@Bu1|h$4_If+(+LaRJ%8kNfXC%bs;N1%(_h^WXp3bI$#K-*?Zs zcP|o2FZy$Il(0`p>HvvkkVGOGOQJ4`3yJj`4;stq-=U5U>rc7!M8~Ry!xTE--q8Bk zR2t=LQz-b_$e1)fy%U%OpFZJ&kBz@k8(;DeOw#$;xG=T*^>gI1CUpLdu?wa-DJtC^ z!T8TxTA$u3UK6iJ@a>((GLnBfabCexCzX7f6S~VU+cXxFqYLqI^fhuh;=(+;l{+#0 z8JDZOe2w4B7#CNGVev`~i>pU&s7rVGX7=5=%Ls{TJi7GUsib(kA|92bM9n&Zl%-QZFvVAru&bKmX2QCJa?gm?Bf zAa46gbN~P0r){2(!IAZ_i>QZvWGz)8g|nD6tWC$uyp% z!jMEIE`(0+F<_XsQ}RPiQdYSPSfrsNir|3D^DS;c&DG_US6vpKQgD z%y!rxRAYEb1DXQfvWj6Dldn5>%k^jTG=BXcSmdxaVkd^DwP5rmEyfh+Fh;Jyn5(TA zb487@@-~bu5-_?*hmn`HcsHXJZpoQuw&2&-7*9ja_W|c}x8y&XPdS**IkbH-MrE|% zqhcMVDGYF~HekkG17_Cf;ZkG3bZSq%W5A?hE#5oRhKLw%Ba59cuv$!dHa^YwH_3Ef zGhNGxvKGw#M~4OVB9(|kBXKTR4axRLPjk#Bq_`c47&{klN2KZe7{vaijV%uTt|E|#h*J2G0B&;!C zYhJUZb1rvlzUA*gAEfW|f=9u9gw_f;NSt&nkf{ewld=pQ&c0{pfHcY_v{4JU>uSX8 z5A8Gu&gK3jzBcf6BpnXN+M6n*DBF=O7?4Api^R+qfy)4{n8ez7)W^oo=|miC)?ihM z8s3>%PzFE#?BrbT|K-<(jzF;N9Hh6KaYn5{p4I?4v9A;3Cb4djN=aoVXKkhu5*sgK zd9(=#t5C!9Tsdw@r&wJJ&gE{&R|gKn@-sKEwY&wnEm{-`B52#=7R4+leg(z9L#i^V znw*LCRgx5>+cd9~=3joO#jc80%#tk zH6nJ?zE4pB=V^_rDSjPsxN4|fK>Olo3$U+=_9M;Rbr0A=Nv$c?W7b&}6k9)dCO+Gz zZGmq>88!;_(h0b~a|)`WW}qx~9&RLiAiC%piio8oCZUYFNo%vSyb4zi{D|vG%Z+oZ zqg>FiYcf>fdEMMC>$kj5cw0-)k&Ng?C<_~p!h~f=rF*`S*v%xCN7@76 zQ8V#XUMXC!wcxX>Dl`TUG1hfBJqEe- z9HQ+&dkl#AE5q0?_`ix}H&k#hYK42=J^URt|B2UubGdiM_mW@2!s>R+yWNgexfjf_ zYNeB~m7e!iwC+*&M3ltSb)j`-N|YsHWwjO_747);av53!`k9BA3VGb#w2mem?(sJLht*Trv^*o#UXFj)Z=z1N0$p zcPQ|+F6-!NUYyJPuGg19_J*#N=>_q`4;?z{3GvWUi2D~p+&8yFiF06xb2dsJ=>)S_ zJxshFa+Wja-`}{fYwpwX>cO~}z21-U>w^}*P_~%0UWM#+^Vt7>528JfP#$MZQjjY; z#-FkdJ*bzhEyY&gq_-nuKg+@9nw9140;X(l53{n?`GX{$`ZZk4+OXFsb3N - + + - - - - + + + + - - - - - + + + + + + + + + + True + True + Resources.resx + + + + + + ResXFileCodeGenerator + Resources.Designer.cs + From c62a2ba6ba4986004289149f41c74ff13039ad73 Mon Sep 17 00:00:00 2001 From: Alan Rynne Date: Tue, 7 May 2024 17:55:16 +0200 Subject: [PATCH 122/261] bonus: Remove some DUI3 project warnings, excluding the ones related to nullability (#3377) fix: Remove DUI3 project warnings, excluding the ones related to nullability --- .../Bindings/ArcGISSendBinding.cs | 2 +- .../Bindings/RhinoSendBinding.cs | 2 +- .../DUI3/Speckle.Connectors.DUI/Bindings/IBinding.cs | 2 +- .../Speckle.Connectors.DUI/Bridge/BrowserBridge.cs | 11 ++++------- .../Speckle.Connectors.DUI/Models/Card/ModelCard.cs | 1 + .../Speckle.Connectors.DUI/Settings/CardSetting.cs | 3 ++- .../Utils/DiscriminatedObject.cs | 2 +- .../Utils/DiscriminatedObjectConverter.cs | 5 +---- Directory.Build.props | 2 +- 9 files changed, 13 insertions(+), 17 deletions(-) diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISSendBinding.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISSendBinding.cs index 79d393375a..b8abea01bd 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISSendBinding.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISSendBinding.cs @@ -2,7 +2,6 @@ using Speckle.Autofac.DependencyInjection; using Speckle.Connectors.DUI.Bindings; using Speckle.Connectors.DUI.Bridge; -using Speckle.Connectors.DUI.Utils; using Speckle.Connectors.ArcGis.Operations.Send; using Speckle.Connectors.Utils.Cancellation; using Speckle.Core.Logging; @@ -10,6 +9,7 @@ using Speckle.Connectors.ArcGIS.Utils; using Speckle.Connectors.DUI.Models.Card; using Speckle.Connectors.DUI.Models.Card.SendFilter; +using Speckle.Connectors.DUI.Settings; namespace Speckle.Connectors.ArcGIS.Bindings; diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSendBinding.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSendBinding.cs index 8d96fc64e2..33adb7f6b0 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSendBinding.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSendBinding.cs @@ -8,7 +8,6 @@ using Speckle.Connectors.DUI.Bridge; using Speckle.Connectors.DUI.Models; using Speckle.Connectors.DUI.Models.Card; -using Speckle.Connectors.DUI.Utils; using Speckle.Connectors.Rhino7.HostApp; using Speckle.Connectors.Utils.Cancellation; using Speckle.Core.Logging; @@ -19,6 +18,7 @@ using Speckle.Connectors.DUI.Models.Card.SendFilter; using Speckle.Connectors.Utils.Operations; using Speckle.Core.Models; +using Speckle.Connectors.DUI.Settings; namespace Speckle.Connectors.Rhino7.Bindings; diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/IBinding.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/IBinding.cs index 88382706cb..bfaacb7c7c 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/IBinding.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/IBinding.cs @@ -16,7 +16,7 @@ public interface IBinding /// /// Bindings will be wrapped by a browser specific bridge, and they will need - /// to use that bridge to send events to the Frontend, via SendToBrowser(IHostAppEvent) or SendToBrowser(string). + /// to use that bridge to send events to the Frontend, via SendToBrowser(IHostAppEvent). /// TODO: we'll probably need a factory class of sorts to handle the proper wrapping. Currently, on bridge instantiation the parent is set in the bindings class that has been wrapped around. Not vvv elegant. /// public IBridge Parent { get; } diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/BrowserBridge.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/BrowserBridge.cs index 276556a18e..c5cfb065cc 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/BrowserBridge.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/BrowserBridge.cs @@ -71,9 +71,10 @@ private struct RunMethodArgs } /// - /// Creates a new bridge. + /// Initializes a new instance of the class. /// - /// The actual binding class. + /// The settings to use for JSON serialization and deserialization. + /// The factory to create a logger for . public BrowserBridge(JsonSerializerSettings jsonSerializerSettings, ILoggerFactory loggerFactory) { _serializerOptions = jsonSerializerSettings; @@ -119,7 +120,6 @@ Action showDevToolsAction } ); - // _logger.LogInformation("Bridge bound to front end name {FrontEndName}", binding.Name); } @@ -212,13 +212,10 @@ private void ExecuteMethod(string methodName, string requestId, string args) var resultTyped = method.Invoke(Binding, typedArgs); - // Was it an async method (in bridgeClass?) - var resultTypedTask = resultTyped as Task; - string resultJson; // Was the method called async? - if (resultTypedTask == null) + if (resultTyped is not Task resultTypedTask) { // Regular method: no need to await things resultJson = JsonConvert.SerializeObject(resultTyped, _serializerOptions); diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/ModelCard.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/ModelCard.cs index 29be3e792e..e883ff8d22 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/ModelCard.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/ModelCard.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using Speckle.Connectors.DUI.Settings; using Speckle.Connectors.DUI.Utils; namespace Speckle.Connectors.DUI.Models.Card; diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Settings/CardSetting.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Settings/CardSetting.cs index 5ce5fd83fb..b7cc2bf382 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Settings/CardSetting.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Settings/CardSetting.cs @@ -1,6 +1,7 @@ using System.Collections.Generic; +using Speckle.Connectors.DUI.Utils; -namespace Speckle.Connectors.DUI.Utils; +namespace Speckle.Connectors.DUI.Settings; public class CardSetting : DiscriminatedObject { diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Utils/DiscriminatedObject.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Utils/DiscriminatedObject.cs index b7385bbff6..e0d341c6b6 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Utils/DiscriminatedObject.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Utils/DiscriminatedObject.cs @@ -2,7 +2,7 @@ namespace Speckle.Connectors.DUI.Utils; /// /// Any polymorphic type base should inherit from this class in order for it to be properly deserialized. -/// - Class inheritance scenario For example, if you have a base class BaseSettings, and from it you create RhinoBaseSettings & AutocadBaseSettings, the BaseSetting class should inherit from this class. +/// - Class inheritance scenario For example, if you have a base class BaseSettings, and from it you create RhinoBaseSettings and AutocadBaseSettings, the BaseSetting class should inherit from this class. /// - Interface scenario: you have an ISenderCard interface, which you implement as ReceiverCard and SenderCard. Both ReceiverCard and SenderCard should inherit from this class. /// /// POC: should probaby be changed to attribute instead of inheritence? TBC diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Utils/DiscriminatedObjectConverter.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Utils/DiscriminatedObjectConverter.cs index faca3fe869..42d6bd145b 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Utils/DiscriminatedObjectConverter.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Utils/DiscriminatedObjectConverter.cs @@ -11,8 +11,7 @@ namespace Speckle.Connectors.DUI.Utils; /// -/// This converter ensures we can do polymorphic deserialization to concrete types. It is automatically added to all -/// serialization settings from . This converter is intended +/// This converter ensures we can do polymorphic deserialization to concrete types. This converter is intended /// for use only with UI bound types, not Speckle Bases. /// // POC: automatic registration of compatible objects @@ -85,8 +84,6 @@ JsonSerializer serializer // then we can cache everything on startup foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies().Reverse()) { - List? types; - try { // POC: contains is weak diff --git a/Directory.Build.props b/Directory.Build.props index 186b4c439e..1e72e65133 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -38,7 +38,7 @@ CA1303;CA1304;CA1305;CA1307;CA1308;CA1309;CA1310;CA1311;CA2101; NU1701; - CA1815;CA1054;CA1852;CA1812;CA1003;CA2109;$(NoWarn) + CA1815;CA1054;CA1852;CA1812;CA1003;CA2109;CA1848;$(NoWarn) From 312876e9ce3f98647999b7e0763233dd8e6b7e74 Mon Sep 17 00:00:00 2001 From: Claire Kuang Date: Tue, 7 May 2024 10:22:06 -0700 Subject: [PATCH 123/261] fix(autocad): polyline3d splines had incorrect displayvalue (#3378) fixes display value for polyline3d splines --- .../Geometry/Polyline2dToSpeckleConverter.cs | 2 +- .../Geometry/Polyline3dToSpeckleConverter.cs | 60 +++++++++---------- 2 files changed, 31 insertions(+), 31 deletions(-) diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/Polyline2dToSpeckleConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/Polyline2dToSpeckleConverter.cs index 9902877848..9091a7b06d 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/Polyline2dToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/Polyline2dToSpeckleConverter.cs @@ -156,7 +156,7 @@ public SOG.Autocad.AutocadPolycurve RawConvert(ADB.Polyline2d target) } } - // for splines, convert the spline curve and display value and add to the segments list and + // for splines, convert the spline curve and display value and add to the segments list if (isSpline) { SOG.Curve spline = _splineConverter.RawConvert(target.Spline); diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/Polyline3dToSpeckleConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/Polyline3dToSpeckleConverter.cs index 346a6f2729..fff827612e 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/Polyline3dToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/Polyline3dToSpeckleConverter.cs @@ -4,7 +4,6 @@ using Speckle.Core.Models; using Speckle.Converters.Autocad.Extensions; using System.Linq; -using Autodesk.AutoCAD.Geometry; namespace Speckle.Converters.Autocad.Geometry; @@ -12,7 +11,7 @@ namespace Speckle.Converters.Autocad.Geometry; /// The class converter. Converts to . /// /// -/// of type will have only s in . +/// of type will have only one in . /// of type and will have only one in . /// The IHostObjectToSpeckleConversion inheritance should only expect database-resident Polyline2d objects. IRawConversion inheritance can expect non database-resident objects, when generated from other converters. /// @@ -65,53 +64,54 @@ public SOG.Autocad.AutocadPolycurve RawConvert(ADB.Polyline3d target) ) .Where(e => e.VertexType != ADB.Vertex3dType.FitVertex) // Do not collect fit vertex points, they are not used for creation .ToList(); - - List segments = new(); for (int i = 0; i < vertices.Count; i++) { - Point3d vertex = vertices[i].Position; + // vertex value is in the Global Coordinate System (GCS). + value.AddRange(vertices[i].Position.ToArray()); + } - // get vertex value in the Global Coordinate System (GCS). - value.AddRange(vertex.ToArray()); + List segments = new(); + // for spline polyline3ds, get the spline curve segment + // and explode the curve to get the spline displayvalue + if (target.PolyType is not ADB.Poly3dType.SimplePoly) + { + // get the spline segment + SOG.Curve spline = _splineConverter.RawConvert(target.Spline); - // construct the segment lines if this is a simple poly - if (i < vertices.Count - 1) + // get the spline displayvalue by exploding the polyline + List segmentValues = new(); + ADB.DBObjectCollection exploded = new(); + target.Explode(exploded); + for (int i = 0; i < exploded.Count; i++) { - if (polyType is SOG.Autocad.AutocadPolyType.Simple3d) + if (exploded[i] is ADB.Curve segment) { - var nextVertex = vertices[i + 1].Position; - SOG.Point start = _pointConverter.RawConvert(vertex); - SOG.Point end = _pointConverter.RawConvert(nextVertex); - - SOG.Line segment = new(start, end, _contextStack.Current.SpeckleUnits); - segments.Add(segment); + segmentValues.AddRange(segment.StartPoint.ToArray()); + if (i == exploded.Count - 1) + { + segmentValues.AddRange(segment.EndPoint.ToArray()); + } } } - } - // get the spline curve segment if this is a spline polyline3d - if (polyType is not SOG.Autocad.AutocadPolyType.Simple3d) - { - // add first 3 coordinate to last for display value polyline for spline - if (target.Closed) + SOG.Polyline displayValue = segmentValues.ConvertToSpecklePolyline(_contextStack.Current.SpeckleUnits); + if (displayValue != null) { - var firstPoint = value.Take(3).ToList(); - value.AddRange(firstPoint); + spline.displayValue = displayValue; } - SOG.Curve spline = _splineConverter.RawConvert(target.Spline); - spline.displayValue = value.ConvertToSpecklePolyline(_contextStack.Current.SpeckleUnits); - segments.Add(spline); } + // for simple polyline3ds just get the polyline segment from the value else { + SOG.Polyline polyline = value.ConvertToSpecklePolyline(_contextStack.Current.SpeckleUnits); if (target.Closed) { - SOG.Point start = _pointConverter.RawConvert(vertices.First().Position); - SOG.Point end = _pointConverter.RawConvert(vertices.Last().Position); - segments.Add(new SOG.Line(start, end, _contextStack.Current.SpeckleUnits)); + polyline.closed = true; } + + segments.Add(polyline); } SOG.Box bbox = _boxConverter.RawConvert(target.GeometricExtents); From 66e53aa594c9d50fefcc2c37c4730b4c1eb12cd7 Mon Sep 17 00:00:00 2001 From: Alan Rynne Date: Wed, 8 May 2024 11:19:58 +0200 Subject: [PATCH 124/261] fix: REVIT - Removed any warnings not related to nullability (#3382) fix: Removed all warnings not related to nullability --- .../Bindings/ReceiveBinding.cs | 144 ------------------ .../Bindings/RevitBaseBinding.cs | 8 +- .../Bindings/SelectionBinding.cs | 6 +- .../Bindings/SendBinding.cs | 4 +- .../DependencyInjection/AutofacUIModule.cs | 2 - .../Operations/Send/RootObjectBuilder.cs | 2 +- .../Plugin/RevitExternalApplication.cs | 4 +- .../Plugin/RevitIdleManager.cs | 2 +- .../Plugin/RevitPlugin.cs | 7 +- .../Speckle.Connectors.RevitShared.projitems | 1 - 10 files changed, 16 insertions(+), 164 deletions(-) delete mode 100644 DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/ReceiveBinding.cs diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/ReceiveBinding.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/ReceiveBinding.cs deleted file mode 100644 index 43d32511a5..0000000000 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/ReceiveBinding.cs +++ /dev/null @@ -1,144 +0,0 @@ -using System; -using Speckle.Connectors.DUI.Bridge; -using Speckle.Connectors.DUI.Models; -using Speckle.Connectors.Utils.Cancellation; -using Speckle.Converters.RevitShared.Helpers; -using Speckle.Core.Logging; - -namespace Speckle.Connectors.Revit.Bindings; - -internal class ReceiveBinding : RevitBaseBinding, ICancelable -{ - public CancellationManager CancellationManager { get; } = new(); - - public ReceiveBinding(RevitContext revitContext, DocumentModelStore store, IBridge bridge) - : base("receiveBinding", store, bridge, revitContext) { } - - public void CancelReceive(string modelCardId) => CancellationManager.CancelOperation(modelCardId); - - public async void Receive(string modelCardId, string versionId) - { - try - { - //// 0 - Init cancellation token source -> Manager also cancel it if exist before - //CancellationTokenSource cts = CancellationManager.InitCancellationTokenSource(modelCardId); - - //// 1 - Get receiver card - //ReceiverModelCard model = _store.GetModelById(modelCardId) as ReceiverModelCard; - - //// 2 - Get commit object from server - //Base commitObject = await Operations.GetCommitBase(Parent, model, versionId, cts.Token).ConfigureAwait(true); - - //if (cts.IsCancellationRequested) - //{ - // return; - //} - - //// 3 - Get converter - //ISpeckleConverter converter = Converters.GetConverter(Doc, RevitAppProvider.Version()); - - //// 4 - Traverse commit object - //List objectsToConvert = Traversal.GetObjectsToConvert(commitObject, converter); - - //// 5 - Bake objects - //BakeObjects(objectsToConvert, converter, modelCardId, cts); - } - catch (Exception e) when (!e.IsFatal()) - { - //if (e is OperationCanceledException) - //{ - // Progress.CancelReceive(Parent, modelCardId); - // return; - //} - //throw; - } - } - - //private async void BakeObjects( - // List objectsToConvert, - // ISpeckleConverter converter, - // string modelCardId, - // CancellationTokenSource cts - //) - //{ - // (bool success, Exception exception) = await RevitTask - // .RunAsync(app => - // { - // string transactionName = $"Baking model from {modelCardId}"; - // using TransactionGroup g = new(Doc, transactionName); - // using Transaction t = new(Doc, transactionName); - // g.Start(); - // t.Start(); - - // try - // { - // converter.SetContextDocument(t); - // List errors = new(); - // int count = 0; - // foreach (Base objToConvert in objectsToConvert) - // { - // count++; - // if (cts.IsCancellationRequested) - // { - // Progress.CancelReceive(Parent, modelCardId, (double)count / objectsToConvert.Count); - // break; - // } - // try - // { - // double progress = (double)count / objectsToConvert.Count; - // Progress.ReceiverProgressToBrowser(Parent, modelCardId, progress); - // object convertedObject = converter.ConvertToNative(objToConvert); - // RefreshView(); - // } - // catch (SpeckleException e) - // { - // errors.Add($"Object couldn't converted with id: {objToConvert.id}, type: {objToConvert.speckle_type}\n"); - // Console.WriteLine(e); - // } - // } - // Notification.ReportReceive(Parent, errors, modelCardId, objectsToConvert.Count); - - // t.Commit(); - - // if (t.GetStatus() == TransactionStatus.RolledBack) - // { - // int numberOfErrors = 0; // Previously get from errorEater - // return ( - // false, - // new SpeckleException( - // $"The Revit API could not resolve {numberOfErrors} unique errors and {numberOfErrors} total errors when trying to commit the Speckle model. The whole transaction is being rolled back." - // ) - // ); - // } - - // g.Assimilate(); - // return (true, null); - // } - // catch (SpeckleException ex) - // { - // t.RollBack(); - // g.RollBack(); - // return (false, ex); //We can't throw exceptions in from RevitTask, but we can return it along with a success status - // } - // }) - // .ConfigureAwait(false); - //} - - //private void RefreshView() - //{ - // // regenerate the document and then implement a hack to "refresh" the view - // UiDoc.Document.Regenerate(); - - // // get the active ui view - // View view = UiDoc.ActiveGraphicalView ?? UiDoc.ActiveView; - // if (view is TableView) - // { - // return; - // } - - // UIView uiView = UiDoc.GetOpenUIViews().FirstOrDefault(uv => uv.ViewId.Equals(view.Id)); - - // // "refresh" the active view - // uiView?.Zoom(1); - //} -} diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/RevitBaseBinding.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/RevitBaseBinding.cs index 6822f0650e..1a18f5ac53 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/RevitBaseBinding.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/RevitBaseBinding.cs @@ -11,14 +11,14 @@ internal abstract class RevitBaseBinding : IBinding public string Name { get; protected set; } public IBridge Parent { get; protected set; } - protected readonly DocumentModelStore _store; - protected readonly RevitContext _revitContext; + protected readonly DocumentModelStore Store; + protected readonly RevitContext RevitContext; public RevitBaseBinding(string name, DocumentModelStore store, IBridge bridge, RevitContext revitContext) { Name = name; Parent = bridge; - _store = store; - _revitContext = revitContext; + Store = store; + RevitContext = revitContext; } } diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SelectionBinding.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SelectionBinding.cs index 3c339526d7..cbc0a5468f 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SelectionBinding.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SelectionBinding.cs @@ -24,9 +24,9 @@ IBridge bridge // POC: we can inject the solution here // TODO: Need to figure it out equivalent of SelectionChanged for Revit2020 - _revitContext.UIApplication.SelectionChanged += (_, _) => _revitIdleManager.SubscribeToIdle(OnSelectionChanged); + RevitContext.UIApplication.SelectionChanged += (_, _) => _revitIdleManager.SubscribeToIdle(OnSelectionChanged); - _revitContext.UIApplication.ViewActivated += (_, _) => + RevitContext.UIApplication.ViewActivated += (_, _) => { Parent.Send(SelectionBindingEvents.SET_SELECTION, new SelectionInfo()); }; @@ -42,7 +42,7 @@ public SelectionInfo GetSelection() // POC: this was also being called on shutdown // probably the bridge needs to be able to know if the plugin has been terminated // also on termination the OnSelectionChanged event needs unwinding - var selectionIds = _revitContext.UIApplication.ActiveUIDocument.Selection + var selectionIds = RevitContext.UIApplication.ActiveUIDocument.Selection .GetElementIds() .Select(id => id.ToString()) .ToList(); diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SendBinding.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SendBinding.cs index 07a5fe4950..67fa8c8b21 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SendBinding.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SendBinding.cs @@ -87,7 +87,7 @@ private async Task HandleSend(string modelCardId) // bubbling up to the bridge. try { - if (_store.GetModelById(modelCardId) is not SenderModelCard modelCard) + if (Store.GetModelById(modelCardId) is not SenderModelCard modelCard) { throw new InvalidOperationException("No publish model card was found."); } @@ -195,7 +195,7 @@ private void DocChangeHandler(Autodesk.Revit.DB.Events.DocumentChangedEventArgs private void RunExpirationChecks() { - List senders = _store.GetSenders(); + List senders = Store.GetSenders(); string[] objectIdsList = ChangedObjectIds.ToArray(); List expiredSenderIds = new(); diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/AutofacUIModule.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/AutofacUIModule.cs index 57a7b04ac1..d3e86d8ac3 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/AutofacUIModule.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/AutofacUIModule.cs @@ -75,8 +75,6 @@ protected override void Load(ContainerBuilder builder) builder.RegisterType().As().SingleInstance(); builder.RegisterType().As().SingleInstance(); builder.RegisterType().As().SingleInstance(); - // POC: Hide Load button as Revit connector is publish only for the open alpha. - //builder.RegisterType().As().SingleInstance(); builder.RegisterType().As().SingleInstance(); // send operation and dependencies diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RootObjectBuilder.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RootObjectBuilder.cs index 606c23bae5..529188dbfc 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RootObjectBuilder.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RootObjectBuilder.cs @@ -99,7 +99,7 @@ public Base Build( collection.elements.Add(converted); } - catch (SpeckleConversionException ex) + catch (SpeckleConversionException) { // POC: logging } diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitExternalApplication.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitExternalApplication.cs index 333ea1dda2..c73cfc59e2 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitExternalApplication.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitExternalApplication.cs @@ -50,7 +50,7 @@ public Result OnStartup(UIControlledApplication application) // POC: not sure what this is doing... could be messing up our Aliasing???? AppDomain.CurrentDomain.AssemblyResolve += OnAssemblyResolve; _container = new AutofacContainer(new StorageInfo()); - _container.PreBuildEvent += _container_PreBuildEvent; + _container.PreBuildEvent += ContainerPreBuildEvent; // init DI _container @@ -72,7 +72,7 @@ public Result OnStartup(UIControlledApplication application) return Result.Succeeded; } - private void _container_PreBuildEvent(object sender, ContainerBuilder containerBuilder) + private void ContainerPreBuildEvent(object sender, ContainerBuilder containerBuilder) { // POC: need to settle on the mechanism and location as to where we should register these services containerBuilder.RegisterRawConversions(); diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitIdleManager.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitIdleManager.cs index d4877b6828..76b723ff9c 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitIdleManager.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitIdleManager.cs @@ -16,7 +16,7 @@ internal class RevitIdleManager : IRevitIdleManager private readonly ConcurrentDictionary _calls = new(); // POC: still not thread safe - private volatile bool _hasSubscribed = false; + private volatile bool _hasSubscribed; public RevitIdleManager(RevitContext revitContext) { diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitPlugin.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitPlugin.cs index 83165bcdad..9e0a2041d4 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitPlugin.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitPlugin.cs @@ -23,7 +23,6 @@ internal class RevitPlugin : IRevitPlugin private readonly RevitSettings _revitSettings; private readonly IEnumerable> _bindings; // should be lazy to ensure the bindings are not created too early private readonly BindingOptions _bindingOptions; - private readonly CefSharpPanel _panel; private readonly RevitContext _revitContext; private readonly CefSharpPanel _cefSharpPanel; @@ -177,9 +176,9 @@ private void RegisterPanelAndInitializePlugin() { var assembly = Assembly.LoadFrom(Path.Combine(path)); var icon = assembly.GetManifestResourceStream(sourceName); - PngBitmapDecoder m_decoder = new(icon, BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.Default); - ImageSource m_source = m_decoder.Frames[0]; - return (m_source); + PngBitmapDecoder decoder = new(icon, BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.Default); + ImageSource source = decoder.Frames[0]; + return source; } catch (Exception ex) when (!ex.IsFatal()) { diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Speckle.Connectors.RevitShared.projitems b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Speckle.Connectors.RevitShared.projitems index a9821c7eba..6543a56b68 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Speckle.Connectors.RevitShared.projitems +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Speckle.Connectors.RevitShared.projitems @@ -18,7 +18,6 @@ - From cd6a7894894d5f8c388d54b0bd0eb2ebb91c9270 Mon Sep 17 00:00:00 2001 From: BovineOx <73857041+BovineOx@users.noreply.github.com> Date: Wed, 8 May 2024 12:45:36 +0100 Subject: [PATCH 125/261] Document.Document & IRevitConversionContextStack (#3380) * Document.Document & IRevitConversionContextStack Fixed Document.Document and also changed to always reference stack to always use IRevitConversionContextStack * Removed dead comment Removed dead comment --- .../Bindings/BasicConnectorBindingRevit.cs | 1 - .../Operations/Send/RootObjectBuilder.cs | 12 ++++++------ .../AutofacRevitConverterModule.cs | 6 +----- .../Speckle.Converters.RevitShared/GlobalUsings.cs | 1 - .../Helpers/IRevitConversionContextStack.cs | 2 +- .../Helpers/RevitConversionContextStack.cs | 6 ++---- .../Raw/ColumnConversionToSpeckle.cs | 4 ++-- .../Raw/Geometry/CurveArrayConversionToSpeckle.cs | 4 ++-- .../Raw/Geometry/LineConversionToSpeckle.cs | 4 ++-- .../Geometry/MeshByMaterialDictionaryToSpeckle.cs | 6 +++--- .../Raw/Geometry/MeshConversionToSpeckle.cs | 6 +++--- .../Raw/Geometry/XyzConversionToPoint.cs | 7 +++++-- .../Raw/ModelCurveArrayToSpeckleConverter.cs | 4 ++-- .../ReferencePointConverter.cs | 4 ++-- .../Services/ScalingServiceToSpeckle.cs | 4 ++-- .../ToSpeckle/DirectShapeConversionToSpeckle.cs | 4 ++-- .../ToSpeckle/HostedElementConversionToSpeckle.cs | 6 +++--- .../ToSpeckle/WallConversionToSpeckle.cs | 6 +++--- 18 files changed, 41 insertions(+), 46 deletions(-) diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/BasicConnectorBindingRevit.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/BasicConnectorBindingRevit.cs index 0452730b05..4eb94b969b 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/BasicConnectorBindingRevit.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/BasicConnectorBindingRevit.cs @@ -72,7 +72,6 @@ public DocumentInfo GetDocumentInfo() } // POC: Notify user here if document is null. - return new DocumentInfo { Name = doc.Title, diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RootObjectBuilder.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RootObjectBuilder.cs index 529188dbfc..ea69596b5d 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RootObjectBuilder.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RootObjectBuilder.cs @@ -17,14 +17,14 @@ public class RootObjectBuilder : IRootObjectBuilder // POC: SendSelection and RevitConversionContextStack should be interfaces, former needs interfaces private readonly ISpeckleConverterToSpeckle _converter; private readonly ToSpeckleConvertedObjectsCache _convertedObjectsCache; - private readonly RevitConversionContextStack _contextStack; + private readonly IRevitConversionContextStack _contextStack; private readonly Dictionary _collectionCache; private readonly Collection _rootObject; public RootObjectBuilder( ISpeckleConverterToSpeckle converter, ToSpeckleConvertedObjectsCache convertedObjectsCache, - RevitConversionContextStack contextStack + IRevitConversionContextStack contextStack ) { _converter = converter; @@ -36,7 +36,7 @@ RevitConversionContextStack contextStack _collectionCache = new Dictionary(); _rootObject = new Collection() { - name = _contextStack.Current.Document.Document.PathName.Split('\\').Last().Split('.').First() + name = _contextStack.Current.Document.PathName.Split('\\').Last().Split('.').First() }; } @@ -47,18 +47,18 @@ public Base Build( CancellationToken ct = default ) { - var doc = _contextStack.Current.Document.Document; // POC: Document.Document is funny + var doc = _contextStack.Current.Document; if (doc.IsFamilyDocument) { throw new SpeckleException("Family Environment documents are not supported."); } - var revitElements = new List(); // = _contextStack.Current.Document.Document.GetElements(sendSelection.SelectedItems).ToList(); + var revitElements = new List(); // = _contextStack.Current.Document.GetElements(sendSelection.SelectedItems).ToList(); foreach (var id in objects) { - var el = _contextStack.Current.Document.Document.GetElement(id); + var el = _contextStack.Current.Document.GetElement(id); if (el != null) { revitElements.Add(el); diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/AutofacRevitConverterModule.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/AutofacRevitConverterModule.cs index 93e4001ae2..f8399dc827 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/AutofacRevitConverterModule.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/AutofacRevitConverterModule.cs @@ -33,11 +33,7 @@ protected override void Load(ContainerBuilder builder) builder.RegisterType().AsSelf().InstancePerLifetimeScope(); // POC: the concrete type can come out if we remove all the reference to it - builder - .RegisterType() - .As() - .AsSelf() - .InstancePerLifetimeScope(); + builder.RegisterType().As().InstancePerLifetimeScope(); builder .RegisterType() diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/GlobalUsings.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/GlobalUsings.cs index 4839a81393..5a7a8f20bd 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/GlobalUsings.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/GlobalUsings.cs @@ -1,6 +1,5 @@ global using DB = Autodesk.Revit.DB; global using DBA = Autodesk.Revit.DB.Architecture; -global using UI = Autodesk.Revit.UI; global using SOG = Objects.Geometry; global using SOBR = Objects.BuiltElements.Revit; global using SOBE = Objects.BuiltElements; diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/IRevitConversionContextStack.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/IRevitConversionContextStack.cs index af3e959715..1cf5d4b80c 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/IRevitConversionContextStack.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/IRevitConversionContextStack.cs @@ -10,4 +10,4 @@ namespace Speckle.Converters.RevitShared.Helpers; )] // POC: so this should *probably* be Document and NOT UI.UIDocument, the former is Conversion centric // and the latter is more for connector -public interface IRevitConversionContextStack : IConversionContextStack { } +public interface IRevitConversionContextStack : IConversionContextStack { } diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/RevitConversionContextStack.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/RevitConversionContextStack.cs index 9b20274ae0..ce43a88901 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/RevitConversionContextStack.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/RevitConversionContextStack.cs @@ -10,9 +10,7 @@ namespace Speckle.Converters.RevitShared.Helpers; )] // POC: so this should *probably* be Document and NOT UI.UIDocument, the former is Conversion centric // and the latter is more for connector -public class RevitConversionContextStack - : ConversionContextStack, - IRevitConversionContextStack +public class RevitConversionContextStack : ConversionContextStack, IRevitConversionContextStack { public const double TOLERANCE = 0.0164042; // 5mm in ft @@ -22,7 +20,7 @@ public RevitConversionContextStack(RevitContext context, IHostToSpeckleUnitConve // so should this perpetuate or do we assume this is valid? // relting on the context.UIApplication?.ActiveUIDocument is not right // this should be some IActiveDocument I suspect? - context.UIApplication?.ActiveUIDocument + context.UIApplication?.ActiveUIDocument?.Document ?? throw new SpeckleConversionException("Active UI document could not be determined"), context.UIApplication.ActiveUIDocument.Document.GetUnits().GetFormatOptions(SpecTypeId.Length).GetUnitTypeId(), unitConverter diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ColumnConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ColumnConversionToSpeckle.cs index f9daa14b1e..f50bea3ec5 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ColumnConversionToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ColumnConversionToSpeckle.cs @@ -16,7 +16,7 @@ public class ColumnConversionToSpeckle : IRawConversion _levelConverter; private readonly ParameterValueExtractor _parameterValueExtractor; private readonly DisplayValueExtractor _displayValueExtractor; - private readonly RevitConversionContextStack _contextStack; + private readonly IRevitConversionContextStack _contextStack; private readonly ParameterObjectAssigner _parameterObjectAssigner; public ColumnConversionToSpeckle( @@ -24,7 +24,7 @@ public ColumnConversionToSpeckle( IRawConversion levelConverter, ParameterValueExtractor parameterValueExtractor, DisplayValueExtractor displayValueExtractor, - RevitConversionContextStack contextStack, + IRevitConversionContextStack contextStack, ParameterObjectAssigner parameterObjectAssigner ) { diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/CurveArrayConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/CurveArrayConversionToSpeckle.cs index a4d5f4fc67..327be89dbf 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/CurveArrayConversionToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/CurveArrayConversionToSpeckle.cs @@ -9,12 +9,12 @@ namespace Speckle.Converters.RevitShared.ToSpeckle; public sealed class CurveArrayConversionToSpeckle : IRawConversion { - private readonly RevitConversionContextStack _contextStack; + private readonly IRevitConversionContextStack _contextStack; private readonly ScalingServiceToSpeckle _scalingService; private readonly IRawConversion _curveConverter; public CurveArrayConversionToSpeckle( - RevitConversionContextStack contextStack, + IRevitConversionContextStack contextStack, ScalingServiceToSpeckle scalingService, IRawConversion curveConverter ) diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/LineConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/LineConversionToSpeckle.cs index 847be282a5..fd00f57360 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/LineConversionToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/LineConversionToSpeckle.cs @@ -7,12 +7,12 @@ namespace Speckle.Converters.RevitShared.ToSpeckle; public class LineConversionToSpeckle : IRawConversion { - private readonly RevitConversionContextStack _contextStack; + private readonly IRevitConversionContextStack _contextStack; private readonly IRawConversion _xyzToPointConverter; private readonly ScalingServiceToSpeckle _scalingService; public LineConversionToSpeckle( - RevitConversionContextStack contextStack, + IRevitConversionContextStack contextStack, IRawConversion xyzToPointConverter, ScalingServiceToSpeckle scalingService ) diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/MeshByMaterialDictionaryToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/MeshByMaterialDictionaryToSpeckle.cs index 2a1e71adf8..f9d7d760df 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/MeshByMaterialDictionaryToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/MeshByMaterialDictionaryToSpeckle.cs @@ -6,13 +6,13 @@ namespace Speckle.Converters.RevitShared.ToSpeckle; public class MeshByMaterialDictionaryToSpeckle : IRawConversion>, List> { - private readonly RevitConversionContextStack _contextStack; + private readonly IRevitConversionContextStack _contextStack; private readonly IRawConversion _xyzToPointConverter; private readonly IRawConversion _materialConverter; public MeshByMaterialDictionaryToSpeckle( IRawConversion materialConverter, - RevitConversionContextStack contextStack, + IRevitConversionContextStack contextStack, IRawConversion xyzToPointConverter ) { @@ -53,7 +53,7 @@ public MeshByMaterialDictionaryToSpeckle( units: _contextStack.Current.SpeckleUnits ); - var doc = _contextStack.Current.Document.Document; + var doc = _contextStack.Current.Document; if (doc.GetElement(materialId) is DB.Material material) { speckleMesh["renderMaterial"] = _materialConverter.RawConvert(material); diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/MeshConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/MeshConversionToSpeckle.cs index 55ef357c86..635537ea78 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/MeshConversionToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/MeshConversionToSpeckle.cs @@ -8,10 +8,10 @@ public class MeshConversionToSpeckle : IRawConversion { private readonly IRawConversion _xyzToPointConverter; private readonly IRawConversion _materialConverter; - private readonly RevitConversionContextStack _contextStack; + private readonly IRevitConversionContextStack _contextStack; public MeshConversionToSpeckle( - RevitConversionContextStack contextStack, + IRevitConversionContextStack contextStack, IRawConversion xyzToPointConverter, IRawConversion materialConverter ) @@ -23,7 +23,7 @@ public MeshConversionToSpeckle( public SOG.Mesh RawConvert(DB.Mesh target) { - var doc = _contextStack.Current.Document.Document; + var doc = _contextStack.Current.Document; List vertices = GetSpeckleMeshVertexData(target); List faces = GetSpeckleMeshFaceData(target); diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/XyzConversionToPoint.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/XyzConversionToPoint.cs index c4e0268611..4322f45094 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/XyzConversionToPoint.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/XyzConversionToPoint.cs @@ -7,9 +7,12 @@ namespace Speckle.Converters.RevitShared.ToSpeckle; public class XyzConversionToPoint : IRawConversion { private readonly ScalingServiceToSpeckle _toSpeckleScalingService; - private readonly RevitConversionContextStack _contextStack; + private readonly IRevitConversionContextStack _contextStack; - public XyzConversionToPoint(ScalingServiceToSpeckle toSpeckleScalingService, RevitConversionContextStack contextStack) + public XyzConversionToPoint( + ScalingServiceToSpeckle toSpeckleScalingService, + IRevitConversionContextStack contextStack + ) { _toSpeckleScalingService = toSpeckleScalingService; _contextStack = contextStack; diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ModelCurveArrayToSpeckleConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ModelCurveArrayToSpeckleConverter.cs index b6131fd7b6..c91e343f68 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ModelCurveArrayToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ModelCurveArrayToSpeckleConverter.cs @@ -8,12 +8,12 @@ namespace Speckle.Converters.RevitShared.Raw; internal class ModelCurveArrayToSpeckleConverter : IRawConversion { - private readonly RevitConversionContextStack _contextStack; + private readonly IRevitConversionContextStack _contextStack; private readonly ScalingServiceToSpeckle _scalingService; private readonly IRawConversion _curveConverter; public ModelCurveArrayToSpeckleConverter( - RevitConversionContextStack contextStack, + IRevitConversionContextStack contextStack, ScalingServiceToSpeckle scalingService, IRawConversion curveConverter ) diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ReferencePointConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ReferencePointConverter.cs index 89e4e35b80..89d68bb58f 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ReferencePointConverter.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ReferencePointConverter.cs @@ -29,7 +29,7 @@ public ReferencePointConverter(IRevitConversionContextStack contextStack, RevitC // doc can change during the lifeycycle of the conversions. This may need some looking into public DB.XYZ ConvertToExternalCoordindates(DB.XYZ inbound, bool isPoint) { - var rpt = GetDocReferencePointTransform(_contextStack.Current.Document.Document); + var rpt = GetDocReferencePointTransform(_contextStack.Current.Document); return isPoint ? rpt.OfPoint(inbound) : rpt.OfVector(inbound); } @@ -60,7 +60,7 @@ public DB.Transform GetReferencePointTransform(string referencePointSetting) // POC: bogus disposal below #pragma warning disable CA2000 - var points = new DB.FilteredElementCollector(_contextStack.Current.Document.Document) + var points = new DB.FilteredElementCollector(_contextStack.Current.Document) .OfClass(typeof(DB.BasePoint)) .Cast() .ToList(); diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Services/ScalingServiceToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Services/ScalingServiceToSpeckle.cs index d036ff33c5..a0c2779048 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Services/ScalingServiceToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Services/ScalingServiceToSpeckle.cs @@ -10,10 +10,10 @@ public sealed class ScalingServiceToSpeckle private readonly double _defaultLengthConversionFactor; // POC: this seems like the reverse relationship - public ScalingServiceToSpeckle(RevitConversionContextStack contextStack) + public ScalingServiceToSpeckle(IRevitConversionContextStack contextStack) { // POC: this is accurate for the current context stack - Units documentUnits = contextStack.Current.Document.Document.GetUnits(); + Units documentUnits = contextStack.Current.Document.GetUnits(); FormatOptions formatOptions = documentUnits.GetFormatOptions(SpecTypeId.Length); var lengthUnitsTypeId = formatOptions.GetUnitTypeId(); _defaultLengthConversionFactor = ScaleStatic(1, lengthUnitsTypeId); diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/DirectShapeConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/DirectShapeConversionToSpeckle.cs index 35bf7b2a94..2e6340e853 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/DirectShapeConversionToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/DirectShapeConversionToSpeckle.cs @@ -9,13 +9,13 @@ namespace Speckle.Converters.Revit2023.ToSpeckle; [NameAndRankValue(nameof(DB.DirectShape), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] public class DirectShapeConversionToSpeckle : BaseConversionToSpeckle { - private readonly RevitConversionContextStack _contextStack; + private readonly IRevitConversionContextStack _contextStack; private readonly ParameterObjectAssigner _parameterObjectAssigner; private readonly DisplayValueExtractor _displayValueExtractor; public DirectShapeConversionToSpeckle( ParameterObjectAssigner parameterObjectAssigner, - RevitConversionContextStack contextStack, + IRevitConversionContextStack contextStack, DisplayValueExtractor displayValueExtractor ) { diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/HostedElementConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/HostedElementConversionToSpeckle.cs index a5b7cca567..5709bba293 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/HostedElementConversionToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/HostedElementConversionToSpeckle.cs @@ -13,12 +13,12 @@ public class HostedElementConversionToSpeckle { private readonly ToSpeckleConvertedObjectsCache _convertedObjectsCache; private readonly ISpeckleConverterToSpeckle _converter; - private readonly RevitConversionContextStack _contextStack; + private readonly IRevitConversionContextStack _contextStack; public HostedElementConversionToSpeckle( ToSpeckleConvertedObjectsCache convertedObjectsCache, ISpeckleConverterToSpeckle converter, - RevitConversionContextStack contextStack + IRevitConversionContextStack contextStack ) { _convertedObjectsCache = convertedObjectsCache; @@ -30,7 +30,7 @@ public IEnumerable ConvertHostedElements(IEnumerable hostedElem { foreach (var elemId in hostedElementIds) { - Element element = _contextStack.Current.Document.Document.GetElement(elemId); + Element element = _contextStack.Current.Document.GetElement(elemId); Base @base; try diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/WallConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/WallConversionToSpeckle.cs index 9ea1acb847..f69d6a14b5 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/WallConversionToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/WallConversionToSpeckle.cs @@ -18,7 +18,7 @@ public class WallConversionToSpeckle : BaseConversionToSpeckle _levelConverter; private readonly IRawConversion> _curveArrArrayConverter; private readonly ParameterValueExtractor _parameterValueExtractor; - private readonly RevitConversionContextStack _contextStack; + private readonly IRevitConversionContextStack _contextStack; private readonly DisplayValueExtractor _displayValueExtractor; private readonly ParameterObjectAssigner _parameterObjectAssigner; private readonly ISpeckleConverterToSpeckle _converter; @@ -27,7 +27,7 @@ public WallConversionToSpeckle( IRawConversion curveConverter, IRawConversion levelConverter, IRawConversion> curveArrArrayConverter, - RevitConversionContextStack contextStack, + IRevitConversionContextStack contextStack, ParameterValueExtractor parameterValueExtractor, DisplayValueExtractor displayValueExtractor, ParameterObjectAssigner parameterObjectAssigner, @@ -124,7 +124,7 @@ private IEnumerable ConvertElements(IEnumerable elementIds) { foreach (DB.ElementId elementId in elementIds) { - yield return _converter.Convert(_contextStack.Current.Document.Document.GetElement(elementId)); + yield return _converter.Convert(_contextStack.Current.Document.GetElement(elementId)); } } From bed47df43c3ee4fdeb86380fdf1485c1e012cc36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?O=C4=9Fuzhan=20Koral?= <45078678+oguzhankoral@users.noreply.github.com> Date: Wed, 8 May 2024 16:08:28 +0300 Subject: [PATCH 126/261] Fix (revit): Get rid of from unnecessary WriteToFileWithDoc if views are same (#3383) * Get rid of from unnecessary WriteToFileWithDoc if views are same * Do not set selection on document switch.. We could do it on UI * We do not need to send empty selection info on document switch --- .../Bindings/SelectionBinding.cs | 5 ----- .../HostApp/RevitDocumentStore.cs | 10 +++++----- .../Bindings/RhinoSelectionBinding.cs | 6 ------ 3 files changed, 5 insertions(+), 16 deletions(-) diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SelectionBinding.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SelectionBinding.cs index cbc0a5468f..ee69c66e52 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SelectionBinding.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SelectionBinding.cs @@ -25,11 +25,6 @@ IBridge bridge // POC: we can inject the solution here // TODO: Need to figure it out equivalent of SelectionChanged for Revit2020 RevitContext.UIApplication.SelectionChanged += (_, _) => _revitIdleManager.SubscribeToIdle(OnSelectionChanged); - - RevitContext.UIApplication.ViewActivated += (_, _) => - { - Parent.Send(SelectionBindingEvents.SET_SELECTION, new SelectionInfo()); - }; } private void OnSelectionChanged() diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/RevitDocumentStore.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/RevitDocumentStore.cs index 43141730e3..b3e4c339a4 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/RevitDocumentStore.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/RevitDocumentStore.cs @@ -57,17 +57,17 @@ private void OnViewActivated(object sender, ViewActivatedEventArgs e) return; } - if (e.PreviousActiveView?.Document != null) - { - WriteToFileWithDoc(e.PreviousActiveView.Document); - } - // Return only if we are switching views that belongs to same document if (e.PreviousActiveView?.Document != null && e.PreviousActiveView.Document.Equals(e.CurrentActiveView.Document)) { return; } + if (e.PreviousActiveView?.Document != null) + { + WriteToFileWithDoc(e.PreviousActiveView.Document); + } + IsDocumentInit = true; ReadFromFile(); OnDocumentChanged(); diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSelectionBinding.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSelectionBinding.cs index 395055fc69..5a00123167 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSelectionBinding.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSelectionBinding.cs @@ -31,12 +31,6 @@ public RhinoSelectionBinding(RhinoIdleManager idleManager, IBridge parent) { idleManager.SubscribeToIdle(OnSelectionChanged); }; - - RhinoDoc.EndOpenDocumentInitialViewUpdate += (_, _) => - { - // Resets selection doc change - Parent?.Send(SELECTION_EVENT, new SelectionInfo()); - }; } private void OnSelectionChanged() From a5d25c7908cdd7112da5de3d80ccac24beb9c78a Mon Sep 17 00:00:00 2001 From: Adam Hathcock Date: Wed, 8 May 2024 16:32:42 +0100 Subject: [PATCH 127/261] Start normalizing props for DUI3 --- .../AutocadConverterToSpeckle.cs | 1 - .../AutocadToSpeckleUnitConverter.cs | 1 - .../Extensions/EntityExtensions.cs | 1 - .../Extensions/ListExtensions.cs | 2 -- .../ToHost/Geometry/CircleToHostConverter.cs | 1 - .../ToHost/Geometry/EllipseToHostConverter.cs | 1 - .../ToHost/Geometry/MeshToHostConverter.cs | 2 -- .../ToHost/Geometry/PolycurveToHostConverter.cs | 2 -- .../ToHost/Geometry/SpeckleFallbackToHostConversion.cs | 4 +--- .../Raw/AutocadPolycurveToHostPolyline2dRawConverter.cs | 1 - .../Raw/AutocadPolycurveToHostPolyline3dRawConverter.cs | 1 - .../Raw/AutocadPolycurveToHostPolylineRawConverter.cs | 1 - .../ToHost/Raw/CurveToHostRawConverter.cs | 2 -- .../ToHost/Raw/IntervalToHostRawConverter.cs | 1 - .../ToHost/Raw/PolycurveToHostPolylineRawConverter.cs | 3 --- .../ToHost/Raw/PolycurveToHostSplineRawConverter.cs | 1 - .../ToSpeckle/Geometry/PolyfaceMeshToSpeckleConverter.cs | 2 -- .../ToSpeckle/Geometry/Polyline2dToSpeckleConverter.cs | 2 -- .../ToSpeckle/Geometry/Polyline3dToSpeckleConverter.cs | 2 -- .../ToSpeckle/Geometry/PolylineToSpeckleConverter.cs | 1 - .../ToSpeckle/Geometry/SplineToSpeckleConverter.cs | 2 -- .../ToSpeckle/Geometry/SubDMeshToSpeckleConverter.cs | 2 -- .../DUI3ControlWebView.xaml.cs | 2 -- DUI3-DX/Directory.Build.Props | 4 +--- .../Speckle.Objects.Common/Speckle.Objects.Common.csproj | 4 ---- .../DependencyInjection/AutofacContainer.cs | 3 --- .../Sdk/Speckle.Autofac/DependencyInjection/IUnitOfWork.cs | 4 +--- DUI3-DX/Sdk/Speckle.Autofac/Files/IStorageInfo.cs | 2 -- DUI3-DX/Sdk/Speckle.Autofac/Files/StorageInfo.cs | 3 --- .../Builders/IHostObjectBuilder.cs | 5 +---- .../Builders/IRootObjectBuilder.cs | 5 +---- .../Cancellation/CancellationManager.cs | 3 --- .../Operations/IRootObjectSender.cs | 4 ---- .../Operations/ISyncToMainThread.cs | 5 +---- .../Operations/ReceiveOperation.cs | 4 ---- .../Operations/RootObjectSender.cs | 4 ---- DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/Send.cs | 7 +------ .../Sdk/Speckle.Connectors.Utils/Operations/SendInfo.cs | 3 +-- .../Speckle.Connectors.Utils/Operations/SendOperation.cs | 6 +----- .../Reflection/AssemblyExtensions.cs | 1 - .../SpeckleTopLevelExceptionHandler.cs | 2 -- DUI3-DX/Sdk/Speckle.Converters.Common/ContextWrapper.cs | 4 +--- .../Speckle.Converters.Common/ConversionContextStack.cs | 3 +-- DUI3-DX/Sdk/Speckle.Converters.Common/DisplayableObject.cs | 5 +---- .../Speckle.Converters.Common/NameAndRankValueAttribute.cs | 4 +--- .../Objects/IConverterResolver.cs | 4 +--- .../Speckle.Converters.Common/RecursiveConveterResolver.cs | 3 +-- .../SpeckleConversionException.cs | 4 +--- 48 files changed, 16 insertions(+), 118 deletions(-) diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/AutocadConverterToSpeckle.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/AutocadConverterToSpeckle.cs index 12eb5acf65..85112323be 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/AutocadConverterToSpeckle.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/AutocadConverterToSpeckle.cs @@ -1,4 +1,3 @@ -using System; using Autodesk.AutoCAD.DatabaseServices; using Speckle.Autofac.DependencyInjection; using Speckle.Converters.Common; diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/AutocadToSpeckleUnitConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/AutocadToSpeckleUnitConverter.cs index 15e92ef90c..3180b4ef94 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/AutocadToSpeckleUnitConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/AutocadToSpeckleUnitConverter.cs @@ -1,4 +1,3 @@ -using System.Collections.Generic; using Autodesk.AutoCAD.DatabaseServices; using Speckle.Converters.Common; using Speckle.Core.Kits; diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/Extensions/EntityExtensions.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/Extensions/EntityExtensions.cs index 6c8515e461..9f99c36098 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/Extensions/EntityExtensions.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/Extensions/EntityExtensions.cs @@ -1,6 +1,5 @@ using Autodesk.AutoCAD.DatabaseServices; using System.Collections; -using System.Collections.Generic; namespace Speckle.Converters.Autocad.Extensions; diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/Extensions/ListExtensions.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/Extensions/ListExtensions.cs index 6731f8f7fa..82ea22ce53 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/Extensions/ListExtensions.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/Extensions/ListExtensions.cs @@ -1,5 +1,3 @@ -using System.Collections.Generic; - namespace Speckle.Converters.Autocad.Extensions; public static class ListExtensions diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/CircleToHostConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/CircleToHostConverter.cs index b1f1604fec..a83a6b1845 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/CircleToHostConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/CircleToHostConverter.cs @@ -1,4 +1,3 @@ -using System; using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; using Speckle.Core.Kits; diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/EllipseToHostConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/EllipseToHostConverter.cs index 824959fbd8..8a7def05a2 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/EllipseToHostConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/EllipseToHostConverter.cs @@ -1,4 +1,3 @@ -using System; using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; using Speckle.Core.Kits; diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/MeshToHostConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/MeshToHostConverter.cs index 4f97cc973b..e75aa5e91d 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/MeshToHostConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/MeshToHostConverter.cs @@ -2,9 +2,7 @@ using Speckle.Converters.Common.Objects; using Speckle.Core.Models; using Objects.Utils; -using System.Linq; using Speckle.Core.Logging; -using System.Collections.Generic; namespace Speckle.Converters.Autocad.Geometry; diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/PolycurveToHostConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/PolycurveToHostConverter.cs index 6a10f2bbc5..a3c458f916 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/PolycurveToHostConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/PolycurveToHostConverter.cs @@ -1,5 +1,3 @@ -using System.Collections.Generic; -using System.Linq; using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; using Speckle.Core.Models; diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/SpeckleFallbackToHostConversion.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/SpeckleFallbackToHostConversion.cs index e09a3ce40a..8271b5751b 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/SpeckleFallbackToHostConversion.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/SpeckleFallbackToHostConversion.cs @@ -1,6 +1,4 @@ -using System; -using System.Collections.Generic; -using Speckle.Converters.Common; +using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; using Speckle.Core.Models; diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/AutocadPolycurveToHostPolyline2dRawConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/AutocadPolycurveToHostPolyline2dRawConverter.cs index e4c46210b0..62c62b14a2 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/AutocadPolycurveToHostPolyline2dRawConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/AutocadPolycurveToHostPolyline2dRawConverter.cs @@ -1,4 +1,3 @@ -using System.Collections.Generic; using Speckle.Converters.Autocad.Extensions; using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/AutocadPolycurveToHostPolyline3dRawConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/AutocadPolycurveToHostPolyline3dRawConverter.cs index 95b0406006..b681e436c6 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/AutocadPolycurveToHostPolyline3dRawConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/AutocadPolycurveToHostPolyline3dRawConverter.cs @@ -1,5 +1,4 @@ using Speckle.Converters.Autocad.Extensions; -using System.Collections.Generic; using Speckle.Converters.Common.Objects; using Speckle.Core.Kits; using Speckle.Converters.Common; diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/AutocadPolycurveToHostPolylineRawConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/AutocadPolycurveToHostPolylineRawConverter.cs index e1b42e61cf..3ad0a1c7ed 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/AutocadPolycurveToHostPolylineRawConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/AutocadPolycurveToHostPolylineRawConverter.cs @@ -1,4 +1,3 @@ -using System.Collections.Generic; using Speckle.Converters.Autocad.Extensions; using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/CurveToHostRawConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/CurveToHostRawConverter.cs index b7fb4bff8f..f7893506be 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/CurveToHostRawConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/CurveToHostRawConverter.cs @@ -1,5 +1,3 @@ -using System.Collections.Generic; -using System.Linq; using Speckle.Converters.Common.Objects; namespace Speckle.Converters.AutocadShared.ToHost.Raw; diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/IntervalToHostRawConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/IntervalToHostRawConverter.cs index e9136438bd..58d03626e9 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/IntervalToHostRawConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/IntervalToHostRawConverter.cs @@ -1,4 +1,3 @@ -using System; using Speckle.Converters.Common.Objects; namespace Speckle.Converters.AutocadShared.ToHost.Raw; diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/PolycurveToHostPolylineRawConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/PolycurveToHostPolylineRawConverter.cs index 874feb8908..b5a182fa2f 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/PolycurveToHostPolylineRawConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/PolycurveToHostPolylineRawConverter.cs @@ -1,6 +1,3 @@ -using System; -using System.Collections.Generic; -using System.Linq; using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/PolycurveToHostSplineRawConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/PolycurveToHostSplineRawConverter.cs index e9f7c38549..25dbe01f7e 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/PolycurveToHostSplineRawConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/PolycurveToHostSplineRawConverter.cs @@ -1,4 +1,3 @@ -using System.Collections.Generic; using Speckle.Converters.Common.Objects; namespace Speckle.Converters.AutocadShared.ToHost.Raw; diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/PolyfaceMeshToSpeckleConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/PolyfaceMeshToSpeckleConverter.cs index 545a430c51..08a1bdbb22 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/PolyfaceMeshToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/PolyfaceMeshToSpeckleConverter.cs @@ -1,5 +1,3 @@ -using System; -using System.Collections.Generic; using Autodesk.AutoCAD.Geometry; using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/Polyline2dToSpeckleConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/Polyline2dToSpeckleConverter.cs index 9091a7b06d..c18458e89b 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/Polyline2dToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/Polyline2dToSpeckleConverter.cs @@ -1,9 +1,7 @@ -using System.Collections.Generic; using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; using Speckle.Core.Models; using Speckle.Converters.Autocad.Extensions; -using System.Linq; namespace Speckle.Converters.Autocad.Geometry; diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/Polyline3dToSpeckleConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/Polyline3dToSpeckleConverter.cs index fff827612e..9434280ca8 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/Polyline3dToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/Polyline3dToSpeckleConverter.cs @@ -1,9 +1,7 @@ -using System.Collections.Generic; using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; using Speckle.Core.Models; using Speckle.Converters.Autocad.Extensions; -using System.Linq; namespace Speckle.Converters.Autocad.Geometry; diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/PolylineToSpeckleConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/PolylineToSpeckleConverter.cs index 44e01315d6..dce4210940 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/PolylineToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/PolylineToSpeckleConverter.cs @@ -1,4 +1,3 @@ -using System.Collections.Generic; using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; using Speckle.Core.Models; diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/SplineToSpeckleConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/SplineToSpeckleConverter.cs index 69953152f7..225aaaa3bf 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/SplineToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/SplineToSpeckleConverter.cs @@ -1,5 +1,3 @@ -using System.Collections.Generic; -using System.Linq; using Autodesk.AutoCAD.Geometry; using Speckle.Converters.Autocad.Extensions; using Speckle.Converters.Common; diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/SubDMeshToSpeckleConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/SubDMeshToSpeckleConverter.cs index 5242265388..296107a5e0 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/SubDMeshToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/SubDMeshToSpeckleConverter.cs @@ -1,5 +1,3 @@ -using System.Collections.Generic; -using System.Linq; using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; using Speckle.Core.Models; diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI.WebView/DUI3ControlWebView.xaml.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI.WebView/DUI3ControlWebView.xaml.cs index 64306ea1d0..4e9cc6bcc5 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI.WebView/DUI3ControlWebView.xaml.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI.WebView/DUI3ControlWebView.xaml.cs @@ -1,5 +1,3 @@ -using System; -using System.Collections.Generic; using System.Windows.Controls; using System.Windows.Threading; using Microsoft.Web.WebView2.Core; diff --git a/DUI3-DX/Directory.Build.Props b/DUI3-DX/Directory.Build.Props index 1ec3ccfb1a..eff3fdaa09 100644 --- a/DUI3-DX/Directory.Build.Props +++ b/DUI3-DX/Directory.Build.Props @@ -3,9 +3,7 @@ enable - - - + enable true diff --git a/DUI3-DX/Objects/Speckle.Objects.Common/Speckle.Objects.Common.csproj b/DUI3-DX/Objects/Speckle.Objects.Common/Speckle.Objects.Common.csproj index 1c5f6eb4d6..02d764eedd 100644 --- a/DUI3-DX/Objects/Speckle.Objects.Common/Speckle.Objects.Common.csproj +++ b/DUI3-DX/Objects/Speckle.Objects.Common/Speckle.Objects.Common.csproj @@ -7,10 +7,6 @@ disable - - false - - diff --git a/DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/AutofacContainer.cs b/DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/AutofacContainer.cs index 235ea7ae60..ceb962573c 100644 --- a/DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/AutofacContainer.cs +++ b/DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/AutofacContainer.cs @@ -1,6 +1,3 @@ -using System; -using System.Collections.Generic; -using System.Linq; using System.Reflection; using Autofac; using Microsoft.Extensions.Logging; diff --git a/DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/IUnitOfWork.cs b/DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/IUnitOfWork.cs index 886483db73..5d58d1aabe 100644 --- a/DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/IUnitOfWork.cs +++ b/DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/IUnitOfWork.cs @@ -1,6 +1,4 @@ -using System; - -namespace Speckle.Autofac.DependencyInjection; +namespace Speckle.Autofac.DependencyInjection; public interface IUnitOfWork : IDisposable where TService : class diff --git a/DUI3-DX/Sdk/Speckle.Autofac/Files/IStorageInfo.cs b/DUI3-DX/Sdk/Speckle.Autofac/Files/IStorageInfo.cs index 1f5c2a733b..0ee9cee332 100644 --- a/DUI3-DX/Sdk/Speckle.Autofac/Files/IStorageInfo.cs +++ b/DUI3-DX/Sdk/Speckle.Autofac/Files/IStorageInfo.cs @@ -1,5 +1,3 @@ -using System.Collections.Generic; - namespace Speckle.Autofac.Files; public interface IStorageInfo diff --git a/DUI3-DX/Sdk/Speckle.Autofac/Files/StorageInfo.cs b/DUI3-DX/Sdk/Speckle.Autofac/Files/StorageInfo.cs index c9cbeab3fa..af55e1405a 100644 --- a/DUI3-DX/Sdk/Speckle.Autofac/Files/StorageInfo.cs +++ b/DUI3-DX/Sdk/Speckle.Autofac/Files/StorageInfo.cs @@ -1,6 +1,3 @@ -using System.Collections.Generic; -using System.IO; - namespace Speckle.Autofac.Files; public class StorageInfo : IStorageInfo diff --git a/DUI3-DX/Sdk/Speckle.Connectors.Utils/Builders/IHostObjectBuilder.cs b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Builders/IHostObjectBuilder.cs index 1c3fb1d89b..aedb5887a6 100644 --- a/DUI3-DX/Sdk/Speckle.Connectors.Utils/Builders/IHostObjectBuilder.cs +++ b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Builders/IHostObjectBuilder.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Threading; -using Speckle.Core.Models; +using Speckle.Core.Models; namespace Speckle.Connectors.Utils.Builders; diff --git a/DUI3-DX/Sdk/Speckle.Connectors.Utils/Builders/IRootObjectBuilder.cs b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Builders/IRootObjectBuilder.cs index 2572a158eb..802272f92c 100644 --- a/DUI3-DX/Sdk/Speckle.Connectors.Utils/Builders/IRootObjectBuilder.cs +++ b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Builders/IRootObjectBuilder.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Threading; -using Speckle.Connectors.Utils.Operations; +using Speckle.Connectors.Utils.Operations; using Speckle.Core.Models; namespace Speckle.Connectors.Utils.Builders; diff --git a/DUI3-DX/Sdk/Speckle.Connectors.Utils/Cancellation/CancellationManager.cs b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Cancellation/CancellationManager.cs index 52913510f9..e11dbb781a 100644 --- a/DUI3-DX/Sdk/Speckle.Connectors.Utils/Cancellation/CancellationManager.cs +++ b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Cancellation/CancellationManager.cs @@ -1,6 +1,3 @@ -using System.Collections.Generic; -using System.Threading; - namespace Speckle.Connectors.Utils.Cancellation; /// diff --git a/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/IRootObjectSender.cs b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/IRootObjectSender.cs index 5ebc3c585e..1fed24ea95 100644 --- a/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/IRootObjectSender.cs +++ b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/IRootObjectSender.cs @@ -1,7 +1,3 @@ -using System; -using System.Collections.Generic; -using System.Threading; -using System.Threading.Tasks; using Speckle.Core.Models; namespace Speckle.Connectors.Utils.Operations; diff --git a/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/ISyncToMainThread.cs b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/ISyncToMainThread.cs index 533ee8f838..e757070e72 100644 --- a/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/ISyncToMainThread.cs +++ b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/ISyncToMainThread.cs @@ -1,7 +1,4 @@ -using System; -using System.Threading.Tasks; - -namespace Speckle.Connectors.Utils.Operations; +namespace Speckle.Connectors.Utils.Operations; public interface ISyncToMainThread { diff --git a/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/ReceiveOperation.cs b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/ReceiveOperation.cs index 4ca52c9a30..0d1c745791 100644 --- a/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/ReceiveOperation.cs +++ b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/ReceiveOperation.cs @@ -1,7 +1,3 @@ -using System; -using System.Collections.Generic; -using System.Threading; -using System.Threading.Tasks; using Speckle.Connectors.Utils.Builders; using Speckle.Core.Api; using Speckle.Core.Credentials; diff --git a/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/RootObjectSender.cs b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/RootObjectSender.cs index d3a54d0ba1..c46faeb7fc 100644 --- a/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/RootObjectSender.cs +++ b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/RootObjectSender.cs @@ -1,7 +1,3 @@ -using System; -using System.Collections.Generic; -using System.Threading; -using System.Threading.Tasks; using Speckle.Core.Api; using Speckle.Core.Credentials; using Speckle.Core.Models; diff --git a/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/Send.cs b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/Send.cs index 44e4cb21a6..9cecea8d46 100644 --- a/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/Send.cs +++ b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/Send.cs @@ -1,10 +1,5 @@ -using System; -using System.Collections.Concurrent; -using System.Collections.Generic; +using System.Collections.Concurrent; using System.Diagnostics; -using System.Linq; -using System.Threading; -using System.Threading.Tasks; using Serilog.Context; using Speckle.Core.Logging; using Speckle.Core.Models; diff --git a/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/SendInfo.cs b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/SendInfo.cs index be5f595a83..65cd622466 100644 --- a/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/SendInfo.cs +++ b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/SendInfo.cs @@ -1,5 +1,4 @@ -using System.Collections.Generic; -using Speckle.Core.Models; +using Speckle.Core.Models; namespace Speckle.Connectors.Utils.Operations; diff --git a/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/SendOperation.cs b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/SendOperation.cs index b29e9c9fc0..f5f9453077 100644 --- a/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/SendOperation.cs +++ b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/SendOperation.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Threading; -using System.Threading.Tasks; -using Speckle.Connectors.Utils.Builders; +using Speckle.Connectors.Utils.Builders; using Speckle.Core.Models; namespace Speckle.Connectors.Utils.Operations; diff --git a/DUI3-DX/Sdk/Speckle.Connectors.Utils/Reflection/AssemblyExtensions.cs b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Reflection/AssemblyExtensions.cs index 498e928615..5e48c146a6 100644 --- a/DUI3-DX/Sdk/Speckle.Connectors.Utils/Reflection/AssemblyExtensions.cs +++ b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Reflection/AssemblyExtensions.cs @@ -1,4 +1,3 @@ -using System.Linq; using System.Reflection; namespace Speckle.Connectors.Utils.Reflection; diff --git a/DUI3-DX/Sdk/Speckle.Connectors.Utils/SpeckleTopLevelExceptionHandler.cs b/DUI3-DX/Sdk/Speckle.Connectors.Utils/SpeckleTopLevelExceptionHandler.cs index c93d61af5e..0eb92feff5 100644 --- a/DUI3-DX/Sdk/Speckle.Connectors.Utils/SpeckleTopLevelExceptionHandler.cs +++ b/DUI3-DX/Sdk/Speckle.Connectors.Utils/SpeckleTopLevelExceptionHandler.cs @@ -1,5 +1,3 @@ -using System; -using System.Threading.Tasks; using Speckle.Core.Logging; namespace Speckle.Connectors.Utils; diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common/ContextWrapper.cs b/DUI3-DX/Sdk/Speckle.Converters.Common/ContextWrapper.cs index 77794f54e5..02088f06bb 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common/ContextWrapper.cs +++ b/DUI3-DX/Sdk/Speckle.Converters.Common/ContextWrapper.cs @@ -1,6 +1,4 @@ -using System; - -namespace Speckle.Converters.Common; +namespace Speckle.Converters.Common; public class ContextWrapper : IDisposable where TDocument : class diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common/ConversionContextStack.cs b/DUI3-DX/Sdk/Speckle.Converters.Common/ConversionContextStack.cs index e824ed511e..908ce1989d 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common/ConversionContextStack.cs +++ b/DUI3-DX/Sdk/Speckle.Converters.Common/ConversionContextStack.cs @@ -1,5 +1,4 @@ -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; +using System.Diagnostics.CodeAnalysis; namespace Speckle.Converters.Common; diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common/DisplayableObject.cs b/DUI3-DX/Sdk/Speckle.Converters.Common/DisplayableObject.cs index aa80876c98..ac62b9bf41 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common/DisplayableObject.cs +++ b/DUI3-DX/Sdk/Speckle.Converters.Common/DisplayableObject.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using Objects; +using Objects; using Objects.Geometry; using Speckle.Core.Models; diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common/NameAndRankValueAttribute.cs b/DUI3-DX/Sdk/Speckle.Converters.Common/NameAndRankValueAttribute.cs index e1ac7fc04b..54f380eeb0 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common/NameAndRankValueAttribute.cs +++ b/DUI3-DX/Sdk/Speckle.Converters.Common/NameAndRankValueAttribute.cs @@ -1,6 +1,4 @@ -using System; - -namespace Speckle.Converters.Common; +namespace Speckle.Converters.Common; // POC: maybe better to put in utils/reflection [AttributeUsage(AttributeTargets.Class)] diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common/Objects/IConverterResolver.cs b/DUI3-DX/Sdk/Speckle.Converters.Common/Objects/IConverterResolver.cs index f0018be82e..5ba47c7eda 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common/Objects/IConverterResolver.cs +++ b/DUI3-DX/Sdk/Speckle.Converters.Common/Objects/IConverterResolver.cs @@ -1,6 +1,4 @@ -using System; - -namespace Speckle.Converters.Common.Objects; +namespace Speckle.Converters.Common.Objects; public interface IConverterResolver where TConverter : class diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common/RecursiveConveterResolver.cs b/DUI3-DX/Sdk/Speckle.Converters.Common/RecursiveConveterResolver.cs index 60f78389f5..88cdcec475 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common/RecursiveConveterResolver.cs +++ b/DUI3-DX/Sdk/Speckle.Converters.Common/RecursiveConveterResolver.cs @@ -1,5 +1,4 @@ -using System; -using Speckle.Autofac.DependencyInjection; +using Speckle.Autofac.DependencyInjection; using Speckle.Converters.Common.Objects; namespace Speckle.Converters.Common; diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common/SpeckleConversionException.cs b/DUI3-DX/Sdk/Speckle.Converters.Common/SpeckleConversionException.cs index 2500ca9aab..19cbd2bf01 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common/SpeckleConversionException.cs +++ b/DUI3-DX/Sdk/Speckle.Converters.Common/SpeckleConversionException.cs @@ -1,6 +1,4 @@ -using System; - -namespace Speckle.Converters.Common; +namespace Speckle.Converters.Common; public class SpeckleConversionException : Exception { From 8ac7fe21512cfa9843a29fa5523ddf8269a86615 Mon Sep 17 00:00:00 2001 From: Adam Hathcock Date: Wed, 8 May 2024 16:55:12 +0100 Subject: [PATCH 128/261] move more --- .../Bindings/AutocadBasicConnectorBinding.cs | 5 +- .../Bindings/AutocadReceiveBinding.cs | 11 +++-- .../Bindings/AutocadSendBinding.cs | 13 ++--- .../HostApp/AutocadDocumentModelStore.cs | 3 +- .../Bindings/AccountBinding.cs | 1 - .../Bindings/IBasicConnectorBinding.cs | 1 - .../Bindings/IReceiveBinding.cs | 2 - .../Bindings/ISelectionBinding.cs | 6 +-- .../Bindings/ISendBinding.cs | 2 - .../Bindings/ISendBindingUICommands.cs | 2 - .../Bindings/ReceiveBindingUICommands.cs | 1 - .../Bindings/SendBindingUICommands.cs | 1 - .../Bindings/TestBinding.cs | 1 - .../Bridge/BrowserBridge.cs | 47 +++++++++--------- .../Speckle.Connectors.DUI/Bridge/IBridge.cs | 3 +- .../Bridge/SyncToCurrentThread.cs | 4 +- .../Bridge/SyncToUIThread.cs | 4 +- .../Models/Card/CreateVersionArgs.cs | 4 +- .../Models/Card/ModelCard.cs | 11 ++--- .../Models/Card/ModelCardError.cs | 8 ++-- .../Models/Card/ModelCardNotification.cs | 6 +-- .../Models/Card/ModelCardProgress.cs | 4 +- .../Models/Card/ReceiveResult.cs | 4 +- .../Models/Card/ReceiverModelCard.cs | 10 ++-- .../Models/Card/ReceiverModelCardResult.cs | 4 +- .../SendFilter/DirectSelectionSendFilter.cs | 7 ++- .../Card/SendFilter/EverythingSendFilter.cs | 7 ++- .../Models/Card/SendFilter/ISendFilter.cs | 6 +-- .../Models/Card/SenderModelCard.cs | 3 +- .../Models/DocumentInfo.cs | 6 +-- .../Models/DocumentModelStore.cs | 7 +-- .../Settings/CardSetting.cs | 9 ++-- .../Speckle.Connectors.DUI.csproj | 5 -- DUI3-DX/DUI3/Speckle.Connectors.DUI/Url.cs | 4 +- .../Utils/DiscriminatedObjectConverter.cs | 19 ++++---- .../Utils/ModelNotFoundException.cs | 2 +- .../Utils/PropertyValidator.cs | 8 ++-- .../Speckle.Objects.Common.csproj | 3 -- .../NotNullExtensions.cs | 48 +++++++++++++++++++ ...nverters.Common.DependencyInjection.csproj | 2 - .../Speckle.Converters.Common.csproj | 1 - 41 files changed, 152 insertions(+), 143 deletions(-) create mode 100644 DUI3-DX/Sdk/Speckle.Connectors.Utils/NotNullExtensions.cs diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadBasicConnectorBinding.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadBasicConnectorBinding.cs index 81a9c6356b..c84713efd0 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadBasicConnectorBinding.cs +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadBasicConnectorBinding.cs @@ -7,6 +7,7 @@ using Speckle.Connectors.DUI.Models.Card; using Speckle.Core.Credentials; using Speckle.Connectors.Autocad.HostApp.Extensions; +using Speckle.Connectors.Utils; namespace Speckle.Connectors.Autocad.Bindings; @@ -96,14 +97,14 @@ public void HighlightModel(string modelCardId) if (model is SenderModelCard senderModelCard) { - List<(DBObject obj, string applicationId)> dbObjects = doc.GetObjects(senderModelCard.SendFilter.GetObjectIds()); + List<(DBObject obj, string applicationId)> dbObjects = doc.GetObjects((senderModelCard.SendFilter?.GetObjectIds()).Empty()); objectIds = dbObjects.Select(tuple => tuple.obj.Id).ToArray(); } if (model is ReceiverModelCard receiverModelCard) { List<(DBObject obj, string applicationId)> dbObjects = doc.GetObjects( - receiverModelCard.ReceiveResult.BakedObjectIds + (receiverModelCard.ReceiveResult?.BakedObjectIds).Empty() ); objectIds = dbObjects.Select(tuple => tuple.obj.Id).ToArray(); } diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadReceiveBinding.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadReceiveBinding.cs index e35dc56a8c..21f46880f1 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadReceiveBinding.cs +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadReceiveBinding.cs @@ -4,6 +4,7 @@ using Speckle.Connectors.DUI.Models; using Speckle.Connectors.Utils.Cancellation; using Speckle.Connectors.DUI.Models.Card; +using Speckle.Connectors.Utils; using Speckle.Connectors.Utils.Operations; using Speckle.Core.Logging; using ICancelable = System.Reactive.Disposables.ICancelable; @@ -54,11 +55,11 @@ public async Task Receive(string modelCardId) // Receive host objects IEnumerable receivedObjectIds = await unitOfWork.Service .Execute( - modelCard.AccountId, // POC: I hear -you are saying why we're passing them separately. Not sure pass the DUI3-> Connectors.DUI project dependency to the SDK-> Connector.Utils - modelCard.ProjectId, - modelCard.ProjectName, - modelCard.ModelName, - modelCard.SelectedVersionId, + modelCard.AccountId.NotNull(), // POC: I hear -you are saying why we're passing them separately. Not sure pass the DUI3-> Connectors.DUI project dependency to the SDK-> Connector.Utils + modelCard.ProjectId.NotNull(), + modelCard.ProjectName.NotNull(), + modelCard.ModelName.NotNull(), + modelCard.SelectedVersionId.NotNull(), cts.Token, onOperationProgressed: (status, progress) => OnSendOperationProgress(modelCardId, status, progress) ) diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadSendBinding.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadSendBinding.cs index 05ca5806bd..cd9620ba7a 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadSendBinding.cs +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadSendBinding.cs @@ -12,6 +12,7 @@ using Speckle.Core.Models; using ICancelable = System.Reactive.Disposables.ICancelable; using Speckle.Connectors.DUI.Models.Card.SendFilter; +using Speckle.Connectors.Utils; namespace Speckle.Connectors.Autocad.Bindings; @@ -95,11 +96,11 @@ private void RunExpirationChecks() foreach (SenderModelCard modelCard in senders) { - var intersection = modelCard.SendFilter.GetObjectIds().Intersect(objectIdsList).ToList(); + var intersection = modelCard.SendFilter?.GetObjectIds().Intersect(objectIdsList).ToList() ?? new(); bool isExpired = intersection.Count != 0; if (isExpired) { - expiredSenderIds.Add(modelCard.ModelCardId); + expiredSenderIds.Add(modelCard.ModelCardId.NotNull()); modelCard.ChangedObjectIds.UnionWith(intersection); } } @@ -132,16 +133,16 @@ private async Task SendInternal(string modelCardId) // Get elements to convert List<(DBObject obj, string applicationId)> autocadObjects = - Application.DocumentManager.CurrentDocument.GetObjects(modelCard.SendFilter.GetObjectIds()); + Application.DocumentManager.CurrentDocument.GetObjects((modelCard.SendFilter?.GetObjectIds()).Empty()); if (autocadObjects.Count == 0) { throw new InvalidOperationException("No objects were found. Please update your send filter!"); } var sendInfo = new SendInfo( - modelCard.AccountId, - modelCard.ProjectId, - modelCard.ModelId, + modelCard.AccountId.NotNull(), + modelCard.ProjectId.NotNull(), + modelCard.ModelId.NotNull(), _autocadSettings.HostAppInfo.Name, _convertedObjectReferences, modelCard.ChangedObjectIds diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/AutocadDocumentModelStore.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/AutocadDocumentModelStore.cs index f2d2f00bfc..5f13296a42 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/AutocadDocumentModelStore.cs +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/AutocadDocumentModelStore.cs @@ -1,5 +1,6 @@ using Speckle.Connectors.DUI.Models; using Speckle.Connectors.DUI.Models.Card; +using Speckle.Connectors.Utils; using Speckle.Newtonsoft.Json; namespace Speckle.Connectors.Autocad.HostApp; @@ -84,7 +85,7 @@ public override void ReadFromFile() return; } - Models = Deserialize(serializedModelCards); + Models = Deserialize(serializedModelCards).NotNull(); } public override void WriteToFile() diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/AccountBinding.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/AccountBinding.cs index a6cd90ba79..ffd61239c1 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/AccountBinding.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/AccountBinding.cs @@ -1,4 +1,3 @@ -using System.Linq; using Speckle.Connectors.DUI.Bridge; using Speckle.Core.Credentials; diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/IBasicConnectorBinding.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/IBasicConnectorBinding.cs index eb3be48b03..e8d773a9c9 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/IBasicConnectorBinding.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/IBasicConnectorBinding.cs @@ -1,4 +1,3 @@ -using System; using Speckle.Connectors.DUI.Bridge; using Speckle.Connectors.DUI.Models; using Speckle.Connectors.DUI.Models.Card; diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/IReceiveBinding.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/IReceiveBinding.cs index 136c55e310..fc7dd6a2ca 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/IReceiveBinding.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/IReceiveBinding.cs @@ -1,5 +1,3 @@ -using System.Threading.Tasks; - namespace Speckle.Connectors.DUI.Bindings; public interface IReceiveBinding : IBinding diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/ISelectionBinding.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/ISelectionBinding.cs index c7cd2ece98..6f9f8e059d 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/ISelectionBinding.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/ISelectionBinding.cs @@ -1,5 +1,3 @@ -using System.Collections.Generic; - namespace Speckle.Connectors.DUI.Bindings; public interface ISelectionBinding : IBinding @@ -14,6 +12,6 @@ public static class SelectionBindingEvents public class SelectionInfo { - public List SelectedObjectIds { get; set; } - public string Summary { get; set; } + public List? SelectedObjectIds { get; set; } + public string? Summary { get; set; } } diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/ISendBinding.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/ISendBinding.cs index 75f54eb6e0..fb4891792a 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/ISendBinding.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/ISendBinding.cs @@ -1,5 +1,3 @@ -using System.Collections.Generic; -using System.Threading.Tasks; using Speckle.Connectors.DUI.Models.Card.SendFilter; namespace Speckle.Connectors.DUI.Bindings; diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/ISendBindingUICommands.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/ISendBindingUICommands.cs index 77b0620ed1..13848f1a71 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/ISendBindingUICommands.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/ISendBindingUICommands.cs @@ -1,5 +1,3 @@ -using System.Collections.Generic; - namespace Speckle.Connectors.DUI.Bindings; public interface ISendBindingUICommands diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/ReceiveBindingUICommands.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/ReceiveBindingUICommands.cs index 6b9bde8b02..c64cdac40f 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/ReceiveBindingUICommands.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/ReceiveBindingUICommands.cs @@ -1,4 +1,3 @@ -using System.Collections.Generic; using Speckle.Connectors.DUI.Bridge; using Speckle.Connectors.DUI.Models.Card; diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/SendBindingUICommands.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/SendBindingUICommands.cs index 1263ddb1f3..9580413088 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/SendBindingUICommands.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/SendBindingUICommands.cs @@ -1,4 +1,3 @@ -using System.Collections.Generic; using Speckle.Connectors.DUI.Bridge; namespace Speckle.Connectors.DUI.Bindings; diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/TestBinding.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/TestBinding.cs index 0e1152f266..3cb80845ed 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/TestBinding.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/TestBinding.cs @@ -1,4 +1,3 @@ -using System; using System.Diagnostics; using Speckle.Connectors.DUI.Bridge; using Speckle.Core.Logging; diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/BrowserBridge.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/BrowserBridge.cs index c5cfb065cc..dda630ed87 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/BrowserBridge.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/BrowserBridge.cs @@ -1,11 +1,6 @@ -using System; -using System.Collections.Generic; -using System.Linq; using System.Reflection; using System.Runtime.InteropServices; -using System.Threading; using Speckle.Newtonsoft.Json; -using System.Threading.Tasks; using Speckle.Core.Logging; using Speckle.Connectors.DUI.Bindings; using System.Threading.Tasks.Dataflow; @@ -31,30 +26,30 @@ public class BrowserBridge : IBridge private readonly Dictionary _resultsStore = new(); private readonly SynchronizationContext _mainThreadContext; - private Dictionary BindingMethodCache { get; set; } - private ActionBlock _actionBlock; + private Dictionary BindingMethodCache { get; set; } = new(); + private ActionBlock? _actionBlock; private Action? _scriptMethod; - private IBinding _binding; - private Type _bindingType; + private IBinding? _binding; + private Type? _bindingType; private readonly ILogger _logger; /// /// Action that opens up the developer tools of the respective browser we're using. While webview2 allows for "right click, inspect", cefsharp does not - hence the need for this. /// - public Action ShowDevToolsAction { get; set; } + public Action? ShowDevToolsAction { get; set; } - public string FrontendBoundName { get; private set; } + public string? FrontendBoundName { get; private set; } - public object Browser { get; private set; } + public object? Browser { get; private set; } - public IBinding Binding + public IBinding? Binding { get => _binding; private set { - if (_binding != null || this != value.Parent) + if (_binding != null || this != value?.Parent) { throw new ArgumentException($"Binding: {FrontendBoundName} is already bound or does not match bridge"); } @@ -142,7 +137,7 @@ public string[] GetBindingsMethodNames() /// public void RunMethod(string methodName, string requestId, string args) { - _actionBlock.Post( + _actionBlock?.Post( new RunMethodArgs { MethodName = methodName, @@ -189,16 +184,16 @@ private void ExecuteMethod(string methodName, string requestId, string args) if (!BindingMethodCache.TryGetValue(methodName, out MethodInfo method)) { throw new SpeckleException( - $"Cannot find method {methodName} in bindings class {_bindingType.AssemblyQualifiedName}." + $"Cannot find method {methodName} in bindings class {_bindingType?.AssemblyQualifiedName}." ); } var parameters = method.GetParameters(); var jsonArgsArray = JsonConvert.DeserializeObject(args); - if (parameters.Length != jsonArgsArray.Length) + if (parameters.Length != jsonArgsArray?.Length) { throw new SpeckleException( - $"Wrong number of arguments when invoking binding function {methodName}, expected {parameters.Length}, but got {jsonArgsArray.Length}." + $"Wrong number of arguments when invoking binding function {methodName}, expected {parameters.Length}, but got {jsonArgsArray?.Length}." ); } @@ -207,6 +202,10 @@ private void ExecuteMethod(string methodName, string requestId, string args) for (int i = 0; i < typedArgs.Length; i++) { var ccc = JsonConvert.DeserializeObject(jsonArgsArray[i], parameters[i].ParameterType, _serializerOptions); + if (ccc is null) + { + continue; + } typedArgs[i] = ccc; } @@ -227,7 +226,7 @@ private void ExecuteMethod(string methodName, string requestId, string args) // If has a "Result" property return the value otherwise null (Task etc) PropertyInfo resultProperty = resultTypedTask.GetType().GetProperty("Result"); - object taskResult = resultProperty?.GetValue(resultTypedTask); + object? taskResult = resultProperty?.GetValue(resultTypedTask); resultJson = JsonConvert.SerializeObject(taskResult, _serializerOptions); } @@ -251,9 +250,13 @@ private void ExecuteMethod(string methodName, string requestId, string args) /// /// /// - private void NotifyUIMethodCallResultReady(string requestId, string serializedData = null) + private void NotifyUIMethodCallResultReady(string requestId, string? serializedData = null) { - _resultsStore[requestId] = serializedData; + if (serializedData is not null) + { + _resultsStore[requestId] = serializedData; + } + string script = $"{FrontendBoundName}.responseReady('{requestId}')"; _scriptMethod!(script); } @@ -276,7 +279,7 @@ public string GetCallResult(string requestId) /// public void ShowDevTools() { - ShowDevToolsAction(); + ShowDevToolsAction?.Invoke(); } public void OpenUrl(string url) diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/IBridge.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/IBridge.cs index 19830605df..f569ed6284 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/IBridge.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/IBridge.cs @@ -1,4 +1,3 @@ -using System; using Speckle.Connectors.DUI.Bindings; namespace Speckle.Connectors.DUI.Bridge; @@ -11,7 +10,7 @@ namespace Speckle.Connectors.DUI.Bridge; public interface IBridge { // POC: documnetation comments - string FrontendBoundName { get; } + string? FrontendBoundName { get; } void AssociateWithBinding(IBinding binding, Action scriptMethod, object browser, Action showDevToolsAction); diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/SyncToCurrentThread.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/SyncToCurrentThread.cs index 723d9c6168..25168fcf32 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/SyncToCurrentThread.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/SyncToCurrentThread.cs @@ -1,6 +1,4 @@ -using System; -using System.Threading.Tasks; -using Speckle.Connectors.Utils.Operations; +using Speckle.Connectors.Utils.Operations; namespace Speckle.Connectors.DUI.Bridge; diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/SyncToUIThread.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/SyncToUIThread.cs index ac9e74086e..3d1d1e21b5 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/SyncToUIThread.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/SyncToUIThread.cs @@ -1,6 +1,4 @@ -using System; -using System.Diagnostics.CodeAnalysis; -using System.Threading.Tasks; +using System.Diagnostics.CodeAnalysis; using Speckle.Connectors.Utils.Operations; namespace Speckle.Connectors.DUI.Bridge; diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/CreateVersionArgs.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/CreateVersionArgs.cs index 7a71b2d071..c4fbcc24d3 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/CreateVersionArgs.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/CreateVersionArgs.cs @@ -2,6 +2,6 @@ public class CreateVersionArgs { - public string ModelCardId { get; set; } - public string ObjectId { get; set; } + public string? ModelCardId { get; set; } + public string? ObjectId { get; set; } } diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/ModelCard.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/ModelCard.cs index e883ff8d22..51aae18fb2 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/ModelCard.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/ModelCard.cs @@ -1,4 +1,3 @@ -using System.Collections.Generic; using Speckle.Connectors.DUI.Settings; using Speckle.Connectors.DUI.Utils; @@ -10,18 +9,18 @@ public class ModelCard : DiscriminatedObject /// This is a unique id generated by the ui to make model cards easier to reference around. /// It's not the actual model (branch) id. /// - public string ModelCardId { get; set; } + public string? ModelCardId { get; set; } /// /// Model id. FKA branch id. /// - public string ModelId { get; set; } + public string? ModelId { get; set; } /// /// Project id. FKA stream id. /// - public string ProjectId { get; set; } - public string AccountId { get; set; } + public string? ProjectId { get; set; } + public string? AccountId { get; set; } - public List Settings { get; set; } + public List? Settings { get; set; } } diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/ModelCardError.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/ModelCardError.cs index cf2ab19116..b9c3c4d3ac 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/ModelCardError.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/ModelCardError.cs @@ -1,9 +1,7 @@ -using System; - -namespace Speckle.Connectors.DUI.Models.Card; +namespace Speckle.Connectors.DUI.Models.Card; public class ModelCardError { - public string ModelCardId { get; set; } - public Exception Error { get; set; } + public string? ModelCardId { get; set; } + public Exception? Error { get; set; } } diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/ModelCardNotification.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/ModelCardNotification.cs index 0970fcdcf7..0a7b60c9d6 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/ModelCardNotification.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/ModelCardNotification.cs @@ -2,9 +2,9 @@ public class ModelCardNotification { - public string ModelCardId { get; set; } - public string Text { get; set; } - public string Level { get; set; } + public string? ModelCardId { get; set; } + public string? Text { get; set; } + public string? Level { get; set; } public int Timeout { get; set; } public bool Dismissible { get; set; } = true; } diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/ModelCardProgress.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/ModelCardProgress.cs index 88a8a66d39..5677a1fc4e 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/ModelCardProgress.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/ModelCardProgress.cs @@ -2,8 +2,8 @@ public class ModelCardProgress { - public string ModelCardId { get; set; } - public string Status { get; set; } + public string? ModelCardId { get; set; } + public string? Status { get; set; } /// /// Progress value between 0 and 1 to calculate UI progress bar width. diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/ReceiveResult.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/ReceiveResult.cs index 78d0e23aca..81431dafb2 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/ReceiveResult.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/ReceiveResult.cs @@ -1,9 +1,7 @@ -using System.Collections.Generic; - namespace Speckle.Connectors.DUI.Models.Card; public class ReceiveResult { - public List BakedObjectIds { get; set; } + public List? BakedObjectIds { get; set; } public bool Display { get; set; } } diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/ReceiverModelCard.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/ReceiverModelCard.cs index a9fd1821df..5b69884618 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/ReceiverModelCard.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/ReceiverModelCard.cs @@ -2,10 +2,10 @@ namespace Speckle.Connectors.DUI.Models.Card; public class ReceiverModelCard : ModelCard { - public string ProjectName { get; set; } - public string ModelName { get; set; } - public string SelectedVersionId { get; set; } - public string LatestVersionId { get; set; } + public string? ProjectName { get; set; } + public string? ModelName { get; set; } + public string? SelectedVersionId { get; set; } + public string? LatestVersionId { get; set; } public bool HasDismissedUpdateWarning { get; set; } - public ReceiveResult ReceiveResult { get; set; } + public ReceiveResult? ReceiveResult { get; set; } } diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/ReceiverModelCardResult.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/ReceiverModelCardResult.cs index aae9f9b67f..161cbe4b66 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/ReceiverModelCardResult.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/ReceiverModelCardResult.cs @@ -2,6 +2,6 @@ namespace Speckle.Connectors.DUI.Models.Card; public class ReceiverModelCardResult { - public string ModelCardId { get; set; } - public ReceiveResult ReceiveResult { get; set; } + public string? ModelCardId { get; set; } + public ReceiveResult? ReceiveResult { get; set; } } diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/SendFilter/DirectSelectionSendFilter.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/SendFilter/DirectSelectionSendFilter.cs index eee7c6a5f6..148f386e57 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/SendFilter/DirectSelectionSendFilter.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/SendFilter/DirectSelectionSendFilter.cs @@ -1,12 +1,11 @@ -using System.Collections.Generic; -using Speckle.Connectors.DUI.Utils; +using Speckle.Connectors.DUI.Utils; namespace Speckle.Connectors.DUI.Models.Card.SendFilter; public abstract class DirectSelectionSendFilter : DiscriminatedObject, ISendFilter { - public string Name { get; set; } = "Selection"; - public string Summary { get; set; } + public string? Name { get; set; } = "Selection"; + public string? Summary { get; set; } public bool IsDefault { get; set; } public List SelectedObjectIds { get; set; } = new List(); public abstract List GetObjectIds(); diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/SendFilter/EverythingSendFilter.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/SendFilter/EverythingSendFilter.cs index adc5151503..b4617ee623 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/SendFilter/EverythingSendFilter.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/SendFilter/EverythingSendFilter.cs @@ -1,12 +1,11 @@ -using System.Collections.Generic; -using Speckle.Connectors.DUI.Utils; +using Speckle.Connectors.DUI.Utils; namespace Speckle.Connectors.DUI.Models.Card.SendFilter; public abstract class EverythingSendFilter : DiscriminatedObject, ISendFilter { - public string Name { get; set; } = "Everything"; - public string Summary { get; set; } = "All supported objects in the file."; + public string? Name { get; set; } = "Everything"; + public string? Summary { get; set; } = "All supported objects in the file."; public bool IsDefault { get; set; } public abstract List GetObjectIds(); public abstract bool CheckExpiry(string[] changedObjectIds); diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/SendFilter/ISendFilter.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/SendFilter/ISendFilter.cs index 0b7d1a745c..e3cdf6afa1 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/SendFilter/ISendFilter.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/SendFilter/ISendFilter.cs @@ -1,11 +1,9 @@ -using System.Collections.Generic; - namespace Speckle.Connectors.DUI.Models.Card.SendFilter; public interface ISendFilter { - public string Name { get; set; } - public string Summary { get; set; } + public string? Name { get; set; } + public string? Summary { get; set; } public bool IsDefault { get; set; } /// diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/SenderModelCard.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/SenderModelCard.cs index 3d8376b037..ecd33fba44 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/SenderModelCard.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/SenderModelCard.cs @@ -1,4 +1,3 @@ -using System.Collections.Generic; using Speckle.Connectors.DUI.Models.Card.SendFilter; using Speckle.Newtonsoft.Json; @@ -6,7 +5,7 @@ namespace Speckle.Connectors.DUI.Models.Card; public class SenderModelCard : ModelCard { - public ISendFilter SendFilter { get; set; } + public ISendFilter? SendFilter { get; set; } [JsonIgnore] public HashSet ChangedObjectIds { get; set; } = new(); diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/DocumentInfo.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/DocumentInfo.cs index 357b286dc2..0781917d1f 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/DocumentInfo.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/DocumentInfo.cs @@ -2,14 +2,14 @@ namespace Speckle.Connectors.DUI.Models; public class DocumentInfo { - public string Location { get; set; + public string? Location { get; set; //?.Replace("\\", "\\\\"); // for some reason, when returning variables from a direct binding call //we don't need this. nevertheless, after switching to a post response back to the ui, //we need this to ensure deserialization in js doesn't throw. it's frustrating! } - public string Name { get; set; } - public string Id { get; set; } + public string? Name { get; set; } + public string? Id { get; set; } public string? Message { get; set; } } diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/DocumentModelStore.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/DocumentModelStore.cs index 4a84af29d8..2cbc36e654 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/DocumentModelStore.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/DocumentModelStore.cs @@ -1,6 +1,3 @@ -using System; -using System.Collections.Generic; -using System.Linq; using Speckle.Connectors.DUI.Utils; using Speckle.Connectors.DUI.Objects; using Speckle.Newtonsoft.Json; @@ -28,7 +25,7 @@ protected DocumentModelStore(JsonSerializerSettings serializerOptions) /// This event is triggered by each specific host app implementation of the document model store. /// // POC: unsure about the PublicAPI annotation, unsure if this changed handle should live here on the store... :/ - public event EventHandler DocumentChanged; + public event EventHandler? DocumentChanged; public virtual bool IsDocumentInit { get; set; } @@ -55,7 +52,7 @@ protected string Serialize() } // POC: this seemms more like a IModelsDeserializer?, seems disconnected from this class - protected List Deserialize(string models) + protected List? Deserialize(string models) { return JsonConvert.DeserializeObject>(models, _serializerOptions); } diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Settings/CardSetting.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Settings/CardSetting.cs index b7cc2bf382..6945a3d4af 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Settings/CardSetting.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Settings/CardSetting.cs @@ -1,13 +1,12 @@ -using System.Collections.Generic; using Speckle.Connectors.DUI.Utils; namespace Speckle.Connectors.DUI.Settings; public class CardSetting : DiscriminatedObject { - public string Id { get; set; } - public string Title { get; set; } - public string Type { get; set; } - public object Value { get; set; } + public string? Id { get; set; } + public string? Title { get; set; } + public string? Type { get; set; } + public object? Value { get; set; } public List? Enum { get; set; } } diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Speckle.Connectors.DUI.csproj b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Speckle.Connectors.DUI.csproj index d94af257c9..2e17ee418c 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Speckle.Connectors.DUI.csproj +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Speckle.Connectors.DUI.csproj @@ -2,17 +2,12 @@ netstandard2.0 - enable - - - false - diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Url.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Url.cs index 4f63cfff78..b5f5a66f1b 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Url.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Url.cs @@ -1,6 +1,4 @@ -using System; - -namespace Speckle.Connectors.DUI; +namespace Speckle.Connectors.DUI; // POC: XAML file accept Static only, but later we can search more is it possible to inject this? or necessary?? diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Utils/DiscriminatedObjectConverter.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Utils/DiscriminatedObjectConverter.cs index 42d6bd145b..079a7060f1 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Utils/DiscriminatedObjectConverter.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Utils/DiscriminatedObjectConverter.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; using System.Diagnostics; -using System.Linq; using System.Reflection; using Speckle.Core.Serialisation; using Speckle.Newtonsoft.Json; @@ -25,16 +22,20 @@ public class DiscriminatedObjectConverter : JsonConverter NullValueHandling = NullValueHandling.Ignore }; - public override void WriteJson(JsonWriter writer, DiscriminatedObject value, JsonSerializer serializer) + public override void WriteJson(JsonWriter writer, DiscriminatedObject? value, JsonSerializer serializer) { + if (value is null) + { + return; + } var jo = JObject.FromObject(value, _localSerializer); jo.WriteTo(writer); } - public override DiscriminatedObject ReadJson( + public override DiscriminatedObject? ReadJson( JsonReader reader, Type objectType, - DiscriminatedObject existingValue, + DiscriminatedObject? existingValue, bool hasExistingValue, JsonSerializer serializer ) @@ -116,13 +117,13 @@ public class AbstractConverter : JsonConverter { public override bool CanConvert(Type objectType) => objectType == typeof(TAbstract); - public override object ReadJson( + public override object? ReadJson( JsonReader reader, Type objectType, - object existingValue, + object? existingValue, JsonSerializer serializer ) => serializer.Deserialize(reader); - public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) => + public override void WriteJson(JsonWriter writer, object? value, JsonSerializer serializer) => serializer.Serialize(writer, value); } diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Utils/ModelNotFoundException.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Utils/ModelNotFoundException.cs index 742050b6b3..a856d5b130 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Utils/ModelNotFoundException.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Utils/ModelNotFoundException.cs @@ -1,5 +1,5 @@ // POC: why is SpeckleException in this namespace? :8 -using System; + using Speckle.Core.Logging; namespace Speckle.Connectors.DUI.Utils; diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Utils/PropertyValidator.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Utils/PropertyValidator.cs index b4fd6f1fd8..6ad8feec42 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Utils/PropertyValidator.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Utils/PropertyValidator.cs @@ -1,6 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; +using Speckle.Connectors.Utils; using Speckle.Newtonsoft.Json; namespace Speckle.Connectors.DUI.Utils; @@ -8,7 +6,7 @@ namespace Speckle.Connectors.DUI.Utils; public class PropertyValidator : DiscriminatedObject { [JsonIgnore] - public List JsonPropertyNames { get; set; } + public List? JsonPropertyNames { get; set; } public bool InitializeNewProperties() { @@ -39,7 +37,7 @@ public bool CheckRemovedProperties() bool removedPropertiesExist = false; var currentPropertyNames = this.GetType().GetProperties().Select(p => p.Name).ToList(); - foreach (var jsonPropName in JsonPropertyNames) + foreach (var jsonPropName in JsonPropertyNames.Empty()) { if (!currentPropertyNames.Contains(jsonPropName)) { diff --git a/DUI3-DX/Objects/Speckle.Objects.Common/Speckle.Objects.Common.csproj b/DUI3-DX/Objects/Speckle.Objects.Common/Speckle.Objects.Common.csproj index 02d764eedd..1b98c0f42c 100644 --- a/DUI3-DX/Objects/Speckle.Objects.Common/Speckle.Objects.Common.csproj +++ b/DUI3-DX/Objects/Speckle.Objects.Common/Speckle.Objects.Common.csproj @@ -1,10 +1,7 @@  - 10.0 - enable netstandard2.0 - disable diff --git a/DUI3-DX/Sdk/Speckle.Connectors.Utils/NotNullExtensions.cs b/DUI3-DX/Sdk/Speckle.Connectors.Utils/NotNullExtensions.cs new file mode 100644 index 0000000000..497edc20ad --- /dev/null +++ b/DUI3-DX/Sdk/Speckle.Connectors.Utils/NotNullExtensions.cs @@ -0,0 +1,48 @@ +namespace Speckle.Connectors.Utils; + +public static class NotNullExtensions +{ + public static IEnumerable Empty(this IEnumerable? source) => source ?? Enumerable.Empty(); + + public static async Task NotNull(this Task task, string? message = null) + where T : class + { + var x = await task.ConfigureAwait(false); + if (x is null) + { + throw new ArgumentNullException(message ?? "Value is null"); + } + return x; + } + + public static async Task NotNull(this Task task, string? message = null) + where T : struct + { + var x = await task.ConfigureAwait(false); + if (x is null) + { + throw new ArgumentNullException(message ?? "Value is null"); + } + return x.Value; + } + + public static T NotNull(this T? obj, string? message = null) + where T : class + { + if (obj is null) + { + throw new ArgumentNullException(message ?? "Value is null"); + } + return obj; + } + + public static T NotNull(this T? obj, string? message = null) + where T : struct + { + if (obj is null) + { + throw new ArgumentNullException(message ?? "Value is null"); + } + return obj.Value; + } +} diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/Speckle.Converters.Common.DependencyInjection.csproj b/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/Speckle.Converters.Common.DependencyInjection.csproj index 6bacb1cc56..7675aeeae6 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/Speckle.Converters.Common.DependencyInjection.csproj +++ b/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/Speckle.Converters.Common.DependencyInjection.csproj @@ -2,8 +2,6 @@ netstandard2.0 - enable - enable diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common/Speckle.Converters.Common.csproj b/DUI3-DX/Sdk/Speckle.Converters.Common/Speckle.Converters.Common.csproj index 313a26cd6a..7c611c401a 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common/Speckle.Converters.Common.csproj +++ b/DUI3-DX/Sdk/Speckle.Converters.Common/Speckle.Converters.Common.csproj @@ -2,7 +2,6 @@ netstandard2.0 - enable From 08dc89756f29dde6046ca5774ebd98aea1583cf7 Mon Sep 17 00:00:00 2001 From: Adam Hathcock Date: Wed, 8 May 2024 16:55:23 +0100 Subject: [PATCH 129/261] fmt --- .../Bindings/AutocadBasicConnectorBinding.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadBasicConnectorBinding.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadBasicConnectorBinding.cs index c84713efd0..46f1f6350b 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadBasicConnectorBinding.cs +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadBasicConnectorBinding.cs @@ -97,7 +97,9 @@ public void HighlightModel(string modelCardId) if (model is SenderModelCard senderModelCard) { - List<(DBObject obj, string applicationId)> dbObjects = doc.GetObjects((senderModelCard.SendFilter?.GetObjectIds()).Empty()); + List<(DBObject obj, string applicationId)> dbObjects = doc.GetObjects( + (senderModelCard.SendFilter?.GetObjectIds()).Empty() + ); objectIds = dbObjects.Select(tuple => tuple.obj.Id).ToArray(); } From 17819afcc700680bc8135c2932cb9077ebdd93ed Mon Sep 17 00:00:00 2001 From: Alan Rynne Date: Wed, 8 May 2024 22:20:26 +0200 Subject: [PATCH 130/261] fix: Do not pack RevitAPI nor Cef in Revit Connector (#3386) --- .../Speckle.Connectors.Revit2023.csproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.Revit2023/Speckle.Connectors.Revit2023.csproj b/DUI3-DX/Connectors/Revit/Speckle.Connectors.Revit2023/Speckle.Connectors.Revit2023.csproj index 23eb4324dc..31bb113828 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.Revit2023/Speckle.Connectors.Revit2023.csproj +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.Revit2023/Speckle.Connectors.Revit2023.csproj @@ -34,11 +34,11 @@ - + - + From 23527bd0d2d6a0ee19a4248ad629d457044bff47 Mon Sep 17 00:00:00 2001 From: Adam Hathcock Date: Thu, 9 May 2024 08:41:59 +0100 Subject: [PATCH 131/261] fix more usings and nullables --- .../Speckle.Core.Tests.Unit/Helpers/Path.cs | 1 - .../Logging/SpeckleLogTests.cs | 1 - .../Models/UtilitiesTests.cs | 3 +-- .../SerializerBreakingChanges.cs | 1 - .../Transports/SQLiteTransportTests.cs | 1 - .../Transports/TransportTests.cs | 1 - .../Bindings/ArcGISReceiveBinding.cs | 11 ++++---- .../Bindings/ArcGISSendBinding.cs | 13 +++++----- .../Bindings/BasicConnectorBindingRevit.cs | 2 -- .../Bindings/Filters.cs | 2 -- .../Bindings/SelectionBinding.cs | 1 - .../Bindings/SendBinding.cs | 5 ---- .../DependencyInjection/AutofacUIModule.cs | 1 - .../HostApp/DocumentModelStorageSchema.cs | 3 +-- .../HostApp/Elements.cs | 2 -- .../HostApp/IdStorageSchema.cs | 3 +-- .../HostApp/RevitDocumentStore.cs | 2 -- .../Operations/Send/RootObjectBuilder.cs | 4 --- .../Plugin/IRevitIdleManager.cs | 2 -- .../Plugin/RevitExternalApplication.cs | 1 - .../Plugin/RevitIdleManager.cs | 2 -- .../Plugin/RevitPlugin.cs | 3 --- .../Bindings/RhinoBasicConnectorBinding.cs | 8 +++--- .../Bindings/RhinoReceiveBinding.cs | 18 +++++-------- .../Bindings/RhinoSelectionBinding.cs | 2 -- .../Bindings/RhinoSendBinding.cs | 26 ++++++++----------- .../DependencyInjection/AutofacRhinoModule.cs | 1 - .../Extensions/BoundingBox.cs | 3 +-- .../Filters/RhinoEverythingFilter.cs | 3 +-- .../Filters/RhinoSelectionFilter.cs | 2 -- .../HostApp/RhinoDocumentStore.cs | 3 +-- .../HostApp/RhinoIdleManager.cs | 1 - .../HostApp/RhinoSettings.cs | 3 +-- .../Operations/Receive/DisableRedrawScope.cs | 3 +-- .../Receive/RhinoHostObjectBuilder.cs | 4 --- .../Operations/Send/RootObjectBuilder.cs | 4 --- .../Speckle.Connectors.Rhino7Command.cs | 1 - .../Plugin/Speckle.Connectors.Rhino7Plugin.cs | 3 +-- 38 files changed, 43 insertions(+), 107 deletions(-) diff --git a/Core/Tests/Speckle.Core.Tests.Unit/Helpers/Path.cs b/Core/Tests/Speckle.Core.Tests.Unit/Helpers/Path.cs index 333954e93e..7878ab510c 100644 --- a/Core/Tests/Speckle.Core.Tests.Unit/Helpers/Path.cs +++ b/Core/Tests/Speckle.Core.Tests.Unit/Helpers/Path.cs @@ -1,5 +1,4 @@ using System.Runtime.InteropServices; -using System.Text.RegularExpressions; using NUnit.Framework; using Speckle.Core.Helpers; diff --git a/Core/Tests/Speckle.Core.Tests.Unit/Logging/SpeckleLogTests.cs b/Core/Tests/Speckle.Core.Tests.Unit/Logging/SpeckleLogTests.cs index 6a97323345..22b703300c 100644 --- a/Core/Tests/Speckle.Core.Tests.Unit/Logging/SpeckleLogTests.cs +++ b/Core/Tests/Speckle.Core.Tests.Unit/Logging/SpeckleLogTests.cs @@ -1,6 +1,5 @@ using NUnit.Framework; using Serilog.Context; -using Serilog.Core; using Serilog.Events; using Speckle.Core.Logging; diff --git a/Core/Tests/Speckle.Core.Tests.Unit/Models/UtilitiesTests.cs b/Core/Tests/Speckle.Core.Tests.Unit/Models/UtilitiesTests.cs index ffa5bce998..f8c47feb14 100644 --- a/Core/Tests/Speckle.Core.Tests.Unit/Models/UtilitiesTests.cs +++ b/Core/Tests/Speckle.Core.Tests.Unit/Models/UtilitiesTests.cs @@ -1,5 +1,4 @@ -using System.Collections; -using NUnit.Framework; +using NUnit.Framework; using Speckle.Core.Helpers; namespace Speckle.Core.Tests.Unit.Models; diff --git a/Core/Tests/Speckle.Core.Tests.Unit/Serialisation/SerializerBreakingChanges.cs b/Core/Tests/Speckle.Core.Tests.Unit/Serialisation/SerializerBreakingChanges.cs index 163d7abd21..0fc9549fd2 100644 --- a/Core/Tests/Speckle.Core.Tests.Unit/Serialisation/SerializerBreakingChanges.cs +++ b/Core/Tests/Speckle.Core.Tests.Unit/Serialisation/SerializerBreakingChanges.cs @@ -1,5 +1,4 @@ using NUnit.Framework; -using Speckle.Core.Logging; using Speckle.Core.Serialisation; namespace Speckle.Core.Tests.Unit.Serialisation; diff --git a/Core/Tests/Speckle.Core.Tests.Unit/Transports/SQLiteTransportTests.cs b/Core/Tests/Speckle.Core.Tests.Unit/Transports/SQLiteTransportTests.cs index 95504f0d03..735536cdcc 100644 --- a/Core/Tests/Speckle.Core.Tests.Unit/Transports/SQLiteTransportTests.cs +++ b/Core/Tests/Speckle.Core.Tests.Unit/Transports/SQLiteTransportTests.cs @@ -1,6 +1,5 @@ using Microsoft.Data.Sqlite; using NUnit.Framework; -using NUnit.Framework.Constraints; using Speckle.Core.Transports; namespace Speckle.Core.Tests.Unit.Transports; diff --git a/Core/Tests/Speckle.Core.Tests.Unit/Transports/TransportTests.cs b/Core/Tests/Speckle.Core.Tests.Unit/Transports/TransportTests.cs index b264a6fe9d..067c5298c3 100644 --- a/Core/Tests/Speckle.Core.Tests.Unit/Transports/TransportTests.cs +++ b/Core/Tests/Speckle.Core.Tests.Unit/Transports/TransportTests.cs @@ -1,6 +1,5 @@ #nullable enable using NUnit.Framework; -using Speckle.Core.Api; using Speckle.Core.Transports; using Speckle.Newtonsoft.Json; diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISReceiveBinding.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISReceiveBinding.cs index d92413b358..cd8574f4a7 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISReceiveBinding.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISReceiveBinding.cs @@ -3,6 +3,7 @@ using Speckle.Connectors.DUI.Bindings; using Speckle.Connectors.DUI.Bridge; using Speckle.Connectors.DUI.Models.Card; +using Speckle.Connectors.Utils; using Speckle.Connectors.Utils.Cancellation; using Speckle.Connectors.Utils.Operations; using Speckle.Core.Logging; @@ -52,11 +53,11 @@ public async Task Receive(string modelCardId) // Receive host objects IEnumerable receivedObjectIds = await unitOfWork.Service .Execute( - modelCard.AccountId, // POC: I hear -you are saying why we're passing them separately. Not sure pass the DUI3-> Connectors.DUI project dependency to the SDK-> Connector.Utils - modelCard.ProjectId, - modelCard.ProjectName, - modelCard.ModelName, - modelCard.SelectedVersionId, + modelCard.AccountId.NotNull(), // POC: I hear -you are saying why we're passing them separately. Not sure pass the DUI3-> Connectors.DUI project dependency to the SDK-> Connector.Utils + modelCard.ProjectId.NotNull(), + modelCard.ProjectName.NotNull(), + modelCard.ModelName.NotNull(), + modelCard.SelectedVersionId.NotNull(), cts.Token, (status, progress) => OnSendOperationProgress(modelCardId, status, progress) ) diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISSendBinding.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISSendBinding.cs index b8abea01bd..74d000a2d5 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISSendBinding.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISSendBinding.cs @@ -10,6 +10,7 @@ using Speckle.Connectors.DUI.Models.Card; using Speckle.Connectors.DUI.Models.Card.SendFilter; using Speckle.Connectors.DUI.Settings; +using Speckle.Connectors.Utils; namespace Speckle.Connectors.ArcGIS.Bindings; @@ -85,10 +86,10 @@ public async Task Send(string modelCardId) string versionId = await unitOfWork.Service .Execute( - modelCard.SendFilter, - modelCard.AccountId, - modelCard.ProjectId, - modelCard.ModelId, + modelCard.SendFilter.NotNull(), + modelCard.AccountId.NotNull(), + modelCard.ProjectId.NotNull(), + modelCard.ModelId.NotNull(), (status, progress) => OnSendOperationProgress(modelCardId, status, progress), cts.Token ) @@ -118,10 +119,10 @@ private void RunExpirationChecks() foreach (var sender in senders) { - bool isExpired = sender.SendFilter.CheckExpiry(ChangedObjectIds.ToArray()); + bool isExpired = sender.SendFilter?.CheckExpiry(ChangedObjectIds.ToArray()) ?? false; if (isExpired) { - expiredSenderIds.Add(sender.ModelCardId); + expiredSenderIds.Add(sender.ModelCardId.NotNull()); } } diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/BasicConnectorBindingRevit.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/BasicConnectorBindingRevit.cs index 4eb94b969b..e0c76b56f5 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/BasicConnectorBindingRevit.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/BasicConnectorBindingRevit.cs @@ -1,5 +1,3 @@ -using System; -using System.Linq; using System.Reflection; using Autodesk.Revit.DB; using Revit.Async; diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/Filters.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/Filters.cs index 7d9a5133fe..4299f92d64 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/Filters.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/Filters.cs @@ -1,5 +1,3 @@ -using System.Collections.Generic; -using System.Linq; using Speckle.Connectors.DUI.Models.Card.SendFilter; namespace Speckle.Connectors.Revit.Bindings; diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SelectionBinding.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SelectionBinding.cs index ee69c66e52..31da50ce5a 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SelectionBinding.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SelectionBinding.cs @@ -1,4 +1,3 @@ -using System.Linq; using Speckle.Connectors.DUI.Bindings; using Speckle.Connectors.DUI.Bridge; using Speckle.Connectors.DUI.Models; diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SendBinding.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SendBinding.cs index 67fa8c8b21..324d1a0a47 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SendBinding.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SendBinding.cs @@ -1,6 +1,3 @@ -using System; -using System.Collections.Generic; -using System.Linq; using Autodesk.Revit.DB; using Speckle.Connectors.DUI.Models.Card.SendFilter; using Speckle.Connectors.Utils.Cancellation; @@ -8,8 +5,6 @@ using Speckle.Connectors.Revit.Plugin; using Speckle.Core.Logging; using Speckle.Connectors.Utils; -using System.Threading.Tasks; -using System.Threading; using Speckle.Converters.RevitShared.Helpers; using Speckle.Connectors.DUI.Models.Card; using Speckle.Connectors.DUI.Bindings; diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/AutofacUIModule.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/AutofacUIModule.cs index d3e86d8ac3..a5a9494d03 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/AutofacUIModule.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/AutofacUIModule.cs @@ -1,4 +1,3 @@ -using System; using System.IO; using Autodesk.Revit.DB; using Autofac; diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/DocumentModelStorageSchema.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/DocumentModelStorageSchema.cs index 788b8dae4a..ded698f755 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/DocumentModelStorageSchema.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/DocumentModelStorageSchema.cs @@ -1,5 +1,4 @@ -using System; -using Autodesk.Revit.DB.ExtensibleStorage; +using Autodesk.Revit.DB.ExtensibleStorage; namespace Speckle.Connectors.Revit.HostApp; diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/Elements.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/Elements.cs index 1718e5606e..acf4dc1d2e 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/Elements.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/Elements.cs @@ -1,5 +1,3 @@ -using System.Collections.Generic; -using System.Linq; using Autodesk.Revit.DB; namespace Speckle.Connectors.Revit.HostApp; diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/IdStorageSchema.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/IdStorageSchema.cs index cd7cd8147c..398c972678 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/IdStorageSchema.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/IdStorageSchema.cs @@ -1,5 +1,4 @@ -using System; -using Autodesk.Revit.DB.ExtensibleStorage; +using Autodesk.Revit.DB.ExtensibleStorage; namespace Speckle.Connectors.Revit.HostApp; diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/RevitDocumentStore.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/RevitDocumentStore.cs index b3e4c339a4..0130c638b7 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/RevitDocumentStore.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/RevitDocumentStore.cs @@ -1,5 +1,3 @@ -using System; -using System.Collections.Generic; using System.Diagnostics; using Autodesk.Revit.DB; using Autodesk.Revit.DB.ExtensibleStorage; diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RootObjectBuilder.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RootObjectBuilder.cs index ea69596b5d..ab17b54882 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RootObjectBuilder.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RootObjectBuilder.cs @@ -1,11 +1,7 @@ -using System; -using System.Collections.Generic; using Speckle.Converters.Common; using Speckle.Core.Models; -using System.Threading; using Autodesk.Revit.DB; using Speckle.Converters.RevitShared.Helpers; -using System.Linq; using Speckle.Connectors.Utils.Builders; using Speckle.Connectors.Utils.Operations; using Speckle.Core.Logging; diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/IRevitIdleManager.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/IRevitIdleManager.cs index ab7fcc435d..3a8360cc90 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/IRevitIdleManager.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/IRevitIdleManager.cs @@ -1,5 +1,3 @@ -using System; - namespace Speckle.Connectors.Revit.Plugin; // POC: needs interface diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitExternalApplication.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitExternalApplication.cs index c73cfc59e2..d9f4038713 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitExternalApplication.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitExternalApplication.cs @@ -1,4 +1,3 @@ -using System; using Autodesk.Revit.UI; using Speckle.Autofac.DependencyInjection; using Speckle.Autofac.Files; diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitIdleManager.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitIdleManager.cs index 76b723ff9c..a86b7f47e4 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitIdleManager.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitIdleManager.cs @@ -1,6 +1,4 @@ -using System; using System.Collections.Concurrent; -using System.Collections.Generic; using Autodesk.Revit.UI; using Autodesk.Revit.UI.Events; using Speckle.Converters.RevitShared.Helpers; diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitPlugin.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitPlugin.cs index 9e0a2041d4..63b7bbe879 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitPlugin.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitPlugin.cs @@ -1,10 +1,7 @@ -using System; -using System.Collections.Generic; using Autodesk.Revit.UI; using Autodesk.Revit.ApplicationServices; using Revit.Async; using CefSharp; -using System.Linq; using Speckle.Connectors.DUI.Bridge; using Speckle.Connectors.DUI.Bindings; using System.Diagnostics; diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoBasicConnectorBinding.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoBasicConnectorBinding.cs index d9a0cbcfd6..a0136b1121 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoBasicConnectorBinding.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoBasicConnectorBinding.cs @@ -1,6 +1,3 @@ -using System; -using System.Collections.Generic; -using System.Linq; using Rhino; using Rhino.DocObjects; using Rhino.Geometry; @@ -11,6 +8,7 @@ using Speckle.Connectors.DUI.Models.Card; using Speckle.Connectors.Rhino7.Extensions; using Speckle.Connectors.Rhino7.HostApp; +using Speckle.Connectors.Utils; namespace Speckle.Connectors.Rhino7.Bindings; @@ -74,12 +72,12 @@ public void HighlightModel(string modelCardId) if (myModel is SenderModelCard sender) { - objectIds = sender.SendFilter.GetObjectIds(); + objectIds = (sender.SendFilter?.GetObjectIds()).Empty().ToList(); } if (myModel is ReceiverModelCard receiver && receiver.ReceiveResult != null) { - objectIds = receiver.ReceiveResult.BakedObjectIds; + objectIds = receiver.ReceiveResult.BakedObjectIds ?? new(); } if (objectIds.Count == 0) diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoReceiveBinding.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoReceiveBinding.cs index 4bcaf6cde4..96f9765930 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoReceiveBinding.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoReceiveBinding.cs @@ -1,13 +1,9 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading; -using System.Threading.Tasks; -using Speckle.Autofac.DependencyInjection; +using Speckle.Autofac.DependencyInjection; using Speckle.Connectors.DUI.Bindings; using Speckle.Connectors.DUI.Bridge; using Speckle.Connectors.DUI.Models; using Speckle.Connectors.DUI.Models.Card; +using Speckle.Connectors.Utils; using Speckle.Connectors.Utils.Cancellation; using Speckle.Connectors.Utils.Operations; using Speckle.Core.Logging; @@ -57,11 +53,11 @@ public async Task Receive(string modelCardId) // Receive host objects IEnumerable receivedObjectIds = await unitOfWork.Service .Execute( - modelCard.AccountId, // POC: I hear -you are saying why we're passing them separately. Not sure pass the DUI3-> Connectors.DUI project dependency to the SDK-> Connector.Utils - modelCard.ProjectId, - modelCard.ProjectName, - modelCard.ModelName, - modelCard.SelectedVersionId, + modelCard.AccountId.NotNull(), // POC: I hear -you are saying why we're passing them separately. Not sure pass the DUI3-> Connectors.DUI project dependency to the SDK-> Connector.Utils + modelCard.ProjectId.NotNull(), + modelCard.ProjectName.NotNull(), + modelCard.ModelName.NotNull(), + modelCard.SelectedVersionId.NotNull(), cts.Token, (status, progress) => OnSendOperationProgress(modelCardId, status, progress) ) diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSelectionBinding.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSelectionBinding.cs index 5a00123167..c4e1feef68 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSelectionBinding.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSelectionBinding.cs @@ -1,5 +1,3 @@ -using System.Collections.Generic; -using System.Linq; using Rhino; using Rhino.DocObjects; using Speckle.Connectors.DUI.Bindings; diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSendBinding.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSendBinding.cs index 33adb7f6b0..17f20d26eb 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSendBinding.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSendBinding.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; -using System.Linq; -using System.Threading; using Rhino; using Speckle.Connectors.DUI.Bindings; using Speckle.Connectors.DUI.Bridge; @@ -12,13 +8,13 @@ using Speckle.Connectors.Utils.Cancellation; using Speckle.Core.Logging; using ICancelable = System.Reactive.Disposables.ICancelable; -using System.Threading.Tasks; using Speckle.Autofac.DependencyInjection; using Rhino.DocObjects; using Speckle.Connectors.DUI.Models.Card.SendFilter; using Speckle.Connectors.Utils.Operations; using Speckle.Core.Models; using Speckle.Connectors.DUI.Settings; +using Speckle.Connectors.Utils; namespace Speckle.Connectors.Rhino7.Bindings; @@ -150,16 +146,16 @@ public async Task Send(string modelCardId) throw new InvalidOperationException("No publish model card was found."); } - List rhinoObjects = modelCard.SendFilter - .GetObjectIds() + List rhinoObjects = (modelCard.SendFilter? + .GetObjectIds()).Empty() .Select(id => RhinoDoc.ActiveDoc.Objects.FindId(new Guid(id))) .Where(obj => obj != null) .ToList(); var sendInfo = new SendInfo( - modelCard.AccountId, - modelCard.ProjectId, - modelCard.ModelId, + modelCard.AccountId.NotNull(), + modelCard.ProjectId.NotNull(), + modelCard.ModelId.NotNull(), _rhinoSettings.HostAppInfo.Name, _convertedObjectReferences, modelCard.ChangedObjectIds @@ -213,12 +209,12 @@ private void RunExpirationChecks() foreach (SenderModelCard modelCard in senders) { - var intersection = modelCard.SendFilter.GetObjectIds().Intersect(objectIdsList).ToList(); - bool isExpired = modelCard.SendFilter.CheckExpiry(ChangedObjectIds.ToArray()); - if (isExpired) + var intersection = modelCard.SendFilter?.GetObjectIds().Intersect(objectIdsList).ToList(); + var isExpired = modelCard.SendFilter?.CheckExpiry(ChangedObjectIds.ToArray()); + if (isExpired ?? false) { - expiredSenderIds.Add(modelCard.ModelCardId); - modelCard.ChangedObjectIds.UnionWith(intersection); + expiredSenderIds.Add(modelCard.ModelCardId.NotNull()); + modelCard.ChangedObjectIds.UnionWith(intersection.Empty()); } } diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/AutofacRhinoModule.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/AutofacRhinoModule.cs index d4828f0539..2eaba3d714 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/AutofacRhinoModule.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/AutofacRhinoModule.cs @@ -1,4 +1,3 @@ -using System; using Autofac; using Microsoft.Extensions.Logging; using Rhino.Commands; diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Extensions/BoundingBox.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Extensions/BoundingBox.cs index 27950f8b5f..983a8d2a40 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Extensions/BoundingBox.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Extensions/BoundingBox.cs @@ -1,5 +1,4 @@ -using System.Collections.Generic; -using Rhino.DocObjects; +using Rhino.DocObjects; using Rhino.Geometry; namespace Speckle.Connectors.Rhino7.Extensions; diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Filters/RhinoEverythingFilter.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Filters/RhinoEverythingFilter.cs index 1bd052be6b..431edbaa6b 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Filters/RhinoEverythingFilter.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Filters/RhinoEverythingFilter.cs @@ -1,5 +1,4 @@ -using System.Collections.Generic; -using Speckle.Connectors.DUI.Models.Card.SendFilter; +using Speckle.Connectors.DUI.Models.Card.SendFilter; namespace Speckle.Connectors.Rhino7.Filters; diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Filters/RhinoSelectionFilter.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Filters/RhinoSelectionFilter.cs index d103620d66..21d153b940 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Filters/RhinoSelectionFilter.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Filters/RhinoSelectionFilter.cs @@ -1,5 +1,3 @@ -using System.Collections.Generic; -using System.Linq; using Speckle.Connectors.DUI.Models.Card.SendFilter; namespace Speckle.Connectors.Rhino7.Filters; diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/RhinoDocumentStore.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/RhinoDocumentStore.cs index 368c643764..6cf62a7fab 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/RhinoDocumentStore.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/RhinoDocumentStore.cs @@ -1,4 +1,3 @@ -using System.Collections.Generic; using Rhino; using Speckle.Connectors.DUI.Models; using Speckle.Connectors.DUI.Models.Card; @@ -56,6 +55,6 @@ public override void ReadFromFile() Models = new List(); return; } - Models = Deserialize(stateString); + Models = Deserialize(stateString) ?? new (); } } diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/RhinoIdleManager.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/RhinoIdleManager.cs index fbb1afe4f7..374d979750 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/RhinoIdleManager.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/RhinoIdleManager.cs @@ -1,4 +1,3 @@ -using System; using System.Collections.Concurrent; using Rhino; diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/RhinoSettings.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/RhinoSettings.cs index bb48c8e6ac..1bb2e89116 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/RhinoSettings.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/RhinoSettings.cs @@ -1,5 +1,4 @@ -using System.Collections.Generic; -using System.IO; +using System.IO; using Speckle.Core.Kits; namespace Speckle.Connectors.Rhino7.HostApp; diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Receive/DisableRedrawScope.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Receive/DisableRedrawScope.cs index 07edaccdc1..1182e5de7a 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Receive/DisableRedrawScope.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Receive/DisableRedrawScope.cs @@ -1,5 +1,4 @@ -using System; -using Rhino.DocObjects.Tables; +using Rhino.DocObjects.Tables; namespace Speckle.Connectors.Rhino7.Operations.Receive; diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Receive/RhinoHostObjectBuilder.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Receive/RhinoHostObjectBuilder.cs index 3e0e0d1d23..48bc85ce99 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Receive/RhinoHostObjectBuilder.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Receive/RhinoHostObjectBuilder.cs @@ -1,7 +1,3 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading; using Rhino; using Rhino.DocObjects; using Rhino.Geometry; diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Send/RootObjectBuilder.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Send/RootObjectBuilder.cs index c6b372800a..bc760a5679 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Send/RootObjectBuilder.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Send/RootObjectBuilder.cs @@ -1,10 +1,6 @@ -using System; -using System.Collections.Generic; -using System.Linq; using Rhino.DocObjects; using Rhino; using Speckle.Core.Models; -using System.Threading; using Speckle.Autofac.DependencyInjection; using Speckle.Converters.Common; using Speckle.Connectors.DUI.Models.Card.SendFilter; diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Plugin/Speckle.Connectors.Rhino7Command.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Plugin/Speckle.Connectors.Rhino7Command.cs index 751213cb0e..d3592ad90b 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Plugin/Speckle.Connectors.Rhino7Command.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Plugin/Speckle.Connectors.Rhino7Command.cs @@ -1,4 +1,3 @@ -using System; using Rhino; using Rhino.Commands; using Rhino.Input.Custom; diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Plugin/Speckle.Connectors.Rhino7Plugin.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Plugin/Speckle.Connectors.Rhino7Plugin.cs index a4abed8dc4..09aeab7af7 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Plugin/Speckle.Connectors.Rhino7Plugin.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Plugin/Speckle.Connectors.Rhino7Plugin.cs @@ -1,5 +1,4 @@ -using System; -using System.IO; +using System.IO; using System.Reflection; using Rhino.PlugIns; using Speckle.Autofac.DependencyInjection; From 06df32d42c3ae8fbf68ad932a88b7f88b22f0d20 Mon Sep 17 00:00:00 2001 From: Adam Hathcock Date: Thu, 9 May 2024 08:42:14 +0100 Subject: [PATCH 132/261] null suppress is not allowed --- All.sln.DotSettings | 1 + 1 file changed, 1 insertion(+) diff --git a/All.sln.DotSettings b/All.sln.DotSettings index 4d2ed20707..a68eee20a7 100644 --- a/All.sln.DotSettings +++ b/All.sln.DotSettings @@ -1,4 +1,5 @@  + False SUGGESTION SUGGESTION SUGGESTION From b198534e41777f3a65d6d2a6b36e53ddc5fa61ad Mon Sep 17 00:00:00 2001 From: Adam Hathcock Date: Thu, 9 May 2024 08:42:36 +0100 Subject: [PATCH 133/261] fmt --- .../Speckle.Connectors.Rhino7/Bindings/RhinoSendBinding.cs | 4 ++-- .../Speckle.Connectors.Rhino7/HostApp/RhinoDocumentStore.cs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSendBinding.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSendBinding.cs index 17f20d26eb..1a6602b473 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSendBinding.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSendBinding.cs @@ -146,8 +146,8 @@ public async Task Send(string modelCardId) throw new InvalidOperationException("No publish model card was found."); } - List rhinoObjects = (modelCard.SendFilter? - .GetObjectIds()).Empty() + List rhinoObjects = (modelCard.SendFilter?.GetObjectIds()) + .Empty() .Select(id => RhinoDoc.ActiveDoc.Objects.FindId(new Guid(id))) .Where(obj => obj != null) .ToList(); diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/RhinoDocumentStore.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/RhinoDocumentStore.cs index 6cf62a7fab..fe745ed80a 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/RhinoDocumentStore.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/RhinoDocumentStore.cs @@ -55,6 +55,6 @@ public override void ReadFromFile() Models = new List(); return; } - Models = Deserialize(stateString) ?? new (); + Models = Deserialize(stateString) ?? new(); } } From 5eae8c9a10a5b0d837b7d553ab32c1f53fdcde39 Mon Sep 17 00:00:00 2001 From: Adam Hathcock Date: Thu, 9 May 2024 09:10:01 +0100 Subject: [PATCH 134/261] remove some null suppression --- .../Bindings/BasicConnectorBinding.cs | 3 ++- .../HostApp/ArcGISSettings.cs | 3 ++- .../Layers/VectorLayerToHostConverter.cs | 2 -- .../Speckle.Converters.Rhino7.csproj | 1 + .../ToHost/Raw/PolyCurveToHostConverter.cs | 2 +- .../Raw/PolyCurveToSpeckleConverter.cs | 3 ++- .../Bridge/BrowserBridge.cs | 6 +++--- .../NotNullExtensions.cs | 20 ++++++++++++++----- .../Speckle.Connectors.Utils.csproj | 4 ++++ ...nverters.Common.DependencyInjection.csproj | 1 + .../ToHost/ToHostConverterWithFallback.cs | 5 +++-- .../ToHost/ToHostConverterWithoutFallback.cs | 5 +++-- 12 files changed, 37 insertions(+), 18 deletions(-) diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/BasicConnectorBinding.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/BasicConnectorBinding.cs index 262afbd18c..464bc9f322 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/BasicConnectorBinding.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/BasicConnectorBinding.cs @@ -6,6 +6,7 @@ using Speckle.Connectors.DUI.Bridge; using Speckle.Connectors.DUI.Models; using Speckle.Connectors.DUI.Models.Card; +using Speckle.Connectors.Utils; using Speckle.Connectors.Utils.Reflection; namespace Speckle.Connectors.ArcGIS.Bindings; @@ -37,7 +38,7 @@ public BasicConnectorBinding(ArcGISDocumentStore store, ArcGISSettings settings, public string GetSourceApplicationVersion() => _settings.HostAppInfo.GetVersion(_settings.HostAppVersion); - public string GetConnectorVersion() => Assembly.GetAssembly(GetType())!.GetVersion(); + public string GetConnectorVersion() => Assembly.GetAssembly(GetType()).NotNull().GetVersion(); // TODO public DocumentInfo GetDocumentInfo() => diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/HostApp/ArcGISSettings.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/HostApp/ArcGISSettings.cs index 480a49426f..860ea96abd 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/HostApp/ArcGISSettings.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/HostApp/ArcGISSettings.cs @@ -1,4 +1,5 @@ using System.IO; +using Speckle.Connectors.Utils; using Speckle.Core.Kits; namespace Speckle.Connectors.ArcGIS.HostApp; @@ -10,7 +11,7 @@ public ArcGISSettings(HostApplication hostAppInfo, HostAppVersion hostAppVersion { HostAppInfo = hostAppInfo; HostAppVersion = hostAppVersion; - Modules = new[] { new DirectoryInfo(typeof(ArcGISSettings).Assembly.Location).Parent!.FullName }; //poc: Net6 requires us to use this `location` property rather than ToString, should we use this everywhere? + Modules = new[] { new DirectoryInfo(typeof(ArcGISSettings).Assembly.Location).Parent.NotNull().FullName }; //poc: Net6 requires us to use this `location` property rather than ToString, should we use this everywhere? } public HostApplication HostAppInfo { get; private set; } diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/VectorLayerToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/VectorLayerToHostConverter.cs index 3d657310f4..0db9ec6554 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/VectorLayerToHostConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/VectorLayerToHostConverter.cs @@ -52,7 +52,5 @@ public string RawConvert(VectorLayer target) { return _tableConverter.RawConvert(target).GetName(); } - - throw new SpeckleConversionException($"Unknown geometry type for layer {target.name}"); } } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Speckle.Converters.Rhino7.csproj b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Speckle.Converters.Rhino7.csproj index 752fe889d4..aa491bf1da 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Speckle.Converters.Rhino7.csproj +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Speckle.Converters.Rhino7.csproj @@ -10,6 +10,7 @@ + diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/PolyCurveToHostConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/PolyCurveToHostConverter.cs index 9334cfba08..af8bd3e910 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/PolyCurveToHostConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/PolyCurveToHostConverter.cs @@ -27,7 +27,7 @@ public RG.PolyCurve RawConvert(SOG.Polycurve target) foreach (var segment in target.segments) { - var childCurve = CurveConverter!.RawConvert(segment); + var childCurve = CurveConverter?.RawConvert(segment); bool success = result.AppendSegment(childCurve); if (!success) { diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/PolyCurveToSpeckleConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/PolyCurveToSpeckleConverter.cs index b576f3065d..7a9217401a 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/PolyCurveToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/PolyCurveToSpeckleConverter.cs @@ -1,5 +1,6 @@ using Objects; using Rhino; +using Speckle.Connectors.Utils; using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; @@ -40,7 +41,7 @@ public SOG.Polycurve RawConvert(RG.PolyCurve target) domain = _intervalConverter.RawConvert(target.Domain), length = target.GetLength(), bbox = _boxConverter.RawConvert(new RG.Box(target.GetBoundingBox(true))), - segments = target.DuplicateSegments().Select(CurveConverter!.RawConvert).ToList(), + segments = target.DuplicateSegments().Select(x => CurveConverter.NotNull().RawConvert(x)).ToList(), units = _contextStack.Current.SpeckleUnits }; return myPoly; diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/BrowserBridge.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/BrowserBridge.cs index dda630ed87..bbc4ed5142 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/BrowserBridge.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/BrowserBridge.cs @@ -258,7 +258,7 @@ private void NotifyUIMethodCallResultReady(string requestId, string? serializedD } string script = $"{FrontendBoundName}.responseReady('{requestId}')"; - _scriptMethod!(script); + _scriptMethod?.Invoke(script); } /// @@ -291,7 +291,7 @@ public void Send(string eventName) { var script = $"{FrontendBoundName}.emit('{eventName}')"; - _scriptMethod!(script); + _scriptMethod?.Invoke(script); } public void Send(string eventName, T data) @@ -300,6 +300,6 @@ public void Send(string eventName, T data) string payload = JsonConvert.SerializeObject(data, _serializerOptions); var script = $"{FrontendBoundName}.emit('{eventName}', '{payload}')"; - _scriptMethod!(script); + _scriptMethod?.Invoke(script); } } diff --git a/DUI3-DX/Sdk/Speckle.Connectors.Utils/NotNullExtensions.cs b/DUI3-DX/Sdk/Speckle.Connectors.Utils/NotNullExtensions.cs index 497edc20ad..c95ec153cb 100644 --- a/DUI3-DX/Sdk/Speckle.Connectors.Utils/NotNullExtensions.cs +++ b/DUI3-DX/Sdk/Speckle.Connectors.Utils/NotNullExtensions.cs @@ -1,4 +1,7 @@ -namespace Speckle.Connectors.Utils; +using System.Diagnostics.CodeAnalysis; +using System.Runtime.CompilerServices; + +namespace Speckle.Connectors.Utils; public static class NotNullExtensions { @@ -26,22 +29,29 @@ public static async Task NotNull(this Task task, string? message = nul return x.Value; } - public static T NotNull(this T? obj, string? message = null) + + public static T NotNull( + [NotNull] this T? obj, + [CallerArgumentExpression(nameof(obj))] string? paramName = null + ) where T : class { if (obj is null) { - throw new ArgumentNullException(message ?? "Value is null"); + throw new ArgumentNullException(paramName ?? "Value is null"); } return obj; } - public static T NotNull(this T? obj, string? message = null) + public static T NotNull( + [NotNull] this T? obj, + [CallerArgumentExpression(nameof(obj))] string? paramName = null + ) where T : struct { if (obj is null) { - throw new ArgumentNullException(message ?? "Value is null"); + throw new ArgumentNullException(paramName ?? "Value is null"); } return obj.Value; } diff --git a/DUI3-DX/Sdk/Speckle.Connectors.Utils/Speckle.Connectors.Utils.csproj b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Speckle.Connectors.Utils.csproj index 1582a2b5e4..394e3a0c7b 100644 --- a/DUI3-DX/Sdk/Speckle.Connectors.Utils/Speckle.Connectors.Utils.csproj +++ b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Speckle.Connectors.Utils.csproj @@ -5,6 +5,10 @@ enable + + + + diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/Speckle.Converters.Common.DependencyInjection.csproj b/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/Speckle.Converters.Common.DependencyInjection.csproj index 7675aeeae6..a5f5a20194 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/Speckle.Converters.Common.DependencyInjection.csproj +++ b/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/Speckle.Converters.Common.DependencyInjection.csproj @@ -10,6 +10,7 @@ + diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/ToHost/ToHostConverterWithFallback.cs b/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/ToHost/ToHostConverterWithFallback.cs index 1062a9d391..547f273e74 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/ToHost/ToHostConverterWithFallback.cs +++ b/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/ToHost/ToHostConverterWithFallback.cs @@ -1,4 +1,5 @@ -using Speckle.Converters.Common.Objects; +using Speckle.Connectors.Utils; +using Speckle.Converters.Common.Objects; using Speckle.Core.Models; using Speckle.Core.Models.Extensions; @@ -44,7 +45,7 @@ public object Convert(Base target) // Direct conversion if a converter is found if (_baseConverter.TryConvert(target, out object? result)) { - return result!; + return result.NotNull(); } // Fallback to display value if it exists. diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/ToHost/ToHostConverterWithoutFallback.cs b/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/ToHost/ToHostConverterWithoutFallback.cs index 8e00677ffd..2e1463a6dd 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/ToHost/ToHostConverterWithoutFallback.cs +++ b/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/ToHost/ToHostConverterWithoutFallback.cs @@ -1,4 +1,5 @@ -using Speckle.Converters.Common.Objects; +using Speckle.Connectors.Utils; +using Speckle.Converters.Common.Objects; using Speckle.Core.Models; namespace Speckle.Converters.Common.DependencyInjection.ToHost; @@ -22,7 +23,7 @@ public object Convert(Base target) { if (TryConvert(target, out object? result)) { - return result!; + return result.NotNull(); } throw new NotSupportedException($"No conversion found for {target.GetType()}"); } From 556afc6e60c04a2295820d9b5655760f3e4d4570 Mon Sep 17 00:00:00 2001 From: Adam Hathcock Date: Thu, 9 May 2024 09:14:17 +0100 Subject: [PATCH 135/261] remove more csproj features --- .../Speckle.Connectors.ArcGIS3.csproj | 2 -- .../Speckle - Backup.Connectors.Revit2023.csproj | 1 - .../Speckle.Connectors.Revit2023.csproj | 1 - .../Speckle.Connectors.Rhino7/Speckle.Connectors.Rhino7.csproj | 1 - .../Speckle.Converters.ArcGIS3.DependencyInjection.csproj | 2 -- .../Speckle.Converters.ArcGIS3.csproj | 2 -- .../Speckle.Converters.Revit2023.DependencyInjection.csproj | 2 -- .../Speckle.Converters.Revit2023.csproj | 2 -- .../Speckle.Converters.Rhino7.DependencyInjection.csproj | 2 -- .../Speckle.Converters.Rhino7/Speckle.Converters.Rhino7.csproj | 2 -- .../Speckle.Connectors.DUI.WebView.csproj | 2 -- DUI3-DX/Sdk/Speckle.Autofac/Speckle.Autofac.csproj | 1 - .../Speckle.Connectors.Utils/Speckle.Connectors.Utils.csproj | 1 - 13 files changed, 21 deletions(-) diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Speckle.Connectors.ArcGIS3.csproj b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Speckle.Connectors.ArcGIS3.csproj index 4887f7ffc9..c96551c0c7 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Speckle.Connectors.ArcGIS3.csproj +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Speckle.Connectors.ArcGIS3.csproj @@ -7,8 +7,6 @@ win-x64 Speckle.Connectors.ArcGIS true - enable - enable diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.Revit2023/Speckle - Backup.Connectors.Revit2023.csproj b/DUI3-DX/Connectors/Revit/Speckle.Connectors.Revit2023/Speckle - Backup.Connectors.Revit2023.csproj index 1f521c09cc..677838f0f2 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.Revit2023/Speckle - Backup.Connectors.Revit2023.csproj +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.Revit2023/Speckle - Backup.Connectors.Revit2023.csproj @@ -4,7 +4,6 @@ x64 win-x64 true - enable diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.Revit2023/Speckle.Connectors.Revit2023.csproj b/DUI3-DX/Connectors/Revit/Speckle.Connectors.Revit2023/Speckle.Connectors.Revit2023.csproj index 31bb113828..9909da18f8 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.Revit2023/Speckle.Connectors.Revit2023.csproj +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.Revit2023/Speckle.Connectors.Revit2023.csproj @@ -3,7 +3,6 @@ net48 x64 true - enable diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Speckle.Connectors.Rhino7.csproj b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Speckle.Connectors.Rhino7.csproj index 111979f8b5..93511a0028 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Speckle.Connectors.Rhino7.csproj +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Speckle.Connectors.Rhino7.csproj @@ -2,7 +2,6 @@ net48 .rhp - enable true true diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3.DependencyInjection/Speckle.Converters.ArcGIS3.DependencyInjection.csproj b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3.DependencyInjection/Speckle.Converters.ArcGIS3.DependencyInjection.csproj index 42ed102e6e..2cb23d51d9 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3.DependencyInjection/Speckle.Converters.ArcGIS3.DependencyInjection.csproj +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3.DependencyInjection/Speckle.Converters.ArcGIS3.DependencyInjection.csproj @@ -2,8 +2,6 @@ net6.0-windows - enable - enable x64 diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Speckle.Converters.ArcGIS3.csproj b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Speckle.Converters.ArcGIS3.csproj index 8227edcfd6..15008fdfa0 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Speckle.Converters.ArcGIS3.csproj +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Speckle.Converters.ArcGIS3.csproj @@ -2,8 +2,6 @@ net6.0-windows - enable - enable x64 diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/Speckle.Converters.Revit2023.DependencyInjection.csproj b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/Speckle.Converters.Revit2023.DependencyInjection.csproj index d61d522f4d..69ca42a770 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/Speckle.Converters.Revit2023.DependencyInjection.csproj +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/Speckle.Converters.Revit2023.DependencyInjection.csproj @@ -3,8 +3,6 @@ net48 x64 - enable - enable diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023/Speckle.Converters.Revit2023.csproj b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023/Speckle.Converters.Revit2023.csproj index 474fb6eadd..b8c7bd8a81 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023/Speckle.Converters.Revit2023.csproj +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023/Speckle.Converters.Revit2023.csproj @@ -3,8 +3,6 @@ net48 x64 - enable - enable diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/Speckle.Converters.Rhino7.DependencyInjection.csproj b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/Speckle.Converters.Rhino7.DependencyInjection.csproj index 468bb44e2a..caf7274915 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/Speckle.Converters.Rhino7.DependencyInjection.csproj +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/Speckle.Converters.Rhino7.DependencyInjection.csproj @@ -1,8 +1,6 @@ net48 - enable - enable false diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Speckle.Converters.Rhino7.csproj b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Speckle.Converters.Rhino7.csproj index aa491bf1da..a46b7442ae 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Speckle.Converters.Rhino7.csproj +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Speckle.Converters.Rhino7.csproj @@ -2,8 +2,6 @@ net48 - enable - enable diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI.WebView/Speckle.Connectors.DUI.WebView.csproj b/DUI3-DX/DUI3/Speckle.Connectors.DUI.WebView/Speckle.Connectors.DUI.WebView.csproj index 3992947dc0..689ceb67c4 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI.WebView/Speckle.Connectors.DUI.WebView.csproj +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI.WebView/Speckle.Connectors.DUI.WebView.csproj @@ -2,9 +2,7 @@ net4.8;net6.0-windows - enable true - Speckle.Connectors.DUI.WebView diff --git a/DUI3-DX/Sdk/Speckle.Autofac/Speckle.Autofac.csproj b/DUI3-DX/Sdk/Speckle.Autofac/Speckle.Autofac.csproj index 876b654ae0..c74a1334ca 100644 --- a/DUI3-DX/Sdk/Speckle.Autofac/Speckle.Autofac.csproj +++ b/DUI3-DX/Sdk/Speckle.Autofac/Speckle.Autofac.csproj @@ -3,7 +3,6 @@ true netstandard2.0 - enable diff --git a/DUI3-DX/Sdk/Speckle.Connectors.Utils/Speckle.Connectors.Utils.csproj b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Speckle.Connectors.Utils.csproj index 394e3a0c7b..44b0181ded 100644 --- a/DUI3-DX/Sdk/Speckle.Connectors.Utils/Speckle.Connectors.Utils.csproj +++ b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Speckle.Connectors.Utils.csproj @@ -2,7 +2,6 @@ netstandard2.0 - enable From 60e7e56ec644536ade43507f04b0f027c33a5555 Mon Sep 17 00:00:00 2001 From: Adam Hathcock Date: Thu, 9 May 2024 09:15:23 +0100 Subject: [PATCH 136/261] fmt --- .../ToSpeckle/Raw/NurbsCurveConverter.cs | 2 +- .../Sdk/Speckle.Connectors.Utils/NotNullExtensions.cs | 11 ++--------- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/NurbsCurveConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/NurbsCurveConverter.cs index 64ffaecc6f..372cf34f54 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/NurbsCurveConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/NurbsCurveConverter.cs @@ -50,7 +50,7 @@ public SOG.Curve RawConvert(RG.NurbsCurve target) // add extra knots at start & end because Rhino's knot multiplicity standard is (# control points + degree - 1) var knots = nurbsCurve.Knots.ToList(); knots.Insert(0, knots[0]); - knots.Insert(knots.Count - 1, knots[knots.Count - 1]); + knots.Insert(knots.Count - 1, knots[^1]); var myCurve = new SOG.Curve(displayValue, _contextStack.Current.SpeckleUnits) { diff --git a/DUI3-DX/Sdk/Speckle.Connectors.Utils/NotNullExtensions.cs b/DUI3-DX/Sdk/Speckle.Connectors.Utils/NotNullExtensions.cs index c95ec153cb..2aecd3260e 100644 --- a/DUI3-DX/Sdk/Speckle.Connectors.Utils/NotNullExtensions.cs +++ b/DUI3-DX/Sdk/Speckle.Connectors.Utils/NotNullExtensions.cs @@ -29,11 +29,7 @@ public static async Task NotNull(this Task task, string? message = nul return x.Value; } - - public static T NotNull( - [NotNull] this T? obj, - [CallerArgumentExpression(nameof(obj))] string? paramName = null - ) + public static T NotNull([NotNull] this T? obj, [CallerArgumentExpression(nameof(obj))] string? paramName = null) where T : class { if (obj is null) @@ -43,10 +39,7 @@ public static T NotNull( return obj; } - public static T NotNull( - [NotNull] this T? obj, - [CallerArgumentExpression(nameof(obj))] string? paramName = null - ) + public static T NotNull([NotNull] this T? obj, [CallerArgumentExpression(nameof(obj))] string? paramName = null) where T : struct { if (obj is null) From 4a944ac0695d5c7743a9ee1b8d34685262589a27 Mon Sep 17 00:00:00 2001 From: Adam Hathcock Date: Thu, 9 May 2024 10:40:22 +0100 Subject: [PATCH 137/261] more removing warnings --- .../SpeckleDUI3ViewModel.cs | 4 ++-- .../SpeckleModule.cs | 2 +- .../Bindings/AutocadSelectionBinding.cs | 2 +- .../Bindings/AutocadSendBinding.cs | 2 +- .../HostApp/AutocadDocumentManager.cs | 1 + .../Operations/Receive/HostObjectBuilder.cs | 2 +- ...eckle - Backup.Connectors.Revit2023.csproj | 4 ---- .../Speckle.Connectors.Revit2023.csproj | 5 +---- .../log20240501.txt | 8 ------- .../Bindings/BasicConnectorBindingRevit.cs | 22 +++++++++---------- .../Bindings/SelectionBinding.cs | 10 ++++++--- .../Bindings/SendBinding.cs | 20 ++++++++++------- .../HostApp/RevitDocumentStore.cs | 17 +++++++++----- .../Plugin/RevitCommand.cs | 2 +- .../Plugin/RevitExternalApplication.cs | 14 ++++++------ .../Plugin/RevitIdleManager.cs | 2 +- .../Plugin/RevitPlugin.cs | 6 +++-- .../Plugin/RevitSettings.cs | 20 ++++++++--------- .../Bindings/RhinoBasicConnectorBinding.cs | 2 +- .../PointcloudLayerToSpeckleConverter.cs | 2 +- .../Layers/VectorLayerToSpeckleConverter.cs | 8 +++---- .../Utils/ArcGISFieldUtils.cs | 2 +- .../Utils/ArcGISProjectUtils.cs | 4 ++-- .../Utils/CharacterCleaner.cs | 2 +- .../Utils/FeatureClassUtils.cs | 12 +++++----- ...ers.Autocad2023.DependencyInjection.csproj | 2 +- .../Speckle.Converters.Autocad2023.csproj | 2 +- .../RevitVersionConversionHelper.cs | 1 + .../Helpers/DisplayValueExtractor.cs | 3 ++- ...urveArrArrayToSpecklePolycurveConverter.cs | 2 +- .../Raw/ModelCurveArrayToSpeckleConverter.cs | 2 +- .../ToSpeckle/CeilingConversionToSpeckle.cs | 2 +- .../Bindings/TestBinding.cs | 2 +- .../Speckle.Connectors.DUI/Bridge/IBridge.cs | 1 + DUI3-DX/Directory.Build.Props | 1 + .../Operations/Send.cs | 6 ++++- .../NamedTypeInjector.cs | 2 +- .../RawConversionRegisterer.cs | 2 +- 38 files changed, 105 insertions(+), 98 deletions(-) delete mode 100644 DUI3-DX/Connectors/Revit/Speckle.Connectors.Revit2023/log20240501.txt diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/SpeckleDUI3ViewModel.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/SpeckleDUI3ViewModel.cs index f410120342..9d74daac4c 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/SpeckleDUI3ViewModel.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/SpeckleDUI3ViewModel.cs @@ -3,7 +3,7 @@ namespace Speckle.Connectors.ArcGIS; -internal class SpeckleDUI3ViewModel : DockPane +internal sealed class SpeckleDUI3ViewModel : DockPane { private const string DOCKPANE_ID = "SpeckleDUI3_SpeckleDUI3"; @@ -33,7 +33,7 @@ protected override async Task UninitializeAsync() /// /// Button implementation to create a new instance of the pane and activate it. /// -internal class SpeckleDUI3OpenButton : Button +internal sealed class SpeckleDUI3OpenButton : Button { protected override void OnClick() { diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/SpeckleModule.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/SpeckleModule.cs index ad9bd5bc05..0e827a8beb 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/SpeckleModule.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/SpeckleModule.cs @@ -15,7 +15,7 @@ namespace Speckle.Connectors.ArcGIS; /// /// This sample shows how to implement pane that contains an Edge WebView2 control using the built-in ArcGIS Pro SDK's WebBrowser control. For details on how to utilize the WebBrowser control in an add-in see here: https://github.com/Esri/arcgis-pro-sdk/wiki/ProConcepts-Framework#webbrowser For details on how to utilize the Microsoft Edge web browser control in an add-in see here: https://github.com/Esri/arcgis-pro-sdk/wiki/ProConcepts-Framework#webbrowser-control /// -internal class SpeckleModule : Module +internal sealed class SpeckleModule : Module { private static SpeckleModule? s_this; diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadSelectionBinding.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadSelectionBinding.cs index 5e2188d4cf..c497916b3f 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadSelectionBinding.cs +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadSelectionBinding.cs @@ -72,7 +72,7 @@ public SelectionInfo GetSelection() continue; } - var handleString = dbObject.Handle.Value.ToString(); + var handleString = dbObject.Handle.Value.ToString((IFormatProvider?)null); objectTypes.Add(dbObject.GetType().Name); objs.Add(handleString); } diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadSendBinding.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadSendBinding.cs index cd9620ba7a..80c624b289 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadSendBinding.cs +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadSendBinding.cs @@ -84,7 +84,7 @@ private void SubscribeToObjectChanges(Document doc) private void OnChangeChangedObjectIds(DBObject dBObject) { - ChangedObjectIds.Add(dBObject.Handle.Value.ToString()); + ChangedObjectIds.Add(dBObject.Handle.Value.ToString((IFormatProvider?)null)); _idleManager.SubscribeToIdle(RunExpirationChecks); } diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/AutocadDocumentManager.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/AutocadDocumentManager.cs index c1e3f03ac0..2de2e27aa3 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/AutocadDocumentManager.cs +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/AutocadDocumentManager.cs @@ -58,6 +58,7 @@ public class AutocadDocumentManager /// Writes the model cards to the current document. /// /// + /// public void WriteModelCards(Document doc, string modelCardsString) { if (doc == null) diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Operations/Receive/HostObjectBuilder.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Operations/Receive/HostObjectBuilder.cs index edb8cfa827..8168e8fc6b 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Operations/Receive/HostObjectBuilder.cs +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Operations/Receive/HostObjectBuilder.cs @@ -85,7 +85,7 @@ CancellationToken cancellationToken conversionResult.Append(layerFullName); - handleValues.Add(conversionResult.Handle.Value.ToString()); + handleValues.Add(conversionResult.Handle.Value.ToString((IFormatProvider?)null)); } onOperationProgressed?.Invoke("Converting", (double)++count / traversalGraph.Length); diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.Revit2023/Speckle - Backup.Connectors.Revit2023.csproj b/DUI3-DX/Connectors/Revit/Speckle.Connectors.Revit2023/Speckle - Backup.Connectors.Revit2023.csproj index 677838f0f2..994dbd662d 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.Revit2023/Speckle - Backup.Connectors.Revit2023.csproj +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.Revit2023/Speckle - Backup.Connectors.Revit2023.csproj @@ -7,10 +7,6 @@ - - - false - diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.Revit2023/Speckle.Connectors.Revit2023.csproj b/DUI3-DX/Connectors/Revit/Speckle.Connectors.Revit2023/Speckle.Connectors.Revit2023.csproj index 9909da18f8..adc9ce54e1 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.Revit2023/Speckle.Connectors.Revit2023.csproj +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.Revit2023/Speckle.Connectors.Revit2023.csproj @@ -6,10 +6,6 @@ - - - false - @@ -33,6 +29,7 @@ + diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.Revit2023/log20240501.txt b/DUI3-DX/Connectors/Revit/Speckle.Connectors.Revit2023/log20240501.txt deleted file mode 100644 index 5fe0f44a0a..0000000000 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.Revit2023/log20240501.txt +++ /dev/null @@ -1,8 +0,0 @@ -2024-05-01 17:45:23.888 +01:00 [INF] Loaded assemblies: ["mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089","UIFrameworkInterop, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089","UIFramework, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","UIFrameworkServices, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","CefSharp.Wpf, Version=92.0.260.0, Culture=neutral, PublicKeyToken=40c4b6fc221f4138","CefSharp.Core, Version=92.0.260.0, Culture=neutral, PublicKeyToken=40c4b6fc221f4138","CefSharp, Version=92.0.260.0, Culture=neutral, PublicKeyToken=40c4b6fc221f4138","CefSharp.Core.Runtime, Version=92.0.260.0, Culture=neutral, PublicKeyToken=40c4b6fc221f4138","System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089","PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35","WindowsBase, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35","PresentationCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35","System.Xaml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089","System.Configuration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a","System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089","Xceed.Wpf.AvalonDock, Version=2.1.0.0, Culture=neutral, PublicKeyToken=3e4669d2f30244f4","Autodesk.UI.Themes, Version=3.0.0.0, Culture=neutral, PublicKeyToken=null","UIFrameworkRes, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","UIFrameworkRes.resources, Version=23.0.0.0, Culture=en-GB, PublicKeyToken=null","AdWindows, Version=4.0.0.6, Culture=neutral, PublicKeyToken=null","WindowsFormsIntegration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35","PresentationFramework.Aero2, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35","PresentationFramework-SystemXml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089","System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a","AdApplicationFrame, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null","AddInManagerUI, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089","System.Windows.Controls.Ribbon, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089","PresentationFramework.Aero, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35","PresentationFramework.Luna, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35","Microsoft.Expression.Interactions, Version=4.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35","UIAutomationTypes, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35","UIAutomationProvider, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35","PresentationFramework-SystemCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089","APIInterop, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","RevitAddInUtility, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","System.Xml.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089","PackageContentsParser, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null","RevitAPIFoundation, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","RevitAPIIFC, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","IntfIFCAPI, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","RevitDBAPI, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","RevitAPI, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","AddInManager, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","RevitDBCoreAPI, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","GraphicsAPI, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","UtilityAPI, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","GeomUtilAPI, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","RoomAreaPlanDBAPI, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","HostObjDBAPI, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","FamilyDBAPI, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","EssentialsDBAPI, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","ArrayElemsDBAPI, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","StructuralDBAPI, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","SculptingDBAPI, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","ElementGroupDBAPI, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","CurtainGridFamilyDBAPI, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","SiteDBAPI, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","DetailDBAPI, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","BuildingSystemsDBAPI, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","EnergyAnalysisDBAPI, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","ATFRevitCoreAPI, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","IntfATFAPI, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","MaterialDBAPI, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","InfrastructureDBAPI, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","AnalysisAppsDBAPI, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","StructuralAnalysisDBAPI, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","RebarDBAPI, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","AssemblyDBAPI, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","StairRampDBAPI, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","APIDBAPI, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","DPartDBAPI, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","PersistenceDBAPI, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","InterfaceUtilAPI, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","InterfaceAPI, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","TextEngineAPI, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","PointCloudAccessAPI, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","NumberingDBAPI, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","MassingDBAPI, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","Autodesk.ATFTranslationServer.DBApplication, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","Autodesk.CivilAlignments.DBApplication, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","Autodesk.CoordinationModelDB, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","Autodesk.Entitlement.Utilities, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","Autodesk.LightboxDB, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","Autodesk.LinkTopography.Parser, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","Autodesk.ResultsBuilder.DBApplication, Version=2023.0.0.0, Culture=neutral, PublicKeyToken=null","Autodesk.RouteAnalysis.DBApplication, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","Autodesk.SteelConnectionsDB, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","Autodesk.StructuralRibbon.Application, Version=2023.0.0.0, Culture=neutral, PublicKeyToken=null","ConnectedDesktopDB, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","KeynoteDBServer, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","Autodesk.MEP.SegmentCalculation.DBApplication, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","Autodesk.MEP.FittingCalculation.DBApplication, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","CollaborateDB, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","AXMImporter, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","RevitAPIExtData, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","Autodesk.CoordinationModel.NavisworksApplication, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null","LightboxCore, Version=2.0.12.0, Culture=neutral, PublicKeyToken=null","LightboxCoreImpl, Version=2.0.12.0, Culture=neutral, PublicKeyToken=null","Microsoft.GeneratedCode, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null","Simulex.Net, Version=2.2.0.5, Culture=neutral, PublicKeyToken=null","RevitAPISteel, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","ASSettings, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null","Microsoft.GeneratedCode, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null","StructuralAnalysisResults, Version=2.5.0.11305, Culture=neutral, PublicKeyToken=null","Autodesk.DesktopConnector.API, Version=7.4.0.296, Culture=neutral, PublicKeyToken=null","System.Runtime.Caching, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a","System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089","System.Runtime.Serialization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089","SMDiagnostics, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089","System.ServiceModel.Internals, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35","System.IdentityModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089","Autodesk.Bcg.Net, Version=8.1.3.0, Culture=neutral, PublicKeyToken=null","Microsoft.Practices.Unity, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35","System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a","Autodesk.Http, Version=14.4.0.0, Culture=neutral, PublicKeyToken=null","netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51","RSCloudClient, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","Autodesk.RevitServer.Management.Client, Version=8.1.1.0, Culture=neutral, PublicKeyToken=null","Autodesk.Bcg, Version=3.27.1.0, Culture=neutral, PublicKeyToken=null","System.Collections, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a","System.Reflection, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a","System.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a","System.Threading, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a","System.Globalization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a","System.Runtime.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a","System.Linq.Expressions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a","Microsoft.Practices.Unity.Configuration, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35","System.Reflection.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a","Anonymously Hosted DynamicMethods Assembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null","DBManagedServices, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","RSCloudClientRevitService, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","Autodesk.Bcg.Http, Version=4.1.0.0, Culture=neutral, PublicKeyToken=d672471c03b2c408","System.Net.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a","System.Net.Http.WebRequest, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a","System.Net.Http.Formatting, Version=5.2.9.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35","AddInJournaling, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","AddInJournalEngine, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","AddInJournalClient, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","FabricationPartBrowser, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","Autodesk.UI.Windows, Version=3.0.0.0, Culture=neutral, PublicKeyToken=null","RevitAPIUI, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","UserInterfaceUtility, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","Autodesk.RevitApplicationHome.Application, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","SSONET, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","CEFRevitUtils, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","CefSharp.Wpf.HwndHost, Version=92.0.260.0, Culture=neutral, PublicKeyToken=40c4b6fc221f4138","Autodesk.RevitApplicationHome.Utilities, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","APIUIAPI, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","DesktopMFCAPI, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","RevitMFCAPI, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","RevitUIAPI, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","BuildingSystemsUIAPI, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","EssentialsUIAPI, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","DetailUIAPI, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","Autodesk.CivilAlignments.Application, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","Autodesk.CoordinationModelUI, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","Autodesk.FreeFormRebar.DB, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","Autodesk.IFC.Export.UI, Version=23.3.1.0, Culture=neutral, PublicKeyToken=null","Autodesk.LightboxUI, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","Autodesk.LinkTopography.Commands.Application, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","Autodesk.LoadAutodeskFamily.Application, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","Autodesk.MemberForces.Application, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","Autodesk.Revit.Config.Client, Version=2.5.0.0, Culture=neutral, PublicKeyToken=null","Polly, Version=7.0.0.0, Culture=neutral, PublicKeyToken=c8a3ffc3f8f825cc","Autodesk.PnIDModeler.Application, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","Autodesk.PnIDModeler.Client, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","Autodesk.PnIDModeler.Application.resources, Version=23.0.0.0, Culture=en-GB, PublicKeyToken=null","Autodesk.PnIDModeler.Client.resources, Version=23.0.0.0, Culture=en-GB, PublicKeyToken=null","Autodesk.Precast.Application, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null","Autodesk.Precast.UI, Version=19.0.1.0, Culture=neutral, PublicKeyToken=null","Autodesk.Precast.RevitBase, Version=20.0.0.0, Culture=neutral, PublicKeyToken=null","Autodesk.Precast.Base, Version=20.0.0.0, Culture=neutral, PublicKeyToken=null","Autodesk.Precast.Localization, Version=20.0.0.0, Culture=neutral, PublicKeyToken=null","Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed","System.Numerics, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089","System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089","Autodesk.Precast.Localization.resources, Version=20.0.0.0, Culture=en-GB, PublicKeyToken=null","Autodesk.Precast.API, Version=20.0.0.0, Culture=neutral, PublicKeyToken=null","Autodesk.Precast.CNC, Version=20.0.0.0, Culture=neutral, PublicKeyToken=null","Autodesk.Precast.CNCExport, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null","Autodesk.Precast.Commands, Version=20.0.0.0, Culture=neutral, PublicKeyToken=null","Autodesk.Precast.Geometry, Version=20.0.0.0, Culture=neutral, PublicKeyToken=null","Autodesk.Precast.RevitGeometry, Version=20.0.0.0, Culture=neutral, PublicKeyToken=null","Autodesk.Precast.RevitUI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null","Autodesk.Precast.ShopDrawings, Version=20.0.0.0, Culture=neutral, PublicKeyToken=null","Autodesk.Precast.Slab, Version=20.0.0.0, Culture=neutral, PublicKeyToken=null","Autodesk.Precast.Wall, Version=20.0.0.0, Culture=neutral, PublicKeyToken=null","Autodesk.ReinforcementNumbering.Application, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","Autodesk.ResultsExplorer.Application, Version=2023.0.0.0, Culture=neutral, PublicKeyToken=null","Microsoft.CSharp, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a","Autodesk.RevisionsOnSheetUI, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","Autodesk.Revit.CloudRendering.Application, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","Autodesk.Revit.SharedViews.Application, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","Autodesk.RouteAnalysis.Application, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","Autodesk.SectionProperties.Application, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","Autodesk.SpaceNaming.Application, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","Autodesk.SteelConnectionsUI, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","DotNetRoots, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null","Autodesk.REX.Framework, Version=2023.0.0.0, Culture=neutral, PublicKeyToken=51e16e3b26b42eda","Autodesk.UnifiedParameters.Application, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","Autodesk.ViewSheetSetUI, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","AutoLoader, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","ConnectedDesktopUI, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","DynamoRevitVersionSelector, Version=2.16.2.9354, Culture=neutral, PublicKeyToken=null","DynamoInstallDetective, Version=2.16.2.5624, Culture=neutral, PublicKeyToken=null","DynamoRevitDS, Version=2.16.2.9354, Culture=neutral, PublicKeyToken=null","RevitServices, Version=2.16.2.9354, Culture=neutral, PublicKeyToken=null","Autodesk.DynamoPlayerForRevit.Application, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","DynamoPlayer, Version=1.0.32.0, Culture=neutral, PublicKeyToken=null","Autodesk.EnergyAnalysis.Application, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","Autodesk.MEP.FittingCalculationUI.Application, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","Autodesk.GenerativeDesignForRevit.Application, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","DynamoPlayerExtension, Version=1.0.32.0, Culture=neutral, PublicKeyToken=null","DynamoCore, Version=2.16.2.5624, Culture=neutral, PublicKeyToken=null","DynamoCoreWpf, Version=2.16.2.5624, Culture=neutral, PublicKeyToken=null","Microsoft.Practices.Prism, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35","vtortola.WebSockets.Rfc6455, Version=2.2.4.0, Culture=neutral, PublicKeyToken=7f78616efb4a208d","vtortola.WebSockets, Version=2.2.4.0, Culture=neutral, PublicKeyToken=7f78616efb4a208d","System.Threading.Tasks.Dataflow, Version=4.5.24.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a","System.Threading.Tasks, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a","System.Diagnostics.Tracing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a","KeynoteUIServer, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","PointCloudSnappingServer, Version=1.0.8640.25549, Culture=neutral, PublicKeyToken=null","Autodesk.MEP.PressureLossReport.Application, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","Autodesk.TwinmotionForRevit, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","Autodesk.BatchPrint.Application, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","Autodesk.BatchPrint.Utilities, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","Collaborate, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","CollaborateBrowser, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","SkyscraperClientHost, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","C4RNET, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","eTransmitForRevit, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","Autodesk.WorksharingMonitor.Application, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","Autodesk.WorksharingMonitor.Utilities, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","ExportViewSelectorAddin, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","FormItConverterRibbon, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","RFAToAXMAddon, Version=23.0.0.0, Culture=neutral, PublicKeyToken=null","FormItConverterRibbon.resources, Version=23.0.0.0, Culture=en-GB, PublicKeyToken=null","RhinoInside.Revit.AddIn, Version=1.16.8620.27572, Culture=neutral, PublicKeyToken=null","RhinoInside.Revit.External, Version=1.16.8620.27572, Culture=neutral, PublicKeyToken=null","RhinoInside.Revit, Version=1.16.8620.27572, Culture=neutral, PublicKeyToken=null","Microsoft.GeneratedCode, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null","Microsoft.GeneratedCode, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null","Microsoft.GeneratedCode, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null","Speckle.Connectors.Revit2023, Version=2.0.999.0, Culture=neutral, PublicKeyToken=null","Speckle.Autofac, Version=2.0.999.0, Culture=neutral, PublicKeyToken=null","Autofac, Version=5.2.0.0, Culture=neutral, PublicKeyToken=17863af14b0044da","SpeckleCore2, Version=2.0.999.0, Culture=neutral, PublicKeyToken=null","Microsoft.Bcl.AsyncInterfaces, Version=7.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51","System.Threading.Tasks.Extensions, Version=4.2.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51","Speckle.Connectors.DUI, Version=2.0.999.0, Culture=neutral, PublicKeyToken=null","Speckle.Newtonsoft.Json, Version=11.0.0.0, Culture=neutral, PublicKeyToken=null","Speckle.Connectors.Utils, Version=2.0.999.0, Culture=neutral, PublicKeyToken=null","System.ValueTuple, Version=4.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51","Speckle.Converters.Common.DependencyInjection, Version=2.0.999.0, Culture=neutral, PublicKeyToken=null","Speckle.Converters.Common, Version=2.0.999.0, Culture=neutral, PublicKeyToken=null","Speckle.Converters.Revit2023.DependencyInjection, Version=2.0.999.0, Culture=neutral, PublicKeyToken=null","Speckle.Converters.Revit2023, Version=2.0.999.0, Culture=neutral, PublicKeyToken=null","Objects, Version=2.0.999.0, Culture=neutral, PublicKeyToken=null","Speckle.Objects.Common, Version=2.0.999.0, Culture=neutral, PublicKeyToken=null","Serilog, Version=2.0.0.0, Culture=neutral, PublicKeyToken=24c2f752a8e58a10","GraphQL.Primitives, Version=6.0.0.0, Culture=neutral, PublicKeyToken=null","GraphQL.Client.Abstractions.Websocket, Version=6.0.0.0, Culture=neutral, PublicKeyToken=null","GraphQL.Client.Abstractions, Version=6.0.0.0, Culture=neutral, PublicKeyToken=null","Microsoft.Extensions.Logging.Abstractions, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60","Serilog.Sinks.File, Version=5.0.0.0, Culture=neutral, PublicKeyToken=24c2f752a8e58a10","Microsoft.Extensions.Logging, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60","Serilog.Extensions.Logging, Version=7.0.0.0, Culture=neutral, PublicKeyToken=24c2f752a8e58a10","Microsoft.Extensions.Options, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60","System.ComponentModel.Composition, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"] -2024-05-01 17:45:25.569 +01:00 [INF] Bridge bound to front end name testBinding -2024-05-01 17:45:25.927 +01:00 [INF] Bridge bound to front end name configBinding -2024-05-01 17:45:25.929 +01:00 [INF] Bridge bound to front end name accountsBinding -2024-05-01 17:45:25.932 +01:00 [INF] Bridge bound to front end name baseBinding -2024-05-01 17:45:25.935 +01:00 [INF] Bridge bound to front end name selectionBinding -2024-05-01 17:45:25.938 +01:00 [INF] Bridge bound to front end name sendBinding -2024-05-01 17:45:25.939 +01:00 [INF] Bridge bound to front end name receiveBinding diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/BasicConnectorBindingRevit.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/BasicConnectorBindingRevit.cs index e0c76b56f5..2b03387d42 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/BasicConnectorBindingRevit.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/BasicConnectorBindingRevit.cs @@ -6,19 +6,20 @@ using Speckle.Connectors.DUI.Models; using Speckle.Connectors.DUI.Models.Card; using Speckle.Connectors.Revit.Plugin; +using Speckle.Connectors.Utils; using Speckle.Converters.RevitShared.Helpers; using Speckle.Core.Logging; namespace Speckle.Connectors.DUI.Bindings; -internal class BasicConnectorBindingRevit : IBasicConnectorBinding +internal sealed class BasicConnectorBindingRevit : IBasicConnectorBinding { // POC: name and bridge might be better for them to be protected props? public string Name { get; private set; } public IBridge Parent { get; private set; } - protected readonly DocumentModelStore _store; - protected readonly RevitContext _revitContext; + private readonly DocumentModelStore _store; + private readonly RevitContext _revitContext; private readonly RevitSettings _revitSettings; public BasicConnectorBindingRevit( @@ -46,21 +47,18 @@ public string GetConnectorVersion() return Assembly.GetAssembly(GetType()).GetVersion(); } - public string GetSourceApplicationName() => _revitSettings.HostSlug; // POC: maybe not right place but... + public string GetSourceApplicationName() => _revitSettings.HostSlug.NotNull(); // POC: maybe not right place but... public string GetSourceApplicationVersion() { // POC: maybe not right place but... - return _revitSettings.HostAppVersion; + return _revitSettings.HostAppVersion.NotNull(); } public DocumentInfo GetDocumentInfo() { // POC: not sure why this would ever be null, is this needed? - if (_revitContext.UIApplication == null) - { - return null; - } + _revitContext.UIApplication.NotNull(); var doc = _revitContext.UIApplication.ActiveUIDocument.Document; @@ -73,7 +71,7 @@ public DocumentInfo GetDocumentInfo() return new DocumentInfo { Name = doc.Title, - Id = doc.GetHashCode().ToString(), + Id = doc.GetHashCode().ToString((IFormatProvider?)null), Location = doc.PathName }; } @@ -107,8 +105,8 @@ public void HighlightModel(string modelCardId) SenderModelCard model = (SenderModelCard)_store.GetModelById(modelCardId); - var elementIds = model.SendFilter.GetObjectIds().Select(ElementId.Parse).ToList(); - if (elementIds.Count == 0) + var elementIds = model.SendFilter?.GetObjectIds().Select(ElementId.Parse).ToList(); + if (elementIds.Empty().Any()) { Commands.SetModelError(modelCardId, new InvalidOperationException("No objects found to highlight.")); return; diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SelectionBinding.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SelectionBinding.cs index 31da50ce5a..fc8669406c 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SelectionBinding.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SelectionBinding.cs @@ -7,7 +7,7 @@ namespace Speckle.Connectors.Revit.Bindings; // POC: we need a base a RevitBaseBinding -internal class SelectionBinding : RevitBaseBinding, ISelectionBinding +internal sealed class SelectionBinding : RevitBaseBinding, ISelectionBinding { private readonly IRevitIdleManager _revitIdleManager; @@ -21,6 +21,10 @@ IBridge bridge { _revitIdleManager = idleManager; + if (RevitContext.UIApplication is null) + { + return; + } // POC: we can inject the solution here // TODO: Need to figure it out equivalent of SelectionChanged for Revit2020 RevitContext.UIApplication.SelectionChanged += (_, _) => _revitIdleManager.SubscribeToIdle(OnSelectionChanged); @@ -36,14 +40,14 @@ public SelectionInfo GetSelection() // POC: this was also being called on shutdown // probably the bridge needs to be able to know if the plugin has been terminated // also on termination the OnSelectionChanged event needs unwinding - var selectionIds = RevitContext.UIApplication.ActiveUIDocument.Selection + var selectionIds = RevitContext.UIApplication?.ActiveUIDocument.Selection .GetElementIds() .Select(id => id.ToString()) .ToList(); return new SelectionInfo() { SelectedObjectIds = selectionIds, - Summary = $"{selectionIds.Count} objects selected." + Summary = $"{selectionIds?.Count} objects selected." }; } } diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SendBinding.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SendBinding.cs index 324d1a0a47..41f85b02af 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SendBinding.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SendBinding.cs @@ -15,7 +15,7 @@ namespace Speckle.Connectors.Revit.Bindings; -internal class SendBinding : RevitBaseBinding, ICancelable, ISendBinding +internal sealed class SendBinding : RevitBaseBinding, ICancelable, ISendBinding { // POC:does it need injecting? public CancellationManager CancellationManager { get; } = new(); @@ -47,6 +47,10 @@ RevitSettings revitSettings _revitSettings = revitSettings; Commands = new SendBindingUICommands(bridge); + if (revitContext.UIApplication is null) + { + return; + } // TODO expiry events // TODO filters need refresh events revitContext.UIApplication.Application.DocumentChanged += (_, e) => DocChangeHandler(e); @@ -91,13 +95,13 @@ private async Task HandleSend(string modelCardId) SendOperation >(); - List revitObjects = modelCard.SendFilter.GetObjectIds().Select(id => ElementId.Parse(id)).ToList(); + List revitObjects = modelCard.SendFilter?.GetObjectIds().Select(id => ElementId.Parse(id)).ToList() ?? new(); var sendInfo = new SendInfo( - modelCard.AccountId, - modelCard.ProjectId, - modelCard.ModelId, - _revitSettings.HostSlug, + modelCard.AccountId.NotNull(), + modelCard.ProjectId.NotNull(), + modelCard.ModelId.NotNull(), + _revitSettings.HostSlug.NotNull(), _convertedObjectReferences, modelCard.ChangedObjectIds ); @@ -196,11 +200,11 @@ private void RunExpirationChecks() foreach (SenderModelCard modelCard in senders) { - var intersection = modelCard.SendFilter.GetObjectIds().Intersect(objectIdsList).ToList(); + var intersection = modelCard.SendFilter.NotNull().GetObjectIds().Intersect(objectIdsList).ToList(); bool isExpired = modelCard.SendFilter.CheckExpiry(ChangedObjectIds.ToArray()); if (isExpired) { - expiredSenderIds.Add(modelCard.ModelCardId); + expiredSenderIds.Add(modelCard.ModelCardId.NotNull()); modelCard.ChangedObjectIds.UnionWith(intersection); } } diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/RevitDocumentStore.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/RevitDocumentStore.cs index 0130c638b7..5d9d79a68a 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/RevitDocumentStore.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/RevitDocumentStore.cs @@ -5,6 +5,7 @@ using Autodesk.Revit.UI.Events; using Speckle.Connectors.DUI.Models; using Speckle.Connectors.DUI.Models.Card; +using Speckle.Connectors.Utils; using Speckle.Converters.RevitShared.Helpers; using Speckle.Core.Logging; using Speckle.Newtonsoft.Json; @@ -12,7 +13,7 @@ namespace Speckle.Connectors.Revit.HostApp; // POC: should be interfaced out -internal class RevitDocumentStore : DocumentModelStore +internal sealed class RevitDocumentStore : DocumentModelStore { // POC: move to somewhere central? private static readonly Guid s_revitDocumentStoreId = new("D35B3695-EDC9-4E15-B62A-D3FC2CB83FA3"); @@ -33,7 +34,7 @@ IdStorageSchema idStorageSchema _documentModelStorageSchema = documentModelStorageSchema; _idStorageSchema = idStorageSchema; - UIApplication uiApplication = _revitContext.UIApplication; + UIApplication? uiApplication = _revitContext.UIApplication.NotNull(); uiApplication.ApplicationClosing += (_, _) => WriteToFile(); // POC: Not sure why we would need it since we have save and clos events uiApplication.Application.DocumentSaving += (_, _) => WriteToFile(); uiApplication.Application.DocumentSavingAs += (_, _) => WriteToFile(); @@ -97,13 +98,13 @@ private void WriteToFileWithDoc(Document doc) t.Commit(); } - public override void WriteToFile() => WriteToFileWithDoc(_revitContext.UIApplication.ActiveUIDocument.Document); + public override void WriteToFile() => WriteToFileWithDoc(_revitContext.UIApplication.NotNull().ActiveUIDocument.Document); public override void ReadFromFile() { try { - Entity stateEntity = GetSpeckleEntity(_revitContext.UIApplication?.ActiveUIDocument.Document); + var stateEntity = GetSpeckleEntity(_revitContext.UIApplication?.ActiveUIDocument.Document); if (stateEntity == null || !stateEntity.IsValid()) { Models = new List(); @@ -111,7 +112,7 @@ public override void ReadFromFile() } string modelsString = stateEntity.Get("contents"); - Models = Deserialize(modelsString); + Models = Deserialize(modelsString).NotNull(); } catch (Exception ex) when (!ex.IsFatal()) { @@ -146,8 +147,12 @@ public override void ReadFromFile() return null; } - private Entity? GetSpeckleEntity(Document doc) + private Entity? GetSpeckleEntity(Document? doc) { + if (doc is null) + { + return null; + } using FilteredElementCollector collector = new(doc); FilteredElementCollector dataStorages = collector.OfClass(typeof(DataStorage)); diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitCommand.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitCommand.cs index 7101dc7b29..7697246693 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitCommand.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitCommand.cs @@ -5,7 +5,7 @@ namespace Speckle.Connectors.Revit.Plugin; [Transaction(TransactionMode.Manual)] -internal class SpeckleRevitCommand : IExternalCommand +internal sealed class SpeckleRevitCommand : IExternalCommand { public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitExternalApplication.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitExternalApplication.cs index d9f4038713..e452a53d33 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitExternalApplication.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitExternalApplication.cs @@ -4,18 +4,18 @@ using System.Reflection; using System.IO; using Autofac; +using Speckle.Connectors.Utils; using Speckle.Converters.Common.DependencyInjection; using Speckle.Converters.Common.Objects; using Speckle.Core.Logging; namespace Speckle.Connectors.Revit.Plugin; -internal class RevitExternalApplication : IExternalApplication +internal sealed class RevitExternalApplication : IExternalApplication { private IRevitPlugin? _revitPlugin; - // POC: temp change to test - public static AutofacContainer? _container; + private AutofacContainer? _container; // POC: this is getting hard coded - need a way of injecting it // I am beginning to think the shared project is not the way @@ -53,7 +53,7 @@ public Result OnStartup(UIControlledApplication application) // init DI _container - .LoadAutofacModules(_revitSettings.ModuleFolders) + .LoadAutofacModules(_revitSettings.ModuleFolders.NotNull()) .AddSingletonInstance(_revitSettings) // apply revit settings into DI .AddSingletonInstance(application) // inject UIControlledApplication application .Build(); @@ -86,7 +86,7 @@ public Result OnShutdown(UIControlledApplication application) // POC: could this be more a generic Connector Init() Shutdown() // possibly with injected pieces or with some abstract methods? // need to look for commonality - _revitPlugin.Shutdown(); + _revitPlugin?.Shutdown(); } catch (Exception e) when (!e.IsFatal()) { @@ -100,7 +100,7 @@ public Result OnShutdown(UIControlledApplication application) private Assembly OnAssemblyResolve(object sender, ResolveEventArgs args) { // POC: tight binding to files - Assembly assembly = null; + Assembly? assembly = null; string name = args.Name.Split(',')[0]; string path = Path.GetDirectoryName(typeof(RevitPlugin).Assembly.Location); @@ -114,6 +114,6 @@ private Assembly OnAssemblyResolve(object sender, ResolveEventArgs args) } } - return assembly; + return assembly.NotNull(); } } diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitIdleManager.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitIdleManager.cs index a86b7f47e4..79bd4408a6 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitIdleManager.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitIdleManager.cs @@ -7,7 +7,7 @@ namespace Speckle.Connectors.Revit.Plugin; // POC: needs interface // is probably misnamed, perhaps OnIdleCallbackManager -internal class RevitIdleManager : IRevitIdleManager +internal sealed class RevitIdleManager : IRevitIdleManager { private readonly UIApplication _uiApplication; diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitPlugin.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitPlugin.cs index 63b7bbe879..d18504934e 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitPlugin.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitPlugin.cs @@ -11,10 +11,11 @@ using System.Windows.Media.Imaging; using System.Windows.Media; using System.IO; +using Speckle.Connectors.Utils; namespace Speckle.Connectors.Revit.Plugin; -internal class RevitPlugin : IRevitPlugin +internal sealed class RevitPlugin : IRevitPlugin { private readonly UIControlledApplication _uIControlledApplication; private readonly RevitSettings _revitSettings; @@ -68,7 +69,7 @@ private void CreateTabAndRibbonPanel(UIControlledApplication application) } RibbonPanel specklePanel = application.CreateRibbonPanel(_revitSettings.RevitTabName, _revitSettings.RevitTabTitle); - PushButton dui3Button = + var dui3Button = specklePanel.AddItem( new PushButtonData( _revitSettings.RevitButtonName, @@ -77,6 +78,7 @@ private void CreateTabAndRibbonPanel(UIControlledApplication application) typeof(SpeckleRevitCommand).FullName ) ) as PushButton; + dui3Button.NotNull(); string path = typeof(RevitPlugin).Assembly.Location; dui3Button.Image = LoadPngImgSource( diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitSettings.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitSettings.cs index 98c7b48334..07659d4db4 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitSettings.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitSettings.cs @@ -1,14 +1,14 @@ namespace Speckle.Connectors.Revit.Plugin; -internal class RevitSettings // POC: need to derive some interface for things that require IHostSettings +internal sealed class RevitSettings // POC: need to derive some interface for things that require IHostSettings { - public string RevitPanelName { get; set; } - public string RevitVersionName { get; set; } - public string RevitTabName { get; set; } - public string RevitTabTitle { get; set; } - public string RevitButtonName { get; set; } - public string RevitButtonText { get; set; } - public string HostSlug { get; set; } // POC: from generic IHostSettings interface - public string HostAppVersion { get; set; } // POC as HostSlug?? - public string[] ModuleFolders { get; set; } + public string? RevitPanelName { get; set; } + public string? RevitVersionName { get; set; } + public string? RevitTabName { get; set; } + public string? RevitTabTitle { get; set; } + public string? RevitButtonName { get; set; } + public string? RevitButtonText { get; set; } + public string? HostSlug { get; set; } // POC: from generic IHostSettings interface + public string? HostAppVersion { get; set; } // POC as HostSlug?? + public string[]? ModuleFolders { get; set; } } diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoBasicConnectorBinding.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoBasicConnectorBinding.cs index a0136b1121..85c0293b13 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoBasicConnectorBinding.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoBasicConnectorBinding.cs @@ -46,7 +46,7 @@ public DocumentInfo GetDocumentInfo() => { Location = RhinoDoc.ActiveDoc.Path, Name = RhinoDoc.ActiveDoc.Name, - Id = RhinoDoc.ActiveDoc.RuntimeSerialNumber.ToString() + Id = RhinoDoc.ActiveDoc.RuntimeSerialNumber.ToString((IFormatProvider?)null) }; public DocumentModelStore GetDocumentState() => _store; diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/PointcloudLayerToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/PointcloudLayerToSpeckleConverter.cs index b9019e5800..4d652b43f7 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/PointcloudLayerToSpeckleConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/PointcloudLayerToSpeckleConverter.cs @@ -28,7 +28,7 @@ private int GetPointColor(LasPoint pt, object renderer) { // get color int color = 0; - string classCode = pt.ClassCode.ToString(); + string classCode = pt.ClassCode.ToString((IFormatProvider?)null); if (renderer is CIMTinUniqueValueRenderer uniqueRenderer) { foreach (CIMUniqueValueGroup group in uniqueRenderer.Groups) diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/VectorLayerToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/VectorLayerToSpeckleConverter.cs index 26ad7e867e..50a4af05fc 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/VectorLayerToSpeckleConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/VectorLayerToSpeckleConverter.cs @@ -38,19 +38,19 @@ public Base Convert(object target) private string SpeckleGeometryType(string nativeGeometryType) { string spekleGeometryType = "None"; - if (nativeGeometryType.ToLower().Contains("point")) + if (nativeGeometryType.Contains("point", StringComparison.CurrentCultureIgnoreCase)) { spekleGeometryType = "Point"; } - else if (nativeGeometryType.ToLower().Contains("polyline")) + else if (nativeGeometryType.Contains("polyline", StringComparison.CurrentCultureIgnoreCase)) { spekleGeometryType = "Polyline"; } - else if (nativeGeometryType.ToLower().Contains("polygon")) + else if (nativeGeometryType.Contains("polygon", StringComparison.CurrentCultureIgnoreCase)) { spekleGeometryType = "Polygon"; } - else if (nativeGeometryType.ToLower().Contains("multipatch")) + else if (nativeGeometryType.Contains("multipatch", StringComparison.CurrentCultureIgnoreCase)) { spekleGeometryType = "Multipatch"; } diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/ArcGISFieldUtils.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/ArcGISFieldUtils.cs index 36b2f6ca31..f53ea51a07 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/ArcGISFieldUtils.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/ArcGISFieldUtils.cs @@ -48,7 +48,7 @@ public ArcGISFieldUtils(ICharacterCleaner characterCleaner) case FieldType.Double: return (double)value; case FieldType.Date: - return DateTime.Parse((string)value); + return DateTime.Parse((string)value, null); case FieldType.DateOnly: return DateOnly.Parse((string)value); case FieldType.TimeOnly: diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/ArcGISProjectUtils.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/ArcGISProjectUtils.cs index 9432955656..e3fd49b330 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/ArcGISProjectUtils.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/ArcGISProjectUtils.cs @@ -60,7 +60,7 @@ public string AddDatabaseToProject(string databasePath) } string parentFolderPath = parentFolder.ToString(); - var fGdbName = databasePath.Replace(parentFolderPath + "\\", ""); + var fGdbName = databasePath.Replace(parentFolderPath + '\\', string.Empty, StringComparison.Ordinal); string fGdbPath = parentFolder.ToString(); Item folderToAdd = ItemFactory.Instance.Create(fGdbPath); @@ -68,7 +68,7 @@ public string AddDatabaseToProject(string databasePath) QueuedTask.Run(() => Project.Current.AddItem(folderToAdd as IProjectItem)); // Add a file geodatabase or a SQLite or enterprise database connection to a project - var gdbToAdd = folderToAdd.GetItems().FirstOrDefault(folderItem => folderItem.Name.Equals(fGdbName)); + var gdbToAdd = folderToAdd.GetItems().FirstOrDefault(folderItem => folderItem.Name.Equals(fGdbName, StringComparison.Ordinal)); if (gdbToAdd is not null) { // POC: QueuedTask diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/CharacterCleaner.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/CharacterCleaner.cs index e49709e89d..b6efbbb84d 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/CharacterCleaner.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/CharacterCleaner.cs @@ -25,6 +25,6 @@ public string CleanCharacters(string key) result += "_"; } } - return key.Replace(" ", "_").Replace("%", "_").Replace("$", "_"); + return key.Replace(' ', '_').Replace('%', '_').Replace('$', '_'); } } diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/FeatureClassUtils.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/FeatureClassUtils.cs index aed54e7773..63fbe20d68 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/FeatureClassUtils.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/FeatureClassUtils.cs @@ -66,27 +66,27 @@ public ACG.GeometryType GetLayerGeometryType(VectorLayer target) } // POC: find better pattern - if (originalGeomType.ToLower().Contains("none")) + if (originalGeomType.Contains("none", StringComparison.CurrentCultureIgnoreCase)) { geomType = ACG.GeometryType.Unknown; } - else if (originalGeomType.ToLower().Contains("pointcloud")) + else if (originalGeomType.Contains("pointcloud", StringComparison.CurrentCultureIgnoreCase)) { geomType = ACG.GeometryType.Unknown; } - else if (originalGeomType.ToLower().Contains("point")) + else if (originalGeomType.Contains("point", StringComparison.CurrentCultureIgnoreCase)) { geomType = ACG.GeometryType.Multipoint; } - else if (originalGeomType.ToLower().Contains("polyline")) + else if (originalGeomType.Contains("polyline", StringComparison.CurrentCultureIgnoreCase)) { geomType = ACG.GeometryType.Polyline; } - else if (originalGeomType.ToLower().Contains("polygon")) + else if (originalGeomType.Contains("polygon", StringComparison.CurrentCultureIgnoreCase)) { geomType = ACG.GeometryType.Polygon; } - else if (originalGeomType.ToLower().Contains("multipatch")) + else if (originalGeomType.Contains("multipatch", StringComparison.CurrentCultureIgnoreCase)) { geomType = ACG.GeometryType.Multipatch; } diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2023.DependencyInjection/Speckle.Converters.Autocad2023.DependencyInjection.csproj b/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2023.DependencyInjection/Speckle.Converters.Autocad2023.DependencyInjection.csproj index 9a107c64a2..04d9915261 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2023.DependencyInjection/Speckle.Converters.Autocad2023.DependencyInjection.csproj +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2023.DependencyInjection/Speckle.Converters.Autocad2023.DependencyInjection.csproj @@ -1,7 +1,7 @@ - netstandard2.0 + net47 x64 diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2023/Speckle.Converters.Autocad2023.csproj b/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2023/Speckle.Converters.Autocad2023.csproj index f60b494008..895443e448 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2023/Speckle.Converters.Autocad2023.csproj +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2023/Speckle.Converters.Autocad2023.csproj @@ -1,7 +1,7 @@  - netstandard2.0 + net47 x64 diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023/RevitVersionConversionHelper.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023/RevitVersionConversionHelper.cs index 515c2e057f..f22ef3a50f 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023/RevitVersionConversionHelper.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023/RevitVersionConversionHelper.cs @@ -17,3 +17,4 @@ public bool IsCurveClosed(DB.NurbSpline nurbsSpline) } } } + diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/DisplayValueExtractor.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/DisplayValueExtractor.cs index 017b8946ff..0b8dfbec3c 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/DisplayValueExtractor.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/DisplayValueExtractor.cs @@ -116,7 +116,7 @@ public DisplayValueExtractor( /// does not have modified geometry (the docs say that modified geometry will not have a geom instance, /// however in my experience, all family instances have a top-level geom instance, but if the family instance /// is modified, then the geom instance won't contain any geometry.) - /// + /// /// This remark also leads me to think that a family instance will not have top-level solids and geom instances. /// We are logging cases where this is not true. /// @@ -124,6 +124,7 @@ public DisplayValueExtractor( /// /// /// + /// private void SortGeometry( DB.Element element, List solids, diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/CurveArrArrayToSpecklePolycurveConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/CurveArrArrayToSpecklePolycurveConverter.cs index 95c07ece74..6cba92f9cd 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/CurveArrArrayToSpecklePolycurveConverter.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/CurveArrArrayToSpecklePolycurveConverter.cs @@ -4,7 +4,7 @@ namespace Speckle.Converters.RevitShared.Raw; -internal class CurveArrArrayToSpecklePolycurveConverter : IRawConversion> +internal sealed class CurveArrArrayToSpecklePolycurveConverter : IRawConversion> { private readonly IRawConversion _curveArrayConverter; diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ModelCurveArrayToSpeckleConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ModelCurveArrayToSpeckleConverter.cs index c91e343f68..42662a643c 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ModelCurveArrayToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ModelCurveArrayToSpeckleConverter.cs @@ -6,7 +6,7 @@ namespace Speckle.Converters.RevitShared.Raw; -internal class ModelCurveArrayToSpeckleConverter : IRawConversion +internal sealed class ModelCurveArrayToSpeckleConverter : IRawConversion { private readonly IRevitConversionContextStack _contextStack; private readonly ScalingServiceToSpeckle _scalingService; diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/CeilingConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/CeilingConversionToSpeckle.cs index e141333b7f..8066b715fe 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/CeilingConversionToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/CeilingConversionToSpeckle.cs @@ -9,7 +9,7 @@ namespace Speckle.Converters.RevitShared.ToSpeckle; [NameAndRankValue(nameof(DB.Ceiling), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -internal class CeilingConversionToSpeckle : BaseConversionToSpeckle +internal sealed class CeilingConversionToSpeckle : BaseConversionToSpeckle { private readonly IRawConversion> _curveArrArrayConverter; private readonly IRawConversion _levelConverter; diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/TestBinding.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/TestBinding.cs index 3cb80845ed..e4676053e0 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/TestBinding.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/TestBinding.cs @@ -36,7 +36,7 @@ public string SayHi(string name, int count, bool sayHelloNotHi) public object GetComplexType() => new { - Id = GetHashCode().ToString() + " - I am a string", + Id = GetHashCode() + " - I am a string", count = GetHashCode(), thisIsABoolean = false }; diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/IBridge.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/IBridge.cs index f569ed6284..b77db4d152 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/IBridge.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/IBridge.cs @@ -24,6 +24,7 @@ public interface IBridge /// This method is called by the Frontend bridge when invoking any of the wrapped binding's methods. /// /// + /// /// /// public void RunMethod(string methodName, string requestId, string args); diff --git a/DUI3-DX/Directory.Build.Props b/DUI3-DX/Directory.Build.Props index eff3fdaa09..8389222c5a 100644 --- a/DUI3-DX/Directory.Build.Props +++ b/DUI3-DX/Directory.Build.Props @@ -5,5 +5,6 @@ enable enable true + NU1903;CS1591;CA1815;CA1003;CA1848;CA1054;CA1812 diff --git a/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/Send.cs b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/Send.cs index 9cecea8d46..9be0d9091c 100644 --- a/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/Send.cs +++ b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/Send.cs @@ -20,7 +20,11 @@ public static class SendHelper /// /// /// + /// /// When , an additional will be included + /// + /// + /// /// The or was /// /// using ServerTransport destination = new(account, streamId); @@ -155,7 +159,7 @@ Dictionary convertedReferences await Task.WhenAll(transportAwaits).ConfigureAwait(false); var parsed = JObject.Parse(obj); - JToken? idToken = parsed.GetValue("id"); + JToken? idToken = parsed.GetValue("id", StringComparison.CurrentCultureIgnoreCase); if (idToken == null) { diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/NamedTypeInjector.cs b/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/NamedTypeInjector.cs index 465415ab33..c0750699bc 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/NamedTypeInjector.cs +++ b/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/NamedTypeInjector.cs @@ -13,7 +13,7 @@ public static ContainerBuilder InjectNamedTypes(this ContainerBuilder contain List types = new(); // POC: hard-coding speckle... :/ - foreach (var asm in AppDomain.CurrentDomain.GetAssemblies().Where(x => x.GetName().Name.StartsWith("Speckle"))) + foreach (var asm in AppDomain.CurrentDomain.GetAssemblies().Where(x => x.GetName().Name.StartsWith("Speckle", StringComparison.CurrentCultureIgnoreCase))) { try { diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/RawConversionRegisterer.cs b/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/RawConversionRegisterer.cs index 3b212a16c4..c088a8ba4b 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/RawConversionRegisterer.cs +++ b/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/RawConversionRegisterer.cs @@ -11,7 +11,7 @@ public static class RawConversionRegisterer public static ContainerBuilder RegisterRawConversions(this ContainerBuilder containerBuilder) { // POC: hard-coding speckle... :/ - foreach (var asm in AppDomain.CurrentDomain.GetAssemblies().Where(x => x.GetName().Name.StartsWith("Speckle"))) + foreach (var asm in AppDomain.CurrentDomain.GetAssemblies().Where(x => x.GetName().Name.StartsWith("Speckle", StringComparison.CurrentCultureIgnoreCase))) { foreach (var type in asm.GetTypes()) { From edd9cade5932522acffedd1de9f093e22a44ee76 Mon Sep 17 00:00:00 2001 From: Adam Hathcock Date: Thu, 9 May 2024 11:02:17 +0100 Subject: [PATCH 138/261] reduce more warnings --- .../DependencyInjection/AutofacArcGISModule.cs | 2 ++ .../DependencyInjection/AutofacAutocadModule.cs | 2 ++ .../DependencyInjection/AutofacUIModule.cs | 8 ++++---- .../DependencyInjection/AutofacRhinoModule.cs | 2 ++ DUI3-DX/Sdk/Speckle.Connectors.Utils/NotNullExtensions.cs | 4 ++-- 5 files changed, 12 insertions(+), 6 deletions(-) diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/DependencyInjection/AutofacArcGISModule.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/DependencyInjection/AutofacArcGISModule.cs index b292184dd9..fb6ef2ae53 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/DependencyInjection/AutofacArcGISModule.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/DependencyInjection/AutofacArcGISModule.cs @@ -103,9 +103,11 @@ private static JsonSerializerSettings GetJsonSerializerSettings() private static void RegisterLoggerFactory(ContainerBuilder builder) { +#pragma warning disable CA1305 var serilogLogger = new LoggerConfiguration().MinimumLevel .Debug() .WriteTo.File("log.txt", rollingInterval: RollingInterval.Day) +#pragma warning restore CA1305 .CreateLogger(); ILoggerFactory loggerFactory = new LoggerFactory().AddSerilog(serilogLogger); diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/DependencyInjection/AutofacAutocadModule.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/DependencyInjection/AutofacAutocadModule.cs index da0c3fb652..c381e0a81f 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/DependencyInjection/AutofacAutocadModule.cs +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/DependencyInjection/AutofacAutocadModule.cs @@ -108,9 +108,11 @@ private static JsonSerializerSettings GetJsonSerializerSettings() private static void RegisterLoggerFactory(ContainerBuilder builder) { +#pragma warning disable CA1305 var serilogLogger = new LoggerConfiguration().MinimumLevel .Debug() .WriteTo.File("log.txt", rollingInterval: RollingInterval.Day) +#pragma warning restore CA1305 .CreateLogger(); ILoggerFactory loggerFactory = new LoggerFactory().AddSerilog(serilogLogger); diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/AutofacUIModule.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/AutofacUIModule.cs index a5a9494d03..e7d74b11cf 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/AutofacUIModule.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/AutofacUIModule.cs @@ -1,4 +1,3 @@ -using System.IO; using Autodesk.Revit.DB; using Autofac; using CefSharp; @@ -90,14 +89,15 @@ protected override void Load(ContainerBuilder builder) // POC: logging factory couldn't be added, which is the recommendation, due to janky dependencies // having a SpeckleLogging service, might be interesting, if a service can listen on a local port or use named pipes - var current = Directory.GetCurrentDirectory(); + +#pragma warning disable CA1305 var serilogLogger = new LoggerConfiguration().MinimumLevel .Debug() .WriteTo.File("log.txt", rollingInterval: RollingInterval.Day) +#pragma warning restore CA1305 .CreateLogger(); - ILoggerFactory loggerFactory = new LoggerFactory(); - var serilog = loggerFactory.AddSerilog(serilogLogger); + ILoggerFactory loggerFactory = new LoggerFactory().AddSerilog(serilogLogger); builder.RegisterInstance(loggerFactory).As().SingleInstance(); } } diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/AutofacRhinoModule.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/AutofacRhinoModule.cs index 2eaba3d714..85b503a89a 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/AutofacRhinoModule.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/AutofacRhinoModule.cs @@ -101,10 +101,12 @@ private static JsonSerializerSettings GetJsonSerializerSettings() private static void RegisterLoggerFactory(ContainerBuilder builder) { +#pragma warning disable CA1305 // POC: will likely need refactoring with our reporting pattern. var serilogLogger = new LoggerConfiguration().MinimumLevel .Debug() .WriteTo.File("log.txt", rollingInterval: RollingInterval.Day) +#pragma warning restore CA1305 .CreateLogger(); ILoggerFactory loggerFactory = new LoggerFactory().AddSerilog(serilogLogger); diff --git a/DUI3-DX/Sdk/Speckle.Connectors.Utils/NotNullExtensions.cs b/DUI3-DX/Sdk/Speckle.Connectors.Utils/NotNullExtensions.cs index 2aecd3260e..a495a73a25 100644 --- a/DUI3-DX/Sdk/Speckle.Connectors.Utils/NotNullExtensions.cs +++ b/DUI3-DX/Sdk/Speckle.Connectors.Utils/NotNullExtensions.cs @@ -7,7 +7,7 @@ public static class NotNullExtensions { public static IEnumerable Empty(this IEnumerable? source) => source ?? Enumerable.Empty(); - public static async Task NotNull(this Task task, string? message = null) + public static async Task NotNull(this Task task, [CallerArgumentExpression(nameof(task))] string? message = null) where T : class { var x = await task.ConfigureAwait(false); @@ -18,7 +18,7 @@ public static async Task NotNull(this Task task, string? message = nul return x; } - public static async Task NotNull(this Task task, string? message = null) + public static async Task NotNull(this Task task, [CallerArgumentExpression(nameof(task))] string? message = null) where T : struct { var x = await task.ConfigureAwait(false); From 7fcb68f1582015b1e15553128efde80f7573e52f Mon Sep 17 00:00:00 2001 From: Adam Hathcock Date: Thu, 9 May 2024 11:32:37 +0100 Subject: [PATCH 139/261] move around no warn --- .../Speckle.Connectors.Revit2023.csproj | 1 + .../DependencyInjection/AutofacUIModule.cs | 2 ++ .../DependencyInjection/AutofacRhinoModule.cs | 5 +++-- .../DependencyInjection/RhinoPlugin.cs | 3 ++- .../HostApp/SpeckleRhinoPanelHost.cs | 2 +- .../Plugin/Speckle.Connectors.Rhino7Command.cs | 6 +----- .../Plugin/Speckle.Connectors.Rhino7Plugin.cs | 4 +--- DUI3-DX/Directory.Build.Props | 1 - 8 files changed, 11 insertions(+), 13 deletions(-) diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.Revit2023/Speckle.Connectors.Revit2023.csproj b/DUI3-DX/Connectors/Revit/Speckle.Connectors.Revit2023/Speckle.Connectors.Revit2023.csproj index adc9ce54e1..1387e8b140 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.Revit2023/Speckle.Connectors.Revit2023.csproj +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.Revit2023/Speckle.Connectors.Revit2023.csproj @@ -3,6 +3,7 @@ net48 x64 true + $(NoWarn);NU1903 diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/AutofacUIModule.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/AutofacUIModule.cs index e7d74b11cf..2b6de06deb 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/AutofacUIModule.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/AutofacUIModule.cs @@ -1,3 +1,4 @@ +using System.Diagnostics.CodeAnalysis; using Autodesk.Revit.DB; using Autofac; using CefSharp; @@ -25,6 +26,7 @@ namespace Speckle.Connectors.Revit.DependencyInjection; // POC: should interface out things that are not public class AutofacUIModule : Module { + [SuppressMessage("Maintainability", "CA1506:Avoid excessive class coupling", Justification = "This is registering everything")] protected override void Load(ContainerBuilder builder) { builder.RegisterInstance(new RevitContext()); diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/AutofacRhinoModule.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/AutofacRhinoModule.cs index 85b503a89a..230c777008 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/AutofacRhinoModule.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/AutofacRhinoModule.cs @@ -22,6 +22,7 @@ using Speckle.Connectors.DUI.Models.Card.SendFilter; using Speckle.Connectors.DUI.WebView; using Speckle.Connectors.Rhino7.Operations.Receive; +using Speckle.Connectors.Utils; using Speckle.Connectors.Utils.Builders; using Speckle.Connectors.Utils.Operations; using Speckle.Core.Models.GraphTraversal; @@ -35,8 +36,8 @@ protected override void Load(ContainerBuilder builder) RegisterLoggerFactory(builder); // Register instances initialised by Rhino - builder.RegisterInstance(SpeckleConnectorsRhino7Plugin.Instance); - builder.RegisterInstance(SpeckleConnectorsRhino7Command.Instance); + builder.RegisterInstance(SpeckleConnectorsRhino7Plugin.Instance.NotNull()); + builder.RegisterInstance(SpeckleConnectorsRhino7Command.Instance.NotNull()); // Register DUI3 related stuff builder.RegisterInstance(GetJsonSerializerSettings()).SingleInstance(); diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/RhinoPlugin.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/RhinoPlugin.cs index a295f9f8b6..e09c4981f7 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/RhinoPlugin.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/RhinoPlugin.cs @@ -3,6 +3,7 @@ using Speckle.Connectors.Rhino7.HostApp; using Speckle.Connectors.Rhino7.Interfaces; using Speckle.Connectors.Rhino7.Plugin; +using Speckle.Connectors.Utils; namespace Speckle.Connectors.Rhino7.DependencyInjection; @@ -21,7 +22,7 @@ public RhinoPlugin(DUI3ControlWebView panel, RhinoSettings settings, RhinoIdleMa public void Initialise() { - _idleManager.SubscribeToIdle(() => RhinoApp.RunScript(SpeckleConnectorsRhino7Command.Instance.EnglishName, false)); + _idleManager.SubscribeToIdle(() => RhinoApp.RunScript(SpeckleConnectorsRhino7Command.Instance.NotNull().EnglishName, false)); } public void Shutdown() { } diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/SpeckleRhinoPanelHost.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/SpeckleRhinoPanelHost.cs index d906161197..d27c7d7a55 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/SpeckleRhinoPanelHost.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/SpeckleRhinoPanelHost.cs @@ -10,7 +10,7 @@ public class SpeckleRhinoPanelHost : RhinoWindows.Controls.WpfElementHost private readonly uint _docSn; public SpeckleRhinoPanelHost(uint docSn) - : base(SpeckleConnectorsRhino7Plugin.Instance.Container?.Resolve(), null) + : base(SpeckleConnectorsRhino7Plugin.Instance?.Container?.Resolve(), null) { _docSn = docSn; } diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Plugin/Speckle.Connectors.Rhino7Command.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Plugin/Speckle.Connectors.Rhino7Command.cs index d3592ad90b..4793862a91 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Plugin/Speckle.Connectors.Rhino7Command.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Plugin/Speckle.Connectors.Rhino7Command.cs @@ -22,12 +22,8 @@ public SpeckleConnectorsRhino7Command() PanelType.System ); } - -#nullable disable ///The only instance of this command. - public static SpeckleConnectorsRhino7Command Instance { get; private set; } - -#nullable enable + public static SpeckleConnectorsRhino7Command? Instance { get; private set; } ///The command name as it appears on the Rhino command line. public override string EnglishName => "SpeckleNewUI"; diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Plugin/Speckle.Connectors.Rhino7Plugin.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Plugin/Speckle.Connectors.Rhino7Plugin.cs index 09aeab7af7..5325ad65ec 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Plugin/Speckle.Connectors.Rhino7Plugin.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Plugin/Speckle.Connectors.Rhino7Plugin.cs @@ -32,11 +32,9 @@ public SpeckleConnectorsRhino7Plugin() Instance = this; } -#nullable disable ///Gets the only instance of the Speckle_Connectors_Rhino7Plugin plug-in. - public static SpeckleConnectorsRhino7Plugin Instance { get; private set; } + public static SpeckleConnectorsRhino7Plugin? Instance { get; private set; } -#nullable enable // You can override methods here to change the plug-in behavior on // loading and shut down, add options pages to the Rhino _Option command // and maintain plug-in wide options in a document. diff --git a/DUI3-DX/Directory.Build.Props b/DUI3-DX/Directory.Build.Props index 8389222c5a..eff3fdaa09 100644 --- a/DUI3-DX/Directory.Build.Props +++ b/DUI3-DX/Directory.Build.Props @@ -5,6 +5,5 @@ enable enable true - NU1903;CS1591;CA1815;CA1003;CA1848;CA1054;CA1812 From 04afe56346b17041b8f31b90551dd60ebf52b885 Mon Sep 17 00:00:00 2001 From: Adam Hathcock Date: Thu, 9 May 2024 11:33:25 +0100 Subject: [PATCH 140/261] fmt --- .../Bindings/SendBinding.cs | 3 ++- .../DependencyInjection/AutofacUIModule.cs | 6 +++++- .../HostApp/RevitDocumentStore.cs | 3 ++- .../DependencyInjection/RhinoPlugin.cs | 4 +++- .../Plugin/Speckle.Connectors.Rhino7Command.cs | 1 + .../Utils/ArcGISProjectUtils.cs | 4 +++- .../RevitVersionConversionHelper.cs | 1 - .../Helpers/DisplayValueExtractor.cs | 2 +- .../Sdk/Speckle.Connectors.Utils/NotNullExtensions.cs | 10 ++++++++-- .../NamedTypeInjector.cs | 6 +++++- .../RawConversionRegisterer.cs | 6 +++++- 11 files changed, 35 insertions(+), 11 deletions(-) diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SendBinding.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SendBinding.cs index 41f85b02af..4a09620ac1 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SendBinding.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SendBinding.cs @@ -95,7 +95,8 @@ private async Task HandleSend(string modelCardId) SendOperation >(); - List revitObjects = modelCard.SendFilter?.GetObjectIds().Select(id => ElementId.Parse(id)).ToList() ?? new(); + List revitObjects = + modelCard.SendFilter?.GetObjectIds().Select(id => ElementId.Parse(id)).ToList() ?? new(); var sendInfo = new SendInfo( modelCard.AccountId.NotNull(), diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/AutofacUIModule.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/AutofacUIModule.cs index 2b6de06deb..b27ff0f4cb 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/AutofacUIModule.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/AutofacUIModule.cs @@ -26,7 +26,11 @@ namespace Speckle.Connectors.Revit.DependencyInjection; // POC: should interface out things that are not public class AutofacUIModule : Module { - [SuppressMessage("Maintainability", "CA1506:Avoid excessive class coupling", Justification = "This is registering everything")] + [SuppressMessage( + "Maintainability", + "CA1506:Avoid excessive class coupling", + Justification = "This is registering everything" + )] protected override void Load(ContainerBuilder builder) { builder.RegisterInstance(new RevitContext()); diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/RevitDocumentStore.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/RevitDocumentStore.cs index 5d9d79a68a..1b042d43f6 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/RevitDocumentStore.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/RevitDocumentStore.cs @@ -98,7 +98,8 @@ private void WriteToFileWithDoc(Document doc) t.Commit(); } - public override void WriteToFile() => WriteToFileWithDoc(_revitContext.UIApplication.NotNull().ActiveUIDocument.Document); + public override void WriteToFile() => + WriteToFileWithDoc(_revitContext.UIApplication.NotNull().ActiveUIDocument.Document); public override void ReadFromFile() { diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/RhinoPlugin.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/RhinoPlugin.cs index e09c4981f7..db689b814f 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/RhinoPlugin.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/RhinoPlugin.cs @@ -22,7 +22,9 @@ public RhinoPlugin(DUI3ControlWebView panel, RhinoSettings settings, RhinoIdleMa public void Initialise() { - _idleManager.SubscribeToIdle(() => RhinoApp.RunScript(SpeckleConnectorsRhino7Command.Instance.NotNull().EnglishName, false)); + _idleManager.SubscribeToIdle( + () => RhinoApp.RunScript(SpeckleConnectorsRhino7Command.Instance.NotNull().EnglishName, false) + ); } public void Shutdown() { } diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Plugin/Speckle.Connectors.Rhino7Command.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Plugin/Speckle.Connectors.Rhino7Command.cs index 4793862a91..d28824f889 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Plugin/Speckle.Connectors.Rhino7Command.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Plugin/Speckle.Connectors.Rhino7Command.cs @@ -22,6 +22,7 @@ public SpeckleConnectorsRhino7Command() PanelType.System ); } + ///The only instance of this command. public static SpeckleConnectorsRhino7Command? Instance { get; private set; } diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/ArcGISProjectUtils.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/ArcGISProjectUtils.cs index e3fd49b330..bf38a876bd 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/ArcGISProjectUtils.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/ArcGISProjectUtils.cs @@ -68,7 +68,9 @@ public string AddDatabaseToProject(string databasePath) QueuedTask.Run(() => Project.Current.AddItem(folderToAdd as IProjectItem)); // Add a file geodatabase or a SQLite or enterprise database connection to a project - var gdbToAdd = folderToAdd.GetItems().FirstOrDefault(folderItem => folderItem.Name.Equals(fGdbName, StringComparison.Ordinal)); + var gdbToAdd = folderToAdd + .GetItems() + .FirstOrDefault(folderItem => folderItem.Name.Equals(fGdbName, StringComparison.Ordinal)); if (gdbToAdd is not null) { // POC: QueuedTask diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023/RevitVersionConversionHelper.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023/RevitVersionConversionHelper.cs index f22ef3a50f..515c2e057f 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023/RevitVersionConversionHelper.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023/RevitVersionConversionHelper.cs @@ -17,4 +17,3 @@ public bool IsCurveClosed(DB.NurbSpline nurbsSpline) } } } - diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/DisplayValueExtractor.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/DisplayValueExtractor.cs index 0b8dfbec3c..c2c5890b5f 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/DisplayValueExtractor.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/DisplayValueExtractor.cs @@ -116,7 +116,7 @@ public DisplayValueExtractor( /// does not have modified geometry (the docs say that modified geometry will not have a geom instance, /// however in my experience, all family instances have a top-level geom instance, but if the family instance /// is modified, then the geom instance won't contain any geometry.) - /// + /// /// This remark also leads me to think that a family instance will not have top-level solids and geom instances. /// We are logging cases where this is not true. /// diff --git a/DUI3-DX/Sdk/Speckle.Connectors.Utils/NotNullExtensions.cs b/DUI3-DX/Sdk/Speckle.Connectors.Utils/NotNullExtensions.cs index a495a73a25..4ca533976a 100644 --- a/DUI3-DX/Sdk/Speckle.Connectors.Utils/NotNullExtensions.cs +++ b/DUI3-DX/Sdk/Speckle.Connectors.Utils/NotNullExtensions.cs @@ -7,7 +7,10 @@ public static class NotNullExtensions { public static IEnumerable Empty(this IEnumerable? source) => source ?? Enumerable.Empty(); - public static async Task NotNull(this Task task, [CallerArgumentExpression(nameof(task))] string? message = null) + public static async Task NotNull( + this Task task, + [CallerArgumentExpression(nameof(task))] string? message = null + ) where T : class { var x = await task.ConfigureAwait(false); @@ -18,7 +21,10 @@ public static async Task NotNull(this Task task, [CallerArgumentExpres return x; } - public static async Task NotNull(this Task task, [CallerArgumentExpression(nameof(task))] string? message = null) + public static async Task NotNull( + this Task task, + [CallerArgumentExpression(nameof(task))] string? message = null + ) where T : struct { var x = await task.ConfigureAwait(false); diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/NamedTypeInjector.cs b/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/NamedTypeInjector.cs index c0750699bc..f022d4fb29 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/NamedTypeInjector.cs +++ b/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/NamedTypeInjector.cs @@ -13,7 +13,11 @@ public static ContainerBuilder InjectNamedTypes(this ContainerBuilder contain List types = new(); // POC: hard-coding speckle... :/ - foreach (var asm in AppDomain.CurrentDomain.GetAssemblies().Where(x => x.GetName().Name.StartsWith("Speckle", StringComparison.CurrentCultureIgnoreCase))) + foreach ( + var asm in AppDomain.CurrentDomain + .GetAssemblies() + .Where(x => x.GetName().Name.StartsWith("Speckle", StringComparison.CurrentCultureIgnoreCase)) + ) { try { diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/RawConversionRegisterer.cs b/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/RawConversionRegisterer.cs index c088a8ba4b..ce68ba20ca 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/RawConversionRegisterer.cs +++ b/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/RawConversionRegisterer.cs @@ -11,7 +11,11 @@ public static class RawConversionRegisterer public static ContainerBuilder RegisterRawConversions(this ContainerBuilder containerBuilder) { // POC: hard-coding speckle... :/ - foreach (var asm in AppDomain.CurrentDomain.GetAssemblies().Where(x => x.GetName().Name.StartsWith("Speckle", StringComparison.CurrentCultureIgnoreCase))) + foreach ( + var asm in AppDomain.CurrentDomain + .GetAssemblies() + .Where(x => x.GetName().Name.StartsWith("Speckle", StringComparison.CurrentCultureIgnoreCase)) + ) { foreach (var type in asm.GetTypes()) { From 73c73739256c6575c8810726f444b6bf681bcf57 Mon Sep 17 00:00:00 2001 From: Adam Hathcock Date: Thu, 9 May 2024 11:41:35 +0100 Subject: [PATCH 141/261] change pragmas or disable --- .../DependencyInjection/AutofacArcGISModule.cs | 2 -- .../DependencyInjection/AutofacAutocadModule.cs | 2 -- .../DependencyInjection/AutofacUIModule.cs | 2 -- .../DependencyInjection/AutofacRhinoModule.cs | 2 -- .../Helpers/RevitCategoryInfo.cs | 4 ++-- .../ReferencePointConverter.cs | 8 +++----- .../ToHost/Raw/NurbsCurveToHostConverter.cs | 9 +-------- 7 files changed, 6 insertions(+), 23 deletions(-) diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/DependencyInjection/AutofacArcGISModule.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/DependencyInjection/AutofacArcGISModule.cs index fb6ef2ae53..b292184dd9 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/DependencyInjection/AutofacArcGISModule.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/DependencyInjection/AutofacArcGISModule.cs @@ -103,11 +103,9 @@ private static JsonSerializerSettings GetJsonSerializerSettings() private static void RegisterLoggerFactory(ContainerBuilder builder) { -#pragma warning disable CA1305 var serilogLogger = new LoggerConfiguration().MinimumLevel .Debug() .WriteTo.File("log.txt", rollingInterval: RollingInterval.Day) -#pragma warning restore CA1305 .CreateLogger(); ILoggerFactory loggerFactory = new LoggerFactory().AddSerilog(serilogLogger); diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/DependencyInjection/AutofacAutocadModule.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/DependencyInjection/AutofacAutocadModule.cs index c381e0a81f..da0c3fb652 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/DependencyInjection/AutofacAutocadModule.cs +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/DependencyInjection/AutofacAutocadModule.cs @@ -108,11 +108,9 @@ private static JsonSerializerSettings GetJsonSerializerSettings() private static void RegisterLoggerFactory(ContainerBuilder builder) { -#pragma warning disable CA1305 var serilogLogger = new LoggerConfiguration().MinimumLevel .Debug() .WriteTo.File("log.txt", rollingInterval: RollingInterval.Day) -#pragma warning restore CA1305 .CreateLogger(); ILoggerFactory loggerFactory = new LoggerFactory().AddSerilog(serilogLogger); diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/AutofacUIModule.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/AutofacUIModule.cs index b27ff0f4cb..daf042113e 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/AutofacUIModule.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/AutofacUIModule.cs @@ -96,11 +96,9 @@ protected override void Load(ContainerBuilder builder) // POC: logging factory couldn't be added, which is the recommendation, due to janky dependencies // having a SpeckleLogging service, might be interesting, if a service can listen on a local port or use named pipes -#pragma warning disable CA1305 var serilogLogger = new LoggerConfiguration().MinimumLevel .Debug() .WriteTo.File("log.txt", rollingInterval: RollingInterval.Day) -#pragma warning restore CA1305 .CreateLogger(); ILoggerFactory loggerFactory = new LoggerFactory().AddSerilog(serilogLogger); diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/AutofacRhinoModule.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/AutofacRhinoModule.cs index 230c777008..8436efde8d 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/AutofacRhinoModule.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/AutofacRhinoModule.cs @@ -102,12 +102,10 @@ private static JsonSerializerSettings GetJsonSerializerSettings() private static void RegisterLoggerFactory(ContainerBuilder builder) { -#pragma warning disable CA1305 // POC: will likely need refactoring with our reporting pattern. var serilogLogger = new LoggerConfiguration().MinimumLevel .Debug() .WriteTo.File("log.txt", rollingInterval: RollingInterval.Day) -#pragma warning restore CA1305 .CreateLogger(); ILoggerFactory loggerFactory = new LoggerFactory().AddSerilog(serilogLogger); diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/RevitCategoryInfo.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/RevitCategoryInfo.cs index 26c13adb66..f883f7c9e8 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/RevitCategoryInfo.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/RevitCategoryInfo.cs @@ -1,3 +1,4 @@ +using System.Diagnostics.CodeAnalysis; using Autodesk.Revit.DB; namespace Speckle.Converters.RevitShared.Helpers; @@ -36,13 +37,12 @@ public List GetElementTypes(Document document) return GetElementTypes(document); } + [SuppressMessage("Reliability", "CA2000:Dispose objects before losing scope")] public List GetElementTypes(Document document) where T : ElementType { // POC: why is this disabled? surely a using statement is golden here? -#pragma warning disable CA2000 // Dispose objects before losing scope var collector = new FilteredElementCollector(document); -#pragma warning restore CA2000 // Dispose objects before losing scope if (BuiltInCategories.Count > 0) { diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ReferencePointConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ReferencePointConverter.cs index 89d68bb58f..1c63df79d6 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ReferencePointConverter.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ReferencePointConverter.cs @@ -1,4 +1,5 @@ -using Speckle.Converters.RevitShared.Helpers; +using System.Diagnostics.CodeAnalysis; +using Speckle.Converters.RevitShared.Helpers; namespace Speckle.Converters.RevitShared; @@ -53,18 +54,17 @@ public DB.Transform GetDocReferencePointTransform(DB.Document doc) return _docTransforms[id]; } + [SuppressMessage("Reliability", "CA2000:Dispose objects before losing scope")] public DB.Transform GetReferencePointTransform(string referencePointSetting) { // first get the main doc base points and reference setting transform var referencePointTransform = DB.Transform.Identity; // POC: bogus disposal below -#pragma warning disable CA2000 var points = new DB.FilteredElementCollector(_contextStack.Current.Document) .OfClass(typeof(DB.BasePoint)) .Cast() .ToList(); -#pragma warning restore CA2000 var projectPoint = points.FirstOrDefault(o => o.IsShared == false); var surveyPoint = points.FirstOrDefault(o => o.IsShared); @@ -84,11 +84,9 @@ public DB.Transform GetReferencePointTransform(string referencePointSetting) var angle = projectPoint.get_Parameter(DB.BuiltInParameter.BASEPOINT_ANGLETON_PARAM)?.AsDouble() ?? 0; // POC: following disposed incorrectly or early or maybe a false negative? -#pragma warning disable CA2000 referencePointTransform = DB.Transform .CreateTranslation(surveyPoint.Position) .Multiply(DB.Transform.CreateRotation(DB.XYZ.BasisZ, angle)); -#pragma warning restore CA2000 break; diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/NurbsCurveToHostConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/NurbsCurveToHostConverter.cs index 41b59620f9..8a18c5b413 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/NurbsCurveToHostConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/NurbsCurveToHostConverter.cs @@ -21,14 +21,7 @@ public NurbsCurveToHostConverter(IRawConversion inter /// ⚠️ This conversion does NOT perform scaling. public RG.NurbsCurve RawConvert(SOG.Curve target) { - RG.NurbsCurve? nurbsCurve = new(target.degree, target.points.Count / 3); - -#pragma warning disable CA1508 - if (nurbsCurve == null) // POC: CNX-9272 Nullability is wrong here, cannot remove this warning but code is required. -#pragma warning restore CA1508 - { - throw new SpeckleConversionException("Attempt to create Nurbs Curve failed with no explanation from Rhino"); - } + RG.NurbsCurve nurbsCurve = new(target.degree, target.points.Count / 3); // Hyper optimised curve control point conversion for (int i = 2, j = 0; i < target.points.Count; i += 3, j++) From ee40758462d0948015790c2b1e55c04c21663244 Mon Sep 17 00:00:00 2001 From: KatKatKateryna <89912278+KatKatKateryna@users.noreply.github.com> Date: Thu, 9 May 2024 18:42:19 +0800 Subject: [PATCH 142/261] Receive non-native geometry in ArcGIS (#3370) * draft for receiving non-native geometry * separate converters * fix utils * recover old GIS features on Receive * conversions; todo: class name; arcs fix * unique class names * add progress bar for baking * fix polycurve and polyline * ellipse * cleaning build errors * refactor * meshes fix * revert arcs * rename GisPolygonGeometry for consistency * reliable geometry name; throw error on CRS projection * register pointcloud converter * fixing poittcloud registration --- .../Operations/Receive/HostObjectBuilder.cs | 153 +++++++++++++----- .../AutofacArcGIS3ConverterModule.cs | 1 + .../Features/GeometryToHostConverter.cs | 16 +- .../Features/GeometryToSpeckleBase.cs | 6 +- .../Features/GisFeatureToSpeckleConverter.cs | 8 +- .../MultipatchFeatureToSpeckleConverter.cs | 6 +- .../PolygonFeatureToSpeckleConverter.cs | 8 +- .../Geometry/GeometryExtension.cs | 2 +- .../Polygon3dToHostConverter.cs | 6 +- .../PolygonToHostConverter.cs | 6 +- .../ArcToHostConverter.cs | 16 +- .../CircleToHostConverter.cs | 7 +- .../EllipseToHostConverter.cs | 13 +- .../MeshToHostConverter.cs | 13 +- .../PolycurveToHostConverter.cs | 13 +- .../PolylineToHostConverter.cs | 6 +- .../Geometry/PointToSpeckleConverter.cs | 22 ++- .../Layers/FeatureClassToHostConverter.cs | 45 +++++- .../PointcloudLayerToSpeckleConverter.cs | 11 +- .../Utils/CharacterCleaner.cs | 2 +- .../Utils/FeatureClassUtils.cs | 72 +++++++-- .../Utils/IFeatureClassUtils.cs | 6 + .../Utils/INonNativeFeaturesUtils.cs | 8 + .../Utils/NonNativeFeaturesUtils.cs | 141 ++++++++++++++++ Objects/Objects/GIS/GisPolygonGeometry.cs | 4 +- Objects/Objects/GIS/GisPolygonGeometry3d.cs | 2 +- 26 files changed, 472 insertions(+), 121 deletions(-) create mode 100644 DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/INonNativeFeaturesUtils.cs create mode 100644 DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/NonNativeFeaturesUtils.cs diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Receive/HostObjectBuilder.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Receive/HostObjectBuilder.cs index f79cd40a2a..17e81693a0 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Receive/HostObjectBuilder.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Receive/HostObjectBuilder.cs @@ -7,6 +7,8 @@ using Speckle.Core.Models.Extensions; using ArcGIS.Desktop.Framework.Threading.Tasks; using Speckle.Converters.ArcGIS3.Utils; +using ArcGIS.Core.Geometry; +using Objects.GIS; namespace Speckle.Connectors.ArcGIS.Operations.Receive; @@ -14,19 +16,59 @@ public class HostObjectBuilder : IHostObjectBuilder { private readonly ISpeckleConverterToHost _toHostConverter; private readonly IArcGISProjectUtils _arcGISProjectUtils; + private readonly INonNativeFeaturesUtils _nonGisFeaturesUtils; // POC: figure out the correct scope to only initialize on Receive - // private readonly IConversionContextStack _contextStack; + private readonly IConversionContextStack _contextStack; public HostObjectBuilder( ISpeckleConverterToHost toHostConverter, - IArcGISProjectUtils arcGISProjectUtils - // IConversionContextStack contextStack + IArcGISProjectUtils arcGISProjectUtils, + IConversionContextStack contextStack, + INonNativeFeaturesUtils nonGisFeaturesUtils ) { _toHostConverter = toHostConverter; _arcGISProjectUtils = arcGISProjectUtils; - // _contextStack = contextStack; + _contextStack = contextStack; + _nonGisFeaturesUtils = nonGisFeaturesUtils; + } + + public Tuple, Geometry> ConvertNonNativeGeometries(Base obj, string[] path, List objectIds) + { + Geometry converted = (Geometry)_toHostConverter.Convert(obj); + objectIds.Add(obj.id); + List objPath = path.ToList(); + objPath.Add(obj.speckle_type.Split(".")[^1]); + return Tuple.Create(objPath, converted); + } + + public Tuple ConvertNativeLayers(Base obj, string[] path, List objectIds) + { + string converted = (string)_toHostConverter.Convert(obj); + objectIds.Add(obj.id); + string objPath = $"{string.Join("\\", path)}\\{((Collection)obj).name}"; + return Tuple.Create(objPath, converted); + } + + public void AddDatasetsToMap(Tuple databaseObj, string databasePath) + { + try + { + LayerFactory.Instance.CreateLayer( + new Uri($"{databasePath}\\{databaseObj.Item2}"), + _contextStack.Current.Document, + layerName: databaseObj.Item1 + ); + } + catch (ArgumentException) + { + StandaloneTableFactory.Instance.CreateStandaloneTable( + new Uri($"{databasePath}\\{databaseObj.Item2}"), + _contextStack.Current.Document, + tableName: databaseObj.Item1 + ); + } } public IEnumerable Build( @@ -48,57 +90,71 @@ CancellationToken cancellationToken // POC: This is where we will define our receive strategy, or maybe later somewhere else according to some setting pass from UI? IEnumerable<(string[], Base)> objectsWithPath = rootObject.TraverseWithPath((obj) => obj is not Collection); + IEnumerable<(string[], Base)> gisObjectsWithPath = objectsWithPath.Where( + x => x.Item2 is VectorLayer || x.Item2 is Objects.GIS.RasterLayer + ); + IEnumerable<(string[], Base)> nonGisObjectsWithPath = objectsWithPath.Where( + x => x.Item2 is not GisFeature && x.Item2 is not VectorLayer && x.Item2 is not Objects.GIS.RasterLayer + ); + List objectIds = new(); int count = 0; - foreach ((string[] path, Base obj) in objectsWithPath) + int allCount = objectsWithPath.Count(); + + Dictionary, Geometry>> convertedGeometries = new(); + List> convertedGISObjects = new(); + + // 1.1. convert non-gis objects in a loop + foreach ((string[] path, Base obj) in nonGisObjectsWithPath) { if (cancellationToken.IsCancellationRequested) { throw new OperationCanceledException(cancellationToken); } - try { - // BAKE OBJECTS HERE + // POC: QueuedTask + QueuedTask.Run(() => + { + convertedGeometries[obj.id] = ConvertNonNativeGeometries(obj, path, objectIds); + }); + onOperationProgressed?.Invoke("Converting", (double)++count / allCount); + } + catch (Exception e) when (!e.IsFatal()) // DO NOT CATCH SPECIFIC STUFF, conversion errors should be recoverable + { + // POC: report, etc. + Debug.WriteLine("conversion error happened."); + } + } + // 1.2. convert Database entries with non-GIS geometry datasets + try + { + onOperationProgressed?.Invoke("Writing to Database", null); + convertedGISObjects.AddRange(_nonGisFeaturesUtils.WriteGeometriesToDatasets(convertedGeometries)); + } + catch (Exception e) when (!e.IsFatal()) // DO NOT CATCH SPECIFIC STUFF, conversion errors should be recoverable + { + // POC: report, etc. + Debug.WriteLine("conversion error happened."); + } + // 2. convert gis-objects in a loop + foreach ((string[] path, Base obj) in gisObjectsWithPath) + { + if (cancellationToken.IsCancellationRequested) + { + throw new OperationCanceledException(cancellationToken); + } + try + { // POC: QueuedTask var task = QueuedTask.Run(() => { - try - { - var converted = _toHostConverter.Convert(obj); - if (converted is string uri) - { - objectIds.Add(obj.id); - // POC: TODO: get map from contextStack instead - try - { - LayerFactory.Instance.CreateLayer( - new Uri($"{databasePath}\\{uri}"), - MapView.Active.Map, - layerName: ((Collection)obj).name - ); - } - catch (ArgumentException) - { - StandaloneTableFactory.Instance.CreateStandaloneTable( - new Uri($"{databasePath}\\{uri}"), - MapView.Active.Map, - tableName: ((Collection)obj).name - ); - } - } - } - catch (ArgumentException) - { - // for the layers with "invalid" names - // doesn't do anything actually, but needs to be logged - throw; - } + convertedGISObjects.Add(ConvertNativeLayers(obj, path, objectIds)); }); task.Wait(cancellationToken); - onOperationProgressed?.Invoke("Converting", (double)++count / objectsWithPath.Count()); + onOperationProgressed?.Invoke("Converting", (double)++count / allCount); } catch (Exception e) when (!e.IsFatal()) // DO NOT CATCH SPECIFIC STUFF, conversion errors should be recoverable { @@ -107,6 +163,25 @@ CancellationToken cancellationToken } } + int bakeCount = 0; + onOperationProgressed?.Invoke("Adding to Map", 0); + // 3. add layer and tables to the Table Of Content + foreach (Tuple databaseObj in convertedGISObjects) + { + if (cancellationToken.IsCancellationRequested) + { + throw new OperationCanceledException(cancellationToken); + } + // BAKE OBJECTS HERE + // POC: QueuedTask + var task = QueuedTask.Run(() => + { + AddDatasetsToMap(databaseObj, databasePath); + onOperationProgressed?.Invoke("Adding to Map", (double)++bakeCount / convertedGISObjects.Count); + }); + task.Wait(cancellationToken); + } + return objectIds; } } diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3.DependencyInjection/AutofacArcGIS3ConverterModule.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3.DependencyInjection/AutofacArcGIS3ConverterModule.cs index 0e0c7268d2..12683316ec 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3.DependencyInjection/AutofacArcGIS3ConverterModule.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3.DependencyInjection/AutofacArcGIS3ConverterModule.cs @@ -21,6 +21,7 @@ protected override void Load(ContainerBuilder builder) builder.RegisterType().As().InstancePerLifetimeScope(); builder.RegisterType().As().InstancePerLifetimeScope(); builder.RegisterType().As().InstancePerLifetimeScope(); + builder.RegisterType().As().InstancePerLifetimeScope(); builder .RegisterType() diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GeometryToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GeometryToHostConverter.cs index 67b55d6b69..60310dcd51 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GeometryToHostConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GeometryToHostConverter.cs @@ -8,15 +8,15 @@ public class GeometryToHostConverter : IRawConversion, ACG.G { private readonly IRawConversion _polylineConverter; private readonly IRawConversion, ACG.Multipoint> _multipointConverter; - private readonly IRawConversion, ACG.Multipatch> _polygon3dConverter; - private readonly IRawConversion, ACG.Polygon> _polygonConverter; + private readonly IRawConversion, ACG.Multipatch> _polygon3dConverter; + private readonly IRawConversion, ACG.Polygon> _polygonConverter; private readonly IRawConversion, ACG.Multipatch> _multipatchConverter; public GeometryToHostConverter( IRawConversion polylineConverter, IRawConversion, ACG.Multipoint> multipointConverter, - IRawConversion, ACG.Multipatch> polygon3dConverter, - IRawConversion, ACG.Polygon> polygonConverter, + IRawConversion, ACG.Multipatch> polygon3dConverter, + IRawConversion, ACG.Polygon> polygonConverter, IRawConversion, ACG.Multipatch> multipatchConverter ) { @@ -43,10 +43,10 @@ public ACG.Geometry RawConvert(IReadOnlyList target) throw new SpeckleConversionException("Polyline conversion only supports one polyline at a time"); } return _polylineConverter.RawConvert(target.Cast().ToList()[0]); - case SGIS.GisPolygonGeometry3d geometry3d: - return _polygon3dConverter.RawConvert(target.Cast().ToList()); - case SGIS.GisPolygonGeometry geometry: - return _polygonConverter.RawConvert(target.Cast().ToList()); + case SGIS.PolygonGeometry3d geometry3d: + return _polygon3dConverter.RawConvert(target.Cast().ToList()); + case SGIS.PolygonGeometry geometry: + return _polygonConverter.RawConvert(target.Cast().ToList()); case SGIS.GisMultipatchGeometry mesh: return _multipatchConverter.RawConvert(target.Cast().ToList()); default: diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GeometryToSpeckleBase.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GeometryToSpeckleBase.cs index ab36eef195..f32ca4bdde 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GeometryToSpeckleBase.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GeometryToSpeckleBase.cs @@ -9,14 +9,14 @@ public class GeometryToSpeckleBaseList : IRawConversion _pointToSpeckleConverter; private readonly IRawConversion> _multiPointFeatureConverter; private readonly IRawConversion> _polylineFeatureConverter; - private readonly IRawConversion> _polygonFeatureConverter; + private readonly IRawConversion> _polygonFeatureConverter; private readonly IRawConversion> _multipatchFeatureConverter; public GeometryToSpeckleBaseList( IRawConversion pointToSpeckleConverter, IRawConversion> multiPointFeatureConverter, IRawConversion> polylineFeatureConverter, - IRawConversion> polygonFeatureConverter, + IRawConversion> polygonFeatureConverter, IRawConversion> multipatchFeatureConverter ) { @@ -37,7 +37,7 @@ public IReadOnlyList RawConvert(ACG.Geometry target) ACG.Multipoint multipoint => _multiPointFeatureConverter.RawConvert(multipoint), ACG.Polyline polyline => _polylineFeatureConverter.RawConvert(polyline), ACG.Polygon polygon => _polygonFeatureConverter.RawConvert(polygon), - ACG.Multipatch multipatch => _multipatchFeatureConverter.RawConvert(multipatch), // GisMultipatchGeometry or GisPolygonGeometry3d + ACG.Multipatch multipatch => _multipatchFeatureConverter.RawConvert(multipatch), // GisMultipatchGeometry or PolygonGeometry3d _ => throw new NotSupportedException($"No conversion found for {target.GetType().Name}"), }; } diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GisFeatureToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GisFeatureToSpeckleConverter.cs index f1883f6429..ff34d8fa0d 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GisFeatureToSpeckleConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GisFeatureToSpeckleConverter.cs @@ -20,7 +20,7 @@ private List GenerateFeatureDisplayValueList(List speckleShapes) List displayVal = new(); foreach (var shp in speckleShapes) { - if (shp is SGIS.GisPolygonGeometry polygon) // also will be valid for Polygon3d, as it inherits from Polygon + if (shp is SGIS.PolygonGeometry polygon) // also will be valid for Polygon3d, as it inherits from Polygon { try { @@ -53,6 +53,7 @@ public SGIS.GisFeature RawConvert(Row target) // get attributes var attributes = new Base(); bool hasGeometry = false; + string geometryField = "Shape"; IReadOnlyList fields = target.GetFields(); foreach (Field field in fields) { @@ -61,6 +62,7 @@ public SGIS.GisFeature RawConvert(Row target) if (field.FieldType == FieldType.Geometry) // ignore the field with geometry itself { hasGeometry = true; + geometryField = name; } // Raster FieldType is not properly supported through API else if ( @@ -91,13 +93,13 @@ public SGIS.GisFeature RawConvert(Row target) } else { - var shape = (ACG.Geometry)target["Shape"]; + var shape = (ACG.Geometry)target[geometryField]; var speckleShapes = _geometryConverter.RawConvert(shape).ToList(); // if geometry is primitive if ( speckleShapes.Count > 0 - && speckleShapes[0] is not SGIS.GisPolygonGeometry + && speckleShapes[0] is not SGIS.PolygonGeometry && speckleShapes[0] is not SGIS.GisMultipatchGeometry ) { diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/MultipatchFeatureToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/MultipatchFeatureToSpeckleConverter.cs index 2322f87ae1..645396f25a 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/MultipatchFeatureToSpeckleConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/MultipatchFeatureToSpeckleConverter.cs @@ -24,7 +24,7 @@ public IReadOnlyList RawConvert(ACG.Multipatch target) { List converted = new(); // placeholder, needs to be declared in order to be used in the Ring patch type - SGIS.GisPolygonGeometry3d polygonGeom = new() { }; + SGIS.PolygonGeometry3d polygonGeom = new() { }; // convert and store all multipatch points per Part List> allPoints = new(); @@ -65,7 +65,7 @@ public IReadOnlyList RawConvert(ACG.Multipatch target) multipatch.units = _contextStack.Current.SpeckleUnits; converted.Add(multipatch); } - // in case of RingMultipatch - return GisPolygonGeometry3d + // in case of RingMultipatch - return PolygonGeometry3d // the following Patch Parts cannot be pushed to external method, as they will possibly, add voids/rings to the same GisPolygon else if (patchType == ACG.PatchType.FirstRing) { @@ -75,7 +75,7 @@ public IReadOnlyList RawConvert(ACG.Multipatch target) converted.Add(polygonGeom); } - // first ring means a start of a new GisPolygonGeometry3d + // first ring means a start of a new PolygonGeometry3d polygonGeom = new() { voids = new List() }; List pointCoords = allPoints[idx].SelectMany(x => new List() { x.x, x.y, x.z }).ToList(); diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/PolygonFeatureToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/PolygonFeatureToSpeckleConverter.cs index b984b2e21b..4eea1ba419 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/PolygonFeatureToSpeckleConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/PolygonFeatureToSpeckleConverter.cs @@ -4,7 +4,7 @@ namespace Speckle.Converters.ArcGIS3.Features; -public class PolygonFeatureToSpeckleConverter : IRawConversion> +public class PolygonFeatureToSpeckleConverter : IRawConversion> { private readonly IRawConversion _segmentConverter; @@ -13,10 +13,10 @@ public PolygonFeatureToSpeckleConverter(IRawConversion RawConvert(ACG.Polygon target) + public IReadOnlyList RawConvert(ACG.Polygon target) { // https://pro.arcgis.com/en/pro-app/latest/sdk/api-reference/topic30235.html - List polygonList = new(); + List polygonList = new(); int partCount = target.PartCount; if (partCount == 0) @@ -24,7 +24,7 @@ public IReadOnlyList RawConvert(ACG.Polygon target) throw new SpeckleConversionException("ArcGIS Polygon contains no parts"); } - GisPolygonGeometry? polygon = null; + PolygonGeometry? polygon = null; // test each part for "exterior ring" for (int idx = 0; idx < partCount; idx++) diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GeometryExtension.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GeometryExtension.cs index 3696822606..cd0e8bfbd0 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GeometryExtension.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GeometryExtension.cs @@ -73,7 +73,7 @@ public static bool IsClockwisePolygon(this SOG.Polyline polyline) return isClockwise; } - public static SOG.Mesh CreateDisplayMeshForPolygon(this SGIS.GisPolygonGeometry polygon) + public static SOG.Mesh CreateDisplayMeshForPolygon(this SGIS.PolygonGeometry polygon) { if (polygon.voids.Count == 0) { diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/Polygon3dToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/Polygon3dToHostConverter.cs index c466b00b1f..cebd781a3b 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/Polygon3dToHostConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/Polygon3dToHostConverter.cs @@ -3,7 +3,7 @@ namespace Speckle.Converters.ArcGIS3.Geometry.GisFeatureGeometriesToHost; -public class Polygon3dToHostConverter : IRawConversion, ACG.Multipatch> +public class Polygon3dToHostConverter : IRawConversion, ACG.Multipatch> { private readonly IRawConversion _pointConverter; private readonly IRawConversion _polylineConverter; @@ -17,7 +17,7 @@ public Polygon3dToHostConverter( _polylineConverter = polylineConverter; } - public ACG.Multipatch RawConvert(List target) + public ACG.Multipatch RawConvert(List target) { if (target.Count == 0) { @@ -25,7 +25,7 @@ public ACG.Multipatch RawConvert(List target) } ACG.MultipatchBuilderEx multipatchPart = new(); - foreach (SGIS.GisPolygonGeometry3d part in target) + foreach (SGIS.PolygonGeometry3d part in target) { ACG.Patch newPatch = multipatchPart.MakePatch(ACG.PatchType.FirstRing); List boundaryPts = part.boundary.GetPoints(); diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/PolygonToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/PolygonToHostConverter.cs index 0520503903..8ae163e2d8 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/PolygonToHostConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/PolygonToHostConverter.cs @@ -3,7 +3,7 @@ namespace Speckle.Converters.ArcGIS3.Geometry.GisFeatureGeometriesToHost; -public class PolygonToHostConverter : IRawConversion, ACG.Polygon> +public class PolygonToHostConverter : IRawConversion, ACG.Polygon> { private readonly IRawConversion _polylineConverter; @@ -12,14 +12,14 @@ public PolygonToHostConverter(IRawConversion polylin _polylineConverter = polylineConverter; } - public ACG.Polygon RawConvert(List target) + public ACG.Polygon RawConvert(List target) { if (target.Count == 0) { throw new SpeckleConversionException("Feature contains no geometries"); } List polyList = new(); - foreach (SGIS.GisPolygonGeometry poly in target) + foreach (SGIS.PolygonGeometry poly in target) { ACG.Polyline boundary = _polylineConverter.RawConvert(poly.boundary); ACG.PolygonBuilderEx polyOuterRing = new(boundary); diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/ArcToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/ArcToHostConverter.cs index fb2e637c7c..b03999420e 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/ArcToHostConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/ArcToHostConverter.cs @@ -19,11 +19,10 @@ public CurveToHostConverter(IRawConversion pointConvert public ACG.Polyline RawConvert(SOG.Arc target) { // Determine the number of vertices to create along the arc - int numVertices = Math.Max((int)target.length, 3); // Determine based on desired segment length or other criteria + int numVertices = Math.Max((int)target.length, 50); // Determine based on desired segment length or other criteria List pointsOriginal = new(); // get correct direction - int coeff = 1; double? angleStart = target.startAngle; double? fullAngle = target.endAngle - target.startAngle; double? radius = target.radius; @@ -33,22 +32,11 @@ public ACG.Polyline RawConvert(SOG.Arc target) throw new SpeckleConversionException("Conversion failed: Arc doesn't have start & end angle or radius"); } - // define the direction - bool isCounterClockwise = !new SOG.Polyline(target.Values()).IsClockwisePolygon(); - if (!((isCounterClockwise is false || fullAngle >= 0) && (isCounterClockwise is true || fullAngle < 0))) - { - fullAngle = Math.PI * 2 - Math.Abs((double)fullAngle); - if (isCounterClockwise is false) - { - coeff = -1; - } - } - // Calculate the vertices along the arc for (int i = 0; i <= numVertices; i++) { // Calculate the point along the arc - double angle = (double)angleStart + coeff * (double)fullAngle * (i / (double)numVertices); + double angle = (double)angleStart + (double)fullAngle * (i / (double)numVertices); SOG.Point pointOnArc = new( target.plane.origin.x + (double)radius * Math.Cos(angle), diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/CircleToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/CircleToHostConverter.cs index 81ccd78f35..c9437eac81 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/CircleToHostConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/CircleToHostConverter.cs @@ -19,7 +19,7 @@ public CircleToHostConverter(IRawConversion pointConver public ACG.Polyline RawConvert(SOG.Circle target) { // Determine the number of vertices to create along the cirlce - int numVertices = Math.Min((int)target.length, 100); // Determine based on desired segment length or other criteria + int numVertices = Math.Max((int)target.length, 100); // Determine based on desired segment length or other criteria List pointsOriginal = new(); if (target.radius == null) @@ -41,7 +41,10 @@ public ACG.Polyline RawConvert(SOG.Circle target) pointsOriginal.Add(pointOnCircle); } - pointsOriginal.Add(pointsOriginal[0]); + if (pointsOriginal[0] != pointsOriginal[^1]) + { + pointsOriginal.Add(pointsOriginal[0]); + } var points = pointsOriginal.Select(x => _pointConverter.RawConvert(x)); return new ACG.PolylineBuilderEx(points, ACG.AttributeFlags.HasZ).ToGeometry(); diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/EllipseToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/EllipseToHostConverter.cs index 403c022550..25e8d9c7c9 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/EllipseToHostConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/EllipseToHostConverter.cs @@ -19,15 +19,13 @@ public EllipseToHostConverter(IRawConversion pointConve public ACG.Polyline RawConvert(SOG.Ellipse target) { // Determine the number of vertices to create along the Ellipse - int numVertices = Math.Max((int)target.length, 3); // Determine based on desired segment length or other criteria + int numVertices = Math.Max((int)target.length, 100); // Determine based on desired segment length or other criteria List pointsOriginal = new(); if (target.firstRadius == null || target.secondRadius == null) { throw new SpeckleConversionException("Conversion failed: Ellipse doesn't have 1st and 2nd radius"); } - double maxRadius = Math.Max((double)target.firstRadius, (double)target.secondRadius); - double minRadius = Math.Min((double)target.firstRadius, (double)target.secondRadius); // Calculate the vertices along the arc for (int i = 0; i <= numVertices; i++) @@ -36,14 +34,17 @@ public ACG.Polyline RawConvert(SOG.Ellipse target) double angle = 2 * Math.PI * (i / (double)numVertices); SOG.Point pointOnEllipse = new( - target.plane.origin.x + maxRadius * Math.Cos(angle), - target.plane.origin.y + minRadius * Math.Sin(angle), + target.plane.origin.x + (double)target.secondRadius * Math.Cos(angle), + target.plane.origin.y + (double)target.firstRadius * Math.Sin(angle), target.plane.origin.z ); pointsOriginal.Add(pointOnEllipse); } - pointsOriginal.Add(pointsOriginal[0]); + if (pointsOriginal[0] != pointsOriginal[^1]) + { + pointsOriginal.Add(pointsOriginal[0]); + } var points = pointsOriginal.Select(x => _pointConverter.RawConvert(x)); return new ACG.PolylineBuilderEx(points, ACG.AttributeFlags.HasZ).ToGeometry(); diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/MeshToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/MeshToHostConverter.cs index 698bc9721a..8a1f5adb62 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/MeshToHostConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/MeshToHostConverter.cs @@ -22,11 +22,20 @@ public ACG.Multipatch RawConvert(SOG.Mesh target) target.TriangulateMesh(); ACG.MultipatchBuilderEx multipatchPart = new(); ACG.Patch newPatch = multipatchPart.MakePatch(ACG.PatchType.Triangles); - for (int i = 0; i < target.VerticesCount; i++) + for (int i = 0; i < target.faces.Count; i++) { + if (i % 4 == 0) + { + continue; + } + int ptIndex = target.faces[i]; newPatch.AddPoint( _pointConverter.RawConvert( - new SOG.Point(target.vertices[i * 3], target.vertices[i * 3 + 1], target.vertices[i * 3 + 2]) + new SOG.Point( + target.vertices[ptIndex * 3], + target.vertices[ptIndex * 3 + 1], + target.vertices[ptIndex * 3 + 2] + ) ) ); } diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/PolycurveToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/PolycurveToHostConverter.cs index 402394d128..fac6239f52 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/PolycurveToHostConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/PolycurveToHostConverter.cs @@ -26,8 +26,19 @@ public ACG.Polyline RawConvert(SOG.Polycurve target) List points = new(); foreach (var segment in target.segments) { + if (segment is SOG.Arc) + { + throw new NotImplementedException("Polycurves with arc segments are not supported"); + } ACG.Polyline converted = (ACG.Polyline)_toHostConverter.Convert((Base)segment); - points.AddRange(converted.Points); + List newPts = converted.Points.ToList(); + + // reverse new segment if needed + if (points.Count > 0 && newPts.Count > 0 && points[^1] != newPts[0] && points[^1] == newPts[^1]) + { + newPts.Reverse(); + } + points.AddRange(newPts); } return new ACG.PolylineBuilderEx(points, ACG.AttributeFlags.HasZ).ToGeometry(); diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/PolylineToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/PolylineToHostConverter.cs index 83edbea880..789512b469 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/PolylineToHostConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/PolylineToHostConverter.cs @@ -18,7 +18,11 @@ public PolylineToHostConverter(IRawConversion pointConv public ACG.Polyline RawConvert(SOG.Polyline target) { - var points = target.GetPoints().Select(x => _pointConverter.RawConvert(x)); + var points = target.GetPoints().Select(x => _pointConverter.RawConvert(x)).ToList(); + if (target.closed) + { + points.Add(points[0]); + } return new ACG.PolylineBuilderEx(points, ACG.AttributeFlags.HasZ).ToGeometry(); } } diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/PointToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/PointToSpeckleConverter.cs index 5a43fd40b4..6d0607b7e6 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/PointToSpeckleConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/PointToSpeckleConverter.cs @@ -16,15 +16,25 @@ public PointToSpeckleConverter(IConversionContextStack contextStack) public SOG.Point RawConvert(MapPoint target) { - if ( - GeometryEngine.Instance.Project(target, _contextStack.Current.Document.SpatialReference) - is not MapPoint reprojectedPt - ) + try + { + if ( + GeometryEngine.Instance.Project(target, _contextStack.Current.Document.SpatialReference) + is not MapPoint reprojectedPt + ) + { + throw new SpeckleConversionException( + $"Conversion to Spatial Reference {_contextStack.Current.Document.SpatialReference} failed" + ); + } + return new(reprojectedPt.X, reprojectedPt.Y, reprojectedPt.Z, _contextStack.Current.SpeckleUnits); + } + catch (ArgumentException ex) { throw new SpeckleConversionException( - $"Conversion to Spatial Reference {_contextStack.Current.Document.SpatialReference} failed" + $"Conversion to Spatial Reference {_contextStack.Current.Document.SpatialReference} failed", + ex ); } - return new(reprojectedPt.X, reprojectedPt.Y, reprojectedPt.Z, _contextStack.Current.SpeckleUnits); } } diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/FeatureClassToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/FeatureClassToHostConverter.cs index 2ec3f8ee05..614cab1729 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/FeatureClassToHostConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/FeatureClassToHostConverter.cs @@ -30,6 +30,48 @@ IArcGISProjectUtils arcGISProjectUtils _arcGISProjectUtils = arcGISProjectUtils; } + private List RecoverOutdatedGisFeatures(VectorLayer target) + { + List gisFeatures = new(); + foreach (Base baseElement in target.elements) + { + if (baseElement is GisFeature feature) + { + gisFeatures.Add(feature); + } + else + { + if ( + baseElement["geometry"] is List originalGeometries + && baseElement["attributes"] is Base originalAttrs + && (baseElement["displayValue"] is List || baseElement["displayValue"] == null) + ) + { + var originalDisplayVal = baseElement["displayValue"]; + List geometry = originalGeometries.Select(x => (Base)x).ToList(); + Base attributes = originalAttrs; + List? displayValue = + originalDisplayVal == null + ? new List() + : ((List)originalDisplayVal).Select(x => (Base)x).ToList(); + GisFeature newfeature = + new() + { + geometry = geometry, + attributes = attributes, + displayValue = displayValue + }; + gisFeatures.Add(newfeature); + } + else + { + gisFeatures.Add((GisFeature)baseElement); + } + } + } + return gisFeatures; + } + public FeatureClass RawConvert(VectorLayer target) { GeometryType geomType = _featureClassUtils.GetLayerGeometryType(target); @@ -90,8 +132,9 @@ public FeatureClass RawConvert(VectorLayer target) try { FeatureClass newFeatureClass = geodatabase.OpenDataset(featureClassName); + // backwards compatibility: + List gisFeatures = RecoverOutdatedGisFeatures(target); // Add features to the FeatureClass - List gisFeatures = target.elements.Select(x => (GisFeature)x).ToList(); geodatabase.ApplyEdits(() => { _featureClassUtils.AddFeaturesToFeatureClass(newFeatureClass, gisFeatures, fields, _gisGeometryConverter); diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/PointcloudLayerToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/PointcloudLayerToSpeckleConverter.cs index b9019e5800..d7603ab493 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/PointcloudLayerToSpeckleConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/PointcloudLayerToSpeckleConverter.cs @@ -4,10 +4,14 @@ using ArcGIS.Core.Data.Analyst3D; using ArcGIS.Core.CIM; using Speckle.Converters.ArcGIS3.Geometry; +using Speckle.Core.Models; namespace Speckle.Converters.ArcGIS3.Layers; -public class PointCloudToSpeckleConverter : IRawConversion +[NameAndRankValue(nameof(LasDatasetLayer), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +public class PointCloudToSpeckleConverter + : IHostObjectToSpeckleConversion, + IRawConversion { private readonly IRawConversion _pointConverter; private readonly IRawConversion _boxConverter; @@ -62,6 +66,11 @@ private int GetPointColor(LasPoint pt, object renderer) return color; } + public Base Convert(object target) + { + return RawConvert((LasDatasetLayer)target); + } + public SGIS.VectorLayer RawConvert(LasDatasetLayer target) { SGIS.VectorLayer speckleLayer = new(); diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/CharacterCleaner.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/CharacterCleaner.cs index e49709e89d..45f65206b5 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/CharacterCleaner.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/CharacterCleaner.cs @@ -25,6 +25,6 @@ public string CleanCharacters(string key) result += "_"; } } - return key.Replace(" ", "_").Replace("%", "_").Replace("$", "_"); + return result; } } diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/FeatureClassUtils.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/FeatureClassUtils.cs index aed54e7773..ec5424d3f1 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/FeatureClassUtils.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/FeatureClassUtils.cs @@ -55,46 +55,86 @@ public void AddFeaturesToFeatureClass( } } + public void AddNonGISFeaturesToFeatureClass( + FeatureClass newFeatureClass, + List features, + List fields + ) + { + foreach (ACG.Geometry geom in features) + { + using (RowBuffer rowBuffer = newFeatureClass.CreateRowBuffer()) + { + ACG.Geometry newGeom = geom; + if (geom is ACG.MapPoint pointGeom) + { + newGeom = new ACG.MultipointBuilderEx( + new List() { pointGeom }, + ACG.AttributeFlags.HasZ + ).ToGeometry(); + } + rowBuffer[newFeatureClass.GetDefinition().GetShapeField()] = newGeom; + + // TODO: get attributes + // newFeatureClass.CreateRow(_fieldsUtils.AssignFieldValuesToRow(rowBuffer, fields, feat)).Dispose(); + newFeatureClass.CreateRow(rowBuffer).Dispose(); + } + } + } + public ACG.GeometryType GetLayerGeometryType(VectorLayer target) { string? originalGeomType = target.geomType != null ? target.geomType : target.nativeGeomType; - ACG.GeometryType geomType; if (string.IsNullOrEmpty(originalGeomType)) { throw new SpeckleConversionException($"Unknown geometry type for layer {target.name}"); } + return GetGeometryTypeFromString(originalGeomType.ToLower()); + } + + public ACG.GeometryType GetGeometryTypeFromString(string target) + { + string originalString = target.ToLower(); // POC: find better pattern - if (originalGeomType.ToLower().Contains("none")) + if (originalString.Contains("none")) + { + return ACG.GeometryType.Unknown; + } + else if (originalString.Contains("pointcloud")) { - geomType = ACG.GeometryType.Unknown; + return ACG.GeometryType.Unknown; } - else if (originalGeomType.ToLower().Contains("pointcloud")) + else if (originalString.Contains("point")) { - geomType = ACG.GeometryType.Unknown; + return ACG.GeometryType.Multipoint; } - else if (originalGeomType.ToLower().Contains("point")) + else if ( + originalString.Contains("line") + || originalString.Contains("curve") + || originalString.Contains("arc") + || originalString.Contains("circle") + || originalString.Contains("ellipse") + ) { - geomType = ACG.GeometryType.Multipoint; + return ACG.GeometryType.Polyline; } - else if (originalGeomType.ToLower().Contains("polyline")) + else if (originalString.Contains("polygon")) { - geomType = ACG.GeometryType.Polyline; + return ACG.GeometryType.Polygon; } - else if (originalGeomType.ToLower().Contains("polygon")) + else if (originalString.Contains("multipatch")) { - geomType = ACG.GeometryType.Polygon; + return ACG.GeometryType.Multipatch; } - else if (originalGeomType.ToLower().Contains("multipatch")) + else if (originalString.Contains("mesh")) { - geomType = ACG.GeometryType.Multipatch; + return ACG.GeometryType.Multipatch; } else { - throw new SpeckleConversionException($"Unknown geometry type for layer {target.name}"); + throw new SpeckleConversionException($"Unknown geometry type {originalString}"); } - - return geomType; } } diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/IFeatureClassUtils.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/IFeatureClassUtils.cs index db8522fe1a..76e753ef02 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/IFeatureClassUtils.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/IFeatureClassUtils.cs @@ -14,6 +14,12 @@ void AddFeaturesToFeatureClass( List fields, IRawConversion, ACG.Geometry> gisGeometryConverter ); + void AddNonGISFeaturesToFeatureClass( + FeatureClass newFeatureClass, + List features, + List fields + ); void AddFeaturesToTable(Table newFeatureClass, List gisFeatures, List fields); public ACG.GeometryType GetLayerGeometryType(VectorLayer target); + public ACG.GeometryType GetGeometryTypeFromString(string target); } diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/INonNativeFeaturesUtils.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/INonNativeFeaturesUtils.cs new file mode 100644 index 0000000000..f269427400 --- /dev/null +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/INonNativeFeaturesUtils.cs @@ -0,0 +1,8 @@ +namespace Speckle.Converters.ArcGIS3.Utils; + +public interface INonNativeFeaturesUtils +{ + public List> WriteGeometriesToDatasets( + Dictionary, ACG.Geometry>> target + ); +} diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/NonNativeFeaturesUtils.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/NonNativeFeaturesUtils.cs new file mode 100644 index 0000000000..190fe22f36 --- /dev/null +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/NonNativeFeaturesUtils.cs @@ -0,0 +1,141 @@ +using System.Diagnostics; +using ArcGIS.Core.Data; +using ArcGIS.Core.Data.DDL; +using ArcGIS.Core.Data.Exceptions; +using ArcGIS.Desktop.Mapping; +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; +using Speckle.Core.Models; +using FieldDescription = ArcGIS.Core.Data.DDL.FieldDescription; +using Speckle.Core.Logging; + +namespace Speckle.Converters.ArcGIS3.Utils; + +public class NonNativeFeaturesUtils : INonNativeFeaturesUtils +{ + private readonly IRawConversion, ACG.Geometry> _gisGeometryConverter; + private readonly IArcGISFieldUtils _fieldsUtils; + private readonly IFeatureClassUtils _featureClassUtils; + private readonly IArcGISProjectUtils _arcGISProjectUtils; + private readonly IConversionContextStack _contextStack; + + public NonNativeFeaturesUtils( + IRawConversion, ACG.Geometry> gisGeometryConverter, + IArcGISFieldUtils fieldsUtils, + IFeatureClassUtils featureClassUtils, + IArcGISProjectUtils arcGISProjectUtils, + IConversionContextStack contextStack + ) + { + _gisGeometryConverter = gisGeometryConverter; + _fieldsUtils = fieldsUtils; + _featureClassUtils = featureClassUtils; + _arcGISProjectUtils = arcGISProjectUtils; + _contextStack = contextStack; + } + + public List> WriteGeometriesToDatasets( + Dictionary, ACG.Geometry>> target + ) + { + List> result = new(); + try + { + // 1. Sort features into groups by path and geom type + Dictionary> geometryGroups = new(); + foreach (var item in target) + { + string objId = item.Key; + (List objPath, ACG.Geometry geom) = item.Value; + string geomType = objPath[^1]; + string parentPath = $"{string.Join("\\", objPath.Where((x, i) => i < objPath.Count - 1))}\\{geomType}"; + + // add dictionnary item if doesn't exist yet + if (!geometryGroups.ContainsKey(parentPath)) + { + geometryGroups[parentPath] = new List(); + } + geometryGroups[parentPath].Add(geom); + } + + // 2. for each group create a Dataset and add geometries there as Features + foreach ((string parentPath, List geomList) in geometryGroups) + { + ACG.GeometryType geomType = _featureClassUtils.GetGeometryTypeFromString(parentPath.Split("\\")[^1]); + try + { + string converted = CreateDatasetInDatabase(geomType, geomList); + result.Add(Tuple.Create(parentPath, converted)); + } + catch (GeodatabaseGeometryException) + { + // do nothing if conversion of some geometry groups fails + } + } + } + catch (Exception e) when (!e.IsFatal()) + { + // POC: report, etc. + Debug.WriteLine("conversion error happened."); + } + return result; + } + + private string CreateDatasetInDatabase(ACG.GeometryType geomType, List geomList) + { + string databasePath = _arcGISProjectUtils.GetDatabasePath(); + FileGeodatabaseConnectionPath fileGeodatabaseConnectionPath = new(new Uri(databasePath)); + Geodatabase geodatabase = new(fileGeodatabaseConnectionPath); + SchemaBuilder schemaBuilder = new(geodatabase); + + // get Spatial Reference from the document + ACG.SpatialReference spatialRef = _contextStack.Current.Document.SpatialReference; + + // TODO: create Fields + List fields = new(); // _fieldsUtils.GetFieldsFromSpeckleLayer(target); + + // TODO: generate meaningful name + string featureClassName = "hash_" + Utilities.HashString(string.Join("\\", geomList.Select(x => x.GetHashCode()))); + + // delete FeatureClass if already exists + foreach (FeatureClassDefinition fClassDefinition in geodatabase.GetDefinitions()) + { + // will cause GeodatabaseCatalogDatasetException if doesn't exist in the database + if (fClassDefinition.GetName() == featureClassName) + { + FeatureClassDescription existingDescription = new(fClassDefinition); + schemaBuilder.Delete(existingDescription); + schemaBuilder.Build(); + } + } + + // Create FeatureClass + try + { + // POC: make sure class has a valid crs + ShapeDescription shpDescription = new(geomType, spatialRef) { HasZ = true }; + FeatureClassDescription featureClassDescription = new(featureClassName, fields, shpDescription); + FeatureClassToken featureClassToken = schemaBuilder.Create(featureClassDescription); + } + catch (ArgumentException ex) + { + // if name has invalid characters/combinations + throw new ArgumentException($"{ex.Message}: {featureClassName}", ex); + } + bool buildStatus = schemaBuilder.Build(); + if (!buildStatus) + { + // POC: log somewhere the error in building the feature class + IReadOnlyList errors = schemaBuilder.ErrorMessages; + } + + FeatureClass newFeatureClass = geodatabase.OpenDataset(featureClassName); + // Add features to the FeatureClass + geodatabase.ApplyEdits(() => + { + _featureClassUtils.AddNonGISFeaturesToFeatureClass(newFeatureClass, geomList, fields); + }); + + return featureClassName; + } +} diff --git a/Objects/Objects/GIS/GisPolygonGeometry.cs b/Objects/Objects/GIS/GisPolygonGeometry.cs index fc4d7d50c0..3937f1a64d 100644 --- a/Objects/Objects/GIS/GisPolygonGeometry.cs +++ b/Objects/Objects/GIS/GisPolygonGeometry.cs @@ -4,13 +4,13 @@ namespace Objects.GIS; -public class GisPolygonGeometry : Base +public class PolygonGeometry : Base { public string units { get; set; } public Polyline boundary { get; set; } public List voids { get; set; } - public GisPolygonGeometry() + public PolygonGeometry() { voids = new List(); } diff --git a/Objects/Objects/GIS/GisPolygonGeometry3d.cs b/Objects/Objects/GIS/GisPolygonGeometry3d.cs index 9e525323a7..93613c89f9 100644 --- a/Objects/Objects/GIS/GisPolygonGeometry3d.cs +++ b/Objects/Objects/GIS/GisPolygonGeometry3d.cs @@ -1,3 +1,3 @@ namespace Objects.GIS; -public class GisPolygonGeometry3d : GisPolygonGeometry { } +public class PolygonGeometry3d : PolygonGeometry { } From 57ab9a1dcffc21c53f97b870185038822b865298 Mon Sep 17 00:00:00 2001 From: Adam Hathcock Date: Thu, 9 May 2024 11:46:23 +0100 Subject: [PATCH 143/261] fix merge --- .../Utils/FeatureClassUtils.cs | 27 +++++++++---------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/FeatureClassUtils.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/FeatureClassUtils.cs index bdbd621517..386a6ac9fa 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/FeatureClassUtils.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/FeatureClassUtils.cs @@ -95,47 +95,44 @@ public ACG.GeometryType GetLayerGeometryType(VectorLayer target) public ACG.GeometryType GetGeometryTypeFromString(string target) { - string originalString = target.ToLower(); - // POC: find better pattern - if (originalGeomType.Contains("none", StringComparison.CurrentCultureIgnoreCase)) + if (target.Contains("none", StringComparison.CurrentCultureIgnoreCase)) { return ACG.GeometryType.Unknown; } - else if (originalGeomType.Contains("pointcloud", StringComparison.CurrentCultureIgnoreCase)) + else if (target.Contains("pointcloud", StringComparison.CurrentCultureIgnoreCase)) { return ACG.GeometryType.Unknown; } - else if (originalGeomType.Contains("point", StringComparison.CurrentCultureIgnoreCase)) + else if (target.Contains("point", StringComparison.CurrentCultureIgnoreCase)) { return ACG.GeometryType.Multipoint; } - else if (originalGeomType.Contains("polyline", StringComparison.CurrentCultureIgnoreCase)) else if ( - originalString.Contains("line") - || originalString.Contains("curve") - || originalString.Contains("arc") - || originalString.Contains("circle") - || originalString.Contains("ellipse") + target.Contains("line") + || target.Contains("curve") + || target.Contains("arc") + || target.Contains("circle") + || target.Contains("ellipse") ) { return ACG.GeometryType.Polyline; } - else if (originalGeomType.Contains("polygon", StringComparison.CurrentCultureIgnoreCase)) + else if (target.Contains("polygon", StringComparison.CurrentCultureIgnoreCase)) { return ACG.GeometryType.Polygon; } - else if (originalGeomType.Contains("multipatch", StringComparison.CurrentCultureIgnoreCase)) + else if (target.Contains("multipatch", StringComparison.CurrentCultureIgnoreCase)) { return ACG.GeometryType.Multipatch; } - else if (originalString.Contains("mesh")) + else if (target.Contains("mesh")) { return ACG.GeometryType.Multipatch; } else { - throw new SpeckleConversionException($"Unknown geometry type {originalString}"); + throw new SpeckleConversionException($"Unknown geometry type {target}"); } } } From a7039e0d00a6ec86c5dd6ceef471d4770268c7fe Mon Sep 17 00:00:00 2001 From: Adam Hathcock Date: Thu, 9 May 2024 11:48:20 +0100 Subject: [PATCH 144/261] forget lower case --- .../Speckle.Converters.ArcGIS3/Utils/FeatureClassUtils.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/FeatureClassUtils.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/FeatureClassUtils.cs index 386a6ac9fa..81fc3cf775 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/FeatureClassUtils.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/FeatureClassUtils.cs @@ -126,7 +126,7 @@ public ACG.GeometryType GetGeometryTypeFromString(string target) { return ACG.GeometryType.Multipatch; } - else if (target.Contains("mesh")) + else if (target.Contains("mesh", StringComparison.CurrentCultureIgnoreCase)) { return ACG.GeometryType.Multipatch; } From 5c3e1c17cafe3cbf90ac75c9a218fd4d76147f23 Mon Sep 17 00:00:00 2001 From: Adam Hathcock Date: Thu, 9 May 2024 11:50:07 +0100 Subject: [PATCH 145/261] oops forgot more --- .../Utils/FeatureClassUtils.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/FeatureClassUtils.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/FeatureClassUtils.cs index 81fc3cf775..73de9127b0 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/FeatureClassUtils.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/FeatureClassUtils.cs @@ -109,11 +109,11 @@ public ACG.GeometryType GetGeometryTypeFromString(string target) return ACG.GeometryType.Multipoint; } else if ( - target.Contains("line") - || target.Contains("curve") - || target.Contains("arc") - || target.Contains("circle") - || target.Contains("ellipse") + target.Contains("line", StringComparison.CurrentCultureIgnoreCase) + || target.Contains("curve", StringComparison.CurrentCultureIgnoreCase) + || target.Contains("arc", StringComparison.CurrentCultureIgnoreCase) + || target.Contains("circle", StringComparison.CurrentCultureIgnoreCase) + || target.Contains("ellipse", StringComparison.CurrentCultureIgnoreCase) ) { return ACG.GeometryType.Polyline; From 7a7f4719427355ac2840720f5883fb3438f6ee1e Mon Sep 17 00:00:00 2001 From: Adam Hathcock Date: Thu, 9 May 2024 12:09:59 +0100 Subject: [PATCH 146/261] remove app.config --- .../Speckle.Connectors.Revit2023.csproj | 2 -- .../Speckle.Connectors.Revit2023/app.config | 35 ------------------- 2 files changed, 37 deletions(-) delete mode 100644 DUI3-DX/Connectors/Revit/Speckle.Connectors.Revit2023/app.config diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.Revit2023/Speckle.Connectors.Revit2023.csproj b/DUI3-DX/Connectors/Revit/Speckle.Connectors.Revit2023/Speckle.Connectors.Revit2023.csproj index 1387e8b140..343787659c 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.Revit2023/Speckle.Connectors.Revit2023.csproj +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.Revit2023/Speckle.Connectors.Revit2023.csproj @@ -30,9 +30,7 @@ - - diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.Revit2023/app.config b/DUI3-DX/Connectors/Revit/Speckle.Connectors.Revit2023/app.config deleted file mode 100644 index 533b795deb..0000000000 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.Revit2023/app.config +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file From 43bf6e782f2c82962955760bb0f7e75f61fa7c9e Mon Sep 17 00:00:00 2001 From: Adam Hathcock Date: Thu, 9 May 2024 12:14:00 +0100 Subject: [PATCH 147/261] remove question mark --- .../HostApp/RevitDocumentStore.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/RevitDocumentStore.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/RevitDocumentStore.cs index 1b042d43f6..6c9f238ce5 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/RevitDocumentStore.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/RevitDocumentStore.cs @@ -34,7 +34,7 @@ IdStorageSchema idStorageSchema _documentModelStorageSchema = documentModelStorageSchema; _idStorageSchema = idStorageSchema; - UIApplication? uiApplication = _revitContext.UIApplication.NotNull(); + UIApplication uiApplication = _revitContext.UIApplication.NotNull(); uiApplication.ApplicationClosing += (_, _) => WriteToFile(); // POC: Not sure why we would need it since we have save and clos events uiApplication.Application.DocumentSaving += (_, _) => WriteToFile(); uiApplication.Application.DocumentSavingAs += (_, _) => WriteToFile(); From cd6cb388e628c6ae06a40af54fc50a290de39732 Mon Sep 17 00:00:00 2001 From: Adam Hathcock Date: Thu, 9 May 2024 12:17:03 +0100 Subject: [PATCH 148/261] fix cast to fail --- .../Speckle.Connectors.RevitShared/Plugin/RevitPlugin.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitPlugin.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitPlugin.cs index d18504934e..92af4b06ad 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitPlugin.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitPlugin.cs @@ -69,7 +69,7 @@ private void CreateTabAndRibbonPanel(UIControlledApplication application) } RibbonPanel specklePanel = application.CreateRibbonPanel(_revitSettings.RevitTabName, _revitSettings.RevitTabTitle); - var dui3Button = + var dui3Button = (PushButton) specklePanel.AddItem( new PushButtonData( _revitSettings.RevitButtonName, @@ -77,8 +77,7 @@ private void CreateTabAndRibbonPanel(UIControlledApplication application) typeof(RevitExternalApplication).Assembly.Location, typeof(SpeckleRevitCommand).FullName ) - ) as PushButton; - dui3Button.NotNull(); + ); string path = typeof(RevitPlugin).Assembly.Location; dui3Button.Image = LoadPngImgSource( From a393e8d5662e8cb5c0094282c4024c768dace95c Mon Sep 17 00:00:00 2001 From: Adam Hathcock Date: Thu, 9 May 2024 12:17:36 +0100 Subject: [PATCH 149/261] remove not null usage --- .../Revit/Speckle.Connectors.RevitShared/Plugin/RevitPlugin.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitPlugin.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitPlugin.cs index 92af4b06ad..72e2c3cc9f 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitPlugin.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitPlugin.cs @@ -11,7 +11,6 @@ using System.Windows.Media.Imaging; using System.Windows.Media; using System.IO; -using Speckle.Connectors.Utils; namespace Speckle.Connectors.Revit.Plugin; From 8687245e6f98cc2c901569cbe92cd5cd63b27ab7 Mon Sep 17 00:00:00 2001 From: Adam Hathcock Date: Thu, 9 May 2024 12:26:15 +0100 Subject: [PATCH 150/261] make record --- .../Bindings/BasicConnectorBindingRevit.cs | 2 +- .../Plugin/RevitExternalApplication.cs | 22 +++++++++--------- .../Plugin/RevitSettings.cs | 23 +++++++++---------- 3 files changed, 23 insertions(+), 24 deletions(-) diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/BasicConnectorBindingRevit.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/BasicConnectorBindingRevit.cs index 2b03387d42..71d39b444a 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/BasicConnectorBindingRevit.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/BasicConnectorBindingRevit.cs @@ -52,7 +52,7 @@ public string GetConnectorVersion() public string GetSourceApplicationVersion() { // POC: maybe not right place but... - return _revitSettings.HostAppVersion.NotNull(); + return _revitSettings.HostAppVersion; } public DocumentInfo GetDocumentInfo() diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitExternalApplication.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitExternalApplication.cs index e452a53d33..b7d74c246b 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitExternalApplication.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitExternalApplication.cs @@ -29,17 +29,17 @@ internal sealed class RevitExternalApplication : IExternalApplication public RevitExternalApplication() { // POC: load from JSON file? - _revitSettings = new RevitSettings - { - RevitPanelName = "Speckle New UI", - RevitTabName = "Speckle", - RevitTabTitle = "Speckle New UI", - RevitVersionName = "2023", - RevitButtonName = "Speckle New UI", - RevitButtonText = "Revit Connector", - ModuleFolders = new string[] { Path.GetDirectoryName(typeof(RevitExternalApplication).Assembly.Location) }, - HostSlug = "Revit" - }; + _revitSettings = new RevitSettings( + "Speckle New UI", + "Speckle", + "Speckle New UI", + "2023", + "Speckle New UI", + "Revit", + new[] { Path.GetDirectoryName(typeof(RevitExternalApplication).Assembly.Location) }, + "Revit Connector", + "2023" //POC: app version? + ); } public Result OnStartup(UIControlledApplication application) diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitSettings.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitSettings.cs index 07659d4db4..a69ef03230 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitSettings.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitSettings.cs @@ -1,14 +1,13 @@ namespace Speckle.Connectors.Revit.Plugin; -internal sealed class RevitSettings // POC: need to derive some interface for things that require IHostSettings -{ - public string? RevitPanelName { get; set; } - public string? RevitVersionName { get; set; } - public string? RevitTabName { get; set; } - public string? RevitTabTitle { get; set; } - public string? RevitButtonName { get; set; } - public string? RevitButtonText { get; set; } - public string? HostSlug { get; set; } // POC: from generic IHostSettings interface - public string? HostAppVersion { get; set; } // POC as HostSlug?? - public string[]? ModuleFolders { get; set; } -} +internal record RevitSettings( // POC: need to derive some interface for things that require IHostSettings{ + string RevitPanelName, + string RevitTabName, + string RevitTabTitle, + string RevitVersionName, + string RevitButtonName, + string RevitButtonText, + string[] ModuleFolders, + string HostSlug, + string HostAppVersion +); From fbb98f3840ccecaee1995a7d07b5e05de0c58652 Mon Sep 17 00:00:00 2001 From: Adam Hathcock Date: Thu, 9 May 2024 13:20:40 +0100 Subject: [PATCH 151/261] remove nullability from true singletons --- .../DependencyInjection/AutofacRhinoModule.cs | 5 ++--- .../DependencyInjection/RhinoPlugin.cs | 5 +---- .../HostApp/SpeckleRhinoPanelHost.cs | 2 +- .../Plugin/Speckle.Connectors.Rhino7Command.cs | 3 +-- .../Plugin/Speckle.Connectors.Rhino7Plugin.cs | 7 +------ 5 files changed, 6 insertions(+), 16 deletions(-) diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/AutofacRhinoModule.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/AutofacRhinoModule.cs index 8436efde8d..2eaba3d714 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/AutofacRhinoModule.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/AutofacRhinoModule.cs @@ -22,7 +22,6 @@ using Speckle.Connectors.DUI.Models.Card.SendFilter; using Speckle.Connectors.DUI.WebView; using Speckle.Connectors.Rhino7.Operations.Receive; -using Speckle.Connectors.Utils; using Speckle.Connectors.Utils.Builders; using Speckle.Connectors.Utils.Operations; using Speckle.Core.Models.GraphTraversal; @@ -36,8 +35,8 @@ protected override void Load(ContainerBuilder builder) RegisterLoggerFactory(builder); // Register instances initialised by Rhino - builder.RegisterInstance(SpeckleConnectorsRhino7Plugin.Instance.NotNull()); - builder.RegisterInstance(SpeckleConnectorsRhino7Command.Instance.NotNull()); + builder.RegisterInstance(SpeckleConnectorsRhino7Plugin.Instance); + builder.RegisterInstance(SpeckleConnectorsRhino7Command.Instance); // Register DUI3 related stuff builder.RegisterInstance(GetJsonSerializerSettings()).SingleInstance(); diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/RhinoPlugin.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/RhinoPlugin.cs index db689b814f..a295f9f8b6 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/RhinoPlugin.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/RhinoPlugin.cs @@ -3,7 +3,6 @@ using Speckle.Connectors.Rhino7.HostApp; using Speckle.Connectors.Rhino7.Interfaces; using Speckle.Connectors.Rhino7.Plugin; -using Speckle.Connectors.Utils; namespace Speckle.Connectors.Rhino7.DependencyInjection; @@ -22,9 +21,7 @@ public RhinoPlugin(DUI3ControlWebView panel, RhinoSettings settings, RhinoIdleMa public void Initialise() { - _idleManager.SubscribeToIdle( - () => RhinoApp.RunScript(SpeckleConnectorsRhino7Command.Instance.NotNull().EnglishName, false) - ); + _idleManager.SubscribeToIdle(() => RhinoApp.RunScript(SpeckleConnectorsRhino7Command.Instance.EnglishName, false)); } public void Shutdown() { } diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/SpeckleRhinoPanelHost.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/SpeckleRhinoPanelHost.cs index d27c7d7a55..d906161197 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/SpeckleRhinoPanelHost.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/SpeckleRhinoPanelHost.cs @@ -10,7 +10,7 @@ public class SpeckleRhinoPanelHost : RhinoWindows.Controls.WpfElementHost private readonly uint _docSn; public SpeckleRhinoPanelHost(uint docSn) - : base(SpeckleConnectorsRhino7Plugin.Instance?.Container?.Resolve(), null) + : base(SpeckleConnectorsRhino7Plugin.Instance.Container?.Resolve(), null) { _docSn = docSn; } diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Plugin/Speckle.Connectors.Rhino7Command.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Plugin/Speckle.Connectors.Rhino7Command.cs index d28824f889..f2b0c18534 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Plugin/Speckle.Connectors.Rhino7Command.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Plugin/Speckle.Connectors.Rhino7Command.cs @@ -13,7 +13,6 @@ public SpeckleConnectorsRhino7Command() { // Rhino only creates one instance of each command class defined in a // plug-in, so it is safe to store a reference in a static property. - Instance = this; Panels.RegisterPanel( SpeckleConnectorsRhino7Plugin.Instance, typeof(SpeckleRhinoPanelHost), @@ -24,7 +23,7 @@ public SpeckleConnectorsRhino7Command() } ///The only instance of this command. - public static SpeckleConnectorsRhino7Command? Instance { get; private set; } + public static SpeckleConnectorsRhino7Command Instance { get; } = new(); ///The command name as it appears on the Rhino command line. public override string EnglishName => "SpeckleNewUI"; diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Plugin/Speckle.Connectors.Rhino7Plugin.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Plugin/Speckle.Connectors.Rhino7Plugin.cs index 5325ad65ec..a666b27b31 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Plugin/Speckle.Connectors.Rhino7Plugin.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Plugin/Speckle.Connectors.Rhino7Plugin.cs @@ -27,13 +27,8 @@ public class SpeckleConnectorsRhino7Plugin : PlugIn protected override string LocalPlugInName => "Speckle (New UI)"; public AutofacContainer? Container { get; private set; } - public SpeckleConnectorsRhino7Plugin() - { - Instance = this; - } - ///Gets the only instance of the Speckle_Connectors_Rhino7Plugin plug-in. - public static SpeckleConnectorsRhino7Plugin? Instance { get; private set; } + public static SpeckleConnectorsRhino7Plugin Instance { get; } = new(); // You can override methods here to change the plug-in behavior on // loading and shut down, add options pages to the Rhino _Option command From 563a0f706ea90f863d4427da0cf0063a55046085 Mon Sep 17 00:00:00 2001 From: Adam Hathcock Date: Thu, 9 May 2024 13:27:02 +0100 Subject: [PATCH 152/261] review feedback --- All.sln | 19 ------------------- DUI3-DX.slnf | 3 +-- .../SendFilter/DirectSelectionSendFilter.cs | 4 ++-- .../Card/SendFilter/EverythingSendFilter.cs | 2 +- .../Models/Card/SendFilter/ISendFilter.cs | 2 +- DUI3-DX/Directory.Build.Props | 4 ++++ .../Speckle.Objects.Common.csproj | 11 ----------- .../Speckle.Connectors.Utils.csproj | 4 ---- .../ToHost/ToHostConverterWithFallback.cs | 2 +- .../ToHost/ToHostConverterWithoutFallback.cs | 7 ++++--- 10 files changed, 14 insertions(+), 44 deletions(-) delete mode 100644 DUI3-DX/Objects/Speckle.Objects.Common/Speckle.Objects.Common.csproj diff --git a/All.sln b/All.sln index d747e01d5f..a0c04e96e4 100644 --- a/All.sln +++ b/All.sln @@ -518,8 +518,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Speckle.Converters.Revit202 EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Speckle.Connectors.DUI", "DUI3-DX\DUI3\Speckle.Connectors.DUI\Speckle.Connectors.DUI.csproj", "{D81C0B87-F0C1-4297-A147-02F001FB7E1E}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Speckle.Objects.Common", "DUI3-DX\Objects\Speckle.Objects.Common\Speckle.Objects.Common.csproj", "{CC968B23-CEED-4543-8629-808F7E66E815}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Speckle.Objects.Revit", "DUI3-DX\Objects\Speckle.Objects.Revit\Speckle.Objects.Revit.csproj", "{01E762F1-C176-40B9-BA3E-9B1FECAF04FF}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Speckle.Autofac", "DUI3-DX\Sdk\Speckle.Autofac\Speckle.Autofac.csproj", "{C9D4CA21-182B-4ED2-81BB-280A6FD713F6}" @@ -2592,22 +2590,6 @@ Global {D81C0B87-F0C1-4297-A147-02F001FB7E1E}.Release|Any CPU.Build.0 = Release|Any CPU {D81C0B87-F0C1-4297-A147-02F001FB7E1E}.Release|x64.ActiveCfg = Release|Any CPU {D81C0B87-F0C1-4297-A147-02F001FB7E1E}.Release|x64.Build.0 = Release|Any CPU - {CC968B23-CEED-4543-8629-808F7E66E815}.Debug Mac|Any CPU.ActiveCfg = Debug|Any CPU - {CC968B23-CEED-4543-8629-808F7E66E815}.Debug Mac|Any CPU.Build.0 = Debug|Any CPU - {CC968B23-CEED-4543-8629-808F7E66E815}.Debug Mac|x64.ActiveCfg = Debug|Any CPU - {CC968B23-CEED-4543-8629-808F7E66E815}.Debug Mac|x64.Build.0 = Debug|Any CPU - {CC968B23-CEED-4543-8629-808F7E66E815}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {CC968B23-CEED-4543-8629-808F7E66E815}.Debug|Any CPU.Build.0 = Debug|Any CPU - {CC968B23-CEED-4543-8629-808F7E66E815}.Debug|x64.ActiveCfg = Debug|x64 - {CC968B23-CEED-4543-8629-808F7E66E815}.Debug|x64.Build.0 = Debug|x64 - {CC968B23-CEED-4543-8629-808F7E66E815}.Release Mac|Any CPU.ActiveCfg = Release|Any CPU - {CC968B23-CEED-4543-8629-808F7E66E815}.Release Mac|Any CPU.Build.0 = Release|Any CPU - {CC968B23-CEED-4543-8629-808F7E66E815}.Release Mac|x64.ActiveCfg = Release|Any CPU - {CC968B23-CEED-4543-8629-808F7E66E815}.Release Mac|x64.Build.0 = Release|Any CPU - {CC968B23-CEED-4543-8629-808F7E66E815}.Release|Any CPU.ActiveCfg = Release|Any CPU - {CC968B23-CEED-4543-8629-808F7E66E815}.Release|Any CPU.Build.0 = Release|Any CPU - {CC968B23-CEED-4543-8629-808F7E66E815}.Release|x64.ActiveCfg = Release|Any CPU - {CC968B23-CEED-4543-8629-808F7E66E815}.Release|x64.Build.0 = Release|Any CPU {01E762F1-C176-40B9-BA3E-9B1FECAF04FF}.Debug Mac|Any CPU.ActiveCfg = Debug|Any CPU {01E762F1-C176-40B9-BA3E-9B1FECAF04FF}.Debug Mac|Any CPU.Build.0 = Debug|Any CPU {01E762F1-C176-40B9-BA3E-9B1FECAF04FF}.Debug Mac|x64.ActiveCfg = Debug|Any CPU @@ -3045,7 +3027,6 @@ Global {83EAD6F0-3CB3-456A-AD81-072127D0DE0E} = {D92751C8-1039-4005-90B2-913E55E0B8BD} {26391930-F86F-47E0-A5F6-B89919E38CE1} = {D92751C8-1039-4005-90B2-913E55E0B8BD} {D81C0B87-F0C1-4297-A147-02F001FB7E1E} = {FD4D6594-D81E-456F-8F2E-35B09E04A755} - {CC968B23-CEED-4543-8629-808F7E66E815} = {B92E6216-2CBA-4EA5-B94B-0A7658C7F84B} {01E762F1-C176-40B9-BA3E-9B1FECAF04FF} = {B92E6216-2CBA-4EA5-B94B-0A7658C7F84B} {C9D4CA21-182B-4ED2-81BB-280A6FD713F6} = {2E00592E-558D-492D-88F9-3ECEE4C0C7DA} {7291B93C-615D-42DE-B8C1-3F9DF643E0FC} = {2E00592E-558D-492D-88F9-3ECEE4C0C7DA} diff --git a/DUI3-DX.slnf b/DUI3-DX.slnf index 9bed907dd3..017671aace 100644 --- a/DUI3-DX.slnf +++ b/DUI3-DX.slnf @@ -25,7 +25,6 @@ "DUI3-DX\\Converters\\Rhino\\Speckle.Converters.Rhino7\\Speckle.Converters.Rhino7.csproj", "DUI3-DX\\DUI3\\Speckle.Connectors.DUI.WebView\\Speckle.Connectors.DUI.WebView.csproj", "DUI3-DX\\DUI3\\Speckle.Connectors.DUI\\Speckle.Connectors.DUI.csproj", - "DUI3-DX\\Objects\\Speckle.Objects.Common\\Speckle.Objects.Common.csproj", "DUI3-DX\\Objects\\Speckle.Objects.Revit\\Speckle.Objects.Revit.csproj", "DUI3-DX\\Sdk\\Speckle.Autofac\\Speckle.Autofac.csproj", "DUI3-DX\\Sdk\\Speckle.Connectors.Utils\\Speckle.Connectors.Utils.csproj", @@ -35,4 +34,4 @@ "Objects\\Tests\\Objects.Tests.Unit\\Objects.Tests.Unit.csproj" ] } -} +} \ No newline at end of file diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/SendFilter/DirectSelectionSendFilter.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/SendFilter/DirectSelectionSendFilter.cs index 148f386e57..97bce1ef6b 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/SendFilter/DirectSelectionSendFilter.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/SendFilter/DirectSelectionSendFilter.cs @@ -4,10 +4,10 @@ namespace Speckle.Connectors.DUI.Models.Card.SendFilter; public abstract class DirectSelectionSendFilter : DiscriminatedObject, ISendFilter { - public string? Name { get; set; } = "Selection"; + public string Name { get; set; } = "Selection"; public string? Summary { get; set; } public bool IsDefault { get; set; } - public List SelectedObjectIds { get; set; } = new List(); + public List SelectedObjectIds { get; set; } = new(); public abstract List GetObjectIds(); public abstract bool CheckExpiry(string[] changedObjectIds); } diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/SendFilter/EverythingSendFilter.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/SendFilter/EverythingSendFilter.cs index b4617ee623..a5c83f77df 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/SendFilter/EverythingSendFilter.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/SendFilter/EverythingSendFilter.cs @@ -4,7 +4,7 @@ namespace Speckle.Connectors.DUI.Models.Card.SendFilter; public abstract class EverythingSendFilter : DiscriminatedObject, ISendFilter { - public string? Name { get; set; } = "Everything"; + public string Name { get; set; } = "Everything"; public string? Summary { get; set; } = "All supported objects in the file."; public bool IsDefault { get; set; } public abstract List GetObjectIds(); diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/SendFilter/ISendFilter.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/SendFilter/ISendFilter.cs index e3cdf6afa1..4e025c43b9 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/SendFilter/ISendFilter.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/SendFilter/ISendFilter.cs @@ -2,7 +2,7 @@ namespace Speckle.Connectors.DUI.Models.Card.SendFilter; public interface ISendFilter { - public string? Name { get; set; } + public string Name { get; set; } public string? Summary { get; set; } public bool IsDefault { get; set; } diff --git a/DUI3-DX/Directory.Build.Props b/DUI3-DX/Directory.Build.Props index eff3fdaa09..0bdaf4b363 100644 --- a/DUI3-DX/Directory.Build.Props +++ b/DUI3-DX/Directory.Build.Props @@ -6,4 +6,8 @@ enable true + + + + diff --git a/DUI3-DX/Objects/Speckle.Objects.Common/Speckle.Objects.Common.csproj b/DUI3-DX/Objects/Speckle.Objects.Common/Speckle.Objects.Common.csproj deleted file mode 100644 index 1b98c0f42c..0000000000 --- a/DUI3-DX/Objects/Speckle.Objects.Common/Speckle.Objects.Common.csproj +++ /dev/null @@ -1,11 +0,0 @@ - - - - netstandard2.0 - - - - - - - diff --git a/DUI3-DX/Sdk/Speckle.Connectors.Utils/Speckle.Connectors.Utils.csproj b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Speckle.Connectors.Utils.csproj index 44b0181ded..2b9166b220 100644 --- a/DUI3-DX/Sdk/Speckle.Connectors.Utils/Speckle.Connectors.Utils.csproj +++ b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Speckle.Connectors.Utils.csproj @@ -3,10 +3,6 @@ netstandard2.0 - - - - diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/ToHost/ToHostConverterWithFallback.cs b/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/ToHost/ToHostConverterWithFallback.cs index 547f273e74..a6ffd8d7d7 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/ToHost/ToHostConverterWithFallback.cs +++ b/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/ToHost/ToHostConverterWithFallback.cs @@ -45,7 +45,7 @@ public object Convert(Base target) // Direct conversion if a converter is found if (_baseConverter.TryConvert(target, out object? result)) { - return result.NotNull(); + return result; } // Fallback to display value if it exists. diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/ToHost/ToHostConverterWithoutFallback.cs b/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/ToHost/ToHostConverterWithoutFallback.cs index 2e1463a6dd..9f86ffbf28 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/ToHost/ToHostConverterWithoutFallback.cs +++ b/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/ToHost/ToHostConverterWithoutFallback.cs @@ -1,4 +1,5 @@ -using Speckle.Connectors.Utils; +using System.Diagnostics.CodeAnalysis; +using Speckle.Connectors.Utils; using Speckle.Converters.Common.Objects; using Speckle.Core.Models; @@ -23,12 +24,12 @@ public object Convert(Base target) { if (TryConvert(target, out object? result)) { - return result.NotNull(); + return result; } throw new NotSupportedException($"No conversion found for {target.GetType()}"); } - internal bool TryConvert(Base target, out object? result) + internal bool TryConvert(Base target, [NotNullWhen(true)] out object? result) { // Direct conversion if a converter is found var objectConverter = _toHost.GetConversionForType(target.GetType()); From 7ac0d7a3700c4ec88ac70adc6fdac4c1453937aa Mon Sep 17 00:00:00 2001 From: Adam Hathcock Date: Thu, 9 May 2024 13:28:39 +0100 Subject: [PATCH 153/261] build fixes --- .../ToHost/Raw/CurveToHostRawConverter.cs | 2 +- .../ToSpeckle/Geometry/SplineToSpeckleConverter.cs | 4 ++-- .../Raw/ModelCurveArrayToSpeckleConverter.cs | 2 +- .../ToHost/ToHostConverterWithFallback.cs | 3 +-- .../ToHost/ToHostConverterWithoutFallback.cs | 1 - 5 files changed, 5 insertions(+), 7 deletions(-) diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/CurveToHostRawConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/CurveToHostRawConverter.cs index f7893506be..fa7046334d 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/CurveToHostRawConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/CurveToHostRawConverter.cs @@ -34,7 +34,7 @@ public AG.NurbCurve3d RawConvert(SOG.Curve target) if (target.knots.Count == points.Count + target.degree - 1) // handles rhino format curves { knotList.Insert(0, knotList[0]); - knotList.Insert(knotList.Count - 1, knotList[knotList.Count - 1]); + knotList.Insert(knotList.Count - 1, knotList[^1]); } if (target.closed && target.periodic) // handles closed periodic curves { diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/SplineToSpeckleConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/SplineToSpeckleConverter.cs index 225aaaa3bf..d4aabd29d4 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/SplineToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/SplineToSpeckleConverter.cs @@ -71,12 +71,12 @@ public SOG.Curve RawConvert(ADB.Spline target) { if (i < 2) { - knots.Insert(knots.Count, knots[knots.Count - 1] + interval); + knots.Insert(knots.Count, knots[^1] + interval); knots.Insert(0, knots[0] - interval); } else { - knots.Insert(knots.Count, knots[knots.Count - 1]); + knots.Insert(knots.Count, knots[^1]); knots.Insert(0, knots[0]); } } diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ModelCurveArrayToSpeckleConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ModelCurveArrayToSpeckleConverter.cs index 42662a643c..50c9bfc003 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ModelCurveArrayToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ModelCurveArrayToSpeckleConverter.cs @@ -34,7 +34,7 @@ public SOG.Polycurve RawConvert(DB.ModelCurveArray target) } var start = curves[0].GetEndPoint(0); - var end = curves[curves.Length - 1].GetEndPoint(1); + var end = curves[^1].GetEndPoint(1); polycurve.units = _contextStack.Current.SpeckleUnits; polycurve.closed = start.DistanceTo(end) < RevitConversionContextStack.TOLERANCE; polycurve.length = _scalingService.ScaleLength(curves.Sum(x => x.Length)); diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/ToHost/ToHostConverterWithFallback.cs b/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/ToHost/ToHostConverterWithFallback.cs index a6ffd8d7d7..2ff6e8a34e 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/ToHost/ToHostConverterWithFallback.cs +++ b/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/ToHost/ToHostConverterWithFallback.cs @@ -1,5 +1,4 @@ -using Speckle.Connectors.Utils; -using Speckle.Converters.Common.Objects; +using Speckle.Converters.Common.Objects; using Speckle.Core.Models; using Speckle.Core.Models.Extensions; diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/ToHost/ToHostConverterWithoutFallback.cs b/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/ToHost/ToHostConverterWithoutFallback.cs index 9f86ffbf28..ff69332e87 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/ToHost/ToHostConverterWithoutFallback.cs +++ b/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/ToHost/ToHostConverterWithoutFallback.cs @@ -1,5 +1,4 @@ using System.Diagnostics.CodeAnalysis; -using Speckle.Connectors.Utils; using Speckle.Converters.Common.Objects; using Speckle.Core.Models; From 4a77485b5a659c0f11e629bda1868fb15da3e97e Mon Sep 17 00:00:00 2001 From: Adam Hathcock Date: Thu, 9 May 2024 14:06:11 +0100 Subject: [PATCH 154/261] more review fixes --- .../Bindings/ArcGISSendBinding.cs | 2 +- .../Bindings/BasicConnectorBinding.cs | 8 +------ .../Bindings/AutocadBasicConnectorBinding.cs | 17 +++++---------- .../Bindings/AutocadSendBinding.cs | 4 ++-- .../Bindings/BasicConnectorBindingRevit.cs | 21 +++++++++---------- .../Bindings/SendBinding.cs | 7 +++++-- .../Bindings/RhinoBasicConnectorBinding.cs | 13 ++++++------ .../Bindings/RhinoSendBinding.cs | 11 +++++----- .../Bindings/IBasicConnectorBinding.cs | 2 +- .../Models/DocumentInfo.cs | 14 ++++--------- .../Operations/Send.cs | 2 +- 11 files changed, 42 insertions(+), 59 deletions(-) diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISSendBinding.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISSendBinding.cs index 74d000a2d5..1b4b5dfc48 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISSendBinding.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISSendBinding.cs @@ -119,7 +119,7 @@ private void RunExpirationChecks() foreach (var sender in senders) { - bool isExpired = sender.SendFilter?.CheckExpiry(ChangedObjectIds.ToArray()) ?? false; + bool isExpired = sender.SendFilter.NotNull().CheckExpiry(ChangedObjectIds.ToArray()); if (isExpired) { expiredSenderIds.Add(sender.ModelCardId.NotNull()); diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/BasicConnectorBinding.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/BasicConnectorBinding.cs index 464bc9f322..edaa556b9c 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/BasicConnectorBinding.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/BasicConnectorBinding.cs @@ -41,13 +41,7 @@ public BasicConnectorBinding(ArcGISDocumentStore store, ArcGISSettings settings, public string GetConnectorVersion() => Assembly.GetAssembly(GetType()).NotNull().GetVersion(); // TODO - public DocumentInfo GetDocumentInfo() => - new() - { - Location = Project.Current.URI, - Name = Project.Current.Name, - Id = Project.Current.Name, - }; + public DocumentInfo GetDocumentInfo() => new(Project.Current.URI, Project.Current.Name, Project.Current.Name); public DocumentModelStore GetDocumentState() => _store; diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadBasicConnectorBinding.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadBasicConnectorBinding.cs index 46f1f6350b..acc36bb4a3 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadBasicConnectorBinding.cs +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadBasicConnectorBinding.cs @@ -42,23 +42,16 @@ public string GetConnectorVersion() => public Account[] GetAccounts() => AccountManager.GetAccounts().ToArray(); - public DocumentInfo GetDocumentInfo() + public DocumentInfo? GetDocumentInfo() { // POC: Will be addressed to move it into AutocadContext! var doc = Application.DocumentManager.MdiActiveDocument; - - if (doc == null) + if (doc is null) { - return new DocumentInfo(); + return null; } - string name = doc.Name.Split(System.IO.Path.PathSeparator).Reverse().First(); - return new DocumentInfo() - { - Name = name, - Id = doc.Name, - Location = doc.Name - }; + return new DocumentInfo(doc.Name, name, doc.Name); } public DocumentModelStore GetDocumentState() => _store; @@ -98,7 +91,7 @@ public void HighlightModel(string modelCardId) if (model is SenderModelCard senderModelCard) { List<(DBObject obj, string applicationId)> dbObjects = doc.GetObjects( - (senderModelCard.SendFilter?.GetObjectIds()).Empty() + senderModelCard.SendFilter.NotNull().GetObjectIds() ); objectIds = dbObjects.Select(tuple => tuple.obj.Id).ToArray(); } diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadSendBinding.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadSendBinding.cs index 80c624b289..b55bed4459 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadSendBinding.cs +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadSendBinding.cs @@ -96,7 +96,7 @@ private void RunExpirationChecks() foreach (SenderModelCard modelCard in senders) { - var intersection = modelCard.SendFilter?.GetObjectIds().Intersect(objectIdsList).ToList() ?? new(); + var intersection = modelCard.SendFilter.NotNull().GetObjectIds().Intersect(objectIdsList).ToList(); bool isExpired = intersection.Count != 0; if (isExpired) { @@ -133,7 +133,7 @@ private async Task SendInternal(string modelCardId) // Get elements to convert List<(DBObject obj, string applicationId)> autocadObjects = - Application.DocumentManager.CurrentDocument.GetObjects((modelCard.SendFilter?.GetObjectIds()).Empty()); + Application.DocumentManager.CurrentDocument.GetObjects(modelCard.SendFilter.NotNull().GetObjectIds()); if (autocadObjects.Count == 0) { throw new InvalidOperationException("No objects were found. Please update your send filter!"); diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/BasicConnectorBindingRevit.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/BasicConnectorBindingRevit.cs index 71d39b444a..45752e4c2f 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/BasicConnectorBindingRevit.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/BasicConnectorBindingRevit.cs @@ -55,25 +55,25 @@ public string GetSourceApplicationVersion() return _revitSettings.HostAppVersion; } - public DocumentInfo GetDocumentInfo() + public DocumentInfo? GetDocumentInfo() { // POC: not sure why this would ever be null, is this needed? _revitContext.UIApplication.NotNull(); var doc = _revitContext.UIApplication.ActiveUIDocument.Document; + if (doc is null) + { + return null; + } + var info = new DocumentInfo(doc.Title, doc.GetHashCode().ToString((IFormatProvider?)null), doc.PathName); if (doc.IsFamilyDocument) { - return new DocumentInfo { Message = "Family Environment files not supported by Speckle." }; + info.Message = "Family Environment files not supported by Speckle."; } // POC: Notify user here if document is null. - return new DocumentInfo - { - Name = doc.Title, - Id = doc.GetHashCode().ToString((IFormatProvider?)null), - Location = doc.PathName - }; + return info; } public DocumentModelStore GetDocumentState() => _store; @@ -101,12 +101,11 @@ public void HighlightModel(string modelCardId) var activeUIDoc = _revitContext.UIApplication?.ActiveUIDocument ?? throw new SpeckleException("Unable to retrieve active UI document"); - var doc = _revitContext.UIApplication.ActiveUIDocument.Document; SenderModelCard model = (SenderModelCard)_store.GetModelById(modelCardId); - var elementIds = model.SendFilter?.GetObjectIds().Select(ElementId.Parse).ToList(); - if (elementIds.Empty().Any()) + var elementIds = model.SendFilter.NotNull().GetObjectIds().Select(ElementId.Parse).ToList(); + if (elementIds.Any()) { Commands.SetModelError(modelCardId, new InvalidOperationException("No objects found to highlight.")); return; diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SendBinding.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SendBinding.cs index 4a09620ac1..0b61b793f2 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SendBinding.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SendBinding.cs @@ -95,8 +95,11 @@ private async Task HandleSend(string modelCardId) SendOperation >(); - List revitObjects = - modelCard.SendFilter?.GetObjectIds().Select(id => ElementId.Parse(id)).ToList() ?? new(); + List revitObjects = modelCard.SendFilter + .NotNull() + .GetObjectIds() + .Select(id => ElementId.Parse(id)) + .ToList(); var sendInfo = new SendInfo( modelCard.AccountId.NotNull(), diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoBasicConnectorBinding.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoBasicConnectorBinding.cs index 85c0293b13..04a0dbe9b3 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoBasicConnectorBinding.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoBasicConnectorBinding.cs @@ -42,12 +42,11 @@ public string GetConnectorVersion() => public string GetSourceApplicationVersion() => "7"; public DocumentInfo GetDocumentInfo() => - new() - { - Location = RhinoDoc.ActiveDoc.Path, - Name = RhinoDoc.ActiveDoc.Name, - Id = RhinoDoc.ActiveDoc.RuntimeSerialNumber.ToString((IFormatProvider?)null) - }; + new( + RhinoDoc.ActiveDoc.Path, + RhinoDoc.ActiveDoc.Name, + RhinoDoc.ActiveDoc.RuntimeSerialNumber.ToString((IFormatProvider?)null) + ); public DocumentModelStore GetDocumentState() => _store; @@ -72,7 +71,7 @@ public void HighlightModel(string modelCardId) if (myModel is SenderModelCard sender) { - objectIds = (sender.SendFilter?.GetObjectIds()).Empty().ToList(); + objectIds = sender.SendFilter.NotNull().GetObjectIds().ToList(); } if (myModel is ReceiverModelCard receiver && receiver.ReceiveResult != null) diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSendBinding.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSendBinding.cs index 1a6602b473..9e94406b78 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSendBinding.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSendBinding.cs @@ -146,8 +146,9 @@ public async Task Send(string modelCardId) throw new InvalidOperationException("No publish model card was found."); } - List rhinoObjects = (modelCard.SendFilter?.GetObjectIds()) - .Empty() + List rhinoObjects = modelCard.SendFilter + .NotNull() + .GetObjectIds() .Select(id => RhinoDoc.ActiveDoc.Objects.FindId(new Guid(id))) .Where(obj => obj != null) .ToList(); @@ -209,9 +210,9 @@ private void RunExpirationChecks() foreach (SenderModelCard modelCard in senders) { - var intersection = modelCard.SendFilter?.GetObjectIds().Intersect(objectIdsList).ToList(); - var isExpired = modelCard.SendFilter?.CheckExpiry(ChangedObjectIds.ToArray()); - if (isExpired ?? false) + var intersection = modelCard.SendFilter.NotNull().GetObjectIds().Intersect(objectIdsList).ToList(); + var isExpired = modelCard.SendFilter.NotNull().CheckExpiry(ChangedObjectIds.ToArray()); + if (isExpired) { expiredSenderIds.Add(modelCard.ModelCardId.NotNull()); modelCard.ChangedObjectIds.UnionWith(intersection.Empty()); diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/IBasicConnectorBinding.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/IBasicConnectorBinding.cs index e8d773a9c9..d711b1e016 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/IBasicConnectorBinding.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/IBasicConnectorBinding.cs @@ -9,7 +9,7 @@ public interface IBasicConnectorBinding : IBinding public string GetSourceApplicationName(); public string GetSourceApplicationVersion(); public string GetConnectorVersion(); - public DocumentInfo GetDocumentInfo(); + public DocumentInfo? GetDocumentInfo(); public DocumentModelStore GetDocumentState(); public void AddModel(ModelCard model); public void UpdateModel(ModelCard model); diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/DocumentInfo.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/DocumentInfo.cs index 0781917d1f..b15a76c278 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/DocumentInfo.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/DocumentInfo.cs @@ -1,15 +1,9 @@ namespace Speckle.Connectors.DUI.Models; -public class DocumentInfo +public record DocumentInfo(string Location, string Name, string Id) { - public string? Location { get; set; - //?.Replace("\\", "\\\\"); // for some reason, when returning variables from a direct binding call - //we don't need this. nevertheless, after switching to a post response back to the ui, - //we need this to ensure deserialization in js doesn't throw. it's frustrating! - } - - public string? Name { get; set; } - public string? Id { get; set; } - + //?.Replace("\\", "\\\\"); // for some reason, when returning variables from a direct binding call + //we don't need this. nevertheless, after switching to a post response back to the ui, + //we need this to ensure deserialization in js doesn't throw. it's frustrating! public string? Message { get; set; } } diff --git a/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/Send.cs b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/Send.cs index 9be0d9091c..457c3126ba 100644 --- a/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/Send.cs +++ b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/Send.cs @@ -159,7 +159,7 @@ Dictionary convertedReferences await Task.WhenAll(transportAwaits).ConfigureAwait(false); var parsed = JObject.Parse(obj); - JToken? idToken = parsed.GetValue("id", StringComparison.CurrentCultureIgnoreCase); + JToken? idToken = parsed.GetValue("id", StringComparison.Ordinal); if (idToken == null) { From 823c46b0ef5a122ac41a439bcb5d166ceb284c4f Mon Sep 17 00:00:00 2001 From: Adam Hathcock Date: Thu, 9 May 2024 14:08:43 +0100 Subject: [PATCH 155/261] change to OrdinalIgnoreCase --- .../Layers/VectorLayerToSpeckleConverter.cs | 8 +++---- .../Utils/FeatureClassUtils.cs | 22 +++++++++---------- .../NamedTypeInjector.cs | 2 +- .../RawConversionRegisterer.cs | 2 +- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/VectorLayerToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/VectorLayerToSpeckleConverter.cs index 50a4af05fc..017178551d 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/VectorLayerToSpeckleConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/VectorLayerToSpeckleConverter.cs @@ -38,19 +38,19 @@ public Base Convert(object target) private string SpeckleGeometryType(string nativeGeometryType) { string spekleGeometryType = "None"; - if (nativeGeometryType.Contains("point", StringComparison.CurrentCultureIgnoreCase)) + if (nativeGeometryType.Contains("point", StringComparison.OrdinalIgnoreCase)) { spekleGeometryType = "Point"; } - else if (nativeGeometryType.Contains("polyline", StringComparison.CurrentCultureIgnoreCase)) + else if (nativeGeometryType.Contains("polyline", StringComparison.OrdinalIgnoreCase)) { spekleGeometryType = "Polyline"; } - else if (nativeGeometryType.Contains("polygon", StringComparison.CurrentCultureIgnoreCase)) + else if (nativeGeometryType.Contains("polygon", StringComparison.OrdinalIgnoreCase)) { spekleGeometryType = "Polygon"; } - else if (nativeGeometryType.Contains("multipatch", StringComparison.CurrentCultureIgnoreCase)) + else if (nativeGeometryType.Contains("multipatch", StringComparison.OrdinalIgnoreCase)) { spekleGeometryType = "Multipatch"; } diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/FeatureClassUtils.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/FeatureClassUtils.cs index 73de9127b0..89d079d69f 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/FeatureClassUtils.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/FeatureClassUtils.cs @@ -96,37 +96,37 @@ public ACG.GeometryType GetLayerGeometryType(VectorLayer target) public ACG.GeometryType GetGeometryTypeFromString(string target) { // POC: find better pattern - if (target.Contains("none", StringComparison.CurrentCultureIgnoreCase)) + if (target.Contains("none", StringComparison.OrdinalIgnoreCase)) { return ACG.GeometryType.Unknown; } - else if (target.Contains("pointcloud", StringComparison.CurrentCultureIgnoreCase)) + else if (target.Contains("pointcloud", StringComparison.OrdinalIgnoreCase)) { return ACG.GeometryType.Unknown; } - else if (target.Contains("point", StringComparison.CurrentCultureIgnoreCase)) + else if (target.Contains("point", StringComparison.OrdinalIgnoreCase)) { return ACG.GeometryType.Multipoint; } else if ( - target.Contains("line", StringComparison.CurrentCultureIgnoreCase) - || target.Contains("curve", StringComparison.CurrentCultureIgnoreCase) - || target.Contains("arc", StringComparison.CurrentCultureIgnoreCase) - || target.Contains("circle", StringComparison.CurrentCultureIgnoreCase) - || target.Contains("ellipse", StringComparison.CurrentCultureIgnoreCase) + target.Contains("line", StringComparison.OrdinalIgnoreCase) + || target.Contains("curve", StringComparison.OrdinalIgnoreCase) + || target.Contains("arc", StringComparison.OrdinalIgnoreCase) + || target.Contains("circle", StringComparison.OrdinalIgnoreCase) + || target.Contains("ellipse", StringComparison.OrdinalIgnoreCase) ) { return ACG.GeometryType.Polyline; } - else if (target.Contains("polygon", StringComparison.CurrentCultureIgnoreCase)) + else if (target.Contains("polygon", StringComparison.OrdinalIgnoreCase)) { return ACG.GeometryType.Polygon; } - else if (target.Contains("multipatch", StringComparison.CurrentCultureIgnoreCase)) + else if (target.Contains("multipatch", StringComparison.OrdinalIgnoreCase)) { return ACG.GeometryType.Multipatch; } - else if (target.Contains("mesh", StringComparison.CurrentCultureIgnoreCase)) + else if (target.Contains("mesh", StringComparison.OrdinalIgnoreCase)) { return ACG.GeometryType.Multipatch; } diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/NamedTypeInjector.cs b/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/NamedTypeInjector.cs index f022d4fb29..f4eeea8058 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/NamedTypeInjector.cs +++ b/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/NamedTypeInjector.cs @@ -16,7 +16,7 @@ public static ContainerBuilder InjectNamedTypes(this ContainerBuilder contain foreach ( var asm in AppDomain.CurrentDomain .GetAssemblies() - .Where(x => x.GetName().Name.StartsWith("Speckle", StringComparison.CurrentCultureIgnoreCase)) + .Where(x => x.GetName().Name.StartsWith("Speckle", StringComparison.OrdinalIgnoreCase)) ) { try diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/RawConversionRegisterer.cs b/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/RawConversionRegisterer.cs index ce68ba20ca..506bd33c13 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/RawConversionRegisterer.cs +++ b/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/RawConversionRegisterer.cs @@ -14,7 +14,7 @@ public static ContainerBuilder RegisterRawConversions(this ContainerBuilder cont foreach ( var asm in AppDomain.CurrentDomain .GetAssemblies() - .Where(x => x.GetName().Name.StartsWith("Speckle", StringComparison.CurrentCultureIgnoreCase)) + .Where(x => x.GetName().Name.StartsWith("Speckle", StringComparison.OrdinalIgnoreCase)) ) { foreach (var type in asm.GetTypes()) From 0e9bf0a68817114e5c16dea5c79fd89035593992 Mon Sep 17 00:00:00 2001 From: Adam Hathcock Date: Thu, 9 May 2024 14:42:38 +0100 Subject: [PATCH 156/261] move notnulls so rhino converter doesn't reference connectors --- .../Speckle.Converters.Rhino7.csproj | 1 - .../Raw/PolyCurveToSpeckleConverter.cs | 1 - .../NotNullExtensions.cs | 57 +++++++++++++++++++ 3 files changed, 57 insertions(+), 2 deletions(-) create mode 100644 DUI3-DX/Sdk/Speckle.Converters.Common/NotNullExtensions.cs diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Speckle.Converters.Rhino7.csproj b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Speckle.Converters.Rhino7.csproj index a46b7442ae..249814e554 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Speckle.Converters.Rhino7.csproj +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Speckle.Converters.Rhino7.csproj @@ -8,7 +8,6 @@ - diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/PolyCurveToSpeckleConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/PolyCurveToSpeckleConverter.cs index 7a9217401a..291b4c1bc5 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/PolyCurveToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/PolyCurveToSpeckleConverter.cs @@ -1,6 +1,5 @@ using Objects; using Rhino; -using Speckle.Connectors.Utils; using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common/NotNullExtensions.cs b/DUI3-DX/Sdk/Speckle.Converters.Common/NotNullExtensions.cs new file mode 100644 index 0000000000..47e864a1bf --- /dev/null +++ b/DUI3-DX/Sdk/Speckle.Converters.Common/NotNullExtensions.cs @@ -0,0 +1,57 @@ +using System.Diagnostics.CodeAnalysis; +using System.Runtime.CompilerServices; + +namespace Speckle.Converters.Common; + +public static class NotNullExtensions +{ + public static IEnumerable Empty(this IEnumerable? source) => source ?? Enumerable.Empty(); + + public static async Task NotNull( + this Task task, + [CallerArgumentExpression(nameof(task))] string? message = null + ) + where T : class + { + var x = await task.ConfigureAwait(false); + if (x is null) + { + throw new ArgumentNullException(message ?? "Value is null"); + } + return x; + } + + public static async Task NotNull( + this Task task, + [CallerArgumentExpression(nameof(task))] string? message = null + ) + where T : struct + { + var x = await task.ConfigureAwait(false); + if (x is null) + { + throw new ArgumentNullException(message ?? "Value is null"); + } + return x.Value; + } + + public static T NotNull([NotNull] this T? obj, [CallerArgumentExpression(nameof(obj))] string? paramName = null) + where T : class + { + if (obj is null) + { + throw new ArgumentNullException(paramName ?? "Value is null"); + } + return obj; + } + + public static T NotNull([NotNull] this T? obj, [CallerArgumentExpression(nameof(obj))] string? paramName = null) + where T : struct + { + if (obj is null) + { + throw new ArgumentNullException(paramName ?? "Value is null"); + } + return obj.Value; + } +} From 9cfc0f13bda3a6abbaaf03af0de115030230a878 Mon Sep 17 00:00:00 2001 From: Adam Hathcock Date: Thu, 9 May 2024 14:46:24 +0100 Subject: [PATCH 157/261] remove needless changes --- .../Bindings/AutocadSelectionBinding.cs | 2 +- .../Bindings/AutocadSendBinding.cs | 2 +- .../Operations/Receive/HostObjectBuilder.cs | 2 +- .../Bindings/BasicConnectorBindingRevit.cs | 2 +- .../Bindings/RhinoBasicConnectorBinding.cs | 8 ++------ .../Layers/PointcloudLayerToSpeckleConverter.cs | 2 +- 6 files changed, 7 insertions(+), 11 deletions(-) diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadSelectionBinding.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadSelectionBinding.cs index c497916b3f..5e2188d4cf 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadSelectionBinding.cs +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadSelectionBinding.cs @@ -72,7 +72,7 @@ public SelectionInfo GetSelection() continue; } - var handleString = dbObject.Handle.Value.ToString((IFormatProvider?)null); + var handleString = dbObject.Handle.Value.ToString(); objectTypes.Add(dbObject.GetType().Name); objs.Add(handleString); } diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadSendBinding.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadSendBinding.cs index b55bed4459..1eff6da0bc 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadSendBinding.cs +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadSendBinding.cs @@ -84,7 +84,7 @@ private void SubscribeToObjectChanges(Document doc) private void OnChangeChangedObjectIds(DBObject dBObject) { - ChangedObjectIds.Add(dBObject.Handle.Value.ToString((IFormatProvider?)null)); + ChangedObjectIds.Add(dBObject.Handle.Value.ToString()); _idleManager.SubscribeToIdle(RunExpirationChecks); } diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Operations/Receive/HostObjectBuilder.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Operations/Receive/HostObjectBuilder.cs index 8168e8fc6b..edb8cfa827 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Operations/Receive/HostObjectBuilder.cs +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Operations/Receive/HostObjectBuilder.cs @@ -85,7 +85,7 @@ CancellationToken cancellationToken conversionResult.Append(layerFullName); - handleValues.Add(conversionResult.Handle.Value.ToString((IFormatProvider?)null)); + handleValues.Add(conversionResult.Handle.Value.ToString()); } onOperationProgressed?.Invoke("Converting", (double)++count / traversalGraph.Length); diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/BasicConnectorBindingRevit.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/BasicConnectorBindingRevit.cs index 45752e4c2f..5b999dc212 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/BasicConnectorBindingRevit.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/BasicConnectorBindingRevit.cs @@ -66,7 +66,7 @@ public string GetSourceApplicationVersion() return null; } - var info = new DocumentInfo(doc.Title, doc.GetHashCode().ToString((IFormatProvider?)null), doc.PathName); + var info = new DocumentInfo(doc.Title, doc.GetHashCode().ToString(), doc.PathName); if (doc.IsFamilyDocument) { info.Message = "Family Environment files not supported by Speckle."; diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoBasicConnectorBinding.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoBasicConnectorBinding.cs index 04a0dbe9b3..a29e2b6ee3 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoBasicConnectorBinding.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoBasicConnectorBinding.cs @@ -42,11 +42,7 @@ public string GetConnectorVersion() => public string GetSourceApplicationVersion() => "7"; public DocumentInfo GetDocumentInfo() => - new( - RhinoDoc.ActiveDoc.Path, - RhinoDoc.ActiveDoc.Name, - RhinoDoc.ActiveDoc.RuntimeSerialNumber.ToString((IFormatProvider?)null) - ); + new(RhinoDoc.ActiveDoc.Path, RhinoDoc.ActiveDoc.Name, RhinoDoc.ActiveDoc.RuntimeSerialNumber.ToString()); public DocumentModelStore GetDocumentState() => _store; @@ -71,7 +67,7 @@ public void HighlightModel(string modelCardId) if (myModel is SenderModelCard sender) { - objectIds = sender.SendFilter.NotNull().GetObjectIds().ToList(); + objectIds = sender.SendFilter.NotNull().GetObjectIds(); } if (myModel is ReceiverModelCard receiver && receiver.ReceiveResult != null) diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/PointcloudLayerToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/PointcloudLayerToSpeckleConverter.cs index 42ecbad9ec..d7603ab493 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/PointcloudLayerToSpeckleConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/PointcloudLayerToSpeckleConverter.cs @@ -32,7 +32,7 @@ private int GetPointColor(LasPoint pt, object renderer) { // get color int color = 0; - string classCode = pt.ClassCode.ToString((IFormatProvider?)null); + string classCode = pt.ClassCode.ToString(); if (renderer is CIMTinUniqueValueRenderer uniqueRenderer) { foreach (CIMUniqueValueGroup group in uniqueRenderer.Groups) From ddea0f5a40000019eaa9691ddfe03a422af790a5 Mon Sep 17 00:00:00 2001 From: Adam Hathcock Date: Thu, 9 May 2024 14:55:33 +0100 Subject: [PATCH 158/261] add back instance the way it was --- .../Plugin/Speckle.Connectors.Rhino7Command.cs | 5 ++++- .../Plugin/Speckle.Connectors.Rhino7Plugin.cs | 9 ++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Plugin/Speckle.Connectors.Rhino7Command.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Plugin/Speckle.Connectors.Rhino7Command.cs index f2b0c18534..f6f9effeb2 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Plugin/Speckle.Connectors.Rhino7Command.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Plugin/Speckle.Connectors.Rhino7Command.cs @@ -13,6 +13,7 @@ public SpeckleConnectorsRhino7Command() { // Rhino only creates one instance of each command class defined in a // plug-in, so it is safe to store a reference in a static property. + Instance = this; Panels.RegisterPanel( SpeckleConnectorsRhino7Plugin.Instance, typeof(SpeckleRhinoPanelHost), @@ -23,7 +24,9 @@ public SpeckleConnectorsRhino7Command() } ///The only instance of this command. - public static SpeckleConnectorsRhino7Command Instance { get; } = new(); +#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable. + public static SpeckleConnectorsRhino7Command Instance { get; private set; } +#pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable. ///The command name as it appears on the Rhino command line. public override string EnglishName => "SpeckleNewUI"; diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Plugin/Speckle.Connectors.Rhino7Plugin.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Plugin/Speckle.Connectors.Rhino7Plugin.cs index a666b27b31..4c85f5de02 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Plugin/Speckle.Connectors.Rhino7Plugin.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Plugin/Speckle.Connectors.Rhino7Plugin.cs @@ -26,9 +26,16 @@ public class SpeckleConnectorsRhino7Plugin : PlugIn protected override string LocalPlugInName => "Speckle (New UI)"; public AutofacContainer? Container { get; private set; } + + public SpeckleConnectorsRhino7Plugin() + { + Instance = this; + } ///Gets the only instance of the Speckle_Connectors_Rhino7Plugin plug-in. - public static SpeckleConnectorsRhino7Plugin Instance { get; } = new(); +#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable. + public static SpeckleConnectorsRhino7Plugin Instance { get; private set; } +#pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable. // You can override methods here to change the plug-in behavior on // loading and shut down, add options pages to the Rhino _Option command From 27e0b59e686a007f860f03ce9f21fcae772007d5 Mon Sep 17 00:00:00 2001 From: Adam Hathcock Date: Thu, 9 May 2024 14:55:45 +0100 Subject: [PATCH 159/261] remove added dependency --- .../Speckle.Converters.Common.DependencyInjection.csproj | 1 - 1 file changed, 1 deletion(-) diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/Speckle.Converters.Common.DependencyInjection.csproj b/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/Speckle.Converters.Common.DependencyInjection.csproj index a5f5a20194..7675aeeae6 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/Speckle.Converters.Common.DependencyInjection.csproj +++ b/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/Speckle.Converters.Common.DependencyInjection.csproj @@ -10,7 +10,6 @@ - From 89a064dbf4afc81164b4c4808c3ffd2922b0613f Mon Sep 17 00:00:00 2001 From: Adam Hathcock Date: Thu, 9 May 2024 15:05:23 +0100 Subject: [PATCH 160/261] allow resultsStore to have null strings --- .../Plugin/Speckle.Connectors.Rhino7Plugin.cs | 2 +- .../Bridge/BrowserBridge.cs | 17 +++++++---------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Plugin/Speckle.Connectors.Rhino7Plugin.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Plugin/Speckle.Connectors.Rhino7Plugin.cs index 4c85f5de02..7d87e9ea3b 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Plugin/Speckle.Connectors.Rhino7Plugin.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Plugin/Speckle.Connectors.Rhino7Plugin.cs @@ -26,7 +26,7 @@ public class SpeckleConnectorsRhino7Plugin : PlugIn protected override string LocalPlugInName => "Speckle (New UI)"; public AutofacContainer? Container { get; private set; } - + public SpeckleConnectorsRhino7Plugin() { Instance = this; diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/BrowserBridge.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/BrowserBridge.cs index bbc4ed5142..6b75c61f45 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/BrowserBridge.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/BrowserBridge.cs @@ -6,6 +6,7 @@ using System.Threading.Tasks.Dataflow; using System.Diagnostics; using Microsoft.Extensions.Logging; +using Speckle.Connectors.Utils; namespace Speckle.Connectors.DUI.Bridge; @@ -23,7 +24,7 @@ public class BrowserBridge : IBridge /// private readonly JsonSerializerSettings _serializerOptions; - private readonly Dictionary _resultsStore = new(); + private readonly Dictionary _resultsStore = new(); private readonly SynchronizationContext _mainThreadContext; private Dictionary BindingMethodCache { get; set; } = new(); @@ -252,13 +253,9 @@ private void ExecuteMethod(string methodName, string requestId, string args) /// private void NotifyUIMethodCallResultReady(string requestId, string? serializedData = null) { - if (serializedData is not null) - { - _resultsStore[requestId] = serializedData; - } - + _resultsStore[requestId] = serializedData; string script = $"{FrontendBoundName}.responseReady('{requestId}')"; - _scriptMethod?.Invoke(script); + _scriptMethod.NotNull().Invoke(script); } /// @@ -266,7 +263,7 @@ private void NotifyUIMethodCallResultReady(string requestId, string? serializedD /// /// /// - public string GetCallResult(string requestId) + public string? GetCallResult(string requestId) { var res = _resultsStore[requestId]; _resultsStore.Remove(requestId); @@ -291,7 +288,7 @@ public void Send(string eventName) { var script = $"{FrontendBoundName}.emit('{eventName}')"; - _scriptMethod?.Invoke(script); + _scriptMethod.NotNull().Invoke(script); } public void Send(string eventName, T data) @@ -300,6 +297,6 @@ public void Send(string eventName, T data) string payload = JsonConvert.SerializeObject(data, _serializerOptions); var script = $"{FrontendBoundName}.emit('{eventName}', '{payload}')"; - _scriptMethod?.Invoke(script); + _scriptMethod.NotNull().Invoke(script); } } From 6d1d4285a3a38f84a9cd113a578f1960f300fee8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?O=C4=9Fuzhan=20Koral?= <45078678+oguzhankoral@users.noreply.github.com> Date: Thu, 9 May 2024 19:54:52 +0300 Subject: [PATCH 161/261] Fix(dui3): host application name of revit (#3390) Temp fix host application name of revit --- .../Bindings/BasicConnectorBindingRevit.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/BasicConnectorBindingRevit.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/BasicConnectorBindingRevit.cs index 4eb94b969b..6932a29671 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/BasicConnectorBindingRevit.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/BasicConnectorBindingRevit.cs @@ -48,7 +48,7 @@ public string GetConnectorVersion() return Assembly.GetAssembly(GetType()).GetVersion(); } - public string GetSourceApplicationName() => _revitSettings.HostSlug; // POC: maybe not right place but... + public string GetSourceApplicationName() => _revitSettings.HostSlug.ToLower(); // POC: maybe not right place but... // ANOTHER POC: We should align this naming from somewhere in common DUI projects instead old structs. I know there are other POC comments around this public string GetSourceApplicationVersion() { From 4d0b3c7ba9d615c221adcccf5f7eba322016f1c4 Mon Sep 17 00:00:00 2001 From: KatKatKateryna <89912278+KatKatKateryna@users.noreply.github.com> Date: Fri, 10 May 2024 01:42:56 +0800 Subject: [PATCH 162/261] Cnx 9462 agis UI final touches (#3389) * ui updated * new icons --- .../Speckle.Connectors.ArcGIS3/Config.daml | 6 +++--- .../DarkImages/s2logo_16.png | Bin 0 -> 714 bytes .../DarkImages/s2logo_32.png | Bin 0 -> 1672 bytes .../Images/s2logo_16.png | Bin 0 -> 714 bytes .../Images/s2logo_32.png | Bin 0 -> 1672 bytes .../Speckle.Connectors.ArcGIS3.csproj | 14 +++++++------- 6 files changed, 10 insertions(+), 10 deletions(-) create mode 100644 DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/DarkImages/s2logo_16.png create mode 100644 DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/DarkImages/s2logo_32.png create mode 100644 DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Images/s2logo_16.png create mode 100644 DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Images/s2logo_32.png diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Config.daml b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Config.daml index d4fa8aa1f2..28017cd03d 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Config.daml +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Config.daml @@ -50,10 +50,10 @@ diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/DarkImages/s2logo_16.png b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/DarkImages/s2logo_16.png new file mode 100644 index 0000000000000000000000000000000000000000..61872f0d0cc34673152721968f5b93ef13aff8b4 GIT binary patch literal 714 zcmV;*0yX`KP)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!vFvd!vV){sAK>D0$)i)K~y+Tm6Kga zQ(+j#hi=(LS5CY!VNB>kidYw2RM5q!h#*C~jYbsGT}U7MaL1G8SD9L~v5(5sEMkL2 zgeW^T1qF-NQcI;>Of1vo)*6=EId1R2^B!qMn?VPDyf4r5yubH(A2_m8oe|w-4myJu zEJZ&|x=dcuLos@Z$H)<%fg=HN4M})OjAGzWDWl)MWA9Px=3(OS--yC`nPz_gR8rBs zhT{VShkFSQ-c3trtf>s@jt!K}zmYTRkOY*Xvnx{I7s{r%w3akQaMIz+#7o;EnLQ<^ zz|Ps=n=nfI)~BP0&-bFJF^)s_83bnyIAZnxTTtZ~L2N}HDv3Jn3N1sGkUxZ$>8 zaOjfQRd{njNy|5siEU~vlepj-2ZU(=QM{h>qRKgm^7b&wuEnsmUdR?~yOKcEe+KE5 zM)Pom&6kPZTgF<^BV!pGaNJZ#C`fu?f-v(t8@lB42bzj$~`gmxjW={HDz zeT<%G4k#NohMaQ->eeMpy}AhUy<2>O8(8-M$$qRa>!BZbkg3ZOC>Q|+ERQYqJZ$|Y zq(WMda0Sv|s*qkfiiBT-U9Gby5c9MyOF#n(W+U;gZ!eNQ6;@xUu=so@*2Yx$F}xk; zZaSrl=p{J?lpPHpuwpI7oV^^?*FC6lx^T;K9?^Tn=(C>A)NLv#X2Ym$>p&qJg|>47 zL9SYg@3|U)u04AO?B9YvY3ORi;vF^08)tInr9X1_fk0(pO(Z5a3$c8&FfYLfZ}S;` wM9%O}Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!vFvd!vV){sAK>D1|3O6K~z{rwU-G@ zR96&+O%<%&Z9zq9i`uxfRV1w@)f!RJHfdt8B8_#!q@=W|+NN0R!YU|=84)N9%1*6f zT~HBGs7?_VP#8cIfyyd7!{7|ayjkAgb7y!1BclvWy~&q*=iGD8`QN+e-J2OUSlfC5 z4o0%ztS1{D0^73S&-nEsAGRZlPhf1%=C3feW%E+%s~J18f$dp*HH*_5+R!}3k4_5< z1ZQ%TvjxwC0V15{NwGSp)vWXLf<552Y`7W)Fx+=GnRR}i(A)Mi3SfNc{m`sqf4nn+ zAI|f7JkRi0dy*T$0}w?6k?8^y*%qF%B*HKVwutpWQ970P5yVNWU3@iF=z()(BWE;HK0Y zJ@xMBdEkocxf_l4S)yj>YWD%!I`ECrSRG$xoJ*1;iegXBZdUuD8dep8~pa0my;Jw~+ByjNbl|KL`2Ub?7Q_Lt~yBmPh|> z5>H@AH862cJx-nb1)Vn+V0BCeto<}-E8h?3>PWyN>Ko8qy&vz3I`E086rDF*a3#YF z4!ax7#$yb*2(A6pSS8NDjL-_KODqB}KSs&hiB3XBI?}M?_yvp&YJ=C|RE+XhnT;bb zsDRf4yD>RbhMA&P%n5J8!st4<##X>1)YG608OoObmnBYKUs`dqDo>P*Z_+RYjm(vKW*0JhV&zV`4}PawNg%d?12K zaTz*w9=&EM1-?TG?hzygDDbG#-8s?HNolx;*-=2nakmJNt)kpPAj z;e8|>O@$udnnQq|6SUXqB!sRW$4*&O$OCR8r1C}P~2I8kW|CjV2)=BU`eff z)kc_YNn{CR1VnOQ$BpsK@k{|D{Wy%I z6HN~r6K@7|LMd^C=AR{0;VZ$**3entL2Mw_gYQ@czReAqDi=JyJ`+pAa$!y4O=1yN zbe;?vhzW}<23!!aTLuc)~K;)jkHB`lpP`uZo-&= zR=hzcX8x6LFk4g(n*bTSMItmEvPXNYE!q>t!24jB*?5d030S%NPqh3t7U#m2VQ%mZ zqkV-~0p+~*{v<;ZU`@q1K49S8E>83XcX1}_&Mm=< z{R)g><3I59>kkv)Z>a!tu!J>n(;-RMD|Bf6#mAX33EtLNk0n>I> zph!F$#o~`4rQS32>95-ydI79CE|5An%`2=PssM}eQOk$>sB852auUV}UoNdTy`eD? z6Wr^n*@8Z2b&+v_k1CO2<->&y_u>2*FYM$z1cv)*oEanidK?6LLqDYr8}={JV2_00 S^FF%(0000 literal 0 HcmV?d00001 diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Images/s2logo_16.png b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Images/s2logo_16.png new file mode 100644 index 0000000000000000000000000000000000000000..61872f0d0cc34673152721968f5b93ef13aff8b4 GIT binary patch literal 714 zcmV;*0yX`KP)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!vFvd!vV){sAK>D0$)i)K~y+Tm6Kga zQ(+j#hi=(LS5CY!VNB>kidYw2RM5q!h#*C~jYbsGT}U7MaL1G8SD9L~v5(5sEMkL2 zgeW^T1qF-NQcI;>Of1vo)*6=EId1R2^B!qMn?VPDyf4r5yubH(A2_m8oe|w-4myJu zEJZ&|x=dcuLos@Z$H)<%fg=HN4M})OjAGzWDWl)MWA9Px=3(OS--yC`nPz_gR8rBs zhT{VShkFSQ-c3trtf>s@jt!K}zmYTRkOY*Xvnx{I7s{r%w3akQaMIz+#7o;EnLQ<^ zz|Ps=n=nfI)~BP0&-bFJF^)s_83bnyIAZnxTTtZ~L2N}HDv3Jn3N1sGkUxZ$>8 zaOjfQRd{njNy|5siEU~vlepj-2ZU(=QM{h>qRKgm^7b&wuEnsmUdR?~yOKcEe+KE5 zM)Pom&6kPZTgF<^BV!pGaNJZ#C`fu?f-v(t8@lB42bzj$~`gmxjW={HDz zeT<%G4k#NohMaQ->eeMpy}AhUy<2>O8(8-M$$qRa>!BZbkg3ZOC>Q|+ERQYqJZ$|Y zq(WMda0Sv|s*qkfiiBT-U9Gby5c9MyOF#n(W+U;gZ!eNQ6;@xUu=so@*2Yx$F}xk; zZaSrl=p{J?lpPHpuwpI7oV^^?*FC6lx^T;K9?^Tn=(C>A)NLv#X2Ym$>p&qJg|>47 zL9SYg@3|U)u04AO?B9YvY3ORi;vF^08)tInr9X1_fk0(pO(Z5a3$c8&FfYLfZ}S;` wM9%O}Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!vFvd!vV){sAK>D1|3O6K~z{rwU-G@ zR96&+O%<%&Z9zq9i`uxfRV1w@)f!RJHfdt8B8_#!q@=W|+NN0R!YU|=84)N9%1*6f zT~HBGs7?_VP#8cIfyyd7!{7|ayjkAgb7y!1BclvWy~&q*=iGD8`QN+e-J2OUSlfC5 z4o0%ztS1{D0^73S&-nEsAGRZlPhf1%=C3feW%E+%s~J18f$dp*HH*_5+R!}3k4_5< z1ZQ%TvjxwC0V15{NwGSp)vWXLf<552Y`7W)Fx+=GnRR}i(A)Mi3SfNc{m`sqf4nn+ zAI|f7JkRi0dy*T$0}w?6k?8^y*%qF%B*HKVwutpWQ970P5yVNWU3@iF=z()(BWE;HK0Y zJ@xMBdEkocxf_l4S)yj>YWD%!I`ECrSRG$xoJ*1;iegXBZdUuD8dep8~pa0my;Jw~+ByjNbl|KL`2Ub?7Q_Lt~yBmPh|> z5>H@AH862cJx-nb1)Vn+V0BCeto<}-E8h?3>PWyN>Ko8qy&vz3I`E086rDF*a3#YF z4!ax7#$yb*2(A6pSS8NDjL-_KODqB}KSs&hiB3XBI?}M?_yvp&YJ=C|RE+XhnT;bb zsDRf4yD>RbhMA&P%n5J8!st4<##X>1)YG608OoObmnBYKUs`dqDo>P*Z_+RYjm(vKW*0JhV&zV`4}PawNg%d?12K zaTz*w9=&EM1-?TG?hzygDDbG#-8s?HNolx;*-=2nakmJNt)kpPAj z;e8|>O@$udnnQq|6SUXqB!sRW$4*&O$OCR8r1C}P~2I8kW|CjV2)=BU`eff z)kc_YNn{CR1VnOQ$BpsK@k{|D{Wy%I z6HN~r6K@7|LMd^C=AR{0;VZ$**3entL2Mw_gYQ@czReAqDi=JyJ`+pAa$!y4O=1yN zbe;?vhzW}<23!!aTLuc)~K;)jkHB`lpP`uZo-&= zR=hzcX8x6LFk4g(n*bTSMItmEvPXNYE!q>t!24jB*?5d030S%NPqh3t7U#m2VQ%mZ zqkV-~0p+~*{v<;ZU`@q1K49S8E>83XcX1}_&Mm=< z{R)g><3I59>kkv)Z>a!tu!J>n(;-RMD|Bf6#mAX33EtLNk0n>I> zph!F$#o~`4rQS32>95-ydI79CE|5An%`2=PssM}eQOk$>sB852auUV}UoNdTy`eD? z6Wr^n*@8Z2b&+v_k1CO2<->&y_u>2*FYM$z1cv)*oEanidK?6LLqDYr8}={JV2_00 S^FF%(0000 literal 0 HcmV?d00001 diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Speckle.Connectors.ArcGIS3.csproj b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Speckle.Connectors.ArcGIS3.csproj index 4887f7ffc9..9809d38114 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Speckle.Connectors.ArcGIS3.csproj +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Speckle.Connectors.ArcGIS3.csproj @@ -13,21 +13,21 @@ - - - - + + + + - + - - + + From 4ef37e35b1ce5bd2f786d6b7f13bca0b3d21f3f8 Mon Sep 17 00:00:00 2001 From: KatKatKateryna <89912278+KatKatKateryna@users.noreply.github.com> Date: Fri, 10 May 2024 18:06:01 +0800 Subject: [PATCH 163/261] align DUI3 naming (#3392) * align DUI3 naming * Speckle (New UI) -> SpeckleNewUI to better align it with other connectors. --------- Co-authored-by: Mucahit Bilal GOKER --- .../ArcGIS/Speckle.Connectors.ArcGIS3/Config.daml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Config.daml b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Config.daml index 28017cd03d..7387b9250a 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Config.daml +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Config.daml @@ -47,19 +47,19 @@ - - + From 03cfb0becb07f252c447fb6d03a105df3287dd5d Mon Sep 17 00:00:00 2001 From: Adam Hathcock Date: Fri, 10 May 2024 11:18:52 +0100 Subject: [PATCH 164/261] SelectionInfo is a record and other review changes --- .../Bindings/ArcGISSelectionBinding.cs | 7 ++----- .../Bindings/AutocadSelectionBinding.cs | 6 +----- .../Bindings/SelectionBinding.cs | 12 +++++------- .../Bindings/RhinoSelectionBinding.cs | 8 ++------ .../ToHost/Raw/PolyCurveToHostConverter.cs | 3 ++- .../Bindings/ISelectionBinding.cs | 6 +----- .../Speckle.Connectors.DUI/Bridge/BrowserBridge.cs | 2 +- .../DUI3/Speckle.Connectors.DUI/Bridge/IBridge.cs | 2 +- 8 files changed, 15 insertions(+), 31 deletions(-) diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISSelectionBinding.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISSelectionBinding.cs index 932223ae9f..b201dd45d3 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISSelectionBinding.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISSelectionBinding.cs @@ -44,10 +44,7 @@ public SelectionInfo GetSelection() .Select(o => o.GetType().ToString().Split(".").Last()) .Distinct() .ToList(); - return new SelectionInfo - { - SelectedObjectIds = selectedMembers.Select(x => x.URI).ToList(), - Summary = $"{selectedMembers.Count} layers ({string.Join(", ", objectTypes)})" - }; + return new SelectionInfo(selectedMembers.Select(x => x.URI).ToList(), + $"{selectedMembers.Count} layers ({string.Join(", ", objectTypes)})"); } } diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadSelectionBinding.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadSelectionBinding.cs index 5e2188d4cf..b52fcba337 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadSelectionBinding.cs +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadSelectionBinding.cs @@ -81,10 +81,6 @@ public SelectionInfo GetSelection() } } List flatObjectTypes = objectTypes.Select(o => o).Distinct().ToList(); - return new SelectionInfo - { - SelectedObjectIds = objs, - Summary = $"{objs.Count} objects ({string.Join(", ", flatObjectTypes)})" - }; + return new SelectionInfo(objs, $"{objs.Count} objects ({string.Join(", ", flatObjectTypes)})"); } } diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SelectionBinding.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SelectionBinding.cs index fc8669406c..0c3aeae27b 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SelectionBinding.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SelectionBinding.cs @@ -2,6 +2,7 @@ using Speckle.Connectors.DUI.Bridge; using Speckle.Connectors.DUI.Models; using Speckle.Connectors.Revit.Plugin; +using Speckle.Converters.Common; using Speckle.Converters.RevitShared.Helpers; namespace Speckle.Connectors.Revit.Bindings; @@ -40,14 +41,11 @@ public SelectionInfo GetSelection() // POC: this was also being called on shutdown // probably the bridge needs to be able to know if the plugin has been terminated // also on termination the OnSelectionChanged event needs unwinding - var selectionIds = RevitContext.UIApplication?.ActiveUIDocument.Selection - .GetElementIds() + var selectionIds = (RevitContext.UIApplication?.ActiveUIDocument.Selection + .GetElementIds()) + .Empty() .Select(id => id.ToString()) .ToList(); - return new SelectionInfo() - { - SelectedObjectIds = selectionIds, - Summary = $"{selectionIds?.Count} objects selected." - }; + return new SelectionInfo(selectionIds, $"{selectionIds.Count} objects selected."); } } diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSelectionBinding.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSelectionBinding.cs index c4e1feef68..8227f07c22 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSelectionBinding.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSelectionBinding.cs @@ -43,11 +43,7 @@ public SelectionInfo GetSelection() List objectIds = objects.Select(o => o.Id.ToString()).ToList(); int layerCount = objects.Select(o => o.Attributes.LayerIndex).Distinct().Count(); List objectTypes = objects.Select(o => o.ObjectType.ToString()).Distinct().ToList(); - return new SelectionInfo - { - SelectedObjectIds = objectIds, - Summary = - $"{objectIds.Count} objects ({string.Join(", ", objectTypes)}) from {layerCount} layer{(layerCount != 1 ? "s" : "")}" - }; + return new SelectionInfo(objectIds, + $"{objectIds.Count} objects ({string.Join(", ", objectTypes)}) from {layerCount} layer{(layerCount != 1 ? "s" : "")}"); } } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/PolyCurveToHostConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/PolyCurveToHostConverter.cs index af8bd3e910..a1498f07c2 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/PolyCurveToHostConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/PolyCurveToHostConverter.cs @@ -1,4 +1,5 @@ using Objects; +using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; using Speckle.Core.Kits; @@ -27,7 +28,7 @@ public RG.PolyCurve RawConvert(SOG.Polycurve target) foreach (var segment in target.segments) { - var childCurve = CurveConverter?.RawConvert(segment); + var childCurve = CurveConverter.NotNull().RawConvert(segment); bool success = result.AppendSegment(childCurve); if (!success) { diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/ISelectionBinding.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/ISelectionBinding.cs index 6f9f8e059d..1bef4f8815 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/ISelectionBinding.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/ISelectionBinding.cs @@ -10,8 +10,4 @@ public static class SelectionBindingEvents public const string SET_SELECTION = "setSelection"; } -public class SelectionInfo -{ - public List? SelectedObjectIds { get; set; } - public string? Summary { get; set; } -} +public record SelectionInfo(List SelectedObjectIds, string Summary); diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/BrowserBridge.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/BrowserBridge.cs index 6b75c61f45..564f587ccf 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/BrowserBridge.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/BrowserBridge.cs @@ -41,7 +41,7 @@ public class BrowserBridge : IBridge /// public Action? ShowDevToolsAction { get; set; } - public string? FrontendBoundName { get; private set; } + public string FrontendBoundName { get; private set; } = "Unknown"; public object? Browser { get; private set; } diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/IBridge.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/IBridge.cs index b77db4d152..1bdcd6e364 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/IBridge.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/IBridge.cs @@ -10,7 +10,7 @@ namespace Speckle.Connectors.DUI.Bridge; public interface IBridge { // POC: documnetation comments - string? FrontendBoundName { get; } + string FrontendBoundName { get; } void AssociateWithBinding(IBinding binding, Action scriptMethod, object browser, Action showDevToolsAction); From df789b58c5982032c449ac72e2cb4685650f337a Mon Sep 17 00:00:00 2001 From: Adam Hathcock Date: Fri, 10 May 2024 11:25:39 +0100 Subject: [PATCH 165/261] more records and fmt --- .../Bindings/ArcGISReceiveBinding.cs | 2 +- .../Bindings/ArcGISSelectionBinding.cs | 6 ++++-- .../Bindings/ArcGISSendBinding.cs | 2 +- .../Bindings/AutocadReceiveBinding.cs | 2 +- .../Bindings/AutocadSendBinding.cs | 2 +- .../Bindings/SelectionBinding.cs | 3 +-- .../Bindings/SendBinding.cs | 2 +- .../Bindings/RhinoReceiveBinding.cs | 2 +- .../Bindings/RhinoSelectionBinding.cs | 6 ++++-- .../Bindings/RhinoSendBinding.cs | 2 +- .../Models/Card/CreateVersionArgs.cs | 6 +----- .../Models/Card/ModelCardError.cs | 6 +----- .../Models/Card/ModelCardProgress.cs | 16 +++++----------- 13 files changed, 23 insertions(+), 34 deletions(-) diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISReceiveBinding.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISReceiveBinding.cs index cd8574f4a7..361ed9f6e0 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISReceiveBinding.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISReceiveBinding.cs @@ -73,7 +73,7 @@ public async Task Receive(string modelCardId) private void OnSendOperationProgress(string modelCardId, string status, double? progress) { - Commands.SetModelProgress(modelCardId, new ModelCardProgress { Status = status, Progress = progress }); + Commands.SetModelProgress(modelCardId, new ModelCardProgress(modelCardId, status, progress)); } public void CancelReceive(string modelCardId) => _cancellationManager.CancelOperation(modelCardId); diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISSelectionBinding.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISSelectionBinding.cs index b201dd45d3..663748f7d2 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISSelectionBinding.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISSelectionBinding.cs @@ -44,7 +44,9 @@ public SelectionInfo GetSelection() .Select(o => o.GetType().ToString().Split(".").Last()) .Distinct() .ToList(); - return new SelectionInfo(selectedMembers.Select(x => x.URI).ToList(), - $"{selectedMembers.Count} layers ({string.Join(", ", objectTypes)})"); + return new SelectionInfo( + selectedMembers.Select(x => x.URI).ToList(), + $"{selectedMembers.Count} layers ({string.Join(", ", objectTypes)})" + ); } } diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISSendBinding.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISSendBinding.cs index 1b4b5dfc48..2f11adf5d0 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISSendBinding.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISSendBinding.cs @@ -132,7 +132,7 @@ private void RunExpirationChecks() private void OnSendOperationProgress(string modelCardId, string status, double? progress) { - Commands.SetModelProgress(modelCardId, new ModelCardProgress { Status = status, Progress = progress }); + Commands.SetModelProgress(modelCardId, new ModelCardProgress(modelCardId, status, progress)); } public void Dispose() diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadReceiveBinding.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadReceiveBinding.cs index 21f46880f1..181e152051 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadReceiveBinding.cs +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadReceiveBinding.cs @@ -75,7 +75,7 @@ public async Task Receive(string modelCardId) private void OnSendOperationProgress(string modelCardId, string status, double? progress) { - Commands.SetModelProgress(modelCardId, new ModelCardProgress { Status = status, Progress = progress }); + Commands.SetModelProgress(modelCardId, new ModelCardProgress(modelCardId, status, progress)); } // POC: JEDD: We should not update the UI until a OperationCancelledException is caught, we don't want to show the UI as cancelled diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadSendBinding.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadSendBinding.cs index 1eff6da0bc..755d3db9e8 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadSendBinding.cs +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadSendBinding.cs @@ -180,7 +180,7 @@ private async Task SendInternal(string modelCardId) private void OnSendOperationProgress(string modelCardId, string status, double? progress) { - Commands.SetModelProgress(modelCardId, new ModelCardProgress { Status = status, Progress = progress }); + Commands.SetModelProgress(modelCardId, new ModelCardProgress(modelCardId, status, progress)); } public void CancelSend(string modelCardId) => _cancellationManager.CancelOperation(modelCardId); diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SelectionBinding.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SelectionBinding.cs index 0c3aeae27b..ddcf5e8a84 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SelectionBinding.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SelectionBinding.cs @@ -41,8 +41,7 @@ public SelectionInfo GetSelection() // POC: this was also being called on shutdown // probably the bridge needs to be able to know if the plugin has been terminated // also on termination the OnSelectionChanged event needs unwinding - var selectionIds = (RevitContext.UIApplication?.ActiveUIDocument.Selection - .GetElementIds()) + var selectionIds = (RevitContext.UIApplication?.ActiveUIDocument.Selection.GetElementIds()) .Empty() .Select(id => id.ToString()) .ToList(); diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SendBinding.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SendBinding.cs index 0b61b793f2..0e45ba653e 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SendBinding.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SendBinding.cs @@ -142,7 +142,7 @@ private async Task HandleSend(string modelCardId) private void OnSendOperationProgress(string modelCardId, string status, double? progress) { - Commands.SetModelProgress(modelCardId, new ModelCardProgress { Status = status, Progress = progress }); + Commands.SetModelProgress(modelCardId, new ModelCardProgress(modelCardId, status, progress)); } private bool HandleSpeckleException(SpeckleException spex) diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoReceiveBinding.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoReceiveBinding.cs index 96f9765930..62071b8b54 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoReceiveBinding.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoReceiveBinding.cs @@ -74,7 +74,7 @@ public async Task Receive(string modelCardId) private void OnSendOperationProgress(string modelCardId, string status, double? progress) { - Commands.SetModelProgress(modelCardId, new ModelCardProgress { Status = status, Progress = progress }); + Commands.SetModelProgress(modelCardId, new ModelCardProgress(modelCardId, status, progress)); } public void CancelSend(string modelCardId) => CancellationManager.CancelOperation(modelCardId); diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSelectionBinding.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSelectionBinding.cs index 8227f07c22..077a4df2fd 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSelectionBinding.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSelectionBinding.cs @@ -43,7 +43,9 @@ public SelectionInfo GetSelection() List objectIds = objects.Select(o => o.Id.ToString()).ToList(); int layerCount = objects.Select(o => o.Attributes.LayerIndex).Distinct().Count(); List objectTypes = objects.Select(o => o.ObjectType.ToString()).Distinct().ToList(); - return new SelectionInfo(objectIds, - $"{objectIds.Count} objects ({string.Join(", ", objectTypes)}) from {layerCount} layer{(layerCount != 1 ? "s" : "")}"); + return new SelectionInfo( + objectIds, + $"{objectIds.Count} objects ({string.Join(", ", objectTypes)}) from {layerCount} layer{(layerCount != 1 ? "s" : "")}" + ); } } diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSendBinding.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSendBinding.cs index 9e94406b78..b4e5c3110a 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSendBinding.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSendBinding.cs @@ -194,7 +194,7 @@ public async Task Send(string modelCardId) private void OnSendOperationProgress(string modelCardId, string status, double? progress) { - Commands.SetModelProgress(modelCardId, new ModelCardProgress { Status = status, Progress = progress }); + Commands.SetModelProgress(modelCardId, new ModelCardProgress(modelCardId, status, progress)); } public void CancelSend(string modelCardId) => _cancellationManager.CancelOperation(modelCardId); diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/CreateVersionArgs.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/CreateVersionArgs.cs index c4fbcc24d3..e99ee583fe 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/CreateVersionArgs.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/CreateVersionArgs.cs @@ -1,7 +1,3 @@ namespace Speckle.Connectors.DUI.Models.Card; -public class CreateVersionArgs -{ - public string? ModelCardId { get; set; } - public string? ObjectId { get; set; } -} +public record CreateVersionArgs(string ModelCardId, string ObjectId); diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/ModelCardError.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/ModelCardError.cs index b9c3c4d3ac..08efd938f0 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/ModelCardError.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/ModelCardError.cs @@ -1,7 +1,3 @@ namespace Speckle.Connectors.DUI.Models.Card; -public class ModelCardError -{ - public string? ModelCardId { get; set; } - public Exception? Error { get; set; } -} +public record ModelCardError(string ModelCardId, Exception Error); diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/ModelCardProgress.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/ModelCardProgress.cs index 5677a1fc4e..1d2dbdeb7f 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/ModelCardProgress.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/ModelCardProgress.cs @@ -1,13 +1,7 @@ namespace Speckle.Connectors.DUI.Models.Card; -public class ModelCardProgress -{ - public string? ModelCardId { get; set; } - public string? Status { get; set; } - - /// - /// Progress value between 0 and 1 to calculate UI progress bar width. - /// If it is null it will swooshing on UI. - /// - public double? Progress { get; set; } -} +/// +/// Progress value between 0 and 1 to calculate UI progress bar width. +/// If it is null it will swooshing on UI. +/// +public record ModelCardProgress(string ModelCardId, string Status, double? Progress); From 069b60189109dbfdb574a7404e180dd3ccf55ede Mon Sep 17 00:00:00 2001 From: Adam Hathcock Date: Fri, 10 May 2024 12:14:34 +0100 Subject: [PATCH 166/261] remove the empty --- .../Bindings/AutocadBasicConnectorBinding.cs | 2 +- .../Speckle.Connectors.RevitShared/Bindings/SelectionBinding.cs | 2 +- .../Speckle.Connectors.Rhino7/Bindings/RhinoSendBinding.cs | 2 +- DUI3-DX/DUI3/Speckle.Connectors.DUI/Utils/PropertyValidator.cs | 2 +- DUI3-DX/Sdk/Speckle.Connectors.Utils/NotNullExtensions.cs | 2 -- DUI3-DX/Sdk/Speckle.Converters.Common/NotNullExtensions.cs | 2 -- 6 files changed, 4 insertions(+), 8 deletions(-) diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadBasicConnectorBinding.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadBasicConnectorBinding.cs index acc36bb4a3..b8d8e1a019 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadBasicConnectorBinding.cs +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadBasicConnectorBinding.cs @@ -99,7 +99,7 @@ public void HighlightModel(string modelCardId) if (model is ReceiverModelCard receiverModelCard) { List<(DBObject obj, string applicationId)> dbObjects = doc.GetObjects( - (receiverModelCard.ReceiveResult?.BakedObjectIds).Empty() + (receiverModelCard.ReceiveResult?.BakedObjectIds).NotNull() ); objectIds = dbObjects.Select(tuple => tuple.obj.Id).ToArray(); } diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SelectionBinding.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SelectionBinding.cs index ddcf5e8a84..49e5f02c03 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SelectionBinding.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SelectionBinding.cs @@ -42,7 +42,7 @@ public SelectionInfo GetSelection() // probably the bridge needs to be able to know if the plugin has been terminated // also on termination the OnSelectionChanged event needs unwinding var selectionIds = (RevitContext.UIApplication?.ActiveUIDocument.Selection.GetElementIds()) - .Empty() + .NotNull() .Select(id => id.ToString()) .ToList(); return new SelectionInfo(selectionIds, $"{selectionIds.Count} objects selected."); diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSendBinding.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSendBinding.cs index b4e5c3110a..6f04a65d00 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSendBinding.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSendBinding.cs @@ -215,7 +215,7 @@ private void RunExpirationChecks() if (isExpired) { expiredSenderIds.Add(modelCard.ModelCardId.NotNull()); - modelCard.ChangedObjectIds.UnionWith(intersection.Empty()); + modelCard.ChangedObjectIds.UnionWith(intersection.NotNull()); } } diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Utils/PropertyValidator.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Utils/PropertyValidator.cs index 6ad8feec42..fd6546990c 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Utils/PropertyValidator.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Utils/PropertyValidator.cs @@ -37,7 +37,7 @@ public bool CheckRemovedProperties() bool removedPropertiesExist = false; var currentPropertyNames = this.GetType().GetProperties().Select(p => p.Name).ToList(); - foreach (var jsonPropName in JsonPropertyNames.Empty()) + foreach (var jsonPropName in JsonPropertyNames.NotNull()) { if (!currentPropertyNames.Contains(jsonPropName)) { diff --git a/DUI3-DX/Sdk/Speckle.Connectors.Utils/NotNullExtensions.cs b/DUI3-DX/Sdk/Speckle.Connectors.Utils/NotNullExtensions.cs index 4ca533976a..a34d6dd671 100644 --- a/DUI3-DX/Sdk/Speckle.Connectors.Utils/NotNullExtensions.cs +++ b/DUI3-DX/Sdk/Speckle.Connectors.Utils/NotNullExtensions.cs @@ -5,8 +5,6 @@ namespace Speckle.Connectors.Utils; public static class NotNullExtensions { - public static IEnumerable Empty(this IEnumerable? source) => source ?? Enumerable.Empty(); - public static async Task NotNull( this Task task, [CallerArgumentExpression(nameof(task))] string? message = null diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common/NotNullExtensions.cs b/DUI3-DX/Sdk/Speckle.Converters.Common/NotNullExtensions.cs index 47e864a1bf..50e9224965 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common/NotNullExtensions.cs +++ b/DUI3-DX/Sdk/Speckle.Converters.Common/NotNullExtensions.cs @@ -5,8 +5,6 @@ namespace Speckle.Converters.Common; public static class NotNullExtensions { - public static IEnumerable Empty(this IEnumerable? source) => source ?? Enumerable.Empty(); - public static async Task NotNull( this Task task, [CallerArgumentExpression(nameof(task))] string? message = null From b5d7c4d3edb26ec959382f0f0dfd5b50b88d273b Mon Sep 17 00:00:00 2001 From: Adam Hathcock Date: Fri, 10 May 2024 12:23:42 +0100 Subject: [PATCH 167/261] Fix DUI3 projects to all use implicit usings --- .../Speckle.Connectors.ArcGIS3/Speckle.Connectors.ArcGIS3.csproj | 1 - .../Speckle.Connectors.Autocad2023.csproj | 1 - .../Speckle.Converters.ArcGIS3.DependencyInjection.csproj | 1 - .../Speckle.Converters.ArcGIS3/Speckle.Converters.ArcGIS3.csproj | 1 - .../Speckle.Converters.Revit2023.DependencyInjection.csproj | 1 - .../Speckle.Converters.Revit2023.csproj | 1 - .../Speckle.Converters.Rhino7.DependencyInjection.csproj | 1 - .../Speckle.Converters.Rhino7/Speckle.Converters.Rhino7.csproj | 1 - DUI3-DX/Directory.Build.Props | 1 + .../Objects/Speckle.Objects.Common/Speckle.Objects.Common.csproj | 1 - .../Speckle.Converters.Common.DependencyInjection.csproj | 1 - 11 files changed, 1 insertion(+), 10 deletions(-) diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Speckle.Connectors.ArcGIS3.csproj b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Speckle.Connectors.ArcGIS3.csproj index 9809d38114..3b67e3fbf2 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Speckle.Connectors.ArcGIS3.csproj +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Speckle.Connectors.ArcGIS3.csproj @@ -7,7 +7,6 @@ win-x64 Speckle.Connectors.ArcGIS true - enable enable diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.Autocad2023/Speckle.Connectors.Autocad2023.csproj b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.Autocad2023/Speckle.Connectors.Autocad2023.csproj index 895ede52aa..3154c13e9f 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.Autocad2023/Speckle.Connectors.Autocad2023.csproj +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.Autocad2023/Speckle.Connectors.Autocad2023.csproj @@ -3,7 +3,6 @@ Speckle.Connectors.Autocad net48 x64 - enable true Program $(ProgramW6432)\Autodesk\AutoCAD 2023\acad.exe diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3.DependencyInjection/Speckle.Converters.ArcGIS3.DependencyInjection.csproj b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3.DependencyInjection/Speckle.Converters.ArcGIS3.DependencyInjection.csproj index 42ed102e6e..dfb8c2936b 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3.DependencyInjection/Speckle.Converters.ArcGIS3.DependencyInjection.csproj +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3.DependencyInjection/Speckle.Converters.ArcGIS3.DependencyInjection.csproj @@ -2,7 +2,6 @@ net6.0-windows - enable enable x64 diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Speckle.Converters.ArcGIS3.csproj b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Speckle.Converters.ArcGIS3.csproj index 8227edcfd6..c009a70fec 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Speckle.Converters.ArcGIS3.csproj +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Speckle.Converters.ArcGIS3.csproj @@ -2,7 +2,6 @@ net6.0-windows - enable enable x64 diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/Speckle.Converters.Revit2023.DependencyInjection.csproj b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/Speckle.Converters.Revit2023.DependencyInjection.csproj index d61d522f4d..643fb34d94 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/Speckle.Converters.Revit2023.DependencyInjection.csproj +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/Speckle.Converters.Revit2023.DependencyInjection.csproj @@ -4,7 +4,6 @@ net48 x64 enable - enable diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023/Speckle.Converters.Revit2023.csproj b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023/Speckle.Converters.Revit2023.csproj index 474fb6eadd..cabfbb3aa5 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023/Speckle.Converters.Revit2023.csproj +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023/Speckle.Converters.Revit2023.csproj @@ -4,7 +4,6 @@ net48 x64 enable - enable diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/Speckle.Converters.Rhino7.DependencyInjection.csproj b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/Speckle.Converters.Rhino7.DependencyInjection.csproj index 468bb44e2a..2ee33bf6c3 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/Speckle.Converters.Rhino7.DependencyInjection.csproj +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/Speckle.Converters.Rhino7.DependencyInjection.csproj @@ -1,7 +1,6 @@ net48 - enable enable false diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Speckle.Converters.Rhino7.csproj b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Speckle.Converters.Rhino7.csproj index 752fe889d4..2cb8365efa 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Speckle.Converters.Rhino7.csproj +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Speckle.Converters.Rhino7.csproj @@ -2,7 +2,6 @@ net48 - enable enable diff --git a/DUI3-DX/Directory.Build.Props b/DUI3-DX/Directory.Build.Props index 1ec3ccfb1a..31b93c20cb 100644 --- a/DUI3-DX/Directory.Build.Props +++ b/DUI3-DX/Directory.Build.Props @@ -3,6 +3,7 @@ enable + enable diff --git a/DUI3-DX/Objects/Speckle.Objects.Common/Speckle.Objects.Common.csproj b/DUI3-DX/Objects/Speckle.Objects.Common/Speckle.Objects.Common.csproj index 1c5f6eb4d6..7d2edc9c8b 100644 --- a/DUI3-DX/Objects/Speckle.Objects.Common/Speckle.Objects.Common.csproj +++ b/DUI3-DX/Objects/Speckle.Objects.Common/Speckle.Objects.Common.csproj @@ -4,7 +4,6 @@ 10.0 enable netstandard2.0 - disable diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/Speckle.Converters.Common.DependencyInjection.csproj b/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/Speckle.Converters.Common.DependencyInjection.csproj index 6bacb1cc56..376eeea864 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/Speckle.Converters.Common.DependencyInjection.csproj +++ b/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/Speckle.Converters.Common.DependencyInjection.csproj @@ -2,7 +2,6 @@ netstandard2.0 - enable enable From 18ca737169338cfa6c7cdf1c4745f77573a8628d Mon Sep 17 00:00:00 2001 From: Adam Hathcock Date: Fri, 10 May 2024 12:23:58 +0100 Subject: [PATCH 168/261] removed unused usings --- Core/Tests/Speckle.Core.Tests.Unit/Helpers/Path.cs | 1 - .../Speckle.Core.Tests.Unit/Logging/SpeckleLogTests.cs | 1 - .../Tests/Speckle.Core.Tests.Unit/Models/UtilitiesTests.cs | 3 +-- .../Serialisation/SerializerBreakingChanges.cs | 1 - .../Transports/SQLiteTransportTests.cs | 1 - .../Speckle.Core.Tests.Unit/Transports/TransportTests.cs | 1 - .../Bindings/BasicConnectorBindingRevit.cs | 2 -- .../Speckle.Connectors.RevitShared/Bindings/Filters.cs | 2 -- .../Bindings/SelectionBinding.cs | 1 - .../Speckle.Connectors.RevitShared/Bindings/SendBinding.cs | 5 ----- .../DependencyInjection/AutofacUIModule.cs | 1 - .../HostApp/DocumentModelStorageSchema.cs | 3 +-- .../Speckle.Connectors.RevitShared/HostApp/Elements.cs | 2 -- .../HostApp/IdStorageSchema.cs | 3 +-- .../HostApp/RevitDocumentStore.cs | 2 -- .../Operations/Send/RootObjectBuilder.cs | 4 ---- .../Plugin/IRevitIdleManager.cs | 2 -- .../Plugin/RevitExternalApplication.cs | 1 - .../Plugin/RevitIdleManager.cs | 2 -- .../Speckle.Connectors.RevitShared/Plugin/RevitPlugin.cs | 3 --- .../Bindings/RhinoBasicConnectorBinding.cs | 3 --- .../Bindings/RhinoReceiveBinding.cs | 7 +------ .../Bindings/RhinoSelectionBinding.cs | 2 -- .../Speckle.Connectors.Rhino7/Bindings/RhinoSendBinding.cs | 5 ----- .../DependencyInjection/AutofacRhinoModule.cs | 1 - .../Speckle.Connectors.Rhino7/Extensions/BoundingBox.cs | 3 +-- .../Filters/RhinoEverythingFilter.cs | 3 +-- .../Filters/RhinoSelectionFilter.cs | 2 -- .../HostApp/RhinoDocumentStore.cs | 1 - .../Speckle.Connectors.Rhino7/HostApp/RhinoIdleManager.cs | 1 - .../Speckle.Connectors.Rhino7/HostApp/RhinoSettings.cs | 3 +-- .../Operations/Receive/DisableRedrawScope.cs | 3 +-- .../Operations/Receive/RhinoHostObjectBuilder.cs | 4 ---- .../Operations/Send/RootObjectBuilder.cs | 4 ---- .../Plugin/Speckle.Connectors.Rhino7Command.cs | 1 - .../Plugin/Speckle.Connectors.Rhino7Plugin.cs | 3 +-- .../AutocadConverterToSpeckle.cs | 1 - .../AutocadToSpeckleUnitConverter.cs | 1 - .../Extensions/EntityExtensions.cs | 1 - .../Extensions/ListExtensions.cs | 2 -- .../ToHost/Geometry/CircleToHostConverter.cs | 1 - .../ToHost/Geometry/EllipseToHostConverter.cs | 1 - .../ToHost/Geometry/MeshToHostConverter.cs | 2 -- .../ToHost/Geometry/PolycurveToHostConverter.cs | 2 -- .../ToHost/Geometry/SpeckleFallbackToHostConversion.cs | 4 +--- .../Raw/AutocadPolycurveToHostPolyline2dRawConverter.cs | 1 - .../Raw/AutocadPolycurveToHostPolyline3dRawConverter.cs | 1 - .../Raw/AutocadPolycurveToHostPolylineRawConverter.cs | 1 - .../ToHost/Raw/CurveToHostRawConverter.cs | 2 -- .../ToHost/Raw/IntervalToHostRawConverter.cs | 1 - .../ToHost/Raw/PolycurveToHostPolylineRawConverter.cs | 3 --- .../ToHost/Raw/PolycurveToHostSplineRawConverter.cs | 1 - .../ToSpeckle/Geometry/PolyfaceMeshToSpeckleConverter.cs | 2 -- .../ToSpeckle/Geometry/Polyline2dToSpeckleConverter.cs | 2 -- .../ToSpeckle/Geometry/Polyline3dToSpeckleConverter.cs | 2 -- .../ToSpeckle/Geometry/PolylineToSpeckleConverter.cs | 1 - .../ToSpeckle/Geometry/SplineToSpeckleConverter.cs | 2 -- .../ToSpeckle/Geometry/SubDMeshToSpeckleConverter.cs | 2 -- .../DUI3ControlWebView.xaml.cs | 2 -- .../DUI3/Speckle.Connectors.DUI/Bindings/AccountBinding.cs | 1 - .../Bindings/IBasicConnectorBinding.cs | 1 - .../Speckle.Connectors.DUI/Bindings/IReceiveBinding.cs | 2 -- .../Speckle.Connectors.DUI/Bindings/ISelectionBinding.cs | 2 -- .../DUI3/Speckle.Connectors.DUI/Bindings/ISendBinding.cs | 2 -- .../Bindings/ISendBindingUICommands.cs | 2 -- .../Bindings/ReceiveBindingUICommands.cs | 1 - .../Bindings/SendBindingUICommands.cs | 1 - .../DUI3/Speckle.Connectors.DUI/Bindings/TestBinding.cs | 1 - .../DUI3/Speckle.Connectors.DUI/Bridge/BrowserBridge.cs | 5 ----- DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/IBridge.cs | 1 - .../Speckle.Connectors.DUI/Bridge/SyncToCurrentThread.cs | 4 +--- .../DUI3/Speckle.Connectors.DUI/Bridge/SyncToUIThread.cs | 4 +--- .../DUI3/Speckle.Connectors.DUI/Models/Card/ModelCard.cs | 1 - .../Speckle.Connectors.DUI/Models/Card/ModelCardError.cs | 4 +--- .../Speckle.Connectors.DUI/Models/Card/ReceiveResult.cs | 2 -- .../Models/Card/SendFilter/DirectSelectionSendFilter.cs | 3 +-- .../Models/Card/SendFilter/EverythingSendFilter.cs | 3 +-- .../Models/Card/SendFilter/ISendFilter.cs | 2 -- .../Speckle.Connectors.DUI/Models/Card/SenderModelCard.cs | 1 - .../Speckle.Connectors.DUI/Models/DocumentModelStore.cs | 3 --- .../DUI3/Speckle.Connectors.DUI/Settings/CardSetting.cs | 1 - DUI3-DX/DUI3/Speckle.Connectors.DUI/Url.cs | 4 +--- .../Utils/DiscriminatedObjectConverter.cs | 3 --- .../Speckle.Connectors.DUI/Utils/ModelNotFoundException.cs | 2 +- .../DUI3/Speckle.Connectors.DUI/Utils/PropertyValidator.cs | 3 --- .../DependencyInjection/AutofacContainer.cs | 3 --- .../Sdk/Speckle.Autofac/DependencyInjection/IUnitOfWork.cs | 4 +--- DUI3-DX/Sdk/Speckle.Autofac/Files/IStorageInfo.cs | 2 -- DUI3-DX/Sdk/Speckle.Autofac/Files/StorageInfo.cs | 3 --- .../Builders/IHostObjectBuilder.cs | 5 +---- .../Builders/IRootObjectBuilder.cs | 5 +---- .../Cancellation/CancellationManager.cs | 3 --- .../Operations/IRootObjectSender.cs | 4 ---- .../Operations/ISyncToMainThread.cs | 5 +---- .../Operations/ReceiveOperation.cs | 4 ---- .../Operations/RootObjectSender.cs | 4 ---- DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/Send.cs | 7 +------ .../Sdk/Speckle.Connectors.Utils/Operations/SendInfo.cs | 3 +-- .../Speckle.Connectors.Utils/Operations/SendOperation.cs | 6 +----- .../Reflection/AssemblyExtensions.cs | 1 - .../SpeckleTopLevelExceptionHandler.cs | 2 -- DUI3-DX/Sdk/Speckle.Converters.Common/ContextWrapper.cs | 4 +--- .../Speckle.Converters.Common/ConversionContextStack.cs | 3 +-- DUI3-DX/Sdk/Speckle.Converters.Common/DisplayableObject.cs | 5 +---- .../Speckle.Converters.Common/NameAndRankValueAttribute.cs | 4 +--- .../Objects/IConverterResolver.cs | 4 +--- .../Speckle.Converters.Common/RecursiveConveterResolver.cs | 3 +-- .../SpeckleConversionException.cs | 4 +--- 108 files changed, 31 insertions(+), 241 deletions(-) diff --git a/Core/Tests/Speckle.Core.Tests.Unit/Helpers/Path.cs b/Core/Tests/Speckle.Core.Tests.Unit/Helpers/Path.cs index 333954e93e..7878ab510c 100644 --- a/Core/Tests/Speckle.Core.Tests.Unit/Helpers/Path.cs +++ b/Core/Tests/Speckle.Core.Tests.Unit/Helpers/Path.cs @@ -1,5 +1,4 @@ using System.Runtime.InteropServices; -using System.Text.RegularExpressions; using NUnit.Framework; using Speckle.Core.Helpers; diff --git a/Core/Tests/Speckle.Core.Tests.Unit/Logging/SpeckleLogTests.cs b/Core/Tests/Speckle.Core.Tests.Unit/Logging/SpeckleLogTests.cs index 6a97323345..22b703300c 100644 --- a/Core/Tests/Speckle.Core.Tests.Unit/Logging/SpeckleLogTests.cs +++ b/Core/Tests/Speckle.Core.Tests.Unit/Logging/SpeckleLogTests.cs @@ -1,6 +1,5 @@ using NUnit.Framework; using Serilog.Context; -using Serilog.Core; using Serilog.Events; using Speckle.Core.Logging; diff --git a/Core/Tests/Speckle.Core.Tests.Unit/Models/UtilitiesTests.cs b/Core/Tests/Speckle.Core.Tests.Unit/Models/UtilitiesTests.cs index ffa5bce998..f8c47feb14 100644 --- a/Core/Tests/Speckle.Core.Tests.Unit/Models/UtilitiesTests.cs +++ b/Core/Tests/Speckle.Core.Tests.Unit/Models/UtilitiesTests.cs @@ -1,5 +1,4 @@ -using System.Collections; -using NUnit.Framework; +using NUnit.Framework; using Speckle.Core.Helpers; namespace Speckle.Core.Tests.Unit.Models; diff --git a/Core/Tests/Speckle.Core.Tests.Unit/Serialisation/SerializerBreakingChanges.cs b/Core/Tests/Speckle.Core.Tests.Unit/Serialisation/SerializerBreakingChanges.cs index 163d7abd21..0fc9549fd2 100644 --- a/Core/Tests/Speckle.Core.Tests.Unit/Serialisation/SerializerBreakingChanges.cs +++ b/Core/Tests/Speckle.Core.Tests.Unit/Serialisation/SerializerBreakingChanges.cs @@ -1,5 +1,4 @@ using NUnit.Framework; -using Speckle.Core.Logging; using Speckle.Core.Serialisation; namespace Speckle.Core.Tests.Unit.Serialisation; diff --git a/Core/Tests/Speckle.Core.Tests.Unit/Transports/SQLiteTransportTests.cs b/Core/Tests/Speckle.Core.Tests.Unit/Transports/SQLiteTransportTests.cs index 95504f0d03..735536cdcc 100644 --- a/Core/Tests/Speckle.Core.Tests.Unit/Transports/SQLiteTransportTests.cs +++ b/Core/Tests/Speckle.Core.Tests.Unit/Transports/SQLiteTransportTests.cs @@ -1,6 +1,5 @@ using Microsoft.Data.Sqlite; using NUnit.Framework; -using NUnit.Framework.Constraints; using Speckle.Core.Transports; namespace Speckle.Core.Tests.Unit.Transports; diff --git a/Core/Tests/Speckle.Core.Tests.Unit/Transports/TransportTests.cs b/Core/Tests/Speckle.Core.Tests.Unit/Transports/TransportTests.cs index b264a6fe9d..067c5298c3 100644 --- a/Core/Tests/Speckle.Core.Tests.Unit/Transports/TransportTests.cs +++ b/Core/Tests/Speckle.Core.Tests.Unit/Transports/TransportTests.cs @@ -1,6 +1,5 @@ #nullable enable using NUnit.Framework; -using Speckle.Core.Api; using Speckle.Core.Transports; using Speckle.Newtonsoft.Json; diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/BasicConnectorBindingRevit.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/BasicConnectorBindingRevit.cs index 6932a29671..92d5e10cac 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/BasicConnectorBindingRevit.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/BasicConnectorBindingRevit.cs @@ -1,5 +1,3 @@ -using System; -using System.Linq; using System.Reflection; using Autodesk.Revit.DB; using Revit.Async; diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/Filters.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/Filters.cs index 7d9a5133fe..4299f92d64 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/Filters.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/Filters.cs @@ -1,5 +1,3 @@ -using System.Collections.Generic; -using System.Linq; using Speckle.Connectors.DUI.Models.Card.SendFilter; namespace Speckle.Connectors.Revit.Bindings; diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SelectionBinding.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SelectionBinding.cs index ee69c66e52..31da50ce5a 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SelectionBinding.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SelectionBinding.cs @@ -1,4 +1,3 @@ -using System.Linq; using Speckle.Connectors.DUI.Bindings; using Speckle.Connectors.DUI.Bridge; using Speckle.Connectors.DUI.Models; diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SendBinding.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SendBinding.cs index 67fa8c8b21..324d1a0a47 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SendBinding.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SendBinding.cs @@ -1,6 +1,3 @@ -using System; -using System.Collections.Generic; -using System.Linq; using Autodesk.Revit.DB; using Speckle.Connectors.DUI.Models.Card.SendFilter; using Speckle.Connectors.Utils.Cancellation; @@ -8,8 +5,6 @@ using Speckle.Connectors.Revit.Plugin; using Speckle.Core.Logging; using Speckle.Connectors.Utils; -using System.Threading.Tasks; -using System.Threading; using Speckle.Converters.RevitShared.Helpers; using Speckle.Connectors.DUI.Models.Card; using Speckle.Connectors.DUI.Bindings; diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/AutofacUIModule.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/AutofacUIModule.cs index d3e86d8ac3..a5a9494d03 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/AutofacUIModule.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/AutofacUIModule.cs @@ -1,4 +1,3 @@ -using System; using System.IO; using Autodesk.Revit.DB; using Autofac; diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/DocumentModelStorageSchema.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/DocumentModelStorageSchema.cs index 788b8dae4a..ded698f755 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/DocumentModelStorageSchema.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/DocumentModelStorageSchema.cs @@ -1,5 +1,4 @@ -using System; -using Autodesk.Revit.DB.ExtensibleStorage; +using Autodesk.Revit.DB.ExtensibleStorage; namespace Speckle.Connectors.Revit.HostApp; diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/Elements.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/Elements.cs index 1718e5606e..acf4dc1d2e 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/Elements.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/Elements.cs @@ -1,5 +1,3 @@ -using System.Collections.Generic; -using System.Linq; using Autodesk.Revit.DB; namespace Speckle.Connectors.Revit.HostApp; diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/IdStorageSchema.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/IdStorageSchema.cs index cd7cd8147c..398c972678 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/IdStorageSchema.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/IdStorageSchema.cs @@ -1,5 +1,4 @@ -using System; -using Autodesk.Revit.DB.ExtensibleStorage; +using Autodesk.Revit.DB.ExtensibleStorage; namespace Speckle.Connectors.Revit.HostApp; diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/RevitDocumentStore.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/RevitDocumentStore.cs index b3e4c339a4..0130c638b7 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/RevitDocumentStore.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/RevitDocumentStore.cs @@ -1,5 +1,3 @@ -using System; -using System.Collections.Generic; using System.Diagnostics; using Autodesk.Revit.DB; using Autodesk.Revit.DB.ExtensibleStorage; diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RootObjectBuilder.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RootObjectBuilder.cs index ea69596b5d..ab17b54882 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RootObjectBuilder.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RootObjectBuilder.cs @@ -1,11 +1,7 @@ -using System; -using System.Collections.Generic; using Speckle.Converters.Common; using Speckle.Core.Models; -using System.Threading; using Autodesk.Revit.DB; using Speckle.Converters.RevitShared.Helpers; -using System.Linq; using Speckle.Connectors.Utils.Builders; using Speckle.Connectors.Utils.Operations; using Speckle.Core.Logging; diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/IRevitIdleManager.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/IRevitIdleManager.cs index ab7fcc435d..3a8360cc90 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/IRevitIdleManager.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/IRevitIdleManager.cs @@ -1,5 +1,3 @@ -using System; - namespace Speckle.Connectors.Revit.Plugin; // POC: needs interface diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitExternalApplication.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitExternalApplication.cs index c73cfc59e2..d9f4038713 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitExternalApplication.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitExternalApplication.cs @@ -1,4 +1,3 @@ -using System; using Autodesk.Revit.UI; using Speckle.Autofac.DependencyInjection; using Speckle.Autofac.Files; diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitIdleManager.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitIdleManager.cs index 76b723ff9c..a86b7f47e4 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitIdleManager.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitIdleManager.cs @@ -1,6 +1,4 @@ -using System; using System.Collections.Concurrent; -using System.Collections.Generic; using Autodesk.Revit.UI; using Autodesk.Revit.UI.Events; using Speckle.Converters.RevitShared.Helpers; diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitPlugin.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitPlugin.cs index 9e0a2041d4..63b7bbe879 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitPlugin.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitPlugin.cs @@ -1,10 +1,7 @@ -using System; -using System.Collections.Generic; using Autodesk.Revit.UI; using Autodesk.Revit.ApplicationServices; using Revit.Async; using CefSharp; -using System.Linq; using Speckle.Connectors.DUI.Bridge; using Speckle.Connectors.DUI.Bindings; using System.Diagnostics; diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoBasicConnectorBinding.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoBasicConnectorBinding.cs index d9a0cbcfd6..5aad7b236d 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoBasicConnectorBinding.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoBasicConnectorBinding.cs @@ -1,6 +1,3 @@ -using System; -using System.Collections.Generic; -using System.Linq; using Rhino; using Rhino.DocObjects; using Rhino.Geometry; diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoReceiveBinding.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoReceiveBinding.cs index 4bcaf6cde4..aaaeabad03 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoReceiveBinding.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoReceiveBinding.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading; -using System.Threading.Tasks; -using Speckle.Autofac.DependencyInjection; +using Speckle.Autofac.DependencyInjection; using Speckle.Connectors.DUI.Bindings; using Speckle.Connectors.DUI.Bridge; using Speckle.Connectors.DUI.Models; diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSelectionBinding.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSelectionBinding.cs index 5a00123167..c4e1feef68 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSelectionBinding.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSelectionBinding.cs @@ -1,5 +1,3 @@ -using System.Collections.Generic; -using System.Linq; using Rhino; using Rhino.DocObjects; using Speckle.Connectors.DUI.Bindings; diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSendBinding.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSendBinding.cs index 33adb7f6b0..8bdcf04817 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSendBinding.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSendBinding.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; -using System.Linq; -using System.Threading; using Rhino; using Speckle.Connectors.DUI.Bindings; using Speckle.Connectors.DUI.Bridge; @@ -12,7 +8,6 @@ using Speckle.Connectors.Utils.Cancellation; using Speckle.Core.Logging; using ICancelable = System.Reactive.Disposables.ICancelable; -using System.Threading.Tasks; using Speckle.Autofac.DependencyInjection; using Rhino.DocObjects; using Speckle.Connectors.DUI.Models.Card.SendFilter; diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/AutofacRhinoModule.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/AutofacRhinoModule.cs index d4828f0539..2eaba3d714 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/AutofacRhinoModule.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/AutofacRhinoModule.cs @@ -1,4 +1,3 @@ -using System; using Autofac; using Microsoft.Extensions.Logging; using Rhino.Commands; diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Extensions/BoundingBox.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Extensions/BoundingBox.cs index 27950f8b5f..983a8d2a40 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Extensions/BoundingBox.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Extensions/BoundingBox.cs @@ -1,5 +1,4 @@ -using System.Collections.Generic; -using Rhino.DocObjects; +using Rhino.DocObjects; using Rhino.Geometry; namespace Speckle.Connectors.Rhino7.Extensions; diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Filters/RhinoEverythingFilter.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Filters/RhinoEverythingFilter.cs index 1bd052be6b..431edbaa6b 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Filters/RhinoEverythingFilter.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Filters/RhinoEverythingFilter.cs @@ -1,5 +1,4 @@ -using System.Collections.Generic; -using Speckle.Connectors.DUI.Models.Card.SendFilter; +using Speckle.Connectors.DUI.Models.Card.SendFilter; namespace Speckle.Connectors.Rhino7.Filters; diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Filters/RhinoSelectionFilter.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Filters/RhinoSelectionFilter.cs index d103620d66..21d153b940 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Filters/RhinoSelectionFilter.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Filters/RhinoSelectionFilter.cs @@ -1,5 +1,3 @@ -using System.Collections.Generic; -using System.Linq; using Speckle.Connectors.DUI.Models.Card.SendFilter; namespace Speckle.Connectors.Rhino7.Filters; diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/RhinoDocumentStore.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/RhinoDocumentStore.cs index 368c643764..4bff9a6b43 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/RhinoDocumentStore.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/RhinoDocumentStore.cs @@ -1,4 +1,3 @@ -using System.Collections.Generic; using Rhino; using Speckle.Connectors.DUI.Models; using Speckle.Connectors.DUI.Models.Card; diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/RhinoIdleManager.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/RhinoIdleManager.cs index fbb1afe4f7..374d979750 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/RhinoIdleManager.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/RhinoIdleManager.cs @@ -1,4 +1,3 @@ -using System; using System.Collections.Concurrent; using Rhino; diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/RhinoSettings.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/RhinoSettings.cs index bb48c8e6ac..1bb2e89116 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/RhinoSettings.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/RhinoSettings.cs @@ -1,5 +1,4 @@ -using System.Collections.Generic; -using System.IO; +using System.IO; using Speckle.Core.Kits; namespace Speckle.Connectors.Rhino7.HostApp; diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Receive/DisableRedrawScope.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Receive/DisableRedrawScope.cs index 07edaccdc1..1182e5de7a 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Receive/DisableRedrawScope.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Receive/DisableRedrawScope.cs @@ -1,5 +1,4 @@ -using System; -using Rhino.DocObjects.Tables; +using Rhino.DocObjects.Tables; namespace Speckle.Connectors.Rhino7.Operations.Receive; diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Receive/RhinoHostObjectBuilder.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Receive/RhinoHostObjectBuilder.cs index 3e0e0d1d23..48bc85ce99 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Receive/RhinoHostObjectBuilder.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Receive/RhinoHostObjectBuilder.cs @@ -1,7 +1,3 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading; using Rhino; using Rhino.DocObjects; using Rhino.Geometry; diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Send/RootObjectBuilder.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Send/RootObjectBuilder.cs index c6b372800a..bc760a5679 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Send/RootObjectBuilder.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Send/RootObjectBuilder.cs @@ -1,10 +1,6 @@ -using System; -using System.Collections.Generic; -using System.Linq; using Rhino.DocObjects; using Rhino; using Speckle.Core.Models; -using System.Threading; using Speckle.Autofac.DependencyInjection; using Speckle.Converters.Common; using Speckle.Connectors.DUI.Models.Card.SendFilter; diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Plugin/Speckle.Connectors.Rhino7Command.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Plugin/Speckle.Connectors.Rhino7Command.cs index 751213cb0e..d3592ad90b 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Plugin/Speckle.Connectors.Rhino7Command.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Plugin/Speckle.Connectors.Rhino7Command.cs @@ -1,4 +1,3 @@ -using System; using Rhino; using Rhino.Commands; using Rhino.Input.Custom; diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Plugin/Speckle.Connectors.Rhino7Plugin.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Plugin/Speckle.Connectors.Rhino7Plugin.cs index a4abed8dc4..09aeab7af7 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Plugin/Speckle.Connectors.Rhino7Plugin.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Plugin/Speckle.Connectors.Rhino7Plugin.cs @@ -1,5 +1,4 @@ -using System; -using System.IO; +using System.IO; using System.Reflection; using Rhino.PlugIns; using Speckle.Autofac.DependencyInjection; diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/AutocadConverterToSpeckle.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/AutocadConverterToSpeckle.cs index 12eb5acf65..85112323be 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/AutocadConverterToSpeckle.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/AutocadConverterToSpeckle.cs @@ -1,4 +1,3 @@ -using System; using Autodesk.AutoCAD.DatabaseServices; using Speckle.Autofac.DependencyInjection; using Speckle.Converters.Common; diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/AutocadToSpeckleUnitConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/AutocadToSpeckleUnitConverter.cs index 15e92ef90c..3180b4ef94 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/AutocadToSpeckleUnitConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/AutocadToSpeckleUnitConverter.cs @@ -1,4 +1,3 @@ -using System.Collections.Generic; using Autodesk.AutoCAD.DatabaseServices; using Speckle.Converters.Common; using Speckle.Core.Kits; diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/Extensions/EntityExtensions.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/Extensions/EntityExtensions.cs index 6c8515e461..9f99c36098 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/Extensions/EntityExtensions.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/Extensions/EntityExtensions.cs @@ -1,6 +1,5 @@ using Autodesk.AutoCAD.DatabaseServices; using System.Collections; -using System.Collections.Generic; namespace Speckle.Converters.Autocad.Extensions; diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/Extensions/ListExtensions.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/Extensions/ListExtensions.cs index 6731f8f7fa..82ea22ce53 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/Extensions/ListExtensions.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/Extensions/ListExtensions.cs @@ -1,5 +1,3 @@ -using System.Collections.Generic; - namespace Speckle.Converters.Autocad.Extensions; public static class ListExtensions diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/CircleToHostConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/CircleToHostConverter.cs index b1f1604fec..a83a6b1845 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/CircleToHostConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/CircleToHostConverter.cs @@ -1,4 +1,3 @@ -using System; using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; using Speckle.Core.Kits; diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/EllipseToHostConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/EllipseToHostConverter.cs index 824959fbd8..8a7def05a2 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/EllipseToHostConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/EllipseToHostConverter.cs @@ -1,4 +1,3 @@ -using System; using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; using Speckle.Core.Kits; diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/MeshToHostConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/MeshToHostConverter.cs index 4f97cc973b..e75aa5e91d 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/MeshToHostConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/MeshToHostConverter.cs @@ -2,9 +2,7 @@ using Speckle.Converters.Common.Objects; using Speckle.Core.Models; using Objects.Utils; -using System.Linq; using Speckle.Core.Logging; -using System.Collections.Generic; namespace Speckle.Converters.Autocad.Geometry; diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/PolycurveToHostConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/PolycurveToHostConverter.cs index 6a10f2bbc5..a3c458f916 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/PolycurveToHostConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/PolycurveToHostConverter.cs @@ -1,5 +1,3 @@ -using System.Collections.Generic; -using System.Linq; using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; using Speckle.Core.Models; diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/SpeckleFallbackToHostConversion.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/SpeckleFallbackToHostConversion.cs index e09a3ce40a..8271b5751b 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/SpeckleFallbackToHostConversion.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/SpeckleFallbackToHostConversion.cs @@ -1,6 +1,4 @@ -using System; -using System.Collections.Generic; -using Speckle.Converters.Common; +using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; using Speckle.Core.Models; diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/AutocadPolycurveToHostPolyline2dRawConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/AutocadPolycurveToHostPolyline2dRawConverter.cs index e4c46210b0..62c62b14a2 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/AutocadPolycurveToHostPolyline2dRawConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/AutocadPolycurveToHostPolyline2dRawConverter.cs @@ -1,4 +1,3 @@ -using System.Collections.Generic; using Speckle.Converters.Autocad.Extensions; using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/AutocadPolycurveToHostPolyline3dRawConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/AutocadPolycurveToHostPolyline3dRawConverter.cs index 95b0406006..b681e436c6 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/AutocadPolycurveToHostPolyline3dRawConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/AutocadPolycurveToHostPolyline3dRawConverter.cs @@ -1,5 +1,4 @@ using Speckle.Converters.Autocad.Extensions; -using System.Collections.Generic; using Speckle.Converters.Common.Objects; using Speckle.Core.Kits; using Speckle.Converters.Common; diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/AutocadPolycurveToHostPolylineRawConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/AutocadPolycurveToHostPolylineRawConverter.cs index e1b42e61cf..3ad0a1c7ed 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/AutocadPolycurveToHostPolylineRawConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/AutocadPolycurveToHostPolylineRawConverter.cs @@ -1,4 +1,3 @@ -using System.Collections.Generic; using Speckle.Converters.Autocad.Extensions; using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/CurveToHostRawConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/CurveToHostRawConverter.cs index b7fb4bff8f..f7893506be 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/CurveToHostRawConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/CurveToHostRawConverter.cs @@ -1,5 +1,3 @@ -using System.Collections.Generic; -using System.Linq; using Speckle.Converters.Common.Objects; namespace Speckle.Converters.AutocadShared.ToHost.Raw; diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/IntervalToHostRawConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/IntervalToHostRawConverter.cs index e9136438bd..58d03626e9 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/IntervalToHostRawConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/IntervalToHostRawConverter.cs @@ -1,4 +1,3 @@ -using System; using Speckle.Converters.Common.Objects; namespace Speckle.Converters.AutocadShared.ToHost.Raw; diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/PolycurveToHostPolylineRawConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/PolycurveToHostPolylineRawConverter.cs index 874feb8908..b5a182fa2f 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/PolycurveToHostPolylineRawConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/PolycurveToHostPolylineRawConverter.cs @@ -1,6 +1,3 @@ -using System; -using System.Collections.Generic; -using System.Linq; using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/PolycurveToHostSplineRawConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/PolycurveToHostSplineRawConverter.cs index e9f7c38549..25dbe01f7e 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/PolycurveToHostSplineRawConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/PolycurveToHostSplineRawConverter.cs @@ -1,4 +1,3 @@ -using System.Collections.Generic; using Speckle.Converters.Common.Objects; namespace Speckle.Converters.AutocadShared.ToHost.Raw; diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/PolyfaceMeshToSpeckleConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/PolyfaceMeshToSpeckleConverter.cs index 545a430c51..08a1bdbb22 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/PolyfaceMeshToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/PolyfaceMeshToSpeckleConverter.cs @@ -1,5 +1,3 @@ -using System; -using System.Collections.Generic; using Autodesk.AutoCAD.Geometry; using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/Polyline2dToSpeckleConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/Polyline2dToSpeckleConverter.cs index 9091a7b06d..c18458e89b 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/Polyline2dToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/Polyline2dToSpeckleConverter.cs @@ -1,9 +1,7 @@ -using System.Collections.Generic; using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; using Speckle.Core.Models; using Speckle.Converters.Autocad.Extensions; -using System.Linq; namespace Speckle.Converters.Autocad.Geometry; diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/Polyline3dToSpeckleConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/Polyline3dToSpeckleConverter.cs index fff827612e..9434280ca8 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/Polyline3dToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/Polyline3dToSpeckleConverter.cs @@ -1,9 +1,7 @@ -using System.Collections.Generic; using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; using Speckle.Core.Models; using Speckle.Converters.Autocad.Extensions; -using System.Linq; namespace Speckle.Converters.Autocad.Geometry; diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/PolylineToSpeckleConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/PolylineToSpeckleConverter.cs index 44e01315d6..dce4210940 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/PolylineToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/PolylineToSpeckleConverter.cs @@ -1,4 +1,3 @@ -using System.Collections.Generic; using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; using Speckle.Core.Models; diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/SplineToSpeckleConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/SplineToSpeckleConverter.cs index 69953152f7..225aaaa3bf 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/SplineToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/SplineToSpeckleConverter.cs @@ -1,5 +1,3 @@ -using System.Collections.Generic; -using System.Linq; using Autodesk.AutoCAD.Geometry; using Speckle.Converters.Autocad.Extensions; using Speckle.Converters.Common; diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/SubDMeshToSpeckleConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/SubDMeshToSpeckleConverter.cs index 5242265388..296107a5e0 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/SubDMeshToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/SubDMeshToSpeckleConverter.cs @@ -1,5 +1,3 @@ -using System.Collections.Generic; -using System.Linq; using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; using Speckle.Core.Models; diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI.WebView/DUI3ControlWebView.xaml.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI.WebView/DUI3ControlWebView.xaml.cs index 64306ea1d0..4e9cc6bcc5 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI.WebView/DUI3ControlWebView.xaml.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI.WebView/DUI3ControlWebView.xaml.cs @@ -1,5 +1,3 @@ -using System; -using System.Collections.Generic; using System.Windows.Controls; using System.Windows.Threading; using Microsoft.Web.WebView2.Core; diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/AccountBinding.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/AccountBinding.cs index a6cd90ba79..ffd61239c1 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/AccountBinding.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/AccountBinding.cs @@ -1,4 +1,3 @@ -using System.Linq; using Speckle.Connectors.DUI.Bridge; using Speckle.Core.Credentials; diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/IBasicConnectorBinding.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/IBasicConnectorBinding.cs index eb3be48b03..e8d773a9c9 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/IBasicConnectorBinding.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/IBasicConnectorBinding.cs @@ -1,4 +1,3 @@ -using System; using Speckle.Connectors.DUI.Bridge; using Speckle.Connectors.DUI.Models; using Speckle.Connectors.DUI.Models.Card; diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/IReceiveBinding.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/IReceiveBinding.cs index 136c55e310..fc7dd6a2ca 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/IReceiveBinding.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/IReceiveBinding.cs @@ -1,5 +1,3 @@ -using System.Threading.Tasks; - namespace Speckle.Connectors.DUI.Bindings; public interface IReceiveBinding : IBinding diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/ISelectionBinding.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/ISelectionBinding.cs index c7cd2ece98..d682c3ed54 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/ISelectionBinding.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/ISelectionBinding.cs @@ -1,5 +1,3 @@ -using System.Collections.Generic; - namespace Speckle.Connectors.DUI.Bindings; public interface ISelectionBinding : IBinding diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/ISendBinding.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/ISendBinding.cs index 75f54eb6e0..fb4891792a 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/ISendBinding.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/ISendBinding.cs @@ -1,5 +1,3 @@ -using System.Collections.Generic; -using System.Threading.Tasks; using Speckle.Connectors.DUI.Models.Card.SendFilter; namespace Speckle.Connectors.DUI.Bindings; diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/ISendBindingUICommands.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/ISendBindingUICommands.cs index 77b0620ed1..13848f1a71 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/ISendBindingUICommands.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/ISendBindingUICommands.cs @@ -1,5 +1,3 @@ -using System.Collections.Generic; - namespace Speckle.Connectors.DUI.Bindings; public interface ISendBindingUICommands diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/ReceiveBindingUICommands.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/ReceiveBindingUICommands.cs index 6b9bde8b02..c64cdac40f 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/ReceiveBindingUICommands.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/ReceiveBindingUICommands.cs @@ -1,4 +1,3 @@ -using System.Collections.Generic; using Speckle.Connectors.DUI.Bridge; using Speckle.Connectors.DUI.Models.Card; diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/SendBindingUICommands.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/SendBindingUICommands.cs index 1263ddb1f3..9580413088 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/SendBindingUICommands.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/SendBindingUICommands.cs @@ -1,4 +1,3 @@ -using System.Collections.Generic; using Speckle.Connectors.DUI.Bridge; namespace Speckle.Connectors.DUI.Bindings; diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/TestBinding.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/TestBinding.cs index 0e1152f266..3cb80845ed 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/TestBinding.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/TestBinding.cs @@ -1,4 +1,3 @@ -using System; using System.Diagnostics; using Speckle.Connectors.DUI.Bridge; using Speckle.Core.Logging; diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/BrowserBridge.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/BrowserBridge.cs index c5cfb065cc..753bd50905 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/BrowserBridge.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/BrowserBridge.cs @@ -1,11 +1,6 @@ -using System; -using System.Collections.Generic; -using System.Linq; using System.Reflection; using System.Runtime.InteropServices; -using System.Threading; using Speckle.Newtonsoft.Json; -using System.Threading.Tasks; using Speckle.Core.Logging; using Speckle.Connectors.DUI.Bindings; using System.Threading.Tasks.Dataflow; diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/IBridge.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/IBridge.cs index 19830605df..1ae77c4ba9 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/IBridge.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/IBridge.cs @@ -1,4 +1,3 @@ -using System; using Speckle.Connectors.DUI.Bindings; namespace Speckle.Connectors.DUI.Bridge; diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/SyncToCurrentThread.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/SyncToCurrentThread.cs index 723d9c6168..25168fcf32 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/SyncToCurrentThread.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/SyncToCurrentThread.cs @@ -1,6 +1,4 @@ -using System; -using System.Threading.Tasks; -using Speckle.Connectors.Utils.Operations; +using Speckle.Connectors.Utils.Operations; namespace Speckle.Connectors.DUI.Bridge; diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/SyncToUIThread.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/SyncToUIThread.cs index ac9e74086e..3d1d1e21b5 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/SyncToUIThread.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/SyncToUIThread.cs @@ -1,6 +1,4 @@ -using System; -using System.Diagnostics.CodeAnalysis; -using System.Threading.Tasks; +using System.Diagnostics.CodeAnalysis; using Speckle.Connectors.Utils.Operations; namespace Speckle.Connectors.DUI.Bridge; diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/ModelCard.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/ModelCard.cs index e883ff8d22..66433a18fa 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/ModelCard.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/ModelCard.cs @@ -1,4 +1,3 @@ -using System.Collections.Generic; using Speckle.Connectors.DUI.Settings; using Speckle.Connectors.DUI.Utils; diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/ModelCardError.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/ModelCardError.cs index cf2ab19116..ec3d29611d 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/ModelCardError.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/ModelCardError.cs @@ -1,6 +1,4 @@ -using System; - -namespace Speckle.Connectors.DUI.Models.Card; +namespace Speckle.Connectors.DUI.Models.Card; public class ModelCardError { diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/ReceiveResult.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/ReceiveResult.cs index 78d0e23aca..0b1967738e 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/ReceiveResult.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/ReceiveResult.cs @@ -1,5 +1,3 @@ -using System.Collections.Generic; - namespace Speckle.Connectors.DUI.Models.Card; public class ReceiveResult diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/SendFilter/DirectSelectionSendFilter.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/SendFilter/DirectSelectionSendFilter.cs index eee7c6a5f6..42138bc307 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/SendFilter/DirectSelectionSendFilter.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/SendFilter/DirectSelectionSendFilter.cs @@ -1,5 +1,4 @@ -using System.Collections.Generic; -using Speckle.Connectors.DUI.Utils; +using Speckle.Connectors.DUI.Utils; namespace Speckle.Connectors.DUI.Models.Card.SendFilter; diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/SendFilter/EverythingSendFilter.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/SendFilter/EverythingSendFilter.cs index adc5151503..687aa18264 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/SendFilter/EverythingSendFilter.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/SendFilter/EverythingSendFilter.cs @@ -1,5 +1,4 @@ -using System.Collections.Generic; -using Speckle.Connectors.DUI.Utils; +using Speckle.Connectors.DUI.Utils; namespace Speckle.Connectors.DUI.Models.Card.SendFilter; diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/SendFilter/ISendFilter.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/SendFilter/ISendFilter.cs index 0b7d1a745c..99972c17fe 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/SendFilter/ISendFilter.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/SendFilter/ISendFilter.cs @@ -1,5 +1,3 @@ -using System.Collections.Generic; - namespace Speckle.Connectors.DUI.Models.Card.SendFilter; public interface ISendFilter diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/SenderModelCard.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/SenderModelCard.cs index 3d8376b037..0586509b8f 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/SenderModelCard.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/SenderModelCard.cs @@ -1,4 +1,3 @@ -using System.Collections.Generic; using Speckle.Connectors.DUI.Models.Card.SendFilter; using Speckle.Newtonsoft.Json; diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/DocumentModelStore.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/DocumentModelStore.cs index 4a84af29d8..673a9c3d00 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/DocumentModelStore.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/DocumentModelStore.cs @@ -1,6 +1,3 @@ -using System; -using System.Collections.Generic; -using System.Linq; using Speckle.Connectors.DUI.Utils; using Speckle.Connectors.DUI.Objects; using Speckle.Newtonsoft.Json; diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Settings/CardSetting.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Settings/CardSetting.cs index b7cc2bf382..0e64670686 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Settings/CardSetting.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Settings/CardSetting.cs @@ -1,4 +1,3 @@ -using System.Collections.Generic; using Speckle.Connectors.DUI.Utils; namespace Speckle.Connectors.DUI.Settings; diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Url.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Url.cs index 4f63cfff78..b5f5a66f1b 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Url.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Url.cs @@ -1,6 +1,4 @@ -using System; - -namespace Speckle.Connectors.DUI; +namespace Speckle.Connectors.DUI; // POC: XAML file accept Static only, but later we can search more is it possible to inject this? or necessary?? diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Utils/DiscriminatedObjectConverter.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Utils/DiscriminatedObjectConverter.cs index 42d6bd145b..4cc1fc2f34 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Utils/DiscriminatedObjectConverter.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Utils/DiscriminatedObjectConverter.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; using System.Diagnostics; -using System.Linq; using System.Reflection; using Speckle.Core.Serialisation; using Speckle.Newtonsoft.Json; diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Utils/ModelNotFoundException.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Utils/ModelNotFoundException.cs index 742050b6b3..a856d5b130 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Utils/ModelNotFoundException.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Utils/ModelNotFoundException.cs @@ -1,5 +1,5 @@ // POC: why is SpeckleException in this namespace? :8 -using System; + using Speckle.Core.Logging; namespace Speckle.Connectors.DUI.Utils; diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Utils/PropertyValidator.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Utils/PropertyValidator.cs index b4fd6f1fd8..88656ed023 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Utils/PropertyValidator.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Utils/PropertyValidator.cs @@ -1,6 +1,3 @@ -using System; -using System.Collections.Generic; -using System.Linq; using Speckle.Newtonsoft.Json; namespace Speckle.Connectors.DUI.Utils; diff --git a/DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/AutofacContainer.cs b/DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/AutofacContainer.cs index 235ea7ae60..ceb962573c 100644 --- a/DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/AutofacContainer.cs +++ b/DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/AutofacContainer.cs @@ -1,6 +1,3 @@ -using System; -using System.Collections.Generic; -using System.Linq; using System.Reflection; using Autofac; using Microsoft.Extensions.Logging; diff --git a/DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/IUnitOfWork.cs b/DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/IUnitOfWork.cs index 886483db73..5d58d1aabe 100644 --- a/DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/IUnitOfWork.cs +++ b/DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/IUnitOfWork.cs @@ -1,6 +1,4 @@ -using System; - -namespace Speckle.Autofac.DependencyInjection; +namespace Speckle.Autofac.DependencyInjection; public interface IUnitOfWork : IDisposable where TService : class diff --git a/DUI3-DX/Sdk/Speckle.Autofac/Files/IStorageInfo.cs b/DUI3-DX/Sdk/Speckle.Autofac/Files/IStorageInfo.cs index 1f5c2a733b..0ee9cee332 100644 --- a/DUI3-DX/Sdk/Speckle.Autofac/Files/IStorageInfo.cs +++ b/DUI3-DX/Sdk/Speckle.Autofac/Files/IStorageInfo.cs @@ -1,5 +1,3 @@ -using System.Collections.Generic; - namespace Speckle.Autofac.Files; public interface IStorageInfo diff --git a/DUI3-DX/Sdk/Speckle.Autofac/Files/StorageInfo.cs b/DUI3-DX/Sdk/Speckle.Autofac/Files/StorageInfo.cs index c9cbeab3fa..af55e1405a 100644 --- a/DUI3-DX/Sdk/Speckle.Autofac/Files/StorageInfo.cs +++ b/DUI3-DX/Sdk/Speckle.Autofac/Files/StorageInfo.cs @@ -1,6 +1,3 @@ -using System.Collections.Generic; -using System.IO; - namespace Speckle.Autofac.Files; public class StorageInfo : IStorageInfo diff --git a/DUI3-DX/Sdk/Speckle.Connectors.Utils/Builders/IHostObjectBuilder.cs b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Builders/IHostObjectBuilder.cs index 1c3fb1d89b..aedb5887a6 100644 --- a/DUI3-DX/Sdk/Speckle.Connectors.Utils/Builders/IHostObjectBuilder.cs +++ b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Builders/IHostObjectBuilder.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Threading; -using Speckle.Core.Models; +using Speckle.Core.Models; namespace Speckle.Connectors.Utils.Builders; diff --git a/DUI3-DX/Sdk/Speckle.Connectors.Utils/Builders/IRootObjectBuilder.cs b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Builders/IRootObjectBuilder.cs index 2572a158eb..802272f92c 100644 --- a/DUI3-DX/Sdk/Speckle.Connectors.Utils/Builders/IRootObjectBuilder.cs +++ b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Builders/IRootObjectBuilder.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Threading; -using Speckle.Connectors.Utils.Operations; +using Speckle.Connectors.Utils.Operations; using Speckle.Core.Models; namespace Speckle.Connectors.Utils.Builders; diff --git a/DUI3-DX/Sdk/Speckle.Connectors.Utils/Cancellation/CancellationManager.cs b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Cancellation/CancellationManager.cs index 52913510f9..e11dbb781a 100644 --- a/DUI3-DX/Sdk/Speckle.Connectors.Utils/Cancellation/CancellationManager.cs +++ b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Cancellation/CancellationManager.cs @@ -1,6 +1,3 @@ -using System.Collections.Generic; -using System.Threading; - namespace Speckle.Connectors.Utils.Cancellation; /// diff --git a/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/IRootObjectSender.cs b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/IRootObjectSender.cs index 5ebc3c585e..1fed24ea95 100644 --- a/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/IRootObjectSender.cs +++ b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/IRootObjectSender.cs @@ -1,7 +1,3 @@ -using System; -using System.Collections.Generic; -using System.Threading; -using System.Threading.Tasks; using Speckle.Core.Models; namespace Speckle.Connectors.Utils.Operations; diff --git a/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/ISyncToMainThread.cs b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/ISyncToMainThread.cs index 533ee8f838..e757070e72 100644 --- a/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/ISyncToMainThread.cs +++ b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/ISyncToMainThread.cs @@ -1,7 +1,4 @@ -using System; -using System.Threading.Tasks; - -namespace Speckle.Connectors.Utils.Operations; +namespace Speckle.Connectors.Utils.Operations; public interface ISyncToMainThread { diff --git a/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/ReceiveOperation.cs b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/ReceiveOperation.cs index 4ca52c9a30..0d1c745791 100644 --- a/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/ReceiveOperation.cs +++ b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/ReceiveOperation.cs @@ -1,7 +1,3 @@ -using System; -using System.Collections.Generic; -using System.Threading; -using System.Threading.Tasks; using Speckle.Connectors.Utils.Builders; using Speckle.Core.Api; using Speckle.Core.Credentials; diff --git a/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/RootObjectSender.cs b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/RootObjectSender.cs index d3a54d0ba1..c46faeb7fc 100644 --- a/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/RootObjectSender.cs +++ b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/RootObjectSender.cs @@ -1,7 +1,3 @@ -using System; -using System.Collections.Generic; -using System.Threading; -using System.Threading.Tasks; using Speckle.Core.Api; using Speckle.Core.Credentials; using Speckle.Core.Models; diff --git a/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/Send.cs b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/Send.cs index 44e4cb21a6..9cecea8d46 100644 --- a/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/Send.cs +++ b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/Send.cs @@ -1,10 +1,5 @@ -using System; -using System.Collections.Concurrent; -using System.Collections.Generic; +using System.Collections.Concurrent; using System.Diagnostics; -using System.Linq; -using System.Threading; -using System.Threading.Tasks; using Serilog.Context; using Speckle.Core.Logging; using Speckle.Core.Models; diff --git a/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/SendInfo.cs b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/SendInfo.cs index be5f595a83..65cd622466 100644 --- a/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/SendInfo.cs +++ b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/SendInfo.cs @@ -1,5 +1,4 @@ -using System.Collections.Generic; -using Speckle.Core.Models; +using Speckle.Core.Models; namespace Speckle.Connectors.Utils.Operations; diff --git a/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/SendOperation.cs b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/SendOperation.cs index b29e9c9fc0..f5f9453077 100644 --- a/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/SendOperation.cs +++ b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/SendOperation.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Threading; -using System.Threading.Tasks; -using Speckle.Connectors.Utils.Builders; +using Speckle.Connectors.Utils.Builders; using Speckle.Core.Models; namespace Speckle.Connectors.Utils.Operations; diff --git a/DUI3-DX/Sdk/Speckle.Connectors.Utils/Reflection/AssemblyExtensions.cs b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Reflection/AssemblyExtensions.cs index 498e928615..5e48c146a6 100644 --- a/DUI3-DX/Sdk/Speckle.Connectors.Utils/Reflection/AssemblyExtensions.cs +++ b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Reflection/AssemblyExtensions.cs @@ -1,4 +1,3 @@ -using System.Linq; using System.Reflection; namespace Speckle.Connectors.Utils.Reflection; diff --git a/DUI3-DX/Sdk/Speckle.Connectors.Utils/SpeckleTopLevelExceptionHandler.cs b/DUI3-DX/Sdk/Speckle.Connectors.Utils/SpeckleTopLevelExceptionHandler.cs index c93d61af5e..0eb92feff5 100644 --- a/DUI3-DX/Sdk/Speckle.Connectors.Utils/SpeckleTopLevelExceptionHandler.cs +++ b/DUI3-DX/Sdk/Speckle.Connectors.Utils/SpeckleTopLevelExceptionHandler.cs @@ -1,5 +1,3 @@ -using System; -using System.Threading.Tasks; using Speckle.Core.Logging; namespace Speckle.Connectors.Utils; diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common/ContextWrapper.cs b/DUI3-DX/Sdk/Speckle.Converters.Common/ContextWrapper.cs index 77794f54e5..02088f06bb 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common/ContextWrapper.cs +++ b/DUI3-DX/Sdk/Speckle.Converters.Common/ContextWrapper.cs @@ -1,6 +1,4 @@ -using System; - -namespace Speckle.Converters.Common; +namespace Speckle.Converters.Common; public class ContextWrapper : IDisposable where TDocument : class diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common/ConversionContextStack.cs b/DUI3-DX/Sdk/Speckle.Converters.Common/ConversionContextStack.cs index e824ed511e..908ce1989d 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common/ConversionContextStack.cs +++ b/DUI3-DX/Sdk/Speckle.Converters.Common/ConversionContextStack.cs @@ -1,5 +1,4 @@ -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; +using System.Diagnostics.CodeAnalysis; namespace Speckle.Converters.Common; diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common/DisplayableObject.cs b/DUI3-DX/Sdk/Speckle.Converters.Common/DisplayableObject.cs index aa80876c98..ac62b9bf41 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common/DisplayableObject.cs +++ b/DUI3-DX/Sdk/Speckle.Converters.Common/DisplayableObject.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using Objects; +using Objects; using Objects.Geometry; using Speckle.Core.Models; diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common/NameAndRankValueAttribute.cs b/DUI3-DX/Sdk/Speckle.Converters.Common/NameAndRankValueAttribute.cs index e1ac7fc04b..54f380eeb0 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common/NameAndRankValueAttribute.cs +++ b/DUI3-DX/Sdk/Speckle.Converters.Common/NameAndRankValueAttribute.cs @@ -1,6 +1,4 @@ -using System; - -namespace Speckle.Converters.Common; +namespace Speckle.Converters.Common; // POC: maybe better to put in utils/reflection [AttributeUsage(AttributeTargets.Class)] diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common/Objects/IConverterResolver.cs b/DUI3-DX/Sdk/Speckle.Converters.Common/Objects/IConverterResolver.cs index f0018be82e..5ba47c7eda 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common/Objects/IConverterResolver.cs +++ b/DUI3-DX/Sdk/Speckle.Converters.Common/Objects/IConverterResolver.cs @@ -1,6 +1,4 @@ -using System; - -namespace Speckle.Converters.Common.Objects; +namespace Speckle.Converters.Common.Objects; public interface IConverterResolver where TConverter : class diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common/RecursiveConveterResolver.cs b/DUI3-DX/Sdk/Speckle.Converters.Common/RecursiveConveterResolver.cs index 60f78389f5..88cdcec475 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common/RecursiveConveterResolver.cs +++ b/DUI3-DX/Sdk/Speckle.Converters.Common/RecursiveConveterResolver.cs @@ -1,5 +1,4 @@ -using System; -using Speckle.Autofac.DependencyInjection; +using Speckle.Autofac.DependencyInjection; using Speckle.Converters.Common.Objects; namespace Speckle.Converters.Common; diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common/SpeckleConversionException.cs b/DUI3-DX/Sdk/Speckle.Converters.Common/SpeckleConversionException.cs index 2500ca9aab..19cbd2bf01 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common/SpeckleConversionException.cs +++ b/DUI3-DX/Sdk/Speckle.Converters.Common/SpeckleConversionException.cs @@ -1,6 +1,4 @@ -using System; - -namespace Speckle.Converters.Common; +namespace Speckle.Converters.Common; public class SpeckleConversionException : Exception { From 916a8c6558594093881d7df7f6af2456d94c323c Mon Sep 17 00:00:00 2001 From: Adam Hathcock Date: Fri, 10 May 2024 12:49:10 +0100 Subject: [PATCH 169/261] merge fixes --- DUI3-DX/DUI3/Speckle.Connectors.DUI/Utils/PropertyValidator.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Utils/PropertyValidator.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Utils/PropertyValidator.cs index 65162b4be4..fd6546990c 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Utils/PropertyValidator.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Utils/PropertyValidator.cs @@ -1,3 +1,4 @@ +using Speckle.Connectors.Utils; using Speckle.Newtonsoft.Json; namespace Speckle.Connectors.DUI.Utils; From 00018600962464d0eb2f086a0a20320612c518fa Mon Sep 17 00:00:00 2001 From: Adam Hathcock Date: Fri, 10 May 2024 12:52:56 +0100 Subject: [PATCH 170/261] Review changes --- .../Bindings/SelectionBinding.cs | 8 ++------ .../Bindings/SendBinding.cs | 7 +------ 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SelectionBinding.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SelectionBinding.cs index 49e5f02c03..61379b2e5e 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SelectionBinding.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SelectionBinding.cs @@ -21,14 +21,10 @@ IBridge bridge : base("selectionBinding", store, bridge, revitContext) { _revitIdleManager = idleManager; - - if (RevitContext.UIApplication is null) - { - return; - } // POC: we can inject the solution here // TODO: Need to figure it out equivalent of SelectionChanged for Revit2020 - RevitContext.UIApplication.SelectionChanged += (_, _) => _revitIdleManager.SubscribeToIdle(OnSelectionChanged); + RevitContext.UIApplication.NotNull().SelectionChanged += (_, _) => + _revitIdleManager.SubscribeToIdle(OnSelectionChanged); } private void OnSelectionChanged() diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SendBinding.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SendBinding.cs index 0e45ba653e..b7cc3c407c 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SendBinding.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SendBinding.cs @@ -46,14 +46,9 @@ RevitSettings revitSettings _unitOfWorkFactory = unitOfWorkFactory; _revitSettings = revitSettings; Commands = new SendBindingUICommands(bridge); - - if (revitContext.UIApplication is null) - { - return; - } // TODO expiry events // TODO filters need refresh events - revitContext.UIApplication.Application.DocumentChanged += (_, e) => DocChangeHandler(e); + revitContext.UIApplication.NotNull().Application.DocumentChanged += (_, e) => DocChangeHandler(e); } public List GetSendFilters() From 969b4486df1fe0208151bad422756467a54a2491 Mon Sep 17 00:00:00 2001 From: Adam Hathcock Date: Fri, 10 May 2024 12:54:28 +0100 Subject: [PATCH 171/261] even more review changes --- .../Bindings/RhinoBasicConnectorBinding.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoBasicConnectorBinding.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoBasicConnectorBinding.cs index a29e2b6ee3..0f897f0fdb 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoBasicConnectorBinding.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoBasicConnectorBinding.cs @@ -72,7 +72,7 @@ public void HighlightModel(string modelCardId) if (myModel is ReceiverModelCard receiver && receiver.ReceiveResult != null) { - objectIds = receiver.ReceiveResult.BakedObjectIds ?? new(); + objectIds = receiver.ReceiveResult.BakedObjectIds.NotNull(); } if (objectIds.Count == 0) From c39bd32865076fd2072cd44ed006356f89e8dce2 Mon Sep 17 00:00:00 2001 From: Adam Hathcock Date: Fri, 10 May 2024 13:23:16 +0100 Subject: [PATCH 172/261] nowarn just for cefsharp reference --- .../Speckle.Connectors.Revit2023.csproj | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.Revit2023/Speckle.Connectors.Revit2023.csproj b/DUI3-DX/Connectors/Revit/Speckle.Connectors.Revit2023/Speckle.Connectors.Revit2023.csproj index 343787659c..87cb2acb1c 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.Revit2023/Speckle.Connectors.Revit2023.csproj +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.Revit2023/Speckle.Connectors.Revit2023.csproj @@ -3,7 +3,6 @@ net48 x64 true - $(NoWarn);NU1903 @@ -30,7 +29,7 @@ - + From 623046a44c6a1d8752810274b56e8d7576db4da5 Mon Sep 17 00:00:00 2001 From: Jedd Morgan <45512892+JR-Morgan@users.noreply.github.com> Date: Fri, 10 May 2024 14:20:34 +0100 Subject: [PATCH 173/261] Deleted old DUI3 projects (#3398) * Deleted old DUI3 projects * and the slnf --- All.sln | 194 ---------- .../Bindings/BasicConnectorBinding.cs | 55 --- ConnectorArcGIS/Bindings/Factory.cs | 20 - ConnectorArcGIS/Config.daml | 67 ---- ConnectorArcGIS/ConnectorArcGIS.csproj | 117 ------ ConnectorArcGIS/ConnectorArcGIS.sln | 25 -- ConnectorArcGIS/DarkImages/AddInDesktop16.png | Bin 1314 -> 0 bytes ConnectorArcGIS/DarkImages/AddInDesktop32.png | Bin 1744 -> 0 bytes ConnectorArcGIS/Images/AddInDesktop16.png | Bin 524 -> 0 bytes ConnectorArcGIS/Images/AddInDesktop32.png | Bin 948 -> 0 bytes ConnectorArcGIS/Properties/AssemblyInfo.cs | 54 --- .../Properties/launchSettings.json | 9 - ConnectorArcGIS/SpeckleDUI3.xaml | 41 -- ConnectorArcGIS/SpeckleDUI3.xaml.cs | 62 ---- ConnectorArcGIS/SpeckleDUI3ViewModel.cs | 92 ----- ConnectorArcGIS/SpeckleModule.cs | 51 --- ConnectorArcGIS/Utils/ArcGisDocumentStore.cs | 21 -- ConnectorArcGIS/app.config | 15 - .../ConnectorAutocad2022DUI3.csproj | 50 --- .../ConnectorAutocad2023DUI3.csproj | 47 --- .../AutocadCivilDUI3Shared.projitems | 34 -- .../AutocadCivilDUI3Shared.shproj | 11 - .../Bindings/BasicConnectorBindingAutocad.cs | 139 ------- .../Bindings/Factory.cs | 35 -- .../Bindings/Filters.cs | 31 -- .../Bindings/ReceiveBinding.cs | 255 ------------- .../Bindings/SelectionBinding.cs | 75 ---- .../Bindings/SendBinding.cs | 254 ------------- .../DUI3PanelWebView.xaml | 20 - .../DUI3PanelWebView.xaml.cs | 40 -- .../AutocadCivilDUI3Shared/Entry.cs | 72 ---- .../Extensions/Editor.cs | 27 -- .../Extensions/Extends3d.cs | 39 -- .../Utils/AutocadDocumentManager.cs | 149 -------- .../Utils/AutocadDocumentModelStore.cs | 82 ---- .../Utils/AutocadIdleManager.cs | 40 -- .../AutocadCivilDUI3Shared/Utils/Objects.cs | 40 -- .../Utils/TransactionContext.cs | 29 -- .../AutocadCivilDUI3Shared/Utils/Utils.cs | 91 ----- .../Properties/launchSettings.json | 8 - .../Revit2020DUI3/Revit2020DUI3.csproj | 67 ---- .../Properties/launchSettings.json | 8 - .../Revit2023DUI3/Revit2023DUI3.csproj | 46 --- .../Bindings/BasicConnectorBindingRevit.cs | 113 ------ .../RevitDUI3Shared/Bindings/Factory.cs | 31 -- .../RevitDUI3Shared/Bindings/Filters.cs | 32 -- .../Bindings/ReceiveBinding.cs | 170 --------- .../Bindings/SelectionBinding.cs | 46 --- .../RevitDUI3Shared/Bindings/SendBinding.cs | 351 ------------------ .../RevitDUI3Shared/CefSharpPanel.xaml | 18 - .../RevitDUI3Shared/CefSharpPanel.xaml.cs | 29 -- .../RevitDUI3/RevitDUI3Shared/Entry.cs | 157 -------- .../RevitDUI3Shared/RevitDUI3Shared.projitems | 37 -- .../RevitDUI3Shared/RevitDUI3Shared.shproj | 11 - .../RevitDUI3Shared/SpeckleRevit2DUI3.addin | 12 - .../SpeckleRevitDUI3Command.cs | 18 - .../RevitDUI3Shared/Utils/PortedOverStuff.cs | 187 ---------- .../RevitDUI3Shared/Utils/RevitAppProvider.cs | 22 -- .../Utils/RevitDocumentStore.cs | 138 ------- .../RevitDUI3Shared/Utils/RevitIdleManager.cs | 39 -- .../RevitDUI3Shared/Utils/Schemas.cs | 42 --- .../Bindings/BasicConnectorBinding.cs | 117 ------ .../ConnectorRhinoWebUI/Bindings/Factory.cs | 54 --- .../ConnectorRhinoWebUI/Bindings/Filters.cs | 21 -- .../Bindings/ReceiveBinding.cs | 215 ----------- .../Bindings/SelectionBinding.cs | 57 --- .../Bindings/SendBinding.cs | 343 ----------------- .../ConnectorRhinoWebUI/Commands.cs | 174 --------- .../ConnectorRhinoWebUI.csproj | 63 ---- .../EmbeddedResources/plugin-utility.ico | Bin 33583 -> 0 bytes .../Extensions/BoundingBox.cs | 35 -- .../ConnectorRhinoWebUI/PanelHosts.cs | 27 -- ConnectorRhino/ConnectorRhinoWebUI/Plugin.cs | 26 -- .../Properties/AssemblyInfo.cs | 20 - .../Properties/launchSettings.json | 8 - .../SpeckleWebUiPanelWebView2.xaml.cs | 86 ----- .../Utils/RhinoDocumentStore.cs | 58 --- .../Utils/RhinoIdleManager.cs | 45 --- .../Utils/SpeckleRhinoObject.cs | 27 -- .../ConnectorRhinoWebUI/Utils/Utils.cs | 17 - .../ConnectorRhinoWebUI/WebUIPanelCef.xaml | 16 - .../ConnectorRhinoWebUI/WebUIPanelCef.xaml.cs | 35 -- .../WebUIPanelWebView2.xaml | 19 - .../WebUIPanelWebView2.xaml.cs | 40 -- DUI3-DX-REVIT.slnf | 1 - DUI3-DX-RHINO.slnf | 1 - DUI3-DX.slnf | 2 - .../Speckle.Objects.Common.csproj | 18 +- .../Speckle.Objects.Revit.csproj | 7 - DUI3.slnf | 156 -------- DesktopUI3/DUI3/Bindings/AccountBinding.cs | 24 -- DesktopUI3/DUI3/Bindings/ConfigBinding.cs | 131 ------- .../DUI3/Bindings/IBasicConnectorBinding.cs | 38 -- DesktopUI3/DUI3/Bindings/IReceiveBinding.cs | 48 --- DesktopUI3/DUI3/Bindings/ISelectionBinding.cs | 19 - DesktopUI3/DUI3/Bindings/ISendBinding.cs | 89 ----- DesktopUI3/DUI3/Bindings/TestBinding.cs | 64 ---- DesktopUI3/DUI3/Bridge.cs | 187 ---------- DesktopUI3/DUI3/BridgeV2.cs | 282 -------------- DesktopUI3/DUI3/Config/ConnectorConfig.cs | 22 -- DesktopUI3/DUI3/Config/GlobalConfig.cs | 11 - DesktopUI3/DUI3/Config/UiConfig.cs | 11 - DesktopUI3/DUI3/DUI3.csproj | 18 - DesktopUI3/DUI3/Interfaces.cs | 58 --- DesktopUI3/DUI3/Models/Card/ModelCardError.cs | 9 - .../DUI3/Models/Card/ModelCardNotification.cs | 10 - .../DUI3/Models/Card/ModelCardProgress.cs | 15 - DesktopUI3/DUI3/Models/ConversionReport.cs | 46 --- DesktopUI3/DUI3/Models/DocumentInfo.cs | 16 - DesktopUI3/DUI3/Models/DocumentModelStore.cs | 63 ---- DesktopUI3/DUI3/Models/Form.cs | 47 --- DesktopUI3/DUI3/Models/ModelCard.cs | 27 -- DesktopUI3/DUI3/Models/NotificationLevel.cs | 12 - DesktopUI3/DUI3/Objects/ConversionContext.cs | 17 - DesktopUI3/DUI3/Objects/ISpeckleHostObject.cs | 8 - DesktopUI3/DUI3/Objects/ReportObject.cs | 14 - DesktopUI3/DUI3/Objects/SpeckleHostObject.cs | 18 - DesktopUI3/DUI3/Onboarding/Factory.cs | 33 -- DesktopUI3/DUI3/Onboarding/OnboardingData.cs | 11 - .../DUI3/Operations/CancellationManager.cs | 83 ----- DesktopUI3/DUI3/Operations/Operations.cs | 60 --- DesktopUI3/DUI3/Operations/Send.cs | 200 ---------- DesktopUI3/DUI3/Settings/CardSetting.cs | 14 - DesktopUI3/DUI3/Utils/Accounts.cs | 15 - DesktopUI3/DUI3/Utils/Converters.cs | 13 - DesktopUI3/DUI3/Utils/DiscriminatedObject.cs | 15 - .../Utils/DiscriminatedObjectConverter.cs | 119 ------ DesktopUI3/DUI3/Utils/Exceptions.cs | 15 - DesktopUI3/DUI3/Utils/PropertyValidator.cs | 53 --- .../Utils/SerializationSettingsFactory.cs | 26 -- DesktopUI3/DUI3/Utils/Traversal.cs | 117 ------ 131 files changed, 1 insertion(+), 7730 deletions(-) delete mode 100644 ConnectorArcGIS/Bindings/BasicConnectorBinding.cs delete mode 100644 ConnectorArcGIS/Bindings/Factory.cs delete mode 100644 ConnectorArcGIS/Config.daml delete mode 100644 ConnectorArcGIS/ConnectorArcGIS.csproj delete mode 100644 ConnectorArcGIS/ConnectorArcGIS.sln delete mode 100644 ConnectorArcGIS/DarkImages/AddInDesktop16.png delete mode 100644 ConnectorArcGIS/DarkImages/AddInDesktop32.png delete mode 100644 ConnectorArcGIS/Images/AddInDesktop16.png delete mode 100644 ConnectorArcGIS/Images/AddInDesktop32.png delete mode 100644 ConnectorArcGIS/Properties/AssemblyInfo.cs delete mode 100644 ConnectorArcGIS/Properties/launchSettings.json delete mode 100644 ConnectorArcGIS/SpeckleDUI3.xaml delete mode 100644 ConnectorArcGIS/SpeckleDUI3.xaml.cs delete mode 100644 ConnectorArcGIS/SpeckleDUI3ViewModel.cs delete mode 100644 ConnectorArcGIS/SpeckleModule.cs delete mode 100644 ConnectorArcGIS/Utils/ArcGisDocumentStore.cs delete mode 100644 ConnectorArcGIS/app.config delete mode 100644 ConnectorAutocadCivil/AutocadCivilDUI3/Autocad2022/ConnectorAutocad2022DUI3.csproj delete mode 100644 ConnectorAutocadCivil/AutocadCivilDUI3/Autocad2023/ConnectorAutocad2023DUI3.csproj delete mode 100644 ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/AutocadCivilDUI3Shared.projitems delete mode 100644 ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/AutocadCivilDUI3Shared.shproj delete mode 100644 ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Bindings/BasicConnectorBindingAutocad.cs delete mode 100644 ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Bindings/Factory.cs delete mode 100644 ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Bindings/Filters.cs delete mode 100644 ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Bindings/ReceiveBinding.cs delete mode 100644 ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Bindings/SelectionBinding.cs delete mode 100644 ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Bindings/SendBinding.cs delete mode 100644 ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/DUI3PanelWebView.xaml delete mode 100644 ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/DUI3PanelWebView.xaml.cs delete mode 100644 ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Entry.cs delete mode 100644 ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Extensions/Editor.cs delete mode 100644 ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Extensions/Extends3d.cs delete mode 100644 ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Utils/AutocadDocumentManager.cs delete mode 100644 ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Utils/AutocadDocumentModelStore.cs delete mode 100644 ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Utils/AutocadIdleManager.cs delete mode 100644 ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Utils/Objects.cs delete mode 100644 ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Utils/TransactionContext.cs delete mode 100644 ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Utils/Utils.cs delete mode 100644 ConnectorRevit/RevitDUI3/Revit2020DUI3/Properties/launchSettings.json delete mode 100644 ConnectorRevit/RevitDUI3/Revit2020DUI3/Revit2020DUI3.csproj delete mode 100644 ConnectorRevit/RevitDUI3/Revit2023DUI3/Properties/launchSettings.json delete mode 100644 ConnectorRevit/RevitDUI3/Revit2023DUI3/Revit2023DUI3.csproj delete mode 100644 ConnectorRevit/RevitDUI3/RevitDUI3Shared/Bindings/BasicConnectorBindingRevit.cs delete mode 100644 ConnectorRevit/RevitDUI3/RevitDUI3Shared/Bindings/Factory.cs delete mode 100644 ConnectorRevit/RevitDUI3/RevitDUI3Shared/Bindings/Filters.cs delete mode 100644 ConnectorRevit/RevitDUI3/RevitDUI3Shared/Bindings/ReceiveBinding.cs delete mode 100644 ConnectorRevit/RevitDUI3/RevitDUI3Shared/Bindings/SelectionBinding.cs delete mode 100644 ConnectorRevit/RevitDUI3/RevitDUI3Shared/Bindings/SendBinding.cs delete mode 100644 ConnectorRevit/RevitDUI3/RevitDUI3Shared/CefSharpPanel.xaml delete mode 100644 ConnectorRevit/RevitDUI3/RevitDUI3Shared/CefSharpPanel.xaml.cs delete mode 100644 ConnectorRevit/RevitDUI3/RevitDUI3Shared/Entry.cs delete mode 100644 ConnectorRevit/RevitDUI3/RevitDUI3Shared/RevitDUI3Shared.projitems delete mode 100644 ConnectorRevit/RevitDUI3/RevitDUI3Shared/RevitDUI3Shared.shproj delete mode 100644 ConnectorRevit/RevitDUI3/RevitDUI3Shared/SpeckleRevit2DUI3.addin delete mode 100644 ConnectorRevit/RevitDUI3/RevitDUI3Shared/SpeckleRevitDUI3Command.cs delete mode 100644 ConnectorRevit/RevitDUI3/RevitDUI3Shared/Utils/PortedOverStuff.cs delete mode 100644 ConnectorRevit/RevitDUI3/RevitDUI3Shared/Utils/RevitAppProvider.cs delete mode 100644 ConnectorRevit/RevitDUI3/RevitDUI3Shared/Utils/RevitDocumentStore.cs delete mode 100644 ConnectorRevit/RevitDUI3/RevitDUI3Shared/Utils/RevitIdleManager.cs delete mode 100644 ConnectorRevit/RevitDUI3/RevitDUI3Shared/Utils/Schemas.cs delete mode 100644 ConnectorRhino/ConnectorRhinoWebUI/Bindings/BasicConnectorBinding.cs delete mode 100644 ConnectorRhino/ConnectorRhinoWebUI/Bindings/Factory.cs delete mode 100644 ConnectorRhino/ConnectorRhinoWebUI/Bindings/Filters.cs delete mode 100644 ConnectorRhino/ConnectorRhinoWebUI/Bindings/ReceiveBinding.cs delete mode 100644 ConnectorRhino/ConnectorRhinoWebUI/Bindings/SelectionBinding.cs delete mode 100644 ConnectorRhino/ConnectorRhinoWebUI/Bindings/SendBinding.cs delete mode 100644 ConnectorRhino/ConnectorRhinoWebUI/Commands.cs delete mode 100644 ConnectorRhino/ConnectorRhinoWebUI/ConnectorRhinoWebUI.csproj delete mode 100644 ConnectorRhino/ConnectorRhinoWebUI/EmbeddedResources/plugin-utility.ico delete mode 100644 ConnectorRhino/ConnectorRhinoWebUI/Extensions/BoundingBox.cs delete mode 100644 ConnectorRhino/ConnectorRhinoWebUI/PanelHosts.cs delete mode 100644 ConnectorRhino/ConnectorRhinoWebUI/Plugin.cs delete mode 100644 ConnectorRhino/ConnectorRhinoWebUI/Properties/AssemblyInfo.cs delete mode 100644 ConnectorRhino/ConnectorRhinoWebUI/Properties/launchSettings.json delete mode 100644 ConnectorRhino/ConnectorRhinoWebUI/SpeckleWebUiPanelWebView2.xaml.cs delete mode 100644 ConnectorRhino/ConnectorRhinoWebUI/Utils/RhinoDocumentStore.cs delete mode 100644 ConnectorRhino/ConnectorRhinoWebUI/Utils/RhinoIdleManager.cs delete mode 100644 ConnectorRhino/ConnectorRhinoWebUI/Utils/SpeckleRhinoObject.cs delete mode 100644 ConnectorRhino/ConnectorRhinoWebUI/Utils/Utils.cs delete mode 100644 ConnectorRhino/ConnectorRhinoWebUI/WebUIPanelCef.xaml delete mode 100644 ConnectorRhino/ConnectorRhinoWebUI/WebUIPanelCef.xaml.cs delete mode 100644 ConnectorRhino/ConnectorRhinoWebUI/WebUIPanelWebView2.xaml delete mode 100644 ConnectorRhino/ConnectorRhinoWebUI/WebUIPanelWebView2.xaml.cs delete mode 100644 DUI3-DX/Objects/Speckle.Objects.Revit/Speckle.Objects.Revit.csproj delete mode 100644 DUI3.slnf delete mode 100644 DesktopUI3/DUI3/Bindings/AccountBinding.cs delete mode 100644 DesktopUI3/DUI3/Bindings/ConfigBinding.cs delete mode 100644 DesktopUI3/DUI3/Bindings/IBasicConnectorBinding.cs delete mode 100644 DesktopUI3/DUI3/Bindings/IReceiveBinding.cs delete mode 100644 DesktopUI3/DUI3/Bindings/ISelectionBinding.cs delete mode 100644 DesktopUI3/DUI3/Bindings/ISendBinding.cs delete mode 100644 DesktopUI3/DUI3/Bindings/TestBinding.cs delete mode 100644 DesktopUI3/DUI3/Bridge.cs delete mode 100644 DesktopUI3/DUI3/BridgeV2.cs delete mode 100644 DesktopUI3/DUI3/Config/ConnectorConfig.cs delete mode 100644 DesktopUI3/DUI3/Config/GlobalConfig.cs delete mode 100644 DesktopUI3/DUI3/Config/UiConfig.cs delete mode 100644 DesktopUI3/DUI3/DUI3.csproj delete mode 100644 DesktopUI3/DUI3/Interfaces.cs delete mode 100644 DesktopUI3/DUI3/Models/Card/ModelCardError.cs delete mode 100644 DesktopUI3/DUI3/Models/Card/ModelCardNotification.cs delete mode 100644 DesktopUI3/DUI3/Models/Card/ModelCardProgress.cs delete mode 100644 DesktopUI3/DUI3/Models/ConversionReport.cs delete mode 100644 DesktopUI3/DUI3/Models/DocumentInfo.cs delete mode 100644 DesktopUI3/DUI3/Models/DocumentModelStore.cs delete mode 100644 DesktopUI3/DUI3/Models/Form.cs delete mode 100644 DesktopUI3/DUI3/Models/ModelCard.cs delete mode 100644 DesktopUI3/DUI3/Models/NotificationLevel.cs delete mode 100644 DesktopUI3/DUI3/Objects/ConversionContext.cs delete mode 100644 DesktopUI3/DUI3/Objects/ISpeckleHostObject.cs delete mode 100644 DesktopUI3/DUI3/Objects/ReportObject.cs delete mode 100644 DesktopUI3/DUI3/Objects/SpeckleHostObject.cs delete mode 100644 DesktopUI3/DUI3/Onboarding/Factory.cs delete mode 100644 DesktopUI3/DUI3/Onboarding/OnboardingData.cs delete mode 100644 DesktopUI3/DUI3/Operations/CancellationManager.cs delete mode 100644 DesktopUI3/DUI3/Operations/Operations.cs delete mode 100644 DesktopUI3/DUI3/Operations/Send.cs delete mode 100644 DesktopUI3/DUI3/Settings/CardSetting.cs delete mode 100644 DesktopUI3/DUI3/Utils/Accounts.cs delete mode 100644 DesktopUI3/DUI3/Utils/Converters.cs delete mode 100644 DesktopUI3/DUI3/Utils/DiscriminatedObject.cs delete mode 100644 DesktopUI3/DUI3/Utils/DiscriminatedObjectConverter.cs delete mode 100644 DesktopUI3/DUI3/Utils/Exceptions.cs delete mode 100644 DesktopUI3/DUI3/Utils/PropertyValidator.cs delete mode 100644 DesktopUI3/DUI3/Utils/SerializationSettingsFactory.cs delete mode 100644 DesktopUI3/DUI3/Utils/Traversal.cs diff --git a/All.sln b/All.sln index d747e01d5f..c2ad4123bf 100644 --- a/All.sln +++ b/All.sln @@ -430,30 +430,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BatchUploader.OperationDriv EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BatchUploader.Sdk", "ConnectorCore\BatchUploader.Sdk\BatchUploader.Sdk.csproj", "{2CC777EB-BD63-4FAB-BC3A-68A640D2E639}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ConnectorsDUI3", "ConnectorsDUI3", "{F1666772-262D-4577-976F-89A1C0E2D73E}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Rhino", "Rhino", "{1F00E9FB-6478-4350-A495-C5667D749832}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConnectorRhinoWebUI", "ConnectorRhino\ConnectorRhinoWebUI\ConnectorRhinoWebUI.csproj", "{CC672C3F-482D-4137-AF8A-D0EC67D0EA7D}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DUI3", "DesktopUI3\DUI3\DUI3.csproj", "{D93D6296-B138-4853-A505-F2AB11B551DB}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "AutocadCivil", "AutocadCivil", "{EA1F6DBC-41B6-4FA6-8A05-89FF91105543}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConnectorAutocad2023DUI3", "ConnectorAutocadCivil\AutocadCivilDUI3\Autocad2023\ConnectorAutocad2023DUI3.csproj", "{1E5C7198-1065-4015-ACB5-BDFA1DC43589}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConnectorAutocad2022DUI3", "ConnectorAutocadCivil\AutocadCivilDUI3\Autocad2022\ConnectorAutocad2022DUI3.csproj", "{5698290F-250F-4336-ADF8-F269A36D1178}" -EndProject -Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "AutocadCivilDUI3Shared", "ConnectorAutocadCivil\AutocadCivilDUI3\AutocadCivilDUI3Shared\AutocadCivilDUI3Shared.shproj", "{2BDE80E8-5F26-4E57-BBA6-109120F5D4EE}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Revit", "Revit", "{047CA18F-AD79-4C31-985D-EEA8E070985D}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Revit2020DUI3", "ConnectorRevit\RevitDUI3\Revit2020DUI3\Revit2020DUI3.csproj", "{2113F03B-BB8D-470B-A9A1-97BB9A554A44}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Revit2023DUI3", "ConnectorRevit\RevitDUI3\Revit2023DUI3\Revit2023DUI3.csproj", "{A364B196-38A3-45AB-A54A-F04D17C0B2DA}" -EndProject -Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "RevitDUI3Shared", "ConnectorRevit\RevitDUI3\RevitDUI3Shared\RevitDUI3Shared.shproj", "{3D7F0278-6CF2-4588-A101-4027ABB8B87F}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConnectorRhino8", "ConnectorRhino\ConnectorRhino8\ConnectorRhino8.csproj", "{D22A887D-976C-4DBF-AE5B-9039F169E61C}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConverterRhino8", "Objects\Converters\ConverterRhinoGh\ConverterRhino8\ConverterRhino8.csproj", "{89996067-3233-410A-A6A1-39E2F11F0626}" @@ -473,10 +449,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConnectorGrasshopper8", "Co EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConverterGrasshopper8", "Objects\Converters\ConverterRhinoGh\ConverterGrasshopper8\ConverterGrasshopper8.csproj", "{15C4FF29-0370-4860-B80A-06CC5E0E8D5F}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ArcGIS", "ArcGIS", "{738FB542-F186-4473-8B70-B08D7EDC1EFD}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConnectorArcGIS", "ConnectorArcGIS\ConnectorArcGIS.csproj", "{63A209B9-3BBA-465C-8D8C-DC9E1F7D379D}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{8A909E95-7A39-4B21-A04A-E168478E71F0}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Objects.Tests.Unit", "Objects\Tests\Objects.Tests.Unit\Objects.Tests.Unit.csproj", "{9E74F0E6-94B4-46BD-B1CA-DD874B459399}" @@ -496,8 +468,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Revit", "Revit", "{4838C66E EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Connectors", "Connectors", "{33D19E88-F3AE-4D28-B588-D91CCF9E3BA8}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Objects", "Objects", "{B92E6216-2CBA-4EA5-B94B-0A7658C7F84B}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Converters", "Converters", "{1FE3C60E-7865-40A5-9794-55ECB64F6489}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "DUI3", "DUI3", "{FD4D6594-D81E-456F-8F2E-35B09E04A755}" @@ -518,10 +488,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Speckle.Converters.Revit202 EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Speckle.Connectors.DUI", "DUI3-DX\DUI3\Speckle.Connectors.DUI\Speckle.Connectors.DUI.csproj", "{D81C0B87-F0C1-4297-A147-02F001FB7E1E}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Speckle.Objects.Common", "DUI3-DX\Objects\Speckle.Objects.Common\Speckle.Objects.Common.csproj", "{CC968B23-CEED-4543-8629-808F7E66E815}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Speckle.Objects.Revit", "DUI3-DX\Objects\Speckle.Objects.Revit\Speckle.Objects.Revit.csproj", "{01E762F1-C176-40B9-BA3E-9B1FECAF04FF}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Speckle.Autofac", "DUI3-DX\Sdk\Speckle.Autofac\Speckle.Autofac.csproj", "{C9D4CA21-182B-4ED2-81BB-280A6FD713F6}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Speckle.Connectors.Utils", "DUI3-DX\Sdk\Speckle.Connectors.Utils\Speckle.Connectors.Utils.csproj", "{7291B93C-615D-42DE-B8C1-3F9DF643E0FC}" @@ -2248,102 +2214,6 @@ Global {2CC777EB-BD63-4FAB-BC3A-68A640D2E639}.Release|Any CPU.Build.0 = Release|Any CPU {2CC777EB-BD63-4FAB-BC3A-68A640D2E639}.Release|x64.ActiveCfg = Release|Any CPU {2CC777EB-BD63-4FAB-BC3A-68A640D2E639}.Release|x64.Build.0 = Release|Any CPU - {CC672C3F-482D-4137-AF8A-D0EC67D0EA7D}.Debug Mac|Any CPU.ActiveCfg = Debug|Any CPU - {CC672C3F-482D-4137-AF8A-D0EC67D0EA7D}.Debug Mac|Any CPU.Build.0 = Debug|Any CPU - {CC672C3F-482D-4137-AF8A-D0EC67D0EA7D}.Debug Mac|x64.ActiveCfg = Debug|Any CPU - {CC672C3F-482D-4137-AF8A-D0EC67D0EA7D}.Debug Mac|x64.Build.0 = Debug|Any CPU - {CC672C3F-482D-4137-AF8A-D0EC67D0EA7D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {CC672C3F-482D-4137-AF8A-D0EC67D0EA7D}.Debug|Any CPU.Build.0 = Debug|Any CPU - {CC672C3F-482D-4137-AF8A-D0EC67D0EA7D}.Debug|x64.ActiveCfg = Debug|Any CPU - {CC672C3F-482D-4137-AF8A-D0EC67D0EA7D}.Debug|x64.Build.0 = Debug|Any CPU - {CC672C3F-482D-4137-AF8A-D0EC67D0EA7D}.Release Mac|Any CPU.ActiveCfg = Debug|Any CPU - {CC672C3F-482D-4137-AF8A-D0EC67D0EA7D}.Release Mac|Any CPU.Build.0 = Debug|Any CPU - {CC672C3F-482D-4137-AF8A-D0EC67D0EA7D}.Release Mac|x64.ActiveCfg = Debug|Any CPU - {CC672C3F-482D-4137-AF8A-D0EC67D0EA7D}.Release Mac|x64.Build.0 = Debug|Any CPU - {CC672C3F-482D-4137-AF8A-D0EC67D0EA7D}.Release|Any CPU.ActiveCfg = Release|Any CPU - {CC672C3F-482D-4137-AF8A-D0EC67D0EA7D}.Release|Any CPU.Build.0 = Release|Any CPU - {CC672C3F-482D-4137-AF8A-D0EC67D0EA7D}.Release|x64.ActiveCfg = Release|Any CPU - {CC672C3F-482D-4137-AF8A-D0EC67D0EA7D}.Release|x64.Build.0 = Release|Any CPU - {D93D6296-B138-4853-A505-F2AB11B551DB}.Debug Mac|Any CPU.ActiveCfg = Debug|Any CPU - {D93D6296-B138-4853-A505-F2AB11B551DB}.Debug Mac|Any CPU.Build.0 = Debug|Any CPU - {D93D6296-B138-4853-A505-F2AB11B551DB}.Debug Mac|x64.ActiveCfg = Debug|Any CPU - {D93D6296-B138-4853-A505-F2AB11B551DB}.Debug Mac|x64.Build.0 = Debug|Any CPU - {D93D6296-B138-4853-A505-F2AB11B551DB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {D93D6296-B138-4853-A505-F2AB11B551DB}.Debug|Any CPU.Build.0 = Debug|Any CPU - {D93D6296-B138-4853-A505-F2AB11B551DB}.Debug|x64.ActiveCfg = Debug|x64 - {D93D6296-B138-4853-A505-F2AB11B551DB}.Debug|x64.Build.0 = Debug|x64 - {D93D6296-B138-4853-A505-F2AB11B551DB}.Release Mac|Any CPU.ActiveCfg = Debug|Any CPU - {D93D6296-B138-4853-A505-F2AB11B551DB}.Release Mac|Any CPU.Build.0 = Debug|Any CPU - {D93D6296-B138-4853-A505-F2AB11B551DB}.Release Mac|x64.ActiveCfg = Debug|Any CPU - {D93D6296-B138-4853-A505-F2AB11B551DB}.Release Mac|x64.Build.0 = Debug|Any CPU - {D93D6296-B138-4853-A505-F2AB11B551DB}.Release|Any CPU.ActiveCfg = Release|Any CPU - {D93D6296-B138-4853-A505-F2AB11B551DB}.Release|Any CPU.Build.0 = Release|Any CPU - {D93D6296-B138-4853-A505-F2AB11B551DB}.Release|x64.ActiveCfg = Release|Any CPU - {D93D6296-B138-4853-A505-F2AB11B551DB}.Release|x64.Build.0 = Release|Any CPU - {1E5C7198-1065-4015-ACB5-BDFA1DC43589}.Debug Mac|Any CPU.ActiveCfg = Debug|Any CPU - {1E5C7198-1065-4015-ACB5-BDFA1DC43589}.Debug Mac|Any CPU.Build.0 = Debug|Any CPU - {1E5C7198-1065-4015-ACB5-BDFA1DC43589}.Debug Mac|x64.ActiveCfg = Debug|Any CPU - {1E5C7198-1065-4015-ACB5-BDFA1DC43589}.Debug Mac|x64.Build.0 = Debug|Any CPU - {1E5C7198-1065-4015-ACB5-BDFA1DC43589}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {1E5C7198-1065-4015-ACB5-BDFA1DC43589}.Debug|Any CPU.Build.0 = Debug|Any CPU - {1E5C7198-1065-4015-ACB5-BDFA1DC43589}.Debug|x64.ActiveCfg = Debug|Any CPU - {1E5C7198-1065-4015-ACB5-BDFA1DC43589}.Debug|x64.Build.0 = Debug|Any CPU - {1E5C7198-1065-4015-ACB5-BDFA1DC43589}.Release Mac|Any CPU.ActiveCfg = Debug|Any CPU - {1E5C7198-1065-4015-ACB5-BDFA1DC43589}.Release Mac|Any CPU.Build.0 = Debug|Any CPU - {1E5C7198-1065-4015-ACB5-BDFA1DC43589}.Release Mac|x64.ActiveCfg = Debug|Any CPU - {1E5C7198-1065-4015-ACB5-BDFA1DC43589}.Release Mac|x64.Build.0 = Debug|Any CPU - {1E5C7198-1065-4015-ACB5-BDFA1DC43589}.Release|Any CPU.ActiveCfg = Release|Any CPU - {1E5C7198-1065-4015-ACB5-BDFA1DC43589}.Release|Any CPU.Build.0 = Release|Any CPU - {1E5C7198-1065-4015-ACB5-BDFA1DC43589}.Release|x64.ActiveCfg = Release|Any CPU - {1E5C7198-1065-4015-ACB5-BDFA1DC43589}.Release|x64.Build.0 = Release|Any CPU - {5698290F-250F-4336-ADF8-F269A36D1178}.Debug Mac|Any CPU.ActiveCfg = Debug|Any CPU - {5698290F-250F-4336-ADF8-F269A36D1178}.Debug Mac|Any CPU.Build.0 = Debug|Any CPU - {5698290F-250F-4336-ADF8-F269A36D1178}.Debug Mac|x64.ActiveCfg = Debug|Any CPU - {5698290F-250F-4336-ADF8-F269A36D1178}.Debug Mac|x64.Build.0 = Debug|Any CPU - {5698290F-250F-4336-ADF8-F269A36D1178}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {5698290F-250F-4336-ADF8-F269A36D1178}.Debug|Any CPU.Build.0 = Debug|Any CPU - {5698290F-250F-4336-ADF8-F269A36D1178}.Debug|x64.ActiveCfg = Debug|Any CPU - {5698290F-250F-4336-ADF8-F269A36D1178}.Debug|x64.Build.0 = Debug|Any CPU - {5698290F-250F-4336-ADF8-F269A36D1178}.Release Mac|Any CPU.ActiveCfg = Debug|Any CPU - {5698290F-250F-4336-ADF8-F269A36D1178}.Release Mac|Any CPU.Build.0 = Debug|Any CPU - {5698290F-250F-4336-ADF8-F269A36D1178}.Release Mac|x64.ActiveCfg = Debug|Any CPU - {5698290F-250F-4336-ADF8-F269A36D1178}.Release Mac|x64.Build.0 = Debug|Any CPU - {5698290F-250F-4336-ADF8-F269A36D1178}.Release|Any CPU.ActiveCfg = Release|Any CPU - {5698290F-250F-4336-ADF8-F269A36D1178}.Release|Any CPU.Build.0 = Release|Any CPU - {5698290F-250F-4336-ADF8-F269A36D1178}.Release|x64.ActiveCfg = Release|Any CPU - {5698290F-250F-4336-ADF8-F269A36D1178}.Release|x64.Build.0 = Release|Any CPU - {2113F03B-BB8D-470B-A9A1-97BB9A554A44}.Debug Mac|Any CPU.ActiveCfg = Debug|Any CPU - {2113F03B-BB8D-470B-A9A1-97BB9A554A44}.Debug Mac|Any CPU.Build.0 = Debug|Any CPU - {2113F03B-BB8D-470B-A9A1-97BB9A554A44}.Debug Mac|x64.ActiveCfg = Debug|Any CPU - {2113F03B-BB8D-470B-A9A1-97BB9A554A44}.Debug Mac|x64.Build.0 = Debug|Any CPU - {2113F03B-BB8D-470B-A9A1-97BB9A554A44}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {2113F03B-BB8D-470B-A9A1-97BB9A554A44}.Debug|Any CPU.Build.0 = Debug|Any CPU - {2113F03B-BB8D-470B-A9A1-97BB9A554A44}.Debug|x64.ActiveCfg = Debug|Any CPU - {2113F03B-BB8D-470B-A9A1-97BB9A554A44}.Debug|x64.Build.0 = Debug|Any CPU - {2113F03B-BB8D-470B-A9A1-97BB9A554A44}.Release Mac|Any CPU.ActiveCfg = Debug|Any CPU - {2113F03B-BB8D-470B-A9A1-97BB9A554A44}.Release Mac|Any CPU.Build.0 = Debug|Any CPU - {2113F03B-BB8D-470B-A9A1-97BB9A554A44}.Release Mac|x64.ActiveCfg = Debug|Any CPU - {2113F03B-BB8D-470B-A9A1-97BB9A554A44}.Release Mac|x64.Build.0 = Debug|Any CPU - {2113F03B-BB8D-470B-A9A1-97BB9A554A44}.Release|Any CPU.ActiveCfg = Release|Any CPU - {2113F03B-BB8D-470B-A9A1-97BB9A554A44}.Release|Any CPU.Build.0 = Release|Any CPU - {2113F03B-BB8D-470B-A9A1-97BB9A554A44}.Release|x64.ActiveCfg = Release|x64 - {2113F03B-BB8D-470B-A9A1-97BB9A554A44}.Release|x64.Build.0 = Release|x64 - {A364B196-38A3-45AB-A54A-F04D17C0B2DA}.Debug Mac|Any CPU.ActiveCfg = Debug|Any CPU - {A364B196-38A3-45AB-A54A-F04D17C0B2DA}.Debug Mac|Any CPU.Build.0 = Debug|Any CPU - {A364B196-38A3-45AB-A54A-F04D17C0B2DA}.Debug Mac|x64.ActiveCfg = Debug|Any CPU - {A364B196-38A3-45AB-A54A-F04D17C0B2DA}.Debug Mac|x64.Build.0 = Debug|Any CPU - {A364B196-38A3-45AB-A54A-F04D17C0B2DA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {A364B196-38A3-45AB-A54A-F04D17C0B2DA}.Debug|Any CPU.Build.0 = Debug|Any CPU - {A364B196-38A3-45AB-A54A-F04D17C0B2DA}.Debug|x64.ActiveCfg = Debug|x64 - {A364B196-38A3-45AB-A54A-F04D17C0B2DA}.Debug|x64.Build.0 = Debug|x64 - {A364B196-38A3-45AB-A54A-F04D17C0B2DA}.Release Mac|Any CPU.ActiveCfg = Debug|Any CPU - {A364B196-38A3-45AB-A54A-F04D17C0B2DA}.Release Mac|Any CPU.Build.0 = Debug|Any CPU - {A364B196-38A3-45AB-A54A-F04D17C0B2DA}.Release Mac|x64.ActiveCfg = Debug|Any CPU - {A364B196-38A3-45AB-A54A-F04D17C0B2DA}.Release Mac|x64.Build.0 = Debug|Any CPU - {A364B196-38A3-45AB-A54A-F04D17C0B2DA}.Release|Any CPU.ActiveCfg = Release|Any CPU - {A364B196-38A3-45AB-A54A-F04D17C0B2DA}.Release|Any CPU.Build.0 = Release|Any CPU - {A364B196-38A3-45AB-A54A-F04D17C0B2DA}.Release|x64.ActiveCfg = Release|x64 - {A364B196-38A3-45AB-A54A-F04D17C0B2DA}.Release|x64.Build.0 = Release|x64 {D22A887D-976C-4DBF-AE5B-9039F169E61C}.Debug Mac|Any CPU.ActiveCfg = Debug Mac|Any CPU {D22A887D-976C-4DBF-AE5B-9039F169E61C}.Debug Mac|x64.ActiveCfg = Debug|Any CPU {D22A887D-976C-4DBF-AE5B-9039F169E61C}.Debug Mac|x64.Build.0 = Debug|Any CPU @@ -2448,22 +2318,6 @@ Global {15C4FF29-0370-4860-B80A-06CC5E0E8D5F}.Release|Any CPU.Build.0 = Release|Any CPU {15C4FF29-0370-4860-B80A-06CC5E0E8D5F}.Release|x64.ActiveCfg = Release|Any CPU {15C4FF29-0370-4860-B80A-06CC5E0E8D5F}.Release|x64.Build.0 = Release|Any CPU - {63A209B9-3BBA-465C-8D8C-DC9E1F7D379D}.Debug Mac|Any CPU.ActiveCfg = Debug|Any CPU - {63A209B9-3BBA-465C-8D8C-DC9E1F7D379D}.Debug Mac|Any CPU.Build.0 = Debug|Any CPU - {63A209B9-3BBA-465C-8D8C-DC9E1F7D379D}.Debug Mac|x64.ActiveCfg = Debug|Any CPU - {63A209B9-3BBA-465C-8D8C-DC9E1F7D379D}.Debug Mac|x64.Build.0 = Debug|Any CPU - {63A209B9-3BBA-465C-8D8C-DC9E1F7D379D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {63A209B9-3BBA-465C-8D8C-DC9E1F7D379D}.Debug|Any CPU.Build.0 = Debug|Any CPU - {63A209B9-3BBA-465C-8D8C-DC9E1F7D379D}.Debug|x64.ActiveCfg = Debug|Any CPU - {63A209B9-3BBA-465C-8D8C-DC9E1F7D379D}.Debug|x64.Build.0 = Debug|Any CPU - {63A209B9-3BBA-465C-8D8C-DC9E1F7D379D}.Release Mac|Any CPU.ActiveCfg = Debug|Any CPU - {63A209B9-3BBA-465C-8D8C-DC9E1F7D379D}.Release Mac|Any CPU.Build.0 = Debug|Any CPU - {63A209B9-3BBA-465C-8D8C-DC9E1F7D379D}.Release Mac|x64.ActiveCfg = Debug|Any CPU - {63A209B9-3BBA-465C-8D8C-DC9E1F7D379D}.Release Mac|x64.Build.0 = Debug|Any CPU - {63A209B9-3BBA-465C-8D8C-DC9E1F7D379D}.Release|Any CPU.ActiveCfg = Release|Any CPU - {63A209B9-3BBA-465C-8D8C-DC9E1F7D379D}.Release|Any CPU.Build.0 = Release|Any CPU - {63A209B9-3BBA-465C-8D8C-DC9E1F7D379D}.Release|x64.ActiveCfg = Release|Any CPU - {63A209B9-3BBA-465C-8D8C-DC9E1F7D379D}.Release|x64.Build.0 = Release|Any CPU {9E74F0E6-94B4-46BD-B1CA-DD874B459399}.Debug Mac|Any CPU.ActiveCfg = Debug|Any CPU {9E74F0E6-94B4-46BD-B1CA-DD874B459399}.Debug Mac|Any CPU.Build.0 = Debug|Any CPU {9E74F0E6-94B4-46BD-B1CA-DD874B459399}.Debug Mac|x64.ActiveCfg = Debug|Any CPU @@ -2592,38 +2446,6 @@ Global {D81C0B87-F0C1-4297-A147-02F001FB7E1E}.Release|Any CPU.Build.0 = Release|Any CPU {D81C0B87-F0C1-4297-A147-02F001FB7E1E}.Release|x64.ActiveCfg = Release|Any CPU {D81C0B87-F0C1-4297-A147-02F001FB7E1E}.Release|x64.Build.0 = Release|Any CPU - {CC968B23-CEED-4543-8629-808F7E66E815}.Debug Mac|Any CPU.ActiveCfg = Debug|Any CPU - {CC968B23-CEED-4543-8629-808F7E66E815}.Debug Mac|Any CPU.Build.0 = Debug|Any CPU - {CC968B23-CEED-4543-8629-808F7E66E815}.Debug Mac|x64.ActiveCfg = Debug|Any CPU - {CC968B23-CEED-4543-8629-808F7E66E815}.Debug Mac|x64.Build.0 = Debug|Any CPU - {CC968B23-CEED-4543-8629-808F7E66E815}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {CC968B23-CEED-4543-8629-808F7E66E815}.Debug|Any CPU.Build.0 = Debug|Any CPU - {CC968B23-CEED-4543-8629-808F7E66E815}.Debug|x64.ActiveCfg = Debug|x64 - {CC968B23-CEED-4543-8629-808F7E66E815}.Debug|x64.Build.0 = Debug|x64 - {CC968B23-CEED-4543-8629-808F7E66E815}.Release Mac|Any CPU.ActiveCfg = Release|Any CPU - {CC968B23-CEED-4543-8629-808F7E66E815}.Release Mac|Any CPU.Build.0 = Release|Any CPU - {CC968B23-CEED-4543-8629-808F7E66E815}.Release Mac|x64.ActiveCfg = Release|Any CPU - {CC968B23-CEED-4543-8629-808F7E66E815}.Release Mac|x64.Build.0 = Release|Any CPU - {CC968B23-CEED-4543-8629-808F7E66E815}.Release|Any CPU.ActiveCfg = Release|Any CPU - {CC968B23-CEED-4543-8629-808F7E66E815}.Release|Any CPU.Build.0 = Release|Any CPU - {CC968B23-CEED-4543-8629-808F7E66E815}.Release|x64.ActiveCfg = Release|Any CPU - {CC968B23-CEED-4543-8629-808F7E66E815}.Release|x64.Build.0 = Release|Any CPU - {01E762F1-C176-40B9-BA3E-9B1FECAF04FF}.Debug Mac|Any CPU.ActiveCfg = Debug|Any CPU - {01E762F1-C176-40B9-BA3E-9B1FECAF04FF}.Debug Mac|Any CPU.Build.0 = Debug|Any CPU - {01E762F1-C176-40B9-BA3E-9B1FECAF04FF}.Debug Mac|x64.ActiveCfg = Debug|Any CPU - {01E762F1-C176-40B9-BA3E-9B1FECAF04FF}.Debug Mac|x64.Build.0 = Debug|Any CPU - {01E762F1-C176-40B9-BA3E-9B1FECAF04FF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {01E762F1-C176-40B9-BA3E-9B1FECAF04FF}.Debug|Any CPU.Build.0 = Debug|Any CPU - {01E762F1-C176-40B9-BA3E-9B1FECAF04FF}.Debug|x64.ActiveCfg = Debug|x64 - {01E762F1-C176-40B9-BA3E-9B1FECAF04FF}.Debug|x64.Build.0 = Debug|x64 - {01E762F1-C176-40B9-BA3E-9B1FECAF04FF}.Release Mac|Any CPU.ActiveCfg = Release|Any CPU - {01E762F1-C176-40B9-BA3E-9B1FECAF04FF}.Release Mac|Any CPU.Build.0 = Release|Any CPU - {01E762F1-C176-40B9-BA3E-9B1FECAF04FF}.Release Mac|x64.ActiveCfg = Release|Any CPU - {01E762F1-C176-40B9-BA3E-9B1FECAF04FF}.Release Mac|x64.Build.0 = Release|Any CPU - {01E762F1-C176-40B9-BA3E-9B1FECAF04FF}.Release|Any CPU.ActiveCfg = Release|Any CPU - {01E762F1-C176-40B9-BA3E-9B1FECAF04FF}.Release|Any CPU.Build.0 = Release|Any CPU - {01E762F1-C176-40B9-BA3E-9B1FECAF04FF}.Release|x64.ActiveCfg = Release|Any CPU - {01E762F1-C176-40B9-BA3E-9B1FECAF04FF}.Release|x64.Build.0 = Release|Any CPU {C9D4CA21-182B-4ED2-81BB-280A6FD713F6}.Debug Mac|Any CPU.ActiveCfg = Debug|Any CPU {C9D4CA21-182B-4ED2-81BB-280A6FD713F6}.Debug Mac|Any CPU.Build.0 = Debug|Any CPU {C9D4CA21-182B-4ED2-81BB-280A6FD713F6}.Debug Mac|x64.ActiveCfg = Debug|Any CPU @@ -3006,17 +2828,6 @@ Global {A0C9EBE0-A56A-4D07-B6EF-2EEAEC45D6C4} = {C6FF0E4F-38A3-4464-98E9-AB71D74B06F4} {7F0206A9-61D4-4D3A-9B43-789DABA7C143} = {DA9DFC36-C53F-4B19-8911-BF7605230BA7} {2CC777EB-BD63-4FAB-BC3A-68A640D2E639} = {DA9DFC36-C53F-4B19-8911-BF7605230BA7} - {1F00E9FB-6478-4350-A495-C5667D749832} = {F1666772-262D-4577-976F-89A1C0E2D73E} - {CC672C3F-482D-4137-AF8A-D0EC67D0EA7D} = {1F00E9FB-6478-4350-A495-C5667D749832} - {D93D6296-B138-4853-A505-F2AB11B551DB} = {F1666772-262D-4577-976F-89A1C0E2D73E} - {EA1F6DBC-41B6-4FA6-8A05-89FF91105543} = {F1666772-262D-4577-976F-89A1C0E2D73E} - {1E5C7198-1065-4015-ACB5-BDFA1DC43589} = {EA1F6DBC-41B6-4FA6-8A05-89FF91105543} - {5698290F-250F-4336-ADF8-F269A36D1178} = {EA1F6DBC-41B6-4FA6-8A05-89FF91105543} - {2BDE80E8-5F26-4E57-BBA6-109120F5D4EE} = {EA1F6DBC-41B6-4FA6-8A05-89FF91105543} - {047CA18F-AD79-4C31-985D-EEA8E070985D} = {F1666772-262D-4577-976F-89A1C0E2D73E} - {2113F03B-BB8D-470B-A9A1-97BB9A554A44} = {047CA18F-AD79-4C31-985D-EEA8E070985D} - {A364B196-38A3-45AB-A54A-F04D17C0B2DA} = {047CA18F-AD79-4C31-985D-EEA8E070985D} - {3D7F0278-6CF2-4588-A101-4027ABB8B87F} = {047CA18F-AD79-4C31-985D-EEA8E070985D} {D22A887D-976C-4DBF-AE5B-9039F169E61C} = {E94E7327-5A9B-48EE-93CC-E9E9A5B980F1} {89996067-3233-410A-A6A1-39E2F11F0626} = {1FD850CA-A8D7-41DC-9316-B315800437E1} {5009BB59-0F77-4202-8FD2-DECC07E93146} = {8AA78EE8-C33B-4BC5-992A-E5DE7AB0BEC7} @@ -3025,8 +2836,6 @@ Global {FB2DEE1D-788B-45B6-B80C-D8F7C8390C37} = {5009BB59-0F77-4202-8FD2-DECC07E93146} {FDBC3082-1FAD-4701-A121-802F591D2D35} = {9461B162-AD2F-4F60-BCE4-E72DCEFD4608} {15C4FF29-0370-4860-B80A-06CC5E0E8D5F} = {1FD850CA-A8D7-41DC-9316-B315800437E1} - {738FB542-F186-4473-8B70-B08D7EDC1EFD} = {F1666772-262D-4577-976F-89A1C0E2D73E} - {63A209B9-3BBA-465C-8D8C-DC9E1F7D379D} = {738FB542-F186-4473-8B70-B08D7EDC1EFD} {8A909E95-7A39-4B21-A04A-E168478E71F0} = {E3916A0F-68D5-4C84-ACAE-41547F75E454} {9E74F0E6-94B4-46BD-B1CA-DD874B459399} = {8A909E95-7A39-4B21-A04A-E168478E71F0} {0B6B5C52-54EC-461F-8729-6244ACA63646} = {B6C38DB9-7B20-4B7E-BC90-6A8CAFC16807} @@ -3034,7 +2843,6 @@ Global {0D23858F-4CC1-4DCA-9207-5EDB8B6CE9DD} = {DA9DFC36-C53F-4B19-8911-BF7605230BA7} {4838C66E-8677-4FBD-9609-25376042E981} = {33D19E88-F3AE-4D28-B588-D91CCF9E3BA8} {33D19E88-F3AE-4D28-B588-D91CCF9E3BA8} = {9DB74760-01DE-4AC1-A81B-BC7784351D22} - {B92E6216-2CBA-4EA5-B94B-0A7658C7F84B} = {9DB74760-01DE-4AC1-A81B-BC7784351D22} {1FE3C60E-7865-40A5-9794-55ECB64F6489} = {9DB74760-01DE-4AC1-A81B-BC7784351D22} {FD4D6594-D81E-456F-8F2E-35B09E04A755} = {9DB74760-01DE-4AC1-A81B-BC7784351D22} {D92751C8-1039-4005-90B2-913E55E0B8BD} = {1FE3C60E-7865-40A5-9794-55ECB64F6489} @@ -3045,8 +2853,6 @@ Global {83EAD6F0-3CB3-456A-AD81-072127D0DE0E} = {D92751C8-1039-4005-90B2-913E55E0B8BD} {26391930-F86F-47E0-A5F6-B89919E38CE1} = {D92751C8-1039-4005-90B2-913E55E0B8BD} {D81C0B87-F0C1-4297-A147-02F001FB7E1E} = {FD4D6594-D81E-456F-8F2E-35B09E04A755} - {CC968B23-CEED-4543-8629-808F7E66E815} = {B92E6216-2CBA-4EA5-B94B-0A7658C7F84B} - {01E762F1-C176-40B9-BA3E-9B1FECAF04FF} = {B92E6216-2CBA-4EA5-B94B-0A7658C7F84B} {C9D4CA21-182B-4ED2-81BB-280A6FD713F6} = {2E00592E-558D-492D-88F9-3ECEE4C0C7DA} {7291B93C-615D-42DE-B8C1-3F9DF643E0FC} = {2E00592E-558D-492D-88F9-3ECEE4C0C7DA} {8AEF06C0-CA5C-4460-BC2D-ADE5F35D0434} = {2E00592E-558D-492D-88F9-3ECEE4C0C7DA} diff --git a/ConnectorArcGIS/Bindings/BasicConnectorBinding.cs b/ConnectorArcGIS/Bindings/BasicConnectorBinding.cs deleted file mode 100644 index 9c93e75973..0000000000 --- a/ConnectorArcGIS/Bindings/BasicConnectorBinding.cs +++ /dev/null @@ -1,55 +0,0 @@ -using System.Reflection; -using ConnectorArcGIS.Utils; -using DUI3; -using DUI3.Bindings; -using DUI3.Models; -using Sentry.Reflection; - -namespace ConnectorArcGIS.Bindings; - -public class BasicConnectorBinding : IBasicConnectorBinding -{ - public string Name { get; set; } = "baseBinding"; - public IBridge Parent { get; set; } - - private readonly ArcGisDocumentStore _store; - - public BasicConnectorBinding(ArcGisDocumentStore store) - { - _store = store; - } - - public string GetSourceApplicationName() => "ArcGIS"; - - public string GetSourceApplicationVersion() => "3"; - - public string GetConnectorVersion() => - typeof(BasicConnectorBinding).Assembly.GetNameAndVersion().Version ?? "No version"; - - // TODO - public DocumentInfo GetDocumentInfo() => - new() - { - Location = "", - Name = "", - Id = "" - }; - - public DocumentModelStore GetDocumentState() => _store; - - public void AddModel(ModelCard model) => _store.Models.Add(model); - - public void UpdateModel(ModelCard model) - { - int idx = _store.Models.FindIndex(m => model.Id == m.Id); - _store.Models[idx] = model; - } - - public void RemoveModel(ModelCard model) - { - int index = _store.Models.FindIndex(m => m.Id == model.Id); - _store.Models.RemoveAt(index); - } - - public void HighlightModel(string modelCardId) => throw new System.NotImplementedException(); -} diff --git a/ConnectorArcGIS/Bindings/Factory.cs b/ConnectorArcGIS/Bindings/Factory.cs deleted file mode 100644 index 962b27520d..0000000000 --- a/ConnectorArcGIS/Bindings/Factory.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System.Collections.Generic; -using ConnectorArcGIS.Utils; -using DUI3; -using DUI3.Bindings; - -namespace ConnectorArcGIS.Bindings; - -public static class Factory -{ - private static readonly ArcGisDocumentStore s_store = new(); - - public static List CreateBindings() - { - BasicConnectorBinding baseBindings = new(s_store); - List bindingsList = - new() { new ConfigBinding("ArcGIS"), new AccountBinding(), new TestBinding(), baseBindings }; - - return bindingsList; - } -} diff --git a/ConnectorArcGIS/Config.daml b/ConnectorArcGIS/Config.daml deleted file mode 100644 index e4fd5de1d8..0000000000 --- a/ConnectorArcGIS/Config.daml +++ /dev/null @@ -1,67 +0,0 @@ - - - - - Speckle - Speckle connector for ArcGIS - Images\AddinDesktop32.png - Speckle Systems - Speckle Systems - 8/5/2021 12:24:21 PM - Framework - - - - - - - - - - - - - - - - - - - - - - diff --git a/ConnectorArcGIS/ConnectorArcGIS.csproj b/ConnectorArcGIS/ConnectorArcGIS.csproj deleted file mode 100644 index 092b314a29..0000000000 --- a/ConnectorArcGIS/ConnectorArcGIS.csproj +++ /dev/null @@ -1,117 +0,0 @@ - - - - net6.0-windows - win10-x64 - false - true - false - 1591;CA1416 - true - true - 10 - AnyCPU - - - - C:\Program Files\ArcGIS\Pro\bin\Microsoft.Web.WebView2.Core.dll - False - False - - - C:\Program Files\ArcGIS\Pro\bin\Microsoft.Web.WebView2.Wpf.dll - False - False - - - C:\Program Files\ArcGIS\Pro\bin\ArcGIS.Desktop.Framework.dll - false - True - - - C:\Program Files\ArcGIS\Pro\bin\ArcGIS.Core.dll - False - False - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\Core\ArcGIS.Desktop.Core.dll - False - False - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\Mapping\ArcGIS.Desktop.Mapping.dll - False - False - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\Catalog\ArcGIS.Desktop.Catalog.dll - False - False - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\Editing\ArcGIS.Desktop.Editing.dll - False - False - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\DesktopExtensions\ArcGIS.Desktop.Extensions.dll - false - True - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\GeoProcessing\ArcGIS.Desktop.GeoProcessing.dll - False - False - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\Layout\ArcGIS.Desktop.Layouts.dll - False - False - - - C:\Program Files\ArcGIS\Pro\bin\ArcGIS.Desktop.Shared.Wpf.dll - False - False - - - C:\Program Files\ArcGIS\Pro\bin\ArcGIS.Desktop.Ribbon.Wpf.dll - False - False - - - C:\Program Files\ArcGIS\Pro\bin\ArcGIS.Desktop.DataGrid.Contrib.Wpf.dll - False - False - - - C:\Program Files\ArcGIS\Pro\bin\ArcGIS.Desktop.Resources.dll - false - True - - - C:\Program Files\ArcGIS\Pro\bin\ArcGIS.Desktop.Resources.dll - False - False - - - C:\Program Files\ArcGIS\Pro\bin\ESRI.ArcGIS.ItemIndex.dll - False - False - - - - - - - - - - - - - - - - - - diff --git a/ConnectorArcGIS/ConnectorArcGIS.sln b/ConnectorArcGIS/ConnectorArcGIS.sln deleted file mode 100644 index 767d10ee43..0000000000 --- a/ConnectorArcGIS/ConnectorArcGIS.sln +++ /dev/null @@ -1,25 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.31727.386 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConnectorArcGIS", "ConnectorArcGIS.csproj", "{79682455-2EAC-4B08-9227-C62F56349AD5}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {79682455-2EAC-4B08-9227-C62F56349AD5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {79682455-2EAC-4B08-9227-C62F56349AD5}.Debug|Any CPU.Build.0 = Debug|Any CPU - {79682455-2EAC-4B08-9227-C62F56349AD5}.Release|Any CPU.ActiveCfg = Release|Any CPU - {79682455-2EAC-4B08-9227-C62F56349AD5}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {8B79B969-1105-4E2D-94AF-82CDDA11DE8F} - EndGlobalSection -EndGlobal diff --git a/ConnectorArcGIS/DarkImages/AddInDesktop16.png b/ConnectorArcGIS/DarkImages/AddInDesktop16.png deleted file mode 100644 index 0118942a923d37745dced41536d71172f7517deb..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1314 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`k|nMYCBgY=CFO}lsSJ)O`AMk? zp1FzXsX?iUDV2pMQ*9U+m^Cs(B1$5BeXNr6bM+EIYV;~{3xK*A7;Nk-3KEmEQ%e+* zQqwc@Y?a>c-mj#PnPRIHZt82`Ti~3Uk?B!Ylp0*+7m{3+ootz+WN)WnQ(*-(AUCxn zQK2F?C$HG5!d3}vt`(3C64qBz04piUwpD^SD#ABF!8yMuRl!uxOgGuU%v{0TQqR!T z+}y-mN5ROz&{W^RSl`${*T~q)#K6kLNC66zfVLH-q*(>IxIyg#@@$ndN=gc>^!3Zj z%k|2Q_413-^$jg8E%gnI^o@*kfhu&1EAvVcD|GXUm0>2hq!uR^WfqiV=I1GZOiWD5 zFD$Tv3bSNU;+l1ennz|zM-B0$V)JVzP|XC=H|jx7ncO3BHWAB;NpiyW)Z+ZoqGVvir744~DzI`cN=+=uFAB-e&w+(vKt_H^esM;Afr7I$IMft0d=ry1 z^FV@{U|qhxR-SpqC5d^-sh%#jNbn4Gmq*EQ}4@91Trf z9F2`FOx&CdV0vBhlS^|`^GaZPQ-FG%U0huajGRnx>IEf;+ybD@E~!PCWvMA{Mftf3 zV2@j6;&zJxPV=C8Q?R%N>JLMldi8;h(Fa8@Qgp+FfN2QCgeP7g2cG;>^MGl-2$;A{ z^UHoRFfdN=ba4!+xHV_eSudtQk>mf3ADc`I;N%lh@rhWMHCaSu#|rTc+b*73D_z|f zchKzJnb0k|)r|_C3qu72JFMDTIvVAZpRQPZcJC7h=Cdqs6d>g;Fd(<~UJ81^dm+<(73@IuqYmV0m9+Os7i{i0=el#xWp=L=ll zcWrlNR9(*{VE_OC diff --git a/ConnectorArcGIS/DarkImages/AddInDesktop32.png b/ConnectorArcGIS/DarkImages/AddInDesktop32.png deleted file mode 100644 index 9713e3b1548cc2ee78c60ad4ffb3a46566609b2b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1744 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdz$r9IylHmNblJdl&R0hYC{G?O` z&)mfH)S%SFl*+=BsWuD@%o>>?5hW46K32*3xq68pHF_1f1wh>l3^w)^1&PVosU-?Y zsp*+{wo31J?^jaDOtDo8H}y5}EpSfF$n>ZxN)4{^3rViZPPR-@vbR&PsjvbXkegbP zs8ErclUHn2VXFi-*9yo63F|8hm3bwJ6}oxF$}kgLQj3#|G7CyF^YauyCMG83 zmzLNn0bL65LT&-v*t}wBFaZNhzap_f-%!s0*lEl2^R8JRMC7?NanVBh8&MvO521ZWi7A`KPhK8g6oCT>m!FugAM$)&lec_lEtDG0q5IQ4=OL~a4lW|!2W%(B!Jx1#)91+d4hGI6`b z6sLJmy(zfeVun+%KF~4xpy)-4ZkP}-4S|^O#0%uWlYeR+FwGYM6ZcJlSNy;{W9RAO z7*cU-Pq?qYaH7Dxw|Vt6-sL_XG#dCA=nEb^pfQtK4{2?@f5-Yn6Pn-PZZfE9Y0HrEx1H z9!!{UoHf^M-t)%bq7T3S{`vE#W^-XsO7HozXLCLFraX~2kgXt)p=H#>-|A#wX*ttK zsyEz0fq7Ti0YpasWR z+$R{k6EQaQOgubCjeVsOtlnOk{w`C6b(O-k z!?%v*K6AM`eR77=`V*;bYYY>29(i2Y;i6QsaMQ#fQ$;238P%!+a}++v7ICVt;*4J- z(t7o6^o7?q*{10_e_A1~bF=-!5qqwE6AORrn%yeg8+zd1YNnkg1x*k3n|IH?7GcRX zm5aSBol`57Z&RkUjQpL}K6dR7mnSsJ-QzxQ+bj^ZpL1#Y`=~J1hg`^%fgqBz3;E zypY`VWYg}1goK7Hr>$HfCJm_;pKI;?o2*r3d5-OQQhbGzDPtR#z=0d{_h&}7^PSf8 zb>5gD)M&Ftrs?+EygIQdKZL&Ay+5huW~Qg(^y=;BTJBYZU1$4y=WKYiF?T?MgwEt` zT`TsR|L}eiBb-#bV0KB@XNO?X7m|OEe!um$R*<1vcj3z0E6+0PZcey)bXUf@iL7he zsyA4hS#t{wI^H6T7(3Ke0lyCJVujWX{t((u~qp@l3TlWoH zzfI9w__aZNhOnDxgV^fc$14>N2duI-*SXET!S?cG;RSYO0%GFg(Vy;~h>>%(s=VC@S26m4%0k2Q>`~uZ6p00i_ I>zopr0LdSn0ssI2 diff --git a/ConnectorArcGIS/Images/AddInDesktop16.png b/ConnectorArcGIS/Images/AddInDesktop16.png deleted file mode 100644 index 5910bbf3dcd0cb09139b0c9926e00f96131d4757..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 524 zcmV+n0`vWeP)#SV*!XQdtWo`zW)u3-ITZ)bVS)1Hr@Kl zz{$$UaP`DN21cm=1AtUN5Gz1JiI2g=(Ssq}!4R(tz+M1pW@cqxuV5w1AS5Nuz{e%d z@ciLDhV#4Ef^E~*)jrVX(1?VK7tH?T6 zV6mVetE9oe&dLMU{OQ|Eumra#H^Zy{AHiV&j|FE@unXFbz5|BS4@5LRd2^9LP1=Fs z?(<^|fByc0Yxw-(Jy;XE3zP*}8B8QO7*;|Jc<}h%4F!2wFfb;P zxhYzAxw&0+>vq3KuWs}H(rta=aCh(dp7Z^j&-d3E1qyPfy+g$3^PX-BvM8b`0+z$sEF<`iyY2Ae<*Q&c8r=f|8OVVw3&**j?e;Ck zVzCTK2dhb)&pH4-5R^=}QQ41M&;^P5et#gz9sk7zdQ8wtsg|iA)B@4{v}Z_qW$A36 zS|g1a!az2SYcVJTJ5US^%!I)ois|a14(e*jz5%?O4nZ^~0%zAJ4|Px%*Qkl&E^=T> z6egvpHz0tI--L%3oLe-0T-F58R?EQ6YCCj}{U&QYu6$zv)bbcNKmd3m+_>vfks-#) zS+kcvH2!lU0R_CwMvf`X*4FLOL@5)Jax6; z@zjyXMoRSp5m`dtYk{B>43|ldep^vNO<~0$sBgFmzQ8Al#W%p^tOAj@!pP@Q82B&( z?xq{SRhAgbf_ZT#W>f)e8~?(cDQ3_(ZOVn^KRz(!*X6hUv&46xLfHSK4s) z{cGSW+o5wJma#18FFSjjaa9}vYo3#w*qX9np;VV%hI1#I$w)f=d;}b3hh_~hDsnr%?w?u=t}mEXYC)KkXZhqyUjxwE z(wvcdBbC~Wuqt9 - - - - - - - - diff --git a/ConnectorArcGIS/SpeckleDUI3.xaml.cs b/ConnectorArcGIS/SpeckleDUI3.xaml.cs deleted file mode 100644 index 9d10d9ac17..0000000000 --- a/ConnectorArcGIS/SpeckleDUI3.xaml.cs +++ /dev/null @@ -1,62 +0,0 @@ -/* - - Copyright 2022 Esri - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - - See the License for the specific language governing permissions and - limitations under the License. - -*/ - -using System.Collections.Generic; -using System.Windows.Controls; -using System.Windows.Threading; -using DUI3; -using Microsoft.Web.WebView2.Core; -using Speckle.Core.Logging; - -namespace ConnectorArcGIS; - -/// -/// Interaction logic for WebViewBrowserView.xaml -/// -public partial class SpeckleDUI3 : UserControl -{ - public SpeckleDUI3() - { - InitializeComponent(); - Browser.CoreWebView2InitializationCompleted += OnInitialized; - } - - private void ShowDevToolsMethod() => Browser.CoreWebView2.OpenDevToolsWindow(); - - private void ExecuteScriptAsyncMethod(string script) - { - if (!Browser.IsInitialized) - { - throw new SpeckleException("Failed to execute script, Webview2 is not initialized yet."); - } - - Browser.Dispatcher.Invoke(() => Browser.ExecuteScriptAsync(script), DispatcherPriority.Background); - } - - private void OnInitialized(object sender, CoreWebView2InitializationCompletedEventArgs e) - { - List bindings = Bindings.Factory.CreateBindings(); - - foreach (IBinding binding in bindings) - { - BrowserBridge bridge = new(Browser, binding, ExecuteScriptAsyncMethod, ShowDevToolsMethod); - Browser.CoreWebView2.AddHostObjectToScript(binding.Name, bridge); - } - } -} diff --git a/ConnectorArcGIS/SpeckleDUI3ViewModel.cs b/ConnectorArcGIS/SpeckleDUI3ViewModel.cs deleted file mode 100644 index 561a13d42e..0000000000 --- a/ConnectorArcGIS/SpeckleDUI3ViewModel.cs +++ /dev/null @@ -1,92 +0,0 @@ -/* - - Copyright 2022 Esri - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - - See the License for the specific language governing permissions and - limitations under the License. - -*/ - -using ArcGIS.Core.CIM; -using ArcGIS.Desktop.Core; -using ArcGIS.Desktop.Framework; -using ArcGIS.Desktop.Framework.Contracts; - -using System.Threading.Tasks; - -namespace ConnectorArcGIS; - -internal class SpeckleDUI3ViewModel : ViewStatePane -{ - private const string VIEW_PANE_ID = "SpeckleDUI3_SpeckleDUI3"; - - /// - /// Consume the passed in CIMView. Call the base constructor to wire up the CIMView. - /// - public SpeckleDUI3ViewModel(CIMView view) - : base(view) { } - - /// - /// Create a new instance of the pane. - /// - internal static SpeckleDUI3ViewModel Create() - { - // Otherwise crash on SqliteConnection - SQLitePCL.Batteries.Init(); - var view = new CIMGenericView { ViewType = VIEW_PANE_ID }; - return FrameworkApplication.Panes.Create(VIEW_PANE_ID, new object[] { view }) as SpeckleDUI3ViewModel; - } - - #region Pane Overrides - - /// - /// Must be overridden in child classes used to persist the state of the view to the CIM. - /// - public override CIMView ViewState - { - get - { - _cimView.InstanceID = (int)InstanceID; - return _cimView; - } - } - - /// - /// Called when the pane is initialized. - /// - protected override async Task InitializeAsync() - { - await base.InitializeAsync(); - } - - /// - /// Called when the pane is uninitialized. - /// - protected override async Task UninitializeAsync() - { - await base.UninitializeAsync(); - } - - #endregion Pane Overrides -} - -/// -/// Button implementation to create a new instance of the pane and activate it. -/// -internal class SpeckleDUI3OpenButton : Button -{ - protected override void OnClick() - { - SpeckleDUI3ViewModel.Create(); - } -} diff --git a/ConnectorArcGIS/SpeckleModule.cs b/ConnectorArcGIS/SpeckleModule.cs deleted file mode 100644 index e50ef359d4..0000000000 --- a/ConnectorArcGIS/SpeckleModule.cs +++ /dev/null @@ -1,51 +0,0 @@ -/* - - Copyright 2022 Esri - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - - See the License for the specific language governing permissions and - limitations under the License. - -*/ - -using ArcGIS.Desktop.Framework; -using ArcGIS.Desktop.Framework.Contracts; - -namespace ConnectorArcGIS; - -/// -/// This sample shows how to implement pane that contains an Edge WebView2 control using the built-in ArcGIS Pro SDK's WebBrowser control. For details on how to utilize the WebBrowser control in an add-in see here: https://github.com/Esri/arcgis-pro-sdk/wiki/ProConcepts-Framework#webbrowser For details on how to utilize the Microsoft Edge web browser control in an add-in see here: https://github.com/Esri/arcgis-pro-sdk/wiki/ProConcepts-Framework#webbrowser-control -/// -internal class SpeckleModule : Module -{ - private static SpeckleModule s_this; - - /// - /// Retrieve the singleton instance to this module here - /// - public static SpeckleModule Current => - s_this ??= (SpeckleModule)FrameworkApplication.FindModule("ConnectorArcGIS_Module"); - - #region Overrides - /// - /// Called by Framework when ArcGIS Pro is closing - /// - /// False to prevent Pro from closing, otherwise True - protected override bool CanUnload() - { - //TODO - add your business logic - //return false to ~cancel~ Application close - return true; - } - - #endregion Overrides -} diff --git a/ConnectorArcGIS/Utils/ArcGisDocumentStore.cs b/ConnectorArcGIS/Utils/ArcGisDocumentStore.cs deleted file mode 100644 index dbd331d35c..0000000000 --- a/ConnectorArcGIS/Utils/ArcGisDocumentStore.cs +++ /dev/null @@ -1,21 +0,0 @@ -using DUI3.Models; - -namespace ConnectorArcGIS.Utils; - -public class ArcGisDocumentStore : DocumentModelStore -{ - public ArcGisDocumentStore() - { - // Subscribe here document related events like OnSave, OnClose, OnOpen etc... - } - - public override void WriteToFile() - { - // Implement the logic to save it to file - } - - public override void ReadFromFile() - { - // Implement the logic to read it from file - } -} diff --git a/ConnectorArcGIS/app.config b/ConnectorArcGIS/app.config deleted file mode 100644 index 0c6db14149..0000000000 --- a/ConnectorArcGIS/app.config +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/ConnectorAutocadCivil/AutocadCivilDUI3/Autocad2022/ConnectorAutocad2022DUI3.csproj b/ConnectorAutocadCivil/AutocadCivilDUI3/Autocad2022/ConnectorAutocad2022DUI3.csproj deleted file mode 100644 index a81dca74cc..0000000000 --- a/ConnectorAutocadCivil/AutocadCivilDUI3/Autocad2022/ConnectorAutocad2022DUI3.csproj +++ /dev/null @@ -1,50 +0,0 @@ - - - Speckle.ConnectorAutocadDUI3 - ConnectorAutocadDUI3 - true - net48 - Program - $(ProgramW6432)\Autodesk\AutoCAD 2022\acad.exe - x64 - ConnectorAutocad2022DUI3 - ConnectorAutocad2022DUI3 - $(DefineConstants);AUTOCAD2022DUI3 - false - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ..\..\..\..\..\..\..\..\Windows\Microsoft.NET\assembly\GAC_MSIL\WindowsFormsIntegration\v4.0_4.0.0.0__31bf3856ad364e35\WindowsFormsIntegration.dll - - - - - diff --git a/ConnectorAutocadCivil/AutocadCivilDUI3/Autocad2023/ConnectorAutocad2023DUI3.csproj b/ConnectorAutocadCivil/AutocadCivilDUI3/Autocad2023/ConnectorAutocad2023DUI3.csproj deleted file mode 100644 index 7292ea6470..0000000000 --- a/ConnectorAutocadCivil/AutocadCivilDUI3/Autocad2023/ConnectorAutocad2023DUI3.csproj +++ /dev/null @@ -1,47 +0,0 @@ - - - Speckle.ConnectorAutocadDUI3 - ConnectorAutocadDUI3 - true - net48 - Program - $(ProgramW6432)\Autodesk\AutoCAD 2023\acad.exe - x64 - ConnectorAutocad2023DUI3 - ConnectorAutocad2023DUI3 - $(DefineConstants);AUTOCAD2023DUI3 - false - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/AutocadCivilDUI3Shared.projitems b/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/AutocadCivilDUI3Shared.projitems deleted file mode 100644 index 5aebdd642f..0000000000 --- a/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/AutocadCivilDUI3Shared.projitems +++ /dev/null @@ -1,34 +0,0 @@ - - - - $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - true - C0FBC7B6-923D-4D92-96FC-B217F620512D - - - AutocadCivilDUI3Shared - - - - - - - - - - DUI3PanelWebView.xaml - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/AutocadCivilDUI3Shared.shproj b/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/AutocadCivilDUI3Shared.shproj deleted file mode 100644 index 99045e1070..0000000000 --- a/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/AutocadCivilDUI3Shared.shproj +++ /dev/null @@ -1,11 +0,0 @@ - - - - {2BDE80E8-5F26-4E57-BBA6-109120F5D4EE} - - - - - - - diff --git a/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Bindings/BasicConnectorBindingAutocad.cs b/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Bindings/BasicConnectorBindingAutocad.cs deleted file mode 100644 index 9aa7ea0f2b..0000000000 --- a/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Bindings/BasicConnectorBindingAutocad.cs +++ /dev/null @@ -1,139 +0,0 @@ -using System; -using System.Linq; -using System.Reflection; -using AutocadCivilDUI3Shared.Extensions; -using AutocadCivilDUI3Shared.Utils; -using Autodesk.AutoCAD.ApplicationServices; -using Autodesk.AutoCAD.DatabaseServices; -using DUI3; -using DUI3.Bindings; -using DUI3.Models; -using Sentry.Reflection; -using Speckle.Core.Credentials; -using Application = Autodesk.AutoCAD.ApplicationServices.Core.Application; - -namespace Speckle.ConnectorAutocadDUI3.Bindings; - -public class BasicConnectorBindingAutocad : IBasicConnectorBinding -{ - public string Name { get; set; } = "baseBinding"; - public IBridge Parent { get; set; } - - private static Document Doc => Application.DocumentManager.MdiActiveDocument; - private readonly AutocadDocumentModelStore _store; - - public BasicConnectorBindingAutocad(AutocadDocumentModelStore store) - { - _store = store; - _store.DocumentChanged += (_, _) => - { - BasicConnectorBindingCommands.NotifyDocumentChanged(Parent); - }; - } - - public string GetConnectorVersion() => Assembly.GetAssembly(GetType()).GetNameAndVersion().Version; - - public string GetSourceApplicationName() => Core.Kits.HostApplications.AutoCAD.Slug; - - public string GetSourceApplicationVersion() - { -#if AUTOCAD2023DUI3 - return "2023"; -# endif -#if AUTOCAD2022DUI3 - return "2022"; -#endif - } - - public Account[] GetAccounts() => AccountManager.GetAccounts().ToArray(); - - public DocumentInfo GetDocumentInfo() - { - if (Doc == null) - return null; - string name = Doc.Name.Split(System.IO.Path.PathSeparator).Reverse().First(); - return new DocumentInfo() - { - Name = name, - Id = Doc.Name, - Location = Doc.Name - }; - } - - public DocumentModelStore GetDocumentState() => _store; - - public void AddModel(ModelCard model) => _store.Models.Add(model); - - public void UpdateModel(ModelCard model) - { - int idx = _store.Models.FindIndex(m => model.ModelCardId == m.ModelCardId); - _store.Models[idx] = model; - } - - public void RemoveModel(ModelCard model) - { - int index = _store.Models.FindIndex(m => m.ModelCardId == model.ModelCardId); - _store.Models.RemoveAt(index); - } - - public void HighlightModel(string modelCardId) - { - if (Doc == null) - { - return; - } - var objectIds = Array.Empty(); - - var model = _store.GetModelById(modelCardId); - if (model == null) - { - return; // TODO: RECEIVERS - } - - if (model is SenderModelCard senderModelCard) - { - var dbObjects = Objects.GetObjectsFromDocument(Doc, senderModelCard.SendFilter.GetObjectIds()); - objectIds = dbObjects.Select(tuple => tuple.obj.Id).ToArray(); - } - - if ( - model is ReceiverModelCard { ReceiveResult: { } } receiverModelCard - && receiverModelCard.ReceiveResult.BakedObjectIds.Count != 0 - ) - { - var dbObjects = Objects.GetObjectsFromDocument(Doc, receiverModelCard.ReceiveResult.BakedObjectIds); - objectIds = dbObjects.Select(tuple => tuple.obj.Id).ToArray(); - } - - if (objectIds.Length == 0) - { - BasicConnectorBindingCommands.SetModelError( - Parent, - modelCardId, - new OperationCanceledException("No objects found to highlight.") - ); - return; - } - - Parent.RunOnMainThread(() => - { - Doc.Editor.SetImpliedSelection(Array.Empty()); // Deselects - Doc.Editor.SetImpliedSelection(objectIds); // Selects - Doc.Editor.UpdateScreen(); - - Extents3d selectedExtents = new(); - var tr = Doc.TransactionManager.StartTransaction(); - foreach (ObjectId objectId in objectIds) - { - Entity entity = tr.GetObject(objectId, OpenMode.ForRead) as Entity; - if (entity != null) - { - selectedExtents.AddExtents(entity.GeometricExtents); - } - } - Doc.Editor.Zoom(selectedExtents); - tr.Commit(); - Autodesk.AutoCAD.Internal.Utils.FlushGraphics(); - }); - } -} diff --git a/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Bindings/Factory.cs b/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Bindings/Factory.cs deleted file mode 100644 index ae41088dec..0000000000 --- a/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Bindings/Factory.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System.Collections.Generic; -using AutocadCivilDUI3Shared.Utils; -using ConnectorAutocadDUI3.Bindings; -using DUI3; -using DUI3.Bindings; -using Speckle.ConnectorAutocadDUI3.Bindings; - -namespace AutocadCivilDUI3Shared.Bindings; - -public static class Factory -{ - private static readonly AutocadDocumentModelStore s_store = new(); - - public static List CreateBindings() - { - BasicConnectorBindingAutocad baseBindings = new(s_store); - SendBinding sendBindings = new(s_store); - ReceiveBinding receiveBindings = new(s_store); - SelectionBinding selectionBinding = new(); - - List bindingsList = - new() - { - new ConfigBinding("Autocad"), - new AccountBinding(), - new TestBinding(), - baseBindings, - sendBindings, - receiveBindings, - selectionBinding - }; - - return bindingsList; - } -} diff --git a/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Bindings/Filters.cs b/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Bindings/Filters.cs deleted file mode 100644 index 6d7e2b3fa6..0000000000 --- a/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Bindings/Filters.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System.Collections.Generic; -using System.Linq; -using DUI3.Bindings; - -namespace AutocadCivilDUI3Shared.Bindings; - -public class AutocadEverythingFilter : EverythingSendFilter -{ - public override bool CheckExpiry(string[] changedObjectIds) - { - return true; - } - - public override List GetObjectIds() - { - return new List(); - } -} - -public class AutocadSelectionFilter : DirectSelectionSendFilter -{ - public override bool CheckExpiry(string[] changedObjectIds) - { - return SelectedObjectIds.Intersect(changedObjectIds).Any(); - } - - public override List GetObjectIds() - { - return SelectedObjectIds; - } -} diff --git a/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Bindings/ReceiveBinding.cs b/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Bindings/ReceiveBinding.cs deleted file mode 100644 index bb92b2c5fb..0000000000 --- a/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Bindings/ReceiveBinding.cs +++ /dev/null @@ -1,255 +0,0 @@ -using System; -using DUI3; -using DUI3.Bindings; -using DUI3.Models; -using AutocadCivilDUI3Shared.Utils; -using Autodesk.AutoCAD.ApplicationServices; -using Autodesk.AutoCAD.DatabaseServices; -using Speckle.Core.Kits; -using Speckle.Core.Models; -using System.Collections.Generic; -using System.Diagnostics; -using System.Linq; -using System.Threading; -using Autodesk.AutoCAD.EditorInput; -using Autodesk.AutoCAD.LayerManager; -using DUI3.Models.Card; -using DUI3.Operations; -using DUI3.Utils; - -namespace ConnectorAutocadDUI3.Bindings; - -public class ReceiveBinding : IReceiveBinding, ICancelable -{ - public string Name { get; set; } = "receiveBinding"; - public IBridge Parent { get; set; } - - private readonly DocumentModelStore _store; - - public CancellationManager CancellationManager { get; } = new(); - - private Document Doc => Autodesk.AutoCAD.ApplicationServices.Core.Application.DocumentManager.MdiActiveDocument; - - public ReceiveBinding(DocumentModelStore store) - { - _store = store; - } - - public void CancelReceive(string modelCardId) => CancellationManager.CancelOperation(modelCardId); - - public async void Receive(string modelCardId) - { - try - { - // 0 - Init cancellation token source -> Manager also cancel it if exist before - var cts = CancellationManager.InitCancellationTokenSource(modelCardId); - - // 1 - Get receiver card - var modelCard = _store.GetModelById(modelCardId) as ReceiverModelCard; - - // 2 - Get commit object from server - var commitObject = await Operations.GetCommitBase(Parent, modelCard, cts.Token).ConfigureAwait(true); - - if (cts.IsCancellationRequested) - { - throw new OperationCanceledException(cts.Token); - } - - // 3 - Get converter - ISpeckleConverter converter = Converters.GetConverter(Doc, Utils.VersionedAppName); - - // 4 - Traverse commit object - BasicConnectorBindingCommands.SetModelProgress( - Parent, - modelCardId, - new ModelCardProgress() { Status = "Parsing structure" } - ); - var objectsToConvert = new List<(List, Base)>(); - foreach (var (objPath, obj) in commitObject.TraverseWithPath((obj) => obj is not Collection)) - { - if (cts.IsCancellationRequested) - { - throw new OperationCanceledException(cts.Token); - } - if (obj is not Collection && converter.CanConvertToNative(obj)) - { - objectsToConvert.Add((objPath, obj)); - } - } - - if (objectsToConvert.Count == 0) - { - throw new Exception("No convertible objects found."); - } - - var baseLayerPrefix = $"SPK-{modelCard.ProjectName}-{modelCard.ModelName}-"; - BasicConnectorBindingCommands.SetModelProgress( - Parent, - modelCardId, - new ModelCardProgress() { Status = "Starting conversion" } - ); - - using var docLock = Doc.LockDocument(); - using var transaction = Doc.Database.TransactionManager.StartTransaction(); - - CreateLayerFilter(modelCard.ProjectName, modelCard.ModelName); - var convertedObjectIds = BakeObjects(objectsToConvert, baseLayerPrefix, modelCardId, cts, converter); - - Autodesk.AutoCAD.Internal.Utils.FlushGraphics(); - ReceiveBindingUiCommands.SetModelConversionResult( - Parent, - modelCardId, - new ReceiveResult() { BakedObjectIds = convertedObjectIds, Display = true } - ); - transaction.Commit(); - } - catch (Exception e) - { - if (e is OperationCanceledException) - { - return; - } - BasicConnectorBindingCommands.SetModelError(Parent, modelCardId, e); - } - } - - private List BakeObjects( - List<(List, Base)> objects, - string baseLayerPrefix, - string modelCardId, - CancellationTokenSource cts, - ISpeckleConverter converter - ) - { - BasicConnectorBindingCommands.SetModelProgress( - Parent, - modelCardId, - new ModelCardProgress() { Status = "Converting" } - ); - var uniqueLayerNames = new HashSet(); - var handleValues = new List(); - var count = 0; - foreach (var (path, obj) in objects) - { - if (cts.IsCancellationRequested) - { - throw new OperationCanceledException(cts.Token); - } - - try - { - var layerFullName = baseLayerPrefix + string.Join("-", path); - layerFullName = Utils.RemoveInvalidChars(layerFullName); - - if (uniqueLayerNames.Add(layerFullName)) - { - CreateLayerOrPurge(layerFullName); - } - - var converted = converter.ConvertToNative(obj); - var flattened = Traversal.FlattenToNativeConversionResult(converted); - foreach (Entity conversionResult in flattened.Cast()) - { - if (conversionResult == null) - { - continue; - } - - conversionResult.Append(layerFullName); - handleValues.Add(conversionResult.Handle.Value.ToString()); - BasicConnectorBindingCommands.SetModelProgress( - Parent, - modelCardId, - new ModelCardProgress() { Status = "Converting", Progress = (double)++count / objects.Count } - ); - } - } - catch (Exception e) // DO NOT CATCH SPECIFIC STUFF, conversion errors should be recoverable - { - // TODO: you know, report, etc. - Debug.WriteLine("conversion error happened."); - } - } - return handleValues; - } - - /// - /// Will create a layer with the provided name, or, if it finds an existing one, will "purge" all objects from it. - /// This ensures we're creating the new objects we've just received rather than overlaying them. - /// - /// - private void CreateLayerOrPurge(string layerName) - { - using var transaction = Doc.TransactionManager.TopTransaction; - - var layerTable = - transaction.TransactionManager.GetObject(Doc.Database.LayerTableId, OpenMode.ForRead) as LayerTable; - var layerTableRecord = new LayerTableRecord() { Name = layerName }; - - var hasLayer = layerTable.Has(layerName); - if (hasLayer) - { - var tvs = new[] { new TypedValue((int)DxfCode.LayerName, layerName) }; - var selectionFilter = new SelectionFilter(tvs); - var selectionResult = Doc.Editor.SelectAll(selectionFilter).Value; - if (selectionResult == null) - { - return; - } - foreach (SelectedObject selectedObject in selectionResult) - { - transaction.GetObject(selectedObject.ObjectId, OpenMode.ForWrite).Erase(); - } - - return; - } - - layerTable.UpgradeOpen(); - layerTable.Add(layerTableRecord); - transaction.AddNewlyCreatedDBObject(layerTableRecord, true); - } - - /// - /// Creates a layer filter for the just received model, grouped under a top level filter "Speckle". Note: manual close and open of the layer properties panel required (it's an acad thing). - /// This comes in handy to quickly access the layers created for this specific model. - /// - /// - /// - private void CreateLayerFilter(string projectName, string modelName) - { - using var docLock = Doc.LockDocument(); - var filterName = Utils.RemoveInvalidChars($@"{projectName}-{modelName}"); - var layerFilterTree = Doc.Database.LayerFilters; - var layerFilterCollection = layerFilterTree.Root.NestedFilters; - var groupFilterName = "Speckle"; - LayerFilter groupFilter = null; - - foreach (LayerFilter existingFilter in layerFilterCollection) - { - if (existingFilter.Name == groupFilterName) - { - groupFilter = existingFilter; - break; - } - } - - if (groupFilter == null) - { - groupFilter = new LayerFilter() { Name = "Speckle", FilterExpression = $"NAME==\"SPK-*\"" }; - layerFilterCollection.Add(groupFilter); - } - - var layerFilterExpression = $"NAME==\"SPK-{filterName}*\""; - foreach (LayerFilter lf in groupFilter.NestedFilters) - { - if (lf.Name == filterName) - { - lf.FilterExpression = layerFilterExpression; - return; - } - } - var layerFilter = new LayerFilter() { Name = filterName, FilterExpression = layerFilterExpression }; - groupFilter.NestedFilters.Add(layerFilter); - Doc.Database.LayerFilters = layerFilterTree; - } -} diff --git a/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Bindings/SelectionBinding.cs b/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Bindings/SelectionBinding.cs deleted file mode 100644 index 917b103f1d..0000000000 --- a/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Bindings/SelectionBinding.cs +++ /dev/null @@ -1,75 +0,0 @@ -using System.Collections.Generic; -using Autodesk.AutoCAD.ApplicationServices; -using Autodesk.AutoCAD.DatabaseServices; -using Autodesk.AutoCAD.EditorInput; -using DUI3; -using DUI3.Bindings; -using Application = Autodesk.AutoCAD.ApplicationServices.Core.Application; - -namespace AutocadCivilDUI3Shared.Bindings; - -public class SelectionBinding : ISelectionBinding -{ - public string Name { get; set; } = "selectionBinding"; - public IBridge Parent { get; set; } - - private readonly List _visitedDocuments = new(); - - public SelectionBinding() - { - Application.DocumentManager.DocumentActivated += (sender, e) => OnDocumentChanged(e.Document); - } - - private void OnDocumentChanged(Document document) - { - // TODO: null check here - if (document == null) - { - return; - } - if (!_visitedDocuments.Contains(document)) - { - document.ImpliedSelectionChanged += (_, _) => - { - Parent.RunOnMainThread(OnSelectionChanged); - }; - _visitedDocuments.Add(document); - } - } - - private void OnSelectionChanged() - { - SelectionInfo selInfo = GetSelection(); - Parent.SendToBrowser(DUI3.Bindings.SelectionBindingEvents.SetSelection, selInfo); - } - - public SelectionInfo GetSelection() - { - Document doc = Application.DocumentManager.MdiActiveDocument; - List objs = new(); - if (doc != null) - { - PromptSelectionResult selection = doc.Editor.SelectImplied(); - if (selection.Status == PromptStatus.OK) - { - using var tr = doc.TransactionManager.StartTransaction(); - foreach (SelectedObject obj in selection.Value) - { - var dbObject = tr.GetObject(obj.ObjectId, OpenMode.ForRead); - if ( - dbObject == null /*|| !dbObject.Visible()*/ - ) - { - continue; - } - - var handleString = dbObject.Handle.Value.ToString(); - objs.Add(handleString); - } - tr.Commit(); - tr.Dispose(); - } - } - return new SelectionInfo { SelectedObjectIds = objs, Summary = $"{objs.Count} objects" }; - } -} diff --git a/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Bindings/SendBinding.cs b/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Bindings/SendBinding.cs deleted file mode 100644 index 3fc26997e2..0000000000 --- a/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Bindings/SendBinding.cs +++ /dev/null @@ -1,254 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Linq; -using System.Threading; -using AutocadCivilDUI3Shared.Utils; -using Autodesk.AutoCAD.ApplicationServices; -using Autodesk.AutoCAD.DatabaseServices; -using DUI3; -using DUI3.Bindings; -using DUI3.Models.Card; -using DUI3.Operations; -using DUI3.Utils; -using Speckle.Core.Api; -using Speckle.Core.Kits; -using Speckle.Core.Logging; -using Speckle.Core.Models; -using Speckle.Core.Transports; -using Application = Autodesk.AutoCAD.ApplicationServices.Core.Application; - -namespace AutocadCivilDUI3Shared.Bindings; - -public class SendBinding : ISendBinding, ICancelable -{ - public string Name { get; set; } = "sendBinding"; - - public IBridge Parent { get; set; } - - private readonly AutocadDocumentModelStore _store; - - private Document Doc => Application.DocumentManager.MdiActiveDocument; - - /// - /// Used internally to aggregate the changed objects' id. - /// - private HashSet ChangedObjectIds { get; set; } = new(); - - /// - /// Keeps track of previously converted objects as a dictionary of (applicationId, object reference). - /// - private readonly Dictionary _convertedObjectReferences = new(); - - public SendBinding(AutocadDocumentModelStore store) - { - _store = store; - Application.DocumentManager.DocumentActivated += (sender, args) => SubscribeToObjectChanges(args.Document); - if (Application.DocumentManager.CurrentDocument != null) - { - // NOTE: catches the case when autocad just opens up with a blank new doc - SubscribeToObjectChanges(Application.DocumentManager.CurrentDocument); - } - } - - private readonly List _docSubsTracker = new(); - - private void SubscribeToObjectChanges(Document doc) - { - if (doc == null || doc.Database == null || _docSubsTracker.Contains(doc.Name)) - { - return; - } - - _docSubsTracker.Add(doc.Name); - doc.Database.ObjectAppended += (_, e) => OnChangeChangedObjectIds(e.DBObject); - doc.Database.ObjectErased += (_, e) => OnChangeChangedObjectIds(e.DBObject); - doc.Database.ObjectModified += (_, e) => OnChangeChangedObjectIds(e.DBObject); - } - - private void OnChangeChangedObjectIds(DBObject dBObject) - { - ChangedObjectIds.Add(dBObject.Handle.Value.ToString()); - AutocadIdleManager.SubscribeToIdle(RunExpirationChecks); - } - - public List GetSendFilters() => new() { new AutocadEverythingFilter(), new AutocadSelectionFilter() }; - - public CancellationManager CancellationManager { get; } = new(); - - public void Send(string modelCardId) - { - Parent.RunOnMainThread(() => SendInternal(modelCardId)); - } - - private async void SendInternal(string modelCardId) - { - try - { - // 0 - Init cancellation token source -> Manager also cancel it if exist before - var cts = CancellationManager.InitCancellationTokenSource(modelCardId); - - // 1 - Setup - var modelCard = _store.GetModelById(modelCardId) as SenderModelCard; - var account = Accounts.GetAccount(modelCard.AccountId); - var converter = Converters.GetConverter(Doc, Utils.Utils.VersionedAppName); - - // 2 - Get elements to convert - var dbObjects = Objects.GetObjectsFromDocument(Doc, modelCard.SendFilter.GetObjectIds()); - if (dbObjects.Count == 0) - { - throw new InvalidOperationException("No objects were found. Please update your send filter!"); - } - // 5 - Convert objects - var commitObject = ConvertObjects(dbObjects, converter, modelCard, cts); - - if (cts.IsCancellationRequested) - { - return; - } - - // 7 - Serialize and Send objects - var transport = new ServerTransport(account, modelCard.ProjectId); - BasicConnectorBindingCommands.SetModelProgress( - Parent, - modelCardId, - new ModelCardProgress { Status = "Uploading..." } - ); - var sendResult = await SendHelper.Send(commitObject, transport, true, null, cts.Token).ConfigureAwait(true); - - // Store the converted references in memory for future send operations, overwriting the existing values for the given application id. - foreach (var kvp in sendResult.convertedReferences) - { - _convertedObjectReferences[kvp.Key + modelCard.ProjectId] = kvp.Value; - } - // It's important to reset the model card's list of changed obj ids so as to ensure we accurately keep track of changes between send operations. - modelCard.ChangedObjectIds = new(); - - if (cts.IsCancellationRequested) - { - throw new OperationCanceledException(cts.Token); - } - - // 8 - Create Version - BasicConnectorBindingCommands.SetModelProgress( - Parent, - modelCardId, - new ModelCardProgress { Status = "Linking version to model..." } - ); - - // 8 - Create the version (commit) - var apiClient = new Client(account); - string versionId = await apiClient - .CommitCreate( - new CommitCreateInput() - { - streamId = modelCard.ProjectId, - branchName = modelCard.ModelId, - sourceApplication = "Rhino", - objectId = sendResult.rootObjId - }, - cts.Token - ) - .ConfigureAwait(true); - - SendBindingUiCommands.SetModelCreatedVersionId(Parent, modelCardId, versionId); - apiClient.Dispose(); - } - catch (Exception e) when (!e.IsFatal()) // All exceptions should be handled here if possible, otherwise we enter "crashing the host app" territory. - { - if (e is OperationCanceledException) - { - return; - } - - BasicConnectorBindingCommands.SetModelError(Parent, modelCardId, e); - } - } - - public void CancelSend(string modelCardId) => CancellationManager.CancelOperation(modelCardId); - - private void RunExpirationChecks() - { - List senders = _store.GetSenders(); - string[] objectIdsList = ChangedObjectIds.ToArray(); - List expiredSenderIds = new(); - - foreach (SenderModelCard modelCard in senders) - { - var intersection = modelCard.SendFilter.GetObjectIds().Intersect(objectIdsList).ToList(); - bool isExpired = intersection.Any(); - if (isExpired) - { - expiredSenderIds.Add(modelCard.ModelCardId); - modelCard.ChangedObjectIds.UnionWith(intersection); - } - } - - SendBindingUiCommands.SetModelsExpired(Parent, expiredSenderIds); - ChangedObjectIds = new HashSet(); - } - - private Base ConvertObjects( - List<(DBObject obj, string layer, string applicationId)> dbObjects, - ISpeckleConverter converter, - SenderModelCard modelCard, - CancellationTokenSource cts - ) - { - var modelWithLayers = new Collection() - { - name = Doc.Name.Split(new[] { "\\" }, StringSplitOptions.None).Reverse().First(), - collectionType = "root" - }; - var collectionCache = new Dictionary(); - int count = 0; - - foreach (var tuple in dbObjects) - { - if (cts.IsCancellationRequested) - { - throw new OperationCanceledException(cts.Token); - } - try - { - Base converted; - var applicationId = tuple.applicationId; - - if ( - !modelCard.ChangedObjectIds.Contains(applicationId) - && _convertedObjectReferences.TryGetValue(applicationId + modelCard.ProjectId, out ObjectReference value) - ) - { - converted = value; - } - else - { - converted = converter.ConvertToSpeckle(tuple.obj); - converted.applicationId = applicationId; - } - - // Create and add a collection for each layer if not done so already. - if (!collectionCache.ContainsKey(tuple.layer)) - { - collectionCache[tuple.layer] = new Collection() { name = tuple.layer, collectionType = "layer" }; - modelWithLayers.elements.Add(collectionCache[tuple.layer]); - } - - collectionCache[tuple.layer].elements.Add(converted); - - BasicConnectorBindingCommands.SetModelProgress( - Parent, - modelCard.ModelCardId, - new ModelCardProgress() { Status = "Converting", Progress = (double)++count / dbObjects.Count } - ); - } - catch (Exception e) when (!e.IsFatal()) - { - // TODO: Add to report, etc. - Debug.WriteLine(e.Message); - } - } - - return modelWithLayers; - } -} diff --git a/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/DUI3PanelWebView.xaml b/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/DUI3PanelWebView.xaml deleted file mode 100644 index 5565b36d5e..0000000000 --- a/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/DUI3PanelWebView.xaml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - diff --git a/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/DUI3PanelWebView.xaml.cs b/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/DUI3PanelWebView.xaml.cs deleted file mode 100644 index c85dab5ce3..0000000000 --- a/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/DUI3PanelWebView.xaml.cs +++ /dev/null @@ -1,40 +0,0 @@ -using System.Collections.Generic; -using System.Windows.Controls; -using System.Windows.Threading; -using AutocadCivilDUI3Shared.Bindings; -using DUI3; -using Microsoft.Web.WebView2.Core; -using Speckle.Core.Logging; - -namespace Speckle.ConnectorAutocadDUI3; - -public partial class Dui3PanelWebView : UserControl -{ - public Dui3PanelWebView() - { - InitializeComponent(); - Browser.CoreWebView2InitializationCompleted += Browser_Initialized_Completed; - } - - private void ShowDevToolsMethod() => Browser.CoreWebView2.OpenDevToolsWindow(); - - private void ExecuteScriptAsyncMethod(string script) - { - if (!Browser.IsInitialized) - { - throw new SpeckleException("Failed to execute script, Webview2 is not initialized yet."); - } - Browser.Dispatcher.Invoke(() => Browser.ExecuteScriptAsync(script), DispatcherPriority.Background); - } - - private void Browser_Initialized_Completed(object sender, CoreWebView2InitializationCompletedEventArgs e) - { - List bindings = Factory.CreateBindings(); - - foreach (IBinding binding in bindings) - { - var bridge = new BrowserBridge(Browser, binding, ExecuteScriptAsyncMethod, ShowDevToolsMethod); - Browser.CoreWebView2.AddHostObjectToScript(binding.Name, bridge); - } - } -} diff --git a/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Entry.cs b/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Entry.cs deleted file mode 100644 index f9dfc6ace7..0000000000 --- a/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Entry.cs +++ /dev/null @@ -1,72 +0,0 @@ -using System; -using System.Drawing; -using System.IO; -using System.Reflection; -using Autodesk.AutoCAD.Windows; -using Autodesk.AutoCAD.Runtime; -using Speckle.ConnectorAutocadDUI3; - -namespace AutocadCivilDUI3Shared; - -public class App : IExtensionApplication -{ - public void Initialize() => AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(OnAssemblyResolve); - - public void Terminate() - { - // Shh. - } - - private Assembly OnAssemblyResolve(object sender, ResolveEventArgs args) - { - Assembly a = null; - string name = args.Name.Split(',')[0]; - string path = Path.GetDirectoryName(typeof(App).Assembly.Location); - - string assemblyFile = Path.Combine(path, name + ".dll"); - - if (File.Exists(assemblyFile)) - { - a = Assembly.LoadFrom(assemblyFile); - } - - return a; - } -} - -public class SpeckleAutocadDui3Command -{ - private static PaletteSet PaletteSet { get; set; } - private static readonly Guid s_id = new("6AD40744-85BF-4B62-9408-5D3CCEB8B876"); - - [CommandMethod("SpeckleDUI3")] - public void SpeckleCommand() - { - if (PaletteSet != null) - { - FocusPalette(); - return; - } - - PaletteSet = new PaletteSet("Speckle DUI3", s_id) - { - Size = new Size(400, 500), - DockEnabled = (DockSides)((int)DockSides.Left + (int)DockSides.Right) - }; - - // NOTE: Autocad 2022 seems to support Webview2 rather well, hence I (Dim) have removed - // all references to Cef. CefSharp also worked rather fine, and we would need to match - // the correct versions, etc.. But it seems it's not needed! - var panelWebView = new Dui3PanelWebView(); - - PaletteSet.AddVisual("Speckle DUI3 WebView", panelWebView); - - FocusPalette(); - } - - private void FocusPalette() - { - PaletteSet.KeepFocus = true; - PaletteSet.Visible = true; - } -} diff --git a/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Extensions/Editor.cs b/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Extensions/Editor.cs deleted file mode 100644 index f388b0c4ee..0000000000 --- a/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Extensions/Editor.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System; -using Autodesk.AutoCAD.DatabaseServices; -using Autodesk.AutoCAD.EditorInput; -using Autodesk.AutoCAD.Geometry; - -namespace AutocadCivilDUI3Shared.Extensions; - -public static class EditorExtensions -{ - public static void Zoom(this Editor editor, Extents3d ext) - { - if (editor == null) - { - throw new ArgumentNullException(nameof(editor)); - } - using ViewTableRecord view = editor.GetCurrentView(); - Matrix3d worldToEye = - Matrix3d.WorldToPlane(view.ViewDirection) - * Matrix3d.Displacement(Point3d.Origin - view.Target) - * Matrix3d.Rotation(view.ViewTwist, view.ViewDirection, view.Target); - ext.TransformBy(worldToEye); - view.Width = ext.MaxPoint.X - ext.MinPoint.X; - view.Height = ext.MaxPoint.Y - ext.MinPoint.Y; - view.CenterPoint = new Point2d((ext.MaxPoint.X + ext.MinPoint.X) / 2.0, (ext.MaxPoint.Y + ext.MinPoint.Y) / 2.0); - editor.SetCurrentView(view); - } -} diff --git a/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Extensions/Extends3d.cs b/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Extensions/Extends3d.cs deleted file mode 100644 index 5f05fec54f..0000000000 --- a/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Extensions/Extends3d.cs +++ /dev/null @@ -1,39 +0,0 @@ -using Autodesk.AutoCAD.DatabaseServices; -using Autodesk.AutoCAD.EditorInput; - -namespace AutocadCivilDUI3Shared.Extensions; - -public static class Extends3dExtensions -{ - public static Extents3d FromObjectIds(Editor editor) - { - Transaction tr = editor.Document.Database.TransactionManager.StartTransaction(); - - PromptSelectionResult selectionResult = editor.SelectImplied(); - - if (selectionResult.Status == PromptStatus.OK) - { - SelectionSet selectionSet = selectionResult.Value; - - if (selectionSet.Count > 0) - { - // Create a bounding box to include all selected objects - Extents3d selectedExtents = new(); - - foreach (ObjectId objectId in selectionSet.GetObjectIds()) - { - Entity entity = tr.GetObject(objectId, OpenMode.ForRead) as Entity; - if (entity != null) - { - selectedExtents.AddExtents(entity.GeometricExtents); - } - } - tr.Commit(); - return selectedExtents; - } - } - - tr.Commit(); - return new Extents3d(); - } -} diff --git a/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Utils/AutocadDocumentManager.cs b/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Utils/AutocadDocumentManager.cs deleted file mode 100644 index 73cc0dd995..0000000000 --- a/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Utils/AutocadDocumentManager.cs +++ /dev/null @@ -1,149 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Text; -using Autodesk.AutoCAD.ApplicationServices; -using Autodesk.AutoCAD.DatabaseServices; - -namespace AutocadCivilDUI3Shared.Utils; - -public static class AutocadDocumentManager -{ - private const string SPECKLE_KEY = "Speckle_DUI3"; - private const string SPECKLE_MODEL_CARDS_KEY = "Speckle_DUI3_Model_Cards"; - - /// - /// Returns all the speckle model cards present in the current document. - /// - /// - /// - public static string ReadModelCards(Document doc) - { - if (doc == null) - { - return null; - } - - using (TransactionContext.StartTransaction(doc)) - { - Transaction tr = doc.Database.TransactionManager.TopTransaction; - DBDictionary nod = (DBDictionary)tr.GetObject(doc.Database.NamedObjectsDictionaryId, OpenMode.ForRead); - if (!nod.Contains(SPECKLE_KEY)) - { - return null; - } - - DBDictionary speckleDict = tr.GetObject(nod.GetAt(SPECKLE_KEY), OpenMode.ForRead) as DBDictionary; - if (speckleDict == null || speckleDict.Count == 0) - { - return null; - } - - ObjectId id = speckleDict.GetAt(SPECKLE_MODEL_CARDS_KEY); - if (id == ObjectId.Null) - { - return null; - } - - Xrecord record = tr.GetObject(id, OpenMode.ForRead) as Xrecord; - string value = GetXrecordData(record); - - try - { - //Try to decode here because there is old data - return Base64Decode(value); - } - catch (ApplicationException e) - { - Debug.WriteLine(e); - return null; - } - } - } - - /// - /// Writes the model cards to the current document. - /// - /// - /// - public static void WriteModelCards(Document doc, string modelCardsString) - { - if (doc == null) - { - return; - } - - using (TransactionContext.StartTransaction(doc)) - { - Transaction tr = doc.Database.TransactionManager.TopTransaction; - var nod = (DBDictionary)tr.GetObject(doc.Database.NamedObjectsDictionaryId, OpenMode.ForRead); - DBDictionary speckleDict; - if (nod.Contains(SPECKLE_KEY)) - { - speckleDict = (DBDictionary)tr.GetObject(nod.GetAt(SPECKLE_KEY), OpenMode.ForWrite); - } - else - { - speckleDict = new DBDictionary(); - nod.UpgradeOpen(); - nod.SetAt(SPECKLE_KEY, speckleDict); - tr.AddNewlyCreatedDBObject(speckleDict, true); - } - Xrecord xRec = new(); - xRec.Data = CreateResultBuffer(modelCardsString); - speckleDict.SetAt(SPECKLE_MODEL_CARDS_KEY, xRec); - tr.AddNewlyCreatedDBObject(xRec, true); - } - } - - private static ResultBuffer CreateResultBuffer(string value) - { - int size = 1024; - var valueEncoded = Base64Encode(value); - var valueEncodedList = SplitString(valueEncoded, size); - - ResultBuffer rb = new(); - - foreach (string valueEncodedSplit in valueEncodedList) - { - rb.Add(new TypedValue((int)DxfCode.Text, valueEncodedSplit)); - } - - return rb; - } - - private static string GetXrecordData(Xrecord pXrecord) - { - StringBuilder valueEncoded = new(); - foreach (TypedValue typedValue in pXrecord.Data) - { - if (typedValue.TypeCode == (int)DxfCode.Text) - { - valueEncoded.Append(typedValue.Value.ToString()); - } - } - - return valueEncoded.ToString(); - } - - private static string Base64Encode(string plainText) - { - var plainTextBytes = System.Text.Encoding.UTF8.GetBytes(plainText); - return System.Convert.ToBase64String(plainTextBytes); - } - - private static string Base64Decode(string base64EncodedData) - { - var base64EncodedBytes = System.Convert.FromBase64String(base64EncodedData); - return System.Text.Encoding.UTF8.GetString(base64EncodedBytes); - } - - private static IEnumerable SplitString(string text, int chunkSize) - { - for (int offset = 0; offset < text.Length; offset += chunkSize) - { - int size = Math.Min(chunkSize, text.Length - offset); - yield return text.Substring(offset, size); - } - } -} diff --git a/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Utils/AutocadDocumentModelStore.cs b/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Utils/AutocadDocumentModelStore.cs deleted file mode 100644 index c846d80ba8..0000000000 --- a/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Utils/AutocadDocumentModelStore.cs +++ /dev/null @@ -1,82 +0,0 @@ -using System.Collections.Generic; -using Autodesk.AutoCAD.ApplicationServices; -using DUI3.Models; -using Application = Autodesk.AutoCAD.ApplicationServices.Core.Application; - -namespace AutocadCivilDUI3Shared.Utils; - -public class AutocadDocumentModelStore : DocumentModelStore -{ - private static Document Doc { get; set; } - private static string s_previousDocName; - - public AutocadDocumentModelStore() - { - if (Doc != null) - { - IsDocumentInit = true; - } - - Application.DocumentManager.DocumentToBeDestroyed += (_, _) => WriteToFile(); - Application.DocumentManager.DocumentActivated += (_, e) => OnDocChangeInternal(e.Document); - Autodesk.AutoCAD.ApplicationServices.Application.DocumentWindowCollection.DocumentWindowActivated += (_, args) => - OnDocChangeInternal(args.DocumentWindow.Document as Document); - } - - /// - /// Tracks whether the doc has been subscribed to save events. - /// TODO: two separate docs can have the same name, this is a brittle implementation - should be correlated with file location. - /// - private readonly List _saveToDocSubTracker = new(); - - private void OnDocChangeInternal(Document doc) - { - Doc = doc; - var nullDocName = "Null Doc"; - var currentDocName = doc != null ? doc.Name : nullDocName; - if (s_previousDocName == currentDocName) - { - return; - } - - s_previousDocName = doc != null ? doc.Name : nullDocName; - - if (doc != null && !_saveToDocSubTracker.Contains(doc.Name)) - { - doc.BeginDocumentClose += (_, _) => WriteToFile(); - doc.Database.BeginSave += (_, _) => WriteToFile(); - _saveToDocSubTracker.Add(doc.Name); - } - - ReadFromFile(); - OnDocumentChanged(); - } - - public override void ReadFromFile() - { - Models = new List(); - if (Doc == null) - { - return; - } - - string serializedModelCards = AutocadDocumentManager.ReadModelCards(Doc); - if (serializedModelCards == null) - { - return; - } - - Models = Deserialize(serializedModelCards); - } - - public override void WriteToFile() - { - if (Doc == null) - { - return; - } - - string modelCardsString = Serialize(); - AutocadDocumentManager.WriteModelCards(Doc, modelCardsString); - } -} diff --git a/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Utils/AutocadIdleManager.cs b/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Utils/AutocadIdleManager.cs deleted file mode 100644 index ac19493921..0000000000 --- a/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Utils/AutocadIdleManager.cs +++ /dev/null @@ -1,40 +0,0 @@ -using System; -using System.Collections.Concurrent; -using Autodesk.AutoCAD.ApplicationServices.Core; - -namespace AutocadCivilDUI3Shared.Utils; - -public static class AutocadIdleManager -{ - private static readonly ConcurrentDictionary s_sCalls = new(); - private static bool s_hasSubscribed; - - /// - /// Subscribe deferred action to RhinoIdle event to run it whenever Rhino become idle. - /// - /// Action to call whenever Rhino become Idle. - public static void SubscribeToIdle(Action action) - { - s_sCalls[action.Method.Name] = action; - - if (s_hasSubscribed) - { - return; - } - - s_hasSubscribed = true; - Application.Idle += OnIdleHandler; - } - - private static void OnIdleHandler(object sender, EventArgs e) - { - foreach (var kvp in s_sCalls) - { - kvp.Value(); - } - - s_sCalls.Clear(); - s_hasSubscribed = false; - Application.Idle -= OnIdleHandler; - } -} diff --git a/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Utils/Objects.cs b/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Utils/Objects.cs deleted file mode 100644 index 4fdd80d8c9..0000000000 --- a/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Utils/Objects.cs +++ /dev/null @@ -1,40 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using Autodesk.AutoCAD.ApplicationServices; -using Autodesk.AutoCAD.DatabaseServices; - -namespace AutocadCivilDUI3Shared.Utils; - -public static class Objects -{ - public static List<(DBObject obj, string layer, string applicationId)> GetObjectsFromDocument( - Document doc, - IEnumerable objectIds - ) - { - using DocumentLock acLckDoc = doc.LockDocument(); - var dbObjects = new List<(DBObject, string layer, string applicationId)>(); - using Transaction tr = doc.Database.TransactionManager.StartTransaction(); - foreach (var objectIdHandle in objectIds) - { - var handle = new Handle(Convert.ToInt64(objectIdHandle)); - var hasFoundObjectId = doc.Database.TryGetObjectId(handle, out ObjectId myObjectId); - if (!hasFoundObjectId) - { - continue; - } - - var dbObject = tr.GetObject(myObjectId, OpenMode.ForRead); - if (dbObject == null) - { - continue; - } - - var layer = (dbObject as Entity)?.Layer; - dbObjects.Add((dbObject, layer, objectIdHandle)); - } - tr.Commit(); - return dbObjects; - } -} diff --git a/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Utils/TransactionContext.cs b/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Utils/TransactionContext.cs deleted file mode 100644 index cda196ea10..0000000000 --- a/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Utils/TransactionContext.cs +++ /dev/null @@ -1,29 +0,0 @@ -using System; -using Autodesk.AutoCAD.ApplicationServices; -using Document = Autodesk.AutoCAD.ApplicationServices.Document; -using Autodesk.AutoCAD.DatabaseServices; - -namespace AutocadCivilDUI3Shared.Utils; - -public class TransactionContext : IDisposable -{ - private DocumentLock _documentLock; - private Transaction _transaction; - - public static TransactionContext StartTransaction(Document document) => new(document); - - private TransactionContext(Document document) - { - _documentLock = document.LockDocument(); - _transaction = document.Database.TransactionManager.StartTransaction(); - } - - public void Dispose() - { - _transaction?.Commit(); - _transaction = null; - - _documentLock?.Dispose(); - _documentLock = null; - } -} diff --git a/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Utils/Utils.cs b/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Utils/Utils.cs deleted file mode 100644 index 654b5d570a..0000000000 --- a/ConnectorAutocadCivil/AutocadCivilDUI3/AutocadCivilDUI3Shared/Utils/Utils.cs +++ /dev/null @@ -1,91 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Linq; -using System.Reflection; -using Autodesk.AutoCAD.ApplicationServices; -using Autodesk.AutoCAD.DatabaseServices; -using Autodesk.AutoCAD.EditorInput; -using Speckle.Core.Kits; - -namespace AutocadCivilDUI3Shared.Utils; - -public static class Utils -{ -#if AUTOCAD2021DUI3 - public static readonly string VersionedAppName = HostApplications.AutoCAD.GetVersion(HostAppVersion.v2021); - public static readonly string AppName = HostApplications.AutoCAD.Name; - public static readonly string Slug = HostApplications.AutoCAD.Slug; -#elif AUTOCAD2022DUI3 - public static readonly string VersionedAppName = HostApplications.AutoCAD.GetVersion(HostAppVersion.v2022); - public static readonly string AppName = HostApplications.AutoCAD.Name; - public static readonly string Slug = HostApplications.AutoCAD.Slug; -#elif AUTOCAD2023DUI3 - public static readonly string VersionedAppName = HostApplications.AutoCAD.GetVersion(HostAppVersion.v2023); - public static readonly string AppName = HostApplications.AutoCAD.Name; - public static readonly string Slug = HostApplications.AutoCAD.Slug; -#elif AUTOCAD2024DUI3 - public static readonly string VersionedAppName = HostApplications.AutoCAD.GetVersion(HostAppVersion.v2024); - public static readonly string AppName = HostApplications.AutoCAD.Name; - public static readonly string Slug = HostApplications.AutoCAD.Slug; -#endif - public static readonly string InvalidChars = @"<>/\:;""?*|=,‘"; - - public static string RemoveInvalidChars(string str) - { - foreach (char c in InvalidChars) - { - str = str.Replace(c.ToString(), string.Empty); - } - - return str; - } - - /// - /// Adds an entity to the autocad database model space record - /// - /// - /// - public static ObjectId Append(this Entity entity, string layer = null) - { - var db = entity.Database ?? Application.DocumentManager.MdiActiveDocument.Database; - Transaction tr = db.TransactionManager.TopTransaction; - if (tr == null) - { - return ObjectId.Null; - } - - BlockTableRecord btr = db.GetModelSpace(OpenMode.ForWrite); - if (entity.IsNewObject) - { - if (layer != null) - { - entity.Layer = layer; - } - - var id = btr.AppendEntity(entity); - tr.AddNewlyCreatedDBObject(entity, true); - return id; - } - else - { - if (layer != null) - { - entity.Layer = layer; - } - - return entity.Id; - } - } - - /// - /// Gets the document model space - /// - /// - /// - /// - public static BlockTableRecord GetModelSpace(this Database db, OpenMode mode = OpenMode.ForRead) - { - return (BlockTableRecord)SymbolUtilityServices.GetBlockModelSpaceId(db).GetObject(mode); - } -} diff --git a/ConnectorRevit/RevitDUI3/Revit2020DUI3/Properties/launchSettings.json b/ConnectorRevit/RevitDUI3/Revit2020DUI3/Properties/launchSettings.json deleted file mode 100644 index d9b9256495..0000000000 --- a/ConnectorRevit/RevitDUI3/Revit2020DUI3/Properties/launchSettings.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "profiles": { - "ConnectorRevit2020DUI3": { - "commandName": "Executable", - "executablePath": "C:\\Program Files\\Autodesk\\Revit 2020\\Revit.exe" - } - } -} diff --git a/ConnectorRevit/RevitDUI3/Revit2020DUI3/Revit2020DUI3.csproj b/ConnectorRevit/RevitDUI3/Revit2020DUI3/Revit2020DUI3.csproj deleted file mode 100644 index f4eface7ee..0000000000 --- a/ConnectorRevit/RevitDUI3/Revit2020DUI3/Revit2020DUI3.csproj +++ /dev/null @@ -1,67 +0,0 @@ - - - AnyCPU - true - Speckle.ConnectorRevitDUI3 - SpeckleConnectorRevitDUI3 - net48 - true - SpeckleRevit2DUI3 - 2020 - ConnectorRevitDUI3 - ConnectorRevitDUI3 - bin\$(Configuration)\ - true - $(DefineConstants);REVIT2020 - false - enable - - - x64 - false - - - x64 - false - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/ConnectorRevit/RevitDUI3/Revit2023DUI3/Properties/launchSettings.json b/ConnectorRevit/RevitDUI3/Revit2023DUI3/Properties/launchSettings.json deleted file mode 100644 index 79de978532..0000000000 --- a/ConnectorRevit/RevitDUI3/Revit2023DUI3/Properties/launchSettings.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "profiles": { - "ConnectorRevit2023DUI3": { - "commandName": "Executable", - "executablePath": "C:\\Program Files\\Autodesk\\Revit 2023\\Revit.exe" - } - } -} diff --git a/ConnectorRevit/RevitDUI3/Revit2023DUI3/Revit2023DUI3.csproj b/ConnectorRevit/RevitDUI3/Revit2023DUI3/Revit2023DUI3.csproj deleted file mode 100644 index 171427f0c2..0000000000 --- a/ConnectorRevit/RevitDUI3/Revit2023DUI3/Revit2023DUI3.csproj +++ /dev/null @@ -1,46 +0,0 @@ - - - AnyCPU - Speckle.ConnectorRevitDUI3 - SpeckleConnectorRevitDUI3 - net48 - true - SpeckleRevit2DUI3 - 2023 - ConnectorRevitDUI3 - ConnectorRevitDUI3 - bin\$(Configuration)\ - true - $(DefineConstants);REVIT2023 - false - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/ConnectorRevit/RevitDUI3/RevitDUI3Shared/Bindings/BasicConnectorBindingRevit.cs b/ConnectorRevit/RevitDUI3/RevitDUI3Shared/Bindings/BasicConnectorBindingRevit.cs deleted file mode 100644 index dcaec00fde..0000000000 --- a/ConnectorRevit/RevitDUI3/RevitDUI3Shared/Bindings/BasicConnectorBindingRevit.cs +++ /dev/null @@ -1,113 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using Autodesk.Revit.DB; -using Autodesk.Revit.UI; -using DUI3; -using DUI3.Bindings; -using DUI3.Models; -using Revit.Async; -using Sentry.Reflection; -using Speckle.ConnectorRevitDUI3.Utils; -using Speckle.Core.Kits; - -namespace Speckle.ConnectorRevitDUI3.Bindings; - -public class BasicConnectorBindingRevit : IBasicConnectorBinding -{ - public string Name { get; set; } = "baseBinding"; - public IBridge Parent { get; set; } - - // POC: statics should go - private static UIApplication RevitApp { get; set; } - private static UIDocument UiDocument => RevitApp.ActiveUIDocument; - private static Document Doc => UiDocument.Document; - - private readonly RevitDocumentStore _store; - - public BasicConnectorBindingRevit(RevitDocumentStore store) - { - RevitApp = RevitAppProvider.RevitApp; - _store = store; - _store.DocumentChanged += (_, _) => - { - BasicConnectorBindingCommands.NotifyDocumentChanged(Parent); - }; - } - - public string GetConnectorVersion() => Assembly.GetAssembly(GetType()).GetNameAndVersion().Version; - - public string GetSourceApplicationName() => HostApplications.Revit.Slug; - - public string GetSourceApplicationVersion() - { -#if REVIT2020 - return "2020"; -#endif -#if REVIT2023 - return "2023"; -#endif - } - - public DocumentInfo GetDocumentInfo() - { - if (UiDocument == null) - { - return null; - } - - return new DocumentInfo - { - Name = UiDocument.Document.Title, - Id = UiDocument.Document.GetHashCode().ToString(), - Location = UiDocument.Document.PathName - }; - } - - public DocumentModelStore GetDocumentState() => _store; - - public void AddModel(ModelCard model) - { - _store.Models.Add(model); - _store.WriteToFile(); - } - - public void UpdateModel(ModelCard model) - { - int idx = _store.Models.FindIndex(m => model.ModelCardId == m.ModelCardId); - _store.Models[idx] = model; - _store.WriteToFile(); - } - - public void RemoveModel(ModelCard model) - { - int index = _store.Models.FindIndex(m => m.ModelCardId == model.ModelCardId); - _store.Models.RemoveAt(index); - _store.WriteToFile(); - } - - public void HighlightModel(string modelCardId) - { - // TODO: Support receivers - var senderModelCard = _store.GetModelById(modelCardId) as SenderModelCard; - - var elementIds = senderModelCard.SendFilter.GetObjectIds().Select(ElementId.Parse).ToList(); - - if (elementIds.Count == 0) - { - BasicConnectorBindingCommands.SetModelError( - Parent, - modelCardId, - new OperationCanceledException("No objects found to highlight.") - ); - return; - } - - RevitTask.RunAsync(() => - { - UiDocument.Selection.SetElementIds(elementIds); - UiDocument.ShowElements(elementIds); - }); - } -} diff --git a/ConnectorRevit/RevitDUI3/RevitDUI3Shared/Bindings/Factory.cs b/ConnectorRevit/RevitDUI3/RevitDUI3Shared/Bindings/Factory.cs deleted file mode 100644 index 5e83874158..0000000000 --- a/ConnectorRevit/RevitDUI3/RevitDUI3Shared/Bindings/Factory.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System.Collections.Generic; -using DUI3; -using DUI3.Bindings; -using Speckle.ConnectorRevitDUI3.Utils; - -namespace Speckle.ConnectorRevitDUI3.Bindings; - -public static class Factory -{ - public static List CreateBindings(RevitDocumentStore store) - { - BasicConnectorBindingRevit baseBinding = new(store); - SelectionBinding selectionBinding = new(); - SendBinding sendBinding = new(store); - // TODO: Revit receive is very flaky right now, removing - // ReceiveBinding receiveBinding = new(store); - List bindingsList = - new() - { - new ConfigBinding("Revit"), - new AccountBinding(), - new TestBinding(), - baseBinding, - selectionBinding, - sendBinding, - // receiveBinding // See above note on receives - }; - - return bindingsList; - } -} diff --git a/ConnectorRevit/RevitDUI3/RevitDUI3Shared/Bindings/Filters.cs b/ConnectorRevit/RevitDUI3/RevitDUI3Shared/Bindings/Filters.cs deleted file mode 100644 index 02fda2e8e8..0000000000 --- a/ConnectorRevit/RevitDUI3/RevitDUI3Shared/Bindings/Filters.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System.Collections.Generic; -using System.Linq; -using DUI3.Bindings; - -namespace Speckle.ConnectorRevitDUI3.Bindings; - -// TODO: implement properly -public class RevitEverythingFilter : EverythingSendFilter -{ - public override List GetObjectIds() - { - return new List(); - } - - public override bool CheckExpiry(string[] changedObjectIds) - { - return true; - } -} - -public class RevitSelectionFilter : DirectSelectionSendFilter -{ - public override List GetObjectIds() - { - return SelectedObjectIds; - } - - public override bool CheckExpiry(string[] changedObjectIds) - { - return SelectedObjectIds.Intersect(changedObjectIds).Any(); - } -} diff --git a/ConnectorRevit/RevitDUI3/RevitDUI3Shared/Bindings/ReceiveBinding.cs b/ConnectorRevit/RevitDUI3/RevitDUI3Shared/Bindings/ReceiveBinding.cs deleted file mode 100644 index 14fe7684e6..0000000000 --- a/ConnectorRevit/RevitDUI3/RevitDUI3Shared/Bindings/ReceiveBinding.cs +++ /dev/null @@ -1,170 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading; -using Autodesk.Revit.DB; -using Autodesk.Revit.UI; -using DUI3; -using DUI3.Bindings; -using DUI3.Models.Card; -using DUI3.Utils; -using DUI3.Operations; -using Revit.Async; -using Speckle.ConnectorRevitDUI3.Utils; -using Speckle.Core.Kits; -using Speckle.Core.Logging; -using Speckle.Core.Models; - -namespace Speckle.ConnectorRevitDUI3.Bindings; - -public class ReceiveBinding : IBinding, ICancelable -{ - public string Name { get; set; } = "receiveBinding"; - public IBridge Parent { get; set; } - private readonly RevitDocumentStore _store; - private static UIApplication s_revitApp; - - private static Document Doc => UiDoc.Document; - private static UIDocument UiDoc => s_revitApp.ActiveUIDocument; - - public CancellationManager CancellationManager { get; } = new(); - - public ReceiveBinding(RevitDocumentStore store) - { - s_revitApp = RevitAppProvider.RevitApp; - _store = store; - } - - public void CancelReceive(string modelCardId) => CancellationManager.CancelOperation(modelCardId); - - public async void Receive(string modelCardId) - { - try - { - // 0 - Init cancellation token source -> Manager also cancel it if exist before - CancellationTokenSource cts = CancellationManager.InitCancellationTokenSource(modelCardId); - - // 1 - Get receiver card - ReceiverModelCard modelCard = _store.GetModelById(modelCardId) as ReceiverModelCard; - - // 2 - Get commit object from server - Base commitObject = await Operations.GetCommitBase(Parent, modelCard, cts.Token).ConfigureAwait(true); - - if (cts.IsCancellationRequested) - { - throw new OperationCanceledException(cts.Token); - } - - // 3 - Get converter - ISpeckleConverter converter = Converters.GetConverter(Doc, RevitAppProvider.Version()); - - // 4 - Traverse commit object - List objectsToConvert = Traversal.GetObjectsToConvert(commitObject, converter); - - // 5 - Bake objects - BakeObjects(objectsToConvert, converter, modelCardId, cts); - } - catch (Exception e) - { - if (e is OperationCanceledException) - { - return; - } - - BasicConnectorBindingCommands.SetModelError(Parent, modelCardId, e); - } - } - - private async void BakeObjects( - List objectsToConvert, - ISpeckleConverter converter, - string modelCardId, - CancellationTokenSource cts - ) - { - (bool success, Exception exception) = await RevitTask - .RunAsync(app => - { - string transactionName = $"Baking model from {modelCardId}"; - using TransactionGroup g = new(Doc, transactionName); - using Transaction t = new(Doc, transactionName); - g.Start(); - t.Start(); - - try - { - converter.SetContextDocument(t); - List errors = new(); - int count = 0; - - foreach (Base objToConvert in objectsToConvert) - { - count++; - if (cts.IsCancellationRequested) - { - throw new OperationCanceledException(cts.Token); - } - - try - { - double progress = (double)count / objectsToConvert.Count; - BasicConnectorBindingCommands.SetModelProgress( - Parent, - modelCardId, - new ModelCardProgress() { Status = "Converting", Progress = progress } - ); - - object convertedObject = converter.ConvertToNative(objToConvert); - RefreshView(); - } - catch (SpeckleException e) - { - errors.Add($"Object couldn't converted with id: {objToConvert.id}, type: {objToConvert.speckle_type}\n"); - Console.WriteLine(e); - } - } - - t.Commit(); - - if (t.GetStatus() == TransactionStatus.RolledBack) - { - int numberOfErrors = 0; // Previously get from errorEater - return ( - false, - new SpeckleException( - $"The Revit API could not resolve {numberOfErrors} unique errors and {numberOfErrors} total errors when trying to commit the Speckle model. The whole transaction is being rolled back." - ) - ); - } - - g.Assimilate(); - return (true, null); - } - catch (SpeckleException ex) - { - t.RollBack(); - g.RollBack(); - return (false, ex); //We can't throw exceptions in from RevitTask, but we can return it along with a success status - } - }) - .ConfigureAwait(false); - } - - private void RefreshView() - { - // regenerate the document and then implement a hack to "refresh" the view - UiDoc.Document.Regenerate(); - - // get the active ui view - View view = UiDoc.ActiveGraphicalView ?? UiDoc.ActiveView; - if (view is TableView) - { - return; - } - - UIView uiView = UiDoc.GetOpenUIViews().FirstOrDefault(uv => uv.ViewId.Equals(view.Id)); - - // "refresh" the active view - uiView?.Zoom(1); - } -} diff --git a/ConnectorRevit/RevitDUI3/RevitDUI3Shared/Bindings/SelectionBinding.cs b/ConnectorRevit/RevitDUI3/RevitDUI3Shared/Bindings/SelectionBinding.cs deleted file mode 100644 index 0162b3e7c6..0000000000 --- a/ConnectorRevit/RevitDUI3/RevitDUI3Shared/Bindings/SelectionBinding.cs +++ /dev/null @@ -1,46 +0,0 @@ -using System.Linq; -using Autodesk.Revit.UI; -using DUI3; -using DUI3.Bindings; -using Speckle.ConnectorRevitDUI3.Utils; - -namespace Speckle.ConnectorRevitDUI3.Bindings; - -public class SelectionBinding : ISelectionBinding -{ - public string Name { get; set; } = "selectionBinding"; - public IBridge Parent { get; set; } - private static UIApplication RevitApp { get; set; } - - public SelectionBinding() - { - RevitApp = RevitAppProvider.RevitApp; - - // TODO: Need to figure it out equivalent of SelectionChanged for Revit2020 -#if REVIT2023 - RevitApp.SelectionChanged += (_,_) => RevitIdleManager.SubscribeToIdle(OnSelectionChanged); -#endif - - RevitApp.ViewActivated += (_, _) => - { - Parent?.SendToBrowser(SelectionBindingEvents.SetSelection, new SelectionInfo()); - }; - } - - private void OnSelectionChanged() - { - var selectionInfo = GetSelection(); - Parent?.SendToBrowser(SelectionBindingEvents.SetSelection, selectionInfo); - } - - public SelectionInfo GetSelection() - { - // TODO: filter supported stuff - var selectionIds = RevitApp.ActiveUIDocument.Selection.GetElementIds().Select(id => id.ToString()).ToList(); - return new SelectionInfo() - { - SelectedObjectIds = selectionIds, - Summary = $"{selectionIds.Count} objects selected." - }; - } -} diff --git a/ConnectorRevit/RevitDUI3/RevitDUI3Shared/Bindings/SendBinding.cs b/ConnectorRevit/RevitDUI3/RevitDUI3Shared/Bindings/SendBinding.cs deleted file mode 100644 index 70f9c758a6..0000000000 --- a/ConnectorRevit/RevitDUI3/RevitDUI3Shared/Bindings/SendBinding.cs +++ /dev/null @@ -1,351 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Linq; -using System.Threading; -using Autodesk.Revit.UI; -using Autodesk.Revit.DB; -using DUI3; -using DUI3.Bindings; -using DUI3.Models.Card; -using DUI3.Operations; -using Speckle.ConnectorRevitDUI3.Utils; -using Speckle.Core.Kits; -using Speckle.Core.Credentials; -using Speckle.Core.Models; -using DUI3.Utils; -using RevitSharedResources.Interfaces; -using Speckle.Core.Api; - -namespace Speckle.ConnectorRevitDUI3.Bindings; - -public class SendBinding : ISendBinding, ICancelable -{ - public string Name { get; set; } = "sendBinding"; - public IBridge Parent { get; set; } - - private readonly RevitDocumentStore _store; - - private static UIApplication s_revitApp; - - private static Document Doc => s_revitApp.ActiveUIDocument.Document; - - public CancellationManager CancellationManager { get; } = new(); - - /// - /// Used internally to aggregate the changed objects' id. - /// - private HashSet ChangedObjectIds { get; set; } = new(); - - /// - /// Keeps track of previously converted objects as a dictionary of (applicationId, object reference). - /// - private readonly Dictionary _convertedObjectReferences = new(); - - /// - /// Thingie we ported from the DUI2 Era. - /// - private static IRevitDocumentAggregateCache revitDocumentAggregateCache; - - public SendBinding(RevitDocumentStore store) - { - s_revitApp = RevitAppProvider.RevitApp; - _store = store; - - s_revitApp.Application.DocumentChanged += (_, e) => StoreChangedElementIdsAndScheduleExpiryCheck(e); - revitDocumentAggregateCache = new RevitDocumentAggregateCache(new UIDocumentProvider(s_revitApp)); - } - - public List GetSendFilters() - { - return new List { new RevitSelectionFilter() { IsDefault = true } }; - } - - private Base ConvertElements( - List elements, - ISpeckleConverter converter, - string modelCardId, - CancellationTokenSource cts - ) - { - var commitObject = new Base(); - - var convertedObjects = new List(); - int count = 0; - foreach (var revitElement in elements) - { - if (cts.IsCancellationRequested) - { - throw new OperationCanceledException(); - } - - count++; - convertedObjects.Add(converter.ConvertToSpeckle(revitElement)); - double progress = (double)count / elements.Count; - BasicConnectorBindingCommands.SetModelProgress( - Parent, - modelCardId, - new ModelCardProgress() { Status = "Converting", Progress = progress } - ); - } - - commitObject["@elements"] = convertedObjects; - - return commitObject; - } - - public async void Send(string modelCardId) - { - try - { - // 0 - Init cancellation token source -> Manager also cancel it if exist before - CancellationTokenSource cts = CancellationManager.InitCancellationTokenSource(modelCardId); - - // 1 - Get model - SenderModelCard modelCard = _store.GetModelById(modelCardId) as SenderModelCard; - - // 2 - Check account exist - Account account = Accounts.GetAccount(modelCard.AccountId); - - // 3 - Get elements to convert - var ids = modelCard.SendFilter.GetObjectIds(); - var elements = new List(); - foreach (var id in ids) - { - var el = Doc.GetElement(ElementId.Parse(id)); - if (el != null) - { - elements.Add(el); - } - } - - if (elements.Count == 0) - { - throw new InvalidOperationException("No objects were found. Please update your send filter!"); - } - - // 4 - Get converter - ISpeckleConverter converter = Converters.GetConverter(Doc, RevitAppProvider.Version()); - converter.SetContextDocument(revitDocumentAggregateCache); - - // 5 - Convert objects - Base commitObject = ConvertElements(elements, converter, modelCard, cts); - - if (cts.IsCancellationRequested) - { - throw new OperationCanceledException(cts.Token); - } - - // 7 - Serialize and Send objects - BasicConnectorBindingCommands.SetModelProgress( - Parent, - modelCardId, - new ModelCardProgress { Status = "Uploading..." } - ); - - throw new InvalidOperationException( - "The next method does not know about the variable transports - string objectId = await Speckle.Core.Api.Operations" - + "\r\n.Send(commitObject, cts.Token, transports, disposeTransports: true)\r\n" - + ".ConfigureAwait(true);\r\n" - ); - - string objectId = await Speckle.Core.Api.Operations - .Send( - commitObject, - cts.Token, /* transports*/ - null, - disposeTransports: true - ) - .ConfigureAwait(true); - - BasicConnectorBindingCommands.SetModelProgress( - Parent, - modelCardId, - new ModelCardProgress { Status = "Linking version to model..." } - ); - - // 8 - Create Version - var apiClient = new Client(account); - string versionId = await apiClient - .CommitCreate( - new CommitCreateInput() - { - streamId = modelCard.ProjectId, - branchName = modelCard.ModelId, - sourceApplication = "Rhino", - objectId = objectId - }, - cts.Token - ) - .ConfigureAwait(true); - - SendBindingUiCommands.SetModelCreatedVersionId(Parent, modelCardId, versionId); - apiClient.Dispose(); - } -#pragma warning disable CA1031 - catch (Exception e) // All exceptions should be handled here if possible, otherwise we enter "crashing the host app" territory. -#pragma warning restore CA1031 - { - if (e is OperationCanceledException) - { - return; - } - - BasicConnectorBindingCommands.SetModelError(Parent, modelCardId, e); - } - } - - public void CancelSend(string modelCardId) => CancellationManager.CancelOperation(modelCardId); - - private Base ConvertElements( - List elements, - ISpeckleConverter converter, - SenderModelCard modelCard, - CancellationTokenSource cts - ) - { - int count = 0; - var rootObject = new Collection { name = Doc.PathName.Split('\\').Reverse().First().Split('.').First() }; - var collectionCache = new Dictionary(); - - foreach (var revitElement in elements) - { - if (cts.IsCancellationRequested) - { - throw new OperationCanceledException(); - } - - var cat = revitElement.Category.Name; - var level = Doc.GetElement(revitElement.LevelId) as Level; - var path = new[] { level == null ? "No level" : level.Name, cat }; - var collection = GetAndCreateObjectHostCollection(path, collectionCache, rootObject); - - count++; - try - { - Base converted; - var applicationId = revitElement.Id.ToString(); - if ( - !modelCard.ChangedObjectIds.Contains(applicationId) - && _convertedObjectReferences.TryGetValue(applicationId + modelCard.ProjectId, out ObjectReference value) - ) - { - converted = value; - } - else - { - converted = converter.ConvertToSpeckle(revitElement); - converted.applicationId = applicationId; - } - - collection.elements.Add(converted); - BasicConnectorBindingCommands.SetModelProgress( - Parent, - modelCard.ModelCardId, - new ModelCardProgress() { Status = "Converting", Progress = (double)count / elements.Count } - ); - } - catch (Exception e) - { - // TODO: Add to report, etc. - Debug.WriteLine(e.Message); - } - } - return rootObject; - } - - /// - /// Creates and nests collections based on the provided path within the root collection provided. This will not return a new collection each time is called, but an existing one if one is found. - /// For example, you can use this to use (or re-use) a new collection for a path of (level, category) as it's currently implemented. - /// - /// - /// - /// - /// - private Collection GetAndCreateObjectHostCollection( - IEnumerable path, - Dictionary cache, - Collection root - ) - { - string fullPathName = string.Join("", path); - if (cache.TryGetValue(fullPathName, out Collection value)) - { - return value; - } - - string flatPathName = ""; - Collection previousCollection = root; - - foreach (var pathItem in path) - { - flatPathName += pathItem; - Collection childCollection; - if (cache.ContainsKey(flatPathName)) - { - childCollection = cache[flatPathName]; - } - else - { - childCollection = new Collection(pathItem, "layer"); - previousCollection.elements.Add(childCollection); - cache[flatPathName] = childCollection; - } - - previousCollection = childCollection; - } - - return previousCollection; - } - - /// - /// Keeps track of the changed element ids as well as checks if any of them need to trigger - /// a filter refresh (e.g., views being added). - /// - /// - private void StoreChangedElementIdsAndScheduleExpiryCheck(Autodesk.Revit.DB.Events.DocumentChangedEventArgs e) - { - ICollection addedElementIds = e.GetAddedElementIds(); - ICollection deletedElementIds = e.GetDeletedElementIds(); - ICollection modifiedElementIds = e.GetModifiedElementIds(); - - foreach (ElementId elementId in addedElementIds) - { - ChangedObjectIds.Add(elementId.ToString()); - } - - foreach (ElementId elementId in deletedElementIds) - { - ChangedObjectIds.Add(elementId.ToString()); - } - - foreach (ElementId elementId in modifiedElementIds) - { - ChangedObjectIds.Add(elementId.ToString()); - } - - // TODO: CHECK IF ANY OF THE ABOVE ELEMENTS NEED TO TRIGGER A FILTER REFRESH - // POC: re-instate - // RevitIdleManager.SubscribeToIdle(RunExpirationChecks); - } - - private void RunExpirationChecks() - { - List senders = _store.GetSenders(); - List expiredSenderIds = new(); - string[] objectIdsList = ChangedObjectIds.ToArray(); - - foreach (var modelCard in senders) - { - var intersection = modelCard.SendFilter.GetObjectIds().Intersect(objectIdsList).ToList(); - bool isExpired = intersection.Any(); - if (isExpired) - { - expiredSenderIds.Add(modelCard.ModelCardId); - modelCard.ChangedObjectIds.UnionWith(intersection); - } - } - SendBindingUiCommands.SetModelsExpired(Parent, expiredSenderIds); - ChangedObjectIds = new HashSet(); - } -} diff --git a/ConnectorRevit/RevitDUI3/RevitDUI3Shared/CefSharpPanel.xaml b/ConnectorRevit/RevitDUI3/RevitDUI3Shared/CefSharpPanel.xaml deleted file mode 100644 index 67ccdb42f6..0000000000 --- a/ConnectorRevit/RevitDUI3/RevitDUI3Shared/CefSharpPanel.xaml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - diff --git a/ConnectorRevit/RevitDUI3/RevitDUI3Shared/CefSharpPanel.xaml.cs b/ConnectorRevit/RevitDUI3/RevitDUI3Shared/CefSharpPanel.xaml.cs deleted file mode 100644 index e9f6dc3336..0000000000 --- a/ConnectorRevit/RevitDUI3/RevitDUI3Shared/CefSharpPanel.xaml.cs +++ /dev/null @@ -1,29 +0,0 @@ -using System.Windows.Controls; -using Autodesk.Revit.UI; -using CefSharp; -using System.Windows.Threading; - -namespace Speckle.ConnectorRevitDUI3; - -public partial class CefSharpPanel : Page, Autodesk.Revit.UI.IDockablePaneProvider -{ - public CefSharpPanel() - { - InitializeComponent(); - } - - public void ExecuteScriptAsync(string script) => - Browser.Dispatcher.Invoke(() => Browser.ExecuteScriptAsync(script), DispatcherPriority.Background); - - public void ShowDevTools() => Browser.ShowDevTools(); - - public void SetupDockablePane(Autodesk.Revit.UI.DockablePaneProviderData data) - { - data.FrameworkElement = this; - data.InitialState = new Autodesk.Revit.UI.DockablePaneState - { - DockPosition = DockPosition.Tabbed, - TabBehind = Autodesk.Revit.UI.DockablePanes.BuiltInDockablePanes.ProjectBrowser - }; - } -} diff --git a/ConnectorRevit/RevitDUI3/RevitDUI3Shared/Entry.cs b/ConnectorRevit/RevitDUI3/RevitDUI3Shared/Entry.cs deleted file mode 100644 index 2f554e3021..0000000000 --- a/ConnectorRevit/RevitDUI3/RevitDUI3Shared/Entry.cs +++ /dev/null @@ -1,157 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.IO; -using System.Linq; -using System.Reflection; -using Autodesk.Revit.ApplicationServices; -using Autodesk.Revit.DB.Events; -using Autodesk.Revit.UI; -using CefSharp; -using DUI3; -using Revit.Async; -using Speckle.ConnectorRevitDUI3.Bindings; -using Speckle.ConnectorRevitDUI3.Utils; -using ArgumentException = Autodesk.Revit.Exceptions.ArgumentException; - -namespace Speckle.ConnectorRevitDUI3; - -public class App : IExternalApplication -{ - private static UIApplication AppInstance { get; set; } - private static UIControlledApplication UiCtrlApp { get; set; } - private static RevitDocumentStore RevitDocumentStore { get; set; } - - public Result OnStartup(UIControlledApplication application) - { - UiCtrlApp = application; - UiCtrlApp.ControlledApplication.ApplicationInitialized += ControlledApplicationOnApplicationInitialized; - CreateTabAndRibbonPanel(application); - - return Result.Succeeded; - } - - private void ControlledApplicationOnApplicationInitialized(object sender, ApplicationInitializedEventArgs e) - { - AppDomain.CurrentDomain.AssemblyResolve += OnAssemblyResolve; - AppInstance = new UIApplication(sender as Application); - RevitAppProvider.RevitApp = AppInstance; - RevitTask.Initialize(AppInstance); - - RegisterPanelAndInitializePlugin(AppInstance); - } - - private void CreateTabAndRibbonPanel(UIControlledApplication application) - { - string tabName = "Speckle"; - try - { - application.CreateRibbonTab(tabName); - } - catch (ArgumentException e) - { - Debug.WriteLine(e.Message); - } - - RibbonPanel specklePanel = application.CreateRibbonPanel(tabName, "Speckle 2 DUI3"); - PushButton _ = - specklePanel.AddItem( - new PushButtonData( - "Speckle 2 DUI3", - "Revit Connector", - typeof(App).Assembly.Location, - typeof(SpeckleRevitDui3Command).FullName - ) - ) as PushButton; - } - - internal static readonly DockablePaneId PanelId = new(new Guid("{85F73DA4-3EF4-4870-BDBC-FD2D238EED31}")); - public static CefSharpPanel CefSharpPanel { get; private set; } - - private void RegisterPanelAndInitializePlugin(UIApplication application) - { - CefSharpSettings.ConcurrentTaskExecution = true; - - CefSharpPanel = new CefSharpPanel(); - UiCtrlApp.RegisterDockablePane(PanelId, "Speckle DUI3", CefSharpPanel); - - RevitDocumentStore = new RevitDocumentStore(); - IEnumerable bridges = Factory - .CreateBindings(RevitDocumentStore) - .Select( - binding => - new BrowserBridge( - CefSharpPanel.Browser, - binding, - CefSharpPanel.ExecuteScriptAsync, - CefSharpPanel.ShowDevTools - ) - ); - -#if REVIT2020 - // Panel.Browser.JavascriptObjectRepository.NameConverter = null; // not available in cef65, we need the below - BindingOptions bindingOptions = new () { CamelCaseJavascriptNames = false }; -#endif - -#if REVIT2023 - CefSharpPanel.Browser.JavascriptObjectRepository.NameConverter = null; - BindingOptions bindingOptions = BindingOptions.DefaultBinder; -#endif - - CefSharpPanel.Browser.IsBrowserInitializedChanged += (sender, e) => - { - // TODO: check if it is actually initialised or not - foreach (BrowserBridge bridge in bridges) - { - CefSharpPanel.Browser.JavascriptObjectRepository.Register( - bridge.FrontendBoundName, - bridge, - true, - bindingOptions - ); - } - -#if REVIT2020 - // NOTE: Cef65 does not work with DUI3 in yarn dev mode. To test things you need to do `yarn build` and serve the build - // folder at port 3000 (or change it to something else if you want to). Guru meditation: Je sais, pas ideal. Mais q'est que nous pouvons faire? Rien. C'est l'autodesk vie. - // NOTE: To run the ui from a build, follow these steps: - // - run `yarn build` in the DUI3 folder - // - run ` PORT=3003 node .output/server/index.mjs` after the build - - CefSharpPanel.Browser.Load("http://localhost:3003"); - CefSharpPanel.Browser.ShowDevTools(); -#endif - -#if REVIT2023 - CefSharpPanel.Browser.Load("http://localhost:8082"); -#endif - }; - } - - public Result OnShutdown(UIControlledApplication application) => Result.Succeeded; - - /// - /// Prevents some dll conflicts. - /// - /// - /// - /// - private static Assembly OnAssemblyResolve(object sender, ResolveEventArgs args) - { - Assembly assembly = null; - string name = args.Name.Split(',')[0]; - string path = Path.GetDirectoryName(typeof(App).Assembly.Location); - - if (path != null) - { - string assemblyFile = Path.Combine(path, name + ".dll"); - - if (File.Exists(assemblyFile)) - { - assembly = Assembly.LoadFrom(assemblyFile); - } - } - - return assembly; - } -} diff --git a/ConnectorRevit/RevitDUI3/RevitDUI3Shared/RevitDUI3Shared.projitems b/ConnectorRevit/RevitDUI3/RevitDUI3Shared/RevitDUI3Shared.projitems deleted file mode 100644 index f3a47a4072..0000000000 --- a/ConnectorRevit/RevitDUI3/RevitDUI3Shared/RevitDUI3Shared.projitems +++ /dev/null @@ -1,37 +0,0 @@ - - - - $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - true - 7917CDBC-7BCF-4EE0-A80F-500C626468BA - - - RevitDUI3Shared - - - - - - - - - - - Panel.xaml - - - - - - - - - - - Always - - - - - - \ No newline at end of file diff --git a/ConnectorRevit/RevitDUI3/RevitDUI3Shared/RevitDUI3Shared.shproj b/ConnectorRevit/RevitDUI3/RevitDUI3Shared/RevitDUI3Shared.shproj deleted file mode 100644 index 37cf5dcb76..0000000000 --- a/ConnectorRevit/RevitDUI3/RevitDUI3Shared/RevitDUI3Shared.shproj +++ /dev/null @@ -1,11 +0,0 @@ - - - - {3D7F0278-6CF2-4588-A101-4027ABB8B87F} - - - - - - - diff --git a/ConnectorRevit/RevitDUI3/RevitDUI3Shared/SpeckleRevit2DUI3.addin b/ConnectorRevit/RevitDUI3/RevitDUI3Shared/SpeckleRevit2DUI3.addin deleted file mode 100644 index 80e2f6ac7c..0000000000 --- a/ConnectorRevit/RevitDUI3/RevitDUI3Shared/SpeckleRevit2DUI3.addin +++ /dev/null @@ -1,12 +0,0 @@ - - - - Speckle 2 for Revit DUI3 (Experimental) - Speckle Connector for Revit DUI3 (Experimental) - SpeckleRevit2DUI3\SpeckleConnectorRevitDUI3.dll - Speckle.ConnectorRevitDUI3.App - 56F4C629-BB39-4023-804B-307AA9749792 - speckle - Speckle: Empowering your design and construction data. For any problems, visit our community forum https://speckle.community - - diff --git a/ConnectorRevit/RevitDUI3/RevitDUI3Shared/SpeckleRevitDUI3Command.cs b/ConnectorRevit/RevitDUI3/RevitDUI3Shared/SpeckleRevitDUI3Command.cs deleted file mode 100644 index e3b33f8b9b..0000000000 --- a/ConnectorRevit/RevitDUI3/RevitDUI3Shared/SpeckleRevitDUI3Command.cs +++ /dev/null @@ -1,18 +0,0 @@ -using Autodesk.Revit.Attributes; -using Autodesk.Revit.DB; -using Autodesk.Revit.UI; -using CefSharp; - -namespace Speckle.ConnectorRevitDUI3; - -[Transaction(TransactionMode.Manual)] -public class SpeckleRevitDui3Command : IExternalCommand -{ - public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) - { - DockablePane panel = commandData.Application.GetDockablePane(App.PanelId); - panel.Show(); - - return Result.Succeeded; - } -} diff --git a/ConnectorRevit/RevitDUI3/RevitDUI3Shared/Utils/PortedOverStuff.cs b/ConnectorRevit/RevitDUI3/RevitDUI3Shared/Utils/PortedOverStuff.cs deleted file mode 100644 index 8bcada0259..0000000000 --- a/ConnectorRevit/RevitDUI3/RevitDUI3Shared/Utils/PortedOverStuff.cs +++ /dev/null @@ -1,187 +0,0 @@ -#nullable enable -using UI = Autodesk.Revit.UI; -using System; -using System.Collections.Generic; -using Autodesk.Revit.DB; -using RevitSharedResources.Interfaces; - -namespace Speckle.ConnectorRevitDUI3.Utils; - -// -// Do note, these are copy-pasted constructs from the dui2 connector. -// - -/// -/// Provides the current to any dependencies which may need it -/// -public class UIDocumentProvider -{ - private UI.UIApplication revitApplication; - - public UIDocumentProvider(UI.UIApplication revitApplication) - { - this.revitApplication = revitApplication; - } - - private UI.UIDocument uiDocument; - - public UI.UIDocument Entity - { - get => uiDocument ?? revitApplication.ActiveUIDocument; - set => uiDocument = value; - } -} - -/// -/// Simple conversion cache to store elements that are retrieved and may be needed again throughout the conversion operation -/// -public sealed class RevitDocumentAggregateCache : IRevitDocumentAggregateCache -{ - private readonly Dictionary objectCaches; - private readonly UIDocumentProvider uiDocumentProvider; - public Document Document => uiDocumentProvider.Entity.Document; - - public RevitDocumentAggregateCache(UIDocumentProvider uiDocumentProvider) - { - this.uiDocumentProvider = uiDocumentProvider; - this.objectCaches = new(); - } - - public IRevitObjectCache GetOrInitializeEmptyCacheOfType(out bool isExistingCache) - { - return GetOrInitializeCacheOfTypeNullable(null, out isExistingCache); - } - - public IRevitObjectCache GetOrInitializeCacheOfType( - Action> initializer, - out bool isExistingCache - ) - { - return GetOrInitializeCacheOfTypeNullable(initializer, out isExistingCache); - } - - private IRevitObjectCache GetOrInitializeCacheOfTypeNullable( - Action>? initializer, - out bool isExistingCache - ) - { - if (!objectCaches.TryGetValue(typeof(T), out var singleCache)) - { - isExistingCache = false; - singleCache = new RevitObjectCache(this); - if (initializer != null) - { - initializer((IRevitObjectCache)singleCache); - } - objectCaches.Add(typeof(T), singleCache); - } - else - { - isExistingCache = true; - } - return (IRevitObjectCache)singleCache; - } - - public IRevitObjectCache? TryGetCacheOfType() - { - if (!objectCaches.TryGetValue(typeof(T), out var singleCache)) - { - return null; - } - return singleCache as IRevitObjectCache; - } - - public void Invalidate() - { - objectCaches.Remove(typeof(T)); - } - - public void InvalidateAll() - { - objectCaches.Clear(); - } -} - -/// -/// Storage of a single type of object in the -/// -/// -internal class RevitObjectCache : IRevitObjectCache -{ - private readonly Dictionary dataStorage; - public IRevitDocumentAggregateCache ParentCache { get; } - - public RevitObjectCache(IRevitDocumentAggregateCache parentCache) - { - ParentCache = parentCache; - dataStorage = new(); - } - - public T GetOrAdd(string key, Func factory, out bool isExistingValue) - { - if (!dataStorage.TryGetValue(key, out var value)) - { - isExistingValue = false; - value = factory(); - dataStorage.Add(key, value); - } - else - { - isExistingValue = true; - } - - return value; - } - - public T? TryGet(string key) - { - if (!dataStorage.TryGetValue(key, out var value)) - { - return default(T); - } - - return value; - } - - public bool ContainsKey(string key) - { - return dataStorage.ContainsKey(key); - } - - public ICollection GetAllKeys() - { - return dataStorage.Keys; - } - - public ICollection GetAllObjects() - { - return dataStorage.Values; - } - - public void Set(string key, T value) - { - dataStorage[key] = value; - } - - public void AddMany(IEnumerable elements, Func keyFactory) - { - foreach (var element in elements) - { - var key = keyFactory(element); - dataStorage[key] = element; - } - } - - public void AddMany(Dictionary elementMap) - { - foreach (var kvp in elementMap) - { - dataStorage[kvp.Key] = kvp.Value; - } - } - - public void Remove(string key) - { - dataStorage.Remove(key); - } -} diff --git a/ConnectorRevit/RevitDUI3/RevitDUI3Shared/Utils/RevitAppProvider.cs b/ConnectorRevit/RevitDUI3/RevitDUI3Shared/Utils/RevitAppProvider.cs deleted file mode 100644 index 9f585dfe91..0000000000 --- a/ConnectorRevit/RevitDUI3/RevitDUI3Shared/Utils/RevitAppProvider.cs +++ /dev/null @@ -1,22 +0,0 @@ -using Autodesk.Revit.UI; - -namespace Speckle.ConnectorRevitDUI3.Utils; - -public static class RevitAppProvider -{ - /// - /// This property gets initialized in the plugin entry, on app initialization. - /// We should be able to use this in any place where we need the revit app! - /// - public static UIApplication RevitApp { get; set; } - - public static string Version() - { -#if REVIT2020 - return "Revit2020"; -#endif -#if REVIT2023 - return "Revit2023"; -#endif - } -} diff --git a/ConnectorRevit/RevitDUI3/RevitDUI3Shared/Utils/RevitDocumentStore.cs b/ConnectorRevit/RevitDUI3/RevitDUI3Shared/Utils/RevitDocumentStore.cs deleted file mode 100644 index 662a9011b7..0000000000 --- a/ConnectorRevit/RevitDUI3/RevitDUI3Shared/Utils/RevitDocumentStore.cs +++ /dev/null @@ -1,138 +0,0 @@ -using System; -using System.Collections.Generic; -using Autodesk.Revit.DB; -using Autodesk.Revit.DB.ExtensibleStorage; -using Autodesk.Revit.UI; -using DUI3.Models; -using Revit.Async; -using Speckle.Core.Logging; - -namespace Speckle.ConnectorRevitDUI3.Utils; - -public class RevitDocumentStore : DocumentModelStore -{ - // POC: statics to come out - private static UIApplication RevitApp { get; set; } - private static UIDocument CurrentDoc => RevitApp.ActiveUIDocument; - - private static readonly Guid s_guid = new("D35B3695-EDC9-4E15-B62A-D3FC2CB83FA3"); - - public RevitDocumentStore() - { - RevitApp = RevitAppProvider.RevitApp; - - RevitApp.ApplicationClosing += (_, _) => WriteToFile(); - RevitApp.Application.DocumentSaving += (_, _) => WriteToFile(); - RevitApp.Application.DocumentSynchronizingWithCentral += (_, _) => WriteToFile(); - - RevitApp.ViewActivated += (_, e) => - { - if (e.Document == null) - { - return; - } - - if (e.PreviousActiveView?.Document.PathName == e.CurrentActiveView.Document.PathName) - { - return; - } - - IsDocumentInit = true; - ReadFromFile(); - OnDocumentChanged(); - }; - - RevitApp.Application.DocumentOpening += (_, _) => IsDocumentInit = false; - RevitApp.Application.DocumentOpened += (_, _) => IsDocumentInit = false; - } - - public override void WriteToFile() - { - if (CurrentDoc == null) - { - return; - } - - RevitTask.RunAsync(() => - { - using Transaction t = new(CurrentDoc.Document, "Speckle Write State"); - t.Start(); - using DataStorage ds = GetSettingsDataStorage(CurrentDoc.Document) ?? DataStorage.Create(CurrentDoc.Document); - - using Entity stateEntity = new(DocumentModelStoreSchema.GetSchema()); - string serializedModels = Serialize(); - stateEntity.Set("contents", serializedModels); - - using Entity idEntity = new(IdStorageSchema.GetSchema()); - idEntity.Set("Id", s_guid); - - ds.SetEntity(idEntity); - ds.SetEntity(stateEntity); - t.Commit(); - }); - } - - public override void ReadFromFile() - { - try - { - Entity stateEntity = GetSpeckleEntity(CurrentDoc.Document); - if (stateEntity == null || !stateEntity.IsValid()) - { - Models = new List(); - return; - } - - string modelsString = stateEntity.Get("contents"); - Models = Deserialize(modelsString); - } - catch (SpeckleException) - { - Models = new List(); - } - } - - private static DataStorage GetSettingsDataStorage(Document doc) - { - using FilteredElementCollector collector = new(doc); - FilteredElementCollector dataStorages = collector.OfClass(typeof(DataStorage)); - - foreach (Element element in dataStorages) - { - DataStorage dataStorage = (DataStorage)element; - Entity settingIdEntity = dataStorage.GetEntity(IdStorageSchema.GetSchema()); - if (!settingIdEntity.IsValid()) - { - continue; - } - - Guid id = settingIdEntity.Get("Id"); - if (!id.Equals(s_guid)) - { - continue; - } - - return dataStorage; - } - return null; - } - - private static Entity GetSpeckleEntity(Document doc) - { - using FilteredElementCollector collector = new(doc); - - FilteredElementCollector dataStorages = collector.OfClass(typeof(DataStorage)); - foreach (Element element in dataStorages) - { - DataStorage dataStorage = (DataStorage)element; - Entity settingEntity = dataStorage.GetEntity(DocumentModelStoreSchema.GetSchema()); - if (!settingEntity.IsValid()) - { - continue; - } - - return settingEntity; - } - return null; - } -} diff --git a/ConnectorRevit/RevitDUI3/RevitDUI3Shared/Utils/RevitIdleManager.cs b/ConnectorRevit/RevitDUI3/RevitDUI3Shared/Utils/RevitIdleManager.cs deleted file mode 100644 index 31afaed753..0000000000 --- a/ConnectorRevit/RevitDUI3/RevitDUI3Shared/Utils/RevitIdleManager.cs +++ /dev/null @@ -1,39 +0,0 @@ -using System; -using System.Collections.Generic; -using Autodesk.Revit.UI.Events; - -namespace Speckle.ConnectorRevitDUI3.Utils; - -public static class RevitIdleManager -{ - private static Dictionary s_calls = new(); - private static bool s_hasSubscribed; - - /// - /// Subscribe deferred action to Idling event to run it whenever Revit becomes idle. - /// - /// Action to call whenever Revit becomes Idle. - public static void SubscribeToIdle(Action action) - { - s_calls[action.Method.Name ?? Guid.NewGuid().ToString()] = action; - - if (s_hasSubscribed) - { - return; - } - - s_hasSubscribed = true; - RevitAppProvider.RevitApp.Idling += RevitAppOnIdle; - } - - private static void RevitAppOnIdle(object sender, IdlingEventArgs e) - { - foreach (KeyValuePair kvp in s_calls) - { - kvp.Value(); - } - s_calls = new Dictionary(); - s_hasSubscribed = false; - RevitAppProvider.RevitApp.Idling -= RevitAppOnIdle; - } -} diff --git a/ConnectorRevit/RevitDUI3/RevitDUI3Shared/Utils/Schemas.cs b/ConnectorRevit/RevitDUI3/RevitDUI3Shared/Utils/Schemas.cs deleted file mode 100644 index fe609d2056..0000000000 --- a/ConnectorRevit/RevitDUI3/RevitDUI3Shared/Utils/Schemas.cs +++ /dev/null @@ -1,42 +0,0 @@ -using System; -using Autodesk.Revit.DB.ExtensibleStorage; - -namespace Speckle.ConnectorRevitDUI3.Utils; - -public static class DocumentModelStoreSchema -{ - private static readonly Guid s_schemaGuid = new("D690F2B4-BDB0-4CB4-8657-17844ADF42AA"); - - public static Schema GetSchema() - { - Schema schema = Schema.Lookup(s_schemaGuid); - if (schema != null) - { - return schema; - } - - using SchemaBuilder builder = new(s_schemaGuid); - builder.SetSchemaName("DUI3State"); - builder.AddSimpleField("contents", typeof(string)); - return builder.Finish(); - } -} - -public static class IdStorageSchema -{ - private static readonly Guid s_schemaGuid = new("D0E2AD18-0DE0-41CF-A2B7-5384267061D7"); - - public static Schema GetSchema() - { - Schema schema = Schema.Lookup(s_schemaGuid); - if (schema != null) - { - return schema; - } - - using SchemaBuilder builder = new(s_schemaGuid); - builder.SetSchemaName("DataStorageUniqueId"); - builder.AddSimpleField("Id", typeof(Guid)); - return builder.Finish(); - } -} diff --git a/ConnectorRhino/ConnectorRhinoWebUI/Bindings/BasicConnectorBinding.cs b/ConnectorRhino/ConnectorRhinoWebUI/Bindings/BasicConnectorBinding.cs deleted file mode 100644 index 7078c5c4c3..0000000000 --- a/ConnectorRhino/ConnectorRhinoWebUI/Bindings/BasicConnectorBinding.cs +++ /dev/null @@ -1,117 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using ConnectorRhinoWebUI.Extensions; -using ConnectorRhinoWebUI.Utils; -using DUI3; -using DUI3.Bindings; -using DUI3.Models; -using Rhino; -using Rhino.DocObjects; -using Rhino.Geometry; -using Sentry.Reflection; - -namespace ConnectorRhinoWebUI.Bindings; - -public class BasicConnectorBinding : IBasicConnectorBinding -{ - public string Name { get; set; } = "baseBinding"; - public IBridge Parent { get; set; } - private readonly RhinoDocumentStore _store; - - public BasicConnectorBinding(RhinoDocumentStore store) - { - _store = store; - _store.DocumentChanged += (_, _) => - { - BasicConnectorBindingCommands.NotifyDocumentChanged(Parent); - }; - } - - public string GetConnectorVersion() => Assembly.GetAssembly(GetType()).GetNameAndVersion().Version; - - public string GetSourceApplicationName() => "Rhino"; - - public string GetSourceApplicationVersion() => "7"; - - public DocumentInfo GetDocumentInfo() => - new() - { - Location = RhinoDoc.ActiveDoc.Path, - Name = RhinoDoc.ActiveDoc.Name, - Id = RhinoDoc.ActiveDoc.RuntimeSerialNumber.ToString() - }; - - public DocumentModelStore GetDocumentState() => _store; - - public void AddModel(ModelCard model) => _store.Models.Add(model); - - public void UpdateModel(ModelCard model) - { - int idx = _store.Models.FindIndex(m => model.ModelCardId == m.ModelCardId); - _store.Models[idx] = model; - } - - public void RemoveModel(ModelCard model) - { - int index = _store.Models.FindIndex(m => m.ModelCardId == model.ModelCardId); - _store.Models.RemoveAt(index); - } - - public void HighlightModel(string modelCardId) - { - var objectIds = new List(); - var myModel = _store.GetModelById(modelCardId); - - if (myModel is SenderModelCard sender) - { - objectIds = sender.SendFilter.GetObjectIds(); - } - - if (myModel is ReceiverModelCard receiver && receiver.ReceiveResult != null) - { - objectIds = receiver.ReceiveResult.BakedObjectIds; - } - - if (objectIds.Count == 0) - { - BasicConnectorBindingCommands.SetModelError( - Parent, - modelCardId, - new OperationCanceledException("No objects found to highlight.") - ); - return; - } - - List rhinoObjects = objectIds - .Select((id) => RhinoDoc.ActiveDoc.Objects.FindId(new Guid(id))) - .Where(o => o != null) - .ToList(); - - RhinoDoc.ActiveDoc.Objects.UnselectAll(); - - if (rhinoObjects.Count == 0) - { - BasicConnectorBindingCommands.SetModelError( - Parent, - modelCardId, - new OperationCanceledException("No objects found to highlight.") - ); - return; - } - - RhinoDoc.ActiveDoc.Objects.Select(rhinoObjects.Select(o => o.Id)); - - // Calculate the bounding box of the selected objects - BoundingBox boundingBox = BoundingBoxExtensions.UnionRhinoObjects(rhinoObjects); - - // Zoom to the calculated bounding box - if (boundingBox.IsValid) - { - RhinoDoc.ActiveDoc.Views.ActiveView.ActiveViewport.ZoomBoundingBox(boundingBox); - } - - RhinoDoc.ActiveDoc.Views.Redraw(); - } -} diff --git a/ConnectorRhino/ConnectorRhinoWebUI/Bindings/Factory.cs b/ConnectorRhino/ConnectorRhinoWebUI/Bindings/Factory.cs deleted file mode 100644 index 7c30d71704..0000000000 --- a/ConnectorRhino/ConnectorRhinoWebUI/Bindings/Factory.cs +++ /dev/null @@ -1,54 +0,0 @@ -using System.Collections.Generic; -using ConnectorRhinoWebUI.Utils; -using DUI3; -using DUI3.Bindings; -using DUI3.Onboarding; - -namespace ConnectorRhinoWebUI.Bindings; - -/// -/// Creates the required bindings, in the correct order, and scaffolds any dependencies. -/// -public static class Factory -{ - private static readonly RhinoDocumentStore s_store = new(); - - public static List CreateBindings() - { - BasicConnectorBinding baseBindings = new(s_store); - SendBinding sendBindings = new(s_store); - ReceiveBinding receiveBindings = new(s_store); - SelectionBinding selectionBindings = new(); - - // Where we pass connector specific onboardings to config binding. - // Below code is just a sample for now! - Dictionary sampleOnboardingsData = - new() - { - { - "mapper", - new OnboardingData() - { - Title = "Mapper", - Blurb = "Map your objects for Revit!", - Completed = false, - Page = "/onboarding/rhino/mapper" - } - } - }; - - List bindingsList = - new() - { - new ConfigBinding(Utils.Utils.AppName, sampleOnboardingsData), - new AccountBinding(), - new TestBinding(), - baseBindings, - sendBindings, - receiveBindings, - selectionBindings - }; - - return bindingsList; - } -} diff --git a/ConnectorRhino/ConnectorRhinoWebUI/Bindings/Filters.cs b/ConnectorRhino/ConnectorRhinoWebUI/Bindings/Filters.cs deleted file mode 100644 index 429fe9d152..0000000000 --- a/ConnectorRhino/ConnectorRhinoWebUI/Bindings/Filters.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System.Collections.Generic; -using System.Linq; -using DUI3.Bindings; -using DUI3.Models; -using Rhino; - -namespace ConnectorRhinoWebUI.Bindings; - -public class RhinoEverythingFilter : EverythingSendFilter -{ - public override List GetObjectIds() => new(); // TODO - - public override bool CheckExpiry(string[] changedObjectIds) => true; -} - -public class RhinoSelectionFilter : DirectSelectionSendFilter -{ - public override List GetObjectIds() => SelectedObjectIds; - - public override bool CheckExpiry(string[] changedObjectIds) => SelectedObjectIds.Intersect(changedObjectIds).Any(); -} diff --git a/ConnectorRhino/ConnectorRhinoWebUI/Bindings/ReceiveBinding.cs b/ConnectorRhino/ConnectorRhinoWebUI/Bindings/ReceiveBinding.cs deleted file mode 100644 index a91ad26940..0000000000 --- a/ConnectorRhino/ConnectorRhinoWebUI/Bindings/ReceiveBinding.cs +++ /dev/null @@ -1,215 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Threading; -using DUI3; -using DUI3.Bindings; -using DUI3.Models; -using DUI3.Models.Card; -using DUI3.Operations; -using DUI3.Settings; -using DUI3.Utils; -using Rhino; -using Rhino.DocObjects; -using Rhino.Geometry; -using Speckle.Core.Kits; -using Speckle.Core.Models; - -using ICancelable = DUI3.Operations.ICancelable; - -namespace ConnectorRhinoWebUI.Bindings; - -public class ReceiveBinding : IReceiveBinding, ICancelable -{ - public string Name { get; set; } = "receiveBinding"; - public IBridge Parent { get; set; } - - private readonly DocumentModelStore _store; - - private RhinoDoc Doc => RhinoDoc.ActiveDoc; - - public CancellationManager CancellationManager { get; } = new(); - - public ReceiveBinding(DocumentModelStore store) - { - _store = store; - } - - public void CancelReceive(string modelCardId) => CancellationManager.CancelOperation(modelCardId); - - public async void Receive(string modelCardId) - { - try - { - // 0 - Init cancellation token source -> Manager also cancel it if exist before - CancellationTokenSource cts = CancellationManager.InitCancellationTokenSource(modelCardId); - - // 1 - Get receiver card - ReceiverModelCard modelCard = _store.GetModelById(modelCardId) as ReceiverModelCard; - - BasicConnectorBindingCommands.SetModelProgress( - Parent, - modelCardId, - new ModelCardProgress() { Status = "Downloading" } - ); - - // 2 - Get commit object from server - Base commitObject = await Operations.GetCommitBase(Parent, modelCard, cts.Token).ConfigureAwait(true); - - if (cts.IsCancellationRequested) - { - throw new OperationCanceledException(cts.Token); - } - - // 3 - Get converter - ISpeckleConverter converter = Converters.GetConverter(Doc, "Rhino7"); - - var objectsToConvert = new List<(List, Base)>(); - - BasicConnectorBindingCommands.SetModelProgress( - Parent, - modelCardId, - new ModelCardProgress() { Status = "Parsing structure" } - ); - - foreach ( - var (objPath, obj) in commitObject.TraverseWithPath( - obj => obj is not Collection && converter.CanConvertToNative(obj) - ) - ) // note the "obj is not collection" is working around a bug of sorts in the rh converter where we assume collections always have a collectionType; also unsure why collection to layer is in the converter (it's fine, but weird) - { - if (cts.IsCancellationRequested) - { - throw new OperationCanceledException(cts.Token); - } - - if (obj is not Collection && converter.CanConvertToNative(obj)) - { - objectsToConvert.Add((objPath, obj)); - } - } - - var baseLayerName = $"Project {modelCard.ProjectName}: Model {modelCard.ModelName}"; - var convertedIds = BakeObjects(objectsToConvert, baseLayerName, modelCardId, cts, converter); - - var receiveResult = new ReceiveResult() { BakedObjectIds = convertedIds, Display = true }; - - ReceiveBindingUiCommands.SetModelConversionResult(Parent, modelCardId, receiveResult); - - // 7 - Redraw the view to render baked objects - Doc.Views.Redraw(); - } - catch (Exception e) - { - if (e is OperationCanceledException) // We do not want to display an error, we just stop sending. - { - return; - } - - BasicConnectorBindingCommands.SetModelError(Parent, modelCardId, e); // NOTE: should be a shard UI binding command - } - } - - private List BakeObjects( - List<(List, Base)> objects, - string baseLayerName, - string modelCardId, - CancellationTokenSource cts, - ISpeckleConverter converter - ) - { - // LETS FUCK AROUND AND FIND OUT - var rootLayerName = baseLayerName; - var rootLayerIndex = Doc.Layers.Find(rootLayerName, true); - - if (rootLayerIndex >= 0) - { - foreach (var layer in RhinoDoc.ActiveDoc.Layers[rootLayerIndex].GetChildren()) - { - RhinoDoc.ActiveDoc.Layers.Purge(layer.Index, false); - } - } - - var cache = new Dictionary(); - rootLayerIndex = Doc.Layers.Add(new Layer() { Name = rootLayerName }); - cache.Add(rootLayerName, rootLayerIndex); - - var newObjectIds = new List(); - var count = 0; - foreach (var (path, baseObj) in objects) - { - if (cts.IsCancellationRequested) - { - throw new OperationCanceledException(cts.Token); - } - var fullLayerName = string.Join("::", path); - var layerIndex = -1; - if (cache.ContainsKey(fullLayerName)) - { - layerIndex = cache[fullLayerName]; - } - - if (layerIndex == -1) - { - layerIndex = GetAndCreateLayerFromPath(path, rootLayerName, cache); - } - - BasicConnectorBindingCommands.SetModelProgress( - Parent, - modelCardId, - new ModelCardProgress() { Status = "Converting & creating objects", Progress = (double)++count / objects.Count } - ); - - var converted = converter.ConvertToNative(baseObj); - if (converted is GeometryBase newObject) - { - var newObjectGuid = Doc.Objects.Add(newObject, new ObjectAttributes() { LayerIndex = layerIndex }); - newObjectIds.Add(newObjectGuid.ToString()); - } - // else something weird happened? a block maybe? also, blocks are treated like $$$ now tbh so i won't dive into them - } - - return newObjectIds; - } - - private int GetAndCreateLayerFromPath(List path, string baseLayerName, Dictionary cache) - { - var currentLayerName = baseLayerName; - var previousLayer = Doc.Layers.FindName(currentLayerName); - foreach (var layerName in path) - { - currentLayerName = baseLayerName + Layer.PathSeparator + layerName; - currentLayerName = currentLayerName.Replace("{", "").Replace("}", ""); // Rhino specific cleanup for gh (see RemoveInvalidRhinoChars) - if (cache.TryGetValue(currentLayerName, out int value)) - { - previousLayer = Doc.Layers.FindIndex(value); - continue; - } - var cleanNewLayerName = layerName.Replace("{", "").Replace("}", ""); - var newLayer = new Layer() { Name = cleanNewLayerName, ParentLayerId = previousLayer.Id }; - var index = Doc.Layers.Add(newLayer); - cache.Add(currentLayerName, index); - previousLayer = Doc.Layers.FindIndex(index); // note we need to get the correct id out, hence why we're double calling this - } - return previousLayer.Index; - } - - public List GetReceiveSettings() => - new() - { - new() - { - Id = "mergeCoplanarFaces", - Title = "Merge Coplanar Faces", - Value = true, - Type = "boolean" - }, - new() - { - Id = "receiveMode", - Title = "Receive Mode", - Value = "Update", - Type = "string", - Enum = new List() { "Update", "Create", "Ignore" } - } - }; -} diff --git a/ConnectorRhino/ConnectorRhinoWebUI/Bindings/SelectionBinding.cs b/ConnectorRhino/ConnectorRhinoWebUI/Bindings/SelectionBinding.cs deleted file mode 100644 index f510edc2f3..0000000000 --- a/ConnectorRhino/ConnectorRhinoWebUI/Bindings/SelectionBinding.cs +++ /dev/null @@ -1,57 +0,0 @@ -using System.Collections.Generic; -using System.Linq; -using ConnectorRhinoWebUI.Utils; -using DUI3; -using DUI3.Bindings; -using Rhino; -using Rhino.DocObjects; - -namespace ConnectorRhinoWebUI.Bindings; - -public class SelectionBinding : ISelectionBinding -{ - public string Name { get; set; } = "selectionBinding"; - public IBridge Parent { get; set; } - - public SelectionBinding() - { - RhinoDoc.SelectObjects += (_, _) => - { - RhinoIdleManager.SubscribeToIdle(OnSelectionChanged); - }; - RhinoDoc.DeselectObjects += (_, _) => - { - RhinoIdleManager.SubscribeToIdle(OnSelectionChanged); - }; - RhinoDoc.DeselectAllObjects += (_, _) => - { - RhinoIdleManager.SubscribeToIdle(OnSelectionChanged); - }; - - RhinoDoc.EndOpenDocumentInitialViewUpdate += (_, _) => - { - // Resets selection doc change - Parent?.SendToBrowser(SelectionBindingEvents.SetSelection, new SelectionInfo()); - }; - } - - private void OnSelectionChanged() - { - SelectionInfo selInfo = GetSelection(); - Parent?.SendToBrowser(SelectionBindingEvents.SetSelection, selInfo); - } - - public SelectionInfo GetSelection() - { - List objects = RhinoDoc.ActiveDoc.Objects.GetSelectedObjects(false, false).ToList(); - List objectIds = objects.Select(o => o.Id.ToString()).ToList(); - int layerCount = objects.Select(o => o.Attributes.LayerIndex).Distinct().Count(); - List objectTypes = objects.Select(o => o.ObjectType.ToString()).Distinct().ToList(); - return new SelectionInfo - { - SelectedObjectIds = objectIds, - Summary = - $"{objectIds.Count} objects ({string.Join(", ", objectTypes)}) from {layerCount} layer{(layerCount != 1 ? "s" : "")}" - }; - } -} diff --git a/ConnectorRhino/ConnectorRhinoWebUI/Bindings/SendBinding.cs b/ConnectorRhino/ConnectorRhinoWebUI/Bindings/SendBinding.cs deleted file mode 100644 index 10509c6d63..0000000000 --- a/ConnectorRhino/ConnectorRhinoWebUI/Bindings/SendBinding.cs +++ /dev/null @@ -1,343 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading; -using System.Threading.Tasks; -using ConnectorRhinoWebUI.Utils; -using DUI3; -using DUI3.Bindings; -using DUI3.Models; -using DUI3.Models.Card; -using DUI3.Operations; -using DUI3.Settings; -using Rhino; -using Rhino.DocObjects; -using Speckle.Core.Credentials; -using Speckle.Core.Models; -using Speckle.Core.Transports; -using DUI3.Utils; -using Speckle.Core.Api; -using Speckle.Core.Kits; -using Speckle.Core.Logging; - -namespace ConnectorRhinoWebUI.Bindings; - -public class SendBinding : ISendBinding, ICancelable -{ - public string Name { get; set; } = "sendBinding"; - public IBridge Parent { get; set; } - private readonly DocumentModelStore _store; - public CancellationManager CancellationManager { get; } = new(); - - /// - /// Used internally to aggregate the changed objects' id. - /// - private HashSet ChangedObjectIds { get; set; } = new(); - - /// - /// Keeps track of previously converted objects as a dictionary of (applicationId, object reference). - /// - private readonly Dictionary _convertedObjectReferences = new(); - - public SendBinding(DocumentModelStore store) - { - _store = store; - - RhinoDoc.LayerTableEvent += (_, _) => - { - SendBindingUiCommands.RefreshSendFilters(Parent); - }; - - RhinoDoc.AddRhinoObject += (_, e) => - { - // NOTE: This does not work if rhino starts and opens a blank doc; - if (!_store.IsDocumentInit) - { - return; - } - - ChangedObjectIds.Add(e.ObjectId.ToString()); - RhinoIdleManager.SubscribeToIdle(RunExpirationChecks); - }; - - RhinoDoc.DeleteRhinoObject += (_, e) => - { - // NOTE: This does not work if rhino starts and opens a blank doc; - if (!_store.IsDocumentInit) - { - return; - } - - ChangedObjectIds.Add(e.ObjectId.ToString()); - RhinoIdleManager.SubscribeToIdle(RunExpirationChecks); - }; - - RhinoDoc.ReplaceRhinoObject += (_, e) => - { - // NOTE: This does not work if rhino starts and opens a blank doc; - if (!_store.IsDocumentInit) - { - return; - } - - ChangedObjectIds.Add(e.NewRhinoObject.Id.ToString()); - ChangedObjectIds.Add(e.OldRhinoObject.Id.ToString()); - RhinoIdleManager.SubscribeToIdle(RunExpirationChecks); - }; - } - - public List GetSendFilters() - { - return new List() - { - new RhinoEverythingFilter(), - new RhinoSelectionFilter() { IsDefault = true } - }; - } - - public List GetSendSettings() - { - return new List() - { - new() - { - Id = "includeAttributes", - Title = "Include Attributes", - Value = true, - Type = "boolean" - }, - }; - } - - public async void Send(string modelCardId) - { - try - { - // 0 - Init cancellation token source -> Manager also cancel it if exist before - CancellationTokenSource cts = CancellationManager.InitCancellationTokenSource(modelCardId); - - // 1 - Get model - - if (_store.GetModelById(modelCardId) is not SenderModelCard modelCard) - { - throw new InvalidOperationException("No publish model card was found."); - } - - // 2 - Check account exist - Account account = Accounts.GetAccount(modelCard.AccountId); - - // 3 - Get elements to convert, throw early if nothing is selected - List rhinoObjects = modelCard.SendFilter - .GetObjectIds() - .Select(id => RhinoDoc.ActiveDoc.Objects.FindId(new Guid(id))) - .Where(obj => obj != null) - .ToList(); - - if (rhinoObjects.Count == 0) - { - throw new InvalidOperationException("No objects were found. Please update your send filter!"); - } - - // 4 - Get converter - ISpeckleConverter converter = Converters.GetConverter(RhinoDoc.ActiveDoc, "Rhino7"); - - // 5 - Convert objects - Base commitObject = ConvertObjects(rhinoObjects, converter, modelCard, cts); - - if (cts.IsCancellationRequested) - { - throw new OperationCanceledException(cts.Token); - } - - // 7 - Serialize and Send objects - BasicConnectorBindingCommands.SetModelProgress( - Parent, - modelCardId, - new ModelCardProgress { Status = "Uploading..." } - ); - var transport = new ServerTransport(account, modelCard.ProjectId); - var sendResult = await SendHelper.Send(commitObject, transport, true, null, cts.Token).ConfigureAwait(true); - - // Store the converted references in memory for future send operations, overwriting the existing values for the given application id. - foreach (var kvp in sendResult.convertedReferences) - { - // TODO: Bug in here, we need to encapsulate cache not only by app id, but also by project id, - // TODO: as otherwise we assume incorrectly that an object exists for a given project (e.g, send box to project 1, send same unchanged box to project 2) - _convertedObjectReferences[kvp.Key + modelCard.ProjectId] = kvp.Value; - } - // It's important to reset the model card's list of changed obj ids so as to ensure we accurately keep track of changes between send operations. - // NOTE: ChangedObjectIds is currently JsonIgnored, but could actually be useful for highlighting changes in host app. - modelCard.ChangedObjectIds = new(); - - BasicConnectorBindingCommands.SetModelProgress( - Parent, - modelCardId, - new ModelCardProgress { Status = "Linking version to model..." } - ); - - // 8 - Create the version (commit) - var apiClient = new Client(account); - string versionId = await apiClient - .CommitCreate( - new CommitCreateInput() - { - streamId = modelCard.ProjectId, - branchName = modelCard.ModelId, - sourceApplication = "Rhino", - objectId = sendResult.rootObjId - }, - cts.Token - ) - .ConfigureAwait(true); - - SendBindingUiCommands.SetModelCreatedVersionId(Parent, modelCardId, versionId); - apiClient.Dispose(); - } - catch (Exception e) when (!e.IsFatal()) // All exceptions should be handled here if possible, otherwise we enter "crashing the host app" territory. - { - if (e is OperationCanceledException) // We do not want to display an error, we just stop sending. - { - return; - } - - BasicConnectorBindingCommands.SetModelError(Parent, modelCardId, e); - } - } - - public void CancelSend(string modelCardId) => CancellationManager.CancelOperation(modelCardId); - - private Base ConvertObjects( - List rhinoObjects, - ISpeckleConverter converter, - SenderModelCard modelCard, - CancellationTokenSource cts - ) - { - var rootObjectCollection = new Collection { name = RhinoDoc.ActiveDoc.Name ?? "Unnamed document" }; - int count = 0; - - Dictionary layerCollectionCache = new(); - // TODO: Handle blocks. - foreach (RhinoObject rhinoObject in rhinoObjects) - { - if (cts.IsCancellationRequested) - { - throw new OperationCanceledException(cts.Token); - } - - // 1. get object layer - var layer = RhinoDoc.ActiveDoc.Layers[rhinoObject.Attributes.LayerIndex]; - - // 2. get or create a nested collection for it - var collectionHost = GetHostObjectCollection(layerCollectionCache, layer, rootObjectCollection); - var applicationId = rhinoObject.Id.ToString(); - - // 3. get from cache or convert: - // What we actually do here is check if the object has been previously converted AND has not changed. - // If that's the case, we insert in the host collection just its object reference which has been saved from the prior conversion. - Base converted; - if ( - !modelCard.ChangedObjectIds.Contains(applicationId) - && _convertedObjectReferences.TryGetValue(applicationId + modelCard.ProjectId, out ObjectReference value) - ) - { - converted = value; - } - else - { - converted = converter.ConvertToSpeckle(rhinoObject); - converted.applicationId = applicationId; - } - - // 4. add to host - collectionHost.elements.Add(converted); - BasicConnectorBindingCommands.SetModelProgress( - Parent, - modelCard.ModelCardId, - new ModelCardProgress() { Status = "Converting", Progress = (double)++count / rhinoObjects.Count } - ); - - // NOTE: useful for testing ui states, pls keep for now so we can easily uncomment - // Thread.Sleep(550); - } - - // 5. profit - return rootObjectCollection; - } - - /// - /// Returns the host collection based on the provided layer. If it's not found, it will be created and hosted within the the rootObjectCollection. - /// - /// - /// - /// - /// - private Collection GetHostObjectCollection( - Dictionary layerCollectionCache, - Layer layer, - Collection rootObjectCollection - ) - { - if (layerCollectionCache.TryGetValue(layer.Index, out Collection value)) - { - return value; - } - - var names = layer.FullPath.Split(new[] { Layer.PathSeparator }, StringSplitOptions.None); - var path = names[0]; - var index = 0; - var previousCollection = rootObjectCollection; - foreach (var layerName in names) - { - var existingLayerIndex = RhinoDoc.ActiveDoc.Layers.FindByFullPath(path, -1); - Collection childCollection = null; - if (layerCollectionCache.ContainsKey(existingLayerIndex)) - { - childCollection = layerCollectionCache[existingLayerIndex]; - } - else - { - childCollection = new Collection(layerName, "layer") - { - applicationId = RhinoDoc.ActiveDoc.Layers[existingLayerIndex].Id.ToString() - }; - previousCollection.elements.Add(childCollection); - layerCollectionCache[existingLayerIndex] = childCollection; - } - - previousCollection = childCollection; - - if (index < names.Length - 1) - { - path += Layer.PathSeparator + names[index + 1]; - } - index++; - } - - layerCollectionCache[layer.Index] = previousCollection; - return previousCollection; - } - - /// - /// Checks if any sender model cards contain any of the changed objects. If so, also updates the changed objects hashset for each model card - this last part is important for on send change detection. - /// - private void RunExpirationChecks() - { - List senders = _store.GetSenders(); - string[] objectIdsList = ChangedObjectIds.ToArray(); - List expiredSenderIds = new(); - - foreach (SenderModelCard modelCard in senders) - { - var intersection = modelCard.SendFilter.GetObjectIds().Intersect(objectIdsList).ToList(); - bool isExpired = intersection.Any(); - if (isExpired) - { - expiredSenderIds.Add(modelCard.ModelCardId); - modelCard.ChangedObjectIds.UnionWith(intersection); - } - } - SendBindingUiCommands.SetModelsExpired(Parent, expiredSenderIds); - ChangedObjectIds = new HashSet(); - } -} diff --git a/ConnectorRhino/ConnectorRhinoWebUI/Commands.cs b/ConnectorRhino/ConnectorRhinoWebUI/Commands.cs deleted file mode 100644 index f8f4a763d2..0000000000 --- a/ConnectorRhino/ConnectorRhinoWebUI/Commands.cs +++ /dev/null @@ -1,174 +0,0 @@ -using System; -using Rhino; -using Rhino.Commands; -using Rhino.Input.Custom; -using Rhino.UI; - -namespace ConnectorRhinoWebUI; - -// NOTE: we have two commands to test both cefsharp and webview2 in the same host app. - -/// -/// Webview2 Panel -/// -public class SpeckleWebUiWebView2Command : Command -{ - public override string EnglishName => "SpeckleWebUIWebView2"; - - public SpeckleWebUiWebView2Command() - { - Panels.RegisterPanel( - ConnectorRhinoWebUiPlugin.Instance, - typeof(SpeckleWebUiWebView2PanelHost), - "DUI3WebView", - System.Drawing.SystemIcons.Information, - PanelType.System - ); - } - - protected override Result RunCommand(RhinoDoc doc, RunMode mode) - { - Guid panelId = typeof(SpeckleWebUiWebView2PanelHost).GUID; - - if (mode == RunMode.Interactive) - { - Panels.OpenPanel(panelId); - return Result.Success; - } - - bool panelVisible = Panels.IsPanelVisible(panelId); - - string prompt = panelVisible - ? "SpeckleWebUIWebView2 panel is visible. New value" - : "SpeckleWebUIWebView2 panel is hidden. New value"; - - using GetOption go = new(); - go.SetCommandPrompt(prompt); - int hideIndex = go.AddOption("Hide"); - int showIndex = go.AddOption("Show"); - int toggleIndex = go.AddOption("Toggle"); - go.Get(); - - if (go.CommandResult() != Result.Success) - { - return go.CommandResult(); - } - - CommandLineOption option = go.Option(); - if (null == option) - { - return Result.Failure; - } - - int index = option.Index; - if (index == hideIndex) - { - if (panelVisible) - { - Panels.ClosePanel(panelId); - } - } - else if (index == showIndex) - { - if (!panelVisible) - { - Panels.OpenPanel(panelId); - } - } - else if (index == toggleIndex) - { - switch (panelVisible) - { - case true: - Panels.ClosePanel(panelId); - break; - default: - Panels.OpenPanel(panelId); - break; - } - } - return Result.Success; - } -} - -/// -/// Cefsharp Panel -/// -public class SpeckleRhinoWebUiCefCommand : Command -{ - public override string EnglishName => "SpeckleRhinoWebUICef"; - - public SpeckleRhinoWebUiCefCommand() - { - Panels.RegisterPanel( - ConnectorRhinoWebUiPlugin.Instance, - typeof(SpeckleWebUiCefPanelHost), - "DUI3CefSharp", - System.Drawing.SystemIcons.Information, - PanelType.System - ); - } - - protected override Result RunCommand(RhinoDoc doc, RunMode mode) - { - Guid panelId = typeof(SpeckleWebUiCefPanelHost).GUID; - - if (mode == RunMode.Interactive) - { - Panels.OpenPanel(panelId); - return Result.Success; - } - - bool panelVisible = Panels.IsPanelVisible(panelId); - - string prompt = panelVisible - ? "SpeckleRhinoWebUICef panel is visible. New value" - : "SpeckleRhinoWebUICef panel is hidden. New value"; - - using GetOption go = new(); - go.SetCommandPrompt(prompt); - int hideIndex = go.AddOption("Hide"); - int showIndex = go.AddOption("Show"); - int toggleIndex = go.AddOption("Toggle"); - go.Get(); - - if (go.CommandResult() != Result.Success) - { - return go.CommandResult(); - } - - CommandLineOption option = go.Option(); - if (null == option) - { - return Result.Failure; - } - - int index = option.Index; - if (index == hideIndex) - { - if (panelVisible) - { - Panels.ClosePanel(panelId); - } - } - else if (index == showIndex) - { - if (!panelVisible) - { - Panels.OpenPanel(panelId); - } - } - else if (index == toggleIndex) - { - if (panelVisible) - { - Panels.ClosePanel(panelId); - } - else - { - Panels.OpenPanel(panelId); - } - } - return Result.Success; - } -} diff --git a/ConnectorRhino/ConnectorRhinoWebUI/ConnectorRhinoWebUI.csproj b/ConnectorRhino/ConnectorRhinoWebUI/ConnectorRhinoWebUI.csproj deleted file mode 100644 index 3bc44cfe78..0000000000 --- a/ConnectorRhino/ConnectorRhinoWebUI/ConnectorRhinoWebUI.csproj +++ /dev/null @@ -1,63 +0,0 @@ - - - - net48 - 1.0 - ConnectorRhinoWebUI - Description of ConnectorRhinoWebUI - .rhp - true - x64 - - - - - - - - - - - - - - - - - - - - - - - - - - - - MSBuild:Compile - Wpf - Designer - - - - - - - - - - C:\Program Files\Rhino 7\System\Rhino.exe - - Program - - - - TRACE;RHINO_7_DUI3; - - - - TRACE;RHINO_7_DUI3; - - - diff --git a/ConnectorRhino/ConnectorRhinoWebUI/EmbeddedResources/plugin-utility.ico b/ConnectorRhino/ConnectorRhinoWebUI/EmbeddedResources/plugin-utility.ico deleted file mode 100644 index 022d1f78842c15850a45c0405c872e51c1070015..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 33583 zcmbrlWmr_-8#cOUVCWPCq(e$tkxnU<1_h)`1nH87p+Op?TUw>0duUV|q#Nn(A!gmy~O&#<8LCpZzzjOG|1(i~Gc`OgsfD$v(b4h3oa znW}ts`Ws(!zC4_9apn0XpBs-6Rkrk3Y`;`LeX7|&3O*K3fBY;d3nh8A;5zaa6y9x9 zRSNb4Xo=XJoIop1)cl5kNEQ|WB|uaH>V`nOZD9Y`w^jT|po;%e9&QJ(IFT1C+9lxw z;o9P>U>FW1pyn5X53r!;x*+8RqR~@KDm4Q9T@a`?!~feCJRd>@SfoQn-eR)6UDj_gQjI-oO2vgS{$g*HZR_uf792;>y{ZA^D*D%~y*AUn1yw+ncXfSp6TG zX;Z6=SkIQ$)*s|b<7|~BE(NdGfGjWFMICN?UE9J|R`s%mRpGw3&l9g{Q;$?xYlsK- zk9>!RbNOf+;B$ZI8YV==FH_qa5I*FZdSCDx)b}&;_8}jAl%L$q2;Lx8UFn{NHK;Q zaw8&2`})%-Awh>h?ZD(9^q6X$5Se%PlaU(&Uqb(X+}JG#$SEm<)k-jueqll&5E5!? zJWWl_^QP@>>l@*c!~1!5Yk@a!-oTavP=w(`bV1ta*_&LqR>q5z<5N?yv4T6-ZU26J z{`m3ZQJP_Qm_d!zP@c_1@j1Pt{akHeT3VV+E}If2CGft?73_2ecZP3fIyM?&S5DX3NK7|^$dCQLENbX2pQGKK21%7LNhX9K=( zr4qCzA$asOq@S8R3?KS)@-;}NJ76`G(sa7Q$W$m3!^`hmh|c%We7W#0Lg58qy)UL9 z!1Wu}{i@%Bp}BQdL)7r?g1Ft<)jxrKam@S{eFWR{4UT!lCByeC{1^(D_V}M|4jr#W z@r@7o`(d}>5=+4u4Lug!NoZ+lx4X-aBes(V?3*?_dt8sBS|nQDvhwWF9Q74x6OOK;S;RK7L@%7uI4KQ>YW}NGAmgq5BCP9h?n&)kMWN1q)>Vuf>O_f)*XIPSiqp4Hw~2#DXxi8XU*Ia~pVh17 zfbd{!Vy%QyJWq!>X{5*nj)+zxz@Z$212oTEEqXA}OuLMnUpT8i9q8w%JPtzJ*_#$1 zuf=z-yrBz;xb^e5x3lA3_%vV6?>0d4uA8!(7pRC!egGs7_`rB&y}iZmZvXJDF51sq zi`7V*njQ}cFNf%q>t7@2CfV=TR)+^DP6(9N`Q3iXH4aByo=h8IC$XysRaNmb7?=HQ zIni0yoj3HR069(DAFBgBM!4tD%l%mlv`PwOf)y}`@qSVZU@cV{XzJ*wLB6)OMlTH1k85!- zzX&`ERg4t{s;dR$AAe=ym7-r;UuWbLNLXMWWzg_!Od%rHcclKFaKnf--Y*paYI^ib z;H%Q{;Iom@8%R69`|cZWKbl<)CbTDOz5)2*7XvJDGWz<|XCPCPM=?_q{26dj+N-$F z(S=u+29}ueiMQKnRCDi3ALqRAmzAPx;p5>cKsZJZMulUsFn2Kt2t?kcQOllL4dvU< z*Sl3nI}qdI)_LO%f*H?df`QTge}+z;Cv8_t1<&XOJO}WGh3>V#-6Sk{FA8QbRL)l< za_g_I$%U7%$?*d{2y{b~hcs}eQN;So7fjs3zx^o;F_0K;K52&2v$KJ9^Cx)QAXD2X znE08`ZSfA~>R57KQi@S9mq;bMy)(#h`qdPM$O;z-VG&ubQ<;rX$dke?==wo9#|2(YV* zE2B6U4PK;3UI}9lWr!yBpyc-78p?wl(|V>)ly_u+N9PL_+4}g3Bzm0CiCraQ(bJj^}hi)MMgGD3eDposFG6oXV2--{wCp zN+~|R+}g=dK@9cSZ=QtKzS~F(+hwUHNlAJ;znTGJf{~_pH-^`*m3MqW(V46ApbcSEx(RB?k2Wr`Wc2sCGX1;f!4EOaW|pN z$`wix+bQmd$jIVODRSV3ft0+~AgWg-X3`E3Y&EYbz`m z(fnVQ#alsVgohm{|6)yY@?v#q1i6^|Zs8qYVamN8?kE7k*rhff?R5)Cz`yP=!qC0` zIQH`LUj<`6WRR_`F>MZB&QRvHz5=c|x$xe9Gp{uS?O3}=9lM}`u+CsCSx-+9#QaT@ z%sNCQEY1jvoQ^=q{LU2f1czUWlwd|PYXC!KO_eca2UJ) zeH(Zu`BoeqqkA1eut$D+i+wafovVHm#j1H0{c3_QDIa{zU%${dx6WtEce|r!InK{F za~l}Z1(8Ur6Hf1VWvwcOf^KgV6lxXtxViIkFh8fm^~M@C3;97xBtRz@Y(zn}$%!e( zo0W@jHwVt6k@nZM3CpBbAS^{>Txg&26()1m!g~GjF-`=|^tg|po2X_L zO}QSqe0lS+#3qI59n-UC_!aRwQo)VOA}&tdAv9S_)8=H4o@En+822`vZS6dNQ7z-R zl3}a(;`Z`@=_TF2zoTuDAY{++nFglQt{`4T1Fx(fB?yfn)*1kbi%IRt=gD$TX4wr* z1y3~n1t|fA&bwLGr06B3pWF08)Ku< zOUWV;tyqs`b|40pOcmQqiO%w(g)Aoj%g7v92MXaBXY%AT@Cm!3{bu*$-3}(!|E4wF zi!+AO4wp-Ji5d3aNPM@>1DREkJ_DQw1Om^K$&wPSQy3SgV{}(uF=jzzj`2o=Mf`3A zjc81#2GeUNQ~j1?A7TO~!5s2twv znXf*IjeOBaPPIfWY@@<*eHgu@tt-Qgw=GF4;u-Hv&!xl7ZY<9*V$+3=smxz^yA`x3 zxb;R?*5?S>6}4;Ws9;}a4F5QZk_1Id#7foOM}xXD~stQxOv!eW7PP{14Hr=^|$Y*^!56CgsK5fAMew8BZLgxvI!w+IFvijm5Y zrb+tL_j_SpDEucV=A=Ni2Og9kKx-o6R=cb58I2zu^1#s7tqegn^}$$#wY`u9nl?Rh zB04E~{r4=~{+6T!G(rm_q8K?48E&vh0?xGVvAiG2y&-AYLuC2m=xq1aDHUr@2M9w! z!Iq7Ze0*`m@U`V_$(1vB<4nro94tkVH}K?(pyqF%^ZS1A5@Sn{VTV^nVxCF?C-5Y&h~KeKDj z9!7!a!zHtx`^gR(82%N8_WSW)FD6RV!y}GyY>Z?>Au?3V^8Dpq=i6h(Q9n%+C%19~ zjJMcGoY4@(n+eE)xfv0>F%Ke2+35?FI7Z{P2u94qZx2Kr_hzaw$_ZD>xT;V`9c9iH z#%*}bZij15vwj@hyXvR$z!VuQR7o<1fKkr@5rDd7perxsx(7Die1J|V0ZAlowU{z*-d^p_Y70>uPn+EC z*mafYNa5Pg*VX7e*2$}Foa^@lK0mVhm?P%?d%bD>1c6RZZeVSrdk=B~kpvor3Rv{b zaGm4{uk4dD&fHjV!`=bM`q^Uc)SJWUa<{7-n6G&R*KB|D2jvW*q2T^SE4ylj{4~oC zeDq^d@B(Tg>MmV}U{Gq80?eI#wF|&HO4_$%a6d%=Du_eygQH0JZ36sOQ>HRlZ!lO-=D95DdmV z^~Cdh?7ds$DdYTa`M*Ewp~NRpbmh{WCmY$}9J=QD zq{5utI69=%>do9adhNcVJV(a==gBN#;|3y~ibUsNr!PPY?og(1Fh&3aRMd4-CReI# zDlb>tCGID9WjPBZVdeO~`-E1f!tl|y^3g-I_jW;GxPy#6MGXtAV=JG|!HNV7Y5~zy zvi(w@(u4-P@w(gbq2sPt{GqdCBAHHqzr77?zcc+6xu7(^Wi|T=b6Bp=dW;DI2V7Nc$?4F+PHZ&%n_k|dKJtFF8RGyYo(qC z$SWyz?zdP?aCSAiR9DeME5R$T2)<+qp05*2!)kXXBy%Wr1pCe^5B_HmLQb(j{r1x7 zR`uiSy6M<31IMQ1*v$E7=Tx@{<2I0oDA*ql82)y56oA54PW3kK#B~K7Q|Ae5XWlQI zPzU(@S$Sn(OxtZyHcR#jZV|;K+`nFwCoA=1u*GX)&&?{&H-V_nzk{+s*L+w;O--mU zTOFg#82j0WMOMyn=KcwFY1LG_??d-qh{Xzcw}GVY;9Q=5e{P*taxHjAzQ47?!5x=- zSp^FEJ5G&ZeXLh%IW_o5uw_^~nO;dkX5#^khCcAG9|htyZj{+$#gRb5$(%O#-^ER1 zw*gs{(6@=UT=!X{69+c7UShVn7`1vlrmb>o8$>`ts->m?iV89R*I_$Nu2=2byLPxvmDL4!G_0xq^B_3SGbJyBR}Wo*zaJQBm{KPoBKq1FSKiPF z>7UO3P_>=V>t+ds{P2M?kA8dmT_zy;zD84Sqky(-N#e~*!(UWi+0Kc8j6FXwJ!b1^ zmY~D|!6IL!@);FJN;Qf^&A_WSQoMnwk)?(sbXF;bIFNz(&}uOMmqM*Z^K+E7DF1m z5eYAbLN^EY*@_4tBK*=4lQH*vmCvy8r7pubCN^2YbRx~=b@#SptX@R0$J#oHJitX& z9&o}6?%=HnfZVUS38PM_a6t4n|W@rgadarh5&OLEpKi!m!0#iQR1q^kw%BuM(9$ z-Y9$&l+`fKz)y`uF>L>SmM%@)KPUX-9p=G&-4{E`60F;WX^&?%r9XcLr949&G%WA; zF}#jmdWWfBYt8fu?1HXt|FQ0oFjtr~p43gRv>df-?~BVEtrw*lpX!J7F#Pw751_dL z2r|XE+#Ppm!3ZH;9_Z*X+xbzfeSw+Nvf}Yn{}#+{ymN!>Nah`rK_BB+Lj1tgY2K6` z%pTh-PJs_V!DYY^ipC##{b4l3dV#t_=exU&UvC&6DJYXajfZ09WQ@r32yw;gPW&C* zjzS}q9o1L=O-u@8O-^_mTZ;Ix4ehm`428YW+B-SNpZpkX)*CFz`1Az^gKq*>2O=Av zA}Z1iTPp19en*=0auSYb?z5G5z$nMn5emN@aT&nd7k8ykds71eRrA|?PpMdn$Xfkw zXG?(-hq~Tk&}*^c`S)}aw+f0M_rs_~XD#6k-d=WA7@?|Zq!n*i5&oGc>wb+wwCK#ibM1Rg1#QJyNwlF6Zr`lt_*`kK z3+VDtY_Y=e?`vU7@bUDrk}15dflPSzpZhY~FJU%E?-b$vcaa39ytB@GD-ocPaU@YO%9yv@VGYXepZXy%xq<;1N=)oOX zq)bb_{Q*zK0uD556~7Mhx4yq*Br8z0(lH1FoA}8o-RdY4uddEp^?Tei=>>whErYrp ztfJG^cxUua_;zN`+5K=PiRj+92=78g~72C6BLQgXG)eQdsAc$K`#F zwO-&x)e_;(ilfRI1;(pWk9b!z;WKA<>uCaGBUEV{>(%>llA!goqt;vAG*xs~Bg{{5 zr}gll01bkiC?G1}*RNmy%oUDWRnF0!l>p6KM9co$+R}6c)-lt3-3}MLD*q<^)2p@C zOa=$vCp0yDSaCT6EJ#V`*#XV88^`0>zPs>qdjby?yDjUBnAoZ1o0%zA#(;n;1BxA@ zFQZojYV!)Mpv!jW<)!SEorlCTC@WHEYpbuP-vnE;oiMM)6M9wHJAe54(P%!#!B)!! z&VXMO#gIMgA1eKTCWk;(%$_>D7%Uc5$-dQ>S;o=$W%N=mm{Pa^yg|r7Qv0>&6^JvYhyU%xrW;cJ!x$ z@;g$P9jvj@ld?ONhA`e1fp+g7PSO81HpbtNYD9~DlDaA3qEmy|-1*m&Bh~r$0?SM;Qc(y@dSPG=cDBgeV&YWLEDHvMK4p zcrmB8P@s8gXPIihQsj@PD&jHiD0f4$=N`M{cXo!#35bCB(5ombSz98gw9dLV~OPvY(S}N&t z@wG22IT<(L4k`Xazm0l);#pb+ZiO7Ym(m1IOa2d?ZQRv>s$MkRCkarjWyXbsY_e>x zb57TV+F}V89JY;ZJ6&lKL}NvDBN}`#DI#BHNtl?Ef$$BbstI48&crfB-1V8fyTYke zcaTF-L<>KAMpoZ`!nUKHTfo|?C&MHoM~>&ac3W#dPr;^|g`+v9d1=Zxgo{HQj=9E( zIeP}QQnh1~!c1;W0+6^gCO&lZ#&DAJ-R#%4*mzr7`ucbsWX>>ej5Ym`9M6+p%GDGD zhm)P#t^cjtH+{V_<|E-y%K`-cwx~8P82e}!Pci9l=~&){IZLV+wk2;SdZjvZ%2cgNjvlN^5ONqpfe zq>N}HHgspAc+5`5Rv0Fx%>U#`#wXl`NA1eI(2291ot@)ti#S<9=PTVxV@S4`M@l4( zo&pe#*D-S~I*W2HhB5N?c%KakKg;F2kI&D*Ra@c9t2e(~(_Q|aV9(aBXXnK@$hALy zD8c`otI#c?MA1R;v!P!Cr75`r$|e=P{3Y6(JmzhsjTlC+}JDpioj(1L0-J&*3LlrgD0=YSGrcGZ5m)SjY~3a zRP$c&&y3*pzSvOBf{KI)s1A){QgF~?<`pSi9Kz-wtV`N;aPB=5QSm&*zEc z_lJSSd?;Mo>GDt${}Wnng)4?LJiQjsec+tJ2dE{frET4F2SVsa8xJ1eP#GPvo_XsV zy!6>~aIycZzyiKJ@FepBS>Jh&MFftq;c)=HMOYjIcXUrj{C|In&MzW)&@*-9I9`a0 z=(GS6;d6jzUX0{Q6N}Y4I#Po2UsqK%C$M+-Z$-1QNZbzAIPJro^^e!Dw{n6_PrYxY zjO7`54kT!q`+b)Y#Gd8S5z2|IY-~@n8SXXv7YuDekQLuWHKVvg!h}PuvaJF?*Sf5l zQR`JRJ~S_oD=P08m?@)*(Dx}2kz%B3`9*>07Kk zD6Pso?zYxu0*jsn;h>Tx8{GAkj#%Ot$dW#i+>T&|rbCrexx)qqUd}a({SNuQy&g{z zGoQy8##(Q;2$n{dQnhxoV4>Dp5c4aPNi)&cy*52e>%`IgfR&0_4T1 ze)IvfQ$4ivI+H8*6PTH9J+s3h>SRd7JIo$?=w19+t6Pw2NDbjX{}MWYKRQnqXy^*` zj%?xyYyyorRpRI}9Lo`MiM9+FO`d*s^ zc;ysF(-YS>3mXPVqW4NgW}mJ$I=%F4q?p_$jEJVXUi-thvK}X$zkKUjxZxPq?Pnal zd@U7+1FJunUkRm@NVV#g2tsdxJw>tI=YjHvfS@lqK=I}qBlS6cjJ29Uu4b?Sj7PY( zfu@$_`v~TtmjB`=K!tf_5<%G52R=SJeZ99=9Y4@puvEet4$*z#8R6zaXmzw2-K1Hd z*yKk?M6=|%9^BM^5KSAa3IR;h=?d`=~c8PbF`wO9PpgOpzg>L7i&DC{`wkK|(ah>FR(|U!;xD>-G0Ss}-||GR z7!5^tyqMIOh@gI(Xu<_n5GS>(-ARze69EyCjC?E=u6VuwOr5O2#@u!%*z&6P1tVWV zyFbp!gUv-(V#2$oLENfTjx#i+ij+>xnyBnRY@X1D%wPq}{>Saqy#`KC@l01D4AN3h z#}ymG`+jKy_&!((4BKA=E`o^cE#Aj0ZIf?I|7k=h7Px(ZSep+$w-6igQdnnQ$GmDu0AGm8eUh$+Ydo?%&$+SoSI|ewTkZ8H^$HP|r>c zkl;+JiC6NW&(&fLQ=P}R){{RAf4r~)4(IV3mIa1v6DJ}_Sys?{e`h;c_a#?3DKL1# zAil~AKZxr{znl(XjrT_pXkfp?Flbm9CG8`ywXyxB`jtsKUC@MmeL6}Jr{^8ioV2Rp zuKud)x9mo;;wg*nSc-{m4&khg$%}WZHpS~lQ$-JbQOk5{-wAKA`Y@bG)$d{#0*!&; z1p`!<7_|kg-`r{TY{;N~+#Q2b0-jel!YAOQNLsa+nq-k7>dJQKI&doy>9OoLZP6-6 zbgyn(OlVyd_E(}Qt#x9e$Rd*$ALII*mIvuSbx%b_FK|q+(e%hlX!6Iq5fXSi?^fDs zkc8$J_5fnRe=nwV|Gii$a?DRtBQRIrTSQLb^S>XTd1BH)C;kZ*1i_a$4CcAL^SXk; z0x?)wKtU%K5A%Hn&SDa&1*n_vTs@JwzIV9XCe>Yg&IO})=M(Bu|I3FD!N>b^s#T{u zx@nia5drI$4KJ)QvHrXn{h^8ZgAsvTVNC8hW;I{w#plN}hRRYij7F`4|25%d_U?`Hu=PkD>p%UCj$(idteEA2<;%I z4^6NrnaDtL%M0%kSF45t#@+-sJn75WV)aq3c<`p!3w(3N^kWObNPTbHKSu+&P7z?D zqm6$%d0LLDbDWK*82^lB*ImE!9p6nvt# zvQJv6x$+&yG_ne{e?$Dk|Hh_xHU`}qb0vQK3k@C64K2FkHE2&Qi+<||bXkbWn%lZP zD(~eiRy_ny6WOrF?22EUU8r%w65p6KnaLyxvgcL3#P))CXK0&NQ!$!sZEDV2wcERhSv}AW`*P^-r}e9^K71`;Hd_y4 zU)}tLeAs1ahHe}>7PJXm3}g;TWmdTNI+rc%`J4tYP*+w2_{Xmtt zKC-))>wUaQVL@&visp$6BVzJXM>GQq;(M+k&U!zQ?(v?>NGLv~DY`Yt_^P`#xJ0)y z2;KcP#|HKq*mt$Pvoenmz292wG;r(~a`Rnm@d!uvdX2&5-ri@<=T88~);f$sA8Xe2 zr6(_~-7%~SlFCU@Ri=6u1E$tldBOZtD`ao}**nqTx}i9my!`wGu5u6?MS-B3!i`uEKP`sjyrs>H0f%zi0kgCa9Uj z>*M3#npa$uJ$GWP?`o_FThGUpRc_aA0>A4>LP$vy)G9iBNMT+Gs_prjEgvz9__`dX zJ~peNjG_Ti7c}WkO$wMOdn@#~htF)XlnF4q9yQ`A64rkxY3igD|BwR`7{A%&J!Gc1Wq zXJ(qniIV)y>}S7})YQ)5Y!g_xl*)2%a$tkQ;t?W#TJ#=W2_f=wk-Sw=(_Lq|r_^7rpn>!?7=q2pKxAo<4ru^A|R~ zk&SN78uteMDC(=8ud+O0xh(4%?u+a8P40mUxRMwkq>(d!e7VyOqY%h%gC0)zJ$-M! z1EwA1TNgDc=UofPo_cL24v}c&Vx{ggJ&^{!G?l4=wj~Pqv(Nh8&LrxMlvmdWhwW`6 zj?9XVVHPE4`9BuMwi?p7B2PNx76Wt~GDNVJ=1wKtQMP19t!G5s2KCWi0V-t1@KJDc zd_-L><>&%-(yx~ta)x+zdo+%tFa|CvlbJRjVM3uN==Rt5WjY|e%N{Y$ljMf9%eUB} zn)lf?zufs&$hqotwX^p5&&wm#!|*!-H6w89xyk$+<5Md36I#h+b$lmy*b<5$*xEFmGn7<*18B0qf0ABTiui9TwIq;6vQ z)xY@==NT#l$Zf-ddJ4kC)K_}aeFwP6wc^J9*2!EpjpYA0#yo2>d%{cQ*mYWy)ABEh5qhKT8DoAw{~yFedFp~2y?-2(y>d96YAzqZqg zS(qg1@$Ih*Smaill)~k-d>adj8n)n>v*w^RcceVn`Ouuy@E3QDzjOVZ=e6#ojI)qW zM?Ei92hazqir7YXPinE`hWEvhB`L`VBfBk# zDcs{eTlMKVsSb9hePnT_L(qDEobI1n3y2x_LFlaiUqZAEX{rEKh0{G{XTA~eewi1U zoIRIv+o4&)ED!sL)QiLT(pOlVQL3>6?Z#h#$KTGmhB09F?>DgEx7I|9ytQ|VMj*>9 z?|$1wsX&2(a9ICQo7Ub}L_4|{RGo75jXow8A+R^8nk*hsa!N`EYRSAp=~Ia|{Ns~n5Eafd73$wt64&*PnM z=$?SN&vzCH+mTlWB#%hxw~xO4Hr-f8cLH;c)4{Tk=#W4DOY-^7L-fu+g#zYEey@7> zp25y0pQ-A)SL zGX=lFE6S46kDpfa$v-{^xB9lV2#2y$>IW-|wH0i5(C>K+pSseKI%VTKu@;c4ud?H}_ zJ+54u%WRB}srVN^OnJK9UIOiCwf2dT-N!Z>>POTIWKn^dqG?^U5& zrc#dEeUKJ|y%KU=nQ|&;0)jgwUh5n)RUf&ny9E=aTI=3Z(zKU~GsfQ0$ji!V-tb9< z*WDs-*poJI@Oe7MG;rRPGz6xfquzP0Uwkl~vlqs?X(=P+*9Gw1KCgqR{wj6%t4JBX zZxp)svAYLQBNG(Ru-F7uM83lzQiV2BtlRWRGa2Jo{%9szGw<3T^FR3^mA~N;c}GJF zdg0u}mo2-?iH>OavrY91!Zunhq(6sSv9XNkC#t2~P~4uM9vWb=lx*HVjTAmWbhhfm z@cqQ%Rpkr?*|s@-^_bc5T9QTnyCjZ;1m$qVzNUY|s<>m)CPG{ySUH{5Y4-=oVuQ{F zXX82HmxuHgVpEzd*j=f)b`?n$2*Udfn6)I}t{Pp4N_!Eh!p%VJ@Sgg{zz7*~d8P0! zWvp6sdv6?w@!Iyj~P#1LYICa_&EQPPUoKA@=*B9R0^U<$cvB6#B>NQ z5yY8U#4IRf=gznuR<6kS@M<&%=!gce2MpYn#ALMGf5>mXt&_Q@^9& z&|$<_XpGi5RS#(hBD`jxdZ$x!gpbC>x;Xa=PhO-CwRa_+r`=y4h?EjBzK1v};P^}v zf`a~$!tYm4ji}!8%L}(q2%5z(N=RTD>q$|Fv9o_>zGd@?;v>aq>BI z&F*6T$WazJ<@JXovu>pkc?=tAn_d6B4n)$6M4K{e&(|AEK1Uy{@g#>%*(Y|APhz^b z%Lj>nJ$C=H zK?nWHUB6SwX_UBHv_<*0>CN+!O_({0Uf&=-`jCY)7cdh(-B*j9lzt%?dBRQz9WAwt zh#5;v36OBJOJ#J~Qym|a(ySV39>N)Zc4sJok-3T=DosQ;!nBy=;`1jCfn2CnPrpH= z?KEusW#5)8IlLE;B?O2uAsY)@s(C=4i)SWa#K^0IpP7@1Q=ZX3M`*5e38N??(Ngu=FquP_Ue4BOanO3U@f{wI2c!#13p0)|ZHYB47U0jRm zTEH7BBv}k#*!TwX1Fy(W#9-Ki0nrW&ZmT0NBrb0CaX_UcuBIkwVEZAh^u4RU0qz8l z@dK6-FB_>dgd)Q{gjGUA8l5z4d0Y@iPj91R{X51!uB?^8T+T2sS2><^+I0}<*DUEz zPJq2AKLzD8|Jge+k3y}TMdc|qe5+LN$ECdw@1z1q?%bH%eTJMF;0PZC-JB zlY?*hM&aF&^UFnY7M{1P=69qz>(jGFeo9~(UWlHKjmb8$6r$|QA8V|N@=mT zkwva%J)<{9vnA*b^1N?wv%5|+)yNZKD5%VSHReK_N#rFD-oM#sBgZeZo3xm2)J!Cm zH|w>>CGjjyIgN-dK7HHURn*NXmxkvf%CqBkAw-%chS{$d@285kCefV_Zy+7f9k|Z7 z*sxNw?A5w0hp+RG%Y~l%mPoZ5FVKAukiU(cL?Q68%j5e+v!OrIFJ#aywdW^W`{S{ z!eiT|no(K>sa$}05Qfsz{Hn%rdN|k6&7&uu+bYFEI@@)p`GR?~;djUz^r@eK<8FBH z3!1SM)YL0K(}PnQyRya?%SK|8TM@|2LOI_=Gs&ch9!3Kq=%3@fI_3BrBQX2Ozd62| z_BA|mqwBDp8OKa9qRqi9+U@VdWmxDVai6987!m>f@vU6HTT{I{ `oL`4X z`(pvlfA|RDkz2P>Ekv=@fyrWI`{JIn?OBw~$ZJYz3m1fVts{iy)!s-6d`kV;=U}=r zw_&jn(6|#s@~>Sk3;R5lI2o<`sd%(>k*bJVjKOIfMm~GJfSTAkU3qO4dGLg6TKZPE z)Y1tdz+X!E8{;_@hTn$hU(6H%K2FY)dKyXq6)l}ZjT*o0@9e&cjwd=AOIZxwJ7U8h zbHGEy8Is=Lmq5A0HUNPfD! zUhPSzy)EJyStfoMs`O|W2EIwGQF#UyB@DuPa=#R}3E8Um2ZD{Oa}M=yz2Dy;6h8G#%B`8$XgI3zR6!Ssv2d{km&G6lq+>eXoxX%ypDm8IC@ELz zaXVo6^BP0P#OkIU{yBU=MKS}X}98NJ$*ktvteAlDA&<_@Iu99nPn^ZDijKcA!sFLh-U+KMY*$o9VHa*sMM2|VO#36CZ40SG zWFjt4@$sUb*er}#aAKs5SuiY@1iaxBFvwNhc>Ei3i*ny$e%?1U>KX^cGfrR*SY>t(_ zGVnw#67s`$Eq{F~__aU2hHr5rrs)9_s6V2{cRD{&C~IdHAlZUMETW=xKd)$c=Re>7 z@FaANtHq|8xKfXM&%L*wfe5X9Col()KgMbMtAx*du|u_m_jse9Cg0+xo2J4^d@ehm z3<*vuxv7|h^(O|*FEL1ihScOoE2GXo4&s!|1IGs?doD&!ym<>-T!u*=Ezv!_tl`lf zTzx|ZA_dIvEPk;cSuJ+F%^a@!aFu!avIBa>B+c^N>I0M0qHgIqmp01eG0AXuaLMrI z3x6}wA^1dcR@mn|MDz#CM@3v>!}U1mE+9s5ey@ z2!vyfaAT6b?vHp;pSs#T`)uf2pzRkhZOPb>6x?GBT#I*9fz`5p)i)tGG!ln5Z^(wc zwM~5Y4>LLrX=Az2XpKq0h=Q!ZE9bq5AhN1a%B{%(lLa}0>e%Qr=Ko}g7ZQf~hv@p3 z7igSfiHXDot1?x<+a{g=8Le0fC|U6ML*UQ-+)lmpoeSSV(_ujwYf6rrlB(iL@o*L; zLVTG$e%0tp2^&PF=lsMhJbNt6#`L^unBUoscze2~uAfQzR|GUkMg$!8^{-#HBt`)T zYubXzFYcf}J5vPGemn0_prfk;Nzb9U&g^HuW0R>{&$ zg_158^oWYmm-%@%>_Icdd}5zIs2V#G_0yo4My9ds0G+bQ;5NEMAsb9m(DHPI42{Io>isKbXS#sO8S{xTB@^p@KgAwSNs8+B-UT3dTH^UI8pEUo46kY^-8K| z4;AO;^NB)|6~f=e**&pANLQ5E4y{&cS%C8*4}HJu7a?J1W2H>3V;nC1?R^Z-`JzJa zZ0k3cz7Om@7nBkCFekG;TORs>PloRyhOJS6QUbB_*U>TUcN%5Sf_gOwie{H5%ozxL z3%SHT*{T|SAnK?5r~ElEs>VcE)aw~PdcVJV&L^P^DH=0wi7#F55XGSPwgT zSgJ-1;@K#If}S5&?gTRmFljB}lO%@hvtTMJWlOsR2=Sy|qEv6}N(T^hdUzhk=<#?p z(Bo|pIIg2sWBSLDEfV!QCgZT$bH^3Cce=@4?pDSa-o9>+SsZok3m z7Z5dTV?El;^Kzd2=4uDLC@xI)sI8S!L%%pU=|jz{jt=0-ssH;YM+#D#5fxNgpxBeS zr7SVoAzYa^sp_)jr;T&0Y=BMI{7>xb$K~zTRHMw7)FIP)+f}A^TI^{O?WyI14J^kc z9uL4Oa853+;Li)WFmv;adJ`J~*>COVGu0W*#k6W~%U%(ivR*fCP&e0&z|JYsQD zLb=-PhOeTq+EXL$>5wyNl_6u(HlKTZc;~SvOYCD(d*-{bSGc{5nO*JN@6{ITiPzbM zvsuqIH$OV;u6(juOO741Qb%fZcHg+ILe++>)VJ%3l47-Q^(YCmIm=x$)_H8z~pA_aE3_s+`DsxFb)qti<=4`{I>-_H$mYS$DUp z?x=xY-b+Q-St;2uX}3l-f3HY&TEhT&tBztR<6!U*iby9FaLtnkmJTt#)Hd zz+YjDhp;`O_j_XB_3ItrZL8=UeyuY^@)nk9 zzv;qBg)#PS(a+r<2Fp*e7+N?X-EmaP_Dto9dA}VH>gzo5U@mLX6SHg`3yq?%9(6bK zW(L;E3yn}OO>r(Yd^AvR@Nu7ATNbG+lqeKO>v0_IU#77RSdG^nK0o%J?Um5z*!60@ zyAtb_J@qxE<5$S^7vj(M&=)%pIrNIZ!PYw`9JKs%j%vP z{4uv)JL0mfqgRm6ur2!(!?&6VDX|vL5H^a^@i_jrjl_u6S*k~Lp2+U$D7sgK{L8=J zn!Rz671x%VEecsPyKuqr9LLxt?YSK5IZ+~O??kM$Q@TCzWYu8yAtx3~SIjxye?WqF zO22&v*B@WjeYvIQ661-stnvEBug0?~l=2pc$X;K0_|RL|*?V|47UqRY;aLfWei5wx zi*@&}RXeX;>D4P{?y40v54T42tC)QtxL=y^wEoIF&40fa?;o0#+Fx1BI;Zzfb4FOj z)W!`JXUVCq>Jm|&-hI-jA+vO}62b%LIOg^d3L4^FyPIe8N88(XGph#c9&%&J^z}d7 z-rHpE4$)~r`SVge`pxQaeevB4-NH+uSqYQ;wzK+IU+EF9YR==2Jz6kDN+|5Wal6#& z(Hnl6)1cZx8ESaZ!p8*Hs(qPLwB3sEmK7du)cZ0xeV z3+IF)YtCFw(owa+wE+g)rxtV0FEI)!xO2;_f9)pLVl5vTpF+uj39$|)Rf#vImPKEz zsqr&)_DKIZX_Nc((6T*$I-RSF5;2&Uz<(2OsD00OQ&B-x@iekgj@1yd4M=!V2-#?) z%FLVW1Y#wnY{*h``-yDI@;#T=gFUWjoy~7PzYii?0kL|yxH%^}dC%7)$7GKomNy}~ zkq}KGWV4}v)4x6Nck}?4#S+!$h)&g$Vi$5bqP1L(NDay3I?IWx{T=+jhX+@hC8y8e zWy}6rH3*!R4?)uAk>BvLwH!{U2Ocm@6%sNwGR8ile8p1j*aLQeF(b)nyxH z;IMc6U<}{fJWop0m11{RYJ-uQ(io~Pg}$nia3SXrZgy~1m1>khnmys0nf$Q*m(7OvL&PN05mIcpUayeGa>X&hvkg2wZ7)PiFj(aUX2l4%-5}QIwj5^C^kQ zh+c_(^8yj$<%Yo;GR!z4WyAhS_$d}5!+t8mg3-hAy5S`r)?7!$nUly*+=2Afi?Mfx zA6E7-gSA2%I*wlJ$%+{KlVqS{g5XM~G6eK-#N#`+P+L)k%O}#18@~yu%R{jz$OkjX z^C9C19i_$UI2=w6q3j<)Qc_YUN&hTuNgp+pVI1EKcgjmqQ*r?%$C8l~yADUlT!PnWSh$jUR&9ED#JJ{9;(h}qw@3# zoKM`2EHW38r;oz|GYxc>5d&XO3u(uW{iELpPmwP-^;ZJ%F4=GmH2%AH}^k--_Y>Zv%077=w`=YoNTF!^5aKQb}R|` zv1^gJcoudHvd4h-jdLL;av7SN>gwuHSXhYX&!2y`inXzq$b6h3Q;8OB#oZYYj8KHsL+}#-V%2H%5h~vn(#K)Qh~9YIHHF-qw+*5N)oprZ_Q$)&+x?`4*IZA zl!TFjBr*;szsK<5!TtO9VP<9qRaI5^_>6{yg#{zWxN+k?lA$&6Qyh7xvKV|;iV{fl z_e3R`55+rUkh?MzX@MiLj>urHK-VO3M9!a!`WG)ggpaXf$1->qhK1o=K>-R1&ttf! zCv$Ddk|lpB-`eNDhfi?R*8)bkGx(;ObwEW@0Yg$8NT2_3{FDJ*SNmERF>6w+ zM-Nn|C83PWh5Us<7{gU#WaFC{V8Mcg=-9C%6ciMgJT!DZPGk|CF#jAgesXhjajmKf z5fKqg|5IH=kbczo5wu@bQI0N3GO$&WLf+yTDBZFOzZ$k@uv=)WAuTN(Ij3{+XU1_1 z9XbpF0h6(H+ja&&?f=u{-rTu!$@4K|u=nfN?=SCzAB~^Nu_bgOlc%!D7|+Lrq9R-_yMn5!YE)EQMN;x1X8h~v=`ruFt_$wfR67M-+6HckuAh zBL+9^`;j9@g2&^bq@?6a(3yL!g@4haMa;NRR8#~dx|Y*iLqmhCAv{Kx?A5zBe)(kt zCItjA_{UF}fXZvv@ZiA%JR|QX+6R7qe$B>C1!yh&d-pbuSGv|w-6b$E2%|=gLcjj~ zVNaexXG24D>0%19l?sC~I(h?x{ocL%cuMsAYebG7J$keVdu!sSZDnU?!^OpgnRk4? zBgPVacOubMf~HKx;w4MT_}WP3z;Tq9SKvC)?`!YgMNLf&qN1XhHHqr`<>lqHsb;6v z>VE-4s%KePS~4=2o12rlFdgwb6UbVVjuR(N;P~-O96g$fEwQnTZ0*~(XUbCDUZBGX z+G`ZQ9XIgm@&x8%4!bOPnP)+_yvrp97m2EL3nsL=Fgwc z(Au?YLEopB$h!ZvwNcQ{m+~Kp|4V#Z>)!u3{wlVp=o{Tmof^KMbQ^Sa8%dAk%_VVh z@i)Y9QuQsy6IxGLNazhmR1}TGCOIKCB{7C%#Kh1@;*b&lFUg9xfovNANkCRYK$4J^ zl!V-Sl7gI+fTSTO-AMA%98miCr=Q+_2mbU9(wtjo`VB>1|6w>g#1rQ{yihn|G%k$t zMe*2)D47s|(qE_Ga^P>cGA$StGv}dl&H_}0hU5C82;5k*0yWE{a64)(YS%{NUi2nB z*c69{aXavM$1XhGm567F2l3)y3hGl*(UAHlUT2)Z+pKKh)M;3AdEaHf`u~n!{O6xv zS}H2RvaK>Kl~iD*tO_fYcCc1egLOM~*r>IKjk*T9YG|UXrWS0qv|+2Q13R6LuW5FWzDQH~Y5-zSske?|2sL!~8XyUSYB7e`?Gh338!#=S&S2 z>k(@nQ%;cAvmBW7ddgLU#iA3B=5zt4Icf5LGbg=5`;*C<W1}DrD|vBr=CEJt%ZT=C zJuaVb$v|3ki?fo%D{oB>2B}HGoy5qDATcHs6IWKO{pV}8&K*OJXpVb(X-w0VgCB_# znM!gRE7DViY*-}CE+kxpTZhx9TOo2zG?5W|L1R-WUrMvM@(AWB(Ab)K9!GTAr)##_ zRpHJu>;zNUMhr9caw zYaX*tlxik_8Xo}PL9TFauYhoqc8D}@kJXl%2s2fOG4X+(&dm5k>tDarT>i9N!^@ZO z>g9yq8VZQA)WAAxEo|tjgDD28Fjtks)yt)yWSEzi$JnB#Oqs&?&YBi#34dDe>66Fk z-nk<@J18=|H`{eYoP#cWxvJoIR7XYWrKZi}^5x5n4>Bld3f$b>U}tBChs35XNG;`0 z>rp?DmAWD(6S?CYI$?*S9(Hx(VxmDim?%nN!-}PX=Hct>OYEG#F#b>K7jkv&i}A!> zD@fnMpVp}-BM@r9J)D)D!m&OHOlTU%Qj)LwRz z_(qzh@8wV1x_kRJrcWmSQ_ts|&Odzki1FXdoH>*6xi;n5^tdJbX$%kbO;b68f`Z`h|0|ix6Br*r@a);3et-<( zSE6=nO4JS=8XDS^-ABhQ;ZG}{J9mz;&)eJEleXt${U6bce~mu(YuBonzE4O0| zynQXTls|3nHW_a-Nqhl~-=KE+fddC((4aw#Ux%(O-rn8}&ad&N_rHa|pk3-KN=Zop zozFBcE-q%Cx!`_t^6%l_oc6y~rX~E}l@;_^Yv!csuO?92;@QE&Q83&a=e@_Fc$_~j z`3IpaXa>q>%thtgg{Tf&iklIUxc&PY)UMlr`y1o%Xlp#4ChR3YyO@OfLr3u{Edy^) zoMLQ-ge#S!IqCnLKLOdAecrUK=E(m)QARLd9?b);IS|qy#Cb<77W)w)Vsl{=drPa5 zfG@REP_u+4A%UHO-}t-sz4{Tz{aiI5L@m?&{B1sb+vzKcd%8Q^ABqi!ka z)22DmhYLQePhuKY&G2%^920f&U7?Aw-E8pU`Lp-cGBYztEKdb<{;B#TwkL|}27a#2 zSY@q^^|qZb$+a79-KZupHRqYw4ytpPmX=a|{3HIfK5d+STa0lq$1b8vhTG_&yOkM! z88HI;_V358-Fq;D=n`M5PusY1u^67l9Wj8!-<~BgYcw8g>Cy-U5`BT{1YfI9+cr)=!M1JNhN|jnLG{n_r@9UK zEpG)g2Zq6wmj=yg?r - /// Calculate bounding box with given rhino objects. - /// - /// RhinoObjects to calculate union of bounding box. - /// - public static BoundingBox UnionRhinoObjects(IEnumerable rhinoObjects) - { - BoundingBox boundingBox = BoundingBox.Unset; - foreach (RhinoObject obj in rhinoObjects) - { - BoundingBox objBoundingBox = obj.Geometry.GetBoundingBox(false); - if (objBoundingBox.IsValid) - { - if (boundingBox.IsValid) - { - boundingBox.Union(objBoundingBox); - } - else - { - boundingBox = objBoundingBox; - } - } - } - - return boundingBox; - } -} diff --git a/ConnectorRhino/ConnectorRhinoWebUI/PanelHosts.cs b/ConnectorRhino/ConnectorRhinoWebUI/PanelHosts.cs deleted file mode 100644 index 0140a81362..0000000000 --- a/ConnectorRhino/ConnectorRhinoWebUI/PanelHosts.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System.Runtime.InteropServices; - -namespace ConnectorRhinoWebUI; - -[Guid("39BC44A4-C9DC-4B0A-9A51-4C31ACBCD76A")] -public class SpeckleWebUiWebView2PanelHost : RhinoWindows.Controls.WpfElementHost -{ - private readonly uint _docSn; - - public SpeckleWebUiWebView2PanelHost(uint docSn) - : base(new WebUiPanelWebView2(), null) - { - _docSn = docSn; - } -} - -[Guid("55B9125D-E8CA-4F65-B016-60DA932AB694")] -public class SpeckleWebUiCefPanelHost : RhinoWindows.Controls.WpfElementHost -{ - private readonly uint _docSn; - - public SpeckleWebUiCefPanelHost(uint docSn) - : base(new WebUiPanelCef(), null) - { - _docSn = docSn; - } -} diff --git a/ConnectorRhino/ConnectorRhinoWebUI/Plugin.cs b/ConnectorRhino/ConnectorRhinoWebUI/Plugin.cs deleted file mode 100644 index 3e640602e4..0000000000 --- a/ConnectorRhino/ConnectorRhinoWebUI/Plugin.cs +++ /dev/null @@ -1,26 +0,0 @@ -using ConnectorRhinoWebUI.Utils; -using Rhino; -using Rhino.PlugIns; - -namespace ConnectorRhinoWebUI; - -/// -/// Every RhinoCommon .rhp assembly must have one and only one PlugIn-derived -/// class. DO NOT create instances of this class yourself. It is the -/// responsibility of Rhino to create an instance of this class. -/// To complete plug-in information, please also see all PlugInDescription -/// attributes in AssemblyInfo.cs (you might need to click "Project" -> -/// "Show All Files" to see it in the "Solution Explorer" window). -/// -public class ConnectorRhinoWebUiPlugin : PlugIn -{ - public static ConnectorRhinoWebUiPlugin Instance { get; private set; } - - public override PlugInLoadTime LoadTime => PlugInLoadTime.AtStartup; - - public ConnectorRhinoWebUiPlugin() - { - Instance = this; - RhinoIdleManager.SubscribeToIdle(() => RhinoApp.RunScript("SpeckleWebUIWebView2", false)); - } -} diff --git a/ConnectorRhino/ConnectorRhinoWebUI/Properties/AssemblyInfo.cs b/ConnectorRhino/ConnectorRhinoWebUI/Properties/AssemblyInfo.cs deleted file mode 100644 index 504a629210..0000000000 --- a/ConnectorRhino/ConnectorRhinoWebUI/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System.Runtime.InteropServices; -using Rhino.PlugIns; - -// Plug-in Description Attributes - all of these are optional. -// These will show in Rhino's option dialog, in the tab Plug-ins. -[assembly: PlugInDescription(DescriptionType.Address, "")] -[assembly: PlugInDescription(DescriptionType.Country, "")] -[assembly: PlugInDescription(DescriptionType.Email, "")] -[assembly: PlugInDescription(DescriptionType.Phone, "")] -[assembly: PlugInDescription(DescriptionType.Fax, "")] -[assembly: PlugInDescription(DescriptionType.Organization, "")] -[assembly: PlugInDescription(DescriptionType.UpdateUrl, "")] -[assembly: PlugInDescription(DescriptionType.WebSite, "")] - -// Icons should be Windows .ico files and contain 32-bit images in the following sizes: 16, 24, 32, 48, and 256. -[assembly: PlugInDescription(DescriptionType.Icon, "ConnectorRhinoWebUI.EmbeddedResources.plugin-utility.ico")] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -// This will also be the Guid of the Rhino plug-in -[assembly: Guid("aef36d52-808d-4ad4-bf45-efb5350fb3cc")] diff --git a/ConnectorRhino/ConnectorRhinoWebUI/Properties/launchSettings.json b/ConnectorRhino/ConnectorRhinoWebUI/Properties/launchSettings.json deleted file mode 100644 index 627d38a6c3..0000000000 --- a/ConnectorRhino/ConnectorRhinoWebUI/Properties/launchSettings.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "profiles": { - "ConnectorRhinoWebUI": { - "commandName": "Project", - "nativeDebugging": false - } - } -} \ No newline at end of file diff --git a/ConnectorRhino/ConnectorRhinoWebUI/SpeckleWebUiPanelWebView2.xaml.cs b/ConnectorRhino/ConnectorRhinoWebUI/SpeckleWebUiPanelWebView2.xaml.cs deleted file mode 100644 index d646b07530..0000000000 --- a/ConnectorRhino/ConnectorRhinoWebUI/SpeckleWebUiPanelWebView2.xaml.cs +++ /dev/null @@ -1,86 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Windows.Controls; -using ConnectorRhinoWebUI.Bindings; -using DUI3; -using DUI3.Bindings; -using DUI3.Models; -using Microsoft.Web.WebView2.Core; -using Microsoft.Web.WebView2.Wpf; -using Speckle.Core.Logging; - -namespace ConnectorRhinoWebUI -{ - /// - /// Interaction logic for SpeckleWebUiPanelWebView2.xaml - /// - public partial class SpeckleWebUiPanelWebView2 : UserControl - { - public SpeckleWebUiPanelWebView2() - { - InitializeComponent(); - Browser.CoreWebView2InitializationCompleted += Browser_Initialized_Completed; - } - - private void Browser_Initialized_Completed(object sender, EventArgs e) - { - Browser.CoreWebView2.OpenDevToolsWindow(); - - void ExecuteScriptAsyncMethod(string script) - { - if (!Browser.IsInitialized) - { - throw new SpeckleException("Failed to execute script, Webview2 is not initialized yet."); - } - - Browser.ExecuteScriptAsync(script); - } - - void ShowDevToolsMethod() => Browser.CoreWebView2.OpenDevToolsWindow(); - - var documentState = new DocumentModelStore(); - - var bindingsToProvide = new List(); - - // Test bindings - bindingsToProvide.Add(new TestBinding()); - bindingsToProvide.Add(new ConfigBinding()); - - // var testBindingBridge = new DUI3.BrowserBridge(Browser, testBinding, executeScriptAsyncMethod, showDevToolsMethod); - // Browser.CoreWebView2.AddHostObjectToScript(testBindingBridge.FrontendBoundName, testBindingBridge); - - var docState = new DocumentModelStore(); - - // Base bindings - var baseBindings = new BasicConnectorBindingRhino(); - var baseBindingsBridge = new DUI3.BrowserBridge( - Browser, - baseBindings, - ExecuteScriptAsyncMethod, - ShowDevToolsMethod - ); - Browser.CoreWebView2.AddHostObjectToScript(baseBindingsBridge.FrontendBoundName, baseBindingsBridge); - - // Config bindings - var configBindings = new ConfigBinding(); - var configBindingsBridge = new BrowserBridge( - Browser, - configBindings, - ExecuteScriptAsyncMethod, - ShowDevToolsMethod - ); - Browser.CoreWebView2.AddHostObjectToScript(configBindingsBridge.FrontendBoundName, configBindingsBridge); - - // Selection bindings - var selectionBinding = new SelectionBinding(); - var selectionBindingBridge = new BrowserBridge( - Browser, - selectionBinding, - ExecuteScriptAsyncMethod, - ShowDevToolsMethod - ); - Browser.CoreWebView2.AddHostObjectToScript(selectionBindingBridge.FrontendBoundName, selectionBindingBridge); - } - } -} diff --git a/ConnectorRhino/ConnectorRhinoWebUI/Utils/RhinoDocumentStore.cs b/ConnectorRhino/ConnectorRhinoWebUI/Utils/RhinoDocumentStore.cs deleted file mode 100644 index ff4a80b5b6..0000000000 --- a/ConnectorRhino/ConnectorRhinoWebUI/Utils/RhinoDocumentStore.cs +++ /dev/null @@ -1,58 +0,0 @@ -using System.Collections.Generic; -using DUI3.Models; -using Rhino; - -namespace ConnectorRhinoWebUI.Utils; - -public class RhinoDocumentStore : DocumentModelStore -{ - private const string SPECKLE_KEY = "Speckle_DUI3"; - public override bool IsDocumentInit { get; set; } = true; // Note: because of rhino implementation details regarding expiry checking of sender cards. - - public RhinoDocumentStore() - { - RhinoDoc.BeginSaveDocument += (_, _) => WriteToFile(); - RhinoDoc.CloseDocument += (_, _) => WriteToFile(); - RhinoDoc.BeginOpenDocument += (_, _) => IsDocumentInit = false; - RhinoDoc.EndOpenDocument += (_, e) => - { - if (e.Merge) - { - return; - } - - if (e.Document == null) - { - return; - } - - IsDocumentInit = true; - ReadFromFile(); - OnDocumentChanged(); - }; - } - - public override void WriteToFile() - { - if (RhinoDoc.ActiveDoc == null) - { - return; // Should throw - } - - RhinoDoc.ActiveDoc?.Strings.Delete(SPECKLE_KEY); - - string serializedState = Serialize(); - RhinoDoc.ActiveDoc?.Strings.SetString(SPECKLE_KEY, SPECKLE_KEY, serializedState); - } - - public override void ReadFromFile() - { - string stateString = RhinoDoc.ActiveDoc.Strings.GetValue(SPECKLE_KEY, SPECKLE_KEY) ?? null; - if (stateString == null) - { - Models = new List(); - return; - } - Models = Deserialize(stateString); - } -} diff --git a/ConnectorRhino/ConnectorRhinoWebUI/Utils/RhinoIdleManager.cs b/ConnectorRhino/ConnectorRhinoWebUI/Utils/RhinoIdleManager.cs deleted file mode 100644 index 608a649df9..0000000000 --- a/ConnectorRhino/ConnectorRhinoWebUI/Utils/RhinoIdleManager.cs +++ /dev/null @@ -1,45 +0,0 @@ -using System; -using System.Collections.Concurrent; -using Rhino; - -namespace ConnectorRhinoWebUI.Utils; - -/// -/// Rhino Idle Manager is a helper util to manage deferred actions. -/// -public static class RhinoIdleManager -{ - // NOTE: ConcurrentDictionary possibly removing the collection has been modified errors in here - private static readonly ConcurrentDictionary s_sCalls = new(); - private static bool s_hasSubscribed; - - /// - /// Subscribe deferred action to RhinoIdle event to run it whenever Rhino become idle. - /// - /// Action to call whenever Rhino become Idle. - public static void SubscribeToIdle(Action action) - { - s_sCalls[action.Method.Name] = action; - - if (s_hasSubscribed) - { - return; - } - - s_hasSubscribed = true; - RhinoApp.Idle += RhinoAppOnIdle; - } - - private static void RhinoAppOnIdle(object sender, EventArgs e) - { - foreach (var kvp in s_sCalls) - { - kvp.Value(); - } - - s_sCalls.Clear(); - - s_hasSubscribed = false; - RhinoApp.Idle -= RhinoAppOnIdle; - } -} diff --git a/ConnectorRhino/ConnectorRhinoWebUI/Utils/SpeckleRhinoObject.cs b/ConnectorRhino/ConnectorRhinoWebUI/Utils/SpeckleRhinoObject.cs deleted file mode 100644 index 3c2b255343..0000000000 --- a/ConnectorRhino/ConnectorRhinoWebUI/Utils/SpeckleRhinoObject.cs +++ /dev/null @@ -1,27 +0,0 @@ -using DUI3.Objects; -using Rhino.DocObjects; - -namespace ConnectorRhinoWebUI.Utils; - -// We get from conversion (result of ToNative) -// Information the Connector needs to track objects -public class SpeckleRhinoObject : SpeckleHostObject -{ - public override RhinoObject NativeObject { get; } - public new string ApplicationId { get; } - public new string SpeckleId { get; } - public new bool IsExpired { get; } - - public SpeckleRhinoObject(RhinoObject rhinoObject, string applicationId, string speckleId, bool isExpired = false) - { - NativeObject = rhinoObject; - ApplicationId = applicationId; - SpeckleId = speckleId; - IsExpired = isExpired; - } - - public override SpeckleHostObject WithExpiredStatus(bool status = true) - { - return new SpeckleRhinoObject(this.NativeObject, this.ApplicationId, this.SpeckleId, status); - } -} diff --git a/ConnectorRhino/ConnectorRhinoWebUI/Utils/Utils.cs b/ConnectorRhino/ConnectorRhinoWebUI/Utils/Utils.cs deleted file mode 100644 index 4b6b5d5db9..0000000000 --- a/ConnectorRhino/ConnectorRhinoWebUI/Utils/Utils.cs +++ /dev/null @@ -1,17 +0,0 @@ -using Speckle.Core.Kits; - -namespace ConnectorRhinoWebUI.Utils; - -public static class Utils -{ -#if RHINO6 - public static string RhinoAppName = HostApplications.Rhino.GetVersion(HostAppVersion.v6); - public static string AppName = "Rhino"; -#elif RHINO7 - public static string RhinoAppName = HostApplications.Rhino.GetVersion(HostAppVersion.v7); - public static string AppName = "Rhino"; -#else - public static readonly string RhinoAppName = HostApplications.Rhino.GetVersion(HostAppVersion.v7); - public static readonly string AppName = "Rhino"; -#endif -} diff --git a/ConnectorRhino/ConnectorRhinoWebUI/WebUIPanelCef.xaml b/ConnectorRhino/ConnectorRhinoWebUI/WebUIPanelCef.xaml deleted file mode 100644 index 7bdd7c1814..0000000000 --- a/ConnectorRhino/ConnectorRhinoWebUI/WebUIPanelCef.xaml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - diff --git a/ConnectorRhino/ConnectorRhinoWebUI/WebUIPanelCef.xaml.cs b/ConnectorRhino/ConnectorRhinoWebUI/WebUIPanelCef.xaml.cs deleted file mode 100644 index 1c24a0c658..0000000000 --- a/ConnectorRhino/ConnectorRhinoWebUI/WebUIPanelCef.xaml.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System.Collections.Generic; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Threading; -using CefSharp; -using DUI3; - -namespace ConnectorRhinoWebUI; - -public partial class WebUiPanelCef : UserControl -{ - public WebUiPanelCef() - { - CefSharpSettings.ConcurrentTaskExecution = true; - InitializeComponent(); - Browser.IsBrowserInitializedChanged += OnInitialized; - } - - private void ShowDevToolsMethod() => Browser.ShowDevTools(); - - private void ExecuteScriptAsyncMethod(string script) => - Browser.Dispatcher.Invoke(() => Browser.EvaluateScriptAsync(script), DispatcherPriority.Background); - - private void OnInitialized(object sender, DependencyPropertyChangedEventArgs e) - { - Browser.JavascriptObjectRepository.NameConverter = null; - - List bindings = Bindings.Factory.CreateBindings(); - foreach (IBinding binding in bindings) - { - BrowserBridge bridge = new(Browser, binding, ExecuteScriptAsyncMethod, ShowDevToolsMethod); - Browser.JavascriptObjectRepository.Register(bridge.FrontendBoundName, bridge, true); - } - } -} diff --git a/ConnectorRhino/ConnectorRhinoWebUI/WebUIPanelWebView2.xaml b/ConnectorRhino/ConnectorRhinoWebUI/WebUIPanelWebView2.xaml deleted file mode 100644 index 3b9dddd74c..0000000000 --- a/ConnectorRhino/ConnectorRhinoWebUI/WebUIPanelWebView2.xaml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - diff --git a/ConnectorRhino/ConnectorRhinoWebUI/WebUIPanelWebView2.xaml.cs b/ConnectorRhino/ConnectorRhinoWebUI/WebUIPanelWebView2.xaml.cs deleted file mode 100644 index 3776ef8d8f..0000000000 --- a/ConnectorRhino/ConnectorRhinoWebUI/WebUIPanelWebView2.xaml.cs +++ /dev/null @@ -1,40 +0,0 @@ -using System.Collections.Generic; -using System.Windows.Controls; -using System.Windows.Threading; -using DUI3; -using Microsoft.Web.WebView2.Core; -using Speckle.Core.Logging; - -namespace ConnectorRhinoWebUI; - -public partial class WebUiPanelWebView2 : UserControl -{ - public WebUiPanelWebView2() - { - InitializeComponent(); - Browser.CoreWebView2InitializationCompleted += OnInitialized; - } - - private void ShowDevToolsMethod() => Browser.CoreWebView2.OpenDevToolsWindow(); - - private void ExecuteScriptAsyncMethod(string script) - { - if (!Browser.IsInitialized) - { - throw new SpeckleException("Failed to execute script, Webview2 is not initialized yet."); - } - - Browser.Dispatcher.Invoke(() => Browser.ExecuteScriptAsync(script), DispatcherPriority.Background); - } - - private void OnInitialized(object sender, CoreWebView2InitializationCompletedEventArgs e) - { - List bindings = Bindings.Factory.CreateBindings(); - - foreach (IBinding binding in bindings) - { - BrowserBridge bridge = new(Browser, binding, ExecuteScriptAsyncMethod, ShowDevToolsMethod); - Browser.CoreWebView2.AddHostObjectToScript(binding.Name, bridge); - } - } -} diff --git a/DUI3-DX-REVIT.slnf b/DUI3-DX-REVIT.slnf index d24183d03f..e84ba6eed1 100644 --- a/DUI3-DX-REVIT.slnf +++ b/DUI3-DX-REVIT.slnf @@ -9,7 +9,6 @@ "DUI3-DX\\Converters\\Revit\\Speckle.Converters.Revit2023\\Speckle.Converters.Revit2023.csproj", "DUI3-DX\\Converters\\Revit\\Speckle.Converters.RevitShared\\Speckle.Converters.RevitShared.shproj", "DUI3-DX\\DUI3\\Speckle.Connectors.DUI\\Speckle.Connectors.DUI.csproj", - "DUI3-DX\\Objects\\Speckle.Objects.Common\\Speckle.Objects.Common.csproj", "DUI3-DX\\Sdk\\Speckle.Autofac\\Speckle.Autofac.csproj", "DUI3-DX\\Sdk\\Speckle.Connectors.Utils\\Speckle.Connectors.Utils.csproj", "DUI3-DX\\Sdk\\Speckle.Converters.Common.DependencyInjection\\Speckle.Converters.Common.DependencyInjection.csproj", diff --git a/DUI3-DX-RHINO.slnf b/DUI3-DX-RHINO.slnf index 7ffe9697a8..16ee76daf2 100644 --- a/DUI3-DX-RHINO.slnf +++ b/DUI3-DX-RHINO.slnf @@ -7,7 +7,6 @@ "DUI3-DX\\Converters\\Rhino\\Speckle.Converters.Rhino7.DependencyInjection\\Speckle.Converters.Rhino7.DependencyInjection.csproj", "DUI3-DX\\Converters\\Rhino\\Speckle.Converters.Rhino7\\Speckle.Converters.Rhino7.csproj", "DUI3-DX\\DUI3\\Speckle.Connectors.DUI\\Speckle.Connectors.DUI.csproj", - "DUI3-DX\\Objects\\Speckle.Objects.Common\\Speckle.Objects.Common.csproj", "DUI3-DX\\Sdk\\Speckle.Autofac\\Speckle.Autofac.csproj", "DUI3-DX\\Sdk\\Speckle.Connectors.Utils\\Speckle.Connectors.Utils.csproj", "DUI3-DX\\Sdk\\Speckle.Converters.Common.DependencyInjection\\Speckle.Converters.Common.DependencyInjection.csproj", diff --git a/DUI3-DX.slnf b/DUI3-DX.slnf index 9bed907dd3..71b80b7edb 100644 --- a/DUI3-DX.slnf +++ b/DUI3-DX.slnf @@ -25,8 +25,6 @@ "DUI3-DX\\Converters\\Rhino\\Speckle.Converters.Rhino7\\Speckle.Converters.Rhino7.csproj", "DUI3-DX\\DUI3\\Speckle.Connectors.DUI.WebView\\Speckle.Connectors.DUI.WebView.csproj", "DUI3-DX\\DUI3\\Speckle.Connectors.DUI\\Speckle.Connectors.DUI.csproj", - "DUI3-DX\\Objects\\Speckle.Objects.Common\\Speckle.Objects.Common.csproj", - "DUI3-DX\\Objects\\Speckle.Objects.Revit\\Speckle.Objects.Revit.csproj", "DUI3-DX\\Sdk\\Speckle.Autofac\\Speckle.Autofac.csproj", "DUI3-DX\\Sdk\\Speckle.Connectors.Utils\\Speckle.Connectors.Utils.csproj", "DUI3-DX\\Sdk\\Speckle.Converters.Common.DependencyInjection\\Speckle.Converters.Common.DependencyInjection.csproj", diff --git a/DUI3-DX/Objects/Speckle.Objects.Common/Speckle.Objects.Common.csproj b/DUI3-DX/Objects/Speckle.Objects.Common/Speckle.Objects.Common.csproj index 7d2edc9c8b..5f282702bb 100644 --- a/DUI3-DX/Objects/Speckle.Objects.Common/Speckle.Objects.Common.csproj +++ b/DUI3-DX/Objects/Speckle.Objects.Common/Speckle.Objects.Common.csproj @@ -1,17 +1 @@ - - - - 10.0 - enable - netstandard2.0 - - - - false - - - - - - - + \ No newline at end of file diff --git a/DUI3-DX/Objects/Speckle.Objects.Revit/Speckle.Objects.Revit.csproj b/DUI3-DX/Objects/Speckle.Objects.Revit/Speckle.Objects.Revit.csproj deleted file mode 100644 index dbdcea46b6..0000000000 --- a/DUI3-DX/Objects/Speckle.Objects.Revit/Speckle.Objects.Revit.csproj +++ /dev/null @@ -1,7 +0,0 @@ - - - - netstandard2.0 - - - diff --git a/DUI3.slnf b/DUI3.slnf deleted file mode 100644 index bd4cd6a75b..0000000000 --- a/DUI3.slnf +++ /dev/null @@ -1,156 +0,0 @@ -{ - "solution": { - "path": "All.sln", - "projects": [ - "Automate\\Speckle.Automate.Sdk\\Speckle.Automate.Sdk.csproj", - "Automate\\Tests\\Speckle.Automate.Sdk.Tests.Integration\\Speckle.Automate.Sdk.Tests.Integration.csproj", - "CNX-8892\\Connectors\\Revit\\Speckle.Connectors.Revit2023\\Speckle.Connectors.Revit2023.csproj", - "CNX-8892\\Connectors\\Revit\\Speckle.Connectors.RevitShared\\Speckle.Connectors.RevitShared.shproj", - "CNX-8892\\Connectors\\Speckle.Connectors.Autofac\\Speckle.Connectors.Autofac.csproj", - "CNX-8892\\Connectors\\Speckle.Connectors.Utils\\Speckle.Connectors.Utils.csproj", - "CNX-8892\\Speckle.Autofac\\Speckle.Autofac.csproj", - "ConnectorArcGIS\\ConnectorArcGIS.csproj", - "ConnectorArchicad\\ConnectorArchicad\\ConnectorArchicad.csproj", - "ConnectorAutocadCivil\\AdvanceSteelAddinRegistrator\\AdvanceSteelAddinRegistrator.csproj", - "ConnectorAutocadCivil\\AutocadCivilDUI3\\Autocad2022\\ConnectorAutocad2022DUI3.csproj", - "ConnectorAutocadCivil\\AutocadCivilDUI3\\Autocad2023\\ConnectorAutocad2023DUI3.csproj", - "ConnectorAutocadCivil\\AutocadCivilDUI3\\AutocadCivilDUI3Shared\\AutocadCivilDUI3Shared.shproj", - "ConnectorAutocadCivil\\ConnectorAdvanceSteel2023\\ConnectorAdvanceSteel2023.csproj", - "ConnectorAutocadCivil\\ConnectorAdvanceSteel2024\\ConnectorAdvanceSteel2024.csproj", - "ConnectorAutocadCivil\\ConnectorAutocad2021\\ConnectorAutocad2021.csproj", - "ConnectorAutocadCivil\\ConnectorAutocad2022\\ConnectorAutocad2022.csproj", - "ConnectorAutocadCivil\\ConnectorAutocad2023\\ConnectorAutocad2023.csproj", - "ConnectorAutocadCivil\\ConnectorAutocad2024\\ConnectorAutocad2024.csproj", - "ConnectorAutocadCivil\\ConnectorAutocadCivil\\ConnectorAutocadCivilShared.shproj", - "ConnectorAutocadCivil\\ConnectorCivil2021\\ConnectorCivil2021.csproj", - "ConnectorAutocadCivil\\ConnectorCivil2022\\ConnectorCivil2022.csproj", - "ConnectorAutocadCivil\\ConnectorCivil2023\\ConnectorCivil2023.csproj", - "ConnectorAutocadCivil\\ConnectorCivil2024\\ConnectorCivil2024.csproj", - "ConnectorBentley\\ConnectorBentleyShared\\ConnectorBentleyShared.shproj", - "ConnectorBentley\\ConnectorMicroStation\\ConnectorMicroStation.csproj", - "ConnectorBentley\\ConnectorOpenBuildings\\ConnectorOpenBuildings.csproj", - "ConnectorBentley\\ConnectorOpenRail\\ConnectorOpenRail.csproj", - "ConnectorBentley\\ConnectorOpenRoads\\ConnectorOpenRoads.csproj", - "ConnectorCSI\\ConnectorCSIBridge\\ConnectorCSIBridge.csproj", - "ConnectorCSI\\ConnectorCSIShared\\ConnectorCSIShared.shproj", - "ConnectorCSI\\ConnectorETABS\\ConnectorETABS.csproj", - "ConnectorCSI\\ConnectorSAFE\\ConnectorSAFE.csproj", - "ConnectorCSI\\ConnectorSAP2000\\ConnectorSAP2000.csproj", - "ConnectorCSI\\DriverCSharp\\DriverCSharp.csproj", - "ConnectorCSI\\DriverPluginCSharp\\DriverPluginCSharp.csproj", - "ConnectorCore\\BatchUploader.OperationDriver\\BatchUploader.OperationDriver.csproj", - "ConnectorCore\\BatchUploader.Sdk\\BatchUploader.Sdk.csproj", - "ConnectorDynamo\\ConnectorDynamoExtension\\ConnectorDynamoExtension.csproj", - "ConnectorDynamo\\ConnectorDynamoFunctions\\ConnectorDynamoFunctions.csproj", - "ConnectorDynamo\\ConnectorDynamo\\ConnectorDynamo.csproj", - "ConnectorGrasshopper\\ConnectorGrasshopper6\\ConnectorGrasshopper6.csproj", - "ConnectorGrasshopper\\ConnectorGrasshopper7\\ConnectorGrasshopper7.csproj", - "ConnectorGrasshopper\\ConnectorGrasshopper8\\ConnectorGrasshopper8.csproj", - "ConnectorGrasshopper\\ConnectorGrasshopperShared\\ConnectorGrasshopperShared.shproj", - "ConnectorGrasshopper\\ConnectorGrasshopperUtils\\ConnectorGrasshopperUtils.csproj", - "ConnectorNavisworks\\ConnectorNavisworks2020\\ConnectorNavisworks2020.csproj", - "ConnectorNavisworks\\ConnectorNavisworks2021\\ConnectorNavisworks2021.csproj", - "ConnectorNavisworks\\ConnectorNavisworks2022\\ConnectorNavisworks2022.csproj", - "ConnectorNavisworks\\ConnectorNavisworks2023\\ConnectorNavisworks2023.csproj", - "ConnectorNavisworks\\ConnectorNavisworks2024\\ConnectorNavisworks2024.csproj", - "ConnectorNavisworks\\ConnectorNavisworks\\ConnectorNavisworks.shproj", - "ConnectorRevit\\ConnectorRevit2020\\ConnectorRevit2020.csproj", - "ConnectorRevit\\ConnectorRevit2021\\ConnectorRevit2021.csproj", - "ConnectorRevit\\ConnectorRevit2022\\ConnectorRevit2022.csproj", - "ConnectorRevit\\ConnectorRevit2023\\ConnectorRevit2023.csproj", - "ConnectorRevit\\ConnectorRevit2024\\ConnectorRevit2024.csproj", - "ConnectorRevit\\ConnectorRevit\\ConnectorRevitShared.shproj", - "ConnectorRevit\\RevitDUI3\\Revit2020DUI3\\Revit2020DUI3.csproj", - "ConnectorRevit\\RevitDUI3\\Revit2023DUI3\\Revit2023DUI3.csproj", - "ConnectorRevit\\RevitDUI3\\RevitDUI3Shared\\RevitDUI3Shared.shproj", - "ConnectorRevit\\RevitSharedResources2020\\RevitSharedResources2020.csproj", - "ConnectorRevit\\RevitSharedResources2021\\RevitSharedResources2021.csproj", - "ConnectorRevit\\RevitSharedResources2022\\RevitSharedResources2022.csproj", - "ConnectorRevit\\RevitSharedResources2023\\RevitSharedResources2023.csproj", - "ConnectorRevit\\RevitSharedResources2024\\RevitSharedResources2024.csproj", - "ConnectorRevit\\RevitSharedResources\\RevitSharedResources.shproj", - "ConnectorRhino\\ConnectorRhino6\\ConnectorRhino6.csproj", - "ConnectorRhino\\ConnectorRhino7\\ConnectorRhino7.csproj", - "ConnectorRhino\\ConnectorRhino8\\ConnectorRhino8.csproj", - "ConnectorRhino\\ConnectorRhinoWebUI\\ConnectorRhinoWebUI.csproj", - "ConnectorRhino\\ConnectorRhino\\ConnectorRhinoShared\\ConnectorRhinoShared.shproj", - "ConnectorTeklaStructures\\ConnectorTeklaStructures2020\\ConnectorTeklaStructures2020.csproj", - "ConnectorTeklaStructures\\ConnectorTeklaStructures2021\\ConnectorTeklaStructures2021.csproj", - "ConnectorTeklaStructures\\ConnectorTeklaStructures2022\\ConnectorTeklaStructures2022.csproj", - "ConnectorTeklaStructures\\ConnectorTeklaStructures2023\\ConnectorTeklaStructures2023.csproj", - "ConnectorTeklaStructures\\ConnectorTeklaStructuresShared\\ConnectorTeklaStructuresShared.shproj", - "Core\\Core\\Core.csproj", - "Core\\Tests\\Speckle.Core.Tests.Integration\\Speckle.Core.Tests.Integration.csproj", - "Core\\Tests\\Speckle.Core.Tests.Performance\\Speckle.Core.Tests.Performance.csproj", - "Core\\Tests\\Speckle.Core.Tests.Unit\\Speckle.Core.Tests.Unit.csproj", - "Core\\Transports\\DiskTransport\\DiskTransport.csproj", - "Core\\Transports\\MongoDBTransport\\MongoDBTransport.csproj", - "DesktopUI2\\AvaloniaHwndHost\\AvaloniaHwndHost.csproj", - "DesktopUI2\\DesktopUI2.Launcher\\DesktopUI2.Launcher.csproj", - "DesktopUI2\\DesktopUI2.WPF\\DesktopUI2.WPF.csproj", - "DesktopUI2\\DesktopUI2\\DesktopUI2.csproj", - "DesktopUI3\\DUI3\\DUI3.csproj", - "Objects\\Converters\\ConverterAutocadCivil\\ConverterAdvanceSteel2023\\ConverterAdvanceSteel2023.csproj", - "Objects\\Converters\\ConverterAutocadCivil\\ConverterAdvanceSteel2024\\ConverterAdvanceSteel2024.csproj", - "Objects\\Converters\\ConverterAutocadCivil\\ConverterAutocad2021\\ConverterAutocad2021.csproj", - "Objects\\Converters\\ConverterAutocadCivil\\ConverterAutocad2022\\ConverterAutocad2022.csproj", - "Objects\\Converters\\ConverterAutocadCivil\\ConverterAutocad2023\\ConverterAutocad2023.csproj", - "Objects\\Converters\\ConverterAutocadCivil\\ConverterAutocad2024\\ConverterAutocad2024.csproj", - "Objects\\Converters\\ConverterAutocadCivil\\ConverterAutocadCivilShared\\ConverterAutocadCivilShared.shproj", - "Objects\\Converters\\ConverterAutocadCivil\\ConverterCivil2021\\ConverterCivil2021.csproj", - "Objects\\Converters\\ConverterAutocadCivil\\ConverterCivil2022\\ConverterCivil2022.csproj", - "Objects\\Converters\\ConverterAutocadCivil\\ConverterCivil2023\\ConverterCivil2023.csproj", - "Objects\\Converters\\ConverterAutocadCivil\\ConverterCivil2024\\ConverterCivil2024.csproj", - "Objects\\Converters\\ConverterBentley\\ConverterBentleyShared\\ConverterBentleyShared.shproj", - "Objects\\Converters\\ConverterBentley\\ConverterMicroStation\\ConverterMicroStation.csproj", - "Objects\\Converters\\ConverterBentley\\ConverterOpenBuildings\\ConverterOpenBuildings.csproj", - "Objects\\Converters\\ConverterBentley\\ConverterOpenRail\\ConverterOpenRail.csproj", - "Objects\\Converters\\ConverterBentley\\ConverterOpenRoads\\ConverterOpenRoads.csproj", - "Objects\\Converters\\ConverterCSI\\ConverterCSIBridge\\ConverterCSIBridge.csproj", - "Objects\\Converters\\ConverterCSI\\ConverterCSIShared\\ConverterCSIShared.shproj", - "Objects\\Converters\\ConverterCSI\\ConverterETABS\\ConverterETABS.csproj", - "Objects\\Converters\\ConverterCSI\\ConverterSAFE\\ConverterSAFE.csproj", - "Objects\\Converters\\ConverterCSI\\ConverterSAP2000\\ConverterSAP2000.csproj", - "Objects\\Converters\\ConverterDxf\\ConverterDxf\\ConverterDxf.csproj", - "Objects\\Converters\\ConverterDynamo\\ConverterDynamoRevit2021\\ConverterDynamoRevit2021.csproj", - "Objects\\Converters\\ConverterDynamo\\ConverterDynamoRevit2022\\ConverterDynamoRevit2022.csproj", - "Objects\\Converters\\ConverterDynamo\\ConverterDynamoRevit2023\\ConverterDynamoRevit2023.csproj", - "Objects\\Converters\\ConverterDynamo\\ConverterDynamoRevit2024\\ConverterDynamoRevit2024.csproj", - "Objects\\Converters\\ConverterDynamo\\ConverterDynamoRevit\\ConverterDynamoRevit.csproj", - "Objects\\Converters\\ConverterDynamo\\ConverterDynamoSandbox\\ConverterDynamoSandbox.csproj", - "Objects\\Converters\\ConverterDynamo\\ConverterDynamoShared\\ConverterDynamoShared.shproj", - "Objects\\Converters\\ConverterNavisworks\\ConverterNavisworks2020\\ConverterNavisworks2020.csproj", - "Objects\\Converters\\ConverterNavisworks\\ConverterNavisworks2021\\ConverterNavisworks2021.csproj", - "Objects\\Converters\\ConverterNavisworks\\ConverterNavisworks2022\\ConverterNavisworks2022.csproj", - "Objects\\Converters\\ConverterNavisworks\\ConverterNavisworks2023\\ConverterNavisworks2023.csproj", - "Objects\\Converters\\ConverterNavisworks\\ConverterNavisworks2024\\ConverterNavisworks2024.csproj", - "Objects\\Converters\\ConverterNavisworks\\ConverterNavisworks\\ConverterNavisworks.shproj", - "Objects\\Converters\\ConverterRevit\\ConverterRevit2020\\ConverterRevit2020.csproj", - "Objects\\Converters\\ConverterRevit\\ConverterRevit2021\\ConverterRevit2021.csproj", - "Objects\\Converters\\ConverterRevit\\ConverterRevit2022\\ConverterRevit2022.csproj", - "Objects\\Converters\\ConverterRevit\\ConverterRevit2023\\ConverterRevit2023.csproj", - "Objects\\Converters\\ConverterRevit\\ConverterRevit2024\\ConverterRevit2024.csproj", - "Objects\\Converters\\ConverterRevit\\ConverterRevitShared\\ConverterRevitShared.shproj", - "Objects\\Converters\\ConverterRevit\\ConverterRevitTests\\ConverterRevitTests2021\\ConverterRevitTests2021.csproj", - "Objects\\Converters\\ConverterRevit\\ConverterRevitTests\\ConverterRevitTests2022\\ConverterRevitTests2022.csproj", - "Objects\\Converters\\ConverterRevit\\ConverterRevitTests\\ConverterRevitTests2023\\ConverterRevitTests2023.csproj", - "Objects\\Converters\\ConverterRevit\\ConverterRevitTests\\ConverterRevitTestsShared\\ConverterRevitTestsShared.shproj", - "Objects\\Converters\\ConverterRevit\\ConverterRevitTests\\TestGenerator\\TestGenerator.csproj", - "Objects\\Converters\\ConverterRhinoGh\\ConverterGrasshopper6\\ConverterGrasshopper6.csproj", - "Objects\\Converters\\ConverterRhinoGh\\ConverterGrasshopper7\\ConverterGrasshopper7.csproj", - "Objects\\Converters\\ConverterRhinoGh\\ConverterGrasshopper8\\ConverterGrasshopper8.csproj", - "Objects\\Converters\\ConverterRhinoGh\\ConverterRhino6\\ConverterRhino6.csproj", - "Objects\\Converters\\ConverterRhinoGh\\ConverterRhino7\\ConverterRhino7.csproj", - "Objects\\Converters\\ConverterRhinoGh\\ConverterRhino8\\ConverterRhino8.csproj", - "Objects\\Converters\\ConverterRhinoGh\\ConverterRhinoGhShared\\ConverterRhinoGhShared.shproj", - "Objects\\Converters\\ConverterTeklaStructures\\ConverterTeklaStructures2020\\ConverterTeklaStructures2020.csproj", - "Objects\\Converters\\ConverterTeklaStructures\\ConverterTeklaStructures2021\\ConverterTeklaStructures2021.csproj", - "Objects\\Converters\\ConverterTeklaStructures\\ConverterTeklaStructures2022\\ConverterTeklaStructures2022.csproj", - "Objects\\Converters\\ConverterTeklaStructures\\ConverterTeklaStructures2023\\ConverterTeklaStructures2023.csproj", - "Objects\\Converters\\ConverterTeklaStructures\\ConverterTeklaStructuresShared\\ConverterTeklaStructuresShared.shproj", - "Objects\\Converters\\StructuralUtilities\\PolygonMesher\\PolygonMesher.csproj", - "Objects\\Objects\\Objects.csproj", - "Objects\\Tests\\Objects.Tests.Unit\\Objects.Tests.Unit.csproj" - ] - } -} \ No newline at end of file diff --git a/DesktopUI3/DUI3/Bindings/AccountBinding.cs b/DesktopUI3/DUI3/Bindings/AccountBinding.cs deleted file mode 100644 index d5004f4246..0000000000 --- a/DesktopUI3/DUI3/Bindings/AccountBinding.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System.Linq; -using JetBrains.Annotations; -using Speckle.Core.Credentials; - -namespace DUI3.Bindings; - -public class AccountBinding : IBinding -{ - public string Name { get; set; } = "accountsBinding"; - public IBridge Parent { get; set; } - - [PublicAPI] - public Account[] GetAccounts() - { - return AccountManager.GetAccounts().ToArray(); - // NOTE: removing the avatars is no longer needed as we've resolved the issue described below via the bridge implementation. - // .Select( - // a => - // { - // a.userInfo.avatar = null; // removing this as the get accounts call was a too large string to do "executeScriptAsync" with (this was not happening if this was a direct return from a binding call). - // return a; - // }).ToArray(); - } -} diff --git a/DesktopUI3/DUI3/Bindings/ConfigBinding.cs b/DesktopUI3/DUI3/Bindings/ConfigBinding.cs deleted file mode 100644 index d2489f5bb1..0000000000 --- a/DesktopUI3/DUI3/Bindings/ConfigBinding.cs +++ /dev/null @@ -1,131 +0,0 @@ -using System.Collections.Generic; -using System.Diagnostics; -using DUI3.Config; -using DUI3.Onboarding; -using DUI3.Utils; -using JetBrains.Annotations; -using Speckle.Core.Logging; -using Speckle.Core.Transports; -using Speckle.Newtonsoft.Json; - -namespace DUI3.Bindings; - -/// -/// Responsible to initialize, validate and retrieve configuration data from AppData/Config.db -/// -public class ConfigBinding : IBinding -{ - public string Name { get; set; } = "configBinding"; - public IBridge Parent { get; set; } - private string HostAppName { get; } - private Dictionary ConnectorOnboardings { get; } - - private static readonly SQLiteTransport s_configStorage = new(scope: "Config"); - private readonly JsonSerializerSettings _serializerOptions = SerializationSettingsFactory.GetSerializerSettings(); - - public ConfigBinding(string hostAppName, Dictionary connectorOnboardings = null) - { - this.HostAppName = hostAppName; - - // If connectorOnboardings is null, initialize it as an empty dictionary - connectorOnboardings ??= new Dictionary(); - this.ConnectorOnboardings = connectorOnboardings; - } - - [PublicAPI] - public UiConfig GetConfig() - { - try - { - return GetOrInitConfig(); - } - catch (SpeckleException e) - { - Debug.WriteLine(e.Message); - // Fallbacks to default configs if something wrong - UiConfig uiConfig = InitDefaultConfig(); - s_configStorage.UpdateObject("configDUI3", JsonConvert.SerializeObject(uiConfig, _serializerOptions)); - return uiConfig; - } - } - - public void UpdateGlobalConfig(GlobalConfig newGlobalConfig) - { - try - { - UiConfig uiConfig = GetOrInitConfig(); - uiConfig.Global = newGlobalConfig; - s_configStorage.UpdateObject("configDUI3", JsonConvert.SerializeObject(uiConfig, _serializerOptions)); - } - catch (SpeckleException e) - { - Debug.WriteLine(e.Message); - // TODO: Log error - } - } - - public void UpdateConnectorConfig(ConnectorConfig newConnectorConfig) - { - try - { - UiConfig uiConfig = GetOrInitConfig(); - uiConfig.Connectors[HostAppName] = newConnectorConfig; - s_configStorage.UpdateObject("configDUI3", JsonConvert.SerializeObject(uiConfig, _serializerOptions)); - } - catch (SpeckleException e) - { - Debug.WriteLine(e.Message); - // TODO: Log error - } - } - - private void ValidateConfigs(UiConfig uiConfig, PropertyValidator config) - { - bool globalConfigsAdded = config.InitializeNewProperties(); - bool globalConfigRemoved = config.CheckRemovedProperties(); - if (globalConfigsAdded || globalConfigRemoved) - { - s_configStorage.UpdateObject("configDUI3", JsonConvert.SerializeObject(uiConfig, _serializerOptions)); - } - } - - private UiConfig GetOrInitConfig() - { - // 1 - If it is not exist, init and return. - string configDui3String = s_configStorage.GetObject("configDUI3"); - if (string.IsNullOrEmpty(configDui3String)) - { - return InitDefaultConfig(); - } - - UiConfig config = JsonConvert.DeserializeObject(configDui3String, _serializerOptions); - - // 2- Check global configs updated or not. - ValidateConfigs(config, config.Global); - - // 3- If connector config already exist in UiConfig, just return it. - if (config.Connectors.TryGetValue(HostAppName.ToLower(), out ConnectorConfig value)) - { - ConnectorConfig existingConnectorConfig = value; - ValidateConfigs(config, existingConnectorConfig); - - return config; - } - - // 4- If connector config didn't initialized yet, init and attach it, then return. - ConnectorConfig connectorConfig = new(HostAppName, ConnectorOnboardings); - config.Connectors.Add(HostAppName, connectorConfig); - s_configStorage.UpdateObject("configDUI3", JsonConvert.SerializeObject(config, _serializerOptions)); - return config; - } - - private UiConfig InitDefaultConfig() - { - ConnectorConfig connectorConfig = new(HostAppName, ConnectorOnboardings); - Dictionary defaultConfigs = new() { { HostAppName, connectorConfig } }; - UiConfig defaultConfig = new() { Global = new GlobalConfig(), Connectors = defaultConfigs }; - string serializedConfigs = JsonConvert.SerializeObject(defaultConfig, _serializerOptions); - s_configStorage.UpdateObject("configDUI3", serializedConfigs); - return defaultConfig; - } -} diff --git a/DesktopUI3/DUI3/Bindings/IBasicConnectorBinding.cs b/DesktopUI3/DUI3/Bindings/IBasicConnectorBinding.cs deleted file mode 100644 index b7013d8dc8..0000000000 --- a/DesktopUI3/DUI3/Bindings/IBasicConnectorBinding.cs +++ /dev/null @@ -1,38 +0,0 @@ -using System; -using DUI3.Models; -using DUI3.Models.Card; - -namespace DUI3.Bindings; - -public interface IBasicConnectorBinding : IBinding -{ - public string GetSourceApplicationName(); - public string GetSourceApplicationVersion(); - public string GetConnectorVersion(); - public DocumentInfo GetDocumentInfo(); - public DocumentModelStore GetDocumentState(); - public void AddModel(ModelCard model); - public void UpdateModel(ModelCard model); - public void RemoveModel(ModelCard model); - - /// - /// Highlights the objects attached to this sender in the host application. - /// - /// - public void HighlightModel(string modelCardId); -} - -public static class BasicConnectorBindingCommands -{ - private const string NOTIFY_DOCUMENT_CHANGED_EVENT_NAME = "documentChanged"; - private const string SET_MODEL_PROGRESS_UI_COMMAND_NAME = "setModelProgress"; - private const string SET_MODEL_ERROR_UI_COMMAND_NAME = "setModelError"; - - public static void NotifyDocumentChanged(IBridge bridge) => bridge.SendToBrowser(NOTIFY_DOCUMENT_CHANGED_EVENT_NAME); - - public static void SetModelProgress(IBridge bridge, string modelCardId, ModelCardProgress progress) => - bridge.SendToBrowser(SET_MODEL_PROGRESS_UI_COMMAND_NAME, new { modelCardId, progress }); - - public static void SetModelError(IBridge bridge, string modelCardId, Exception error) => - bridge.SendToBrowser(SET_MODEL_ERROR_UI_COMMAND_NAME, new { modelCardId, error = error.Message }); -} diff --git a/DesktopUI3/DUI3/Bindings/IReceiveBinding.cs b/DesktopUI3/DUI3/Bindings/IReceiveBinding.cs deleted file mode 100644 index 293f7ce5c1..0000000000 --- a/DesktopUI3/DUI3/Bindings/IReceiveBinding.cs +++ /dev/null @@ -1,48 +0,0 @@ -using System.Collections.Generic; -using DUI3.Models; -using DUI3.Models.Card; -using DUI3.Utils; - -namespace DUI3.Bindings; - -public interface IReceiveBinding : IBinding -{ - /// - /// Instructs the host app to start receiving this model version. - /// - /// Model card id - public void Receive(string modelCardId); - - /// - /// Instructs the host app to cancel the receiving for a given model. - /// - /// - public void CancelReceive(string modelCardId); -} - -public static class ReceiveBindingUiCommands -{ - private const string SET_MODEL_RECEIVE_RESULT_UI_COMMAND_NAME = "setModelReceiveResult"; - - public static void SetModelConversionResult(IBridge bridge, string modelCardId, ReceiveResult receiveResult) => - bridge.SendToBrowser(SET_MODEL_RECEIVE_RESULT_UI_COMMAND_NAME, new { modelCardId, receiveResult }); -} - -public class ReceiverModelCard : ModelCard -{ - public string SelectedVersionId { get; set; } - public string LatestVersionId { get; set; } - public string ProjectName { get; set; } - public string ModelName { get; set; } - public bool HasDismissedUpdateWarning { get; set; } - public ReceiveResult ReceiveResult { get; set; } -} - -public class ReceiveResult : DiscriminatedObject -{ - public List BakedObjectIds { get; set; } - - public bool Display { get; set; } = false; - - // TODO/THINK Later: results, reports, etc. ? -} diff --git a/DesktopUI3/DUI3/Bindings/ISelectionBinding.cs b/DesktopUI3/DUI3/Bindings/ISelectionBinding.cs deleted file mode 100644 index 9dcd594ebd..0000000000 --- a/DesktopUI3/DUI3/Bindings/ISelectionBinding.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System.Collections.Generic; - -namespace DUI3.Bindings; - -public interface ISelectionBinding : IBinding -{ - public SelectionInfo GetSelection(); -} - -public static class SelectionBindingEvents -{ - public static readonly string SetSelection = "setSelection"; -} - -public class SelectionInfo -{ - public List SelectedObjectIds { get; set; } - public string Summary { get; set; } -} diff --git a/DesktopUI3/DUI3/Bindings/ISendBinding.cs b/DesktopUI3/DUI3/Bindings/ISendBinding.cs deleted file mode 100644 index 59c75ec703..0000000000 --- a/DesktopUI3/DUI3/Bindings/ISendBinding.cs +++ /dev/null @@ -1,89 +0,0 @@ -using System; -using System.Collections.Generic; -using DUI3.Models; -using DUI3.Models.Card; -using DUI3.Utils; -using Speckle.Newtonsoft.Json; - -namespace DUI3.Bindings; - -public interface ISendBinding : IBinding -{ - public List GetSendFilters(); - - /// - /// Instructs the host app to start sending this model. - /// - /// - public void Send(string modelCardId); - - /// - /// Instructs the host app to cancel the sending for a given model. - /// - /// - public void CancelSend(string modelCardId); -} - -public static class SendBindingUiCommands -{ - private const string REFRESH_SEND_FILTERS_UI_COMMAND_NAME = "refreshSendFilters"; - private const string SET_MODELS_EXPIRED_UI_COMMAND_NAME = "setModelsExpired"; - private const string SET_MODEL_CREATED_VERSION_ID_UI_COMMAND_NAME = "setModelCreatedVersionId"; - - public static void RefreshSendFilters(IBridge bridge) => bridge.SendToBrowser(REFRESH_SEND_FILTERS_UI_COMMAND_NAME); - - public static void SetModelsExpired(IBridge bridge, IEnumerable expiredModelIds) => - bridge.SendToBrowser(SET_MODELS_EXPIRED_UI_COMMAND_NAME, expiredModelIds); - - public static void SetModelCreatedVersionId(IBridge bridge, string modelCardId, string versionId) => - bridge.SendToBrowser(SET_MODEL_CREATED_VERSION_ID_UI_COMMAND_NAME, new { modelCardId, versionId }); -} - -public class SenderModelCard : ModelCard -{ - public ISendFilter SendFilter { get; set; } - public string ProjectId { get; set; } - public string ModelId { get; set; } - - [JsonIgnore] - public HashSet ChangedObjectIds { get; set; } = new(); -} - -public interface ISendFilter -{ - public string Name { get; set; } - public string Summary { get; set; } - public bool IsDefault { get; set; } - - /// - /// Gets the ids of the objects targeted by the filter from the host application. - /// - /// - public List GetObjectIds(); - - /// - /// Checks whether any of the targeted objects are affected by changes from the host application. - /// - /// - /// - public bool CheckExpiry(string[] changedObjectIds); -} - -public abstract class EverythingSendFilter : DiscriminatedObject, ISendFilter -{ - public string Name { get; set; } = "Everything"; - public string Summary { get; set; } = "All supported objects in the file."; - public bool IsDefault { get; set; } - public abstract List GetObjectIds(); - public abstract bool CheckExpiry(string[] changedObjectIds); -} - -public abstract class DirectSelectionSendFilter : DiscriminatedObject, ISendFilter -{ - public string Name { get; set; } = "Selection"; - public string Summary { get; set; } - public bool IsDefault { get; set; } - public List SelectedObjectIds { get; set; } = new List(); - public abstract List GetObjectIds(); - public abstract bool CheckExpiry(string[] changedObjectIds); -} diff --git a/DesktopUI3/DUI3/Bindings/TestBinding.cs b/DesktopUI3/DUI3/Bindings/TestBinding.cs deleted file mode 100644 index 1f90ef0245..0000000000 --- a/DesktopUI3/DUI3/Bindings/TestBinding.cs +++ /dev/null @@ -1,64 +0,0 @@ -using System; -using System.Diagnostics; -using Speckle.Core.Logging; - -namespace DUI3.Bindings; - -/// -/// Meant as a testing ground for various scenarios. Note this binding is directly scaffolded from here - no need for -/// implementations in host applications. -/// -public class TestBinding : IBinding -{ - public string Name { get; set; } = "testBinding"; - public IBridge Parent { get; set; } - - public string SayHi(string name, int count, bool sayHelloNotHi) - { - var baseGreeting = $"{(sayHelloNotHi ? "Hello" : "Hi")} {name}!"; - var finalGreeting = ""; - for (int i = 0; i < Math.Max(1, Math.Abs(count)); i++) - { - finalGreeting += baseGreeting + Environment.NewLine; - } - - return finalGreeting; - } - - public void ShouldThrow() - { - throw new SpeckleException("I am supposed to throw."); - } - - public void GoAway() - { - Debug.WriteLine("Okay, going away."); - } - - public object GetComplexType() - { - return new { Id = GetHashCode().ToString(), count = GetHashCode() }; - } - - public void TriggerEvent(string eventName) - { - switch (eventName) - { - case "emptyTestEvent": - Parent.SendToBrowser("emptyTestEvent"); - break; - case "testEvent": - default: - Parent.SendToBrowser( - "testEvent", - new - { - IsOk = true, - Name = "foo", - Count = 42 - } - ); - break; - } - } -} diff --git a/DesktopUI3/DUI3/Bridge.cs b/DesktopUI3/DUI3/Bridge.cs deleted file mode 100644 index fe522cf4c1..0000000000 --- a/DesktopUI3/DUI3/Bridge.cs +++ /dev/null @@ -1,187 +0,0 @@ -// using System; -// using System.Collections.Generic; -// using System.Linq; -// using System.Reflection; -// using System.Runtime.InteropServices; -// using Speckle.Newtonsoft.Json; -// using System.Threading.Tasks; -// using Speckle.Core.Logging; -// -// namespace DUI3 -// { -// -// /// -// /// Wraps a binding class, and manages its calls from the Frontend to .NET, and sending events from .NET to the the Frontend. -// /// See also: https://github.com/johot/WebView2-better-bridge -// /// -// [ClassInterface(ClassInterfaceType.AutoDual)] -// [ComVisible(true)] -// public class BrowserBridge : IBridge -// { -// /// -// /// The name under which we expect the frontend to hoist this bindings class to the global scope. -// /// e.g., `receiveBindings` should be available as `window.receiveBindings`. -// /// -// public string FrontendBoundName { get; } -// -// public object Browser { get; } -// -// public IBinding Binding { get; } -// -// public Action ExecuteScriptAsync { get; set; } -// public Action ShowDevToolsAction { get; set; } -// private Type BindingType { get; set; } -// private Dictionary BindingMethodCache { get; set; } -// -// private JsonSerializerSettings _serializerOptions = DUI3.Utils.SerializationSettingsFactory.GetSerializerSettings(); -// -// /// -// /// Creates a new bridge. -// /// -// /// The host browser instance. -// /// The actual binding class. -// /// A simple action that does the browser's version of executeScriptAsync(string). -// public BrowserBridge(object browser, IBinding binding, Action executeScriptAsync, Action showDevToolsAction) -// { -// FrontendBoundName = binding.Name; -// Browser = browser; -// Binding = binding; -// -// BindingType = Binding.GetType(); -// BindingMethodCache = new Dictionary(); -// // Note: we need to filter out getter and setter methods here because they are not really nicely -// // supported across browsers, hence the !method.IsSpecialName. -// foreach(var m in BindingType.GetMethods().Where(method => !method.IsSpecialName)) -// { -// BindingMethodCache[m.Name] = m; -// } -// -// Binding.Parent = this; -// -// ExecuteScriptAsync = executeScriptAsync; -// ShowDevToolsAction = showDevToolsAction; -// } -// -// /// -// /// Used by the Frontend bridge logic to understand which methods are available. -// /// -// /// -// public string[] GetBindingsMethodNames() -// { -// return BindingMethodCache.Keys.ToArray(); -// } -// -// /// -// /// Used by the Frontend bridge to call into .NET. -// /// TODO: Check and test -// /// -// /// -// /// -// /// -// public string RunMethod(string methodName, string args) -// { -// // Note: You might be tempted to make this method async Task to prevent the task.Wait() below. -// // Do not do that! Cef65 doesn't like waiting for async .NET methods. -// // Note: we have this pokemon catch 'em all here because throwing errors in .NET is -// // very risky, and we might crash the host application. Behaviour seems also to differ -// // between various browser controls (e.g.: cefsharp handles things nicely - basically -// // passing back the exception to the browser, but webview throws an access violation -// // error that kills Rhino.). -// try -// { -// if (!BindingMethodCache.ContainsKey(methodName)) -// throw new SpeckleException($"Cannot find method {methodName} in bindings class {BindingType.AssemblyQualifiedName}."); -// -// var method = BindingMethodCache[methodName]; -// var parameters = method.GetParameters(); -// var jsonArgsArray = JsonConvert.DeserializeObject(args); -// -// if (parameters.Length != jsonArgsArray.Length) -// throw new SpeckleException($"Wrong number of arguments when invoking binding function {methodName}, expected {parameters.Length}, but got {jsonArgsArray.Length}."); -// -// var typedArgs = new object[jsonArgsArray.Length]; -// -// for (int i = 0; i < typedArgs.Length; i++) -// { -// var ccc = JsonConvert.DeserializeObject(jsonArgsArray[i], parameters[i].ParameterType, _serializerOptions); -// typedArgs[i] = ccc; -// } -// -// -// -// var resultTyped = method.Invoke(Binding, typedArgs); -// -// // Was it an async method (in bridgeClass?) -// var resultTypedTask = resultTyped as Task; -// -// string resultJson; -// -// // Was the method called async? -// if (resultTypedTask == null) -// { -// // Regular method: no need to await things -// resultJson = JsonConvert.SerializeObject(resultTyped, _serializerOptions); -// } -// else // It's an async call -// { -// // See note at start of function. Do not asyncify! -// resultTypedTask.Wait(); -// -// // If has a "Result" property return the value otherwise null (Task etc) -// var resultProperty = resultTypedTask.GetType().GetProperty("Result"); -// var taskResult = resultProperty != null ? resultProperty.GetValue(resultTypedTask) : null; -// resultJson =JsonConvert.SerializeObject(taskResult, _serializerOptions); -// } -// -// return resultJson; -// } -// catch (Exception e) -// { -// // TODO: properly log the exeception. -// return JsonConvert.SerializeObject(new { Error = e.Message, InnerError = e.InnerException?.Message }, _serializerOptions); -// } -// } -// -// /// -// /// Notifies the Frontend about something by doing the browser specific way for `browser.ExecuteScriptAsync("window.FrontendBoundName.on(eventName, etc.)")`. -// /// -// /// -// public void SendToBrowser(string eventName, object data = null) -// { -// string script; -// if (data != null) -// { -// var payload = JsonConvert.SerializeObject(data, _serializerOptions); -// script = $"{FrontendBoundName}.emit('{eventName}', '{payload}')"; -// } -// else -// { -// script = $"{FrontendBoundName}.emit('{eventName}')"; -// } -// ExecuteScriptAsync(script); -// } -// -// /// -// /// Shows the dev tools. This is currently only needed for CefSharp - other browser -// /// controls allow for right click + inspect. -// /// -// public void ShowDevTools() -// { -// ShowDevToolsAction(); -// } -// -// public void OpenUrl(string url) -// { -// try -// { -// System.Diagnostics.Process.Start(url); -// } -// catch (Exception _) -// { -// // TODO: Log. If it ever happens. -// } -// -// } -// } -// -// } diff --git a/DesktopUI3/DUI3/BridgeV2.cs b/DesktopUI3/DUI3/BridgeV2.cs deleted file mode 100644 index 03dfb29d32..0000000000 --- a/DesktopUI3/DUI3/BridgeV2.cs +++ /dev/null @@ -1,282 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Runtime.InteropServices; -using System.Threading; -using Speckle.Newtonsoft.Json; -using System.Threading.Tasks; -using System.Threading.Tasks.Dataflow; -using Speckle.Core.Logging; - -namespace DUI3; - -/// -/// Wraps a binding class, and manages its calls from the Frontend to .NET, and sending events from .NET to the the Frontend. -/// Initially inspired by: https://github.com/johot/WebView2-better-bridge -/// -[ClassInterface(ClassInterfaceType.AutoDual)] -[ComVisible(true)] -public class BrowserBridge : IBridge -{ - /// - /// The name under which we expect the frontend to hoist this bindings class to the global scope. - /// e.g., `receiveBindings` should be available as `window.receiveBindings`. - /// - public string FrontendBoundName { get; } - public object Browser { get; } - public IBinding Binding { get; } - public Action ExecuteScriptAsync { get; set; } - public Action ShowDevToolsAction { get; set; } - private Type BindingType { get; set; } - private Dictionary BindingMethodCache { get; set; } - private readonly JsonSerializerSettings _serializerOptions = - DUI3.Utils.SerializationSettingsFactory.GetSerializerSettings(); - private readonly ActionBlock _actionBlock; - private readonly SynchronizationContext _mainThreadContext; - - private struct RunMethodArgs - { - public string MethodName; - public string RequestId; - public string MethodArgs; - } - - /// - /// Creates a new bridge. - /// - /// The host browser instance. - /// The actual binding class. - /// A simple action that does the browser's version of executeScriptAsync(string). - public BrowserBridge(object browser, IBinding binding, Action executeScriptAsync, Action showDevToolsAction) - { - FrontendBoundName = binding.Name; - Browser = browser; - Binding = binding; - - BindingType = Binding.GetType(); - BindingMethodCache = new Dictionary(); - // Note: we need to filter out getter and setter methods here because they are not really nicely - // supported across browsers, hence the !method.IsSpecialName. - foreach (var m in BindingType.GetMethods().Where(method => !method.IsSpecialName)) - { - BindingMethodCache[m.Name] = m; - } - - Binding.Parent = this; - - ExecuteScriptAsync = executeScriptAsync; - ShowDevToolsAction = showDevToolsAction; - - // Capture the main thread's SynchronizationContext - _mainThreadContext = SynchronizationContext.Current; - - // Whenever the ui will call run method inside .net, it will post a message to this action block. - // This conveniently executes the code outside the UI thread and does not block during long operations (such as sending). - _actionBlock = new ActionBlock( - args => ExecuteMethod(args.MethodName, args.RequestId, args.MethodArgs), - new ExecutionDataflowBlockOptions - { - MaxDegreeOfParallelism = 1000, - CancellationToken = new CancellationTokenSource(TimeSpan.FromHours(3)).Token // Not sure we need such a long time. - } - ); - } - - /// - /// Used by the Frontend bridge logic to understand which methods are available. - /// - /// - public string[] GetBindingsMethodNames() - { - return BindingMethodCache.Keys.ToArray(); - } - - /// - /// This method posts the requested call to our action block executor. - /// - /// - /// - /// - public void RunMethod(string methodName, string requestId, string args) - { - _actionBlock.Post( - new RunMethodArgs - { - MethodName = methodName, - RequestId = requestId, - MethodArgs = args - } - ); - } - - /// - /// Run actions on main thread. - /// - /// Action to run on main thread. - public void RunOnMainThread(Action action) - { - _mainThreadContext.Post( - _ => - { - // Execute the action on the main thread - action.Invoke(); - }, - null - ); - } - - /// - /// Used by the action block to invoke the actual method called by the UI. - /// - /// - /// - /// - /// - private void ExecuteMethod(string methodName, string requestId, string args) - { - // Note: You might be tempted to make this method async Task to prevent the task.Wait() below. - // Do not do that! Cef65 doesn't like waiting for async .NET methods. - // Note: we have this pokemon catch 'em all here because throwing errors in .NET is - // very risky, and we might crash the host application. Behaviour seems also to differ - // between various browser controls (e.g.: cefsharp handles things nicely - basically - // passing back the exception to the browser, but webview throws an access violation - // error that kills Rhino.). - try - { - if (!BindingMethodCache.ContainsKey(methodName)) - { - throw new SpeckleException( - $"Cannot find method {methodName} in bindings class {BindingType.AssemblyQualifiedName}." - ); - } - - var method = BindingMethodCache[methodName]; - var parameters = method.GetParameters(); - var jsonArgsArray = JsonConvert.DeserializeObject(args); - - if (parameters.Length != jsonArgsArray.Length) - { - throw new SpeckleException( - $"Wrong number of arguments when invoking binding function {methodName}, expected {parameters.Length}, but got {jsonArgsArray.Length}." - ); - } - - var typedArgs = new object[jsonArgsArray.Length]; - - for (int i = 0; i < typedArgs.Length; i++) - { - var ccc = JsonConvert.DeserializeObject(jsonArgsArray[i], parameters[i].ParameterType, _serializerOptions); - typedArgs[i] = ccc; - } - - var resultTyped = method.Invoke(Binding, typedArgs); - - // Was it an async method (in bridgeClass?) - var resultTypedTask = resultTyped as Task; - - string resultJson; - - // Was the method called async? - if (resultTypedTask == null) - { - // Regular method: no need to await things - resultJson = JsonConvert.SerializeObject(resultTyped, _serializerOptions); - } - else // It's an async call - { - // See note at start of function. Do not asyncify! - resultTypedTask.Wait(); - - // If has a "Result" property return the value otherwise null (Task etc) - PropertyInfo resultProperty = resultTypedTask.GetType().GetProperty("Result"); - object taskResult = resultProperty?.GetValue(resultTypedTask); - resultJson = JsonConvert.SerializeObject(taskResult, _serializerOptions); - } - - NotifyUIMethodCallResultReady(requestId, resultJson); - } - catch (Exception e) // DO NOT EVER CAPTURE SPECIFIC EXCEPTIONS HERE (unknown ones will slip) - WE DO NOT WANT TO BUBBLE SHIT UP IN CRAZY CONTEXTS; They should be gracefully sent to the UI; THIS COMES FROM "NEVER CRASH THE HOST APP IF POSSIBLE" RULE - { - // TODO: properly log the exeception. - var serializedError = JsonConvert.SerializeObject( - new { Error = e.Message, InnerError = e.InnerException?.Message }, - _serializerOptions - ); - - NotifyUIMethodCallResultReady(requestId, serializedError); - } - } - - /// - /// NOTE: This method suffers from a limitation: returning strings to the ui via a script invocation is not the same - /// as returning strings from a method. The more reliable approach was the latter. Keeping it here for the sake of - /// "do not do things this way" demo. - /// - /// - /// - private void ReturnResultToBinding_old(string requestId, string serializedData = null) - { - string script = $"{FrontendBoundName}.receiveResponse('{requestId}', '{serializedData}')"; // sending the string this way makes for some strange deserialization issues. - ExecuteScriptAsync(script); - } - - private readonly Dictionary _resultsStore = new(); - - /// - /// Notifies the UI that the method call is ready. We do not give the result back to the ui here via ExecuteScriptAsync - /// because of limitations we discovered along the way (e.g, / chars need to be escaped). - /// - /// - /// - private void NotifyUIMethodCallResultReady(string requestId, string serializedData = null) - { - _resultsStore[requestId] = serializedData; - string script = $"{FrontendBoundName}.responseReady('{requestId}')"; - ExecuteScriptAsync(script); - } - - /// - /// Called by the ui to get back the serialized result of the method. See comments above for why. - /// - /// - /// - public string GetCallResult(string requestId) - { - var res = _resultsStore[requestId]; - _resultsStore.Remove(requestId); - return res; - } - - /// - /// Notifies the Frontend about something by doing the browser specific way for `browser.ExecuteScriptAsync("window.FrontendBoundName.on(eventName, etc.)")`. - /// - public void SendToBrowser(string eventName, object data = null) - { - string script; - if (data != null) - { - var payload = JsonConvert.SerializeObject(data, _serializerOptions); - script = $"{FrontendBoundName}.emit('{eventName}', '{payload}')"; - } - else - { - script = $"{FrontendBoundName}.emit('{eventName}')"; - } - ExecuteScriptAsync(script); - } - - /// - /// Shows the dev tools. This is currently only needed for CefSharp - other browser - /// controls allow for right click + inspect. - /// - public void ShowDevTools() - { - ShowDevToolsAction(); - } - - public void OpenUrl(string url) - { - System.Diagnostics.Process.Start(url); - } -} diff --git a/DesktopUI3/DUI3/Config/ConnectorConfig.cs b/DesktopUI3/DUI3/Config/ConnectorConfig.cs deleted file mode 100644 index d7f247d842..0000000000 --- a/DesktopUI3/DUI3/Config/ConnectorConfig.cs +++ /dev/null @@ -1,22 +0,0 @@ -using System.Collections.Generic; -using DUI3.Onboarding; -using DUI3.Utils; - -namespace DUI3.Config; - -public class ConnectorConfig : PropertyValidator -{ - public string HostApp { set; get; } - - public bool? DarkTheme { set; get; } = false; - - public Dictionary Onboardings { get; set; } - - public ConnectorConfig() { } - - public ConnectorConfig(string hostApp, Dictionary onboardings) - { - HostApp = hostApp; - this.Onboardings = onboardings; - } -} diff --git a/DesktopUI3/DUI3/Config/GlobalConfig.cs b/DesktopUI3/DUI3/Config/GlobalConfig.cs deleted file mode 100644 index 7088b9a6b5..0000000000 --- a/DesktopUI3/DUI3/Config/GlobalConfig.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System.Collections.Generic; -using DUI3.Onboarding; -using DUI3.Utils; - -namespace DUI3.Config; - -public class GlobalConfig : PropertyValidator -{ - public bool? OnboardingSkipped { get; set; } = false; - public Dictionary Onboardings { get; set; } = Factory.CreateDefaults(); -} diff --git a/DesktopUI3/DUI3/Config/UiConfig.cs b/DesktopUI3/DUI3/Config/UiConfig.cs deleted file mode 100644 index de00b6430e..0000000000 --- a/DesktopUI3/DUI3/Config/UiConfig.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System.Collections.Generic; -using DUI3.Utils; - -namespace DUI3.Config; - -public class UiConfig : DiscriminatedObject -{ - public GlobalConfig Global { get; set; } - - public Dictionary Connectors { get; set; } -} diff --git a/DesktopUI3/DUI3/DUI3.csproj b/DesktopUI3/DUI3/DUI3.csproj deleted file mode 100644 index d46e3bbca8..0000000000 --- a/DesktopUI3/DUI3/DUI3.csproj +++ /dev/null @@ -1,18 +0,0 @@ - - - - netstandard2.0 - Library - - - - - - - - - - - - - diff --git a/DesktopUI3/DUI3/Interfaces.cs b/DesktopUI3/DUI3/Interfaces.cs deleted file mode 100644 index 7937bc5b37..0000000000 --- a/DesktopUI3/DUI3/Interfaces.cs +++ /dev/null @@ -1,58 +0,0 @@ -using System; - -namespace DUI3; - -/// -/// Describes the most basic binding. -/// -public interface IBinding -{ - /// - /// This will be the name under which it will be available in the Frontend, e.g. - /// window.superBinding, or window.mapperBinding. Please use camelCase even if - /// it hurts. - /// - public string Name { get; set; } - - /// - /// Bindings will be wrapped by a browser specific bridge, and they will need - /// to use that bridge to send events to the Frontend, via SendToBrowser(IHostAppEvent) or SendToBrowser(string). - /// TODO: we'll probably need a factory class of sorts to handle the proper wrapping. Currently, on bridge instantiation the parent is set in the bindings class that has been wrapped around. Not vvv elegant. - /// - public IBridge Parent { get; set; } -} - -/// -/// Describes a bridge - a wrapper class around a specific browser host. Not needed right now, -/// but if in the future we will have other bridge classes (e.g, ones that wrap around other browsers), -/// it just might be useful. -/// -public interface IBridge -{ - /// - /// This method is called by the Frontend bridge to understand what it can actually call. It should return the method names of the bindings that this bridge wraps around. - /// - /// - public string[] GetBindingsMethodNames(); - - /// - /// This method is called by the Frontend bridge when invoking any of the wrapped binding's methods. - /// - /// - /// - /// - public void RunMethod(string methodName, string requestId, string args); - - /// - /// Run actions on main thread. - /// Some applications might need to run some operations on main thread as deferred actions. - /// - /// Action to run on main thread. - public void RunOnMainThread(Action action); - - /// - /// Sends to the Frontend an event with an optional payload. - /// - /// - public void SendToBrowser(string eventName, object data = null); -} diff --git a/DesktopUI3/DUI3/Models/Card/ModelCardError.cs b/DesktopUI3/DUI3/Models/Card/ModelCardError.cs deleted file mode 100644 index 2850531d02..0000000000 --- a/DesktopUI3/DUI3/Models/Card/ModelCardError.cs +++ /dev/null @@ -1,9 +0,0 @@ -using System; - -namespace DUI3.Models.Card; - -public class ModelCardError -{ - public string ModelCardId { get; set; } - public Exception Error { get; set; } -} diff --git a/DesktopUI3/DUI3/Models/Card/ModelCardNotification.cs b/DesktopUI3/DUI3/Models/Card/ModelCardNotification.cs deleted file mode 100644 index 392f852793..0000000000 --- a/DesktopUI3/DUI3/Models/Card/ModelCardNotification.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace DUI3.Models.Card; - -public class ModelCardNotification -{ - public string ModelCardId { get; set; } - public string Text { get; set; } - public string Level { get; set; } - public int Timeout { get; set; } - public bool Dismissible { get; set; } = true; -} diff --git a/DesktopUI3/DUI3/Models/Card/ModelCardProgress.cs b/DesktopUI3/DUI3/Models/Card/ModelCardProgress.cs deleted file mode 100644 index 32cffe151c..0000000000 --- a/DesktopUI3/DUI3/Models/Card/ModelCardProgress.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System; - -namespace DUI3.Models.Card; - -public class ModelCardProgress -{ - public string ModelCardId { get; set; } - public string Status { get; set; } - - /// - /// Progress value between 0 and 1 to calculate UI progress bar width. - /// If it is null it will swooshing on UI. - /// - public double? Progress { get; set; } -} diff --git a/DesktopUI3/DUI3/Models/ConversionReport.cs b/DesktopUI3/DUI3/Models/ConversionReport.cs deleted file mode 100644 index e50cc9837d..0000000000 --- a/DesktopUI3/DUI3/Models/ConversionReport.cs +++ /dev/null @@ -1,46 +0,0 @@ -using System.Collections.Generic; - -namespace DUI3.Models; - -public class ConversionReport -{ - /// - /// An overall summary. - /// - public string Summary { get; set; } - - /// - /// Specific reports for sets of objects (e.g., failed conversions, conversion fallbacks, etc. - /// - public List Items { get; set; } - - public (ReportItem success, ReportItem warning, ReportItem danger) InitializeSuccessWarningDangerReport() - { - var success = new ReportItem() { Level = NotificationLevel.Success, Message = "Successful conversions" }; - var warning = new ReportItem() { Level = NotificationLevel.Warning, Message = "Partially successful conversions" }; - var danger = new ReportItem() { Level = NotificationLevel.Danger, Message = "Failed conversions" }; - - Items.Add(success); - Items.Add(warning); - Items.Add(danger); - return (success, warning, danger); - } -} - -public class ReportItem -{ - /// - /// A short message. - /// - public string Message { get; set; } - - /// - /// Warning, Info, Success, Danger - etc. Use the NotificationLevel class. - /// - public string Level { get; set; } - - /// - /// The affected objects. - /// - public List ObjectIds { get; set; } = new(); -} diff --git a/DesktopUI3/DUI3/Models/DocumentInfo.cs b/DesktopUI3/DUI3/Models/DocumentInfo.cs deleted file mode 100644 index 9ed0aa4c43..0000000000 --- a/DesktopUI3/DUI3/Models/DocumentInfo.cs +++ /dev/null @@ -1,16 +0,0 @@ -using JetBrains.Annotations; - -namespace DUI3.Models; - -[PublicAPI] -public class DocumentInfo -{ - public string Location { get; set; - //?.Replace("\\", "\\\\"); // for some reason, when returning variables from a direct binding call - //we don't need this. nevertheless, after switching to a post response back to the ui, - //we need this to ensure deserialization in js doesn't throw. it's frustrating! - } - - public string Name { get; set; } - public string Id { get; set; } -} diff --git a/DesktopUI3/DUI3/Models/DocumentModelStore.cs b/DesktopUI3/DUI3/Models/DocumentModelStore.cs deleted file mode 100644 index 3013752d3e..0000000000 --- a/DesktopUI3/DUI3/Models/DocumentModelStore.cs +++ /dev/null @@ -1,63 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using DUI3.Bindings; -using DUI3.Objects; -using DUI3.Utils; -using JetBrains.Annotations; -using Speckle.Newtonsoft.Json; - -namespace DUI3.Models; - -/// -/// Encapsulates the state Speckle needs to persist in the host app's document. -/// -public abstract class DocumentModelStore : DiscriminatedObject -{ - // POC: public setter? - public List SpeckleHostObjects { get; set; } = new List(); - - // POC: public setter? - public List Models { get; set; } = new List(); - - private static readonly JsonSerializerSettings s_serializerOptions = - DUI3.Utils.SerializationSettingsFactory.GetSerializerSettings(); - - /// - /// This event is triggered by each specific host app implementation of the document model store. - /// - [PublicAPI] - public event EventHandler DocumentChanged; - - public virtual bool IsDocumentInit { get; set; } - - public ModelCard GetModelById(string id) - { - var model = Models.First(model => model.ModelCardId == id) ?? throw new ModelNotFoundException(); - return model; - } - - protected void OnDocumentChanged() => DocumentChanged?.Invoke(this, EventArgs.Empty); - - public List GetSenders() => - Models.Where(model => model.TypeDiscriminator == nameof(SenderModelCard)).Cast().ToList(); - - public List GetReceivers() => - Models.Where(model => model.TypeDiscriminator == nameof(ReceiverModelCard)).Cast().ToList(); - - protected string Serialize() - { - var serialized = JsonConvert.SerializeObject(Models, s_serializerOptions); - return serialized; - } - - protected static List Deserialize(string models) - { - var deserializedModels = JsonConvert.DeserializeObject>(models, s_serializerOptions); - return deserializedModels; - } - - public abstract void WriteToFile(); - - public abstract void ReadFromFile(); -} diff --git a/DesktopUI3/DUI3/Models/Form.cs b/DesktopUI3/DUI3/Models/Form.cs deleted file mode 100644 index 8cb3cb92c4..0000000000 --- a/DesktopUI3/DUI3/Models/Form.cs +++ /dev/null @@ -1,47 +0,0 @@ -using System.Collections.Generic; -using DUI3.Utils; - -namespace DUI3.Models; - -public class FormInputBase : DiscriminatedObject -{ - public string Label { get; set; } - public bool ShowLabel { get; set; } -} - -public class FormTextInput : FormInputBase -{ - public string Value { get; set; } - public string Placeholder { get; set; } -} - -public class BooleanValueInput : FormInputBase -{ - public bool Value { get; set; } -} - -public class ListValueInput : FormInputBase -{ - public List Options { get; set; } = new(); - public List SelectedOptions { get; set; } = new(); - public bool MultiSelect { get; set; } = true; -} - -public class ListValueItem : DiscriminatedObject -{ - public string Id { get; set; } - public string Name { get; set; } - public string Color { get; set; } -} - -public class TreeValueInput : FormInputBase -{ - public List Nodes { get; set; } = new(); - public bool MultiSelect { get; set; } = true; -} - -public class TreeListValueItem : ListValueItem -{ - public bool Selected { get; set; } - public List Nodes { get; set; } = new(); -} diff --git a/DesktopUI3/DUI3/Models/ModelCard.cs b/DesktopUI3/DUI3/Models/ModelCard.cs deleted file mode 100644 index d1c4b29f74..0000000000 --- a/DesktopUI3/DUI3/Models/ModelCard.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System.Collections.Generic; -using DUI3.Settings; -using DUI3.Utils; - -namespace DUI3.Models; - -public class ModelCard : DiscriminatedObject -{ - /// - /// This is a unique id generated by the ui to make model cards easier to reference around. - /// It's not the actual model (branch) id. - /// - public string ModelCardId { get; set; } - - /// - /// Model id. FKA branch id. - /// - public string ModelId { get; set; } - - /// - /// Project id. FKA stream id. - /// - public string ProjectId { get; set; } - public string AccountId { get; set; } - - public List Settings { get; set; } -} diff --git a/DesktopUI3/DUI3/Models/NotificationLevel.cs b/DesktopUI3/DUI3/Models/NotificationLevel.cs deleted file mode 100644 index 94ca2125e6..0000000000 --- a/DesktopUI3/DUI3/Models/NotificationLevel.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace DUI3.Models; - -/// -/// Use this class to ensure coherent styling of any items (e.g., notifications) in the frontend based on their status. -/// -public static class NotificationLevel -{ - public static readonly string Danger = "danger"; - public static readonly string Warning = "warning"; - public static readonly string Info = "info"; - public static readonly string Success = "success"; -} diff --git a/DesktopUI3/DUI3/Objects/ConversionContext.cs b/DesktopUI3/DUI3/Objects/ConversionContext.cs deleted file mode 100644 index 4b8aab6052..0000000000 --- a/DesktopUI3/DUI3/Objects/ConversionContext.cs +++ /dev/null @@ -1,17 +0,0 @@ -using Speckle.Core.Models; - -namespace DUI3.Objects; - -// TODO: This should be move to the core? -// What we pass into conversion -// Info that the converter needs to convert an object -public class ConversionContext //Name pending -{ - public Base ToConvert { get; set; } - public string ParentApplicationId { get; set; } //Rhino, we interpret this as layer path, in other connectors we interpret this as parent object id - // TODO: public List LocalToGlobalTransformation { get; set; } // For connectors which don't have blocks - - //public string LayerPath { get; set; } //What rhino needs <-- Not actually rhino specific, speckle collections paths, we can create this always - //public ElementId hostElementId { get; set; } //What Revit needs - //public UnityObject parentObject { get; set; } //Reference to the parent object -} diff --git a/DesktopUI3/DUI3/Objects/ISpeckleHostObject.cs b/DesktopUI3/DUI3/Objects/ISpeckleHostObject.cs deleted file mode 100644 index 2958f09824..0000000000 --- a/DesktopUI3/DUI3/Objects/ISpeckleHostObject.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace DUI3.Objects; - -public interface ISpeckleHostObject -{ - public string ApplicationId { get; } - public string SpeckleId { get; } - public bool IsExpired { get; } -} diff --git a/DesktopUI3/DUI3/Objects/ReportObject.cs b/DesktopUI3/DUI3/Objects/ReportObject.cs deleted file mode 100644 index b599eb0d46..0000000000 --- a/DesktopUI3/DUI3/Objects/ReportObject.cs +++ /dev/null @@ -1,14 +0,0 @@ -namespace DUI3.Objects; - -public enum ConversionResult -{ - Success, - Failed -} - -// Information the UI needs to report objects -public class ReportObject -{ - public SpeckleHostObject SpeckleHostObject { get; } - public ConversionResult ConversionResult { get; } -} diff --git a/DesktopUI3/DUI3/Objects/SpeckleHostObject.cs b/DesktopUI3/DUI3/Objects/SpeckleHostObject.cs deleted file mode 100644 index 6875a1a282..0000000000 --- a/DesktopUI3/DUI3/Objects/SpeckleHostObject.cs +++ /dev/null @@ -1,18 +0,0 @@ -namespace DUI3.Objects; - -//Operations.Receive gives us Base object --> Creates speckle base objects into C# base objects -//Traverse function to get Traversal Context maps Base -> TraversalContext (with parental hierarchy) -//Map Traversal contexts to ConversionContexts + ??Reporting object?? -//Perform conversion - might need to create more report objects on the fly as we convert (for Instances) -//Map conversion result to SpeckleHostObject - -// result of a ToNative conversion... -public abstract class SpeckleHostObject : ISpeckleHostObject -{ - public virtual T NativeObject { get; } - public string ApplicationId { get; } - public string SpeckleId { get; } - public bool IsExpired { get; } - - public abstract SpeckleHostObject WithExpiredStatus(bool status = true); -} diff --git a/DesktopUI3/DUI3/Onboarding/Factory.cs b/DesktopUI3/DUI3/Onboarding/Factory.cs deleted file mode 100644 index 865bd1d0f1..0000000000 --- a/DesktopUI3/DUI3/Onboarding/Factory.cs +++ /dev/null @@ -1,33 +0,0 @@ -using System.Collections.Generic; - -namespace DUI3.Onboarding; - -public static class Factory -{ - public static OnboardingData CreateSend() - { - return new() - { - Title = "Send", - Blurb = "Send first model to Speckleverse!", - Completed = false, - Page = "/onboarding/send", - }; - } - - public static OnboardingData CreateReceive() - { - return new() - { - Title = "Receive", - Blurb = "Receive first model from Speckleverse!", - Completed = false, - Page = "/onboarding/receive", - }; - } - - public static Dictionary CreateDefaults() - { - return new Dictionary() { { "send", CreateSend() }, { "receive", CreateReceive() } }; - } -} diff --git a/DesktopUI3/DUI3/Onboarding/OnboardingData.cs b/DesktopUI3/DUI3/Onboarding/OnboardingData.cs deleted file mode 100644 index 76ad6226fa..0000000000 --- a/DesktopUI3/DUI3/Onboarding/OnboardingData.cs +++ /dev/null @@ -1,11 +0,0 @@ -using DUI3.Utils; - -namespace DUI3.Onboarding; - -public class OnboardingData : DiscriminatedObject -{ - public string Title { get; set; } - public string Blurb { get; set; } - public bool? Completed { get; set; } = false; - public string Page { get; set; } -} diff --git a/DesktopUI3/DUI3/Operations/CancellationManager.cs b/DesktopUI3/DUI3/Operations/CancellationManager.cs deleted file mode 100644 index 0d833ae10f..0000000000 --- a/DesktopUI3/DUI3/Operations/CancellationManager.cs +++ /dev/null @@ -1,83 +0,0 @@ -using System.Collections.Generic; -using System.Threading; - -namespace DUI3.Operations; - -/// -/// Provides a mechanism for cancelling operations. -/// -public interface ICancelable -{ - public CancellationManager CancellationManager { get; } -} - -/// -/// Util class to manage cancellations. -/// -public class CancellationManager -{ - /// - /// Dictionary to relate with registered id. - /// - private readonly Dictionary _operationsInProgress = new(); - - /// - /// Get token with registered id. - /// - /// Id of the operation. - /// CancellationToken that belongs to operation. - public CancellationToken GetToken(string id) - { - return _operationsInProgress[id].Token; - } - - /// - /// Whether given id registered or not. - /// - /// Id to check registration. - /// Whether given id registered or not. - public bool IsExist(string id) - { - return _operationsInProgress.ContainsKey(id); - } - - /// - /// Initialize a token source for cancellable operation. - /// - /// Id to register token. - /// Initialized cancellation token source. - public CancellationTokenSource InitCancellationTokenSource(string id) - { - if (IsExist(id)) - { - CancelOperation(id); - } - - var cts = new CancellationTokenSource(); - _operationsInProgress[id] = cts; - return cts; - } - - /// - /// Cancel operation. - /// - /// Id to cancel operation. - public void CancelOperation(string id) - { - if (_operationsInProgress.TryGetValue(id, out CancellationTokenSource cts)) - { - cts.Cancel(); - _operationsInProgress.Remove(id); - } - } - - /// - /// Whether cancellation requested already or not. - /// - /// Id to check cancellation requested already or not. - /// - public bool IsCancellationRequested(string id) - { - return _operationsInProgress[id].IsCancellationRequested; - } -} diff --git a/DesktopUI3/DUI3/Operations/Operations.cs b/DesktopUI3/DUI3/Operations/Operations.cs deleted file mode 100644 index 46b4389a8d..0000000000 --- a/DesktopUI3/DUI3/Operations/Operations.cs +++ /dev/null @@ -1,60 +0,0 @@ -#nullable enable -using System; -using System.Threading; -using System.Threading.Tasks; -using DUI3.Bindings; - -using DUI3.Utils; -using Speckle.Core.Api; -using Speckle.Core.Credentials; -using Speckle.Core.Logging; -using Speckle.Core.Models; -using Speckle.Core.Transports; - -namespace DUI3.Operations; - -public static class Operations -{ - public static async Task GetCommitBase(IBridge parent, ReceiverModelCard modelCard, CancellationToken token) - { - Account account = Accounts.GetAccount(modelCard.AccountId); - Client client = new(account); - - Commit version = await client - .CommitGet(modelCard.ProjectId, modelCard.SelectedVersionId, token) - .ConfigureAwait(false); - - Base commitObject = await ReceiveCommit(account, modelCard.ProjectId, version.referencedObject, parent, token) - .ConfigureAwait(true); - - client.Dispose(); - return commitObject; - } - - /// - /// Convenience wrapper around with connector-style error handling - /// - /// the to receive - /// The requested commit data - /// Thrown when any receive operation errors - /// Thrown when requests a cancellation - private static async Task ReceiveCommit( - Account account, - string projectId, - string referencedObjectId, - IBridge parent, - CancellationToken token - ) - { - using ServerTransport transport = new(account, projectId); - - Base? commitObject = - await Speckle.Core.Api.Operations - .Receive(referencedObjectId, cancellationToken: token, remoteTransport: transport) - .ConfigureAwait(false) - ?? throw new SpeckleException( - $"Failed to receive commit: {referencedObjectId} objects from server: {nameof(Speckle.Core.Api.Operations)} returned null" - ); - return commitObject; - } -} diff --git a/DesktopUI3/DUI3/Operations/Send.cs b/DesktopUI3/DUI3/Operations/Send.cs deleted file mode 100644 index 60273ef5db..0000000000 --- a/DesktopUI3/DUI3/Operations/Send.cs +++ /dev/null @@ -1,200 +0,0 @@ -#nullable enable -using System; -using System.Collections.Concurrent; -using System.Collections.Generic; -using System.Diagnostics; -using System.Linq; -using System.Threading; -using System.Threading.Tasks; -using Serilog.Context; -using Speckle.Core.Logging; -using Speckle.Core.Models; -using Speckle.Core.Serialisation; -using Speckle.Core.Transports; -using Speckle.Newtonsoft.Json.Linq; - -namespace DUI3.Operations; - -/// -/// NOTE: Contains copy pasted code from the OG Send operations in Core (the non-obsolete ones). -/// -public static class SendHelper -{ - /// - /// IMPORTANT: Copy pasted function from Operations.Send in Core, but this time returning the converted references from the serializer. - /// Sends a Speckle Object to the provided and (optionally) the default local cache - /// - /// - /// - /// When , an additional will be included - /// The or was - /// - /// using ServerTransport destination = new(account, streamId); - /// string objectId = await Send(mySpeckleObject, destination, true); - /// - public static async Task<(string rootObjId, Dictionary convertedReferences)> Send( - Base value, - ITransport transport, - bool useDefaultCache, - Action>? onProgressAction = null, - CancellationToken cancellationToken = default - ) - { - if (transport is null) - { - throw new ArgumentNullException(nameof(transport), "Expected a transport to be explicitly specified"); - } - - List transports = new() { transport }; - using SQLiteTransport? localCache = useDefaultCache ? new SQLiteTransport { TransportName = "LC" } : null; - if (localCache is not null) - { - transports.Add(localCache); - } - - return await Send(value, transports, onProgressAction, cancellationToken).ConfigureAwait(false); - } - - /// - /// IMPORTANT: Copy pasted function from Operations.Send in Core, but this time returning the converted references from the serializer. - /// It's marked as private as DUI3 only uses the one above. - /// Note that this should be structured better in the future - this is here to minimise core changes coming from DUI3. - /// - /// - /// - /// - /// - /// - /// - /// - /// - private static async Task<(string rootObjId, Dictionary convertedReferences)> Send( - Base value, - IReadOnlyCollection transports, - Action>? onProgressAction = null, - CancellationToken cancellationToken = default - ) - { - if (value is null) - { - throw new ArgumentNullException(nameof(value)); - } - - if (transports.Count == 0) - { - throw new ArgumentException("Expected at least on transport to be specified", nameof(transports)); - } - - var transportContext = transports.ToDictionary(t => t.TransportName, t => t.TransportContext); - - // make sure all logs in the operation have the proper context - using (LogContext.PushProperty("transportContext", transportContext)) - using (LogContext.PushProperty("correlationId", Guid.NewGuid().ToString())) - { - var sendTimer = Stopwatch.StartNew(); - SpeckleLog.Logger.Information("Starting send operation"); - - var internalProgressAction = GetInternalProgressAction(onProgressAction); - - BaseObjectSerializerV2 serializerV2 = - new(transports, internalProgressAction, trackDetachedChildren: true, cancellationToken); - - foreach (var t in transports) - { - t.OnProgressAction = internalProgressAction; - t.CancellationToken = cancellationToken; - t.BeginWrite(); - } - - (string rootObjId, Dictionary) serializerReturnValue; - try - { - serializerReturnValue = await SerializerSend(value, serializerV2, cancellationToken).ConfigureAwait(false); - } - catch (Exception ex) when (!ex.IsFatal()) - { - SpeckleLog.Logger.Information( - ex, - "Send operation failed after {elapsed} seconds", - sendTimer.Elapsed.TotalSeconds - ); - if (ex is OperationCanceledException or SpeckleException) - { - throw; - } - - throw new SpeckleException("Send operation was unsuccessful", ex); - } - finally - { - foreach (var t in transports) - { - t.EndWrite(); - } - } - - sendTimer.Stop(); - SpeckleLog.Logger - .ForContext("transportElapsedBreakdown", transports.ToDictionary(t => t.TransportName, t => t.Elapsed)) - .ForContext("note", "the elapsed summary doesn't need to add up to the total elapsed... Threading magic...") - .ForContext("serializerElapsed", serializerV2.Elapsed) - .Information( - "Finished sending {objectCount} objects after {elapsed}, result {objectId}", - transports.Max(t => t.SavedObjectCount), - sendTimer.Elapsed.TotalSeconds, - serializerReturnValue.rootObjId - ); - return serializerReturnValue; - } - } - - internal static async Task<( - string rootObjectId, - Dictionary convertedReferences - )> SerializerSend(Base value, BaseObjectSerializerV2 serializer, CancellationToken cancellationToken = default) - { - string obj = serializer.Serialize(value); - Task[] transportAwaits = serializer.WriteTransports.Select(t => t.WriteComplete()).ToArray(); - - cancellationToken.ThrowIfCancellationRequested(); - - await Task.WhenAll(transportAwaits).ConfigureAwait(false); - - var parsed = JObject.Parse(obj); - JToken? idToken = parsed.GetValue("id"); - - if (idToken == null) - { - throw new SpeckleException("Failed to get id of serialized object"); - } - - return (idToken.ToString(), serializer.ObjectReferences); - } - - /// - /// Factory for progress actions used internally inside send and receive methods. - /// - /// - /// - private static Action? GetInternalProgressAction( - Action>? onProgressAction - ) - { - if (onProgressAction is null) - { - return null; - } - - var localProgressDict = new ConcurrentDictionary(); - - return (name, processed) => - { - if (!localProgressDict.TryAdd(name, processed)) - { - localProgressDict[name] += processed; - } - - onProgressAction.Invoke(localProgressDict); - }; - } -} diff --git a/DesktopUI3/DUI3/Settings/CardSetting.cs b/DesktopUI3/DUI3/Settings/CardSetting.cs deleted file mode 100644 index e0d74c8a37..0000000000 --- a/DesktopUI3/DUI3/Settings/CardSetting.cs +++ /dev/null @@ -1,14 +0,0 @@ -#nullable enable -using System.Collections.Generic; -using DUI3.Utils; - -namespace DUI3.Settings; - -public class CardSetting : DiscriminatedObject -{ - public string Id { get; set; } - public string Title { get; set; } - public string Type { get; set; } - public object Value { get; set; } - public List? Enum { get; set; } -} diff --git a/DesktopUI3/DUI3/Utils/Accounts.cs b/DesktopUI3/DUI3/Utils/Accounts.cs deleted file mode 100644 index 56759a5f97..0000000000 --- a/DesktopUI3/DUI3/Utils/Accounts.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System.Linq; -using Speckle.Core.Credentials; - -namespace DUI3.Utils; - -public static class Accounts -{ - public static Account GetAccount(string accountId) - { - Account account = - AccountManager.GetAccounts().FirstOrDefault(acc => acc.id == accountId) - ?? throw new SpeckleAccountManagerException(); - return account; - } -} diff --git a/DesktopUI3/DUI3/Utils/Converters.cs b/DesktopUI3/DUI3/Utils/Converters.cs deleted file mode 100644 index 17eed144ed..0000000000 --- a/DesktopUI3/DUI3/Utils/Converters.cs +++ /dev/null @@ -1,13 +0,0 @@ -using Speckle.Core.Kits; - -namespace DUI3.Utils; - -public static class Converters -{ - public static ISpeckleConverter GetConverter(T document, string appNameVersion) - { - ISpeckleConverter converter = KitManager.GetDefaultKit().LoadConverter(appNameVersion); - converter.SetContextDocument(document); - return converter; - } -} diff --git a/DesktopUI3/DUI3/Utils/DiscriminatedObject.cs b/DesktopUI3/DUI3/Utils/DiscriminatedObject.cs deleted file mode 100644 index e90b31c874..0000000000 --- a/DesktopUI3/DUI3/Utils/DiscriminatedObject.cs +++ /dev/null @@ -1,15 +0,0 @@ -namespace DUI3.Utils; - -/// -/// Any polymorphic type base should inherit from this class in order for it to be properly deserialized. -/// - Class inheritance scenario For example, if you have a base class BaseSettings, and from it you create RhinoBaseSettings & AutocadBaseSettings, the BaseSetting class should inherit from this class. -/// - Interface scenario: you have an ISenderCard interface, which you implement as ReceiverCard and SenderCard. Both ReceiverCard and SenderCard should inherit from this class. -/// -public class DiscriminatedObject -{ - public string TypeDiscriminator - { - get => this.GetType().Name; - set { } - } -} diff --git a/DesktopUI3/DUI3/Utils/DiscriminatedObjectConverter.cs b/DesktopUI3/DUI3/Utils/DiscriminatedObjectConverter.cs deleted file mode 100644 index 0afbb16778..0000000000 --- a/DesktopUI3/DUI3/Utils/DiscriminatedObjectConverter.cs +++ /dev/null @@ -1,119 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Linq; -using System.Reflection; -using Speckle.Core.Logging; -using Speckle.Newtonsoft.Json; -using Speckle.Newtonsoft.Json.Linq; -using Speckle.Newtonsoft.Json.Serialization; - -namespace DUI3.Utils; - -/// -/// This converter ensures we can do polymorphic deserialization to concrete types. It is automatically added to all -/// serialization settings from . This converter is intended -/// for use only with UI bound types, not Speckle Bases. -/// -public class DiscriminatedObjectConverter : JsonConverter -{ - private readonly JsonSerializer _localSerializer = - new() - { - DefaultValueHandling = DefaultValueHandling.Ignore, - ContractResolver = new CamelCasePropertyNamesContractResolver(), - NullValueHandling = NullValueHandling.Ignore - }; - - public override void WriteJson(JsonWriter writer, DiscriminatedObject value, JsonSerializer serializer) - { - var jo = JObject.FromObject(value, _localSerializer); - jo.WriteTo(writer); - } - - public override DiscriminatedObject ReadJson( - JsonReader reader, - Type objectType, - DiscriminatedObject existingValue, - bool hasExistingValue, - JsonSerializer serializer - ) - { - JObject jsonObject = JObject.Load(reader); - - var typeName = - jsonObject.Value("typeDiscriminator") - ?? throw new Speckle.Core.Serialisation.SpeckleDeserializeException( - "DUI3 Discriminator converter deserialization failed: did not find a typeDiscriminator field." - ); - var type = - GetTypeByName(typeName) - ?? throw new Speckle.Core.Serialisation.SpeckleDeserializeException( - "DUI3 Discriminator converter deserialization failed, type not found: " + typeName - ); - var obj = Activator.CreateInstance(type); - serializer.Populate(jsonObject.CreateReader(), obj); - - // Store the JSON property names in the object for later comparison - if (obj is PropertyValidator pv) - { - // Capture property names from JSON - var jsonPropertyNames = jsonObject.Properties().Select(p => p.Name).ToList(); - - pv.JsonPropertyNames = jsonPropertyNames; - } - - return obj as DiscriminatedObject; - } - - private static readonly Dictionary s_typeCache = new(); - - private Type GetTypeByName(string name) - { - s_typeCache.TryGetValue(name, out Type myType); - if (myType != null) - { - return myType; - } - - foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies().Reverse()) - { - try - { - // assembly. - var allAssemblyTypes = assembly.DefinedTypes; - var assemblyTypesEnumerable = allAssemblyTypes.ToList(); - if (assemblyTypesEnumerable.Any()) - { - var type = assemblyTypesEnumerable.FirstOrDefault(t => t.FullName != null && t.FullName.Contains(name)); - - if (type != null) - { - s_typeCache[name] = type; - return type; - } - } - } - catch (Exception e) // DO NOT CHANGE THIS TO SPECKLE EXCEPTION - { - Debug.WriteLine(e.Message); - } - } - return null; - } -} - -public class AbstractConverter : JsonConverter -{ - public override bool CanConvert(Type objectType) => objectType == typeof(TAbstract); - - public override object ReadJson( - JsonReader reader, - Type objectType, - object existingValue, - JsonSerializer serializer - ) => serializer.Deserialize(reader); - - public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) => - serializer.Serialize(writer, value); -} diff --git a/DesktopUI3/DUI3/Utils/Exceptions.cs b/DesktopUI3/DUI3/Utils/Exceptions.cs deleted file mode 100644 index c1f461c1c8..0000000000 --- a/DesktopUI3/DUI3/Utils/Exceptions.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System; -using Speckle.Core.Logging; - -namespace DUI3.Utils; - -public class ModelNotFoundException : SpeckleException -{ - public ModelNotFoundException(string message) - : base(message) { } - - public ModelNotFoundException(string message, Exception inner) - : base(message, inner) { } - - public ModelNotFoundException() { } -} diff --git a/DesktopUI3/DUI3/Utils/PropertyValidator.cs b/DesktopUI3/DUI3/Utils/PropertyValidator.cs deleted file mode 100644 index fb095d8fbe..0000000000 --- a/DesktopUI3/DUI3/Utils/PropertyValidator.cs +++ /dev/null @@ -1,53 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using Speckle.Newtonsoft.Json; - -namespace DUI3.Utils; - -public class PropertyValidator : DiscriminatedObject -{ - [JsonIgnore] - public List JsonPropertyNames { get; set; } - - public bool InitializeNewProperties() - { - bool isUpdated = false; - var properties = this.GetType().GetProperties(); - - // Create a new instance of the current type to get default values - var defaultInstance = Activator.CreateInstance(this.GetType()); - - foreach (var property in properties) - { - if (property.GetValue(this) == null) - { - // Get the default value from the new instance - var defaultValue = property.GetValue(defaultInstance); - - // Set this default value to the current instance - property.SetValue(this, defaultValue); - isUpdated = true; - } - } - - return isUpdated; // Return true if any property was updated - } - - public bool CheckRemovedProperties() - { - bool removedPropertiesExist = false; - var currentPropertyNames = this.GetType().GetProperties().Select(p => p.Name).ToList(); - - foreach (var jsonPropName in JsonPropertyNames) - { - if (!currentPropertyNames.Contains(jsonPropName)) - { - // This property was in the JSON but not in the class - removedPropertiesExist = true; - } - } - - return removedPropertiesExist; - } -} diff --git a/DesktopUI3/DUI3/Utils/SerializationSettingsFactory.cs b/DesktopUI3/DUI3/Utils/SerializationSettingsFactory.cs deleted file mode 100644 index d6d407e6ce..0000000000 --- a/DesktopUI3/DUI3/Utils/SerializationSettingsFactory.cs +++ /dev/null @@ -1,26 +0,0 @@ -using DUI3.Bindings; -using Speckle.Newtonsoft.Json; -using Speckle.Newtonsoft.Json.Serialization; - -namespace DUI3.Utils; - -public static class SerializationSettingsFactory -{ - /// - /// Get the canonical Newtonsoft serialization/deserialization settings which we use in DUI3, which currently consist of a camel case name strategy and a discriminated object converter. - /// - /// - public static JsonSerializerSettings GetSerializerSettings() - { - var serializerOptions = new JsonSerializerSettings - { - ContractResolver = new CamelCasePropertyNamesContractResolver(), - NullValueHandling = NullValueHandling.Ignore, - ReferenceLoopHandling = ReferenceLoopHandling.Ignore, - DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate, - Converters = { new DiscriminatedObjectConverter(), new AbstractConverter() } - }; - - return serializerOptions; - } -} diff --git a/DesktopUI3/DUI3/Utils/Traversal.cs b/DesktopUI3/DUI3/Utils/Traversal.cs deleted file mode 100644 index f472b4731d..0000000000 --- a/DesktopUI3/DUI3/Utils/Traversal.cs +++ /dev/null @@ -1,117 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using System.Linq; -using Speckle.Core.Kits; -using Speckle.Core.Models; -using Speckle.Core.Models.Extensions; -using Speckle.Core.Models.GraphTraversal; - -namespace DUI3.Utils; - -public static class Traversal -{ - public static List GetObjectsToConvert(Base commitObject, ISpeckleConverter converter) - { - var traverseFunction = DefaultTraversal.CreateTraverseFunc(converter); - - return traverseFunction - .Traverse(commitObject) - .Select(tc => tc.Current) // Previously we were creating ApplicationObject, now just returning Base object. - .Reverse() - .ToList(); - } - - /// - /// A variation of the OG Traversal extension from Alan, but with tracking the object path as well. - /// - /// - /// - /// - public static IEnumerable<(List, Base)> TraverseWithPath( - this Base root, - BaseExtensions.BaseRecursionBreaker recursionBreaker - ) - { - var stack = new Stack<(List, Base)>(); - stack.Push((new List(), root)); - - while (stack.Count > 0) - { - (List path, Base current) = stack.Pop(); - yield return (path, current); - - if (recursionBreaker(current)) - { - continue; - } - - foreach (string child in current.GetDynamicMemberNames()) - { - // NOTE: we can store collections rather than just path names. Where we have an actual collection, use that, where not, create a mock one based on the prop name - var localPathFragment = child; - if (current is Collection { name: { } } c) - { - localPathFragment = c.name; - } - - var newPath = new List(path) { localPathFragment }; - switch (current[child]) - { - case Base o: - stack.Push((newPath, o)); - break; - case IDictionary dictionary: - { - foreach (object obj in dictionary.Keys) - { - if (obj is Base b) - { - stack.Push((newPath, b)); - } - } - - break; - } - case IList collection: - { - foreach (object obj in collection) - { - if (obj is Base b) - { - stack.Push((newPath, b)); - } - } - break; - } - } - } - } - } - - /// - /// Utility function to flatten a conversion result that might have nested lists of objects. - /// This happens, for example, in the case of multiple display value fallbacks for a given object. - /// - /// - /// - public static List FlattenToNativeConversionResult(object item) - { - var convertedList = new List(); - void Flatten(object item) - { - if (item is IList list) - { - foreach (object child in list) - { - Flatten(child); - } - } - else - { - convertedList.Add(item); - } - } - Flatten(item); - return convertedList; - } -} From cf3085317a40562ab4262f90fa4b6d96c3b3298d Mon Sep 17 00:00:00 2001 From: KatKatKateryna <89912278+KatKatKateryna@users.noreply.github.com> Date: Fri, 10 May 2024 23:08:52 +0800 Subject: [PATCH 174/261] CNX-9444 implement graph traversal in arc gis on receive (#3393) * graph traversal, parentId as dataset name; updated Tuples * mistake with polylines: multiple can be converted * typo * rename to List converters * rename to List * refactor HostObjectBuilder --- .../AutofacArcGISModule.cs | 2 + .../Operations/Receive/HostObjectBuilder.cs | 117 +++++++++--------- .../Features/GeometryToHostConverter.cs | 10 +- ...er.cs => MultipatchListToHostConverter.cs} | 4 +- ...er.cs => MultipointListToHostConverter.cs} | 4 +- ...ter.cs => Polygon3dListToHostConverter.cs} | 4 +- ...erter.cs => PolygonListToHostConverter.cs} | 4 +- .../PolylineListToHostConverter.cs | 29 +++++ .../Utils/INonNativeFeaturesUtils.cs | 4 +- .../Utils/NonNativeFeaturesUtils.cs | 30 ++--- 10 files changed, 117 insertions(+), 91 deletions(-) rename DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/{MultipatchToHostConverter.cs => MultipatchListToHostConverter.cs} (83%) rename DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/{MultipointToHostConverter.cs => MultipointListToHostConverter.cs} (79%) rename DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/{Polygon3dToHostConverter.cs => Polygon3dListToHostConverter.cs} (91%) rename DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/{PolygonToHostConverter.cs => PolygonListToHostConverter.cs} (86%) create mode 100644 DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/PolylineListToHostConverter.cs diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/DependencyInjection/AutofacArcGISModule.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/DependencyInjection/AutofacArcGISModule.cs index b292184dd9..fdf7013f0e 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/DependencyInjection/AutofacArcGISModule.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/DependencyInjection/AutofacArcGISModule.cs @@ -26,6 +26,7 @@ // This should go whenever it is aligned. using IRootObjectSender = Speckle.Connectors.ArcGis.Operations.Send.IRootObjectSender; using RootObjectSender = Speckle.Connectors.ArcGis.Operations.Send.RootObjectSender; +using Speckle.Core.Models.GraphTraversal; namespace Speckle.Connectors.ArcGIS.DependencyInjection; @@ -73,6 +74,7 @@ protected override void Load(ContainerBuilder builder) builder.RegisterType().InstancePerLifetimeScope(); builder.RegisterType().InstancePerLifetimeScope(); builder.RegisterType().As().InstancePerLifetimeScope(); + builder.RegisterInstance(DefaultTraversal.CreateTraversalFunc()); //POC: how tf does this work? builder.RegisterType().As().SingleInstance(); diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Receive/HostObjectBuilder.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Receive/HostObjectBuilder.cs index 17e81693a0..f281752b4a 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Receive/HostObjectBuilder.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Receive/HostObjectBuilder.cs @@ -4,11 +4,11 @@ using Speckle.Converters.Common; using Speckle.Core.Logging; using Speckle.Core.Models; -using Speckle.Core.Models.Extensions; using ArcGIS.Desktop.Framework.Threading.Tasks; using Speckle.Converters.ArcGIS3.Utils; using ArcGIS.Core.Geometry; using Objects.GIS; +using Speckle.Core.Models.GraphTraversal; namespace Speckle.Connectors.ArcGIS.Operations.Receive; @@ -20,38 +20,46 @@ public class HostObjectBuilder : IHostObjectBuilder // POC: figure out the correct scope to only initialize on Receive private readonly IConversionContextStack _contextStack; + private readonly GraphTraversal _traverseFunction; public HostObjectBuilder( ISpeckleConverterToHost toHostConverter, IArcGISProjectUtils arcGISProjectUtils, IConversionContextStack contextStack, - INonNativeFeaturesUtils nonGisFeaturesUtils + INonNativeFeaturesUtils nonGisFeaturesUtils, + GraphTraversal traverseFunction ) { _toHostConverter = toHostConverter; _arcGISProjectUtils = arcGISProjectUtils; _contextStack = contextStack; _nonGisFeaturesUtils = nonGisFeaturesUtils; + _traverseFunction = traverseFunction; } - public Tuple, Geometry> ConvertNonNativeGeometries(Base obj, string[] path, List objectIds) + public (string, Geometry, string?) ConvertNonNativeGeometries( + Base obj, + string[] path, + string? parentId, + List objectIds + ) { Geometry converted = (Geometry)_toHostConverter.Convert(obj); objectIds.Add(obj.id); List objPath = path.ToList(); objPath.Add(obj.speckle_type.Split(".")[^1]); - return Tuple.Create(objPath, converted); + return ($"{string.Join("\\", objPath)}", converted, parentId); } - public Tuple ConvertNativeLayers(Base obj, string[] path, List objectIds) + public (string, string) ConvertNativeLayers(Base obj, string[] path, List objectIds) { string converted = (string)_toHostConverter.Convert(obj); objectIds.Add(obj.id); string objPath = $"{string.Join("\\", path)}\\{((Collection)obj).name}"; - return Tuple.Create(objPath, converted); + return (objPath, converted); } - public void AddDatasetsToMap(Tuple databaseObj, string databasePath) + public void AddDatasetsToMap((string, string) databaseObj, string databasePath) { try { @@ -71,6 +79,13 @@ public void AddDatasetsToMap(Tuple databaseObj, string databaseP } } + private string[] GetLayerPath(TraversalContext context) + { + string[] collectionBasedPath = context.GetAscendantOfType().Select(c => c.name).ToArray(); + string[] reverseOrderPath = collectionBasedPath.Any() ? collectionBasedPath : context.GetPropertyPath().ToArray(); + return reverseOrderPath.Reverse().ToArray(); + } + public IEnumerable Build( Base rootObject, string projectName, @@ -88,37 +103,45 @@ CancellationToken cancellationToken _arcGISProjectUtils.AddDatabaseToProject(databasePath); // POC: This is where we will define our receive strategy, or maybe later somewhere else according to some setting pass from UI? - IEnumerable<(string[], Base)> objectsWithPath = rootObject.TraverseWithPath((obj) => obj is not Collection); + var objectsToConvert = _traverseFunction + .Traverse(rootObject) + .Where(ctx => ctx.Parent?.Current is not VectorLayer && ctx.Parent?.Current is not Objects.GIS.RasterLayer) + .Select(ctx => (GetLayerPath(ctx), ctx.Current, ctx.Parent?.Current.id)) + .ToList(); - IEnumerable<(string[], Base)> gisObjectsWithPath = objectsWithPath.Where( - x => x.Item2 is VectorLayer || x.Item2 is Objects.GIS.RasterLayer - ); - IEnumerable<(string[], Base)> nonGisObjectsWithPath = objectsWithPath.Where( - x => x.Item2 is not GisFeature && x.Item2 is not VectorLayer && x.Item2 is not Objects.GIS.RasterLayer - ); - - List objectIds = new(); + int allCount = objectsToConvert.Count; int count = 0; - int allCount = objectsWithPath.Count(); - - Dictionary, Geometry>> convertedGeometries = new(); - List> convertedGISObjects = new(); + Dictionary convertedGeometries = new(); + List objectIds = new(); + List<(string, string)> convertedGISObjects = new(); - // 1.1. convert non-gis objects in a loop - foreach ((string[] path, Base obj) in nonGisObjectsWithPath) + // 1. convert everything + foreach (var item in objectsToConvert) { - if (cancellationToken.IsCancellationRequested) - { - throw new OperationCanceledException(cancellationToken); - } + (string[] path, Base obj, string? parentId) = item; + cancellationToken.ThrowIfCancellationRequested(); try { - // POC: QueuedTask - QueuedTask.Run(() => + if (obj is VectorLayer or Objects.GIS.RasterLayer) { - convertedGeometries[obj.id] = ConvertNonNativeGeometries(obj, path, objectIds); - }); - onOperationProgressed?.Invoke("Converting", (double)++count / allCount); + // POC: QueuedTask + var task = QueuedTask.Run(() => + { + convertedGISObjects.Add(ConvertNativeLayers(obj, path, objectIds)); + }); + task.Wait(cancellationToken); + + onOperationProgressed?.Invoke("Converting", (double)++count / allCount); + } + else + { + // POC: QueuedTask + QueuedTask.Run(() => + { + convertedGeometries[obj.id] = ConvertNonNativeGeometries(obj, path, parentId, objectIds); + }); + onOperationProgressed?.Invoke("Converting", (double)++count / allCount); + } } catch (Exception e) when (!e.IsFatal()) // DO NOT CATCH SPECIFIC STUFF, conversion errors should be recoverable { @@ -126,7 +149,8 @@ CancellationToken cancellationToken Debug.WriteLine("conversion error happened."); } } - // 1.2. convert Database entries with non-GIS geometry datasets + + // 2. convert Database entries with non-GIS geometry datasets try { onOperationProgressed?.Invoke("Writing to Database", null); @@ -138,35 +162,10 @@ CancellationToken cancellationToken Debug.WriteLine("conversion error happened."); } - // 2. convert gis-objects in a loop - foreach ((string[] path, Base obj) in gisObjectsWithPath) - { - if (cancellationToken.IsCancellationRequested) - { - throw new OperationCanceledException(cancellationToken); - } - try - { - // POC: QueuedTask - var task = QueuedTask.Run(() => - { - convertedGISObjects.Add(ConvertNativeLayers(obj, path, objectIds)); - }); - task.Wait(cancellationToken); - - onOperationProgressed?.Invoke("Converting", (double)++count / allCount); - } - catch (Exception e) when (!e.IsFatal()) // DO NOT CATCH SPECIFIC STUFF, conversion errors should be recoverable - { - // POC: report, etc. - Debug.WriteLine("conversion error happened."); - } - } - int bakeCount = 0; - onOperationProgressed?.Invoke("Adding to Map", 0); + onOperationProgressed?.Invoke("Adding to Map", bakeCount); // 3. add layer and tables to the Table Of Content - foreach (Tuple databaseObj in convertedGISObjects) + foreach ((string, string) databaseObj in convertedGISObjects) { if (cancellationToken.IsCancellationRequested) { diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GeometryToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GeometryToHostConverter.cs index 60310dcd51..4ca74197b5 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GeometryToHostConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GeometryToHostConverter.cs @@ -6,14 +6,14 @@ namespace Speckle.Converters.ArcGIS3.Features; public class GeometryToHostConverter : IRawConversion, ACG.Geometry> { - private readonly IRawConversion _polylineConverter; + private readonly IRawConversion, ACG.Polyline> _polylineConverter; private readonly IRawConversion, ACG.Multipoint> _multipointConverter; private readonly IRawConversion, ACG.Multipatch> _polygon3dConverter; private readonly IRawConversion, ACG.Polygon> _polygonConverter; private readonly IRawConversion, ACG.Multipatch> _multipatchConverter; public GeometryToHostConverter( - IRawConversion polylineConverter, + IRawConversion, ACG.Polyline> polylineConverter, IRawConversion, ACG.Multipoint> multipointConverter, IRawConversion, ACG.Multipatch> polygon3dConverter, IRawConversion, ACG.Polygon> polygonConverter, @@ -38,11 +38,7 @@ public ACG.Geometry RawConvert(IReadOnlyList target) case SOG.Point point: return _multipointConverter.RawConvert(target.Cast().ToList()); case SOG.Polyline polyline: - if (target.Count > 1) - { - throw new SpeckleConversionException("Polyline conversion only supports one polyline at a time"); - } - return _polylineConverter.RawConvert(target.Cast().ToList()[0]); + return _polylineConverter.RawConvert(target.Cast().ToList()); case SGIS.PolygonGeometry3d geometry3d: return _polygon3dConverter.RawConvert(target.Cast().ToList()); case SGIS.PolygonGeometry geometry: diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/MultipatchToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/MultipatchListToHostConverter.cs similarity index 83% rename from DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/MultipatchToHostConverter.cs rename to DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/MultipatchListToHostConverter.cs index 80942d1189..3966c7addb 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/MultipatchToHostConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/MultipatchListToHostConverter.cs @@ -3,11 +3,11 @@ namespace Speckle.Converters.ArcGIS3.Geometry.GisFeatureGeometriesToHost; -public class MultipatchToHostConverter : IRawConversion, ACG.Multipatch> +public class MultipatchListToHostConverter : IRawConversion, ACG.Multipatch> { private readonly IRawConversion _pointConverter; - public MultipatchToHostConverter(IRawConversion pointConverter) + public MultipatchListToHostConverter(IRawConversion pointConverter) { _pointConverter = pointConverter; } diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/MultipointToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/MultipointListToHostConverter.cs similarity index 79% rename from DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/MultipointToHostConverter.cs rename to DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/MultipointListToHostConverter.cs index 88dc2c41ff..651c020011 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/MultipointToHostConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/MultipointListToHostConverter.cs @@ -3,11 +3,11 @@ namespace Speckle.Converters.ArcGIS3.Geometry.GisFeatureGeometriesToHost; -public class MultipointToHostConverter : IRawConversion, ACG.Multipoint> +public class PointListToHostConverter : IRawConversion, ACG.Multipoint> { private readonly IRawConversion _pointConverter; - public MultipointToHostConverter(IRawConversion pointConverter) + public PointListToHostConverter(IRawConversion pointConverter) { _pointConverter = pointConverter; } diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/Polygon3dToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/Polygon3dListToHostConverter.cs similarity index 91% rename from DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/Polygon3dToHostConverter.cs rename to DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/Polygon3dListToHostConverter.cs index cebd781a3b..8a58236e56 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/Polygon3dToHostConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/Polygon3dListToHostConverter.cs @@ -3,12 +3,12 @@ namespace Speckle.Converters.ArcGIS3.Geometry.GisFeatureGeometriesToHost; -public class Polygon3dToHostConverter : IRawConversion, ACG.Multipatch> +public class Polygon3dListToHostConverter : IRawConversion, ACG.Multipatch> { private readonly IRawConversion _pointConverter; private readonly IRawConversion _polylineConverter; - public Polygon3dToHostConverter( + public Polygon3dListToHostConverter( IRawConversion pointConverter, IRawConversion polylineConverter ) diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/PolygonToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/PolygonListToHostConverter.cs similarity index 86% rename from DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/PolygonToHostConverter.cs rename to DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/PolygonListToHostConverter.cs index 8ae163e2d8..d8e1fc9ffd 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/PolygonToHostConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/PolygonListToHostConverter.cs @@ -3,11 +3,11 @@ namespace Speckle.Converters.ArcGIS3.Geometry.GisFeatureGeometriesToHost; -public class PolygonToHostConverter : IRawConversion, ACG.Polygon> +public class PolygonListToHostConverter : IRawConversion, ACG.Polygon> { private readonly IRawConversion _polylineConverter; - public PolygonToHostConverter(IRawConversion polylineConverter) + public PolygonListToHostConverter(IRawConversion polylineConverter) { _polylineConverter = polylineConverter; } diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/PolylineListToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/PolylineListToHostConverter.cs new file mode 100644 index 0000000000..cfde1fee8c --- /dev/null +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/PolylineListToHostConverter.cs @@ -0,0 +1,29 @@ +using Speckle.Converters.Common.Objects; +using Speckle.Converters.Common; + +namespace Speckle.Converters.ArcGIS3.Geometry.GisFeatureGeometriesToHost; + +public class PolylineListToHostConverter : IRawConversion, ACG.Polyline> +{ + private readonly IRawConversion _polylineConverter; + + public PolylineListToHostConverter(IRawConversion polylineConverter) + { + _polylineConverter = polylineConverter; + } + + public ACG.Polyline RawConvert(List target) + { + if (target.Count == 0) + { + throw new SpeckleConversionException("Feature contains no geometries"); + } + List polyList = new(); + foreach (SOG.Polyline poly in target) + { + ACG.Polyline arcgisPoly = _polylineConverter.RawConvert(poly); + polyList.Add(arcgisPoly); + } + return new ACG.PolylineBuilderEx(polyList, ACG.AttributeFlags.HasZ).ToGeometry(); + } +} diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/INonNativeFeaturesUtils.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/INonNativeFeaturesUtils.cs index f269427400..1405621f31 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/INonNativeFeaturesUtils.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/INonNativeFeaturesUtils.cs @@ -2,7 +2,7 @@ namespace Speckle.Converters.ArcGIS3.Utils; public interface INonNativeFeaturesUtils { - public List> WriteGeometriesToDatasets( - Dictionary, ACG.Geometry>> target + public List<(string, string)> WriteGeometriesToDatasets( + Dictionary convertedObjs ); } diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/NonNativeFeaturesUtils.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/NonNativeFeaturesUtils.cs index 190fe22f36..362b9b6839 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/NonNativeFeaturesUtils.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/NonNativeFeaturesUtils.cs @@ -34,38 +34,38 @@ public NonNativeFeaturesUtils( _contextStack = contextStack; } - public List> WriteGeometriesToDatasets( - Dictionary, ACG.Geometry>> target + public List<(string, string)> WriteGeometriesToDatasets( + Dictionary convertedObjs ) { - List> result = new(); + List<(string, string)> result = new(); try { // 1. Sort features into groups by path and geom type - Dictionary> geometryGroups = new(); - foreach (var item in target) + Dictionary, string?)> geometryGroups = new(); + foreach (var item in convertedObjs) { string objId = item.Key; - (List objPath, ACG.Geometry geom) = item.Value; - string geomType = objPath[^1]; - string parentPath = $"{string.Join("\\", objPath.Where((x, i) => i < objPath.Count - 1))}\\{geomType}"; + (string parentPath, ACG.Geometry geom, string? parentId) = item.Value; // add dictionnary item if doesn't exist yet if (!geometryGroups.ContainsKey(parentPath)) { - geometryGroups[parentPath] = new List(); + geometryGroups[parentPath] = (new List(), parentId); } - geometryGroups[parentPath].Add(geom); + geometryGroups[parentPath].Item1.Add(geom); } // 2. for each group create a Dataset and add geometries there as Features - foreach ((string parentPath, List geomList) in geometryGroups) + foreach (var item in geometryGroups) { + string parentPath = item.Key; + (List geomList, string? parentId) = item.Value; ACG.GeometryType geomType = _featureClassUtils.GetGeometryTypeFromString(parentPath.Split("\\")[^1]); try { - string converted = CreateDatasetInDatabase(geomType, geomList); - result.Add(Tuple.Create(parentPath, converted)); + string converted = CreateDatasetInDatabase(geomType, geomList, parentId); + result.Add((parentPath, converted)); } catch (GeodatabaseGeometryException) { @@ -81,7 +81,7 @@ public List> WriteGeometriesToDatasets( return result; } - private string CreateDatasetInDatabase(ACG.GeometryType geomType, List geomList) + private string CreateDatasetInDatabase(ACG.GeometryType geomType, List geomList, string? parentId) { string databasePath = _arcGISProjectUtils.GetDatabasePath(); FileGeodatabaseConnectionPath fileGeodatabaseConnectionPath = new(new Uri(databasePath)); @@ -95,7 +95,7 @@ private string CreateDatasetInDatabase(ACG.GeometryType geomType, List fields = new(); // _fieldsUtils.GetFieldsFromSpeckleLayer(target); // TODO: generate meaningful name - string featureClassName = "hash_" + Utilities.HashString(string.Join("\\", geomList.Select(x => x.GetHashCode()))); + string featureClassName = $"speckleID_{geomType}_{parentId}"; // delete FeatureClass if already exists foreach (FeatureClassDefinition fClassDefinition in geodatabase.GetDefinitions()) From b8e16fa6a3fb82d3101348874f36eda0c5b1b06b Mon Sep 17 00:00:00 2001 From: Jedd Morgan <45512892+JR-Morgan@users.noreply.github.com> Date: Fri, 10 May 2024 18:06:21 +0100 Subject: [PATCH 175/261] Try catch per object converted (#3401) --- .../Utils/NonNativeFeaturesUtils.cs | 31 ++++++++++++------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/NonNativeFeaturesUtils.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/NonNativeFeaturesUtils.cs index 362b9b6839..fe8964792c 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/NonNativeFeaturesUtils.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/NonNativeFeaturesUtils.cs @@ -39,11 +39,11 @@ public NonNativeFeaturesUtils( ) { List<(string, string)> result = new(); - try + // 1. Sort features into groups by path and geom type + Dictionary, string?)> geometryGroups = new(); + foreach (var item in convertedObjs) { - // 1. Sort features into groups by path and geom type - Dictionary, string?)> geometryGroups = new(); - foreach (var item in convertedObjs) + try { string objId = item.Key; (string parentPath, ACG.Geometry geom, string? parentId) = item.Value; @@ -53,11 +53,20 @@ public NonNativeFeaturesUtils( { geometryGroups[parentPath] = (new List(), parentId); } + geometryGroups[parentPath].Item1.Add(geom); } + catch (Exception e) when (!e.IsFatal()) + { + // POC: report, etc. + Debug.WriteLine("conversion error happened."); + } + } - // 2. for each group create a Dataset and add geometries there as Features - foreach (var item in geometryGroups) + // 2. for each group create a Dataset and add geometries there as Features + foreach (var item in geometryGroups) + { + try { string parentPath = item.Key; (List geomList, string? parentId) = item.Value; @@ -72,11 +81,11 @@ public NonNativeFeaturesUtils( // do nothing if conversion of some geometry groups fails } } - } - catch (Exception e) when (!e.IsFatal()) - { - // POC: report, etc. - Debug.WriteLine("conversion error happened."); + catch (Exception e) when (!e.IsFatal()) + { + // POC: report, etc. + Debug.WriteLine("conversion error happened."); + } } return result; } From 072fab93da1950324fa13beab88fd3beb5c7c0cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?O=C4=9Fuzhan=20Koral?= <45078678+oguzhankoral@users.noreply.github.com> Date: Sat, 11 May 2024 01:36:22 +0300 Subject: [PATCH 176/261] CNX-9199 implement opening revit and dui3 when double clicking a file (#3394) * PostApplicationInit actions * Add notes * Remove test purpose task dialog * Update note * More notes * Revert OnDocumentChanged call after ReadFromFile * Remove unused using --- .../HostApp/RevitDocumentStore.cs | 5 +++ .../Plugin/RevitPlugin.cs | 33 ++++++++++++------- 2 files changed, 26 insertions(+), 12 deletions(-) diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/RevitDocumentStore.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/RevitDocumentStore.cs index 0130c638b7..2fc366a751 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/RevitDocumentStore.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/RevitDocumentStore.cs @@ -43,6 +43,11 @@ IdStorageSchema idStorageSchema uiApplication.Application.DocumentOpening += (_, _) => IsDocumentInit = false; uiApplication.Application.DocumentOpened += (_, _) => IsDocumentInit = false; + + // There is no event that we can hook here for double-click file open... + // It is kind of harmless since we create this object as "SingleInstance". + ReadFromFile(); + OnDocumentChanged(); } /// diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitPlugin.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitPlugin.cs index 63b7bbe879..68f78dc0b2 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitPlugin.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitPlugin.cs @@ -42,9 +42,10 @@ CefSharpPanel cefSharpPanel public void Initialise() { - _uIControlledApplication.ControlledApplication.ApplicationInitialized += OnApplicationInitialized; - + // Create and register panels before app initialized. this is needed for double-click file open CreateTabAndRibbonPanel(_uIControlledApplication); + RegisterDockablePane(); + _uIControlledApplication.ControlledApplication.ApplicationInitialized += OnApplicationInitialized; } public void Shutdown() @@ -104,19 +105,14 @@ private void OnApplicationInitialized(object sender, Autodesk.Revit.DB.Events.Ap // POC: might be worth to interface this out, we shall see... RevitTask.Initialize(uiApplication); - RegisterPanelAndInitializePlugin(); + PostApplicationInit(); // for double-click file open } - private void RegisterPanelAndInitializePlugin() + /// + /// Actions to run after UiApplication initialized. This is needed for double-click file open issue. + /// + private void PostApplicationInit() { - CefSharpSettings.ConcurrentTaskExecution = true; - - _uIControlledApplication.RegisterDockablePane( - RevitExternalApplication.DoackablePanelId, - _revitSettings.RevitPanelName, - _cefSharpPanel - ); - // binding the bindings to each bridge foreach (IBinding binding in _bindings.Select(x => x.Value)) { @@ -167,6 +163,19 @@ private void RegisterPanelAndInitializePlugin() }; } + private void RegisterDockablePane() + { + CefSharpSettings.ConcurrentTaskExecution = true; + + // Registering dockable pane should happen before UiApplication is initialized with RevitTask. + // Otherwise pane cannot be registered for double-click file open. + _uIControlledApplication.RegisterDockablePane( + RevitExternalApplication.DoackablePanelId, + _revitSettings.RevitPanelName, + _cefSharpPanel + ); + } + private ImageSource? LoadPngImgSource(string sourceName, string path) { try From ec1cc06e6d1d90552c7e089d3178befa26634a0e Mon Sep 17 00:00:00 2001 From: Claire Kuang Date: Mon, 13 May 2024 03:42:25 -0700 Subject: [PATCH 177/261] fix(autocad): CNX-9497 adds trim domains to ellipse conversions (#3402) adds trim domains to ellipse conversions --- .../ToHost/Geometry/EllipseToHostConverter.cs | 21 ++++++++++++++++++- .../Geometry/EllipseToSpeckleConverter.cs | 6 +++++- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/EllipseToHostConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/EllipseToHostConverter.cs index 8a7def05a2..708ea51f69 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/EllipseToHostConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/EllipseToHostConverter.cs @@ -41,6 +41,25 @@ public ADB.Ellipse RawConvert(SOG.Ellipse target) AG.Vector3d majorAxis = f * (double)target.firstRadius * xAxis.GetNormal(); double radiusRatio = (double)target.secondRadius / (double)target.firstRadius; - return new(origin, normal, majorAxis, radiusRatio, 0, 2 * Math.PI); + + // get trim + double startAngle = 0; + double endAngle = Math.PI * 2; + if ( + target.domain.start is double domainStart + && target.domain.end is double domainEnd + && target.trimDomain is SOP.Interval trim + && trim.start is double start + && trim.end is double end + ) + { + // normalize the start and end trim values to [0,2pi] + startAngle = (start - domainStart) / (domainEnd - domainStart) * Math.PI * 2; + endAngle = (end - domainStart) / (domainEnd - domainStart) * Math.PI * 2; + } + + ADB.Ellipse ellipse = new(origin, normal, majorAxis, radiusRatio, startAngle, endAngle); + + return ellipse; } } diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/EllipseToSpeckleConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/EllipseToSpeckleConverter.cs index de51e2ad5d..06dae2c11b 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/EllipseToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/EllipseToSpeckleConverter.cs @@ -29,10 +29,14 @@ public SOG.Ellipse RawConvert(ADB.Ellipse target) SOG.Plane plane = _planeConverter.RawConvert(new AG.Plane(target.Center, target.MajorAxis, target.MinorAxis)); SOG.Box bbox = _boxConverter.RawConvert(target.GeometricExtents); + // the start and end param corresponds to start and end angle in radians + SOP.Interval trim = new(target.StartAngle, target.EndAngle); + SOG.Ellipse ellipse = new(plane, target.MajorRadius, target.MinorRadius, _contextStack.Current.SpeckleUnits) { - domain = new SOP.Interval(target.StartParam, target.EndParam), + domain = new(0, Math.PI * 2), + trimDomain = trim, length = target.GetDistanceAtParameter(target.EndParam), bbox = bbox }; From 2112d6946a35e48d3f870b86cf342fede1e25c1d Mon Sep 17 00:00:00 2001 From: Jedd Morgan <45512892+JR-Morgan@users.noreply.github.com> Date: Mon, 13 May 2024 12:02:27 +0100 Subject: [PATCH 178/261] CNX-9261 fallback conversions on receive arc gis (#3403) * Added fallback logic to ArcGIS * Removed throw on empty selection * Fixed warnings * don't return elements with GIS parent at any level; don't add pt to the closed polyline is already "closed" --------- Co-authored-by: KatKatKateryna --- .../Bindings/ArcGISSelectionBinding.cs | 6 --- .../Operations/Receive/HostObjectBuilder.cs | 19 ++++++-- .../AutofacArcGIS3ConverterModule.cs | 7 ++- .../ArcGISConverterToHost.cs | 40 ----------------- .../Geometry/FallbackToHostConverter.cs | 44 +++++++++++++++++++ .../MeshListToHostConverter.cs | 44 +++++++++++++++++++ ...nverter.cs => PointListToHostConverter.cs} | 0 .../ArcToHostConverter.cs | 3 +- .../EllipseToHostConverter.cs | 5 ++- .../MeshToHostConverter.cs | 31 ++----------- ...stConverter.cs => PointToHostConverter.cs} | 10 +++-- .../PolylineToHostConverter.cs | 5 ++- .../Geometry/PointSingleToHostConverter.cs | 14 ++++++ .../Utils/INonNativeFeaturesUtils.cs | 4 +- .../Utils/NonNativeFeaturesUtils.cs | 14 +++--- .../DisplayableObject.cs | 9 ++-- 16 files changed, 154 insertions(+), 101 deletions(-) delete mode 100644 DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ArcGISConverterToHost.cs create mode 100644 DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/FallbackToHostConverter.cs create mode 100644 DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/MeshListToHostConverter.cs rename DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/{MultipointListToHostConverter.cs => PointListToHostConverter.cs} (100%) rename DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/{PointSingleToHostConverter.cs => PointToHostConverter.cs} (50%) create mode 100644 DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/PointSingleToHostConverter.cs diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISSelectionBinding.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISSelectionBinding.cs index 932223ae9f..7b7d066a2a 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISSelectionBinding.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISSelectionBinding.cs @@ -2,7 +2,6 @@ using Speckle.Connectors.DUI.Bridge; using ArcGIS.Desktop.Mapping.Events; using ArcGIS.Desktop.Mapping; -using Speckle.Core.Logging; namespace Speckle.Connectors.ArcGIS.Bindings; @@ -35,11 +34,6 @@ public SelectionInfo GetSelection() selectedMembers.AddRange(mapView.GetSelectedLayers()); selectedMembers.AddRange(mapView.GetSelectedStandaloneTables()); - if (selectedMembers.Count == 0) - { - throw new SpeckleException("No data to send"); - } - List objectTypes = selectedMembers .Select(o => o.GetType().ToString().Split(".").Last()) .Distinct() diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Receive/HostObjectBuilder.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Receive/HostObjectBuilder.cs index f281752b4a..4d4caa9e7a 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Receive/HostObjectBuilder.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Receive/HostObjectBuilder.cs @@ -37,7 +37,7 @@ GraphTraversal traverseFunction _traverseFunction = traverseFunction; } - public (string, Geometry, string?) ConvertNonNativeGeometries( + public (string path, Geometry converted, string? parentId) ConvertNonNativeGeometries( Base obj, string[] path, string? parentId, @@ -86,6 +86,19 @@ private string[] GetLayerPath(TraversalContext context) return reverseOrderPath.Reverse().ToArray(); } + private bool HasGISParent(TraversalContext context) + { + List vectorLayers = context + .GetAscendantOfType() + .Where(obj => obj != context.Current) + .ToList(); + List rasterLayers = context + .GetAscendantOfType() + .Where(obj => obj != context.Current) + .ToList(); + return vectorLayers.Count + rasterLayers.Count > 0; + } + public IEnumerable Build( Base rootObject, string projectName, @@ -105,13 +118,13 @@ CancellationToken cancellationToken // POC: This is where we will define our receive strategy, or maybe later somewhere else according to some setting pass from UI? var objectsToConvert = _traverseFunction .Traverse(rootObject) - .Where(ctx => ctx.Parent?.Current is not VectorLayer && ctx.Parent?.Current is not Objects.GIS.RasterLayer) + .Where(ctx => HasGISParent(ctx) is false) .Select(ctx => (GetLayerPath(ctx), ctx.Current, ctx.Parent?.Current.id)) .ToList(); int allCount = objectsToConvert.Count; int count = 0; - Dictionary convertedGeometries = new(); + Dictionary convertedGeometries = new(); List objectIds = new(); List<(string, string)> convertedGISObjects = new(); diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3.DependencyInjection/AutofacArcGIS3ConverterModule.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3.DependencyInjection/AutofacArcGIS3ConverterModule.cs index 12683316ec..de255199a0 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3.DependencyInjection/AutofacArcGIS3ConverterModule.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3.DependencyInjection/AutofacArcGIS3ConverterModule.cs @@ -6,6 +6,7 @@ using Speckle.Autofac.DependencyInjection; using Speckle.Converters.ArcGIS3.Utils; using Speckle.Converters.Common; +using Speckle.Converters.Common.DependencyInjection.ToHost; using Speckle.Converters.Common.Objects; namespace Speckle.Converters.ArcGIS3.DependencyInjection; @@ -16,7 +17,7 @@ protected override void Load(ContainerBuilder builder) { // most things should be InstancePerLifetimeScope so we get one per operation builder.RegisterType().As().InstancePerLifetimeScope(); - builder.RegisterType().As().InstancePerLifetimeScope(); + builder.RegisterType().As().InstancePerLifetimeScope(); builder.RegisterType().As().InstancePerLifetimeScope(); builder.RegisterType().As().InstancePerLifetimeScope(); builder.RegisterType().As().InstancePerLifetimeScope(); @@ -43,5 +44,9 @@ protected override void Load(ContainerBuilder builder) .RegisterType>() .As>() .InstancePerLifetimeScope(); + builder + .RegisterType>() + .As>() + .InstancePerLifetimeScope(); } } diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ArcGISConverterToHost.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ArcGISConverterToHost.cs deleted file mode 100644 index 1c844363eb..0000000000 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ArcGISConverterToHost.cs +++ /dev/null @@ -1,40 +0,0 @@ -using Speckle.Autofac.DependencyInjection; -using Speckle.Converters.Common; -using Speckle.Converters.Common.Objects; -using Speckle.Core.Models; - -namespace Speckle.Converters.ArcGIS3; - -public class ArcGISConverterToHost : ISpeckleConverterToHost -{ - private readonly IFactory _toHost; - - public ArcGISConverterToHost(IFactory toHost) - { - _toHost = toHost; - } - - public object Convert(Base target) - { - Type type = target.GetType(); - - try - { - var objectConverter = _toHost.ResolveInstance(type.Name); - - if (objectConverter == null) - { - throw new NotSupportedException($"No conversion found for {target.GetType().Name}"); - } - - var convertedObject = objectConverter.Convert(target); - - return convertedObject; - } - catch (SpeckleConversionException e) - { - Console.WriteLine(e); - throw; // POC: Just rethrowing for now, Logs may be needed here. - } - } -} diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/FallbackToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/FallbackToHostConverter.cs new file mode 100644 index 0000000000..3eddcc8d81 --- /dev/null +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/FallbackToHostConverter.cs @@ -0,0 +1,44 @@ +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; +using Speckle.Core.Models; + +namespace Speckle.Converters.ArcGIS3.Geometry; + +[NameAndRankValue(nameof(DisplayableObject), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +public class FallbackToHostConverter : ISpeckleObjectToHostConversion, IRawConversion +{ + private readonly IRawConversion, ACG.Multipatch> _meshListConverter; + private readonly IRawConversion, ACG.Polyline> _polylineListConverter; + private readonly IRawConversion, ACG.Multipoint> _pointListConverter; + + public FallbackToHostConverter( + IRawConversion, ACG.Multipatch> meshListConverter, + IRawConversion, ACG.Polyline> polylineListConverter, + IRawConversion, ACG.Multipoint> pointListConverter + ) + { + _meshListConverter = meshListConverter; + _polylineListConverter = polylineListConverter; + _pointListConverter = pointListConverter; + } + + public object Convert(Base target) => RawConvert((DisplayableObject)target); + + public ACG.Geometry RawConvert(DisplayableObject target) + { + if (!target.displayValue.Any()) + { + throw new NotSupportedException($"Zero fallback values specified"); + } + + var first = target.displayValue[0]; + + return first switch + { + SOG.Polyline => _polylineListConverter.RawConvert(target.displayValue.Cast().ToList()), + SOG.Mesh => _meshListConverter.RawConvert(target.displayValue.Cast().ToList()), + SOG.Point => _pointListConverter.RawConvert(target.displayValue.Cast().ToList()), + _ => throw new NotSupportedException($"Found unsupported fallback geometry: {first.GetType()}") + }; + } +} diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/MeshListToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/MeshListToHostConverter.cs new file mode 100644 index 0000000000..305c1223ea --- /dev/null +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/MeshListToHostConverter.cs @@ -0,0 +1,44 @@ +using Objects.Utils; +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; + +namespace Speckle.Converters.ArcGIS3.Geometry.GisFeatureGeometriesToHost; + +public class MeshListToHostConverter : IRawConversion, ACG.Multipatch> +{ + private readonly IRawConversion _pointConverter; + + public MeshListToHostConverter(IRawConversion pointConverter) + { + _pointConverter = pointConverter; + } + + public ACG.Multipatch RawConvert(List target) + { + if (target.Count == 0) + { + throw new SpeckleConversionException("Feature contains no geometries"); + } + ACG.MultipatchBuilderEx multipatchPart = new(); + foreach (SOG.Mesh part in target) + { + part.TriangulateMesh(); + ACG.Patch newPatch = multipatchPart.MakePatch(ACG.PatchType.Triangles); + for (int i = 0; i < part.faces.Count; i++) + { + if (i % 4 == 0) + { + continue; + } + int ptIndex = part.faces[i]; + newPatch.AddPoint( + _pointConverter.RawConvert( + new SOG.Point(part.vertices[ptIndex * 3], part.vertices[ptIndex * 3 + 1], part.vertices[ptIndex * 3 + 2]) + ) + ); + } + multipatchPart.Patches.Add(newPatch); + } + return multipatchPart.ToGeometry(); + } +} diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/MultipointListToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/PointListToHostConverter.cs similarity index 100% rename from DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/MultipointListToHostConverter.cs rename to DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/PointListToHostConverter.cs diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/ArcToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/ArcToHostConverter.cs index b03999420e..635d47ecbc 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/ArcToHostConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/ArcToHostConverter.cs @@ -4,7 +4,8 @@ namespace Speckle.Converters.ArcGIS3.Geometry.ISpeckleObjectToHost; -[NameAndRankValue(nameof(SOG.Arc), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +//TODO: Ellipses don't convert correctly, see Autocad test stream +//[NameAndRankValue(nameof(SOG.Arc), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] public class CurveToHostConverter : ISpeckleObjectToHostConversion, IRawConversion { private readonly IRawConversion _pointConverter; diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/EllipseToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/EllipseToHostConverter.cs index 25e8d9c7c9..511350cd71 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/EllipseToHostConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/EllipseToHostConverter.cs @@ -1,10 +1,11 @@ -using Speckle.Converters.Common; +using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; using Speckle.Core.Models; namespace Speckle.Converters.ArcGIS3.Geometry.ISpeckleObjectToHost; -[NameAndRankValue(nameof(SOG.Ellipse), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +//TODO: Ellipses don't convert correctly, see Autocad test stream +// [NameAndRankValue(nameof(SOG.Ellipse), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] public class EllipseToHostConverter : ISpeckleObjectToHostConversion, IRawConversion { private readonly IRawConversion _pointConverter; diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/MeshToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/MeshToHostConverter.cs index 8a1f5adb62..498c51caae 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/MeshToHostConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/MeshToHostConverter.cs @@ -1,4 +1,3 @@ -using Objects.Utils; using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; using Speckle.Core.Models; @@ -8,39 +7,17 @@ namespace Speckle.Converters.ArcGIS3.Geometry.ISpeckleObjectToHost; [NameAndRankValue(nameof(SOG.Mesh), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] public class MeshToHostConverter : ISpeckleObjectToHostConversion, IRawConversion { - private readonly IRawConversion _pointConverter; + private readonly IRawConversion, ACG.Multipatch> _meshConverter; - public MeshToHostConverter(IRawConversion pointConverter) + public MeshToHostConverter(IRawConversion, ACG.Multipatch> meshConverter) { - _pointConverter = pointConverter; + _meshConverter = meshConverter; } public object Convert(Base target) => RawConvert((SOG.Mesh)target); public ACG.Multipatch RawConvert(SOG.Mesh target) { - target.TriangulateMesh(); - ACG.MultipatchBuilderEx multipatchPart = new(); - ACG.Patch newPatch = multipatchPart.MakePatch(ACG.PatchType.Triangles); - for (int i = 0; i < target.faces.Count; i++) - { - if (i % 4 == 0) - { - continue; - } - int ptIndex = target.faces[i]; - newPatch.AddPoint( - _pointConverter.RawConvert( - new SOG.Point( - target.vertices[ptIndex * 3], - target.vertices[ptIndex * 3 + 1], - target.vertices[ptIndex * 3 + 2] - ) - ) - ); - } - multipatchPart.Patches.Add(newPatch); - - return multipatchPart.ToGeometry(); + return _meshConverter.RawConvert(new List { target }); } } diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/PointSingleToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/PointToHostConverter.cs similarity index 50% rename from DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/PointSingleToHostConverter.cs rename to DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/PointToHostConverter.cs index 7c6f07a60b..3e81f2f983 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/PointSingleToHostConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/PointToHostConverter.cs @@ -5,12 +5,14 @@ namespace Speckle.Converters.ArcGIS3.Geometry.ISpeckleObjectToHost; [NameAndRankValue(nameof(SOG.Point), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class PointToHostConverter : ISpeckleObjectToHostConversion, IRawConversion +public class PointToHostConverter : ISpeckleObjectToHostConversion { - public object Convert(Base target) => RawConvert((SOG.Point)target); + private readonly IRawConversion, ACG.Multipoint> _pointConverter; - public ACG.MapPoint RawConvert(SOG.Point target) + public PointToHostConverter(IRawConversion, ACG.Multipoint> pointConverter) { - return new ACG.MapPointBuilderEx(target.x, target.y, target.z).ToGeometry(); + _pointConverter = pointConverter; } + + public object Convert(Base target) => _pointConverter.RawConvert(new List { (SOG.Point)target }); } diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/PolylineToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/PolylineToHostConverter.cs index 789512b469..8cf283f144 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/PolylineToHostConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/PolylineToHostConverter.cs @@ -18,8 +18,9 @@ public PolylineToHostConverter(IRawConversion pointConv public ACG.Polyline RawConvert(SOG.Polyline target) { - var points = target.GetPoints().Select(x => _pointConverter.RawConvert(x)).ToList(); - if (target.closed) + List originalPts = target.GetPoints(); + var points = originalPts.Select(x => _pointConverter.RawConvert(x)).ToList(); + if (target.closed && originalPts[0] != originalPts[^1]) { points.Add(points[0]); } diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/PointSingleToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/PointSingleToHostConverter.cs new file mode 100644 index 0000000000..c073945561 --- /dev/null +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/PointSingleToHostConverter.cs @@ -0,0 +1,14 @@ +using Speckle.Converters.Common.Objects; +using Speckle.Core.Models; + +namespace Speckle.Converters.ArcGIS3.Geometry; + +public class PointToHostConverter : IRawConversion +{ + public object Convert(Base target) => RawConvert((SOG.Point)target); + + public ACG.MapPoint RawConvert(SOG.Point target) + { + return new ACG.MapPointBuilderEx(target.x, target.y, target.z).ToGeometry(); + } +} diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/INonNativeFeaturesUtils.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/INonNativeFeaturesUtils.cs index 1405621f31..6ab9c32603 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/INonNativeFeaturesUtils.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/INonNativeFeaturesUtils.cs @@ -2,7 +2,7 @@ namespace Speckle.Converters.ArcGIS3.Utils; public interface INonNativeFeaturesUtils { - public List<(string, string)> WriteGeometriesToDatasets( - Dictionary convertedObjs + public List<(string parentPath, string converted)> WriteGeometriesToDatasets( + Dictionary convertedObjs ); } diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/NonNativeFeaturesUtils.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/NonNativeFeaturesUtils.cs index fe8964792c..a04d8936a9 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/NonNativeFeaturesUtils.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/NonNativeFeaturesUtils.cs @@ -34,13 +34,13 @@ public NonNativeFeaturesUtils( _contextStack = contextStack; } - public List<(string, string)> WriteGeometriesToDatasets( - Dictionary convertedObjs + public List<(string parentPath, string converted)> WriteGeometriesToDatasets( + Dictionary convertedObjs ) { List<(string, string)> result = new(); // 1. Sort features into groups by path and geom type - Dictionary, string?)> geometryGroups = new(); + Dictionary geometries, string? parentId)> geometryGroups = new(); foreach (var item in convertedObjs) { try @@ -54,12 +54,12 @@ public NonNativeFeaturesUtils( geometryGroups[parentPath] = (new List(), parentId); } - geometryGroups[parentPath].Item1.Add(geom); + geometryGroups[parentPath].geometries.Add(geom); } - catch (Exception e) when (!e.IsFatal()) + catch (Exception ex) when (!ex.IsFatal()) { // POC: report, etc. - Debug.WriteLine("conversion error happened."); + Debug.WriteLine($"conversion error happened. {ex.Message}"); } } @@ -70,7 +70,7 @@ public NonNativeFeaturesUtils( { string parentPath = item.Key; (List geomList, string? parentId) = item.Value; - ACG.GeometryType geomType = _featureClassUtils.GetGeometryTypeFromString(parentPath.Split("\\")[^1]); + ACG.GeometryType geomType = geomList[0].GeometryType; try { string converted = CreateDatasetInDatabase(geomType, geomList, parentId); diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common/DisplayableObject.cs b/DUI3-DX/Sdk/Speckle.Converters.Common/DisplayableObject.cs index ac62b9bf41..a1f2b91d5b 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common/DisplayableObject.cs +++ b/DUI3-DX/Sdk/Speckle.Converters.Common/DisplayableObject.cs @@ -13,15 +13,12 @@ public sealed class DisplayableObject : Base, IDisplayValue> { public DisplayableObject(IReadOnlyList displayValue) { - var invalidGeometries = displayValue - .Where(b => b is not (Line or Polyline or Mesh)) - .Select(b => b.GetType()) - .Distinct(); + var invalidGeometry = displayValue.FirstOrDefault(b => b is not (Line or Polyline or Mesh or Arc or Point)); - if (invalidGeometries.Any()) + if (invalidGeometry != null) { throw new ArgumentException( - $"Displayable objects should only contain simple geometries (lines, polylines, meshes) but contained {invalidGeometries}" + $"Displayable objects should only contain simple geometries (lines, polylines, meshes) but contained {invalidGeometry}" ); } From 68fc57699e8d3e3cc69bae811cb03c7aa04d2bbb Mon Sep 17 00:00:00 2001 From: KatKatKateryna <89912278+KatKatKateryna@users.noreply.github.com> Date: Mon, 13 May 2024 21:31:42 +0800 Subject: [PATCH 179/261] unfreeze empty Document State for newly created ArcGIS Project (#3404) * align DUI3 naming * Speckle (New UI) -> SpeckleNewUI to better align it with other connectors. * ArcgisDocumentStore -> DocumentModelStore * subscribe to map change * remove usings --------- Co-authored-by: Mucahit Bilal GOKER --- .../Bindings/ArcGISReceiveBinding.cs | 6 +++--- .../Bindings/ArcGISSendBinding.cs | 6 +++--- .../Bindings/BasicConnectorBinding.cs | 5 ++--- .../DependencyInjection/AutofacArcGISModule.cs | 3 ++- .../Utils/ArcGisDocumentStore.cs | 7 +++++++ 5 files changed, 17 insertions(+), 10 deletions(-) diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISReceiveBinding.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISReceiveBinding.cs index d92413b358..99c0f0ca9a 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISReceiveBinding.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISReceiveBinding.cs @@ -1,7 +1,7 @@ using Speckle.Autofac.DependencyInjection; -using Speckle.Connectors.ArcGIS.Utils; using Speckle.Connectors.DUI.Bindings; using Speckle.Connectors.DUI.Bridge; +using Speckle.Connectors.DUI.Models; using Speckle.Connectors.DUI.Models.Card; using Speckle.Connectors.Utils.Cancellation; using Speckle.Connectors.Utils.Operations; @@ -14,14 +14,14 @@ public sealed class ArcGISReceiveBinding : IReceiveBinding, ICancelable { public string Name { get; } = "receiveBinding"; private readonly CancellationManager _cancellationManager; - private readonly ArcGISDocumentStore _store; + private readonly DocumentModelStore _store; private readonly IUnitOfWorkFactory _unitOfWorkFactory; public ReceiveBindingUICommands Commands { get; } public IBridge Parent { get; } public ArcGISReceiveBinding( - ArcGISDocumentStore store, + DocumentModelStore store, IBridge parent, CancellationManager cancellationManager, IUnitOfWorkFactory unitOfWorkFactory diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISSendBinding.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISSendBinding.cs index b8abea01bd..83b59cf52d 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISSendBinding.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISSendBinding.cs @@ -6,7 +6,7 @@ using Speckle.Connectors.Utils.Cancellation; using Speckle.Core.Logging; using ICancelable = System.Reactive.Disposables.ICancelable; -using Speckle.Connectors.ArcGIS.Utils; +using Speckle.Connectors.DUI.Models; using Speckle.Connectors.DUI.Models.Card; using Speckle.Connectors.DUI.Models.Card.SendFilter; using Speckle.Connectors.DUI.Settings; @@ -19,7 +19,7 @@ public sealed class ArcGISSendBinding : ISendBinding, ICancelable public SendBindingUICommands Commands { get; } public IBridge Parent { get; } - private readonly ArcGISDocumentStore _store; + private readonly DocumentModelStore _store; private readonly IUnitOfWorkFactory _unitOfWorkFactory; // POC: unused? :D private readonly List _sendFilters; private readonly CancellationManager _cancellationManager; @@ -30,7 +30,7 @@ public sealed class ArcGISSendBinding : ISendBinding, ICancelable private HashSet ChangedObjectIds { get; set; } = new(); public ArcGISSendBinding( - ArcGISDocumentStore store, + DocumentModelStore store, IBridge parent, IEnumerable sendFilters, IUnitOfWorkFactory unitOfWorkFactory, diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/BasicConnectorBinding.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/BasicConnectorBinding.cs index 262afbd18c..fdd2057793 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/BasicConnectorBinding.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/BasicConnectorBinding.cs @@ -1,7 +1,6 @@ using System.Reflection; using ArcGIS.Desktop.Core; using Speckle.Connectors.ArcGIS.HostApp; -using Speckle.Connectors.ArcGIS.Utils; using Speckle.Connectors.DUI.Bindings; using Speckle.Connectors.DUI.Bridge; using Speckle.Connectors.DUI.Models; @@ -17,10 +16,10 @@ public class BasicConnectorBinding : IBasicConnectorBinding public IBridge Parent { get; } public BasicConnectorBindingCommands Commands { get; } - private readonly ArcGISDocumentStore _store; + private readonly DocumentModelStore _store; private readonly ArcGISSettings _settings; - public BasicConnectorBinding(ArcGISDocumentStore store, ArcGISSettings settings, IBridge parent) + public BasicConnectorBinding(DocumentModelStore store, ArcGISSettings settings, IBridge parent) { _store = store; _settings = settings; diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/DependencyInjection/AutofacArcGISModule.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/DependencyInjection/AutofacArcGISModule.cs index fdf7013f0e..78fef6c662 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/DependencyInjection/AutofacArcGISModule.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/DependencyInjection/AutofacArcGISModule.cs @@ -21,6 +21,7 @@ using Speckle.Connectors.Utils.Operations; using ArcGIS.Core.Geometry; using Speckle.Connectors.ArcGIS.Filters; +using Speckle.Connectors.DUI.Models; // POC: This is a temp reference to root object senders to tweak CI failing after having generic interfaces into common project. // This should go whenever it is aligned. @@ -41,7 +42,7 @@ protected override void Load(ContainerBuilder builder) builder.RegisterType().As().InstancePerDependency(); //TODO: Verify why we need one bridge instance per dependency. builder.RegisterType().SingleInstance(); - builder.RegisterType().SingleInstance(); + builder.RegisterType().As().SingleInstance(); // Register bindings builder.RegisterType().As().SingleInstance(); diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Utils/ArcGisDocumentStore.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Utils/ArcGisDocumentStore.cs index 0870acaa08..d5f09934e3 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Utils/ArcGisDocumentStore.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Utils/ArcGisDocumentStore.cs @@ -1,3 +1,4 @@ +using ArcGIS.Desktop.Mapping.Events; using Speckle.Connectors.DUI.Models; using Speckle.Newtonsoft.Json; @@ -9,6 +10,12 @@ public ArcGISDocumentStore(JsonSerializerSettings serializerOption) : base(serializerOption) { // POC: Subscribe here document related events like OnSave, OnClose, OnOpen etc... + ActiveMapViewChangedEvent.Subscribe(OnMapViewChanged); + } + + private void OnMapViewChanged(ActiveMapViewChangedEventArgs args) + { + OnDocumentChanged(); } public override void WriteToFile() From dd861572c3e4c4cec8cdd16e11fdbba0d932bbb7 Mon Sep 17 00:00:00 2001 From: KatKatKateryna <89912278+KatKatKateryna@users.noreply.github.com> Date: Mon, 13 May 2024 22:05:44 +0800 Subject: [PATCH 180/261] Cnx 9507 Arcgis scaling on receive (#3406) * add scaling factor on receive * fix * correct units --- .../MeshListToHostConverter.cs | 3 +++ .../Geometry/PointSingleToHostConverter.cs | 17 ++++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/MeshListToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/MeshListToHostConverter.cs index 305c1223ea..42c5df2692 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/MeshListToHostConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/MeshListToHostConverter.cs @@ -34,6 +34,9 @@ public ACG.Multipatch RawConvert(List target) newPatch.AddPoint( _pointConverter.RawConvert( new SOG.Point(part.vertices[ptIndex * 3], part.vertices[ptIndex * 3 + 1], part.vertices[ptIndex * 3 + 2]) + { + units = part.units + } ) ); } diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/PointSingleToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/PointSingleToHostConverter.cs index c073945561..b51e099727 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/PointSingleToHostConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/PointSingleToHostConverter.cs @@ -1,14 +1,29 @@ +using ArcGIS.Desktop.Mapping; +using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; +using Speckle.Core.Kits; using Speckle.Core.Models; namespace Speckle.Converters.ArcGIS3.Geometry; public class PointToHostConverter : IRawConversion { + private readonly IConversionContextStack _contextStack; + + public PointToHostConverter(IConversionContextStack contextStack) + { + _contextStack = contextStack; + } + public object Convert(Base target) => RawConvert((SOG.Point)target); public ACG.MapPoint RawConvert(SOG.Point target) { - return new ACG.MapPointBuilderEx(target.x, target.y, target.z).ToGeometry(); + double scaleFactor = Units.GetConversionFactor(target.units, _contextStack.Current.SpeckleUnits); + return new ACG.MapPointBuilderEx( + target.x * scaleFactor, + target.y * scaleFactor, + target.z * scaleFactor + ).ToGeometry(); } } From 6f69997fba18b68828590785b4625b0a19f98920 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?O=C4=9Fuzhan=20Koral?= <45078678+oguzhankoral@users.noreply.github.com> Date: Tue, 14 May 2024 13:58:40 +0300 Subject: [PATCH 181/261] CNX-9499 Save model cards into metadata and read/write on map init/switch (#3412) * Save model cards into metadata and read/write on map init/switch * Do not mess existing metadata --- .../Utils/ArcGisDocumentStore.cs | 93 ++++++++++++++++++- 1 file changed, 88 insertions(+), 5 deletions(-) diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Utils/ArcGisDocumentStore.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Utils/ArcGisDocumentStore.cs index d5f09934e3..c6c3853b00 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Utils/ArcGisDocumentStore.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Utils/ArcGisDocumentStore.cs @@ -1,5 +1,10 @@ +using System.Xml.Linq; +using ArcGIS.Desktop.Core.Events; +using ArcGIS.Desktop.Framework.Threading.Tasks; +using ArcGIS.Desktop.Mapping; using ArcGIS.Desktop.Mapping.Events; using Speckle.Connectors.DUI.Models; +using Speckle.Connectors.DUI.Models.Card; using Speckle.Newtonsoft.Json; namespace Speckle.Connectors.ArcGIS.Utils; @@ -9,22 +14,100 @@ public class ArcGISDocumentStore : DocumentModelStore public ArcGISDocumentStore(JsonSerializerSettings serializerOption) : base(serializerOption) { - // POC: Subscribe here document related events like OnSave, OnClose, OnOpen etc... ActiveMapViewChangedEvent.Subscribe(OnMapViewChanged); + ProjectSavingEvent.Subscribe(OnProjectSaving); + ProjectClosingEvent.Subscribe(OnProjectClosing); } + private Task OnProjectClosing(ProjectClosingEventArgs arg) + { + if (MapView.Active is null) + { + return Task.CompletedTask; + } + + WriteToFile(); + return Task.CompletedTask; + } + + private Task OnProjectSaving(ProjectEventArgs arg) + { + if (MapView.Active is null) + { + return Task.CompletedTask; + } + + WriteToFile(); + return Task.CompletedTask; + } + + /// + /// On map view switch, this event trigger twice, first for outgoing view, second for incoming view. + /// private void OnMapViewChanged(ActiveMapViewChangedEventArgs args) { - OnDocumentChanged(); + if (args.OutgoingView is not null) + { + WriteToFileWithMap(args.OutgoingView.Map); + } + + if (args.IncomingView is not null) + { + IsDocumentInit = true; + ReadFromFile(); + OnDocumentChanged(); + } } - public override void WriteToFile() + private void WriteToFileWithMap(Map map) { - // Implement the logic to save it to file + QueuedTask.Run(() => + { + // Read existing metadata - To prevent messing existing metadata. 🤞 Hope other add-in developers will do same :D + var existingMetadata = map.GetMetadata(); + + // Parse existing metadata + XDocument existingXmlDocument = !string.IsNullOrEmpty(existingMetadata) + ? XDocument.Parse(existingMetadata) + : new XDocument(new XElement("metadata")); + + string serializedModels = Serialize(); + + XElement xmlModelCards = new("SpeckleModelCards", serializedModels); + + // Check if SpeckleModelCards element already exists at root and update it + var speckleModelCardsElement = existingXmlDocument.Root?.Element("SpeckleModelCards"); + if (speckleModelCardsElement != null) + { + speckleModelCardsElement.ReplaceWith(xmlModelCards); + } + else + { + existingXmlDocument.Root?.Add(xmlModelCards); + } + + map.SetMetadata(existingXmlDocument.ToString()); + }); } + public override void WriteToFile() => WriteToFileWithMap(MapView.Active.Map); + public override void ReadFromFile() { - // Implement the logic to read it from file + Map map = MapView.Active.Map; + QueuedTask.Run(() => + { + var metadata = map.GetMetadata(); + var root = XDocument.Parse(metadata).Root; + var element = root?.Element("SpeckleModelCards"); + if (element is null) + { + Models = new List(); + return; + } + + string modelsString = element.Value; + Models = Deserialize(modelsString); + }); } } From 2d32d5c7f49976cf650539d6b3ae7e32548b7243 Mon Sep 17 00:00:00 2001 From: Dimitrie Stefanescu Date: Tue, 14 May 2024 13:16:03 +0100 Subject: [PATCH 182/261] Cnx 9487 persist model card state to host file on any change of model card state (#3407) * feat(dui3/rhino): persists changes to state on update * feat(dui3): arcgis compat changes seems arcgis was not implementing model persistatance yet, so i'm not going to dig too deep into it * feat(dui3): ensures proper events for collection changed and implements acad * feat(dui3): revit implementation for save on change * feat(dui3): last bits and bobs for auto saving stream cards (arcgis scaffold) * chore(dui3): removed unnecessary using statement * fix(dui3): potential fix for the revit mouse dragged window issue, thx 2 ogu for the inspiration!!! * Align ArcGIS * chore(dui3): cleanup revit unused func as per review * fix(dui3): revert unrelated unneeded changes * fix(dui3): removes unnecessary using --------- Co-authored-by: oguzhankoral --- .../Bindings/ArcGISSendBinding.cs | 2 +- .../Bindings/BasicConnectorBinding.cs | 12 +-- .../AutofacArcGISModule.cs | 6 +- .../Utils/ArcGisDocumentStore.cs | 25 +++---- .../Bindings/AutocadBasicConnectorBinding.cs | 12 +-- .../Bindings/AutocadSendBinding.cs | 2 +- .../AutofacAutocadModule.cs | 6 +- .../HostApp/AutocadDocumentModelStore.cs | 27 ++----- .../Bindings/BasicConnectorBindingRevit.cs | 18 +---- .../Bindings/SendBinding.cs | 2 +- .../DependencyInjection/AutofacUIModule.cs | 6 +- .../HostApp/RevitDocumentStore.cs | 67 ++++++++--------- .../Bindings/RhinoBasicConnectorBinding.cs | 12 +-- .../Bindings/RhinoSendBinding.cs | 2 +- .../DependencyInjection/AutofacRhinoModule.cs | 6 +- .../HostApp/RhinoDocumentStore.cs | 9 +-- .../Models/DocumentModelStore.cs | 73 +++++++++++++++---- 17 files changed, 146 insertions(+), 141 deletions(-) diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISSendBinding.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISSendBinding.cs index 83b59cf52d..716d7d8098 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISSendBinding.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISSendBinding.cs @@ -113,7 +113,7 @@ public async Task Send(string modelCardId) /// private void RunExpirationChecks() { - List senders = _store.GetSenders(); + var senders = _store.GetSenders(); List expiredSenderIds = new(); foreach (var sender in senders) diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/BasicConnectorBinding.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/BasicConnectorBinding.cs index fdd2057793..cc13fe0aed 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/BasicConnectorBinding.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/BasicConnectorBinding.cs @@ -51,17 +51,9 @@ public DocumentInfo GetDocumentInfo() => public void AddModel(ModelCard model) => _store.Models.Add(model); - public void UpdateModel(ModelCard model) - { - int idx = _store.Models.FindIndex(m => model.ModelCardId == m.ModelCardId); - _store.Models[idx] = model; - } + public void UpdateModel(ModelCard model) => _store.UpdateModel(model); - public void RemoveModel(ModelCard model) - { - int index = _store.Models.FindIndex(m => m.ModelCardId == model.ModelCardId); - _store.Models.RemoveAt(index); - } + public void RemoveModel(ModelCard model) => _store.RemoveModel(model); public void HighlightModel(string modelCardId) => throw new System.NotImplementedException(); } diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/DependencyInjection/AutofacArcGISModule.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/DependencyInjection/AutofacArcGISModule.cs index 78fef6c662..6e8e2e9757 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/DependencyInjection/AutofacArcGISModule.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/DependencyInjection/AutofacArcGISModule.cs @@ -42,7 +42,11 @@ protected override void Load(ContainerBuilder builder) builder.RegisterType().As().InstancePerDependency(); //TODO: Verify why we need one bridge instance per dependency. builder.RegisterType().SingleInstance(); - builder.RegisterType().As().SingleInstance(); + builder + .RegisterType() + .As() + .SingleInstance() + .WithParameter("writeToFileOnChange", true); // Register bindings builder.RegisterType().As().SingleInstance(); diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Utils/ArcGisDocumentStore.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Utils/ArcGisDocumentStore.cs index c6c3853b00..d91949b6c2 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Utils/ArcGisDocumentStore.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Utils/ArcGisDocumentStore.cs @@ -4,15 +4,14 @@ using ArcGIS.Desktop.Mapping; using ArcGIS.Desktop.Mapping.Events; using Speckle.Connectors.DUI.Models; -using Speckle.Connectors.DUI.Models.Card; using Speckle.Newtonsoft.Json; namespace Speckle.Connectors.ArcGIS.Utils; public class ArcGISDocumentStore : DocumentModelStore { - public ArcGISDocumentStore(JsonSerializerSettings serializerOption) - : base(serializerOption) + public ArcGISDocumentStore(JsonSerializerSettings serializerOption, bool writeToFileOnChange) + : base(serializerOption, writeToFileOnChange) { ActiveMapViewChangedEvent.Subscribe(OnMapViewChanged); ProjectSavingEvent.Subscribe(OnProjectSaving); @@ -46,21 +45,19 @@ private Task OnProjectSaving(ProjectEventArgs arg) /// private void OnMapViewChanged(ActiveMapViewChangedEventArgs args) { - if (args.OutgoingView is not null) + if (args.IncomingView is null) { - WriteToFileWithMap(args.OutgoingView.Map); + return; } - if (args.IncomingView is not null) - { - IsDocumentInit = true; - ReadFromFile(); - OnDocumentChanged(); - } + IsDocumentInit = true; + ReadFromFile(); + OnDocumentChanged(); } - private void WriteToFileWithMap(Map map) + public override void WriteToFile() { + Map map = MapView.Active.Map; QueuedTask.Run(() => { // Read existing metadata - To prevent messing existing metadata. 🤞 Hope other add-in developers will do same :D @@ -90,8 +87,6 @@ private void WriteToFileWithMap(Map map) }); } - public override void WriteToFile() => WriteToFileWithMap(MapView.Active.Map); - public override void ReadFromFile() { Map map = MapView.Active.Map; @@ -102,7 +97,7 @@ public override void ReadFromFile() var element = root?.Element("SpeckleModelCards"); if (element is null) { - Models = new List(); + Models = new(); return; } diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadBasicConnectorBinding.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadBasicConnectorBinding.cs index 81a9c6356b..6cfa96caac 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadBasicConnectorBinding.cs +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadBasicConnectorBinding.cs @@ -64,17 +64,9 @@ public DocumentInfo GetDocumentInfo() public void AddModel(ModelCard model) => _store.Models.Add(model); - public void UpdateModel(ModelCard model) - { - int idx = _store.Models.FindIndex(m => model.ModelCardId == m.ModelCardId); - _store.Models[idx] = model; - } + public void UpdateModel(ModelCard model) => _store.UpdateModel(model); - public void RemoveModel(ModelCard model) - { - int index = _store.Models.FindIndex(m => m.ModelCardId == model.ModelCardId); - _store.Models.RemoveAt(index); - } + public void RemoveModel(ModelCard model) => _store.RemoveModel(model); public void HighlightModel(string modelCardId) { diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadSendBinding.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadSendBinding.cs index 05ca5806bd..55ebece9d7 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadSendBinding.cs +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadSendBinding.cs @@ -89,7 +89,7 @@ private void OnChangeChangedObjectIds(DBObject dBObject) private void RunExpirationChecks() { - List senders = _store.GetSenders(); + var senders = _store.GetSenders(); string[] objectIdsList = ChangedObjectIds.ToArray(); List expiredSenderIds = new(); diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/DependencyInjection/AutofacAutocadModule.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/DependencyInjection/AutofacAutocadModule.cs index da0c3fb652..7acc0979eb 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/DependencyInjection/AutofacAutocadModule.cs +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/DependencyInjection/AutofacAutocadModule.cs @@ -43,7 +43,11 @@ protected override void Load(ContainerBuilder builder) builder.RegisterType().As().SingleInstance(); builder.RegisterType().InstancePerDependency(); builder.RegisterInstance(new AutocadDocumentManager()); // TODO: Dependent to TransactionContext, can be moved to AutocadContext - builder.RegisterType().As().SingleInstance(); + builder + .RegisterType() + .As() + .SingleInstance() + .WithParameter("writeToFileOnChange", true); builder.RegisterType().SingleInstance(); builder.RegisterType().SingleInstance(); builder.RegisterType().SingleInstance(); diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/AutocadDocumentModelStore.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/AutocadDocumentModelStore.cs index f2d2f00bfc..b7338ed775 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/AutocadDocumentModelStore.cs +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/AutocadDocumentModelStore.cs @@ -1,5 +1,4 @@ using Speckle.Connectors.DUI.Models; -using Speckle.Connectors.DUI.Models.Card; using Speckle.Newtonsoft.Json; namespace Speckle.Connectors.Autocad.HostApp; @@ -12,9 +11,10 @@ public class AutocadDocumentStore : DocumentModelStore public AutocadDocumentStore( JsonSerializerSettings jsonSerializerSettings, - AutocadDocumentManager autocadDocumentManager + AutocadDocumentManager autocadDocumentManager, + bool writeToFileOnChange ) - : base(jsonSerializerSettings) + : base(jsonSerializerSettings, writeToFileOnChange) { _autocadDocumentManager = autocadDocumentManager; _previousDocName = _nullDocumentName; @@ -29,9 +29,6 @@ AutocadDocumentManager autocadDocumentManager OnDocChangeInternal(Application.DocumentManager.MdiActiveDocument); } - // Whenever we switch document, it will be triggered for existing one - Application.DocumentManager.DocumentToBeDeactivated += (_, _) => WriteToFile(); - Application.DocumentManager.DocumentToBeDestroyed += (_, _) => WriteToFile(); Application.DocumentManager.DocumentActivated += (_, e) => OnDocChangeInternal(e.Document); // since below event triggered as secondary, it breaks the logic in OnDocChangeInternal function, leaving it here for now. @@ -39,12 +36,6 @@ AutocadDocumentManager autocadDocumentManager // OnDocChangeInternal((Document)args.DocumentWindow.Document); } - /// - /// Tracks whether the doc has been subscribed to save events. - /// POC: two separate docs can have the same name, this is a brittle implementation - should be correlated with file location. - /// - private readonly List _saveToDocSubTracker = new(); - private void OnDocChangeInternal(Document doc) { var currentDocName = doc != null ? doc.Name : _nullDocumentName; @@ -53,22 +44,14 @@ private void OnDocChangeInternal(Document doc) return; } - _previousDocName = doc != null ? doc.Name : _nullDocumentName; - - if (doc != null && !_saveToDocSubTracker.Contains(doc.Name)) - { - doc.BeginDocumentClose += (_, _) => WriteToFile(); - doc.Database.BeginSave += (_, _) => WriteToFile(); - _saveToDocSubTracker.Add(doc.Name); - } - + _previousDocName = currentDocName; ReadFromFile(); OnDocumentChanged(); } public override void ReadFromFile() { - Models = new List(); + Models = new(); // POC: Will be addressed to move it into AutocadContext! Document doc = Application.DocumentManager.MdiActiveDocument; diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/BasicConnectorBindingRevit.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/BasicConnectorBindingRevit.cs index 92d5e10cac..5dd7e4390b 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/BasicConnectorBindingRevit.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/BasicConnectorBindingRevit.cs @@ -34,6 +34,7 @@ RevitContext revitContext _revitContext = revitContext; _revitSettings = revitSettings; Commands = new BasicConnectorBindingCommands(parent); + // POC: event binding? _store.DocumentChanged += (_, _) => { @@ -80,22 +81,11 @@ public DocumentInfo GetDocumentInfo() public DocumentModelStore GetDocumentState() => _store; - public void AddModel(ModelCard model) - { - _store.Models.Add(model); - } + public void AddModel(ModelCard model) => _store.Models.Add(model); - public void UpdateModel(ModelCard model) - { - int idx = _store.Models.FindIndex(m => model.ModelCardId == m.ModelCardId); - _store.Models[idx] = model; - } + public void UpdateModel(ModelCard model) => _store.UpdateModel(model); - public void RemoveModel(ModelCard model) - { - int index = _store.Models.FindIndex(m => m.ModelCardId == model.ModelCardId); - _store.Models.RemoveAt(index); - } + public void RemoveModel(ModelCard model) => _store.RemoveModel(model); public void HighlightModel(string modelCardId) { diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SendBinding.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SendBinding.cs index 324d1a0a47..2fcd4e3b43 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SendBinding.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SendBinding.cs @@ -190,7 +190,7 @@ private void DocChangeHandler(Autodesk.Revit.DB.Events.DocumentChangedEventArgs private void RunExpirationChecks() { - List senders = Store.GetSenders(); + var senders = Store.GetSenders(); string[] objectIdsList = ChangedObjectIds.ToArray(); List expiredSenderIds = new(); diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/AutofacUIModule.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/AutofacUIModule.cs index a5a9494d03..4245804195 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/AutofacUIModule.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/AutofacUIModule.cs @@ -59,7 +59,11 @@ protected override void Load(ContainerBuilder builder) builder.RegisterType().As().InstancePerDependency(); // register - builder.RegisterType().As().SingleInstance(); + builder + .RegisterType() + .As() + .SingleInstance() + .WithParameter("writeToFileOnChange", true); // Storage Schema builder.RegisterType().InstancePerLifetimeScope(); diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/RevitDocumentStore.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/RevitDocumentStore.cs index 2fc366a751..8c3777fc62 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/RevitDocumentStore.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/RevitDocumentStore.cs @@ -3,8 +3,9 @@ using Autodesk.Revit.DB.ExtensibleStorage; using Autodesk.Revit.UI; using Autodesk.Revit.UI.Events; +using Revit.Async; using Speckle.Connectors.DUI.Models; -using Speckle.Connectors.DUI.Models.Card; +using Speckle.Connectors.Revit.Plugin; using Speckle.Converters.RevitShared.Helpers; using Speckle.Core.Logging; using Speckle.Newtonsoft.Json; @@ -18,32 +19,34 @@ internal class RevitDocumentStore : DocumentModelStore private static readonly Guid s_revitDocumentStoreId = new("D35B3695-EDC9-4E15-B62A-D3FC2CB83FA3"); private readonly RevitContext _revitContext; + private readonly IRevitIdleManager _idleManager; private readonly DocumentModelStorageSchema _documentModelStorageSchema; private readonly IdStorageSchema _idStorageSchema; public RevitDocumentStore( + IRevitIdleManager idleManager, RevitContext revitContext, JsonSerializerSettings serializerSettings, DocumentModelStorageSchema documentModelStorageSchema, - IdStorageSchema idStorageSchema + IdStorageSchema idStorageSchema, + bool writeToFileOnChange ) - : base(serializerSettings) + : base(serializerSettings, writeToFileOnChange) { + _idleManager = idleManager; _revitContext = revitContext; _documentModelStorageSchema = documentModelStorageSchema; _idStorageSchema = idStorageSchema; UIApplication uiApplication = _revitContext.UIApplication; - uiApplication.ApplicationClosing += (_, _) => WriteToFile(); // POC: Not sure why we would need it since we have save and clos events - uiApplication.Application.DocumentSaving += (_, _) => WriteToFile(); - uiApplication.Application.DocumentSavingAs += (_, _) => WriteToFile(); - uiApplication.Application.DocumentSynchronizingWithCentral += (_, _) => WriteToFile(); // POC: Not sure why we have it uiApplication.ViewActivated += OnViewActivated; uiApplication.Application.DocumentOpening += (_, _) => IsDocumentInit = false; uiApplication.Application.DocumentOpened += (_, _) => IsDocumentInit = false; + Models.CollectionChanged += (_, _) => WriteToFile(); + // There is no event that we can hook here for double-click file open... // It is kind of harmless since we create this object as "SingleInstance". ReadFromFile(); @@ -66,44 +69,42 @@ private void OnViewActivated(object sender, ViewActivatedEventArgs e) return; } - if (e.PreviousActiveView?.Document != null) - { - WriteToFileWithDoc(e.PreviousActiveView.Document); - } - IsDocumentInit = true; - ReadFromFile(); - OnDocumentChanged(); + _idleManager.SubscribeToIdle(() => + { + ReadFromFile(); + OnDocumentChanged(); + }); } - private void WriteToFileWithDoc(Document doc) + public override void WriteToFile() { - // POC: this can happen? + var doc = _revitContext.UIApplication?.ActiveUIDocument.Document; + // POC: this can happen? A: Not really, imho (dim) if (doc == null) { return; } - string serializedModels = Serialize(); - - using Transaction t = new(doc, "Speckle Write State"); - t.Start(); - using DataStorage ds = GetSettingsDataStorage(doc) ?? DataStorage.Create(doc); + RevitTask.RunAsync(() => + { + using Transaction t = new(doc, "Speckle Write State"); + t.Start(); + using DataStorage ds = GetSettingsDataStorage(doc) ?? DataStorage.Create(doc); - using Entity stateEntity = new(_documentModelStorageSchema.GetSchema()); - // string serializedModels = Serialize(); - stateEntity.Set("contents", serializedModels); + using Entity stateEntity = new(_documentModelStorageSchema.GetSchema()); + string serializedModels = Serialize(); + stateEntity.Set("contents", serializedModels); - using Entity idEntity = new(_idStorageSchema.GetSchema()); - idEntity.Set("Id", s_revitDocumentStoreId); + using Entity idEntity = new(_idStorageSchema.GetSchema()); + idEntity.Set("Id", s_revitDocumentStoreId); - ds.SetEntity(idEntity); - ds.SetEntity(stateEntity); - t.Commit(); + ds.SetEntity(idEntity); + ds.SetEntity(stateEntity); + t.Commit(); + }); } - public override void WriteToFile() => WriteToFileWithDoc(_revitContext.UIApplication.ActiveUIDocument.Document); - public override void ReadFromFile() { try @@ -111,7 +112,7 @@ public override void ReadFromFile() Entity stateEntity = GetSpeckleEntity(_revitContext.UIApplication?.ActiveUIDocument.Document); if (stateEntity == null || !stateEntity.IsValid()) { - Models = new List(); + Models = new(); return; } @@ -120,7 +121,7 @@ public override void ReadFromFile() } catch (Exception ex) when (!ex.IsFatal()) { - Models = new List(); + Models = new(); Debug.WriteLine(ex.Message); // POC: Log here error and notify UI that cards not read succesfully } } diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoBasicConnectorBinding.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoBasicConnectorBinding.cs index 5aad7b236d..e735b0c4b4 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoBasicConnectorBinding.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoBasicConnectorBinding.cs @@ -52,17 +52,9 @@ public DocumentInfo GetDocumentInfo() => public void AddModel(ModelCard model) => _store.Models.Add(model); - public void UpdateModel(ModelCard model) - { - int idx = _store.Models.FindIndex(m => model.ModelCardId == m.ModelCardId); - _store.Models[idx] = model; - } + public void UpdateModel(ModelCard model) => _store.UpdateModel(model); - public void RemoveModel(ModelCard model) - { - int index = _store.Models.FindIndex(m => m.ModelCardId == model.ModelCardId); - _store.Models.RemoveAt(index); - } + public void RemoveModel(ModelCard model) => _store.RemoveModel(model); public void HighlightModel(string modelCardId) { diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSendBinding.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSendBinding.cs index 8bdcf04817..d6ff227a0a 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSendBinding.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSendBinding.cs @@ -202,7 +202,7 @@ private void OnSendOperationProgress(string modelCardId, string status, double? /// private void RunExpirationChecks() { - List senders = _store.GetSenders(); + var senders = _store.GetSenders(); string[] objectIdsList = ChangedObjectIds.ToArray(); List expiredSenderIds = new(); diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/AutofacRhinoModule.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/AutofacRhinoModule.cs index 2eaba3d714..286b1e2c59 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/AutofacRhinoModule.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/AutofacRhinoModule.cs @@ -45,7 +45,11 @@ protected override void Load(ContainerBuilder builder) // Register other connector specific types builder.RegisterType().As().SingleInstance(); - builder.RegisterType().As().SingleInstance(); + builder + .RegisterType() + .As() + .SingleInstance() + .WithParameter("writeToFileOnChange", true); builder.RegisterType().SingleInstance(); // Register bindings diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/RhinoDocumentStore.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/RhinoDocumentStore.cs index 4bff9a6b43..045338695d 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/RhinoDocumentStore.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/RhinoDocumentStore.cs @@ -1,6 +1,5 @@ using Rhino; using Speckle.Connectors.DUI.Models; -using Speckle.Connectors.DUI.Models.Card; using Speckle.Newtonsoft.Json; namespace Speckle.Connectors.Rhino7.HostApp; @@ -10,11 +9,9 @@ public class RhinoDocumentStore : DocumentModelStore private const string SPECKLE_KEY = "Speckle_DUI3"; public override bool IsDocumentInit { get; set; } = true; // Note: because of rhino implementation details regarding expiry checking of sender cards. - public RhinoDocumentStore(JsonSerializerSettings jsonSerializerSettings) - : base(jsonSerializerSettings) + public RhinoDocumentStore(JsonSerializerSettings jsonSerializerSettings, bool writeToFileOnChange) + : base(jsonSerializerSettings, writeToFileOnChange) { - RhinoDoc.BeginSaveDocument += (_, _) => WriteToFile(); - RhinoDoc.CloseDocument += (_, _) => WriteToFile(); RhinoDoc.BeginOpenDocument += (_, _) => IsDocumentInit = false; RhinoDoc.EndOpenDocument += (_, e) => { @@ -52,7 +49,7 @@ public override void ReadFromFile() string stateString = RhinoDoc.ActiveDoc.Strings.GetValue(SPECKLE_KEY, SPECKLE_KEY); if (stateString == null) { - Models = new List(); + Models = new(); return; } Models = Deserialize(stateString); diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/DocumentModelStore.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/DocumentModelStore.cs index 673a9c3d00..2885d42b5e 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/DocumentModelStore.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/DocumentModelStore.cs @@ -1,5 +1,5 @@ +using System.Collections.ObjectModel; using Speckle.Connectors.DUI.Utils; -using Speckle.Connectors.DUI.Objects; using Speckle.Newtonsoft.Json; using Speckle.Connectors.DUI.Models.Card; @@ -8,17 +8,46 @@ namespace Speckle.Connectors.DUI.Models; /// /// Encapsulates the state Speckle needs to persist in the host app's document. /// -public abstract class DocumentModelStore : DiscriminatedObject +public abstract class DocumentModelStore { - public List SpeckleHostObjects { get; set; } = new List(); + private ObservableCollection _models = new(); - public List Models { get; set; } = new List(); + /// + /// Stores all the model cards in the current document/file. + /// + public ObservableCollection Models + { + get => _models; + protected set + { + _models = value; + RegisterWriteOnChangeEvent(); + } + } private readonly JsonSerializerSettings _serializerOptions; - protected DocumentModelStore(JsonSerializerSettings serializerOptions) + private readonly bool _writeToFileOnChange; + + /// + /// Base host app state class that controls the storage of the models in the file. + /// + /// our custom serialiser that should be globally DI'ed in. + /// Whether to store the models state in the file on any change. Defaults to false out of caution, but it's recommended to set to true, unless severe host app limitations. + protected DocumentModelStore(JsonSerializerSettings serializerOptions, bool writeToFileOnChange = false) { _serializerOptions = serializerOptions; + _writeToFileOnChange = writeToFileOnChange; + + RegisterWriteOnChangeEvent(); + } + + private void RegisterWriteOnChangeEvent() + { + if (_writeToFileOnChange) + { + _models.CollectionChanged += (_, _) => WriteToFile(); + } } /// @@ -30,21 +59,33 @@ protected DocumentModelStore(JsonSerializerSettings serializerOptions) public virtual bool IsDocumentInit { get; set; } // TODO: not sure about this, throwing an exception, needs some thought... + // Further note (dim): If we reach to the stage of throwing an exception here because a model is not found, there's a huge misalignment between the UI's list of model cards and the host app's. + // In theory this should never really happen, but if it does public ModelCard GetModelById(string id) { var model = Models.First(model => model.ModelCardId == id) ?? throw new ModelNotFoundException(); return model; } + public void UpdateModel(ModelCard model) + { + int idx = Models.ToList().FindIndex(m => model.ModelCardId == m.ModelCardId); + Models[idx] = model; + } + + public void RemoveModel(ModelCard model) + { + int index = Models.ToList().FindIndex(m => m.ModelCardId == model.ModelCardId); + Models.RemoveAt(index); + } + protected void OnDocumentChanged() => DocumentChanged?.Invoke(this, EventArgs.Empty); - // POC: why not IEnumerable? - public List GetSenders() => - Models.Where(model => model.TypeDiscriminator == nameof(SenderModelCard)).Cast().ToList(); + public IEnumerable GetSenders() => + Models.Where(model => model.TypeDiscriminator == nameof(SenderModelCard)).Cast(); - // POC: why not IEnumerable? - public List GetReceivers() => - Models.Where(model => model.TypeDiscriminator == nameof(ReceiverModelCard)).Cast().ToList(); + public IEnumerable GetReceivers() => + Models.Where(model => model.TypeDiscriminator == nameof(ReceiverModelCard)).Cast(); protected string Serialize() { @@ -52,12 +93,18 @@ protected string Serialize() } // POC: this seemms more like a IModelsDeserializer?, seems disconnected from this class - protected List Deserialize(string models) + protected ObservableCollection Deserialize(string models) { - return JsonConvert.DeserializeObject>(models, _serializerOptions); + return JsonConvert.DeserializeObject>(models, _serializerOptions); } + /// + /// Implement this method according to the host app's specific ways of storing custom data in its file. + /// public abstract void WriteToFile(); + /// + /// Implement this method according to the host app's specific ways of reading custom data from its file. + /// public abstract void ReadFromFile(); } From 879b1ea43e7b7cc8444da18f545762b3e2713f3c Mon Sep 17 00:00:00 2001 From: Adam Hathcock Date: Tue, 14 May 2024 14:38:06 +0100 Subject: [PATCH 183/261] merge fixes --- .../Speckle.Connectors.ArcGIS3/Utils/ArcGisDocumentStore.cs | 3 ++- .../HostApp/AutocadDocumentModelStore.cs | 1 + .../HostApp/RevitDocumentStore.cs | 3 ++- .../DUI3/Speckle.Connectors.DUI/Models/DocumentModelStore.cs | 2 +- 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Utils/ArcGisDocumentStore.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Utils/ArcGisDocumentStore.cs index d91949b6c2..02260acc2e 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Utils/ArcGisDocumentStore.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Utils/ArcGisDocumentStore.cs @@ -4,6 +4,7 @@ using ArcGIS.Desktop.Mapping; using ArcGIS.Desktop.Mapping.Events; using Speckle.Connectors.DUI.Models; +using Speckle.Connectors.Utils; using Speckle.Newtonsoft.Json; namespace Speckle.Connectors.ArcGIS.Utils; @@ -102,7 +103,7 @@ public override void ReadFromFile() } string modelsString = element.Value; - Models = Deserialize(modelsString); + Models = Deserialize(modelsString).NotNull(); }); } } diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/AutocadDocumentModelStore.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/AutocadDocumentModelStore.cs index ac5eb96a17..aca2df3076 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/AutocadDocumentModelStore.cs +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/AutocadDocumentModelStore.cs @@ -1,4 +1,5 @@ using Speckle.Connectors.DUI.Models; +using Speckle.Connectors.Utils; using Speckle.Newtonsoft.Json; namespace Speckle.Connectors.Autocad.HostApp; diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/RevitDocumentStore.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/RevitDocumentStore.cs index 2919728f7d..920f195226 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/RevitDocumentStore.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/RevitDocumentStore.cs @@ -6,6 +6,7 @@ using Revit.Async; using Speckle.Connectors.DUI.Models; using Speckle.Connectors.Revit.Plugin; +using Speckle.Connectors.Utils; using Speckle.Converters.RevitShared.Helpers; using Speckle.Core.Logging; using Speckle.Newtonsoft.Json; @@ -38,7 +39,7 @@ bool writeToFileOnChange _documentModelStorageSchema = documentModelStorageSchema; _idStorageSchema = idStorageSchema; - UIApplication uiApplication = _revitContext.UIApplication; + UIApplication uiApplication = _revitContext.UIApplication.NotNull(); uiApplication.ViewActivated += OnViewActivated; diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/DocumentModelStore.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/DocumentModelStore.cs index 0a7319c18e..65de41e5b8 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/DocumentModelStore.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/DocumentModelStore.cs @@ -93,7 +93,7 @@ protected string Serialize() } // POC: this seemms more like a IModelsDeserializer?, seems disconnected from this class - protected ObservableCollection Deserialize(string models) + protected ObservableCollection? Deserialize(string models) { return JsonConvert.DeserializeObject>(models, _serializerOptions); } From 8077906d3628df8a77c66f3a56c88fb441b1be5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?O=C4=9Fuzhan=20Koral?= <45078678+oguzhankoral@users.noreply.github.com> Date: Wed, 15 May 2024 19:13:07 +0300 Subject: [PATCH 184/261] CNX-9509 RHN opening up plugin panel again results in error (#3421) * Clear WpfHost.Child on panel close * Remove dup ServerTransport registration * Fix behavioral difference on closing Rhino Panels --- .../DependencyInjection/AutofacRhinoModule.cs | 1 - .../HostApp/SpeckleRhinoPanelHost.cs | 36 +++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/AutofacRhinoModule.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/AutofacRhinoModule.cs index 286b1e2c59..33e848d795 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/AutofacRhinoModule.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/AutofacRhinoModule.cs @@ -63,7 +63,6 @@ protected override void Load(ContainerBuilder builder) // binding dependencies builder.RegisterType().InstancePerDependency(); - builder.RegisterType().As().InstancePerDependency(); // register send filters builder.RegisterType().As().InstancePerDependency(); diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/SpeckleRhinoPanelHost.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/SpeckleRhinoPanelHost.cs index d906161197..1852a8e1e5 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/SpeckleRhinoPanelHost.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/SpeckleRhinoPanelHost.cs @@ -1,4 +1,7 @@ using System.Runtime.InteropServices; +using System.Windows; +using System.Windows.Controls; +using Rhino.UI; using Speckle.Connectors.DUI.WebView; using Speckle.Connectors.Rhino7.Plugin; @@ -8,10 +11,43 @@ namespace Speckle.Connectors.Rhino7.HostApp; public class SpeckleRhinoPanelHost : RhinoWindows.Controls.WpfElementHost { private readonly uint _docSn; + private readonly DUI3ControlWebView? _webView; public SpeckleRhinoPanelHost(uint docSn) : base(SpeckleConnectorsRhino7Plugin.Instance.Container?.Resolve(), null) { _docSn = docSn; + _webView = SpeckleConnectorsRhino7Plugin.Instance.Container?.Resolve(); + Panels.Closed += PanelsOnClosed; + } + + private void PanelsOnClosed(object sender, PanelEventArgs e) + { + if (e.PanelId == typeof(SpeckleRhinoPanelHost).GUID) + { + // This check comes from behavioral difference on closing Rhino Panels. + // IsPanelVisible returns; + // - True, when docked Panel closed from the list on right click on panel tab, + // whenever it is closed with this way, Rhino.Panels tries to reinit this object and expect the different UIElement, that's why we disconnect Child. + // - False, when detached Panel is closed by 'X' close button. + // whenever it is closed with this way, Rhino.Panels don't create this object, that's why we do not disconnect Child UIElement. + if (!Panels.IsPanelVisible(typeof(SpeckleRhinoPanelHost).GUID)) + { + return; + } + + // Unsubscribe from the event to prevent growing registrations. + Panels.Closed -= PanelsOnClosed; + + // Disconnect UIElement from WpfElementHost. Otherwise, we can't reinit panel with same DUI3ControlWebView + if (_webView != null) + { + // Since WpfHost inherited from Border, find the parent as border and set null it's Child. + if (LogicalTreeHelper.GetParent(_webView) is Border border) + { + border.Child = null; + } + } + } } } From a385de212eec94fc9c37898cff4fab735eb09b9a Mon Sep 17 00:00:00 2001 From: Dimitrie Stefanescu Date: Wed, 15 May 2024 17:52:31 +0100 Subject: [PATCH 185/261] Dim/dui3/cnx 9563 creating new project triggers documentless state (#3420) * fix(dui3): returns early in family environments + adds fallback for unsaved docs * fix(dui3/revit): handles gracefully shutdown (unrelated) * fix(dui3): corrects argument order for docinfo * fix(dui3): acad doc info changes --- .../Bindings/BasicConnectorBinding.cs | 1 - .../Bindings/AutocadBasicConnectorBinding.cs | 4 ++-- .../Bindings/BasicConnectorBindingRevit.cs | 12 ++++-------- .../Plugin/RevitPlugin.cs | 6 ++++-- 4 files changed, 10 insertions(+), 13 deletions(-) diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/BasicConnectorBinding.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/BasicConnectorBinding.cs index 936f728c6f..30504b4c80 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/BasicConnectorBinding.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/BasicConnectorBinding.cs @@ -39,7 +39,6 @@ public BasicConnectorBinding(DocumentModelStore store, ArcGISSettings settings, public string GetConnectorVersion() => Assembly.GetAssembly(GetType()).NotNull().GetVersion(); - // TODO public DocumentInfo GetDocumentInfo() => new(Project.Current.URI, Project.Current.Name, Project.Current.Name); public DocumentModelStore GetDocumentState() => _store; diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadBasicConnectorBinding.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadBasicConnectorBinding.cs index 29d7febb54..70db8d0228 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadBasicConnectorBinding.cs +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadBasicConnectorBinding.cs @@ -50,8 +50,8 @@ public string GetConnectorVersion() => { return null; } - string name = doc.Name.Split(System.IO.Path.PathSeparator).Reverse().First(); - return new DocumentInfo(doc.Name, name, doc.Name); + string name = doc.Name.Split(System.IO.Path.PathSeparator).Last(); + return new DocumentInfo(doc.Name, name, doc.GetHashCode().ToString()); } public DocumentModelStore GetDocumentState() => _store; diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/BasicConnectorBindingRevit.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/BasicConnectorBindingRevit.cs index 19cb9d2e02..7fc3d212e5 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/BasicConnectorBindingRevit.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/BasicConnectorBindingRevit.cs @@ -50,11 +50,7 @@ public string GetConnectorVersion() public string GetSourceApplicationName() => _revitSettings.HostSlug.ToLower(); // POC: maybe not right place but... // ANOTHER POC: We should align this naming from somewhere in common DUI projects instead old structs. I know there are other POC comments around this - public string GetSourceApplicationVersion() - { - // POC: maybe not right place but... - return _revitSettings.HostAppVersion; - } + public string GetSourceApplicationVersion() => _revitSettings.HostAppVersion; // POC: maybe not right place but... public DocumentInfo? GetDocumentInfo() { @@ -67,13 +63,13 @@ public string GetSourceApplicationVersion() return null; } - var info = new DocumentInfo(doc.Title, doc.GetHashCode().ToString(), doc.PathName); if (doc.IsFamilyDocument) { - info.Message = "Family Environment files not supported by Speckle."; + return new DocumentInfo("", "", "") { Message = "Family environment files not supported by Speckle." }; } - // POC: Notify user here if document is null. + var info = new DocumentInfo(doc.PathName, doc.Title, doc.GetHashCode().ToString()); + return info; } diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitPlugin.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitPlugin.cs index 2ccfaae456..13d3500b2f 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitPlugin.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitPlugin.cs @@ -127,8 +127,10 @@ private void PostApplicationInit() _cefSharpPanel.Browser.IsBrowserInitializedChanged += (sender, e) => { - // Not needed now, as we should be able to correctly open dev tools via user interaction - // _cefSharpPanel.ShowDevTools(); + if (e.NewValue is false) + { + return; + } foreach (IBinding binding in _bindings.Select(x => x.Value)) { From c0d0262e568709a739d8d4acd9e0d81629f2c1cf Mon Sep 17 00:00:00 2001 From: KatKatKateryna <89912278+KatKatKateryna@users.noreply.github.com> Date: Mon, 20 May 2024 19:05:08 +0800 Subject: [PATCH 186/261] Cnx 9502 agis object tracking change detection (#3423) * basic change events * update Ids in Model card if objects were deleted --- .../Bindings/ArcGISSelectionBinding.cs | 6 +- .../Bindings/ArcGISSendBinding.cs | 66 ++++++++++++++++++- 2 files changed, 66 insertions(+), 6 deletions(-) diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISSelectionBinding.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISSelectionBinding.cs index 93c6802c51..ddc096b629 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISSelectionBinding.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISSelectionBinding.cs @@ -7,8 +7,6 @@ namespace Speckle.Connectors.ArcGIS.Bindings; public class ArcGISSelectionBinding : ISelectionBinding { - private const string SELECTION_EVENT = "setSelection"; - public string Name { get; } = "selectionBinding"; public IBridge Parent { get; set; } @@ -17,14 +15,14 @@ public ArcGISSelectionBinding(IBridge parent) Parent = parent; // example: https://github.com/Esri/arcgis-pro-sdk-community-samples/blob/master/Map-Authoring/QueryBuilderControl/DefinitionQueryDockPaneViewModel.cs - MapViewEventArgs args = new(MapView.Active); + // MapViewEventArgs args = new(MapView.Active); TOCSelectionChangedEvent.Subscribe(OnSelectionChanged, true); } private void OnSelectionChanged(MapViewEventArgs args) { SelectionInfo selInfo = GetSelection(); - Parent?.Send(SELECTION_EVENT, selInfo); + Parent?.Send(SelectionBindingEvents.SET_SELECTION, selInfo); } public SelectionInfo GetSelection() diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISSendBinding.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISSendBinding.cs index 8e8755ec88..3b294007d8 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISSendBinding.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISSendBinding.cs @@ -11,6 +11,9 @@ using Speckle.Connectors.DUI.Models.Card.SendFilter; using Speckle.Connectors.DUI.Settings; using Speckle.Connectors.Utils; +using ArcGIS.Desktop.Mapping.Events; +using ArcGIS.Desktop.Mapping; +using Speckle.Connectors.ArcGIS.Filters; namespace Speckle.Connectors.ArcGIS.Bindings; @@ -45,6 +48,54 @@ CancellationManager cancellationManager Parent = parent; Commands = new SendBindingUICommands(parent); + SubscribeToArcGISEvents(); + } + + private void SubscribeToArcGISEvents() + { + LayersRemovedEvent.Subscribe(GetIdsForLayersRemovedEvent, true); + StandaloneTablesRemovedEvent.Subscribe(GetIdsForStandaloneTablesRemovedEvent, true); + MapPropertyChangedEvent.Subscribe(GetIdsForMapPropertyChangedEvent, true); // Map units, CRS etc. + MapMemberPropertiesChangedEvent.Subscribe(GetIdsForMapMemberPropertiesChangedEvent, true); // e.g. Layer name + } + + private void GetIdsForLayersRemovedEvent(LayerEventsArgs args) + { + foreach (Layer layer in args.Layers) + { + ChangedObjectIds.Add(layer.URI); + } + RunExpirationChecks(true); + } + + private void GetIdsForStandaloneTablesRemovedEvent(StandaloneTableEventArgs args) + { + foreach (StandaloneTable table in args.Tables) + { + ChangedObjectIds.Add(table.URI); + } + RunExpirationChecks(true); + } + + private void GetIdsForMapPropertyChangedEvent(MapPropertyChangedEventArgs args) + { + foreach (Map map in args.Maps) + { + foreach (MapMember member in map.Layers) + { + ChangedObjectIds.Add(member.URI); + } + } + RunExpirationChecks(false); + } + + private void GetIdsForMapMemberPropertiesChangedEvent(MapMemberPropertiesChangedEventArgs args) + { + foreach (MapMember member in args.MapMembers) + { + ChangedObjectIds.Add(member.URI); + } + RunExpirationChecks(false); } public List GetSendFilters() => _sendFilters; @@ -112,17 +163,28 @@ public async Task Send(string modelCardId) /// /// Checks if any sender model cards contain any of the changed objects. If so, also updates the changed objects hashset for each model card - this last part is important for on send change detection. /// - private void RunExpirationChecks() + private void RunExpirationChecks(bool idsDeleted) { var senders = _store.GetSenders(); List expiredSenderIds = new(); + string[] objectIdsList = ChangedObjectIds.ToArray(); - foreach (var sender in senders) + foreach (SenderModelCard sender in senders) { + var objIds = sender.SendFilter.NotNull().GetObjectIds(); + var intersection = objIds.Intersect(objectIdsList).ToList(); bool isExpired = sender.SendFilter.NotNull().CheckExpiry(ChangedObjectIds.ToArray()); if (isExpired) { expiredSenderIds.Add(sender.ModelCardId.NotNull()); + sender.ChangedObjectIds.UnionWith(intersection.NotNull()); + + // Update the model card object Ids + if (idsDeleted && sender.SendFilter is ArcGISSelectionFilter filter) + { + List remainingObjIds = objIds.SkipWhile(x => intersection.Contains(x)).ToList(); + filter.SelectedObjectIds = remainingObjIds; + } } } From e2e664f8e2e7e85e3f7a4b0cb2bc6de6975ad9ed Mon Sep 17 00:00:00 2001 From: Adam Hathcock Date: Mon, 20 May 2024 12:07:01 +0100 Subject: [PATCH 187/261] Auto interface demo (#3399) * Demo of InterfaceGenerator * fmt * use new package * update autointerface again * fix autogenerated interfaces --- DUI3-DX/Directory.Build.Props | 1 + .../Speckle.Autofac/DependencyInjection/Factory.cs | 9 +++++++-- .../Speckle.Autofac/DependencyInjection/IFactory.cs | 12 ------------ .../DependencyInjection/IUnitOfWork.cs | 7 ------- .../DependencyInjection/IUnitOfWorkFactory.cs | 9 --------- .../DependencyInjection/UnitOfWork.cs | 8 +++++++- .../DependencyInjection/UnitOfWorkFactory.cs | 2 ++ DUI3-DX/Sdk/Speckle.Autofac/Files/IStorageInfo.cs | 6 ------ DUI3-DX/Sdk/Speckle.Autofac/Files/StorageInfo.cs | 3 +++ 9 files changed, 20 insertions(+), 37 deletions(-) delete mode 100644 DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/IFactory.cs delete mode 100644 DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/IUnitOfWork.cs delete mode 100644 DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/IUnitOfWorkFactory.cs delete mode 100644 DUI3-DX/Sdk/Speckle.Autofac/Files/IStorageInfo.cs diff --git a/DUI3-DX/Directory.Build.Props b/DUI3-DX/Directory.Build.Props index f6527d23eb..add00d3739 100644 --- a/DUI3-DX/Directory.Build.Props +++ b/DUI3-DX/Directory.Build.Props @@ -9,5 +9,6 @@ + diff --git a/DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/Factory.cs b/DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/Factory.cs index f173abc4e4..e68fce561d 100644 --- a/DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/Factory.cs +++ b/DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/Factory.cs @@ -1,7 +1,9 @@ using Autofac.Features.Indexed; +using Speckle.InterfaceGenerator; namespace Speckle.Autofac.DependencyInjection; +[GenerateAutoInterface] public class Factory : IFactory where TValue : class { @@ -14,7 +16,10 @@ public Factory(IIndex types) public TValue? ResolveInstance(TKey strongName) { - _types.TryGetValue(strongName, out TValue value); - return value; + if (_types.TryGetValue(strongName, out TValue value)) + { + return value; + } + return null; } } diff --git a/DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/IFactory.cs b/DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/IFactory.cs deleted file mode 100644 index d3471c4cfb..0000000000 --- a/DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/IFactory.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace Speckle.Autofac.DependencyInjection; - -// POC: NEXT UP -// * begin scope: https://stackoverflow.com/questions/49595198/autofac-resolving-through-factory-methods -// Interceptors? - -// POC: this might be somehting that could go in a wholly converter agnostic project -public interface IFactory - where TValue : class -{ - TValue? ResolveInstance(TKey strongName); -} diff --git a/DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/IUnitOfWork.cs b/DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/IUnitOfWork.cs deleted file mode 100644 index 5d58d1aabe..0000000000 --- a/DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/IUnitOfWork.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Speckle.Autofac.DependencyInjection; - -public interface IUnitOfWork : IDisposable - where TService : class -{ - TService Service { get; } -} diff --git a/DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/IUnitOfWorkFactory.cs b/DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/IUnitOfWorkFactory.cs deleted file mode 100644 index 020af4151c..0000000000 --- a/DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/IUnitOfWorkFactory.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace Speckle.Autofac.DependencyInjection; - -public interface IUnitOfWorkFactory -{ - // POC: this takes a TService but I wonder if the resolution could be in the - // Resolve method - IUnitOfWork Resolve() - where TService : class; -} diff --git a/DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/UnitOfWork.cs b/DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/UnitOfWork.cs index 650e8b3296..43e69adf3d 100644 --- a/DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/UnitOfWork.cs +++ b/DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/UnitOfWork.cs @@ -1,7 +1,12 @@ using Autofac; +using Speckle.InterfaceGenerator; namespace Speckle.Autofac.DependencyInjection; +public partial interface IUnitOfWork : IDisposable + where TService : class { } + +[GenerateAutoInterface] public sealed class UnitOfWork : IUnitOfWork where TService : class { @@ -14,8 +19,9 @@ public UnitOfWork(ILifetimeScope unitOfWorkScope, TService service) Service = service; } - public TService Service { get; private set; } + public TService Service { get; } + [AutoInterfaceIgnore] public void Dispose() => Disposing(true); private void Disposing(bool fromDispose) diff --git a/DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/UnitOfWorkFactory.cs b/DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/UnitOfWorkFactory.cs index 94603a2264..295519d8ef 100644 --- a/DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/UnitOfWorkFactory.cs +++ b/DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/UnitOfWorkFactory.cs @@ -1,9 +1,11 @@ using Autofac; using Autofac.Core; +using Speckle.InterfaceGenerator; using Speckle.Core.Logging; namespace Speckle.Autofac.DependencyInjection; +[GenerateAutoInterface] public class UnitOfWorkFactory : IUnitOfWorkFactory { private readonly ILifetimeScope _parentScope; diff --git a/DUI3-DX/Sdk/Speckle.Autofac/Files/IStorageInfo.cs b/DUI3-DX/Sdk/Speckle.Autofac/Files/IStorageInfo.cs deleted file mode 100644 index 0ee9cee332..0000000000 --- a/DUI3-DX/Sdk/Speckle.Autofac/Files/IStorageInfo.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace Speckle.Autofac.Files; - -public interface IStorageInfo -{ - IEnumerable GetFilenamesInDirectory(string path, string pattern); -} diff --git a/DUI3-DX/Sdk/Speckle.Autofac/Files/StorageInfo.cs b/DUI3-DX/Sdk/Speckle.Autofac/Files/StorageInfo.cs index af55e1405a..a810c1c838 100644 --- a/DUI3-DX/Sdk/Speckle.Autofac/Files/StorageInfo.cs +++ b/DUI3-DX/Sdk/Speckle.Autofac/Files/StorageInfo.cs @@ -1,5 +1,8 @@ +using Speckle.InterfaceGenerator; + namespace Speckle.Autofac.Files; +[GenerateAutoInterface] public class StorageInfo : IStorageInfo { public IEnumerable GetFilenamesInDirectory(string path, string pattern) From e54e5a2a1a32045bd6060593304d78525ecd2055 Mon Sep 17 00:00:00 2001 From: Adam Hathcock Date: Mon, 20 May 2024 12:46:02 +0100 Subject: [PATCH 188/261] Add more null checks for Revit (#3425) * Add more null checks for Revit * consolidate assembly resolving * Remove comment --- .../SpeckleModule.cs | 26 ++--------------- .../Plugin/AutocadExtensionApplication.cs | 22 ++------------ .../Bindings/BasicConnectorBindingRevit.cs | 2 +- .../Bindings/SelectionBinding.cs | 2 +- .../HostApp/RevitDocumentStore.cs | 2 +- .../Plugin/RevitExternalApplication.cs | 29 ++++--------------- .../Plugin/Speckle.Connectors.Rhino7Plugin.cs | 27 ++--------------- .../Sdk/Speckle.Autofac/AssemblyResolver.cs | 26 +++++++++++++++++ 8 files changed, 42 insertions(+), 94 deletions(-) create mode 100644 DUI3-DX/Sdk/Speckle.Autofac/AssemblyResolver.cs diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/SpeckleModule.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/SpeckleModule.cs index 0e827a8beb..2d881184b9 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/SpeckleModule.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/SpeckleModule.cs @@ -1,7 +1,6 @@ -using System.IO; -using System.Reflection; using ArcGIS.Desktop.Framework; using Autofac; +using Speckle.Autofac; using Speckle.Autofac.DependencyInjection; using Speckle.Autofac.Files; using Speckle.Connectors.ArcGIS.HostApp; @@ -29,7 +28,7 @@ internal sealed class SpeckleModule : Module public SpeckleModule() { - AppDomain.CurrentDomain.AssemblyResolve += OnAssemblyResolve; + AppDomain.CurrentDomain.AssemblyResolve += AssemblyResolver.OnAssemblyResolve; Container = new AutofacContainer(new StorageInfo()); Container.PreBuildEvent += Container_PreBuildEvent; @@ -57,25 +56,4 @@ private static void Container_PreBuildEvent(object? sender, ContainerBuilder con containerBuilder.InjectNamedTypes(); containerBuilder.InjectNamedTypes(); } - - private static Assembly? OnAssemblyResolve(object? sender, ResolveEventArgs args) - { - // POC: dupe code - // POC: tight binding to files - Assembly? assembly = null; - string name = args.Name.Split(',')[0]; - string? path = Path.GetDirectoryName(typeof(SpeckleModule).Assembly.Location); - - if (path != null) - { - string assemblyFile = Path.Combine(path, name + ".dll"); - - if (File.Exists(assemblyFile)) - { - assembly = Assembly.LoadFrom(assemblyFile); - } - } - - return assembly; - } } diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Plugin/AutocadExtensionApplication.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Plugin/AutocadExtensionApplication.cs index e2598b1d73..d0773abcb0 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Plugin/AutocadExtensionApplication.cs +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Plugin/AutocadExtensionApplication.cs @@ -1,28 +1,12 @@ -using System.IO; -using System.Reflection; using Autodesk.AutoCAD.Runtime; +using Speckle.Autofac; namespace Speckle.Connectors.Autocad.Plugin; public class AutocadExtensionApplication : IExtensionApplication { - public void Initialize() => AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(OnAssemblyResolve); + public void Initialize() => + AppDomain.CurrentDomain.AssemblyResolve += AssemblyResolver.OnAssemblyResolve; public void Terminate() { } - - private Assembly? OnAssemblyResolve(object sender, ResolveEventArgs args) - { - Assembly? a = null; - string name = args.Name.Split(',')[0]; - string path = Path.GetDirectoryName(typeof(AutocadExtensionApplication).Assembly.Location); - - string assemblyFile = Path.Combine(path, name + ".dll"); - - if (File.Exists(assemblyFile)) - { - a = Assembly.LoadFrom(assemblyFile); - } - - return a; - } } diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/BasicConnectorBindingRevit.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/BasicConnectorBindingRevit.cs index 7fc3d212e5..fb01f781e6 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/BasicConnectorBindingRevit.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/BasicConnectorBindingRevit.cs @@ -57,7 +57,7 @@ public string GetConnectorVersion() // POC: not sure why this would ever be null, is this needed? _revitContext.UIApplication.NotNull(); - var doc = _revitContext.UIApplication.ActiveUIDocument.Document; + var doc = _revitContext.UIApplication.ActiveUIDocument?.Document; if (doc is null) { return null; diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SelectionBinding.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SelectionBinding.cs index 61379b2e5e..9cbf1bcc15 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SelectionBinding.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SelectionBinding.cs @@ -37,7 +37,7 @@ public SelectionInfo GetSelection() // POC: this was also being called on shutdown // probably the bridge needs to be able to know if the plugin has been terminated // also on termination the OnSelectionChanged event needs unwinding - var selectionIds = (RevitContext.UIApplication?.ActiveUIDocument.Selection.GetElementIds()) + var selectionIds = (RevitContext.UIApplication?.ActiveUIDocument?.Selection.GetElementIds()) .NotNull() .Select(id => id.ToString()) .ToList(); diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/RevitDocumentStore.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/RevitDocumentStore.cs index 920f195226..0c5807aed1 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/RevitDocumentStore.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/RevitDocumentStore.cs @@ -110,7 +110,7 @@ public override void ReadFromFile() { try { - var stateEntity = GetSpeckleEntity(_revitContext.UIApplication?.ActiveUIDocument.Document); + var stateEntity = GetSpeckleEntity(_revitContext.UIApplication?.ActiveUIDocument?.Document); if (stateEntity == null || !stateEntity.IsValid()) { Models = new(); diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitExternalApplication.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitExternalApplication.cs index b7d74c246b..d5ae6e8a80 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitExternalApplication.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitExternalApplication.cs @@ -1,9 +1,9 @@ using Autodesk.Revit.UI; using Speckle.Autofac.DependencyInjection; using Speckle.Autofac.Files; -using System.Reflection; using System.IO; using Autofac; +using Speckle.Autofac; using Speckle.Connectors.Utils; using Speckle.Converters.Common.DependencyInjection; using Speckle.Converters.Common.Objects; @@ -47,15 +47,16 @@ public Result OnStartup(UIControlledApplication application) try { // POC: not sure what this is doing... could be messing up our Aliasing???? - AppDomain.CurrentDomain.AssemblyResolve += OnAssemblyResolve; + AppDomain.CurrentDomain.AssemblyResolve += AssemblyResolver.OnAssemblyResolve; + _container = new AutofacContainer(new StorageInfo()); _container.PreBuildEvent += ContainerPreBuildEvent; // init DI _container .LoadAutofacModules(_revitSettings.ModuleFolders.NotNull()) - .AddSingletonInstance(_revitSettings) // apply revit settings into DI - .AddSingletonInstance(application) // inject UIControlledApplication application + .AddSingletonInstance(_revitSettings) // apply revit settings into DI + .AddSingletonInstance(application) // inject UIControlledApplication application .Build(); // resolve root object @@ -96,24 +97,4 @@ public Result OnShutdown(UIControlledApplication application) return Result.Succeeded; } - - private Assembly OnAssemblyResolve(object sender, ResolveEventArgs args) - { - // POC: tight binding to files - Assembly? assembly = null; - string name = args.Name.Split(',')[0]; - string path = Path.GetDirectoryName(typeof(RevitPlugin).Assembly.Location); - - if (path != null) - { - string assemblyFile = Path.Combine(path, name + ".dll"); - - if (File.Exists(assemblyFile)) - { - assembly = Assembly.LoadFrom(assemblyFile); - } - } - - return assembly.NotNull(); - } } diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Plugin/Speckle.Connectors.Rhino7Plugin.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Plugin/Speckle.Connectors.Rhino7Plugin.cs index 7d87e9ea3b..8b2013164e 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Plugin/Speckle.Connectors.Rhino7Plugin.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Plugin/Speckle.Connectors.Rhino7Plugin.cs @@ -1,6 +1,5 @@ -using System.IO; -using System.Reflection; -using Rhino.PlugIns; +using Rhino.PlugIns; +using Speckle.Autofac; using Speckle.Autofac.DependencyInjection; using Speckle.Autofac.Files; using Speckle.Connectors.Rhino7.DependencyInjection; @@ -45,7 +44,7 @@ protected override LoadReturnCode OnLoad(ref string errorMessage) { try { - AppDomain.CurrentDomain.AssemblyResolve += OnAssemblyResolve; + AppDomain.CurrentDomain.AssemblyResolve += AssemblyResolver.OnAssemblyResolve; Container = new AutofacContainer(new StorageInfo()); @@ -78,24 +77,4 @@ protected override void OnShutdown() _rhinoPlugin?.Shutdown(); base.OnShutdown(); } - - private Assembly? OnAssemblyResolve(object sender, ResolveEventArgs args) - { - // POC: tight binding to files - Assembly? assembly = null; - string name = args.Name.Split(',')[0]; - string path = Path.GetDirectoryName(typeof(SpeckleConnectorsRhino7Plugin).Assembly.Location); - - if (path != null) - { - string assemblyFile = Path.Combine(path, name + ".dll"); - - if (File.Exists(assemblyFile)) - { - assembly = Assembly.LoadFrom(assemblyFile); - } - } - - return assembly; - } } diff --git a/DUI3-DX/Sdk/Speckle.Autofac/AssemblyResolver.cs b/DUI3-DX/Sdk/Speckle.Autofac/AssemblyResolver.cs new file mode 100644 index 0000000000..8f887f56ea --- /dev/null +++ b/DUI3-DX/Sdk/Speckle.Autofac/AssemblyResolver.cs @@ -0,0 +1,26 @@ +using System.Reflection; + +namespace Speckle.Autofac; + +public static class AssemblyResolver +{ + public static Assembly? OnAssemblyResolve(object? sender, ResolveEventArgs args) + { + // POC: tight binding to files + string name = args.Name.Split(',')[0]; + string? path = Path.GetDirectoryName(typeof(T).Assembly.Location); + + if (path == null) + { + return null; + } + string assemblyFile = Path.Combine(path, name + ".dll"); + + Assembly? assembly = null; + if (File.Exists(assemblyFile)) + { + assembly = Assembly.LoadFrom(assemblyFile); + } + return assembly; + } +} From bd178265977be598db7062e26a8b5fc5e495ce68 Mon Sep 17 00:00:00 2001 From: Adam Hathcock Date: Mon, 20 May 2024 14:49:08 +0100 Subject: [PATCH 189/261] CNX-9433 Remove duplication on the Connector Autofac modules again (#3417) * base changes * all connectors and converters converted * do renames * fmt * Merge remote-tracking branch 'origin/dui3/alpha' into CNX-9433-Remove-dups-2 * don't rely on DI to specify, each implementation is writeToFileOnChange true * refactor loading * plugins also load with their assembly * resolve more common things * only grab types that are the correct ones * fmt * remove debug * remove module * Remove dependencies * merge fixes * remove foreach extension --- .../ArcGISConnectorModule.cs | 51 +++++ .../AutofacArcGISModule.cs | 121 ----------- .../Speckle.Connectors.ArcGIS3.csproj | 3 +- .../SpeckleModule.cs | 22 +- .../Utils/ArcGisDocumentStore.cs | 4 +- .../Speckle.Connectors.Autocad2023.csproj | 3 +- .../AutocadConnectorModule.cs | 67 ++++++ .../AutofacAutocadModule.cs | 123 ----------- .../HostApp/AutocadDocumentModelStore.cs | 5 +- .../Plugin/AutocadCommand.cs | 22 +- ...Speckle.Connectors.AutocadShared.projitems | 2 +- .../Speckle.Connectors.Revit2023.csproj | 1 - .../DependencyInjection/AutofacUIModule.cs | 111 ---------- .../RevitConnectorShared.cs | 61 ++++++ .../HostApp/RevitDocumentStore.cs | 5 +- .../Plugin/RevitExternalApplication.cs | 28 +-- .../Speckle.Connectors.RevitShared.projitems | 2 +- .../DependencyInjection/AutofacRhinoModule.cs | 116 ---------- .../RhinoConnectorModule.cs | 67 ++++++ .../HostApp/RhinoDocumentStore.cs | 4 +- .../Plugin/Speckle.Connectors.Rhino7Plugin.cs | 16 +- .../Speckle.Connectors.Rhino7.csproj | 3 +- .../ArcGISConverterModule.cs | 28 +++ .../AutofacArcGIS3ConverterModule.cs | 52 ----- .../AutocadConverterModule.cs | 22 ++ .../AutofacAutocadConverterModule.cs | 42 ---- .../AutofacRevitConverterModule.cs | 54 ----- .../RevitConverterModule.cs | 42 ++++ ...rters.Revit2023.DependencyInjection.csproj | 9 +- .../AutofacRhinoConverterModule.cs | 56 ----- .../RhinoConverterModule.cs | 21 ++ ...nverters.Rhino7.DependencyInjection.csproj | 1 - .../ContainerRegistration.cs | 12 ++ .../ContainerRegistration.cs | 44 ++++ .../Models/DocumentModelStore.cs | 2 +- .../Speckle.Connectors.DUI.csproj | 1 + .../Speckle.Autofac/ContainerRegistration.cs | 12 ++ .../DependencyInjection/AutofacContainer.cs | 107 ---------- .../DependencyInjection/ISpeckleModule.cs | 6 + .../DependencyInjection/SpeckleContainer.cs | 19 ++ .../SpeckleContainerBuilder.cs | 199 ++++++++++++++++++ .../ContainerRegistration.cs | 26 +++ .../Speckle.Connectors.Utils.csproj | 5 +- .../ContainerRegistration.cs | 39 ++++ .../NamedTypeInjector.cs | 41 +--- .../RawConversionRegisterer.cs | 40 +--- 46 files changed, 780 insertions(+), 937 deletions(-) create mode 100644 DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/DependencyInjection/ArcGISConnectorModule.cs delete mode 100644 DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/DependencyInjection/AutofacArcGISModule.cs create mode 100644 DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/DependencyInjection/AutocadConnectorModule.cs delete mode 100644 DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/DependencyInjection/AutofacAutocadModule.cs delete mode 100644 DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/AutofacUIModule.cs create mode 100644 DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/RevitConnectorShared.cs delete mode 100644 DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/AutofacRhinoModule.cs create mode 100644 DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/RhinoConnectorModule.cs create mode 100644 DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3.DependencyInjection/ArcGISConverterModule.cs delete mode 100644 DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3.DependencyInjection/AutofacArcGIS3ConverterModule.cs create mode 100644 DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2023.DependencyInjection/AutocadConverterModule.cs delete mode 100644 DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2023.DependencyInjection/AutofacAutocadConverterModule.cs delete mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/AutofacRevitConverterModule.cs create mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/RevitConverterModule.cs delete mode 100644 DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/AutofacRhinoConverterModule.cs create mode 100644 DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/RhinoConverterModule.cs create mode 100644 DUI3-DX/DUI3/Speckle.Connectors.DUI.WebView/ContainerRegistration.cs create mode 100644 DUI3-DX/DUI3/Speckle.Connectors.DUI/ContainerRegistration.cs create mode 100644 DUI3-DX/Sdk/Speckle.Autofac/ContainerRegistration.cs delete mode 100644 DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/AutofacContainer.cs create mode 100644 DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/ISpeckleModule.cs create mode 100644 DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/SpeckleContainer.cs create mode 100644 DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/SpeckleContainerBuilder.cs create mode 100644 DUI3-DX/Sdk/Speckle.Connectors.Utils/ContainerRegistration.cs create mode 100644 DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/ContainerRegistration.cs diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/DependencyInjection/ArcGISConnectorModule.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/DependencyInjection/ArcGISConnectorModule.cs new file mode 100644 index 0000000000..8dfd2110d7 --- /dev/null +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/DependencyInjection/ArcGISConnectorModule.cs @@ -0,0 +1,51 @@ +using Speckle.Autofac.DependencyInjection; +using Speckle.Connectors.ArcGIS.Bindings; +using Speckle.Connectors.ArcGis.Operations.Send; +using Speckle.Connectors.DUI.Bindings; +using Speckle.Connectors.ArcGIS.Utils; +using Speckle.Connectors.ArcGIS.Operations.Receive; +using Speckle.Connectors.DUI.Models.Card.SendFilter; +using Speckle.Connectors.DUI.WebView; +using Speckle.Connectors.Utils.Builders; +using Speckle.Autofac; +using Speckle.Connectors.ArcGIS.Filters; +using Speckle.Connectors.DUI; +using Speckle.Connectors.DUI.Models; +using Speckle.Connectors.Utils; +using Speckle.Core.Models.GraphTraversal; + +// POC: This is a temp reference to root object senders to tweak CI failing after having generic interfaces into common project. +// This should go whenever it is aligned. + +namespace Speckle.Connectors.ArcGIS.DependencyInjection; + +public class ArcGISConnectorModule : ISpeckleModule +{ + public void Load(SpeckleContainerBuilder builder) + { + builder.AddAutofac(); + builder.AddConnectorUtils(); + builder.AddDUI(); + builder.AddDUIView(); + + builder.AddSingleton(); + + // Register bindings + builder.AddSingleton(); + builder.AddSingleton("connectorName", "ArcGIS"); // POC: Easier like this for now, should be cleaned up later + builder.AddSingleton(); + builder.AddSingleton(); + builder.AddSingleton(); + builder.AddSingleton(); + builder.AddSingleton(); + builder.AddSingleton(); + + builder.AddTransient(); + builder.AddScoped(); + builder.AddSingleton(DefaultTraversal.CreateTraversalFunc()); + + // register send operation and dependencies + builder.AddScoped(); + builder.AddScoped(); + } +} diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/DependencyInjection/AutofacArcGISModule.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/DependencyInjection/AutofacArcGISModule.cs deleted file mode 100644 index 6e8e2e9757..0000000000 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/DependencyInjection/AutofacArcGISModule.cs +++ /dev/null @@ -1,121 +0,0 @@ -using Autofac; -using Microsoft.Extensions.Logging; -using Serilog; -using Speckle.Autofac.DependencyInjection; -using Speckle.Connectors.ArcGIS.Bindings; -using Speckle.Connectors.ArcGis.Operations.Send; -using Speckle.Connectors.DUI.Bindings; -using Speckle.Connectors.DUI.Bridge; -using Speckle.Connectors.DUI.Utils; -using Speckle.Converters.Common; -using Speckle.Newtonsoft.Json; -using Speckle.Newtonsoft.Json.Serialization; -using Speckle.Connectors.ArcGIS.Utils; -using Speckle.Connectors.Utils.Cancellation; -using Speckle.Converters.ArcGIS3; -using Speckle.Core.Transports; -using Speckle.Connectors.ArcGIS.Operations.Receive; -using Speckle.Connectors.DUI.Models.Card.SendFilter; -using Speckle.Connectors.DUI.WebView; -using Speckle.Connectors.Utils.Builders; -using Speckle.Connectors.Utils.Operations; -using ArcGIS.Core.Geometry; -using Speckle.Connectors.ArcGIS.Filters; -using Speckle.Connectors.DUI.Models; - -// POC: This is a temp reference to root object senders to tweak CI failing after having generic interfaces into common project. -// This should go whenever it is aligned. -using IRootObjectSender = Speckle.Connectors.ArcGis.Operations.Send.IRootObjectSender; -using RootObjectSender = Speckle.Connectors.ArcGis.Operations.Send.RootObjectSender; -using Speckle.Core.Models.GraphTraversal; - -namespace Speckle.Connectors.ArcGIS.DependencyInjection; - -public class AutofacArcGISModule : Module -{ - protected override void Load(ContainerBuilder builder) - { - RegisterLoggerFactory(builder); - - // Register DUI3 related stuff - builder.RegisterInstance(GetJsonSerializerSettings()).SingleInstance(); - builder.RegisterType().As().InstancePerDependency(); //TODO: Verify why we need one bridge instance per dependency. - - builder.RegisterType().SingleInstance(); - builder - .RegisterType() - .As() - .SingleInstance() - .WithParameter("writeToFileOnChange", true); - - // Register bindings - builder.RegisterType().As().SingleInstance(); - builder.RegisterType().As().SingleInstance().WithParameter("connectorName", "ArcGIS"); // POC: Easier like this for now, should be cleaned up later - builder.RegisterType().As().SingleInstance(); - builder.RegisterType().As().As().SingleInstance(); - builder.RegisterType().As().SingleInstance(); - builder.RegisterType().As().SingleInstance(); - builder.RegisterType().As().SingleInstance(); - builder - .RegisterType() - .As>() - .InstancePerLifetimeScope(); - - // Operations - builder.RegisterType().AsSelf().InstancePerLifetimeScope(); - builder.RegisterType().As().InstancePerLifetimeScope(); - - // Object Builders - builder.RegisterType().As().InstancePerLifetimeScope(); - // POC: Register here also RootObjectBuilder as IRootObjectBuilder - - // binding dependencies - builder.RegisterType().InstancePerDependency(); - - // register send filters - builder.RegisterType().As().InstancePerLifetimeScope(); - - // register send operation and dependencies - builder.RegisterType().InstancePerLifetimeScope(); - builder.RegisterType().InstancePerLifetimeScope(); - builder.RegisterType().As().InstancePerLifetimeScope(); - builder.RegisterInstance(DefaultTraversal.CreateTraversalFunc()); - - //POC: how tf does this work? - builder.RegisterType().As().SingleInstance(); - - // Register converter factory - builder.RegisterType().As().InstancePerLifetimeScope(); - } - - //poc: dupe code - private static JsonSerializerSettings GetJsonSerializerSettings() - { - // Register WebView2 panel stuff - JsonSerializerSettings settings = - new() - { - Error = (_, args) => - { - Console.WriteLine("*** JSON ERROR: " + args.ErrorContext); - }, - ContractResolver = new CamelCasePropertyNamesContractResolver(), - NullValueHandling = NullValueHandling.Ignore, - ReferenceLoopHandling = ReferenceLoopHandling.Ignore, - DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate, - Converters = { new DiscriminatedObjectConverter(), new AbstractConverter() } - }; - return settings; - } - - private static void RegisterLoggerFactory(ContainerBuilder builder) - { - var serilogLogger = new LoggerConfiguration().MinimumLevel - .Debug() - .WriteTo.File("log.txt", rollingInterval: RollingInterval.Day) - .CreateLogger(); - - ILoggerFactory loggerFactory = new LoggerFactory().AddSerilog(serilogLogger); - builder.RegisterInstance(loggerFactory).As().SingleInstance(); - } -} diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Speckle.Connectors.ArcGIS3.csproj b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Speckle.Connectors.ArcGIS3.csproj index a356b04b8e..9e9e4a9d1f 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Speckle.Connectors.ArcGIS3.csproj +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Speckle.Connectors.ArcGIS3.csproj @@ -19,8 +19,7 @@ - - + diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/SpeckleModule.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/SpeckleModule.cs index 2d881184b9..e457309fcf 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/SpeckleModule.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/SpeckleModule.cs @@ -1,12 +1,9 @@ +using System.Reflection; using ArcGIS.Desktop.Framework; -using Autofac; using Speckle.Autofac; using Speckle.Autofac.DependencyInjection; -using Speckle.Autofac.Files; using Speckle.Connectors.ArcGIS.HostApp; -using Speckle.Converters.Common.Objects; using Speckle.Core.Kits; -using Speckle.Converters.Common.DependencyInjection; using Module = ArcGIS.Desktop.Framework.Contracts.Module; namespace Speckle.Connectors.ArcGIS; @@ -24,19 +21,21 @@ internal sealed class SpeckleModule : Module public static SpeckleModule Current => s_this ??= (SpeckleModule)FrameworkApplication.FindModule("ConnectorArcGIS_Module"); - public AutofacContainer Container { get; } + public SpeckleContainer Container { get; } public SpeckleModule() { AppDomain.CurrentDomain.AssemblyResolve += AssemblyResolver.OnAssemblyResolve; - Container = new AutofacContainer(new StorageInfo()); - Container.PreBuildEvent += Container_PreBuildEvent; + var builder = SpeckleContainerBuilder.CreateInstance(); // Register Settings var arcgisSettings = new ArcGISSettings(HostApplications.ArcGIS, HostAppVersion.v3); - Container.LoadAutofacModules(arcgisSettings.Modules).AddSingletonInstance(arcgisSettings).Build(); + Container = builder + .LoadAutofacModules(Assembly.GetExecutingAssembly(), arcgisSettings.Modules) + .AddSingleton(arcgisSettings) + .Build(); } /// @@ -49,11 +48,4 @@ protected override bool CanUnload() //return false to ~cancel~ Application close return true; } - - private static void Container_PreBuildEvent(object? sender, ContainerBuilder containerBuilder) - { - containerBuilder.RegisterRawConversions(); - containerBuilder.InjectNamedTypes(); - containerBuilder.InjectNamedTypes(); - } } diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Utils/ArcGisDocumentStore.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Utils/ArcGisDocumentStore.cs index 02260acc2e..d8ca75f959 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Utils/ArcGisDocumentStore.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Utils/ArcGisDocumentStore.cs @@ -11,8 +11,8 @@ namespace Speckle.Connectors.ArcGIS.Utils; public class ArcGISDocumentStore : DocumentModelStore { - public ArcGISDocumentStore(JsonSerializerSettings serializerOption, bool writeToFileOnChange) - : base(serializerOption, writeToFileOnChange) + public ArcGISDocumentStore(JsonSerializerSettings serializerOption) + : base(serializerOption, true) { ActiveMapViewChangedEvent.Subscribe(OnMapViewChanged); ProjectSavingEvent.Subscribe(OnProjectSaving); diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.Autocad2023/Speckle.Connectors.Autocad2023.csproj b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.Autocad2023/Speckle.Connectors.Autocad2023.csproj index 3154c13e9f..40658970e5 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.Autocad2023/Speckle.Connectors.Autocad2023.csproj +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.Autocad2023/Speckle.Connectors.Autocad2023.csproj @@ -16,8 +16,7 @@ - - + diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/DependencyInjection/AutocadConnectorModule.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/DependencyInjection/AutocadConnectorModule.cs new file mode 100644 index 0000000000..a7702d9c2e --- /dev/null +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/DependencyInjection/AutocadConnectorModule.cs @@ -0,0 +1,67 @@ +using Autodesk.AutoCAD.DatabaseServices; +using Speckle.Autofac; +using Speckle.Autofac.DependencyInjection; +using Speckle.Connectors.Autocad.Bindings; +using Speckle.Connectors.Autocad.Filters; +using Speckle.Connectors.Autocad.HostApp; +using Speckle.Connectors.Autocad.Interfaces; +using Speckle.Connectors.Autocad.Operations.Receive; +using Speckle.Connectors.Autocad.Operations.Send; +using Speckle.Connectors.Autocad.Plugin; +using Speckle.Connectors.DUI; +using Speckle.Connectors.DUI.Bindings; +using Speckle.Connectors.DUI.Models; +using Speckle.Connectors.DUI.Models.Card.SendFilter; +using Speckle.Connectors.DUI.WebView; +using Speckle.Connectors.Utils; +using Speckle.Connectors.Utils.Builders; +using Speckle.Connectors.Utils.Operations; +using Speckle.Converters.Autocad; +using Speckle.Converters.Common; +using Speckle.Core.Models.GraphTraversal; + +namespace Speckle.Connectors.Autocad.DependencyInjection; + +public class AutocadConnectorModule : ISpeckleModule +{ + public void Load(SpeckleContainerBuilder builder) + { + builder.AddAutofac(); + builder.AddConnectorUtils(); + builder.AddDUI(); + builder.AddDUIView(); + + // Register other connector specific types + builder.AddSingleton(); + builder.AddTransient(); + builder.AddSingleton(new AutocadDocumentManager()); // TODO: Dependent to TransactionContext, can be moved to AutocadContext + builder.AddSingleton(); + builder.AddSingleton(); + builder.AddSingleton(); + builder.AddSingleton(); + + // Operations + builder.AddScoped>(); + builder.AddSingleton(DefaultTraversal.CreateTraversalFunc()); + + // Object Builders + builder.AddScoped(); + builder.AddSingleton, RootObjectBuilder>(); + + // Register bindings + + builder.AddSingleton(); + builder.AddSingleton("connectorName", "Autocad"); // POC: Easier like this for now, should be cleaned up later + builder.AddSingleton(); + builder.AddSingleton(); + builder.AddSingleton(); + builder.AddSingleton(); + builder.AddSingleton(); + builder.AddSingleton(); + + builder.AddSingleton, AutocadToSpeckleUnitConverter>(); + + // register send filters + builder.AddTransient(); + } +} diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/DependencyInjection/AutofacAutocadModule.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/DependencyInjection/AutofacAutocadModule.cs deleted file mode 100644 index 7acc0979eb..0000000000 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/DependencyInjection/AutofacAutocadModule.cs +++ /dev/null @@ -1,123 +0,0 @@ -using Autodesk.AutoCAD.DatabaseServices; -using Autofac; -using Microsoft.Extensions.Logging; -using Serilog; -using Speckle.Autofac.DependencyInjection; -using Speckle.Connectors.Autocad.Bindings; -using Speckle.Connectors.Autocad.HostApp; -using Speckle.Connectors.Autocad.Plugin; -using Speckle.Connectors.DUI.Bindings; -using Speckle.Connectors.DUI.Bridge; -using Speckle.Connectors.DUI.Models; -using Speckle.Connectors.DUI.Utils; -using Speckle.Converters.Common; -using Speckle.Converters.Autocad; -using Speckle.Newtonsoft.Json; -using Speckle.Newtonsoft.Json.Serialization; -using Speckle.Connectors.Autocad.Interfaces; -using Speckle.Connectors.Utils.Cancellation; -using Speckle.Connectors.Autocad.Filters; -using Speckle.Connectors.Autocad.Operations.Receive; -using Speckle.Connectors.Autocad.Operations.Send; -using Speckle.Connectors.DUI.Models.Card.SendFilter; -using Speckle.Connectors.DUI.WebView; -using Speckle.Connectors.Utils.Builders; -using Speckle.Connectors.Utils.Operations; -using Speckle.Core.Models.GraphTraversal; -using Speckle.Core.Transports; - -namespace Speckle.Connectors.Autocad.DependencyInjection; - -public class AutofacAutocadModule : Module -{ - protected override void Load(ContainerBuilder builder) - { - RegisterLoggerFactory(builder); - - // Register DUI3 related stuff - builder.RegisterInstance(GetJsonSerializerSettings()).SingleInstance(); - builder.RegisterType().SingleInstance(); - builder.RegisterType().As().InstancePerDependency(); // POC: Each binding should have it's own bridge instance - - // Register other connector specific types - builder.RegisterType().As().SingleInstance(); - builder.RegisterType().InstancePerDependency(); - builder.RegisterInstance(new AutocadDocumentManager()); // TODO: Dependent to TransactionContext, can be moved to AutocadContext - builder - .RegisterType() - .As() - .SingleInstance() - .WithParameter("writeToFileOnChange", true); - builder.RegisterType().SingleInstance(); - builder.RegisterType().SingleInstance(); - builder.RegisterType().SingleInstance(); - - // Operations - builder.RegisterType>().InstancePerLifetimeScope(); - builder.RegisterType().InstancePerLifetimeScope(); - builder.RegisterType().As().SingleInstance().AutoActivate(); // Auto activation makes SynchronizationContext available right after building. Otherwise we were missing it in UoWs. - builder.RegisterInstance(DefaultTraversal.CreateTraversalFunc()); - - // Object Builders - builder.RegisterType().As().InstancePerLifetimeScope(); - builder - .RegisterType() - .As>() - .SingleInstance(); - builder.RegisterType().As().SingleInstance(); - - // Register bindings - builder.RegisterType().As().SingleInstance(); - builder.RegisterType().As().SingleInstance().WithParameter("connectorName", "Autocad"); // POC: Easier like this for now, should be cleaned up later - builder.RegisterType().As().SingleInstance(); - builder.RegisterType().As().As().SingleInstance(); - builder.RegisterType().As().SingleInstance(); - builder.RegisterType().As().SingleInstance(); - builder.RegisterType().As().SingleInstance(); - builder - .RegisterType() - .As>() - .SingleInstance(); - - // binding dependencies - builder.RegisterType().InstancePerDependency(); - - // register send filters - builder.RegisterType().As().InstancePerDependency(); - - // Register converter factory - builder.RegisterType().As().InstancePerLifetimeScope(); - - builder.RegisterType().As().InstancePerDependency(); - } - - private static JsonSerializerSettings GetJsonSerializerSettings() - { - // Register WebView2 panel stuff - JsonSerializerSettings settings = - new() - { - Error = (_, args) => - { - Console.WriteLine("*** JSON ERROR: " + args.ErrorContext); - }, - ContractResolver = new CamelCasePropertyNamesContractResolver(), - NullValueHandling = NullValueHandling.Ignore, - ReferenceLoopHandling = ReferenceLoopHandling.Ignore, - DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate, - Converters = { new DiscriminatedObjectConverter(), new AbstractConverter() } - }; - return settings; - } - - private static void RegisterLoggerFactory(ContainerBuilder builder) - { - var serilogLogger = new LoggerConfiguration().MinimumLevel - .Debug() - .WriteTo.File("log.txt", rollingInterval: RollingInterval.Day) - .CreateLogger(); - - ILoggerFactory loggerFactory = new LoggerFactory().AddSerilog(serilogLogger); - builder.RegisterInstance(loggerFactory).As().SingleInstance(); - } -} diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/AutocadDocumentModelStore.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/AutocadDocumentModelStore.cs index aca2df3076..17ebfccee0 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/AutocadDocumentModelStore.cs +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/AutocadDocumentModelStore.cs @@ -12,10 +12,9 @@ public class AutocadDocumentStore : DocumentModelStore public AutocadDocumentStore( JsonSerializerSettings jsonSerializerSettings, - AutocadDocumentManager autocadDocumentManager, - bool writeToFileOnChange + AutocadDocumentManager autocadDocumentManager ) - : base(jsonSerializerSettings, writeToFileOnChange) + : base(jsonSerializerSettings, true) { _autocadDocumentManager = autocadDocumentManager; _previousDocName = _nullDocumentName; diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Plugin/AutocadCommand.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Plugin/AutocadCommand.cs index 996dcaa90b..6727399792 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Plugin/AutocadCommand.cs +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Plugin/AutocadCommand.cs @@ -1,13 +1,10 @@ using System.Drawing; +using System.Reflection; using Autodesk.AutoCAD.Runtime; using Autodesk.AutoCAD.Windows; -using Autofac; using Speckle.Autofac.DependencyInjection; -using Speckle.Autofac.Files; using Speckle.Connectors.Autocad.HostApp; -using Speckle.Converters.Common.Objects; using Speckle.Core.Kits; -using Speckle.Converters.Common.DependencyInjection; using Speckle.Connectors.Autocad.Interfaces; using Speckle.Connectors.DUI.WebView; @@ -19,7 +16,7 @@ public class AutocadCommand private static readonly Guid s_id = new("3223E594-1B09-4E54-B3DD-8EA0BECE7BA5"); private IAutocadPlugin? _autocadPlugin; - public AutofacContainer? Container { get; private set; } + public SpeckleContainer? Container { get; private set; } [CommandMethod("SpeckleNewUI")] public void Command() @@ -36,12 +33,14 @@ public void Command() DockEnabled = (DockSides)((int)DockSides.Left + (int)DockSides.Right) }; - Container = new AutofacContainer(new StorageInfo()); - Container.PreBuildEvent += ContainerPreBuildEvent; + var builder = SpeckleContainerBuilder.CreateInstance(); var autocadSettings = new AutocadSettings(HostApplications.AutoCAD, HostAppVersion.v2023); - Container.LoadAutofacModules(autocadSettings.Modules).AddSingletonInstance(autocadSettings).Build(); + Container = builder + .LoadAutofacModules(Assembly.GetExecutingAssembly(), autocadSettings.Modules) + .AddSingleton(autocadSettings) + .Build(); // Resolve root plugin object and initialise. _autocadPlugin = Container.Resolve(); @@ -62,11 +61,4 @@ private void FocusPalette() PaletteSet.Visible = true; } } - - private void ContainerPreBuildEvent(object sender, ContainerBuilder containerBuilder) - { - containerBuilder.RegisterRawConversions(); - containerBuilder.InjectNamedTypes(); - containerBuilder.InjectNamedTypes(); - } } diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Speckle.Connectors.AutocadShared.projitems b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Speckle.Connectors.AutocadShared.projitems index 7a352d9712..271ae9efd6 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Speckle.Connectors.AutocadShared.projitems +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Speckle.Connectors.AutocadShared.projitems @@ -13,7 +13,7 @@ - + diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.Revit2023/Speckle.Connectors.Revit2023.csproj b/DUI3-DX/Connectors/Revit/Speckle.Connectors.Revit2023/Speckle.Connectors.Revit2023.csproj index 87cb2acb1c..9927081c9c 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.Revit2023/Speckle.Connectors.Revit2023.csproj +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.Revit2023/Speckle.Connectors.Revit2023.csproj @@ -31,7 +31,6 @@ - diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/AutofacUIModule.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/AutofacUIModule.cs deleted file mode 100644 index 006b05aef2..0000000000 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/AutofacUIModule.cs +++ /dev/null @@ -1,111 +0,0 @@ -using System.Diagnostics.CodeAnalysis; -using Autodesk.Revit.DB; -using Autofac; -using CefSharp; -using Microsoft.Extensions.Logging; -using Serilog; -using Speckle.Autofac.DependencyInjection; -using Speckle.Connectors.DUI.Bindings; -using Speckle.Connectors.DUI.Bridge; -using Speckle.Connectors.DUI.Models; -using Speckle.Connectors.DUI.Models.Card.SendFilter; -using Speckle.Connectors.DUI.Utils; -using Speckle.Connectors.Revit.Bindings; -using Speckle.Connectors.Revit.HostApp; -using Speckle.Connectors.Revit.Operations.Send; -using Speckle.Connectors.Revit.Plugin; -using Speckle.Connectors.Utils.Builders; -using Speckle.Connectors.Utils.Operations; -using Speckle.Converters.RevitShared.Helpers; -using Speckle.Core.Transports; -using Speckle.Newtonsoft.Json; -using Speckle.Newtonsoft.Json.Serialization; - -namespace Speckle.Connectors.Revit.DependencyInjection; - -// POC: should interface out things that are not -public class AutofacUIModule : Module -{ - [SuppressMessage( - "Maintainability", - "CA1506:Avoid excessive class coupling", - Justification = "This is registering everything" - )] - protected override void Load(ContainerBuilder builder) - { - builder.RegisterInstance(new RevitContext()); - - // POC: different versons for different versions of CEF - builder.RegisterInstance(BindingOptions.DefaultBinder); - - // create JSON Settings - // POC: this could be created through a factory or delegate, maybe delegate factory - // https://autofac.readthedocs.io/en/latest/advanced/delegate-factories.html - JsonSerializerSettings settings = - new() - { - Error = (object sender, Newtonsoft.Json.Serialization.ErrorEventArgs args) => - { - Console.WriteLine("*** JSON ERROR: " + args.ErrorContext.ToString()); - }, - ContractResolver = new CamelCasePropertyNamesContractResolver(), - NullValueHandling = NullValueHandling.Ignore, - ReferenceLoopHandling = ReferenceLoopHandling.Ignore, - DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate, - Converters = { new DiscriminatedObjectConverter(), new AbstractConverter() } - }; - - var panel = new CefSharpPanel(); - panel.Browser.JavascriptObjectRepository.NameConverter = null; - - builder.RegisterInstance(panel).SingleInstance(); - builder.RegisterInstance(settings).SingleInstance(); - builder.RegisterType().As().SingleInstance(); - builder.RegisterType().As().InstancePerDependency(); - - // register - builder - .RegisterType() - .As() - .SingleInstance() - .WithParameter("writeToFileOnChange", true); - - // Storage Schema - builder.RegisterType().InstancePerLifetimeScope(); - builder.RegisterType().InstancePerLifetimeScope(); - - // POC: we need to review the scopes and create a document on what the policy is - // and where the UoW should be - // register UI bindings - builder.RegisterType().As().SingleInstance(); - builder.RegisterType().As().SingleInstance().WithParameter("connectorName", "Revit"); // POC: Easier like this for now, should be cleaned up later - builder.RegisterType().As().SingleInstance(); - builder.RegisterType().As().SingleInstance(); - builder.RegisterType().As().SingleInstance(); - builder.RegisterType().As().SingleInstance(); - builder.RegisterType().As().SingleInstance(); - - // send operation and dependencies - builder.RegisterType().As().SingleInstance().AutoActivate(); - builder.RegisterType>().AsSelf().InstancePerLifetimeScope(); - builder.RegisterType().AsSelf().InstancePerLifetimeScope(); - builder.RegisterType().AsSelf().InstancePerLifetimeScope(); - builder.RegisterType().As>().InstancePerLifetimeScope(); - builder.RegisterType().As().InstancePerDependency(); - builder.RegisterType().As().SingleInstance(); - - // POC: this can be injected in maybe a common place, perhaps a module in Speckle.Converters.Common.DependencyInjection - builder.RegisterType().As().InstancePerLifetimeScope(); - - // POC: logging factory couldn't be added, which is the recommendation, due to janky dependencies - // having a SpeckleLogging service, might be interesting, if a service can listen on a local port or use named pipes - - var serilogLogger = new LoggerConfiguration().MinimumLevel - .Debug() - .WriteTo.File("log.txt", rollingInterval: RollingInterval.Day) - .CreateLogger(); - - ILoggerFactory loggerFactory = new LoggerFactory().AddSerilog(serilogLogger); - builder.RegisterInstance(loggerFactory).As().SingleInstance(); - } -} diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/RevitConnectorShared.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/RevitConnectorShared.cs new file mode 100644 index 0000000000..b9e5bf7556 --- /dev/null +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/RevitConnectorShared.cs @@ -0,0 +1,61 @@ +using Autodesk.Revit.DB; +using CefSharp; +using Speckle.Autofac; +using Speckle.Autofac.DependencyInjection; +using Speckle.Connectors.DUI; +using Speckle.Connectors.DUI.Bindings; +using Speckle.Connectors.DUI.Models; +using Speckle.Connectors.Revit.Bindings; +using Speckle.Connectors.Revit.HostApp; +using Speckle.Connectors.Revit.Operations.Send; +using Speckle.Connectors.Revit.Plugin; +using Speckle.Connectors.Utils; +using Speckle.Connectors.Utils.Builders; +using Speckle.Connectors.Utils.Operations; + +namespace Speckle.Connectors.Revit.DependencyInjection; + +// POC: should interface out things that are not +public class RevitConnectorModule : ISpeckleModule +{ + public void Load(SpeckleContainerBuilder builder) + { + builder.AddAutofac(); + builder.AddConnectorUtils(); + builder.AddDUI(); + //builder.AddDUIView(); + + // POC: different versons for different versions of CEF + builder.AddSingleton(BindingOptions.DefaultBinder); + + var panel = new CefSharpPanel(); + panel.Browser.JavascriptObjectRepository.NameConverter = null; + + builder.AddSingleton(panel); + builder.AddSingleton(); + + // register + builder.AddSingleton(); + + // Storage Schema + builder.AddScoped(); + builder.AddScoped(); + + // POC: we need to review the scopes and create a document on what the policy is + // and where the UoW should be + // register UI bindings + builder.AddSingleton(); + builder.AddSingleton("connectorName", "ArcGIS"); // POC: Easier like this for now, should be cleaned up later + builder.AddSingleton(); + builder.AddSingleton(); + builder.AddSingleton(); + builder.AddSingleton(); + builder.AddSingleton(); + //no receive? + builder.AddSingleton(); + + // send operation and dependencies + builder.AddScoped>(); + builder.AddScoped, RootObjectBuilder>(); + } +} diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/RevitDocumentStore.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/RevitDocumentStore.cs index 0c5807aed1..6d31480be2 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/RevitDocumentStore.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/RevitDocumentStore.cs @@ -29,10 +29,9 @@ public RevitDocumentStore( RevitContext revitContext, JsonSerializerSettings serializerSettings, DocumentModelStorageSchema documentModelStorageSchema, - IdStorageSchema idStorageSchema, - bool writeToFileOnChange + IdStorageSchema idStorageSchema ) - : base(serializerSettings, writeToFileOnChange) + : base(serializerSettings, true) { _idleManager = idleManager; _revitContext = revitContext; diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitExternalApplication.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitExternalApplication.cs index d5ae6e8a80..c84c839054 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitExternalApplication.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitExternalApplication.cs @@ -1,12 +1,9 @@ using Autodesk.Revit.UI; using Speckle.Autofac.DependencyInjection; -using Speckle.Autofac.Files; using System.IO; -using Autofac; +using System.Reflection; using Speckle.Autofac; using Speckle.Connectors.Utils; -using Speckle.Converters.Common.DependencyInjection; -using Speckle.Converters.Common.Objects; using Speckle.Core.Logging; namespace Speckle.Connectors.Revit.Plugin; @@ -15,7 +12,7 @@ internal sealed class RevitExternalApplication : IExternalApplication { private IRevitPlugin? _revitPlugin; - private AutofacContainer? _container; + private SpeckleContainer? _container; // POC: this is getting hard coded - need a way of injecting it // I am beginning to think the shared project is not the way @@ -48,15 +45,12 @@ public Result OnStartup(UIControlledApplication application) { // POC: not sure what this is doing... could be messing up our Aliasing???? AppDomain.CurrentDomain.AssemblyResolve += AssemblyResolver.OnAssemblyResolve; - - _container = new AutofacContainer(new StorageInfo()); - _container.PreBuildEvent += ContainerPreBuildEvent; - + var containerBuilder = SpeckleContainerBuilder.CreateInstance(); // init DI - _container - .LoadAutofacModules(_revitSettings.ModuleFolders.NotNull()) - .AddSingletonInstance(_revitSettings) // apply revit settings into DI - .AddSingletonInstance(application) // inject UIControlledApplication application + _container = containerBuilder + .LoadAutofacModules(Assembly.GetExecutingAssembly(), _revitSettings.ModuleFolders.NotNull()) + .AddSingleton(_revitSettings) // apply revit settings into DI + .AddSingleton(application) // inject UIControlledApplication application .Build(); // resolve root object @@ -72,14 +66,6 @@ public Result OnStartup(UIControlledApplication application) return Result.Succeeded; } - private void ContainerPreBuildEvent(object sender, ContainerBuilder containerBuilder) - { - // POC: need to settle on the mechanism and location as to where we should register these services - containerBuilder.RegisterRawConversions(); - containerBuilder.InjectNamedTypes(); - containerBuilder.InjectNamedTypes(); - } - public Result OnShutdown(UIControlledApplication application) { try diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Speckle.Connectors.RevitShared.projitems b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Speckle.Connectors.RevitShared.projitems index 6543a56b68..2391c8144a 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Speckle.Connectors.RevitShared.projitems +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Speckle.Connectors.RevitShared.projitems @@ -26,7 +26,7 @@ - + CefSharpPanel.xaml diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/AutofacRhinoModule.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/AutofacRhinoModule.cs deleted file mode 100644 index 33e848d795..0000000000 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/AutofacRhinoModule.cs +++ /dev/null @@ -1,116 +0,0 @@ -using Autofac; -using Microsoft.Extensions.Logging; -using Rhino.Commands; -using Rhino.DocObjects; -using Rhino.PlugIns; -using Serilog; -using Speckle.Autofac.DependencyInjection; -using Speckle.Connectors.DUI.Bindings; -using Speckle.Connectors.DUI.Bridge; -using Speckle.Connectors.DUI.Models; -using Speckle.Connectors.DUI.Utils; -using Speckle.Connectors.Rhino7.Bindings; -using Speckle.Connectors.Rhino7.Filters; -using Speckle.Connectors.Rhino7.HostApp; -using Speckle.Connectors.Rhino7.Interfaces; -using Speckle.Connectors.Rhino7.Operations.Send; -using Speckle.Connectors.Rhino7.Plugin; -using Speckle.Connectors.Utils.Cancellation; -using Speckle.Core.Transports; -using Speckle.Newtonsoft.Json; -using Speckle.Newtonsoft.Json.Serialization; -using Speckle.Connectors.DUI.Models.Card.SendFilter; -using Speckle.Connectors.DUI.WebView; -using Speckle.Connectors.Rhino7.Operations.Receive; -using Speckle.Connectors.Utils.Builders; -using Speckle.Connectors.Utils.Operations; -using Speckle.Core.Models.GraphTraversal; - -namespace Speckle.Connectors.Rhino7.DependencyInjection; - -public class AutofacRhinoModule : Module -{ - protected override void Load(ContainerBuilder builder) - { - RegisterLoggerFactory(builder); - - // Register instances initialised by Rhino - builder.RegisterInstance(SpeckleConnectorsRhino7Plugin.Instance); - builder.RegisterInstance(SpeckleConnectorsRhino7Command.Instance); - - // Register DUI3 related stuff - builder.RegisterInstance(GetJsonSerializerSettings()).SingleInstance(); - builder.RegisterType().SingleInstance(); - builder.RegisterType().As().InstancePerDependency(); // POC: Each binding should have it's own bridge instance - - // Register other connector specific types - builder.RegisterType().As().SingleInstance(); - builder - .RegisterType() - .As() - .SingleInstance() - .WithParameter("writeToFileOnChange", true); - builder.RegisterType().SingleInstance(); - - // Register bindings - builder.RegisterType().As().SingleInstance(); - builder.RegisterType().As().SingleInstance().WithParameter("connectorName", "Rhino"); // POC: Easier like this for now, should be cleaned up later - builder.RegisterType().As().SingleInstance(); - builder.RegisterType().As().As().SingleInstance(); - builder.RegisterType().As().SingleInstance(); - builder.RegisterType().As().SingleInstance(); - builder.RegisterType().As().SingleInstance(); - - // binding dependencies - builder.RegisterType().InstancePerDependency(); - - // register send filters - builder.RegisterType().As().InstancePerDependency(); - - // register send operation and dependencies - builder.RegisterType().As().InstancePerLifetimeScope(); - builder.RegisterType>().InstancePerLifetimeScope(); - builder.RegisterType().InstancePerLifetimeScope(); - builder.RegisterInstance(DefaultTraversal.CreateTraversalFunc()); - builder.RegisterType().As().SingleInstance(); - - builder.RegisterType().As().InstancePerLifetimeScope(); - - builder.RegisterType().As>().SingleInstance(); - builder.RegisterType().As().SingleInstance(); - - builder.RegisterType().As().InstancePerDependency(); - } - - private static JsonSerializerSettings GetJsonSerializerSettings() - { - // Register WebView2 panel stuff - JsonSerializerSettings settings = - new() - { - Error = (_, args) => - { - // POC: we should probably do a bit more than just swallowing this! - Console.WriteLine("*** JSON ERROR: " + args.ErrorContext); - }, - ContractResolver = new CamelCasePropertyNamesContractResolver(), - NullValueHandling = NullValueHandling.Ignore, - ReferenceLoopHandling = ReferenceLoopHandling.Ignore, - DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate, - Converters = { new DiscriminatedObjectConverter(), new AbstractConverter() } - }; - return settings; - } - - private static void RegisterLoggerFactory(ContainerBuilder builder) - { - // POC: will likely need refactoring with our reporting pattern. - var serilogLogger = new LoggerConfiguration().MinimumLevel - .Debug() - .WriteTo.File("log.txt", rollingInterval: RollingInterval.Day) - .CreateLogger(); - - ILoggerFactory loggerFactory = new LoggerFactory().AddSerilog(serilogLogger); - builder.RegisterInstance(loggerFactory).As().SingleInstance(); - } -} diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/RhinoConnectorModule.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/RhinoConnectorModule.cs new file mode 100644 index 0000000000..ebda7699de --- /dev/null +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/RhinoConnectorModule.cs @@ -0,0 +1,67 @@ +using Rhino.Commands; +using Rhino.DocObjects; +using Rhino.PlugIns; +using Speckle.Autofac; +using Speckle.Autofac.DependencyInjection; +using Speckle.Connectors.DUI; +using Speckle.Connectors.DUI.Bindings; +using Speckle.Connectors.DUI.Models; +using Speckle.Connectors.Rhino7.Bindings; +using Speckle.Connectors.Rhino7.Filters; +using Speckle.Connectors.Rhino7.HostApp; +using Speckle.Connectors.Rhino7.Interfaces; +using Speckle.Connectors.Rhino7.Operations.Send; +using Speckle.Connectors.Rhino7.Plugin; +using Speckle.Connectors.Utils.Cancellation; +using Speckle.Connectors.DUI.Models.Card.SendFilter; +using Speckle.Connectors.DUI.WebView; +using Speckle.Connectors.Rhino7.Operations.Receive; +using Speckle.Connectors.Utils; +using Speckle.Connectors.Utils.Builders; +using Speckle.Connectors.Utils.Operations; +using Speckle.Core.Models.GraphTraversal; + +namespace Speckle.Connectors.Rhino7.DependencyInjection; + +public class RhinoConnectorModule : ISpeckleModule +{ + public void Load(SpeckleContainerBuilder builder) + { + // Register instances initialised by Rhino + builder.AddSingleton(SpeckleConnectorsRhino7Plugin.Instance); + builder.AddSingleton(SpeckleConnectorsRhino7Command.Instance); + + builder.AddAutofac(); + builder.AddConnectorUtils(); + builder.AddDUI(); + builder.AddDUIView(); + + // Register other connector specific types + builder.AddSingleton(); + builder.AddSingleton(); + builder.AddSingleton(); + + // Register bindings + builder.AddSingleton(); + builder.AddSingleton("connectorName", "Rhino"); // POC: Easier like this for now, should be cleaned up later + builder.AddSingleton(); + builder.AddSingleton(); + builder.AddSingleton(); + builder.AddSingleton(); + builder.AddSingleton(); + builder.AddSingleton(); + + // binding dependencies + builder.AddTransient(); + + // register send filters + builder.AddScoped(); + builder.AddScoped(); + + // register send operation and dependencies + builder.AddScoped>(); + builder.AddSingleton(DefaultTraversal.CreateTraversalFunc()); + + builder.AddSingleton, RootObjectBuilder>(); + } +} diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/RhinoDocumentStore.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/RhinoDocumentStore.cs index c705a27612..2545b44089 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/RhinoDocumentStore.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/RhinoDocumentStore.cs @@ -9,8 +9,8 @@ public class RhinoDocumentStore : DocumentModelStore private const string SPECKLE_KEY = "Speckle_DUI3"; public override bool IsDocumentInit { get; set; } = true; // Note: because of rhino implementation details regarding expiry checking of sender cards. - public RhinoDocumentStore(JsonSerializerSettings jsonSerializerSettings, bool writeToFileOnChange) - : base(jsonSerializerSettings, writeToFileOnChange) + public RhinoDocumentStore(JsonSerializerSettings jsonSerializerSettings) + : base(jsonSerializerSettings, true) { RhinoDoc.BeginOpenDocument += (_, _) => IsDocumentInit = false; RhinoDoc.EndOpenDocument += (_, e) => diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Plugin/Speckle.Connectors.Rhino7Plugin.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Plugin/Speckle.Connectors.Rhino7Plugin.cs index 8b2013164e..8dff82b2d5 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Plugin/Speckle.Connectors.Rhino7Plugin.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Plugin/Speckle.Connectors.Rhino7Plugin.cs @@ -1,8 +1,7 @@ -using Rhino.PlugIns; +using System.Reflection; +using Rhino.PlugIns; using Speckle.Autofac; using Speckle.Autofac.DependencyInjection; -using Speckle.Autofac.Files; -using Speckle.Connectors.Rhino7.DependencyInjection; using Speckle.Connectors.Rhino7.HostApp; using Speckle.Connectors.Rhino7.Interfaces; using Speckle.Core.Kits; @@ -24,7 +23,7 @@ public class SpeckleConnectorsRhino7Plugin : PlugIn private IRhinoPlugin? _rhinoPlugin; protected override string LocalPlugInName => "Speckle (New UI)"; - public AutofacContainer? Container { get; private set; } + public SpeckleContainer? Container { get; private set; } public SpeckleConnectorsRhino7Plugin() { @@ -46,17 +45,16 @@ protected override LoadReturnCode OnLoad(ref string errorMessage) { AppDomain.CurrentDomain.AssemblyResolve += AssemblyResolver.OnAssemblyResolve; - Container = new AutofacContainer(new StorageInfo()); + var builder = SpeckleContainerBuilder.CreateInstance(); // Register Settings var rhinoSettings = new RhinoSettings(HostApplications.Rhino, HostAppVersion.v7); // POC: We must load the Rhino connector module manually because we only search for DLL files when calling `LoadAutofacModules`, // but the Rhino connector has `.rhp` as it's extension. - Container - .AddModule(new AutofacRhinoModule()) - .LoadAutofacModules(rhinoSettings.Modules) - .AddSingletonInstance(rhinoSettings) + Container = builder + .LoadAutofacModules(Assembly.GetExecutingAssembly(), rhinoSettings.Modules) + .AddSingleton(rhinoSettings) .Build(); // Resolve root plugin object and initialise. diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Speckle.Connectors.Rhino7.csproj b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Speckle.Connectors.Rhino7.csproj index 93511a0028..eddc6f5826 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Speckle.Connectors.Rhino7.csproj +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Speckle.Connectors.Rhino7.csproj @@ -12,16 +12,15 @@ - - + diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3.DependencyInjection/ArcGISConverterModule.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3.DependencyInjection/ArcGISConverterModule.cs new file mode 100644 index 0000000000..fc7cc0b773 --- /dev/null +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3.DependencyInjection/ArcGISConverterModule.cs @@ -0,0 +1,28 @@ +using ArcGIS.Core.Geometry; +using ArcGIS.Desktop.Mapping; +using Speckle.Autofac.DependencyInjection; +using Speckle.Converters.ArcGIS3.Utils; +using Speckle.Converters.Common; +using Speckle.Converters.Common.DependencyInjection; + +namespace Speckle.Converters.ArcGIS3.DependencyInjection; + +public class ArcGISConverterModule : ISpeckleModule +{ + public void Load(SpeckleContainerBuilder builder) + { + builder.AddConverterCommon(); + // most things should be InstancePerLifetimeScope so we get one per operation + builder.AddScoped(); + builder.AddScoped(); + builder.AddScoped(); + builder.AddScoped(); + builder.AddScoped(); + builder.AddScoped(); + + builder.AddScoped, ArcGISToSpeckleUnitConverter>(); + + // single stack per conversion + builder.AddScoped, ArcGISConversionContextStack>(); + } +} diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3.DependencyInjection/AutofacArcGIS3ConverterModule.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3.DependencyInjection/AutofacArcGIS3ConverterModule.cs deleted file mode 100644 index de255199a0..0000000000 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3.DependencyInjection/AutofacArcGIS3ConverterModule.cs +++ /dev/null @@ -1,52 +0,0 @@ -// POC: not sure we should have this here as it attaches us to autofac, maybe a bit prematurely... - -using ArcGIS.Core.Geometry; -using ArcGIS.Desktop.Mapping; -using Autofac; -using Speckle.Autofac.DependencyInjection; -using Speckle.Converters.ArcGIS3.Utils; -using Speckle.Converters.Common; -using Speckle.Converters.Common.DependencyInjection.ToHost; -using Speckle.Converters.Common.Objects; - -namespace Speckle.Converters.ArcGIS3.DependencyInjection; - -public class AutofacArcGISConverterModule : Module -{ - protected override void Load(ContainerBuilder builder) - { - // most things should be InstancePerLifetimeScope so we get one per operation - builder.RegisterType().As().InstancePerLifetimeScope(); - builder.RegisterType().As().InstancePerLifetimeScope(); - builder.RegisterType().As().InstancePerLifetimeScope(); - builder.RegisterType().As().InstancePerLifetimeScope(); - builder.RegisterType().As().InstancePerLifetimeScope(); - builder.RegisterType().As().InstancePerLifetimeScope(); - builder.RegisterType().As().InstancePerLifetimeScope(); - - builder - .RegisterType() - .As>() - .InstancePerLifetimeScope(); - - // single stack per conversion - builder - .RegisterType() - .As>() - .InstancePerLifetimeScope(); - - // factory for conversions - builder - .RegisterType>() - .As>() - .InstancePerLifetimeScope(); - builder - .RegisterType>() - .As>() - .InstancePerLifetimeScope(); - builder - .RegisterType>() - .As>() - .InstancePerLifetimeScope(); - } -} diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2023.DependencyInjection/AutocadConverterModule.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2023.DependencyInjection/AutocadConverterModule.cs new file mode 100644 index 0000000000..5b2f42298d --- /dev/null +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2023.DependencyInjection/AutocadConverterModule.cs @@ -0,0 +1,22 @@ +using Autodesk.AutoCAD.ApplicationServices; +using Autodesk.AutoCAD.DatabaseServices; +using Speckle.Autofac.DependencyInjection; +using Speckle.Converters.Autocad; +using Speckle.Converters.Common; +using Speckle.Converters.Common.DependencyInjection; + +namespace Speckle.Converters.Autocad2023.DependencyInjection; + +public class AutocadConverterModule : ISpeckleModule +{ + public void Load(SpeckleContainerBuilder builder) + { + builder.AddConverterCommon(); + // POC: below comment maybe incorrect (sorry if I wrote that!) stateless services + // can be injected as Singleton(), only where we have state we wish to wrap in a unit of work + builder.AddScoped(); + + // single stack per conversion + builder.AddScoped, AutocadConversionContextStack>(); + } +} diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2023.DependencyInjection/AutofacAutocadConverterModule.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2023.DependencyInjection/AutofacAutocadConverterModule.cs deleted file mode 100644 index ba5890a6bb..0000000000 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2023.DependencyInjection/AutofacAutocadConverterModule.cs +++ /dev/null @@ -1,42 +0,0 @@ -using Autodesk.AutoCAD.ApplicationServices; -using Autodesk.AutoCAD.DatabaseServices; -using Autofac; -using Speckle.Autofac.DependencyInjection; -using Speckle.Converters.Autocad; -using Speckle.Converters.Common; -using Speckle.Converters.Common.DependencyInjection.ToHost; -using Speckle.Converters.Common.Objects; - -namespace Speckle.Converters.Autocad2023.DependencyInjection; - -public class AutofacAutocadConverterModule : Module -{ - protected override void Load(ContainerBuilder builder) - { - // POC: below comment maybe incorrect (sorry if I wrote that!) stateless services - // can be injected as Singleton(), only where we have state we wish to wrap in a unit of work - builder.RegisterType().As().InstancePerLifetimeScope(); - builder.RegisterType().As().InstancePerLifetimeScope(); - - // single stack per conversion - builder - .RegisterType() - .As>() - .InstancePerLifetimeScope(); - - // factory for conversions - builder - .RegisterType>() - .As>() - .InstancePerLifetimeScope(); - - builder - .RegisterType>() - .As>() - .InstancePerLifetimeScope(); - builder - .RegisterType>() - .As>() - .InstancePerLifetimeScope(); - } -} diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/AutofacRevitConverterModule.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/AutofacRevitConverterModule.cs deleted file mode 100644 index f8399dc827..0000000000 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/AutofacRevitConverterModule.cs +++ /dev/null @@ -1,54 +0,0 @@ -// POC: not sure we should have this here as it attaches us to autofac, maybe a bit prematurely... - -using Autodesk.Revit.DB; -using Autofac; -using Speckle.Autofac.DependencyInjection; -using Speckle.Converters.Common; -using Speckle.Converters.Common.Objects; -using Speckle.Converters.RevitShared; -using Speckle.Converters.RevitShared.Helpers; -using Speckle.Converters.RevitShared.Services; -using Speckle.Converters.RevitShared.ToSpeckle; - -namespace Speckle.Converters.Revit2023.DependencyInjection; - -public class AutofacRevitConverterModule : Module -{ - protected override void Load(ContainerBuilder builder) - { - // most things should be InstancePerLifetimeScope so we get one per operation - builder.RegisterType().As().InstancePerLifetimeScope(); - - // factory for conversions - builder - .RegisterType>() - .As>() - .InstancePerLifetimeScope(); - builder - .RegisterType>() - .As>() - .InstancePerLifetimeScope(); - - // POC: do we need ToSpeckleScalingService as is, do we need to interface it out? - builder.RegisterType().AsSelf().InstancePerLifetimeScope(); - - // POC: the concrete type can come out if we remove all the reference to it - builder.RegisterType().As().InstancePerLifetimeScope(); - - builder - .RegisterType() - .As>() - .InstancePerLifetimeScope(); - - builder.RegisterType().As().InstancePerLifetimeScope(); - builder.RegisterType().AsSelf().InstancePerLifetimeScope(); - - builder.RegisterType().As().InstancePerLifetimeScope(); - - builder.RegisterType().AsSelf().InstancePerLifetimeScope(); - builder.RegisterType().AsSelf().InstancePerLifetimeScope(); - builder.RegisterType().AsSelf().InstancePerLifetimeScope(); - builder.RegisterType().AsSelf().InstancePerLifetimeScope(); - builder.RegisterType().As().InstancePerLifetimeScope(); - } -} diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/RevitConverterModule.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/RevitConverterModule.cs new file mode 100644 index 0000000000..e7cf89a01f --- /dev/null +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/RevitConverterModule.cs @@ -0,0 +1,42 @@ +using Autodesk.Revit.DB; +using Speckle.Autofac.DependencyInjection; +using Speckle.Converters.Common; +using Speckle.Converters.Common.DependencyInjection; +using Speckle.Converters.RevitShared; +using Speckle.Converters.RevitShared.Helpers; +using Speckle.Converters.RevitShared.Services; +using Speckle.Converters.RevitShared.ToSpeckle; + +namespace Speckle.Converters.Revit2023.DependencyInjection; + +public class RevitConverterModule : ISpeckleModule +{ + public void Load(SpeckleContainerBuilder builder) + { + builder.AddConverterCommon(); + builder.AddSingleton(new RevitContext()); + // most things should be InstancePerLifetimeScope so we get one per operation + builder.AddScoped(); + + // POC: do we need ToSpeckleScalingService as is, do we need to interface it out? + builder.AddScoped(); + + // POC: the concrete type can come out if we remove all the reference to it + builder.AddScoped(); + + builder.AddScoped, RevitToSpeckleUnitConverter>(); + + builder.AddScoped(); + builder.AddScoped(); + + builder.AddScoped(); + + builder.AddScoped(); + builder.AddScoped(); + builder.AddScoped(); + builder.AddScoped(); + builder.AddScoped(); + builder.AddScoped(); + builder.AddScoped(); + } +} diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/Speckle.Converters.Revit2023.DependencyInjection.csproj b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/Speckle.Converters.Revit2023.DependencyInjection.csproj index 4c6e810627..704fef95ed 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/Speckle.Converters.Revit2023.DependencyInjection.csproj +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/Speckle.Converters.Revit2023.DependencyInjection.csproj @@ -6,14 +6,9 @@ + - - True - - - - - + diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/AutofacRhinoConverterModule.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/AutofacRhinoConverterModule.cs deleted file mode 100644 index 9131d5241c..0000000000 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/AutofacRhinoConverterModule.cs +++ /dev/null @@ -1,56 +0,0 @@ -using Autofac; -using Speckle.Autofac.DependencyInjection; -using Speckle.Converters.Common; -using Speckle.Converters.Common.Objects; -using Rhino; -using Speckle.Converters.Common.DependencyInjection; -using Speckle.Converters.Common.DependencyInjection.ToHost; -using Speckle.Converters.Rhino7.ToSpeckle; - -namespace Speckle.Converters.Rhino7.DependencyInjection; - -public class AutofacRhinoConverterModule : Module -{ - protected override void Load(ContainerBuilder builder) - { - // single stack per conversion - builder - .RegisterType() - .As>() - .InstancePerLifetimeScope(); - - builder.RegisterRawConversions(); - - // To Speckle - builder - .RegisterType() - .As>() - .InstancePerLifetimeScope(); - builder.RegisterType().As().InstancePerLifetimeScope(); - - /* - POC: CNX-9267 Moved the Injection of converters into the converter module. Not sure if this is 100% right, as this doesn't just register the conversions within this converter, but any conversions found in any Speckle.*.dll file. - This will require consolidating across other connectors. - */ - builder.InjectNamedTypes(); - builder - .RegisterType>() - .As>() - .InstancePerLifetimeScope(); - builder - .RegisterType>() - .As>() - .InstancePerLifetimeScope(); - builder.RegisterType().As().InstancePerLifetimeScope(); - - /* - POC: CNX-9267 Moved the Injection of converters into the converter module. Not sure if this is 100% right, as this doesn't just register the conversions within this converter, but any conversions found in any Speckle.*.dll file. - This will require consolidating across other connectors. - */ - builder.InjectNamedTypes(); - builder - .RegisterType>() - .As>() - .InstancePerLifetimeScope(); - } -} diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/RhinoConverterModule.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/RhinoConverterModule.cs new file mode 100644 index 0000000000..c2c0fca280 --- /dev/null +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/RhinoConverterModule.cs @@ -0,0 +1,21 @@ +using Speckle.Autofac.DependencyInjection; +using Speckle.Converters.Common; +using Rhino; +using Speckle.Converters.Common.DependencyInjection; +using Speckle.Converters.Rhino7.ToSpeckle; + +namespace Speckle.Converters.Rhino7.DependencyInjection; + +public class RhinoConverterModule : ISpeckleModule +{ + public void Load(SpeckleContainerBuilder builder) + { + builder.AddConverterCommon(); + // single stack per conversion + builder.AddScoped, RhinoConversionContextStack>(); + + // To Speckle + builder.AddScoped, RhinoToSpeckleUnitConverter>(); + builder.AddScoped(); + } +} diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/Speckle.Converters.Rhino7.DependencyInjection.csproj b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/Speckle.Converters.Rhino7.DependencyInjection.csproj index caf7274915..d944ee5ed1 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/Speckle.Converters.Rhino7.DependencyInjection.csproj +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/Speckle.Converters.Rhino7.DependencyInjection.csproj @@ -11,7 +11,6 @@ - diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI.WebView/ContainerRegistration.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI.WebView/ContainerRegistration.cs new file mode 100644 index 0000000000..6d4d2de007 --- /dev/null +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI.WebView/ContainerRegistration.cs @@ -0,0 +1,12 @@ +using Speckle.Autofac.DependencyInjection; + +namespace Speckle.Connectors.DUI.WebView; + +public static class ContainerRegistration +{ + public static void AddDUIView(this SpeckleContainerBuilder speckleContainerBuilder) + { + // send operation and dependencies + speckleContainerBuilder.AddSingleton(); + } +} diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/ContainerRegistration.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/ContainerRegistration.cs new file mode 100644 index 0000000000..3de29febee --- /dev/null +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/ContainerRegistration.cs @@ -0,0 +1,44 @@ +using Speckle.Autofac.DependencyInjection; +using Speckle.Connectors.DUI.Bridge; +using Speckle.Connectors.DUI.Models.Card.SendFilter; +using Speckle.Connectors.DUI.Utils; +using Speckle.Connectors.Utils.Operations; +using Speckle.Core.Transports; +using Speckle.Newtonsoft.Json; +using Speckle.Newtonsoft.Json.Serialization; + +namespace Speckle.Connectors.DUI; + +public static class ContainerRegistration +{ + public static void AddDUI(this SpeckleContainerBuilder speckleContainerBuilder) + { + // send operation and dependencies + speckleContainerBuilder.AddSingletonInstance(); + speckleContainerBuilder.AddTransient(); + speckleContainerBuilder.AddSingleton(); + speckleContainerBuilder.AddTransient(); // POC: Each binding should have it's own bridge instance + + speckleContainerBuilder.AddSingleton(GetJsonSerializerSettings()); + } + + private static JsonSerializerSettings GetJsonSerializerSettings() + { + // Register WebView2 panel stuff + JsonSerializerSettings settings = + new() + { + Error = (_, args) => + { + // POC: we should probably do a bit more than just swallowing this! + Console.WriteLine("*** JSON ERROR: " + args.ErrorContext); + }, + ContractResolver = new CamelCasePropertyNamesContractResolver(), + NullValueHandling = NullValueHandling.Ignore, + ReferenceLoopHandling = ReferenceLoopHandling.Ignore, + DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate, + Converters = { new DiscriminatedObjectConverter(), new AbstractConverter() } + }; + return settings; + } +} diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/DocumentModelStore.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/DocumentModelStore.cs index 65de41e5b8..c43cb83ae3 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/DocumentModelStore.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/DocumentModelStore.cs @@ -34,7 +34,7 @@ protected set /// /// our custom serialiser that should be globally DI'ed in. /// Whether to store the models state in the file on any change. Defaults to false out of caution, but it's recommended to set to true, unless severe host app limitations. - protected DocumentModelStore(JsonSerializerSettings serializerOptions, bool writeToFileOnChange = false) + protected DocumentModelStore(JsonSerializerSettings serializerOptions, bool writeToFileOnChange) { _serializerOptions = serializerOptions; _writeToFileOnChange = writeToFileOnChange; diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Speckle.Connectors.DUI.csproj b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Speckle.Connectors.DUI.csproj index 2e17ee418c..e0a93209c5 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Speckle.Connectors.DUI.csproj +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Speckle.Connectors.DUI.csproj @@ -11,6 +11,7 @@ + diff --git a/DUI3-DX/Sdk/Speckle.Autofac/ContainerRegistration.cs b/DUI3-DX/Sdk/Speckle.Autofac/ContainerRegistration.cs new file mode 100644 index 0000000000..f99b7c6728 --- /dev/null +++ b/DUI3-DX/Sdk/Speckle.Autofac/ContainerRegistration.cs @@ -0,0 +1,12 @@ +using Speckle.Autofac.DependencyInjection; + +namespace Speckle.Autofac; + +public static class ContainerRegistration +{ + public static void AddAutofac(this SpeckleContainerBuilder builder) + { + // send operation and dependencies + builder.AddScoped(); + } +} diff --git a/DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/AutofacContainer.cs b/DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/AutofacContainer.cs deleted file mode 100644 index ceb962573c..0000000000 --- a/DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/AutofacContainer.cs +++ /dev/null @@ -1,107 +0,0 @@ -using System.Reflection; -using Autofac; -using Microsoft.Extensions.Logging; -using Speckle.Autofac.Files; -using Speckle.Core.Logging; -using Module = Autofac.Module; - -namespace Speckle.Autofac.DependencyInjection; - -// POC: wrap the IContainer or expose it? -public class AutofacContainer -{ - // Declare the event. - public event EventHandler? PreBuildEvent; - - private readonly ContainerBuilder _builder; - private readonly IStorageInfo _storageInfo; - - private IContainer? _container; - - public AutofacContainer(IStorageInfo storageInfo) - { - _storageInfo = storageInfo; - - _builder = new ContainerBuilder(); - } - - // POC: HOW TO GET TYPES loaded, this feels a bit heavy handed and relies on Autofac where we can probably do something different - public AutofacContainer LoadAutofacModules(IEnumerable dependencyPaths) - { - // look for assemblies in these paths that offer autofac modules - foreach (string path in dependencyPaths) - { - // POC: naming conventions - // find assemblies - var assembliesInPath = _storageInfo.GetFilenamesInDirectory(path, "Speckle*.dll"); - - foreach (var file in assembliesInPath) - { - // POC: ignore already loaded? Or just get that instead of loading it? - try - { - // inspect the assemblies for Autofac.Module - var assembly = Assembly.LoadFrom(file); - var moduleClasses = assembly.GetTypes().Where(x => x.BaseType == typeof(Module)); - - // create each module - // POC: could look for some attribute here - foreach (var moduleClass in moduleClasses) - { - var module = (Module)Activator.CreateInstance(moduleClass); - _builder.RegisterModule(module); - } - } - // POC: catch only certain exceptions - catch (Exception ex) when (!ex.IsFatal()) { } - } - } - - return this; - } - - public AutofacContainer AddModule(Module module) - { - _builder.RegisterModule(module); - - return this; - } - - public AutofacContainer AddSingletonInstance(T instance) - where T : class - { - _builder.RegisterInstance(instance); - - return this; - } - - public AutofacContainer Build() - { - // before we build give some last minute registration options. - PreBuildEvent?.Invoke(this, _builder); - - _container = _builder.Build(); - - // POC: we could create the factory on construction of the container and then inject that and store it - var logger = _container.Resolve().CreateLogger(); - - // POC: we could probably expand on this - List assemblies = AppDomain.CurrentDomain.GetAssemblies().Select(x => x.FullName).ToList(); - logger.LogInformation("Loaded assemblies: {@Assemblies}", assemblies); - - return this; - } - - public T Resolve() - where T : class - { - if (_container == null) - { - throw new InvalidOperationException( - $"Container was not initialized, {nameof(Build)} must be called before calling {nameof(Resolve)}" - ); - } - - return _container.Resolve(); - } -} diff --git a/DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/ISpeckleModule.cs b/DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/ISpeckleModule.cs new file mode 100644 index 0000000000..795caa576c --- /dev/null +++ b/DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/ISpeckleModule.cs @@ -0,0 +1,6 @@ +namespace Speckle.Autofac.DependencyInjection; + +public interface ISpeckleModule +{ + void Load(SpeckleContainerBuilder builder); +} diff --git a/DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/SpeckleContainer.cs b/DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/SpeckleContainer.cs new file mode 100644 index 0000000000..189481d641 --- /dev/null +++ b/DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/SpeckleContainer.cs @@ -0,0 +1,19 @@ +using Autofac; + +namespace Speckle.Autofac.DependencyInjection; + +public class SpeckleContainer +{ + private readonly IContainer _container; + + public SpeckleContainer(IContainer container) + { + _container = container; + } + + public T Resolve() + where T : class + { + return _container.Resolve(); + } +} diff --git a/DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/SpeckleContainerBuilder.cs b/DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/SpeckleContainerBuilder.cs new file mode 100644 index 0000000000..45c162f3ae --- /dev/null +++ b/DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/SpeckleContainerBuilder.cs @@ -0,0 +1,199 @@ +using System.Reflection; +using Autofac; +using Microsoft.Extensions.Logging; +using Speckle.Autofac.Files; +using Speckle.Core.Logging; +using Module = Autofac.Module; + +namespace Speckle.Autofac.DependencyInjection; + +public class SpeckleContainerBuilder +{ + private static readonly Type s_moduleType = typeof(ISpeckleModule); + private readonly IStorageInfo _storageInfo; + + private SpeckleContainerBuilder(IStorageInfo storageInfo, ContainerBuilder? containerBuilder) + { + _storageInfo = storageInfo; + ContainerBuilder = containerBuilder ?? new ContainerBuilder(); + } + + public static SpeckleContainerBuilder CreateInstance() => new(new StorageInfo(), null); + + private static SpeckleContainerBuilder CreateInstanceForLoading(ContainerBuilder containerBuilder) => + new(new StorageInfo(), containerBuilder); + + // POC: HOW TO GET TYPES loaded, this feels a bit heavy handed and relies on Autofac where we can probably do something different + public SpeckleContainerBuilder LoadAutofacModules(Assembly pluginAssembly, IEnumerable dependencyPaths) + { + // look for assemblies in these paths that offer autofac modules + foreach (string path in dependencyPaths) + { + // POC: naming conventions + // find assemblies + var assembliesInPath = _storageInfo.GetFilenamesInDirectory(path, "Speckle*.dll"); + var assemblies = assembliesInPath.Select(LoadAssemblyFile).ToList(); + if (assemblies.All(x => x != pluginAssembly)) + { + LoadAssembly(pluginAssembly); + } + } + + return this; + } + + private Assembly? LoadAssemblyFile(string file) + { + try + { + // inspect the assemblies for Autofac.Module + var assembly = Assembly.LoadFrom(file); + LoadAssembly(assembly); + return assembly; + } + // POC: catch only certain exceptions + catch (Exception ex) when (!ex.IsFatal()) + { + return null; + } + } + + private void LoadAssembly(Assembly assembly) + { + var moduleClasses = assembly.GetTypes().Where(x => x.GetInterfaces().Contains(s_moduleType)).ToList(); + + // create each module + // POC: could look for some attribute here + foreach (var moduleClass in moduleClasses) + { + var module = (ISpeckleModule)Activator.CreateInstance(moduleClass); + ContainerBuilder.RegisterModule(new ModuleAdapter(module)); + } + } + + private readonly Lazy> _types = + new(() => + { + var types = new List(); + foreach ( + var asm in AppDomain.CurrentDomain + .GetAssemblies() + .Where(x => x.GetName().Name.StartsWith("Speckle", StringComparison.OrdinalIgnoreCase)) + ) + { + types.AddRange(asm.GetTypes()); + } + return types; + }); + + public IReadOnlyList SpeckleTypes => _types.Value; + public ContainerBuilder ContainerBuilder { get; } + + private class ModuleAdapter : Module + { + private readonly ISpeckleModule _speckleModule; + + public ModuleAdapter(ISpeckleModule speckleModule) + { + _speckleModule = speckleModule; + } + + protected override void Load(ContainerBuilder builder) => _speckleModule.Load(CreateInstanceForLoading(builder)); + } + + public SpeckleContainerBuilder AddModule(ISpeckleModule module) + { + ContainerBuilder.RegisterModule(new ModuleAdapter(module)); + + return this; + } + + public SpeckleContainerBuilder AddSingleton(T instance) + where T : class + { + ContainerBuilder.RegisterInstance(instance).SingleInstance(); + return this; + } + + public SpeckleContainerBuilder AddSingleton() + where T : class + { + ContainerBuilder.RegisterType().AsSelf().SingleInstance(); + return this; + } + + public SpeckleContainerBuilder AddSingletonInstance() + where T : class + { + ContainerBuilder.RegisterType().AsSelf().SingleInstance().AutoActivate(); + return this; + } + + public SpeckleContainerBuilder AddSingletonInstance() + where T : class, TInterface + where TInterface : notnull + { + ContainerBuilder.RegisterType().As().SingleInstance().AutoActivate(); + return this; + } + + public SpeckleContainerBuilder AddSingleton() + where T : class, TInterface + where TInterface : notnull + { + ContainerBuilder.RegisterType().As().SingleInstance(); + return this; + } + + public SpeckleContainerBuilder AddSingleton(string param, string value) + where T : class, TInterface + where TInterface : notnull + { + ContainerBuilder.RegisterType().As().SingleInstance().WithParameter(param, value); + return this; + } + + public SpeckleContainerBuilder AddScoped() + where T : class, TInterface + where TInterface : notnull + { + ContainerBuilder.RegisterType().As().InstancePerLifetimeScope(); + return this; + } + + public SpeckleContainerBuilder AddScoped() + where T : class + { + ContainerBuilder.RegisterType().AsSelf().InstancePerLifetimeScope(); + return this; + } + + public SpeckleContainerBuilder AddTransient() + where T : class, TInterface + where TInterface : notnull + { + ContainerBuilder.RegisterType().As().InstancePerDependency(); + return this; + } + + public SpeckleContainerBuilder AddTransient() + where T : class + { + ContainerBuilder.RegisterType().AsSelf().InstancePerDependency(); + return this; + } + + public SpeckleContainer Build() + { + var container = ContainerBuilder.Build(); + + // POC: we could create the factory on construction of the container and then inject that and store it + var logger = container.Resolve().CreateLogger(); + + // POC: we could probably expand on this + List assemblies = AppDomain.CurrentDomain.GetAssemblies().Select(x => x.FullName).ToList(); + logger.LogInformation("Loaded assemblies: {@Assemblies}", assemblies); + + return new SpeckleContainer(container); + } +} diff --git a/DUI3-DX/Sdk/Speckle.Connectors.Utils/ContainerRegistration.cs b/DUI3-DX/Sdk/Speckle.Connectors.Utils/ContainerRegistration.cs new file mode 100644 index 0000000000..b444f9ba95 --- /dev/null +++ b/DUI3-DX/Sdk/Speckle.Connectors.Utils/ContainerRegistration.cs @@ -0,0 +1,26 @@ +using Microsoft.Extensions.Logging; +using Serilog; +using Speckle.Autofac.DependencyInjection; +using Speckle.Connectors.Utils.Cancellation; +using Speckle.Connectors.Utils.Operations; + +namespace Speckle.Connectors.Utils; + +public static class ContainerRegistration +{ + public static void AddConnectorUtils(this SpeckleContainerBuilder builder) + { + // send operation and dependencies + builder.AddSingleton(); + builder.AddScoped(); + + // POC: will likely need refactoring with our reporting pattern. + var serilogLogger = new LoggerConfiguration().MinimumLevel + .Debug() + .WriteTo.File("log.txt", rollingInterval: RollingInterval.Day) + .CreateLogger(); + + ILoggerFactory loggerFactory = new LoggerFactory().AddSerilog(serilogLogger); + builder.AddSingleton(loggerFactory); + } +} diff --git a/DUI3-DX/Sdk/Speckle.Connectors.Utils/Speckle.Connectors.Utils.csproj b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Speckle.Connectors.Utils.csproj index 2b9166b220..55e445a089 100644 --- a/DUI3-DX/Sdk/Speckle.Connectors.Utils/Speckle.Connectors.Utils.csproj +++ b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Speckle.Connectors.Utils.csproj @@ -3,9 +3,12 @@ netstandard2.0 - + + + + diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/ContainerRegistration.cs b/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/ContainerRegistration.cs new file mode 100644 index 0000000000..3f8f9d7d61 --- /dev/null +++ b/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/ContainerRegistration.cs @@ -0,0 +1,39 @@ +using Speckle.Autofac.DependencyInjection; +using Speckle.Converters.Common.DependencyInjection.ToHost; +using Speckle.Converters.Common.Objects; + +namespace Speckle.Converters.Common.DependencyInjection; + +public static class ContainerRegistration +{ + public static void AddConverterCommon(this SpeckleContainerBuilder builder) + { + /* + POC: CNX-9267 Moved the Injection of converters into the converter module. Not sure if this is 100% right, as this doesn't just register the conversions within this converter, but any conversions found in any Speckle.*.dll file. + This will require consolidating across other connectors. + */ + builder.AddScoped< + IFactory, + Factory + >(); + builder.AddScoped< + IConverterResolver, + RecursiveConverterResolver + >(); + + builder.AddScoped< + IFactory, + Factory + >(); + builder.AddScoped< + IConverterResolver, + RecursiveConverterResolver + >(); + + builder.AddScoped(); + + builder.RegisterRawConversions(); + builder.InjectNamedTypes(); + builder.InjectNamedTypes(); + } +} diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/NamedTypeInjector.cs b/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/NamedTypeInjector.cs index f4eeea8058..77a7b0206b 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/NamedTypeInjector.cs +++ b/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/NamedTypeInjector.cs @@ -1,36 +1,16 @@ using System.Reflection; using Autofac; +using Speckle.Autofac.DependencyInjection; using Speckle.Converters.Common.Objects; -using Speckle.Core.Logging; namespace Speckle.Converters.Common.DependencyInjection; public static class ConversionTypesInjector { - public static ContainerBuilder InjectNamedTypes(this ContainerBuilder containerBuilder) + public static void InjectNamedTypes(this SpeckleContainerBuilder containerBuilder) where T : notnull { - List types = new(); - - // POC: hard-coding speckle... :/ - foreach ( - var asm in AppDomain.CurrentDomain - .GetAssemblies() - .Where(x => x.GetName().Name.StartsWith("Speckle", StringComparison.OrdinalIgnoreCase)) - ) - { - try - { - var asmTypes = asm.GetTypes(); - - // POC: IsAssignableFrom() - types.AddRange(asmTypes.Where(y => y.GetInterface(typeof(T).Name) != null)); - } - catch (Exception ex) when (!ex.IsFatal()) - { - // POC: be more specific - } - } + var types = containerBuilder.SpeckleTypes.Where(x => x.GetInterfaces().Contains(typeof(T))); // we only care about named types var byName = types @@ -53,7 +33,7 @@ var asm in AppDomain.CurrentDomain var first = namedTypes[0]; // POC: may need to be instance per lifecycle scope - containerBuilder.RegisterType(first.type).Keyed(first.name).InstancePerLifetimeScope(); + containerBuilder.ContainerBuilder.RegisterType(first.type).Keyed(first.name).InstancePerLifetimeScope(); // POC: not sure yet if... // * This should be an array of types @@ -64,7 +44,7 @@ var asm in AppDomain.CurrentDomain // POC: should we explode if no found? if (secondaryType != null) { - containerBuilder + containerBuilder.ContainerBuilder .RegisterType(first.type) .As(secondaryType) .PropertiesAutowired(PropertyWiringOptions.AllowCircularDependencies) @@ -76,7 +56,10 @@ var asm in AppDomain.CurrentDomain foreach (var other in namedTypes) { // POC: is this the right scope? - containerBuilder.RegisterType(other.type).Keyed($"{other.name}|{other.rank}").InstancePerLifetimeScope(); + containerBuilder.ContainerBuilder + .RegisterType(other.type) + .Keyed($"{other.name}|{other.rank}") + .InstancePerLifetimeScope(); // POC: not sure yet if... // * This should be an array of types @@ -84,15 +67,13 @@ var asm in AppDomain.CurrentDomain // * Whether this is in the write project... hmmm // POC: IsAssignableFrom() // NOT very DRY - secondaryType = secondaryType = first.type.GetInterface(typeof(IRawConversion<,>).Name); + secondaryType = first.type.GetInterface(typeof(IRawConversion<,>).Name); // POC: should we explode if no found? if (secondaryType != null) { - containerBuilder.RegisterType(first.type).As(secondaryType).InstancePerLifetimeScope(); + containerBuilder.ContainerBuilder.RegisterType(first.type).As(secondaryType).InstancePerLifetimeScope(); } } } - - return containerBuilder; } } diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/RawConversionRegisterer.cs b/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/RawConversionRegisterer.cs index 506bd33c13..9c2530943d 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/RawConversionRegisterer.cs +++ b/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/RawConversionRegisterer.cs @@ -1,5 +1,5 @@ -using System.Reflection; using Autofac; +using Speckle.Autofac.DependencyInjection; using Speckle.Converters.Common.Objects; namespace Speckle.Converters.Common.DependencyInjection; @@ -8,22 +8,13 @@ namespace Speckle.Converters.Common.DependencyInjection; // NameAndRankAttribute work that needs doing public static class RawConversionRegisterer { - public static ContainerBuilder RegisterRawConversions(this ContainerBuilder containerBuilder) + public static void RegisterRawConversions(this SpeckleContainerBuilder containerBuilder) { // POC: hard-coding speckle... :/ - foreach ( - var asm in AppDomain.CurrentDomain - .GetAssemblies() - .Where(x => x.GetName().Name.StartsWith("Speckle", StringComparison.OrdinalIgnoreCase)) - ) + foreach (Type speckleType in containerBuilder.SpeckleTypes) { - foreach (var type in asm.GetTypes()) - { - RegisterRawConversionsForType(containerBuilder, type); - } + RegisterRawConversionsForType(containerBuilder.ContainerBuilder, speckleType); } - - return containerBuilder; } private static void RegisterRawConversionsForType(ContainerBuilder containerBuilder, Type type) @@ -45,27 +36,4 @@ private static void RegisterRawConversionsForType(ContainerBuilder containerBuil .InstancePerLifetimeScope(); } } - - public static ContainerBuilder RegisterTypesInAssemblyAsInterface( - this ContainerBuilder containerBuilder, - Assembly assembly, - Type interfaceType - ) - { - bool isGeneric = interfaceType.IsGenericType; - foreach (var type in assembly.GetTypes().Where(type => type.IsClass && !type.IsAbstract)) - { - IEnumerable interfaceTypes = type.GetInterfaces(); - interfaceTypes = isGeneric - ? interfaceTypes.Where(it => it.IsGenericType && it.GetGenericTypeDefinition() == interfaceType) - : interfaceTypes.Where(it => it == interfaceType); - - foreach (var iterfaceTypeMatch in interfaceTypes) - { - containerBuilder.RegisterType(type).As(iterfaceTypeMatch).InstancePerLifetimeScope(); - } - } - - return containerBuilder; - } } From 4ac8a8ed21ffe7b2b45f51032e14eaf5e49ffb3e Mon Sep 17 00:00:00 2001 From: KatKatKateryna <89912278+KatKatKateryna@users.noreply.github.com> Date: Tue, 21 May 2024 16:22:55 +0800 Subject: [PATCH 190/261] dynamic subscriptions to layers and tables (#3430) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * dynamic subscriptions to layers and tables * merge fix * Implement missing registration --------- Co-authored-by: Oğuzhan Koral <45078678+oguzhankoral@users.noreply.github.com> Co-authored-by: oguzhankoral --- .../Bindings/ArcGISSendBinding.cs | 129 ++++++++++++++++++ .../ArcGISConnectorModule.cs | 1 + 2 files changed, 130 insertions(+) diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISSendBinding.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISSendBinding.cs index 3b294007d8..0c8a553c20 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISSendBinding.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISSendBinding.cs @@ -14,6 +14,9 @@ using ArcGIS.Desktop.Mapping.Events; using ArcGIS.Desktop.Mapping; using Speckle.Connectors.ArcGIS.Filters; +using ArcGIS.Desktop.Editing.Events; +using ArcGIS.Desktop.Framework.Threading.Tasks; +using ArcGIS.Core.Data; namespace Speckle.Connectors.ArcGIS.Bindings; @@ -32,6 +35,8 @@ public sealed class ArcGISSendBinding : ISendBinding, ICancelable /// Used internally to aggregate the changed objects' id. /// private HashSet ChangedObjectIds { get; set; } = new(); + private List SubscribedLayers { get; set; } = new(); + private List SubscribedTables { get; set; } = new(); public ArcGISSendBinding( DocumentModelStore store, @@ -57,6 +62,111 @@ private void SubscribeToArcGISEvents() StandaloneTablesRemovedEvent.Subscribe(GetIdsForStandaloneTablesRemovedEvent, true); MapPropertyChangedEvent.Subscribe(GetIdsForMapPropertyChangedEvent, true); // Map units, CRS etc. MapMemberPropertiesChangedEvent.Subscribe(GetIdsForMapMemberPropertiesChangedEvent, true); // e.g. Layer name + + ActiveMapViewChangedEvent.Subscribe(SubscribeToMapMembersDataSourceChange, true); + LayersAddedEvent.Subscribe(GetIdsForLayersAddedEvent, true); + StandaloneTablesAddedEvent.Subscribe(GetIdsForStandaloneTablesAddedEvent, true); + } + + private void SubscribeToMapMembersDataSourceChange(ActiveMapViewChangedEventArgs args) + { + var task = QueuedTask.Run(() => + { + if (MapView.Active == null) + { + return; + } + + // subscribe to layers + foreach (Layer layer in MapView.Active.Map.Layers) + { + if (layer is FeatureLayer featureLayer) + { + SubscribeToFeatureLayerDataSourceChange(featureLayer); + } + } + // subscribe to tables + foreach (StandaloneTable table in MapView.Active.Map.StandaloneTables) + { + SubscribeToTableDataSourceChange(table); + } + }); + task.Wait(); + } + + private void SubscribeToFeatureLayerDataSourceChange(FeatureLayer layer) + { + if (SubscribedLayers.Contains(layer)) + { + return; + } + Table layerTable = layer.GetTable(); + SubscribeToAnyDataSourceChange(layerTable); + SubscribedLayers.Add(layer); + } + + private void SubscribeToTableDataSourceChange(StandaloneTable table) + { + if (SubscribedTables.Contains(table)) + { + return; + } + Table layerTable = table.GetTable(); + SubscribeToAnyDataSourceChange(layerTable); + SubscribedTables.Add(table); + } + + private void SubscribeToAnyDataSourceChange(Table layerTable) + { + RowCreatedEvent.Subscribe( + (args) => + { + OnRowChanged(args); + }, + layerTable + ); + RowChangedEvent.Subscribe( + (args) => + { + OnRowChanged(args); + }, + layerTable + ); + RowDeletedEvent.Subscribe( + (args) => + { + OnRowChanged(args); + }, + layerTable + ); + } + + private void OnRowChanged(RowChangedEventArgs args) + { + if (args == null || MapView.Active == null) + { + return; + } + + // get the path of the edited dataset + var datasetURI = args.Row.GetTable().GetPath(); + + // find all layers & tables reading from the dataset + foreach (Layer layer in MapView.Active.Map.Layers) + { + if (layer.GetPath() == datasetURI) + { + ChangedObjectIds.Add(layer.URI); + } + } + foreach (StandaloneTable table in MapView.Active.Map.StandaloneTables) + { + if (table.GetPath() == datasetURI) + { + ChangedObjectIds.Add(table.URI); + } + } + RunExpirationChecks(false); } private void GetIdsForLayersRemovedEvent(LayerEventsArgs args) @@ -89,6 +199,25 @@ private void GetIdsForMapPropertyChangedEvent(MapPropertyChangedEventArgs args) RunExpirationChecks(false); } + private void GetIdsForLayersAddedEvent(LayerEventsArgs args) + { + foreach (Layer layer in args.Layers) + { + if (layer is FeatureLayer featureLayer) + { + SubscribeToFeatureLayerDataSourceChange(featureLayer); + } + } + } + + private void GetIdsForStandaloneTablesAddedEvent(StandaloneTableEventArgs args) + { + foreach (StandaloneTable table in args.Tables) + { + SubscribeToTableDataSourceChange(table); + } + } + private void GetIdsForMapMemberPropertiesChangedEvent(MapMemberPropertiesChangedEventArgs args) { foreach (MapMember member in args.MapMembers) diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/DependencyInjection/ArcGISConnectorModule.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/DependencyInjection/ArcGISConnectorModule.cs index 8dfd2110d7..cb031d6265 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/DependencyInjection/ArcGISConnectorModule.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/DependencyInjection/ArcGISConnectorModule.cs @@ -47,5 +47,6 @@ public void Load(SpeckleContainerBuilder builder) // register send operation and dependencies builder.AddScoped(); builder.AddScoped(); + builder.AddScoped(); } } From 055c3b6cb45710573bb27f6e2b69358869a3b5af Mon Sep 17 00:00:00 2001 From: Adam Hathcock Date: Tue, 21 May 2024 10:38:49 +0100 Subject: [PATCH 191/261] CNX-9434 use proposed naming standard for all DUI3 converter classes (#3431) * ITypedConverter * ITypedConverter.Convert * IToHostTopLevelConverter * IToSpeckleTopLevelConverter * IRootToHostConverter * IRootToSpeckleConverter * IRootObjectBuilder * IRootToSpeckleConverter * fix more AutocadRootObject * remove string from factory * fmt * fix naming * fixed build * Move some naming around * enforce host registration * fmt * make another thing static --- .../ArcGISConnectorModule.cs | 2 +- .../Operations/Receive/HostObjectBuilder.cs | 14 ++--- .../Operations/Send/RootObjectBuilder.cs | 2 +- .../Bindings/AutocadBasicConnectorBinding.cs | 12 ++--- .../Bindings/AutocadSendBinding.cs | 8 +-- .../AutocadConnectorModule.cs | 11 ++-- .../HostApp/Extensions/DocumentExtensions.cs | 7 +-- ...Builder.cs => AutocadHostObjectBuilder.cs} | 8 +-- .../Operations/Send/AutocadRootObject.cs | 5 ++ ...Builder.cs => AutocadRootObjectBuilder.cs} | 17 +++--- ...Speckle.Connectors.AutocadShared.projitems | 5 +- ...ectorShared.cs => RevitConnectorModule.cs} | 2 +- ...ctBuilder.cs => RevitRootObjectBuilder.cs} | 13 ++--- .../Speckle.Connectors.RevitShared.projitems | 4 +- .../RhinoConnectorModule.cs | 2 +- .../Receive/RhinoHostObjectBuilder.cs | 8 +-- ...ctBuilder.cs => RhinoRootObjectBuilder.cs} | 6 +-- .../ArcGISConverterModule.cs | 4 +- .../ArcGISToSpeckleUnitConverter.cs | 24 +++++---- ...Conversion.cs => FakeTopLevelConverter.cs} | 6 +-- .../Features/GeometryToHostConverter.cs | 34 ++++++------ .../Features/GeometryToSpeckleBase.cs | 34 ++++++------ .../Features/GisFeatureToSpeckleConverter.cs | 10 ++-- .../Features/GisRasterToSpeckleConverter.cs | 10 ++-- .../MultipatchFeatureToSpeckleConverter.cs | 10 ++-- .../MultipointFeatureToSpeckleConverter.cs | 10 ++-- .../PointFeatureToSpeckleConverter.cs | 6 +-- .../PolygonFeatureToSpeckleConverter.cs | 10 ++-- .../PolylineFeatureToSpeckleConverter.cs | 10 ++-- .../BezierSegmentToSpeckleConverter.cs | 10 ++-- .../EllipticArcSegmentToSpeckleConverter.cs | 10 ++-- .../Geometry/EnvelopBoxToSpeckleConverter.cs | 12 ++--- .../Geometry/FallbackToHostConverter.cs | 24 ++++----- .../MeshListToHostConverter.cs | 10 ++-- .../MultipatchListToHostConverter.cs | 10 ++-- .../PointListToHostConverter.cs | 10 ++-- .../Polygon3dListToHostConverter.cs | 16 +++--- .../PolygonListToHostConverter.cs | 12 ++--- .../PolylineListToHostConverter.cs | 10 ++-- .../ArcToHostConverter.cs | 12 ++--- .../CircleToHostConverter.cs | 12 ++--- .../EllipseToHostConverter.cs | 12 ++--- .../LineToHostConverter.cs | 12 ++--- .../MeshToHostConverter.cs | 12 ++--- .../PointToHostConverter.cs | 8 +-- .../PolycurveToHostConverter.cs | 18 +++---- .../PolylineToHostConverter.cs | 12 ++--- .../Geometry/PointSingleToHostConverter.cs | 6 +-- .../Geometry/PointToSpeckleConverter.cs | 4 +- .../SegmentCollectionToSpeckleConverter.cs | 26 +++++----- .../Layers/FeatureClassToHostConverter.cs | 8 +-- .../Layers/PointcloudLayerToHostConverter.cs | 6 +-- .../PointcloudLayerToSpeckleConverter.cs | 20 +++---- .../Layers/RasterLayerToHostConverter.cs | 6 +-- .../Layers/RasterLayerToSpeckleConverter.cs | 14 +++-- .../Layers/TableToHostConverter.cs | 4 +- .../Layers/TableToSpeckleConverter.cs | 14 ++--- .../Layers/VectorLayerToHostConverter.cs | 24 ++++----- .../Layers/VectorLayerToSpeckleConverter.cs | 12 ++--- .../Utils/FeatureClassUtils.cs | 4 +- .../Utils/IFeatureClassUtils.cs | 2 +- .../Utils/NonNativeFeaturesUtils.cs | 4 +- .../AutocadConverterModule.cs | 5 +- ...eckle.cs => AutocadRootToHostConverter.cs} | 8 +-- .../AutocadToSpeckleUnitConverter.cs | 26 +++++----- ...Speckle.Converters.AutocadShared.projitems | 2 +- .../ToHost/Geometry/ArcToHostConverter.cs | 18 +++---- .../AutocadPolycurveToHostConverter.cs | 20 +++---- .../ToHost/Geometry/CircleToHostConverter.cs | 18 +++---- .../ToHost/Geometry/CurveToHostConverter.cs | 10 ++-- .../ToHost/Geometry/EllipseToHostConverter.cs | 20 +++---- .../ToHost/Geometry/LineToHostConverter.cs | 12 ++--- .../ToHost/Geometry/MeshToHostConverter.cs | 12 ++--- .../ToHost/Geometry/PointToHostConverter.cs | 10 ++-- .../Geometry/PolycurveToHostConverter.cs | 14 ++--- .../Geometry/PolylineToHostConverter.cs | 12 ++--- .../SpeckleFallbackToHostConversion.cs | 30 +++++------ .../ToHost/Raw/ArcToHostRawConverter.cs | 24 ++++----- ...adPolycurveToHostPolyline2dRawConverter.cs | 11 ++-- ...adPolycurveToHostPolyline3dRawConverter.cs | 5 +- ...ocadPolycurveToHostPolylineRawConverter.cs | 10 ++-- .../ToHost/Raw/CurveToHostRawConverter.cs | 16 +++--- .../ToHost/Raw/IntervalToHostRawConverter.cs | 4 +- .../ToHost/Raw/PlaneToHostRawConverter.cs | 16 +++--- .../ToHost/Raw/PointToHostRawConverter.cs | 4 +- .../PolycurveToHostPolylineRawConverter.cs | 18 +++---- .../Raw/PolycurveToHostSplineRawConverter.cs | 28 +++++----- .../ToHost/Raw/VectorToHostRawConverter.cs | 6 +-- .../Geometry/ArcToSpeckleConverter.cs | 28 +++++----- .../Geometry/CircleToSpeckleConverter.cs | 14 ++--- .../Geometry/EllipseToSpeckleConverter.cs | 14 ++--- .../Geometry/LineToSpeckleConverter.cs | 20 +++---- .../Geometry/PointToSpeckleConverter.cs | 8 +-- .../PolyfaceMeshToSpeckleConverter.cs | 16 +++--- .../Geometry/Polyline2dToSpeckleConverter.cs | 38 +++++++------- .../Geometry/Polyline3dToSpeckleConverter.cs | 20 +++---- .../Geometry/PolylineToSpeckleConverter.cs | 32 ++++++------ .../Geometry/SplineToSpeckleConverter.cs | 18 +++---- .../Geometry/SubDMeshToSpeckleConverter.cs | 14 ++--- .../ToSpeckle/Raw/BoxToSpeckleRawConverter.cs | 12 ++--- .../Raw/CircularArc3dToSpeckleConverter.cs | 20 +++---- .../Raw/IntervalToSpeckleRawConverter.cs | 6 +-- .../Raw/LineSegment3dToSpeckleRawConverter.cs | 12 ++--- .../Raw/PlaneToSpeckleRawConverter.cs | 22 ++++---- .../Raw/PointToSpeckleRawConverter.cs | 5 +- .../Raw/VectorToSpeckleRawConverter.cs | 4 +- .../RevitConverterModule.cs | 6 +-- .../Helpers/DisplayValueExtractor.cs | 6 +-- .../Helpers/ParameterObjectAssigner.cs | 6 +-- .../Helpers/SlopeArrowExtractor.cs | 8 +-- .../Raw/BeamConversionToSpeckle.cs | 16 +++--- .../Raw/BoundarySegmentConversionToSpeckle.cs | 10 ++-- .../Raw/BraceToSpeckleConverter.cs | 12 ++--- .../Raw/ColumnConversionToSpeckle.cs | 18 +++---- .../Raw/Geometry/ArcToSpeckleConverter.cs | 20 +++---- .../BoundingBoxXYZToSpeckleConverter.cs | 18 +++---- .../Raw/Geometry/CircleToSpeckleConverter.cs | 10 ++-- ...urveArrArrayToSpecklePolycurveConverter.cs | 10 ++-- .../Geometry/CurveArrayConversionToSpeckle.cs | 10 ++-- .../Raw/Geometry/CurveConversionToSpeckle.cs | 38 +++++++------- .../Raw/Geometry/EllipseToSpeckleConverter.cs | 10 ++-- .../HermiteSplineToSpeckleConverter.cs | 10 ++-- .../Raw/Geometry/LineConversionToSpeckle.cs | 12 ++--- .../MeshByMaterialDictionaryToSpeckle.cs | 17 +++--- .../Raw/Geometry/MeshConversionToSpeckle.cs | 16 +++--- .../Geometry/NurbsSplineToSpeckleConverter.cs | 12 ++--- .../Raw/Geometry/PlaneToSpeckleConverter.cs | 20 +++---- .../Geometry/PointCloudToSpeckleConverter.cs | 16 +++--- .../Raw/Geometry/PointConversionToSpeckle.cs | 8 +-- .../Geometry/PolylineToSpeckleConverter.cs | 10 ++-- .../Raw/Geometry/VectorToSpeckleConverter.cs | 4 +- .../Raw/Geometry/XyzConversionToPoint.cs | 4 +- .../Raw/LevelConversionToSpeckle.cs | 4 +- .../Raw/LocationConversionToSpeckle.cs | 16 +++--- .../Raw/MaterialConversionToSpeckle.cs | 4 +- .../ModelCurveArrArrayToSpeckleConverter.cs | 10 ++-- .../Raw/ModelCurveArrayToSpeckleConverter.cs | 10 ++-- .../Raw/ParameterConversionToSpeckle.cs | 4 +- ...Speckle.cs => RevitRootToHostConverter.cs} | 11 ++-- .../Speckle.Converters.RevitShared.projitems | 22 ++++---- ...e.cs => BaseTopLevelConverterToSpeckle.cs} | 10 ++-- ...s => CeilingTopLevelConverterToSpeckle.cs} | 18 +++---- ... DirectShapeTopLevelConverterToSpeckle.cs} | 6 +-- ...s => ElementTopLevelConverterToSpeckle.cs} | 6 +-- ...ExtrusionRoofToSpeckleTopLevelConverter.cs | 25 ++++----- .../FamilyInstanceConversionToSpeckle.cs | 46 ---------------- ...amilyInstanceTopLevelConverterToSpeckle.cs | 46 ++++++++++++++++ ....cs => FloorTopLevelConverterToSpeckle.cs} | 18 +++---- ...FootPrintRoofToSpeckleTopLevelConverter.cs | 19 +++---- .../HostedElementConversionToSpeckle.cs | 4 +- .../ModelCurveToSpeckleTopLevelConverter.cs | 10 ++-- ...BaseToSpeckleTopLevelTopLevelConverter.cs} | 7 +-- ...e.cs => RoomTopLevelConverterToSpeckle.cs} | 24 ++++----- ...> TopographyTopLevelConverterToSpeckle.cs} | 9 ++-- ...e.cs => WallTopLevelConverterToSpeckle.cs} | 30 +++++------ .../RhinoConverterModule.cs | 7 +-- ...kleToHostGeometryBaseTopLevelConverter.cs} | 10 ++-- .../ToHost/Raw/ArcToHostConverter.cs | 24 ++++----- .../ToHost/Raw/BrepToHostConverter.cs | 30 +++++------ .../ToHost/Raw/CircleToHostConverter.cs | 24 ++++----- .../ToHost/Raw/CurveToHostConverter.cs | 52 +++++++++---------- .../ToHost/Raw/EllipseToHostConverter.cs | 28 +++++----- .../Raw/FlatPointListToHostConverter.cs | 4 +- .../ToHost/Raw/IntervalToHostConverter.cs | 4 +- .../ToHost/Raw/LineToHostConverter.cs | 12 ++--- .../ToHost/Raw/MeshToHostConverter.cs | 10 ++-- .../ToHost/Raw/NurbsCurveToHostConverter.cs | 10 ++-- .../ToHost/Raw/PlaneToHostConverter.cs | 18 +++---- .../ToHost/Raw/PointCloudToHostConverter.cs | 10 ++-- .../ToHost/Raw/PointToHostConverter.cs | 6 +-- .../ToHost/Raw/PolyCurveToHostConverter.cs | 14 ++--- .../ToHost/Raw/PolylineToHostConverter.cs | 22 ++++---- .../ToHost/Raw/SpiralToHostConverter.cs | 16 +++--- .../ToHost/Raw/SurfaceToHostConverter.cs | 4 +- .../ToHost/Raw/VectorToHostConverter.cs | 4 +- .../TopLevel/ArcToHostTopLevelConverter.cs | 4 +- .../TopLevel/BrepToHostTopLevelConverter.cs | 4 +- .../TopLevel/CircleToHostTopLevelConverter.cs | 4 +- .../EllipseToHostTopLevelConverter.cs | 4 +- .../FallbackToHostTopLevelConverter.cs | 26 +++++----- .../TopLevel/LineToHostTopLevelConverter.cs | 4 +- .../TopLevel/MeshToHostTopLevelConverter.cs | 4 +- .../NurbsCurveToHostTopLevelConverter.cs | 4 +- .../PointCloudToHostTopLevelConverter.cs | 5 +- .../TopLevel/PointToHostTopLevelConverter.cs | 4 +- .../PolycurveToHostTopLevelConverter.cs | 4 +- .../PolylineToHostTopLevelConverter.cs | 5 +- .../Raw/ArcCurveToSpeckleConverter.cs | 28 +++++----- .../ToSpeckle/Raw/ArcToSpeckleConverter.cs | 26 +++++----- .../ToSpeckle/Raw/BoxToSpeckleConverter.cs | 20 +++---- .../ToSpeckle/Raw/BrepToSpeckleConverter.cs | 44 ++++++++-------- .../ToSpeckle/Raw/CircleToSpeckleConverter.cs | 12 ++--- .../Raw/ControlPointToSpeckleConverter.cs | 6 +-- .../ToSpeckle/Raw/CurveToSpeckleConverter.cs | 36 ++++++------- .../Raw/EllipseToSpeckleConverter.cs | 16 +++--- .../Raw/IntervalToSpeckleConverter.cs | 4 +- .../ToSpeckle/Raw/LineToSpeckleConverter.cs | 22 ++++---- .../ToSpeckle/Raw/MeshToSpeckleConverter.cs | 14 ++--- .../ToSpeckle/Raw/NurbsCurveConverter.cs | 22 ++++---- .../Raw/NurbsSurfaceToSpeckleConverter.cs | 24 ++++----- .../ToSpeckle/Raw/PlaneToSpeckleConverter.cs | 20 +++---- .../ToSpeckle/Raw/PointToSpeckleConverter.cs | 7 ++- .../Raw/PolyCurveToSpeckleConverter.cs | 20 +++---- .../Raw/PolylineToSpeckleConverter.cs | 28 +++++----- .../ToSpeckle/Raw/RawPointCloudToSpeckle.cs | 10 ++-- .../ToSpeckle/Raw/VectorToSpeckleConverter.cs | 4 +- .../ToSpeckle/RhinoConverterToSpeckle.cs | 29 ----------- .../BrepObjectToSpeckleTopLevelConverter.cs | 8 +-- .../CurveObjectToSpeckleTopLevelConverter.cs | 2 +- ...trusionObjectToSpeckleTopLevelConverter.cs | 8 +-- .../MeshObjectToSpeckleTopLevelConverter.cs | 2 +- ...ntCloudObjectToSpeckleTopLevelConverter.cs | 2 +- .../PointObjectToSpeckleTopLevelConverter.cs | 2 +- .../RhinoObjectToSpeckleTopLevelConverter.cs | 9 ++-- .../DependencyInjection/Factory.cs | 8 +-- .../ContainerRegistration.cs | 33 ++++++------ .../NamedTypeInjector.cs | 4 +- .../RawConversionRegisterer.cs | 2 +- ...thFallback.cs => ConverterWithFallback.cs} | 16 +++--- ...allback.cs => ConverterWithoutFallback.cs} | 12 ++--- .../ConversionContext.cs | 2 +- .../ConversionContextStack.cs | 4 +- .../IConversionContextStack.cs | 18 ------- ...erterToHost.cs => IRootToHostConverter.cs} | 2 +- .../IRootToSpeckleConverter.cs} | 12 ++--- .../ISpeckleConverterToSpeckle.cs | 8 --- .../Objects/FloorConversion.cs | 3 -- .../Objects/IConverterResolver.cs | 7 --- .../Objects/IRawConversion.cs | 6 --- ...version.cs => IToHostTopLevelConverter.cs} | 2 +- ...sion.cs => IToSpeckleTopLevelConverter.cs} | 2 +- .../Objects/ITypedConverter.cs | 6 +++ ...olver.cs => RecursiveConverterResolver.cs} | 9 ++-- 233 files changed, 1445 insertions(+), 1535 deletions(-) rename DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Operations/Receive/{HostObjectBuilder.cs => AutocadHostObjectBuilder.cs} (95%) create mode 100644 DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Operations/Send/AutocadRootObject.cs rename DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Operations/Send/{RootObjectBuilder.cs => AutocadRootObjectBuilder.cs} (82%) rename DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/{RevitConnectorShared.cs => RevitConnectorModule.cs} (96%) rename DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/{RootObjectBuilder.cs => RevitRootObjectBuilder.cs} (89%) rename DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Send/{RootObjectBuilder.cs => RhinoRootObjectBuilder.cs} (96%) rename DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/{FakeConversion.cs => FakeTopLevelConverter.cs} (61%) rename DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/{AutocadConverterToSpeckle.cs => AutocadRootToHostConverter.cs} (85%) rename DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/{RevitConverterToSpeckle.cs => RevitRootToHostConverter.cs} (76%) rename DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/{BaseConversionToSpeckle.cs => BaseTopLevelConverterToSpeckle.cs} (76%) rename DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/{CeilingConversionToSpeckle.cs => CeilingTopLevelConverterToSpeckle.cs} (76%) rename DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/{DirectShapeConversionToSpeckle.cs => DirectShapeTopLevelConverterToSpeckle.cs} (86%) rename DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/{ElementConversionToSpeckle.cs => ElementTopLevelConverterToSpeckle.cs} (86%) delete mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/FamilyInstanceConversionToSpeckle.cs create mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/FamilyInstanceTopLevelConverterToSpeckle.cs rename DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/{FloorConversionToSpeckle.cs => FloorTopLevelConverterToSpeckle.cs} (85%) rename DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/{RoofBaseToSpeckleTopLevelConversion.cs => RoofBaseToSpeckleTopLevelTopLevelConverter.cs} (85%) rename DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/{RoomConversionToSpeckle.cs => RoomTopLevelConverterToSpeckle.cs} (68%) rename DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/{TopographyConversionToSpeckle.cs => TopographyTopLevelConverterToSpeckle.cs} (75%) rename DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/{WallConversionToSpeckle.cs => WallTopLevelConverterToSpeckle.cs} (84%) rename DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/{SpeckleToHostGeometryBaseConversion.cs => SpeckleToHostGeometryBaseTopLevelConverter.cs} (77%) delete mode 100644 DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/RhinoConverterToSpeckle.cs rename DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/ToHost/{ToHostConverterWithFallback.cs => ConverterWithFallback.cs} (80%) rename DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/ToHost/{ToHostConverterWithoutFallback.cs => ConverterWithoutFallback.cs} (63%) delete mode 100644 DUI3-DX/Sdk/Speckle.Converters.Common/IConversionContextStack.cs rename DUI3-DX/Sdk/Speckle.Converters.Common/{ISpeckleConverterToHost.cs => IRootToHostConverter.cs} (71%) rename DUI3-DX/{Converters/ArcGIS/Speckle.Converters.ArcGIS3/ArcGISConverterToSpeckle.cs => Sdk/Speckle.Converters.Common/IRootToSpeckleConverter.cs} (68%) delete mode 100644 DUI3-DX/Sdk/Speckle.Converters.Common/ISpeckleConverterToSpeckle.cs delete mode 100644 DUI3-DX/Sdk/Speckle.Converters.Common/Objects/FloorConversion.cs delete mode 100644 DUI3-DX/Sdk/Speckle.Converters.Common/Objects/IConverterResolver.cs delete mode 100644 DUI3-DX/Sdk/Speckle.Converters.Common/Objects/IRawConversion.cs rename DUI3-DX/Sdk/Speckle.Converters.Common/Objects/{ISpeckleObjectToHostConversion.cs => IToHostTopLevelConverter.cs} (83%) rename DUI3-DX/Sdk/Speckle.Converters.Common/Objects/{IHostObjectToSpeckleConversion.cs => IToSpeckleTopLevelConverter.cs} (83%) create mode 100644 DUI3-DX/Sdk/Speckle.Converters.Common/Objects/ITypedConverter.cs rename DUI3-DX/Sdk/Speckle.Converters.Common/{RecursiveConveterResolver.cs => RecursiveConverterResolver.cs} (62%) diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/DependencyInjection/ArcGISConnectorModule.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/DependencyInjection/ArcGISConnectorModule.cs index cb031d6265..61f304fb93 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/DependencyInjection/ArcGISConnectorModule.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/DependencyInjection/ArcGISConnectorModule.cs @@ -41,7 +41,7 @@ public void Load(SpeckleContainerBuilder builder) builder.AddSingleton(); builder.AddTransient(); - builder.AddScoped(); + builder.AddScoped(); builder.AddSingleton(DefaultTraversal.CreateTraversalFunc()); // register send operation and dependencies diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Receive/HostObjectBuilder.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Receive/HostObjectBuilder.cs index 4d4caa9e7a..865c0abdcb 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Receive/HostObjectBuilder.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Receive/HostObjectBuilder.cs @@ -12,9 +12,9 @@ namespace Speckle.Connectors.ArcGIS.Operations.Receive; -public class HostObjectBuilder : IHostObjectBuilder +public class ArcGISHostObjectBuilder : IHostObjectBuilder { - private readonly ISpeckleConverterToHost _toHostConverter; + private readonly IRootToHostConverter _converter; private readonly IArcGISProjectUtils _arcGISProjectUtils; private readonly INonNativeFeaturesUtils _nonGisFeaturesUtils; @@ -22,15 +22,15 @@ public class HostObjectBuilder : IHostObjectBuilder private readonly IConversionContextStack _contextStack; private readonly GraphTraversal _traverseFunction; - public HostObjectBuilder( - ISpeckleConverterToHost toHostConverter, + public ArcGISHostObjectBuilder( + IRootToHostConverter converter, IArcGISProjectUtils arcGISProjectUtils, IConversionContextStack contextStack, INonNativeFeaturesUtils nonGisFeaturesUtils, GraphTraversal traverseFunction ) { - _toHostConverter = toHostConverter; + _converter = converter; _arcGISProjectUtils = arcGISProjectUtils; _contextStack = contextStack; _nonGisFeaturesUtils = nonGisFeaturesUtils; @@ -44,7 +44,7 @@ GraphTraversal traverseFunction List objectIds ) { - Geometry converted = (Geometry)_toHostConverter.Convert(obj); + Geometry converted = (Geometry)_converter.Convert(obj); objectIds.Add(obj.id); List objPath = path.ToList(); objPath.Add(obj.speckle_type.Split(".")[^1]); @@ -53,7 +53,7 @@ List objectIds public (string, string) ConvertNativeLayers(Base obj, string[] path, List objectIds) { - string converted = (string)_toHostConverter.Convert(obj); + string converted = (string)_converter.Convert(obj); objectIds.Add(obj.id); string objPath = $"{string.Join("\\", path)}\\{((Collection)obj).name}"; return (objPath, converted); diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Send/RootObjectBuilder.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Send/RootObjectBuilder.cs index f6ff7824b1..ec933d68b1 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Send/RootObjectBuilder.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Send/RootObjectBuilder.cs @@ -50,7 +50,7 @@ private Collection ConvertObjects( { // POC: does this feel like the right place? I am wondering if this should be called from within send/rcv? // begin the unit of work - using var uow = _unitOfWorkFactory.Resolve(); + using var uow = _unitOfWorkFactory.Resolve(); var converter = uow.Service; // var rootObjectCollection = new Collection { name = RhinoDoc.ActiveDoc.Name ?? "Unnamed document" }; diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadBasicConnectorBinding.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadBasicConnectorBinding.cs index 70db8d0228..27159ce2f9 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadBasicConnectorBinding.cs +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadBasicConnectorBinding.cs @@ -82,18 +82,14 @@ public void HighlightModel(string modelCardId) if (model is SenderModelCard senderModelCard) { - List<(DBObject obj, string applicationId)> dbObjects = doc.GetObjects( - senderModelCard.SendFilter.NotNull().GetObjectIds() - ); - objectIds = dbObjects.Select(tuple => tuple.obj.Id).ToArray(); + var dbObjects = doc.GetObjects(senderModelCard.SendFilter.NotNull().GetObjectIds()); + objectIds = dbObjects.Select(tuple => tuple.Root.Id).ToArray(); } if (model is ReceiverModelCard receiverModelCard) { - List<(DBObject obj, string applicationId)> dbObjects = doc.GetObjects( - (receiverModelCard.ReceiveResult?.BakedObjectIds).NotNull() - ); - objectIds = dbObjects.Select(tuple => tuple.obj.Id).ToArray(); + var dbObjects = doc.GetObjects((receiverModelCard.ReceiveResult?.BakedObjectIds).NotNull()); + objectIds = dbObjects.Select(tuple => tuple.Root.Id).ToArray(); } if (objectIds.Length == 0) diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadSendBinding.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadSendBinding.cs index 4ee724bfa7..d33db5b048 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadSendBinding.cs +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadSendBinding.cs @@ -8,6 +8,7 @@ using Speckle.Connectors.Utils.Cancellation; using Speckle.Core.Logging; using Speckle.Autofac.DependencyInjection; +using Speckle.Connectors.Autocad.Operations.Send; using Speckle.Connectors.Utils.Operations; using Speckle.Core.Models; using ICancelable = System.Reactive.Disposables.ICancelable; @@ -121,7 +122,7 @@ private async Task SendInternal(string modelCardId) { try { - using var uow = _unitOfWorkFactory.Resolve>(); + using var uow = _unitOfWorkFactory.Resolve>(); // 0 - Init cancellation token source -> Manager also cancel it if exist before CancellationTokenSource cts = _cancellationManager.InitCancellationTokenSource(modelCardId); @@ -132,8 +133,9 @@ private async Task SendInternal(string modelCardId) } // Get elements to convert - List<(DBObject obj, string applicationId)> autocadObjects = - Application.DocumentManager.CurrentDocument.GetObjects(modelCard.SendFilter.NotNull().GetObjectIds()); + List autocadObjects = Application.DocumentManager.CurrentDocument.GetObjects( + modelCard.SendFilter.NotNull().GetObjectIds() + ); if (autocadObjects.Count == 0) { throw new InvalidOperationException("No objects were found. Please update your send filter!"); diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/DependencyInjection/AutocadConnectorModule.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/DependencyInjection/AutocadConnectorModule.cs index a7702d9c2e..e2ec747ba9 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/DependencyInjection/AutocadConnectorModule.cs +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/DependencyInjection/AutocadConnectorModule.cs @@ -1,4 +1,3 @@ -using Autodesk.AutoCAD.DatabaseServices; using Speckle.Autofac; using Speckle.Autofac.DependencyInjection; using Speckle.Connectors.Autocad.Bindings; @@ -16,8 +15,6 @@ using Speckle.Connectors.Utils; using Speckle.Connectors.Utils.Builders; using Speckle.Connectors.Utils.Operations; -using Speckle.Converters.Autocad; -using Speckle.Converters.Common; using Speckle.Core.Models.GraphTraversal; namespace Speckle.Connectors.Autocad.DependencyInjection; @@ -41,12 +38,12 @@ public void Load(SpeckleContainerBuilder builder) builder.AddSingleton(); // Operations - builder.AddScoped>(); + builder.AddScoped>(); builder.AddSingleton(DefaultTraversal.CreateTraversalFunc()); // Object Builders - builder.AddScoped(); - builder.AddSingleton, RootObjectBuilder>(); + builder.AddScoped(); + builder.AddSingleton, AutocadRootObjectBuilder>(); // Register bindings @@ -59,8 +56,6 @@ public void Load(SpeckleContainerBuilder builder) builder.AddSingleton(); builder.AddSingleton(); - builder.AddSingleton, AutocadToSpeckleUnitConverter>(); - // register send filters builder.AddTransient(); } diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/Extensions/DocumentExtensions.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/Extensions/DocumentExtensions.cs index 5462c67269..a0ab9e54a2 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/Extensions/DocumentExtensions.cs +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/Extensions/DocumentExtensions.cs @@ -1,12 +1,13 @@ using Autodesk.AutoCAD.DatabaseServices; +using Speckle.Connectors.Autocad.Operations.Send; namespace Speckle.Connectors.Autocad.HostApp.Extensions; public static class DocumentExtensions { - public static List<(DBObject, string)> GetObjects(this Document doc, IEnumerable objectIds) + public static List GetObjects(this Document doc, IEnumerable objectIds) { - List<(DBObject, string)> objects = new(); + List objects = new(); using (TransactionContext.StartTransaction(doc)) { Transaction tr = doc.Database.TransactionManager.TopTransaction; @@ -20,7 +21,7 @@ public static class DocumentExtensions { if (tr.GetObject(myObjectId, OpenMode.ForRead) is DBObject dbObject) { - objects.Add((dbObject, objectIdHandle)); + objects.Add(new(dbObject, objectIdHandle)); } } } diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Operations/Receive/HostObjectBuilder.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Operations/Receive/AutocadHostObjectBuilder.cs similarity index 95% rename from DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Operations/Receive/HostObjectBuilder.cs rename to DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Operations/Receive/AutocadHostObjectBuilder.cs index edb8cfa827..9b6b081c5e 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Operations/Receive/HostObjectBuilder.cs +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Operations/Receive/AutocadHostObjectBuilder.cs @@ -10,14 +10,14 @@ namespace Speckle.Connectors.Autocad.Operations.Receive; -public class HostObjectBuilder : IHostObjectBuilder +public class AutocadHostObjectBuilder : IHostObjectBuilder { - private readonly ISpeckleConverterToHost _converter; + private readonly IRootToHostConverter _converter; private readonly AutocadLayerManager _autocadLayerManager; private readonly GraphTraversal _traversalFunction; - public HostObjectBuilder( - ISpeckleConverterToHost converter, + public AutocadHostObjectBuilder( + IRootToHostConverter converter, AutocadLayerManager autocadLayerManager, GraphTraversal traversalFunction ) diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Operations/Send/AutocadRootObject.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Operations/Send/AutocadRootObject.cs new file mode 100644 index 0000000000..6696617b23 --- /dev/null +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Operations/Send/AutocadRootObject.cs @@ -0,0 +1,5 @@ +using Autodesk.AutoCAD.DatabaseServices; + +namespace Speckle.Connectors.Autocad.Operations.Send; + +public record AutocadRootObject(DBObject Root, string ApplicationId); diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Operations/Send/RootObjectBuilder.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Operations/Send/AutocadRootObjectBuilder.cs similarity index 82% rename from DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Operations/Send/RootObjectBuilder.cs rename to DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Operations/Send/AutocadRootObjectBuilder.cs index 621979f9bb..0155986fe4 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Operations/Send/RootObjectBuilder.cs +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Operations/Send/AutocadRootObjectBuilder.cs @@ -8,18 +8,18 @@ namespace Speckle.Connectors.Autocad.Operations.Send; -public class RootObjectBuilder : IRootObjectBuilder<(DBObject obj, string applicationId)> +public class AutocadRootObjectBuilder : IRootObjectBuilder { - private readonly ISpeckleConverterToSpeckle _converter; + private readonly IRootToSpeckleConverter _converter; private readonly string[] _documentPathSeparator = { "\\" }; - public RootObjectBuilder(ISpeckleConverterToSpeckle converter) + public AutocadRootObjectBuilder(IRootToSpeckleConverter converter) { _converter = converter; } public Base Build( - IReadOnlyList<(DBObject obj, string applicationId)> objects, + IReadOnlyList objects, SendInfo sendInfo, Action? onOperationProgressed = null, CancellationToken ct = default @@ -39,13 +39,10 @@ public Base Build( Dictionary collectionCache = new(); int count = 0; - foreach ((DBObject obj, string applicationId) tuple in objects) + foreach (var (root, applicationId) in objects) { ct.ThrowIfCancellationRequested(); - var dbObject = tuple.obj; - var applicationId = tuple.applicationId; - try { Base converted; @@ -58,7 +55,7 @@ public Base Build( } else { - converted = _converter.Convert(dbObject); + converted = _converter.Convert(root); if (converted == null) { @@ -69,7 +66,7 @@ public Base Build( } // Create and add a collection for each layer if not done so already. - if ((tuple.obj as Entity)?.Layer is string layer) + if ((root as Entity)?.Layer is string layer) { if (!collectionCache.TryGetValue(layer, out Collection? collection)) { diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Speckle.Connectors.AutocadShared.projitems b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Speckle.Connectors.AutocadShared.projitems index 271ae9efd6..d45686060d 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Speckle.Connectors.AutocadShared.projitems +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Speckle.Connectors.AutocadShared.projitems @@ -26,8 +26,9 @@ - - + + + diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/RevitConnectorShared.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/RevitConnectorModule.cs similarity index 96% rename from DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/RevitConnectorShared.cs rename to DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/RevitConnectorModule.cs index b9e5bf7556..4d6a302e27 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/RevitConnectorShared.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/RevitConnectorModule.cs @@ -56,6 +56,6 @@ public void Load(SpeckleContainerBuilder builder) // send operation and dependencies builder.AddScoped>(); - builder.AddScoped, RootObjectBuilder>(); + builder.AddScoped, RevitRootObjectBuilder>(); } } diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RootObjectBuilder.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RevitRootObjectBuilder.cs similarity index 89% rename from DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RootObjectBuilder.cs rename to DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RevitRootObjectBuilder.cs index ab17b54882..2f7f484807 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RootObjectBuilder.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RevitRootObjectBuilder.cs @@ -8,24 +8,17 @@ namespace Speckle.Connectors.Revit.Operations.Send; -public class RootObjectBuilder : IRootObjectBuilder +public class RevitRootObjectBuilder : IRootObjectBuilder { // POC: SendSelection and RevitConversionContextStack should be interfaces, former needs interfaces - private readonly ISpeckleConverterToSpeckle _converter; - private readonly ToSpeckleConvertedObjectsCache _convertedObjectsCache; + private readonly IRootToSpeckleConverter _converter; private readonly IRevitConversionContextStack _contextStack; private readonly Dictionary _collectionCache; private readonly Collection _rootObject; - public RootObjectBuilder( - ISpeckleConverterToSpeckle converter, - ToSpeckleConvertedObjectsCache convertedObjectsCache, - IRevitConversionContextStack contextStack - ) + public RevitRootObjectBuilder(IRootToSpeckleConverter converter, IRevitConversionContextStack contextStack) { _converter = converter; - // POC: needs considering if this is something to add now or needs refactoring - _convertedObjectsCache = convertedObjectsCache; _contextStack = contextStack; // Note, this class is instantiated per unit of work (aka per send operation), so we can safely initialize what we need in here. diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Speckle.Connectors.RevitShared.projitems b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Speckle.Connectors.RevitShared.projitems index 2391c8144a..d7bcb0a2d3 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Speckle.Connectors.RevitShared.projitems +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Speckle.Connectors.RevitShared.projitems @@ -26,8 +26,8 @@ - - + + CefSharpPanel.xaml diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/RhinoConnectorModule.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/RhinoConnectorModule.cs index ebda7699de..3cc59fd408 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/RhinoConnectorModule.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/RhinoConnectorModule.cs @@ -62,6 +62,6 @@ public void Load(SpeckleContainerBuilder builder) builder.AddScoped>(); builder.AddSingleton(DefaultTraversal.CreateTraversalFunc()); - builder.AddSingleton, RootObjectBuilder>(); + builder.AddSingleton, RhinoRootObjectBuilder>(); } } diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Receive/RhinoHostObjectBuilder.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Receive/RhinoHostObjectBuilder.cs index 48bc85ce99..f0a2f5822e 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Receive/RhinoHostObjectBuilder.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Receive/RhinoHostObjectBuilder.cs @@ -11,17 +11,17 @@ namespace Speckle.Connectors.Rhino7.Operations.Receive; public class RhinoHostObjectBuilder : IHostObjectBuilder { - private readonly ISpeckleConverterToHost _toHostConverter; + private readonly IRootToHostConverter _converter; private readonly IConversionContextStack _contextStack; private readonly GraphTraversal _traverseFunction; public RhinoHostObjectBuilder( - ISpeckleConverterToHost toHostConverter, + IRootToHostConverter converter, IConversionContextStack contextStack, GraphTraversal traverseFunction ) { - _toHostConverter = toHostConverter; + _converter = converter; _contextStack = contextStack; _traverseFunction = traverseFunction; } @@ -106,7 +106,7 @@ CancellationToken cancellationToken onOperationProgressed?.Invoke("Converting & creating objects", (double)++count / objects.Count); - var result = _toHostConverter.Convert(baseObj); + var result = _converter.Convert(baseObj); var conversionIds = HandleConversionResult(result, baseObj, layerIndex); newObjectIds.AddRange(conversionIds); diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Send/RootObjectBuilder.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Send/RhinoRootObjectBuilder.cs similarity index 96% rename from DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Send/RootObjectBuilder.cs rename to DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Send/RhinoRootObjectBuilder.cs index bc760a5679..e599829eaa 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Send/RootObjectBuilder.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Send/RhinoRootObjectBuilder.cs @@ -12,11 +12,11 @@ namespace Speckle.Connectors.Rhino7.Operations.Send; /// /// Stateless builder object to turn an into a object /// -public class RootObjectBuilder : IRootObjectBuilder +public class RhinoRootObjectBuilder : IRootObjectBuilder { private readonly IUnitOfWorkFactory _unitOfWorkFactory; - public RootObjectBuilder(IUnitOfWorkFactory unitOfWorkFactory) + public RhinoRootObjectBuilder(IUnitOfWorkFactory unitOfWorkFactory) { _unitOfWorkFactory = unitOfWorkFactory; } @@ -48,7 +48,7 @@ private Collection ConvertObjects( { // POC: does this feel like the right place? I am wondering if this should be called from within send/rcv? // begin the unit of work - using var uow = _unitOfWorkFactory.Resolve(); + using var uow = _unitOfWorkFactory.Resolve(); var converter = uow.Service; var rootObjectCollection = new Collection { name = RhinoDoc.ActiveDoc.Name ?? "Unnamed document" }; diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3.DependencyInjection/ArcGISConverterModule.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3.DependencyInjection/ArcGISConverterModule.cs index fc7cc0b773..a2bc5383a9 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3.DependencyInjection/ArcGISConverterModule.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3.DependencyInjection/ArcGISConverterModule.cs @@ -11,9 +11,9 @@ public class ArcGISConverterModule : ISpeckleModule { public void Load(SpeckleContainerBuilder builder) { - builder.AddConverterCommon(); + //don't need a host specific RootToSpeckleConverter + builder.AddConverterCommon(); // most things should be InstancePerLifetimeScope so we get one per operation - builder.AddScoped(); builder.AddScoped(); builder.AddScoped(); builder.AddScoped(); diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ArcGISToSpeckleUnitConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ArcGISToSpeckleUnitConverter.cs index be2c0e835b..a40e3d15d7 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ArcGISToSpeckleUnitConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ArcGISToSpeckleUnitConverter.cs @@ -7,29 +7,31 @@ namespace Speckle.Converters.ArcGIS3; public class ArcGISToSpeckleUnitConverter : IHostToSpeckleUnitConverter { - private readonly Dictionary _unitMapping = new(); + private static readonly IReadOnlyDictionary s_unitMapping = Create(); - public ArcGISToSpeckleUnitConverter() + private static IReadOnlyDictionary Create() { + var dict = new Dictionary(); // POC: we should have a unit test to confirm these are as expected and don't change //_unitMapping[LinearUnit.] = Units.Meters; - _unitMapping[LinearUnit.Millimeters.Name] = Units.Millimeters; - _unitMapping[LinearUnit.Centimeters.Name] = Units.Centimeters; - _unitMapping[LinearUnit.Meters.Name] = Units.Meters; - _unitMapping[LinearUnit.Kilometers.Name] = Units.Kilometers; - _unitMapping[LinearUnit.Inches.Name] = Units.Inches; - _unitMapping[LinearUnit.Feet.Name] = Units.Feet; - _unitMapping[LinearUnit.Yards.Name] = Units.Yards; - _unitMapping[LinearUnit.Miles.Name] = Units.Miles; + dict[LinearUnit.Millimeters.Name] = Units.Millimeters; + dict[LinearUnit.Centimeters.Name] = Units.Centimeters; + dict[LinearUnit.Meters.Name] = Units.Meters; + dict[LinearUnit.Kilometers.Name] = Units.Kilometers; + dict[LinearUnit.Inches.Name] = Units.Inches; + dict[LinearUnit.Feet.Name] = Units.Feet; + dict[LinearUnit.Yards.Name] = Units.Yards; + dict[LinearUnit.Miles.Name] = Units.Miles; //_unitMapping[LinearUnit.Decimeters] = Units.; //_unitMapping[LinearUnit.NauticalMiles] = Units.; + return dict; } public string ConvertOrThrow(Unit hostUnit) { var linearUnit = LinearUnit.CreateLinearUnit(hostUnit.Wkt).Name; - if (_unitMapping.TryGetValue(linearUnit, out string? value)) + if (s_unitMapping.TryGetValue(linearUnit, out string? value)) { return value; } diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/FakeConversion.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/FakeTopLevelConverter.cs similarity index 61% rename from DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/FakeConversion.cs rename to DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/FakeTopLevelConverter.cs index c920467276..1c02e2120b 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/FakeConversion.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/FakeTopLevelConverter.cs @@ -6,11 +6,11 @@ namespace Speckle.Converters.ArcGIS3; [NameAndRankValue(nameof(String), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class FakeConversion : IHostObjectToSpeckleConversion, IRawConversion +public class FakeTopLevelConverter : IToSpeckleTopLevelConverter, ITypedConverter { - public Base Convert(object target) => RawConvert((String)target); + public Base Convert(object target) => Convert((String)target); - public Point RawConvert(String target) + public Point Convert(String target) { return new Point(0, 0, 100) { ["customText"] = target }; } diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GeometryToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GeometryToHostConverter.cs index 4ca74197b5..2ee8dc31d2 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GeometryToHostConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GeometryToHostConverter.cs @@ -4,20 +4,20 @@ namespace Speckle.Converters.ArcGIS3.Features; -public class GeometryToHostConverter : IRawConversion, ACG.Geometry> +public class GeometryToHostConverter : ITypedConverter, ACG.Geometry> { - private readonly IRawConversion, ACG.Polyline> _polylineConverter; - private readonly IRawConversion, ACG.Multipoint> _multipointConverter; - private readonly IRawConversion, ACG.Multipatch> _polygon3dConverter; - private readonly IRawConversion, ACG.Polygon> _polygonConverter; - private readonly IRawConversion, ACG.Multipatch> _multipatchConverter; + private readonly ITypedConverter, ACG.Polyline> _polylineConverter; + private readonly ITypedConverter, ACG.Multipoint> _multipointConverter; + private readonly ITypedConverter, ACG.Multipatch> _polygon3dConverter; + private readonly ITypedConverter, ACG.Polygon> _polygonConverter; + private readonly ITypedConverter, ACG.Multipatch> _multipatchConverter; public GeometryToHostConverter( - IRawConversion, ACG.Polyline> polylineConverter, - IRawConversion, ACG.Multipoint> multipointConverter, - IRawConversion, ACG.Multipatch> polygon3dConverter, - IRawConversion, ACG.Polygon> polygonConverter, - IRawConversion, ACG.Multipatch> multipatchConverter + ITypedConverter, ACG.Polyline> polylineConverter, + ITypedConverter, ACG.Multipoint> multipointConverter, + ITypedConverter, ACG.Multipatch> polygon3dConverter, + ITypedConverter, ACG.Polygon> polygonConverter, + ITypedConverter, ACG.Multipatch> multipatchConverter ) { _polylineConverter = polylineConverter; @@ -27,7 +27,7 @@ public GeometryToHostConverter( _multipatchConverter = multipatchConverter; } - public ACG.Geometry RawConvert(IReadOnlyList target) + public ACG.Geometry Convert(IReadOnlyList target) { try { @@ -36,15 +36,15 @@ public ACG.Geometry RawConvert(IReadOnlyList target) switch (target[0]) { case SOG.Point point: - return _multipointConverter.RawConvert(target.Cast().ToList()); + return _multipointConverter.Convert(target.Cast().ToList()); case SOG.Polyline polyline: - return _polylineConverter.RawConvert(target.Cast().ToList()); + return _polylineConverter.Convert(target.Cast().ToList()); case SGIS.PolygonGeometry3d geometry3d: - return _polygon3dConverter.RawConvert(target.Cast().ToList()); + return _polygon3dConverter.Convert(target.Cast().ToList()); case SGIS.PolygonGeometry geometry: - return _polygonConverter.RawConvert(target.Cast().ToList()); + return _polygonConverter.Convert(target.Cast().ToList()); case SGIS.GisMultipatchGeometry mesh: - return _multipatchConverter.RawConvert(target.Cast().ToList()); + return _multipatchConverter.Convert(target.Cast().ToList()); default: throw new NotSupportedException($"No conversion found for type {target[0]}"); } diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GeometryToSpeckleBase.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GeometryToSpeckleBase.cs index f32ca4bdde..db4c5cab66 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GeometryToSpeckleBase.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GeometryToSpeckleBase.cs @@ -4,20 +4,20 @@ namespace Speckle.Converters.ArcGIS3.Features; -public class GeometryToSpeckleBaseList : IRawConversion> +public class GeometryToSpeckleBaseList : ITypedConverter> { - private readonly IRawConversion _pointToSpeckleConverter; - private readonly IRawConversion> _multiPointFeatureConverter; - private readonly IRawConversion> _polylineFeatureConverter; - private readonly IRawConversion> _polygonFeatureConverter; - private readonly IRawConversion> _multipatchFeatureConverter; + private readonly ITypedConverter _pointToSpeckleConverter; + private readonly ITypedConverter> _multiPointFeatureConverter; + private readonly ITypedConverter> _polylineFeatureConverter; + private readonly ITypedConverter> _polygonFeatureConverter; + private readonly ITypedConverter> _multipatchFeatureConverter; public GeometryToSpeckleBaseList( - IRawConversion pointToSpeckleConverter, - IRawConversion> multiPointFeatureConverter, - IRawConversion> polylineFeatureConverter, - IRawConversion> polygonFeatureConverter, - IRawConversion> multipatchFeatureConverter + ITypedConverter pointToSpeckleConverter, + ITypedConverter> multiPointFeatureConverter, + ITypedConverter> polylineFeatureConverter, + ITypedConverter> polygonFeatureConverter, + ITypedConverter> multipatchFeatureConverter ) { _pointToSpeckleConverter = pointToSpeckleConverter; @@ -27,17 +27,17 @@ public GeometryToSpeckleBaseList( _multipatchFeatureConverter = multipatchFeatureConverter; } - public IReadOnlyList RawConvert(ACG.Geometry target) + public IReadOnlyList Convert(ACG.Geometry target) { try { return target switch { - ACG.MapPoint point => new List() { _pointToSpeckleConverter.RawConvert(point) }, - ACG.Multipoint multipoint => _multiPointFeatureConverter.RawConvert(multipoint), - ACG.Polyline polyline => _polylineFeatureConverter.RawConvert(polyline), - ACG.Polygon polygon => _polygonFeatureConverter.RawConvert(polygon), - ACG.Multipatch multipatch => _multipatchFeatureConverter.RawConvert(multipatch), // GisMultipatchGeometry or PolygonGeometry3d + ACG.MapPoint point => new List() { _pointToSpeckleConverter.Convert(point) }, + ACG.Multipoint multipoint => _multiPointFeatureConverter.Convert(multipoint), + ACG.Polyline polyline => _polylineFeatureConverter.Convert(polyline), + ACG.Polygon polygon => _polygonFeatureConverter.Convert(polygon), + ACG.Multipatch multipatch => _multipatchFeatureConverter.Convert(multipatch), // GisMultipatchGeometry or PolygonGeometry3d _ => throw new NotSupportedException($"No conversion found for {target.GetType().Name}"), }; } diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GisFeatureToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GisFeatureToSpeckleConverter.cs index ff34d8fa0d..10aac2ae25 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GisFeatureToSpeckleConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GisFeatureToSpeckleConverter.cs @@ -6,11 +6,11 @@ namespace Speckle.Converters.ArcGIS3.Features; -public class GisFeatureToSpeckleConverter : IRawConversion +public class GisFeatureToSpeckleConverter : ITypedConverter { - private readonly IRawConversion> _geometryConverter; + private readonly ITypedConverter> _geometryConverter; - public GisFeatureToSpeckleConverter(IRawConversion> geometryConverter) + public GisFeatureToSpeckleConverter(ITypedConverter> geometryConverter) { _geometryConverter = geometryConverter; } @@ -48,7 +48,7 @@ private List GenerateFeatureDisplayValueList(List speckleShapes) return displayVal; } - public SGIS.GisFeature RawConvert(Row target) + public SGIS.GisFeature Convert(Row target) { // get attributes var attributes = new Base(); @@ -94,7 +94,7 @@ public SGIS.GisFeature RawConvert(Row target) else { var shape = (ACG.Geometry)target[geometryField]; - var speckleShapes = _geometryConverter.RawConvert(shape).ToList(); + var speckleShapes = _geometryConverter.Convert(shape).ToList(); // if geometry is primitive if ( diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GisRasterToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GisRasterToSpeckleConverter.cs index a223c1713b..bcee923315 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GisRasterToSpeckleConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GisRasterToSpeckleConverter.cs @@ -8,13 +8,13 @@ namespace Speckle.Converters.ArcGIS3.Features; -public class GisRasterToSpeckleConverter : IRawConversion +public class GisRasterToSpeckleConverter : ITypedConverter { - private readonly IRawConversion> _geometryConverter; + private readonly ITypedConverter> _geometryConverter; private readonly IConversionContextStack _contextStack; public GisRasterToSpeckleConverter( - IRawConversion> geometryConverter, + ITypedConverter> geometryConverter, IConversionContextStack contextStack ) { @@ -22,7 +22,7 @@ IConversionContextStack contextStack _contextStack = contextStack; } - public Base Convert(object target) => RawConvert((Raster)target); + public Base Convert(object target) => Convert((Raster)target); private List GetRasterMeshCoords(Raster target, List> pixelValsPerBand) { @@ -102,7 +102,7 @@ private List GetRasterColors(int bandCount, List> pixelValsPerBa return newColors; } - public RasterElement RawConvert(Raster target) + public RasterElement Convert(Raster target) { // assisting variables var extent = target.GetExtent(); diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/MultipatchFeatureToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/MultipatchFeatureToSpeckleConverter.cs index 645396f25a..2da8dd6bf1 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/MultipatchFeatureToSpeckleConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/MultipatchFeatureToSpeckleConverter.cs @@ -6,21 +6,21 @@ namespace Speckle.Converters.ArcGIS3.Features; -public class MultipatchFeatureToSpeckleConverter : IRawConversion> +public class MultipatchFeatureToSpeckleConverter : ITypedConverter> { private readonly IConversionContextStack _contextStack; - private readonly IRawConversion _pointConverter; + private readonly ITypedConverter _pointConverter; public MultipatchFeatureToSpeckleConverter( IConversionContextStack contextStack, - IRawConversion pointConverter + ITypedConverter pointConverter ) { _contextStack = contextStack; _pointConverter = pointConverter; } - public IReadOnlyList RawConvert(ACG.Multipatch target) + public IReadOnlyList Convert(ACG.Multipatch target) { List converted = new(); // placeholder, needs to be declared in order to be used in the Ring patch type @@ -35,7 +35,7 @@ public IReadOnlyList RawConvert(ACG.Multipatch target) int ptCount = target.GetPatchPointCount(idx); for (int ptIdx = ptStartIndex; ptIdx < ptStartIndex + ptCount; ptIdx++) { - pointList.Add(_pointConverter.RawConvert(target.Points[ptIdx])); + pointList.Add(_pointConverter.Convert(target.Points[ptIdx])); } allPoints.Add(pointList); } diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/MultipointFeatureToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/MultipointFeatureToSpeckleConverter.cs index 6d7abbab9a..c7e1669038 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/MultipointFeatureToSpeckleConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/MultipointFeatureToSpeckleConverter.cs @@ -2,21 +2,21 @@ namespace Speckle.Converters.ArcGIS3.Features; -public class MultipointFeatureToSpeckleConverter : IRawConversion> +public class MultipointFeatureToSpeckleConverter : ITypedConverter> { - private readonly IRawConversion _pointConverter; + private readonly ITypedConverter _pointConverter; - public MultipointFeatureToSpeckleConverter(IRawConversion pointConverter) + public MultipointFeatureToSpeckleConverter(ITypedConverter pointConverter) { _pointConverter = pointConverter; } - public IReadOnlyList RawConvert(ACG.Multipoint target) + public IReadOnlyList Convert(ACG.Multipoint target) { List multipoint = new(); foreach (ACG.MapPoint point in target.Points) { - multipoint.Add(_pointConverter.RawConvert(point)); + multipoint.Add(_pointConverter.Convert(point)); } return multipoint; diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/PointFeatureToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/PointFeatureToSpeckleConverter.cs index 7f26b81371..5be96b9357 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/PointFeatureToSpeckleConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/PointFeatureToSpeckleConverter.cs @@ -6,7 +6,7 @@ namespace Speckle.Converters.ArcGIS3.Features; [NameAndRankValue(nameof(ACG.MapPoint), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class PointFeatureToSpeckleConverter : IHostObjectToSpeckleConversion, IRawConversion +public class PointFeatureToSpeckleConverter : IToSpeckleTopLevelConverter, ITypedConverter { private readonly IConversionContextStack _contextStack; @@ -15,9 +15,9 @@ public PointFeatureToSpeckleConverter(IConversionContextStack con _contextStack = contextStack; } - public Base Convert(object target) => RawConvert((ACG.MapPoint)target); + public Base Convert(object target) => Convert((ACG.MapPoint)target); - public Base RawConvert(ACG.MapPoint target) + public Base Convert(ACG.MapPoint target) { if ( ACG.GeometryEngine.Instance.Project(target, _contextStack.Current.Document.SpatialReference) diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/PolygonFeatureToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/PolygonFeatureToSpeckleConverter.cs index 4eea1ba419..3bbf377d3b 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/PolygonFeatureToSpeckleConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/PolygonFeatureToSpeckleConverter.cs @@ -4,16 +4,16 @@ namespace Speckle.Converters.ArcGIS3.Features; -public class PolygonFeatureToSpeckleConverter : IRawConversion> +public class PolygonFeatureToSpeckleConverter : ITypedConverter> { - private readonly IRawConversion _segmentConverter; + private readonly ITypedConverter _segmentConverter; - public PolygonFeatureToSpeckleConverter(IRawConversion segmentConverter) + public PolygonFeatureToSpeckleConverter(ITypedConverter segmentConverter) { _segmentConverter = segmentConverter; } - public IReadOnlyList RawConvert(ACG.Polygon target) + public IReadOnlyList Convert(ACG.Polygon target) { // https://pro.arcgis.com/en/pro-app/latest/sdk/api-reference/topic30235.html List polygonList = new(); @@ -30,7 +30,7 @@ public IReadOnlyList RawConvert(ACG.Polygon target) for (int idx = 0; idx < partCount; idx++) { ACG.ReadOnlySegmentCollection segmentCollection = target.Parts[idx]; - SOG.Polyline polyline = _segmentConverter.RawConvert(segmentCollection); + SOG.Polyline polyline = _segmentConverter.Convert(segmentCollection); bool isExteriorRing = target.IsExteriorRing(idx); if (isExteriorRing is true) diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/PolylineFeatureToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/PolylineFeatureToSpeckleConverter.cs index e9bd50001e..2af833bed4 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/PolylineFeatureToSpeckleConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/PolylineFeatureToSpeckleConverter.cs @@ -2,22 +2,22 @@ namespace Speckle.Converters.ArcGIS3.Features; -public class PolyineFeatureToSpeckleConverter : IRawConversion> +public class PolyineFeatureToSpeckleConverter : ITypedConverter> { - private readonly IRawConversion _segmentConverter; + private readonly ITypedConverter _segmentConverter; - public PolyineFeatureToSpeckleConverter(IRawConversion segmentConverter) + public PolyineFeatureToSpeckleConverter(ITypedConverter segmentConverter) { _segmentConverter = segmentConverter; } - public IReadOnlyList RawConvert(ACG.Polyline target) + public IReadOnlyList Convert(ACG.Polyline target) { // https://pro.arcgis.com/en/pro-app/latest/sdk/api-reference/topic8480.html List polylineList = new(); foreach (var segmentCollection in target.Parts) { - polylineList.Add(_segmentConverter.RawConvert(segmentCollection)); + polylineList.Add(_segmentConverter.Convert(segmentCollection)); } return polylineList; } diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/BezierSegmentToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/BezierSegmentToSpeckleConverter.cs index 71638333da..8c62df731d 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/BezierSegmentToSpeckleConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/BezierSegmentToSpeckleConverter.cs @@ -4,21 +4,21 @@ namespace Speckle.Converters.ArcGIS3.Geometry; -public class BezierSegmentToSpeckleConverter : IRawConversion +public class BezierSegmentToSpeckleConverter : ITypedConverter { private readonly IConversionContextStack _contextStack; - private readonly IRawConversion _pointConverter; + private readonly ITypedConverter _pointConverter; public BezierSegmentToSpeckleConverter( IConversionContextStack contextStack, - IRawConversion pointConverter + ITypedConverter pointConverter ) { _contextStack = contextStack; _pointConverter = pointConverter; } - public SOG.Polyline RawConvert(ACG.CubicBezierSegment target) + public SOG.Polyline Convert(ACG.CubicBezierSegment target) { // Determine the number of vertices to create along the arc int numVertices = Math.Max((int)target.Length, 3); // Determine based on desired segment length or other criteria @@ -43,7 +43,7 @@ public SOG.Polyline RawConvert(ACG.CubicBezierSegment target) + t * t * t * target.EndPoint.Y; ACG.MapPoint pointOnCurve = ACG.MapPointBuilderEx.CreateMapPoint(x, y, target.SpatialReference); - points.Add(_pointConverter.RawConvert(pointOnCurve)); + points.Add(_pointConverter.Convert(pointOnCurve)); } // create Speckle Polyline diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/EllipticArcSegmentToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/EllipticArcSegmentToSpeckleConverter.cs index 11905f94a8..af4c3716c4 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/EllipticArcSegmentToSpeckleConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/EllipticArcSegmentToSpeckleConverter.cs @@ -4,21 +4,21 @@ namespace Speckle.Converters.ArcGIS3.Geometry; -public class EllipticArcToSpeckleConverter : IRawConversion +public class EllipticArcToSpeckleConverter : ITypedConverter { private readonly IConversionContextStack _contextStack; - private readonly IRawConversion _pointConverter; + private readonly ITypedConverter _pointConverter; public EllipticArcToSpeckleConverter( IConversionContextStack contextStack, - IRawConversion pointConverter + ITypedConverter pointConverter ) { _contextStack = contextStack; _pointConverter = pointConverter; } - public SOG.Polyline RawConvert(ACG.EllipticArcSegment target) + public SOG.Polyline Convert(ACG.EllipticArcSegment target) { // Determine the number of vertices to create along the arc int numVertices = Math.Max((int)target.Length, 3); // Determine based on desired segment length or other criteria @@ -52,7 +52,7 @@ public SOG.Polyline RawConvert(ACG.EllipticArcSegment target) target.SpatialReference ); - points.Add(_pointConverter.RawConvert(pointOnArc)); + points.Add(_pointConverter.Convert(pointOnArc)); } // create Speckle Polyline diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/EnvelopBoxToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/EnvelopBoxToSpeckleConverter.cs index 68d74e968f..5a101f250f 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/EnvelopBoxToSpeckleConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/EnvelopBoxToSpeckleConverter.cs @@ -6,21 +6,21 @@ namespace Speckle.Converters.ArcGIS3.Geometry; -public class EnvelopToSpeckleConverter : IRawConversion +public class EnvelopToSpeckleConverter : ITypedConverter { private readonly IConversionContextStack _contextStack; - private readonly IRawConversion _pointConverter; + private readonly ITypedConverter _pointConverter; public EnvelopToSpeckleConverter( IConversionContextStack contextStack, - IRawConversion pointConverter + ITypedConverter pointConverter ) { _contextStack = contextStack; _pointConverter = pointConverter; } - public SOG.Box RawConvert(Envelope target) + public SOG.Box Convert(Envelope target) { MapPoint pointMin = new MapPointBuilderEx( target.XMin, @@ -34,8 +34,8 @@ public SOG.Box RawConvert(Envelope target) target.ZMax, _contextStack.Current.Document.SpatialReference ).ToGeometry(); - SOG.Point minPtSpeckle = _pointConverter.RawConvert(pointMin); - SOG.Point maxPtSpeckle = _pointConverter.RawConvert(pointMax); + SOG.Point minPtSpeckle = _pointConverter.Convert(pointMin); + SOG.Point maxPtSpeckle = _pointConverter.Convert(pointMax); var units = _contextStack.Current.SpeckleUnits; diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/FallbackToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/FallbackToHostConverter.cs index 3eddcc8d81..ec9f1eef77 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/FallbackToHostConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/FallbackToHostConverter.cs @@ -5,16 +5,16 @@ namespace Speckle.Converters.ArcGIS3.Geometry; [NameAndRankValue(nameof(DisplayableObject), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class FallbackToHostConverter : ISpeckleObjectToHostConversion, IRawConversion +public class FallbackToHostConverter : IToHostTopLevelConverter, ITypedConverter { - private readonly IRawConversion, ACG.Multipatch> _meshListConverter; - private readonly IRawConversion, ACG.Polyline> _polylineListConverter; - private readonly IRawConversion, ACG.Multipoint> _pointListConverter; + private readonly ITypedConverter, ACG.Multipatch> _meshListConverter; + private readonly ITypedConverter, ACG.Polyline> _polylineListConverter; + private readonly ITypedConverter, ACG.Multipoint> _pointListConverter; public FallbackToHostConverter( - IRawConversion, ACG.Multipatch> meshListConverter, - IRawConversion, ACG.Polyline> polylineListConverter, - IRawConversion, ACG.Multipoint> pointListConverter + ITypedConverter, ACG.Multipatch> meshListConverter, + ITypedConverter, ACG.Polyline> polylineListConverter, + ITypedConverter, ACG.Multipoint> pointListConverter ) { _meshListConverter = meshListConverter; @@ -22,9 +22,9 @@ public FallbackToHostConverter( _pointListConverter = pointListConverter; } - public object Convert(Base target) => RawConvert((DisplayableObject)target); + public object Convert(Base target) => Convert((DisplayableObject)target); - public ACG.Geometry RawConvert(DisplayableObject target) + public ACG.Geometry Convert(DisplayableObject target) { if (!target.displayValue.Any()) { @@ -35,9 +35,9 @@ public ACG.Geometry RawConvert(DisplayableObject target) return first switch { - SOG.Polyline => _polylineListConverter.RawConvert(target.displayValue.Cast().ToList()), - SOG.Mesh => _meshListConverter.RawConvert(target.displayValue.Cast().ToList()), - SOG.Point => _pointListConverter.RawConvert(target.displayValue.Cast().ToList()), + SOG.Polyline => _polylineListConverter.Convert(target.displayValue.Cast().ToList()), + SOG.Mesh => _meshListConverter.Convert(target.displayValue.Cast().ToList()), + SOG.Point => _pointListConverter.Convert(target.displayValue.Cast().ToList()), _ => throw new NotSupportedException($"Found unsupported fallback geometry: {first.GetType()}") }; } diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/MeshListToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/MeshListToHostConverter.cs index 42c5df2692..7730f54308 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/MeshListToHostConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/MeshListToHostConverter.cs @@ -4,16 +4,16 @@ namespace Speckle.Converters.ArcGIS3.Geometry.GisFeatureGeometriesToHost; -public class MeshListToHostConverter : IRawConversion, ACG.Multipatch> +public class MeshListToHostConverter : ITypedConverter, ACG.Multipatch> { - private readonly IRawConversion _pointConverter; + private readonly ITypedConverter _pointConverter; - public MeshListToHostConverter(IRawConversion pointConverter) + public MeshListToHostConverter(ITypedConverter pointConverter) { _pointConverter = pointConverter; } - public ACG.Multipatch RawConvert(List target) + public ACG.Multipatch Convert(List target) { if (target.Count == 0) { @@ -32,7 +32,7 @@ public ACG.Multipatch RawConvert(List target) } int ptIndex = part.faces[i]; newPatch.AddPoint( - _pointConverter.RawConvert( + _pointConverter.Convert( new SOG.Point(part.vertices[ptIndex * 3], part.vertices[ptIndex * 3 + 1], part.vertices[ptIndex * 3 + 2]) { units = part.units diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/MultipatchListToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/MultipatchListToHostConverter.cs index 3966c7addb..e2a4d6028e 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/MultipatchListToHostConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/MultipatchListToHostConverter.cs @@ -3,16 +3,16 @@ namespace Speckle.Converters.ArcGIS3.Geometry.GisFeatureGeometriesToHost; -public class MultipatchListToHostConverter : IRawConversion, ACG.Multipatch> +public class MultipatchListToHostConverter : ITypedConverter, ACG.Multipatch> { - private readonly IRawConversion _pointConverter; + private readonly ITypedConverter _pointConverter; - public MultipatchListToHostConverter(IRawConversion pointConverter) + public MultipatchListToHostConverter(ITypedConverter pointConverter) { _pointConverter = pointConverter; } - public ACG.Multipatch RawConvert(List target) + public ACG.Multipatch Convert(List target) { if (target.Count == 0) { @@ -25,7 +25,7 @@ public ACG.Multipatch RawConvert(List target) for (int i = 0; i < part.vertices.Count / 3; i++) { newPatch.AddPoint( - _pointConverter.RawConvert( + _pointConverter.Convert( new SOG.Point(part.vertices[i * 3], part.vertices[i * 3 + 1], part.vertices[i * 3 + 2]) ) ); diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/PointListToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/PointListToHostConverter.cs index 651c020011..ac1d3e5467 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/PointListToHostConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/PointListToHostConverter.cs @@ -3,16 +3,16 @@ namespace Speckle.Converters.ArcGIS3.Geometry.GisFeatureGeometriesToHost; -public class PointListToHostConverter : IRawConversion, ACG.Multipoint> +public class PointListToHostConverter : ITypedConverter, ACG.Multipoint> { - private readonly IRawConversion _pointConverter; + private readonly ITypedConverter _pointConverter; - public PointListToHostConverter(IRawConversion pointConverter) + public PointListToHostConverter(ITypedConverter pointConverter) { _pointConverter = pointConverter; } - public ACG.Multipoint RawConvert(List target) + public ACG.Multipoint Convert(List target) { if (target.Count == 0) { @@ -21,7 +21,7 @@ public ACG.Multipoint RawConvert(List target) List pointList = new(); foreach (SOG.Point pt in target) { - pointList.Add(_pointConverter.RawConvert(pt)); + pointList.Add(_pointConverter.Convert(pt)); } return new ACG.MultipointBuilderEx(pointList, ACG.AttributeFlags.HasZ).ToGeometry(); } diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/Polygon3dListToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/Polygon3dListToHostConverter.cs index 8a58236e56..72f6951056 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/Polygon3dListToHostConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/Polygon3dListToHostConverter.cs @@ -3,21 +3,21 @@ namespace Speckle.Converters.ArcGIS3.Geometry.GisFeatureGeometriesToHost; -public class Polygon3dListToHostConverter : IRawConversion, ACG.Multipatch> +public class Polygon3dListToHostConverter : ITypedConverter, ACG.Multipatch> { - private readonly IRawConversion _pointConverter; - private readonly IRawConversion _polylineConverter; + private readonly ITypedConverter _pointConverter; + private readonly ITypedConverter _polylineConverter; public Polygon3dListToHostConverter( - IRawConversion pointConverter, - IRawConversion polylineConverter + ITypedConverter pointConverter, + ITypedConverter polylineConverter ) { _pointConverter = pointConverter; _polylineConverter = polylineConverter; } - public ACG.Multipatch RawConvert(List target) + public ACG.Multipatch Convert(List target) { if (target.Count == 0) { @@ -31,7 +31,7 @@ public ACG.Multipatch RawConvert(List target) List boundaryPts = part.boundary.GetPoints(); foreach (SOG.Point pt in boundaryPts) { - newPatch.AddPoint(_pointConverter.RawConvert(pt)); + newPatch.AddPoint(_pointConverter.Convert(pt)); } multipatchPart.Patches.Add(newPatch); @@ -41,7 +41,7 @@ public ACG.Multipatch RawConvert(List target) List loopPts = loop.GetPoints(); foreach (SOG.Point pt in loopPts) { - newLoopPatch.AddPoint(_pointConverter.RawConvert(pt)); + newLoopPatch.AddPoint(_pointConverter.Convert(pt)); } multipatchPart.Patches.Add(newLoopPatch); } diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/PolygonListToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/PolygonListToHostConverter.cs index d8e1fc9ffd..b6aa76cb1c 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/PolygonListToHostConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/PolygonListToHostConverter.cs @@ -3,16 +3,16 @@ namespace Speckle.Converters.ArcGIS3.Geometry.GisFeatureGeometriesToHost; -public class PolygonListToHostConverter : IRawConversion, ACG.Polygon> +public class PolygonListToHostConverter : ITypedConverter, ACG.Polygon> { - private readonly IRawConversion _polylineConverter; + private readonly ITypedConverter _polylineConverter; - public PolygonListToHostConverter(IRawConversion polylineConverter) + public PolygonListToHostConverter(ITypedConverter polylineConverter) { _polylineConverter = polylineConverter; } - public ACG.Polygon RawConvert(List target) + public ACG.Polygon Convert(List target) { if (target.Count == 0) { @@ -21,13 +21,13 @@ public ACG.Polygon RawConvert(List target) List polyList = new(); foreach (SGIS.PolygonGeometry poly in target) { - ACG.Polyline boundary = _polylineConverter.RawConvert(poly.boundary); + ACG.Polyline boundary = _polylineConverter.Convert(poly.boundary); ACG.PolygonBuilderEx polyOuterRing = new(boundary); foreach (SOG.Polyline loop in poly.voids) { // adding inner loops: https://github.com/esri/arcgis-pro-sdk/wiki/ProSnippets-Geometry#build-a-donut-polygon - ACG.Polyline loopNative = _polylineConverter.RawConvert(loop); + ACG.Polyline loopNative = _polylineConverter.Convert(loop); polyOuterRing.AddPart(loopNative.Copy3DCoordinatesToList()); } ACG.Polygon polygon = polyOuterRing.ToGeometry(); diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/PolylineListToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/PolylineListToHostConverter.cs index cfde1fee8c..97983c42bf 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/PolylineListToHostConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/PolylineListToHostConverter.cs @@ -3,16 +3,16 @@ namespace Speckle.Converters.ArcGIS3.Geometry.GisFeatureGeometriesToHost; -public class PolylineListToHostConverter : IRawConversion, ACG.Polyline> +public class PolylineListToHostConverter : ITypedConverter, ACG.Polyline> { - private readonly IRawConversion _polylineConverter; + private readonly ITypedConverter _polylineConverter; - public PolylineListToHostConverter(IRawConversion polylineConverter) + public PolylineListToHostConverter(ITypedConverter polylineConverter) { _polylineConverter = polylineConverter; } - public ACG.Polyline RawConvert(List target) + public ACG.Polyline Convert(List target) { if (target.Count == 0) { @@ -21,7 +21,7 @@ public ACG.Polyline RawConvert(List target) List polyList = new(); foreach (SOG.Polyline poly in target) { - ACG.Polyline arcgisPoly = _polylineConverter.RawConvert(poly); + ACG.Polyline arcgisPoly = _polylineConverter.Convert(poly); polyList.Add(arcgisPoly); } return new ACG.PolylineBuilderEx(polyList, ACG.AttributeFlags.HasZ).ToGeometry(); diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/ArcToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/ArcToHostConverter.cs index 635d47ecbc..ec46307cfc 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/ArcToHostConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/ArcToHostConverter.cs @@ -6,18 +6,18 @@ namespace Speckle.Converters.ArcGIS3.Geometry.ISpeckleObjectToHost; //TODO: Ellipses don't convert correctly, see Autocad test stream //[NameAndRankValue(nameof(SOG.Arc), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class CurveToHostConverter : ISpeckleObjectToHostConversion, IRawConversion +public class CurveToHostConverter : IToHostTopLevelConverter, ITypedConverter { - private readonly IRawConversion _pointConverter; + private readonly ITypedConverter _pointConverter; - public CurveToHostConverter(IRawConversion pointConverter) + public CurveToHostConverter(ITypedConverter pointConverter) { _pointConverter = pointConverter; } - public object Convert(Base target) => RawConvert((SOG.Arc)target); + public object Convert(Base target) => Convert((SOG.Arc)target); - public ACG.Polyline RawConvert(SOG.Arc target) + public ACG.Polyline Convert(SOG.Arc target) { // Determine the number of vertices to create along the arc int numVertices = Math.Max((int)target.length, 50); // Determine based on desired segment length or other criteria @@ -48,7 +48,7 @@ public ACG.Polyline RawConvert(SOG.Arc target) pointsOriginal.Add(pointOnArc); } - var points = pointsOriginal.Select(x => _pointConverter.RawConvert(x)); + var points = pointsOriginal.Select(x => _pointConverter.Convert(x)); return new ACG.PolylineBuilderEx(points, ACG.AttributeFlags.HasZ).ToGeometry(); } } diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/CircleToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/CircleToHostConverter.cs index c9437eac81..cff9770e7d 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/CircleToHostConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/CircleToHostConverter.cs @@ -5,18 +5,18 @@ namespace Speckle.Converters.ArcGIS3.Geometry.ISpeckleObjectToHost; [NameAndRankValue(nameof(SOG.Circle), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class CircleToHostConverter : ISpeckleObjectToHostConversion, IRawConversion +public class CircleToHostConverter : IToHostTopLevelConverter, ITypedConverter { - private readonly IRawConversion _pointConverter; + private readonly ITypedConverter _pointConverter; - public CircleToHostConverter(IRawConversion pointConverter) + public CircleToHostConverter(ITypedConverter pointConverter) { _pointConverter = pointConverter; } - public object Convert(Base target) => RawConvert((SOG.Circle)target); + public object Convert(Base target) => Convert((SOG.Circle)target); - public ACG.Polyline RawConvert(SOG.Circle target) + public ACG.Polyline Convert(SOG.Circle target) { // Determine the number of vertices to create along the cirlce int numVertices = Math.Max((int)target.length, 100); // Determine based on desired segment length or other criteria @@ -46,7 +46,7 @@ public ACG.Polyline RawConvert(SOG.Circle target) pointsOriginal.Add(pointsOriginal[0]); } - var points = pointsOriginal.Select(x => _pointConverter.RawConvert(x)); + var points = pointsOriginal.Select(x => _pointConverter.Convert(x)); return new ACG.PolylineBuilderEx(points, ACG.AttributeFlags.HasZ).ToGeometry(); } } diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/EllipseToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/EllipseToHostConverter.cs index 511350cd71..94ee04b951 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/EllipseToHostConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/EllipseToHostConverter.cs @@ -6,18 +6,18 @@ namespace Speckle.Converters.ArcGIS3.Geometry.ISpeckleObjectToHost; //TODO: Ellipses don't convert correctly, see Autocad test stream // [NameAndRankValue(nameof(SOG.Ellipse), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class EllipseToHostConverter : ISpeckleObjectToHostConversion, IRawConversion +public class EllipseToHostConverter : IToHostTopLevelConverter, ITypedConverter { - private readonly IRawConversion _pointConverter; + private readonly ITypedConverter _pointConverter; - public EllipseToHostConverter(IRawConversion pointConverter) + public EllipseToHostConverter(ITypedConverter pointConverter) { _pointConverter = pointConverter; } - public object Convert(Base target) => RawConvert((SOG.Ellipse)target); + public object Convert(Base target) => Convert((SOG.Ellipse)target); - public ACG.Polyline RawConvert(SOG.Ellipse target) + public ACG.Polyline Convert(SOG.Ellipse target) { // Determine the number of vertices to create along the Ellipse int numVertices = Math.Max((int)target.length, 100); // Determine based on desired segment length or other criteria @@ -47,7 +47,7 @@ public ACG.Polyline RawConvert(SOG.Ellipse target) pointsOriginal.Add(pointsOriginal[0]); } - var points = pointsOriginal.Select(x => _pointConverter.RawConvert(x)); + var points = pointsOriginal.Select(x => _pointConverter.Convert(x)); return new ACG.PolylineBuilderEx(points, ACG.AttributeFlags.HasZ).ToGeometry(); } } diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/LineToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/LineToHostConverter.cs index 761b20e0b6..60a1447d7b 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/LineToHostConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/LineToHostConverter.cs @@ -5,21 +5,21 @@ namespace Speckle.Converters.ArcGIS3.Geometry.ISpeckleObjectToHost; [NameAndRankValue(nameof(SOG.Line), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class LineSingleToHostConverter : ISpeckleObjectToHostConversion, IRawConversion +public class LineSingleToHostConverter : IToHostTopLevelConverter, ITypedConverter { - private readonly IRawConversion _pointConverter; + private readonly ITypedConverter _pointConverter; - public LineSingleToHostConverter(IRawConversion pointConverter) + public LineSingleToHostConverter(ITypedConverter pointConverter) { _pointConverter = pointConverter; } - public object Convert(Base target) => RawConvert((SOG.Line)target); + public object Convert(Base target) => Convert((SOG.Line)target); - public ACG.Polyline RawConvert(SOG.Line target) + public ACG.Polyline Convert(SOG.Line target) { List originalPoints = new() { target.start, target.end }; - IEnumerable points = originalPoints.Select(x => _pointConverter.RawConvert(x)); + IEnumerable points = originalPoints.Select(x => _pointConverter.Convert(x)); return new ACG.PolylineBuilderEx(points, ACG.AttributeFlags.HasZ).ToGeometry(); } } diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/MeshToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/MeshToHostConverter.cs index 498c51caae..8de4c957e4 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/MeshToHostConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/MeshToHostConverter.cs @@ -5,19 +5,19 @@ namespace Speckle.Converters.ArcGIS3.Geometry.ISpeckleObjectToHost; [NameAndRankValue(nameof(SOG.Mesh), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class MeshToHostConverter : ISpeckleObjectToHostConversion, IRawConversion +public class MeshToHostConverter : IToHostTopLevelConverter, ITypedConverter { - private readonly IRawConversion, ACG.Multipatch> _meshConverter; + private readonly ITypedConverter, ACG.Multipatch> _meshConverter; - public MeshToHostConverter(IRawConversion, ACG.Multipatch> meshConverter) + public MeshToHostConverter(ITypedConverter, ACG.Multipatch> meshConverter) { _meshConverter = meshConverter; } - public object Convert(Base target) => RawConvert((SOG.Mesh)target); + public object Convert(Base target) => Convert((SOG.Mesh)target); - public ACG.Multipatch RawConvert(SOG.Mesh target) + public ACG.Multipatch Convert(SOG.Mesh target) { - return _meshConverter.RawConvert(new List { target }); + return _meshConverter.Convert(new List { target }); } } diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/PointToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/PointToHostConverter.cs index 3e81f2f983..abf671574a 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/PointToHostConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/PointToHostConverter.cs @@ -5,14 +5,14 @@ namespace Speckle.Converters.ArcGIS3.Geometry.ISpeckleObjectToHost; [NameAndRankValue(nameof(SOG.Point), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class PointToHostConverter : ISpeckleObjectToHostConversion +public class PointToHostConverter : IToHostTopLevelConverter { - private readonly IRawConversion, ACG.Multipoint> _pointConverter; + private readonly ITypedConverter, ACG.Multipoint> _pointConverter; - public PointToHostConverter(IRawConversion, ACG.Multipoint> pointConverter) + public PointToHostConverter(ITypedConverter, ACG.Multipoint> pointConverter) { _pointConverter = pointConverter; } - public object Convert(Base target) => _pointConverter.RawConvert(new List { (SOG.Point)target }); + public object Convert(Base target) => _pointConverter.Convert(new List { (SOG.Point)target }); } diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/PolycurveToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/PolycurveToHostConverter.cs index fac6239f52..35adddb385 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/PolycurveToHostConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/PolycurveToHostConverter.cs @@ -5,23 +5,23 @@ namespace Speckle.Converters.ArcGIS3.Geometry.ISpeckleObjectToHost; [NameAndRankValue(nameof(SOG.Polycurve), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class PolycurveToHostConverter : ISpeckleObjectToHostConversion, IRawConversion +public class PolycurveToHostConverter : IToHostTopLevelConverter, ITypedConverter { - private readonly IRawConversion _pointConverter; - private readonly ISpeckleConverterToHost _toHostConverter; + private readonly ITypedConverter _pointConverter; + private readonly IRootToHostConverter _converter; public PolycurveToHostConverter( - IRawConversion pointConverter, - ISpeckleConverterToHost toHostConverter + ITypedConverter pointConverter, + IRootToHostConverter converter ) { _pointConverter = pointConverter; - _toHostConverter = toHostConverter; + _converter = converter; } - public object Convert(Base target) => RawConvert((SOG.Polycurve)target); + public object Convert(Base target) => Convert((SOG.Polycurve)target); - public ACG.Polyline RawConvert(SOG.Polycurve target) + public ACG.Polyline Convert(SOG.Polycurve target) { List points = new(); foreach (var segment in target.segments) @@ -30,7 +30,7 @@ public ACG.Polyline RawConvert(SOG.Polycurve target) { throw new NotImplementedException("Polycurves with arc segments are not supported"); } - ACG.Polyline converted = (ACG.Polyline)_toHostConverter.Convert((Base)segment); + ACG.Polyline converted = (ACG.Polyline)_converter.Convert((Base)segment); List newPts = converted.Points.ToList(); // reverse new segment if needed diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/PolylineToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/PolylineToHostConverter.cs index 8cf283f144..6615607b98 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/PolylineToHostConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/PolylineToHostConverter.cs @@ -5,21 +5,21 @@ namespace Speckle.Converters.ArcGIS3.Geometry.ISpeckleObjectToHost; [NameAndRankValue(nameof(SOG.Polyline), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class PolylineToHostConverter : ISpeckleObjectToHostConversion, IRawConversion +public class PolylineToHostConverter : IToHostTopLevelConverter, ITypedConverter { - private readonly IRawConversion _pointConverter; + private readonly ITypedConverter _pointConverter; - public PolylineToHostConverter(IRawConversion pointConverter) + public PolylineToHostConverter(ITypedConverter pointConverter) { _pointConverter = pointConverter; } - public object Convert(Base target) => RawConvert((SOG.Polyline)target); + public object Convert(Base target) => Convert((SOG.Polyline)target); - public ACG.Polyline RawConvert(SOG.Polyline target) + public ACG.Polyline Convert(SOG.Polyline target) { List originalPts = target.GetPoints(); - var points = originalPts.Select(x => _pointConverter.RawConvert(x)).ToList(); + var points = originalPts.Select(x => _pointConverter.Convert(x)).ToList(); if (target.closed && originalPts[0] != originalPts[^1]) { points.Add(points[0]); diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/PointSingleToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/PointSingleToHostConverter.cs index b51e099727..d444c193ad 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/PointSingleToHostConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/PointSingleToHostConverter.cs @@ -6,7 +6,7 @@ namespace Speckle.Converters.ArcGIS3.Geometry; -public class PointToHostConverter : IRawConversion +public class PointToHostConverter : ITypedConverter { private readonly IConversionContextStack _contextStack; @@ -15,9 +15,9 @@ public PointToHostConverter(IConversionContextStack contextStack) _contextStack = contextStack; } - public object Convert(Base target) => RawConvert((SOG.Point)target); + public object Convert(Base target) => Convert((SOG.Point)target); - public ACG.MapPoint RawConvert(SOG.Point target) + public ACG.MapPoint Convert(SOG.Point target) { double scaleFactor = Units.GetConversionFactor(target.units, _contextStack.Current.SpeckleUnits); return new ACG.MapPointBuilderEx( diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/PointToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/PointToSpeckleConverter.cs index 6d0607b7e6..96a2efe233 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/PointToSpeckleConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/PointToSpeckleConverter.cs @@ -5,7 +5,7 @@ namespace Speckle.Converters.ArcGIS3.Geometry; -public class PointToSpeckleConverter : IRawConversion +public class PointToSpeckleConverter : ITypedConverter { private readonly IConversionContextStack _contextStack; @@ -14,7 +14,7 @@ public PointToSpeckleConverter(IConversionContextStack contextStack) _contextStack = contextStack; } - public SOG.Point RawConvert(MapPoint target) + public SOG.Point Convert(MapPoint target) { try { diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/SegmentCollectionToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/SegmentCollectionToSpeckleConverter.cs index 1aabe1e188..0c9572c24e 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/SegmentCollectionToSpeckleConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/SegmentCollectionToSpeckleConverter.cs @@ -4,18 +4,18 @@ namespace Speckle.Converters.ArcGIS3.Geometry; -public class SegmentCollectionToSpeckleConverter : IRawConversion +public class SegmentCollectionToSpeckleConverter : ITypedConverter { private readonly IConversionContextStack _contextStack; - private readonly IRawConversion _pointConverter; - private readonly IRawConversion _arcConverter; - private readonly IRawConversion _bezierConverter; + private readonly ITypedConverter _pointConverter; + private readonly ITypedConverter _arcConverter; + private readonly ITypedConverter _bezierConverter; public SegmentCollectionToSpeckleConverter( IConversionContextStack contextStack, - IRawConversion pointConverter, - IRawConversion arcConverter, - IRawConversion bezierConverter + ITypedConverter pointConverter, + ITypedConverter arcConverter, + ITypedConverter bezierConverter ) { _contextStack = contextStack; @@ -24,7 +24,7 @@ public SegmentCollectionToSpeckleConverter( _bezierConverter = bezierConverter; } - public SOG.Polyline RawConvert(ACG.ReadOnlySegmentCollection target) + public SOG.Polyline Convert(ACG.ReadOnlySegmentCollection target) { // https://pro.arcgis.com/en/pro-app/latest/sdk/api-reference/topic8480.html double len = 0; @@ -38,20 +38,20 @@ public SOG.Polyline RawConvert(ACG.ReadOnlySegmentCollection target) switch (segment.SegmentType) { case ACG.SegmentType.Line: - points.Add(_pointConverter.RawConvert(segment.StartPoint)); - points.Add(_pointConverter.RawConvert(segment.EndPoint)); + points.Add(_pointConverter.Convert(segment.StartPoint)); + points.Add(_pointConverter.Convert(segment.EndPoint)); break; case ACG.SegmentType.Bezier: var segmentBezier = (ACG.CubicBezierSegment)segment; - points.AddRange(_bezierConverter.RawConvert(segmentBezier).GetPoints()); + points.AddRange(_bezierConverter.Convert(segmentBezier).GetPoints()); break; case ACG.SegmentType.EllipticArc: var segmentElliptic = (ACG.EllipticArcSegment)segment; - points.AddRange(_arcConverter.RawConvert(segmentElliptic).GetPoints()); + points.AddRange(_arcConverter.Convert(segmentElliptic).GetPoints()); break; } } - // var box = _boxConverter.RawConvert(target.Extent); + // var box = _boxConverter.Convert(target.Extent); SOG.Polyline polyline = new(points.SelectMany(pt => new[] { pt.x, pt.y, pt.z }).ToList(), _contextStack.Current.SpeckleUnits) { }; diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/FeatureClassToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/FeatureClassToHostConverter.cs index 614cab1729..e05be2a71e 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/FeatureClassToHostConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/FeatureClassToHostConverter.cs @@ -10,15 +10,15 @@ namespace Speckle.Converters.ArcGIS3.Layers; -public class FeatureClassToHostConverter : IRawConversion +public class FeatureClassToHostConverter : ITypedConverter { - private readonly IRawConversion, ACG.Geometry> _gisGeometryConverter; + private readonly ITypedConverter, ACG.Geometry> _gisGeometryConverter; private readonly IFeatureClassUtils _featureClassUtils; private readonly IArcGISFieldUtils _fieldsUtils; private readonly IArcGISProjectUtils _arcGISProjectUtils; public FeatureClassToHostConverter( - IRawConversion, ACG.Geometry> gisGeometryConverter, + ITypedConverter, ACG.Geometry> gisGeometryConverter, IFeatureClassUtils featureClassUtils, IArcGISFieldUtils fieldsUtils, IArcGISProjectUtils arcGISProjectUtils @@ -72,7 +72,7 @@ private List RecoverOutdatedGisFeatures(VectorLayer target) return gisFeatures; } - public FeatureClass RawConvert(VectorLayer target) + public FeatureClass Convert(VectorLayer target) { GeometryType geomType = _featureClassUtils.GetLayerGeometryType(target); diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/PointcloudLayerToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/PointcloudLayerToHostConverter.cs index 28a8bdaa6f..2011596618 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/PointcloudLayerToHostConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/PointcloudLayerToHostConverter.cs @@ -5,11 +5,11 @@ namespace Speckle.Converters.ArcGIS3.Layers; -public class PointcloudLayerToHostConverter : IRawConversion +public class PointcloudLayerToHostConverter : ITypedConverter { - public object Convert(Base target) => RawConvert((VectorLayer)target); + public object Convert(Base target) => Convert((VectorLayer)target); - public LasDatasetLayer RawConvert(VectorLayer target) + public LasDatasetLayer Convert(VectorLayer target) { // POC: throw new NotImplementedException($"Receiving Pointclouds is not supported"); diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/PointcloudLayerToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/PointcloudLayerToSpeckleConverter.cs index d7603ab493..f4d3281629 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/PointcloudLayerToSpeckleConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/PointcloudLayerToSpeckleConverter.cs @@ -10,16 +10,16 @@ namespace Speckle.Converters.ArcGIS3.Layers; [NameAndRankValue(nameof(LasDatasetLayer), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] public class PointCloudToSpeckleConverter - : IHostObjectToSpeckleConversion, - IRawConversion + : IToSpeckleTopLevelConverter, + ITypedConverter { - private readonly IRawConversion _pointConverter; - private readonly IRawConversion _boxConverter; + private readonly ITypedConverter _pointConverter; + private readonly ITypedConverter _boxConverter; private readonly IConversionContextStack _contextStack; public PointCloudToSpeckleConverter( - IRawConversion pointConverter, - IRawConversion boxConverter, + ITypedConverter pointConverter, + ITypedConverter boxConverter, IConversionContextStack contextStack ) { @@ -68,10 +68,10 @@ private int GetPointColor(LasPoint pt, object renderer) public Base Convert(object target) { - return RawConvert((LasDatasetLayer)target); + return Convert((LasDatasetLayer)target); } - public SGIS.VectorLayer RawConvert(LasDatasetLayer target) + public SGIS.VectorLayer Convert(LasDatasetLayer target) { SGIS.VectorLayer speckleLayer = new(); @@ -102,7 +102,7 @@ public SGIS.VectorLayer RawConvert(LasDatasetLayer target) { using (LasPoint pt = ptCursor.Current) { - specklePts.Add(_pointConverter.RawConvert(pt.ToMapPoint())); + specklePts.Add(_pointConverter.Convert(pt.ToMapPoint())); values.Add(pt.ClassCode); int color = GetPointColor(pt, renderer); speckleColors.Add(color); @@ -116,7 +116,7 @@ public SGIS.VectorLayer RawConvert(LasDatasetLayer target) points = specklePts.SelectMany(pt => new List() { pt.x, pt.y, pt.z }).ToList(), colors = speckleColors, sizes = values, - bbox = _boxConverter.RawConvert(target.QueryExtent()), + bbox = _boxConverter.Convert(target.QueryExtent()), units = _contextStack.Current.SpeckleUnits }; diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/RasterLayerToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/RasterLayerToHostConverter.cs index 9e57a0515f..f97cbc5dd8 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/RasterLayerToHostConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/RasterLayerToHostConverter.cs @@ -6,11 +6,11 @@ namespace Speckle.Converters.ArcGIS3.Layers; [NameAndRankValue(nameof(RasterLayer), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class RasterLayerToHostConverter : ISpeckleObjectToHostConversion, IRawConversion +public class RasterLayerToHostConverter : IToHostTopLevelConverter, ITypedConverter { - public object Convert(Base target) => RawConvert((RasterLayer)target); + public object Convert(Base target) => Convert((RasterLayer)target); - public string RawConvert(RasterLayer target) + public string Convert(RasterLayer target) { // POC: throw new NotImplementedException($"Receiving Rasters is not supported"); diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/RasterLayerToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/RasterLayerToSpeckleConverter.cs index 76302858a1..f5f96584ad 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/RasterLayerToSpeckleConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/RasterLayerToSpeckleConverter.cs @@ -10,15 +10,13 @@ namespace Speckle.Converters.ArcGIS3.Layers; [NameAndRankValue(nameof(RasterLayer), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class RasterLayerToSpeckleConverter - : IHostObjectToSpeckleConversion, - IRawConversion +public class RasterLayerToSpeckleConverter : IToSpeckleTopLevelConverter, ITypedConverter { - private readonly IRawConversion _gisRasterConverter; + private readonly ITypedConverter _gisRasterConverter; private readonly IConversionContextStack _contextStack; public RasterLayerToSpeckleConverter( - IRawConversion gisRasterConverter, + ITypedConverter gisRasterConverter, IConversionContextStack contextStack ) { @@ -28,10 +26,10 @@ IConversionContextStack contextStack public Base Convert(object target) { - return RawConvert((RasterLayer)target); + return Convert((RasterLayer)target); } - public SGIS.RasterLayer RawConvert(RasterLayer target) + public SGIS.RasterLayer Convert(RasterLayer target) { var speckleLayer = new SGIS.RasterLayer(); @@ -63,7 +61,7 @@ public SGIS.RasterLayer RawConvert(RasterLayer target) speckleLayer.units = _contextStack.Current.SpeckleUnits; // write details about the Raster - RasterElement element = _gisRasterConverter.RawConvert(target.GetRaster()); + RasterElement element = _gisRasterConverter.Convert(target.GetRaster()); speckleLayer.elements.Add(element); return speckleLayer; diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/TableToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/TableToHostConverter.cs index 2b11816d2f..b330f26dc5 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/TableToHostConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/TableToHostConverter.cs @@ -8,7 +8,7 @@ namespace Speckle.Converters.ArcGIS3.Layers; -public class TableLayerToHostConverter : IRawConversion +public class TableLayerToHostConverter : ITypedConverter { private readonly IFeatureClassUtils _featureClassUtils; private readonly IArcGISFieldUtils _fieldsUtils; @@ -25,7 +25,7 @@ IArcGISFieldUtils fieldsUtils _fieldsUtils = fieldsUtils; } - public Table RawConvert(VectorLayer target) + public Table Convert(VectorLayer target) { string databasePath = _arcGISProjectUtils.GetDatabasePath(); FileGeodatabaseConnectionPath fileGeodatabaseConnectionPath = new(new Uri(databasePath)); diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/TableToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/TableToSpeckleConverter.cs index 8f88a2df31..31ee4bf6fc 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/TableToSpeckleConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/TableToSpeckleConverter.cs @@ -10,14 +10,14 @@ namespace Speckle.Converters.ArcGIS3.Layers; [NameAndRankValue(nameof(StandaloneTable), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] public class StandaloneTableToSpeckleConverter - : IHostObjectToSpeckleConversion, - IRawConversion + : IToSpeckleTopLevelConverter, + ITypedConverter { - private readonly IRawConversion _gisFeatureConverter; + private readonly ITypedConverter _gisFeatureConverter; private readonly IConversionContextStack _contextStack; public StandaloneTableToSpeckleConverter( - IRawConversion gisFeatureConverter, + ITypedConverter gisFeatureConverter, IConversionContextStack contextStack ) { @@ -27,10 +27,10 @@ IConversionContextStack contextStack public Base Convert(object target) { - return RawConvert((StandaloneTable)target); + return Convert((StandaloneTable)target); } - public VectorLayer RawConvert(StandaloneTable target) + public VectorLayer Convert(StandaloneTable target) { VectorLayer speckleLayer = new() { name = target.Name, }; @@ -57,7 +57,7 @@ public VectorLayer RawConvert(StandaloneTable target) // Same IDisposable issue appears to happen on Row class too. Docs say it should always be disposed of manually by the caller. using (Row row = rowCursor.Current) { - GisFeature element = _gisFeatureConverter.RawConvert(row); + GisFeature element = _gisFeatureConverter.Convert(row); // replace "attributes", to remove non-visible layer attributes Base elementAttributes = new(); diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/VectorLayerToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/VectorLayerToHostConverter.cs index 0db9ec6554..8648970fa1 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/VectorLayerToHostConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/VectorLayerToHostConverter.cs @@ -10,17 +10,17 @@ namespace Speckle.Converters.ArcGIS3.Layers; [NameAndRankValue(nameof(VectorLayer), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class VectorLayerToHostConverter : ISpeckleObjectToHostConversion, IRawConversion +public class VectorLayerToHostConverter : IToHostTopLevelConverter, ITypedConverter { - private readonly IRawConversion _featureClassConverter; - private readonly IRawConversion _tableConverter; - private readonly IRawConversion _pointcloudLayerConverter; + private readonly ITypedConverter _featureClassConverter; + private readonly ITypedConverter _tableConverter; + private readonly ITypedConverter _pointcloudLayerConverter; private readonly IFeatureClassUtils _featureClassUtils; public VectorLayerToHostConverter( - IRawConversion featureClassConverter, - IRawConversion tableConverter, - IRawConversion pointcloudLayerConverter, + ITypedConverter featureClassConverter, + ITypedConverter tableConverter, + ITypedConverter pointcloudLayerConverter, IFeatureClassUtils featureClassUtils ) { @@ -30,27 +30,27 @@ IFeatureClassUtils featureClassUtils _featureClassUtils = featureClassUtils; } - public object Convert(Base target) => RawConvert((VectorLayer)target); + public object Convert(Base target) => Convert((VectorLayer)target); - public string RawConvert(VectorLayer target) + public string Convert(VectorLayer target) { // pointcloud layers need to be checked separately, because there is no ArcGIS Geometry type // for Pointcloud. In ArcGIS it's a completely different layer class, so "GetLayerGeometryType" // will return "Invalid" type if (target.geomType == "Pointcloud") { - return _pointcloudLayerConverter.RawConvert(target).Name; + return _pointcloudLayerConverter.Convert(target).Name; } // check if Speckle VectorLayer should become a FeatureClass, StandaloneTable or PointcloudLayer GeometryType geomType = _featureClassUtils.GetLayerGeometryType(target); if (geomType != GeometryType.Unknown) // feature class { - return _featureClassConverter.RawConvert(target).GetName(); + return _featureClassConverter.Convert(target).GetName(); } else // table { - return _tableConverter.RawConvert(target).GetName(); + return _tableConverter.Convert(target).GetName(); } } } diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/VectorLayerToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/VectorLayerToSpeckleConverter.cs index 017178551d..02a0917b0f 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/VectorLayerToSpeckleConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/VectorLayerToSpeckleConverter.cs @@ -10,15 +10,15 @@ namespace Speckle.Converters.ArcGIS3.Layers; [NameAndRankValue(nameof(FeatureLayer), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class VectorLayerToSpeckleConverter : IHostObjectToSpeckleConversion, IRawConversion +public class VectorLayerToSpeckleConverter : IToSpeckleTopLevelConverter, ITypedConverter { - private readonly IRawConversion _gisFeatureConverter; + private readonly ITypedConverter _gisFeatureConverter; private readonly IFeatureClassUtils _featureClassUtils; private readonly IArcGISFieldUtils _fieldsUtils; private readonly IConversionContextStack _contextStack; public VectorLayerToSpeckleConverter( - IRawConversion gisFeatureConverter, + ITypedConverter gisFeatureConverter, IFeatureClassUtils featureClassUtils, IArcGISFieldUtils fieldsUtils, IConversionContextStack contextStack @@ -32,7 +32,7 @@ IConversionContextStack contextStack public Base Convert(object target) { - return RawConvert((FeatureLayer)target); + return Convert((FeatureLayer)target); } private string SpeckleGeometryType(string nativeGeometryType) @@ -57,7 +57,7 @@ private string SpeckleGeometryType(string nativeGeometryType) return spekleGeometryType; } - public VectorLayer RawConvert(FeatureLayer target) + public VectorLayer Convert(FeatureLayer target) { VectorLayer speckleLayer = new(); @@ -115,7 +115,7 @@ public VectorLayer RawConvert(FeatureLayer target) // Same IDisposable issue appears to happen on Row class too. Docs say it should always be disposed of manually by the caller. using (Row row = rowCursor.Current) { - GisFeature element = _gisFeatureConverter.RawConvert(row); + GisFeature element = _gisFeatureConverter.Convert(row); // replace element "attributes", to remove those non-visible on Layer level Base elementAttributes = new(); diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/FeatureClassUtils.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/FeatureClassUtils.cs index 89d079d69f..49f46aba53 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/FeatureClassUtils.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/FeatureClassUtils.cs @@ -31,7 +31,7 @@ public void AddFeaturesToFeatureClass( FeatureClass newFeatureClass, List gisFeatures, List fields, - IRawConversion, ACG.Geometry> gisGeometryConverter + ITypedConverter, ACG.Geometry> gisGeometryConverter ) { foreach (GisFeature feat in gisFeatures) @@ -41,7 +41,7 @@ public void AddFeaturesToFeatureClass( if (feat.geometry != null) { List geometryToConvert = feat.geometry; - ACG.Geometry nativeShape = gisGeometryConverter.RawConvert(geometryToConvert); + ACG.Geometry nativeShape = gisGeometryConverter.Convert(geometryToConvert); rowBuffer[newFeatureClass.GetDefinition().GetShapeField()] = nativeShape; } else diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/IFeatureClassUtils.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/IFeatureClassUtils.cs index 76e753ef02..2946ac3931 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/IFeatureClassUtils.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/IFeatureClassUtils.cs @@ -12,7 +12,7 @@ void AddFeaturesToFeatureClass( FeatureClass newFeatureClass, List gisFeatures, List fields, - IRawConversion, ACG.Geometry> gisGeometryConverter + ITypedConverter, ACG.Geometry> gisGeometryConverter ); void AddNonGISFeaturesToFeatureClass( FeatureClass newFeatureClass, diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/NonNativeFeaturesUtils.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/NonNativeFeaturesUtils.cs index a04d8936a9..1682b8774c 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/NonNativeFeaturesUtils.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/NonNativeFeaturesUtils.cs @@ -13,14 +13,14 @@ namespace Speckle.Converters.ArcGIS3.Utils; public class NonNativeFeaturesUtils : INonNativeFeaturesUtils { - private readonly IRawConversion, ACG.Geometry> _gisGeometryConverter; + private readonly ITypedConverter, ACG.Geometry> _gisGeometryConverter; private readonly IArcGISFieldUtils _fieldsUtils; private readonly IFeatureClassUtils _featureClassUtils; private readonly IArcGISProjectUtils _arcGISProjectUtils; private readonly IConversionContextStack _contextStack; public NonNativeFeaturesUtils( - IRawConversion, ACG.Geometry> gisGeometryConverter, + ITypedConverter, ACG.Geometry> gisGeometryConverter, IArcGISFieldUtils fieldsUtils, IFeatureClassUtils featureClassUtils, IArcGISProjectUtils arcGISProjectUtils, diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2023.DependencyInjection/AutocadConverterModule.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2023.DependencyInjection/AutocadConverterModule.cs index 5b2f42298d..375d2c8170 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2023.DependencyInjection/AutocadConverterModule.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2023.DependencyInjection/AutocadConverterModule.cs @@ -11,10 +11,7 @@ public class AutocadConverterModule : ISpeckleModule { public void Load(SpeckleContainerBuilder builder) { - builder.AddConverterCommon(); - // POC: below comment maybe incorrect (sorry if I wrote that!) stateless services - // can be injected as Singleton(), only where we have state we wish to wrap in a unit of work - builder.AddScoped(); + builder.AddConverterCommon(); // single stack per conversion builder.AddScoped, AutocadConversionContextStack>(); diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/AutocadConverterToSpeckle.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/AutocadRootToHostConverter.cs similarity index 85% rename from DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/AutocadConverterToSpeckle.cs rename to DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/AutocadRootToHostConverter.cs index 85112323be..4a53d211c2 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/AutocadConverterToSpeckle.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/AutocadRootToHostConverter.cs @@ -6,13 +6,13 @@ namespace Speckle.Converters.Autocad; -public class AutocadConverterToSpeckle : ISpeckleConverterToSpeckle +public class AutocadRootToHostConverter : IRootToSpeckleConverter { - private readonly IFactory _toSpeckle; + private readonly IFactory _toSpeckle; private readonly IConversionContextStack _contextStack; - public AutocadConverterToSpeckle( - IFactory toSpeckle, + public AutocadRootToHostConverter( + IFactory toSpeckle, IConversionContextStack contextStack ) { diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/AutocadToSpeckleUnitConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/AutocadToSpeckleUnitConverter.cs index 3180b4ef94..b5b611e2d9 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/AutocadToSpeckleUnitConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/AutocadToSpeckleUnitConverter.cs @@ -7,25 +7,27 @@ namespace Speckle.Converters.Autocad; public class AutocadToSpeckleUnitConverter : IHostToSpeckleUnitConverter { - private readonly Dictionary _unitMapping = new(); + private static readonly IReadOnlyDictionary s_unitsMapping = Create(); - public AutocadToSpeckleUnitConverter() + private static IReadOnlyDictionary Create() { + var dict = new Dictionary(); // POC: we should have a unit test to confirm these are as expected and don't change - _unitMapping[UnitsValue.Undefined] = Units.Meters; - _unitMapping[UnitsValue.Millimeters] = Units.Millimeters; - _unitMapping[UnitsValue.Centimeters] = Units.Centimeters; - _unitMapping[UnitsValue.Meters] = Units.Meters; - _unitMapping[UnitsValue.Kilometers] = Units.Kilometers; - _unitMapping[UnitsValue.Inches] = Units.Inches; - _unitMapping[UnitsValue.Feet] = Units.Feet; - _unitMapping[UnitsValue.Yards] = Units.Yards; - _unitMapping[UnitsValue.Miles] = Units.Miles; + dict[UnitsValue.Undefined] = Units.Meters; + dict[UnitsValue.Millimeters] = Units.Millimeters; + dict[UnitsValue.Centimeters] = Units.Centimeters; + dict[UnitsValue.Meters] = Units.Meters; + dict[UnitsValue.Kilometers] = Units.Kilometers; + dict[UnitsValue.Inches] = Units.Inches; + dict[UnitsValue.Feet] = Units.Feet; + dict[UnitsValue.Yards] = Units.Yards; + dict[UnitsValue.Miles] = Units.Miles; + return dict; } public string ConvertOrThrow(UnitsValue hostUnit) { - if (_unitMapping.TryGetValue(hostUnit, out string value)) + if (s_unitsMapping.TryGetValue(hostUnit, out string value)) { return value; } diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/Speckle.Converters.AutocadShared.projitems b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/Speckle.Converters.AutocadShared.projitems index 100e5186db..3644c81cc1 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/Speckle.Converters.AutocadShared.projitems +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/Speckle.Converters.AutocadShared.projitems @@ -9,7 +9,7 @@ Speckle.Converters.AutocadShared - + diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/ArcToHostConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/ArcToHostConverter.cs index d5653a7eb1..0d639ab956 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/ArcToHostConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/ArcToHostConverter.cs @@ -5,15 +5,15 @@ namespace Speckle.Converters.Autocad.ToHost.Geometry; [NameAndRankValue(nameof(SOG.Arc), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class ArcToHostConverter : ISpeckleObjectToHostConversion, IRawConversion +public class ArcToHostConverter : IToHostTopLevelConverter, ITypedConverter { - private readonly IRawConversion _arcConverter; - private readonly IRawConversion _planeConverter; + private readonly ITypedConverter _arcConverter; + private readonly ITypedConverter _planeConverter; private readonly IConversionContextStack _contextStack; public ArcToHostConverter( - IRawConversion arcConverter, - IRawConversion planeConverter, + ITypedConverter arcConverter, + ITypedConverter planeConverter, IConversionContextStack contextStack ) { @@ -22,16 +22,16 @@ public ArcToHostConverter( _contextStack = contextStack; } - public object Convert(Base target) => RawConvert((SOG.Arc)target); + public object Convert(Base target) => Convert((SOG.Arc)target); - public ADB.Arc RawConvert(SOG.Arc target) + public ADB.Arc Convert(SOG.Arc target) { // the most reliable method to convert to autocad convention is to calculate from start, end, and midpoint // because of different plane & start/end angle conventions - AG.CircularArc3d circularArc = _arcConverter.RawConvert(target); + AG.CircularArc3d circularArc = _arcConverter.Convert(target); // calculate adjusted start and end angles from circularArc reference - AG.Plane plane = _planeConverter.RawConvert(target.plane); + AG.Plane plane = _planeConverter.Convert(target.plane); double angle = circularArc.ReferenceVector.AngleOnPlane(plane); double startAngle = circularArc.StartAngle + angle; double endAngle = circularArc.EndAngle + angle; diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/AutocadPolycurveToHostConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/AutocadPolycurveToHostConverter.cs index fa7b5e3c58..2458753639 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/AutocadPolycurveToHostConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/AutocadPolycurveToHostConverter.cs @@ -5,16 +5,16 @@ namespace Speckle.Converters.Autocad2023.ToHost.Geometry; [NameAndRankValue(nameof(SOG.Autocad.AutocadPolycurve), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class AutocadPolycurveToHostConverter : ISpeckleObjectToHostConversion +public class AutocadPolycurveToHostConverter : IToHostTopLevelConverter { - private readonly IRawConversion _polylineConverter; - private readonly IRawConversion _polyline2dConverter; - private readonly IRawConversion _polyline3dConverter; + private readonly ITypedConverter _polylineConverter; + private readonly ITypedConverter _polyline2dConverter; + private readonly ITypedConverter _polyline3dConverter; public AutocadPolycurveToHostConverter( - IRawConversion polylineConverter, - IRawConversion polyline2dConverter, - IRawConversion polyline3dConverter + ITypedConverter polylineConverter, + ITypedConverter polyline2dConverter, + ITypedConverter polyline3dConverter ) { _polylineConverter = polylineConverter; @@ -29,18 +29,18 @@ public object Convert(Base target) switch (polycurve.polyType) { case SOG.Autocad.AutocadPolyType.Light: - return _polylineConverter.RawConvert(polycurve); + return _polylineConverter.Convert(polycurve); case SOG.Autocad.AutocadPolyType.Simple2d: case SOG.Autocad.AutocadPolyType.FitCurve2d: case SOG.Autocad.AutocadPolyType.CubicSpline2d: case SOG.Autocad.AutocadPolyType.QuadSpline2d: - return _polyline2dConverter.RawConvert(polycurve); + return _polyline2dConverter.Convert(polycurve); case SOG.Autocad.AutocadPolyType.Simple3d: case SOG.Autocad.AutocadPolyType.CubicSpline3d: case SOG.Autocad.AutocadPolyType.QuadSpline3d: - return _polyline3dConverter.RawConvert(polycurve); + return _polyline3dConverter.Convert(polycurve); default: throw new SpeckleConversionException("Unknown poly type for AutocadPolycurve"); diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/CircleToHostConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/CircleToHostConverter.cs index a83a6b1845..6ec53e825f 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/CircleToHostConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/CircleToHostConverter.cs @@ -6,15 +6,15 @@ namespace Speckle.Converters.Autocad.ToHost.Geometry; [NameAndRankValue(nameof(SOG.Circle), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class CircleToHostConverter : ISpeckleObjectToHostConversion, IRawConversion +public class CircleToHostConverter : IToHostTopLevelConverter, ITypedConverter { - private readonly IRawConversion _pointConverter; - private readonly IRawConversion _vectorConverter; + private readonly ITypedConverter _pointConverter; + private readonly ITypedConverter _vectorConverter; private readonly IConversionContextStack _contextStack; public CircleToHostConverter( - IRawConversion pointConverter, - IRawConversion vectorConverter, + ITypedConverter pointConverter, + ITypedConverter vectorConverter, IConversionContextStack contextStack ) { @@ -23,12 +23,12 @@ public CircleToHostConverter( _contextStack = contextStack; } - public object Convert(Base target) => RawConvert((SOG.Circle)target); + public object Convert(Base target) => Convert((SOG.Circle)target); - public ADB.Circle RawConvert(SOG.Circle target) + public ADB.Circle Convert(SOG.Circle target) { - AG.Vector3d normal = _vectorConverter.RawConvert(target.plane.normal); - AG.Point3d origin = _pointConverter.RawConvert(target.plane.origin); + AG.Vector3d normal = _vectorConverter.Convert(target.plane.normal); + AG.Point3d origin = _pointConverter.Convert(target.plane.origin); double f = Units.GetConversionFactor(target.units, _contextStack.Current.SpeckleUnits); if (target.radius is null) diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/CurveToHostConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/CurveToHostConverter.cs index cc25a40304..2f49ebad17 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/CurveToHostConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/CurveToHostConverter.cs @@ -5,16 +5,16 @@ namespace Speckle.Converters.AutocadShared.ToHost.Geometry; [NameAndRankValue(nameof(SOG.Curve), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class CurveToHostConverter : ISpeckleObjectToHostConversion, IRawConversion +public class CurveToHostConverter : IToHostTopLevelConverter, ITypedConverter { - private readonly IRawConversion _curveConverter; + private readonly ITypedConverter _curveConverter; - public CurveToHostConverter(IRawConversion curveConverter) + public CurveToHostConverter(ITypedConverter curveConverter) { _curveConverter = curveConverter; } - public object Convert(Base target) => RawConvert((SOG.Curve)target); + public object Convert(Base target) => Convert((SOG.Curve)target); - public ADB.Curve RawConvert(SOG.Curve target) => ADB.Curve.CreateFromGeCurve(_curveConverter.RawConvert(target)); + public ADB.Curve Convert(SOG.Curve target) => ADB.Curve.CreateFromGeCurve(_curveConverter.Convert(target)); } diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/EllipseToHostConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/EllipseToHostConverter.cs index 708ea51f69..58a59a6803 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/EllipseToHostConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/EllipseToHostConverter.cs @@ -6,15 +6,15 @@ namespace Speckle.Converters.Autocad.ToHost.Geometry; [NameAndRankValue(nameof(SOG.Ellipse), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class EllipseToHostConverter : ISpeckleObjectToHostConversion, IRawConversion +public class EllipseToHostConverter : IToHostTopLevelConverter, ITypedConverter { - private readonly IRawConversion _pointConverter; - private readonly IRawConversion _vectorConverter; + private readonly ITypedConverter _pointConverter; + private readonly ITypedConverter _vectorConverter; private readonly IConversionContextStack _contextStack; public EllipseToHostConverter( - IRawConversion pointConverter, - IRawConversion vectorConverter, + ITypedConverter pointConverter, + ITypedConverter vectorConverter, IConversionContextStack contextStack ) { @@ -23,15 +23,15 @@ public EllipseToHostConverter( _contextStack = contextStack; } - public object Convert(Base target) => RawConvert((SOG.Ellipse)target); + public object Convert(Base target) => Convert((SOG.Ellipse)target); /// Throws if any ellipse radius value is null. - public ADB.Ellipse RawConvert(SOG.Ellipse target) + public ADB.Ellipse Convert(SOG.Ellipse target) { double f = Units.GetConversionFactor(target.units, _contextStack.Current.SpeckleUnits); - AG.Point3d origin = _pointConverter.RawConvert(target.plane.origin); - AG.Vector3d normal = _vectorConverter.RawConvert(target.plane.normal); - AG.Vector3d xAxis = _vectorConverter.RawConvert(target.plane.xdir); + AG.Point3d origin = _pointConverter.Convert(target.plane.origin); + AG.Vector3d normal = _vectorConverter.Convert(target.plane.normal); + AG.Vector3d xAxis = _vectorConverter.Convert(target.plane.xdir); // POC: how possibly we might have firstRadius and secondRadius is possibly null? if (target.firstRadius is null || target.secondRadius is null) diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/LineToHostConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/LineToHostConverter.cs index b07a33c594..d1144816a8 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/LineToHostConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/LineToHostConverter.cs @@ -5,17 +5,17 @@ namespace Speckle.Converters.Autocad.ToHost.Geometry; [NameAndRankValue(nameof(SOG.Line), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class LineToHostConverter : ISpeckleObjectToHostConversion, IRawConversion +public class LineToHostConverter : IToHostTopLevelConverter, ITypedConverter { - private readonly IRawConversion _pointConverter; + private readonly ITypedConverter _pointConverter; - public LineToHostConverter(IRawConversion pointConverter) + public LineToHostConverter(ITypedConverter pointConverter) { _pointConverter = pointConverter; } - public object Convert(Base target) => RawConvert((SOG.Line)target); + public object Convert(Base target) => Convert((SOG.Line)target); - public ADB.Line RawConvert(SOG.Line target) => - new(_pointConverter.RawConvert(target.start), _pointConverter.RawConvert(target.end)); + public ADB.Line Convert(SOG.Line target) => + new(_pointConverter.Convert(target.start), _pointConverter.Convert(target.end)); } diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/MeshToHostConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/MeshToHostConverter.cs index e75aa5e91d..5a90a27d1d 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/MeshToHostConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/MeshToHostConverter.cs @@ -7,13 +7,13 @@ namespace Speckle.Converters.Autocad.Geometry; [NameAndRankValue(nameof(SOG.Mesh), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class MeshToHostConverter : ISpeckleObjectToHostConversion, IRawConversion +public class MeshToHostConverter : IToHostTopLevelConverter, ITypedConverter { - private readonly IRawConversion _pointConverter; + private readonly ITypedConverter _pointConverter; private readonly IConversionContextStack _contextStack; public MeshToHostConverter( - IRawConversion pointConverter, + ITypedConverter pointConverter, IConversionContextStack contextStack ) { @@ -21,18 +21,18 @@ public MeshToHostConverter( _contextStack = contextStack; } - public object Convert(Base target) => RawConvert((SOG.Mesh)target); + public object Convert(Base target) => Convert((SOG.Mesh)target); /// /// Mesh conversion requires transaction since it's vertices needed to be added into database in advance.. /// - public ADB.PolyFaceMesh RawConvert(SOG.Mesh target) + public ADB.PolyFaceMesh Convert(SOG.Mesh target) { target.TriangulateMesh(true); // get vertex points using AG.Point3dCollection vertices = new(); - List points = target.GetPoints().Select(o => _pointConverter.RawConvert(o)).ToList(); + List points = target.GetPoints().Select(o => _pointConverter.Convert(o)).ToList(); foreach (var point in points) { vertices.Add(point); diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/PointToHostConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/PointToHostConverter.cs index 177a5f7808..5816423983 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/PointToHostConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/PointToHostConverter.cs @@ -5,16 +5,16 @@ namespace Speckle.Converters.Autocad.ToHost.Geometry; [NameAndRankValue(nameof(SOG.Point), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class PointToHostConverter : ISpeckleObjectToHostConversion, IRawConversion +public class PointToHostConverter : IToHostTopLevelConverter, ITypedConverter { - private readonly IRawConversion _pointConverter; + private readonly ITypedConverter _pointConverter; - public PointToHostConverter(IRawConversion pointConverter) + public PointToHostConverter(ITypedConverter pointConverter) { _pointConverter = pointConverter; } - public object Convert(Base target) => RawConvert((SOG.Point)target); + public object Convert(Base target) => Convert((SOG.Point)target); - public ADB.DBPoint RawConvert(SOG.Point target) => new(_pointConverter.RawConvert(target)); + public ADB.DBPoint Convert(SOG.Point target) => new(_pointConverter.Convert(target)); } diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/PolycurveToHostConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/PolycurveToHostConverter.cs index a3c458f916..7ba28edb9e 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/PolycurveToHostConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/PolycurveToHostConverter.cs @@ -10,14 +10,14 @@ namespace Speckle.Converters.AutocadShared.ToHost.Geometry; /// Otherwise we convert it as spline (list of ADB.Entity) that switch cases according to each segment type. /// [NameAndRankValue(nameof(SOG.Polycurve), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class PolycurveToHostConverter : ISpeckleObjectToHostConversion +public class PolycurveToHostConverter : IToHostTopLevelConverter { - private readonly IRawConversion _polylineConverter; - private readonly IRawConversion> _splineConverter; + private readonly ITypedConverter _polylineConverter; + private readonly ITypedConverter> _splineConverter; public PolycurveToHostConverter( - IRawConversion polylineConverter, - IRawConversion> splineConverter + ITypedConverter polylineConverter, + ITypedConverter> splineConverter ) { _polylineConverter = polylineConverter; @@ -32,11 +32,11 @@ public object Convert(Base target) if (convertAsSpline || !isPlanar) { - return _splineConverter.RawConvert(polycurve); + return _splineConverter.Convert(polycurve); } else { - return _polylineConverter.RawConvert(polycurve); + return _polylineConverter.Convert(polycurve); } } diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/PolylineToHostConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/PolylineToHostConverter.cs index bf5fa03bf8..7bbf367950 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/PolylineToHostConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/PolylineToHostConverter.cs @@ -5,21 +5,21 @@ namespace Speckle.Converters.Autocad.ToHost.Geometry; [NameAndRankValue(nameof(SOG.Polyline), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class PolylineToHostConverter : ISpeckleObjectToHostConversion, IRawConversion +public class PolylineToHostConverter : IToHostTopLevelConverter, ITypedConverter { - private readonly IRawConversion _pointConverter; + private readonly ITypedConverter _pointConverter; - public PolylineToHostConverter(IRawConversion pointConverter) + public PolylineToHostConverter(ITypedConverter pointConverter) { _pointConverter = pointConverter; } - public object Convert(Base target) => RawConvert((SOG.Polyline)target); + public object Convert(Base target) => Convert((SOG.Polyline)target); - public ADB.Polyline3d RawConvert(SOG.Polyline target) + public ADB.Polyline3d Convert(SOG.Polyline target) { AG.Point3dCollection vertices = new(); - target.GetPoints().ForEach(o => vertices.Add(_pointConverter.RawConvert(o))); + target.GetPoints().ForEach(o => vertices.Add(_pointConverter.Convert(o))); return new(ADB.Poly3dType.SimplePoly, vertices, target.closed); } } diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/SpeckleFallbackToHostConversion.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/SpeckleFallbackToHostConversion.cs index 8271b5751b..113ae43963 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/SpeckleFallbackToHostConversion.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/SpeckleFallbackToHostConversion.cs @@ -5,18 +5,18 @@ namespace Speckle.Converters.Rhino7.ToHost.TopLevel; [NameAndRankValue(nameof(DisplayableObject), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class SpeckleFallbackToAutocadConversion - : ISpeckleObjectToHostConversion, - IRawConversion> +public class SpeckleFallbackToAutocadTopLevelConverter + : IToHostTopLevelConverter, + ITypedConverter> { - private readonly IRawConversion _lineConverter; - private readonly IRawConversion _polylineConverter; - private readonly IRawConversion _meshConverter; + private readonly ITypedConverter _lineConverter; + private readonly ITypedConverter _polylineConverter; + private readonly ITypedConverter _meshConverter; - public SpeckleFallbackToAutocadConversion( - IRawConversion lineConverter, - IRawConversion polylineConverter, - IRawConversion meshConverter + public SpeckleFallbackToAutocadTopLevelConverter( + ITypedConverter lineConverter, + ITypedConverter polylineConverter, + ITypedConverter meshConverter ) { _lineConverter = lineConverter; @@ -24,18 +24,18 @@ public SpeckleFallbackToAutocadConversion( _meshConverter = meshConverter; } - public object Convert(Base target) => RawConvert((DisplayableObject)target); + public object Convert(Base target) => Convert((DisplayableObject)target); - public List RawConvert(DisplayableObject target) + public List Convert(DisplayableObject target) { var result = new List(); foreach (var item in target.displayValue) { ADB.Entity x = item switch { - SOG.Line line => _lineConverter.RawConvert(line), - SOG.Polyline polyline => _polylineConverter.RawConvert(polyline), - SOG.Mesh mesh => _meshConverter.RawConvert(mesh), + SOG.Line line => _lineConverter.Convert(line), + SOG.Polyline polyline => _polylineConverter.Convert(polyline), + SOG.Mesh mesh => _meshConverter.Convert(mesh), _ => throw new NotSupportedException($"Found unsupported fallback geometry: {item.GetType()}") }; result.Add(x); diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/ArcToHostRawConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/ArcToHostRawConverter.cs index c305245a7b..73158e8970 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/ArcToHostRawConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/ArcToHostRawConverter.cs @@ -5,31 +5,31 @@ namespace Speckle.Converters.Autocad.ToHost.Raw; [NameAndRankValue(nameof(SOG.Arc), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class ArcToHostRowConverter : IRawConversion +public class ArcToHostRowConverter : ITypedConverter { - private readonly IRawConversion _pointConverter; - private readonly IRawConversion _vectorConverter; + private readonly ITypedConverter _pointConverter; + private readonly ITypedConverter _vectorConverter; public ArcToHostRowConverter( - IRawConversion pointConverter, - IRawConversion vectorConverter + ITypedConverter pointConverter, + ITypedConverter vectorConverter ) { _pointConverter = pointConverter; _vectorConverter = vectorConverter; } - public object Convert(Base target) => RawConvert((SOG.Arc)target); + public object Convert(Base target) => Convert((SOG.Arc)target); - public AG.CircularArc3d RawConvert(SOG.Arc target) + public AG.CircularArc3d Convert(SOG.Arc target) { - AG.Point3d start = _pointConverter.RawConvert(target.startPoint); - AG.Point3d end = _pointConverter.RawConvert(target.endPoint); - AG.Point3d mid = _pointConverter.RawConvert(target.midPoint); + AG.Point3d start = _pointConverter.Convert(target.startPoint); + AG.Point3d end = _pointConverter.Convert(target.endPoint); + AG.Point3d mid = _pointConverter.Convert(target.midPoint); AG.CircularArc3d arc = new(start, mid, end); - AG.Vector3d normal = _vectorConverter.RawConvert(target.plane.normal); - AG.Vector3d xdir = _vectorConverter.RawConvert(target.plane.xdir); + AG.Vector3d normal = _vectorConverter.Convert(target.plane.normal); + AG.Vector3d xdir = _vectorConverter.Convert(target.plane.xdir); arc.SetAxes(normal, xdir); if (target.startAngle is double startAngle && target.endAngle is double endAngle) diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/AutocadPolycurveToHostPolyline2dRawConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/AutocadPolycurveToHostPolyline2dRawConverter.cs index 62c62b14a2..8c78f79845 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/AutocadPolycurveToHostPolyline2dRawConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/AutocadPolycurveToHostPolyline2dRawConverter.cs @@ -5,13 +5,14 @@ namespace Speckle.Converters.Autocad2023.ToHost.Raw; -public class AutocadPolycurveToHostPolyline2dRawConverter : IRawConversion +public class AutocadPolycurveToHostPolyline2dRawConverter + : ITypedConverter { - private readonly IRawConversion _vectorConverter; + private readonly ITypedConverter _vectorConverter; private readonly IConversionContextStack _contextStack; public AutocadPolycurveToHostPolyline2dRawConverter( - IRawConversion vectorConverter, + ITypedConverter vectorConverter, IConversionContextStack contextStack ) { @@ -19,7 +20,7 @@ public AutocadPolycurveToHostPolyline2dRawConverter( _contextStack = contextStack; } - public ADB.Polyline2d RawConvert(SOG.Autocad.AutocadPolycurve target) + public ADB.Polyline2d Convert(SOG.Autocad.AutocadPolycurve target) { // check for normal if (target.normal is not SOG.Vector normal) @@ -50,7 +51,7 @@ public ADB.Polyline2d RawConvert(SOG.Autocad.AutocadPolycurve target) } // create the polyline2d using the empty constructor - AG.Vector3d convertedNormal = _vectorConverter.RawConvert(normal); + AG.Vector3d convertedNormal = _vectorConverter.Convert(normal); double convertedElevation = elevation * f; ADB.Polyline2d polyline = new() diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/AutocadPolycurveToHostPolyline3dRawConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/AutocadPolycurveToHostPolyline3dRawConverter.cs index b681e436c6..1444d8da6a 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/AutocadPolycurveToHostPolyline3dRawConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/AutocadPolycurveToHostPolyline3dRawConverter.cs @@ -5,7 +5,8 @@ namespace Speckle.Converters.Autocad2023.ToHost.Raw; -public class AutocadPolycurveToHostPolyline3dRawConverter : IRawConversion +public class AutocadPolycurveToHostPolyline3dRawConverter + : ITypedConverter { private readonly IConversionContextStack _contextStack; @@ -14,7 +15,7 @@ public AutocadPolycurveToHostPolyline3dRawConverter(IConversionContextStack +public class AutocadPolycurveToHostPolylineRawConverter : ITypedConverter { - private readonly IRawConversion _vectorConverter; + private readonly ITypedConverter _vectorConverter; private readonly IConversionContextStack _contextStack; public AutocadPolycurveToHostPolylineRawConverter( - IRawConversion vectorConverter, + ITypedConverter vectorConverter, IConversionContextStack contextStack ) { @@ -19,7 +19,7 @@ public AutocadPolycurveToHostPolylineRawConverter( _contextStack = contextStack; } - public ADB.Polyline RawConvert(SOG.Autocad.AutocadPolycurve target) + public ADB.Polyline Convert(SOG.Autocad.AutocadPolycurve target) { if (target.normal is null || target.elevation is null) { @@ -34,7 +34,7 @@ public ADB.Polyline RawConvert(SOG.Autocad.AutocadPolycurve target) ADB.Polyline polyline = new() { - Normal = _vectorConverter.RawConvert(target.normal), + Normal = _vectorConverter.Convert(target.normal), Elevation = (double)target.elevation * f, Closed = target.closed }; diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/CurveToHostRawConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/CurveToHostRawConverter.cs index fa7046334d..5e3e6cc805 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/CurveToHostRawConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/CurveToHostRawConverter.cs @@ -2,23 +2,23 @@ namespace Speckle.Converters.AutocadShared.ToHost.Raw; -public class CurveToHostRawConverter : IRawConversion +public class CurveToHostRawConverter : ITypedConverter { - private readonly IRawConversion _pointConverter; - private readonly IRawConversion _intervalConverter; + private readonly ITypedConverter _pointConverter; + private readonly ITypedConverter _intervalConverter; public CurveToHostRawConverter( - IRawConversion pointConverter, - IRawConversion intervalConverter + ITypedConverter pointConverter, + ITypedConverter intervalConverter ) { _pointConverter = pointConverter; _intervalConverter = intervalConverter; } - public AG.NurbCurve3d RawConvert(SOG.Curve target) + public AG.NurbCurve3d Convert(SOG.Curve target) { - var points = target.GetPoints().Select(p => _pointConverter.RawConvert(p)).ToList(); + var points = target.GetPoints().Select(p => _pointConverter.Convert(p)).ToList(); if (target.closed && target.periodic) { points = points.GetRange(0, points.Count - target.degree); @@ -67,7 +67,7 @@ public AG.NurbCurve3d RawConvert(SOG.Curve target) curve.MakeClosed(); } - curve.SetInterval(_intervalConverter.RawConvert(target.domain)); + curve.SetInterval(_intervalConverter.Convert(target.domain)); return curve; } diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/IntervalToHostRawConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/IntervalToHostRawConverter.cs index 58d03626e9..713266fba4 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/IntervalToHostRawConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/IntervalToHostRawConverter.cs @@ -2,10 +2,10 @@ namespace Speckle.Converters.AutocadShared.ToHost.Raw; -public class IntervalToHostRawConverter : IRawConversion +public class IntervalToHostRawConverter : ITypedConverter { /// Throws if target start or end value is null. - public AG.Interval RawConvert(SOP.Interval target) + public AG.Interval Convert(SOP.Interval target) { // POC: the tolerance might be in some settings or in some context? if (target.start is null || target.end is null) diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/PlaneToHostRawConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/PlaneToHostRawConverter.cs index 4928988e81..6b100dd28e 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/PlaneToHostRawConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/PlaneToHostRawConverter.cs @@ -3,22 +3,22 @@ namespace Speckle.Converters.Autocad.ToHost.Raw; -public class PlaneToHostRawConverter : IRawConversion +public class PlaneToHostRawConverter : ITypedConverter { - private readonly IRawConversion _pointConverter; - private readonly IRawConversion _vectorConverter; + private readonly ITypedConverter _pointConverter; + private readonly ITypedConverter _vectorConverter; public PlaneToHostRawConverter( - IRawConversion pointConverter, - IRawConversion vectorConverter + ITypedConverter pointConverter, + ITypedConverter vectorConverter ) { _pointConverter = pointConverter; _vectorConverter = vectorConverter; } - public object Convert(Base target) => RawConvert((SOG.Plane)target); + public object Convert(Base target) => Convert((SOG.Plane)target); - public AG.Plane RawConvert(SOG.Plane target) => - new(_pointConverter.RawConvert(target.origin), _vectorConverter.RawConvert(target.normal)); + public AG.Plane Convert(SOG.Plane target) => + new(_pointConverter.Convert(target.origin), _vectorConverter.Convert(target.normal)); } diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/PointToHostRawConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/PointToHostRawConverter.cs index 26be7f9334..467448fbe8 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/PointToHostRawConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/PointToHostRawConverter.cs @@ -4,7 +4,7 @@ namespace Speckle.Converters.Autocad.ToHost.Raw; -public class PointToHostRawConverter : IRawConversion +public class PointToHostRawConverter : ITypedConverter { private readonly IConversionContextStack _contextStack; @@ -13,7 +13,7 @@ public PointToHostRawConverter(IConversionContextStack _contextStack = contextStack; } - public AG.Point3d RawConvert(SOG.Point target) + public AG.Point3d Convert(SOG.Point target) { double f = Units.GetConversionFactor(target.units, _contextStack.Current.SpeckleUnits); AG.Point3d point = new(target.x * f, target.y * f, target.z * f); diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/PolycurveToHostPolylineRawConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/PolycurveToHostPolylineRawConverter.cs index b5a182fa2f..faa13f0167 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/PolycurveToHostPolylineRawConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/PolycurveToHostPolylineRawConverter.cs @@ -6,21 +6,21 @@ namespace Speckle.Converters.AutocadShared.ToHost.Raw; /// /// If polycurve segments consist of only with Line and Arc, we convert it as ADB.Polyline. /// -public class PolycurveToHostPolylineRawConverter : IRawConversion +public class PolycurveToHostPolylineRawConverter : ITypedConverter { private readonly IConversionContextStack _contextStack; - private readonly IRawConversion _pointConverter; + private readonly ITypedConverter _pointConverter; public PolycurveToHostPolylineRawConverter( IConversionContextStack contextStack, - IRawConversion pointConverter + ITypedConverter pointConverter ) { _contextStack = contextStack; _pointConverter = pointConverter; } - public ADB.Polyline RawConvert(SOG.Polycurve target) + public ADB.Polyline Convert(SOG.Polycurve target) { ADB.Polyline polyline = new() { Closed = target.closed }; AG.Plane plane = @@ -35,10 +35,10 @@ public ADB.Polyline RawConvert(SOG.Polycurve target) switch (segment) { case SOG.Line o: - polyline.AddVertexAt(count, _pointConverter.RawConvert(o.start).Convert2d(plane), 0, 0, 0); + polyline.AddVertexAt(count, _pointConverter.Convert(o.start).Convert2d(plane), 0, 0, 0); if (!target.closed && count == target.segments.Count - 1) { - polyline.AddVertexAt(count + 1, _pointConverter.RawConvert(o.end).Convert2d(plane), 0, 0, 0); + polyline.AddVertexAt(count + 1, _pointConverter.Convert(o.end).Convert2d(plane), 0, 0, 0); } count++; @@ -53,16 +53,16 @@ public ADB.Polyline RawConvert(SOG.Polycurve target) } var bulge = Math.Tan((double)angle / 4) * BulgeDirection(arc.startPoint, arc.midPoint, arc.endPoint); - polyline.AddVertexAt(count, _pointConverter.RawConvert(arc.startPoint).Convert2d(plane), bulge, 0, 0); + polyline.AddVertexAt(count, _pointConverter.Convert(arc.startPoint).Convert2d(plane), bulge, 0, 0); if (!target.closed && count == target.segments.Count - 1) { - polyline.AddVertexAt(count + 1, _pointConverter.RawConvert(arc.endPoint).Convert2d(plane), 0, 0, 0); + polyline.AddVertexAt(count + 1, _pointConverter.Convert(arc.endPoint).Convert2d(plane), 0, 0, 0); } count++; break; case SOG.Spiral o: - List vertices = o.displayValue.GetPoints().Select(_pointConverter.RawConvert).ToList(); + List vertices = o.displayValue.GetPoints().Select(_pointConverter.Convert).ToList(); foreach (AG.Point3d vertex in vertices) { polyline.AddVertexAt(count, vertex.Convert2d(plane), 0, 0, 0); diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/PolycurveToHostSplineRawConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/PolycurveToHostSplineRawConverter.cs index 25dbe01f7e..c9c1e1ce66 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/PolycurveToHostSplineRawConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/PolycurveToHostSplineRawConverter.cs @@ -5,18 +5,18 @@ namespace Speckle.Converters.AutocadShared.ToHost.Raw; /// /// Polycurve segments might appear in different ICurve types which requires to handle separately for each segment. /// -public class PolycurveToHostSplineRawConverter : IRawConversion> +public class PolycurveToHostSplineRawConverter : ITypedConverter> { - private readonly IRawConversion _lineConverter; - private readonly IRawConversion _polylineConverter; - private readonly IRawConversion _arcConverter; - private readonly IRawConversion _curveConverter; + private readonly ITypedConverter _lineConverter; + private readonly ITypedConverter _polylineConverter; + private readonly ITypedConverter _arcConverter; + private readonly ITypedConverter _curveConverter; public PolycurveToHostSplineRawConverter( - IRawConversion lineConverter, - IRawConversion polylineConverter, - IRawConversion arcConverter, - IRawConversion curveConverter + ITypedConverter lineConverter, + ITypedConverter polylineConverter, + ITypedConverter arcConverter, + ITypedConverter curveConverter ) { _lineConverter = lineConverter; @@ -25,7 +25,7 @@ public PolycurveToHostSplineRawConverter( _curveConverter = curveConverter; } - public List RawConvert(SOG.Polycurve target) + public List Convert(SOG.Polycurve target) { // POC: We can improve this once we have IIndex of raw converters and we can get rid of case converters? // POC: Should we join entities? @@ -36,16 +36,16 @@ public PolycurveToHostSplineRawConverter( switch (segment) { case SOG.Arc arc: - list.Add(_arcConverter.RawConvert(arc)); + list.Add(_arcConverter.Convert(arc)); break; case SOG.Line line: - list.Add(_lineConverter.RawConvert(line)); + list.Add(_lineConverter.Convert(line)); break; case SOG.Polyline polyline: - list.Add(_polylineConverter.RawConvert(polyline)); + list.Add(_polylineConverter.Convert(polyline)); break; case SOG.Curve curve: - list.Add(_curveConverter.RawConvert(curve)); + list.Add(_curveConverter.Convert(curve)); break; default: break; diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/VectorToHostRawConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/VectorToHostRawConverter.cs index 3c44da75f2..5897dcf651 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/VectorToHostRawConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/VectorToHostRawConverter.cs @@ -5,7 +5,7 @@ namespace Speckle.Converters.Autocad.ToHost.Raw; -public class VectorToHostRawConverter : IRawConversion +public class VectorToHostRawConverter : ITypedConverter { private readonly IConversionContextStack _contextStack; @@ -14,9 +14,9 @@ public VectorToHostRawConverter(IConversionContextStack RawConvert((SOG.Vector)target); + public object Convert(Base target) => Convert((SOG.Vector)target); - public AG.Vector3d RawConvert(SOG.Vector target) + public AG.Vector3d Convert(SOG.Vector target) { double f = Units.GetConversionFactor(target.units, _contextStack.Current.SpeckleUnits); return new(target.x * f, target.y * f, target.z * f); diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/ArcToSpeckleConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/ArcToSpeckleConverter.cs index 39a60873f0..36d7b796f6 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/ArcToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/ArcToSpeckleConverter.cs @@ -5,17 +5,17 @@ namespace Speckle.Converters.Autocad.ToSpeckle.Geometry; [NameAndRankValue(nameof(ADB.Arc), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class DBArcToSpeckleConverter : IHostObjectToSpeckleConversion, IRawConversion +public class DBArcToSpeckleConverter : IToSpeckleTopLevelConverter, ITypedConverter { - private readonly IRawConversion _pointConverter; - private readonly IRawConversion _planeConverter; - private readonly IRawConversion _boxConverter; + private readonly ITypedConverter _pointConverter; + private readonly ITypedConverter _planeConverter; + private readonly ITypedConverter _boxConverter; private readonly IConversionContextStack _contextStack; public DBArcToSpeckleConverter( - IRawConversion pointConverter, - IRawConversion planeConverter, - IRawConversion boxConverter, + ITypedConverter pointConverter, + ITypedConverter planeConverter, + ITypedConverter boxConverter, IConversionContextStack contextStack ) { @@ -25,16 +25,16 @@ public DBArcToSpeckleConverter( _contextStack = contextStack; } - public Base Convert(object target) => RawConvert((ADB.Arc)target); + public Base Convert(object target) => Convert((ADB.Arc)target); - public SOG.Arc RawConvert(ADB.Arc target) + public SOG.Arc Convert(ADB.Arc target) { - SOG.Plane plane = _planeConverter.RawConvert(target.GetPlane()); - SOG.Point start = _pointConverter.RawConvert(target.StartPoint); - SOG.Point end = _pointConverter.RawConvert(target.EndPoint); - SOG.Point mid = _pointConverter.RawConvert(target.GetPointAtDist(target.Length / 2.0)); + SOG.Plane plane = _planeConverter.Convert(target.GetPlane()); + SOG.Point start = _pointConverter.Convert(target.StartPoint); + SOG.Point end = _pointConverter.Convert(target.EndPoint); + SOG.Point mid = _pointConverter.Convert(target.GetPointAtDist(target.Length / 2.0)); SOP.Interval domain = new(target.StartParam, target.EndParam); - SOG.Box bbox = _boxConverter.RawConvert(target.GeometricExtents); + SOG.Box bbox = _boxConverter.Convert(target.GeometricExtents); SOG.Arc arc = new( diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/CircleToSpeckleConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/CircleToSpeckleConverter.cs index 3bdfb3cf95..18b45a8daf 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/CircleToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/CircleToSpeckleConverter.cs @@ -5,15 +5,15 @@ namespace Speckle.Converters.Autocad.ToSpeckle.Geometry; [NameAndRankValue(nameof(ADB.Circle), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class DBCircleToSpeckleConverter : IHostObjectToSpeckleConversion +public class DBCircleToSpeckleConverter : IToSpeckleTopLevelConverter { - private readonly IRawConversion _planeConverter; - private readonly IRawConversion _boxConverter; + private readonly ITypedConverter _planeConverter; + private readonly ITypedConverter _boxConverter; private readonly IConversionContextStack _contextStack; public DBCircleToSpeckleConverter( - IRawConversion planeConverter, - IRawConversion boxConverter, + ITypedConverter planeConverter, + ITypedConverter boxConverter, IConversionContextStack contextStack ) { @@ -26,8 +26,8 @@ public DBCircleToSpeckleConverter( public SOG.Circle RawConvert(ADB.Circle target) { - SOG.Plane plane = _planeConverter.RawConvert(target.GetPlane()); - SOG.Box bbox = _boxConverter.RawConvert(target.GeometricExtents); + SOG.Plane plane = _planeConverter.Convert(target.GetPlane()); + SOG.Box bbox = _boxConverter.Convert(target.GeometricExtents); SOG.Circle circle = new(plane, target.Radius, _contextStack.Current.SpeckleUnits) { length = target.Circumference, bbox = bbox }; diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/EllipseToSpeckleConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/EllipseToSpeckleConverter.cs index 06dae2c11b..524e1a1d8c 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/EllipseToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/EllipseToSpeckleConverter.cs @@ -5,15 +5,15 @@ namespace Speckle.Converters.Autocad.ToSpeckle.Geometry; [NameAndRankValue(nameof(ADB.Ellipse), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class DBEllipseToSpeckleConverter : IHostObjectToSpeckleConversion +public class DBEllipseToSpeckleConverter : IToSpeckleTopLevelConverter { - private readonly IRawConversion _planeConverter; - private readonly IRawConversion _boxConverter; + private readonly ITypedConverter _planeConverter; + private readonly ITypedConverter _boxConverter; private readonly IConversionContextStack _contextStack; public DBEllipseToSpeckleConverter( - IRawConversion planeConverter, - IRawConversion boxConverter, + ITypedConverter planeConverter, + ITypedConverter boxConverter, IConversionContextStack contextStack ) { @@ -26,8 +26,8 @@ public DBEllipseToSpeckleConverter( public SOG.Ellipse RawConvert(ADB.Ellipse target) { - SOG.Plane plane = _planeConverter.RawConvert(new AG.Plane(target.Center, target.MajorAxis, target.MinorAxis)); - SOG.Box bbox = _boxConverter.RawConvert(target.GeometricExtents); + SOG.Plane plane = _planeConverter.Convert(new AG.Plane(target.Center, target.MajorAxis, target.MinorAxis)); + SOG.Box bbox = _boxConverter.Convert(target.GeometricExtents); // the start and end param corresponds to start and end angle in radians SOP.Interval trim = new(target.StartAngle, target.EndAngle); diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/LineToSpeckleConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/LineToSpeckleConverter.cs index f68c1b5ba1..22787e2290 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/LineToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/LineToSpeckleConverter.cs @@ -5,15 +5,15 @@ namespace Speckle.Converters.Autocad.ToSpeckle.Geometry; [NameAndRankValue(nameof(ADB.Line), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class LineToSpeckleConverter : IHostObjectToSpeckleConversion, IRawConversion +public class LineToSpeckleConverter : IToSpeckleTopLevelConverter, ITypedConverter { - private readonly IRawConversion _pointConverter; - private readonly IRawConversion _boxConverter; + private readonly ITypedConverter _pointConverter; + private readonly ITypedConverter _boxConverter; private readonly IConversionContextStack _contextStack; public LineToSpeckleConverter( - IRawConversion pointConverter, - IRawConversion boxConverter, + ITypedConverter pointConverter, + ITypedConverter boxConverter, IConversionContextStack contextStack ) { @@ -22,17 +22,17 @@ public LineToSpeckleConverter( _contextStack = contextStack; } - public Base Convert(object target) => RawConvert((ADB.Line)target); + public Base Convert(object target) => Convert((ADB.Line)target); - public SOG.Line RawConvert(ADB.Line target) => + public SOG.Line Convert(ADB.Line target) => new( - _pointConverter.RawConvert(target.StartPoint), - _pointConverter.RawConvert(target.EndPoint), + _pointConverter.Convert(target.StartPoint), + _pointConverter.Convert(target.EndPoint), _contextStack.Current.SpeckleUnits ) { length = target.Length, domain = new SOP.Interval(0, target.Length), - bbox = _boxConverter.RawConvert(target.GeometricExtents) + bbox = _boxConverter.Convert(target.GeometricExtents) }; } diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/PointToSpeckleConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/PointToSpeckleConverter.cs index f22f60ef34..20b59aa1aa 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/PointToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/PointToSpeckleConverter.cs @@ -5,16 +5,16 @@ namespace Speckle.Converters.Autocad.ToSpeckle.Geometry; [NameAndRankValue(nameof(ADB.DBPoint), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class PointToSpeckleConverter : IHostObjectToSpeckleConversion +public class PointToSpeckleConverter : IToSpeckleTopLevelConverter { - private readonly IRawConversion _pointConverter; + private readonly ITypedConverter _pointConverter; - public PointToSpeckleConverter(IRawConversion pointConverter) + public PointToSpeckleConverter(ITypedConverter pointConverter) { _pointConverter = pointConverter; } public Base Convert(object target) => RawConvert((ADB.DBPoint)target); - public SOG.Point RawConvert(ADB.DBPoint target) => _pointConverter.RawConvert(target.Position); + public SOG.Point RawConvert(ADB.DBPoint target) => _pointConverter.Convert(target.Position); } diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/PolyfaceMeshToSpeckleConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/PolyfaceMeshToSpeckleConverter.cs index 08a1bdbb22..f96503a298 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/PolyfaceMeshToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/PolyfaceMeshToSpeckleConverter.cs @@ -9,18 +9,18 @@ namespace Speckle.Converters.Autocad.Geometry; /// The class converter. Converts to . /// /// -/// The IHostObjectToSpeckleConversion inheritance should only expect database-resident objects. IRawConversion inheritance can expect non database-resident objects, when generated from other converters. +/// The IToSpeckleTopLevelConverter inheritance should only expect database-resident objects. IRawConversion inheritance can expect non database-resident objects, when generated from other converters. /// [NameAndRankValue(nameof(ADB.PolyFaceMesh), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class DBPolyfaceMeshToSpeckleConverter : IHostObjectToSpeckleConversion +public class DBPolyfaceMeshToSpeckleConverter : IToSpeckleTopLevelConverter { - private readonly IRawConversion _pointConverter; - private readonly IRawConversion _boxConverter; + private readonly ITypedConverter _pointConverter; + private readonly ITypedConverter _boxConverter; private readonly IConversionContextStack _contextStack; public DBPolyfaceMeshToSpeckleConverter( - IRawConversion pointConverter, - IRawConversion boxConverter, + ITypedConverter pointConverter, + ITypedConverter boxConverter, IConversionContextStack contextStack ) { @@ -87,10 +87,10 @@ public SOG.Mesh RawConvert(ADB.PolyFaceMesh target) List vertices = new(dbVertices.Count * 3); foreach (Point3d vert in dbVertices) { - vertices.AddRange(_pointConverter.RawConvert(vert).ToList()); + vertices.AddRange(_pointConverter.Convert(vert).ToList()); } - SOG.Box bbox = _boxConverter.RawConvert(target.GeometricExtents); + SOG.Box bbox = _boxConverter.Convert(target.GeometricExtents); SOG.Mesh speckleMesh = new(vertices, faces, colors, null, _contextStack.Current.SpeckleUnits) diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/Polyline2dToSpeckleConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/Polyline2dToSpeckleConverter.cs index c18458e89b..330d832cba 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/Polyline2dToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/Polyline2dToSpeckleConverter.cs @@ -12,26 +12,26 @@ namespace Speckle.Converters.Autocad.Geometry; /// of type will have only s and s in . /// of type will have only s in . /// of type and will have only one in . -/// The IHostObjectToSpeckleConversion inheritance should only expect database-resident objects. IRawConversion inheritance can expect non database-resident objects, when generated from other converters. +/// The IToSpeckleTopLevelConverter inheritance should only expect database-resident objects. IRawConversion inheritance can expect non database-resident objects, when generated from other converters. /// [NameAndRankValue(nameof(ADB.Polyline2d), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class Polyline2dToSpeckleConverter : IHostObjectToSpeckleConversion +public class Polyline2dToSpeckleConverter : IToSpeckleTopLevelConverter { - private readonly IRawConversion _arcConverter; - private readonly IRawConversion _lineConverter; - private readonly IRawConversion _polylineConverter; - private readonly IRawConversion _splineConverter; - private readonly IRawConversion _vectorConverter; - private readonly IRawConversion _boxConverter; + private readonly ITypedConverter _arcConverter; + private readonly ITypedConverter _lineConverter; + private readonly ITypedConverter _polylineConverter; + private readonly ITypedConverter _splineConverter; + private readonly ITypedConverter _vectorConverter; + private readonly ITypedConverter _boxConverter; private readonly IConversionContextStack _contextStack; public Polyline2dToSpeckleConverter( - IRawConversion arcConverter, - IRawConversion lineConverter, - IRawConversion polylineConverter, - IRawConversion splineConverter, - IRawConversion vectorConverter, - IRawConversion boxConverter, + ITypedConverter arcConverter, + ITypedConverter lineConverter, + ITypedConverter polylineConverter, + ITypedConverter splineConverter, + ITypedConverter vectorConverter, + ITypedConverter boxConverter, IConversionContextStack contextStack ) { @@ -137,7 +137,7 @@ public SOG.Autocad.AutocadPolycurve RawConvert(ADB.Polyline2d target) arc.ReverseCurve(); } - segments.Add(_arcConverter.RawConvert(arc)); + segments.Add(_arcConverter.Convert(arc)); previousPoint = arc.EndPoint; break; case ADB.Line line: @@ -146,7 +146,7 @@ public SOG.Autocad.AutocadPolycurve RawConvert(ADB.Polyline2d target) line.ReverseCurve(); } - segments.Add(_lineConverter.RawConvert(line)); + segments.Add(_lineConverter.Convert(line)); previousPoint = line.EndPoint; break; } @@ -157,7 +157,7 @@ public SOG.Autocad.AutocadPolycurve RawConvert(ADB.Polyline2d target) // for splines, convert the spline curve and display value and add to the segments list if (isSpline) { - SOG.Curve spline = _splineConverter.RawConvert(target.Spline); + SOG.Curve spline = _splineConverter.Convert(target.Spline); SOG.Polyline displayValue = segmentValues.ConvertToSpecklePolyline(_contextStack.Current.SpeckleUnits); if (displayValue != null) { @@ -167,8 +167,8 @@ public SOG.Autocad.AutocadPolycurve RawConvert(ADB.Polyline2d target) segments.Add(spline); } - SOG.Vector normal = _vectorConverter.RawConvert(target.Normal); - SOG.Box bbox = _boxConverter.RawConvert(target.GeometricExtents); + SOG.Vector normal = _vectorConverter.Convert(target.Normal); + SOG.Box bbox = _boxConverter.Convert(target.GeometricExtents); SOG.Autocad.AutocadPolycurve polycurve = new() { diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/Polyline3dToSpeckleConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/Polyline3dToSpeckleConverter.cs index 9434280ca8..fdef5bd478 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/Polyline3dToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/Polyline3dToSpeckleConverter.cs @@ -11,20 +11,20 @@ namespace Speckle.Converters.Autocad.Geometry; /// /// of type will have only one in . /// of type and will have only one in . -/// The IHostObjectToSpeckleConversion inheritance should only expect database-resident Polyline2d objects. IRawConversion inheritance can expect non database-resident objects, when generated from other converters. +/// The IToSpeckleTopLevelConverter inheritance should only expect database-resident Polyline2d objects. IRawConversion inheritance can expect non database-resident objects, when generated from other converters. /// [NameAndRankValue(nameof(ADB.Polyline3d), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class Polyline3dToSpeckleConverter : IHostObjectToSpeckleConversion +public class Polyline3dToSpeckleConverter : IToSpeckleTopLevelConverter { - private readonly IRawConversion _pointConverter; - private readonly IRawConversion _splineConverter; - private readonly IRawConversion _boxConverter; + private readonly ITypedConverter _pointConverter; + private readonly ITypedConverter _splineConverter; + private readonly ITypedConverter _boxConverter; private readonly IConversionContextStack _contextStack; public Polyline3dToSpeckleConverter( - IRawConversion pointConverter, - IRawConversion splineConverter, - IRawConversion boxConverter, + ITypedConverter pointConverter, + ITypedConverter splineConverter, + ITypedConverter boxConverter, IConversionContextStack contextStack ) { @@ -74,7 +74,7 @@ public SOG.Autocad.AutocadPolycurve RawConvert(ADB.Polyline3d target) if (target.PolyType is not ADB.Poly3dType.SimplePoly) { // get the spline segment - SOG.Curve spline = _splineConverter.RawConvert(target.Spline); + SOG.Curve spline = _splineConverter.Convert(target.Spline); // get the spline displayvalue by exploding the polyline List segmentValues = new(); @@ -112,7 +112,7 @@ public SOG.Autocad.AutocadPolycurve RawConvert(ADB.Polyline3d target) segments.Add(polyline); } - SOG.Box bbox = _boxConverter.RawConvert(target.GeometricExtents); + SOG.Box bbox = _boxConverter.Convert(target.GeometricExtents); SOG.Autocad.AutocadPolycurve polycurve = new() diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/PolylineToSpeckleConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/PolylineToSpeckleConverter.cs index dce4210940..33a57b6b7f 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/PolylineToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/PolylineToSpeckleConverter.cs @@ -12,20 +12,20 @@ namespace Speckle.Converters.Autocad.Geometry; /// [NameAndRankValue(nameof(ADB.Polyline), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] public class PolylineToSpeckleConverter - : IHostObjectToSpeckleConversion, - IRawConversion + : IToSpeckleTopLevelConverter, + ITypedConverter { - private readonly IRawConversion _lineConverter; - private readonly IRawConversion _arcConverter; - private readonly IRawConversion _vectorConverter; - private readonly IRawConversion _boxConverter; + private readonly ITypedConverter _lineConverter; + private readonly ITypedConverter _arcConverter; + private readonly ITypedConverter _vectorConverter; + private readonly ITypedConverter _boxConverter; private readonly IConversionContextStack _contextStack; public PolylineToSpeckleConverter( - IRawConversion lineConverter, - IRawConversion arcConverter, - IRawConversion vectorConverter, - IRawConversion boxConverter, + ITypedConverter lineConverter, + ITypedConverter arcConverter, + ITypedConverter vectorConverter, + ITypedConverter boxConverter, IConversionContextStack contextStack ) { @@ -36,9 +36,9 @@ public PolylineToSpeckleConverter( _contextStack = contextStack; } - public Base Convert(object target) => RawConvert((ADB.Polyline)target); + public Base Convert(object target) => Convert((ADB.Polyline)target); - public SOG.Autocad.AutocadPolycurve RawConvert(ADB.Polyline target) + public SOG.Autocad.AutocadPolycurve Convert(ADB.Polyline target) { List value = new(target.NumberOfVertices * 3); List bulges = new(target.NumberOfVertices); @@ -58,11 +58,11 @@ public SOG.Autocad.AutocadPolycurve RawConvert(ADB.Polyline target) { case ADB.SegmentType.Line: AG.LineSegment3d line = target.GetLineSegmentAt(i); - segments.Add(_lineConverter.RawConvert(line)); + segments.Add(_lineConverter.Convert(line)); break; case ADB.SegmentType.Arc: AG.CircularArc3d arc = target.GetArcSegmentAt(i); - segments.Add(_arcConverter.RawConvert(arc)); + segments.Add(_arcConverter.Convert(arc)); break; default: // we are skipping segments of type Empty, Point, and Coincident @@ -70,8 +70,8 @@ public SOG.Autocad.AutocadPolycurve RawConvert(ADB.Polyline target) } } - SOG.Vector normal = _vectorConverter.RawConvert(target.Normal); - SOG.Box bbox = _boxConverter.RawConvert(target.GeometricExtents); + SOG.Vector normal = _vectorConverter.Convert(target.Normal); + SOG.Box bbox = _boxConverter.Convert(target.GeometricExtents); SOG.Autocad.AutocadPolycurve polycurve = new() diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/SplineToSpeckleConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/SplineToSpeckleConverter.cs index d4aabd29d4..059f92f033 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/SplineToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/SplineToSpeckleConverter.cs @@ -7,15 +7,15 @@ namespace Speckle.Converters.Autocad.ToSpeckle.Geometry; [NameAndRankValue(nameof(ADB.Spline), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class SplineToSpeckleConverter : IHostObjectToSpeckleConversion, IRawConversion +public class SplineToSpeckleConverter : IToSpeckleTopLevelConverter, ITypedConverter { - private readonly IRawConversion _intervalConverter; - private readonly IRawConversion _boxConverter; + private readonly ITypedConverter _intervalConverter; + private readonly ITypedConverter _boxConverter; private readonly IConversionContextStack _contextStack; public SplineToSpeckleConverter( - IRawConversion intervalConverter, - IRawConversion boxConverter, + ITypedConverter intervalConverter, + ITypedConverter boxConverter, IConversionContextStack contextStack ) { @@ -24,9 +24,9 @@ public SplineToSpeckleConverter( _contextStack = contextStack; } - public Base Convert(object target) => RawConvert((ADB.Spline)target); + public Base Convert(object target) => Convert((ADB.Spline)target); - public SOG.Curve RawConvert(ADB.Spline target) + public SOG.Curve Convert(ADB.Spline target) { // get nurbs and geo data ADB.NurbsData data = target.NurbsData; @@ -38,7 +38,7 @@ public SOG.Curve RawConvert(ADB.Spline target) if (target.GetGeCurve() is NurbCurve3d nurbs) { length = nurbs.GetLength(nurbs.StartParameter, nurbs.EndParameter, 0.001); - domain = _intervalConverter.RawConvert(nurbs.GetInterval()); + domain = _intervalConverter.Convert(nurbs.GetInterval()); if (nurbs.Knots.Count < nurbs.NumberOfControlPoints + nurbs.Degree + 1 && target.IsPeriodic) { periodicClosed = true; @@ -109,7 +109,7 @@ public SOG.Curve RawConvert(ADB.Spline target) closed = periodicClosed || target.Closed, length = length, domain = domain, - bbox = _boxConverter.RawConvert(target.GeometricExtents), + bbox = _boxConverter.Convert(target.GeometricExtents), units = _contextStack.Current.SpeckleUnits }; diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/SubDMeshToSpeckleConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/SubDMeshToSpeckleConverter.cs index 296107a5e0..98686f8006 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/SubDMeshToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/SubDMeshToSpeckleConverter.cs @@ -5,15 +5,15 @@ namespace Speckle.Converters.Autocad.Geometry; [NameAndRankValue(nameof(ADB.SubDMesh), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class DBSubDMeshToSpeckleConverter : IHostObjectToSpeckleConversion +public class DBSubDMeshToSpeckleConverter : IToSpeckleTopLevelConverter { - private readonly IRawConversion _pointConverter; - private readonly IRawConversion _boxConverter; + private readonly ITypedConverter _pointConverter; + private readonly ITypedConverter _boxConverter; private readonly IConversionContextStack _contextStack; public DBSubDMeshToSpeckleConverter( - IRawConversion pointConverter, - IRawConversion boxConverter, + ITypedConverter pointConverter, + ITypedConverter boxConverter, IConversionContextStack contextStack ) { @@ -30,7 +30,7 @@ public SOG.Mesh RawConvert(ADB.SubDMesh target) var vertices = new List(target.Vertices.Count * 3); foreach (AG.Point3d vert in target.Vertices) { - vertices.AddRange(_pointConverter.RawConvert(vert).ToList()); + vertices.AddRange(_pointConverter.Convert(vert).ToList()); } // faces @@ -67,7 +67,7 @@ public SOG.Mesh RawConvert(ADB.SubDMesh target) .ToList(); // bbox - SOG.Box bbox = _boxConverter.RawConvert(target.GeometricExtents); + SOG.Box bbox = _boxConverter.Convert(target.GeometricExtents); SOG.Mesh speckleMesh = new(vertices, faces, colors, null, _contextStack.Current.SpeckleUnits) { bbox = bbox }; diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Raw/BoxToSpeckleRawConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Raw/BoxToSpeckleRawConverter.cs index 62f798ae11..a36bbb60f6 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Raw/BoxToSpeckleRawConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Raw/BoxToSpeckleRawConverter.cs @@ -4,13 +4,13 @@ namespace Speckle.Converters.Autocad.ToSpeckle.Raw; -public class BoxToSpeckleRawConverter : IRawConversion +public class BoxToSpeckleRawConverter : ITypedConverter { - private readonly IRawConversion _planeConverter; + private readonly ITypedConverter _planeConverter; private readonly IConversionContextStack _contextStack; public BoxToSpeckleRawConverter( - IRawConversion planeConverter, + ITypedConverter planeConverter, IConversionContextStack contextStack ) { @@ -18,9 +18,9 @@ public BoxToSpeckleRawConverter( _contextStack = contextStack; } - public Base Convert(object target) => RawConvert((ADB.Extents3d)target); + public Base Convert(object target) => Convert((ADB.Extents3d)target); - public SOG.Box RawConvert(ADB.Extents3d target) + public SOG.Box Convert(ADB.Extents3d target) { // get dimension intervals and volume SOP.Interval xSize = new(target.MinPoint.X, target.MaxPoint.X); @@ -31,7 +31,7 @@ public SOG.Box RawConvert(ADB.Extents3d target) // get the base plane of the bounding box from extents and current UCS var ucs = _contextStack.Current.Document.Editor.CurrentUserCoordinateSystem.CoordinateSystem3d; AG.Plane acadPlane = new(target.MinPoint, ucs.Xaxis, ucs.Yaxis); - SOG.Plane plane = _planeConverter.RawConvert(acadPlane); + SOG.Plane plane = _planeConverter.Convert(acadPlane); SOG.Box box = new(plane, xSize, ySize, zSize, _contextStack.Current.SpeckleUnits) { volume = volume }; diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Raw/CircularArc3dToSpeckleConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Raw/CircularArc3dToSpeckleConverter.cs index 5979f9d7aa..ec8f91e0b7 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Raw/CircularArc3dToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Raw/CircularArc3dToSpeckleConverter.cs @@ -3,15 +3,15 @@ namespace Speckle.Converters.Autocad.ToSpeckle.Raw; -public class CircularArc3dToSpeckleConverter : IRawConversion +public class CircularArc3dToSpeckleConverter : ITypedConverter { - private readonly IRawConversion _pointConverter; - private readonly IRawConversion _planeConverter; + private readonly ITypedConverter _pointConverter; + private readonly ITypedConverter _planeConverter; private readonly IConversionContextStack _contextStack; public CircularArc3dToSpeckleConverter( - IRawConversion pointConverter, - IRawConversion planeConverter, + ITypedConverter pointConverter, + ITypedConverter planeConverter, IConversionContextStack contextStack ) { @@ -20,12 +20,12 @@ public CircularArc3dToSpeckleConverter( _contextStack = contextStack; } - public SOG.Arc RawConvert(AG.CircularArc3d target) + public SOG.Arc Convert(AG.CircularArc3d target) { - SOG.Plane plane = _planeConverter.RawConvert(target.GetPlane()); - SOG.Point start = _pointConverter.RawConvert(target.StartPoint); - SOG.Point end = _pointConverter.RawConvert(target.EndPoint); - SOG.Point mid = _pointConverter.RawConvert(target.EvaluatePoint(0.5)); // POC: testing, unsure + SOG.Plane plane = _planeConverter.Convert(target.GetPlane()); + SOG.Point start = _pointConverter.Convert(target.StartPoint); + SOG.Point end = _pointConverter.Convert(target.EndPoint); + SOG.Point mid = _pointConverter.Convert(target.EvaluatePoint(0.5)); // POC: testing, unsure SOP.Interval domain = new(target.GetInterval().LowerBound, target.GetInterval().UpperBound); SOG.Arc arc = diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Raw/IntervalToSpeckleRawConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Raw/IntervalToSpeckleRawConverter.cs index 77613f996d..fe5ac853d4 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Raw/IntervalToSpeckleRawConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Raw/IntervalToSpeckleRawConverter.cs @@ -3,9 +3,9 @@ namespace Speckle.Converters.Autocad.ToSpeckle.Raw; -public class IntervalToSpeckleConverter : IRawConversion +public class IntervalToSpeckleConverter : ITypedConverter { - public Base Convert(object target) => RawConvert((AG.Interval)target); + public Base Convert(object target) => Convert((AG.Interval)target); - public SOP.Interval RawConvert(AG.Interval target) => new(target.LowerBound, target.UpperBound); + public SOP.Interval Convert(AG.Interval target) => new(target.LowerBound, target.UpperBound); } diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Raw/LineSegment3dToSpeckleRawConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Raw/LineSegment3dToSpeckleRawConverter.cs index f1bc383664..f4079ca5ee 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Raw/LineSegment3dToSpeckleRawConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Raw/LineSegment3dToSpeckleRawConverter.cs @@ -3,13 +3,13 @@ namespace Speckle.Converters.Autocad.ToSpeckle.Raw; -public class LineSegment3dToSpeckleRawConverter : IRawConversion +public class LineSegment3dToSpeckleRawConverter : ITypedConverter { - private readonly IRawConversion _pointConverter; + private readonly ITypedConverter _pointConverter; private readonly IConversionContextStack _contextStack; public LineSegment3dToSpeckleRawConverter( - IRawConversion pointConverter, + ITypedConverter pointConverter, IConversionContextStack contextStack ) { @@ -17,10 +17,10 @@ public LineSegment3dToSpeckleRawConverter( _contextStack = contextStack; } - public SOG.Line RawConvert(AG.LineSegment3d target) => + public SOG.Line Convert(AG.LineSegment3d target) => new( - _pointConverter.RawConvert(target.StartPoint), - _pointConverter.RawConvert(target.EndPoint), + _pointConverter.Convert(target.StartPoint), + _pointConverter.Convert(target.EndPoint), _contextStack.Current.SpeckleUnits ) { diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Raw/PlaneToSpeckleRawConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Raw/PlaneToSpeckleRawConverter.cs index 86ac812497..4c5bc6f1ce 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Raw/PlaneToSpeckleRawConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Raw/PlaneToSpeckleRawConverter.cs @@ -4,15 +4,15 @@ namespace Speckle.Converters.Autocad.ToSpeckle.Raw; -public class PlaneToSpeckleRawConverter : IHostObjectToSpeckleConversion, IRawConversion +public class PlaneToSpeckleRawConverter : IToSpeckleTopLevelConverter, ITypedConverter { - private readonly IRawConversion _vectorConverter; - private readonly IRawConversion _pointConverter; + private readonly ITypedConverter _vectorConverter; + private readonly ITypedConverter _pointConverter; private readonly IConversionContextStack _contextStack; public PlaneToSpeckleRawConverter( - IRawConversion vectorConverter, - IRawConversion pointConverter, + ITypedConverter vectorConverter, + ITypedConverter pointConverter, IConversionContextStack contextStack ) { @@ -21,14 +21,14 @@ public PlaneToSpeckleRawConverter( _contextStack = contextStack; } - public Base Convert(object target) => RawConvert((AG.Plane)target); + public Base Convert(object target) => Convert((AG.Plane)target); - public SOG.Plane RawConvert(AG.Plane target) => + public SOG.Plane Convert(AG.Plane target) => new( - _pointConverter.RawConvert(target.PointOnPlane), - _vectorConverter.RawConvert(target.Normal), - _vectorConverter.RawConvert(target.GetCoordinateSystem().Xaxis), - _vectorConverter.RawConvert(target.GetCoordinateSystem().Yaxis), + _pointConverter.Convert(target.PointOnPlane), + _vectorConverter.Convert(target.Normal), + _vectorConverter.Convert(target.GetCoordinateSystem().Xaxis), + _vectorConverter.Convert(target.GetCoordinateSystem().Yaxis), _contextStack.Current.SpeckleUnits ); } diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Raw/PointToSpeckleRawConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Raw/PointToSpeckleRawConverter.cs index 5dc90c63ca..df8c45f237 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Raw/PointToSpeckleRawConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Raw/PointToSpeckleRawConverter.cs @@ -3,7 +3,7 @@ namespace Speckle.Converters.Autocad.ToSpeckle.Raw; -public class PointToSpeckleRawConverter : IRawConversion +public class PointToSpeckleRawConverter : ITypedConverter { private readonly IConversionContextStack _contextStack; @@ -12,6 +12,5 @@ public PointToSpeckleRawConverter(IConversionContextStack - new(target.X, target.Y, target.Z, _contextStack.Current.SpeckleUnits); + public SOG.Point Convert(AG.Point3d target) => new(target.X, target.Y, target.Z, _contextStack.Current.SpeckleUnits); } diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Raw/VectorToSpeckleRawConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Raw/VectorToSpeckleRawConverter.cs index 770e24cf69..2eca1149e5 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Raw/VectorToSpeckleRawConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Raw/VectorToSpeckleRawConverter.cs @@ -3,7 +3,7 @@ namespace Speckle.Converters.Autocad.ToSpeckle.Raw; -public class VectorToSpeckleRawConverter : IRawConversion +public class VectorToSpeckleRawConverter : ITypedConverter { private readonly IConversionContextStack _contextStack; @@ -12,6 +12,6 @@ public VectorToSpeckleRawConverter(IConversionContextStack + public SOG.Vector Convert(AG.Vector3d target) => new(target.X, target.Y, target.Z, _contextStack.Current.SpeckleUnits); } diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/RevitConverterModule.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/RevitConverterModule.cs index e7cf89a01f..d4e6d197ac 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/RevitConverterModule.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/RevitConverterModule.cs @@ -13,10 +13,8 @@ public class RevitConverterModule : ISpeckleModule { public void Load(SpeckleContainerBuilder builder) { - builder.AddConverterCommon(); + builder.AddConverterCommon(); builder.AddSingleton(new RevitContext()); - // most things should be InstancePerLifetimeScope so we get one per operation - builder.AddScoped(); // POC: do we need ToSpeckleScalingService as is, do we need to interface it out? builder.AddScoped(); @@ -24,8 +22,6 @@ public void Load(SpeckleContainerBuilder builder) // POC: the concrete type can come out if we remove all the reference to it builder.AddScoped(); - builder.AddScoped, RevitToSpeckleUnitConverter>(); - builder.AddScoped(); builder.AddScoped(); diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/DisplayValueExtractor.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/DisplayValueExtractor.cs index c2c5890b5f..3a9fdb33de 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/DisplayValueExtractor.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/DisplayValueExtractor.cs @@ -6,10 +6,10 @@ namespace Speckle.Converters.RevitShared.Helpers; // POC: needs breaking down https://spockle.atlassian.net/browse/CNX-9354 public sealed class DisplayValueExtractor { - private readonly IRawConversion>, List> _meshByMaterialConverter; + private readonly ITypedConverter>, List> _meshByMaterialConverter; public DisplayValueExtractor( - IRawConversion>, List> meshByMaterialConverter + ITypedConverter>, List> meshByMaterialConverter ) { _meshByMaterialConverter = meshByMaterialConverter; @@ -39,7 +39,7 @@ public DisplayValueExtractor( var meshesByMaterial = GetMeshesByMaterial(meshes, solids); - return _meshByMaterialConverter.RawConvert(meshesByMaterial); + return _meshByMaterialConverter.Convert(meshesByMaterial); } private static Dictionary> GetMeshesByMaterial( diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/ParameterObjectAssigner.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/ParameterObjectAssigner.cs index e5fa30d136..2c4f3b2112 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/ParameterObjectAssigner.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/ParameterObjectAssigner.cs @@ -10,11 +10,11 @@ namespace Speckle.Converters.RevitShared.Helpers; // did it go away? public sealed class ParameterObjectAssigner { - private readonly IRawConversion _paramConverter; + private readonly ITypedConverter _paramConverter; private readonly ParameterValueExtractor _parameterValueExtractor; public ParameterObjectAssigner( - IRawConversion paramConverter, + ITypedConverter paramConverter, ParameterValueExtractor parameterValueExtractor ) { @@ -56,7 +56,7 @@ private void AssignSpeckleParamToBaseObject( { try { - SOBR.Parameter speckleParam = _paramConverter.RawConvert(kv.Value); + SOBR.Parameter speckleParam = _paramConverter.Convert(kv.Value); speckleParam.isTypeParameter = isTypeParameter; paramBase[kv.Key] = speckleParam; } diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/SlopeArrowExtractor.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/SlopeArrowExtractor.cs index cd75314874..9db6d14583 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/SlopeArrowExtractor.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/SlopeArrowExtractor.cs @@ -4,11 +4,11 @@ namespace Speckle.Converters.RevitShared.Helpers; public class SlopeArrowExtractor : ISlopeArrowExtractor { - private readonly IRawConversion _pointConverter; + private readonly ITypedConverter _pointConverter; private readonly ParameterValueExtractor _parameterValueExtractor; public SlopeArrowExtractor( - IRawConversion pointConverter, + ITypedConverter pointConverter, ParameterValueExtractor parameterValueExtractor ) { @@ -48,12 +48,12 @@ ParameterValueExtractor parameterValueExtractor public SOG.Point GetSlopeArrowHead(DB.ModelLine slopeArrow) { - return _pointConverter.RawConvert(((DB.LocationCurve)slopeArrow.Location).Curve.GetEndPoint(1)); + return _pointConverter.Convert(((DB.LocationCurve)slopeArrow.Location).Curve.GetEndPoint(1)); } public SOG.Point GetSlopeArrowTail(DB.ModelLine slopeArrow) { - return _pointConverter.RawConvert(((DB.LocationCurve)slopeArrow.Location).Curve.GetEndPoint(0)); + return _pointConverter.Convert(((DB.LocationCurve)slopeArrow.Location).Curve.GetEndPoint(0)); } public double GetSlopeArrowTailOffset(DB.ModelLine slopeArrow) diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/BeamConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/BeamConversionToSpeckle.cs index 1bc69a941b..d6ee746e43 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/BeamConversionToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/BeamConversionToSpeckle.cs @@ -10,17 +10,17 @@ namespace Speckle.Converters.RevitShared.ToSpeckle; // This will definitely explode if we tried. Goes back to the `CanConvert` functionality conversation. // As-is, what we are saying is that it can take "any Family Instance" and turn it into a Speckle.RevitBeam, which is far from correct. // CNX-9312 -public class BeamConversionToSpeckle : IRawConversion +public class BeamConversionToSpeckle : ITypedConverter { - private readonly IRawConversion _locationConverter; - private readonly IRawConversion _levelConverter; + private readonly ITypedConverter _locationConverter; + private readonly ITypedConverter _levelConverter; private readonly ParameterValueExtractor _parameterValueExtractor; private readonly DisplayValueExtractor _displayValueExtractor; private readonly ParameterObjectAssigner _parameterObjectAssigner; public BeamConversionToSpeckle( - IRawConversion locationConverter, - IRawConversion levelConverter, + ITypedConverter locationConverter, + ITypedConverter levelConverter, ParameterValueExtractor parameterValueExtractor, DisplayValueExtractor displayValueExtractor, ParameterObjectAssigner parameterObjectAssigner @@ -33,9 +33,9 @@ ParameterObjectAssigner parameterObjectAssigner _parameterObjectAssigner = parameterObjectAssigner; } - public SOBR.RevitBeam RawConvert(DB.FamilyInstance target) + public SOBR.RevitBeam Convert(DB.FamilyInstance target) { - var baseGeometry = _locationConverter.RawConvert(target.Location); + var baseGeometry = _locationConverter.Convert(target.Location); if (baseGeometry is not ICurve baseCurve) { throw new SpeckleConversionException( @@ -56,7 +56,7 @@ public SOBR.RevitBeam RawConvert(DB.FamilyInstance target) target, DB.BuiltInParameter.INSTANCE_REFERENCE_LEVEL_PARAM ); - speckleBeam.level = _levelConverter.RawConvert(level); + speckleBeam.level = _levelConverter.Convert(level); speckleBeam.displayValue = _displayValueExtractor.GetDisplayValue(target); diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/BoundarySegmentConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/BoundarySegmentConversionToSpeckle.cs index faebfe4a2b..8f02d4c345 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/BoundarySegmentConversionToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/BoundarySegmentConversionToSpeckle.cs @@ -3,16 +3,16 @@ namespace Speckle.Converters.RevitShared.ToSpeckle; -public class BoundarySegmentConversionToSpeckle : IRawConversion, SOG.Polycurve> +public class BoundarySegmentConversionToSpeckle : ITypedConverter, SOG.Polycurve> { - private readonly IRawConversion _curveConverter; + private readonly ITypedConverter _curveConverter; - public BoundarySegmentConversionToSpeckle(IRawConversion curveConverter) + public BoundarySegmentConversionToSpeckle(ITypedConverter curveConverter) { _curveConverter = curveConverter; } - public SOG.Polycurve RawConvert(IList target) + public SOG.Polycurve Convert(IList target) { if (target.Count == 0) { @@ -23,7 +23,7 @@ public SOG.Polycurve RawConvert(IList target) foreach (var segment in target) { DB.Curve revitCurve = segment.GetCurve(); - var curve = _curveConverter.RawConvert(revitCurve); + var curve = _curveConverter.Convert(revitCurve); // POC: We used to attach the `elementID` of every curve in a PolyCurve as a dynamic property. // We've removed this as it seemed unnecessary. diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/BraceToSpeckleConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/BraceToSpeckleConverter.cs index b82ffa2a66..ccae249fe5 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/BraceToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/BraceToSpeckleConverter.cs @@ -7,22 +7,22 @@ namespace Speckle.Converters.RevitShared.ToSpeckle; // This will definitely explode if we tried. Goes back to the `CanConvert` functionality conversation. // As-is, what we are saying is that it can take "any Family Instance" and turn it into a Speckle.RevitBeam, which is far from correct. // CNX-9312 -public class BraceToSpeckleConverter : IRawConversion +public class BraceToSpeckleConverter : ITypedConverter { - private readonly IRawConversion _beamConverter; + private readonly ITypedConverter _beamConverter; - public BraceToSpeckleConverter(IRawConversion beamConverter) + public BraceToSpeckleConverter(ITypedConverter beamConverter) { _beamConverter = beamConverter; } - public SOBR.RevitBrace RawConvert(DB.FamilyInstance target) + public SOBR.RevitBrace Convert(DB.FamilyInstance target) { // POC: we might want some easy one-liner here to FamilyMatchesOrThrow(target, DB.Structure.StructuralType.Brace) or similar - // and added in each RawConvert + // and added in each Convert // POC: this and the beam lost the notes we were returning, though this seems against even the original pattern - var beam = _beamConverter.RawConvert(target); + var beam = _beamConverter.Convert(target); var brace = new SOBR.RevitBrace() { diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ColumnConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ColumnConversionToSpeckle.cs index f50bea3ec5..3c5b738aa9 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ColumnConversionToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ColumnConversionToSpeckle.cs @@ -10,18 +10,18 @@ namespace Speckle.Converters.RevitShared.ToSpeckle; // POC: There is no validation on this converter to prevent conversion from "not a Revit Beam" to a Speckle Beam. // This will definitely explode if we tried. Goes back to the `CanConvert` functionality conversation. -public class ColumnConversionToSpeckle : IRawConversion +public class ColumnConversionToSpeckle : ITypedConverter { - private readonly IRawConversion _locationConverter; - private readonly IRawConversion _levelConverter; + private readonly ITypedConverter _locationConverter; + private readonly ITypedConverter _levelConverter; private readonly ParameterValueExtractor _parameterValueExtractor; private readonly DisplayValueExtractor _displayValueExtractor; private readonly IRevitConversionContextStack _contextStack; private readonly ParameterObjectAssigner _parameterObjectAssigner; public ColumnConversionToSpeckle( - IRawConversion locationConverter, - IRawConversion levelConverter, + ITypedConverter locationConverter, + ITypedConverter levelConverter, ParameterValueExtractor parameterValueExtractor, DisplayValueExtractor displayValueExtractor, IRevitConversionContextStack contextStack, @@ -36,7 +36,7 @@ ParameterObjectAssigner parameterObjectAssigner _parameterObjectAssigner = parameterObjectAssigner; } - public RevitColumn RawConvert(DB.FamilyInstance target) + public RevitColumn Convert(DB.FamilyInstance target) { FamilySymbol symbol = (FamilySymbol)target.Document.GetElement(target.GetTypeId()); @@ -47,14 +47,14 @@ public RevitColumn RawConvert(DB.FamilyInstance target) target, BuiltInParameter.FAMILY_BASE_LEVEL_PARAM ); - speckleColumn.level = _levelConverter.RawConvert(level); + speckleColumn.level = _levelConverter.Convert(level); Level topLevel = _parameterValueExtractor.GetValueAsDocumentObject( target, BuiltInParameter.FAMILY_TOP_LEVEL_PARAM ); - speckleColumn.topLevel = _levelConverter.RawConvert(topLevel); + speckleColumn.topLevel = _levelConverter.Convert(topLevel); speckleColumn.baseOffset = _parameterValueExtractor.GetValueAsDouble( target, DB.BuiltInParameter.FAMILY_BASE_LEVEL_OFFSET_PARAM @@ -87,7 +87,7 @@ public RevitColumn RawConvert(DB.FamilyInstance target) private ICurve? GetBaseCurve(DB.FamilyInstance target, double topLevelElevation, double topLevelOffset) { - Base baseGeometry = _locationConverter.RawConvert(target.Location); + Base baseGeometry = _locationConverter.Convert(target.Location); ICurve? baseCurve = baseGeometry as ICurve; if (baseGeometry is ICurve) diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/ArcToSpeckleConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/ArcToSpeckleConverter.cs index d6d1119312..d6774a710b 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/ArcToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/ArcToSpeckleConverter.cs @@ -5,17 +5,17 @@ namespace Speckle.Converters.RevitShared.ToSpeckle; -public class ArcToSpeckleConverter : IRawConversion +public class ArcToSpeckleConverter : ITypedConverter { private readonly IRevitConversionContextStack _contextStack; - private readonly IRawConversion _xyzToPointConverter; - private readonly IRawConversion _planeConverter; + private readonly ITypedConverter _xyzToPointConverter; + private readonly ITypedConverter _planeConverter; private readonly ScalingServiceToSpeckle _scalingService; public ArcToSpeckleConverter( IRevitConversionContextStack contextStack, - IRawConversion xyzToPointConverter, - IRawConversion planeConverter, + ITypedConverter xyzToPointConverter, + ITypedConverter planeConverter, ScalingServiceToSpeckle scalingService ) { @@ -25,7 +25,7 @@ ScalingServiceToSpeckle scalingService _scalingService = scalingService; } - public SOG.Arc RawConvert(DB.Arc target) + public SOG.Arc Convert(DB.Arc target) { // see https://forums.autodesk.com/t5/revit-api-forum/how-to-retrieve-startangle-and-endangle-of-arc-object/td-p/7637128 var arcPlane = DB.Plane.CreateByOriginAndBasis(target.Center, target.XDirection, target.YDirection); @@ -43,15 +43,15 @@ public SOG.Arc RawConvert(DB.Arc target) return new SOG.Arc() { - plane = _planeConverter.RawConvert(arcPlane), + plane = _planeConverter.Convert(arcPlane), radius = _scalingService.ScaleLength(target.Radius), startAngle = startAngle, endAngle = endAngle, angleRadians = endAngle - startAngle, units = _contextStack.Current.SpeckleUnits, - endPoint = _xyzToPointConverter.RawConvert(end), - startPoint = _xyzToPointConverter.RawConvert(start), - midPoint = _xyzToPointConverter.RawConvert(mid), + endPoint = _xyzToPointConverter.Convert(end), + startPoint = _xyzToPointConverter.Convert(start), + midPoint = _xyzToPointConverter.Convert(mid), length = _scalingService.ScaleLength(target.Length), domain = new Interval(target.GetEndParameter(0), target.GetEndParameter(1)) }; diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/BoundingBoxXYZToSpeckleConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/BoundingBoxXYZToSpeckleConverter.cs index 6117a58d45..a891579ad5 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/BoundingBoxXYZToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/BoundingBoxXYZToSpeckleConverter.cs @@ -4,16 +4,16 @@ namespace Speckle.Converters.RevitShared.ToSpeckle; -public class BoundingBoxXYZToSpeckleConverter : IRawConversion +public class BoundingBoxXYZToSpeckleConverter : ITypedConverter { private readonly IRevitConversionContextStack _contextStack; - private readonly IRawConversion _xyzToPointConverter; - private readonly IRawConversion _planeConverter; + private readonly ITypedConverter _xyzToPointConverter; + private readonly ITypedConverter _planeConverter; public BoundingBoxXYZToSpeckleConverter( IRevitConversionContextStack contextStack, - IRawConversion xyzToPointConverter, - IRawConversion planeConverter + ITypedConverter xyzToPointConverter, + ITypedConverter planeConverter ) { _contextStack = contextStack; @@ -21,11 +21,11 @@ public BoundingBoxXYZToSpeckleConverter( _planeConverter = planeConverter; } - public SOG.Box RawConvert(DB.BoundingBoxXYZ target) + public SOG.Box Convert(DB.BoundingBoxXYZ target) { // convert min and max pts to speckle first - var min = _xyzToPointConverter.RawConvert(target.Min); - var max = _xyzToPointConverter.RawConvert(target.Max); + var min = _xyzToPointConverter.Convert(target.Min); + var max = _xyzToPointConverter.Convert(target.Max); // get the base plane of the bounding box from the transform var transform = target.Transform; @@ -40,7 +40,7 @@ public SOG.Box RawConvert(DB.BoundingBoxXYZ target) xSize = new Interval(min.x, max.x), ySize = new Interval(min.y, max.y), zSize = new Interval(min.z, max.z), - basePlane = _planeConverter.RawConvert(plane), + basePlane = _planeConverter.Convert(plane), units = _contextStack.Current.SpeckleUnits }; diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/CircleToSpeckleConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/CircleToSpeckleConverter.cs index cd37f03088..7abdc08cfc 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/CircleToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/CircleToSpeckleConverter.cs @@ -4,15 +4,15 @@ namespace Speckle.Converters.RevitShared.ToSpeckle; -public class CircleToSpeckleConverter : IRawConversion +public class CircleToSpeckleConverter : ITypedConverter { private readonly IRevitConversionContextStack _contextStack; - private readonly IRawConversion _planeConverter; + private readonly ITypedConverter _planeConverter; private readonly ScalingServiceToSpeckle _scalingService; public CircleToSpeckleConverter( IRevitConversionContextStack contextStack, - IRawConversion planeConverter, + ITypedConverter planeConverter, ScalingServiceToSpeckle scalingService ) { @@ -21,7 +21,7 @@ ScalingServiceToSpeckle scalingService _scalingService = scalingService; } - public SOG.Circle RawConvert(DB.Arc target) + public SOG.Circle Convert(DB.Arc target) { // POC: should we check for arc of 360 and throw? Original CircleToSpeckle did not do this. @@ -29,7 +29,7 @@ public SOG.Circle RawConvert(DB.Arc target) var arcPlane = DB.Plane.CreateByNormalAndOrigin(target.Normal, target.Center); var c = new SOG.Circle() { - plane = _planeConverter.RawConvert(arcPlane), + plane = _planeConverter.Convert(arcPlane), radius = _scalingService.ScaleLength(target.Radius), units = _contextStack.Current.SpeckleUnits, length = _scalingService.ScaleLength(target.Length) diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/CurveArrArrayToSpecklePolycurveConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/CurveArrArrayToSpecklePolycurveConverter.cs index 6cba92f9cd..4644bc1435 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/CurveArrArrayToSpecklePolycurveConverter.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/CurveArrArrayToSpecklePolycurveConverter.cs @@ -4,21 +4,21 @@ namespace Speckle.Converters.RevitShared.Raw; -internal sealed class CurveArrArrayToSpecklePolycurveConverter : IRawConversion> +internal sealed class CurveArrArrayToSpecklePolycurveConverter : ITypedConverter> { - private readonly IRawConversion _curveArrayConverter; + private readonly ITypedConverter _curveArrayConverter; - public CurveArrArrayToSpecklePolycurveConverter(IRawConversion curveArrayConverter) + public CurveArrArrayToSpecklePolycurveConverter(ITypedConverter curveArrayConverter) { _curveArrayConverter = curveArrayConverter; } - public List RawConvert(CurveArrArray target) + public List Convert(CurveArrArray target) { List polycurves = new(); foreach (var curveArray in GetCurveArrays(target)) { - polycurves.Add(_curveArrayConverter.RawConvert(curveArray)); + polycurves.Add(_curveArrayConverter.Convert(curveArray)); } return polycurves; diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/CurveArrayConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/CurveArrayConversionToSpeckle.cs index 327be89dbf..8ec80fe9f7 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/CurveArrayConversionToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/CurveArrayConversionToSpeckle.cs @@ -7,16 +7,16 @@ namespace Speckle.Converters.RevitShared.ToSpeckle; -public sealed class CurveArrayConversionToSpeckle : IRawConversion +public sealed class CurveArrayConversionToSpeckle : ITypedConverter { private readonly IRevitConversionContextStack _contextStack; private readonly ScalingServiceToSpeckle _scalingService; - private readonly IRawConversion _curveConverter; + private readonly ITypedConverter _curveConverter; public CurveArrayConversionToSpeckle( IRevitConversionContextStack contextStack, ScalingServiceToSpeckle scalingService, - IRawConversion curveConverter + ITypedConverter curveConverter ) { _contextStack = contextStack; @@ -24,7 +24,7 @@ public CurveArrayConversionToSpeckle( _curveConverter = curveConverter; } - public Polycurve RawConvert(CurveArray target) + public Polycurve Convert(CurveArray target) { List curves = target.Cast().ToList(); @@ -34,7 +34,7 @@ public Polycurve RawConvert(CurveArray target) closed = curves.First().GetEndPoint(0).DistanceTo(curves.Last().GetEndPoint(1)) < RevitConversionContextStack.TOLERANCE, length = _scalingService.ScaleLength(curves.Sum(x => x.Length)), - segments = curves.Select(x => _curveConverter.RawConvert(x)).ToList() + segments = curves.Select(x => _curveConverter.Convert(x)).ToList() }; } } diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/CurveConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/CurveConversionToSpeckle.cs index ec60b6e0ac..0b034a779c 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/CurveConversionToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/CurveConversionToSpeckle.cs @@ -4,22 +4,22 @@ namespace Speckle.Converters.RevitShared.ToSpeckle; -public class CurveConversionToSpeckle : IRawConversion +public class CurveConversionToSpeckle : ITypedConverter { - private readonly IRawConversion _lineConverter; - private readonly IRawConversion _arcConverter; - private readonly IRawConversion _circleConverter; - private readonly IRawConversion _ellipseConverter; - private readonly IRawConversion _nurbsConverter; - private readonly IRawConversion _hermiteConverter; // POC: should this be ICurve? + private readonly ITypedConverter _lineConverter; + private readonly ITypedConverter _arcConverter; + private readonly ITypedConverter _circleConverter; + private readonly ITypedConverter _ellipseConverter; + private readonly ITypedConverter _nurbsConverter; + private readonly ITypedConverter _hermiteConverter; // POC: should this be ICurve? public CurveConversionToSpeckle( - IRawConversion lineConverter, - IRawConversion arcConverter, - IRawConversion circleConverter, - IRawConversion ellipseConverter, - IRawConversion nurbsConverter, - IRawConversion hermiteConverter + ITypedConverter lineConverter, + ITypedConverter arcConverter, + ITypedConverter circleConverter, + ITypedConverter ellipseConverter, + ITypedConverter nurbsConverter, + ITypedConverter hermiteConverter ) { _lineConverter = lineConverter; @@ -30,16 +30,16 @@ public CurveConversionToSpeckle( _hermiteConverter = hermiteConverter; } - public ICurve RawConvert(DB.Curve target) + public ICurve Convert(DB.Curve target) { return target switch { - DB.Line line => _lineConverter.RawConvert(line), + DB.Line line => _lineConverter.Convert(line), // POC: are maybe arc.IsCyclic ? - DB.Arc arc => arc.IsClosed ? _circleConverter.RawConvert(arc) : _arcConverter.RawConvert(arc), - DB.Ellipse ellipse => _ellipseConverter.RawConvert(ellipse), - DB.NurbSpline nurbs => _nurbsConverter.RawConvert(nurbs), - DB.HermiteSpline hermite => _hermiteConverter.RawConvert(hermite), + DB.Arc arc => arc.IsClosed ? _circleConverter.Convert(arc) : _arcConverter.Convert(arc), + DB.Ellipse ellipse => _ellipseConverter.Convert(ellipse), + DB.NurbSpline nurbs => _nurbsConverter.Convert(nurbs), + DB.HermiteSpline hermite => _hermiteConverter.Convert(hermite), _ => throw new SpeckleConversionException($"Unsupported curve type {target.GetType()}") }; diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/EllipseToSpeckleConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/EllipseToSpeckleConverter.cs index e41d373c4e..96ca62f8f1 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/EllipseToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/EllipseToSpeckleConverter.cs @@ -5,15 +5,15 @@ namespace Speckle.Converters.RevitShared.ToSpeckle; -public class EllipseToSpeckleConverter : IRawConversion +public class EllipseToSpeckleConverter : ITypedConverter { private readonly IRevitConversionContextStack _contextStack; - private readonly IRawConversion _planeConverter; + private readonly ITypedConverter _planeConverter; private readonly ScalingServiceToSpeckle _scalingService; public EllipseToSpeckleConverter( IRevitConversionContextStack contextStack, - IRawConversion planeConverter, + ITypedConverter planeConverter, ScalingServiceToSpeckle scalingService ) { @@ -22,7 +22,7 @@ ScalingServiceToSpeckle scalingService _scalingService = scalingService; } - public SOG.Ellipse RawConvert(DB.Ellipse target) + public SOG.Ellipse Convert(DB.Ellipse target) { using (DB.Plane basePlane = DB.Plane.CreateByOriginAndBasis(target.Center, target.XDirection, target.YDirection)) { @@ -30,7 +30,7 @@ public SOG.Ellipse RawConvert(DB.Ellipse target) return new SOG.Ellipse() { - plane = _planeConverter.RawConvert(basePlane), + plane = _planeConverter.Convert(basePlane), // POC: scale length correct? seems right? firstRadius = _scalingService.ScaleLength(target.RadiusX), secondRadius = _scalingService.ScaleLength(target.RadiusY), diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/HermiteSplineToSpeckleConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/HermiteSplineToSpeckleConverter.cs index a25569a03e..5aa2a07ed2 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/HermiteSplineToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/HermiteSplineToSpeckleConverter.cs @@ -2,18 +2,18 @@ namespace Speckle.Converters.RevitShared.ToSpeckle; -public class HerminteSplitToSpeckleConverter : IRawConversion +public class HerminteSplitToSpeckleConverter : ITypedConverter { - private readonly IRawConversion _splineConverter; + private readonly ITypedConverter _splineConverter; - public HerminteSplitToSpeckleConverter(IRawConversion splineConverter) + public HerminteSplitToSpeckleConverter(ITypedConverter splineConverter) { _splineConverter = splineConverter; } - public SOG.Curve RawConvert(DB.HermiteSpline target) + public SOG.Curve Convert(DB.HermiteSpline target) { var nurbs = DB.NurbSpline.Create(target); - return _splineConverter.RawConvert(nurbs); + return _splineConverter.Convert(nurbs); } } diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/LineConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/LineConversionToSpeckle.cs index fd00f57360..2405cf0b22 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/LineConversionToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/LineConversionToSpeckle.cs @@ -5,15 +5,15 @@ namespace Speckle.Converters.RevitShared.ToSpeckle; -public class LineConversionToSpeckle : IRawConversion +public class LineConversionToSpeckle : ITypedConverter { private readonly IRevitConversionContextStack _contextStack; - private readonly IRawConversion _xyzToPointConverter; + private readonly ITypedConverter _xyzToPointConverter; private readonly ScalingServiceToSpeckle _scalingService; public LineConversionToSpeckle( IRevitConversionContextStack contextStack, - IRawConversion xyzToPointConverter, + ITypedConverter xyzToPointConverter, ScalingServiceToSpeckle scalingService ) { @@ -22,12 +22,12 @@ ScalingServiceToSpeckle scalingService _scalingService = scalingService; } - public SOG.Line RawConvert(DB.Line target) => + public SOG.Line Convert(DB.Line target) => new() { units = _contextStack.Current.SpeckleUnits, - start = _xyzToPointConverter.RawConvert(target.GetEndPoint(0)), - end = _xyzToPointConverter.RawConvert(target.GetEndPoint(1)), + start = _xyzToPointConverter.Convert(target.GetEndPoint(0)), + end = _xyzToPointConverter.Convert(target.GetEndPoint(1)), domain = new Interval(target.GetEndParameter(0), target.GetEndParameter(1)), length = _scalingService.ScaleLength(target.Length) }; diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/MeshByMaterialDictionaryToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/MeshByMaterialDictionaryToSpeckle.cs index f9d7d760df..29b0bd9f98 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/MeshByMaterialDictionaryToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/MeshByMaterialDictionaryToSpeckle.cs @@ -4,16 +4,17 @@ namespace Speckle.Converters.RevitShared.ToSpeckle; -public class MeshByMaterialDictionaryToSpeckle : IRawConversion>, List> +public class MeshByMaterialDictionaryToSpeckle + : ITypedConverter>, List> { private readonly IRevitConversionContextStack _contextStack; - private readonly IRawConversion _xyzToPointConverter; - private readonly IRawConversion _materialConverter; + private readonly ITypedConverter _xyzToPointConverter; + private readonly ITypedConverter _materialConverter; public MeshByMaterialDictionaryToSpeckle( - IRawConversion materialConverter, + ITypedConverter materialConverter, IRevitConversionContextStack contextStack, - IRawConversion xyzToPointConverter + ITypedConverter xyzToPointConverter ) { _materialConverter = materialConverter; @@ -34,7 +35,7 @@ public MeshByMaterialDictionaryToSpeckle( /// Also note that, for each unique material, the method tries to retrieve the related DB.Material from the current document and convert it. If the conversion is successful, /// the material is added to the corresponding Speckle mesh. If the conversion fails, the operation simply continues without the material. /// - public List RawConvert(Dictionary> target) + public List Convert(Dictionary> target) { var result = new List(target.Keys.Count); @@ -56,7 +57,7 @@ public MeshByMaterialDictionaryToSpeckle( var doc = _contextStack.Current.Document; if (doc.GetElement(materialId) is DB.Material material) { - speckleMesh["renderMaterial"] = _materialConverter.RawConvert(material); + speckleMesh["renderMaterial"] = _materialConverter.Convert(material); } // Append the revit mesh data to the speckle mesh @@ -77,7 +78,7 @@ private void AppendToSpeckleMesh(DB.Mesh mesh, SOG.Mesh speckleMesh) foreach (var vert in mesh.Vertices) { - var (x, y, z) = _xyzToPointConverter.RawConvert(vert); + var (x, y, z) = _xyzToPointConverter.Convert(vert); speckleMesh.vertices.Add(x); speckleMesh.vertices.Add(y); speckleMesh.vertices.Add(z); diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/MeshConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/MeshConversionToSpeckle.cs index 635537ea78..2f6c494ba0 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/MeshConversionToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/MeshConversionToSpeckle.cs @@ -4,16 +4,16 @@ namespace Speckle.Converters.RevitShared.ToSpeckle; -public class MeshConversionToSpeckle : IRawConversion +public class MeshConversionToSpeckle : ITypedConverter { - private readonly IRawConversion _xyzToPointConverter; - private readonly IRawConversion _materialConverter; + private readonly ITypedConverter _xyzToPointConverter; + private readonly ITypedConverter _materialConverter; private readonly IRevitConversionContextStack _contextStack; public MeshConversionToSpeckle( IRevitConversionContextStack contextStack, - IRawConversion xyzToPointConverter, - IRawConversion materialConverter + ITypedConverter xyzToPointConverter, + ITypedConverter materialConverter ) { _contextStack = contextStack; @@ -21,7 +21,7 @@ public MeshConversionToSpeckle( _materialConverter = materialConverter; } - public SOG.Mesh RawConvert(DB.Mesh target) + public SOG.Mesh Convert(DB.Mesh target) { var doc = _contextStack.Current.Document; @@ -31,7 +31,7 @@ public SOG.Mesh RawConvert(DB.Mesh target) RenderMaterial? speckleMaterial = null; if (doc.GetElement(target.MaterialElementId) is DB.Material revitMaterial) { - speckleMaterial = _materialConverter.RawConvert(revitMaterial); + speckleMaterial = _materialConverter.Convert(revitMaterial); } return new SOG.Mesh(vertices, faces, units: _contextStack.Current.SpeckleUnits) @@ -46,7 +46,7 @@ private List GetSpeckleMeshVertexData(DB.Mesh target) foreach (var vert in target.Vertices) { - vertices.AddRange(_xyzToPointConverter.RawConvert(vert).ToList()); + vertices.AddRange(_xyzToPointConverter.Convert(vert).ToList()); } return vertices; diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/NurbsSplineToSpeckleConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/NurbsSplineToSpeckleConverter.cs index 8a8015b6de..7229f639e3 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/NurbsSplineToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/NurbsSplineToSpeckleConverter.cs @@ -5,17 +5,17 @@ namespace Speckle.Converters.RevitShared.ToSpeckle; -public class NurbsSplineToSpeckleConverter : IRawConversion +public class NurbsSplineToSpeckleConverter : ITypedConverter { private readonly IRevitVersionConversionHelper _conversionHelper; private readonly IRevitConversionContextStack _contextStack; - private readonly IRawConversion _xyzToPointConverter; + private readonly ITypedConverter _xyzToPointConverter; private readonly ScalingServiceToSpeckle _scalingService; public NurbsSplineToSpeckleConverter( IRevitVersionConversionHelper conversionHelper, IRevitConversionContextStack contextStack, - IRawConversion xyzToPointConverter, + ITypedConverter xyzToPointConverter, ScalingServiceToSpeckle scalingService ) { @@ -25,18 +25,18 @@ ScalingServiceToSpeckle scalingService _scalingService = scalingService; } - public SOG.Curve RawConvert(DB.NurbSpline target) + public SOG.Curve Convert(DB.NurbSpline target) { var units = _contextStack.Current.SpeckleUnits; var points = new List(); foreach (var p in target.CtrlPoints) { - var point = _xyzToPointConverter.RawConvert(p); + var point = _xyzToPointConverter.Convert(p); points.AddRange(new List { point.x, point.y, point.z }); } - var coords = target.Tessellate().SelectMany(xyz => _xyzToPointConverter.RawConvert(xyz).ToList()).ToList(); + var coords = target.Tessellate().SelectMany(xyz => _xyzToPointConverter.Convert(xyz).ToList()).ToList(); return new SOG.Curve() { diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/PlaneToSpeckleConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/PlaneToSpeckleConverter.cs index 82fb38a004..27cef7bab6 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/PlaneToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/PlaneToSpeckleConverter.cs @@ -3,16 +3,16 @@ namespace Speckle.Converters.RevitShared.ToSpeckle; -public class PlaneToSpeckleConverter : IRawConversion +public class PlaneToSpeckleConverter : ITypedConverter { private readonly IRevitConversionContextStack _contextStack; - private readonly IRawConversion _xyzToPointConverter; - private readonly IRawConversion _xyzToVectorConverter; + private readonly ITypedConverter _xyzToPointConverter; + private readonly ITypedConverter _xyzToVectorConverter; public PlaneToSpeckleConverter( IRevitConversionContextStack contextStack, - IRawConversion xyzToPointConverter, - IRawConversion xyzToVectorConverter + ITypedConverter xyzToPointConverter, + ITypedConverter xyzToVectorConverter ) { _contextStack = contextStack; @@ -20,12 +20,12 @@ public PlaneToSpeckleConverter( _xyzToVectorConverter = xyzToVectorConverter; } - public SOG.Plane RawConvert(DB.Plane target) + public SOG.Plane Convert(DB.Plane target) { - var origin = _xyzToPointConverter.RawConvert(target.Origin); - var normal = _xyzToVectorConverter.RawConvert(target.Normal); - var xdir = _xyzToVectorConverter.RawConvert(target.XVec); - var ydir = _xyzToVectorConverter.RawConvert(target.YVec); + var origin = _xyzToPointConverter.Convert(target.Origin); + var normal = _xyzToVectorConverter.Convert(target.Normal); + var xdir = _xyzToVectorConverter.Convert(target.XVec); + var ydir = _xyzToVectorConverter.Convert(target.YVec); return new SOG.Plane(origin, normal, xdir, ydir, _contextStack.Current.SpeckleUnits); } diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/PointCloudToSpeckleConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/PointCloudToSpeckleConverter.cs index 9f20289b53..ab86301cd2 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/PointCloudToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/PointCloudToSpeckleConverter.cs @@ -3,16 +3,16 @@ namespace Speckle.Converters.RevitShared.ToSpeckle; -public class PointCloudToSpeckleConverter : IRawConversion +public class PointCloudToSpeckleConverter : ITypedConverter { private readonly IRevitConversionContextStack _contextStack; - private readonly IRawConversion _xyzToPointConverter; - private readonly IRawConversion _boundingBoxConverter; + private readonly ITypedConverter _xyzToPointConverter; + private readonly ITypedConverter _boundingBoxConverter; public PointCloudToSpeckleConverter( IRevitConversionContextStack contextStack, - IRawConversion xyzToPointConverter, - IRawConversion boundingBoxConverter + ITypedConverter xyzToPointConverter, + ITypedConverter boundingBoxConverter ) { _contextStack = contextStack; @@ -20,7 +20,7 @@ public PointCloudToSpeckleConverter( _boundingBoxConverter = boundingBoxConverter; } - public SOG.Pointcloud RawConvert(DB.PointCloudInstance target) + public SOG.Pointcloud Convert(DB.PointCloudInstance target) { var boundingBox = target.get_BoundingBox(null); using DB.Transform transform = target.GetTransform(); @@ -33,12 +33,12 @@ public SOG.Pointcloud RawConvert(DB.PointCloudInstance target) var specklePointCloud = new SOG.Pointcloud { points = points - .Select(o => _xyzToPointConverter.RawConvert(transform.OfPoint(o))) + .Select(o => _xyzToPointConverter.Convert(transform.OfPoint(o))) .SelectMany(o => new List() { o.x, o.y, o.z }) .ToList(), colors = points.Select(o => o.Color).ToList(), units = _contextStack.Current.SpeckleUnits, - bbox = _boundingBoxConverter.RawConvert(boundingBox) + bbox = _boundingBoxConverter.Convert(boundingBox) }; return specklePointCloud; diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/PointConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/PointConversionToSpeckle.cs index 349383fa43..8f6ca703db 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/PointConversionToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/PointConversionToSpeckle.cs @@ -2,14 +2,14 @@ namespace Speckle.Converters.RevitShared.ToSpeckle; -public class PointConversionToSpeckle : IRawConversion +public class PointConversionToSpeckle : ITypedConverter { - private readonly IRawConversion _xyzToPointConverter; + private readonly ITypedConverter _xyzToPointConverter; - public PointConversionToSpeckle(IRawConversion xyzToPointConverter) + public PointConversionToSpeckle(ITypedConverter xyzToPointConverter) { _xyzToPointConverter = xyzToPointConverter; } - public SOG.Point RawConvert(DB.Point target) => _xyzToPointConverter.RawConvert(target.Coord); + public SOG.Point Convert(DB.Point target) => _xyzToPointConverter.Convert(target.Coord); } diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/PolylineToSpeckleConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/PolylineToSpeckleConverter.cs index 785ee1faf7..5efb22e278 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/PolylineToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/PolylineToSpeckleConverter.cs @@ -3,23 +3,23 @@ namespace Speckle.Converters.RevitShared.ToSpeckle; -public class PolylineToSpeckleConverter : IRawConversion +public class PolylineToSpeckleConverter : ITypedConverter { private readonly IRevitConversionContextStack _contextStack; - private readonly IRawConversion _xyzToPointConverter; + private readonly ITypedConverter _xyzToPointConverter; public PolylineToSpeckleConverter( IRevitConversionContextStack contextStack, - IRawConversion xyzToPointConverter + ITypedConverter xyzToPointConverter ) { _contextStack = contextStack; _xyzToPointConverter = xyzToPointConverter; } - public SOG.Polyline RawConvert(DB.PolyLine target) + public SOG.Polyline Convert(DB.PolyLine target) { - var coords = target.GetCoordinates().SelectMany(coord => _xyzToPointConverter.RawConvert(coord).ToList()).ToList(); + var coords = target.GetCoordinates().SelectMany(coord => _xyzToPointConverter.Convert(coord).ToList()).ToList(); return new SOG.Polyline(coords, _contextStack.Current.SpeckleUnits); } } diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/VectorToSpeckleConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/VectorToSpeckleConverter.cs index e9b8d7e77a..e97cf962f4 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/VectorToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/VectorToSpeckleConverter.cs @@ -3,7 +3,7 @@ namespace Speckle.Converters.RevitShared.ToSpeckle; -public class VectorToSpeckleConverter : IRawConversion +public class VectorToSpeckleConverter : ITypedConverter { private readonly IReferencePointConverter _referencePointConverter; private readonly ScalingServiceToSpeckle _scalingService; @@ -17,7 +17,7 @@ ScalingServiceToSpeckle scalingService _scalingService = scalingService; } - public SOG.Vector RawConvert(DB.XYZ target) + public SOG.Vector Convert(DB.XYZ target) { // POC: originally had a concept of not transforming, but this was // optional arg defaulting to false - removing the argument appeared to break nothing diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/XyzConversionToPoint.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/XyzConversionToPoint.cs index 4322f45094..bf250d06c3 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/XyzConversionToPoint.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/XyzConversionToPoint.cs @@ -4,7 +4,7 @@ namespace Speckle.Converters.RevitShared.ToSpeckle; -public class XyzConversionToPoint : IRawConversion +public class XyzConversionToPoint : ITypedConverter { private readonly ScalingServiceToSpeckle _toSpeckleScalingService; private readonly IRevitConversionContextStack _contextStack; @@ -18,7 +18,7 @@ IRevitConversionContextStack contextStack _contextStack = contextStack; } - public SOG.Point RawConvert(DB.XYZ target) + public SOG.Point Convert(DB.XYZ target) { var pointToSpeckle = new SOG.Point( _toSpeckleScalingService.ScaleLength(target.X), diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/LevelConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/LevelConversionToSpeckle.cs index a47d7d6ee3..33e1d7fea2 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/LevelConversionToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/LevelConversionToSpeckle.cs @@ -3,7 +3,7 @@ namespace Speckle.Converters.RevitShared.ToSpeckle; -public class LevelConversionToSpeckle : IRawConversion +public class LevelConversionToSpeckle : ITypedConverter { private readonly ScalingServiceToSpeckle _scalingService; @@ -12,7 +12,7 @@ public LevelConversionToSpeckle(ScalingServiceToSpeckle scalingService) _scalingService = scalingService; } - public SOBR.RevitLevel RawConvert(DB.Level target) + public SOBR.RevitLevel Convert(DB.Level target) { SOBR.RevitLevel level = new() diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/LocationConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/LocationConversionToSpeckle.cs index 65692ed677..29d3378103 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/LocationConversionToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/LocationConversionToSpeckle.cs @@ -5,29 +5,29 @@ namespace Speckle.Converters.RevitShared.ToSpeckle; -public class LocationConversionToSpeckle : IRawConversion +public class LocationConversionToSpeckle : ITypedConverter { - private readonly IRawConversion _curveConverter; - private readonly IRawConversion _xyzConverter; + private readonly ITypedConverter _curveConverter; + private readonly ITypedConverter _xyzConverter; // POC: review IRawConversion which always returns a Base, this is ToSpeckle, so... this breaks // the meaning of IRawConversion, it could be IToSpeckleRawConversion // also a factory type public LocationConversionToSpeckle( - IRawConversion curveConverter, - IRawConversion xyzConverter + ITypedConverter curveConverter, + ITypedConverter xyzConverter ) { _curveConverter = curveConverter; _xyzConverter = xyzConverter; } - public Base RawConvert(DB.Location target) + public Base Convert(DB.Location target) { return target switch { - DB.LocationCurve curve => (_curveConverter.RawConvert(curve.Curve) as Base)!, // POC: ICurve and Base are not related but we know they must be, had to soft cast and then !. - DB.LocationPoint point => _xyzConverter.RawConvert(point.Point), + DB.LocationCurve curve => (_curveConverter.Convert(curve.Curve) as Base)!, // POC: ICurve and Base are not related but we know they must be, had to soft cast and then !. + DB.LocationPoint point => _xyzConverter.Convert(point.Point), _ => throw new SpeckleConversionException($"Unexpected location type {target.GetType()}") }; } diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/MaterialConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/MaterialConversionToSpeckle.cs index 5547c028d6..f7f48974f7 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/MaterialConversionToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/MaterialConversionToSpeckle.cs @@ -3,9 +3,9 @@ namespace Speckle.Converters.RevitShared.ToSpeckle; -public class MaterialConversionToSpeckle : IRawConversion +public class MaterialConversionToSpeckle : ITypedConverter { - public RenderMaterial RawConvert(DB.Material target) => + public RenderMaterial Convert(DB.Material target) => // POC: not sure we should be pulling in System.Drawing - // maybe this isn't a problem as it's part of the netstandard Fwk // ideally we'd have serialiser of our own colour class, i.e. to serialise to an uint diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ModelCurveArrArrayToSpeckleConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ModelCurveArrArrayToSpeckleConverter.cs index 0790d2767e..d294360b2d 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ModelCurveArrArrayToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ModelCurveArrArrayToSpeckleConverter.cs @@ -4,23 +4,23 @@ namespace Speckle.Converters.RevitShared.Raw; -internal sealed class ModelCurveArrArrayConverterToSpeckle : IRawConversion +internal sealed class ModelCurveArrArrayConverterToSpeckle : ITypedConverter { - private readonly IRawConversion _modelCurveArrayConverter; + private readonly ITypedConverter _modelCurveArrayConverter; - public ModelCurveArrArrayConverterToSpeckle(IRawConversion modelCurveArrayConverter) + public ModelCurveArrArrayConverterToSpeckle(ITypedConverter modelCurveArrayConverter) { _modelCurveArrayConverter = modelCurveArrayConverter; } - public SOG.Polycurve[] RawConvert(ModelCurveArrArray target) + public SOG.Polycurve[] Convert(ModelCurveArrArray target) { var polycurves = new Polycurve[target.Size]; var revitArrays = target.Cast().ToArray(); for (int i = 0; i < polycurves.Length; i++) { - polycurves[i] = _modelCurveArrayConverter.RawConvert(revitArrays[i]); + polycurves[i] = _modelCurveArrayConverter.Convert(revitArrays[i]); } return polycurves; diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ModelCurveArrayToSpeckleConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ModelCurveArrayToSpeckleConverter.cs index 50c9bfc003..5bfd4d11bb 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ModelCurveArrayToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ModelCurveArrayToSpeckleConverter.cs @@ -6,16 +6,16 @@ namespace Speckle.Converters.RevitShared.Raw; -internal sealed class ModelCurveArrayToSpeckleConverter : IRawConversion +internal sealed class ModelCurveArrayToSpeckleConverter : ITypedConverter { private readonly IRevitConversionContextStack _contextStack; private readonly ScalingServiceToSpeckle _scalingService; - private readonly IRawConversion _curveConverter; + private readonly ITypedConverter _curveConverter; public ModelCurveArrayToSpeckleConverter( IRevitConversionContextStack contextStack, ScalingServiceToSpeckle scalingService, - IRawConversion curveConverter + ITypedConverter curveConverter ) { _contextStack = contextStack; @@ -23,7 +23,7 @@ public ModelCurveArrayToSpeckleConverter( _curveConverter = curveConverter; } - public SOG.Polycurve RawConvert(DB.ModelCurveArray target) + public SOG.Polycurve Convert(DB.ModelCurveArray target) { SOG.Polycurve polycurve = new(); var curves = target.Cast().Select(mc => mc.GeometryCurve).ToArray(); @@ -39,7 +39,7 @@ public SOG.Polycurve RawConvert(DB.ModelCurveArray target) polycurve.closed = start.DistanceTo(end) < RevitConversionContextStack.TOLERANCE; polycurve.length = _scalingService.ScaleLength(curves.Sum(x => x.Length)); - polycurve.segments.AddRange(curves.Select(x => _curveConverter.RawConvert(x))); + polycurve.segments.AddRange(curves.Select(x => _curveConverter.Convert(x))); return polycurve; } diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ParameterConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ParameterConversionToSpeckle.cs index 4f58e6234b..a0b1f01da5 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ParameterConversionToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ParameterConversionToSpeckle.cs @@ -5,7 +5,7 @@ namespace Speckle.Converters.RevitShared.ToSpeckle; -public class ParameterConversionToSpeckle : IRawConversion +public class ParameterConversionToSpeckle : ITypedConverter { private readonly ParameterValueExtractor _valueExtractor; @@ -14,7 +14,7 @@ public ParameterConversionToSpeckle(ParameterValueExtractor valueExtractor) _valueExtractor = valueExtractor; } - public SOBR.Parameter RawConvert(Parameter target) + public SOBR.Parameter Convert(Parameter target) { string internalName = target.GetInternalName(); ForgeTypeId? unitTypeId = null; diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/RevitConverterToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/RevitRootToHostConverter.cs similarity index 76% rename from DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/RevitConverterToSpeckle.cs rename to DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/RevitRootToHostConverter.cs index 540cd4ccad..78790ee19e 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/RevitConverterToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/RevitRootToHostConverter.cs @@ -6,20 +6,17 @@ namespace Speckle.Converters.RevitShared; // POC: maybe possible to restrict the access so this cannot be created directly? -public class RevitConverterToSpeckle : ISpeckleConverterToSpeckle +public class RevitRootToHostConverter : IRootToSpeckleConverter { - private readonly IConverterResolver _toSpeckle; - private readonly ToSpeckleConvertedObjectsCache _convertedObjectsCache; + private readonly IConverterResolver _toSpeckle; private readonly ParameterValueExtractor _parameterValueExtractor; - public RevitConverterToSpeckle( - IConverterResolver toSpeckle, - ToSpeckleConvertedObjectsCache convertedObjectsCache, + public RevitRootToHostConverter( + IConverterResolver toSpeckle, ParameterValueExtractor parameterValueExtractor ) { _toSpeckle = toSpeckle; - _convertedObjectsCache = convertedObjectsCache; _parameterValueExtractor = parameterValueExtractor; } diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Speckle.Converters.RevitShared.projitems b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Speckle.Converters.RevitShared.projitems index f0af693909..5e5d29480e 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Speckle.Converters.RevitShared.projitems +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Speckle.Converters.RevitShared.projitems @@ -52,15 +52,15 @@ - - - + + + - - - - + + + + @@ -72,9 +72,9 @@ - - - - + + + + \ No newline at end of file diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/BaseConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/BaseTopLevelConverterToSpeckle.cs similarity index 76% rename from DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/BaseConversionToSpeckle.cs rename to DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/BaseTopLevelConverterToSpeckle.cs index a91f949110..f7a94c8d1f 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/BaseConversionToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/BaseTopLevelConverterToSpeckle.cs @@ -6,15 +6,15 @@ namespace Speckle.Converters.RevitShared.ToSpeckle; // POC: maybe but could be generic abstract Converters.Common? // or maybe it's not actually doing very much now and can come out -public abstract class BaseConversionToSpeckle - : IHostObjectToSpeckleConversion, +public abstract class BaseTopLevelConverterToSpeckle + : IToSpeckleTopLevelConverter, // POC: why do we need to do this for each base conversion? - IRawConversion + ITypedConverter where TSpeckle : Base { public Base Convert(object target) { - var result = RawConvert((THost)target); + var result = Convert((THost)target); // POC: unless I am going bonkers, we've constrained TSpeckle to Base // so it should always BE base? @@ -28,5 +28,5 @@ public Base Convert(object target) return @base; } - public abstract TSpeckle RawConvert(THost target); + public abstract TSpeckle Convert(THost target); } diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/CeilingConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/CeilingTopLevelConverterToSpeckle.cs similarity index 76% rename from DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/CeilingConversionToSpeckle.cs rename to DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/CeilingTopLevelConverterToSpeckle.cs index 8066b715fe..c3de2636aa 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/CeilingConversionToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/CeilingTopLevelConverterToSpeckle.cs @@ -9,19 +9,19 @@ namespace Speckle.Converters.RevitShared.ToSpeckle; [NameAndRankValue(nameof(DB.Ceiling), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -internal sealed class CeilingConversionToSpeckle : BaseConversionToSpeckle +internal sealed class CeilingTopLevelConverterToSpeckle : BaseTopLevelConverterToSpeckle { - private readonly IRawConversion> _curveArrArrayConverter; - private readonly IRawConversion _levelConverter; + private readonly ITypedConverter> _curveArrArrayConverter; + private readonly ITypedConverter _levelConverter; private readonly ParameterValueExtractor _parameterValueExtractor; private readonly ParameterObjectAssigner _parameterObjectAssigner; private readonly DisplayValueExtractor _displayValueExtractor; //private readonly HostedElementConversionToSpeckle _hostedElementConverter; - public CeilingConversionToSpeckle( - IRawConversion> curveArrArrayConverter, - IRawConversion levelConverter, + public CeilingTopLevelConverterToSpeckle( + ITypedConverter> curveArrArrayConverter, + ITypedConverter levelConverter, ParameterValueExtractor parameterValueExtractor, ParameterObjectAssigner parameterObjectAssigner, DisplayValueExtractor displayValueExtractor @@ -34,10 +34,10 @@ DisplayValueExtractor displayValueExtractor _displayValueExtractor = displayValueExtractor; } - public override RevitCeiling RawConvert(DB.Ceiling target) + public override RevitCeiling Convert(DB.Ceiling target) { var sketch = (Sketch)target.Document.GetElement(target.SketchId); - List profiles = _curveArrArrayConverter.RawConvert(sketch.Profile); + List profiles = _curveArrArrayConverter.Convert(sketch.Profile); var speckleCeiling = new RevitCeiling(); @@ -59,7 +59,7 @@ public override RevitCeiling RawConvert(DB.Ceiling target) // but it is never being set. We should be setting it var level = _parameterValueExtractor.GetValueAsDocumentObject(target, DB.BuiltInParameter.LEVEL_PARAM); - speckleCeiling.level = _levelConverter.RawConvert(level); + speckleCeiling.level = _levelConverter.Convert(level); _parameterObjectAssigner.AssignParametersToBase(target, speckleCeiling); speckleCeiling.displayValue = _displayValueExtractor.GetDisplayValue(target); diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/DirectShapeConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/DirectShapeTopLevelConverterToSpeckle.cs similarity index 86% rename from DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/DirectShapeConversionToSpeckle.cs rename to DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/DirectShapeTopLevelConverterToSpeckle.cs index 2e6340e853..c9c9ca5e14 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/DirectShapeConversionToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/DirectShapeTopLevelConverterToSpeckle.cs @@ -7,13 +7,13 @@ namespace Speckle.Converters.Revit2023.ToSpeckle; [NameAndRankValue(nameof(DB.DirectShape), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class DirectShapeConversionToSpeckle : BaseConversionToSpeckle +public class DirectShapeTopLevelConverterToSpeckle : BaseTopLevelConverterToSpeckle { private readonly IRevitConversionContextStack _contextStack; private readonly ParameterObjectAssigner _parameterObjectAssigner; private readonly DisplayValueExtractor _displayValueExtractor; - public DirectShapeConversionToSpeckle( + public DirectShapeTopLevelConverterToSpeckle( ParameterObjectAssigner parameterObjectAssigner, IRevitConversionContextStack contextStack, DisplayValueExtractor displayValueExtractor @@ -24,7 +24,7 @@ DisplayValueExtractor displayValueExtractor _displayValueExtractor = displayValueExtractor; } - public override SOBR.DirectShape RawConvert(DB.DirectShape target) + public override SOBR.DirectShape Convert(DB.DirectShape target) { var category = target.Category.GetBuiltInCategory().GetSchemaBuilderCategoryFromBuiltIn(); diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/ElementConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/ElementTopLevelConverterToSpeckle.cs similarity index 86% rename from DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/ElementConversionToSpeckle.cs rename to DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/ElementTopLevelConverterToSpeckle.cs index ac3a9fd795..c3b96c9001 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/ElementConversionToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/ElementTopLevelConverterToSpeckle.cs @@ -6,16 +6,16 @@ namespace Speckle.Converters.RevitShared.ToSpeckle; // POC: not currently used? clearly some missing pieces [NameAndRankValue(nameof(DB.Element), 0)] -public class ElementConversionToSpeckle : BaseConversionToSpeckle +public class ElementTopLevelConverterToSpeckle : BaseTopLevelConverterToSpeckle { private readonly DisplayValueExtractor _displayValueExtractor; - public ElementConversionToSpeckle(DisplayValueExtractor displayValueExtractor) + public ElementTopLevelConverterToSpeckle(DisplayValueExtractor displayValueExtractor) { _displayValueExtractor = displayValueExtractor; } - public override RevitElement RawConvert(DB.Element target) + public override RevitElement Convert(DB.Element target) { RevitElement speckleElement = new(); diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/ExtrusionRoofToSpeckleTopLevelConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/ExtrusionRoofToSpeckleTopLevelConverter.cs index 90b05a640a..d46c93794f 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/ExtrusionRoofToSpeckleTopLevelConverter.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/ExtrusionRoofToSpeckleTopLevelConverter.cs @@ -8,20 +8,21 @@ namespace Speckle.Converters.RevitShared.ToSpeckle; [NameAndRankValue(nameof(DB.ExtrusionRoof), 0)] -public class ExtrusionRoofToSpeckleTopLevelConverter : BaseConversionToSpeckle +public class ExtrusionRoofToSpeckleTopLevelConverter + : BaseTopLevelConverterToSpeckle { - private readonly IRawConversion _levelConverter; - private readonly IRawConversion _modelCurveArrayConverter; - private readonly IRawConversion _pointConverter; + private readonly ITypedConverter _levelConverter; + private readonly ITypedConverter _modelCurveArrayConverter; + private readonly ITypedConverter _pointConverter; private readonly ParameterValueExtractor _parameterValueExtractor; private readonly DisplayValueExtractor _displayValueExtractor; private readonly HostedElementConversionToSpeckle _hostedElementConverter; private readonly ParameterObjectAssigner _parameterObjectAssigner; public ExtrusionRoofToSpeckleTopLevelConverter( - IRawConversion levelConverter, - IRawConversion modelCurveArrayConverter, - IRawConversion pointConverter, + ITypedConverter levelConverter, + ITypedConverter modelCurveArrayConverter, + ITypedConverter pointConverter, ParameterValueExtractor parameterValueExtractor, DisplayValueExtractor displayValueExtractor, HostedElementConversionToSpeckle hostedElementConverter, @@ -37,7 +38,7 @@ ParameterObjectAssigner parameterObjectAssigner _parameterObjectAssigner = parameterObjectAssigner; } - public override RevitExtrusionRoof RawConvert(DB.ExtrusionRoof target) + public override RevitExtrusionRoof Convert(DB.ExtrusionRoof target) { var speckleExtrusionRoof = new RevitExtrusionRoof { @@ -46,15 +47,15 @@ public override RevitExtrusionRoof RawConvert(DB.ExtrusionRoof target) }; var plane = target.GetProfile().get_Item(0).SketchPlane.GetPlane(); speckleExtrusionRoof.referenceLine = new SOG.Line( - _pointConverter.RawConvert(plane.Origin.Add(plane.XVec.Normalize().Negate())), - _pointConverter.RawConvert(plane.Origin) + _pointConverter.Convert(plane.Origin.Add(plane.XVec.Normalize().Negate())), + _pointConverter.Convert(plane.Origin) ); var level = _parameterValueExtractor.GetValueAsDocumentObject( target, DB.BuiltInParameter.ROOF_CONSTRAINT_LEVEL_PARAM ); - speckleExtrusionRoof.level = _levelConverter.RawConvert(level); - speckleExtrusionRoof.outline = _modelCurveArrayConverter.RawConvert(target.GetProfile()); + speckleExtrusionRoof.level = _levelConverter.Convert(level); + speckleExtrusionRoof.outline = _modelCurveArrayConverter.Convert(target.GetProfile()); var elementType = (DB.ElementType)target.Document.GetElement(target.GetTypeId()); speckleExtrusionRoof.type = elementType.Name; diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/FamilyInstanceConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/FamilyInstanceConversionToSpeckle.cs deleted file mode 100644 index ae7c3f9b2c..0000000000 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/FamilyInstanceConversionToSpeckle.cs +++ /dev/null @@ -1,46 +0,0 @@ -using Speckle.Converters.Common; -using Speckle.Converters.Common.Objects; -using Speckle.Core.Models; - -namespace Speckle.Converters.RevitShared.ToSpeckle; - -// POC: bin for now? This is also a parent child relationship and may need a pattern for this -// so we don't end up with some god FamilyInstanceConversionToSpeckle converter -[NameAndRankValue(nameof(DB.FamilyInstance), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public sealed class FamilyInstanceConversionToSpeckle : BaseConversionToSpeckle -{ - private readonly IRawConversion _elementConverter; - private readonly IRawConversion _beamConversion; - private readonly IRawConversion _columnConversion; - private readonly IRawConversion _braceConversion; - - public FamilyInstanceConversionToSpeckle( - IRawConversion elementConverter, - IRawConversion beamConversion, - IRawConversion columnConversion, - IRawConversion braceConversion - ) - { - _elementConverter = elementConverter; - _beamConversion = beamConversion; - _columnConversion = columnConversion; - _braceConversion = braceConversion; - } - - public override Base RawConvert(DB.FamilyInstance target) - { - return target.StructuralType switch - { - DB.Structure.StructuralType.Beam => _beamConversion.RawConvert(target), - DB.Structure.StructuralType.Column => _columnConversion.RawConvert(target), - DB.Structure.StructuralType.Brace => _braceConversion.RawConvert(target), - - // POC: return generic element conversion or throw? - // - //throw new SpeckleConversionException( - // $"No conditional converters registered that could convert object of type {target.GetType()}" - //); - _ => _elementConverter.RawConvert(target) - }; - } -} diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/FamilyInstanceTopLevelConverterToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/FamilyInstanceTopLevelConverterToSpeckle.cs new file mode 100644 index 0000000000..446dcd4383 --- /dev/null +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/FamilyInstanceTopLevelConverterToSpeckle.cs @@ -0,0 +1,46 @@ +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; +using Speckle.Core.Models; + +namespace Speckle.Converters.RevitShared.ToSpeckle; + +// POC: bin for now? This is also a parent child relationship and may need a pattern for this +// so we don't end up with some god FamilyInstanceTopLevelConverterToSpeckle converter +[NameAndRankValue(nameof(DB.FamilyInstance), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +public sealed class FamilyInstanceTopLevelConverterToSpeckle : BaseTopLevelConverterToSpeckle +{ + private readonly ITypedConverter _elementConverter; + private readonly ITypedConverter _beamConversion; + private readonly ITypedConverter _columnConversion; + private readonly ITypedConverter _braceConversion; + + public FamilyInstanceTopLevelConverterToSpeckle( + ITypedConverter elementConverter, + ITypedConverter beamConversion, + ITypedConverter columnConversion, + ITypedConverter braceConversion + ) + { + _elementConverter = elementConverter; + _beamConversion = beamConversion; + _columnConversion = columnConversion; + _braceConversion = braceConversion; + } + + public override Base Convert(DB.FamilyInstance target) + { + return target.StructuralType switch + { + DB.Structure.StructuralType.Beam => _beamConversion.Convert(target), + DB.Structure.StructuralType.Column => _columnConversion.Convert(target), + DB.Structure.StructuralType.Brace => _braceConversion.Convert(target), + + // POC: return generic element conversion or throw? + // + //throw new SpeckleConversionException( + // $"No conditional converters registered that could convert object of type {target.GetType()}" + //); + _ => _elementConverter.Convert(target) + }; + } +} diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/FloorConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/FloorTopLevelConverterToSpeckle.cs similarity index 85% rename from DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/FloorConversionToSpeckle.cs rename to DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/FloorTopLevelConverterToSpeckle.cs index 16b409f294..13d0d3086f 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/FloorConversionToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/FloorTopLevelConverterToSpeckle.cs @@ -12,18 +12,18 @@ namespace Speckle.Converters.Common; // clould be anywhere or all in once place - rooting through box 274 for something you need, when said box has a miriad different // and unrelated items, is no fun. Plus when you need that item, you end up bringing out the whole box/ [NameAndRankValue(nameof(DB.Floor), 0)] -public class FloorConversionToSpeckle : BaseConversionToSpeckle +public class FloorTopLevelConverterToSpeckle : BaseTopLevelConverterToSpeckle { - private readonly IRawConversion> _curveArrArrayConverter; - private readonly IRawConversion _levelConverter; + private readonly ITypedConverter> _curveArrArrayConverter; + private readonly ITypedConverter _levelConverter; private readonly ParameterValueExtractor _parameterValueExtractor; private readonly ParameterObjectAssigner _parameterObjectAssigner; private readonly DisplayValueExtractor _displayValueExtractor; private readonly ISlopeArrowExtractor _slopeArrowExtractor; - public FloorConversionToSpeckle( - IRawConversion> curveArrArrayConverter, - IRawConversion levelConverter, + public FloorTopLevelConverterToSpeckle( + ITypedConverter> curveArrArrayConverter, + ITypedConverter levelConverter, ParameterValueExtractor parameterValueExtractor, ParameterObjectAssigner parameterObjectAssigner, DisplayValueExtractor displayValueExtractor, @@ -38,12 +38,12 @@ ISlopeArrowExtractor slopeArrowExtractor _slopeArrowExtractor = slopeArrowExtractor; } - public override SOBR.RevitFloor RawConvert(DB.Floor target) + public override SOBR.RevitFloor Convert(DB.Floor target) { SOBR.RevitFloor speckleFloor = new(); var sketch = (DB.Sketch)target.Document.GetElement(target.SketchId); - List profiles = _curveArrArrayConverter.RawConvert(sketch.Profile); + List profiles = _curveArrArrayConverter.Convert(sketch.Profile); DB.ElementType type = (DB.ElementType)target.Document.GetElement(target.GetTypeId()); @@ -62,7 +62,7 @@ public override SOBR.RevitFloor RawConvert(DB.Floor target) } var level = _parameterValueExtractor.GetValueAsDocumentObject(target, DB.BuiltInParameter.LEVEL_PARAM); - speckleFloor.level = _levelConverter.RawConvert(level); + speckleFloor.level = _levelConverter.Convert(level); speckleFloor.structural = _parameterValueExtractor.GetValueAsBool(target, DB.BuiltInParameter.FLOOR_PARAM_IS_STRUCTURAL) ?? false; diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/FootPrintRoofToSpeckleTopLevelConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/FootPrintRoofToSpeckleTopLevelConverter.cs index c4bc3379de..1c8e74bb04 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/FootPrintRoofToSpeckleTopLevelConverter.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/FootPrintRoofToSpeckleTopLevelConverter.cs @@ -11,18 +11,19 @@ namespace Speckle.Converters.RevitShared.ToSpeckle; [NameAndRankValue(nameof(DB.FootPrintRoof), 0)] -public class FootPrintRoofToSpeckleTopLevelConverter : BaseConversionToSpeckle +public class FootPrintRoofToSpeckleTopLevelConverter + : BaseTopLevelConverterToSpeckle { - private readonly IRawConversion _levelConverter; - private readonly IRawConversion _modelCurveArrArrayConverter; + private readonly ITypedConverter _levelConverter; + private readonly ITypedConverter _modelCurveArrArrayConverter; private readonly ParameterValueExtractor _parameterValueExtractor; private readonly DisplayValueExtractor _displayValueExtractor; private readonly HostedElementConversionToSpeckle _hostedElementConverter; private readonly ParameterObjectAssigner _parameterObjectAssigner; public FootPrintRoofToSpeckleTopLevelConverter( - IRawConversion levelConverter, - IRawConversion modelCurveArrArrayConverter, + ITypedConverter levelConverter, + ITypedConverter modelCurveArrArrayConverter, ParameterValueExtractor parameterValueExtractor, DisplayValueExtractor displayValueExtractor, HostedElementConversionToSpeckle hostedElementConverter, @@ -37,7 +38,7 @@ ParameterObjectAssigner parameterObjectAssigner _parameterObjectAssigner = parameterObjectAssigner; } - public override RevitFootprintRoof RawConvert(FootPrintRoof target) + public override RevitFootprintRoof Convert(FootPrintRoof target) { var baseLevel = _parameterValueExtractor.GetValueAsDocumentObject( target, @@ -58,8 +59,8 @@ out var topLevel RevitFootprintRoof speckleFootprintRoof = new() { - level = _levelConverter.RawConvert(baseLevel), - cutOffLevel = topLevel is not null ? _levelConverter.RawConvert(topLevel) : null, + level = _levelConverter.Convert(baseLevel), + cutOffLevel = topLevel is not null ? _levelConverter.Convert(topLevel) : null, slope = slope }; @@ -67,7 +68,7 @@ out var topLevel // are voids // POC: CNX-9403 in current connector, we are doing serious gymnastics to get the slope of the floor as defined by // slope arrow. The way we are doing it relies on dynamic props and only works for Revit <-> Revit - var profiles = _modelCurveArrArrayConverter.RawConvert(target.GetProfiles()); + var profiles = _modelCurveArrArrayConverter.Convert(target.GetProfiles()); speckleFootprintRoof.outline = profiles.FirstOrDefault(); speckleFootprintRoof.voids = profiles.Skip(1).ToList(); diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/HostedElementConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/HostedElementConversionToSpeckle.cs index 5709bba293..53eef628a9 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/HostedElementConversionToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/HostedElementConversionToSpeckle.cs @@ -12,12 +12,12 @@ namespace Speckle.Converters.RevitShared.ToSpeckle; public class HostedElementConversionToSpeckle { private readonly ToSpeckleConvertedObjectsCache _convertedObjectsCache; - private readonly ISpeckleConverterToSpeckle _converter; + private readonly IRootToSpeckleConverter _converter; private readonly IRevitConversionContextStack _contextStack; public HostedElementConversionToSpeckle( ToSpeckleConvertedObjectsCache convertedObjectsCache, - ISpeckleConverterToSpeckle converter, + IRootToSpeckleConverter converter, IRevitConversionContextStack contextStack ) { diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/ModelCurveToSpeckleTopLevelConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/ModelCurveToSpeckleTopLevelConverter.cs index 25094cb0e9..240cbe4713 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/ModelCurveToSpeckleTopLevelConverter.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/ModelCurveToSpeckleTopLevelConverter.cs @@ -8,13 +8,13 @@ namespace Speckle.Converters.RevitShared.ToSpeckle; // POC: ModelCurve looks a bit bogus and we may wish to revise what that is and how it inherits // see https://spockle.atlassian.net/browse/CNX-9381 [NameAndRankValue(nameof(DB.ModelCurve), 0)] -public class ModelCurveToSpeckleTopLevelConverter : BaseConversionToSpeckle +public class ModelCurveToSpeckleTopLevelConverter : BaseTopLevelConverterToSpeckle { - private readonly IRawConversion _curveConverter; + private readonly ITypedConverter _curveConverter; private readonly IRevitConversionContextStack _conversionContext; public ModelCurveToSpeckleTopLevelConverter( - IRawConversion curveConverter, + ITypedConverter curveConverter, IRevitConversionContextStack conversionContext ) { @@ -22,11 +22,11 @@ IRevitConversionContextStack conversionContext _conversionContext = conversionContext; } - public override SOBR.Curve.ModelCurve RawConvert(DB.ModelCurve target) + public override SOBR.Curve.ModelCurve Convert(DB.ModelCurve target) { var modelCurve = new SOBR.Curve.ModelCurve() { - baseCurve = _curveConverter.RawConvert(target.GeometryCurve), + baseCurve = _curveConverter.Convert(target.GeometryCurve), lineStyle = target.LineStyle.Name, elementId = target.Id.ToString(), units = _conversionContext.Current.SpeckleUnits diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/RoofBaseToSpeckleTopLevelConversion.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/RoofBaseToSpeckleTopLevelTopLevelConverter.cs similarity index 85% rename from DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/RoofBaseToSpeckleTopLevelConversion.cs rename to DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/RoofBaseToSpeckleTopLevelTopLevelConverter.cs index 464e78ba01..77f9ce831c 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/RoofBaseToSpeckleTopLevelConversion.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/RoofBaseToSpeckleTopLevelTopLevelConverter.cs @@ -7,13 +7,14 @@ namespace Speckle.Converters.RevitShared.ToSpeckle; [NameAndRankValue(nameof(DB.RoofBase), 0)] -internal sealed class RoofBaseToSpeckleTopLevelConversion : BaseConversionToSpeckle +internal sealed class RoofBaseToSpeckleTopLevelTopLevelConverter + : BaseTopLevelConverterToSpeckle { private readonly DisplayValueExtractor _displayValueExtractor; private readonly HostedElementConversionToSpeckle _hostedElementConverter; private readonly ParameterObjectAssigner _parameterObjectAssigner; - public RoofBaseToSpeckleTopLevelConversion( + public RoofBaseToSpeckleTopLevelTopLevelConverter( DisplayValueExtractor displayValueExtractor, HostedElementConversionToSpeckle hostedElementConverter, ParameterObjectAssigner parameterObjectAssigner @@ -24,7 +25,7 @@ ParameterObjectAssigner parameterObjectAssigner _parameterObjectAssigner = parameterObjectAssigner; } - public override RevitRoof RawConvert(RoofBase target) + public override RevitRoof Convert(RoofBase target) { RevitRoof revitRoof = new(); var elementType = (ElementType)target.Document.GetElement(target.GetTypeId()); diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/RoomConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/RoomTopLevelConverterToSpeckle.cs similarity index 68% rename from DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/RoomConversionToSpeckle.cs rename to DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/RoomTopLevelConverterToSpeckle.cs index 16a94cac1e..6e4e1f91cb 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/RoomConversionToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/RoomTopLevelConverterToSpeckle.cs @@ -7,22 +7,22 @@ namespace Speckle.Converters.RevitShared.ToSpeckle; [NameAndRankValue(nameof(DBA.Room), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class RoomConversionToSpeckle : BaseConversionToSpeckle +public class RoomTopLevelConverterToSpeckle : BaseTopLevelConverterToSpeckle { private readonly DisplayValueExtractor _displayValueExtractor; private readonly ParameterObjectAssigner _parameterObjectAssigner; - private readonly IRawConversion _levelConverter; + private readonly ITypedConverter _levelConverter; private readonly ParameterValueExtractor _parameterValueExtractor; - private readonly IRawConversion _locationConverter; - private readonly IRawConversion, SOG.Polycurve> _boundarySegmentConverter; + private readonly ITypedConverter _locationConverter; + private readonly ITypedConverter, SOG.Polycurve> _boundarySegmentConverter; - public RoomConversionToSpeckle( + public RoomTopLevelConverterToSpeckle( DisplayValueExtractor displayValueExtractor, ParameterObjectAssigner parameterObjectAssigner, - IRawConversion levelConverter, + ITypedConverter levelConverter, ParameterValueExtractor parameterValueExtractor, - IRawConversion locationConverter, - IRawConversion, SOG.Polycurve> boundarySegmentConverter + ITypedConverter locationConverter, + ITypedConverter, SOG.Polycurve> boundarySegmentConverter ) { _displayValueExtractor = displayValueExtractor; @@ -33,19 +33,19 @@ public RoomConversionToSpeckle( _boundarySegmentConverter = boundarySegmentConverter; } - public override SOBE.Room RawConvert(DBA.Room target) + public override SOBE.Room Convert(DBA.Room target) { var number = target.Number; var name = _parameterValueExtractor.GetValueAsString(target, DB.BuiltInParameter.ROOM_NAME); var area = _parameterValueExtractor.GetValueAsDouble(target, DB.BuiltInParameter.ROOM_AREA); var displayValue = _displayValueExtractor.GetDisplayValue(target); - var basePoint = (SOG.Point)_locationConverter.RawConvert(target.Location); - var level = _levelConverter.RawConvert(target.Level); + var basePoint = (SOG.Point)_locationConverter.Convert(target.Location); + var level = _levelConverter.Convert(target.Level); var profiles = target .GetBoundarySegments(new DB.SpatialElementBoundaryOptions()) - .Select(c => (ICurve)_boundarySegmentConverter.RawConvert(c)) + .Select(c => (ICurve)_boundarySegmentConverter.Convert(c)) .ToList(); var outline = profiles.First(); diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/TopographyConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/TopographyTopLevelConverterToSpeckle.cs similarity index 75% rename from DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/TopographyConversionToSpeckle.cs rename to DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/TopographyTopLevelConverterToSpeckle.cs index f26cbfb6a6..eea4ea51c9 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/TopographyConversionToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/TopographyTopLevelConverterToSpeckle.cs @@ -6,12 +6,13 @@ namespace Speckle.Converters.RevitShared.ToSpeckle; // POC: needs review feels, BIG, feels like it could be broken down.. // i.e. GetParams(), GetGeom()? feels like it's doing too much [NameAndRankValue(nameof(DBA.TopographySurface), 0)] -public class TopographyConversionToSpeckle : BaseConversionToSpeckle +public class TopographyTopLevelConverterToSpeckle + : BaseTopLevelConverterToSpeckle { private readonly DisplayValueExtractor _displayValueExtractor; private readonly ParameterObjectAssigner _parameterObjectAssigner; - public TopographyConversionToSpeckle( + public TopographyTopLevelConverterToSpeckle( DisplayValueExtractor displayValueExtractor, ParameterObjectAssigner parameterObjectAssigner ) @@ -20,7 +21,7 @@ ParameterObjectAssigner parameterObjectAssigner _parameterObjectAssigner = parameterObjectAssigner; } - public override SOBR.RevitTopography RawConvert(DBA.TopographySurface target) + public override SOBR.RevitTopography Convert(DBA.TopographySurface target) { var speckleTopo = new SOBR.RevitTopography { @@ -28,7 +29,7 @@ public override SOBR.RevitTopography RawConvert(DBA.TopographySurface target) elementId = target.Id.ToString() }; - // POC: shouldn't we just do this in the RevitConverterToSpeckle ? + // POC: shouldn't we just do this in the RevitConverter ? _parameterObjectAssigner.AssignParametersToBase(target, speckleTopo); return speckleTopo; diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/WallConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/WallTopLevelConverterToSpeckle.cs similarity index 84% rename from DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/WallConversionToSpeckle.cs rename to DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/WallTopLevelConverterToSpeckle.cs index f69d6a14b5..8e0cce3ba9 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/WallConversionToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/WallTopLevelConverterToSpeckle.cs @@ -12,26 +12,26 @@ namespace Speckle.Converters.RevitShared.ToSpeckle; // POC: needs review feels, BIG, feels like it could be broken down.. // i.e. GetParams(), GetGeom()? feels like it's doing too much [NameAndRankValue(nameof(DB.Wall), 0)] -public class WallConversionToSpeckle : BaseConversionToSpeckle +public class WallTopLevelConverterToSpeckle : BaseTopLevelConverterToSpeckle { - private readonly IRawConversion _curveConverter; - private readonly IRawConversion _levelConverter; - private readonly IRawConversion> _curveArrArrayConverter; + private readonly ITypedConverter _curveConverter; + private readonly ITypedConverter _levelConverter; + private readonly ITypedConverter> _curveArrArrayConverter; private readonly ParameterValueExtractor _parameterValueExtractor; private readonly IRevitConversionContextStack _contextStack; private readonly DisplayValueExtractor _displayValueExtractor; private readonly ParameterObjectAssigner _parameterObjectAssigner; - private readonly ISpeckleConverterToSpeckle _converter; + private readonly IRootToSpeckleConverter _converter; - public WallConversionToSpeckle( - IRawConversion curveConverter, - IRawConversion levelConverter, - IRawConversion> curveArrArrayConverter, + public WallTopLevelConverterToSpeckle( + ITypedConverter curveConverter, + ITypedConverter levelConverter, + ITypedConverter> curveArrArrayConverter, IRevitConversionContextStack contextStack, ParameterValueExtractor parameterValueExtractor, DisplayValueExtractor displayValueExtractor, ParameterObjectAssigner parameterObjectAssigner, - ISpeckleConverterToSpeckle converter + IRootToSpeckleConverter converter ) { _curveConverter = curveConverter; @@ -44,7 +44,7 @@ ISpeckleConverterToSpeckle converter _converter = converter; } - public override SOBR.RevitWall RawConvert(DB.Wall target) + public override SOBR.RevitWall Convert(DB.Wall target) { SOBR.RevitWall speckleWall = new() { family = target.WallType.FamilyName.ToString(), type = target.WallType.Name }; @@ -66,19 +66,19 @@ private void AssignSpecificParameters(DB.Wall target, RevitWall speckleWall) ); } - speckleWall.baseLine = _curveConverter.RawConvert(locationCurve.Curve); + speckleWall.baseLine = _curveConverter.Convert(locationCurve.Curve); var level = _parameterValueExtractor.GetValueAsDocumentObject( target, DB.BuiltInParameter.WALL_BASE_CONSTRAINT ); - speckleWall.level = _levelConverter.RawConvert(level); + speckleWall.level = _levelConverter.Convert(level); var topLevel = _parameterValueExtractor.GetValueAsDocumentObject( target, DB.BuiltInParameter.WALL_BASE_CONSTRAINT ); - speckleWall.topLevel = _levelConverter.RawConvert(topLevel); + speckleWall.topLevel = _levelConverter.Convert(topLevel); // POC : what to do if these parameters are unset (instead of assigning default) _ = _parameterValueExtractor.TryGetValueAsDouble( @@ -167,7 +167,7 @@ private void AssignVoids(DB.Wall target, SOBR.RevitWall speckleWall) return; } - List polycurves = _curveArrArrayConverter.RawConvert(profile); + List polycurves = _curveArrArrayConverter.Convert(profile); if (polycurves.Count > 1) { diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/RhinoConverterModule.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/RhinoConverterModule.cs index c2c0fca280..9117848c90 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/RhinoConverterModule.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/RhinoConverterModule.cs @@ -2,7 +2,6 @@ using Speckle.Converters.Common; using Rhino; using Speckle.Converters.Common.DependencyInjection; -using Speckle.Converters.Rhino7.ToSpeckle; namespace Speckle.Converters.Rhino7.DependencyInjection; @@ -10,12 +9,8 @@ public class RhinoConverterModule : ISpeckleModule { public void Load(SpeckleContainerBuilder builder) { - builder.AddConverterCommon(); + builder.AddConverterCommon(); // single stack per conversion builder.AddScoped, RhinoConversionContextStack>(); - - // To Speckle - builder.AddScoped, RhinoToSpeckleUnitConverter>(); - builder.AddScoped(); } } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/SpeckleToHostGeometryBaseConversion.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/SpeckleToHostGeometryBaseTopLevelConverter.cs similarity index 77% rename from DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/SpeckleToHostGeometryBaseConversion.cs rename to DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/SpeckleToHostGeometryBaseTopLevelConverter.cs index 27435f3333..75ff2162c2 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/SpeckleToHostGeometryBaseConversion.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/SpeckleToHostGeometryBaseTopLevelConverter.cs @@ -6,16 +6,16 @@ namespace Speckle.Converters.Rhino7; -public abstract class SpeckleToHostGeometryBaseConversion : ISpeckleObjectToHostConversion +public abstract class SpeckleToHostGeometryBaseTopLevelConverter : IToHostTopLevelConverter where TIn : Base where TOut : RG.GeometryBase { protected IConversionContextStack ContextStack { get; private set; } - private readonly IRawConversion _geometryBaseConverter; + private readonly ITypedConverter _geometryBaseConverter; - protected SpeckleToHostGeometryBaseConversion( + protected SpeckleToHostGeometryBaseTopLevelConverter( IConversionContextStack contextStack, - IRawConversion geometryBaseConverter + ITypedConverter geometryBaseConverter ) { ContextStack = contextStack; @@ -25,7 +25,7 @@ IRawConversion geometryBaseConverter public object Convert(Base target) { var castedBase = (TIn)target; - var result = _geometryBaseConverter.RawConvert(castedBase); + var result = _geometryBaseConverter.Convert(castedBase); /* * POC: CNX-9270 Looking at a simpler, more performant way of doing unit scaling on `ToNative` diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/ArcToHostConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/ArcToHostConverter.cs index 291395ee9e..0068c38ef2 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/ArcToHostConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/ArcToHostConverter.cs @@ -5,14 +5,14 @@ namespace Speckle.Converters.Rhino7.ToHost.Raw; /// /// Converts a SpeckleArcRaw object to a Rhino.Geometry.Arc object or Rhino.Geometry.ArcCurve object. /// -public class ArcToHostConverter : IRawConversion, IRawConversion +public class ArcToHostConverter : ITypedConverter, ITypedConverter { - private readonly IRawConversion _pointConverter; - private readonly IRawConversion _intervalConverter; + private readonly ITypedConverter _pointConverter; + private readonly ITypedConverter _intervalConverter; public ArcToHostConverter( - IRawConversion pointConverter, - IRawConversion intervalConverter + ITypedConverter pointConverter, + ITypedConverter intervalConverter ) { _pointConverter = pointConverter; @@ -26,12 +26,12 @@ public ArcToHostConverter( /// The converted object. /// ⚠️ This conversion does NOT perform scaling. ///
⚠️ This method does not preserve the original curve domain
- public RG.Arc RawConvert(SOG.Arc target) + public RG.Arc Convert(SOG.Arc target) { var rhinoArc = new RG.Arc( - _pointConverter.RawConvert(target.startPoint), - _pointConverter.RawConvert(target.midPoint), - _pointConverter.RawConvert(target.endPoint) + _pointConverter.Convert(target.startPoint), + _pointConverter.Convert(target.midPoint), + _pointConverter.Convert(target.endPoint) ); return rhinoArc; } @@ -45,10 +45,10 @@ public RG.Arc RawConvert(SOG.Arc target) /// The converted object. /// ⚠️ This conversion does NOT perform scaling. ///
⚠️ Converting to instead of preserves the domain of the curve.
- RG.ArcCurve IRawConversion.RawConvert(SOG.Arc target) + RG.ArcCurve ITypedConverter.Convert(SOG.Arc target) { - var rhinoArc = RawConvert(target); - var arcCurve = new RG.ArcCurve(rhinoArc) { Domain = _intervalConverter.RawConvert(target.domain) }; + var rhinoArc = Convert(target); + var arcCurve = new RG.ArcCurve(rhinoArc) { Domain = _intervalConverter.Convert(target.domain) }; return arcCurve; } } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/BrepToHostConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/BrepToHostConverter.cs index e27a846a1b..db94e2f7f0 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/BrepToHostConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/BrepToHostConverter.cs @@ -5,20 +5,20 @@ namespace Speckle.Converters.Rhino7.ToHost.Raw; -public class BrepToHostConverter : IRawConversion +public class BrepToHostConverter : ITypedConverter { private readonly IConversionContextStack _contextStack; - private readonly IRawConversion _curveConverter; - private readonly IRawConversion _surfaceConverter; - private readonly IRawConversion _pointConverter; - private readonly IRawConversion _intervalConverter; + private readonly ITypedConverter _curveConverter; + private readonly ITypedConverter _surfaceConverter; + private readonly ITypedConverter _pointConverter; + private readonly ITypedConverter _intervalConverter; public BrepToHostConverter( IConversionContextStack contextStack, - IRawConversion curveConverter, - IRawConversion surfaceConverter, - IRawConversion pointConverter, - IRawConversion intervalConverter + ITypedConverter curveConverter, + ITypedConverter surfaceConverter, + ITypedConverter pointConverter, + ITypedConverter intervalConverter ) { _contextStack = contextStack; @@ -40,17 +40,17 @@ public BrepToHostConverter( /// The Speckle Brep object to be converted. /// The equivalent Rhino Brep object. /// ⚠️ This conversion does NOT perform scaling. - public RG.Brep RawConvert(SOG.Brep target) + public RG.Brep Convert(SOG.Brep target) { var tolerance = _contextStack.Current.Document.ModelAbsoluteTolerance; var rhinoBrep = new RG.Brep(); // Geometry goes in first, always. Order doesn't matter. - target.Curve3D.ForEach(curve => rhinoBrep.AddEdgeCurve(_curveConverter.RawConvert(curve))); - target.Curve2D.ForEach(curve => rhinoBrep.AddTrimCurve(_curveConverter.RawConvert(curve))); - target.Surfaces.ForEach(surface => rhinoBrep.AddSurface(_surfaceConverter.RawConvert(surface))); - target.Vertices.ForEach(vertex => rhinoBrep.Vertices.Add(_pointConverter.RawConvert(vertex), tolerance)); + target.Curve3D.ForEach(curve => rhinoBrep.AddEdgeCurve(_curveConverter.Convert(curve))); + target.Curve2D.ForEach(curve => rhinoBrep.AddTrimCurve(_curveConverter.Convert(curve))); + target.Surfaces.ForEach(surface => rhinoBrep.AddSurface(_surfaceConverter.Convert(surface))); + target.Vertices.ForEach(vertex => rhinoBrep.Vertices.Add(_pointConverter.Convert(vertex), tolerance)); // Order matters, first edges, then faces, finally loops. target.Edges.ForEach(edge => ConvertSpeckleBrepEdge(rhinoBrep, edge, tolerance)); @@ -151,7 +151,7 @@ private void ConvertSpeckleBrepEdge(RG.Brep rhinoBrep, SOG.BrepEdge speckleEdge, speckleEdge.StartIndex, speckleEdge.EndIndex, speckleEdge.Curve3dIndex, - _intervalConverter.RawConvert(speckleEdge.Domain), + _intervalConverter.Convert(speckleEdge.Domain), tolerance ); } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/CircleToHostConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/CircleToHostConverter.cs index 06f31256a5..1431d3fc1a 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/CircleToHostConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/CircleToHostConverter.cs @@ -4,26 +4,26 @@ namespace Speckle.Converters.Rhino7.ToHost.Raw; /// /// This class is responsible for converting a into and objects. -/// Implements the interface, +/// Implements the interface, /// providing implementation for to and conversion. /// -public class CircleToHostConverter : IRawConversion, IRawConversion +public class CircleToHostConverter : ITypedConverter, ITypedConverter { - private readonly IRawConversion _planeConverter; - private readonly IRawConversion _intervalConverter; + private readonly ITypedConverter _planeConverter; + private readonly ITypedConverter _intervalConverter; /// /// Constructs a new instance of the class. /// /// - /// An implementation of used to convert into . + /// An implementation of used to convert into . /// /// - /// An implementation of used to convert into . + /// An implementation of used to convert into . /// public CircleToHostConverter( - IRawConversion intervalConverter, - IRawConversion planeConverter + ITypedConverter intervalConverter, + ITypedConverter planeConverter ) { _intervalConverter = intervalConverter; @@ -40,7 +40,7 @@ public CircleToHostConverter( /// /// ⚠️ This conversion does NOT perform scaling. ///
⚠️ This conversion does not preserve the curve domain. If you need it preserved you must request a conversion to conversion instead
- public RG.Circle RawConvert(SOG.Circle target) + public RG.Circle Convert(SOG.Circle target) { if (target.radius == null) { @@ -48,11 +48,11 @@ public RG.Circle RawConvert(SOG.Circle target) throw new ArgumentNullException(nameof(target), "Circle radius cannot be null"); } - var plane = _planeConverter.RawConvert(target.plane); + var plane = _planeConverter.Convert(target.plane); var radius = target.radius.Value; return new RG.Circle(plane, radius); } - RG.ArcCurve IRawConversion.RawConvert(SOG.Circle target) => - new(RawConvert(target)) { Domain = _intervalConverter.RawConvert(target.domain) }; + RG.ArcCurve ITypedConverter.Convert(SOG.Circle target) => + new(Convert(target)) { Domain = _intervalConverter.Convert(target.domain) }; } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/CurveToHostConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/CurveToHostConverter.cs index a9b13e3b76..a61425dc2a 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/CurveToHostConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/CurveToHostConverter.cs @@ -3,26 +3,26 @@ namespace Speckle.Converters.Rhino7.ToHost.Raw; -public class CurveToHostConverter : IRawConversion +public class CurveToHostConverter : ITypedConverter { - private readonly IRawConversion _lineConverter; - private readonly IRawConversion _arcConverter; - private readonly IRawConversion _ellipseConverter; - private readonly IRawConversion _spiralConverter; - private readonly IRawConversion _circleConverter; - private readonly IRawConversion _polylineConverter; - private readonly IRawConversion _polyCurveConverter; - private readonly IRawConversion _nurbsCurveConverter; + private readonly ITypedConverter _lineConverter; + private readonly ITypedConverter _arcConverter; + private readonly ITypedConverter _ellipseConverter; + private readonly ITypedConverter _spiralConverter; + private readonly ITypedConverter _circleConverter; + private readonly ITypedConverter _polylineConverter; + private readonly ITypedConverter _polyCurveConverter; + private readonly ITypedConverter _nurbsCurveConverter; public CurveToHostConverter( - IRawConversion lineConverter, - IRawConversion arcConverter, - IRawConversion ellipseConverter, - IRawConversion spiralConverter, - IRawConversion circleConverter, - IRawConversion polylineConverter, - IRawConversion polyCurveConverter, - IRawConversion nurbsCurveConverter + ITypedConverter lineConverter, + ITypedConverter arcConverter, + ITypedConverter ellipseConverter, + ITypedConverter spiralConverter, + ITypedConverter circleConverter, + ITypedConverter polylineConverter, + ITypedConverter polyCurveConverter, + ITypedConverter nurbsCurveConverter ) { _lineConverter = lineConverter; @@ -42,17 +42,17 @@ public CurveToHostConverter( /// The converted RG.Curve object. /// Thrown when the conversion is not supported for the given type of curve. /// ⚠️ This conversion does NOT perform scaling. - public RG.Curve RawConvert(ICurve target) => + public RG.Curve Convert(ICurve target) => target switch { - SOG.Line line => _lineConverter.RawConvert(line), - SOG.Arc arc => _arcConverter.RawConvert(arc), - SOG.Circle circle => _circleConverter.RawConvert(circle), - SOG.Ellipse ellipse => _ellipseConverter.RawConvert(ellipse), - SOG.Spiral spiral => _spiralConverter.RawConvert(spiral), - SOG.Polyline polyline => _polylineConverter.RawConvert(polyline), - SOG.Curve curve => _nurbsCurveConverter.RawConvert(curve), - SOG.Polycurve polyCurve => _polyCurveConverter.RawConvert(polyCurve), + SOG.Line line => _lineConverter.Convert(line), + SOG.Arc arc => _arcConverter.Convert(arc), + SOG.Circle circle => _circleConverter.Convert(circle), + SOG.Ellipse ellipse => _ellipseConverter.Convert(ellipse), + SOG.Spiral spiral => _spiralConverter.Convert(spiral), + SOG.Polyline polyline => _polylineConverter.Convert(polyline), + SOG.Curve curve => _nurbsCurveConverter.Convert(curve), + SOG.Polycurve polyCurve => _polyCurveConverter.Convert(polyCurve), _ => throw new NotSupportedException($"Unable to convert curves of type {target.GetType().Name}") }; } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/EllipseToHostConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/EllipseToHostConverter.cs index a394547db8..74f309a61f 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/EllipseToHostConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/EllipseToHostConverter.cs @@ -3,15 +3,15 @@ namespace Speckle.Converters.Rhino7.ToHost.Raw; public class EllipseToHostConverter - : IRawConversion, - IRawConversion + : ITypedConverter, + ITypedConverter { - private readonly IRawConversion _planeConverter; - private readonly IRawConversion _intervalConverter; + private readonly ITypedConverter _planeConverter; + private readonly ITypedConverter _intervalConverter; public EllipseToHostConverter( - IRawConversion planeConverter, - IRawConversion intervalConverter + ITypedConverter planeConverter, + ITypedConverter intervalConverter ) { _planeConverter = planeConverter; @@ -26,18 +26,14 @@ public EllipseToHostConverter( /// Thrown when or properties are null. /// ⚠️ This conversion does NOT perform scaling. ///
⚠️ This conversion does not preserve the curve domain. If you need it preserved you must request a conversion to conversion instead
- public RG.Ellipse RawConvert(SOG.Ellipse target) + public RG.Ellipse Convert(SOG.Ellipse target) { if (!target.firstRadius.HasValue || !target.secondRadius.HasValue) { throw new InvalidOperationException($"Ellipses cannot have null radii"); } - return new RG.Ellipse( - _planeConverter.RawConvert(target.plane), - target.firstRadius.Value, - target.secondRadius.Value - ); + return new RG.Ellipse(_planeConverter.Convert(target.plane), target.firstRadius.Value, target.secondRadius.Value); } /// @@ -47,15 +43,15 @@ public RG.Ellipse RawConvert(SOG.Ellipse target) /// /// A that represents the provided . /// - RG.NurbsCurve IRawConversion.RawConvert(SOG.Ellipse target) + RG.NurbsCurve ITypedConverter.Convert(SOG.Ellipse target) { - var rhinoEllipse = RawConvert(target); + var rhinoEllipse = Convert(target); var rhinoNurbsEllipse = rhinoEllipse.ToNurbsCurve(); - rhinoNurbsEllipse.Domain = _intervalConverter.RawConvert(target.domain); + rhinoNurbsEllipse.Domain = _intervalConverter.Convert(target.domain); if (target.trimDomain != null) { - rhinoNurbsEllipse = rhinoNurbsEllipse.Trim(_intervalConverter.RawConvert(target.trimDomain)).ToNurbsCurve(); + rhinoNurbsEllipse = rhinoNurbsEllipse.Trim(_intervalConverter.Convert(target.trimDomain)).ToNurbsCurve(); } return rhinoNurbsEllipse; diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/FlatPointListToHostConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/FlatPointListToHostConverter.cs index 9865ff8c54..f0363a387d 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/FlatPointListToHostConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/FlatPointListToHostConverter.cs @@ -7,7 +7,7 @@ namespace Speckle.Converters.Rhino7.ToHost.Raw; /// /// Converts a flat list of raw double values to a Point3dList. /// -public class FlatPointListToHostConverter : IRawConversion, Point3dList> +public class FlatPointListToHostConverter : ITypedConverter, Point3dList> { /// /// Converts a flat list of raw double values to a Point3dList. @@ -19,7 +19,7 @@ public class FlatPointListToHostConverter : IRawConversion /// with the numbers being coordinates of each point in the format {x1, y1, z1, x2, y2, z2, ..., xN, yN, zN} /// /// Throws when the input list count is not a multiple of 3. - public Point3dList RawConvert(IReadOnlyList target) + public Point3dList Convert(IReadOnlyList target) { if (target.Count % 3 != 0) { diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/IntervalToHostConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/IntervalToHostConverter.cs index 405d1b2ac3..f201283ebd 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/IntervalToHostConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/IntervalToHostConverter.cs @@ -2,7 +2,7 @@ namespace Speckle.Converters.Rhino7.ToHost.Raw; -public class IntervalToHostConverter : IRawConversion +public class IntervalToHostConverter : ITypedConverter { /// /// Converts a Speckle Interval object to a Rhino.Geometry.Interval object. @@ -11,7 +11,7 @@ public class IntervalToHostConverter : IRawConversion /// The converted Rhino.Geometry.Interval object. /// Thrown when the start or end value of the Interval is null. /// ⚠️ This conversion does NOT perform scaling. - public RG.Interval RawConvert(SOP.Interval target) + public RG.Interval Convert(SOP.Interval target) { if (!target.start.HasValue || !target.end.HasValue) // POC: CNX-9272 Interval start and end being nullable makes no sense. { diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/LineToHostConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/LineToHostConverter.cs index 2d2846f1bf..c549e96741 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/LineToHostConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/LineToHostConverter.cs @@ -2,11 +2,11 @@ namespace Speckle.Converters.Rhino7.ToHost.Raw; -public class LineToHostConverter : IRawConversion, IRawConversion +public class LineToHostConverter : ITypedConverter, ITypedConverter { - private readonly IRawConversion _pointConverter; + private readonly ITypedConverter _pointConverter; - public LineToHostConverter(IRawConversion pointConverter) + public LineToHostConverter(ITypedConverter pointConverter) { _pointConverter = pointConverter; } @@ -22,13 +22,13 @@ public LineToHostConverter(IRawConversion pointConverter) /// If you need it preserved you must request a conversion to /// conversion instead /// - public RG.Line RawConvert(SOG.Line target) => - new(_pointConverter.RawConvert(target.start), _pointConverter.RawConvert(target.end)); + public RG.Line Convert(SOG.Line target) => + new(_pointConverter.Convert(target.start), _pointConverter.Convert(target.end)); /// /// Converts a Speckle Line object to a Rhino LineCurve object. /// /// The Speckle Line object to convert. /// Returns the resulting Rhino LineCurve object. - RG.LineCurve IRawConversion.RawConvert(SOG.Line target) => new(RawConvert(target)); + RG.LineCurve ITypedConverter.Convert(SOG.Line target) => new(Convert(target)); } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/MeshToHostConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/MeshToHostConverter.cs index adf67b4f8f..d3917dafd3 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/MeshToHostConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/MeshToHostConverter.cs @@ -5,11 +5,11 @@ namespace Speckle.Converters.Rhino7.ToHost.Raw; -public class MeshToHostConverter : IRawConversion +public class MeshToHostConverter : ITypedConverter { - private readonly IRawConversion, Point3dList> _pointListConverter; + private readonly ITypedConverter, Point3dList> _pointListConverter; - public MeshToHostConverter(IRawConversion, Point3dList> pointListConverter) + public MeshToHostConverter(ITypedConverter, Point3dList> pointListConverter) { _pointListConverter = pointListConverter; } @@ -20,13 +20,13 @@ public MeshToHostConverter(IRawConversion, Point3dList> po /// The Speckle mesh object to convert. /// A Rhino mesh object converted from the Speckle mesh. /// ⚠️ This conversion does NOT perform scaling. - public RG.Mesh RawConvert(SOG.Mesh target) + public RG.Mesh Convert(SOG.Mesh target) { target.AlignVerticesWithTexCoordsByIndex(); RG.Mesh m = new(); - var vertices = _pointListConverter.RawConvert(target.vertices); + var vertices = _pointListConverter.Convert(target.vertices); var colors = target.colors.Select(Color.FromArgb).ToArray(); m.Vertices.AddVertices(vertices); diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/NurbsCurveToHostConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/NurbsCurveToHostConverter.cs index 8a18c5b413..9f9bf52811 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/NurbsCurveToHostConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/NurbsCurveToHostConverter.cs @@ -3,11 +3,11 @@ namespace Speckle.Converters.Rhino7.ToHost.Raw; -public class NurbsCurveToHostConverter : IRawConversion +public class NurbsCurveToHostConverter : ITypedConverter { - private readonly IRawConversion _intervalConverter; + private readonly ITypedConverter _intervalConverter; - public NurbsCurveToHostConverter(IRawConversion intervalConverter) + public NurbsCurveToHostConverter(ITypedConverter intervalConverter) { _intervalConverter = intervalConverter; } @@ -19,7 +19,7 @@ public NurbsCurveToHostConverter(IRawConversion inter /// The converted Rhino NurbsCurve object. /// Thrown when the conversion fails. /// ⚠️ This conversion does NOT perform scaling. - public RG.NurbsCurve RawConvert(SOG.Curve target) + public RG.NurbsCurve Convert(SOG.Curve target) { RG.NurbsCurve nurbsCurve = new(target.degree, target.points.Count / 3); @@ -45,7 +45,7 @@ public RG.NurbsCurve RawConvert(SOG.Curve target) } } - nurbsCurve.Domain = _intervalConverter.RawConvert(target.domain); + nurbsCurve.Domain = _intervalConverter.Convert(target.domain); return nurbsCurve; } } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/PlaneToHostConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/PlaneToHostConverter.cs index e4068eeeba..49e10ab69e 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/PlaneToHostConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/PlaneToHostConverter.cs @@ -2,14 +2,14 @@ namespace Speckle.Converters.Rhino7.ToHost.Raw; -public class PlaneToHostConverter : IRawConversion +public class PlaneToHostConverter : ITypedConverter { - private readonly IRawConversion _pointConverter; - private readonly IRawConversion _vectorConverter; + private readonly ITypedConverter _pointConverter; + private readonly ITypedConverter _vectorConverter; public PlaneToHostConverter( - IRawConversion pointConverter, - IRawConversion vectorConverter + ITypedConverter pointConverter, + ITypedConverter vectorConverter ) { _pointConverter = pointConverter; @@ -22,10 +22,10 @@ public PlaneToHostConverter( /// The Speckle Plane object to be converted. /// The converted Rhino Plane object. /// ⚠️ This conversion does NOT perform scaling. - public RG.Plane RawConvert(SOG.Plane target) => + public RG.Plane Convert(SOG.Plane target) => new( - _pointConverter.RawConvert(target.origin), - _vectorConverter.RawConvert(target.xdir), - _vectorConverter.RawConvert(target.ydir) + _pointConverter.Convert(target.origin), + _vectorConverter.Convert(target.xdir), + _vectorConverter.Convert(target.ydir) ); } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/PointCloudToHostConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/PointCloudToHostConverter.cs index 327c594cad..a6d749b15c 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/PointCloudToHostConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/PointCloudToHostConverter.cs @@ -4,11 +4,11 @@ namespace Speckle.Converters.Rhino7.ToHost.Raw; -public class PointCloudToHostConverter : IRawConversion +public class PointCloudToHostConverter : ITypedConverter { - private readonly IRawConversion, Point3dList> _pointListConverter; + private readonly ITypedConverter, Point3dList> _pointListConverter; - public PointCloudToHostConverter(IRawConversion, Point3dList> pointListConverter) + public PointCloudToHostConverter(ITypedConverter, Point3dList> pointListConverter) { _pointListConverter = pointListConverter; } @@ -19,9 +19,9 @@ public PointCloudToHostConverter(IRawConversion, Point3dLi /// The raw Speckle Pointcloud object to convert. /// The converted Rhino PointCloud object. /// ⚠️ This conversion does NOT perform scaling. - public RG.PointCloud RawConvert(SOG.Pointcloud target) + public RG.PointCloud Convert(SOG.Pointcloud target) { - var rhinoPoints = _pointListConverter.RawConvert(target.points); + var rhinoPoints = _pointListConverter.Convert(target.points); var rhinoPointCloud = new RG.PointCloud(rhinoPoints); if (target.colors.Count == rhinoPoints.Count) diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/PointToHostConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/PointToHostConverter.cs index 676203ef0a..8ce40bcb59 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/PointToHostConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/PointToHostConverter.cs @@ -2,7 +2,7 @@ namespace Speckle.Converters.Rhino7.ToHost.Raw; -public class PointToHostConverter : IRawConversion, IRawConversion +public class PointToHostConverter : ITypedConverter, ITypedConverter { /// /// Converts a Speckle Point object to a Rhino Point3d object. @@ -10,7 +10,7 @@ public class PointToHostConverter : IRawConversion, IRawC /// The Speckle Point object to convert. /// The converted Rhino Point3d object. /// ⚠️ This conversion does NOT perform scaling. - public RG.Point3d RawConvert(SOG.Point target) => new(target.x, target.y, target.z); + public RG.Point3d Convert(SOG.Point target) => new(target.x, target.y, target.z); /// /// Converts a Speckle Point object to a Rhino Point object. @@ -18,5 +18,5 @@ public class PointToHostConverter : IRawConversion, IRawC /// The Speckle Point object to convert. /// The converted Rhino Point object. /// ⚠️ This conversion does NOT perform scaling. - RG.Point IRawConversion.RawConvert(SOG.Point target) => new(RawConvert(target)); + RG.Point ITypedConverter.Convert(SOG.Point target) => new(Convert(target)); } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/PolyCurveToHostConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/PolyCurveToHostConverter.cs index a1498f07c2..3f35905090 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/PolyCurveToHostConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/PolyCurveToHostConverter.cs @@ -5,13 +5,13 @@ namespace Speckle.Converters.Rhino7.ToHost.Raw; -public class PolyCurveToHostConverter : IRawConversion +public class PolyCurveToHostConverter : ITypedConverter { - public IRawConversion? CurveConverter { get; set; } // POC: CNX-9311 Circular dependency injected by the container using property. + public ITypedConverter? CurveConverter { get; set; } // POC: CNX-9311 Circular dependency injected by the container using property. - private readonly IRawConversion _intervalConverter; + private readonly ITypedConverter _intervalConverter; - public PolyCurveToHostConverter(IRawConversion intervalConverter) + public PolyCurveToHostConverter(ITypedConverter intervalConverter) { _intervalConverter = intervalConverter; } @@ -22,13 +22,13 @@ public PolyCurveToHostConverter(IRawConversion interv /// The SpecklePolyCurve object to convert. /// The converted Rhino PolyCurve object. /// ⚠️ This conversion does NOT perform scaling. - public RG.PolyCurve RawConvert(SOG.Polycurve target) + public RG.PolyCurve Convert(SOG.Polycurve target) { RG.PolyCurve result = new(); foreach (var segment in target.segments) { - var childCurve = CurveConverter.NotNull().RawConvert(segment); + var childCurve = CurveConverter.NotNull().Convert(segment); bool success = result.AppendSegment(childCurve); if (!success) { @@ -36,7 +36,7 @@ public RG.PolyCurve RawConvert(SOG.Polycurve target) } } - result.Domain = _intervalConverter.RawConvert(target.domain); + result.Domain = _intervalConverter.Convert(target.domain); return result; } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/PolylineToHostConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/PolylineToHostConverter.cs index 546becbb40..5abe48fed5 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/PolylineToHostConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/PolylineToHostConverter.cs @@ -4,15 +4,15 @@ namespace Speckle.Converters.Rhino7.ToHost.Raw; public class PolylineToHostConverter - : IRawConversion, - IRawConversion + : ITypedConverter, + ITypedConverter { - private readonly IRawConversion, Point3dList> _pointListConverter; - private readonly IRawConversion _intervalConverter; + private readonly ITypedConverter, Point3dList> _pointListConverter; + private readonly ITypedConverter _intervalConverter; public PolylineToHostConverter( - IRawConversion, Point3dList> pointListConverter, - IRawConversion intervalConverter + ITypedConverter, Point3dList> pointListConverter, + ITypedConverter intervalConverter ) { _pointListConverter = pointListConverter; @@ -30,9 +30,9 @@ public PolylineToHostConverter( /// If you need it preserved you must request a conversion to /// conversion instead /// - public RG.Polyline RawConvert(SOG.Polyline target) + public RG.Polyline Convert(SOG.Polyline target) { - var points = _pointListConverter.RawConvert(target.value); + var points = _pointListConverter.Convert(target.value); if (target.closed) { @@ -52,10 +52,10 @@ public RG.Polyline RawConvert(SOG.Polyline target) /// The Speckle polyline object to be converted. /// The converted Rhino Polyline object. /// ⚠️ This conversion does NOT perform scaling. - RG.PolylineCurve IRawConversion.RawConvert(SOG.Polyline target) + RG.PolylineCurve ITypedConverter.Convert(SOG.Polyline target) { - var poly = RawConvert(target).ToPolylineCurve(); - poly.Domain = _intervalConverter.RawConvert(target.domain); + var poly = Convert(target).ToPolylineCurve(); + poly.Domain = _intervalConverter.Convert(target.domain); return poly; } } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpiralToHostConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpiralToHostConverter.cs index eaaf5d92e6..cb7f5a8745 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpiralToHostConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpiralToHostConverter.cs @@ -2,14 +2,14 @@ namespace Speckle.Converters.Rhino7.ToHost.Raw; -public class SpiralToHostConverter : IRawConversion +public class SpiralToHostConverter : ITypedConverter { - private readonly IRawConversion _polylineConverter; - private readonly IRawConversion _intervalConverter; + private readonly ITypedConverter _polylineConverter; + private readonly ITypedConverter _intervalConverter; public SpiralToHostConverter( - IRawConversion polylineConverter, - IRawConversion intervalConverter + ITypedConverter polylineConverter, + ITypedConverter intervalConverter ) { _polylineConverter = polylineConverter; @@ -22,10 +22,10 @@ public SpiralToHostConverter( /// The Speckle Spiral object to be converted. /// A Rhino PolylineCurve object. /// ⚠️ This conversion does NOT perform scaling. - public RG.PolylineCurve RawConvert(SOG.Spiral target) + public RG.PolylineCurve Convert(SOG.Spiral target) { - var result = _polylineConverter.RawConvert(target.displayValue); - result.Domain = _intervalConverter.RawConvert(target.domain); + var result = _polylineConverter.Convert(target.displayValue); + result.Domain = _intervalConverter.Convert(target.domain); return result; } } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SurfaceToHostConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SurfaceToHostConverter.cs index 0cb7e67818..91da44ec59 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SurfaceToHostConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SurfaceToHostConverter.cs @@ -2,7 +2,7 @@ namespace Speckle.Converters.Rhino7.ToHost.Raw; -public class SurfaceToHostConverter : IRawConversion +public class SurfaceToHostConverter : ITypedConverter { /// /// Converts a raw Speckle surface to a Rhino NURBS surface. @@ -10,7 +10,7 @@ public class SurfaceToHostConverter : IRawConversionThe raw Speckle surface to convert. /// The converted Rhino NURBS surface. /// ⚠️ This conversion does NOT perform scaling. - public RG.NurbsSurface RawConvert(SOG.Surface target) + public RG.NurbsSurface Convert(SOG.Surface target) { // Create rhino surface var points = target.GetControlPoints().ToList(); diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/VectorToHostConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/VectorToHostConverter.cs index c0b4bd0b61..77e017f0fd 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/VectorToHostConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/VectorToHostConverter.cs @@ -2,7 +2,7 @@ namespace Speckle.Converters.Rhino7.ToHost.Raw; -public class VectorToHostConverter : IRawConversion +public class VectorToHostConverter : ITypedConverter { /// /// Converts a Speckle.Vector object to a Rhino Vector3d object. @@ -10,5 +10,5 @@ public class VectorToHostConverter : IRawConversion /// The Speckle.Vector to be converted. /// The converted Rhino Vector3d object. /// ⚠️ This conversion does NOT perform scaling. - public RG.Vector3d RawConvert(SOG.Vector target) => new(target.x, target.y, target.z); + public RG.Vector3d Convert(SOG.Vector target) => new(target.x, target.y, target.z); } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/ArcToHostTopLevelConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/ArcToHostTopLevelConverter.cs index 682ccab3e5..12c4420914 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/ArcToHostTopLevelConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/ArcToHostTopLevelConverter.cs @@ -5,11 +5,11 @@ namespace Speckle.Converters.Rhino7.ToHost.TopLevel; [NameAndRankValue(nameof(SOG.Arc), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class ArcToHostTopLevelConverter : SpeckleToHostGeometryBaseConversion +public class ArcToHostTopLevelConverter : SpeckleToHostGeometryBaseTopLevelConverter { public ArcToHostTopLevelConverter( IConversionContextStack contextStack, - IRawConversion geometryBaseConverter + ITypedConverter geometryBaseConverter ) : base(contextStack, geometryBaseConverter) { } } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/BrepToHostTopLevelConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/BrepToHostTopLevelConverter.cs index c8b963517d..6ca70d3ad1 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/BrepToHostTopLevelConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/BrepToHostTopLevelConverter.cs @@ -5,11 +5,11 @@ namespace Speckle.Converters.Rhino7.ToHost.TopLevel; [NameAndRankValue(nameof(SOG.Brep), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class BrepToHostTopLevelConverter : SpeckleToHostGeometryBaseConversion +public class BrepToHostTopLevelConverter : SpeckleToHostGeometryBaseTopLevelConverter { public BrepToHostTopLevelConverter( IConversionContextStack contextStack, - IRawConversion geometryBaseConverter + ITypedConverter geometryBaseConverter ) : base(contextStack, geometryBaseConverter) { } } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/CircleToHostTopLevelConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/CircleToHostTopLevelConverter.cs index d3c21b737f..1493120e57 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/CircleToHostTopLevelConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/CircleToHostTopLevelConverter.cs @@ -5,11 +5,11 @@ namespace Speckle.Converters.Rhino7.ToHost.TopLevel; [NameAndRankValue(nameof(SOG.Circle), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class CircleToHostTopLevelConverter : SpeckleToHostGeometryBaseConversion +public class CircleToHostTopLevelConverter : SpeckleToHostGeometryBaseTopLevelConverter { public CircleToHostTopLevelConverter( IConversionContextStack contextStack, - IRawConversion geometryBaseConverter + ITypedConverter geometryBaseConverter ) : base(contextStack, geometryBaseConverter) { } } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/EllipseToHostTopLevelConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/EllipseToHostTopLevelConverter.cs index 20040aa439..e6a4b03a41 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/EllipseToHostTopLevelConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/EllipseToHostTopLevelConverter.cs @@ -5,11 +5,11 @@ namespace Speckle.Converters.Rhino7.ToHost.TopLevel; [NameAndRankValue(nameof(SOG.Ellipse), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class EllipseToHostTopLevelConverter : SpeckleToHostGeometryBaseConversion +public class EllipseToHostTopLevelConverter : SpeckleToHostGeometryBaseTopLevelConverter { public EllipseToHostTopLevelConverter( IConversionContextStack contextStack, - IRawConversion geometryBaseConverter + ITypedConverter geometryBaseConverter ) : base(contextStack, geometryBaseConverter) { } } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/FallbackToHostTopLevelConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/FallbackToHostTopLevelConverter.cs index be7ff4491d..811433890c 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/FallbackToHostTopLevelConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/FallbackToHostTopLevelConverter.cs @@ -8,18 +8,18 @@ namespace Speckle.Converters.Rhino7.ToHost.TopLevel; [NameAndRankValue(nameof(DisplayableObject), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] public class FallbackToHostTopLevelConverter - : ISpeckleObjectToHostConversion, - IRawConversion> + : IToHostTopLevelConverter, + ITypedConverter> { - private readonly IRawConversion _lineConverter; - private readonly IRawConversion _polylineConverter; - private readonly IRawConversion _meshConverter; + private readonly ITypedConverter _lineConverter; + private readonly ITypedConverter _polylineConverter; + private readonly ITypedConverter _meshConverter; private readonly IConversionContextStack _contextStack; public FallbackToHostTopLevelConverter( - IRawConversion lineConverter, - IRawConversion polylineConverter, - IRawConversion meshConverter, + ITypedConverter lineConverter, + ITypedConverter polylineConverter, + ITypedConverter meshConverter, IConversionContextStack contextStack ) { @@ -29,18 +29,18 @@ IConversionContextStack contextStack _contextStack = contextStack; } - public object Convert(Base target) => RawConvert((DisplayableObject)target); + public object Convert(Base target) => Convert((DisplayableObject)target); - public List RawConvert(DisplayableObject target) + public List Convert(DisplayableObject target) { var result = new List(); foreach (var item in target.displayValue) { RG.GeometryBase x = item switch { - SOG.Line line => _lineConverter.RawConvert(line), - SOG.Polyline polyline => _polylineConverter.RawConvert(polyline), - SOG.Mesh mesh => _meshConverter.RawConvert(mesh), + SOG.Line line => _lineConverter.Convert(line), + SOG.Polyline polyline => _polylineConverter.Convert(polyline), + SOG.Mesh mesh => _meshConverter.Convert(mesh), _ => throw new NotSupportedException($"Found unsupported fallback geometry: {item.GetType()}") }; x.Transform(GetUnitsTransform(item)); diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/LineToHostTopLevelConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/LineToHostTopLevelConverter.cs index 28c5dbe39e..5a64a3ebab 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/LineToHostTopLevelConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/LineToHostTopLevelConverter.cs @@ -5,11 +5,11 @@ namespace Speckle.Converters.Rhino7.ToHost.TopLevel; [NameAndRankValue(nameof(SOG.Line), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class LineToHostTopLevelConverter : SpeckleToHostGeometryBaseConversion +public class LineToHostTopLevelConverter : SpeckleToHostGeometryBaseTopLevelConverter { public LineToHostTopLevelConverter( IConversionContextStack contextStack, - IRawConversion geometryBaseConverter + ITypedConverter geometryBaseConverter ) : base(contextStack, geometryBaseConverter) { } } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/MeshToHostTopLevelConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/MeshToHostTopLevelConverter.cs index 573a401934..c7d047df3b 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/MeshToHostTopLevelConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/MeshToHostTopLevelConverter.cs @@ -5,11 +5,11 @@ namespace Speckle.Converters.Rhino7.ToHost.TopLevel; [NameAndRankValue(nameof(SOG.Mesh), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class MeshToHostTopLevelConverter : SpeckleToHostGeometryBaseConversion +public class MeshToHostTopLevelConverter : SpeckleToHostGeometryBaseTopLevelConverter { public MeshToHostTopLevelConverter( IConversionContextStack contextStack, - IRawConversion geometryBaseConverter + ITypedConverter geometryBaseConverter ) : base(contextStack, geometryBaseConverter) { } } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/NurbsCurveToHostTopLevelConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/NurbsCurveToHostTopLevelConverter.cs index fed264c879..987b46161f 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/NurbsCurveToHostTopLevelConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/NurbsCurveToHostTopLevelConverter.cs @@ -5,11 +5,11 @@ namespace Speckle.Converters.Rhino7.ToHost.TopLevel; [NameAndRankValue(nameof(SOG.Curve), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class NurbsCurveToHostTopLevelConverter : SpeckleToHostGeometryBaseConversion +public class NurbsCurveToHostTopLevelConverter : SpeckleToHostGeometryBaseTopLevelConverter { public NurbsCurveToHostTopLevelConverter( IConversionContextStack contextStack, - IRawConversion geometryBaseConverter + ITypedConverter geometryBaseConverter ) : base(contextStack, geometryBaseConverter) { } } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/PointCloudToHostTopLevelConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/PointCloudToHostTopLevelConverter.cs index 7a8f5c962a..51a2613e90 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/PointCloudToHostTopLevelConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/PointCloudToHostTopLevelConverter.cs @@ -5,11 +5,12 @@ namespace Speckle.Converters.Rhino7.ToHost.TopLevel; [NameAndRankValue(nameof(SOG.Pointcloud), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class PointCloudToHostTopLevelConverter : SpeckleToHostGeometryBaseConversion +public class PointCloudToHostTopLevelConverter + : SpeckleToHostGeometryBaseTopLevelConverter { public PointCloudToHostTopLevelConverter( IConversionContextStack contextStack, - IRawConversion geometryBaseConverter + ITypedConverter geometryBaseConverter ) : base(contextStack, geometryBaseConverter) { } } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/PointToHostTopLevelConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/PointToHostTopLevelConverter.cs index 94d3049b6f..de10053ce9 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/PointToHostTopLevelConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/PointToHostTopLevelConverter.cs @@ -5,11 +5,11 @@ namespace Speckle.Converters.Rhino7.ToHost.TopLevel; [NameAndRankValue(nameof(SOG.Point), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class PointToHostTopLevelConverter : SpeckleToHostGeometryBaseConversion +public class PointToHostTopLevelConverter : SpeckleToHostGeometryBaseTopLevelConverter { public PointToHostTopLevelConverter( IConversionContextStack contextStack, - IRawConversion geometryBaseConverter + ITypedConverter geometryBaseConverter ) : base(contextStack, geometryBaseConverter) { } } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/PolycurveToHostTopLevelConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/PolycurveToHostTopLevelConverter.cs index 48f9555b3b..d6f8d2f14b 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/PolycurveToHostTopLevelConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/PolycurveToHostTopLevelConverter.cs @@ -5,11 +5,11 @@ namespace Speckle.Converters.Rhino7.ToHost.TopLevel; [NameAndRankValue(nameof(SOG.Polycurve), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class PolycurveToHostTopLevelConverter : SpeckleToHostGeometryBaseConversion +public class PolycurveToHostTopLevelConverter : SpeckleToHostGeometryBaseTopLevelConverter { public PolycurveToHostTopLevelConverter( IConversionContextStack contextStack, - IRawConversion geometryBaseConverter + ITypedConverter geometryBaseConverter ) : base(contextStack, geometryBaseConverter) { } } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/PolylineToHostTopLevelConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/PolylineToHostTopLevelConverter.cs index 388cf84bc2..081f217f04 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/PolylineToHostTopLevelConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/PolylineToHostTopLevelConverter.cs @@ -5,11 +5,12 @@ namespace Speckle.Converters.Rhino7.ToHost.TopLevel; [NameAndRankValue(nameof(SOG.Polyline), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class PolylineToHostTopLevelConverter : SpeckleToHostGeometryBaseConversion +public class PolylineToHostTopLevelConverter + : SpeckleToHostGeometryBaseTopLevelConverter { public PolylineToHostTopLevelConverter( IConversionContextStack contextStack, - IRawConversion geometryBaseConverter + ITypedConverter geometryBaseConverter ) : base(contextStack, geometryBaseConverter) { } } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/ArcCurveToSpeckleConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/ArcCurveToSpeckleConverter.cs index d40330cba6..8a3eee9cb7 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/ArcCurveToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/ArcCurveToSpeckleConverter.cs @@ -6,17 +6,17 @@ namespace Speckle.Converters.Rhino7.ToSpeckle.Raw; -public class ArcCurveToSpeckleConverter : IRawConversion, IRawConversion +public class ArcCurveToSpeckleConverter : ITypedConverter, ITypedConverter { - private readonly IRawConversion _circleConverter; - private readonly IRawConversion _arcConverter; - private readonly IRawConversion _intervalConverter; + private readonly ITypedConverter _circleConverter; + private readonly ITypedConverter _arcConverter; + private readonly ITypedConverter _intervalConverter; private readonly IConversionContextStack _contextStack; public ArcCurveToSpeckleConverter( - IRawConversion circleConverter, - IRawConversion arcConverter, - IRawConversion intervalConverter, + ITypedConverter circleConverter, + ITypedConverter arcConverter, + ITypedConverter intervalConverter, IConversionContextStack contextStack ) { @@ -36,26 +36,26 @@ IConversionContextStack contextStack /// Otherwise, the output will be a Speckle Arc.
/// ✅ This method preserves the domain of the original ArcCurve.
/// - public ICurve RawConvert(RG.ArcCurve target) + public ICurve Convert(RG.ArcCurve target) { var tolerance = _contextStack.Current.Document.ModelAbsoluteTolerance; if (target.IsCompleteCircle) { target.TryGetCircle(out var getObj, tolerance); - var cir = _circleConverter.RawConvert(getObj); - cir.domain = _intervalConverter.RawConvert(target.Domain); + var cir = _circleConverter.Convert(getObj); + cir.domain = _intervalConverter.Convert(target.Domain); return cir; } - var arc = _arcConverter.RawConvert(target.Arc); - arc.domain = _intervalConverter.RawConvert(target.Domain); + var arc = _arcConverter.Convert(target.Arc); + arc.domain = _intervalConverter.Convert(target.Domain); return arc; } // POC: CNX-9275 Need to implement this because ICurve and Base are not related, this one is needed at the top-level, the other is for better typed experience. // This also causes us to have to force cast ICurve to Base as a result, which is expected to always succeed but not nice. - /// + /// /// The converted ICurve with a cast to object - Base IRawConversion.RawConvert(RG.ArcCurve target) => (Base)RawConvert(target); + Base ITypedConverter.Convert(RG.ArcCurve target) => (Base)Convert(target); } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/ArcToSpeckleConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/ArcToSpeckleConverter.cs index b96049f613..82c89c2551 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/ArcToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/ArcToSpeckleConverter.cs @@ -4,17 +4,17 @@ namespace Speckle.Converters.Rhino7.ToSpeckle.Raw; -public class ArcToSpeckleConverter : IRawConversion +public class ArcToSpeckleConverter : ITypedConverter { - private readonly IRawConversion _pointConverter; - private readonly IRawConversion _planeConverter; - private readonly IRawConversion _boxConverter; + private readonly ITypedConverter _pointConverter; + private readonly ITypedConverter _planeConverter; + private readonly ITypedConverter _boxConverter; private readonly IConversionContextStack _contextStack; public ArcToSpeckleConverter( - IRawConversion pointConverter, - IRawConversion planeConverter, - IRawConversion boxConverter, + ITypedConverter pointConverter, + ITypedConverter planeConverter, + ITypedConverter boxConverter, IConversionContextStack contextStack ) { @@ -32,9 +32,9 @@ IConversionContextStack contextStack /// /// This method assumes the domain of the arc is (0,1) as Arc types in Rhino do not have domain. You may want to request a conversion from ArcCurve instead. /// - public SOG.Arc RawConvert(RG.Arc target) => + public SOG.Arc Convert(RG.Arc target) => new( - _planeConverter.RawConvert(target.Plane), + _planeConverter.Convert(target.Plane), target.Radius, target.StartAngle, target.EndAngle, @@ -42,11 +42,11 @@ public SOG.Arc RawConvert(RG.Arc target) => _contextStack.Current.SpeckleUnits ) { - startPoint = _pointConverter.RawConvert(target.StartPoint), - midPoint = _pointConverter.RawConvert(target.MidPoint), - endPoint = _pointConverter.RawConvert(target.EndPoint), + startPoint = _pointConverter.Convert(target.StartPoint), + midPoint = _pointConverter.Convert(target.MidPoint), + endPoint = _pointConverter.Convert(target.EndPoint), domain = new SOP.Interval(0, 1), length = target.Length, - bbox = _boxConverter.RawConvert(new RG.Box(target.BoundingBox())) + bbox = _boxConverter.Convert(new RG.Box(target.BoundingBox())) }; } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/BoxToSpeckleConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/BoxToSpeckleConverter.cs index 6c1526f83d..cebd6e5d70 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/BoxToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/BoxToSpeckleConverter.cs @@ -4,15 +4,15 @@ namespace Speckle.Converters.Rhino7.ToSpeckle.Raw; -public class BoxToSpeckleConverter : IRawConversion +public class BoxToSpeckleConverter : ITypedConverter { - private readonly IRawConversion _planeConverter; - private readonly IRawConversion _intervalConverter; + private readonly ITypedConverter _planeConverter; + private readonly ITypedConverter _intervalConverter; private readonly IConversionContextStack _contextStack; public BoxToSpeckleConverter( - IRawConversion planeConverter, - IRawConversion intervalConverter, + ITypedConverter planeConverter, + ITypedConverter intervalConverter, IConversionContextStack contextStack ) { @@ -26,12 +26,12 @@ IConversionContextStack contextStack ///
/// The Rhino Box object to convert. /// The converted Speckle Box object. - public SOG.Box RawConvert(RG.Box target) => + public SOG.Box Convert(RG.Box target) => new( - _planeConverter.RawConvert(target.Plane), - _intervalConverter.RawConvert(target.X), - _intervalConverter.RawConvert(target.Y), - _intervalConverter.RawConvert(target.Z), + _planeConverter.Convert(target.Plane), + _intervalConverter.Convert(target.X), + _intervalConverter.Convert(target.Y), + _intervalConverter.Convert(target.Z), _contextStack.Current.SpeckleUnits ) { diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/BrepToSpeckleConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/BrepToSpeckleConverter.cs index ef5e607bc2..236653d4d7 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/BrepToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/BrepToSpeckleConverter.cs @@ -7,23 +7,23 @@ namespace Speckle.Converters.Rhino7.ToSpeckle.Raw; -public class BrepToSpeckleConverter : IRawConversion +public class BrepToSpeckleConverter : ITypedConverter { - private readonly IRawConversion _pointConverter; - private readonly IRawConversion _curveConverter; - private readonly IRawConversion _surfaceConverter; - private readonly IRawConversion _meshConverter; - private readonly IRawConversion _boxConverter; - private readonly IRawConversion _intervalConverter; + private readonly ITypedConverter _pointConverter; + private readonly ITypedConverter _curveConverter; + private readonly ITypedConverter _surfaceConverter; + private readonly ITypedConverter _meshConverter; + private readonly ITypedConverter _boxConverter; + private readonly ITypedConverter _intervalConverter; private readonly IConversionContextStack _contextStack; public BrepToSpeckleConverter( - IRawConversion pointConverter, - IRawConversion curveConverter, - IRawConversion surfaceConverter, - IRawConversion meshConverter, - IRawConversion boxConverter, - IRawConversion intervalConverter, + ITypedConverter pointConverter, + ITypedConverter curveConverter, + ITypedConverter surfaceConverter, + ITypedConverter meshConverter, + ITypedConverter boxConverter, + ITypedConverter intervalConverter, IConversionContextStack contextStack ) { @@ -41,7 +41,7 @@ IConversionContextStack contextStack ///
/// The Brep object to convert. /// The converted Speckle Brep object. - public SOG.Brep RawConvert(RG.Brep target) + public SOG.Brep Convert(RG.Brep target) { var tol = _contextStack.Current.Document.ModelAbsoluteTolerance; target.Repair(tol); @@ -57,7 +57,7 @@ public SOG.Brep RawConvert(RG.Brep target) var displayValue = new List(); if (displayMesh != null) { - displayValue.Add(_meshConverter.RawConvert(displayMesh)); + displayValue.Add(_meshConverter.Convert(displayMesh)); } // POC: CNX-9277 Swap input material for something coming from the context. @@ -67,15 +67,15 @@ public SOG.Brep RawConvert(RG.Brep target) // } // Vertices, uv curves, 3d curves and surfaces - var vertices = target.Vertices.Select(vertex => _pointConverter.RawConvert(vertex.Location)).ToList(); - var curves3d = target.Curves3D.Select(curve3d => _curveConverter.RawConvert(curve3d)).ToList(); - var surfaces = target.Surfaces.Select(srf => _surfaceConverter.RawConvert(srf.ToNurbsSurface())).ToList(); + var vertices = target.Vertices.Select(vertex => _pointConverter.Convert(vertex.Location)).ToList(); + var curves3d = target.Curves3D.Select(curve3d => _curveConverter.Convert(curve3d)).ToList(); + var surfaces = target.Surfaces.Select(srf => _surfaceConverter.Convert(srf.ToNurbsSurface())).ToList(); List curves2d; using (_contextStack.Push(Units.None)) { // Curves2D are unitless, so we convert them within a new pushed context with None units. - curves2d = target.Curves2D.Select(curve2d => _curveConverter.RawConvert(curve2d)).ToList(); + curves2d = target.Curves2D.Select(curve2d => _curveConverter.Convert(curve2d)).ToList(); } var speckleBrep = new SOG.Brep @@ -89,7 +89,7 @@ public SOG.Brep RawConvert(RG.Brep target) Orientation = (SOG.BrepOrientation)target.SolidOrientation, volume = target.IsSolid ? target.GetVolume() : 0, area = target.GetArea(), - bbox = _boxConverter.RawConvert(new RG.Box(target.GetBoundingBox(false))), + bbox = _boxConverter.Convert(new RG.Box(target.GetBoundingBox(false))), units = _contextStack.Current.SpeckleUnits }; @@ -131,7 +131,7 @@ public SOG.Brep RawConvert(RG.Brep target) edge.StartVertex?.VertexIndex ?? -1, edge.EndVertex?.VertexIndex ?? -1, edge.ProxyCurveIsReversed, - _intervalConverter.RawConvert(edge.Domain) + _intervalConverter.Convert(edge.Domain) ) ) .ToList(); @@ -153,7 +153,7 @@ public SOG.Brep RawConvert(RG.Brep target) trim.EndVertex.VertexIndex ) { - Domain = _intervalConverter.RawConvert(trim.Domain) + Domain = _intervalConverter.Convert(trim.Domain) }; return t; diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/CircleToSpeckleConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/CircleToSpeckleConverter.cs index efb03701b5..0e3f91e3bf 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/CircleToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/CircleToSpeckleConverter.cs @@ -5,13 +5,13 @@ namespace Speckle.Converters.Rhino7.ToSpeckle.Raw; -public class CircleToSpeckleConverter : IRawConversion +public class CircleToSpeckleConverter : ITypedConverter { - private readonly IRawConversion _planeConverter; + private readonly ITypedConverter _planeConverter; private readonly IConversionContextStack _contextStack; public CircleToSpeckleConverter( - IRawConversion planeConverter, + ITypedConverter planeConverter, IConversionContextStack contextStack ) { @@ -19,7 +19,7 @@ IConversionContextStack contextStack _contextStack = contextStack; } - public Base Convert(object target) => RawConvert((RG.Circle)target); + public Base Convert(object target) => Convert((RG.Circle)target); /// /// Converts a RG.Circle object to a SOG.Circle object. @@ -29,8 +29,8 @@ IConversionContextStack contextStack /// /// ⚠️ This conversion assumes the domain of a circle is (0,1) as Rhino Circle types do not have a domain. If you want to preserve the domain use ArcCurve conversion instead. /// - public SOG.Circle RawConvert(RG.Circle target) => - new(_planeConverter.RawConvert(target.Plane), target.Radius, _contextStack.Current.SpeckleUnits) + public SOG.Circle Convert(RG.Circle target) => + new(_planeConverter.Convert(target.Plane), target.Radius, _contextStack.Current.SpeckleUnits) { domain = new SOP.Interval(0, 1), length = 2 * Math.PI * target.Radius, diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/ControlPointToSpeckleConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/ControlPointToSpeckleConverter.cs index f06ea34ed7..d3747e2faf 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/ControlPointToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/ControlPointToSpeckleConverter.cs @@ -5,7 +5,7 @@ namespace Speckle.Converters.Rhino7.ToSpeckle.Raw; -public class ControlPointToSpeckleConverter : IRawConversion +public class ControlPointToSpeckleConverter : ITypedConverter { private readonly IConversionContextStack _contextStack; @@ -19,8 +19,8 @@ public ControlPointToSpeckleConverter(IConversionContextStack /// The ControlPoint object to convert. /// The converted Speckle ControlPoint object. - public SOG.ControlPoint RawConvert(RG.ControlPoint target) => + public SOG.ControlPoint Convert(RG.ControlPoint target) => new(target.Location.X, target.Location.Y, target.Location.Z, target.Weight, _contextStack.Current.SpeckleUnits); - public Base Convert(object target) => RawConvert((RG.ControlPoint)target); + public Base Convert(object target) => Convert((RG.ControlPoint)target); } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/CurveToSpeckleConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/CurveToSpeckleConverter.cs index c842b0d31a..5c792ebaf8 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/CurveToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/CurveToSpeckleConverter.cs @@ -5,20 +5,20 @@ namespace Speckle.Converters.Rhino7.ToSpeckle.Raw; // POC: CNX-9278 This converter decides which specific curve conversion to use. IIndex may be a better choice. -public class CurveToSpeckleConverter : IRawConversion, IRawConversion +public class CurveToSpeckleConverter : ITypedConverter, ITypedConverter { - private readonly IRawConversion _polyCurveConverter; - private readonly IRawConversion _arcCurveConverter; - private readonly IRawConversion _polylineConverter; - private readonly IRawConversion _nurbsCurveConverter; - private readonly IRawConversion _lineCurveConverter; + private readonly ITypedConverter _polyCurveConverter; + private readonly ITypedConverter _arcCurveConverter; + private readonly ITypedConverter _polylineConverter; + private readonly ITypedConverter _nurbsCurveConverter; + private readonly ITypedConverter _lineCurveConverter; public CurveToSpeckleConverter( - IRawConversion polyCurveConverter, - IRawConversion arcCurveConverter, - IRawConversion polylineConverter, - IRawConversion nurbsCurveConverter, - IRawConversion lineCurveConverter + ITypedConverter polyCurveConverter, + ITypedConverter arcCurveConverter, + ITypedConverter polylineConverter, + ITypedConverter nurbsCurveConverter, + ITypedConverter lineCurveConverter ) { _polyCurveConverter = polyCurveConverter; @@ -37,15 +37,15 @@ public CurveToSpeckleConverter( /// This is the main converter when the type of curve you input or output does not matter to the caller.
/// ⚠️ If an unsupported type of Curve is input, it will be converted to NURBS. /// - public ICurve RawConvert(RG.Curve target) => + public ICurve Convert(RG.Curve target) => target switch { - RG.PolyCurve polyCurve => _polyCurveConverter.RawConvert(polyCurve), - RG.ArcCurve arcCurve => _arcCurveConverter.RawConvert(arcCurve), - RG.PolylineCurve polylineCurve => _polylineConverter.RawConvert(polylineCurve), - RG.LineCurve lineCurve => _lineCurveConverter.RawConvert(lineCurve), - _ => _nurbsCurveConverter.RawConvert(target.ToNurbsCurve()) + RG.PolyCurve polyCurve => _polyCurveConverter.Convert(polyCurve), + RG.ArcCurve arcCurve => _arcCurveConverter.Convert(arcCurve), + RG.PolylineCurve polylineCurve => _polylineConverter.Convert(polylineCurve), + RG.LineCurve lineCurve => _lineCurveConverter.Convert(lineCurve), + _ => _nurbsCurveConverter.Convert(target.ToNurbsCurve()) }; - Base IRawConversion.RawConvert(RG.Curve target) => (Base)RawConvert(target); + Base ITypedConverter.Convert(RG.Curve target) => (Base)Convert(target); } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/EllipseToSpeckleConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/EllipseToSpeckleConverter.cs index d0d0d6b467..fc6b52cc8f 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/EllipseToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/EllipseToSpeckleConverter.cs @@ -4,15 +4,15 @@ namespace Speckle.Converters.Rhino7.ToSpeckle.Raw; -public class EllipseToSpeckleConverter : IRawConversion +public class EllipseToSpeckleConverter : ITypedConverter { - private readonly IRawConversion _planeConverter; - private readonly IRawConversion _boxConverter; + private readonly ITypedConverter _planeConverter; + private readonly ITypedConverter _boxConverter; private readonly IConversionContextStack _contextStack; public EllipseToSpeckleConverter( - IRawConversion planeConverter, - IRawConversion boxConverter, + ITypedConverter planeConverter, + ITypedConverter boxConverter, IConversionContextStack contextStack ) { @@ -29,11 +29,11 @@ IConversionContextStack contextStack /// /// ⚠️ Rhino ellipses are not curves. The result is a mathematical representation of an ellipse that can be converted into NURBS for display. /// - public SOG.Ellipse RawConvert(RG.Ellipse target) + public SOG.Ellipse Convert(RG.Ellipse target) { var nurbsCurve = target.ToNurbsCurve(); return new( - _planeConverter.RawConvert(target.Plane), + _planeConverter.Convert(target.Plane), target.Radius1, target.Radius2, _contextStack.Current.SpeckleUnits @@ -42,7 +42,7 @@ public SOG.Ellipse RawConvert(RG.Ellipse target) domain = new SOP.Interval(0, 1), length = nurbsCurve.GetLength(), area = Math.PI * target.Radius1 * target.Radius2, - bbox = _boxConverter.RawConvert(new RG.Box(nurbsCurve.GetBoundingBox(true))) + bbox = _boxConverter.Convert(new RG.Box(nurbsCurve.GetBoundingBox(true))) }; } } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/IntervalToSpeckleConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/IntervalToSpeckleConverter.cs index 8bda6f9f1e..272fecafdb 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/IntervalToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/IntervalToSpeckleConverter.cs @@ -2,12 +2,12 @@ namespace Speckle.Converters.Rhino7.ToSpeckle.Raw; -public class IntervalToSpeckleConverter : IRawConversion +public class IntervalToSpeckleConverter : ITypedConverter { /// /// Converts a Rhino Interval object to a Speckle Interval object. /// /// The Rhino Interval object to be converted. /// The converted Speckle Interval object. - public SOP.Interval RawConvert(RG.Interval target) => new(target.T0, target.T1); + public SOP.Interval Convert(RG.Interval target) => new(target.T0, target.T1); } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/LineToSpeckleConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/LineToSpeckleConverter.cs index 54daf38549..f40620f78d 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/LineToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/LineToSpeckleConverter.cs @@ -4,15 +4,15 @@ namespace Speckle.Converters.Rhino7.ToSpeckle.Raw; -public class LineToSpeckleConverter : IRawConversion, IRawConversion +public class LineToSpeckleConverter : ITypedConverter, ITypedConverter { - private readonly IRawConversion _pointConverter; - private readonly IRawConversion _boxConverter; + private readonly ITypedConverter _pointConverter; + private readonly ITypedConverter _boxConverter; private readonly IConversionContextStack _contextStack; public LineToSpeckleConverter( - IRawConversion pointConverter, - IRawConversion boxConverter, + ITypedConverter pointConverter, + ITypedConverter boxConverter, IConversionContextStack contextStack ) { @@ -29,17 +29,13 @@ IConversionContextStack contextStack /// /// ⚠️ This conversion assumes the domain of a line is (0, LENGTH), as Rhino Lines do not have domain. If you want the domain preserved use LineCurve conversions instead. /// - public SOG.Line RawConvert(RG.Line target) => - new( - _pointConverter.RawConvert(target.From), - _pointConverter.RawConvert(target.To), - _contextStack.Current.SpeckleUnits - ) + public SOG.Line Convert(RG.Line target) => + new(_pointConverter.Convert(target.From), _pointConverter.Convert(target.To), _contextStack.Current.SpeckleUnits) { length = target.Length, domain = new SOP.Interval(0, target.Length), - bbox = _boxConverter.RawConvert(new RG.Box(target.BoundingBox)) + bbox = _boxConverter.Convert(new RG.Box(target.BoundingBox)) }; - public SOG.Line RawConvert(RG.LineCurve target) => RawConvert(target.Line); + public SOG.Line Convert(RG.LineCurve target) => Convert(target.Line); } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/MeshToSpeckleConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/MeshToSpeckleConverter.cs index 5d116a78c4..73aa3f4a8a 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/MeshToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/MeshToSpeckleConverter.cs @@ -5,15 +5,15 @@ namespace Speckle.Converters.Rhino7.ToSpeckle.Raw; [NameAndRankValue(nameof(RG.Mesh), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class MeshToSpeckleConverter : IRawConversion +public class MeshToSpeckleConverter : ITypedConverter { - private readonly IRawConversion _pointConverter; - private readonly IRawConversion _boxConverter; + private readonly ITypedConverter _pointConverter; + private readonly ITypedConverter _boxConverter; private readonly IConversionContextStack _contextStack; public MeshToSpeckleConverter( - IRawConversion pointConverter, - IRawConversion boxConverter, + ITypedConverter pointConverter, + ITypedConverter boxConverter, IConversionContextStack contextStack ) { @@ -28,7 +28,7 @@ IConversionContextStack contextStack /// The Rhino Mesh to be converted. /// The converted Speckle Mesh. /// Thrown when the Rhino Mesh has 0 vertices or faces. - public SOG.Mesh RawConvert(RG.Mesh target) + public SOG.Mesh Convert(RG.Mesh target) { if (target.Vertices.Count == 0 || target.Faces.Count == 0) { @@ -55,7 +55,7 @@ public SOG.Mesh RawConvert(RG.Mesh target) var colors = target.VertexColors.Select(cl => cl.ToArgb()).ToList(); var volume = target.IsClosed ? target.Volume() : 0; - var bbox = _boxConverter.RawConvert(new RG.Box(target.GetBoundingBox(false))); + var bbox = _boxConverter.Convert(new RG.Box(target.GetBoundingBox(false))); return new SOG.Mesh(vertexCoordinates, faces, colors, textureCoordinates, _contextStack.Current.SpeckleUnits) { diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/NurbsCurveConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/NurbsCurveConverter.cs index 372cf34f54..6cf8dca53d 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/NurbsCurveConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/NurbsCurveConverter.cs @@ -4,17 +4,17 @@ namespace Speckle.Converters.Rhino7.ToSpeckle.Raw; -public class NurbsCurveConverter : IRawConversion +public class NurbsCurveConverter : ITypedConverter { - private readonly IRawConversion _polylineConverter; - private readonly IRawConversion _intervalConverter; - private readonly IRawConversion _boxConverter; + private readonly ITypedConverter _polylineConverter; + private readonly ITypedConverter _intervalConverter; + private readonly ITypedConverter _boxConverter; private readonly IConversionContextStack _contextStack; public NurbsCurveConverter( - IRawConversion polylineConverter, - IRawConversion intervalConverter, - IRawConversion boxConverter, + ITypedConverter polylineConverter, + ITypedConverter intervalConverter, + ITypedConverter boxConverter, IConversionContextStack contextStack ) { @@ -34,7 +34,7 @@ IConversionContextStack contextStack /// It adds 1 extra knot at the start and end of the vector by repeating the first and last value. /// This is because Rhino's standard of (controlPoints + degree + 1) wasn't followed on other software. /// - public SOG.Curve RawConvert(RG.NurbsCurve target) + public SOG.Curve Convert(RG.NurbsCurve target) { target.ToPolyline(0, 1, 0, 0, 0, 0.1, 0, 0, true).TryGetPolyline(out var poly); if (target.IsClosed) @@ -42,7 +42,7 @@ public SOG.Curve RawConvert(RG.NurbsCurve target) poly.Add(poly[0]); } - SOG.Polyline displayValue = _polylineConverter.RawConvert(poly); + SOG.Polyline displayValue = _polylineConverter.Convert(poly); var nurbsCurve = target.ToNurbsCurve(); @@ -60,10 +60,10 @@ public SOG.Curve RawConvert(RG.NurbsCurve target) degree = nurbsCurve.Degree, periodic = nurbsCurve.IsPeriodic, rational = nurbsCurve.IsRational, - domain = _intervalConverter.RawConvert(nurbsCurve.Domain), + domain = _intervalConverter.Convert(nurbsCurve.Domain), closed = nurbsCurve.IsClosed, length = nurbsCurve.GetLength(), - bbox = _boxConverter.RawConvert(new RG.Box(nurbsCurve.GetBoundingBox(true))) + bbox = _boxConverter.Convert(new RG.Box(nurbsCurve.GetBoundingBox(true))) }; return myCurve; diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/NurbsSurfaceToSpeckleConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/NurbsSurfaceToSpeckleConverter.cs index d9dd19b64d..0d663ff520 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/NurbsSurfaceToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/NurbsSurfaceToSpeckleConverter.cs @@ -5,17 +5,17 @@ namespace Speckle.Converters.Rhino7.ToSpeckle.Raw; -public class NurbsSurfaceToSpeckleConverter : IRawConversion +public class NurbsSurfaceToSpeckleConverter : ITypedConverter { - private readonly IRawConversion _boxConverter; - private readonly IRawConversion _intervalConverter; - private readonly IRawConversion _controlPointConverter; + private readonly ITypedConverter _boxConverter; + private readonly ITypedConverter _intervalConverter; + private readonly ITypedConverter _controlPointConverter; private readonly IConversionContextStack _contextStack; public NurbsSurfaceToSpeckleConverter( - IRawConversion boxConverter, - IRawConversion intervalConverter, - IRawConversion controlPointConverter, + ITypedConverter boxConverter, + ITypedConverter intervalConverter, + ITypedConverter controlPointConverter, IConversionContextStack contextStack ) { @@ -30,7 +30,7 @@ IConversionContextStack contextStack ///
/// The NurbsSurface object to convert. /// A Surface object representing the converted NurbsSurface. - public SOG.Surface RawConvert(RG.NurbsSurface target) + public SOG.Surface Convert(RG.NurbsSurface target) { var result = new SOG.Surface { @@ -39,12 +39,12 @@ public SOG.Surface RawConvert(RG.NurbsSurface target) rational = target.IsRational, closedU = target.IsClosed(0), closedV = target.IsClosed(1), - domainU = _intervalConverter.RawConvert(target.Domain(0)), - domainV = _intervalConverter.RawConvert(target.Domain(1)), + domainU = _intervalConverter.Convert(target.Domain(0)), + domainV = _intervalConverter.Convert(target.Domain(1)), knotsU = target.KnotsU.ToList(), knotsV = target.KnotsV.ToList(), units = _contextStack.Current.SpeckleUnits, - bbox = _boxConverter.RawConvert(new RG.Box(target.GetBoundingBox(true))) + bbox = _boxConverter.Convert(new RG.Box(target.GetBoundingBox(true))) }; result.SetControlPoints(ControlPointsToSpeckle(target.Points)); @@ -61,7 +61,7 @@ public SOG.Surface RawConvert(RG.NurbsSurface target) for (var j = 0; j < controlPoints.CountV; j++) { var pt = controlPoints.GetControlPoint(i, j); - row.Add(_controlPointConverter.RawConvert(pt)); + row.Add(_controlPointConverter.Convert(pt)); } points.Add(row); diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/PlaneToSpeckleConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/PlaneToSpeckleConverter.cs index f9f973c5cb..40d15be50c 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/PlaneToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/PlaneToSpeckleConverter.cs @@ -4,15 +4,15 @@ namespace Speckle.Converters.Rhino7.ToSpeckle.Raw; -public class PlaneToSpeckleConverter : IRawConversion +public class PlaneToSpeckleConverter : ITypedConverter { - private readonly IRawConversion _vectorConverter; - private readonly IRawConversion _pointConverter; + private readonly ITypedConverter _vectorConverter; + private readonly ITypedConverter _pointConverter; private readonly IConversionContextStack _contextStack; public PlaneToSpeckleConverter( - IRawConversion vectorConverter, - IRawConversion pointConverter, + ITypedConverter vectorConverter, + ITypedConverter pointConverter, IConversionContextStack contextStack ) { @@ -26,12 +26,12 @@ IConversionContextStack contextStack ///
/// The instance of Rhino Plane to convert. /// The converted instance of Speckle Plane. - public SOG.Plane RawConvert(RG.Plane target) => + public SOG.Plane Convert(RG.Plane target) => new( - _pointConverter.RawConvert(target.Origin), - _vectorConverter.RawConvert(target.ZAxis), - _vectorConverter.RawConvert(target.XAxis), - _vectorConverter.RawConvert(target.YAxis), + _pointConverter.Convert(target.Origin), + _vectorConverter.Convert(target.ZAxis), + _vectorConverter.Convert(target.XAxis), + _vectorConverter.Convert(target.YAxis), _contextStack.Current.SpeckleUnits ); } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/PointToSpeckleConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/PointToSpeckleConverter.cs index 54c08d6ea5..2bfdfdae1c 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/PointToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/PointToSpeckleConverter.cs @@ -4,7 +4,7 @@ namespace Speckle.Converters.Rhino7.ToSpeckle.Raw; -public class PointToSpeckleConverter : IRawConversion, IRawConversion +public class PointToSpeckleConverter : ITypedConverter, ITypedConverter { private readonly IConversionContextStack _contextStack; @@ -18,8 +18,7 @@ public PointToSpeckleConverter(IConversionContextStack con ///
/// The Rhino 3D point to convert. /// The converted Speckle point. - public SOG.Point RawConvert(RG.Point3d target) => - new(target.X, target.Y, target.Z, _contextStack.Current.SpeckleUnits); + public SOG.Point Convert(RG.Point3d target) => new(target.X, target.Y, target.Z, _contextStack.Current.SpeckleUnits); - public SOG.Point RawConvert(RG.Point target) => RawConvert(target.Location); + public SOG.Point Convert(RG.Point target) => Convert(target.Location); } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/PolyCurveToSpeckleConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/PolyCurveToSpeckleConverter.cs index 291b4c1bc5..6937d6b007 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/PolyCurveToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/PolyCurveToSpeckleConverter.cs @@ -5,16 +5,16 @@ namespace Speckle.Converters.Rhino7.ToSpeckle.Raw; -public class PolyCurveToSpeckleConverter : IRawConversion +public class PolyCurveToSpeckleConverter : ITypedConverter { - public IRawConversion? CurveConverter { get; set; } // POC: CNX-9279 This created a circular dependency on the constructor, making it a property allows for the container to resolve it correctly - private readonly IRawConversion _intervalConverter; - private readonly IRawConversion _boxConverter; + public ITypedConverter? CurveConverter { get; set; } // POC: CNX-9279 This created a circular dependency on the constructor, making it a property allows for the container to resolve it correctly + private readonly ITypedConverter _intervalConverter; + private readonly ITypedConverter _boxConverter; private readonly IConversionContextStack _contextStack; public PolyCurveToSpeckleConverter( - IRawConversion intervalConverter, - IRawConversion boxConverter, + ITypedConverter intervalConverter, + ITypedConverter boxConverter, IConversionContextStack contextStack ) { @@ -32,15 +32,15 @@ IConversionContextStack contextStack /// This method removes the nesting of the PolyCurve by duplicating the segments at a granular level. /// All PolyLIne, PolyCurve and NURBS curves with G1 discontinuities will be broken down. /// - public SOG.Polycurve RawConvert(RG.PolyCurve target) + public SOG.Polycurve Convert(RG.PolyCurve target) { var myPoly = new SOG.Polycurve { closed = target.IsClosed, - domain = _intervalConverter.RawConvert(target.Domain), + domain = _intervalConverter.Convert(target.Domain), length = target.GetLength(), - bbox = _boxConverter.RawConvert(new RG.Box(target.GetBoundingBox(true))), - segments = target.DuplicateSegments().Select(x => CurveConverter.NotNull().RawConvert(x)).ToList(), + bbox = _boxConverter.Convert(new RG.Box(target.GetBoundingBox(true))), + segments = target.DuplicateSegments().Select(x => CurveConverter.NotNull().Convert(x)).ToList(), units = _contextStack.Current.SpeckleUnits }; return myPoly; diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/PolylineToSpeckleConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/PolylineToSpeckleConverter.cs index ad202ff632..1ee241e7d1 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/PolylineToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/PolylineToSpeckleConverter.cs @@ -5,19 +5,19 @@ namespace Speckle.Converters.Rhino7.ToSpeckle.Raw; public class PolylineToSpeckleConverter - : IRawConversion, - IRawConversion + : ITypedConverter, + ITypedConverter { - private readonly IRawConversion _pointConverter; - private readonly IRawConversion _boxConverter; - private readonly IRawConversion _intervalConverter; + private readonly ITypedConverter _pointConverter; + private readonly ITypedConverter _boxConverter; + private readonly ITypedConverter _intervalConverter; private readonly IConversionContextStack _contextStack; public PolylineToSpeckleConverter( - IRawConversion pointConverter, - IRawConversion boxConverter, + ITypedConverter pointConverter, + ITypedConverter boxConverter, IConversionContextStack contextStack, - IRawConversion intervalConverter + ITypedConverter intervalConverter ) { _pointConverter = pointConverter; @@ -32,10 +32,10 @@ public PolylineToSpeckleConverter( /// The Rhino polyline to be converted. /// The converted Speckle polyline. /// ⚠️ This conversion assumes domain interval is (0,LENGTH) as Rhino Polylines have no domain. If needed, you may want to use PolylineCurve conversion instead. - public SOG.Polyline RawConvert(RG.Polyline target) + public SOG.Polyline Convert(RG.Polyline target) { - var box = _boxConverter.RawConvert(new RG.Box(target.BoundingBox)); - var points = target.Select(pt => _pointConverter.RawConvert(pt)).ToList(); + var box = _boxConverter.Convert(new RG.Box(target.BoundingBox)); + var points = target.Select(pt => _pointConverter.Convert(pt)).ToList(); if (target.IsClosed) { @@ -60,10 +60,10 @@ public SOG.Polyline RawConvert(RG.Polyline target) /// The Rhino PolylineCurve to be converted. /// The converted Speckle polyline. /// ✅ This conversion respects the domain of the original PolylineCurve - public SOG.Polyline RawConvert(RG.PolylineCurve target) + public SOG.Polyline Convert(RG.PolylineCurve target) { - var result = RawConvert(target.ToPolyline()); - result.domain = _intervalConverter.RawConvert(target.Domain); + var result = Convert(target.ToPolyline()); + result.domain = _intervalConverter.Convert(target.Domain); return result; } } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/RawPointCloudToSpeckle.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/RawPointCloudToSpeckle.cs index 0acf866e3c..5e4a17e6cb 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/RawPointCloudToSpeckle.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/RawPointCloudToSpeckle.cs @@ -4,14 +4,14 @@ namespace Speckle.Converters.Rhino7.ToSpeckle.Raw; -public class RawPointCloudToSpeckle : IRawConversion +public class RawPointCloudToSpeckle : ITypedConverter { private readonly IConversionContextStack _contextStack; - private readonly IRawConversion _boxConverter; + private readonly ITypedConverter _boxConverter; public RawPointCloudToSpeckle( IConversionContextStack contextStack, - IRawConversion boxConverter + ITypedConverter boxConverter ) { _contextStack = contextStack; @@ -23,12 +23,12 @@ public RawPointCloudToSpeckle( ///
/// The Rhino PointCloud object to convert. /// The converted Speckle Pointcloud object. - public SOG.Pointcloud RawConvert(RG.PointCloud target) => + public SOG.Pointcloud Convert(RG.PointCloud target) => new() { points = target.GetPoints().SelectMany(pt => new[] { pt.X, pt.Y, pt.Z }).ToList(), colors = target.GetColors().Select(o => o.ToArgb()).ToList(), - bbox = _boxConverter.RawConvert(new RG.Box(target.GetBoundingBox(true))), + bbox = _boxConverter.Convert(new RG.Box(target.GetBoundingBox(true))), units = _contextStack.Current.SpeckleUnits }; } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/VectorToSpeckleConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/VectorToSpeckleConverter.cs index 6237826d35..489eddedc4 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/VectorToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/VectorToSpeckleConverter.cs @@ -4,7 +4,7 @@ namespace Speckle.Converters.Rhino7.ToSpeckle.Raw; -public class VectorToSpeckleConverter : IRawConversion +public class VectorToSpeckleConverter : ITypedConverter { private readonly IConversionContextStack _contextStack; @@ -18,6 +18,6 @@ public VectorToSpeckleConverter(IConversionContextStack co ///
/// The Rhino Vector3d object to convert. /// The converted Speckle Vector object. - public SOG.Vector RawConvert(RG.Vector3d target) => + public SOG.Vector Convert(RG.Vector3d target) => new(target.X, target.Y, target.Z, _contextStack.Current.SpeckleUnits); } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/RhinoConverterToSpeckle.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/RhinoConverterToSpeckle.cs deleted file mode 100644 index d581c438e8..0000000000 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/RhinoConverterToSpeckle.cs +++ /dev/null @@ -1,29 +0,0 @@ -using Speckle.Autofac.DependencyInjection; -using Speckle.Converters.Common; -using Speckle.Converters.Common.Objects; -using Speckle.Core.Models; - -namespace Speckle.Converters.Rhino7.ToSpeckle; - -public class RhinoConverterToSpeckle : ISpeckleConverterToSpeckle -{ - private readonly IFactory _toSpeckle; - - public RhinoConverterToSpeckle(IFactory toSpeckle) - { - _toSpeckle = toSpeckle; - } - - public Base Convert(object target) - { - var type = target.GetType(); - var objectConverter = _toSpeckle.ResolveInstance(type.Name); - - if (objectConverter == null) - { - throw new NotSupportedException($"No conversion found for {type.Name}"); - } - - return objectConverter.Convert(target); - } -} diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/BrepObjectToSpeckleTopLevelConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/BrepObjectToSpeckleTopLevelConverter.cs index b57c8a08e5..7520c1bd83 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/BrepObjectToSpeckleTopLevelConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/BrepObjectToSpeckleTopLevelConverter.cs @@ -6,11 +6,11 @@ namespace Speckle.Converters.Rhino7.ToSpeckle.TopLevel; [NameAndRankValue(nameof(BrepObject), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class BrepObjectToSpeckleTopLevelConverter : IHostObjectToSpeckleConversion +public class BrepObjectToSpeckleTopLevelConverter : IToSpeckleTopLevelConverter { - private readonly IRawConversion _curveConverter; + private readonly ITypedConverter _curveConverter; - public BrepObjectToSpeckleTopLevelConverter(IRawConversion curveConverter) + public BrepObjectToSpeckleTopLevelConverter(ITypedConverter curveConverter) { _curveConverter = curveConverter; } @@ -18,7 +18,7 @@ public BrepObjectToSpeckleTopLevelConverter(IRawConversion cu public Base Convert(object target) { var curveObject = (BrepObject)target; - var speckleCurve = _curveConverter.RawConvert(curveObject.BrepGeometry); + var speckleCurve = _curveConverter.Convert(curveObject.BrepGeometry); return speckleCurve; } } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/CurveObjectToSpeckleTopLevelConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/CurveObjectToSpeckleTopLevelConverter.cs index 285130be58..a8214a0c97 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/CurveObjectToSpeckleTopLevelConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/CurveObjectToSpeckleTopLevelConverter.cs @@ -8,7 +8,7 @@ namespace Speckle.Converters.Rhino7.ToSpeckle.TopLevel; [NameAndRankValue(nameof(CurveObject), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] public class CurveObjectToSpeckleTopLevelConverter : RhinoObjectToSpeckleTopLevelConverter { - public CurveObjectToSpeckleTopLevelConverter(IRawConversion conversion) + public CurveObjectToSpeckleTopLevelConverter(ITypedConverter conversion) : base(conversion) { } protected override RG.Curve GetTypedGeometry(CurveObject input) => input.CurveGeometry; diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/ExtrusionObjectToSpeckleTopLevelConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/ExtrusionObjectToSpeckleTopLevelConverter.cs index 5be77ff94c..46d2c27586 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/ExtrusionObjectToSpeckleTopLevelConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/ExtrusionObjectToSpeckleTopLevelConverter.cs @@ -6,11 +6,11 @@ namespace Speckle.Converters.Rhino7.ToSpeckle.TopLevel; [NameAndRankValue(nameof(ExtrusionObject), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class ExtrusionObjectToSpeckleTopLevelConverter : IHostObjectToSpeckleConversion +public class ExtrusionObjectToSpeckleTopLevelConverter : IToSpeckleTopLevelConverter { - private readonly IRawConversion _curveConverter; + private readonly ITypedConverter _curveConverter; - public ExtrusionObjectToSpeckleTopLevelConverter(IRawConversion curveConverter) + public ExtrusionObjectToSpeckleTopLevelConverter(ITypedConverter curveConverter) { _curveConverter = curveConverter; } @@ -18,7 +18,7 @@ public ExtrusionObjectToSpeckleTopLevelConverter(IRawConversion { - public MeshObjectToSpeckleTopLevelConverter(IRawConversion conversion) + public MeshObjectToSpeckleTopLevelConverter(ITypedConverter conversion) : base(conversion) { } protected override RG.Mesh GetTypedGeometry(MeshObject input) => input.MeshGeometry; diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/PointCloudObjectToSpeckleTopLevelConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/PointCloudObjectToSpeckleTopLevelConverter.cs index 6436640448..e741e38e49 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/PointCloudObjectToSpeckleTopLevelConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/PointCloudObjectToSpeckleTopLevelConverter.cs @@ -8,7 +8,7 @@ namespace Speckle.Converters.Rhino7.ToSpeckle.TopLevel; public class PointCloudObjectToSpeckleTopLevelConverter : RhinoObjectToSpeckleTopLevelConverter { - public PointCloudObjectToSpeckleTopLevelConverter(IRawConversion conversion) + public PointCloudObjectToSpeckleTopLevelConverter(ITypedConverter conversion) : base(conversion) { } protected override RG.PointCloud GetTypedGeometry(PointCloudObject input) => input.PointCloudGeometry; diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/PointObjectToSpeckleTopLevelConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/PointObjectToSpeckleTopLevelConverter.cs index e73af8acbf..7d9c750b64 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/PointObjectToSpeckleTopLevelConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/PointObjectToSpeckleTopLevelConverter.cs @@ -8,7 +8,7 @@ namespace Speckle.Converters.Rhino7.ToSpeckle.TopLevel; public class PointObjectToSpeckleTopLevelConverter : RhinoObjectToSpeckleTopLevelConverter { - public PointObjectToSpeckleTopLevelConverter(IRawConversion conversion) + public PointObjectToSpeckleTopLevelConverter(ITypedConverter conversion) : base(conversion) { } protected override RG.Point GetTypedGeometry(PointObject input) => input.PointGeometry; diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/RhinoObjectToSpeckleTopLevelConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/RhinoObjectToSpeckleTopLevelConverter.cs index 3cc03f3930..edff24473a 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/RhinoObjectToSpeckleTopLevelConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/RhinoObjectToSpeckleTopLevelConverter.cs @@ -3,15 +3,14 @@ namespace Speckle.Converters.Rhino7.ToSpeckle.TopLevel; -public abstract class RhinoObjectToSpeckleTopLevelConverter - : IHostObjectToSpeckleConversion +public abstract class RhinoObjectToSpeckleTopLevelConverter : IToSpeckleTopLevelConverter where TTopLevelIn : Rhino.DocObjects.RhinoObject where TInRaw : RG.GeometryBase where TOutRaw : Base { - public IRawConversion Conversion { get; } + public ITypedConverter Conversion { get; } - protected RhinoObjectToSpeckleTopLevelConverter(IRawConversion conversion) + protected RhinoObjectToSpeckleTopLevelConverter(ITypedConverter conversion) { Conversion = conversion; } @@ -24,7 +23,7 @@ public virtual Base Convert(object target) var typedTarget = (TTopLevelIn)target; var typedGeometry = GetTypedGeometry(typedTarget); - var result = Conversion.RawConvert(typedGeometry); + var result = Conversion.Convert(typedGeometry); // POC: Any common operations for all RhinoObjects should be done here, not on the specific implementer // Things like user-dictionaries and other user-defined metadata. diff --git a/DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/Factory.cs b/DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/Factory.cs index e68fce561d..bfd7593aae 100644 --- a/DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/Factory.cs +++ b/DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/Factory.cs @@ -4,17 +4,17 @@ namespace Speckle.Autofac.DependencyInjection; [GenerateAutoInterface] -public class Factory : IFactory +public class Factory : IFactory where TValue : class { - private readonly IIndex _types; + private readonly IIndex _types; - public Factory(IIndex types) + public Factory(IIndex types) { _types = types; } - public TValue? ResolveInstance(TKey strongName) + public TValue? ResolveInstance(string strongName) { if (_types.TryGetValue(strongName, out TValue value)) { diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/ContainerRegistration.cs b/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/ContainerRegistration.cs index 3f8f9d7d61..6a5fb37913 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/ContainerRegistration.cs +++ b/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/ContainerRegistration.cs @@ -6,34 +6,31 @@ namespace Speckle.Converters.Common.DependencyInjection; public static class ContainerRegistration { - public static void AddConverterCommon(this SpeckleContainerBuilder builder) + public static void AddConverterCommon( + this SpeckleContainerBuilder builder + ) + where TRootToSpeckleConverter : class, IRootToSpeckleConverter + where THostToSpeckleUnitConverter : class, IHostToSpeckleUnitConverter { + builder.AddScoped(); + builder.AddScoped, THostToSpeckleUnitConverter>(); /* POC: CNX-9267 Moved the Injection of converters into the converter module. Not sure if this is 100% right, as this doesn't just register the conversions within this converter, but any conversions found in any Speckle.*.dll file. This will require consolidating across other connectors. */ + builder.AddScoped, Factory>(); builder.AddScoped< - IFactory, - Factory - >(); - builder.AddScoped< - IConverterResolver, - RecursiveConverterResolver + IConverterResolver, + ConverterResolver >(); - builder.AddScoped< - IFactory, - Factory - >(); - builder.AddScoped< - IConverterResolver, - RecursiveConverterResolver - >(); + builder.AddScoped, Factory>(); + builder.AddScoped, ConverterResolver>(); - builder.AddScoped(); + builder.AddScoped(); builder.RegisterRawConversions(); - builder.InjectNamedTypes(); - builder.InjectNamedTypes(); + builder.InjectNamedTypes(); + builder.InjectNamedTypes(); } } diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/NamedTypeInjector.cs b/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/NamedTypeInjector.cs index 77a7b0206b..c4a0800ce7 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/NamedTypeInjector.cs +++ b/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/NamedTypeInjector.cs @@ -40,7 +40,7 @@ public static void InjectNamedTypes(this SpeckleContainerBuilder containerBui // * Whether the scope should be modified or modifiable // * Whether this is in the write project... hmmm // POC: IsAssignableFrom() - var secondaryType = first.type.GetInterface(typeof(IRawConversion<,>).Name); + var secondaryType = first.type.GetInterface(typeof(ITypedConverter<,>).Name); // POC: should we explode if no found? if (secondaryType != null) { @@ -67,7 +67,7 @@ public static void InjectNamedTypes(this SpeckleContainerBuilder containerBui // * Whether this is in the write project... hmmm // POC: IsAssignableFrom() // NOT very DRY - secondaryType = first.type.GetInterface(typeof(IRawConversion<,>).Name); + secondaryType = first.type.GetInterface(typeof(ITypedConverter<,>).Name); // POC: should we explode if no found? if (secondaryType != null) { diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/RawConversionRegisterer.cs b/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/RawConversionRegisterer.cs index 9c2530943d..73745af1f7 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/RawConversionRegisterer.cs +++ b/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/RawConversionRegisterer.cs @@ -25,7 +25,7 @@ private static void RegisterRawConversionsForType(ContainerBuilder containerBuil } var rawConversionInterfaces = type.GetInterfaces() - .Where(it => it.IsGenericType && it.GetGenericTypeDefinition() == typeof(IRawConversion<,>)); + .Where(it => it.IsGenericType && it.GetGenericTypeDefinition() == typeof(ITypedConverter<,>)); foreach (var conversionInterface in rawConversionInterfaces) { diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/ToHost/ToHostConverterWithFallback.cs b/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/ToHost/ConverterWithFallback.cs similarity index 80% rename from DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/ToHost/ToHostConverterWithFallback.cs rename to DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/ToHost/ConverterWithFallback.cs index 2ff6e8a34e..d20f915ba9 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/ToHost/ToHostConverterWithFallback.cs +++ b/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/ToHost/ConverterWithFallback.cs @@ -6,21 +6,21 @@ namespace Speckle.Converters.Common.DependencyInjection.ToHost; // POC: CNX-9394 Find a better home for this outside `DependencyInjection` project /// -/// +/// ///
/// If no suitable converter conversion is found, and the target object has a displayValue property /// a converter with strong name of is resolved for. ///
-/// -public sealed class ToHostConverterWithFallback : ISpeckleConverterToHost +/// +public sealed class ConverterWithFallback : IRootToHostConverter { - private readonly IConverterResolver _toHost; - private readonly ToHostConverterWithoutFallback _baseConverter; + private readonly IConverterResolver _toHost; + private readonly ConverterWithoutFallback _baseConverter; - public ToHostConverterWithFallback(IConverterResolver toHost) + public ConverterWithFallback(IConverterResolver toHost) { _toHost = toHost; - _baseConverter = new ToHostConverterWithoutFallback(toHost); + _baseConverter = new ConverterWithoutFallback(toHost); } /// @@ -31,7 +31,7 @@ public ToHostConverterWithFallback(IConverterResolver /// /// The conversion is done in the following order of preference: - /// 1. Direct conversion using the method. + /// 1. Direct conversion using the method. /// 2. Fallback to display value using the method, if a direct conversion is not possible. /// /// If the direct conversion is not available and there is no displayValue, a is thrown. diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/ToHost/ToHostConverterWithoutFallback.cs b/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/ToHost/ConverterWithoutFallback.cs similarity index 63% rename from DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/ToHost/ToHostConverterWithoutFallback.cs rename to DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/ToHost/ConverterWithoutFallback.cs index ff69332e87..c6b24fff40 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/ToHost/ToHostConverterWithoutFallback.cs +++ b/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/ToHost/ConverterWithoutFallback.cs @@ -6,15 +6,15 @@ namespace Speckle.Converters.Common.DependencyInjection.ToHost; // POC: CNX-9394 Find a better home for this outside `DependencyInjection` project /// -/// Provides an implementation for -/// that resolves a via the injected +/// Provides an implementation for +/// that resolves a via the injected /// -/// -public sealed class ToHostConverterWithoutFallback : ISpeckleConverterToHost +/// +public sealed class ConverterWithoutFallback : IRootToHostConverter { - private readonly IConverterResolver _toHost; + private readonly IConverterResolver _toHost; - public ToHostConverterWithoutFallback(IConverterResolver converterResolver) + public ConverterWithoutFallback(IConverterResolver converterResolver) { _toHost = converterResolver; } diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common/ConversionContext.cs b/DUI3-DX/Sdk/Speckle.Converters.Common/ConversionContext.cs index 178af2782c..723877d0b9 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common/ConversionContext.cs +++ b/DUI3-DX/Sdk/Speckle.Converters.Common/ConversionContext.cs @@ -10,6 +10,6 @@ public ConversionContext(TDocument doc, string speckleUnits) SpeckleUnits = speckleUnits; } - public TDocument Document { get; protected set; } + public TDocument Document { get; } public string SpeckleUnits { get; private set; } } diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common/ConversionContextStack.cs b/DUI3-DX/Sdk/Speckle.Converters.Common/ConversionContextStack.cs index 908ce1989d..918a29d3c1 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common/ConversionContextStack.cs +++ b/DUI3-DX/Sdk/Speckle.Converters.Common/ConversionContextStack.cs @@ -1,4 +1,5 @@ using System.Diagnostics.CodeAnalysis; +using Speckle.InterfaceGenerator; namespace Speckle.Converters.Common; @@ -8,7 +9,8 @@ namespace Speckle.Converters.Common; "CA1711:Identifiers should not have incorrect suffix", Justification = "Name ends in Stack but it is in fact a Stack, just not inheriting from `System.Collections.Stack`" )] -public class ConversionContextStack : IConversionContextStack +[GenerateAutoInterface] +public abstract class ConversionContextStack : IConversionContextStack where TDocument : class { private readonly IHostToSpeckleUnitConverter _unitConverter; diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common/IConversionContextStack.cs b/DUI3-DX/Sdk/Speckle.Converters.Common/IConversionContextStack.cs deleted file mode 100644 index d06a35f778..0000000000 --- a/DUI3-DX/Sdk/Speckle.Converters.Common/IConversionContextStack.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System.Diagnostics.CodeAnalysis; - -namespace Speckle.Converters.Common; - -// POC: Suppressed naming warning for now, but we should evaluate if we should follow this or disable it. -[SuppressMessage( - "Naming", - "CA1711:Identifiers should not have incorrect suffix", - Justification = "Name ends in Stack but it is in fact a Stack, just not inheriting from `System.Collections.Stack`" -)] -public interface IConversionContextStack - where TDocument : class -{ - ContextWrapper Push(string speckleUnit); - ContextWrapper Push(THostUnit hostUnit); - void Pop(); - ConversionContext Current { get; } -} diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common/ISpeckleConverterToHost.cs b/DUI3-DX/Sdk/Speckle.Converters.Common/IRootToHostConverter.cs similarity index 71% rename from DUI3-DX/Sdk/Speckle.Converters.Common/ISpeckleConverterToHost.cs rename to DUI3-DX/Sdk/Speckle.Converters.Common/IRootToHostConverter.cs index e24e1ddebe..2f11b6e5c4 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common/ISpeckleConverterToHost.cs +++ b/DUI3-DX/Sdk/Speckle.Converters.Common/IRootToHostConverter.cs @@ -2,7 +2,7 @@ namespace Speckle.Converters.Common; -public interface ISpeckleConverterToHost +public interface IRootToHostConverter { object Convert(Base target); } diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ArcGISConverterToSpeckle.cs b/DUI3-DX/Sdk/Speckle.Converters.Common/IRootToSpeckleConverter.cs similarity index 68% rename from DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ArcGISConverterToSpeckle.cs rename to DUI3-DX/Sdk/Speckle.Converters.Common/IRootToSpeckleConverter.cs index bc7673b5c9..6a19ebb13a 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ArcGISConverterToSpeckle.cs +++ b/DUI3-DX/Sdk/Speckle.Converters.Common/IRootToSpeckleConverter.cs @@ -1,16 +1,16 @@ using Speckle.Autofac.DependencyInjection; -using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; using Speckle.Core.Models; +using Speckle.InterfaceGenerator; -namespace Speckle.Converters.ArcGIS3; +namespace Speckle.Converters.Common; -//poc: dupe code from rhino -public class ArcGISConverterToSpeckle : ISpeckleConverterToSpeckle +[GenerateAutoInterface] +public class RootToSpeckleConverter : IRootToSpeckleConverter { - private readonly IFactory _toSpeckle; + private readonly IFactory _toSpeckle; - public ArcGISConverterToSpeckle(IFactory toSpeckle) + public RootToSpeckleConverter(IFactory toSpeckle) { _toSpeckle = toSpeckle; } diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common/ISpeckleConverterToSpeckle.cs b/DUI3-DX/Sdk/Speckle.Converters.Common/ISpeckleConverterToSpeckle.cs deleted file mode 100644 index 459cb99736..0000000000 --- a/DUI3-DX/Sdk/Speckle.Converters.Common/ISpeckleConverterToSpeckle.cs +++ /dev/null @@ -1,8 +0,0 @@ -using Speckle.Core.Models; - -namespace Speckle.Converters.Common; - -public interface ISpeckleConverterToSpeckle -{ - Base Convert(object target); -} diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common/Objects/FloorConversion.cs b/DUI3-DX/Sdk/Speckle.Converters.Common/Objects/FloorConversion.cs deleted file mode 100644 index 16613848df..0000000000 --- a/DUI3-DX/Sdk/Speckle.Converters.Common/Objects/FloorConversion.cs +++ /dev/null @@ -1,3 +0,0 @@ -namespace Speckle.Converters.Common.Objects; - -public class FloorConversion { } diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common/Objects/IConverterResolver.cs b/DUI3-DX/Sdk/Speckle.Converters.Common/Objects/IConverterResolver.cs deleted file mode 100644 index 5ba47c7eda..0000000000 --- a/DUI3-DX/Sdk/Speckle.Converters.Common/Objects/IConverterResolver.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Speckle.Converters.Common.Objects; - -public interface IConverterResolver - where TConverter : class -{ - public TConverter? GetConversionForType(Type objectType); -} diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common/Objects/IRawConversion.cs b/DUI3-DX/Sdk/Speckle.Converters.Common/Objects/IRawConversion.cs deleted file mode 100644 index 0b2060e8c1..0000000000 --- a/DUI3-DX/Sdk/Speckle.Converters.Common/Objects/IRawConversion.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace Speckle.Converters.Common.Objects; - -public interface IRawConversion -{ - TOut RawConvert(TIn target); -} diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common/Objects/ISpeckleObjectToHostConversion.cs b/DUI3-DX/Sdk/Speckle.Converters.Common/Objects/IToHostTopLevelConverter.cs similarity index 83% rename from DUI3-DX/Sdk/Speckle.Converters.Common/Objects/ISpeckleObjectToHostConversion.cs rename to DUI3-DX/Sdk/Speckle.Converters.Common/Objects/IToHostTopLevelConverter.cs index ffb203143f..59869df951 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common/Objects/ISpeckleObjectToHostConversion.cs +++ b/DUI3-DX/Sdk/Speckle.Converters.Common/Objects/IToHostTopLevelConverter.cs @@ -6,7 +6,7 @@ namespace Speckle.Converters.Common.Objects; // * begin scope: https://stackoverflow.com/questions/49595198/autofac-resolving-through-factory-methods // Interceptors? -public interface ISpeckleObjectToHostConversion +public interface IToHostTopLevelConverter { object Convert(Base target); } diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common/Objects/IHostObjectToSpeckleConversion.cs b/DUI3-DX/Sdk/Speckle.Converters.Common/Objects/IToSpeckleTopLevelConverter.cs similarity index 83% rename from DUI3-DX/Sdk/Speckle.Converters.Common/Objects/IHostObjectToSpeckleConversion.cs rename to DUI3-DX/Sdk/Speckle.Converters.Common/Objects/IToSpeckleTopLevelConverter.cs index f12977017e..b0d7525e6e 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common/Objects/IHostObjectToSpeckleConversion.cs +++ b/DUI3-DX/Sdk/Speckle.Converters.Common/Objects/IToSpeckleTopLevelConverter.cs @@ -6,7 +6,7 @@ namespace Speckle.Converters.Common.Objects; // * begin scope: https://stackoverflow.com/questions/49595198/autofac-resolving-through-factory-methods // Interceptors? -public interface IHostObjectToSpeckleConversion +public interface IToSpeckleTopLevelConverter { Base Convert(object target); } diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common/Objects/ITypedConverter.cs b/DUI3-DX/Sdk/Speckle.Converters.Common/Objects/ITypedConverter.cs new file mode 100644 index 0000000000..80efa37f86 --- /dev/null +++ b/DUI3-DX/Sdk/Speckle.Converters.Common/Objects/ITypedConverter.cs @@ -0,0 +1,6 @@ +namespace Speckle.Converters.Common.Objects; + +public interface ITypedConverter +{ + TOut Convert(TIn target); +} diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common/RecursiveConveterResolver.cs b/DUI3-DX/Sdk/Speckle.Converters.Common/RecursiveConverterResolver.cs similarity index 62% rename from DUI3-DX/Sdk/Speckle.Converters.Common/RecursiveConveterResolver.cs rename to DUI3-DX/Sdk/Speckle.Converters.Common/RecursiveConverterResolver.cs index 88cdcec475..0c18169e5c 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common/RecursiveConveterResolver.cs +++ b/DUI3-DX/Sdk/Speckle.Converters.Common/RecursiveConverterResolver.cs @@ -1,14 +1,15 @@ using Speckle.Autofac.DependencyInjection; -using Speckle.Converters.Common.Objects; +using Speckle.InterfaceGenerator; namespace Speckle.Converters.Common; -public sealed class RecursiveConverterResolver : IConverterResolver +[GenerateAutoInterface] +public sealed class ConverterResolver : IConverterResolver where TConverter : class { - private readonly IFactory _factory; + private readonly IFactory _factory; - public RecursiveConverterResolver(IFactory factory) + public ConverterResolver(IFactory factory) { _factory = factory; } From 50370cf897e1aab263b7458ed64fbe864540635c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?O=C4=9Fuzhan=20Koral?= <45078678+oguzhankoral@users.noreply.github.com> Date: Wed, 22 May 2024 14:06:28 +0300 Subject: [PATCH 192/261] CNX-9503 ArcGIS send caching (#3433) * Implement send caching by using SendOperation ArcGIS classes removed, they are not needed anymore * Rename ISyncToMainThread to ISyncToThread * Overwrite ISyncToThread to SyncToCurrentThread for rhino too --- .../Bindings/ArcGISSendBinding.cs | 57 +++++++++++--- .../ArcGISConnectorModule.cs | 11 ++- .../Operations/Send/IRootObjectSender.cs | 22 ------ .../Operations/Send/RootObjectBuilder.cs | 73 +++++++---------- .../Operations/Send/RootObjectSender.cs | 78 ------------------- .../Operations/Send/SendOperation.cs | 48 ------------ .../RhinoConnectorModule.cs | 4 + .../Bridge/SyncToCurrentThread.cs | 2 +- .../Bridge/SyncToUIThread.cs | 2 +- .../ContainerRegistration.cs | 2 +- ...{ISyncToMainThread.cs => ISyncToThread.cs} | 2 +- .../Operations/ReceiveOperation.cs | 8 +- .../Operations/SendOperation.cs | 8 +- 13 files changed, 98 insertions(+), 219 deletions(-) delete mode 100644 DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Send/IRootObjectSender.cs delete mode 100644 DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Send/RootObjectSender.cs delete mode 100644 DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Send/SendOperation.cs rename DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/{ISyncToMainThread.cs => ISyncToThread.cs} (74%) diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISSendBinding.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISSendBinding.cs index 0c8a553c20..5227145454 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISSendBinding.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISSendBinding.cs @@ -2,7 +2,6 @@ using Speckle.Autofac.DependencyInjection; using Speckle.Connectors.DUI.Bindings; using Speckle.Connectors.DUI.Bridge; -using Speckle.Connectors.ArcGis.Operations.Send; using Speckle.Connectors.Utils.Cancellation; using Speckle.Core.Logging; using ICancelable = System.Reactive.Disposables.ICancelable; @@ -17,6 +16,8 @@ using ArcGIS.Desktop.Editing.Events; using ArcGIS.Desktop.Framework.Threading.Tasks; using ArcGIS.Core.Data; +using Speckle.Connectors.Utils.Operations; +using Speckle.Core.Models; namespace Speckle.Connectors.ArcGIS.Bindings; @@ -31,6 +32,8 @@ public sealed class ArcGISSendBinding : ISendBinding, ICancelable private readonly List _sendFilters; private readonly CancellationManager _cancellationManager; + private readonly Dictionary _convertedObjectReferences = new(); + /// /// Used internally to aggregate the changed objects' id. /// @@ -252,7 +255,7 @@ public List GetSendSettings() public async Task Send(string modelCardId) { //poc: dupe code between connectors - using IUnitOfWork unitOfWork = _unitOfWorkFactory.Resolve(); + using IUnitOfWork> unitOfWork = _unitOfWorkFactory.Resolve>(); try { // 0 - Init cancellation token source -> Manager also cancel it if exist before @@ -264,18 +267,48 @@ public async Task Send(string modelCardId) throw new InvalidOperationException("No publish model card was found."); } - string versionId = await unitOfWork.Service - .Execute( - modelCard.SendFilter.NotNull(), - modelCard.AccountId.NotNull(), - modelCard.ProjectId.NotNull(), - modelCard.ModelId.NotNull(), - (status, progress) => OnSendOperationProgress(modelCardId, status, progress), - cts.Token - ) + var sendInfo = new SendInfo( + modelCard.AccountId.NotNull(), + modelCard.ProjectId.NotNull(), + modelCard.ModelId.NotNull(), + "ArcGIS", + _convertedObjectReferences, + modelCard.ChangedObjectIds + ); + + var sendResult = await QueuedTask + .Run(async () => + { + List mapMembers = modelCard.SendFilter + .NotNull() + .GetObjectIds() + .Select(id => (MapMember)MapView.Active.Map.FindLayer(id) ?? MapView.Active.Map.FindStandaloneTable(id)) + .Where(obj => obj != null) + .ToList(); + + var result = await unitOfWork.Service + .Execute( + mapMembers, + sendInfo, + (status, progress) => OnSendOperationProgress(modelCardId, status, progress), + cts.Token + ) + .ConfigureAwait(false); + + // Store the converted references in memory for future send operations, overwriting the existing values for the given application id. + foreach (var kvp in result.convertedReferences) + { + _convertedObjectReferences[kvp.Key + modelCard.ProjectId] = kvp.Value; + } + + // It's important to reset the model card's list of changed obj ids so as to ensure we accurately keep track of changes between send operations. + modelCard.ChangedObjectIds = new(); + + return result; + }) .ConfigureAwait(false); - Commands.SetModelCreatedVersionId(modelCardId, versionId); + Commands.SetModelCreatedVersionId(modelCardId, sendResult.rootObjId); } catch (OperationCanceledException) { diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/DependencyInjection/ArcGISConnectorModule.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/DependencyInjection/ArcGISConnectorModule.cs index 61f304fb93..1cf7a60174 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/DependencyInjection/ArcGISConnectorModule.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/DependencyInjection/ArcGISConnectorModule.cs @@ -1,3 +1,4 @@ +using ArcGIS.Desktop.Mapping; using Speckle.Autofac.DependencyInjection; using Speckle.Connectors.ArcGIS.Bindings; using Speckle.Connectors.ArcGis.Operations.Send; @@ -10,8 +11,10 @@ using Speckle.Autofac; using Speckle.Connectors.ArcGIS.Filters; using Speckle.Connectors.DUI; +using Speckle.Connectors.DUI.Bridge; using Speckle.Connectors.DUI.Models; using Speckle.Connectors.Utils; +using Speckle.Connectors.Utils.Operations; using Speckle.Core.Models.GraphTraversal; // POC: This is a temp reference to root object senders to tweak CI failing after having generic interfaces into common project. @@ -28,6 +31,10 @@ public void Load(SpeckleContainerBuilder builder) builder.AddDUI(); builder.AddDUIView(); + // POC: Overwriting the SyncToMainThread to SyncToCurrentThread for ArcGIS only! + // On SendOperation, once we called QueuedTask, it expect to run everything on same thread. + builder.AddSingletonInstance(); + builder.AddSingleton(); // Register bindings @@ -45,8 +52,8 @@ public void Load(SpeckleContainerBuilder builder) builder.AddSingleton(DefaultTraversal.CreateTraversalFunc()); // register send operation and dependencies - builder.AddScoped(); + builder.AddScoped>(); builder.AddScoped(); - builder.AddScoped(); + builder.AddSingleton, RootObjectBuilder>(); } } diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Send/IRootObjectSender.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Send/IRootObjectSender.cs deleted file mode 100644 index 5acb5eab38..0000000000 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Send/IRootObjectSender.cs +++ /dev/null @@ -1,22 +0,0 @@ -using Speckle.Core.Models; - -namespace Speckle.Connectors.ArcGis.Operations.Send; - -//poc: duped from rhino - -/// -/// Contract for the send operation that handles an assembled object. -/// In production, this will send to a server. -/// In testing, this could send to a sqlite db or just save to a dictionary. -/// -public interface IRootObjectSender -{ - public Task Send( - Base commitObject, - string accountId, - string projectId, - string modelId, - Action? onOperationProgressed = null, - CancellationToken ct = default - ); -} diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Send/RootObjectBuilder.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Send/RootObjectBuilder.cs index ec933d68b1..637d39bbae 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Send/RootObjectBuilder.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Send/RootObjectBuilder.cs @@ -1,8 +1,8 @@ using ArcGIS.Desktop.Mapping; using Speckle.Autofac.DependencyInjection; -using Speckle.Connectors.DUI.Models.Card.SendFilter; +using Speckle.Connectors.Utils.Builders; +using Speckle.Connectors.Utils.Operations; using Speckle.Converters.Common; -using Speckle.Core.Logging; using Speckle.Core.Models; namespace Speckle.Connectors.ArcGis.Operations.Send; @@ -10,7 +10,7 @@ namespace Speckle.Connectors.ArcGis.Operations.Send; /// /// Stateless builder object to turn an ISendFilter into a object /// -public class RootObjectBuilder +public class RootObjectBuilder : IRootObjectBuilder { private readonly IUnitOfWorkFactory _unitOfWorkFactory; @@ -20,65 +20,51 @@ public RootObjectBuilder(IUnitOfWorkFactory unitOfWorkFactory) } public Base Build( - ISendFilter sendFilter, + IReadOnlyList objects, + SendInfo sendInfo, Action? onOperationProgressed = null, CancellationToken ct = default ) { - if (MapView.Active == null) + if (!objects.Any()) { - throw new SpeckleException("No Map currently active"); + // POC: not sure if we would want to throw in here? + throw new InvalidOperationException("No objects were found. Please update your send filter!"); } - List selectedObjects = sendFilter.GetObjectIds().Where(obj => obj != null).ToList(); - - if (selectedObjects.Count == 0) - { - throw new InvalidOperationException("No layers were found. Please update your send filter!"); - } - - Base commitObject = ConvertObjects(selectedObjects, onOperationProgressed, ct); - return commitObject; - } - - //poc: semi dupe - private Collection ConvertObjects( - IReadOnlyList uriList, - Action? onOperationProgressed = null, - CancellationToken cancellationToken = default - ) - { // POC: does this feel like the right place? I am wondering if this should be called from within send/rcv? // begin the unit of work using var uow = _unitOfWorkFactory.Resolve(); var converter = uow.Service; - // var rootObjectCollection = new Collection { name = RhinoDoc.ActiveDoc.Name ?? "Unnamed document" }; int count = 0; Collection rootObjectCollection = new(); //TODO: Collections - foreach (string uri in uriList) + foreach (MapMember mapMember in objects) { - cancellationToken.ThrowIfCancellationRequested(); + ct.ThrowIfCancellationRequested(); var collectionHost = rootObjectCollection; - var applicationId = uri; - - Base converted = new(); - - MapMember mapMember = MapView.Active.Map.FindLayer(uri); - if (mapMember is null) - { - mapMember = MapView.Active.Map.FindStandaloneTable(uri); - } - if (mapMember is null) - { - continue; - } + var applicationId = mapMember.URI; try { - converted = converter.Convert(mapMember); + Base converted; + if ( + !sendInfo.ChangedObjectIds.Contains(applicationId) + && sendInfo.ConvertedObjects.TryGetValue(applicationId + sendInfo.ProjectId, out ObjectReference? value) + ) + { + converted = value; + } + else + { + converted = converter.Convert(mapMember); + converted.applicationId = applicationId; + } + + // add to host + collectionHost.elements.Add(converted); } // POC: Exception handling on conversion logic must be revisited after several connectors have working conversions catch (SpeckleConversionException e) @@ -94,10 +80,7 @@ private Collection ConvertObjects( continue; } - converted.applicationId = applicationId; - // add to host - collectionHost.elements.Add(converted); - onOperationProgressed?.Invoke("Converting", (double)++count / uriList.Count); + onOperationProgressed?.Invoke("Converting", (double)++count / objects.Count); } return rootObjectCollection; diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Send/RootObjectSender.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Send/RootObjectSender.cs deleted file mode 100644 index 4d799d488d..0000000000 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Send/RootObjectSender.cs +++ /dev/null @@ -1,78 +0,0 @@ -using Speckle.Connectors.Utils.Operations; -using Speckle.Core.Api; -using Speckle.Core.Credentials; -using Speckle.Core.Models; -using Speckle.Core.Transports; - -namespace Speckle.Connectors.ArcGis.Operations.Send; - -//poc: this class is a file paste from rhino - -/// -/// Default implementation of the which takes a and sends -/// it to a server described by the parameters in the method -/// -internal sealed class RootObjectSender : IRootObjectSender -{ - // POC: this is going off the concrete type which is not so great, though this is the example: - // see delegate factories: https://autofac.readthedocs.io/en/latest/advanced/delegate-factories.html - // I am pretty sure this delegate can be moved as I am sure Autofac looks at the return type and knows nothing - // about the class the factory is defined in - // this is binding us to the transport concrete type, so... that needs some thought - private readonly ServerTransport.Factory _transportFactory; - - public RootObjectSender(ServerTransport.Factory transportFactory) - { - _transportFactory = transportFactory; - } - - public async Task Send( - Base commitObject, - string accountId, - string projectId, - string modelId, - Action? onOperationProgressed = null, - CancellationToken ct = default - ) - { - ct.ThrowIfCancellationRequested(); - - onOperationProgressed?.Invoke("Uploading...", null); - - Account account = AccountManager.GetAccount(accountId); - - ITransport transport = _transportFactory(account, projectId, 60, null); - var sendResult = await SendHelper.Send(commitObject, transport, true, null, ct).ConfigureAwait(false); - - ct.ThrowIfCancellationRequested(); - //// Store the converted references in memory for future send operations, overwriting the existing values for the given application id. - //foreach (var kvp in sendResult.ConvertedReferences) - //{ - // // TODO: Bug in here, we need to encapsulate cache not only by app id, but also by project id, - // // TODO: as otherwise we assume incorrectly that an object exists for a given project (e.g, send box to project 1, send same unchanged box to project 2) - // _convertedObjectReferences[kvp.Key + projectId] = kvp.Value; - //} - // It's important to reset the model card's list of changed obj ids so as to ensure we accurately keep track of changes between send operations. - // NOTE: ChangedObjectIds is currently JsonIgnored, but could actually be useful for highlighting changes in host app. - //modelCard.ChangedObjectIds = new(); - - onOperationProgressed?.Invoke("Linking version to model...", null); - - // 8 - Create the version (commit) - using var apiClient = new Client(account); - string versionId = await apiClient - .CommitCreate( - new CommitCreateInput - { - streamId = projectId, - branchName = modelId, - sourceApplication = "ArcGIS", - objectId = sendResult.rootObjId - }, - ct - ) - .ConfigureAwait(true); - - return versionId; - } -} diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Send/SendOperation.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Send/SendOperation.cs deleted file mode 100644 index 03bddea6a9..0000000000 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Send/SendOperation.cs +++ /dev/null @@ -1,48 +0,0 @@ -using ArcGIS.Desktop.Framework.Threading.Tasks; -using Speckle.Core.Models; -using Speckle.Connectors.DUI.Models.Card.SendFilter; - -namespace Speckle.Connectors.ArcGis.Operations.Send; - -//POC: This file is a copy-paste from Rhino - -/// -/// Stateless send operation orchestrator. -/// -public sealed class SendOperation -{ - private readonly RootObjectBuilder _baseBuilder; - private readonly IRootObjectSender _baseObjectSender; - - public SendOperation(RootObjectBuilder baseBuilder, IRootObjectSender baseObjectSender) - { - _baseBuilder = baseBuilder; - _baseObjectSender = baseObjectSender; - } - - /// - /// Executes a send operation given information about the host objects and the destination account. - /// - public async Task Execute( - ISendFilter sendFilter, - string accountId, - string projectId, - string modelId, - Action? onOperationProgressed = null, - CancellationToken ct = default - ) - { - // POC: decide where to push operations to MCT - Base commitObject = await QueuedTask - .Run(() => _baseBuilder.Build(sendFilter, onOperationProgressed, ct)) - .ConfigureAwait(false); - - // base object handler is separated so we can do some testing on non-production databases - // exact interface may want to be tweaked when we implement this - string versionId = await _baseObjectSender - .Send(commitObject, accountId, projectId, modelId, onOperationProgressed, ct) - .ConfigureAwait(false); - - return versionId; - } -} diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/RhinoConnectorModule.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/RhinoConnectorModule.cs index 3cc59fd408..15475b4f62 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/RhinoConnectorModule.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/RhinoConnectorModule.cs @@ -5,6 +5,7 @@ using Speckle.Autofac.DependencyInjection; using Speckle.Connectors.DUI; using Speckle.Connectors.DUI.Bindings; +using Speckle.Connectors.DUI.Bridge; using Speckle.Connectors.DUI.Models; using Speckle.Connectors.Rhino7.Bindings; using Speckle.Connectors.Rhino7.Filters; @@ -36,6 +37,9 @@ public void Load(SpeckleContainerBuilder builder) builder.AddDUI(); builder.AddDUIView(); + // POC: Overwriting the SyncToMainThread to SyncToCurrentThread for Rhino! + builder.AddSingletonInstance(); + // Register other connector specific types builder.AddSingleton(); builder.AddSingleton(); diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/SyncToCurrentThread.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/SyncToCurrentThread.cs index 25168fcf32..8896771bd0 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/SyncToCurrentThread.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/SyncToCurrentThread.cs @@ -5,7 +5,7 @@ namespace Speckle.Connectors.DUI.Bridge; /// /// Implements the ISyncToMainThread interface and runs a given function on the current thread using Task.Run. /// -public class SyncToCurrentThread : ISyncToMainThread +public class SyncToCurrentThread : ISyncToThread { /// /// Executes a given function on the current thread using Task.Run. diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/SyncToUIThread.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/SyncToUIThread.cs index 3d1d1e21b5..90a52df570 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/SyncToUIThread.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/SyncToUIThread.cs @@ -3,7 +3,7 @@ namespace Speckle.Connectors.DUI.Bridge; -public class SyncToUIThread : ISyncToMainThread +public class SyncToUIThread : ISyncToThread { private readonly IBridge _bridge; diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/ContainerRegistration.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/ContainerRegistration.cs index 3de29febee..6671c44837 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/ContainerRegistration.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/ContainerRegistration.cs @@ -14,7 +14,7 @@ public static class ContainerRegistration public static void AddDUI(this SpeckleContainerBuilder speckleContainerBuilder) { // send operation and dependencies - speckleContainerBuilder.AddSingletonInstance(); + speckleContainerBuilder.AddSingletonInstance(); speckleContainerBuilder.AddTransient(); speckleContainerBuilder.AddSingleton(); speckleContainerBuilder.AddTransient(); // POC: Each binding should have it's own bridge instance diff --git a/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/ISyncToMainThread.cs b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/ISyncToThread.cs similarity index 74% rename from DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/ISyncToMainThread.cs rename to DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/ISyncToThread.cs index e757070e72..7e1950a300 100644 --- a/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/ISyncToMainThread.cs +++ b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/ISyncToThread.cs @@ -1,6 +1,6 @@ namespace Speckle.Connectors.Utils.Operations; -public interface ISyncToMainThread +public interface ISyncToThread { public Task RunOnThread(Func func); } diff --git a/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/ReceiveOperation.cs b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/ReceiveOperation.cs index 0d1c745791..dcf56c1a53 100644 --- a/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/ReceiveOperation.cs +++ b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/ReceiveOperation.cs @@ -9,12 +9,12 @@ namespace Speckle.Connectors.Utils.Operations; public sealed class ReceiveOperation { private readonly IHostObjectBuilder _hostObjectBuilder; - private readonly ISyncToMainThread _syncToMainThread; + private readonly ISyncToThread _syncToThread; - public ReceiveOperation(IHostObjectBuilder hostObjectBuilder, ISyncToMainThread syncToMainThread) + public ReceiveOperation(IHostObjectBuilder hostObjectBuilder, ISyncToThread syncToThread) { _hostObjectBuilder = hostObjectBuilder; - _syncToMainThread = syncToMainThread; + _syncToThread = syncToThread; } public async Task> Execute( @@ -42,7 +42,7 @@ public async Task> Execute( cancellationToken.ThrowIfCancellationRequested(); // 4 - Convert objects - return await _syncToMainThread + return await _syncToThread .RunOnThread(() => { return _hostObjectBuilder.Build(commitObject, projectName, modelName, onOperationProgressed, cancellationToken); diff --git a/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/SendOperation.cs b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/SendOperation.cs index f5f9453077..38f1a5dedc 100644 --- a/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/SendOperation.cs +++ b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/SendOperation.cs @@ -7,17 +7,17 @@ public sealed class SendOperation { private readonly IRootObjectBuilder _rootObjectBuilder; private readonly IRootObjectSender _baseObjectSender; - private readonly ISyncToMainThread _syncToMainThread; + private readonly ISyncToThread _syncToThread; public SendOperation( IRootObjectBuilder rootObjectBuilder, IRootObjectSender baseObjectSender, - ISyncToMainThread syncToMainThread + ISyncToThread syncToThread ) { _rootObjectBuilder = rootObjectBuilder; _baseObjectSender = baseObjectSender; - _syncToMainThread = syncToMainThread; + _syncToThread = syncToThread; } public async Task<(string rootObjId, Dictionary convertedReferences)> Execute( @@ -27,7 +27,7 @@ ISyncToMainThread syncToMainThread CancellationToken ct = default ) { - Base commitObject = await _syncToMainThread + Base commitObject = await _syncToThread .RunOnThread(() => _rootObjectBuilder.Build(objects, sendInfo, onOperationProgressed, ct)) .ConfigureAwait(false); From 034f2e96d894e9d65a3589f84aa8a3588a616575 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?O=C4=9Fuzhan=20Koral?= <45078678+oguzhankoral@users.noreply.github.com> Date: Fri, 24 May 2024 15:01:26 +0300 Subject: [PATCH 193/261] CNX-9500 Implement highlighting sent elements (#3432) * Implement highlighting sent elements * Remove not null check from active map * Edit using as inline --- .../Bindings/BasicConnectorBinding.cs | 99 ++++++++++++++++++- 1 file changed, 98 insertions(+), 1 deletion(-) diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/BasicConnectorBinding.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/BasicConnectorBinding.cs index 30504b4c80..97d3aceb5e 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/BasicConnectorBinding.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/BasicConnectorBinding.cs @@ -1,5 +1,9 @@ using System.Reflection; +using ArcGIS.Core.Data; +using ArcGIS.Core.Geometry; using ArcGIS.Desktop.Core; +using ArcGIS.Desktop.Framework.Threading.Tasks; +using ArcGIS.Desktop.Mapping; using Speckle.Connectors.ArcGIS.HostApp; using Speckle.Connectors.DUI.Bindings; using Speckle.Connectors.DUI.Bridge; @@ -49,5 +53,98 @@ public BasicConnectorBinding(DocumentModelStore store, ArcGISSettings settings, public void RemoveModel(ModelCard model) => _store.RemoveModel(model); - public void HighlightModel(string modelCardId) => throw new System.NotImplementedException(); + public async void HighlightModel(string modelCardId) + { + MapView mapView = MapView.Active; + + var model = _store.GetModelById(modelCardId); + + if (model is null) + { + return; + } + + var objectIds = new List(); + + if (model is SenderModelCard senderModelCard) + { + objectIds = senderModelCard.SendFilter.NotNull().GetObjectIds(); + } + + if (model is ReceiverModelCard receiverModelCard) + { + objectIds = receiverModelCard.ReceiveResult?.BakedObjectIds.NotNull(); + } + + if (objectIds is null) + { + return; + } + + await QueuedTask + .Run(() => + { + List mapMembers = GetMapMembers(objectIds, mapView); + ClearSelection(); + SelectMapMembers(mapMembers); + mapView.ZoomToSelected(); + }) + .ConfigureAwait(false); + } + + private List GetMapMembers(List objectIds, MapView mapView) + { + List mapMembers = new(); + + foreach (string objectId in objectIds) + { + MapMember mapMember = mapView.Map.FindLayer(objectId); + if (mapMember is null) + { + mapMember = mapView.Map.FindStandaloneTable(objectId); + } + if (mapMember is null) + { + continue; + } + mapMembers.Add(mapMember); + } + + return mapMembers; + } + + private void ClearSelection() + { + List mapMembers = MapView.Active.Map.GetLayersAsFlattenedList().ToList(); + foreach (var member in mapMembers) + { + if (member is FeatureLayer featureLayer) + { + featureLayer.ClearSelection(); + } + } + } + + private void SelectMapMembers(List mapMembers) + { + foreach (var member in mapMembers) + { + if (member is FeatureLayer featureLayer) + { + using RowCursor rowCursor = featureLayer.Search(); + while (rowCursor.MoveNext()) + { + using (var row = rowCursor.Current) + { + if (row is not Feature feature) + { + continue; + } + Geometry geometry = feature.GetShape(); + MapView.Active.SelectFeatures(geometry, SelectionCombinationMethod.Add); + } + } + } + } + } } From 8fcf59aaae481e805feb7dfd14c1fc0a1c2b93ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?O=C4=9Fuzhan=20Koral?= <45078678+oguzhankoral@users.noreply.github.com> Date: Fri, 24 May 2024 22:17:37 +0300 Subject: [PATCH 194/261] CNX-9303 define a top level error handling strategy for all connectors most likely in the i bridge (#3439) * Catch TargetInvocationException on bridge * Catch AggregateException for async calls * Extract ReportUnhandledError method * Be more specific on binding methods and catch unhandled expections on the bridge * Remove unused namespaces * SpeckleSendFilterException inherit from SpeckleException * Simplify general error handling on bridge * Simplify error message --- .../Bindings/ArcGISReceiveBinding.cs | 14 +++++---- .../Bindings/ArcGISSendBinding.cs | 30 ++++++++++++------- .../Operations/Send/RootObjectBuilder.cs | 6 ---- .../Bindings/AutocadReceiveBinding.cs | 14 +++++---- .../Bindings/AutocadSendBinding.cs | 21 ++++++++----- .../Bindings/SendBinding.cs | 25 +++++++++++----- .../Operations/Send/RevitRootObjectBuilder.cs | 3 +- .../Bindings/RhinoReceiveBinding.cs | 14 +++++---- .../Bindings/RhinoSendBinding.cs | 26 ++++++++++------ .../Operations/Send/RhinoRootObjectBuilder.cs | 13 +------- .../Bridge/BrowserBridge.cs | 18 ++++++++++- .../Exceptions/SpeckleSendFilterException.cs | 14 +++++++++ 12 files changed, 125 insertions(+), 73 deletions(-) create mode 100644 DUI3-DX/DUI3/Speckle.Connectors.DUI/Exceptions/SpeckleSendFilterException.cs diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISReceiveBinding.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISReceiveBinding.cs index 58d2e9e462..f39adfc67d 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISReceiveBinding.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISReceiveBinding.cs @@ -6,7 +6,6 @@ using Speckle.Connectors.Utils; using Speckle.Connectors.Utils.Cancellation; using Speckle.Connectors.Utils.Operations; -using Speckle.Core.Logging; using ICancelable = System.Reactive.Disposables.ICancelable; namespace Speckle.Connectors.ArcGIS.Bindings; @@ -39,15 +38,16 @@ public async Task Receive(string modelCardId) { try { - // Init cancellation token source -> Manager also cancel it if exist before - CancellationTokenSource cts = _cancellationManager.InitCancellationTokenSource(modelCardId); - // Get receiver card if (_store.GetModelById(modelCardId) is not ReceiverModelCard modelCard) { + // Handle as GLOBAL ERROR at BrowserBridge throw new InvalidOperationException("No download model card was found."); } + // Init cancellation token source -> Manager also cancel it if exist before + CancellationTokenSource cts = _cancellationManager.InitCancellationTokenSource(modelCardId); + using IUnitOfWork unitOfWork = _unitOfWorkFactory.Resolve(); // Receive host objects @@ -65,9 +65,11 @@ public async Task Receive(string modelCardId) Commands.SetModelReceiveResult(modelCardId, receivedObjectIds.ToList()); } - catch (Exception e) when (!e.IsFatal()) // All exceptions should be handled here if possible, otherwise we enter "crashing the host app" territory. + // Catch here specific exceptions if they related to model card. + catch (OperationCanceledException) { - Commands.SetModelError(modelCardId, e); + // SWALLOW -> UI handles it immediately, so we do not need to handle anything + return; } } diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISSendBinding.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISSendBinding.cs index 5227145454..9f883384c3 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISSendBinding.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISSendBinding.cs @@ -3,19 +3,19 @@ using Speckle.Connectors.DUI.Bindings; using Speckle.Connectors.DUI.Bridge; using Speckle.Connectors.Utils.Cancellation; -using Speckle.Core.Logging; using ICancelable = System.Reactive.Disposables.ICancelable; using Speckle.Connectors.DUI.Models; using Speckle.Connectors.DUI.Models.Card; using Speckle.Connectors.DUI.Models.Card.SendFilter; using Speckle.Connectors.DUI.Settings; -using Speckle.Connectors.Utils; using ArcGIS.Desktop.Mapping.Events; using ArcGIS.Desktop.Mapping; using Speckle.Connectors.ArcGIS.Filters; using ArcGIS.Desktop.Editing.Events; using ArcGIS.Desktop.Framework.Threading.Tasks; using ArcGIS.Core.Data; +using Speckle.Connectors.DUI.Exceptions; +using Speckle.Connectors.Utils; using Speckle.Connectors.Utils.Operations; using Speckle.Core.Models; @@ -258,15 +258,15 @@ public async Task Send(string modelCardId) using IUnitOfWork> unitOfWork = _unitOfWorkFactory.Resolve>(); try { - // 0 - Init cancellation token source -> Manager also cancel it if exist before - CancellationTokenSource cts = _cancellationManager.InitCancellationTokenSource(modelCardId); - - // 1 - Get model if (_store.GetModelById(modelCardId) is not SenderModelCard modelCard) { + // Handle as GLOBAL ERROR at BrowserBridge throw new InvalidOperationException("No publish model card was found."); } + // Init cancellation token source -> Manager also cancel it if exist before + CancellationTokenSource cts = _cancellationManager.InitCancellationTokenSource(modelCardId); + var sendInfo = new SendInfo( modelCard.AccountId.NotNull(), modelCard.ProjectId.NotNull(), @@ -286,6 +286,14 @@ public async Task Send(string modelCardId) .Where(obj => obj != null) .ToList(); + if (!mapMembers.Any()) + { + // Handle as CARD ERROR in this function + throw new SpeckleSendFilterException( + "No objects were found to convert. Please update your publish filter!" + ); + } + var result = await unitOfWork.Service .Execute( mapMembers, @@ -310,13 +318,15 @@ public async Task Send(string modelCardId) Commands.SetModelCreatedVersionId(modelCardId, sendResult.rootObjId); } - catch (OperationCanceledException) + // Catch here specific exceptions if they related to model card. + catch (SpeckleSendFilterException e) { - return; + Commands.SetModelError(modelCardId, e); } - catch (Exception e) when (!e.IsFatal()) // All exceptions should be handled here if possible, otherwise we enter "crashing the host app" territory. + catch (OperationCanceledException) { - Commands.SetModelError(modelCardId, e); + // SWALLOW -> UI handles it immediately, so we do not need to handle anything + return; } } diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Send/RootObjectBuilder.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Send/RootObjectBuilder.cs index 637d39bbae..6af77c66cb 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Send/RootObjectBuilder.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Send/RootObjectBuilder.cs @@ -26,12 +26,6 @@ public Base Build( CancellationToken ct = default ) { - if (!objects.Any()) - { - // POC: not sure if we would want to throw in here? - throw new InvalidOperationException("No objects were found. Please update your send filter!"); - } - // POC: does this feel like the right place? I am wondering if this should be called from within send/rcv? // begin the unit of work using var uow = _unitOfWorkFactory.Resolve(); diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadReceiveBinding.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadReceiveBinding.cs index 181e152051..7cce92087a 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadReceiveBinding.cs +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadReceiveBinding.cs @@ -6,7 +6,6 @@ using Speckle.Connectors.DUI.Models.Card; using Speckle.Connectors.Utils; using Speckle.Connectors.Utils.Operations; -using Speckle.Core.Logging; using ICancelable = System.Reactive.Disposables.ICancelable; namespace Speckle.Connectors.Autocad.Bindings; @@ -43,15 +42,16 @@ public async Task Receive(string modelCardId) using var unitOfWork = _unitOfWorkFactory.Resolve(); try { - // Init cancellation token source -> Manager also cancel it if exist before - CancellationTokenSource cts = _cancellationManager.InitCancellationTokenSource(modelCardId); - // Get receiver card if (_store.GetModelById(modelCardId) is not ReceiverModelCard modelCard) { + // Handle as GLOBAL ERROR at BrowserBridge throw new InvalidOperationException("No download model card was found."); } + // Init cancellation token source -> Manager also cancel it if exist before + CancellationTokenSource cts = _cancellationManager.InitCancellationTokenSource(modelCardId); + // Receive host objects IEnumerable receivedObjectIds = await unitOfWork.Service .Execute( @@ -67,9 +67,11 @@ public async Task Receive(string modelCardId) Commands.SetModelReceiveResult(modelCardId, receivedObjectIds.ToList()); } - catch (Exception e) when (!e.IsFatal()) // All exceptions should be handled here if possible, otherwise we enter "crashing the host app" territory. + // Catch here specific exceptions if they related to model card. + catch (OperationCanceledException) { - Commands.SetModelError(modelCardId, e); + // SWALLOW -> UI handles it immediately, so we do not need to handle anything + return; } } diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadSendBinding.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadSendBinding.cs index d33db5b048..2549d7744a 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadSendBinding.cs +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadSendBinding.cs @@ -6,9 +6,9 @@ using Speckle.Connectors.DUI.Models; using Speckle.Connectors.DUI.Models.Card; using Speckle.Connectors.Utils.Cancellation; -using Speckle.Core.Logging; using Speckle.Autofac.DependencyInjection; using Speckle.Connectors.Autocad.Operations.Send; +using Speckle.Connectors.DUI.Exceptions; using Speckle.Connectors.Utils.Operations; using Speckle.Core.Models; using ICancelable = System.Reactive.Disposables.ICancelable; @@ -122,23 +122,26 @@ private async Task SendInternal(string modelCardId) { try { - using var uow = _unitOfWorkFactory.Resolve>(); - // 0 - Init cancellation token source -> Manager also cancel it if exist before - CancellationTokenSource cts = _cancellationManager.InitCancellationTokenSource(modelCardId); - - // 1 - Get model if (_store.GetModelById(modelCardId) is not SenderModelCard modelCard) { + // Handle as GLOBAL ERROR at BrowserBridge throw new InvalidOperationException("No publish model card was found."); } + using var uow = _unitOfWorkFactory.Resolve>(); + + // Init cancellation token source -> Manager also cancel it if exist before + CancellationTokenSource cts = _cancellationManager.InitCancellationTokenSource(modelCardId); + // Get elements to convert List autocadObjects = Application.DocumentManager.CurrentDocument.GetObjects( modelCard.SendFilter.NotNull().GetObjectIds() ); + if (autocadObjects.Count == 0) { - throw new InvalidOperationException("No objects were found. Please update your send filter!"); + // Handle as CARD ERROR in this function + throw new SpeckleSendFilterException("No objects were found to convert. Please update your publish filter!"); } var sendInfo = new SendInfo( @@ -170,11 +173,13 @@ private async Task SendInternal(string modelCardId) Commands.SetModelCreatedVersionId(modelCardId, sendResult.rootObjId); } + // Catch here specific exceptions if they related to model card. catch (OperationCanceledException) { + // SWALLOW -> UI handles it immediately, so we do not need to handle anything return; } - catch (Exception e) when (!e.IsFatal()) // All exceptions should be handled here if possible, otherwise we enter "crashing the host app" territory. + catch (SpeckleSendFilterException e) { Commands.SetModelError(modelCardId, e); } diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SendBinding.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SendBinding.cs index d8eac56d4e..0383e8a77c 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SendBinding.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SendBinding.cs @@ -9,6 +9,7 @@ using Speckle.Connectors.DUI.Models.Card; using Speckle.Connectors.DUI.Bindings; using Speckle.Autofac.DependencyInjection; +using Speckle.Connectors.DUI.Exceptions; using Speckle.Connectors.DUI.Models; using Speckle.Connectors.Utils.Operations; using Speckle.Core.Models; @@ -72,10 +73,6 @@ public void CancelSend(string modelCardId) private async Task HandleSend(string modelCardId) { - // POC: probably the CTS SHOULD be injected as InstancePerLifetimeScope and then - // it can be injected where needed instead of passing it around like a bomb :D - CancellationTokenSource cts = CancellationManager.InitCancellationTokenSource(modelCardId); - // POC: this try catch pattern is coming from Rhino. I see there is a semi implemented "SpeckleTopLevelExceptionHandler" // above that wraps the call of this HandleSend, but it currently is not doing anything - resulting in all errors from here // bubbling up to the bridge. @@ -83,9 +80,14 @@ private async Task HandleSend(string modelCardId) { if (Store.GetModelById(modelCardId) is not SenderModelCard modelCard) { + // Handle as GLOBAL ERROR at BrowserBridge throw new InvalidOperationException("No publish model card was found."); } + // POC: probably the CTS SHOULD be injected as InstancePerLifetimeScope and then + // it can be injected where needed instead of passing it around like a bomb :D + CancellationTokenSource cts = CancellationManager.InitCancellationTokenSource(modelCardId); + using IUnitOfWork> sendOperation = _unitOfWorkFactory.Resolve< SendOperation >(); @@ -96,6 +98,12 @@ private async Task HandleSend(string modelCardId) .Select(id => ElementId.Parse(id)) .ToList(); + if (!revitObjects.Any()) + { + // Handle as CARD ERROR in this function + throw new SpeckleSendFilterException("No objects were found to convert. Please update your publish filter!"); + } + var sendInfo = new SendInfo( modelCard.AccountId.NotNull(), modelCard.ProjectId.NotNull(), @@ -125,13 +133,14 @@ private async Task HandleSend(string modelCardId) Commands.SetModelCreatedVersionId(modelCardId, sendResult.rootObjId); } - catch (OperationCanceledException) + // Catch here specific exceptions if they related to model card. + catch (SpeckleSendFilterException e) { - return; + Commands.SetModelError(modelCardId, e); } - catch (Exception e) when (!e.IsFatal()) // All exceptions should be handled here if possible, otherwise we enter "crashing the host app" territory. + catch (OperationCanceledException) { - Commands.SetModelError(modelCardId, e); + return; } } diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RevitRootObjectBuilder.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RevitRootObjectBuilder.cs index 2f7f484807..921d443444 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RevitRootObjectBuilder.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RevitRootObjectBuilder.cs @@ -1,6 +1,7 @@ using Speckle.Converters.Common; using Speckle.Core.Models; using Autodesk.Revit.DB; +using Speckle.Connectors.DUI.Exceptions; using Speckle.Converters.RevitShared.Helpers; using Speckle.Connectors.Utils.Builders; using Speckle.Connectors.Utils.Operations; @@ -56,7 +57,7 @@ public Base Build( if (revitElements.Count == 0) { - throw new InvalidOperationException("No objects were found. Please update your send filter!"); + throw new SpeckleSendFilterException("No objects were found. Please update your send filter!"); } var countProgress = 0; // because for(int i = 0; ...) loops are so last year diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoReceiveBinding.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoReceiveBinding.cs index 62071b8b54..2373bc69ad 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoReceiveBinding.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoReceiveBinding.cs @@ -6,7 +6,6 @@ using Speckle.Connectors.Utils; using Speckle.Connectors.Utils.Cancellation; using Speckle.Connectors.Utils.Operations; -using Speckle.Core.Logging; namespace Speckle.Connectors.Rhino7.Bindings; @@ -41,15 +40,16 @@ public async Task Receive(string modelCardId) using var unitOfWork = _unitOfWorkFactory.Resolve(); try { - // Init cancellation token source -> Manager also cancel it if exist before - CancellationTokenSource cts = CancellationManager.InitCancellationTokenSource(modelCardId); - // Get receiver card if (_store.GetModelById(modelCardId) is not ReceiverModelCard modelCard) { + // Handle as GLOBAL ERROR at BrowserBridge throw new InvalidOperationException("No download model card was found."); } + // Init cancellation token source -> Manager also cancel it if exist before + CancellationTokenSource cts = CancellationManager.InitCancellationTokenSource(modelCardId); + // Receive host objects IEnumerable receivedObjectIds = await unitOfWork.Service .Execute( @@ -66,9 +66,11 @@ public async Task Receive(string modelCardId) // POC: Here we can't set receive result if ReceiveOperation throws an error. Commands.SetModelReceiveResult(modelCardId, receivedObjectIds.ToList()); } - catch (Exception e) when (!e.IsFatal()) // All exceptions should be handled here if possible, otherwise we enter "crashing the host app" territory. + // Catch here specific exceptions if they related to model card. + catch (OperationCanceledException) { - Commands.SetModelError(modelCardId, e); + // SWALLOW -> UI handles it immediately, so we do not need to handle anything + return; } } diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSendBinding.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSendBinding.cs index 25e3631635..76bca9085c 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSendBinding.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSendBinding.cs @@ -6,10 +6,10 @@ using Speckle.Connectors.DUI.Models.Card; using Speckle.Connectors.Rhino7.HostApp; using Speckle.Connectors.Utils.Cancellation; -using Speckle.Core.Logging; using ICancelable = System.Reactive.Disposables.ICancelable; using Speckle.Autofac.DependencyInjection; using Rhino.DocObjects; +using Speckle.Connectors.DUI.Exceptions; using Speckle.Connectors.DUI.Models.Card.SendFilter; using Speckle.Connectors.Utils.Operations; using Speckle.Core.Models; @@ -137,15 +137,15 @@ public async Task Send(string modelCardId) using var unitOfWork = _unitOfWorkFactory.Resolve>(); try { - // 0 - Init cancellation token source -> Manager also cancel it if exist before - CancellationTokenSource cts = _cancellationManager.InitCancellationTokenSource(modelCardId); - - // 1 - Get model if (_store.GetModelById(modelCardId) is not SenderModelCard modelCard) { + // Handle as GLOBAL ERROR at BrowserBridge throw new InvalidOperationException("No publish model card was found."); } + // Init cancellation token source -> Manager also cancel it if exist before + CancellationTokenSource cts = _cancellationManager.InitCancellationTokenSource(modelCardId); + List rhinoObjects = modelCard.SendFilter .NotNull() .GetObjectIds() @@ -153,6 +153,12 @@ public async Task Send(string modelCardId) .Where(obj => obj != null) .ToList(); + if (!rhinoObjects.Any()) + { + // Handle as CARD ERROR in this function + throw new SpeckleSendFilterException("No objects were found to convert. Please update your publish filter!"); + } + var sendInfo = new SendInfo( modelCard.AccountId.NotNull(), modelCard.ProjectId.NotNull(), @@ -182,13 +188,15 @@ public async Task Send(string modelCardId) Commands.SetModelCreatedVersionId(modelCardId, sendResult.rootObjId); } - catch (OperationCanceledException) + // Catch here specific exceptions if they related to model card. + catch (SpeckleSendFilterException e) { - return; + Commands.SetModelError(modelCardId, e); } - catch (Exception e) when (!e.IsFatal()) // All exceptions should be handled here if possible, otherwise we enter "crashing the host app" territory. + catch (OperationCanceledException) { - Commands.SetModelError(modelCardId, e); + // SWALLOW -> UI handles it immediately, so we do not need to handle anything + return; } } diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Send/RhinoRootObjectBuilder.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Send/RhinoRootObjectBuilder.cs index e599829eaa..5f1020556c 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Send/RhinoRootObjectBuilder.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Send/RhinoRootObjectBuilder.cs @@ -26,18 +26,7 @@ public Base Build( SendInfo sendInfo, Action? onOperationProgressed = null, CancellationToken ct = default - ) - { - if (!objects.Any()) - { - // POC: not sure if we would want to throw in here? - throw new InvalidOperationException("No objects were found. Please update your send filter!"); - } - - Base commitObject = ConvertObjects(objects, sendInfo, onOperationProgressed, ct); - - return commitObject; - } + ) => ConvertObjects(objects, sendInfo, onOperationProgressed, ct); private Collection ConvertObjects( IReadOnlyList rhinoObjects, diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/BrowserBridge.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/BrowserBridge.cs index 564f587ccf..5050f652e3 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/BrowserBridge.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/BrowserBridge.cs @@ -207,6 +207,7 @@ private void ExecuteMethod(string methodName, string requestId, string args) { continue; } + typedArgs[i] = ccc; } @@ -223,7 +224,7 @@ private void ExecuteMethod(string methodName, string requestId, string args) else // It's an async call { // See note at start of function. Do not asyncify! - resultTypedTask.Wait(); + resultTypedTask.GetAwaiter().GetResult(); // If has a "Result" property return the value otherwise null (Task etc) PropertyInfo resultProperty = resultTypedTask.GetType().GetProperty("Result"); @@ -243,6 +244,21 @@ private void ExecuteMethod(string methodName, string requestId, string args) NotifyUIMethodCallResultReady(requestId, serializedError); } + catch (Exception e) when (!e.IsFatal()) + { + ReportUnhandledError(requestId, e); + } + } + + /// + /// Errors that not handled on bindings. + /// + private void ReportUnhandledError(string requestId, Exception e) + { + var errorDetails = new { e.Message, Error = e.ToString() }; + + var serializedError = JsonConvert.SerializeObject(errorDetails, _serializerOptions); + NotifyUIMethodCallResultReady(requestId, serializedError); } /// diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Exceptions/SpeckleSendFilterException.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Exceptions/SpeckleSendFilterException.cs new file mode 100644 index 0000000000..f5ef115b07 --- /dev/null +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Exceptions/SpeckleSendFilterException.cs @@ -0,0 +1,14 @@ +using Speckle.Core.Logging; + +namespace Speckle.Connectors.DUI.Exceptions; + +public class SpeckleSendFilterException : SpeckleException +{ + public SpeckleSendFilterException() { } + + public SpeckleSendFilterException(string message) + : base(message) { } + + public SpeckleSendFilterException(string message, Exception innerException) + : base(message, innerException) { } +} From 1f59f01c465bf3b036a62ecf6d460dfb187cfd66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?O=C4=9Fuzhan=20Koral?= <45078678+oguzhankoral@users.noreply.github.com> Date: Mon, 27 May 2024 16:42:26 +0300 Subject: [PATCH 195/261] Chore (dui3): error message from inner exception on sync functions (#3441) * Pass inner exception message if it is thrown on SYNC function * Extend error details --- .../Speckle.Connectors.DUI/Bridge/BrowserBridge.cs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/BrowserBridge.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/BrowserBridge.cs index 5050f652e3..ba25335a97 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/BrowserBridge.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/BrowserBridge.cs @@ -7,6 +7,7 @@ using System.Diagnostics; using Microsoft.Extensions.Logging; using Speckle.Connectors.Utils; +using Speckle.Core.Models.Extensions; namespace Speckle.Connectors.DUI.Bridge; @@ -255,7 +256,17 @@ private void ExecuteMethod(string methodName, string requestId, string args) /// private void ReportUnhandledError(string requestId, Exception e) { - var errorDetails = new { e.Message, Error = e.ToString() }; + var message = e.Message; + if (e is TargetInvocationException tie) // Exception on SYNC function calls. Message should be passed from inner exception since it is wrapped. + { + message = tie.InnerException?.Message; + } + var errorDetails = new + { + Message = message, // Topmost message + Error = e.ToFormattedString(), // All messages from exceptions + StackTrace = e.ToString() + }; var serializedError = JsonConvert.SerializeObject(errorDetails, _serializerOptions); NotifyUIMethodCallResultReady(requestId, serializedError); From 59a9f23f81e8a670186578dd15736952940c04c8 Mon Sep 17 00:00:00 2001 From: Alan Rynne Date: Wed, 29 May 2024 10:07:29 +0200 Subject: [PATCH 196/261] fix: Warnings picked up in net8.0 (#3446) --- .../Bindings/ArcGISSendBinding.cs | 2 +- .../Operations/Receive/HostObjectBuilder.cs | 8 +++----- .../Operations/Receive/AutocadHostObjectBuilder.cs | 2 +- .../Bindings/BasicConnectorBindingRevit.cs | 2 +- .../Bindings/SendBinding.cs | 2 +- .../Operations/Send/RevitRootObjectBuilder.cs | 4 ++-- .../Bindings/RhinoSendBinding.cs | 2 +- .../Operations/Receive/RhinoHostObjectBuilder.cs | 3 ++- .../Utils/NonNativeFeaturesUtils.cs | 7 ++++--- .../Raw/PolycurveToHostPolylineRawConverter.cs | 2 +- .../Helpers/DisplayValueExtractor.cs | 14 ++++++++------ .../ReferencePointConverter.cs | 7 ++++--- 12 files changed, 29 insertions(+), 26 deletions(-) diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISSendBinding.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISSendBinding.cs index 9f883384c3..537acd8f5c 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISSendBinding.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISSendBinding.cs @@ -286,7 +286,7 @@ public async Task Send(string modelCardId) .Where(obj => obj != null) .ToList(); - if (!mapMembers.Any()) + if (mapMembers.Count == 0) { // Handle as CARD ERROR in this function throw new SpeckleSendFilterException( diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Receive/HostObjectBuilder.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Receive/HostObjectBuilder.cs index 865c0abdcb..6bae793020 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Receive/HostObjectBuilder.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Receive/HostObjectBuilder.cs @@ -82,7 +82,8 @@ public void AddDatasetsToMap((string, string) databaseObj, string databasePath) private string[] GetLayerPath(TraversalContext context) { string[] collectionBasedPath = context.GetAscendantOfType().Select(c => c.name).ToArray(); - string[] reverseOrderPath = collectionBasedPath.Any() ? collectionBasedPath : context.GetPropertyPath().ToArray(); + string[] reverseOrderPath = + collectionBasedPath.Length != 0 ? collectionBasedPath : context.GetPropertyPath().ToArray(); return reverseOrderPath.Reverse().ToArray(); } @@ -180,10 +181,7 @@ CancellationToken cancellationToken // 3. add layer and tables to the Table Of Content foreach ((string, string) databaseObj in convertedGISObjects) { - if (cancellationToken.IsCancellationRequested) - { - throw new OperationCanceledException(cancellationToken); - } + cancellationToken.ThrowIfCancellationRequested(); // BAKE OBJECTS HERE // POC: QueuedTask var task = QueuedTask.Run(() => diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Operations/Receive/AutocadHostObjectBuilder.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Operations/Receive/AutocadHostObjectBuilder.cs index 9b6b081c5e..12cdf9aaec 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Operations/Receive/AutocadHostObjectBuilder.cs +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Operations/Receive/AutocadHostObjectBuilder.cs @@ -103,7 +103,7 @@ CancellationToken cancellationToken private string GetLayerPath(TraversalContext context, string baseLayerPrefix) { string[] collectionBasedPath = context.GetAscendantOfType().Select(c => c.name).ToArray(); - string[] path = collectionBasedPath.Any() ? collectionBasedPath : context.GetPropertyPath().ToArray(); + string[] path = collectionBasedPath.Length != 0 ? collectionBasedPath : context.GetPropertyPath().ToArray(); return _autocadLayerManager.LayerFullName(baseLayerPrefix, string.Join("-", path)); //TODO: reverse path? } diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/BasicConnectorBindingRevit.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/BasicConnectorBindingRevit.cs index fb01f781e6..56d73f3296 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/BasicConnectorBindingRevit.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/BasicConnectorBindingRevit.cs @@ -91,7 +91,7 @@ public void HighlightModel(string modelCardId) SenderModelCard model = (SenderModelCard)_store.GetModelById(modelCardId); var elementIds = model.SendFilter.NotNull().GetObjectIds().Select(ElementId.Parse).ToList(); - if (elementIds.Any()) + if (elementIds.Count != 0) { Commands.SetModelError(modelCardId, new InvalidOperationException("No objects found to highlight.")); return; diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SendBinding.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SendBinding.cs index 0383e8a77c..223c8d4b0c 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SendBinding.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SendBinding.cs @@ -98,7 +98,7 @@ private async Task HandleSend(string modelCardId) .Select(id => ElementId.Parse(id)) .ToList(); - if (!revitObjects.Any()) + if (revitObjects.Count == 0) { // Handle as CARD ERROR in this function throw new SpeckleSendFilterException("No objects were found to convert. Please update your publish filter!"); diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RevitRootObjectBuilder.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RevitRootObjectBuilder.cs index 921d443444..de37e9d8ad 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RevitRootObjectBuilder.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RevitRootObjectBuilder.cs @@ -122,9 +122,9 @@ private Collection GetAndCreateObjectHostCollection(string[] path) { flatPathName += pathItem; Collection childCollection; - if (_collectionCache.ContainsKey(flatPathName)) + if (_collectionCache.TryGetValue(flatPathName, out Collection? collection)) { - childCollection = _collectionCache[flatPathName]; + childCollection = collection; } else { diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSendBinding.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSendBinding.cs index 76bca9085c..e609468020 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSendBinding.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSendBinding.cs @@ -153,7 +153,7 @@ public async Task Send(string modelCardId) .Where(obj => obj != null) .ToList(); - if (!rhinoObjects.Any()) + if (rhinoObjects.Count == 0) { // Handle as CARD ERROR in this function throw new SpeckleSendFilterException("No objects were found to convert. Please update your publish filter!"); diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Receive/RhinoHostObjectBuilder.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Receive/RhinoHostObjectBuilder.cs index f0a2f5822e..7de29b7a57 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Receive/RhinoHostObjectBuilder.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Receive/RhinoHostObjectBuilder.cs @@ -194,7 +194,8 @@ private int GetAndCreateLayerFromPath(string[] path, string baseLayerName, Dicti private string[] GetLayerPath(TraversalContext context) { string[] collectionBasedPath = context.GetAscendantOfType().Select(c => c.name).ToArray(); - string[] reverseOrderPath = collectionBasedPath.Any() ? collectionBasedPath : context.GetPropertyPath().ToArray(); + string[] reverseOrderPath = + collectionBasedPath.Length != 0 ? collectionBasedPath : context.GetPropertyPath().ToArray(); return reverseOrderPath.Reverse().ToArray(); } } diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/NonNativeFeaturesUtils.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/NonNativeFeaturesUtils.cs index 1682b8774c..4f0fa7cdfc 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/NonNativeFeaturesUtils.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/NonNativeFeaturesUtils.cs @@ -49,12 +49,13 @@ public NonNativeFeaturesUtils( (string parentPath, ACG.Geometry geom, string? parentId) = item.Value; // add dictionnary item if doesn't exist yet - if (!geometryGroups.ContainsKey(parentPath)) + if (!geometryGroups.TryGetValue(parentPath, out var value)) { - geometryGroups[parentPath] = (new List(), parentId); + value = (new List(), parentId); + geometryGroups[parentPath] = value; } - geometryGroups[parentPath].geometries.Add(geom); + value.geometries.Add(geom); } catch (Exception ex) when (!ex.IsFatal()) { diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/PolycurveToHostPolylineRawConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/PolycurveToHostPolylineRawConverter.cs index faa13f0167..1a3425ebe7 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/PolycurveToHostPolylineRawConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/PolycurveToHostPolylineRawConverter.cs @@ -49,7 +49,7 @@ public ADB.Polyline Convert(SOG.Polycurve target) angle = angle < 0 ? angle + 2 * Math.PI : angle; if (angle is null) { - throw new ArgumentNullException(nameof(arc), "Cannot convert arc without angle value."); + throw new ArgumentNullException(nameof(target), "Cannot convert arc without angle value."); } var bulge = Math.Tan((double)angle / 4) * BulgeDirection(arc.startPoint, arc.midPoint, arc.endPoint); diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/DisplayValueExtractor.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/DisplayValueExtractor.cs index 3a9fdb33de..cd65fb5f90 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/DisplayValueExtractor.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/DisplayValueExtractor.cs @@ -51,12 +51,13 @@ public DisplayValueExtractor( foreach (var mesh in meshes) { var materialId = mesh.MaterialElementId; - if (!meshesByMaterial.ContainsKey(materialId)) + if (!meshesByMaterial.TryGetValue(materialId, out List? value)) { - meshesByMaterial[materialId] = new List(); + value = new List(); + meshesByMaterial[materialId] = value; } - meshesByMaterial[materialId].Add(mesh); + value.Add(mesh); } foreach (var solid in solids) @@ -64,12 +65,13 @@ public DisplayValueExtractor( foreach (DB.Face face in solid.Faces) { var materialId = face.MaterialElementId; - if (!meshesByMaterial.ContainsKey(materialId)) + if (!meshesByMaterial.TryGetValue(materialId, out List? value)) { - meshesByMaterial[materialId] = new List(); + value = new List(); + meshesByMaterial[materialId] = value; } - meshesByMaterial[materialId].Add(face.Triangulate()); + value.Add(face.Triangulate()); } } diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ReferencePointConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ReferencePointConverter.cs index 1c63df79d6..901c5c5572 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ReferencePointConverter.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ReferencePointConverter.cs @@ -42,16 +42,17 @@ public DB.Transform GetDocReferencePointTransform(DB.Document doc) //if the current doc is unsaved it will not, but then it'll be the only one :) var id = doc.PathName; - if (!_docTransforms.ContainsKey(id)) + if (!_docTransforms.TryGetValue(id, out DB.Transform? transform)) { // get from settings var referencePointSetting = _revitSettings.TryGetSettingString("reference-point", out string value) ? value : string.Empty; - _docTransforms[id] = GetReferencePointTransform(referencePointSetting); + transform = GetReferencePointTransform(referencePointSetting); + _docTransforms[id] = transform; } - return _docTransforms[id]; + return transform; } [SuppressMessage("Reliability", "CA2000:Dispose objects before losing scope")] From a8153b1723554ab33533d8c4af724f79827b5114 Mon Sep 17 00:00:00 2001 From: Alan Rynne Date: Wed, 29 May 2024 10:19:56 +0200 Subject: [PATCH 197/261] fix: Bump to dotnet 8 --- global.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/global.json b/global.json index 3cb4f9622d..18b689d104 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "7.0.0", + "version": "8.0.0", "rollForward": "latestMinor", "allowPrerelease": false } From 70412bc761cd874dbab2f72ff802f7e63ed4b6b4 Mon Sep 17 00:00:00 2001 From: Alan Rynne Date: Wed, 29 May 2024 10:23:41 +0200 Subject: [PATCH 198/261] fix: Simplify our lives making DUI3 projects not packable for now --- DUI3-DX/Directory.Build.Props | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/DUI3-DX/Directory.Build.Props b/DUI3-DX/Directory.Build.Props index add00d3739..64c85531c3 100644 --- a/DUI3-DX/Directory.Build.Props +++ b/DUI3-DX/Directory.Build.Props @@ -1,14 +1,15 @@ - - - enable - enable - true - + + + enable + enable + true + false + - - - - - + + + + + \ No newline at end of file From 94178b63aaeed6aac3791d2a2e025d8f13269fd0 Mon Sep 17 00:00:00 2001 From: Alan Rynne Date: Wed, 29 May 2024 10:35:36 +0200 Subject: [PATCH 199/261] fix: Enable windows targeting on windows specific projects to fix nuget pack run --- .../Speckle.Connectors.ArcGIS3.csproj | 32 +++++++++++-------- .../Speckle.Connectors.DUI.WebView.csproj | 7 ++-- 2 files changed, 22 insertions(+), 17 deletions(-) diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Speckle.Connectors.ArcGIS3.csproj b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Speckle.Connectors.ArcGIS3.csproj index 9e9e4a9d1f..2f19e002e1 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Speckle.Connectors.ArcGIS3.csproj +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Speckle.Connectors.ArcGIS3.csproj @@ -7,24 +7,28 @@ win-x64 Speckle.Connectors.ArcGIS true + true - + - - - - - + + + + + - + - - + + - + - - - + + + - + \ No newline at end of file diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI.WebView/Speckle.Connectors.DUI.WebView.csproj b/DUI3-DX/DUI3/Speckle.Connectors.DUI.WebView/Speckle.Connectors.DUI.WebView.csproj index 689ceb67c4..ed1204c751 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI.WebView/Speckle.Connectors.DUI.WebView.csproj +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI.WebView/Speckle.Connectors.DUI.WebView.csproj @@ -1,8 +1,9 @@ - net4.8;net6.0-windows + net48;net6.0-windows true + true @@ -10,6 +11,6 @@ - + - + \ No newline at end of file From 0e55bfc1785f27bad3f78334ead0faf6b94274db Mon Sep 17 00:00:00 2001 From: Alan Rynne Date: Wed, 29 May 2024 10:51:29 +0200 Subject: [PATCH 200/261] fix: Enforce min dotnet 7 but allow major version rollforward --- global.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/global.json b/global.json index 18b689d104..08f229ce09 100644 --- a/global.json +++ b/global.json @@ -1,7 +1,7 @@ { "sdk": { - "version": "8.0.0", - "rollForward": "latestMinor", + "version": "7.0.0", + "rollForward": "latestMajor", "allowPrerelease": false } } From 875d4b49cb76ba7e20632e53e06731779a715128 Mon Sep 17 00:00:00 2001 From: Adam Hathcock Date: Wed, 29 May 2024 10:38:47 +0100 Subject: [PATCH 201/261] CNX-9308 CNX-9632 Moving to Github Actions for DUI3 (#3418) Co-authored-by: Alan Rynne --- .circleci/scripts/config-template.yml | 22 -- .circleci/scripts/parameters.json | 22 +- .config/dotnet-tools.json | 24 +- .github/dependabot.yml | 6 + .github/workflows/ci.yml | 41 ++ .github/workflows/main.yml | 32 ++ .gitignore | 2 + All.sln | 98 +++-- Build/Build.csproj | 13 + Build/Consts.cs | 45 +++ Build/Github.cs | 42 +++ Build/Program.cs | 180 +++++++++ .../Speckle.Core.Tests.Performance.csproj | 4 +- DUI3-DX.slnf | 1 + ...sri.ArcGISPro.Extensions30.Speckle.targets | 352 ++++++++++++++++++ .../Speckle.Connectors.ArcGIS3.csproj | 6 +- .../Speckle.Connectors.Autocad2023.csproj | 1 + ...eckle - Backup.Connectors.Revit2023.csproj | 60 --- .../Speckle.Connectors.Revit2023.csproj | 2 +- .../Speckle.Connectors.Rhino7.csproj | 2 + .../Speckle.Converters.ArcGIS3.csproj | 15 +- ...ers.Autocad2023.DependencyInjection.csproj | 2 +- .../Speckle.Converters.Autocad2023.csproj | 2 +- Directory.Build.props | 2 +- Directory.Build.targets | 8 - GitVersion.yml | 10 + Objects/Objects/Objects.csproj | 8 +- build.ps1 | 3 + build.sh | 4 + 29 files changed, 840 insertions(+), 169 deletions(-) create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/main.yml create mode 100644 Build/Build.csproj create mode 100644 Build/Consts.cs create mode 100644 Build/Github.cs create mode 100644 Build/Program.cs create mode 100644 DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Esri.ArcGISPro.Extensions30.Speckle.targets delete mode 100644 DUI3-DX/Connectors/Revit/Speckle.Connectors.Revit2023/Speckle - Backup.Connectors.Revit2023.csproj create mode 100644 GitVersion.yml create mode 100644 build.ps1 create mode 100755 build.sh diff --git a/.circleci/scripts/config-template.yml b/.circleci/scripts/config-template.yml index 061fa2ef5e..f3bd874b86 100644 --- a/.circleci/scripts/config-template.yml +++ b/.circleci/scripts/config-template.yml @@ -18,9 +18,6 @@ workflows: - build-sdk: requires: - get-ci-tools - build-dui3: - jobs: - - build-dui3-job nuget: jobs: - build-sdk: @@ -75,25 +72,6 @@ commands: --collect:"XPlat Code Coverage" -- DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.Format=opencover jobs: # Each project will have individual jobs for each specific task it has to execute (build, release...) - build-dui3-job: - executor: - name: win/default - shell: powershell.exe - steps: - - checkout - - run: - name: Enforce formatting - command: | - dotnet tool restore - dotnet csharpier --check . - - run: - name: Dotnet Restore - command: | - dotnet restore DUI3-DX.slnf - - run: - name: Build DUI3 Solution filter - command: | - msbuild DUI3-DX.slnf /p:Configuration=Release /p:IsDesktopBuild=false build-sdk: docker: - image: cimg/base:2021.01 diff --git a/.circleci/scripts/parameters.json b/.circleci/scripts/parameters.json index 3530ba7244..f5529641b7 100644 --- a/.circleci/scripts/parameters.json +++ b/.circleci/scripts/parameters.json @@ -1,12 +1,12 @@ { - "core": true, - "rhino": true, - "revit": true, - "dynamo": true, - "csi": true, - "autocadcivil": true, - "bentley": true, - "archicad": true, - "teklastructures": true, - "navisworks": true -} + "core": true, + "rhino": true, + "revit": true, + "dynamo": true, + "csi": true, + "autocadcivil": true, + "bentley": true, + "archicad": true, + "teklastructures": true, + "navisworks": true + } \ No newline at end of file diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index 3b0ca23774..47a1501435 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -4,27 +4,19 @@ "tools": { "dotnet-t4": { "version": "2.2.1", - "commands": [ - "t4" - ] - }, - "jetbrains.resharper.globaltools": { - "version": "2023.1.0", - "commands": [ - "jb" - ] + "commands": ["t4"] }, "csharpier": { "version": "0.23.0", - "commands": [ - "dotnet-csharpier" - ] + "commands": ["dotnet-csharpier"] }, "husky": { "version": "0.5.4", - "commands": [ - "husky" - ] + "commands": ["husky"] + }, + "gitversion.tool": { + "version": "5.12.0", + "commands": ["dotnet-gitversion"] } } -} \ No newline at end of file +} diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000000..3413224bf0 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,6 @@ +version: 2 +updates: + - package-ecosystem: "github-actions" # search for actions - there are other options available + directory: "/" # search in .github/workflows under root `/` + schedule: + interval: "weekly" # check for action update every week \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000000..d8ac5bfcdf --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,41 @@ +name: .NET Build + +on: + pull_request: # Run build on every pull request that is not to main/dev + branches-ignore: + - main + - dev + workflow_call: + outputs: + version: + value: ${{ jobs.build.outputs.version }} + +jobs: + build: + runs-on: windows-latest + outputs: + version: ${{ steps.set-version.outputs.version }} + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Setup .NET + uses: actions/setup-dotnet@v4 + with: + dotnet-version: 7.x.x + + - name: ⚒️ Run build + run: ./build.ps1 + + - name: ⬆️ Upload artifacts + uses: actions/upload-artifact@v4 + with: + name: output-${{ env.GitVersion_AssemblySemFileVer }} + path: output/*.* + compression-level: 0 # no compression + + - id: set-version + name: Set version to output + run: echo "version=${{env.GitVersion_FullSemVer}}" >> "$GITHUB_OUTPUT" diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000000..871f58e657 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,32 @@ +name: .NET Build and Publish + +on: + push: + branches: ["main", "dev", "dui3/alpha"] # Continuous delivery on every long-lived branch + tags: ["3.*"] # Manual delivery on every 3.x tag + pull_request: + branches: ["main", "dev"] # Releases on every PR that targets main or dev + +jobs: + build: + uses: ./.github/workflows/ci.yml + + deploy-installers: + runs-on: ubuntu-latest + needs: build + steps: + - name: 🔫 Trigger Build Installers + uses: ALEEF02/workflow-dispatch@v3.0.0 + with: + workflow: Build Installers + repo: specklesystems/connector-installers + token: ${{ secrets.CONNECTORS_GH_TOKEN }} + inputs: '{ "run_id": "${{ github.run_id }}", "version": "${{ needs.build.outputs.version }}" }' + ref: main + wait-for-completion: true + wait-for-completion-interval: 10s + wait-for-completion-timeout: 10m + display-workflow-run-url: true + display-workflow-run-url-interval: 10s + workflow-logs: true + run-name: "Deploying from: ${{ github.ref_name }}" diff --git a/.gitignore b/.gitignore index 1775cb1c7d..f7b3cd5d9a 100644 --- a/.gitignore +++ b/.gitignore @@ -382,3 +382,5 @@ ConnectorArchicad/AddOn/Build* **/yarn.lock + +output/ diff --git a/All.sln b/All.sln index 10b475678a..ab1b3af2c6 100644 --- a/All.sln +++ b/All.sln @@ -524,9 +524,20 @@ Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Speckle.Converters.AutocadS EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Speckle.Converters.Autocad2023", "DUI3-DX\Converters\Autocad\Speckle.Converters.Autocad2023\Speckle.Converters.Autocad2023.csproj", "{631C295A-7CCF-4B42-8686-7034E31469E7}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Speckle.Converters.Autocad2023.DependencyInjection", "DUI3-DX\Converters\Autocad\Speckle.Converters.Autocad2023.DependencyInjection\Speckle.Converters.Autocad2023.DependencyInjection.csproj", "{D940853C-003A-482C-BDB0-665367F274A0}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Speckle.Converters.Autocad2023.DependencyInjection", "DUI3-DX\Converters\Autocad\Speckle.Converters.Autocad2023.DependencyInjection\Speckle.Converters.Autocad2023.DependencyInjection.csproj", "{D940853C-003A-482C-BDB0-665367F274A0}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Speckle.Connectors.DUI.WebView", "DUI3-DX\DUI3\Speckle.Connectors.DUI.WebView\Speckle.Connectors.DUI.WebView.csproj", "{7420652C-3046-4F38-BE64-9B9E69D76FA2}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Speckle.Connectors.DUI.WebView", "DUI3-DX\DUI3\Speckle.Connectors.DUI.WebView\Speckle.Connectors.DUI.WebView.csproj", "{7420652C-3046-4F38-BE64-9B9E69D76FA2}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Build", "Build", "{326ECEE0-D009-4A65-B24C-00FA343D8B99}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Build", "Build\Build.csproj", "{3973D572-5E24-476F-B058-8022D826B793}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Workflows", "Workflows", "{2AB6B848-E8F6-4BB7-AE8F-9913C74C893F}" + ProjectSection(SolutionItems) = preProject + .github\workflows\ci.yml = .github\workflows\ci.yml + .github\workflows\main.yml = .github\workflows\main.yml + .github\workflows\test.yml = .github\workflows\test.yml + EndProjectSection EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RevitSharedResources2025", "ConnectorRevit\RevitSharedResources2025\RevitSharedResources2025.csproj", "{7B02BACC-D9B6-4FFE-A450-7ECB5F71F209}" EndProject @@ -2478,8 +2489,8 @@ Global {01F98733-7352-47AD-A594-537D979DE3DE}.Debug Mac|x64.Build.0 = Debug|Any CPU {01F98733-7352-47AD-A594-537D979DE3DE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {01F98733-7352-47AD-A594-537D979DE3DE}.Debug|Any CPU.Build.0 = Debug|Any CPU - {01F98733-7352-47AD-A594-537D979DE3DE}.Debug|x64.ActiveCfg = Debug|x64 - {01F98733-7352-47AD-A594-537D979DE3DE}.Debug|x64.Build.0 = Debug|x64 + {01F98733-7352-47AD-A594-537D979DE3DE}.Debug|x64.ActiveCfg = Debug|Any CPU + {01F98733-7352-47AD-A594-537D979DE3DE}.Debug|x64.Build.0 = Debug|Any CPU {01F98733-7352-47AD-A594-537D979DE3DE}.Release Mac|Any CPU.ActiveCfg = Release|Any CPU {01F98733-7352-47AD-A594-537D979DE3DE}.Release Mac|Any CPU.Build.0 = Release|Any CPU {01F98733-7352-47AD-A594-537D979DE3DE}.Release Mac|x64.ActiveCfg = Release|Any CPU @@ -2494,8 +2505,8 @@ Global {83EAD6F0-3CB3-456A-AD81-072127D0DE0E}.Debug Mac|x64.Build.0 = Debug|Any CPU {83EAD6F0-3CB3-456A-AD81-072127D0DE0E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {83EAD6F0-3CB3-456A-AD81-072127D0DE0E}.Debug|Any CPU.Build.0 = Debug|Any CPU - {83EAD6F0-3CB3-456A-AD81-072127D0DE0E}.Debug|x64.ActiveCfg = Debug|x64 - {83EAD6F0-3CB3-456A-AD81-072127D0DE0E}.Debug|x64.Build.0 = Debug|x64 + {83EAD6F0-3CB3-456A-AD81-072127D0DE0E}.Debug|x64.ActiveCfg = Debug|Any CPU + {83EAD6F0-3CB3-456A-AD81-072127D0DE0E}.Debug|x64.Build.0 = Debug|Any CPU {83EAD6F0-3CB3-456A-AD81-072127D0DE0E}.Release Mac|Any CPU.ActiveCfg = Release|Any CPU {83EAD6F0-3CB3-456A-AD81-072127D0DE0E}.Release Mac|Any CPU.Build.0 = Release|Any CPU {83EAD6F0-3CB3-456A-AD81-072127D0DE0E}.Release Mac|x64.ActiveCfg = Release|Any CPU @@ -2510,8 +2521,8 @@ Global {26391930-F86F-47E0-A5F6-B89919E38CE1}.Debug Mac|x64.Build.0 = Debug|Any CPU {26391930-F86F-47E0-A5F6-B89919E38CE1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {26391930-F86F-47E0-A5F6-B89919E38CE1}.Debug|Any CPU.Build.0 = Debug|Any CPU - {26391930-F86F-47E0-A5F6-B89919E38CE1}.Debug|x64.ActiveCfg = Debug|x64 - {26391930-F86F-47E0-A5F6-B89919E38CE1}.Debug|x64.Build.0 = Debug|x64 + {26391930-F86F-47E0-A5F6-B89919E38CE1}.Debug|x64.ActiveCfg = Debug|Any CPU + {26391930-F86F-47E0-A5F6-B89919E38CE1}.Debug|x64.Build.0 = Debug|Any CPU {26391930-F86F-47E0-A5F6-B89919E38CE1}.Release Mac|Any CPU.ActiveCfg = Release|Any CPU {26391930-F86F-47E0-A5F6-B89919E38CE1}.Release Mac|Any CPU.Build.0 = Release|Any CPU {26391930-F86F-47E0-A5F6-B89919E38CE1}.Release Mac|x64.ActiveCfg = Release|Any CPU @@ -2526,8 +2537,8 @@ Global {D81C0B87-F0C1-4297-A147-02F001FB7E1E}.Debug Mac|x64.Build.0 = Debug|Any CPU {D81C0B87-F0C1-4297-A147-02F001FB7E1E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {D81C0B87-F0C1-4297-A147-02F001FB7E1E}.Debug|Any CPU.Build.0 = Debug|Any CPU - {D81C0B87-F0C1-4297-A147-02F001FB7E1E}.Debug|x64.ActiveCfg = Debug|x64 - {D81C0B87-F0C1-4297-A147-02F001FB7E1E}.Debug|x64.Build.0 = Debug|x64 + {D81C0B87-F0C1-4297-A147-02F001FB7E1E}.Debug|x64.ActiveCfg = Debug|Any CPU + {D81C0B87-F0C1-4297-A147-02F001FB7E1E}.Debug|x64.Build.0 = Debug|Any CPU {D81C0B87-F0C1-4297-A147-02F001FB7E1E}.Release Mac|Any CPU.ActiveCfg = Release|Any CPU {D81C0B87-F0C1-4297-A147-02F001FB7E1E}.Release Mac|Any CPU.Build.0 = Release|Any CPU {D81C0B87-F0C1-4297-A147-02F001FB7E1E}.Release Mac|x64.ActiveCfg = Release|Any CPU @@ -2542,8 +2553,8 @@ Global {C9D4CA21-182B-4ED2-81BB-280A6FD713F6}.Debug Mac|x64.Build.0 = Debug|Any CPU {C9D4CA21-182B-4ED2-81BB-280A6FD713F6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {C9D4CA21-182B-4ED2-81BB-280A6FD713F6}.Debug|Any CPU.Build.0 = Debug|Any CPU - {C9D4CA21-182B-4ED2-81BB-280A6FD713F6}.Debug|x64.ActiveCfg = Debug|x64 - {C9D4CA21-182B-4ED2-81BB-280A6FD713F6}.Debug|x64.Build.0 = Debug|x64 + {C9D4CA21-182B-4ED2-81BB-280A6FD713F6}.Debug|x64.ActiveCfg = Debug|Any CPU + {C9D4CA21-182B-4ED2-81BB-280A6FD713F6}.Debug|x64.Build.0 = Debug|Any CPU {C9D4CA21-182B-4ED2-81BB-280A6FD713F6}.Release Mac|Any CPU.ActiveCfg = Release|Any CPU {C9D4CA21-182B-4ED2-81BB-280A6FD713F6}.Release Mac|Any CPU.Build.0 = Release|Any CPU {C9D4CA21-182B-4ED2-81BB-280A6FD713F6}.Release Mac|x64.ActiveCfg = Release|Any CPU @@ -2558,8 +2569,8 @@ Global {7291B93C-615D-42DE-B8C1-3F9DF643E0FC}.Debug Mac|x64.Build.0 = Debug|Any CPU {7291B93C-615D-42DE-B8C1-3F9DF643E0FC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {7291B93C-615D-42DE-B8C1-3F9DF643E0FC}.Debug|Any CPU.Build.0 = Debug|Any CPU - {7291B93C-615D-42DE-B8C1-3F9DF643E0FC}.Debug|x64.ActiveCfg = Debug|x64 - {7291B93C-615D-42DE-B8C1-3F9DF643E0FC}.Debug|x64.Build.0 = Debug|x64 + {7291B93C-615D-42DE-B8C1-3F9DF643E0FC}.Debug|x64.ActiveCfg = Debug|Any CPU + {7291B93C-615D-42DE-B8C1-3F9DF643E0FC}.Debug|x64.Build.0 = Debug|Any CPU {7291B93C-615D-42DE-B8C1-3F9DF643E0FC}.Release Mac|Any CPU.ActiveCfg = Release|Any CPU {7291B93C-615D-42DE-B8C1-3F9DF643E0FC}.Release Mac|Any CPU.Build.0 = Release|Any CPU {7291B93C-615D-42DE-B8C1-3F9DF643E0FC}.Release Mac|x64.ActiveCfg = Release|Any CPU @@ -2574,8 +2585,8 @@ Global {8AEF06C0-CA5C-4460-BC2D-ADE5F35D0434}.Debug Mac|x64.Build.0 = Debug|Any CPU {8AEF06C0-CA5C-4460-BC2D-ADE5F35D0434}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {8AEF06C0-CA5C-4460-BC2D-ADE5F35D0434}.Debug|Any CPU.Build.0 = Debug|Any CPU - {8AEF06C0-CA5C-4460-BC2D-ADE5F35D0434}.Debug|x64.ActiveCfg = Debug|x64 - {8AEF06C0-CA5C-4460-BC2D-ADE5F35D0434}.Debug|x64.Build.0 = Debug|x64 + {8AEF06C0-CA5C-4460-BC2D-ADE5F35D0434}.Debug|x64.ActiveCfg = Debug|Any CPU + {8AEF06C0-CA5C-4460-BC2D-ADE5F35D0434}.Debug|x64.Build.0 = Debug|Any CPU {8AEF06C0-CA5C-4460-BC2D-ADE5F35D0434}.Release Mac|Any CPU.ActiveCfg = Release|Any CPU {8AEF06C0-CA5C-4460-BC2D-ADE5F35D0434}.Release Mac|Any CPU.Build.0 = Release|Any CPU {8AEF06C0-CA5C-4460-BC2D-ADE5F35D0434}.Release Mac|x64.ActiveCfg = Release|Any CPU @@ -2632,22 +2643,6 @@ Global {9C1ECA1D-DE98-4FB7-92D0-FC45BB308E5D}.Release|Any CPU.Build.0 = Release|Any CPU {9C1ECA1D-DE98-4FB7-92D0-FC45BB308E5D}.Release|x64.ActiveCfg = Release|Any CPU {9C1ECA1D-DE98-4FB7-92D0-FC45BB308E5D}.Release|x64.Build.0 = Release|Any CPU - {89C4CBC7-1606-40DE-B6DA-FBE3AAC98395}.Debug Mac|Any CPU.ActiveCfg = Debug|Any CPU - {89C4CBC7-1606-40DE-B6DA-FBE3AAC98395}.Debug Mac|Any CPU.Build.0 = Debug|Any CPU - {89C4CBC7-1606-40DE-B6DA-FBE3AAC98395}.Debug Mac|x64.ActiveCfg = Debug|Any CPU - {89C4CBC7-1606-40DE-B6DA-FBE3AAC98395}.Debug Mac|x64.Build.0 = Debug|Any CPU - {89C4CBC7-1606-40DE-B6DA-FBE3AAC98395}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {89C4CBC7-1606-40DE-B6DA-FBE3AAC98395}.Debug|Any CPU.Build.0 = Debug|Any CPU - {89C4CBC7-1606-40DE-B6DA-FBE3AAC98395}.Debug|x64.ActiveCfg = Debug|Any CPU - {89C4CBC7-1606-40DE-B6DA-FBE3AAC98395}.Debug|x64.Build.0 = Debug|Any CPU - {89C4CBC7-1606-40DE-B6DA-FBE3AAC98395}.Release Mac|Any CPU.ActiveCfg = Debug|Any CPU - {89C4CBC7-1606-40DE-B6DA-FBE3AAC98395}.Release Mac|Any CPU.Build.0 = Debug|Any CPU - {89C4CBC7-1606-40DE-B6DA-FBE3AAC98395}.Release Mac|x64.ActiveCfg = Debug|Any CPU - {89C4CBC7-1606-40DE-B6DA-FBE3AAC98395}.Release Mac|x64.Build.0 = Debug|Any CPU - {89C4CBC7-1606-40DE-B6DA-FBE3AAC98395}.Release|Any CPU.ActiveCfg = Release|Any CPU - {89C4CBC7-1606-40DE-B6DA-FBE3AAC98395}.Release|Any CPU.Build.0 = Release|Any CPU - {89C4CBC7-1606-40DE-B6DA-FBE3AAC98395}.Release|x64.ActiveCfg = Release|Any CPU - {89C4CBC7-1606-40DE-B6DA-FBE3AAC98395}.Release|x64.Build.0 = Release|Any CPU {A97F7177-86C7-4B38-A6ED-DA51BF762471}.Debug Mac|Any CPU.ActiveCfg = Debug|Any CPU {A97F7177-86C7-4B38-A6ED-DA51BF762471}.Debug Mac|Any CPU.Build.0 = Debug|Any CPU {A97F7177-86C7-4B38-A6ED-DA51BF762471}.Debug Mac|x64.ActiveCfg = Debug|Any CPU @@ -2696,6 +2691,22 @@ Global {7DFF1591-237D-499E-A767-EE37B93FB958}.Release|Any CPU.Build.0 = Release|Any CPU {7DFF1591-237D-499E-A767-EE37B93FB958}.Release|x64.ActiveCfg = Release|Any CPU {7DFF1591-237D-499E-A767-EE37B93FB958}.Release|x64.Build.0 = Release|Any CPU + {89C4CBC7-1606-40DE-B6DA-FBE3AAC98395}.Debug Mac|Any CPU.ActiveCfg = Debug|Any CPU + {89C4CBC7-1606-40DE-B6DA-FBE3AAC98395}.Debug Mac|Any CPU.Build.0 = Debug|Any CPU + {89C4CBC7-1606-40DE-B6DA-FBE3AAC98395}.Debug Mac|x64.ActiveCfg = Debug|Any CPU + {89C4CBC7-1606-40DE-B6DA-FBE3AAC98395}.Debug Mac|x64.Build.0 = Debug|Any CPU + {89C4CBC7-1606-40DE-B6DA-FBE3AAC98395}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {89C4CBC7-1606-40DE-B6DA-FBE3AAC98395}.Debug|Any CPU.Build.0 = Debug|Any CPU + {89C4CBC7-1606-40DE-B6DA-FBE3AAC98395}.Debug|x64.ActiveCfg = Debug|Any CPU + {89C4CBC7-1606-40DE-B6DA-FBE3AAC98395}.Debug|x64.Build.0 = Debug|Any CPU + {89C4CBC7-1606-40DE-B6DA-FBE3AAC98395}.Release Mac|Any CPU.ActiveCfg = Debug|Any CPU + {89C4CBC7-1606-40DE-B6DA-FBE3AAC98395}.Release Mac|Any CPU.Build.0 = Debug|Any CPU + {89C4CBC7-1606-40DE-B6DA-FBE3AAC98395}.Release Mac|x64.ActiveCfg = Debug|Any CPU + {89C4CBC7-1606-40DE-B6DA-FBE3AAC98395}.Release Mac|x64.Build.0 = Debug|Any CPU + {89C4CBC7-1606-40DE-B6DA-FBE3AAC98395}.Release|Any CPU.ActiveCfg = Release|Any CPU + {89C4CBC7-1606-40DE-B6DA-FBE3AAC98395}.Release|Any CPU.Build.0 = Release|Any CPU + {89C4CBC7-1606-40DE-B6DA-FBE3AAC98395}.Release|x64.ActiveCfg = Release|Any CPU + {89C4CBC7-1606-40DE-B6DA-FBE3AAC98395}.Release|x64.Build.0 = Release|Any CPU {11F7D41B-AFCA-4D29-BC08-285A14BF3A3B}.Debug Mac|Any CPU.ActiveCfg = Debug|Any CPU {11F7D41B-AFCA-4D29-BC08-285A14BF3A3B}.Debug Mac|Any CPU.Build.0 = Debug|Any CPU {11F7D41B-AFCA-4D29-BC08-285A14BF3A3B}.Debug Mac|x64.ActiveCfg = Debug|Any CPU @@ -2760,6 +2771,22 @@ Global {7420652C-3046-4F38-BE64-9B9E69D76FA2}.Release|Any CPU.Build.0 = Release|Any CPU {7420652C-3046-4F38-BE64-9B9E69D76FA2}.Release|x64.ActiveCfg = Release|Any CPU {7420652C-3046-4F38-BE64-9B9E69D76FA2}.Release|x64.Build.0 = Release|Any CPU + {3973D572-5E24-476F-B058-8022D826B793}.Debug Mac|Any CPU.ActiveCfg = Debug|Any CPU + {3973D572-5E24-476F-B058-8022D826B793}.Debug Mac|Any CPU.Build.0 = Debug|Any CPU + {3973D572-5E24-476F-B058-8022D826B793}.Debug Mac|x64.ActiveCfg = Debug|Any CPU + {3973D572-5E24-476F-B058-8022D826B793}.Debug Mac|x64.Build.0 = Debug|Any CPU + {3973D572-5E24-476F-B058-8022D826B793}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3973D572-5E24-476F-B058-8022D826B793}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3973D572-5E24-476F-B058-8022D826B793}.Debug|x64.ActiveCfg = Debug|Any CPU + {3973D572-5E24-476F-B058-8022D826B793}.Debug|x64.Build.0 = Debug|Any CPU + {3973D572-5E24-476F-B058-8022D826B793}.Release Mac|Any CPU.ActiveCfg = Debug|Any CPU + {3973D572-5E24-476F-B058-8022D826B793}.Release Mac|Any CPU.Build.0 = Debug|Any CPU + {3973D572-5E24-476F-B058-8022D826B793}.Release Mac|x64.ActiveCfg = Debug|Any CPU + {3973D572-5E24-476F-B058-8022D826B793}.Release Mac|x64.Build.0 = Debug|Any CPU + {3973D572-5E24-476F-B058-8022D826B793}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3973D572-5E24-476F-B058-8022D826B793}.Release|Any CPU.Build.0 = Release|Any CPU + {3973D572-5E24-476F-B058-8022D826B793}.Release|x64.ActiveCfg = Release|Any CPU + {3973D572-5E24-476F-B058-8022D826B793}.Release|x64.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -2956,20 +2983,21 @@ Global {34C2C062-E43F-4FB5-B839-64BC044CCEF3} = {1FE3C60E-7865-40A5-9794-55ECB64F6489} {65A2F556-F14A-49F3-8A92-7F2E1E7ED3B5} = {34C2C062-E43F-4FB5-B839-64BC044CCEF3} {9C1ECA1D-DE98-4FB7-92D0-FC45BB308E5D} = {34C2C062-E43F-4FB5-B839-64BC044CCEF3} - {743489BF-1941-43D5-8AF9-35C56D0DCC34} = {33D19E88-F3AE-4D28-B588-D91CCF9E3BA8} - {89C4CBC7-1606-40DE-B6DA-FBE3AAC98395} = {743489BF-1941-43D5-8AF9-35C56D0DCC34} - {41BC679F-887F-44CF-971D-A5502EE87DB0} = {743489BF-1941-43D5-8AF9-35C56D0DCC34} {A97F7177-86C7-4B38-A6ED-DA51BF762471} = {CE4B899D-9C0A-4B5D-B91A-CE62D2327695} {CE4B899D-9C0A-4B5D-B91A-CE62D2327695} = {33D19E88-F3AE-4D28-B588-D91CCF9E3BA8} {139F7A79-69E4-4B8A-B2A5-6A30A66C495C} = {CCF48B65-33D1-4E8B-A57B-E03394730B21} {7DFF1591-237D-499E-A767-EE37B93FB958} = {CCF48B65-33D1-4E8B-A57B-E03394730B21} {CCF48B65-33D1-4E8B-A57B-E03394730B21} = {1FE3C60E-7865-40A5-9794-55ECB64F6489} + {743489BF-1941-43D5-8AF9-35C56D0DCC34} = {33D19E88-F3AE-4D28-B588-D91CCF9E3BA8} + {89C4CBC7-1606-40DE-B6DA-FBE3AAC98395} = {743489BF-1941-43D5-8AF9-35C56D0DCC34} + {41BC679F-887F-44CF-971D-A5502EE87DB0} = {743489BF-1941-43D5-8AF9-35C56D0DCC34} {11F7D41B-AFCA-4D29-BC08-285A14BF3A3B} = {2E00592E-558D-492D-88F9-3ECEE4C0C7DA} {804E065F-914C-414A-AF84-009312C3CFF6} = {1FE3C60E-7865-40A5-9794-55ECB64F6489} {9ADD1B7A-6401-4202-8613-F668E2FBC0A4} = {804E065F-914C-414A-AF84-009312C3CFF6} {631C295A-7CCF-4B42-8686-7034E31469E7} = {804E065F-914C-414A-AF84-009312C3CFF6} {D940853C-003A-482C-BDB0-665367F274A0} = {804E065F-914C-414A-AF84-009312C3CFF6} {7420652C-3046-4F38-BE64-9B9E69D76FA2} = {FD4D6594-D81E-456F-8F2E-35B09E04A755} + {3973D572-5E24-476F-B058-8022D826B793} = {326ECEE0-D009-4A65-B24C-00FA343D8B99} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {1D43D91B-4F01-4A78-8250-CC6F9BD93A14} diff --git a/Build/Build.csproj b/Build/Build.csproj new file mode 100644 index 0000000000..74408729a7 --- /dev/null +++ b/Build/Build.csproj @@ -0,0 +1,13 @@ + + + + Exe + net7.0 + enable + + + + + + + diff --git a/Build/Consts.cs b/Build/Consts.cs new file mode 100644 index 0000000000..d8921e234f --- /dev/null +++ b/Build/Consts.cs @@ -0,0 +1,45 @@ +using System.Collections.Generic; + +namespace Build; + +public static class Consts +{ + public static readonly string[] Solutions = { "DUI3-DX.slnf" }; + + public static InstallerProject[] InstallerManifests = + { + new( + "arcgis", + new InstallerAsset[] { new("DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3", "net6.0-windows") } + ), + new("rhino", new InstallerAsset[] { new("DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7", "net48") }), + new("revit", new InstallerAsset[] { new("DUI3-DX/Connectors/Revit/Speckle.Connectors.Revit2023", "net48") }), + new("autocad", new InstallerAsset[] { new("DUI3-DX/Connectors/Autocad/Speckle.Connectors.Autocad2023", "net48") }) + }; +} + +public readonly struct InstallerProject +{ + public string HostAppSlug { get; init; } + public IReadOnlyList Projects { get; init; } + + public InstallerProject(string hostAppSlug, IReadOnlyList projects) + { + HostAppSlug = hostAppSlug; + Projects = projects; + } + + public override string ToString() => $"{HostAppSlug}"; +} + +public readonly struct InstallerAsset +{ + public InstallerAsset(string projectPath, string targetName) + { + ProjectPath = projectPath; + TargetName = targetName; + } + + public string ProjectPath { get; init; } + public string TargetName { get; init; } +} diff --git a/Build/Github.cs b/Build/Github.cs new file mode 100644 index 0000000000..5d3267937e --- /dev/null +++ b/Build/Github.cs @@ -0,0 +1,42 @@ +using System; +using System.Net.Http; +using System.Net.Http.Headers; +using System.Net.Mime; +using System.Text.Json; +using System.Threading.Tasks; + +namespace Build; + +public static class Github +{ + public static async Task BuildInstallers(string token, string runId, string version) + { + using var client = new HttpClient(); + var payload = new { event_type = "build-installers", client_payload = new { run_id = runId, version } }; + var content = new StringContent( + JsonSerializer.Serialize(payload), + new MediaTypeHeaderValue(MediaTypeNames.Application.Json) + ); + + var request = new HttpRequestMessage() + { + Method = HttpMethod.Post, + RequestUri = new Uri("https://api.github.com/repos/specklesystems/connector-installers/dispatches"), + Headers = + { + Accept = { new MediaTypeWithQualityHeaderValue("application/vnd.github+json") }, + Authorization = new AuthenticationHeaderValue("Bearer", token), + UserAgent = { new ProductInfoHeaderValue("Speckle.build", "3.0.0") } + }, + Content = content + }; + request.Headers.Add("X-GitHub-Api-Version", "2022-11-28"); + var response = await client.SendAsync(request).ConfigureAwait(false); + if (!response.IsSuccessStatusCode) + { + throw new InvalidOperationException( + $"{response.StatusCode} {response.ReasonPhrase} {await response.Content.ReadAsStringAsync().ConfigureAwait(false)}" + ); + } + } +} diff --git a/Build/Program.cs b/Build/Program.cs new file mode 100644 index 0000000000..10bc82322c --- /dev/null +++ b/Build/Program.cs @@ -0,0 +1,180 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.IO.Compression; +using System.Linq; +using Build; +using GlobExpressions; +using static Bullseye.Targets; +using static SimpleExec.Command; + +const string CLEAN = "clean"; +const string RESTORE = "restore"; +const string BUILD = "build"; +const string TEST = "test"; +const string FORMAT = "format"; +const string ZIP = "zip"; +const string VERSION = "version"; +const string RESTORE_TOOLS = "restore-tools"; +const string BUILD_SERVER_VERSION = "build-server-version"; + +var arguments = new List(); +if (args.Length > 1) +{ + arguments = args.ToList(); + args = new[] { arguments.First() }; + arguments = arguments.Skip(1).ToList(); +} + +Target( + CLEAN, + ForEach("**/output"), + dir => + { + IEnumerable GetDirectories(string d) + { + return Glob.Directories(".", d); + } + + void RemoveDirectory(string d) + { + if (Directory.Exists(d)) + { + Console.WriteLine(d); + Directory.Delete(d, true); + } + } + + foreach (var d in GetDirectories(dir)) + { + RemoveDirectory(d); + } + } +); + +Target( + VERSION, + async () => + { + var (output, _) = await ReadAsync("dotnet", "minver -v w").ConfigureAwait(false); + output = output.Trim(); + Console.WriteLine($"Version: {output}"); + Run("echo", $"\"version={output}\" >> $GITHUB_OUTPUT"); + } +); + +Target( + RESTORE_TOOLS, + () => + { + Run("dotnet", "tool restore"); + } +); + +Target( + FORMAT, + DependsOn(RESTORE_TOOLS), + () => + { + Run("dotnet", "csharpier --check ."); + } +); + +Target( + RESTORE, + Consts.Solutions, + s => + { + Run("dotnet", $"restore {s}"); + } +); + +Target( + BUILD_SERVER_VERSION, + DependsOn(RESTORE_TOOLS), + () => + { + Run("dotnet", "tool run dotnet-gitversion /output json /output buildserver"); + } +); + +Target( + BUILD, + DependsOn(RESTORE, BUILD_SERVER_VERSION), + Consts.Solutions, + s => + { + var version = Environment.GetEnvironmentVariable("GitVersion_FullSemVer") ?? "3.0.0-localBuild"; + var fileVersion = Environment.GetEnvironmentVariable("GitVersion_AssemblySemFileVer") ?? "3.0.0.0"; + Console.WriteLine($"Version: {version} & {fileVersion}"); + Run( + "dotnet", + $"build {s} -c Release --no-restore -p:IsDesktopBuild=false -p:Version={version} -p:FileVersion={fileVersion} -v:m" + ); + } +); + +Target( + TEST, + DependsOn(BUILD), + () => + { + IEnumerable GetFiles(string d) + { + return Glob.Files(".", d); + } + + foreach (var file in GetFiles("**/*.Test.csproj")) + { + Run("dotnet", $"test {file} -c Release --no-restore --verbosity=normal"); + } + } +); + +Target( + ZIP, + DependsOn(TEST), + Consts.InstallerManifests, + x => + { + var outputDir = Path.Combine(".", "output"); + var slugDir = Path.Combine(outputDir, x.HostAppSlug); + + Directory.CreateDirectory(outputDir); + Directory.CreateDirectory(slugDir); + + foreach (var asset in x.Projects) + { + var fullPath = Path.Combine(".", asset.ProjectPath, "bin", "Release", asset.TargetName); + if (!Directory.Exists(fullPath)) + { + throw new InvalidOperationException("Could not find: " + fullPath); + } + + var assetName = Path.GetFileName(asset.ProjectPath); + var connectorDir = Path.Combine(slugDir, assetName); + + Directory.CreateDirectory(connectorDir); + foreach (var directory in Directory.EnumerateDirectories(fullPath, "*", SearchOption.AllDirectories)) + { + Directory.CreateDirectory(directory.Replace(fullPath, connectorDir)); + } + + foreach (var file in Directory.EnumerateFiles(fullPath, "*", SearchOption.AllDirectories)) + { + Console.WriteLine(file); + File.Copy(file, file.Replace(fullPath, connectorDir), true); + } + } + + var outputPath = Path.Combine(outputDir, $"{x.HostAppSlug}.zip"); + File.Delete(outputPath); + Console.WriteLine($"Zipping: '{slugDir}' to '{outputPath}'"); + ZipFile.CreateFromDirectory(slugDir, outputPath); + // Directory.Delete(slugDir, true); + } +); + +Target("default", DependsOn(FORMAT, ZIP), () => Console.WriteLine("Done!")); + +await RunTargetsAndExitAsync(args).ConfigureAwait(true); diff --git a/Core/Tests/Speckle.Core.Tests.Performance/Speckle.Core.Tests.Performance.csproj b/Core/Tests/Speckle.Core.Tests.Performance/Speckle.Core.Tests.Performance.csproj index 8b53d9d4a8..625d087f71 100644 --- a/Core/Tests/Speckle.Core.Tests.Performance/Speckle.Core.Tests.Performance.csproj +++ b/Core/Tests/Speckle.Core.Tests.Performance/Speckle.Core.Tests.Performance.csproj @@ -1,7 +1,7 @@ - net481 + net48 enable disable exe @@ -13,7 +13,7 @@ - + diff --git a/DUI3-DX.slnf b/DUI3-DX.slnf index c8a3bf311c..bd01603c29 100644 --- a/DUI3-DX.slnf +++ b/DUI3-DX.slnf @@ -2,6 +2,7 @@ "solution": { "path": "All.sln", "projects": [ + "Build\\Build.csproj", "Core\\Core\\Core.csproj", "Core\\Tests\\Speckle.Core.Tests.Integration\\Speckle.Core.Tests.Integration.csproj", "Core\\Tests\\Speckle.Core.Tests.Performance\\Speckle.Core.Tests.Performance.csproj", diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Esri.ArcGISPro.Extensions30.Speckle.targets b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Esri.ArcGISPro.Extensions30.Speckle.targets new file mode 100644 index 0000000000..a25abf1d91 --- /dev/null +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Esri.ArcGISPro.Extensions30.Speckle.targets @@ -0,0 +1,352 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + (); + System.Uri relativeTo = new Uri(this.RelativeTo); + foreach (var i in Paths) { + try { + System.Uri itemFullPath = new Uri(i.GetMetadata("FullPath")); + var relativeUri = relativeTo.MakeRelativeUri(itemFullPath); + + result.Add(new TaskItem(Uri.UnescapeDataString(relativeUri.ToString()))); + } + catch { + return false; + } + } + RelativePaths = result.ToArray(); + foreach (var i in RelativePaths) + { + Log.LogMessage(MessageImportance.Low, "RelativePaths: " + i.ToString()); + } + return true; + ]]> + + + + + + + + + + + + + + + + + + + + + + + + + Addin + + + $([MSBuild]::GetRegistryValueFromView('HKEY_LOCAL_MACHINE\SOFTWARE\ESRI\ArcGISPro', 'InstallDir', null, RegistryView.Registry64)) + $(registry:HKEY_CURRENT_USER\SOFTWARE\ESRI\ArcGISPro@InstallDir) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Speckle.Connectors.ArcGIS3.csproj b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Speckle.Connectors.ArcGIS3.csproj index 2f19e002e1..0dc50a19aa 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Speckle.Connectors.ArcGIS3.csproj +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Speckle.Connectors.ArcGIS3.csproj @@ -7,6 +7,7 @@ win-x64 Speckle.Connectors.ArcGIS true + false true @@ -19,7 +20,8 @@ - + @@ -31,4 +33,6 @@ + + \ No newline at end of file diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.Autocad2023/Speckle.Connectors.Autocad2023.csproj b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.Autocad2023/Speckle.Connectors.Autocad2023.csproj index 40658970e5..4ef5a65342 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.Autocad2023/Speckle.Connectors.Autocad2023.csproj +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.Autocad2023/Speckle.Connectors.Autocad2023.csproj @@ -7,6 +7,7 @@ Program $(ProgramW6432)\Autodesk\AutoCAD 2023\acad.exe + diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.Revit2023/Speckle - Backup.Connectors.Revit2023.csproj b/DUI3-DX/Connectors/Revit/Speckle.Connectors.Revit2023/Speckle - Backup.Connectors.Revit2023.csproj deleted file mode 100644 index 994dbd662d..0000000000 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.Revit2023/Speckle - Backup.Connectors.Revit2023.csproj +++ /dev/null @@ -1,60 +0,0 @@ - - - net48 - x64 - win-x64 - true - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.Revit2023/Speckle.Connectors.Revit2023.csproj b/DUI3-DX/Connectors/Revit/Speckle.Connectors.Revit2023/Speckle.Connectors.Revit2023.csproj index 9927081c9c..a24cfec381 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.Revit2023/Speckle.Connectors.Revit2023.csproj +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.Revit2023/Speckle.Connectors.Revit2023.csproj @@ -1,4 +1,4 @@ - + net48 x64 diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Speckle.Connectors.Rhino7.csproj b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Speckle.Connectors.Rhino7.csproj index eddc6f5826..cf48f27e61 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Speckle.Connectors.Rhino7.csproj +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Speckle.Connectors.Rhino7.csproj @@ -4,6 +4,7 @@ .rhp true true + true @@ -14,6 +15,7 @@ + diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Speckle.Converters.ArcGIS3.csproj b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Speckle.Converters.ArcGIS3.csproj index 596f00af45..3b07dc8f64 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Speckle.Converters.ArcGIS3.csproj +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Speckle.Converters.ArcGIS3.csproj @@ -3,14 +3,17 @@ net6.0-windows x64 + true - + - - - - - + + + + + \ No newline at end of file diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2023.DependencyInjection/Speckle.Converters.Autocad2023.DependencyInjection.csproj b/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2023.DependencyInjection/Speckle.Converters.Autocad2023.DependencyInjection.csproj index 04d9915261..c115e62f88 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2023.DependencyInjection/Speckle.Converters.Autocad2023.DependencyInjection.csproj +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2023.DependencyInjection/Speckle.Converters.Autocad2023.DependencyInjection.csproj @@ -1,7 +1,7 @@ - net47 + net48 x64 diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2023/Speckle.Converters.Autocad2023.csproj b/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2023/Speckle.Converters.Autocad2023.csproj index 895443e448..60d55503f4 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2023/Speckle.Converters.Autocad2023.csproj +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2023/Speckle.Converters.Autocad2023.csproj @@ -1,7 +1,7 @@  - net47 + net48 x64 diff --git a/Directory.Build.props b/Directory.Build.props index 1e72e65133..cc6e4ea861 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -127,7 +127,7 @@ $(MSBuildThisFileDirectory) - + diff --git a/Directory.Build.targets b/Directory.Build.targets index bfe533e029..74264cc54f 100644 --- a/Directory.Build.targets +++ b/Directory.Build.targets @@ -41,14 +41,6 @@ Command="cp '$(TargetDir)$(AssemblyName).dll' $HOME'/.config/Speckle/Kits/$(KitFolder)/'"/> - - - - + - - + + - + \ No newline at end of file diff --git a/Objects/Objects/Objects.csproj b/Objects/Objects/Objects.csproj index 4f5b21d880..c0bd0b62b5 100644 --- a/Objects/Objects/Objects.csproj +++ b/Objects/Objects/Objects.csproj @@ -15,15 +15,15 @@ true - - $(WarningsNotAsErrors); + + $(NoWarn); CA1008; CA1024; CA1034; CA1065; CA1708; CA1711; CA1716; CA1724; CA1725; CA1819; CS8618; CA2201; CA2225; CS0659; CS0661; CS0728; IDE0041; IDE0060; IDE1006; - + @@ -33,4 +33,4 @@ - + \ No newline at end of file From 9aa8249ebf95345979bd32fe44472567125efd65 Mon Sep 17 00:00:00 2001 From: KatKatKateryna <89912278+KatKatKateryna@users.noreply.github.com> Date: Thu, 30 May 2024 16:55:31 +0800 Subject: [PATCH 208/261] CNX-9445 arc gis precision check for acrs circles curves ellipse (#3428) * clean segment converters * send densified curved segments using Map CRS precision * receive circles without segmentation * convert precision points to meters; use factoryCode for unit conversion to Speckle; add USfeet unit * remove unused conversions * fix * remove line segment converter * merge conflicts --- .../Bindings/ArcGISSendBinding.cs | 2 +- .../ArcGISToSpeckleUnitConverter.cs | 31 ++++----- .../PolylineFeatureToSpeckleConverter.cs | 29 +++++++- .../BezierSegmentToSpeckleConverter.cs | 58 ---------------- .../EllipticArcSegmentToSpeckleConverter.cs | 67 ------------------- .../CircleToHostConverter.cs | 45 ++++++------- .../SegmentCollectionToSpeckleConverter.cs | 44 ++++++------ 7 files changed, 87 insertions(+), 189 deletions(-) delete mode 100644 DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/BezierSegmentToSpeckleConverter.cs delete mode 100644 DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/EllipticArcSegmentToSpeckleConverter.cs diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISSendBinding.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISSendBinding.cs index c5db590209..8e9fba23bd 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISSendBinding.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISSendBinding.cs @@ -261,7 +261,7 @@ public List GetSendSettings() public async Task Send(string modelCardId) { //poc: dupe code between connectors - using IUnitOfWork> unitOfWork = _unitOfWorkFactory.Resolve>(); + using var unitOfWork = _unitOfWorkFactory.Resolve>(); try { if (_store.GetModelById(modelCardId) is not SenderModelCard modelCard) diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ArcGISToSpeckleUnitConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ArcGISToSpeckleUnitConverter.cs index a40e3d15d7..d36f1f32a6 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ArcGISToSpeckleUnitConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ArcGISToSpeckleUnitConverter.cs @@ -7,31 +7,28 @@ namespace Speckle.Converters.ArcGIS3; public class ArcGISToSpeckleUnitConverter : IHostToSpeckleUnitConverter { - private static readonly IReadOnlyDictionary s_unitMapping = Create(); + private readonly Dictionary _unitMapping = new(); - private static IReadOnlyDictionary Create() + private ArcGISToSpeckleUnitConverter() { - var dict = new Dictionary(); // POC: we should have a unit test to confirm these are as expected and don't change - //_unitMapping[LinearUnit.] = Units.Meters; - dict[LinearUnit.Millimeters.Name] = Units.Millimeters; - dict[LinearUnit.Centimeters.Name] = Units.Centimeters; - dict[LinearUnit.Meters.Name] = Units.Meters; - dict[LinearUnit.Kilometers.Name] = Units.Kilometers; - dict[LinearUnit.Inches.Name] = Units.Inches; - dict[LinearUnit.Feet.Name] = Units.Feet; - dict[LinearUnit.Yards.Name] = Units.Yards; - dict[LinearUnit.Miles.Name] = Units.Miles; - //_unitMapping[LinearUnit.Decimeters] = Units.; - //_unitMapping[LinearUnit.NauticalMiles] = Units.; - return dict; + // more units: https://pro.arcgis.com/en/pro-app/latest/sdk/api-reference/topic8349.html + _unitMapping[LinearUnit.Millimeters.FactoryCode] = Units.Millimeters; + _unitMapping[LinearUnit.Centimeters.FactoryCode] = Units.Centimeters; + _unitMapping[LinearUnit.Meters.FactoryCode] = Units.Meters; + _unitMapping[LinearUnit.Kilometers.FactoryCode] = Units.Kilometers; + _unitMapping[LinearUnit.Inches.FactoryCode] = Units.Inches; + _unitMapping[LinearUnit.Feet.FactoryCode] = Units.Feet; + _unitMapping[LinearUnit.Yards.FactoryCode] = Units.Yards; + _unitMapping[LinearUnit.Miles.FactoryCode] = Units.Miles; + _unitMapping[9003] = Units.USFeet; } public string ConvertOrThrow(Unit hostUnit) { - var linearUnit = LinearUnit.CreateLinearUnit(hostUnit.Wkt).Name; + int linearUnit = LinearUnit.CreateLinearUnit(hostUnit.Wkt).FactoryCode; - if (s_unitMapping.TryGetValue(linearUnit, out string? value)) + if (_unitMapping.TryGetValue(linearUnit, out string? value)) { return value; } diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/PolylineFeatureToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/PolylineFeatureToSpeckleConverter.cs index 2af833bed4..b28ad710c4 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/PolylineFeatureToSpeckleConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/PolylineFeatureToSpeckleConverter.cs @@ -1,3 +1,5 @@ +using ArcGIS.Desktop.Mapping; +using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; namespace Speckle.Converters.ArcGIS3.Features; @@ -5,17 +7,40 @@ namespace Speckle.Converters.ArcGIS3.Features; public class PolyineFeatureToSpeckleConverter : ITypedConverter> { private readonly ITypedConverter _segmentConverter; + private readonly IConversionContextStack _contextStack; - public PolyineFeatureToSpeckleConverter(ITypedConverter segmentConverter) + public PolyineFeatureToSpeckleConverter( + ITypedConverter segmentConverter, + IConversionContextStack contextStack + ) { _segmentConverter = segmentConverter; + _contextStack = contextStack; } public IReadOnlyList Convert(ACG.Polyline target) { // https://pro.arcgis.com/en/pro-app/latest/sdk/api-reference/topic8480.html List polylineList = new(); - foreach (var segmentCollection in target.Parts) + ACG.Polyline polylineToConvert = target; + + // segmentize the polylines with curves using precision value of the Map's Spatial Reference + if (target.HasCurves is true) + { + double tolerance = _contextStack.Current.Document.SpatialReference.XYTolerance; + double conversionFactorToMeter = _contextStack.Current.Document.SpatialReference.Unit.ConversionFactor; + var densifiedPolyline = ACG.GeometryEngine.Instance.DensifyByDeviation( + target, + tolerance * conversionFactorToMeter + ); + polylineToConvert = (ACG.Polyline)densifiedPolyline; + if (densifiedPolyline == null) + { + throw new ArgumentException("Polyline densification failed"); + } + } + + foreach (var segmentCollection in polylineToConvert.Parts) { polylineList.Add(_segmentConverter.Convert(segmentCollection)); } diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/BezierSegmentToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/BezierSegmentToSpeckleConverter.cs deleted file mode 100644 index 8c62df731d..0000000000 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/BezierSegmentToSpeckleConverter.cs +++ /dev/null @@ -1,58 +0,0 @@ -using Speckle.Converters.Common.Objects; -using Speckle.Converters.Common; -using ArcGIS.Desktop.Mapping; - -namespace Speckle.Converters.ArcGIS3.Geometry; - -public class BezierSegmentToSpeckleConverter : ITypedConverter -{ - private readonly IConversionContextStack _contextStack; - private readonly ITypedConverter _pointConverter; - - public BezierSegmentToSpeckleConverter( - IConversionContextStack contextStack, - ITypedConverter pointConverter - ) - { - _contextStack = contextStack; - _pointConverter = pointConverter; - } - - public SOG.Polyline Convert(ACG.CubicBezierSegment target) - { - // Determine the number of vertices to create along the arc - int numVertices = Math.Max((int)target.Length, 3); // Determine based on desired segment length or other criteria - List points = new(); - - // Calculate the vertices along the curve - for (int i = 0; i <= numVertices; i++) - { - double t = i / (double)numVertices; - - // Calculate the point using the cubic Bezier formula - double x = - (1 - t) * (1 - t) * (1 - t) * target.StartPoint.X - + 3 * (1 - t) * (1 - t) * t * target.ControlPoint1.X - + 3 * (1 - t) * t * t * target.ControlPoint2.X - + t * t * t * target.EndPoint.X; - - double y = - (1 - t) * (1 - t) * (1 - t) * target.StartPoint.Y - + 3 * (1 - t) * (1 - t) * t * target.ControlPoint1.Y - + 3 * (1 - t) * t * t * target.ControlPoint2.Y - + t * t * t * target.EndPoint.Y; - - ACG.MapPoint pointOnCurve = ACG.MapPointBuilderEx.CreateMapPoint(x, y, target.SpatialReference); - points.Add(_pointConverter.Convert(pointOnCurve)); - } - - // create Speckle Polyline - SOG.Polyline polyline = - new(points.SelectMany(pt => new[] { pt.x, pt.y, pt.z }).ToList(), _contextStack.Current.SpeckleUnits) - { - // bbox = box, - length = target.Length - }; - return polyline; - } -} diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/EllipticArcSegmentToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/EllipticArcSegmentToSpeckleConverter.cs deleted file mode 100644 index af4c3716c4..0000000000 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/EllipticArcSegmentToSpeckleConverter.cs +++ /dev/null @@ -1,67 +0,0 @@ -using Speckle.Converters.Common.Objects; -using Speckle.Converters.Common; -using ArcGIS.Desktop.Mapping; - -namespace Speckle.Converters.ArcGIS3.Geometry; - -public class EllipticArcToSpeckleConverter : ITypedConverter -{ - private readonly IConversionContextStack _contextStack; - private readonly ITypedConverter _pointConverter; - - public EllipticArcToSpeckleConverter( - IConversionContextStack contextStack, - ITypedConverter pointConverter - ) - { - _contextStack = contextStack; - _pointConverter = pointConverter; - } - - public SOG.Polyline Convert(ACG.EllipticArcSegment target) - { - // Determine the number of vertices to create along the arc - int numVertices = Math.Max((int)target.Length, 3); // Determine based on desired segment length or other criteria - List points = new(); - - // get correct direction - int coeff = 1; - double fullAngle = target.EndAngle - target.StartAngle; - double angleStart = target.StartAngle; - - // define the direction - if ( - !((target.IsCounterClockwise is false || fullAngle >= 0) && (target.IsCounterClockwise is true || fullAngle < 0)) - ) - { - fullAngle = Math.PI * 2 - Math.Abs(fullAngle); - if (target.IsCounterClockwise is false) - { - coeff = -1; - } - } - - // Calculate the vertices along the arc - for (int i = 0; i <= numVertices; i++) - { - // Calculate the point along the arc - double angle = angleStart + coeff * fullAngle * (i / (double)numVertices); - ACG.MapPoint pointOnArc = ACG.MapPointBuilderEx.CreateMapPoint( - target.CenterPoint.X + target.SemiMajorAxis * Math.Cos(angle), - target.CenterPoint.Y + target.SemiMinorAxis * Math.Sin(angle), - target.SpatialReference - ); - - points.Add(_pointConverter.Convert(pointOnArc)); - } - - // create Speckle Polyline - SOG.Polyline polyline = - new(points.SelectMany(pt => new[] { pt.x, pt.y, pt.z }).ToList(), _contextStack.Current.SpeckleUnits) - { - // bbox = box, - length = target.Length - }; - return polyline; - } -} diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/CircleToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/CircleToHostConverter.cs index cff9770e7d..7e3ce179f2 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/CircleToHostConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/CircleToHostConverter.cs @@ -1,5 +1,7 @@ +using ArcGIS.Desktop.Mapping; using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; +using Speckle.Core.Kits; using Speckle.Core.Models; namespace Speckle.Converters.ArcGIS3.Geometry.ISpeckleObjectToHost; @@ -8,45 +10,38 @@ namespace Speckle.Converters.ArcGIS3.Geometry.ISpeckleObjectToHost; public class CircleToHostConverter : IToHostTopLevelConverter, ITypedConverter { private readonly ITypedConverter _pointConverter; + private readonly IConversionContextStack _contextStack; - public CircleToHostConverter(ITypedConverter pointConverter) + public CircleToHostConverter( + ITypedConverter pointConverter, + IConversionContextStack contextStack + ) { _pointConverter = pointConverter; + _contextStack = contextStack; } public object Convert(Base target) => Convert((SOG.Circle)target); public ACG.Polyline Convert(SOG.Circle target) { - // Determine the number of vertices to create along the cirlce - int numVertices = Math.Max((int)target.length, 100); // Determine based on desired segment length or other criteria - List pointsOriginal = new(); - if (target.radius == null) { throw new SpeckleConversionException("Conversion failed: Circle doesn't have a radius"); } - // Calculate the vertices along the arc - for (int i = 0; i <= numVertices; i++) - { - // Calculate the point along the arc - double angle = 2 * Math.PI * (i / (double)numVertices); - SOG.Point pointOnCircle = - new( - target.plane.origin.x + (double)target.radius * Math.Cos(angle), - target.plane.origin.y + (double)target.radius * Math.Sin(angle), - target.plane.origin.z - ); - - pointsOriginal.Add(pointOnCircle); - } - if (pointsOriginal[0] != pointsOriginal[^1]) - { - pointsOriginal.Add(pointsOriginal[0]); - } + // create a native ArcGIS circle segment + ACG.MapPoint centerPt = _pointConverter.Convert(target.plane.origin); + + double scaleFactor = Units.GetConversionFactor(target.units, _contextStack.Current.SpeckleUnits); + ACG.EllipticArcSegment circleSegment = ACG.EllipticArcBuilderEx.CreateCircle( + new ACG.Coordinate2D(centerPt.X, centerPt.Y), + (double)target.radius * scaleFactor, + ACG.ArcOrientation.ArcClockwise + ); + + var circlePolyline = new ACG.PolylineBuilderEx(circleSegment, ACG.AttributeFlags.HasZ).ToGeometry(); - var points = pointsOriginal.Select(x => _pointConverter.Convert(x)); - return new ACG.PolylineBuilderEx(points, ACG.AttributeFlags.HasZ).ToGeometry(); + return circlePolyline; } } diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/SegmentCollectionToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/SegmentCollectionToSpeckleConverter.cs index 0c9572c24e..0e13f55260 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/SegmentCollectionToSpeckleConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/SegmentCollectionToSpeckleConverter.cs @@ -8,20 +8,14 @@ public class SegmentCollectionToSpeckleConverter : ITypedConverter _contextStack; private readonly ITypedConverter _pointConverter; - private readonly ITypedConverter _arcConverter; - private readonly ITypedConverter _bezierConverter; public SegmentCollectionToSpeckleConverter( IConversionContextStack contextStack, - ITypedConverter pointConverter, - ITypedConverter arcConverter, - ITypedConverter bezierConverter + ITypedConverter pointConverter ) { _contextStack = contextStack; _pointConverter = pointConverter; - _arcConverter = arcConverter; - _bezierConverter = bezierConverter; } public SOG.Polyline Convert(ACG.ReadOnlySegmentCollection target) @@ -34,27 +28,39 @@ public SOG.Polyline Convert(ACG.ReadOnlySegmentCollection target) { len += segment.Length; - // do something specific per segment type + // specific conversion per segment type switch (segment.SegmentType) { case ACG.SegmentType.Line: - points.Add(_pointConverter.Convert(segment.StartPoint)); - points.Add(_pointConverter.Convert(segment.EndPoint)); - break; - case ACG.SegmentType.Bezier: - var segmentBezier = (ACG.CubicBezierSegment)segment; - points.AddRange(_bezierConverter.Convert(segmentBezier).GetPoints()); - break; - case ACG.SegmentType.EllipticArc: - var segmentElliptic = (ACG.EllipticArcSegment)segment; - points.AddRange(_arcConverter.Convert(segmentElliptic).GetPoints()); + points = AddPtsToPolylinePts( + points, + new List() + { + _pointConverter.Convert(segment.StartPoint), + _pointConverter.Convert(segment.EndPoint) + } + ); break; + default: + throw new SpeckleConversionException($"Segment of type '{segment.SegmentType}' cannot be converted"); } } - // var box = _boxConverter.Convert(target.Extent); SOG.Polyline polyline = new(points.SelectMany(pt => new[] { pt.x, pt.y, pt.z }).ToList(), _contextStack.Current.SpeckleUnits) { }; return polyline; } + + private List AddPtsToPolylinePts(List points, List newSegmentPts) + { + if (points.Count == 0 || points[^1] != newSegmentPts[0]) + { + points.AddRange(newSegmentPts); + } + else + { + points.AddRange(newSegmentPts.GetRange(1, newSegmentPts.Count - 1)); + } + return points; + } } From 5469a123e1f0f14454a3a745aeb6a0450325ac05 Mon Sep 17 00:00:00 2001 From: KatKatKateryna <89912278+KatKatKateryna@users.noreply.github.com> Date: Thu, 30 May 2024 17:17:50 +0800 Subject: [PATCH 209/261] CNX-9446 create enums for arc gis custom types (#3429) * add layer geometry types class * fix dataset overwriting caused by the fallback conversions * class for FieldTypes * declutter CreateDatasetInDatabase * post-merge issues * post-merge issues2 --------- Co-authored-by: Alan Rynne --- .../Features/GisFeatureToSpeckleConverter.cs | 16 +-- .../PointcloudLayerToSpeckleConverter.cs | 3 +- .../Layers/VectorLayerToHostConverter.cs | 2 +- .../Layers/VectorLayerToSpeckleConverter.cs | 34 ++--- .../Utils/ArcGISFieldUtils.cs | 57 +-------- .../Utils/FeatureClassUtils.cs | 57 ++------- .../Utils/GISAttributeFieldType.cs | 119 ++++++++++++++++++ .../Utils/GISLayerGeometryType.cs | 12 ++ .../Utils/IArcGISFieldUtils.cs | 2 - .../Utils/IFeatureClassUtils.cs | 1 - .../Utils/NonNativeFeaturesUtils.cs | 22 ++-- 11 files changed, 175 insertions(+), 150 deletions(-) create mode 100644 DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/GISAttributeFieldType.cs create mode 100644 DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/GISLayerGeometryType.cs diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GisFeatureToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GisFeatureToSpeckleConverter.cs index 10aac2ae25..a3c9d41e40 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GisFeatureToSpeckleConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GisFeatureToSpeckleConverter.cs @@ -3,6 +3,7 @@ using ArcGIS.Core.Data; using Speckle.Converters.ArcGIS3.Geometry; using Speckle.Converters.Common; +using Speckle.Converters.ArcGIS3.Utils; namespace Speckle.Converters.ArcGIS3.Features; @@ -57,32 +58,23 @@ public SGIS.GisFeature Convert(Row target) IReadOnlyList fields = target.GetFields(); foreach (Field field in fields) { - string name = field.Name; // POC: check for all possible reserved Shape names if (field.FieldType == FieldType.Geometry) // ignore the field with geometry itself { hasGeometry = true; - geometryField = name; + geometryField = field.Name; } // Raster FieldType is not properly supported through API else if ( field.FieldType == FieldType.Raster || field.FieldType == FieldType.Blob || field.FieldType == FieldType.XML ) { - attributes[name] = null; + attributes[field.Name] = null; } // to not break serializer (DateOnly) and to simplify complex types - else if ( - field.FieldType == FieldType.DateOnly - || field.FieldType == FieldType.TimeOnly - || field.FieldType == FieldType.TimestampOffset - ) - { - attributes[name] = target[name]?.ToString(); - } else { - attributes[name] = target[name]; + attributes[field.Name] = GISAttributeFieldType.FieldValueToSpeckle(target, field); } } diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/PointcloudLayerToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/PointcloudLayerToSpeckleConverter.cs index f4d3281629..bf23636895 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/PointcloudLayerToSpeckleConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/PointcloudLayerToSpeckleConverter.cs @@ -5,6 +5,7 @@ using ArcGIS.Core.CIM; using Speckle.Converters.ArcGIS3.Geometry; using Speckle.Core.Models; +using Speckle.Converters.ArcGIS3.Utils; namespace Speckle.Converters.ArcGIS3.Layers; @@ -88,7 +89,7 @@ public SGIS.VectorLayer Convert(LasDatasetLayer target) speckleLayer.name = target.Name; speckleLayer.units = _contextStack.Current.SpeckleUnits; speckleLayer.nativeGeomType = target.MapLayerType.ToString(); - speckleLayer.geomType = "Pointcloud"; + speckleLayer.geomType = GISLayerGeometryType.POINTCLOUD; // prepare data for pointcloud List specklePts = new(); diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/VectorLayerToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/VectorLayerToHostConverter.cs index 8648970fa1..58297364df 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/VectorLayerToHostConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/VectorLayerToHostConverter.cs @@ -37,7 +37,7 @@ public string Convert(VectorLayer target) // pointcloud layers need to be checked separately, because there is no ArcGIS Geometry type // for Pointcloud. In ArcGIS it's a completely different layer class, so "GetLayerGeometryType" // will return "Invalid" type - if (target.geomType == "Pointcloud") + if (target.geomType == GISLayerGeometryType.POINTCLOUD) { return _pointcloudLayerConverter.Convert(target).Name; } diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/VectorLayerToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/VectorLayerToSpeckleConverter.cs index 02a0917b0f..cf38ebc4d4 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/VectorLayerToSpeckleConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/VectorLayerToSpeckleConverter.cs @@ -6,6 +6,7 @@ using ArcGIS.Core.Data; using ArcGIS.Core.Geometry; using Speckle.Converters.ArcGIS3.Utils; +using ArcGIS.Core.CIM; namespace Speckle.Converters.ArcGIS3.Layers; @@ -35,26 +36,18 @@ public Base Convert(object target) return Convert((FeatureLayer)target); } - private string SpeckleGeometryType(string nativeGeometryType) + private string AssignSpeckleGeometryType(esriGeometryType nativeGeometryType) { - string spekleGeometryType = "None"; - if (nativeGeometryType.Contains("point", StringComparison.OrdinalIgnoreCase)) + return nativeGeometryType switch { - spekleGeometryType = "Point"; - } - else if (nativeGeometryType.Contains("polyline", StringComparison.OrdinalIgnoreCase)) - { - spekleGeometryType = "Polyline"; - } - else if (nativeGeometryType.Contains("polygon", StringComparison.OrdinalIgnoreCase)) - { - spekleGeometryType = "Polygon"; - } - else if (nativeGeometryType.Contains("multipatch", StringComparison.OrdinalIgnoreCase)) - { - spekleGeometryType = "Multipatch"; - } - return spekleGeometryType; + esriGeometryType.esriGeometryMultipoint => GISLayerGeometryType.POINT, + esriGeometryType.esriGeometryPoint => GISLayerGeometryType.POINT, + esriGeometryType.esriGeometryLine => GISLayerGeometryType.POLYLINE, + esriGeometryType.esriGeometryPolyline => GISLayerGeometryType.POLYLINE, + esriGeometryType.esriGeometryPolygon => GISLayerGeometryType.POLYGON, + esriGeometryType.esriGeometryMultiPatch => GISLayerGeometryType.MULTIPATCH, + _ => GISLayerGeometryType.NONE, + }; } public VectorLayer Convert(FeatureLayer target) @@ -94,14 +87,13 @@ public VectorLayer Convert(FeatureLayer target) continue; } addedFieldDescriptions.Add(field); - allLayerAttributes[name] = (int)field.Type; + allLayerAttributes[name] = GISAttributeFieldType.FieldTypeToSpeckle(field.Type); } } speckleLayer.attributes = allLayerAttributes; - speckleLayer.nativeGeomType = target.ShapeType.ToString(); // get a simple geometry type - string spekleGeometryType = SpeckleGeometryType(speckleLayer.nativeGeomType); + string spekleGeometryType = AssignSpeckleGeometryType(target.ShapeType); speckleLayer.geomType = spekleGeometryType; // search the rows diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/ArcGISFieldUtils.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/ArcGISFieldUtils.cs index f53ea51a07..1f98758611 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/ArcGISFieldUtils.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/ArcGISFieldUtils.cs @@ -16,54 +16,6 @@ public ArcGISFieldUtils(ICharacterCleaner characterCleaner) _characterCleaner = characterCleaner; } - public object? FieldValueToNativeType(FieldType fieldType, object? value) - { - // Geometry: ignored - // Blob, Raster, TimestampOffset, XML: converted to String (field type already converted to String on Send) - switch (fieldType) - { - case FieldType.GUID: - return value; - case FieldType.OID: - return value; - } - - if (value is not null) - { - try - { - switch (fieldType) - { - case FieldType.String: - return (string)value; - case FieldType.Single: - return (float)(double)value; - case FieldType.Integer: - // need this step because sent "ints" seem to be received as "longs" - return (int)(long)value; - case FieldType.BigInteger: - return (long)value; - case FieldType.SmallInteger: - return (short)(long)value; - case FieldType.Double: - return (double)value; - case FieldType.Date: - return DateTime.Parse((string)value, null); - case FieldType.DateOnly: - return DateOnly.Parse((string)value); - case FieldType.TimeOnly: - return TimeOnly.Parse((string)value); - } - } - catch (InvalidCastException) - { - return value; - } - } - - return value; - } - public RowBuffer AssignFieldValuesToRow(RowBuffer rowBuffer, List fields, GisFeature feat) { foreach (FieldDescription field in fields) @@ -79,7 +31,7 @@ public RowBuffer AssignFieldValuesToRow(RowBuffer rowBuffer, List GetFieldsFromSpeckleLayer(VectorLayer target) { List fields = new(); @@ -121,7 +68,7 @@ public List GetFieldsFromSpeckleLayer(VectorLayer target) if (field.Value is not null) { string key = field.Key; - FieldType fieldType = GetFieldTypeFromInt((int)(long)field.Value); + FieldType fieldType = GISAttributeFieldType.FieldTypeToNative(field.Value); FieldDescription fieldDescription = new(_characterCleaner.CleanCharacters(key), fieldType) { AliasName = key }; diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/FeatureClassUtils.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/FeatureClassUtils.cs index 49f46aba53..dce6ce6853 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/FeatureClassUtils.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/FeatureClassUtils.cs @@ -85,54 +85,15 @@ List fields public ACG.GeometryType GetLayerGeometryType(VectorLayer target) { string? originalGeomType = target.geomType != null ? target.geomType : target.nativeGeomType; - - if (string.IsNullOrEmpty(originalGeomType)) - { - throw new SpeckleConversionException($"Unknown geometry type for layer {target.name}"); - } - return GetGeometryTypeFromString(originalGeomType.ToLower()); - } - - public ACG.GeometryType GetGeometryTypeFromString(string target) - { - // POC: find better pattern - if (target.Contains("none", StringComparison.OrdinalIgnoreCase)) + return originalGeomType switch { - return ACG.GeometryType.Unknown; - } - else if (target.Contains("pointcloud", StringComparison.OrdinalIgnoreCase)) - { - return ACG.GeometryType.Unknown; - } - else if (target.Contains("point", StringComparison.OrdinalIgnoreCase)) - { - return ACG.GeometryType.Multipoint; - } - else if ( - target.Contains("line", StringComparison.OrdinalIgnoreCase) - || target.Contains("curve", StringComparison.OrdinalIgnoreCase) - || target.Contains("arc", StringComparison.OrdinalIgnoreCase) - || target.Contains("circle", StringComparison.OrdinalIgnoreCase) - || target.Contains("ellipse", StringComparison.OrdinalIgnoreCase) - ) - { - return ACG.GeometryType.Polyline; - } - else if (target.Contains("polygon", StringComparison.OrdinalIgnoreCase)) - { - return ACG.GeometryType.Polygon; - } - else if (target.Contains("multipatch", StringComparison.OrdinalIgnoreCase)) - { - return ACG.GeometryType.Multipatch; - } - else if (target.Contains("mesh", StringComparison.OrdinalIgnoreCase)) - { - return ACG.GeometryType.Multipatch; - } - else - { - throw new SpeckleConversionException($"Unknown geometry type {target}"); - } + GISLayerGeometryType.NONE => ACG.GeometryType.Unknown, + GISLayerGeometryType.POINT => ACG.GeometryType.Multipoint, + GISLayerGeometryType.POLYGON => ACG.GeometryType.Polygon, + GISLayerGeometryType.POLYLINE => ACG.GeometryType.Polyline, + GISLayerGeometryType.MULTIPATCH => ACG.GeometryType.Multipatch, + GISLayerGeometryType.POLYGON3D => ACG.GeometryType.Multipatch, + _ => throw new ArgumentOutOfRangeException(nameof(target)), + }; } } diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/GISAttributeFieldType.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/GISAttributeFieldType.cs new file mode 100644 index 0000000000..64cb937987 --- /dev/null +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/GISAttributeFieldType.cs @@ -0,0 +1,119 @@ +using ArcGIS.Core.Data; + +namespace Speckle.Converters.ArcGIS3.Utils; + +public static class GISAttributeFieldType +{ + public const string GUID_TYPE = "Guid"; + public const string OID = "Oid"; // object identifier: int + public const string STRING_TYPE = "String"; + public const string FLOAT_TYPE = "Float"; // single-precision floating point number + public const string INTEGER_TYPE = "Integer"; // 32-bit int + public const string BIGINTEGER = "BigInteger"; // 64-bit int + public const string SMALLINTEGER = "SmallInteger"; // 16-bit int + public const string DOUBLE_TYPE = "Double"; + public const string DATETIME = "DateTime"; + public const string DATEONLY = "DateOnly"; + public const string TIMEONLY = "TimeOnly"; + public const string TIMESTAMPOFFSET = "TimeStampOffset"; + + public static string FieldTypeToSpeckle(FieldType fieldType) + { + return fieldType switch + { + FieldType.GUID => GUID_TYPE, + FieldType.OID => OID, + FieldType.String => STRING_TYPE, + FieldType.Single => FLOAT_TYPE, + FieldType.Integer => INTEGER_TYPE, + FieldType.BigInteger => BIGINTEGER, + FieldType.SmallInteger => SMALLINTEGER, + FieldType.Double => DOUBLE_TYPE, + FieldType.Date => DATETIME, + FieldType.DateOnly => DATEONLY, + FieldType.TimeOnly => TIMEONLY, + FieldType.TimestampOffset => TIMESTAMPOFFSET, + _ => throw new ArgumentOutOfRangeException(nameof(fieldType)), + }; + } + + public static FieldType FieldTypeToNative(object fieldType) + { + if (fieldType is string fieldStringType) + { + return fieldStringType switch + { + GUID_TYPE => FieldType.GUID, + OID => FieldType.OID, + STRING_TYPE => FieldType.String, + FLOAT_TYPE => FieldType.Single, + INTEGER_TYPE => FieldType.Integer, + BIGINTEGER => FieldType.BigInteger, + SMALLINTEGER => FieldType.SmallInteger, + DOUBLE_TYPE => FieldType.Double, + DATETIME => FieldType.Date, + DATEONLY => FieldType.DateOnly, + TIMEONLY => FieldType.TimeOnly, + TIMESTAMPOFFSET => FieldType.String, // sending and receiving as stings + _ => throw new ArgumentOutOfRangeException(nameof(fieldType)), + }; + } + // old way: + return (FieldType)(int)(long)fieldType; + } + + public static object? FieldValueToSpeckle(Row row, Field field) + { + if ( + field.FieldType == FieldType.DateOnly + || field.FieldType == FieldType.TimeOnly + || field.FieldType == FieldType.TimestampOffset + ) + { + return row[field.Name]?.ToString(); + } + else + { + return row[field.Name]; + } + } + + public static object? SpeckleValueToNativeFieldType(FieldType fieldType, object? value) + { + // Geometry: ignored + // Blob, Raster, TimestampOffset, XML: converted to String (field type already converted to String on Send) + switch (fieldType) + { + case FieldType.GUID: + return value; + case FieldType.OID: + return value; + } + + if (value is not null) + { + try + { + return fieldType switch + { + FieldType.String => (string)value, + FieldType.Single => (float)(double)value, + FieldType.Integer => (int)(long)value, // need this step because sent "ints" seem to be received as "longs" + FieldType.BigInteger => (long)value, + FieldType.SmallInteger => (short)(long)value, + FieldType.Double => (double)value, + FieldType.Date => DateTime.Parse((string)value, null), + FieldType.DateOnly => DateOnly.Parse((string)value), + FieldType.TimeOnly => TimeOnly.Parse((string)value), + _ => value, + }; + } + catch (InvalidCastException) + { + return value; + } + } + + return value; + } +} diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/GISLayerGeometryType.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/GISLayerGeometryType.cs new file mode 100644 index 0000000000..612eff4807 --- /dev/null +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/GISLayerGeometryType.cs @@ -0,0 +1,12 @@ +namespace Speckle.Converters.ArcGIS3.Utils; + +public static class GISLayerGeometryType +{ + public const string NONE = "None"; + public const string POINT = "Point"; + public const string POLYLINE = "Polyline"; + public const string POLYGON = "Polygon"; + public const string POLYGON3D = "Polygon3d"; + public const string MULTIPATCH = "Multipatch"; + public const string POINTCLOUD = "Pointcloud"; +} diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/IArcGISFieldUtils.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/IArcGISFieldUtils.cs index a60a980273..959e9793fe 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/IArcGISFieldUtils.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/IArcGISFieldUtils.cs @@ -7,7 +7,5 @@ namespace Speckle.Converters.ArcGIS3.Utils; public interface IArcGISFieldUtils { public RowBuffer AssignFieldValuesToRow(RowBuffer rowBuffer, List fields, GisFeature feat); - public object? FieldValueToNativeType(FieldType fieldType, object? value); public List GetFieldsFromSpeckleLayer(VectorLayer target); - public FieldType GetFieldTypeFromInt(int fieldType); } diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/IFeatureClassUtils.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/IFeatureClassUtils.cs index 2946ac3931..289c05eeb6 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/IFeatureClassUtils.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/IFeatureClassUtils.cs @@ -21,5 +21,4 @@ List fields ); void AddFeaturesToTable(Table newFeatureClass, List gisFeatures, List fields); public ACG.GeometryType GetLayerGeometryType(VectorLayer target); - public ACG.GeometryType GetGeometryTypeFromString(string target); } diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/NonNativeFeaturesUtils.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/NonNativeFeaturesUtils.cs index 4f0fa7cdfc..544ccc553f 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/NonNativeFeaturesUtils.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/NonNativeFeaturesUtils.cs @@ -49,13 +49,15 @@ public NonNativeFeaturesUtils( (string parentPath, ACG.Geometry geom, string? parentId) = item.Value; // add dictionnary item if doesn't exist yet - if (!geometryGroups.TryGetValue(parentPath, out var value)) + // Key must be unique per parent and speckle_type + // Key is composed of parentId and parentPath (that contains speckle_type) + string uniqueKey = $"{parentId}_{parentPath}"; + if (!geometryGroups.TryGetValue(uniqueKey, out (List geometries, string? parentId) value)) { - value = (new List(), parentId); - geometryGroups[parentPath] = value; + geometryGroups[uniqueKey] = (new List(), parentId); } - value.geometries.Add(geom); + geometryGroups[uniqueKey].geometries.Add(geom); } catch (Exception ex) when (!ex.IsFatal()) { @@ -69,12 +71,13 @@ public NonNativeFeaturesUtils( { try { - string parentPath = item.Key; + string uniqueKey = item.Key; // parentId_parentPath + string parentPath = uniqueKey.Split('_', 2)[^1]; + string speckle_type = parentPath.Split("\\")[^1]; (List geomList, string? parentId) = item.Value; - ACG.GeometryType geomType = geomList[0].GeometryType; try { - string converted = CreateDatasetInDatabase(geomType, geomList, parentId); + string converted = CreateDatasetInDatabase(speckle_type, geomList, parentId); result.Add((parentPath, converted)); } catch (GeodatabaseGeometryException) @@ -91,7 +94,7 @@ public NonNativeFeaturesUtils( return result; } - private string CreateDatasetInDatabase(ACG.GeometryType geomType, List geomList, string? parentId) + private string CreateDatasetInDatabase(string speckle_type, List geomList, string? parentId) { string databasePath = _arcGISProjectUtils.GetDatabasePath(); FileGeodatabaseConnectionPath fileGeodatabaseConnectionPath = new(new Uri(databasePath)); @@ -105,7 +108,7 @@ private string CreateDatasetInDatabase(ACG.GeometryType geomType, List fields = new(); // _fieldsUtils.GetFieldsFromSpeckleLayer(target); // TODO: generate meaningful name - string featureClassName = $"speckleID_{geomType}_{parentId}"; + string featureClassName = $"speckleTYPE_{speckle_type}_speckleID_{parentId}"; // delete FeatureClass if already exists foreach (FeatureClassDefinition fClassDefinition in geodatabase.GetDefinitions()) @@ -123,6 +126,7 @@ private string CreateDatasetInDatabase(ACG.GeometryType geomType, List Date: Thu, 30 May 2024 17:18:02 +0800 Subject: [PATCH 210/261] CNX-9501 agis highlighting loaded elements (#3443) * get URIs of received layers * add TOC selection (highlight) - because non-feature layers and multipatch feature layers will not be visible on the canvas. Also there might be multiple layers with the same shapes but different properties, just canvas selection might not be helpful * select features from the entire layer * conflicts --------- Co-authored-by: Alan Rynne --- .../Bindings/BasicConnectorBinding.cs | 45 ++++++++++++------- .../Operations/Receive/HostObjectBuilder.cs | 38 ++++++++++------ 2 files changed, 54 insertions(+), 29 deletions(-) diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/BasicConnectorBinding.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/BasicConnectorBinding.cs index 97d3aceb5e..e1d8f3a4e5 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/BasicConnectorBinding.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/BasicConnectorBinding.cs @@ -1,6 +1,4 @@ using System.Reflection; -using ArcGIS.Core.Data; -using ArcGIS.Core.Geometry; using ArcGIS.Desktop.Core; using ArcGIS.Desktop.Framework.Threading.Tasks; using ArcGIS.Desktop.Mapping; @@ -85,7 +83,9 @@ await QueuedTask .Run(() => { List mapMembers = GetMapMembers(objectIds, mapView); + ClearSelectionInTOC(); ClearSelection(); + SelectMapMembersInTOC(mapMembers); SelectMapMembers(mapMembers); mapView.ZoomToSelected(); }) @@ -125,26 +125,39 @@ private void ClearSelection() } } + private void ClearSelectionInTOC() + { + MapView.Active.ClearTOCSelection(); + } + private void SelectMapMembers(List mapMembers) { foreach (var member in mapMembers) { - if (member is FeatureLayer featureLayer) + if (member is FeatureLayer layer) + { + layer.Select(); + } + } + } + + private void SelectMapMembersInTOC(List mapMembers) + { + List layers = new(); + List tables = new(); + + foreach (MapMember member in mapMembers) + { + if (member is Layer layer) + { + layers.Add(layer); + } + else if (member is StandaloneTable table) { - using RowCursor rowCursor = featureLayer.Search(); - while (rowCursor.MoveNext()) - { - using (var row = rowCursor.Current) - { - if (row is not Feature feature) - { - continue; - } - Geometry geometry = feature.GetShape(); - MapView.Active.SelectFeatures(geometry, SelectionCombinationMethod.Add); - } - } + tables.Add(table); } } + MapView.Active.SelectLayers(layers); + // MapView.Active.SelectStandaloneTables(tables); // clears previous selection, not clear how to ADD selection instead } } diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Receive/HostObjectBuilder.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Receive/HostObjectBuilder.cs index 6bae793020..2d80e9bb33 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Receive/HostObjectBuilder.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Receive/HostObjectBuilder.cs @@ -59,23 +59,27 @@ List objectIds return (objPath, converted); } - public void AddDatasetsToMap((string, string) databaseObj, string databasePath) + public string AddDatasetsToMap((string, string) databaseObj, string databasePath) { try { - LayerFactory.Instance.CreateLayer( - new Uri($"{databasePath}\\{databaseObj.Item2}"), - _contextStack.Current.Document, - layerName: databaseObj.Item1 - ); + return LayerFactory.Instance + .CreateLayer( + new Uri($"{databasePath}\\{databaseObj.Item2}"), + _contextStack.Current.Document, + layerName: databaseObj.Item1 + ) + .URI; } catch (ArgumentException) { - StandaloneTableFactory.Instance.CreateStandaloneTable( - new Uri($"{databasePath}\\{databaseObj.Item2}"), - _contextStack.Current.Document, - tableName: databaseObj.Item1 - ); + return StandaloneTableFactory.Instance + .CreateStandaloneTable( + new Uri($"{databasePath}\\{databaseObj.Item2}"), + _contextStack.Current.Document, + tableName: databaseObj.Item1 + ) + .URI; } } @@ -177,6 +181,7 @@ CancellationToken cancellationToken } int bakeCount = 0; + List bakedLayersURIs = new(); onOperationProgressed?.Invoke("Adding to Map", bakeCount); // 3. add layer and tables to the Table Of Content foreach ((string, string) databaseObj in convertedGISObjects) @@ -186,12 +191,19 @@ CancellationToken cancellationToken // POC: QueuedTask var task = QueuedTask.Run(() => { - AddDatasetsToMap(databaseObj, databasePath); + try + { + bakedLayersURIs.Add(AddDatasetsToMap(databaseObj, databasePath)); + } + catch (Exception e) when (!e.IsFatal()) + { + // log error ("Layer X couldn't be added to Map"), but not cancel all operations + } onOperationProgressed?.Invoke("Adding to Map", (double)++bakeCount / convertedGISObjects.Count); }); task.Wait(cancellationToken); } - return objectIds; + return bakedLayersURIs; } } From 7b8b37896e30e05c9ad647d38dddc01ebc4a125e Mon Sep 17 00:00:00 2001 From: KatKatKateryna <89912278+KatKatKateryna@users.noreply.github.com> Date: Thu, 30 May 2024 20:11:17 +0800 Subject: [PATCH 211/261] Fix: Reverting wrong conflict resolving unit converter (#3452) On merge to alpha, these changes from Adam were accidentally reverted, and now it's changed back. --- .../ArcGISToSpeckleUnitConverter.cs | 26 ++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ArcGISToSpeckleUnitConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ArcGISToSpeckleUnitConverter.cs index d36f1f32a6..44d9786b8f 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ArcGISToSpeckleUnitConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ArcGISToSpeckleUnitConverter.cs @@ -7,28 +7,30 @@ namespace Speckle.Converters.ArcGIS3; public class ArcGISToSpeckleUnitConverter : IHostToSpeckleUnitConverter { - private readonly Dictionary _unitMapping = new(); + private static readonly IReadOnlyDictionary s_unitMapping = Create(); - private ArcGISToSpeckleUnitConverter() + private static IReadOnlyDictionary Create() { // POC: we should have a unit test to confirm these are as expected and don't change // more units: https://pro.arcgis.com/en/pro-app/latest/sdk/api-reference/topic8349.html - _unitMapping[LinearUnit.Millimeters.FactoryCode] = Units.Millimeters; - _unitMapping[LinearUnit.Centimeters.FactoryCode] = Units.Centimeters; - _unitMapping[LinearUnit.Meters.FactoryCode] = Units.Meters; - _unitMapping[LinearUnit.Kilometers.FactoryCode] = Units.Kilometers; - _unitMapping[LinearUnit.Inches.FactoryCode] = Units.Inches; - _unitMapping[LinearUnit.Feet.FactoryCode] = Units.Feet; - _unitMapping[LinearUnit.Yards.FactoryCode] = Units.Yards; - _unitMapping[LinearUnit.Miles.FactoryCode] = Units.Miles; - _unitMapping[9003] = Units.USFeet; + var dict = new Dictionary(); + dict[LinearUnit.Millimeters.FactoryCode] = Units.Millimeters; + dict[LinearUnit.Centimeters.FactoryCode] = Units.Centimeters; + dict[LinearUnit.Meters.FactoryCode] = Units.Meters; + dict[LinearUnit.Kilometers.FactoryCode] = Units.Kilometers; + dict[LinearUnit.Inches.FactoryCode] = Units.Inches; + dict[LinearUnit.Feet.FactoryCode] = Units.Feet; + dict[LinearUnit.Yards.FactoryCode] = Units.Yards; + dict[LinearUnit.Miles.FactoryCode] = Units.Miles; + dict[9003] = Units.USFeet; + return dict; } public string ConvertOrThrow(Unit hostUnit) { int linearUnit = LinearUnit.CreateLinearUnit(hostUnit.Wkt).FactoryCode; - if (_unitMapping.TryGetValue(linearUnit, out string? value)) + if (s_unitMapping.TryGetValue(linearUnit, out string? value)) { return value; } From ca5922cb80ff516f42ba8c07be0fe375b2b83767 Mon Sep 17 00:00:00 2001 From: Jedd Morgan <45512892+JR-Morgan@users.noreply.github.com> Date: Thu, 30 May 2024 15:17:34 +0100 Subject: [PATCH 212/261] Promoted several analysers to warnings for DUI3 (#3454) * Promoted several warnings out of `NoWarn` * accidental CS9057 --- Core/Core/Core.csproj | 4 ++-- DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/BrowserBridge.cs | 2 ++ Directory.Build.props | 3 +-- Directory.Build.targets | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Core/Core/Core.csproj b/Core/Core/Core.csproj index 15bac62d5a..275dcc12cc 100644 --- a/Core/Core/Core.csproj +++ b/Core/Core/Core.csproj @@ -23,7 +23,7 @@ CA1502; CA1506; CA1708; CA1710; CA1711; CA1716; CA1720; CA1721; CA1724; CA1816; CA1851; CA1861; - CA2201; CS8618; + CA2201; CS8618; CA1054; CS0419; CS0618; CS0659; CS0809; CS8600; CS8602; CS8603; CS8604; IDE0032; IDE0059; IDE0130; IDE1006; @@ -68,4 +68,4 @@ - \ No newline at end of file + diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/BrowserBridge.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/BrowserBridge.cs index ba25335a97..e1a434eab8 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/BrowserBridge.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/BrowserBridge.cs @@ -5,6 +5,7 @@ using Speckle.Connectors.DUI.Bindings; using System.Threading.Tasks.Dataflow; using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; using Microsoft.Extensions.Logging; using Speckle.Connectors.Utils; using Speckle.Core.Models.Extensions; @@ -306,6 +307,7 @@ public void ShowDevTools() ShowDevToolsAction?.Invoke(); } + [SuppressMessage("Design", "CA1054:URI-like parameters should not be strings", Justification = "Url run as process")] public void OpenUrl(string url) { Process.Start(new ProcessStartInfo { FileName = url, UseShellExecute = true }); diff --git a/Directory.Build.props b/Directory.Build.props index cc6e4ea861..a092bcd468 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -36,9 +36,8 @@ CS1591;CS1573; CA1303;CA1304;CA1305;CA1307;CA1308;CA1309;CA1310;CA1311;CA2101; - NU1701; - CA1815;CA1054;CA1852;CA1812;CA1003;CA2109;CA1848;$(NoWarn) + CA1815;CA1852;CA1812;CA1003;CA2109;CA1848;$(NoWarn) diff --git a/Directory.Build.targets b/Directory.Build.targets index 74264cc54f..92df7ec0f3 100644 --- a/Directory.Build.targets +++ b/Directory.Build.targets @@ -66,7 +66,7 @@ CS0618;CA1034;CA2201;CA1051;CA1040;CA1724; IDE0044;IDE0130;CA1508; - CA5394;CA2007;CA1852;CA1819;CA1711;CA1063;CA1816;CA2234; + CA5394;CA2007;CA1852;CA1819;CA1711;CA1063;CA1816;CA2234;CA1054; false From 040373f95145354392d13de28cafceab7530b6e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?O=C4=9Fuzhan=20Koral?= <45078678+oguzhankoral@users.noreply.github.com> Date: Thu, 30 May 2024 17:53:45 +0300 Subject: [PATCH 213/261] Store emit response and return later from bridge (#3456) Store response and return later --- DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/BrowserBridge.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/BrowserBridge.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/BrowserBridge.cs index e1a434eab8..6351021645 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/BrowserBridge.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/BrowserBridge.cs @@ -324,8 +324,9 @@ public void Send(string eventName, T data) where T : class { string payload = JsonConvert.SerializeObject(data, _serializerOptions); - var script = $"{FrontendBoundName}.emit('{eventName}', '{payload}')"; - + string requestId = $"{Guid.NewGuid()}_{eventName}"; + _resultsStore[requestId] = payload; + var script = $"{FrontendBoundName}.emitResponseReady('{eventName}', '{requestId}')"; _scriptMethod.NotNull().Invoke(script); } } From a705a5e0a30d9cfc632c891a199a5fea62e024ee Mon Sep 17 00:00:00 2001 From: Alan Rynne Date: Fri, 31 May 2024 16:15:46 +0200 Subject: [PATCH 214/261] chore(revit): Delete remaining files from old DUI3 POC (#3458) --- .../Speckle.Connectors.Revit2023/Class1.cs | 10 --- .../Properties/AssemblyInfo.cs | 36 --------- .../Speckle.Connectors.Revit2023.csproj | 80 ------------------- .../packages.config | 4 - .../RevitPlugin/IRevitPlugin.cs | 11 --- .../RevitPlugin/RevitExternalApplication.cs | 65 --------------- .../RevitPlugin/RevitSettings.cs | 10 --- .../RevitPlugin/SpeckleRevit.addin | 12 --- .../RevitPlugin/SpeckleRevitCommand.cs | 19 ----- .../Speckle.Connectors.RevitShared.projitems | 20 ----- .../Speckle.Connectors.RevitShared.shproj | 13 --- 11 files changed, 280 deletions(-) delete mode 100644 ConnectorRevit/RevitDUI3/Speckle.Connectors.Revit2023/Class1.cs delete mode 100644 ConnectorRevit/RevitDUI3/Speckle.Connectors.Revit2023/Properties/AssemblyInfo.cs delete mode 100644 ConnectorRevit/RevitDUI3/Speckle.Connectors.Revit2023/Speckle.Connectors.Revit2023.csproj delete mode 100644 ConnectorRevit/RevitDUI3/Speckle.Connectors.Revit2023/packages.config delete mode 100644 ConnectorRevit/RevitDUI3/Speckle.Connectors.RevitShared/RevitPlugin/IRevitPlugin.cs delete mode 100644 ConnectorRevit/RevitDUI3/Speckle.Connectors.RevitShared/RevitPlugin/RevitExternalApplication.cs delete mode 100644 ConnectorRevit/RevitDUI3/Speckle.Connectors.RevitShared/RevitPlugin/RevitSettings.cs delete mode 100644 ConnectorRevit/RevitDUI3/Speckle.Connectors.RevitShared/RevitPlugin/SpeckleRevit.addin delete mode 100644 ConnectorRevit/RevitDUI3/Speckle.Connectors.RevitShared/RevitPlugin/SpeckleRevitCommand.cs delete mode 100644 ConnectorRevit/RevitDUI3/Speckle.Connectors.RevitShared/Speckle.Connectors.RevitShared.projitems delete mode 100644 ConnectorRevit/RevitDUI3/Speckle.Connectors.RevitShared/Speckle.Connectors.RevitShared.shproj diff --git a/ConnectorRevit/RevitDUI3/Speckle.Connectors.Revit2023/Class1.cs b/ConnectorRevit/RevitDUI3/Speckle.Connectors.Revit2023/Class1.cs deleted file mode 100644 index 4ea4d39b06..0000000000 --- a/ConnectorRevit/RevitDUI3/Speckle.Connectors.Revit2023/Class1.cs +++ /dev/null @@ -1,10 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Speckle.Connectors.Revit2023 -{ - public class Class1 { } -} diff --git a/ConnectorRevit/RevitDUI3/Speckle.Connectors.Revit2023/Properties/AssemblyInfo.cs b/ConnectorRevit/RevitDUI3/Speckle.Connectors.Revit2023/Properties/AssemblyInfo.cs deleted file mode 100644 index 8cff72a923..0000000000 --- a/ConnectorRevit/RevitDUI3/Speckle.Connectors.Revit2023/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("Speckle.Connectors.Revit2023")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("Speckle.Connectors.Revit2023")] -[assembly: AssemblyCopyright("Copyright © 2024")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("e1ff75ec-2bdf-4276-9c81-6eb195661348")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/ConnectorRevit/RevitDUI3/Speckle.Connectors.Revit2023/Speckle.Connectors.Revit2023.csproj b/ConnectorRevit/RevitDUI3/Speckle.Connectors.Revit2023/Speckle.Connectors.Revit2023.csproj deleted file mode 100644 index 9d33e84d2e..0000000000 --- a/ConnectorRevit/RevitDUI3/Speckle.Connectors.Revit2023/Speckle.Connectors.Revit2023.csproj +++ /dev/null @@ -1,80 +0,0 @@ - - - - - Enable - 10.0 - Debug - AnyCPU - {E1FF75EC-2BDF-4276-9C81-6EB195661348} - Library - Properties - Speckle.Connectors.Revit2023 - Speckle.Connectors.Revit2023 - v4.8 - 512 - true - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 0 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - ..\..\..\packages\Revit_All_Main_Versions_API_x64.2023.0.0\lib\net48\AdWindows.dll - False - False - - - ..\..\..\packages\Revit_All_Main_Versions_API_x64.2023.0.0\lib\net48\RevitAPI.dll - False - False - - - ..\..\..\packages\Revit_All_Main_Versions_API_x64.2023.0.0\lib\net48\RevitAPIUI.dll - False - False - - - - - - - - - - - ..\..\..\packages\Revit_All_Main_Versions_API_x64.2023.0.0\lib\net48\UIFramework.dll - False - False - - - - - - - - - - - - {fd33c66e-cdaa-40ce-a7ea-0ee2bdce0ca4} - Speckle.Connectors.DependencyInjection - - - - - \ No newline at end of file diff --git a/ConnectorRevit/RevitDUI3/Speckle.Connectors.Revit2023/packages.config b/ConnectorRevit/RevitDUI3/Speckle.Connectors.Revit2023/packages.config deleted file mode 100644 index f7ed1d2901..0000000000 --- a/ConnectorRevit/RevitDUI3/Speckle.Connectors.Revit2023/packages.config +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/ConnectorRevit/RevitDUI3/Speckle.Connectors.RevitShared/RevitPlugin/IRevitPlugin.cs b/ConnectorRevit/RevitDUI3/Speckle.Connectors.RevitShared/RevitPlugin/IRevitPlugin.cs deleted file mode 100644 index 4c38ec5021..0000000000 --- a/ConnectorRevit/RevitDUI3/Speckle.Connectors.RevitShared/RevitPlugin/IRevitPlugin.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Speckle.Connectors.RevitShared.RevitPlugin; - -internal interface IRevitPlugin -{ - void Initialise(); - void Shutdown(); -} diff --git a/ConnectorRevit/RevitDUI3/Speckle.Connectors.RevitShared/RevitPlugin/RevitExternalApplication.cs b/ConnectorRevit/RevitDUI3/Speckle.Connectors.RevitShared/RevitPlugin/RevitExternalApplication.cs deleted file mode 100644 index db9a5e4478..0000000000 --- a/ConnectorRevit/RevitDUI3/Speckle.Connectors.RevitShared/RevitPlugin/RevitExternalApplication.cs +++ /dev/null @@ -1,65 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using Autodesk.Revit.UI; -using Speckle.Connectors.DependencyInjection; - -namespace Speckle.Connectors.RevitShared.RevitPlugin; - -internal class RevitExternalApplication : IExternalApplication -{ - private IRevitPlugin? _revitPlugin = null; - private SpeckleDependencyContainer? _container = null; - - // POC: this is getting hard coded - need a way of injecting it - // I am beginning to think the shared project is not the way - // and an assembly which is invoked with some specialisation is the right way to go - // maybe subclassing, or some hook to inject som configuration - private RevitSettings _revitSettings = new RevitSettings { RevitVersionName = "REVIT2023" }; - - public Result OnStartup(UIControlledApplication application) - { - try - { - _container = new SpeckleDependencyContainer(); - - // *** AUTOFAC MODULES *** - - // init DI - _container - .AddDependencies(new string[] { "" }) - .AddInstance(_revitSettings) // apply revit settings into DI - .AddInstance(application) // inject UIControlledApplication application - .Build(); - - // resolve root object - _revitPlugin = _container.Resolve(); - _revitPlugin.Initialise(); - } - catch (Exception ex) - { - // POC: feedback? - return Result.Failed; - } - - return Result.Succeeded; - } - - public Result OnShutdown(UIControlledApplication application) - { - try - { - // POC: could this be more a generic Connector Init() Shutdown() - // possibly with injected pieces or with some abstract methods? - // need to look for commonality - _revitPlugin.Shutdown(); - } - catch (Exception ex) - { - // POC: feedback? - return Result.Failed; - } - - return Result.Succeeded; - } -} diff --git a/ConnectorRevit/RevitDUI3/Speckle.Connectors.RevitShared/RevitPlugin/RevitSettings.cs b/ConnectorRevit/RevitDUI3/Speckle.Connectors.RevitShared/RevitPlugin/RevitSettings.cs deleted file mode 100644 index fd0c7b8a0d..0000000000 --- a/ConnectorRevit/RevitDUI3/Speckle.Connectors.RevitShared/RevitPlugin/RevitSettings.cs +++ /dev/null @@ -1,10 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Speckle.Connectors.RevitShared.RevitPlugin; - -internal class RevitSettings -{ - public string RevitVersionName { get; set; } -} diff --git a/ConnectorRevit/RevitDUI3/Speckle.Connectors.RevitShared/RevitPlugin/SpeckleRevit.addin b/ConnectorRevit/RevitDUI3/Speckle.Connectors.RevitShared/RevitPlugin/SpeckleRevit.addin deleted file mode 100644 index a1db0754ef..0000000000 --- a/ConnectorRevit/RevitDUI3/Speckle.Connectors.RevitShared/RevitPlugin/SpeckleRevit.addin +++ /dev/null @@ -1,12 +0,0 @@ - - - - Speckle.Connectors.Revit2023 - DUI3 (WIP) - Speckle.Connectors.Revit2023 - DUI3 (WIP) - Speckle.Connectors.Revit2023\Speckle.Connectors.Revit2023.dll - Speckle.ConnectorRevitDUI3.App - 56F4C629-BB39-4023-804B-307AA9749792 - speckle - Speckle: Empowering your design and construction data. For any problems, visit our community forum https://speckle.community - - diff --git a/ConnectorRevit/RevitDUI3/Speckle.Connectors.RevitShared/RevitPlugin/SpeckleRevitCommand.cs b/ConnectorRevit/RevitDUI3/Speckle.Connectors.RevitShared/RevitPlugin/SpeckleRevitCommand.cs deleted file mode 100644 index 1494cae947..0000000000 --- a/ConnectorRevit/RevitDUI3/Speckle.Connectors.RevitShared/RevitPlugin/SpeckleRevitCommand.cs +++ /dev/null @@ -1,19 +0,0 @@ -using Autodesk.Revit.Attributes; -using Autodesk.Revit.DB; -using Autodesk.Revit.UI; -using CefSharp; - -namespace Speckle.RevitPlugin; - -[Transaction(TransactionMode.Manual)] -public class SpeckleRevitCommand : IExternalCommand -{ - public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) - { - DockablePane panel = commandData.Application.GetDockablePane(App.PanelId); - panel.Show(); - - App.CefSharpPanel.Browser.ShowDevTools(); - return Result.Succeeded; - } -} diff --git a/ConnectorRevit/RevitDUI3/Speckle.Connectors.RevitShared/Speckle.Connectors.RevitShared.projitems b/ConnectorRevit/RevitDUI3/Speckle.Connectors.RevitShared/Speckle.Connectors.RevitShared.projitems deleted file mode 100644 index d8025bd015..0000000000 --- a/ConnectorRevit/RevitDUI3/Speckle.Connectors.RevitShared/Speckle.Connectors.RevitShared.projitems +++ /dev/null @@ -1,20 +0,0 @@ - - - - $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - true - 32aea787-c986-4b76-a57f-0da5453aa1f5 - - - Speckle.Connectors.RevitShared - - - - - - - - - - - \ No newline at end of file diff --git a/ConnectorRevit/RevitDUI3/Speckle.Connectors.RevitShared/Speckle.Connectors.RevitShared.shproj b/ConnectorRevit/RevitDUI3/Speckle.Connectors.RevitShared/Speckle.Connectors.RevitShared.shproj deleted file mode 100644 index cd8d375b77..0000000000 --- a/ConnectorRevit/RevitDUI3/Speckle.Connectors.RevitShared/Speckle.Connectors.RevitShared.shproj +++ /dev/null @@ -1,13 +0,0 @@ - - - - 32aea787-c986-4b76-a57f-0da5453aa1f5 - 14.0 - - - - - - - - From 53b90557b575b9c52409a849a101317fccea569a Mon Sep 17 00:00:00 2001 From: Adam Hathcock Date: Mon, 3 Jun 2024 10:09:25 +0100 Subject: [PATCH 215/261] Alpha branch fixes (#3462) * Clean up for build merge. Need global.json to not roll on major versions * latestMajor back --- Build/Program.cs | 8 ++++---- DUI3-DX/Directory.Build.Props | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Build/Program.cs b/Build/Program.cs index fda26ea38a..37675e3a64 100644 --- a/Build/Program.cs +++ b/Build/Program.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.IO; using System.IO.Compression; -using System.Linq; using Build; using GlobExpressions; using static Bullseye.Targets; @@ -18,13 +17,14 @@ const string RESTORE_TOOLS = "restore-tools"; const string BUILD_SERVER_VERSION = "build-server-version"; -var arguments = new List(); +//need to pass arguments +/*var arguments = new List(); if (args.Length > 1) { arguments = args.ToList(); args = new[] { arguments.First() }; - arguments = arguments.Skip(1).ToList(); -} + //arguments = arguments.Skip(1).ToList(); +}*/ Target( CLEAN, diff --git a/DUI3-DX/Directory.Build.Props b/DUI3-DX/Directory.Build.Props index 64c85531c3..dd2485d9d7 100644 --- a/DUI3-DX/Directory.Build.Props +++ b/DUI3-DX/Directory.Build.Props @@ -9,7 +9,7 @@ - - + + - \ No newline at end of file + From 3191365691e4b2901ebe8b83065ddb693cde473f Mon Sep 17 00:00:00 2001 From: KatKatKateryna <89912278+KatKatKateryna@users.noreply.github.com> Date: Wed, 5 Jun 2024 17:46:04 +0800 Subject: [PATCH 216/261] Arcgis documentation kate jedd (#3459) * expanding context stack Document from Map to (Project, Map) * move all database operations to context stack (it should only be called once per any operation and results (e.g. database path) accessible throughout converters) * fix Uri format needed for adding layers * Register ArcGISDocument * database URI fix --------- Co-authored-by: oguzhankoral --- .../Operations/Receive/HostObjectBuilder.cs | 29 +++-- .../ArcGISConverterModule.cs | 5 +- .../ArcGISConversionContextStack.cs | 100 +++++++++++++++++- .../Features/GisRasterToSpeckleConverter.cs | 8 +- .../MultipatchFeatureToSpeckleConverter.cs | 5 +- .../PointFeatureToSpeckleConverter.cs | 9 +- .../PolylineFeatureToSpeckleConverter.cs | 9 +- .../Geometry/EnvelopBoxToSpeckleConverter.cs | 9 +- .../CircleToHostConverter.cs | 5 +- .../Geometry/PointSingleToHostConverter.cs | 5 +- .../Geometry/PointToSpeckleConverter.cs | 11 +- .../SegmentCollectionToSpeckleConverter.cs | 5 +- .../Layers/FeatureClassToHostConverter.cs | 16 +-- .../PointcloudLayerToSpeckleConverter.cs | 6 +- .../Layers/RasterLayerToSpeckleConverter.cs | 9 +- .../Layers/TableToHostConverter.cs | 11 +- .../Layers/TableToSpeckleConverter.cs | 8 +- .../Layers/VectorLayerToHostConverter.cs | 5 +- .../Layers/VectorLayerToSpeckleConverter.cs | 6 +- .../Utils/ArcGISProjectUtils.cs | 82 -------------- .../Utils/IArcGISProjectUtils.cs | 7 -- .../Utils/NonNativeFeaturesUtils.cs | 22 +--- 22 files changed, 171 insertions(+), 201 deletions(-) delete mode 100644 DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/ArcGISProjectUtils.cs delete mode 100644 DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/IArcGISProjectUtils.cs diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Receive/HostObjectBuilder.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Receive/HostObjectBuilder.cs index 2d80e9bb33..ccbf054609 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Receive/HostObjectBuilder.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Receive/HostObjectBuilder.cs @@ -9,29 +9,27 @@ using ArcGIS.Core.Geometry; using Objects.GIS; using Speckle.Core.Models.GraphTraversal; +using Speckle.Converters.ArcGIS3; namespace Speckle.Connectors.ArcGIS.Operations.Receive; public class ArcGISHostObjectBuilder : IHostObjectBuilder { private readonly IRootToHostConverter _converter; - private readonly IArcGISProjectUtils _arcGISProjectUtils; private readonly INonNativeFeaturesUtils _nonGisFeaturesUtils; // POC: figure out the correct scope to only initialize on Receive - private readonly IConversionContextStack _contextStack; + private readonly IConversionContextStack _contextStack; private readonly GraphTraversal _traverseFunction; public ArcGISHostObjectBuilder( IRootToHostConverter converter, - IArcGISProjectUtils arcGISProjectUtils, - IConversionContextStack contextStack, + IConversionContextStack contextStack, INonNativeFeaturesUtils nonGisFeaturesUtils, GraphTraversal traverseFunction ) { _converter = converter; - _arcGISProjectUtils = arcGISProjectUtils; _contextStack = contextStack; _nonGisFeaturesUtils = nonGisFeaturesUtils; _traverseFunction = traverseFunction; @@ -59,14 +57,16 @@ List objectIds return (objPath, converted); } - public string AddDatasetsToMap((string, string) databaseObj, string databasePath) + public string AddDatasetsToMap((string, string) databaseObj) { try { return LayerFactory.Instance .CreateLayer( - new Uri($"{databasePath}\\{databaseObj.Item2}"), - _contextStack.Current.Document, + new Uri( + $"{_contextStack.Current.Document.SpeckleDatabasePath.AbsolutePath.Replace('/', '\\')}\\{databaseObj.Item2}" + ), + _contextStack.Current.Document.Map, layerName: databaseObj.Item1 ) .URI; @@ -75,8 +75,10 @@ public string AddDatasetsToMap((string, string) databaseObj, string databasePath { return StandaloneTableFactory.Instance .CreateStandaloneTable( - new Uri($"{databasePath}\\{databaseObj.Item2}"), - _contextStack.Current.Document, + new Uri( + $"{_contextStack.Current.Document.SpeckleDatabasePath.AbsolutePath.Replace('/', '\\')}\\{databaseObj.Item2}" + ), + _contextStack.Current.Document.Map, tableName: databaseObj.Item1 ) .URI; @@ -115,11 +117,6 @@ CancellationToken cancellationToken // Prompt the UI conversion started. Progress bar will swoosh. onOperationProgressed?.Invoke("Converting", null); - // create and add Geodatabase to a project - - string databasePath = _arcGISProjectUtils.GetDatabasePath(); - _arcGISProjectUtils.AddDatabaseToProject(databasePath); - // POC: This is where we will define our receive strategy, or maybe later somewhere else according to some setting pass from UI? var objectsToConvert = _traverseFunction .Traverse(rootObject) @@ -193,7 +190,7 @@ CancellationToken cancellationToken { try { - bakedLayersURIs.Add(AddDatasetsToMap(databaseObj, databasePath)); + bakedLayersURIs.Add(AddDatasetsToMap(databaseObj)); } catch (Exception e) when (!e.IsFatal()) { diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3.DependencyInjection/ArcGISConverterModule.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3.DependencyInjection/ArcGISConverterModule.cs index a2bc5383a9..30a739310b 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3.DependencyInjection/ArcGISConverterModule.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3.DependencyInjection/ArcGISConverterModule.cs @@ -1,5 +1,4 @@ using ArcGIS.Core.Geometry; -using ArcGIS.Desktop.Mapping; using Speckle.Autofac.DependencyInjection; using Speckle.Converters.ArcGIS3.Utils; using Speckle.Converters.Common; @@ -17,12 +16,12 @@ public void Load(SpeckleContainerBuilder builder) builder.AddScoped(); builder.AddScoped(); builder.AddScoped(); - builder.AddScoped(); builder.AddScoped(); + builder.AddScoped(); builder.AddScoped, ArcGISToSpeckleUnitConverter>(); // single stack per conversion - builder.AddScoped, ArcGISConversionContextStack>(); + builder.AddScoped, ArcGISConversionContextStack>(); } } diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ArcGISConversionContextStack.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ArcGISConversionContextStack.cs index 6290242235..1649d205dc 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ArcGISConversionContextStack.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ArcGISConversionContextStack.cs @@ -1,18 +1,110 @@ using System.Diagnostics.CodeAnalysis; -using ArcGIS.Core.Geometry; +using ArcGIS.Core.Data.DDL; +using ArcGIS.Core.Data; +using ArcGIS.Desktop.Core; +using ArcGIS.Desktop.Framework.Threading.Tasks; using ArcGIS.Desktop.Mapping; using Speckle.Converters.Common; namespace Speckle.Converters.ArcGIS3; +public class ArcGISDocument +{ + public Project Project { get; } + public Map Map { get; } + public Uri SpeckleDatabasePath { get; } + + public ArcGISDocument() + { + Project = Project.Current; + Map = MapView.Active.Map; + SpeckleDatabasePath = EnsureOrAddSpeckleDatabase(); + } + + private const string FGDB_NAME = "Speckle.gdb"; + + public Uri EnsureOrAddSpeckleDatabase() + { + return AddDatabaseToProject(GetDatabasePath()); + } + + public Uri GetDatabasePath() + { + try + { + var parentDirectory = Directory.GetParent(Project.Current.URI); + if (parentDirectory == null) + { + throw new ArgumentException($"Project directory {Project.Current.URI} not found"); + } + var fGdbPath = new Uri(parentDirectory.FullName); + return new Uri($"{fGdbPath}/{FGDB_NAME}"); + } + catch (Exception ex) + when (ex + is IOException + or UnauthorizedAccessException + or ArgumentException + or NotSupportedException + or System.Security.SecurityException + ) + { + throw; + } + } + + public Uri AddDatabaseToProject(Uri databasePath) + { + // Create a FileGeodatabaseConnectionPath with the name of the file geodatabase you wish to create + FileGeodatabaseConnectionPath fileGeodatabaseConnectionPath = new(databasePath); + // Create actual database in the specified Path unless already exists + try + { + Geodatabase geodatabase = SchemaBuilder.CreateGeodatabase(fileGeodatabaseConnectionPath); + geodatabase.Dispose(); + } + catch (ArcGIS.Core.Data.Exceptions.GeodatabaseWorkspaceException) + { + // geodatabase already exists, do nothing + } + + // Add a folder connection to a project + var parentFolder = Path.GetDirectoryName(databasePath.AbsolutePath); + if (parentFolder == null) + { + // POC: customize the exception type + throw new ArgumentException($"Invalid path: {databasePath}"); + } + var fGdbName = databasePath.Segments[^1]; + Item folderToAdd = ItemFactory.Instance.Create(parentFolder); + // POC: QueuedTask + QueuedTask.Run(() => Project.Current.AddItem(folderToAdd as IProjectItem)); + + // Add a file geodatabase or a SQLite or enterprise database connection to a project + var gdbToAdd = folderToAdd + .GetItems() + .FirstOrDefault(folderItem => folderItem.Name.Equals(fGdbName, StringComparison.Ordinal)); + if (gdbToAdd is not null) + { + // POC: QueuedTask + var addedGeodatabase = QueuedTask.Run(() => Project.Current.AddItem(gdbToAdd as IProjectItem)); + } + + return databasePath; + } +} + // POC: Suppressed naming warning for now, but we should evaluate if we should follow this or disable it. [SuppressMessage( "Naming", "CA1711:Identifiers should not have incorrect suffix", Justification = "Name ends in Stack but it is in fact a Stack, just not inheriting from `System.Collections.Stack`" )] -public class ArcGISConversionContextStack : ConversionContextStack +public class ArcGISConversionContextStack : ConversionContextStack { - public ArcGISConversionContextStack(IHostToSpeckleUnitConverter unitConverter) - : base(MapView.Active.Map, MapView.Active.Map.SpatialReference.Unit, unitConverter) { } + public ArcGISConversionContextStack( + IHostToSpeckleUnitConverter unitConverter, + ArcGISDocument arcGisDocument + ) + : base(arcGisDocument, MapView.Active.Map.SpatialReference.Unit, unitConverter) { } } diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GisRasterToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GisRasterToSpeckleConverter.cs index bcee923315..af3e268b8b 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GisRasterToSpeckleConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GisRasterToSpeckleConverter.cs @@ -3,19 +3,17 @@ using Objects.GIS; using ArcGIS.Core.Data.Raster; using Speckle.Converters.Common; -using ArcGIS.Desktop.Mapping; -using ArcGIS.Core.Geometry; namespace Speckle.Converters.ArcGIS3.Features; public class GisRasterToSpeckleConverter : ITypedConverter { - private readonly ITypedConverter> _geometryConverter; - private readonly IConversionContextStack _contextStack; + private readonly ITypedConverter> _geometryConverter; + private readonly IConversionContextStack _contextStack; public GisRasterToSpeckleConverter( ITypedConverter> geometryConverter, - IConversionContextStack contextStack + IConversionContextStack contextStack ) { _geometryConverter = geometryConverter; diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/MultipatchFeatureToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/MultipatchFeatureToSpeckleConverter.cs index 2da8dd6bf1..2e15ae765b 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/MultipatchFeatureToSpeckleConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/MultipatchFeatureToSpeckleConverter.cs @@ -1,6 +1,5 @@ using Speckle.Converters.Common.Objects; using Speckle.Converters.Common; -using ArcGIS.Desktop.Mapping; using Speckle.Core.Models; using Speckle.Converters.ArcGIS3.Geometry; @@ -8,11 +7,11 @@ namespace Speckle.Converters.ArcGIS3.Features; public class MultipatchFeatureToSpeckleConverter : ITypedConverter> { - private readonly IConversionContextStack _contextStack; + private readonly IConversionContextStack _contextStack; private readonly ITypedConverter _pointConverter; public MultipatchFeatureToSpeckleConverter( - IConversionContextStack contextStack, + IConversionContextStack contextStack, ITypedConverter pointConverter ) { diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/PointFeatureToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/PointFeatureToSpeckleConverter.cs index 5be96b9357..7b53a664de 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/PointFeatureToSpeckleConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/PointFeatureToSpeckleConverter.cs @@ -1,16 +1,15 @@ using Speckle.Converters.Common.Objects; using Speckle.Core.Models; using Speckle.Converters.Common; -using ArcGIS.Desktop.Mapping; namespace Speckle.Converters.ArcGIS3.Features; [NameAndRankValue(nameof(ACG.MapPoint), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] public class PointFeatureToSpeckleConverter : IToSpeckleTopLevelConverter, ITypedConverter { - private readonly IConversionContextStack _contextStack; + private readonly IConversionContextStack _contextStack; - public PointFeatureToSpeckleConverter(IConversionContextStack contextStack) + public PointFeatureToSpeckleConverter(IConversionContextStack contextStack) { _contextStack = contextStack; } @@ -20,12 +19,12 @@ public PointFeatureToSpeckleConverter(IConversionContextStack con public Base Convert(ACG.MapPoint target) { if ( - ACG.GeometryEngine.Instance.Project(target, _contextStack.Current.Document.SpatialReference) + ACG.GeometryEngine.Instance.Project(target, _contextStack.Current.Document.Map.SpatialReference) is not ACG.MapPoint reprojectedPt ) { throw new SpeckleConversionException( - $"Conversion to Spatial Reference {_contextStack.Current.Document.SpatialReference} failed" + $"Conversion to Spatial Reference {_contextStack.Current.Document.Map.SpatialReference} failed" ); } List geometry = diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/PolylineFeatureToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/PolylineFeatureToSpeckleConverter.cs index b28ad710c4..92bc6ff70e 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/PolylineFeatureToSpeckleConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/PolylineFeatureToSpeckleConverter.cs @@ -1,4 +1,3 @@ -using ArcGIS.Desktop.Mapping; using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; @@ -7,11 +6,11 @@ namespace Speckle.Converters.ArcGIS3.Features; public class PolyineFeatureToSpeckleConverter : ITypedConverter> { private readonly ITypedConverter _segmentConverter; - private readonly IConversionContextStack _contextStack; + private readonly IConversionContextStack _contextStack; public PolyineFeatureToSpeckleConverter( ITypedConverter segmentConverter, - IConversionContextStack contextStack + IConversionContextStack contextStack ) { _segmentConverter = segmentConverter; @@ -27,8 +26,8 @@ public PolyineFeatureToSpeckleConverter( // segmentize the polylines with curves using precision value of the Map's Spatial Reference if (target.HasCurves is true) { - double tolerance = _contextStack.Current.Document.SpatialReference.XYTolerance; - double conversionFactorToMeter = _contextStack.Current.Document.SpatialReference.Unit.ConversionFactor; + double tolerance = _contextStack.Current.Document.Map.SpatialReference.XYTolerance; + double conversionFactorToMeter = _contextStack.Current.Document.Map.SpatialReference.Unit.ConversionFactor; var densifiedPolyline = ACG.GeometryEngine.Instance.DensifyByDeviation( target, tolerance * conversionFactorToMeter diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/EnvelopBoxToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/EnvelopBoxToSpeckleConverter.cs index 5a101f250f..15dad97faf 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/EnvelopBoxToSpeckleConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/EnvelopBoxToSpeckleConverter.cs @@ -1,18 +1,17 @@ using ArcGIS.Core.Geometry; using Speckle.Converters.Common.Objects; using Speckle.Converters.Common; -using ArcGIS.Desktop.Mapping; using Objects.Primitive; namespace Speckle.Converters.ArcGIS3.Geometry; public class EnvelopToSpeckleConverter : ITypedConverter { - private readonly IConversionContextStack _contextStack; + private readonly IConversionContextStack _contextStack; private readonly ITypedConverter _pointConverter; public EnvelopToSpeckleConverter( - IConversionContextStack contextStack, + IConversionContextStack contextStack, ITypedConverter pointConverter ) { @@ -26,13 +25,13 @@ public SOG.Box Convert(Envelope target) target.XMin, target.YMin, target.ZMin, - _contextStack.Current.Document.SpatialReference + _contextStack.Current.Document.Map.SpatialReference ).ToGeometry(); MapPoint pointMax = new MapPointBuilderEx( target.XMax, target.YMax, target.ZMax, - _contextStack.Current.Document.SpatialReference + _contextStack.Current.Document.Map.SpatialReference ).ToGeometry(); SOG.Point minPtSpeckle = _pointConverter.Convert(pointMin); SOG.Point maxPtSpeckle = _pointConverter.Convert(pointMax); diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/CircleToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/CircleToHostConverter.cs index 7e3ce179f2..d4ffe06c35 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/CircleToHostConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/CircleToHostConverter.cs @@ -1,4 +1,3 @@ -using ArcGIS.Desktop.Mapping; using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; using Speckle.Core.Kits; @@ -10,11 +9,11 @@ namespace Speckle.Converters.ArcGIS3.Geometry.ISpeckleObjectToHost; public class CircleToHostConverter : IToHostTopLevelConverter, ITypedConverter { private readonly ITypedConverter _pointConverter; - private readonly IConversionContextStack _contextStack; + private readonly IConversionContextStack _contextStack; public CircleToHostConverter( ITypedConverter pointConverter, - IConversionContextStack contextStack + IConversionContextStack contextStack ) { _pointConverter = pointConverter; diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/PointSingleToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/PointSingleToHostConverter.cs index d444c193ad..e30ec589e5 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/PointSingleToHostConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/PointSingleToHostConverter.cs @@ -1,4 +1,3 @@ -using ArcGIS.Desktop.Mapping; using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; using Speckle.Core.Kits; @@ -8,9 +7,9 @@ namespace Speckle.Converters.ArcGIS3.Geometry; public class PointToHostConverter : ITypedConverter { - private readonly IConversionContextStack _contextStack; + private readonly IConversionContextStack _contextStack; - public PointToHostConverter(IConversionContextStack contextStack) + public PointToHostConverter(IConversionContextStack contextStack) { _contextStack = contextStack; } diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/PointToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/PointToSpeckleConverter.cs index 96a2efe233..198af4e5ee 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/PointToSpeckleConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/PointToSpeckleConverter.cs @@ -1,15 +1,14 @@ using ArcGIS.Core.Geometry; using Speckle.Converters.Common.Objects; using Speckle.Converters.Common; -using ArcGIS.Desktop.Mapping; namespace Speckle.Converters.ArcGIS3.Geometry; public class PointToSpeckleConverter : ITypedConverter { - private readonly IConversionContextStack _contextStack; + private readonly IConversionContextStack _contextStack; - public PointToSpeckleConverter(IConversionContextStack contextStack) + public PointToSpeckleConverter(IConversionContextStack contextStack) { _contextStack = contextStack; } @@ -19,12 +18,12 @@ public SOG.Point Convert(MapPoint target) try { if ( - GeometryEngine.Instance.Project(target, _contextStack.Current.Document.SpatialReference) + GeometryEngine.Instance.Project(target, _contextStack.Current.Document.Map.SpatialReference) is not MapPoint reprojectedPt ) { throw new SpeckleConversionException( - $"Conversion to Spatial Reference {_contextStack.Current.Document.SpatialReference} failed" + $"Conversion to Spatial Reference {_contextStack.Current.Document.Map.SpatialReference} failed" ); } return new(reprojectedPt.X, reprojectedPt.Y, reprojectedPt.Z, _contextStack.Current.SpeckleUnits); @@ -32,7 +31,7 @@ is not MapPoint reprojectedPt catch (ArgumentException ex) { throw new SpeckleConversionException( - $"Conversion to Spatial Reference {_contextStack.Current.Document.SpatialReference} failed", + $"Conversion to Spatial Reference {_contextStack.Current.Document.Map.SpatialReference} failed", ex ); } diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/SegmentCollectionToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/SegmentCollectionToSpeckleConverter.cs index 0e13f55260..2d3c93fce8 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/SegmentCollectionToSpeckleConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/SegmentCollectionToSpeckleConverter.cs @@ -1,4 +1,3 @@ -using ArcGIS.Desktop.Mapping; using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; @@ -6,11 +5,11 @@ namespace Speckle.Converters.ArcGIS3.Geometry; public class SegmentCollectionToSpeckleConverter : ITypedConverter { - private readonly IConversionContextStack _contextStack; + private readonly IConversionContextStack _contextStack; private readonly ITypedConverter _pointConverter; public SegmentCollectionToSpeckleConverter( - IConversionContextStack contextStack, + IConversionContextStack contextStack, ITypedConverter pointConverter ) { diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/FeatureClassToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/FeatureClassToHostConverter.cs index e05be2a71e..0a084ffee8 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/FeatureClassToHostConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/FeatureClassToHostConverter.cs @@ -1,9 +1,9 @@ using ArcGIS.Core.Data; using ArcGIS.Core.Data.DDL; using ArcGIS.Core.Data.Exceptions; -using ArcGIS.Core.Geometry; using Objects.GIS; using Speckle.Converters.ArcGIS3.Utils; +using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; using Speckle.Core.Models; using FieldDescription = ArcGIS.Core.Data.DDL.FieldDescription; @@ -15,19 +15,19 @@ public class FeatureClassToHostConverter : ITypedConverter, ACG.Geometry> _gisGeometryConverter; private readonly IFeatureClassUtils _featureClassUtils; private readonly IArcGISFieldUtils _fieldsUtils; - private readonly IArcGISProjectUtils _arcGISProjectUtils; + private readonly IConversionContextStack _contextStack; public FeatureClassToHostConverter( ITypedConverter, ACG.Geometry> gisGeometryConverter, IFeatureClassUtils featureClassUtils, IArcGISFieldUtils fieldsUtils, - IArcGISProjectUtils arcGISProjectUtils + IConversionContextStack contextStack ) { _gisGeometryConverter = gisGeometryConverter; _featureClassUtils = featureClassUtils; _fieldsUtils = fieldsUtils; - _arcGISProjectUtils = arcGISProjectUtils; + _contextStack = contextStack; } private List RecoverOutdatedGisFeatures(VectorLayer target) @@ -74,10 +74,10 @@ private List RecoverOutdatedGisFeatures(VectorLayer target) public FeatureClass Convert(VectorLayer target) { - GeometryType geomType = _featureClassUtils.GetLayerGeometryType(target); + ACG.GeometryType geomType = _featureClassUtils.GetLayerGeometryType(target); - string databasePath = _arcGISProjectUtils.GetDatabasePath(); - FileGeodatabaseConnectionPath fileGeodatabaseConnectionPath = new(new Uri(databasePath)); + FileGeodatabaseConnectionPath fileGeodatabaseConnectionPath = + new(_contextStack.Current.Document.SpeckleDatabasePath); Geodatabase geodatabase = new(fileGeodatabaseConnectionPath); SchemaBuilder schemaBuilder = new(geodatabase); @@ -87,7 +87,7 @@ public FeatureClass Convert(VectorLayer target) { wktString = target.crs.wkt.ToString(); } - SpatialReference spatialRef = SpatialReferenceBuilder.CreateSpatialReference(wktString); + ACG.SpatialReference spatialRef = ACG.SpatialReferenceBuilder.CreateSpatialReference(wktString); // create Fields List fields = _fieldsUtils.GetFieldsFromSpeckleLayer(target); diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/PointcloudLayerToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/PointcloudLayerToSpeckleConverter.cs index bf23636895..6c1590aaa3 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/PointcloudLayerToSpeckleConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/PointcloudLayerToSpeckleConverter.cs @@ -16,12 +16,12 @@ public class PointCloudToSpeckleConverter { private readonly ITypedConverter _pointConverter; private readonly ITypedConverter _boxConverter; - private readonly IConversionContextStack _contextStack; + private readonly IConversionContextStack _contextStack; public PointCloudToSpeckleConverter( ITypedConverter pointConverter, ITypedConverter boxConverter, - IConversionContextStack contextStack + IConversionContextStack contextStack ) { _pointConverter = pointConverter; @@ -77,7 +77,7 @@ public SGIS.VectorLayer Convert(LasDatasetLayer target) SGIS.VectorLayer speckleLayer = new(); // get document CRS (for writing geometry coords) - var spatialRef = _contextStack.Current.Document.SpatialReference; + var spatialRef = _contextStack.Current.Document.Map.SpatialReference; speckleLayer.crs = new SGIS.CRS { wkt = spatialRef.Wkt, diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/RasterLayerToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/RasterLayerToSpeckleConverter.cs index f5f96584ad..3afee5b6c3 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/RasterLayerToSpeckleConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/RasterLayerToSpeckleConverter.cs @@ -2,7 +2,6 @@ using Speckle.Core.Models; using Objects.GIS; using Speckle.Converters.Common; -using ArcGIS.Desktop.Mapping; using ArcGIS.Core.Geometry; using RasterLayer = ArcGIS.Desktop.Mapping.RasterLayer; using ArcGIS.Core.Data.Raster; @@ -13,11 +12,11 @@ namespace Speckle.Converters.ArcGIS3.Layers; public class RasterLayerToSpeckleConverter : IToSpeckleTopLevelConverter, ITypedConverter { private readonly ITypedConverter _gisRasterConverter; - private readonly IConversionContextStack _contextStack; + private readonly IConversionContextStack _contextStack; public RasterLayerToSpeckleConverter( ITypedConverter gisRasterConverter, - IConversionContextStack contextStack + IConversionContextStack contextStack ) { _gisRasterConverter = gisRasterConverter; @@ -34,7 +33,7 @@ public SGIS.RasterLayer Convert(RasterLayer target) var speckleLayer = new SGIS.RasterLayer(); // get document CRS (for writing geometry coords) - var spatialRef = _contextStack.Current.Document.SpatialReference; + var spatialRef = _contextStack.Current.Document.Map.SpatialReference; speckleLayer.crs = new CRS { wkt = spatialRef.Wkt, @@ -47,7 +46,7 @@ public SGIS.RasterLayer Convert(RasterLayer target) // get active map CRS if layer CRS is empty if (spatialRefRaster.Unit is null) { - spatialRefRaster = _contextStack.Current.Document.SpatialReference; + spatialRefRaster = _contextStack.Current.Document.Map.SpatialReference; } speckleLayer.rasterCrs = new CRS { diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/TableToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/TableToHostConverter.cs index b330f26dc5..374f09c23d 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/TableToHostConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/TableToHostConverter.cs @@ -5,6 +5,7 @@ using Speckle.Converters.ArcGIS3.Utils; using Speckle.Converters.Common.Objects; using FieldDescription = ArcGIS.Core.Data.DDL.FieldDescription; +using Speckle.Converters.Common; namespace Speckle.Converters.ArcGIS3.Layers; @@ -12,23 +13,23 @@ public class TableLayerToHostConverter : ITypedConverter { private readonly IFeatureClassUtils _featureClassUtils; private readonly IArcGISFieldUtils _fieldsUtils; - private readonly IArcGISProjectUtils _arcGISProjectUtils; + private readonly IConversionContextStack _contextStack; public TableLayerToHostConverter( IFeatureClassUtils featureClassUtils, - IArcGISProjectUtils arcGISProjectUtils, + IConversionContextStack contextStack, IArcGISFieldUtils fieldsUtils ) { _featureClassUtils = featureClassUtils; - _arcGISProjectUtils = arcGISProjectUtils; + _contextStack = contextStack; _fieldsUtils = fieldsUtils; } public Table Convert(VectorLayer target) { - string databasePath = _arcGISProjectUtils.GetDatabasePath(); - FileGeodatabaseConnectionPath fileGeodatabaseConnectionPath = new(new Uri(databasePath)); + FileGeodatabaseConnectionPath fileGeodatabaseConnectionPath = + new(_contextStack.Current.Document.SpeckleDatabasePath); Geodatabase geodatabase = new(fileGeodatabaseConnectionPath); SchemaBuilder schemaBuilder = new(geodatabase); diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/TableToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/TableToSpeckleConverter.cs index 31ee4bf6fc..110f752fc9 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/TableToSpeckleConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/TableToSpeckleConverter.cs @@ -4,7 +4,6 @@ using Speckle.Converters.Common; using ArcGIS.Desktop.Mapping; using ArcGIS.Core.Data; -using ArcGIS.Core.Geometry; namespace Speckle.Converters.ArcGIS3.Layers; @@ -14,15 +13,10 @@ public class StandaloneTableToSpeckleConverter ITypedConverter { private readonly ITypedConverter _gisFeatureConverter; - private readonly IConversionContextStack _contextStack; - public StandaloneTableToSpeckleConverter( - ITypedConverter gisFeatureConverter, - IConversionContextStack contextStack - ) + public StandaloneTableToSpeckleConverter(ITypedConverter gisFeatureConverter) { _gisFeatureConverter = gisFeatureConverter; - _contextStack = contextStack; } public Base Convert(object target) diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/VectorLayerToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/VectorLayerToHostConverter.cs index 58297364df..d4438f7339 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/VectorLayerToHostConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/VectorLayerToHostConverter.cs @@ -1,5 +1,4 @@ using ArcGIS.Core.Data; -using ArcGIS.Core.Geometry; using ArcGIS.Desktop.Mapping; using Objects.GIS; using Speckle.Converters.ArcGIS3.Utils; @@ -43,8 +42,8 @@ public string Convert(VectorLayer target) } // check if Speckle VectorLayer should become a FeatureClass, StandaloneTable or PointcloudLayer - GeometryType geomType = _featureClassUtils.GetLayerGeometryType(target); - if (geomType != GeometryType.Unknown) // feature class + ACG.GeometryType geomType = _featureClassUtils.GetLayerGeometryType(target); + if (geomType != ACG.GeometryType.Unknown) // feature class { return _featureClassConverter.Convert(target).GetName(); } diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/VectorLayerToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/VectorLayerToSpeckleConverter.cs index cf38ebc4d4..5712ecc8ee 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/VectorLayerToSpeckleConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/VectorLayerToSpeckleConverter.cs @@ -16,13 +16,13 @@ public class VectorLayerToSpeckleConverter : IToSpeckleTopLevelConverter, ITyped private readonly ITypedConverter _gisFeatureConverter; private readonly IFeatureClassUtils _featureClassUtils; private readonly IArcGISFieldUtils _fieldsUtils; - private readonly IConversionContextStack _contextStack; + private readonly IConversionContextStack _contextStack; public VectorLayerToSpeckleConverter( ITypedConverter gisFeatureConverter, IFeatureClassUtils featureClassUtils, IArcGISFieldUtils fieldsUtils, - IConversionContextStack contextStack + IConversionContextStack contextStack ) { _gisFeatureConverter = gisFeatureConverter; @@ -55,7 +55,7 @@ public VectorLayer Convert(FeatureLayer target) VectorLayer speckleLayer = new(); // get document CRS (for writing geometry coords) - var spatialRef = _contextStack.Current.Document.SpatialReference; + var spatialRef = _contextStack.Current.Document.Map.SpatialReference; speckleLayer.crs = new CRS { wkt = spatialRef.Wkt, diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/ArcGISProjectUtils.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/ArcGISProjectUtils.cs deleted file mode 100644 index bf38a876bd..0000000000 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/ArcGISProjectUtils.cs +++ /dev/null @@ -1,82 +0,0 @@ -using ArcGIS.Core.Data; -using ArcGIS.Core.Data.DDL; -using ArcGIS.Desktop.Core; -using ArcGIS.Desktop.Framework.Threading.Tasks; - -namespace Speckle.Converters.ArcGIS3.Utils; - -public class ArcGISProjectUtils : IArcGISProjectUtils -{ - private const string FGDB_NAME = "Speckle.gdb"; - - public string GetDatabasePath() - { - string fGdbPath; - try - { - var parentDirectory = Directory.GetParent(Project.Current.URI); - if (parentDirectory == null) - { - throw new ArgumentException($"Project directory {Project.Current.URI} not found"); - } - fGdbPath = parentDirectory.ToString(); - } - catch (Exception ex) - when (ex - is IOException - or UnauthorizedAccessException - or ArgumentException - or NotSupportedException - or System.Security.SecurityException - ) - { - throw; - } - - return $"{fGdbPath}\\{FGDB_NAME}"; - } - - public string AddDatabaseToProject(string databasePath) - { - // Create a FileGeodatabaseConnectionPath with the name of the file geodatabase you wish to create - FileGeodatabaseConnectionPath fileGeodatabaseConnectionPath = new(new Uri(databasePath)); - // Create actual database in the specified Path unless already exists - try - { - Geodatabase geodatabase = SchemaBuilder.CreateGeodatabase(fileGeodatabaseConnectionPath); - geodatabase.Dispose(); - } - catch (ArcGIS.Core.Data.Exceptions.GeodatabaseWorkspaceException) - { - // geodatabase already exists, do nothing - } - - // Add a folder connection to a project - var parentFolder = Directory.GetParent(databasePath); - if (parentFolder == null) - { - // POC: customize the exception type - throw new ArgumentException($"Invalid path: {databasePath}"); - } - - string parentFolderPath = parentFolder.ToString(); - var fGdbName = databasePath.Replace(parentFolderPath + '\\', string.Empty, StringComparison.Ordinal); - - string fGdbPath = parentFolder.ToString(); - Item folderToAdd = ItemFactory.Instance.Create(fGdbPath); - // POC: QueuedTask - QueuedTask.Run(() => Project.Current.AddItem(folderToAdd as IProjectItem)); - - // Add a file geodatabase or a SQLite or enterprise database connection to a project - var gdbToAdd = folderToAdd - .GetItems() - .FirstOrDefault(folderItem => folderItem.Name.Equals(fGdbName, StringComparison.Ordinal)); - if (gdbToAdd is not null) - { - // POC: QueuedTask - var addedGeodatabase = QueuedTask.Run(() => Project.Current.AddItem(gdbToAdd as IProjectItem)); - } - - return fGdbName; - } -} diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/IArcGISProjectUtils.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/IArcGISProjectUtils.cs deleted file mode 100644 index c86e271073..0000000000 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/IArcGISProjectUtils.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Speckle.Converters.ArcGIS3.Utils; - -public interface IArcGISProjectUtils -{ - string GetDatabasePath(); - string AddDatabaseToProject(string databasePath); -} diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/NonNativeFeaturesUtils.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/NonNativeFeaturesUtils.cs index 544ccc553f..cdb5226076 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/NonNativeFeaturesUtils.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/NonNativeFeaturesUtils.cs @@ -2,10 +2,7 @@ using ArcGIS.Core.Data; using ArcGIS.Core.Data.DDL; using ArcGIS.Core.Data.Exceptions; -using ArcGIS.Desktop.Mapping; using Speckle.Converters.Common; -using Speckle.Converters.Common.Objects; -using Speckle.Core.Models; using FieldDescription = ArcGIS.Core.Data.DDL.FieldDescription; using Speckle.Core.Logging; @@ -13,24 +10,15 @@ namespace Speckle.Converters.ArcGIS3.Utils; public class NonNativeFeaturesUtils : INonNativeFeaturesUtils { - private readonly ITypedConverter, ACG.Geometry> _gisGeometryConverter; - private readonly IArcGISFieldUtils _fieldsUtils; private readonly IFeatureClassUtils _featureClassUtils; - private readonly IArcGISProjectUtils _arcGISProjectUtils; - private readonly IConversionContextStack _contextStack; + private readonly IConversionContextStack _contextStack; public NonNativeFeaturesUtils( - ITypedConverter, ACG.Geometry> gisGeometryConverter, - IArcGISFieldUtils fieldsUtils, IFeatureClassUtils featureClassUtils, - IArcGISProjectUtils arcGISProjectUtils, - IConversionContextStack contextStack + IConversionContextStack contextStack ) { - _gisGeometryConverter = gisGeometryConverter; - _fieldsUtils = fieldsUtils; _featureClassUtils = featureClassUtils; - _arcGISProjectUtils = arcGISProjectUtils; _contextStack = contextStack; } @@ -96,13 +84,13 @@ public NonNativeFeaturesUtils( private string CreateDatasetInDatabase(string speckle_type, List geomList, string? parentId) { - string databasePath = _arcGISProjectUtils.GetDatabasePath(); - FileGeodatabaseConnectionPath fileGeodatabaseConnectionPath = new(new Uri(databasePath)); + FileGeodatabaseConnectionPath fileGeodatabaseConnectionPath = + new(_contextStack.Current.Document.SpeckleDatabasePath); Geodatabase geodatabase = new(fileGeodatabaseConnectionPath); SchemaBuilder schemaBuilder = new(geodatabase); // get Spatial Reference from the document - ACG.SpatialReference spatialRef = _contextStack.Current.Document.SpatialReference; + ACG.SpatialReference spatialRef = _contextStack.Current.Document.Map.SpatialReference; // TODO: create Fields List fields = new(); // _fieldsUtils.GetFieldsFromSpeckleLayer(target); From 406e1e28c3e7107677f6854c14e47deccddb976c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?O=C4=9Fuzhan=20Koral?= <45078678+oguzhankoral@users.noreply.github.com> Date: Thu, 6 Jun 2024 12:27:22 +0300 Subject: [PATCH 217/261] Send receive reports (#3448) * Conversion Results * Rhino * ReceiveConversionResult * Fixed highlighting * Moved result out of core * SendConversionResult * Send error message instead all serialized exception * Align conversion results with UI report * Highlight object on Rhino * Throw inner exception for highlight object * Highlight sub elements of group in Rhino * WIP * Arcgis Receive Reporting * split * Acad highlight objects method * Revit highlight objects method * Arcgis highlight objects method * Have public setters for deserialization * wip * wip so jedd can push * wip refactoring revit * wip acad (send) * wip - acad receive * wip arcgis refactor * Remove using * pass correct IDs to bakedObjId * pass layers (not features) IDs to model card BakedObjects. --------- Co-authored-by: Jedd Morgan <45512892+JR-Morgan@users.noreply.github.com> Co-authored-by: Dimitrie Stefanescu Co-authored-by: KatKatKateryna --- .../Bindings/ArcGISReceiveBinding.cs | 9 +- .../Bindings/ArcGISSendBinding.cs | 4 +- .../Bindings/BasicConnectorBinding.cs | 14 +- .../ArcGISConnectorModule.cs | 4 +- .../HostApp/SyncToQueuedTask.cs | 9 ++ .../Operations/Receive/HostObjectBuilder.cs | 81 +++++------- .../Operations/Send/RootObjectBuilder.cs | 22 ++-- .../Bindings/AutocadBasicConnectorBinding.cs | 19 ++- .../Bindings/AutocadReceiveBinding.cs | 6 +- .../Bindings/AutocadSendBinding.cs | 4 +- .../HostApp/Extensions/EntityExtensions.cs | 2 +- .../Receive/AutocadHostObjectBuilder.cs | 121 ++++++++++-------- .../Operations/Send/AutocadRootObject.cs | 1 + .../Send/AutocadRootObjectBuilder.cs | 38 ++---- .../Bindings/BasicConnectorBindingRevit.cs | 26 ++-- .../Bindings/SendBinding.cs | 5 +- .../Operations/Send/RevitRootObjectBuilder.cs | 15 ++- .../Bindings/RhinoBasicConnectorBinding.cs | 63 +++++++-- .../Bindings/RhinoReceiveBinding.cs | 11 +- .../Bindings/RhinoSendBinding.cs | 4 +- .../Receive/RhinoHostObjectBuilder.cs | 60 ++++----- .../Operations/Send/RhinoRootObjectBuilder.cs | 28 ++-- .../Utils/ArcGISProjectUtils.cs | 0 .../Bindings/IBasicConnectorBinding.cs | 2 + .../Bindings/ReceiveBindingUICommands.cs | 20 ++- .../Bindings/SendBindingUICommands.cs | 19 ++- .../Bridge/SyncToCurrentThread.cs | 2 +- .../Models/Card/ReceiveResult.cs | 12 +- .../Models/Card/ReceiverModelCard.cs | 2 +- .../Models/Card/ReceiverModelCardResult.cs | 2 +- .../Utils/DiscriminatedObjectConverter.cs | 3 +- .../Builders/IHostObjectBuilder.cs | 10 +- .../Builders/IRootObjectBuilder.cs | 9 +- .../Builders/TraversalExtensions.cs | 26 ++++ .../Conversion/ReportResult.cs | 112 ++++++++++++++++ .../Operations/ReceiveOperation.cs | 2 +- .../Operations/SendOperation.cs | 22 +++- .../ToHost/ConverterWithFallback.cs | 25 +--- .../ToHost/ConverterWithoutFallback.cs | 14 +- 39 files changed, 529 insertions(+), 299 deletions(-) create mode 100644 DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/HostApp/SyncToQueuedTask.cs create mode 100644 DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/ArcGISProjectUtils.cs create mode 100644 DUI3-DX/Sdk/Speckle.Connectors.Utils/Builders/TraversalExtensions.cs create mode 100644 DUI3-DX/Sdk/Speckle.Connectors.Utils/Conversion/ReportResult.cs diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISReceiveBinding.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISReceiveBinding.cs index f39adfc67d..6541824541 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISReceiveBinding.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISReceiveBinding.cs @@ -51,7 +51,7 @@ public async Task Receive(string modelCardId) using IUnitOfWork unitOfWork = _unitOfWorkFactory.Resolve(); // Receive host objects - IEnumerable receivedObjectIds = await unitOfWork.Service + var receiveOperationResults = await unitOfWork.Service .Execute( modelCard.AccountId.NotNull(), // POC: I hear -you are saying why we're passing them separately. Not sure pass the DUI3-> Connectors.DUI project dependency to the SDK-> Connector.Utils modelCard.ProjectId.NotNull(), @@ -63,7 +63,12 @@ public async Task Receive(string modelCardId) ) .ConfigureAwait(false); - Commands.SetModelReceiveResult(modelCardId, receivedObjectIds.ToList()); + modelCard.BakedObjectIds = receiveOperationResults.BakedObjectIds.ToList(); + Commands.SetModelReceiveResult( + modelCardId, + receiveOperationResults.BakedObjectIds, + receiveOperationResults.ConversionResults + ); } // Catch here specific exceptions if they related to model card. catch (OperationCanceledException) diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISSendBinding.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISSendBinding.cs index 8e9fba23bd..7391a8cea3 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISSendBinding.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISSendBinding.cs @@ -310,7 +310,7 @@ public async Task Send(string modelCardId) .ConfigureAwait(false); // Store the converted references in memory for future send operations, overwriting the existing values for the given application id. - foreach (var kvp in result.convertedReferences) + foreach (var kvp in result.ConvertedReferences) { _convertedObjectReferences[kvp.Key + modelCard.ProjectId] = kvp.Value; } @@ -322,7 +322,7 @@ public async Task Send(string modelCardId) }) .ConfigureAwait(false); - Commands.SetModelCreatedVersionId(modelCardId, sendResult.rootObjId); + Commands.SetModelSendResult(modelCardId, sendResult.RootObjId, sendResult.ConversionResults); } // Catch here specific exceptions if they related to model card. catch (SpeckleSendFilterException e) diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/BasicConnectorBinding.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/BasicConnectorBinding.cs index e1d8f3a4e5..b49d2a77f2 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/BasicConnectorBinding.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/BasicConnectorBinding.cs @@ -51,10 +51,10 @@ public BasicConnectorBinding(DocumentModelStore store, ArcGISSettings settings, public void RemoveModel(ModelCard model) => _store.RemoveModel(model); - public async void HighlightModel(string modelCardId) - { - MapView mapView = MapView.Active; + public void HighlightObjects(List objectIds) => HighlightObjectsOnView(objectIds); + public void HighlightModel(string modelCardId) + { var model = _store.GetModelById(modelCardId); if (model is null) @@ -71,13 +71,19 @@ public async void HighlightModel(string modelCardId) if (model is ReceiverModelCard receiverModelCard) { - objectIds = receiverModelCard.ReceiveResult?.BakedObjectIds.NotNull(); + objectIds = receiverModelCard.BakedObjectIds.NotNull(); } if (objectIds is null) { return; } + HighlightObjectsOnView(objectIds); + } + + private async void HighlightObjectsOnView(List objectIds) + { + MapView mapView = MapView.Active; await QueuedTask .Run(() => diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/DependencyInjection/ArcGISConnectorModule.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/DependencyInjection/ArcGISConnectorModule.cs index 1cf7a60174..91ddd3ee24 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/DependencyInjection/ArcGISConnectorModule.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/DependencyInjection/ArcGISConnectorModule.cs @@ -10,8 +10,8 @@ using Speckle.Connectors.Utils.Builders; using Speckle.Autofac; using Speckle.Connectors.ArcGIS.Filters; +using Speckle.Connectors.ArcGIS.HostApp; using Speckle.Connectors.DUI; -using Speckle.Connectors.DUI.Bridge; using Speckle.Connectors.DUI.Models; using Speckle.Connectors.Utils; using Speckle.Connectors.Utils.Operations; @@ -33,7 +33,7 @@ public void Load(SpeckleContainerBuilder builder) // POC: Overwriting the SyncToMainThread to SyncToCurrentThread for ArcGIS only! // On SendOperation, once we called QueuedTask, it expect to run everything on same thread. - builder.AddSingletonInstance(); + builder.AddSingletonInstance(); builder.AddSingleton(); diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/HostApp/SyncToQueuedTask.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/HostApp/SyncToQueuedTask.cs new file mode 100644 index 0000000000..58aa7875ca --- /dev/null +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/HostApp/SyncToQueuedTask.cs @@ -0,0 +1,9 @@ +using ArcGIS.Desktop.Framework.Threading.Tasks; +using Speckle.Connectors.Utils.Operations; + +namespace Speckle.Connectors.ArcGIS.HostApp; + +public class SyncToQueuedTask : ISyncToThread +{ + public Task RunOnThread(Func func) => QueuedTask.Run(func); +} diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Receive/HostObjectBuilder.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Receive/HostObjectBuilder.cs index ccbf054609..ce31b4775c 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Receive/HostObjectBuilder.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Receive/HostObjectBuilder.cs @@ -1,13 +1,12 @@ -using System.Diagnostics; using ArcGIS.Desktop.Mapping; using Speckle.Connectors.Utils.Builders; using Speckle.Converters.Common; using Speckle.Core.Logging; using Speckle.Core.Models; -using ArcGIS.Desktop.Framework.Threading.Tasks; using Speckle.Converters.ArcGIS3.Utils; using ArcGIS.Core.Geometry; using Objects.GIS; +using Speckle.Connectors.Utils.Conversion; using Speckle.Core.Models.GraphTraversal; using Speckle.Converters.ArcGIS3; @@ -49,11 +48,11 @@ List objectIds return ($"{string.Join("\\", objPath)}", converted, parentId); } - public (string, string) ConvertNativeLayers(Base obj, string[] path, List objectIds) + public (string path, string converted) ConvertNativeLayers(Collection obj, string[] path, List objectIds) { string converted = (string)_converter.Convert(obj); objectIds.Add(obj.id); - string objPath = $"{string.Join("\\", path)}\\{((Collection)obj).name}"; + string objPath = $"{string.Join("\\", path)}\\{obj.name}"; return (objPath, converted); } @@ -106,7 +105,7 @@ private bool HasGISParent(TraversalContext context) return vectorLayers.Count + rasterLayers.Count > 0; } - public IEnumerable Build( + public HostObjectBuilderResult Build( Base rootObject, string projectName, string modelName, @@ -128,9 +127,11 @@ CancellationToken cancellationToken int count = 0; Dictionary convertedGeometries = new(); List objectIds = new(); - List<(string, string)> convertedGISObjects = new(); + List<(string path, string converted)> convertedGISObjects = new(); // 1. convert everything + List results = new(objectsToConvert.Count); + List bakedObjectIds = new(); foreach (var item in objectsToConvert) { (string[] path, Base obj, string? parentId) = item; @@ -139,68 +140,48 @@ CancellationToken cancellationToken { if (obj is VectorLayer or Objects.GIS.RasterLayer) { - // POC: QueuedTask - var task = QueuedTask.Run(() => - { - convertedGISObjects.Add(ConvertNativeLayers(obj, path, objectIds)); - }); - task.Wait(cancellationToken); - - onOperationProgressed?.Invoke("Converting", (double)++count / allCount); + var result = ConvertNativeLayers((Collection)obj, path, objectIds); + convertedGISObjects.Add(result); + // NOTE: Dim doesn't really know what is what - is the result.path the id of the obj? + // TODO: is the type in here basically a GIS Layer? + results.Add(new(Status.SUCCESS, obj, result.path, "GIS Layer")); } else { - // POC: QueuedTask - QueuedTask.Run(() => - { - convertedGeometries[obj.id] = ConvertNonNativeGeometries(obj, path, parentId, objectIds); - }); - onOperationProgressed?.Invoke("Converting", (double)++count / allCount); + var result = ConvertNonNativeGeometries(obj, path, parentId, objectIds); + convertedGeometries[obj.id] = result; + + // NOTE: Dim doesn't really know what is what - is the result.path the id of the obj? + results.Add(new(Status.SUCCESS, obj, result.path, result.converted.GetType().ToString())); //POC: what native id?, path may not be unique + // TODO: Do we need this here? I remember oguzhan saying something that selection/object highlighting is weird in arcgis (weird is subjective) + // bakedObjectIds.Add(result.path); } } - catch (Exception e) when (!e.IsFatal()) // DO NOT CATCH SPECIFIC STUFF, conversion errors should be recoverable + catch (Exception ex) when (!ex.IsFatal()) // DO NOT CATCH SPECIFIC STUFF, conversion errors should be recoverable { - // POC: report, etc. - Debug.WriteLine("conversion error happened."); + results.Add(new(Status.ERROR, obj, null, null, ex)); } + onOperationProgressed?.Invoke("Converting", (double)++count / allCount); } // 2. convert Database entries with non-GIS geometry datasets - try - { - onOperationProgressed?.Invoke("Writing to Database", null); - convertedGISObjects.AddRange(_nonGisFeaturesUtils.WriteGeometriesToDatasets(convertedGeometries)); - } - catch (Exception e) when (!e.IsFatal()) // DO NOT CATCH SPECIFIC STUFF, conversion errors should be recoverable - { - // POC: report, etc. - Debug.WriteLine("conversion error happened."); - } + + onOperationProgressed?.Invoke("Writing to Database", null); + convertedGISObjects.AddRange(_nonGisFeaturesUtils.WriteGeometriesToDatasets(convertedGeometries)); int bakeCount = 0; - List bakedLayersURIs = new(); onOperationProgressed?.Invoke("Adding to Map", bakeCount); // 3. add layer and tables to the Table Of Content - foreach ((string, string) databaseObj in convertedGISObjects) + foreach (var databaseObj in convertedGISObjects) { cancellationToken.ThrowIfCancellationRequested(); + // BAKE OBJECTS HERE - // POC: QueuedTask - var task = QueuedTask.Run(() => - { - try - { - bakedLayersURIs.Add(AddDatasetsToMap(databaseObj)); - } - catch (Exception e) when (!e.IsFatal()) - { - // log error ("Layer X couldn't be added to Map"), but not cancel all operations - } - onOperationProgressed?.Invoke("Adding to Map", (double)++bakeCount / convertedGISObjects.Count); - }); - task.Wait(cancellationToken); + bakedObjectIds.Add(AddDatasetsToMap(databaseObj)); + onOperationProgressed?.Invoke("Adding to Map", (double)++bakeCount / convertedGISObjects.Count); } - return bakedLayersURIs; + // TODO: validated a correct set regarding bakedobject ids + return new(bakedObjectIds, results); } } diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Send/RootObjectBuilder.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Send/RootObjectBuilder.cs index 6af77c66cb..c07f396bbb 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Send/RootObjectBuilder.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Send/RootObjectBuilder.cs @@ -1,8 +1,10 @@ using ArcGIS.Desktop.Mapping; using Speckle.Autofac.DependencyInjection; using Speckle.Connectors.Utils.Builders; +using Speckle.Connectors.Utils.Conversion; using Speckle.Connectors.Utils.Operations; using Speckle.Converters.Common; +using Speckle.Core.Logging; using Speckle.Core.Models; namespace Speckle.Connectors.ArcGis.Operations.Send; @@ -19,7 +21,7 @@ public RootObjectBuilder(IUnitOfWorkFactory unitOfWorkFactory) _unitOfWorkFactory = unitOfWorkFactory; } - public Base Build( + public RootObjectBuilderResult Build( IReadOnlyList objects, SendInfo sendInfo, Action? onOperationProgressed = null, @@ -35,6 +37,7 @@ public Base Build( Collection rootObjectCollection = new(); //TODO: Collections + List results = new(objects.Count); foreach (MapMember mapMember in objects) { ct.ThrowIfCancellationRequested(); @@ -59,24 +62,17 @@ public Base Build( // add to host collectionHost.elements.Add(converted); + results.Add(new(Status.SUCCESS, applicationId, mapMember.GetType().Name, converted)); } - // POC: Exception handling on conversion logic must be revisited after several connectors have working conversions - catch (SpeckleConversionException e) + catch (Exception ex) when (!ex.IsFatal()) { - // POC: DO something with the exception - Console.WriteLine(e); - continue; - } - catch (NotSupportedException e) - { - // POC: DO something with the exception - Console.WriteLine(e); - continue; + results.Add(new(Status.ERROR, applicationId, mapMember.GetType().Name, null, ex)); + // POC: add logging } onOperationProgressed?.Invoke("Converting", (double)++count / objects.Count); } - return rootObjectCollection; + return new(rootObjectCollection, results); } } diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadBasicConnectorBinding.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadBasicConnectorBinding.cs index 27159ce2f9..a87ea7f70d 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadBasicConnectorBinding.cs +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadBasicConnectorBinding.cs @@ -62,6 +62,16 @@ public string GetConnectorVersion() => public void RemoveModel(ModelCard model) => _store.RemoveModel(model); + public void HighlightObjects(List objectIds) + { + // POC: Will be addressed to move it into AutocadContext! + var doc = Application.DocumentManager.MdiActiveDocument; + + var dbObjects = doc.GetObjects(objectIds); + var acadObjectIds = dbObjects.Select(tuple => tuple.Root.Id).ToArray(); + HighlightObjectsOnView(acadObjectIds); + } + public void HighlightModel(string modelCardId) { // POC: Will be addressed to move it into AutocadContext! @@ -88,7 +98,7 @@ public void HighlightModel(string modelCardId) if (model is ReceiverModelCard receiverModelCard) { - var dbObjects = doc.GetObjects((receiverModelCard.ReceiveResult?.BakedObjectIds).NotNull()); + var dbObjects = doc.GetObjects(receiverModelCard.BakedObjectIds.NotNull()); objectIds = dbObjects.Select(tuple => tuple.Root.Id).ToArray(); } @@ -98,6 +108,13 @@ public void HighlightModel(string modelCardId) return; } + HighlightObjectsOnView(objectIds); + } + + private void HighlightObjectsOnView(ObjectId[] objectIds) + { + var doc = Application.DocumentManager.MdiActiveDocument; + Parent.RunOnMainThread(() => { doc.Editor.SetImpliedSelection(Array.Empty()); // Deselects diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadReceiveBinding.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadReceiveBinding.cs index 7cce92087a..7c91a049dd 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadReceiveBinding.cs +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadReceiveBinding.cs @@ -12,7 +12,7 @@ namespace Speckle.Connectors.Autocad.Bindings; public sealed class AutocadReceiveBinding : IReceiveBinding, ICancelable { - public string Name { get; } = "receiveBinding"; + public string Name => "receiveBinding"; public IBridge Parent { get; } private readonly DocumentModelStore _store; @@ -53,7 +53,7 @@ public async Task Receive(string modelCardId) CancellationTokenSource cts = _cancellationManager.InitCancellationTokenSource(modelCardId); // Receive host objects - IEnumerable receivedObjectIds = await unitOfWork.Service + var operationResults = await unitOfWork.Service .Execute( modelCard.AccountId.NotNull(), // POC: I hear -you are saying why we're passing them separately. Not sure pass the DUI3-> Connectors.DUI project dependency to the SDK-> Connector.Utils modelCard.ProjectId.NotNull(), @@ -65,7 +65,7 @@ public async Task Receive(string modelCardId) ) .ConfigureAwait(false); - Commands.SetModelReceiveResult(modelCardId, receivedObjectIds.ToList()); + Commands.SetModelReceiveResult(modelCardId, operationResults.BakedObjectIds, operationResults.ConversionResults); } // Catch here specific exceptions if they related to model card. catch (OperationCanceledException) diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadSendBinding.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadSendBinding.cs index 2549d7744a..4321772b6e 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadSendBinding.cs +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadSendBinding.cs @@ -163,7 +163,7 @@ private async Task SendInternal(string modelCardId) .ConfigureAwait(false); // Store the converted references in memory for future send operations, overwriting the existing values for the given application id. - foreach (var kvp in sendResult.convertedReferences) + foreach (var kvp in sendResult.ConvertedReferences) { _convertedObjectReferences[kvp.Key + modelCard.ProjectId] = kvp.Value; } @@ -171,7 +171,7 @@ private async Task SendInternal(string modelCardId) // It's important to reset the model card's list of changed obj ids so as to ensure we accurately keep track of changes between send operations. modelCard.ChangedObjectIds = new(); - Commands.SetModelCreatedVersionId(modelCardId, sendResult.rootObjId); + Commands.SetModelSendResult(modelCardId, sendResult.RootObjId, sendResult.ConversionResults); } // Catch here specific exceptions if they related to model card. catch (OperationCanceledException) diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/Extensions/EntityExtensions.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/Extensions/EntityExtensions.cs index 1ddc70d912..d98c98b3db 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/Extensions/EntityExtensions.cs +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/Extensions/EntityExtensions.cs @@ -10,7 +10,7 @@ public static class EntityExtensions /// Entity to add into database. /// Layer to append object. /// Throws when there is no top transaction in the document. - public static ObjectId Append(this Entity entity, string? layer = null) + public static ObjectId AppendToDb(this Entity entity, string? layer = null) { // POC: Will be addressed to move it into AutocadContext! var db = entity.Database ?? Application.DocumentManager.MdiActiveDocument.Database; diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Operations/Receive/AutocadHostObjectBuilder.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Operations/Receive/AutocadHostObjectBuilder.cs index 12cdf9aaec..e5b720aad7 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Operations/Receive/AutocadHostObjectBuilder.cs +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Operations/Receive/AutocadHostObjectBuilder.cs @@ -1,9 +1,9 @@ -using System.Diagnostics; using Autodesk.AutoCAD.DatabaseServices; using Speckle.Connectors.Autocad.HostApp; using Speckle.Connectors.Autocad.HostApp.Extensions; using Speckle.Core.Models; using Speckle.Connectors.Utils.Builders; +using Speckle.Connectors.Utils.Conversion; using Speckle.Converters.Common; using Speckle.Core.Logging; using Speckle.Core.Models.GraphTraversal; @@ -12,22 +12,22 @@ namespace Speckle.Connectors.Autocad.Operations.Receive; public class AutocadHostObjectBuilder : IHostObjectBuilder { - private readonly IRootToHostConverter _converter; private readonly AutocadLayerManager _autocadLayerManager; + private readonly IRootToHostConverter _converter; private readonly GraphTraversal _traversalFunction; public AutocadHostObjectBuilder( IRootToHostConverter converter, - AutocadLayerManager autocadLayerManager, - GraphTraversal traversalFunction + GraphTraversal traversalFunction, + AutocadLayerManager autocadLayerManager ) { _converter = converter; - _autocadLayerManager = autocadLayerManager; _traversalFunction = traversalFunction; + _autocadLayerManager = autocadLayerManager; } - public IEnumerable Build( + public HostObjectBuilderResult Build( Base rootObject, string projectName, string modelName, @@ -40,64 +40,73 @@ CancellationToken cancellationToken // Layer filter for received commit with project and model name _autocadLayerManager.CreateLayerFilter(projectName, modelName); - var traversalGraph = _traversalFunction.Traverse(rootObject).ToArray(); + //TODO: make the layerManager handle \/ ? string baseLayerPrefix = $"SPK-{projectName}-{modelName}-"; - HashSet uniqueLayerNames = new(); - List handleValues = new(); - int count = 0; - // POC: Will be addressed to move it into AutocadContext! - using (TransactionContext.StartTransaction(Application.DocumentManager.MdiActiveDocument)) + List results = new(); + List bakedObjectIds = new(); + foreach (var tc in _traversalFunction.TraverseWithProgress(rootObject, onOperationProgressed, cancellationToken)) + { + try + { + var convertedObjects = ConvertObject(tc, baseLayerPrefix, uniqueLayerNames).ToList(); + + results.AddRange( + convertedObjects.Select( + e => + new ReceiveConversionResult(Status.SUCCESS, tc.Current, e.Handle.Value.ToString(), e.GetType().ToString()) + ) + ); + + bakedObjectIds.AddRange(convertedObjects.Select(e => e.Handle.Value.ToString())); + } + catch (Exception ex) when (!ex.IsFatal()) + { + results.Add(new(Status.ERROR, tc.Current, null, null, ex)); + } + } + + return new(bakedObjectIds, results); + } + + private IEnumerable ConvertObject(TraversalContext tc, string baseLayerPrefix, ISet uniqueLayerNames) + { + using TransactionContext transactionContext = TransactionContext.StartTransaction( + Application.DocumentManager.MdiActiveDocument + ); + + string layerFullName = GetLayerPath(tc, baseLayerPrefix); + + if (uniqueLayerNames.Add(layerFullName)) + { + _autocadLayerManager.CreateLayerOrPurge(layerFullName); + } + + //POC: this transaction used to be called in the converter, We've moved it here to unify converter implementation + //POC: Is this transaction 100% needed? we are already inside a transaction? + object converted; + using (var tr = Application.DocumentManager.CurrentDocument.Database.TransactionManager.StartTransaction()) { - foreach (TraversalContext tc in traversalGraph) + converted = _converter.Convert(tc.Current); + tr.Commit(); + } + + IEnumerable flattened = Utilities.FlattenToHostConversionResult(converted).Cast(); + + foreach (Entity? conversionResult in flattened) + { + if (conversionResult == null) { - cancellationToken.ThrowIfCancellationRequested(); - - try - { - string layerFullName = GetLayerPath(tc, baseLayerPrefix); - - if (uniqueLayerNames.Add(layerFullName)) - { - _autocadLayerManager.CreateLayerOrPurge(layerFullName); - } - - //POC: this transaction used to be called in the converter, We've moved it here to unify converter implementation - //POC: Is this transaction 100% needed? we are already inside a transaction? - object converted; - using (var tr = Application.DocumentManager.CurrentDocument.Database.TransactionManager.StartTransaction()) - { - converted = _converter.Convert(tc.Current); - tr.Commit(); - } - - List flattened = Utilities.FlattenToHostConversionResult(converted); - - foreach (Entity conversionResult in flattened.Cast()) - { - if (conversionResult == null) - { - // POC: This needed to be double checked why we check null and continue - continue; - } - - conversionResult.Append(layerFullName); - - handleValues.Add(conversionResult.Handle.Value.ToString()); - } - - onOperationProgressed?.Invoke("Converting", (double)++count / traversalGraph.Length); - } - catch (Exception e) when (!e.IsFatal()) // DO NOT CATCH SPECIFIC STUFF, conversion errors should be recoverable - { - // POC: report, etc. - Debug.WriteLine("conversion error happened."); - } + // POC: This needed to be double checked why we check null and continue + continue; } + + conversionResult.AppendToDb(layerFullName); + + yield return conversionResult; } - return handleValues; } private string GetLayerPath(TraversalContext context, string baseLayerPrefix) diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Operations/Send/AutocadRootObject.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Operations/Send/AutocadRootObject.cs index 6696617b23..02b33f8bff 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Operations/Send/AutocadRootObject.cs +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Operations/Send/AutocadRootObject.cs @@ -2,4 +2,5 @@ namespace Speckle.Connectors.Autocad.Operations.Send; +// Note: naming is a bit confusing, Root is similar to base commit object, or root commit object, etc. It might be just in my head (dim) public record AutocadRootObject(DBObject Root, string ApplicationId); diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Operations/Send/AutocadRootObjectBuilder.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Operations/Send/AutocadRootObjectBuilder.cs index 0155986fe4..cb49f54f13 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Operations/Send/AutocadRootObjectBuilder.cs +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Operations/Send/AutocadRootObjectBuilder.cs @@ -1,6 +1,6 @@ -using System.Diagnostics; -using Autodesk.AutoCAD.DatabaseServices; +using Autodesk.AutoCAD.DatabaseServices; using Speckle.Connectors.Utils.Builders; +using Speckle.Connectors.Utils.Conversion; using Speckle.Connectors.Utils.Operations; using Speckle.Converters.Common; using Speckle.Core.Logging; @@ -18,7 +18,7 @@ public AutocadRootObjectBuilder(IRootToSpeckleConverter converter) _converter = converter; } - public Base Build( + public RootObjectBuilderResult Build( IReadOnlyList objects, SendInfo sendInfo, Action? onOperationProgressed = null, @@ -39,7 +39,8 @@ public Base Build( Dictionary collectionCache = new(); int count = 0; - foreach (var (root, applicationId) in objects) + List results = new(objects.Count); + foreach (var (dbObject, applicationId) in objects) { ct.ThrowIfCancellationRequested(); @@ -55,18 +56,12 @@ public Base Build( } else { - converted = _converter.Convert(root); - - if (converted == null) - { - continue; - } - + converted = _converter.Convert(dbObject); converted.applicationId = applicationId; } // Create and add a collection for each layer if not done so already. - if ((root as Entity)?.Layer is string layer) + if ((dbObject as Entity)?.Layer is string layer) { if (!collectionCache.TryGetValue(layer, out Collection? collection)) { @@ -78,22 +73,17 @@ public Base Build( collection.elements.Add(converted); } - onOperationProgressed?.Invoke("Converting", (double)++count / objects.Count); + results.Add(new(Status.SUCCESS, applicationId, dbObject.GetType().ToString(), converted)); } - catch (SpeckleConversionException e) + catch (Exception ex) when (!ex.IsFatal()) { - Console.WriteLine(e); - } - catch (NotSupportedException e) - { - Console.WriteLine(e); - } - catch (Exception e) when (!e.IsFatal()) - { - Debug.WriteLine(e.Message); + results.Add(new(Status.ERROR, applicationId, dbObject.GetType().ToString(), null, ex)); + // POC: add logging } + + onOperationProgressed?.Invoke("Converting", (double)++count / objects.Count); } - return modelWithLayers; + return new(modelWithLayers, results); } } diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/BasicConnectorBindingRevit.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/BasicConnectorBindingRevit.cs index 56d73f3296..7b1382ce7b 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/BasicConnectorBindingRevit.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/BasicConnectorBindingRevit.cs @@ -18,6 +18,8 @@ internal sealed class BasicConnectorBindingRevit : IBasicConnectorBinding public string Name { get; private set; } public IBridge Parent { get; private set; } + public BasicConnectorBindingCommands Commands { get; } + private readonly DocumentModelStore _store; private readonly RevitContext _revitContext; private readonly RevitSettings _revitSettings; @@ -83,11 +85,6 @@ public string GetConnectorVersion() public void HighlightModel(string modelCardId) { - // POC: don't know if we can rely on storing the ActiveUIDocument, hence getting it each time - var activeUIDoc = - _revitContext.UIApplication?.ActiveUIDocument - ?? throw new SpeckleException("Unable to retrieve active UI document"); - SenderModelCard model = (SenderModelCard)_store.GetModelById(modelCardId); var elementIds = model.SendFilter.NotNull().GetObjectIds().Select(ElementId.Parse).ToList(); @@ -97,13 +94,24 @@ public void HighlightModel(string modelCardId) return; } + HighlightObjectsOnView(elementIds); + } + + public void HighlightObjects(List objectIds) => + HighlightObjectsOnView(objectIds.Select(ElementId.Parse).ToList()); + + private void HighlightObjectsOnView(List objectIds) + { + // POC: don't know if we can rely on storing the ActiveUIDocument, hence getting it each time + var activeUIDoc = + _revitContext.UIApplication?.ActiveUIDocument + ?? throw new SpeckleException("Unable to retrieve active UI document"); + // UiDocument operations should be wrapped into RevitTask, otherwise doesn't work on other tasks. RevitTask.RunAsync(() => { - activeUIDoc.Selection.SetElementIds(elementIds); - activeUIDoc.ShowElements(elementIds); + activeUIDoc.Selection.SetElementIds(objectIds); + activeUIDoc.ShowElements(objectIds); }); } - - public BasicConnectorBindingCommands Commands { get; } } diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SendBinding.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SendBinding.cs index 223c8d4b0c..a721ac2283 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SendBinding.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SendBinding.cs @@ -123,7 +123,7 @@ private async Task HandleSend(string modelCardId) .ConfigureAwait(false); // Store the converted references in memory for future send operations, overwriting the existing values for the given application id. - foreach (var kvp in sendResult.convertedReferences) + foreach (var kvp in sendResult.ConvertedReferences) { _convertedObjectReferences[kvp.Key + modelCard.ProjectId] = kvp.Value; } @@ -131,7 +131,8 @@ private async Task HandleSend(string modelCardId) // It's important to reset the model card's list of changed obj ids so as to ensure we accurately keep track of changes between send operations. modelCard.ChangedObjectIds = new(); - Commands.SetModelCreatedVersionId(modelCardId, sendResult.rootObjId); + //TODO: send full send resul to UI? + Commands.SetModelSendResult(modelCardId, sendResult.RootObjId, sendResult.ConversionResults); } // Catch here specific exceptions if they related to model card. catch (SpeckleSendFilterException e) diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RevitRootObjectBuilder.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RevitRootObjectBuilder.cs index de37e9d8ad..5d42abaa10 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RevitRootObjectBuilder.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RevitRootObjectBuilder.cs @@ -4,6 +4,7 @@ using Speckle.Connectors.DUI.Exceptions; using Speckle.Converters.RevitShared.Helpers; using Speckle.Connectors.Utils.Builders; +using Speckle.Connectors.Utils.Conversion; using Speckle.Connectors.Utils.Operations; using Speckle.Core.Logging; @@ -30,7 +31,7 @@ public RevitRootObjectBuilder(IRootToSpeckleConverter converter, IRevitConversio }; } - public Base Build( + public RootObjectBuilderResult Build( IReadOnlyList objects, SendInfo sendInfo, Action? onOperationProgressed = null, @@ -62,6 +63,7 @@ public Base Build( var countProgress = 0; // because for(int i = 0; ...) loops are so last year + List results = new(revitElements.Count); foreach (Element revitElement in revitElements) { ct.ThrowIfCancellationRequested(); @@ -88,17 +90,18 @@ public Base Build( } collection.elements.Add(converted); + results.Add(new(Status.SUCCESS, applicationId, revitElement.GetType().Name, converted)); } - catch (SpeckleConversionException) + catch (Exception ex) when (!ex.IsFatal()) { - // POC: logging + results.Add(new(Status.ERROR, applicationId, revitElement.GetType().Name, null, ex)); + // POC: add logging } - countProgress++; - onOperationProgressed?.Invoke("Converting", (double)countProgress / revitElements.Count); + onOperationProgressed?.Invoke("Converting", (double)++countProgress / revitElements.Count); } - return _rootObject; + return new(_rootObject, results); } /// diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoBasicConnectorBinding.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoBasicConnectorBinding.cs index d28a3a22dc..4154665c7b 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoBasicConnectorBinding.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoBasicConnectorBinding.cs @@ -52,6 +52,21 @@ public DocumentInfo GetDocumentInfo() => public void RemoveModel(ModelCard model) => _store.RemoveModel(model); + public void HighlightObjects(List objectIds) + { + var objects = GetObjectsFromIds(objectIds); + + if (objects.rhinoObjects.Count == 0 && objects.groups.Count == 0) + { + throw new InvalidOperationException( + "Highlighting RhinoObject is not successful.", + new ArgumentException($"{objectIds} is not a valid id", nameof(objectIds)) + ); + } + + HighlightObjectsOnView(objects.rhinoObjects, objects.groups); + } + public void HighlightModel(string modelCardId) { var objectIds = new List(); @@ -62,9 +77,9 @@ public void HighlightModel(string modelCardId) objectIds = sender.SendFilter.NotNull().GetObjectIds(); } - if (myModel is ReceiverModelCard receiver && receiver.ReceiveResult != null) + if (myModel is ReceiverModelCard receiver && receiver.BakedObjectIds != null) { - objectIds = receiver.ReceiveResult.BakedObjectIds.NotNull(); + objectIds = receiver.BakedObjectIds; } if (objectIds.Count == 0) @@ -73,23 +88,55 @@ public void HighlightModel(string modelCardId) return; } + var objects = GetObjectsFromIds(objectIds); + + RhinoDoc.ActiveDoc.Objects.UnselectAll(); + + if (objects.rhinoObjects.Count == 0 && objects.groups.Count == 0) + { + Commands.SetModelError(modelCardId, new OperationCanceledException("No objects found to highlight.")); + return; + } + + HighlightObjectsOnView(objects.rhinoObjects, objects.groups); + } + + private (List rhinoObjects, List groups) GetObjectsFromIds(List objectIds) + { List rhinoObjects = objectIds .Select((id) => RhinoDoc.ActiveDoc.Objects.FindId(new Guid(id))) .Where(o => o != null) .ToList(); + // POC: On receive we group objects if return multiple objects + List groups = objectIds + .Select((id) => RhinoDoc.ActiveDoc.Groups.FindId(new Guid(id))) + .Where(o => o != null) + .ToList(); + + return (rhinoObjects, groups); + } + + private void HighlightObjectsOnView(IReadOnlyList rhinoObjects, IReadOnlyList groups) + { RhinoDoc.ActiveDoc.Objects.UnselectAll(); + List rhinoObjectsToSelect = new(rhinoObjects); - if (rhinoObjects.Count == 0) + foreach (Group group in groups) { - Commands.SetModelError(modelCardId, new OperationCanceledException("No objects found to highlight.")); - return; + int groupIndex = RhinoDoc.ActiveDoc.Groups.Find(group.Name); + if (groupIndex < 0) + { + continue; + } + var allRhinoObjects = RhinoDoc.ActiveDoc.Objects.GetObjectList(ObjectType.AnyObject); + var subRhinoObjects = allRhinoObjects.Where(o => o.GetGroupList().Contains(groupIndex)); + rhinoObjectsToSelect.AddRange(subRhinoObjects); } - - RhinoDoc.ActiveDoc.Objects.Select(rhinoObjects.Select(o => o.Id)); + RhinoDoc.ActiveDoc.Objects.Select(rhinoObjectsToSelect.Select(o => o.Id)); // Calculate the bounding box of the selected objects - BoundingBox boundingBox = BoundingBoxExtensions.UnionRhinoObjects(rhinoObjects); + BoundingBox boundingBox = BoundingBoxExtensions.UnionRhinoObjects(rhinoObjectsToSelect); // Zoom to the calculated bounding box if (boundingBox.IsValid) diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoReceiveBinding.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoReceiveBinding.cs index 2373bc69ad..5b27b6b69e 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoReceiveBinding.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoReceiveBinding.cs @@ -4,6 +4,7 @@ using Speckle.Connectors.DUI.Models; using Speckle.Connectors.DUI.Models.Card; using Speckle.Connectors.Utils; +using Speckle.Connectors.Utils.Builders; using Speckle.Connectors.Utils.Cancellation; using Speckle.Connectors.Utils.Operations; @@ -51,7 +52,7 @@ public async Task Receive(string modelCardId) CancellationTokenSource cts = CancellationManager.InitCancellationTokenSource(modelCardId); // Receive host objects - IEnumerable receivedObjectIds = await unitOfWork.Service + HostObjectBuilderResult conversionResults = await unitOfWork.Service .Execute( modelCard.AccountId.NotNull(), // POC: I hear -you are saying why we're passing them separately. Not sure pass the DUI3-> Connectors.DUI project dependency to the SDK-> Connector.Utils modelCard.ProjectId.NotNull(), @@ -63,8 +64,12 @@ public async Task Receive(string modelCardId) ) .ConfigureAwait(false); - // POC: Here we can't set receive result if ReceiveOperation throws an error. - Commands.SetModelReceiveResult(modelCardId, receivedObjectIds.ToList()); + modelCard.BakedObjectIds = conversionResults.BakedObjectIds.ToList(); + Commands.SetModelReceiveResult( + modelCardId, + conversionResults.BakedObjectIds, + conversionResults.ConversionResults + ); } // Catch here specific exceptions if they related to model card. catch (OperationCanceledException) diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSendBinding.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSendBinding.cs index e609468020..e767b9c3cf 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSendBinding.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSendBinding.cs @@ -178,7 +178,7 @@ public async Task Send(string modelCardId) .ConfigureAwait(false); // Store the converted references in memory for future send operations, overwriting the existing values for the given application id. - foreach (var kvp in sendResult.convertedReferences) + foreach (var kvp in sendResult.ConvertedReferences) { _convertedObjectReferences[kvp.Key + modelCard.ProjectId] = kvp.Value; } @@ -186,7 +186,7 @@ public async Task Send(string modelCardId) // It's important to reset the model card's list of changed obj ids so as to ensure we accurately keep track of changes between send operations. modelCard.ChangedObjectIds = new(); - Commands.SetModelCreatedVersionId(modelCardId, sendResult.rootObjId); + Commands.SetModelSendResult(modelCardId, sendResult.RootObjId, sendResult.ConversionResults); } // Catch here specific exceptions if they related to model card. catch (SpeckleSendFilterException e) diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Receive/RhinoHostObjectBuilder.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Receive/RhinoHostObjectBuilder.cs index 7de29b7a57..26215d4464 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Receive/RhinoHostObjectBuilder.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Receive/RhinoHostObjectBuilder.cs @@ -2,6 +2,7 @@ using Rhino.DocObjects; using Rhino.Geometry; using Speckle.Connectors.Utils.Builders; +using Speckle.Connectors.Utils.Conversion; using Speckle.Converters.Common; using Speckle.Core.Logging; using Speckle.Core.Models; @@ -26,7 +27,7 @@ GraphTraversal traverseFunction _traverseFunction = traverseFunction; } - public IEnumerable Build( + public HostObjectBuilderResult Build( Base rootObject, string projectName, string modelName, @@ -38,25 +39,18 @@ CancellationToken cancellationToken var baseLayerName = $"Project {projectName}: Model {modelName}"; var objectsToConvert = _traverseFunction - .Traverse(rootObject) - .Where(obj => obj.Current is not Collection) - .Select(ctx => (GetLayerPath(ctx), ctx.Current)) - .ToArray(); + .TraverseWithProgress(rootObject, onOperationProgressed, cancellationToken) + .Where(obj => obj.Current is not Collection); - var convertedIds = BakeObjects(objectsToConvert, baseLayerName, onOperationProgressed, cancellationToken); + var conversionResults = BakeObjects(objectsToConvert, baseLayerName); _contextStack.Current.Document.Views.Redraw(); - return convertedIds; + return conversionResults; } // POC: Potentially refactor out into an IObjectBaker. - private List BakeObjects( - IReadOnlyCollection<(string[], Base)> objects, - string baseLayerName, - Action? onOperationProgressed, - CancellationToken cancellationToken - ) + private HostObjectBuilderResult BakeObjects(IEnumerable objectsGraph, string baseLayerName) { RhinoDoc doc = _contextStack.Current.Document; var rootLayerIndex = _contextStack.Current.Document.Layers.Find(Guid.Empty, baseLayerName, RhinoMath.UnsetIntIndex); @@ -85,48 +79,38 @@ CancellationToken cancellationToken rootLayerIndex = doc.Layers.Add(new Layer { Name = baseLayerName }); cache.Add(baseLayerName, rootLayerIndex); - var newObjectIds = new List(); - var count = 0; - - // POC: We delay throwing conversion exceptions until the end of the conversion loop, then throw all within an aggregate exception if something happened. - var conversionExceptions = new List(); - using var noDraw = new DisableRedrawScope(doc.Views); - foreach ((string[] path, Base baseObj) in objects) + var conversionResults = new List(); + var bakedObjectIds = new List(); + + foreach (TraversalContext tc in objectsGraph) { try { - cancellationToken.ThrowIfCancellationRequested(); + var path = GetLayerPath(tc); var fullLayerName = string.Join(Layer.PathSeparator, path); var layerIndex = cache.TryGetValue(fullLayerName, out int value) ? value : GetAndCreateLayerFromPath(path, baseLayerName, cache); - onOperationProgressed?.Invoke("Converting & creating objects", (double)++count / objects.Count); + var result = _converter.Convert(tc.Current); - var result = _converter.Convert(baseObj); - - var conversionIds = HandleConversionResult(result, baseObj, layerIndex); - newObjectIds.AddRange(conversionIds); - } - catch (OperationCanceledException) - { - throw; + var conversionIds = HandleConversionResult(result, tc.Current, layerIndex); + foreach (var r in conversionIds) + { + conversionResults.Add(new(Status.SUCCESS, tc.Current, r, result.GetType().ToString())); + bakedObjectIds.Add(r); + } } - catch (Exception e) when (!e.IsFatal()) + catch (Exception ex) when (!ex.IsFatal()) { - conversionExceptions.Add(e); + conversionResults.Add(new(Status.ERROR, tc.Current, null, null, ex)); } } - if (conversionExceptions.Count != 0) - { - throw new AggregateException("Conversion failed for some objects.", conversionExceptions); - } - - return newObjectIds; + return new(bakedObjectIds, conversionResults); } private IReadOnlyList HandleConversionResult(object conversionResult, Base originalObject, int layerIndex) diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Send/RhinoRootObjectBuilder.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Send/RhinoRootObjectBuilder.cs index 5f1020556c..cfb94ca620 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Send/RhinoRootObjectBuilder.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Send/RhinoRootObjectBuilder.cs @@ -5,7 +5,9 @@ using Speckle.Converters.Common; using Speckle.Connectors.DUI.Models.Card.SendFilter; using Speckle.Connectors.Utils.Builders; +using Speckle.Connectors.Utils.Conversion; using Speckle.Connectors.Utils.Operations; +using Speckle.Core.Logging; namespace Speckle.Connectors.Rhino7.Operations.Send; @@ -21,14 +23,14 @@ public RhinoRootObjectBuilder(IUnitOfWorkFactory unitOfWorkFactory) _unitOfWorkFactory = unitOfWorkFactory; } - public Base Build( + public RootObjectBuilderResult Build( IReadOnlyList objects, SendInfo sendInfo, Action? onOperationProgressed = null, CancellationToken ct = default ) => ConvertObjects(objects, sendInfo, onOperationProgressed, ct); - private Collection ConvertObjects( + private RootObjectBuilderResult ConvertObjects( IReadOnlyList rhinoObjects, SendInfo sendInfo, Action? onOperationProgressed = null, @@ -43,9 +45,10 @@ private Collection ConvertObjects( var rootObjectCollection = new Collection { name = RhinoDoc.ActiveDoc.Name ?? "Unnamed document" }; int count = 0; - Dictionary layerCollectionCache = new(); // POC: This seems to always start empty, so it's not caching anything out here. + Dictionary layerCollectionCache = new(); // POC: Handle blocks. + List results = new(rhinoObjects.Count); foreach (RhinoObject rhinoObject in rhinoObjects) { cancellationToken.ThrowIfCancellationRequested(); @@ -59,7 +62,6 @@ private Collection ConvertObjects( try { // get from cache or convert: - // POC: We're not using the cache here yet but should once the POC is working. // What we actually do here is check if the object has been previously converted AND has not changed. // If that's the case, we insert in the host collection just its object reference which has been saved from the prior conversion. Base converted; @@ -78,26 +80,22 @@ private Collection ConvertObjects( // add to host collectionHost.elements.Add(converted); - onOperationProgressed?.Invoke("Converting", (double)++count / rhinoObjects.Count); - } - // POC: Exception handling on conversion logic must be revisited after several connectors have working conversions - catch (SpeckleConversionException e) - { - // POC: DO something with the exception - Console.WriteLine(e); + + results.Add(new(Status.SUCCESS, applicationId, rhinoObject.ObjectType.ToString(), converted)); } - catch (NotSupportedException e) + catch (Exception ex) when (!ex.IsFatal()) { - // POC: DO something with the exception - Console.WriteLine(e); + results.Add(new(Status.ERROR, applicationId, rhinoObject.ObjectType.ToString(), null, ex)); } + onOperationProgressed?.Invoke("Converting", (double)++count / rhinoObjects.Count); + // NOTE: useful for testing ui states, pls keep for now so we can easily uncomment // Thread.Sleep(550); } // 5. profit - return rootObjectCollection; + return new(rootObjectCollection, results); } /// diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/ArcGISProjectUtils.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/ArcGISProjectUtils.cs new file mode 100644 index 0000000000..e69de29bb2 diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/IBasicConnectorBinding.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/IBasicConnectorBinding.cs index d711b1e016..2ac4dcb62e 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/IBasicConnectorBinding.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/IBasicConnectorBinding.cs @@ -21,6 +21,8 @@ public interface IBasicConnectorBinding : IBinding /// public void HighlightModel(string modelCardId); + public void HighlightObjects(List objectIds); + public BasicConnectorBindingCommands Commands { get; } } diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/ReceiveBindingUICommands.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/ReceiveBindingUICommands.cs index c64cdac40f..62bcc2813d 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/ReceiveBindingUICommands.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/ReceiveBindingUICommands.cs @@ -1,5 +1,5 @@ using Speckle.Connectors.DUI.Bridge; -using Speckle.Connectors.DUI.Models.Card; +using Speckle.Connectors.Utils.Conversion; namespace Speckle.Connectors.DUI.Bindings; @@ -11,14 +11,20 @@ public class ReceiveBindingUICommands : BasicConnectorBindingCommands public ReceiveBindingUICommands(IBridge bridge) : base(bridge) { } - public void SetModelReceiveResult(string modelCardId, List bakedObjectIds) + public void SetModelReceiveResult( + string modelCardId, + IEnumerable bakedObjectIds, + IEnumerable conversionResults + ) { - ReceiverModelCardResult res = - new() + Bridge.Send( + SET_MODEL_RECEIVE_RESULT_UI_COMMAND_NAME, + new { ModelCardId = modelCardId, - ReceiveResult = new ReceiveResult() { BakedObjectIds = bakedObjectIds } - }; - Bridge.Send(SET_MODEL_RECEIVE_RESULT_UI_COMMAND_NAME, res); + bakedObjectIds, + conversionResults + } + ); } } diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/SendBindingUICommands.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/SendBindingUICommands.cs index 9580413088..7652fe9e5a 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/SendBindingUICommands.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/SendBindingUICommands.cs @@ -1,4 +1,5 @@ using Speckle.Connectors.DUI.Bridge; +using Speckle.Connectors.Utils.Conversion; namespace Speckle.Connectors.DUI.Bindings; @@ -7,7 +8,7 @@ public class SendBindingUICommands : BasicConnectorBindingCommands { private const string REFRESH_SEND_FILTERS_UI_COMMAND_NAME = "refreshSendFilters"; private const string SET_MODELS_EXPIRED_UI_COMMAND_NAME = "setModelsExpired"; - private const string SET_MODEL_CREATED_VERSION_ID_UI_COMMAND_NAME = "setModelCreatedVersionId"; + private const string SET_MODEL_SEND_RESULT_UI_COMMAND_NAME = "setModelSendResult"; public SendBindingUICommands(IBridge bridge) : base(bridge) { } @@ -18,6 +19,18 @@ public SendBindingUICommands(IBridge bridge) public void SetModelsExpired(IEnumerable expiredModelIds) => Bridge.Send(SET_MODELS_EXPIRED_UI_COMMAND_NAME, expiredModelIds); - public void SetModelCreatedVersionId(string modelCardId, string versionId) => - Bridge.Send(SET_MODEL_CREATED_VERSION_ID_UI_COMMAND_NAME, new { modelCardId, versionId }); + public void SetModelSendResult( + string modelCardId, + string versionId, + IEnumerable sendConversionResults + ) => + Bridge.Send( + SET_MODEL_SEND_RESULT_UI_COMMAND_NAME, + new + { + modelCardId, + versionId, + sendConversionResults + } + ); } diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/SyncToCurrentThread.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/SyncToCurrentThread.cs index 8896771bd0..820d49fd0c 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/SyncToCurrentThread.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/SyncToCurrentThread.cs @@ -3,7 +3,7 @@ namespace Speckle.Connectors.DUI.Bridge; /// -/// Implements the ISyncToMainThread interface and runs a given function on the current thread using Task.Run. +/// Implements the interface and runs a given function on the current thread using Task.Run. /// public class SyncToCurrentThread : ISyncToThread { diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/ReceiveResult.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/ReceiveResult.cs index 81431dafb2..c4473e7f38 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/ReceiveResult.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/ReceiveResult.cs @@ -1,7 +1,5 @@ -namespace Speckle.Connectors.DUI.Models.Card; - -public class ReceiveResult -{ - public List? BakedObjectIds { get; set; } - public bool Display { get; set; } -} +// using Speckle.Connectors.Utils.Builders; +// +// namespace Speckle.Connectors.DUI.Models.Card; +// +// public record ReceiveResult(bool Display, HostObjectBuilderResult ReceiveConversionResults); diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/ReceiverModelCard.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/ReceiverModelCard.cs index 5b69884618..143a646709 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/ReceiverModelCard.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/ReceiverModelCard.cs @@ -7,5 +7,5 @@ public class ReceiverModelCard : ModelCard public string? SelectedVersionId { get; set; } public string? LatestVersionId { get; set; } public bool HasDismissedUpdateWarning { get; set; } - public ReceiveResult? ReceiveResult { get; set; } + public List? BakedObjectIds { get; set; } } diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/ReceiverModelCardResult.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/ReceiverModelCardResult.cs index 161cbe4b66..a1bb275dd0 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/ReceiverModelCardResult.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/ReceiverModelCardResult.cs @@ -3,5 +3,5 @@ namespace Speckle.Connectors.DUI.Models.Card; public class ReceiverModelCardResult { public string? ModelCardId { get; set; } - public ReceiveResult? ReceiveResult { get; set; } + public List BakedObjectIds { get; set; } = new(); } diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Utils/DiscriminatedObjectConverter.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Utils/DiscriminatedObjectConverter.cs index 079a7060f1..2d1dfedf8f 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Utils/DiscriminatedObjectConverter.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Utils/DiscriminatedObjectConverter.cs @@ -52,7 +52,7 @@ JsonSerializer serializer ?? throw new SpeckleDeserializeException( "DUI3 Discriminator converter deserialization failed, type not found: " + typeName ); - var obj = Activator.CreateInstance(type); + var obj = Activator.CreateInstance(type, true); serializer.Populate(jsonObject.CreateReader(), obj); // Store the JSON property names in the object for later comparison @@ -101,6 +101,7 @@ JsonSerializer serializer // the call above is causing load of all assemblies (which is also possibly not good) // AND it explodes for me loading an exception, so at the last this should // catch System.Reflection.ReflectionTypeLoadException (and anthing else DefinedTypes might throw) + // LATER COMMENT: Since discriminated object is only used in DUI3 models, we could restrict to only "this" assembly? catch (ReflectionTypeLoadException ex) { // POC: logging diff --git a/DUI3-DX/Sdk/Speckle.Connectors.Utils/Builders/IHostObjectBuilder.cs b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Builders/IHostObjectBuilder.cs index aedb5887a6..853b2b3ba4 100644 --- a/DUI3-DX/Sdk/Speckle.Connectors.Utils/Builders/IHostObjectBuilder.cs +++ b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Builders/IHostObjectBuilder.cs @@ -1,4 +1,5 @@ -using Speckle.Core.Models; +using Speckle.Connectors.Utils.Conversion; +using Speckle.Core.Models; namespace Speckle.Connectors.Utils.Builders; @@ -16,7 +17,7 @@ public interface IHostObjectBuilder /// List of application ids. // POC: Where we will return these ids will matter later when we target to also cache received application ids. /// Project and model name are needed for now to construct host app objects into related layers or filters. /// POC: we might consider later to have HostObjectBuilderContext? that might hold all possible data we will need. - IEnumerable Build( + HostObjectBuilderResult Build( Base rootObject, string projectName, string modelName, @@ -24,3 +25,8 @@ IEnumerable Build( CancellationToken cancellationToken ); } + +public record HostObjectBuilderResult( + IEnumerable BakedObjectIds, + IEnumerable ConversionResults +); diff --git a/DUI3-DX/Sdk/Speckle.Connectors.Utils/Builders/IRootObjectBuilder.cs b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Builders/IRootObjectBuilder.cs index 802272f92c..bdf9fdf2a5 100644 --- a/DUI3-DX/Sdk/Speckle.Connectors.Utils/Builders/IRootObjectBuilder.cs +++ b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Builders/IRootObjectBuilder.cs @@ -1,14 +1,17 @@ -using Speckle.Connectors.Utils.Operations; +using Speckle.Connectors.Utils.Conversion; +using Speckle.Connectors.Utils.Operations; using Speckle.Core.Models; namespace Speckle.Connectors.Utils.Builders; -public interface IRootObjectBuilder +public interface IRootObjectBuilder { - public Base Build( + public RootObjectBuilderResult Build( IReadOnlyList objects, SendInfo sendInfo, Action? onOperationProgressed = null, CancellationToken ct = default ); } + +public record RootObjectBuilderResult(Base RootObject, IEnumerable ConversionResults); diff --git a/DUI3-DX/Sdk/Speckle.Connectors.Utils/Builders/TraversalExtensions.cs b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Builders/TraversalExtensions.cs new file mode 100644 index 0000000000..56df5701f7 --- /dev/null +++ b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Builders/TraversalExtensions.cs @@ -0,0 +1,26 @@ +using Speckle.Core.Models; +using Speckle.Core.Models.GraphTraversal; + +namespace Speckle.Connectors.Utils.Builders; + +public static class TraversalExtensions +{ + public static IEnumerable TraverseWithProgress( + this GraphTraversal traversalFunction, + Base rootObject, + Action? onOperationProgressed, + CancellationToken cancellationToken = default + ) + { + var traversalGraph = traversalFunction.Traverse(rootObject).ToArray(); + int count = 0; + foreach (var tc in traversalGraph) + { + cancellationToken.ThrowIfCancellationRequested(); + + yield return tc; + + onOperationProgressed?.Invoke("Converting", (double)++count / traversalGraph.Length); + } + } +} diff --git a/DUI3-DX/Sdk/Speckle.Connectors.Utils/Conversion/ReportResult.cs b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Conversion/ReportResult.cs new file mode 100644 index 0000000000..2cd6606b3d --- /dev/null +++ b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Conversion/ReportResult.cs @@ -0,0 +1,112 @@ +using Speckle.Core.Models; + +namespace Speckle.Connectors.Utils.Conversion; + +public class Report : Base +{ + public required IEnumerable ConversionResults { get; set; } +} + +public enum Status +{ + NONE = 0, // Do not fucking use + SUCCESS = 1, + INFO = 2, // Not in use yet, maybe later as discussed + WARNING = 3, // Not in use yet, maybe later as discussed + ERROR = 4 +} + +public class SendConversionResult : ConversionResult +{ + public SendConversionResult( + Status status, + string sourceId, + string sourceType, + Base? result = null, + Exception? exception = null + ) + { + Status = status; + SourceId = sourceId; + SourceType = sourceType; + ResultId = result?.id; + ResultType = result?.speckle_type; + if (exception is not null) + { + Error = new ErrorWrapper() { Message = exception.Message, StackTrace = exception.StackTrace }; + } + } +} + +public class ReceiveConversionResult : ConversionResult +{ + public ReceiveConversionResult( + Status status, + Base source, + string? resultId = null, + string? resultType = null, + Exception? exception = null + ) + { + Status = status; + SourceId = source.id; + SourceType = source.speckle_type; // Note: we'll parse it nicely in FE + ResultId = resultId; + ResultType = resultType; + if (exception is not null) + { + Error = new ErrorWrapper() { Message = exception.Message, StackTrace = exception.StackTrace }; + } + } +} + +/// +/// Base class for which we inherit send or receive conversion results. Note, the properties Source* and Result* swap meaning if they are a +/// send conversion result or a receive conversion result - but i do not believe this requires fully separate classes, especially +/// for what this is meant to be at its core: a list of green or red checkmarks in the UI. To make DX easier, the two classes above embody +/// this one and provided clean constructors for each case. +/// POC: Inherits from Base so we can attach the conversion report to the root commit object. Can be revisited later (it's not a problem to not inherit from base). +/// +public abstract class ConversionResult : Base +{ + public Status Status { get; init; } + + /// + /// For receive conversion reports, this is the id of the speckle object. For send, it's the host app object id. + /// + public string? SourceId { get; init; } + + /// + /// For receive conversion reports, this is the type of the speckle object. For send, it's the host app object type. + /// + public string? SourceType { get; init; } + + /// + /// For receive conversion reports, this is the id of the host app object. For send, it's the speckle object id. + /// + public string? ResultId { get; init; } + + /// + /// For receive conversion reports, this is the type of the host app object. For send, it's the speckle object type. + /// + public string? ResultType { get; init; } + + /// + /// The exception, if any. + /// + public ErrorWrapper? Error { get; init; } + + // /// + // /// Makes it easy for the FE to discriminate (against report types, not people). + // /// + // public string Type => this.GetType().ToString(); +} + +/// +/// Wraps around exceptions to make them nicely serializable for the ui. +/// +public class ErrorWrapper : Base +{ + public required string Message { get; set; } + public required string StackTrace { get; set; } +}; diff --git a/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/ReceiveOperation.cs b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/ReceiveOperation.cs index dcf56c1a53..a93a2c61f7 100644 --- a/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/ReceiveOperation.cs +++ b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/ReceiveOperation.cs @@ -17,7 +17,7 @@ public ReceiveOperation(IHostObjectBuilder hostObjectBuilder, ISyncToThread sync _syncToThread = syncToThread; } - public async Task> Execute( + public async Task Execute( string accountId, // POC: all these string arguments exists in ModelCard but not sure to pass this dependency here, TBD! string projectId, string projectName, diff --git a/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/SendOperation.cs b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/SendOperation.cs index 38f1a5dedc..c7ae1f458e 100644 --- a/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/SendOperation.cs +++ b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/SendOperation.cs @@ -1,4 +1,5 @@ using Speckle.Connectors.Utils.Builders; +using Speckle.Connectors.Utils.Conversion; using Speckle.Core.Models; namespace Speckle.Connectors.Utils.Operations; @@ -20,19 +21,32 @@ ISyncToThread syncToThread _syncToThread = syncToThread; } - public async Task<(string rootObjId, Dictionary convertedReferences)> Execute( + public async Task Execute( IReadOnlyList objects, SendInfo sendInfo, Action? onOperationProgressed = null, CancellationToken ct = default ) { - Base commitObject = await _syncToThread + var buildResult = await _syncToThread .RunOnThread(() => _rootObjectBuilder.Build(objects, sendInfo, onOperationProgressed, ct)) .ConfigureAwait(false); - // base object handler is separated so we can do some testing on non-production databases + // POC: Jonathon asks on behalf of willow twin - let's explore how this can work + buildResult.RootObject["@report"] = new Report { ConversionResults = buildResult.ConversionResults }; + + // base object handler is separated, so we can do some testing on non-production databases // exact interface may want to be tweaked when we implement this - return await _baseObjectSender.Send(commitObject, sendInfo, onOperationProgressed, ct).ConfigureAwait(false); + var (rootObjId, convertedReferences) = await _baseObjectSender + .Send(buildResult.RootObject, sendInfo, onOperationProgressed, ct) + .ConfigureAwait(false); + + return new(rootObjId, convertedReferences, buildResult.ConversionResults); } } + +public record SendOperationResult( + string RootObjId, + IReadOnlyDictionary ConvertedReferences, + IEnumerable ConversionResults +); diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/ToHost/ConverterWithFallback.cs b/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/ToHost/ConverterWithFallback.cs index d20f915ba9..9d972cdd99 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/ToHost/ConverterWithFallback.cs +++ b/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/ToHost/ConverterWithFallback.cs @@ -14,12 +14,10 @@ namespace Speckle.Converters.Common.DependencyInjection.ToHost; /// public sealed class ConverterWithFallback : IRootToHostConverter { - private readonly IConverterResolver _toHost; private readonly ConverterWithoutFallback _baseConverter; public ConverterWithFallback(IConverterResolver toHost) { - _toHost = toHost; _baseConverter = new ConverterWithoutFallback(toHost); } @@ -31,7 +29,7 @@ public ConverterWithFallback(IConverterResolver toHost /// Fallbacks to display value if a direct conversion is not possible. /// /// The conversion is done in the following order of preference: - /// 1. Direct conversion using the method. + /// 1. Direct conversion using the . /// 2. Fallback to display value using the method, if a direct conversion is not possible. /// /// If the direct conversion is not available and there is no displayValue, a is thrown. @@ -39,12 +37,12 @@ public ConverterWithFallback(IConverterResolver toHost /// Thrown when no conversion is found for . public object Convert(Base target) { - var typeName = target.GetType().Name; + Type type = target.GetType(); // Direct conversion if a converter is found - if (_baseConverter.TryConvert(target, out object? result)) + if (_baseConverter.TryGetConverter(type, out IToHostTopLevelConverter? result)) { - return result; + return result.Convert(target); } // Fallback to display value if it exists. @@ -54,24 +52,13 @@ public object Convert(Base target) return FallbackToDisplayValue(displayValue); } - // Throw instead of null-return! - throw new NotSupportedException($"No conversion found for {typeName}"); + throw new NotSupportedException($"No conversion found for {type}"); } private object FallbackToDisplayValue(IReadOnlyList displayValue) { - // Create a temp Displayable object that handles the displayValue. var tempDisplayableObject = new DisplayableObject(displayValue); - var displayableObjectConverter = _toHost.GetConversionForType(typeof(DisplayableObject)); - - // It is not guaranteed that a fallback converter has been registered in all connectors - if (displayableObjectConverter == null) - { - throw new InvalidOperationException("No converter for fallback displayable objects was found."); - } - - // Run the conversion, which will (or could?) return an `IEnumerable`. We don't care at this point, connector will. - return displayableObjectConverter.Convert(tempDisplayableObject); + return _baseConverter.Convert(tempDisplayableObject); } } diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/ToHost/ConverterWithoutFallback.cs b/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/ToHost/ConverterWithoutFallback.cs index c6b24fff40..c2ec1bd9e3 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/ToHost/ConverterWithoutFallback.cs +++ b/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/ToHost/ConverterWithoutFallback.cs @@ -21,20 +21,22 @@ public ConverterWithoutFallback(IConverterResolver con public object Convert(Base target) { - if (TryConvert(target, out object? result)) + if (!TryGetConverter(target.GetType(), out IToHostTopLevelConverter? converter)) { - return result; + throw new NotSupportedException($"No conversion found for {target.GetType()}"); } - throw new NotSupportedException($"No conversion found for {target.GetType()}"); + + object result = converter.Convert(target); + return result; } - internal bool TryConvert(Base target, [NotNullWhen(true)] out object? result) + internal bool TryGetConverter(Type target, [NotNullWhen(true)] out IToHostTopLevelConverter? result) { // Direct conversion if a converter is found - var objectConverter = _toHost.GetConversionForType(target.GetType()); + var objectConverter = _toHost.GetConversionForType(target); if (objectConverter != null) { - result = objectConverter.Convert(target); + result = objectConverter; return true; } From 1d305c78578041d6f56e407a6d85c4df7a393463 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?O=C4=9Fuzhan=20Koral?= <45078678+oguzhankoral@users.noreply.github.com> Date: Thu, 6 Jun 2024 19:14:47 +0300 Subject: [PATCH 218/261] Use Map on GetDocumentInfo instead Project (#3484) --- .../Bindings/BasicConnectorBinding.cs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/BasicConnectorBinding.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/BasicConnectorBinding.cs index b49d2a77f2..bfa36dfc87 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/BasicConnectorBinding.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/BasicConnectorBinding.cs @@ -1,5 +1,4 @@ using System.Reflection; -using ArcGIS.Desktop.Core; using ArcGIS.Desktop.Framework.Threading.Tasks; using ArcGIS.Desktop.Mapping; using Speckle.Connectors.ArcGIS.HostApp; @@ -41,7 +40,15 @@ public BasicConnectorBinding(DocumentModelStore store, ArcGISSettings settings, public string GetConnectorVersion() => Assembly.GetAssembly(GetType()).NotNull().GetVersion(); - public DocumentInfo GetDocumentInfo() => new(Project.Current.URI, Project.Current.Name, Project.Current.Name); + public DocumentInfo? GetDocumentInfo() + { + if (MapView.Active is null) + { + return null; + } + + return new DocumentInfo(MapView.Active.Map.URI, MapView.Active.Map.Name, MapView.Active.Map.Name); + } public DocumentModelStore GetDocumentState() => _store; From 78ee21b514e6777cc01c9581eeb7865b11ea8edd Mon Sep 17 00:00:00 2001 From: Jedd Morgan <45512892+JR-Morgan@users.noreply.github.com> Date: Thu, 6 Jun 2024 18:17:56 +0100 Subject: [PATCH 219/261] Update global.json to 8.0.200 + rollForward patch versions only (#3485) * rollPatch NET version * Roll to 8.0.100 * 200 channel * Fix for rhino mac * 204 magic * Roll forward with security patches --- .circleci/scripts/config-template.yml | 2 +- .github/workflows/ci.yml | 2 +- global.json | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.circleci/scripts/config-template.yml b/.circleci/scripts/config-template.yml index f64173dbb2..15f6b5918f 100644 --- a/.circleci/scripts/config-template.yml +++ b/.circleci/scripts/config-template.yml @@ -420,7 +420,7 @@ jobs: # Each project will have individual jobs for each specific task it has to build-connector-dotnet-mac: docker: - - image: mcr.microsoft.com/dotnet/sdk:7.0 + - image: mcr.microsoft.com/dotnet/sdk:8.0.204 parameters: slnname: type: string diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b2b7682d3f..ed038082f1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -24,7 +24,7 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v4 with: - dotnet-version: 7.x.x + dotnet-version: 8.0.2xx # Align with global.json (including roll forward rules) - name: ⚒️ Run GitVersion run: ./build.ps1 build-server-version diff --git a/global.json b/global.json index 08f229ce09..c09ced8c12 100644 --- a/global.json +++ b/global.json @@ -1,7 +1,7 @@ { "sdk": { - "version": "7.0.0", - "rollForward": "latestMajor", + "version": "8.0.200", + "rollForward": "latestPatch", "allowPrerelease": false } } From f57d2852a5a94e8b15bf576b6b1ed1e215805c84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?O=C4=9Fuzhan=20Koral?= <45078678+oguzhankoral@users.noreply.github.com> Date: Thu, 6 Jun 2024 23:16:08 +0300 Subject: [PATCH 220/261] Do not catch speckle exception at top (#3488) * Do not throw SpeckleException from UnitOfWorkFactory * Do not catch SpeckleException at the top --- .../Speckle.Connectors.DUI/Bridge/BrowserBridge.cs | 11 +---------- .../DependencyInjection/UnitOfWorkFactory.cs | 6 ++++-- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/BrowserBridge.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/BrowserBridge.cs index 6351021645..2c27fccc38 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/BrowserBridge.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/BrowserBridge.cs @@ -236,16 +236,7 @@ private void ExecuteMethod(string methodName, string requestId, string args) NotifyUIMethodCallResultReady(requestId, resultJson); } - catch (SpeckleException e) - { - // TODO: properly log the exeception. - var serializedError = JsonConvert.SerializeObject( - new { Error = e.Message, InnerError = e.InnerException?.Message }, - _serializerOptions - ); - - NotifyUIMethodCallResultReady(requestId, serializedError); - } + // TOP-LEVEL: Where we report unhandled exceptions as global toast notification in UI! catch (Exception e) when (!e.IsFatal()) { ReportUnhandledError(requestId, e); diff --git a/DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/UnitOfWorkFactory.cs b/DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/UnitOfWorkFactory.cs index 295519d8ef..bbd8deb59d 100644 --- a/DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/UnitOfWorkFactory.cs +++ b/DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/UnitOfWorkFactory.cs @@ -1,7 +1,6 @@ using Autofac; using Autofac.Core; using Speckle.InterfaceGenerator; -using Speckle.Core.Logging; namespace Speckle.Autofac.DependencyInjection; @@ -32,7 +31,10 @@ public IUnitOfWork Resolve() childScope?.Dispose(); // POC: check exception and how to pass this further up - throw new SpeckleException($"Dependency error resolving {typeof(TService)} within UnitOfWorkFactory", dre); + throw new DependencyResolutionException( + $"Dependency error resolving {typeof(TService)} within UnitOfWorkFactory", + dre + ); } } } From 1b5e8349d201a43936da2319de634e74b0fce21c Mon Sep 17 00:00:00 2001 From: Jedd Morgan <45512892+JR-Morgan@users.noreply.github.com> Date: Fri, 7 Jun 2024 15:26:33 +0100 Subject: [PATCH 221/261] Bump interface gen (#3493) Bumped interface generator --- All.sln | 247 +++++++++++++++++----------------- DUI3-DX/Directory.Build.Props | 2 +- 2 files changed, 122 insertions(+), 127 deletions(-) diff --git a/All.sln b/All.sln index ab1b3af2c6..eb6cd8b14a 100644 --- a/All.sln +++ b/All.sln @@ -530,7 +530,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Speckle.Connectors.DUI.WebV EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Build", "Build", "{326ECEE0-D009-4A65-B24C-00FA343D8B99}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Build", "Build\Build.csproj", "{3973D572-5E24-476F-B058-8022D826B793}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Build", "Build\Build.csproj", "{3973D572-5E24-476F-B058-8022D826B793}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Workflows", "Workflows", "{2AB6B848-E8F6-4BB7-AE8F-9913C74C893F}" ProjectSection(SolutionItems) = preProject @@ -2371,118 +2371,6 @@ Global {0D23858F-4CC1-4DCA-9207-5EDB8B6CE9DD}.Release|Any CPU.Build.0 = Release|Any CPU {0D23858F-4CC1-4DCA-9207-5EDB8B6CE9DD}.Release|x64.ActiveCfg = Release|Any CPU {0D23858F-4CC1-4DCA-9207-5EDB8B6CE9DD}.Release|x64.Build.0 = Release|Any CPU - {7B02BACC-D9B6-4FFE-A450-7ECB5F71F209}.Debug Mac|Any CPU.ActiveCfg = Debug|Any CPU - {7B02BACC-D9B6-4FFE-A450-7ECB5F71F209}.Debug Mac|Any CPU.Build.0 = Debug|Any CPU - {7B02BACC-D9B6-4FFE-A450-7ECB5F71F209}.Debug Mac|x64.ActiveCfg = Debug|Any CPU - {7B02BACC-D9B6-4FFE-A450-7ECB5F71F209}.Debug Mac|x64.Build.0 = Debug|Any CPU - {7B02BACC-D9B6-4FFE-A450-7ECB5F71F209}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {7B02BACC-D9B6-4FFE-A450-7ECB5F71F209}.Debug|Any CPU.Build.0 = Debug|Any CPU - {7B02BACC-D9B6-4FFE-A450-7ECB5F71F209}.Debug|x64.ActiveCfg = Debug|Any CPU - {7B02BACC-D9B6-4FFE-A450-7ECB5F71F209}.Debug|x64.Build.0 = Debug|Any CPU - {7B02BACC-D9B6-4FFE-A450-7ECB5F71F209}.Release Mac|Any CPU.ActiveCfg = Release|Any CPU - {7B02BACC-D9B6-4FFE-A450-7ECB5F71F209}.Release Mac|Any CPU.Build.0 = Release|Any CPU - {7B02BACC-D9B6-4FFE-A450-7ECB5F71F209}.Release Mac|x64.ActiveCfg = Release|Any CPU - {7B02BACC-D9B6-4FFE-A450-7ECB5F71F209}.Release Mac|x64.Build.0 = Release|Any CPU - {7B02BACC-D9B6-4FFE-A450-7ECB5F71F209}.Release|Any CPU.ActiveCfg = Release|Any CPU - {7B02BACC-D9B6-4FFE-A450-7ECB5F71F209}.Release|Any CPU.Build.0 = Release|Any CPU - {7B02BACC-D9B6-4FFE-A450-7ECB5F71F209}.Release|x64.ActiveCfg = Release|Any CPU - {7B02BACC-D9B6-4FFE-A450-7ECB5F71F209}.Release|x64.Build.0 = Release|Any CPU - {D607BD0A-9F7F-4C3A-9B9C-FEAD6BA49C7C}.Debug Mac|Any CPU.ActiveCfg = Debug|Any CPU - {D607BD0A-9F7F-4C3A-9B9C-FEAD6BA49C7C}.Debug Mac|Any CPU.Build.0 = Debug|Any CPU - {D607BD0A-9F7F-4C3A-9B9C-FEAD6BA49C7C}.Debug Mac|x64.ActiveCfg = Debug|Any CPU - {D607BD0A-9F7F-4C3A-9B9C-FEAD6BA49C7C}.Debug Mac|x64.Build.0 = Debug|Any CPU - {D607BD0A-9F7F-4C3A-9B9C-FEAD6BA49C7C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {D607BD0A-9F7F-4C3A-9B9C-FEAD6BA49C7C}.Debug|Any CPU.Build.0 = Debug|Any CPU - {D607BD0A-9F7F-4C3A-9B9C-FEAD6BA49C7C}.Debug|x64.ActiveCfg = Debug|Any CPU - {D607BD0A-9F7F-4C3A-9B9C-FEAD6BA49C7C}.Debug|x64.Build.0 = Debug|Any CPU - {D607BD0A-9F7F-4C3A-9B9C-FEAD6BA49C7C}.Release Mac|Any CPU.ActiveCfg = Release|Any CPU - {D607BD0A-9F7F-4C3A-9B9C-FEAD6BA49C7C}.Release Mac|Any CPU.Build.0 = Release|Any CPU - {D607BD0A-9F7F-4C3A-9B9C-FEAD6BA49C7C}.Release Mac|x64.ActiveCfg = Release|Any CPU - {D607BD0A-9F7F-4C3A-9B9C-FEAD6BA49C7C}.Release Mac|x64.Build.0 = Release|Any CPU - {D607BD0A-9F7F-4C3A-9B9C-FEAD6BA49C7C}.Release|Any CPU.ActiveCfg = Release|Any CPU - {D607BD0A-9F7F-4C3A-9B9C-FEAD6BA49C7C}.Release|Any CPU.Build.0 = Release|Any CPU - {D607BD0A-9F7F-4C3A-9B9C-FEAD6BA49C7C}.Release|x64.ActiveCfg = Release|Any CPU - {D607BD0A-9F7F-4C3A-9B9C-FEAD6BA49C7C}.Release|x64.Build.0 = Release|Any CPU - {C0295BF9-9A40-4FCD-BE39-E943985CA3F8}.Debug Mac|Any CPU.ActiveCfg = Debug|Any CPU - {C0295BF9-9A40-4FCD-BE39-E943985CA3F8}.Debug Mac|Any CPU.Build.0 = Debug|Any CPU - {C0295BF9-9A40-4FCD-BE39-E943985CA3F8}.Debug Mac|x64.ActiveCfg = Debug|Any CPU - {C0295BF9-9A40-4FCD-BE39-E943985CA3F8}.Debug Mac|x64.Build.0 = Debug|Any CPU - {C0295BF9-9A40-4FCD-BE39-E943985CA3F8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {C0295BF9-9A40-4FCD-BE39-E943985CA3F8}.Debug|Any CPU.Build.0 = Debug|Any CPU - {C0295BF9-9A40-4FCD-BE39-E943985CA3F8}.Debug|x64.ActiveCfg = Debug|Any CPU - {C0295BF9-9A40-4FCD-BE39-E943985CA3F8}.Debug|x64.Build.0 = Debug|Any CPU - {C0295BF9-9A40-4FCD-BE39-E943985CA3F8}.Release Mac|Any CPU.ActiveCfg = Release|Any CPU - {C0295BF9-9A40-4FCD-BE39-E943985CA3F8}.Release Mac|Any CPU.Build.0 = Release|Any CPU - {C0295BF9-9A40-4FCD-BE39-E943985CA3F8}.Release Mac|x64.ActiveCfg = Release|Any CPU - {C0295BF9-9A40-4FCD-BE39-E943985CA3F8}.Release Mac|x64.Build.0 = Release|Any CPU - {C0295BF9-9A40-4FCD-BE39-E943985CA3F8}.Release|Any CPU.ActiveCfg = Release|Any CPU - {C0295BF9-9A40-4FCD-BE39-E943985CA3F8}.Release|Any CPU.Build.0 = Release|Any CPU - {C0295BF9-9A40-4FCD-BE39-E943985CA3F8}.Release|x64.ActiveCfg = Release|Any CPU - {C0295BF9-9A40-4FCD-BE39-E943985CA3F8}.Release|x64.Build.0 = Release|Any CPU - {42FE69BF-C821-43E8-8EAE-8F342749EF7A}.Debug Mac|Any CPU.ActiveCfg = Debug|Any CPU - {42FE69BF-C821-43E8-8EAE-8F342749EF7A}.Debug Mac|Any CPU.Build.0 = Debug|Any CPU - {42FE69BF-C821-43E8-8EAE-8F342749EF7A}.Debug Mac|x64.ActiveCfg = Debug|Any CPU - {42FE69BF-C821-43E8-8EAE-8F342749EF7A}.Debug Mac|x64.Build.0 = Debug|Any CPU - {42FE69BF-C821-43E8-8EAE-8F342749EF7A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {42FE69BF-C821-43E8-8EAE-8F342749EF7A}.Debug|Any CPU.Build.0 = Debug|Any CPU - {42FE69BF-C821-43E8-8EAE-8F342749EF7A}.Debug|x64.ActiveCfg = Debug|Any CPU - {42FE69BF-C821-43E8-8EAE-8F342749EF7A}.Debug|x64.Build.0 = Debug|Any CPU - {42FE69BF-C821-43E8-8EAE-8F342749EF7A}.Release Mac|Any CPU.ActiveCfg = Release|Any CPU - {42FE69BF-C821-43E8-8EAE-8F342749EF7A}.Release Mac|Any CPU.Build.0 = Release|Any CPU - {42FE69BF-C821-43E8-8EAE-8F342749EF7A}.Release Mac|x64.ActiveCfg = Release|Any CPU - {42FE69BF-C821-43E8-8EAE-8F342749EF7A}.Release Mac|x64.Build.0 = Release|Any CPU - {42FE69BF-C821-43E8-8EAE-8F342749EF7A}.Release|Any CPU.ActiveCfg = Release|Any CPU - {42FE69BF-C821-43E8-8EAE-8F342749EF7A}.Release|Any CPU.Build.0 = Release|Any CPU - {42FE69BF-C821-43E8-8EAE-8F342749EF7A}.Release|x64.ActiveCfg = Release|Any CPU - {42FE69BF-C821-43E8-8EAE-8F342749EF7A}.Release|x64.Build.0 = Release|Any CPU - {829688CD-CECE-4F6C-A5A0-032BB39CD9E0}.Debug Mac|Any CPU.ActiveCfg = Debug|Any CPU - {829688CD-CECE-4F6C-A5A0-032BB39CD9E0}.Debug Mac|Any CPU.Build.0 = Debug|Any CPU - {829688CD-CECE-4F6C-A5A0-032BB39CD9E0}.Debug Mac|x64.ActiveCfg = Debug|Any CPU - {829688CD-CECE-4F6C-A5A0-032BB39CD9E0}.Debug Mac|x64.Build.0 = Debug|Any CPU - {829688CD-CECE-4F6C-A5A0-032BB39CD9E0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {829688CD-CECE-4F6C-A5A0-032BB39CD9E0}.Debug|Any CPU.Build.0 = Debug|Any CPU - {829688CD-CECE-4F6C-A5A0-032BB39CD9E0}.Debug|x64.ActiveCfg = Debug|Any CPU - {829688CD-CECE-4F6C-A5A0-032BB39CD9E0}.Debug|x64.Build.0 = Debug|Any CPU - {829688CD-CECE-4F6C-A5A0-032BB39CD9E0}.Release Mac|Any CPU.ActiveCfg = Release|Any CPU - {829688CD-CECE-4F6C-A5A0-032BB39CD9E0}.Release Mac|Any CPU.Build.0 = Release|Any CPU - {829688CD-CECE-4F6C-A5A0-032BB39CD9E0}.Release Mac|x64.ActiveCfg = Release|Any CPU - {829688CD-CECE-4F6C-A5A0-032BB39CD9E0}.Release Mac|x64.Build.0 = Release|Any CPU - {829688CD-CECE-4F6C-A5A0-032BB39CD9E0}.Release|Any CPU.ActiveCfg = Release|Any CPU - {829688CD-CECE-4F6C-A5A0-032BB39CD9E0}.Release|Any CPU.Build.0 = Release|Any CPU - {829688CD-CECE-4F6C-A5A0-032BB39CD9E0}.Release|x64.ActiveCfg = Release|Any CPU - {829688CD-CECE-4F6C-A5A0-032BB39CD9E0}.Release|x64.Build.0 = Release|Any CPU - {70DEAA13-6DC8-44A0-B287-9E806A8054F1}.Debug Mac|Any CPU.ActiveCfg = Debug|Any CPU - {70DEAA13-6DC8-44A0-B287-9E806A8054F1}.Debug Mac|Any CPU.Build.0 = Debug|Any CPU - {70DEAA13-6DC8-44A0-B287-9E806A8054F1}.Debug Mac|x64.ActiveCfg = Debug|Any CPU - {70DEAA13-6DC8-44A0-B287-9E806A8054F1}.Debug Mac|x64.Build.0 = Debug|Any CPU - {70DEAA13-6DC8-44A0-B287-9E806A8054F1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {70DEAA13-6DC8-44A0-B287-9E806A8054F1}.Debug|Any CPU.Build.0 = Debug|Any CPU - {70DEAA13-6DC8-44A0-B287-9E806A8054F1}.Debug|x64.ActiveCfg = Debug|Any CPU - {70DEAA13-6DC8-44A0-B287-9E806A8054F1}.Debug|x64.Build.0 = Debug|Any CPU - {70DEAA13-6DC8-44A0-B287-9E806A8054F1}.Release Mac|Any CPU.ActiveCfg = Release|Any CPU - {70DEAA13-6DC8-44A0-B287-9E806A8054F1}.Release Mac|Any CPU.Build.0 = Release|Any CPU - {70DEAA13-6DC8-44A0-B287-9E806A8054F1}.Release Mac|x64.ActiveCfg = Release|Any CPU - {70DEAA13-6DC8-44A0-B287-9E806A8054F1}.Release Mac|x64.Build.0 = Release|Any CPU - {70DEAA13-6DC8-44A0-B287-9E806A8054F1}.Release|Any CPU.ActiveCfg = Release|Any CPU - {70DEAA13-6DC8-44A0-B287-9E806A8054F1}.Release|Any CPU.Build.0 = Release|Any CPU - {70DEAA13-6DC8-44A0-B287-9E806A8054F1}.Release|x64.ActiveCfg = Release|Any CPU - {70DEAA13-6DC8-44A0-B287-9E806A8054F1}.Release|x64.Build.0 = Release|Any CPU - {F06E4C37-4076-4272-9CA6-FB505E02CD31}.Debug Mac|Any CPU.ActiveCfg = Debug|Any CPU - {F06E4C37-4076-4272-9CA6-FB505E02CD31}.Debug Mac|Any CPU.Build.0 = Debug|Any CPU - {F06E4C37-4076-4272-9CA6-FB505E02CD31}.Debug Mac|x64.ActiveCfg = Debug|Any CPU - {F06E4C37-4076-4272-9CA6-FB505E02CD31}.Debug Mac|x64.Build.0 = Debug|Any CPU - {F06E4C37-4076-4272-9CA6-FB505E02CD31}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {F06E4C37-4076-4272-9CA6-FB505E02CD31}.Debug|Any CPU.Build.0 = Debug|Any CPU - {F06E4C37-4076-4272-9CA6-FB505E02CD31}.Debug|x64.ActiveCfg = Debug|Any CPU - {F06E4C37-4076-4272-9CA6-FB505E02CD31}.Debug|x64.Build.0 = Debug|Any CPU - {F06E4C37-4076-4272-9CA6-FB505E02CD31}.Release Mac|Any CPU.ActiveCfg = Release|Any CPU - {F06E4C37-4076-4272-9CA6-FB505E02CD31}.Release Mac|Any CPU.Build.0 = Release|Any CPU - {F06E4C37-4076-4272-9CA6-FB505E02CD31}.Release Mac|x64.ActiveCfg = Release|Any CPU - {F06E4C37-4076-4272-9CA6-FB505E02CD31}.Release Mac|x64.Build.0 = Release|Any CPU - {F06E4C37-4076-4272-9CA6-FB505E02CD31}.Release|Any CPU.ActiveCfg = Release|Any CPU - {F06E4C37-4076-4272-9CA6-FB505E02CD31}.Release|Any CPU.Build.0 = Release|Any CPU - {F06E4C37-4076-4272-9CA6-FB505E02CD31}.Release|x64.ActiveCfg = Release|Any CPU - {F06E4C37-4076-4272-9CA6-FB505E02CD31}.Release|x64.Build.0 = Release|Any CPU {01F98733-7352-47AD-A594-537D979DE3DE}.Debug Mac|Any CPU.ActiveCfg = Debug|Any CPU {01F98733-7352-47AD-A594-537D979DE3DE}.Debug Mac|Any CPU.Build.0 = Debug|Any CPU {01F98733-7352-47AD-A594-537D979DE3DE}.Debug Mac|x64.ActiveCfg = Debug|Any CPU @@ -2787,6 +2675,118 @@ Global {3973D572-5E24-476F-B058-8022D826B793}.Release|Any CPU.Build.0 = Release|Any CPU {3973D572-5E24-476F-B058-8022D826B793}.Release|x64.ActiveCfg = Release|Any CPU {3973D572-5E24-476F-B058-8022D826B793}.Release|x64.Build.0 = Release|Any CPU + {7B02BACC-D9B6-4FFE-A450-7ECB5F71F209}.Debug Mac|Any CPU.ActiveCfg = Debug|Any CPU + {7B02BACC-D9B6-4FFE-A450-7ECB5F71F209}.Debug Mac|Any CPU.Build.0 = Debug|Any CPU + {7B02BACC-D9B6-4FFE-A450-7ECB5F71F209}.Debug Mac|x64.ActiveCfg = Debug|Any CPU + {7B02BACC-D9B6-4FFE-A450-7ECB5F71F209}.Debug Mac|x64.Build.0 = Debug|Any CPU + {7B02BACC-D9B6-4FFE-A450-7ECB5F71F209}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7B02BACC-D9B6-4FFE-A450-7ECB5F71F209}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7B02BACC-D9B6-4FFE-A450-7ECB5F71F209}.Debug|x64.ActiveCfg = Debug|Any CPU + {7B02BACC-D9B6-4FFE-A450-7ECB5F71F209}.Debug|x64.Build.0 = Debug|Any CPU + {7B02BACC-D9B6-4FFE-A450-7ECB5F71F209}.Release Mac|Any CPU.ActiveCfg = Release|Any CPU + {7B02BACC-D9B6-4FFE-A450-7ECB5F71F209}.Release Mac|Any CPU.Build.0 = Release|Any CPU + {7B02BACC-D9B6-4FFE-A450-7ECB5F71F209}.Release Mac|x64.ActiveCfg = Release|Any CPU + {7B02BACC-D9B6-4FFE-A450-7ECB5F71F209}.Release Mac|x64.Build.0 = Release|Any CPU + {7B02BACC-D9B6-4FFE-A450-7ECB5F71F209}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7B02BACC-D9B6-4FFE-A450-7ECB5F71F209}.Release|Any CPU.Build.0 = Release|Any CPU + {7B02BACC-D9B6-4FFE-A450-7ECB5F71F209}.Release|x64.ActiveCfg = Release|Any CPU + {7B02BACC-D9B6-4FFE-A450-7ECB5F71F209}.Release|x64.Build.0 = Release|Any CPU + {D607BD0A-9F7F-4C3A-9B9C-FEAD6BA49C7C}.Debug Mac|Any CPU.ActiveCfg = Debug|Any CPU + {D607BD0A-9F7F-4C3A-9B9C-FEAD6BA49C7C}.Debug Mac|Any CPU.Build.0 = Debug|Any CPU + {D607BD0A-9F7F-4C3A-9B9C-FEAD6BA49C7C}.Debug Mac|x64.ActiveCfg = Debug|Any CPU + {D607BD0A-9F7F-4C3A-9B9C-FEAD6BA49C7C}.Debug Mac|x64.Build.0 = Debug|Any CPU + {D607BD0A-9F7F-4C3A-9B9C-FEAD6BA49C7C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D607BD0A-9F7F-4C3A-9B9C-FEAD6BA49C7C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D607BD0A-9F7F-4C3A-9B9C-FEAD6BA49C7C}.Debug|x64.ActiveCfg = Debug|Any CPU + {D607BD0A-9F7F-4C3A-9B9C-FEAD6BA49C7C}.Debug|x64.Build.0 = Debug|Any CPU + {D607BD0A-9F7F-4C3A-9B9C-FEAD6BA49C7C}.Release Mac|Any CPU.ActiveCfg = Release|Any CPU + {D607BD0A-9F7F-4C3A-9B9C-FEAD6BA49C7C}.Release Mac|Any CPU.Build.0 = Release|Any CPU + {D607BD0A-9F7F-4C3A-9B9C-FEAD6BA49C7C}.Release Mac|x64.ActiveCfg = Release|Any CPU + {D607BD0A-9F7F-4C3A-9B9C-FEAD6BA49C7C}.Release Mac|x64.Build.0 = Release|Any CPU + {D607BD0A-9F7F-4C3A-9B9C-FEAD6BA49C7C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D607BD0A-9F7F-4C3A-9B9C-FEAD6BA49C7C}.Release|Any CPU.Build.0 = Release|Any CPU + {D607BD0A-9F7F-4C3A-9B9C-FEAD6BA49C7C}.Release|x64.ActiveCfg = Release|Any CPU + {D607BD0A-9F7F-4C3A-9B9C-FEAD6BA49C7C}.Release|x64.Build.0 = Release|Any CPU + {C0295BF9-9A40-4FCD-BE39-E943985CA3F8}.Debug Mac|Any CPU.ActiveCfg = Debug|Any CPU + {C0295BF9-9A40-4FCD-BE39-E943985CA3F8}.Debug Mac|Any CPU.Build.0 = Debug|Any CPU + {C0295BF9-9A40-4FCD-BE39-E943985CA3F8}.Debug Mac|x64.ActiveCfg = Debug|Any CPU + {C0295BF9-9A40-4FCD-BE39-E943985CA3F8}.Debug Mac|x64.Build.0 = Debug|Any CPU + {C0295BF9-9A40-4FCD-BE39-E943985CA3F8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C0295BF9-9A40-4FCD-BE39-E943985CA3F8}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C0295BF9-9A40-4FCD-BE39-E943985CA3F8}.Debug|x64.ActiveCfg = Debug|Any CPU + {C0295BF9-9A40-4FCD-BE39-E943985CA3F8}.Debug|x64.Build.0 = Debug|Any CPU + {C0295BF9-9A40-4FCD-BE39-E943985CA3F8}.Release Mac|Any CPU.ActiveCfg = Release|Any CPU + {C0295BF9-9A40-4FCD-BE39-E943985CA3F8}.Release Mac|Any CPU.Build.0 = Release|Any CPU + {C0295BF9-9A40-4FCD-BE39-E943985CA3F8}.Release Mac|x64.ActiveCfg = Release|Any CPU + {C0295BF9-9A40-4FCD-BE39-E943985CA3F8}.Release Mac|x64.Build.0 = Release|Any CPU + {C0295BF9-9A40-4FCD-BE39-E943985CA3F8}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C0295BF9-9A40-4FCD-BE39-E943985CA3F8}.Release|Any CPU.Build.0 = Release|Any CPU + {C0295BF9-9A40-4FCD-BE39-E943985CA3F8}.Release|x64.ActiveCfg = Release|Any CPU + {C0295BF9-9A40-4FCD-BE39-E943985CA3F8}.Release|x64.Build.0 = Release|Any CPU + {42FE69BF-C821-43E8-8EAE-8F342749EF7A}.Debug Mac|Any CPU.ActiveCfg = Debug|Any CPU + {42FE69BF-C821-43E8-8EAE-8F342749EF7A}.Debug Mac|Any CPU.Build.0 = Debug|Any CPU + {42FE69BF-C821-43E8-8EAE-8F342749EF7A}.Debug Mac|x64.ActiveCfg = Debug|Any CPU + {42FE69BF-C821-43E8-8EAE-8F342749EF7A}.Debug Mac|x64.Build.0 = Debug|Any CPU + {42FE69BF-C821-43E8-8EAE-8F342749EF7A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {42FE69BF-C821-43E8-8EAE-8F342749EF7A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {42FE69BF-C821-43E8-8EAE-8F342749EF7A}.Debug|x64.ActiveCfg = Debug|Any CPU + {42FE69BF-C821-43E8-8EAE-8F342749EF7A}.Debug|x64.Build.0 = Debug|Any CPU + {42FE69BF-C821-43E8-8EAE-8F342749EF7A}.Release Mac|Any CPU.ActiveCfg = Release|Any CPU + {42FE69BF-C821-43E8-8EAE-8F342749EF7A}.Release Mac|Any CPU.Build.0 = Release|Any CPU + {42FE69BF-C821-43E8-8EAE-8F342749EF7A}.Release Mac|x64.ActiveCfg = Release|Any CPU + {42FE69BF-C821-43E8-8EAE-8F342749EF7A}.Release Mac|x64.Build.0 = Release|Any CPU + {42FE69BF-C821-43E8-8EAE-8F342749EF7A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {42FE69BF-C821-43E8-8EAE-8F342749EF7A}.Release|Any CPU.Build.0 = Release|Any CPU + {42FE69BF-C821-43E8-8EAE-8F342749EF7A}.Release|x64.ActiveCfg = Release|Any CPU + {42FE69BF-C821-43E8-8EAE-8F342749EF7A}.Release|x64.Build.0 = Release|Any CPU + {829688CD-CECE-4F6C-A5A0-032BB39CD9E0}.Debug Mac|Any CPU.ActiveCfg = Debug|Any CPU + {829688CD-CECE-4F6C-A5A0-032BB39CD9E0}.Debug Mac|Any CPU.Build.0 = Debug|Any CPU + {829688CD-CECE-4F6C-A5A0-032BB39CD9E0}.Debug Mac|x64.ActiveCfg = Debug|Any CPU + {829688CD-CECE-4F6C-A5A0-032BB39CD9E0}.Debug Mac|x64.Build.0 = Debug|Any CPU + {829688CD-CECE-4F6C-A5A0-032BB39CD9E0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {829688CD-CECE-4F6C-A5A0-032BB39CD9E0}.Debug|Any CPU.Build.0 = Debug|Any CPU + {829688CD-CECE-4F6C-A5A0-032BB39CD9E0}.Debug|x64.ActiveCfg = Debug|Any CPU + {829688CD-CECE-4F6C-A5A0-032BB39CD9E0}.Debug|x64.Build.0 = Debug|Any CPU + {829688CD-CECE-4F6C-A5A0-032BB39CD9E0}.Release Mac|Any CPU.ActiveCfg = Release|Any CPU + {829688CD-CECE-4F6C-A5A0-032BB39CD9E0}.Release Mac|Any CPU.Build.0 = Release|Any CPU + {829688CD-CECE-4F6C-A5A0-032BB39CD9E0}.Release Mac|x64.ActiveCfg = Release|Any CPU + {829688CD-CECE-4F6C-A5A0-032BB39CD9E0}.Release Mac|x64.Build.0 = Release|Any CPU + {829688CD-CECE-4F6C-A5A0-032BB39CD9E0}.Release|Any CPU.ActiveCfg = Release|Any CPU + {829688CD-CECE-4F6C-A5A0-032BB39CD9E0}.Release|Any CPU.Build.0 = Release|Any CPU + {829688CD-CECE-4F6C-A5A0-032BB39CD9E0}.Release|x64.ActiveCfg = Release|Any CPU + {829688CD-CECE-4F6C-A5A0-032BB39CD9E0}.Release|x64.Build.0 = Release|Any CPU + {70DEAA13-6DC8-44A0-B287-9E806A8054F1}.Debug Mac|Any CPU.ActiveCfg = Debug|Any CPU + {70DEAA13-6DC8-44A0-B287-9E806A8054F1}.Debug Mac|Any CPU.Build.0 = Debug|Any CPU + {70DEAA13-6DC8-44A0-B287-9E806A8054F1}.Debug Mac|x64.ActiveCfg = Debug|Any CPU + {70DEAA13-6DC8-44A0-B287-9E806A8054F1}.Debug Mac|x64.Build.0 = Debug|Any CPU + {70DEAA13-6DC8-44A0-B287-9E806A8054F1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {70DEAA13-6DC8-44A0-B287-9E806A8054F1}.Debug|Any CPU.Build.0 = Debug|Any CPU + {70DEAA13-6DC8-44A0-B287-9E806A8054F1}.Debug|x64.ActiveCfg = Debug|Any CPU + {70DEAA13-6DC8-44A0-B287-9E806A8054F1}.Debug|x64.Build.0 = Debug|Any CPU + {70DEAA13-6DC8-44A0-B287-9E806A8054F1}.Release Mac|Any CPU.ActiveCfg = Release|Any CPU + {70DEAA13-6DC8-44A0-B287-9E806A8054F1}.Release Mac|Any CPU.Build.0 = Release|Any CPU + {70DEAA13-6DC8-44A0-B287-9E806A8054F1}.Release Mac|x64.ActiveCfg = Release|Any CPU + {70DEAA13-6DC8-44A0-B287-9E806A8054F1}.Release Mac|x64.Build.0 = Release|Any CPU + {70DEAA13-6DC8-44A0-B287-9E806A8054F1}.Release|Any CPU.ActiveCfg = Release|Any CPU + {70DEAA13-6DC8-44A0-B287-9E806A8054F1}.Release|Any CPU.Build.0 = Release|Any CPU + {70DEAA13-6DC8-44A0-B287-9E806A8054F1}.Release|x64.ActiveCfg = Release|Any CPU + {70DEAA13-6DC8-44A0-B287-9E806A8054F1}.Release|x64.Build.0 = Release|Any CPU + {F06E4C37-4076-4272-9CA6-FB505E02CD31}.Debug Mac|Any CPU.ActiveCfg = Debug|Any CPU + {F06E4C37-4076-4272-9CA6-FB505E02CD31}.Debug Mac|Any CPU.Build.0 = Debug|Any CPU + {F06E4C37-4076-4272-9CA6-FB505E02CD31}.Debug Mac|x64.ActiveCfg = Debug|Any CPU + {F06E4C37-4076-4272-9CA6-FB505E02CD31}.Debug Mac|x64.Build.0 = Debug|Any CPU + {F06E4C37-4076-4272-9CA6-FB505E02CD31}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F06E4C37-4076-4272-9CA6-FB505E02CD31}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F06E4C37-4076-4272-9CA6-FB505E02CD31}.Debug|x64.ActiveCfg = Debug|Any CPU + {F06E4C37-4076-4272-9CA6-FB505E02CD31}.Debug|x64.Build.0 = Debug|Any CPU + {F06E4C37-4076-4272-9CA6-FB505E02CD31}.Release Mac|Any CPU.ActiveCfg = Release|Any CPU + {F06E4C37-4076-4272-9CA6-FB505E02CD31}.Release Mac|Any CPU.Build.0 = Release|Any CPU + {F06E4C37-4076-4272-9CA6-FB505E02CD31}.Release Mac|x64.ActiveCfg = Release|Any CPU + {F06E4C37-4076-4272-9CA6-FB505E02CD31}.Release Mac|x64.Build.0 = Release|Any CPU + {F06E4C37-4076-4272-9CA6-FB505E02CD31}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F06E4C37-4076-4272-9CA6-FB505E02CD31}.Release|Any CPU.Build.0 = Release|Any CPU + {F06E4C37-4076-4272-9CA6-FB505E02CD31}.Release|x64.ActiveCfg = Release|Any CPU + {F06E4C37-4076-4272-9CA6-FB505E02CD31}.Release|x64.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -2956,13 +2956,6 @@ Global {0B6B5C52-54EC-461F-8729-6244ACA63646} = {B6C38DB9-7B20-4B7E-BC90-6A8CAFC16807} {2568500E-F1BC-440E-9150-DD4820B3FAD6} = {B6887DDC-B9B9-4B00-95DC-1DD930A1E901} {0D23858F-4CC1-4DCA-9207-5EDB8B6CE9DD} = {DA9DFC36-C53F-4B19-8911-BF7605230BA7} - {7B02BACC-D9B6-4FFE-A450-7ECB5F71F209} = {C73C19B5-72A3-4C63-8D56-0A7E7DB46CA5} - {D607BD0A-9F7F-4C3A-9B9C-FEAD6BA49C7C} = {42A86931-7497-4A34-B2FD-060231CD0A8F} - {C0295BF9-9A40-4FCD-BE39-E943985CA3F8} = {925C0BF6-A0B1-4699-9C4B-078E01D652CC} - {42FE69BF-C821-43E8-8EAE-8F342749EF7A} = {890F3257-FCC2-4ED8-9180-22B3641B494C} - {829688CD-CECE-4F6C-A5A0-032BB39CD9E0} = {BE521908-7944-46F3-98BF-B47D34509934} - {70DEAA13-6DC8-44A0-B287-9E806A8054F1} = {890F3257-FCC2-4ED8-9180-22B3641B494C} - {F06E4C37-4076-4272-9CA6-FB505E02CD31} = {BE521908-7944-46F3-98BF-B47D34509934} {4838C66E-8677-4FBD-9609-25376042E981} = {33D19E88-F3AE-4D28-B588-D91CCF9E3BA8} {33D19E88-F3AE-4D28-B588-D91CCF9E3BA8} = {9DB74760-01DE-4AC1-A81B-BC7784351D22} {1FE3C60E-7865-40A5-9794-55ECB64F6489} = {9DB74760-01DE-4AC1-A81B-BC7784351D22} @@ -2998,6 +2991,13 @@ Global {D940853C-003A-482C-BDB0-665367F274A0} = {804E065F-914C-414A-AF84-009312C3CFF6} {7420652C-3046-4F38-BE64-9B9E69D76FA2} = {FD4D6594-D81E-456F-8F2E-35B09E04A755} {3973D572-5E24-476F-B058-8022D826B793} = {326ECEE0-D009-4A65-B24C-00FA343D8B99} + {7B02BACC-D9B6-4FFE-A450-7ECB5F71F209} = {C73C19B5-72A3-4C63-8D56-0A7E7DB46CA5} + {D607BD0A-9F7F-4C3A-9B9C-FEAD6BA49C7C} = {42A86931-7497-4A34-B2FD-060231CD0A8F} + {C0295BF9-9A40-4FCD-BE39-E943985CA3F8} = {925C0BF6-A0B1-4699-9C4B-078E01D652CC} + {42FE69BF-C821-43E8-8EAE-8F342749EF7A} = {890F3257-FCC2-4ED8-9180-22B3641B494C} + {829688CD-CECE-4F6C-A5A0-032BB39CD9E0} = {BE521908-7944-46F3-98BF-B47D34509934} + {70DEAA13-6DC8-44A0-B287-9E806A8054F1} = {890F3257-FCC2-4ED8-9180-22B3641B494C} + {F06E4C37-4076-4272-9CA6-FB505E02CD31} = {BE521908-7944-46F3-98BF-B47D34509934} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {1D43D91B-4F01-4A78-8250-CC6F9BD93A14} @@ -3013,24 +3013,21 @@ Global Objects\Converters\ConverterRevit\ConverterRevitTests\ConverterRevitTestsShared\ConverterRevitTestsShared.projitems*{1085f4b5-fdad-4ff8-b144-dddbd9454f55}*SharedItemsImports = 13 Objects\Converters\ConverterRhinoGh\ConverterRhinoGhShared\ConverterRhinoGhShared.projitems*{15c4ff29-0370-4860-b80a-06cc5e0e8d5f}*SharedItemsImports = 5 Objects\Converters\ConverterRevit\ConverterRevitTests\ConverterRevitTestsShared\ConverterRevitTestsShared.projitems*{1d1b6eda-8fd9-4758-9195-c3476db31f4e}*SharedItemsImports = 5 - ConnectorAutocadCivil\AutocadCivilDUI3\AutocadCivilDUI3Shared\AutocadCivilDUI3Shared.projitems*{1e5c7198-1065-4015-acb5-bdfa1dc43589}*SharedItemsImports = 5 Objects\Converters\ConverterAutocadCivil\ConverterAutocadCivilShared\ConverterAutocadCivilShared.projitems*{1f21e740-6b05-47bd-8d2a-c9ed5e91c577}*SharedItemsImports = 5 - ConnectorRevit\RevitDUI3\RevitDUI3Shared\RevitDUI3Shared.projitems*{2113f03b-bb8d-470b-a9a1-97bb9a554a44}*SharedItemsImports = 5 Objects\Converters\ConverterCSI\ConverterCSIShared\ConverterCSIShared.projitems*{21223ba5-c6e8-405d-b581-106c4726edc0}*SharedItemsImports = 5 ConnectorNavisworks\ConnectorNavisworks\ConnectorNavisworks.Shared.projitems*{2568500e-f1bc-440e-9150-db4820b3fad6}*SharedItemsImports = 5 + ConnectorNavisworks\ConnectorNavisworks\ConnectorNavisworks.Shared.projitems*{2568500e-f1bc-440e-9150-dd4820b3fad6}*SharedItemsImports = 5 DUI3-DX\Converters\Revit\Speckle.Converters.RevitShared\Speckle.Converters.RevitShared.projitems*{26391930-f86f-47e0-a5f6-b89919e38ce1}*SharedItemsImports = 5 ConnectorAutocadCivil\ConnectorAutocadCivil\ConnectorAutocadCivilShared.projitems*{2639e37d-80d3-415a-b4d1-20d7f321f27f}*SharedItemsImports = 5 Objects\Converters\ConverterRhinoGh\ConverterRhinoGhShared\ConverterRhinoGhShared.projitems*{26eca1be-f5b2-4a41-9658-46a4a917bfe6}*SharedItemsImports = 5 ConnectorRevit\ConnectorRevit\ConnectorRevit.projitems*{27a79aca-7ea8-4406-8bb8-216578cc3ab7}*SharedItemsImports = 5 ConnectorTeklaStructures\ConnectorTeklaStructuresShared\ConnectorTeklaStructuresShared.projitems*{28e2ea7f-ffd1-4e13-9165-0243b5ac82f5}*SharedItemsImports = 13 - ConnectorAutocadCivil\AutocadCivilDUI3\AutocadCivilDUI3Shared\AutocadCivilDUI3Shared.projitems*{2bde80e8-5f26-4e57-bba6-109120f5d4ee}*SharedItemsImports = 13 Objects\Converters\ConverterAutocadCivil\ConverterAutocadCivilShared\ConverterAutocadCivilShared.projitems*{2d0f9f8a-2e89-4780-978a-cd92d6d7b843}*SharedItemsImports = 13 Objects\Converters\ConverterRevit\ConverterRevitShared\ConverterRevitShared.projitems*{2dcd648d-dca5-4d2a-8b14-ad2cb85d24b0}*SharedItemsImports = 13 ConnectorBentley\ConnectorBentleyShared\ConnectorBentleyShared.projitems*{372d9f0f-ede9-4050-bf8c-758911c5c2e0}*SharedItemsImports = 13 ConnectorTeklaStructures\ConnectorTeklaStructuresShared\ConnectorTeklaStructuresShared.projitems*{3af1ef30-0906-4926-a02c-4e3ad666352a}*SharedItemsImports = 5 ConnectorAutocadCivil\ConnectorAutocadCivil\ConnectorAutocadCivilShared.projitems*{3b9189b9-e485-448a-8793-9b9587a36791}*SharedItemsImports = 5 Objects\Converters\ConverterRhinoGh\ConverterRhinoGhShared\ConverterRhinoGhShared.projitems*{3cdef4cc-2cfa-4939-8427-3ed00fa9db55}*SharedItemsImports = 5 - ConnectorRevit\RevitDUI3\RevitDUI3Shared\RevitDUI3Shared.projitems*{3d7f0278-6cf2-4588-a101-4027abb8b87f}*SharedItemsImports = 13 Objects\Converters\ConverterDynamo\ConverterDynamoShared\ConverterDynamoShared.projitems*{3df12639-78b6-41b3-a046-a675035369be}*SharedItemsImports = 5 ConnectorAutocadCivil\ConnectorAutocadCivil\ConnectorAutocadCivilShared.projitems*{3e30d170-3cb4-4728-97d5-887c5019da9b}*SharedItemsImports = 5 DUI3-DX\Connectors\Autocad\Speckle.Connectors.AutocadShared\Speckle.Connectors.AutocadShared.projitems*{41bc679f-887f-44cf-971d-a5502ee87db0}*SharedItemsImports = 13 @@ -3046,7 +3043,6 @@ Global ConnectorTeklaStructures\ConnectorTeklaStructuresShared\ConnectorTeklaStructuresShared.projitems*{511c2fb0-9c73-4ac9-ba59-c8a84c089c59}*SharedItemsImports = 5 ConnectorRevit\RevitSharedResources\RevitSharedResources.projitems*{521a7d9c-637f-4965-a6e6-ba96df99807d}*SharedItemsImports = 5 Objects\Converters\ConverterRevit\ConverterRevitTests\ConverterRevitTestsShared\ConverterRevitTestsShared.projitems*{54e90327-5f48-468d-9349-17aaceaa0a77}*SharedItemsImports = 5 - ConnectorAutocadCivil\AutocadCivilDUI3\AutocadCivilDUI3Shared\AutocadCivilDUI3Shared.projitems*{5698290f-250f-4336-adf8-f269a36d1178}*SharedItemsImports = 5 ConnectorBentley\ConnectorBentleyShared\ConnectorBentleyShared.projitems*{57bf94a8-8f73-4d1a-91d2-b10cc64178b6}*SharedItemsImports = 5 ConnectorRevit\ConnectorRevit\ConnectorRevit.projitems*{586a5a37-93f6-427e-8df8-c10db4d6822a}*SharedItemsImports = 5 ConnectorAutocadCivil\ConnectorAutocadCivil\ConnectorAutocadCivilShared.projitems*{58a88f1a-7489-46d2-949d-2fc3f68c8d84}*SharedItemsImports = 5 @@ -3088,7 +3084,6 @@ Global ConnectorNavisworks\ConnectorNavisworks\ConnectorNavisworks.Shared.projitems*{9a7d7f9a-4fe1-4053-950b-50b43bc81087}*SharedItemsImports = 5 DUI3-DX\Converters\Autocad\Speckle.Converters.AutocadShared\Speckle.Converters.AutocadShared.projitems*{9add1b7a-6401-4202-8613-f668e2fbc0a4}*SharedItemsImports = 13 ConnectorCSI\ConnectorCSIShared\ConnectorCSIShared.projitems*{9d188843-8841-4a76-a844-efbe8e32ee05}*SharedItemsImports = 5 - ConnectorRevit\RevitDUI3\RevitDUI3Shared\RevitDUI3Shared.projitems*{a364b196-38a3-45ab-a54a-f04d17c0b2da}*SharedItemsImports = 5 ConnectorBentley\ConnectorBentleyShared\ConnectorBentleyShared.projitems*{a3a0ee09-6055-4009-ab8e-13fbc1a403a9}*SharedItemsImports = 5 ConnectorNavisworks\ConnectorNavisworks\ConnectorNavisworks.Shared.projitems*{a517a609-cab1-4b33-b83c-1b13b34e4560}*SharedItemsImports = 13 ConnectorRhino\ConnectorRhino\ConnectorRhinoShared\ConnectorRhinoShared.projitems*{a64acbf9-db82-4839-af99-57ed2e7989f4}*SharedItemsImports = 5 diff --git a/DUI3-DX/Directory.Build.Props b/DUI3-DX/Directory.Build.Props index dd2485d9d7..56a58f6ad6 100644 --- a/DUI3-DX/Directory.Build.Props +++ b/DUI3-DX/Directory.Build.Props @@ -10,6 +10,6 @@ - + From 61f5b204d0281458d0c96164a034e809e5a67162 Mon Sep 17 00:00:00 2001 From: Alan Rynne Date: Fri, 7 Jun 2024 16:39:49 +0200 Subject: [PATCH 222/261] feat: Swap CI to run on ubuntu (#3489) * fix: Renamed `.Props` to `.props` and aligned solution * feat: Swap CI to run on ubuntu --- .github/workflows/ci.yml | 8 ++++---- All.sln | 4 ++-- DUI3-DX/{Directory.Build.Props => Directory.Build.props} | 0 3 files changed, 6 insertions(+), 6 deletions(-) rename DUI3-DX/{Directory.Build.Props => Directory.Build.props} (100%) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ed038082f1..a375a63a3a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,7 +12,7 @@ on: jobs: build: - runs-on: windows-latest + runs-on: ubuntu-latest outputs: version: ${{ steps.set-version.outputs.version }} steps: @@ -26,10 +26,10 @@ jobs: with: dotnet-version: 8.0.2xx # Align with global.json (including roll forward rules) - name: ⚒️ Run GitVersion - run: ./build.ps1 build-server-version + run: ./build.sh build-server-version - name: ⚒️ Run build - run: ./build.ps1 + run: ./build.sh - name: ⬆️ Upload artifacts uses: actions/upload-artifact@v4 @@ -40,4 +40,4 @@ jobs: - id: set-version name: Set version to output - run: echo "version=${{ env.GitVersion_FullSemVer }}" >> "$Env:GITHUB_OUTPUT" + run: echo "version=${{ env.GitVersion_FullSemVer }}" >> "$GITHUB_OUTPUT" diff --git a/All.sln b/All.sln index eb6cd8b14a..d62369f249 100644 --- a/All.sln +++ b/All.sln @@ -24,7 +24,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Transports", "Transports", EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Objects", "Objects", "{E3916A0F-68D5-4C84-ACAE-41547F75E454}" ProjectSection(SolutionItems) = preProject - Objects\Directory.Build.Props = Objects\Directory.Build.Props + Objects\Directory.Build.props = Objects\Directory.Build.props EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Converters", "Converters", "{4DE5ED81-2A55-4C23-A05F-3C9B9B06F85D}" @@ -457,7 +457,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DllConflictManagement", "Co EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "DUI3-DX", "DUI3-DX", "{9DB74760-01DE-4AC1-A81B-BC7784351D22}" ProjectSection(SolutionItems) = preProject - DUI3-DX\Directory.Build.Props = DUI3-DX\Directory.Build.Props + DUI3-DX\Directory.Build.props = DUI3-DX\Directory.Build.props EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Revit", "Revit", "{4838C66E-8677-4FBD-9609-25376042E981}" diff --git a/DUI3-DX/Directory.Build.Props b/DUI3-DX/Directory.Build.props similarity index 100% rename from DUI3-DX/Directory.Build.Props rename to DUI3-DX/Directory.Build.props From dd0a8b381c93c5af18eafdc9d20eb7158f06f4cb Mon Sep 17 00:00:00 2001 From: Jedd Morgan <45512892+JR-Morgan@users.noreply.github.com> Date: Sat, 8 Jun 2024 14:01:05 +0100 Subject: [PATCH 223/261] arc gis traversal cleanup (#3482) * Changes to traversal for arcgis * Changed filed type casting to use ConvertTo * Simplified GetAcendents * xml comment * Shuffled some functions around * More tweaks * More changes * dumbdumb net versioning --- .../TraversalContextExtensions.cs | 30 +++-- .../TraversalContextExtensionsTests.cs | 10 ++ .../Operations/Receive/HostObjectBuilder.cs | 103 ++++++++---------- .../Receive/RhinoHostObjectBuilder.cs | 4 +- .../Utils/GISAttributeFieldType.cs | 10 +- .../Utils/INonNativeFeaturesUtils.cs | 4 +- .../Utils/NonNativeFeaturesUtils.cs | 36 +++--- 7 files changed, 102 insertions(+), 95 deletions(-) diff --git a/Core/Core/Models/GraphTraversal/TraversalContextExtensions.cs b/Core/Core/Models/GraphTraversal/TraversalContextExtensions.cs index b987cb1b45..dab65ed446 100644 --- a/Core/Core/Models/GraphTraversal/TraversalContextExtensions.cs +++ b/Core/Core/Models/GraphTraversal/TraversalContextExtensions.cs @@ -1,4 +1,6 @@ using System.Collections.Generic; +using System.Diagnostics.Contracts; +using System.Linq; namespace Speckle.Core.Models.GraphTraversal; @@ -10,6 +12,7 @@ public static class TraversalContextExtensions /// /// /// + [Pure] public static IEnumerable GetPropertyPath(this TraversalContext context) { TraversalContext? head = context; @@ -26,22 +29,31 @@ public static IEnumerable GetPropertyPath(this TraversalContext context) } /// - /// Walks up the tree, returning all typed ascendant, starting the closest , - /// walking up nodes + /// Walks up the tree, returning all ascendant, including /// /// - /// - public static IEnumerable GetAscendantOfType(this TraversalContext context) - where T : Base + /// and all its ascendants + [Pure] + public static IEnumerable GetAscendants(this TraversalContext context) { TraversalContext? head = context; do { - if (head.Current is T c) - { - yield return c; - } + yield return head.Current; head = head.Parent; } while (head != null); } + + /// + /// Walks up the tree, returning all typed ascendant, starting the closest , + /// walking up nodes + /// + /// + /// and all its ascendants of type + [Pure] + public static IEnumerable GetAscendantOfType(this TraversalContext context) + where T : Base + { + return context.GetAscendants().OfType(); + } } diff --git a/Core/Tests/Speckle.Core.Tests.Unit/Models/GraphTraversal/TraversalContextExtensionsTests.cs b/Core/Tests/Speckle.Core.Tests.Unit/Models/GraphTraversal/TraversalContextExtensionsTests.cs index 9686e289bb..e8a38cf800 100644 --- a/Core/Tests/Speckle.Core.Tests.Unit/Models/GraphTraversal/TraversalContextExtensionsTests.cs +++ b/Core/Tests/Speckle.Core.Tests.Unit/Models/GraphTraversal/TraversalContextExtensionsTests.cs @@ -28,6 +28,16 @@ public void GetPropertyPath_ReturnsSequentialPath(int depth) Assert.That(path, Is.EquivalentTo(expected)); } + [TestCaseSource(nameof(TestDepths))] + public void GetAscendant(int depth) + { + var testData = CreateLinkedList(depth, i => new()); + + var all = TraversalContextExtensions.GetAscendants(testData).ToArray(); + + Assert.That(all, Has.Length.EqualTo(depth)); + } + [TestCaseSource(nameof(TestDepths))] public void GetAscendantOfType_AllBase(int depth) { diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Receive/HostObjectBuilder.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Receive/HostObjectBuilder.cs index ce31b4775c..2b770782ef 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Receive/HostObjectBuilder.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Receive/HostObjectBuilder.cs @@ -1,3 +1,4 @@ +using System.Diagnostics.Contracts; using ArcGIS.Desktop.Mapping; using Speckle.Connectors.Utils.Builders; using Speckle.Converters.Common; @@ -9,6 +10,7 @@ using Speckle.Connectors.Utils.Conversion; using Speckle.Core.Models.GraphTraversal; using Speckle.Converters.ArcGIS3; +using RasterLayer = Objects.GIS.RasterLayer; namespace Speckle.Connectors.ArcGIS.Operations.Receive; @@ -34,77 +36,40 @@ GraphTraversal traverseFunction _traverseFunction = traverseFunction; } - public (string path, Geometry converted, string? parentId) ConvertNonNativeGeometries( - Base obj, - string[] path, - string? parentId, - List objectIds - ) + private (string path, Geometry converted) ConvertNonNativeGeometries(Base obj, string[] path) { Geometry converted = (Geometry)_converter.Convert(obj); - objectIds.Add(obj.id); List objPath = path.ToList(); objPath.Add(obj.speckle_type.Split(".")[^1]); - return ($"{string.Join("\\", objPath)}", converted, parentId); + return (string.Join("\\", objPath), converted); } - public (string path, string converted) ConvertNativeLayers(Collection obj, string[] path, List objectIds) + private (string path, string converted) ConvertNativeLayers(Collection obj, string[] path) { string converted = (string)_converter.Convert(obj); - objectIds.Add(obj.id); string objPath = $"{string.Join("\\", path)}\\{obj.name}"; return (objPath, converted); } - public string AddDatasetsToMap((string, string) databaseObj) + private string AddDatasetsToMap((string nestedLayerName, string datasetId) databaseObj) { + Uri uri = + new( + $"{_contextStack.Current.Document.SpeckleDatabasePath.AbsolutePath.Replace('/', '\\')}\\{databaseObj.datasetId}" + ); + Map map = _contextStack.Current.Document.Map; try { - return LayerFactory.Instance - .CreateLayer( - new Uri( - $"{_contextStack.Current.Document.SpeckleDatabasePath.AbsolutePath.Replace('/', '\\')}\\{databaseObj.Item2}" - ), - _contextStack.Current.Document.Map, - layerName: databaseObj.Item1 - ) - .URI; + return LayerFactory.Instance.CreateLayer(uri, map, layerName: databaseObj.nestedLayerName).URI; } catch (ArgumentException) { return StandaloneTableFactory.Instance - .CreateStandaloneTable( - new Uri( - $"{_contextStack.Current.Document.SpeckleDatabasePath.AbsolutePath.Replace('/', '\\')}\\{databaseObj.Item2}" - ), - _contextStack.Current.Document.Map, - tableName: databaseObj.Item1 - ) + .CreateStandaloneTable(uri, map, tableName: databaseObj.nestedLayerName) .URI; } } - private string[] GetLayerPath(TraversalContext context) - { - string[] collectionBasedPath = context.GetAscendantOfType().Select(c => c.name).ToArray(); - string[] reverseOrderPath = - collectionBasedPath.Length != 0 ? collectionBasedPath : context.GetPropertyPath().ToArray(); - return reverseOrderPath.Reverse().ToArray(); - } - - private bool HasGISParent(TraversalContext context) - { - List vectorLayers = context - .GetAscendantOfType() - .Where(obj => obj != context.Current) - .ToList(); - List rasterLayers = context - .GetAscendantOfType() - .Where(obj => obj != context.Current) - .ToList(); - return vectorLayers.Count + rasterLayers.Count > 0; - } - public HostObjectBuilderResult Build( Base rootObject, string projectName, @@ -116,31 +81,31 @@ CancellationToken cancellationToken // Prompt the UI conversion started. Progress bar will swoosh. onOperationProgressed?.Invoke("Converting", null); - // POC: This is where we will define our receive strategy, or maybe later somewhere else according to some setting pass from UI? var objectsToConvert = _traverseFunction .Traverse(rootObject) + .Where(ctx => ctx.Current is not Collection || IsGISType(ctx.Current)) .Where(ctx => HasGISParent(ctx) is false) - .Select(ctx => (GetLayerPath(ctx), ctx.Current, ctx.Parent?.Current.id)) .ToList(); int allCount = objectsToConvert.Count; int count = 0; - Dictionary convertedGeometries = new(); - List objectIds = new(); + Dictionary convertedGeometries = new(); List<(string path, string converted)> convertedGISObjects = new(); // 1. convert everything List results = new(objectsToConvert.Count); List bakedObjectIds = new(); - foreach (var item in objectsToConvert) + foreach (TraversalContext ctx in objectsToConvert) { - (string[] path, Base obj, string? parentId) = item; + string[] path = GetLayerPath(ctx); + Base obj = ctx.Current; + cancellationToken.ThrowIfCancellationRequested(); try { - if (obj is VectorLayer or Objects.GIS.RasterLayer) + if (IsGISType(obj)) { - var result = ConvertNativeLayers((Collection)obj, path, objectIds); + var result = ConvertNativeLayers((Collection)obj, path); convertedGISObjects.Add(result); // NOTE: Dim doesn't really know what is what - is the result.path the id of the obj? // TODO: is the type in here basically a GIS Layer? @@ -148,8 +113,8 @@ CancellationToken cancellationToken } else { - var result = ConvertNonNativeGeometries(obj, path, parentId, objectIds); - convertedGeometries[obj.id] = result; + var result = ConvertNonNativeGeometries(obj, path); + convertedGeometries[ctx] = result; // NOTE: Dim doesn't really know what is what - is the result.path the id of the obj? results.Add(new(Status.SUCCESS, obj, result.path, result.converted.GetType().ToString())); //POC: what native id?, path may not be unique @@ -184,4 +149,26 @@ CancellationToken cancellationToken // TODO: validated a correct set regarding bakedobject ids return new(bakedObjectIds, results); } + + [Pure] + private static string[] GetLayerPath(TraversalContext context) + { + string[] collectionBasedPath = context.GetAscendantOfType().Select(c => c.name).ToArray(); + string[] reverseOrderPath = + collectionBasedPath.Length != 0 ? collectionBasedPath : context.GetPropertyPath().ToArray(); + return reverseOrderPath.Reverse().ToArray(); + } + + [Pure] + private static bool HasGISParent(TraversalContext context) + { + List gisLayers = context.GetAscendants().Where(IsGISType).Where(obj => obj != context.Current).ToList(); + return gisLayers.Count > 0; + } + + [Pure] + private static bool IsGISType(Base obj) + { + return obj is RasterLayer or VectorLayer; + } } diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Receive/RhinoHostObjectBuilder.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Receive/RhinoHostObjectBuilder.cs index 26215d4464..02f653f08a 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Receive/RhinoHostObjectBuilder.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Receive/RhinoHostObjectBuilder.cs @@ -1,3 +1,4 @@ +using System.Diagnostics.Contracts; using Rhino; using Rhino.DocObjects; using Rhino.Geometry; @@ -175,7 +176,8 @@ private int GetAndCreateLayerFromPath(string[] path, string baseLayerName, Dicti return previousLayer.Index; } - private string[] GetLayerPath(TraversalContext context) + [Pure] + private static string[] GetLayerPath(TraversalContext context) { string[] collectionBasedPath = context.GetAscendantOfType().Select(c => c.name).ToArray(); string[] reverseOrderPath = diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/GISAttributeFieldType.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/GISAttributeFieldType.cs index 64cb937987..332a6d077a 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/GISAttributeFieldType.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/GISAttributeFieldType.cs @@ -97,11 +97,11 @@ public static FieldType FieldTypeToNative(object fieldType) return fieldType switch { FieldType.String => (string)value, - FieldType.Single => (float)(double)value, - FieldType.Integer => (int)(long)value, // need this step because sent "ints" seem to be received as "longs" - FieldType.BigInteger => (long)value, - FieldType.SmallInteger => (short)(long)value, - FieldType.Double => (double)value, + FieldType.Single => Convert.ToSingle(value), + FieldType.Integer => Convert.ToInt32(value), // need this step because sent "ints" seem to be received as "longs" + FieldType.BigInteger => Convert.ToInt64(value), + FieldType.SmallInteger => Convert.ToInt16(value), + FieldType.Double => Convert.ToDouble(value), FieldType.Date => DateTime.Parse((string)value, null), FieldType.DateOnly => DateOnly.Parse((string)value), FieldType.TimeOnly => TimeOnly.Parse((string)value), diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/INonNativeFeaturesUtils.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/INonNativeFeaturesUtils.cs index 6ab9c32603..1f4295b457 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/INonNativeFeaturesUtils.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/INonNativeFeaturesUtils.cs @@ -1,8 +1,10 @@ +using Speckle.Core.Models.GraphTraversal; + namespace Speckle.Converters.ArcGIS3.Utils; public interface INonNativeFeaturesUtils { public List<(string parentPath, string converted)> WriteGeometriesToDatasets( - Dictionary convertedObjs + Dictionary convertedObjs ); } diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/NonNativeFeaturesUtils.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/NonNativeFeaturesUtils.cs index cdb5226076..621ad260ca 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/NonNativeFeaturesUtils.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/NonNativeFeaturesUtils.cs @@ -5,6 +5,7 @@ using Speckle.Converters.Common; using FieldDescription = ArcGIS.Core.Data.DDL.FieldDescription; using Speckle.Core.Logging; +using Speckle.Core.Models.GraphTraversal; namespace Speckle.Converters.ArcGIS3.Utils; @@ -23,24 +24,25 @@ public NonNativeFeaturesUtils( } public List<(string parentPath, string converted)> WriteGeometriesToDatasets( - Dictionary convertedObjs + Dictionary convertedObjs ) { - List<(string, string)> result = new(); + List<(string parentPath, string converted)> result = new(); // 1. Sort features into groups by path and geom type Dictionary geometries, string? parentId)> geometryGroups = new(); foreach (var item in convertedObjs) { try { - string objId = item.Key; - (string parentPath, ACG.Geometry geom, string? parentId) = item.Value; + TraversalContext context = item.Key; + (string parentPath, ACG.Geometry geom) = item.Value; + string? parentId = context.Parent?.Current.id; // add dictionnary item if doesn't exist yet // Key must be unique per parent and speckle_type // Key is composed of parentId and parentPath (that contains speckle_type) string uniqueKey = $"{parentId}_{parentPath}"; - if (!geometryGroups.TryGetValue(uniqueKey, out (List geometries, string? parentId) value)) + if (!geometryGroups.TryGetValue(uniqueKey, out _)) { geometryGroups[uniqueKey] = (new List(), parentId); } @@ -57,26 +59,18 @@ public NonNativeFeaturesUtils( // 2. for each group create a Dataset and add geometries there as Features foreach (var item in geometryGroups) { + string uniqueKey = item.Key; // parentId_parentPath + string parentPath = uniqueKey.Split('_', 2)[^1]; + string speckle_type = parentPath.Split('\\')[^1]; + (List geomList, string? parentId) = item.Value; try { - string uniqueKey = item.Key; // parentId_parentPath - string parentPath = uniqueKey.Split('_', 2)[^1]; - string speckle_type = parentPath.Split("\\")[^1]; - (List geomList, string? parentId) = item.Value; - try - { - string converted = CreateDatasetInDatabase(speckle_type, geomList, parentId); - result.Add((parentPath, converted)); - } - catch (GeodatabaseGeometryException) - { - // do nothing if conversion of some geometry groups fails - } + string converted = CreateDatasetInDatabase(speckle_type, geomList, parentId); + result.Add((parentPath, converted)); } - catch (Exception e) when (!e.IsFatal()) + catch (GeodatabaseGeometryException) { - // POC: report, etc. - Debug.WriteLine("conversion error happened."); + // do nothing if writing of some geometry groups fails } } return result; From 5f883e6beec15f9d1e669eedd60eff4592a4b3ae Mon Sep 17 00:00:00 2001 From: Dimitrie Stefanescu Date: Sat, 8 Jun 2024 17:35:36 +0100 Subject: [PATCH 224/261] Dim/dui3/send caching di (DUI3-79) (#3491) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat(dui3): wip send caching di implements rhino * fix(dui3): fixes fatal crash on object deleted and re-send/highlight i distinctly remember fixing this before in dui3 😔 * feat(dui3): di send cache in acad * wip(dui3): di cache revit wip * fix(revit): we seem to be cursed to be unable to do basic boolean logic * feat(dui3): wraps up di caching revit * feat(caching): cleanup * chore(dui3): rename arcgis object builder as others * feat(dui3): implements di cache in arcgis - NOT TESTED * chore(caching): adds comment on nullability * feat(arcgis): makes cache non-nullable * fix(caching): makes cache non-nullable where we know it's going to be non-nullable: specifically, in host app implementations of the root object builder and send bindings * chore(dui3): removes a bunch of dead code and comments * feat(caching): adds a "null" do nothing cache and makes it non-optional in the root object sender * chore(caching): removes unnecessary comment * fix(acgis): registers cache! --- .../Bindings/ArcGISSendBinding.cs | 26 +++---- .../ArcGISConnectorModule.cs | 8 ++- ...tBuilder.cs => ArcGISRootObjectBuilder.cs} | 21 ++++-- .../Bindings/AutocadSendBinding.cs | 29 +++----- .../AutocadConnectorModule.cs | 4 ++ .../HostApp/Extensions/DocumentExtensions.cs | 20 +++++- .../Send/AutocadRootObjectBuilder.cs | 20 ++++-- .../Bindings/BasicConnectorBindingRevit.cs | 2 +- .../{SendBinding.cs => RevitSendBinding.cs} | 71 ++++--------------- .../RevitConnectorModule.cs | 6 +- .../Operations/Send/RevitRootObjectBuilder.cs | 24 +++++-- .../Speckle.Connectors.RevitShared.projitems | 2 +- .../Bindings/RhinoSendBinding.cs | 35 +++------ .../RhinoConnectorModule.cs | 4 ++ .../Operations/Send/RhinoRootObjectBuilder.cs | 19 +++-- .../Models/Card/SenderModelCard.cs | 5 +- .../Caching/ISendConversionCache.cs | 23 ++++++ .../Caching/NullSendConversionCache.cs | 19 +++++ .../Caching/SendConversionCache.cs | 28 ++++++++ .../Operations/RootObjectSender.cs | 7 +- .../Operations/SendInfo.cs | 18 +---- .../SpeckleTopLevelExceptionHandler.cs | 44 ------------ 22 files changed, 217 insertions(+), 218 deletions(-) rename DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Send/{RootObjectBuilder.cs => ArcGISRootObjectBuilder.cs} (74%) rename DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/{SendBinding.cs => RevitSendBinding.cs} (72%) create mode 100644 DUI3-DX/Sdk/Speckle.Connectors.Utils/Caching/ISendConversionCache.cs create mode 100644 DUI3-DX/Sdk/Speckle.Connectors.Utils/Caching/NullSendConversionCache.cs create mode 100644 DUI3-DX/Sdk/Speckle.Connectors.Utils/Caching/SendConversionCache.cs delete mode 100644 DUI3-DX/Sdk/Speckle.Connectors.Utils/SpeckleTopLevelExceptionHandler.cs diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISSendBinding.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISSendBinding.cs index 7391a8cea3..95a4a0abc5 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISSendBinding.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISSendBinding.cs @@ -16,8 +16,8 @@ using ArcGIS.Core.Data; using Speckle.Connectors.DUI.Exceptions; using Speckle.Connectors.Utils; +using Speckle.Connectors.Utils.Caching; using Speckle.Connectors.Utils.Operations; -using Speckle.Core.Models; namespace Speckle.Connectors.ArcGIS.Bindings; @@ -31,8 +31,7 @@ public sealed class ArcGISSendBinding : ISendBinding, ICancelable private readonly IUnitOfWorkFactory _unitOfWorkFactory; // POC: unused? :D private readonly List _sendFilters; private readonly CancellationManager _cancellationManager; - - private readonly Dictionary _convertedObjectReferences = new(); + private readonly ISendConversionCache _sendConversionCache; /// /// Used internally to aggregate the changed objects' id. @@ -46,14 +45,15 @@ public ArcGISSendBinding( IBridge parent, IEnumerable sendFilters, IUnitOfWorkFactory unitOfWorkFactory, - CancellationManager cancellationManager + CancellationManager cancellationManager, + ISendConversionCache sendConversionCache ) { _store = store; _unitOfWorkFactory = unitOfWorkFactory; _sendFilters = sendFilters.ToList(); _cancellationManager = cancellationManager; - + _sendConversionCache = sendConversionCache; Parent = parent; Commands = new SendBindingUICommands(parent); SubscribeToArcGISEvents(); @@ -277,9 +277,7 @@ public async Task Send(string modelCardId) modelCard.AccountId.NotNull(), modelCard.ProjectId.NotNull(), modelCard.ModelId.NotNull(), - "ArcGIS", - _convertedObjectReferences, - modelCard.ChangedObjectIds + "ArcGIS" ); var sendResult = await QueuedTask @@ -309,15 +307,6 @@ public async Task Send(string modelCardId) ) .ConfigureAwait(false); - // Store the converted references in memory for future send operations, overwriting the existing values for the given application id. - foreach (var kvp in result.ConvertedReferences) - { - _convertedObjectReferences[kvp.Key + modelCard.ProjectId] = kvp.Value; - } - - // It's important to reset the model card's list of changed obj ids so as to ensure we accurately keep track of changes between send operations. - modelCard.ChangedObjectIds = new(); - return result; }) .ConfigureAwait(false); @@ -347,6 +336,8 @@ private void RunExpirationChecks(bool idsDeleted) List expiredSenderIds = new(); string[] objectIdsList = ChangedObjectIds.ToArray(); + _sendConversionCache.EvictObjects(objectIdsList); + foreach (SenderModelCard sender in senders) { var objIds = sender.SendFilter.NotNull().GetObjectIds(); @@ -355,7 +346,6 @@ private void RunExpirationChecks(bool idsDeleted) if (isExpired) { expiredSenderIds.Add(sender.ModelCardId.NotNull()); - sender.ChangedObjectIds.UnionWith(intersection.NotNull()); // Update the model card object Ids if (idsDeleted && sender.SendFilter is ArcGISSelectionFilter filter) diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/DependencyInjection/ArcGISConnectorModule.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/DependencyInjection/ArcGISConnectorModule.cs index 91ddd3ee24..1c5c0a8559 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/DependencyInjection/ArcGISConnectorModule.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/DependencyInjection/ArcGISConnectorModule.cs @@ -14,6 +14,7 @@ using Speckle.Connectors.DUI; using Speckle.Connectors.DUI.Models; using Speckle.Connectors.Utils; +using Speckle.Connectors.Utils.Caching; using Speckle.Connectors.Utils.Operations; using Speckle.Core.Models.GraphTraversal; @@ -53,7 +54,10 @@ public void Load(SpeckleContainerBuilder builder) // register send operation and dependencies builder.AddScoped>(); - builder.AddScoped(); - builder.AddSingleton, RootObjectBuilder>(); + builder.AddScoped(); + builder.AddSingleton, ArcGISRootObjectBuilder>(); + + // register send conversion cache + builder.AddSingleton(); } } diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Send/RootObjectBuilder.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Send/ArcGISRootObjectBuilder.cs similarity index 74% rename from DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Send/RootObjectBuilder.cs rename to DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Send/ArcGISRootObjectBuilder.cs index c07f396bbb..9b371194e0 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Send/RootObjectBuilder.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Send/ArcGISRootObjectBuilder.cs @@ -1,6 +1,8 @@ +using System.Diagnostics; using ArcGIS.Desktop.Mapping; using Speckle.Autofac.DependencyInjection; using Speckle.Connectors.Utils.Builders; +using Speckle.Connectors.Utils.Caching; using Speckle.Connectors.Utils.Conversion; using Speckle.Connectors.Utils.Operations; using Speckle.Converters.Common; @@ -12,13 +14,15 @@ namespace Speckle.Connectors.ArcGis.Operations.Send; /// /// Stateless builder object to turn an ISendFilter into a object /// -public class RootObjectBuilder : IRootObjectBuilder +public class ArcGISRootObjectBuilder : IRootObjectBuilder { private readonly IUnitOfWorkFactory _unitOfWorkFactory; + private readonly ISendConversionCache _sendConversionCache; - public RootObjectBuilder(IUnitOfWorkFactory unitOfWorkFactory) + public ArcGISRootObjectBuilder(IUnitOfWorkFactory unitOfWorkFactory, ISendConversionCache sendConversionCache) { _unitOfWorkFactory = unitOfWorkFactory; + _sendConversionCache = sendConversionCache; } public RootObjectBuilderResult Build( @@ -38,6 +42,8 @@ public RootObjectBuilderResult Build( Collection rootObjectCollection = new(); //TODO: Collections List results = new(objects.Count); + var cacheHitCount = 0; + foreach (MapMember mapMember in objects) { ct.ThrowIfCancellationRequested(); @@ -47,12 +53,10 @@ public RootObjectBuilderResult Build( try { Base converted; - if ( - !sendInfo.ChangedObjectIds.Contains(applicationId) - && sendInfo.ConvertedObjects.TryGetValue(applicationId + sendInfo.ProjectId, out ObjectReference? value) - ) + if (_sendConversionCache.TryGetValue(sendInfo.ProjectId, applicationId, out ObjectReference value)) { converted = value; + cacheHitCount++; } else { @@ -73,6 +77,11 @@ public RootObjectBuilderResult Build( onOperationProgressed?.Invoke("Converting", (double)++count / objects.Count); } + // POC: Log would be nice, or can be removed. + Debug.WriteLine( + $"Cache hit count {cacheHitCount} out of {objects.Count} ({(double)cacheHitCount / objects.Count})" + ); + return new(rootObjectCollection, results); } } diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadSendBinding.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadSendBinding.cs index 4321772b6e..a994b9eb9f 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadSendBinding.cs +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadSendBinding.cs @@ -10,10 +10,10 @@ using Speckle.Connectors.Autocad.Operations.Send; using Speckle.Connectors.DUI.Exceptions; using Speckle.Connectors.Utils.Operations; -using Speckle.Core.Models; using ICancelable = System.Reactive.Disposables.ICancelable; using Speckle.Connectors.DUI.Models.Card.SendFilter; using Speckle.Connectors.Utils; +using Speckle.Connectors.Utils.Caching; namespace Speckle.Connectors.Autocad.Bindings; @@ -29,17 +29,13 @@ public sealed class AutocadSendBinding : ISendBinding, ICancelable private readonly CancellationManager _cancellationManager; private readonly IUnitOfWorkFactory _unitOfWorkFactory; private readonly AutocadSettings _autocadSettings; + private readonly ISendConversionCache _sendConversionCache; /// /// Used internally to aggregate the changed objects' id. /// private HashSet ChangedObjectIds { get; set; } = new(); - /// - /// Keeps track of previously converted objects as a dictionary of (applicationId, object reference). - /// - private readonly Dictionary _convertedObjectReferences = new(); - public AutocadSendBinding( DocumentModelStore store, AutocadIdleManager idleManager, @@ -47,7 +43,8 @@ public AutocadSendBinding( IEnumerable sendFilters, CancellationManager cancellationManager, AutocadSettings autocadSettings, - IUnitOfWorkFactory unitOfWorkFactory + IUnitOfWorkFactory unitOfWorkFactory, + ISendConversionCache sendConversionCache ) { _store = store; @@ -56,7 +53,7 @@ IUnitOfWorkFactory unitOfWorkFactory _autocadSettings = autocadSettings; _cancellationManager = cancellationManager; _sendFilters = sendFilters.ToList(); - + _sendConversionCache = sendConversionCache; Parent = parent; Commands = new SendBindingUICommands(parent); @@ -95,6 +92,8 @@ private void RunExpirationChecks() string[] objectIdsList = ChangedObjectIds.ToArray(); List expiredSenderIds = new(); + _sendConversionCache.EvictObjects(objectIdsList); + foreach (SenderModelCard modelCard in senders) { var intersection = modelCard.SendFilter.NotNull().GetObjectIds().Intersect(objectIdsList).ToList(); @@ -102,7 +101,6 @@ private void RunExpirationChecks() if (isExpired) { expiredSenderIds.Add(modelCard.ModelCardId.NotNull()); - modelCard.ChangedObjectIds.UnionWith(intersection); } } @@ -148,9 +146,7 @@ private async Task SendInternal(string modelCardId) modelCard.AccountId.NotNull(), modelCard.ProjectId.NotNull(), modelCard.ModelId.NotNull(), - _autocadSettings.HostAppInfo.Name, - _convertedObjectReferences, - modelCard.ChangedObjectIds + _autocadSettings.HostAppInfo.Name ); var sendResult = await uow.Service @@ -162,15 +158,6 @@ private async Task SendInternal(string modelCardId) ) .ConfigureAwait(false); - // Store the converted references in memory for future send operations, overwriting the existing values for the given application id. - foreach (var kvp in sendResult.ConvertedReferences) - { - _convertedObjectReferences[kvp.Key + modelCard.ProjectId] = kvp.Value; - } - - // It's important to reset the model card's list of changed obj ids so as to ensure we accurately keep track of changes between send operations. - modelCard.ChangedObjectIds = new(); - Commands.SetModelSendResult(modelCardId, sendResult.RootObjId, sendResult.ConversionResults); } // Catch here specific exceptions if they related to model card. diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/DependencyInjection/AutocadConnectorModule.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/DependencyInjection/AutocadConnectorModule.cs index e2ec747ba9..98733f04d2 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/DependencyInjection/AutocadConnectorModule.cs +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/DependencyInjection/AutocadConnectorModule.cs @@ -14,6 +14,7 @@ using Speckle.Connectors.DUI.WebView; using Speckle.Connectors.Utils; using Speckle.Connectors.Utils.Builders; +using Speckle.Connectors.Utils.Caching; using Speckle.Connectors.Utils.Operations; using Speckle.Core.Models.GraphTraversal; @@ -58,5 +59,8 @@ public void Load(SpeckleContainerBuilder builder) // register send filters builder.AddTransient(); + + // register send conversion cache + builder.AddSingleton(); } } diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/Extensions/DocumentExtensions.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/Extensions/DocumentExtensions.cs index a0ab9e54a2..300dd8e94f 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/Extensions/DocumentExtensions.cs +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/Extensions/DocumentExtensions.cs @@ -1,4 +1,5 @@ using Autodesk.AutoCAD.DatabaseServices; +using Autodesk.AutoCAD.Runtime; using Speckle.Connectors.Autocad.Operations.Send; namespace Speckle.Connectors.Autocad.HostApp.Extensions; @@ -17,13 +18,26 @@ public static List GetObjects(this Document doc, IEnumerable< if (long.TryParse(objectIdHandle, out long parsedId)) { Handle handle = new(parsedId); - if (doc.Database.TryGetObjectId(handle, out ObjectId myObjectId)) + // Note: Fatal crash happens here when objects are deleted, so we need to catch it. + try { - if (tr.GetObject(myObjectId, OpenMode.ForRead) is DBObject dbObject) + if (doc.Database.TryGetObjectId(handle, out ObjectId myObjectId)) { - objects.Add(new(dbObject, objectIdHandle)); + if (tr.GetObject(myObjectId, OpenMode.ForRead) is DBObject dbObject) + { + objects.Add(new(dbObject, objectIdHandle)); + } } } + catch (Autodesk.AutoCAD.Runtime.Exception e) + { + if (e.ErrorStatus == ErrorStatus.WasErased) // Note: TBD if we want to catch more things in here. For now maybe not, but it does seem like this function gets into "crashes the host app territory" + { + continue; + } + + throw; + } } } } diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Operations/Send/AutocadRootObjectBuilder.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Operations/Send/AutocadRootObjectBuilder.cs index cb49f54f13..3073a07b25 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Operations/Send/AutocadRootObjectBuilder.cs +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Operations/Send/AutocadRootObjectBuilder.cs @@ -1,5 +1,7 @@ -using Autodesk.AutoCAD.DatabaseServices; +using System.Diagnostics; +using Autodesk.AutoCAD.DatabaseServices; using Speckle.Connectors.Utils.Builders; +using Speckle.Connectors.Utils.Caching; using Speckle.Connectors.Utils.Conversion; using Speckle.Connectors.Utils.Operations; using Speckle.Converters.Common; @@ -12,10 +14,12 @@ public class AutocadRootObjectBuilder : IRootObjectBuilder { private readonly IRootToSpeckleConverter _converter; private readonly string[] _documentPathSeparator = { "\\" }; + private readonly ISendConversionCache _sendConversionCache; - public AutocadRootObjectBuilder(IRootToSpeckleConverter converter) + public AutocadRootObjectBuilder(IRootToSpeckleConverter converter, ISendConversionCache sendConversionCache) { _converter = converter; + _sendConversionCache = sendConversionCache; } public RootObjectBuilderResult Build( @@ -40,6 +44,7 @@ public RootObjectBuilderResult Build( int count = 0; List results = new(objects.Count); + var cacheHitCount = 0; foreach (var (dbObject, applicationId) in objects) { ct.ThrowIfCancellationRequested(); @@ -47,12 +52,10 @@ public RootObjectBuilderResult Build( try { Base converted; - if ( - !sendInfo.ChangedObjectIds.Contains(applicationId) - && sendInfo.ConvertedObjects.TryGetValue(applicationId + sendInfo.ProjectId, out ObjectReference value) // POC: Interface out constructing keys here to use it otherplaces with a same code. -> https://spockle.atlassian.net/browse/CNX-9313 - ) + if (_sendConversionCache.TryGetValue(sendInfo.ProjectId, applicationId, out ObjectReference value)) { converted = value; + cacheHitCount++; } else { @@ -84,6 +87,11 @@ public RootObjectBuilderResult Build( onOperationProgressed?.Invoke("Converting", (double)++count / objects.Count); } + // POC: Log would be nice, or can be removed. + Debug.WriteLine( + $"Cache hit count {cacheHitCount} out of {objects.Count} ({(double)cacheHitCount / objects.Count})" + ); + return new(modelWithLayers, results); } } diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/BasicConnectorBindingRevit.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/BasicConnectorBindingRevit.cs index 7b1382ce7b..3aa6be233f 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/BasicConnectorBindingRevit.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/BasicConnectorBindingRevit.cs @@ -88,7 +88,7 @@ public void HighlightModel(string modelCardId) SenderModelCard model = (SenderModelCard)_store.GetModelById(modelCardId); var elementIds = model.SendFilter.NotNull().GetObjectIds().Select(ElementId.Parse).ToList(); - if (elementIds.Count != 0) + if (elementIds.Count == 0) { Commands.SetModelError(modelCardId, new InvalidOperationException("No objects found to highlight.")); return; diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SendBinding.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/RevitSendBinding.cs similarity index 72% rename from DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SendBinding.cs rename to DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/RevitSendBinding.cs index a721ac2283..bbfa2a815b 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SendBinding.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/RevitSendBinding.cs @@ -3,7 +3,6 @@ using Speckle.Connectors.Utils.Cancellation; using Speckle.Connectors.DUI.Bridge; using Speckle.Connectors.Revit.Plugin; -using Speckle.Core.Logging; using Speckle.Connectors.Utils; using Speckle.Converters.RevitShared.Helpers; using Speckle.Connectors.DUI.Models.Card; @@ -11,12 +10,12 @@ using Speckle.Autofac.DependencyInjection; using Speckle.Connectors.DUI.Exceptions; using Speckle.Connectors.DUI.Models; +using Speckle.Connectors.Utils.Caching; using Speckle.Connectors.Utils.Operations; -using Speckle.Core.Models; namespace Speckle.Connectors.Revit.Bindings; -internal sealed class SendBinding : RevitBaseBinding, ICancelable, ISendBinding +internal sealed class RevitSendBinding : RevitBaseBinding, ICancelable, ISendBinding { // POC:does it need injecting? public CancellationManager CancellationManager { get; } = new(); @@ -24,28 +23,27 @@ internal sealed class SendBinding : RevitBaseBinding, ICancelable, ISendBinding // POC: does it need injecting? private HashSet ChangedObjectIds { get; set; } = new(); - /// - /// Keeps track of previously converted objects as a dictionary of (applicationId, object reference). - /// - private readonly Dictionary _convertedObjectReferences = new(); - private readonly RevitSettings _revitSettings; private readonly IRevitIdleManager _idleManager; private readonly IUnitOfWorkFactory _unitOfWorkFactory; + private readonly ISendConversionCache _sendConversionCache; - public SendBinding( + public RevitSendBinding( IRevitIdleManager idleManager, RevitContext revitContext, DocumentModelStore store, IBridge bridge, IUnitOfWorkFactory unitOfWorkFactory, - RevitSettings revitSettings + RevitSettings revitSettings, + ISendConversionCache sendConversionCache ) : base("sendBinding", store, bridge, revitContext) { _idleManager = idleManager; _unitOfWorkFactory = unitOfWorkFactory; _revitSettings = revitSettings; + _sendConversionCache = sendConversionCache; + Commands = new SendBindingUICommands(bridge); // TODO expiry events // TODO filters need refresh events @@ -57,13 +55,6 @@ public List GetSendFilters() return new List { new RevitSelectionFilter() { IsDefault = true } }; } - public async Task Send(string modelCardId) - { - await SpeckleTopLevelExceptionHandler - .Run(() => HandleSend(modelCardId), HandleSpeckleException, HandleUnexpectedException, HandleFatalException) - .ConfigureAwait(false); - } - public void CancelSend(string modelCardId) { CancellationManager.CancelOperation(modelCardId); @@ -71,11 +62,9 @@ public void CancelSend(string modelCardId) public SendBindingUICommands Commands { get; } - private async Task HandleSend(string modelCardId) + public async Task Send(string modelCardId) { - // POC: this try catch pattern is coming from Rhino. I see there is a semi implemented "SpeckleTopLevelExceptionHandler" - // above that wraps the call of this HandleSend, but it currently is not doing anything - resulting in all errors from here - // bubbling up to the bridge. + // Note: removed top level handling thing as it was confusing me try { if (Store.GetModelById(modelCardId) is not SenderModelCard modelCard) @@ -108,9 +97,7 @@ private async Task HandleSend(string modelCardId) modelCard.AccountId.NotNull(), modelCard.ProjectId.NotNull(), modelCard.ModelId.NotNull(), - _revitSettings.HostSlug.NotNull(), - _convertedObjectReferences, - modelCard.ChangedObjectIds + _revitSettings.HostSlug.NotNull() ); var sendResult = await sendOperation.Service @@ -122,16 +109,6 @@ private async Task HandleSend(string modelCardId) ) .ConfigureAwait(false); - // Store the converted references in memory for future send operations, overwriting the existing values for the given application id. - foreach (var kvp in sendResult.ConvertedReferences) - { - _convertedObjectReferences[kvp.Key + modelCard.ProjectId] = kvp.Value; - } - - // It's important to reset the model card's list of changed obj ids so as to ensure we accurately keep track of changes between send operations. - modelCard.ChangedObjectIds = new(); - - //TODO: send full send resul to UI? Commands.SetModelSendResult(modelCardId, sendResult.RootObjId, sendResult.ConversionResults); } // Catch here specific exceptions if they related to model card. @@ -150,27 +127,6 @@ private void OnSendOperationProgress(string modelCardId, string status, double? Commands.SetModelProgress(modelCardId, new ModelCardProgress(modelCardId, status, progress)); } - private bool HandleSpeckleException(SpeckleException spex) - { - // POC: do something here - - return false; - } - - private bool HandleUnexpectedException(Exception ex) - { - // POC: do something here - - return false; - } - - private bool HandleFatalException(Exception ex) - { - // POC: do something here - - return false; - } - /// /// Keeps track of the changed element ids as well as checks if any of them need to trigger /// a filter refresh (e.g., views being added). @@ -207,14 +163,15 @@ private void RunExpirationChecks() string[] objectIdsList = ChangedObjectIds.ToArray(); List expiredSenderIds = new(); + _sendConversionCache.EvictObjects(objectIdsList); + foreach (SenderModelCard modelCard in senders) { var intersection = modelCard.SendFilter.NotNull().GetObjectIds().Intersect(objectIdsList).ToList(); - bool isExpired = modelCard.SendFilter.CheckExpiry(ChangedObjectIds.ToArray()); + bool isExpired = intersection.Count != 0; if (isExpired) { expiredSenderIds.Add(modelCard.ModelCardId.NotNull()); - modelCard.ChangedObjectIds.UnionWith(intersection); } } diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/RevitConnectorModule.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/RevitConnectorModule.cs index 4d6a302e27..c0193834cd 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/RevitConnectorModule.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/RevitConnectorModule.cs @@ -11,6 +11,7 @@ using Speckle.Connectors.Revit.Plugin; using Speckle.Connectors.Utils; using Speckle.Connectors.Utils.Builders; +using Speckle.Connectors.Utils.Caching; using Speckle.Connectors.Utils.Operations; namespace Speckle.Connectors.Revit.DependencyInjection; @@ -50,12 +51,15 @@ public void Load(SpeckleContainerBuilder builder) builder.AddSingleton(); builder.AddSingleton(); builder.AddSingleton(); - builder.AddSingleton(); + builder.AddSingleton(); //no receive? builder.AddSingleton(); // send operation and dependencies builder.AddScoped>(); builder.AddScoped, RevitRootObjectBuilder>(); + + // register send conversion cache + builder.AddSingleton(); } } diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RevitRootObjectBuilder.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RevitRootObjectBuilder.cs index 5d42abaa10..b22ef0a3ca 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RevitRootObjectBuilder.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RevitRootObjectBuilder.cs @@ -1,9 +1,11 @@ +using System.Diagnostics; using Speckle.Converters.Common; using Speckle.Core.Models; using Autodesk.Revit.DB; using Speckle.Connectors.DUI.Exceptions; using Speckle.Converters.RevitShared.Helpers; using Speckle.Connectors.Utils.Builders; +using Speckle.Connectors.Utils.Caching; using Speckle.Connectors.Utils.Conversion; using Speckle.Connectors.Utils.Operations; using Speckle.Core.Logging; @@ -17,12 +19,17 @@ public class RevitRootObjectBuilder : IRootObjectBuilder private readonly IRevitConversionContextStack _contextStack; private readonly Dictionary _collectionCache; private readonly Collection _rootObject; + private readonly ISendConversionCache _sendConversionCache; - public RevitRootObjectBuilder(IRootToSpeckleConverter converter, IRevitConversionContextStack contextStack) + public RevitRootObjectBuilder( + IRootToSpeckleConverter converter, + IRevitConversionContextStack contextStack, + ISendConversionCache sendConversionCache + ) { _converter = converter; _contextStack = contextStack; - + _sendConversionCache = sendConversionCache; // Note, this class is instantiated per unit of work (aka per send operation), so we can safely initialize what we need in here. _collectionCache = new Dictionary(); _rootObject = new Collection() @@ -62,7 +69,7 @@ public RootObjectBuilderResult Build( } var countProgress = 0; // because for(int i = 0; ...) loops are so last year - + var cacheHitCount = 0; List results = new(revitElements.Count); foreach (Element revitElement in revitElements) { @@ -76,12 +83,10 @@ public RootObjectBuilderResult Build( try { Base converted; - if ( - !sendInfo.ChangedObjectIds.Contains(applicationId) - && sendInfo.ConvertedObjects.TryGetValue(applicationId + sendInfo.ProjectId, out ObjectReference value) - ) + if (_sendConversionCache.TryGetValue(sendInfo.ProjectId, applicationId, out ObjectReference value)) { converted = value; + cacheHitCount++; } else { @@ -101,6 +106,11 @@ public RootObjectBuilderResult Build( onOperationProgressed?.Invoke("Converting", (double)++countProgress / revitElements.Count); } + // POC: Log would be nice, or can be removed. + Debug.WriteLine( + $"Cache hit count {cacheHitCount} out of {objects.Count} ({(double)cacheHitCount / objects.Count})" + ); + return new(_rootObject, results); } diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Speckle.Connectors.RevitShared.projitems b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Speckle.Connectors.RevitShared.projitems index d7bcb0a2d3..8a671aefc9 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Speckle.Connectors.RevitShared.projitems +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Speckle.Connectors.RevitShared.projitems @@ -20,7 +20,7 @@ - + diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSendBinding.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSendBinding.cs index e767b9c3cf..6f3b66e6ff 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSendBinding.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSendBinding.cs @@ -1,4 +1,3 @@ -using System.Diagnostics.CodeAnalysis; using Rhino; using Speckle.Connectors.DUI.Bindings; using Speckle.Connectors.DUI.Bridge; @@ -12,9 +11,9 @@ using Speckle.Connectors.DUI.Exceptions; using Speckle.Connectors.DUI.Models.Card.SendFilter; using Speckle.Connectors.Utils.Operations; -using Speckle.Core.Models; using Speckle.Connectors.DUI.Settings; using Speckle.Connectors.Utils; +using Speckle.Connectors.Utils.Caching; namespace Speckle.Connectors.Rhino7.Bindings; @@ -37,10 +36,7 @@ public sealed class RhinoSendBinding : ISendBinding, ICancelable /// private HashSet ChangedObjectIds { get; set; } = new(); - /// - /// Keeps track of previously converted objects as a dictionary of (applicationId, object reference). - /// - private readonly Dictionary _convertedObjectReferences = new(); + private readonly ISendConversionCache _sendConversionCache; public RhinoSendBinding( DocumentModelStore store, @@ -50,7 +46,8 @@ public RhinoSendBinding( SendOperation sendOperation, IUnitOfWorkFactory unitOfWorkFactory, RhinoSettings rhinoSettings, - CancellationManager cancellationManager + CancellationManager cancellationManager, + ISendConversionCache sendConversionCache ) { _store = store; @@ -60,6 +57,7 @@ CancellationManager cancellationManager _sendFilters = sendFilters.ToList(); _rhinoSettings = rhinoSettings; _cancellationManager = cancellationManager; + _sendConversionCache = sendConversionCache; Parent = parent; Commands = new SendBindingUICommands(parent); // POC: Commands are tightly coupled with their bindings, at least for now, saves us injecting a factory. SubscribeToRhinoEvents(); @@ -127,11 +125,6 @@ public List GetSendSettings() }; } - [SuppressMessage( - "Maintainability", - "CA1506:Avoid excessive class coupling", - Justification = "Being refactored on in parallel, muting this issue so CI can pass initially." - )] public async Task Send(string modelCardId) { using var unitOfWork = _unitOfWorkFactory.Resolve>(); @@ -163,9 +156,7 @@ public async Task Send(string modelCardId) modelCard.AccountId.NotNull(), modelCard.ProjectId.NotNull(), modelCard.ModelId.NotNull(), - _rhinoSettings.HostAppInfo.Name, - _convertedObjectReferences, - modelCard.ChangedObjectIds + _rhinoSettings.HostAppInfo.Name ); var sendResult = await unitOfWork.Service @@ -177,15 +168,6 @@ public async Task Send(string modelCardId) ) .ConfigureAwait(false); - // Store the converted references in memory for future send operations, overwriting the existing values for the given application id. - foreach (var kvp in sendResult.ConvertedReferences) - { - _convertedObjectReferences[kvp.Key + modelCard.ProjectId] = kvp.Value; - } - - // It's important to reset the model card's list of changed obj ids so as to ensure we accurately keep track of changes between send operations. - modelCard.ChangedObjectIds = new(); - Commands.SetModelSendResult(modelCardId, sendResult.RootObjId, sendResult.ConversionResults); } // Catch here specific exceptions if they related to model card. @@ -216,14 +198,15 @@ private void RunExpirationChecks() string[] objectIdsList = ChangedObjectIds.ToArray(); List expiredSenderIds = new(); + _sendConversionCache.EvictObjects(objectIdsList); + foreach (SenderModelCard modelCard in senders) { var intersection = modelCard.SendFilter.NotNull().GetObjectIds().Intersect(objectIdsList).ToList(); - var isExpired = modelCard.SendFilter.NotNull().CheckExpiry(ChangedObjectIds.ToArray()); + var isExpired = intersection.Count != 0; if (isExpired) { expiredSenderIds.Add(modelCard.ModelCardId.NotNull()); - modelCard.ChangedObjectIds.UnionWith(intersection.NotNull()); } } diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/RhinoConnectorModule.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/RhinoConnectorModule.cs index 15475b4f62..96d6aaa56b 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/RhinoConnectorModule.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/RhinoConnectorModule.cs @@ -19,6 +19,7 @@ using Speckle.Connectors.Rhino7.Operations.Receive; using Speckle.Connectors.Utils; using Speckle.Connectors.Utils.Builders; +using Speckle.Connectors.Utils.Caching; using Speckle.Connectors.Utils.Operations; using Speckle.Core.Models.GraphTraversal; @@ -62,6 +63,9 @@ public void Load(SpeckleContainerBuilder builder) builder.AddScoped(); builder.AddScoped(); + // register send conversion cache + builder.AddSingleton(); + // register send operation and dependencies builder.AddScoped>(); builder.AddSingleton(DefaultTraversal.CreateTraversalFunc()); diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Send/RhinoRootObjectBuilder.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Send/RhinoRootObjectBuilder.cs index cfb94ca620..2d5996c97a 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Send/RhinoRootObjectBuilder.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Send/RhinoRootObjectBuilder.cs @@ -1,3 +1,4 @@ +using System.Diagnostics; using Rhino.DocObjects; using Rhino; using Speckle.Core.Models; @@ -5,6 +6,7 @@ using Speckle.Converters.Common; using Speckle.Connectors.DUI.Models.Card.SendFilter; using Speckle.Connectors.Utils.Builders; +using Speckle.Connectors.Utils.Caching; using Speckle.Connectors.Utils.Conversion; using Speckle.Connectors.Utils.Operations; using Speckle.Core.Logging; @@ -17,10 +19,12 @@ namespace Speckle.Connectors.Rhino7.Operations.Send; public class RhinoRootObjectBuilder : IRootObjectBuilder { private readonly IUnitOfWorkFactory _unitOfWorkFactory; + private readonly ISendConversionCache _sendConversionCache; - public RhinoRootObjectBuilder(IUnitOfWorkFactory unitOfWorkFactory) + public RhinoRootObjectBuilder(IUnitOfWorkFactory unitOfWorkFactory, ISendConversionCache sendConversionCache) { _unitOfWorkFactory = unitOfWorkFactory; + _sendConversionCache = sendConversionCache; } public RootObjectBuilderResult Build( @@ -49,6 +53,7 @@ private RootObjectBuilderResult ConvertObjects( // POC: Handle blocks. List results = new(rhinoObjects.Count); + var cacheHitCount = 0; foreach (RhinoObject rhinoObject in rhinoObjects) { cancellationToken.ThrowIfCancellationRequested(); @@ -65,12 +70,11 @@ private RootObjectBuilderResult ConvertObjects( // What we actually do here is check if the object has been previously converted AND has not changed. // If that's the case, we insert in the host collection just its object reference which has been saved from the prior conversion. Base converted; - if ( - !sendInfo.ChangedObjectIds.Contains(applicationId) - && sendInfo.ConvertedObjects.TryGetValue(applicationId + sendInfo.ProjectId, out ObjectReference value) - ) + + if (_sendConversionCache.TryGetValue(sendInfo.ProjectId, applicationId, out ObjectReference value)) { converted = value; + cacheHitCount++; } else { @@ -94,6 +98,11 @@ private RootObjectBuilderResult ConvertObjects( // Thread.Sleep(550); } + // POC: Log would be nice, or can be removed. + Debug.WriteLine( + $"Cache hit count {cacheHitCount} out of {rhinoObjects.Count} ({(double)cacheHitCount / rhinoObjects.Count})" + ); + // 5. profit return new(rootObjectCollection, results); } diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/SenderModelCard.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/SenderModelCard.cs index ecd33fba44..1bee9faabc 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/SenderModelCard.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Models/Card/SenderModelCard.cs @@ -1,5 +1,4 @@ using Speckle.Connectors.DUI.Models.Card.SendFilter; -using Speckle.Newtonsoft.Json; namespace Speckle.Connectors.DUI.Models.Card; @@ -7,6 +6,6 @@ public class SenderModelCard : ModelCard { public ISendFilter? SendFilter { get; set; } - [JsonIgnore] - public HashSet ChangedObjectIds { get; set; } = new(); + // [JsonIgnore] + // public HashSet ChangedObjectIds { get; set; } = new(); } diff --git a/DUI3-DX/Sdk/Speckle.Connectors.Utils/Caching/ISendConversionCache.cs b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Caching/ISendConversionCache.cs new file mode 100644 index 0000000000..ce5bfc41a2 --- /dev/null +++ b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Caching/ISendConversionCache.cs @@ -0,0 +1,23 @@ +using Speckle.Core.Models; + +namespace Speckle.Connectors.Utils.Caching; + +/// +/// Stores object references resulting from a send operation. These can be retrieved back during a subsequent send operation to bypass conversion if +/// they have not been changed. On large sends with small changes, this makes the process much speedier! +/// Note: do not and should not persist between file opens, should just persist in memory between send operations. Always eagerly invalidate. +/// If you ever implement a different conversion cache, do remember that objects in speckle are namespaced to each project (stream). E.g., if you send A to project C and project D, A needs to exist twice in the db. As such, always namespace stored references by project id. +/// Further note: Caching is optional in the send ops; an instance of this should be injected only in applications where we know we can rely on change tracking! +/// +public interface ISendConversionCache +{ + void StoreSendResult(string projectId, Dictionary convertedReferences); + + /// + /// Call this method whenever you need to invalidate a set of objects that have changed in the host app. + /// Failure to do so correctly will result in cache poisoning and incorrect version creation (stale objects). + /// + /// + public void EvictObjects(IEnumerable objectIds); + bool TryGetValue(string projectId, string applicationId, out ObjectReference objectReference); +} diff --git a/DUI3-DX/Sdk/Speckle.Connectors.Utils/Caching/NullSendConversionCache.cs b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Caching/NullSendConversionCache.cs new file mode 100644 index 0000000000..ec8e85f46c --- /dev/null +++ b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Caching/NullSendConversionCache.cs @@ -0,0 +1,19 @@ +using Speckle.Core.Models; + +namespace Speckle.Connectors.Utils.Caching; + +/// +/// A null send conversion cache for future use in connectors that cannot support . It does nothing! +/// +public class NullSendConversionCache : ISendConversionCache +{ + public void StoreSendResult(string projectId, Dictionary convertedReferences) { } + + public void EvictObjects(IEnumerable objectIds) { } + + public bool TryGetValue(string projectId, string applicationId, out ObjectReference objectReference) + { + objectReference = new ObjectReference(); + return false; + } +} diff --git a/DUI3-DX/Sdk/Speckle.Connectors.Utils/Caching/SendConversionCache.cs b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Caching/SendConversionCache.cs new file mode 100644 index 0000000000..94a9883927 --- /dev/null +++ b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Caching/SendConversionCache.cs @@ -0,0 +1,28 @@ +using Speckle.Core.Models; + +namespace Speckle.Connectors.Utils.Caching; + +/// +public class SendConversionCache : ISendConversionCache +{ + public SendConversionCache() { } + + private Dictionary<(string applicationId, string projectId), ObjectReference> Cache { get; set; } = new(); // NOTE: as this dude's accessed from potentially more operations at the same time, it might be safer to bless him as a concurrent dictionary. + + public void StoreSendResult(string projectId, Dictionary convertedReferences) + { + foreach (var kvp in convertedReferences) + { + Cache[(kvp.Key, projectId)] = kvp.Value; + } + } + + /// + public void EvictObjects(IEnumerable objectIds) => + Cache = Cache + .Where(kvp => !objectIds.Contains(kvp.Key.applicationId)) + .ToDictionary(kvp => kvp.Key, kvp => kvp.Value); + + public bool TryGetValue(string projectId, string applicationId, out ObjectReference objectReference) => + Cache.TryGetValue((applicationId, projectId), out objectReference); +} diff --git a/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/RootObjectSender.cs b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/RootObjectSender.cs index c46faeb7fc..0234361f66 100644 --- a/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/RootObjectSender.cs +++ b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/RootObjectSender.cs @@ -1,3 +1,4 @@ +using Speckle.Connectors.Utils.Caching; using Speckle.Core.Api; using Speckle.Core.Credentials; using Speckle.Core.Models; @@ -15,10 +16,12 @@ public sealed class RootObjectSender : IRootObjectSender { // POC: Revisit this factory pattern, I think we could solve this higher up by injecting a scoped factory for `SendOperation` in the SendBinding private readonly ServerTransport.Factory _transportFactory; + private readonly ISendConversionCache _sendConversionCache; - public RootObjectSender(ServerTransport.Factory transportFactory) + public RootObjectSender(ServerTransport.Factory transportFactory, ISendConversionCache sendConversionCache) { _transportFactory = transportFactory; + _sendConversionCache = sendConversionCache; } public async Task<(string rootObjId, Dictionary convertedReferences)> Send( @@ -37,6 +40,8 @@ public RootObjectSender(ServerTransport.Factory transportFactory) ITransport transport = _transportFactory(account, sendInfo.ProjectId, 60, null); var sendResult = await SendHelper.Send(commitObject, transport, true, null, ct).ConfigureAwait(false); + _sendConversionCache.StoreSendResult(sendInfo.ProjectId, sendResult.convertedReferences); + ct.ThrowIfCancellationRequested(); onOperationProgressed?.Invoke("Linking version to model...", null); diff --git a/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/SendInfo.cs b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/SendInfo.cs index 65cd622466..0b45d1161f 100644 --- a/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/SendInfo.cs +++ b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Operations/SendInfo.cs @@ -1,31 +1,17 @@ -using Speckle.Core.Models; - -namespace Speckle.Connectors.Utils.Operations; +namespace Speckle.Connectors.Utils.Operations; public readonly struct SendInfo { - public SendInfo( - string accountId, - string projectId, - string modelId, - string sourceApplication, - IReadOnlyDictionary convertedObjects, - ISet changedObjectIds - ) + public SendInfo(string accountId, string projectId, string modelId, string sourceApplication) { AccountId = accountId; ProjectId = projectId; ModelId = modelId; SourceApplication = sourceApplication; - ConvertedObjects = convertedObjects; - ChangedObjectIds = changedObjectIds; } public string AccountId { get; } public string ProjectId { get; } public string ModelId { get; } public string SourceApplication { get; } - public IReadOnlyDictionary ConvertedObjects { get; } - - public ISet ChangedObjectIds { get; } } diff --git a/DUI3-DX/Sdk/Speckle.Connectors.Utils/SpeckleTopLevelExceptionHandler.cs b/DUI3-DX/Sdk/Speckle.Connectors.Utils/SpeckleTopLevelExceptionHandler.cs deleted file mode 100644 index 0eb92feff5..0000000000 --- a/DUI3-DX/Sdk/Speckle.Connectors.Utils/SpeckleTopLevelExceptionHandler.cs +++ /dev/null @@ -1,44 +0,0 @@ -using Speckle.Core.Logging; - -namespace Speckle.Connectors.Utils; - -// POC: consider wisdom of static -public static class SpeckleTopLevelExceptionHandler -{ - // POC: async/await? - // handlers for - public static async Task Run( - Func run, - Func? speckleError = null, - Func? unexpectedError = null, - Func? fatalError = null - ) - { - // POC: TL-handler - try - { - await run().ConfigureAwait(false); - } - catch (SpeckleException spex) - { - if (speckleError == null || !speckleError(spex)) - { - throw; - } - } - catch (Exception ex) when (!ex.IsFatal()) - { - if (unexpectedError == null || !unexpectedError(ex)) - { - throw; - } - } - catch (Exception ex) when (ex.IsFatal()) - { - if (fatalError == null || !fatalError(ex)) - { - throw; - } - } - } -} From cc7075891d9b837c47bed96be96795420415619f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?O=C4=9Fuzhan=20Koral?= <45078678+oguzhankoral@users.noreply.github.com> Date: Mon, 10 Jun 2024 17:33:23 +0300 Subject: [PATCH 225/261] Fix revit threading (#3498) Fix the behavior - It is broken when registrations extracted out.. --- .../DependencyInjection/RevitConnectorModule.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/RevitConnectorModule.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/RevitConnectorModule.cs index c0193834cd..ec1bcb5566 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/RevitConnectorModule.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/RevitConnectorModule.cs @@ -4,6 +4,7 @@ using Speckle.Autofac.DependencyInjection; using Speckle.Connectors.DUI; using Speckle.Connectors.DUI.Bindings; +using Speckle.Connectors.DUI.Bridge; using Speckle.Connectors.DUI.Models; using Speckle.Connectors.Revit.Bindings; using Speckle.Connectors.Revit.HostApp; @@ -26,6 +27,8 @@ public void Load(SpeckleContainerBuilder builder) builder.AddDUI(); //builder.AddDUIView(); + builder.AddSingletonInstance(); + // POC: different versons for different versions of CEF builder.AddSingleton(BindingOptions.DefaultBinder); From f6a23ebd7dcc7652f4992cc5d2f7656a39b1d98d Mon Sep 17 00:00:00 2001 From: KatKatKateryna <89912278+KatKatKateryna@users.noreply.github.com> Date: Thu, 13 Jun 2024 16:48:05 +0800 Subject: [PATCH 226/261] DUI3-295 track non native received objects for the full report (#3497) * introduce ConverionTracker; simplify variables * track conversions up to writing groups into dataset * throw exceptions for failed datasets. TODO: write to results * correct results * correct result order * properly updating Trackers * more comments * remove fake Exception from GIS layers * Move BUILD function to the top --- .../Bindings/BasicConnectorBinding.cs | 8 +- .../Operations/Receive/HostObjectBuilder.cs | 142 +++++++++++------- .../Utils/ArcGISProjectUtils.cs | 0 .../Utils/ConversionTracker.cs | 88 +++++++++++ .../Utils/INonNativeFeaturesUtils.cs | 4 +- .../Utils/NonNativeFeaturesUtils.cs | 82 ++++++---- 6 files changed, 237 insertions(+), 87 deletions(-) delete mode 100644 DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/ArcGISProjectUtils.cs create mode 100644 DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/ConversionTracker.cs diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/BasicConnectorBinding.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/BasicConnectorBinding.cs index bfa36dfc87..dd2fa19efa 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/BasicConnectorBinding.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/BasicConnectorBinding.cs @@ -171,6 +171,12 @@ private void SelectMapMembersInTOC(List mapMembers) } } MapView.Active.SelectLayers(layers); - // MapView.Active.SelectStandaloneTables(tables); // clears previous selection, not clear how to ADD selection instead + + // this step clears previous selection, not clear how to ADD selection instead + // this is why, activating it only if no layers are selected + if (layers.Count == 0) + { + MapView.Active.SelectStandaloneTables(tables); + } } } diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Receive/HostObjectBuilder.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Receive/HostObjectBuilder.cs index 2b770782ef..a681f5317a 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Receive/HostObjectBuilder.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Receive/HostObjectBuilder.cs @@ -36,40 +36,6 @@ GraphTraversal traverseFunction _traverseFunction = traverseFunction; } - private (string path, Geometry converted) ConvertNonNativeGeometries(Base obj, string[] path) - { - Geometry converted = (Geometry)_converter.Convert(obj); - List objPath = path.ToList(); - objPath.Add(obj.speckle_type.Split(".")[^1]); - return (string.Join("\\", objPath), converted); - } - - private (string path, string converted) ConvertNativeLayers(Collection obj, string[] path) - { - string converted = (string)_converter.Convert(obj); - string objPath = $"{string.Join("\\", path)}\\{obj.name}"; - return (objPath, converted); - } - - private string AddDatasetsToMap((string nestedLayerName, string datasetId) databaseObj) - { - Uri uri = - new( - $"{_contextStack.Current.Document.SpeckleDatabasePath.AbsolutePath.Replace('/', '\\')}\\{databaseObj.datasetId}" - ); - Map map = _contextStack.Current.Document.Map; - try - { - return LayerFactory.Instance.CreateLayer(uri, map, layerName: databaseObj.nestedLayerName).URI; - } - catch (ArgumentException) - { - return StandaloneTableFactory.Instance - .CreateStandaloneTable(uri, map, tableName: databaseObj.nestedLayerName) - .URI; - } - } - public HostObjectBuilderResult Build( Base rootObject, string projectName, @@ -89,8 +55,7 @@ CancellationToken cancellationToken int allCount = objectsToConvert.Count; int count = 0; - Dictionary convertedGeometries = new(); - List<(string path, string converted)> convertedGISObjects = new(); + Dictionary conversionTracker = new(); // 1. convert everything List results = new(objectsToConvert.Count); @@ -105,21 +70,15 @@ CancellationToken cancellationToken { if (IsGISType(obj)) { - var result = ConvertNativeLayers((Collection)obj, path); - convertedGISObjects.Add(result); - // NOTE: Dim doesn't really know what is what - is the result.path the id of the obj? - // TODO: is the type in here basically a GIS Layer? - results.Add(new(Status.SUCCESS, obj, result.path, "GIS Layer")); + string nestedLayerPath = $"{string.Join("\\", path)}\\{((Collection)obj).name}"; + string datasetId = (string)_converter.Convert(obj); + conversionTracker[ctx] = new ObjectConversionTracker(obj, nestedLayerPath, datasetId); } else { - var result = ConvertNonNativeGeometries(obj, path); - convertedGeometries[ctx] = result; - - // NOTE: Dim doesn't really know what is what - is the result.path the id of the obj? - results.Add(new(Status.SUCCESS, obj, result.path, result.converted.GetType().ToString())); //POC: what native id?, path may not be unique - // TODO: Do we need this here? I remember oguzhan saying something that selection/object highlighting is weird in arcgis (weird is subjective) - // bakedObjectIds.Add(result.path); + string nestedLayerPath = $"{string.Join("\\", path)}\\{obj.speckle_type.Split(".")[^1]}"; + Geometry converted = (Geometry)_converter.Convert(obj); + conversionTracker[ctx] = new ObjectConversionTracker(obj, nestedLayerPath, converted); } } catch (Exception ex) when (!ex.IsFatal()) // DO NOT CATCH SPECIFIC STUFF, conversion errors should be recoverable @@ -130,26 +89,101 @@ CancellationToken cancellationToken } // 2. convert Database entries with non-GIS geometry datasets - onOperationProgressed?.Invoke("Writing to Database", null); - convertedGISObjects.AddRange(_nonGisFeaturesUtils.WriteGeometriesToDatasets(convertedGeometries)); + _nonGisFeaturesUtils.WriteGeometriesToDatasets(conversionTracker); + // 3. add layer and tables to the Table Of Content int bakeCount = 0; + Dictionary bakedMapMembers = new(); onOperationProgressed?.Invoke("Adding to Map", bakeCount); - // 3. add layer and tables to the Table Of Content - foreach (var databaseObj in convertedGISObjects) + foreach (var item in conversionTracker) { cancellationToken.ThrowIfCancellationRequested(); + var trackerItem = conversionTracker[item.Key]; // updated tracker object // BAKE OBJECTS HERE - bakedObjectIds.Add(AddDatasetsToMap(databaseObj)); - onOperationProgressed?.Invoke("Adding to Map", (double)++bakeCount / convertedGISObjects.Count); + if (trackerItem.Exception != null) + { + results.Add(new(Status.ERROR, trackerItem.Base, null, null, trackerItem.Exception)); + } + else if (trackerItem.DatasetId == null) + { + results.Add( + new(Status.ERROR, trackerItem.Base, null, null, new ArgumentException("Unknown error: Dataset not created")) + ); + } + else if (bakedMapMembers.TryGetValue(trackerItem.DatasetId, out MapMember? value)) + { + // only add a report item + AddResultsFromTracker(trackerItem, results); + } + else + { + // add layer and layer URI to tracker + MapMember mapMember = AddDatasetsToMap(trackerItem); + trackerItem.AddConvertedMapMember(mapMember); + trackerItem.AddLayerURI(mapMember.URI); + conversionTracker[item.Key] = trackerItem; + + // add layer URI to bakedIds + bakedObjectIds.Add(trackerItem.MappedLayerURI == null ? "" : trackerItem.MappedLayerURI); + + // add report item + AddResultsFromTracker(trackerItem, results); + } + onOperationProgressed?.Invoke("Adding to Map", (double)++bakeCount / conversionTracker.Count); } // TODO: validated a correct set regarding bakedobject ids return new(bakedObjectIds, results); } + private void AddResultsFromTracker(ObjectConversionTracker trackerItem, List results) + { + // prioritize individual hostAppGeometry type, if available: + if (trackerItem.HostAppGeom != null) + { + results.Add( + new(Status.SUCCESS, trackerItem.Base, trackerItem.MappedLayerURI, trackerItem.HostAppGeom.GetType().ToString()) + ); + } + else + { + results.Add( + new( + Status.SUCCESS, + trackerItem.Base, + trackerItem.MappedLayerURI, + trackerItem.HostAppMapMember?.GetType().ToString() + ) + ); + } + } + + private MapMember AddDatasetsToMap(ObjectConversionTracker trackerItem) + { + string? datasetId = trackerItem.DatasetId; // should not ne null here + string nestedLayerName = trackerItem.NestedLayerName; + + Uri uri = new($"{_contextStack.Current.Document.SpeckleDatabasePath.AbsolutePath.Replace('/', '\\')}\\{datasetId}"); + Map map = _contextStack.Current.Document.Map; + + // Most of the Speckle-written datasets will be containing geometry and added as Layers + // although, some datasets might be just tables (e.g. native GIS Tables, in the future maybe Revit schedules etc. + // We can create a connection to the dataset in advance and determine its type, but this will be more + // expensive, than assuming by default that it's a layer with geometry (which in most cases it's expected to be) + try + { + var layer = LayerFactory.Instance.CreateLayer(uri, map, layerName: nestedLayerName); + return layer; + } + catch (ArgumentException) + { + var table = StandaloneTableFactory.Instance.CreateStandaloneTable(uri, map, tableName: nestedLayerName); + return table; + } + } + [Pure] private static string[] GetLayerPath(TraversalContext context) { diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/ArcGISProjectUtils.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/ArcGISProjectUtils.cs deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/ConversionTracker.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/ConversionTracker.cs new file mode 100644 index 0000000000..cb01772ed7 --- /dev/null +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/ConversionTracker.cs @@ -0,0 +1,88 @@ +using ArcGIS.Desktop.Mapping; +using Speckle.Core.Models; + +namespace Speckle.Converters.ArcGIS3.Utils; + +/// +/// Container connecting the received Base object, converted hostApp object, dataset it was written to, +/// URI of the layer mapped from the dataset and, if applicable, feature/row id. +/// +public struct ObjectConversionTracker +{ + public Base Base { get; set; } + public string NestedLayerName { get; set; } + public ACG.Geometry? HostAppGeom { get; set; } + public MapMember? HostAppMapMember { get; set; } + public string? DatasetId { get; set; } + public int? DatasetRow { get; set; } + public string? MappedLayerURI { get; set; } + public Exception? Exception { get; set; } + + public void AddException(Exception ex) + { + Exception = ex; + HostAppGeom = null; + DatasetId = null; + DatasetRow = null; + MappedLayerURI = null; + } + + public void AddDatasetId(string datasetId) + { + DatasetId = datasetId; + } + + public void AddDatasetRow(int datasetRow) + { + DatasetRow = datasetRow; + } + + public void AddConvertedMapMember(MapMember mapMember) + { + HostAppMapMember = mapMember; + } + + public void AddLayerURI(string layerURIstring) + { + MappedLayerURI = layerURIstring; + } + + /// + /// Initializes a new instance of . + /// + /// Original received Base object. + /// String with the full traversed path to the object. Will be used to create nested layer structure in the TOC. + public ObjectConversionTracker(Base baseObj, string nestedLayerName) + { + Base = baseObj; + NestedLayerName = nestedLayerName; + } + + /// + /// Constructor for received non-GIS geometries. + /// Initializes a new instance of , accepting converted hostApp geometry. + /// + /// Original received Base object. + /// String with the full traversed path to the object. Will be used to create nested layer structure in the TOC. + /// Converted ArcGIS.Core.Geometry. + public ObjectConversionTracker(Base baseObj, string nestedLayerName, ACG.Geometry hostAppGeom) + { + Base = baseObj; + NestedLayerName = nestedLayerName; + HostAppGeom = hostAppGeom; + } + + /// + /// Constructor for received native GIS layers. + /// Initializes a new instance of , accepting datasetID of a coverted Speckle layer. + /// + /// Original received Base object. + /// String with the full traversed path to the object. Will be used to create nested layer structure in the TOC. + /// ID of the locally written dataset, created from received Speckle layer. + public ObjectConversionTracker(Base baseObj, string nestedLayerName, string datasetId) + { + Base = baseObj; + NestedLayerName = nestedLayerName; + DatasetId = datasetId; + } +} diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/INonNativeFeaturesUtils.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/INonNativeFeaturesUtils.cs index 1f4295b457..25cd904fca 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/INonNativeFeaturesUtils.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/INonNativeFeaturesUtils.cs @@ -4,7 +4,5 @@ namespace Speckle.Converters.ArcGIS3.Utils; public interface INonNativeFeaturesUtils { - public List<(string parentPath, string converted)> WriteGeometriesToDatasets( - Dictionary convertedObjs - ); + public void WriteGeometriesToDatasets(Dictionary conversionTracker); } diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/NonNativeFeaturesUtils.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/NonNativeFeaturesUtils.cs index 621ad260ca..7f91dbbf32 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/NonNativeFeaturesUtils.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/NonNativeFeaturesUtils.cs @@ -23,35 +23,58 @@ public NonNativeFeaturesUtils( _contextStack = contextStack; } - public List<(string parentPath, string converted)> WriteGeometriesToDatasets( - Dictionary convertedObjs + public void WriteGeometriesToDatasets( + // Dictionary conversionTracker + Dictionary conversionTracker ) { - List<(string parentPath, string converted)> result = new(); // 1. Sort features into groups by path and geom type - Dictionary geometries, string? parentId)> geometryGroups = new(); - foreach (var item in convertedObjs) + Dictionary> geometryGroups = new(); + foreach (var item in conversionTracker) { try { TraversalContext context = item.Key; - (string parentPath, ACG.Geometry geom) = item.Value; + var trackerItem = item.Value; + ACG.Geometry? geom = trackerItem.HostAppGeom; + string? datasetId = trackerItem.DatasetId; + if (geom != null && datasetId == null) // only non-native geomerties, not written into a dataset yet + { + string nestedParentPath = trackerItem.NestedLayerName; + string speckle_type = nestedParentPath.Split('\\')[^1]; + + string? parentId = context.Parent?.Current.id; + + // add dictionnary item if doesn't exist yet + // Key must be unique per parent and speckle_type + string uniqueKey = $"speckleTYPE_{speckle_type}_speckleID_{parentId}"; + if (!geometryGroups.TryGetValue(uniqueKey, out _)) + { + geometryGroups[uniqueKey] = new List(); + } - string? parentId = context.Parent?.Current.id; - // add dictionnary item if doesn't exist yet - // Key must be unique per parent and speckle_type - // Key is composed of parentId and parentPath (that contains speckle_type) - string uniqueKey = $"{parentId}_{parentPath}"; - if (!geometryGroups.TryGetValue(uniqueKey, out _)) + geometryGroups[uniqueKey].Add(geom); + + // record changes in conversion tracker + trackerItem.AddDatasetId(uniqueKey); + trackerItem.AddDatasetRow(geometryGroups[uniqueKey].Count - 1); + conversionTracker[item.Key] = trackerItem; + } + else if (geom == null && datasetId != null) // GIS layers, already written to a dataset { - geometryGroups[uniqueKey] = (new List(), parentId); + continue; + } + else + { + throw new ArgumentException($"Unexpected geometry and datasetId values: {geom}, {datasetId}"); } - - geometryGroups[uniqueKey].geometries.Add(geom); } catch (Exception ex) when (!ex.IsFatal()) { // POC: report, etc. + var trackerItem = item.Value; + trackerItem.AddException(ex); + conversionTracker[item.Key] = trackerItem; Debug.WriteLine($"conversion error happened. {ex.Message}"); } } @@ -59,24 +82,30 @@ public NonNativeFeaturesUtils( // 2. for each group create a Dataset and add geometries there as Features foreach (var item in geometryGroups) { - string uniqueKey = item.Key; // parentId_parentPath - string parentPath = uniqueKey.Split('_', 2)[^1]; - string speckle_type = parentPath.Split('\\')[^1]; - (List geomList, string? parentId) = item.Value; + string uniqueKey = item.Key; + List geomList = item.Value; try { - string converted = CreateDatasetInDatabase(speckle_type, geomList, parentId); - result.Add((parentPath, converted)); + CreateDatasetInDatabase(uniqueKey, geomList); } - catch (GeodatabaseGeometryException) + catch (GeodatabaseGeometryException ex) { // do nothing if writing of some geometry groups fails + // only record in conversionTracker: + foreach (var conversionItem in conversionTracker) + { + if (conversionItem.Value.DatasetId == uniqueKey) + { + var trackerItem = conversionItem.Value; + trackerItem.AddException(ex); + conversionTracker[conversionItem.Key] = trackerItem; + } + } } } - return result; } - private string CreateDatasetInDatabase(string speckle_type, List geomList, string? parentId) + private void CreateDatasetInDatabase(string featureClassName, List geomList) { FileGeodatabaseConnectionPath fileGeodatabaseConnectionPath = new(_contextStack.Current.Document.SpeckleDatabasePath); @@ -89,9 +118,6 @@ private string CreateDatasetInDatabase(string speckle_type, List g // TODO: create Fields List fields = new(); // _fieldsUtils.GetFieldsFromSpeckleLayer(target); - // TODO: generate meaningful name - string featureClassName = $"speckleTYPE_{speckle_type}_speckleID_{parentId}"; - // delete FeatureClass if already exists foreach (FeatureClassDefinition fClassDefinition in geodatabase.GetDefinitions()) { @@ -131,7 +157,5 @@ private string CreateDatasetInDatabase(string speckle_type, List g { _featureClassUtils.AddNonGISFeaturesToFeatureClass(newFeatureClass, geomList, fields); }); - - return featureClassName; } } From ccf143e8f9cadf6a6600942aee72f5411697fd0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?O=C4=9Fuzhan=20Koral?= <45078678+oguzhankoral@users.noreply.github.com> Date: Thu, 13 Jun 2024 15:41:55 +0300 Subject: [PATCH 227/261] DUI3-174 Cancel ops on doc swap (#3504) * Revit, Acad cancel all ops and set global notification to UI - UI is implemented * Document SetGlobalNotification * Remove old ICancelable from bindings * Remove autocad logic --- .../Bindings/ArcGISReceiveBinding.cs | 10 +------ .../Bindings/ArcGISSendBinding.cs | 10 +------ .../Bindings/AutocadReceiveBinding.cs | 15 +--------- .../Bindings/AutocadSendBinding.cs | 10 +------ .../Bindings/RevitSendBinding.cs | 28 +++++++++++++++---- .../Bindings/RhinoReceiveBinding.cs | 19 ++++--------- .../Bindings/RhinoSendBinding.cs | 10 +------ .../Bindings/IBasicConnectorBinding.cs | 28 +++++++++++++++++++ .../Cancellation/CancellationManager.cs | 12 ++++++++ 9 files changed, 74 insertions(+), 68 deletions(-) diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISReceiveBinding.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISReceiveBinding.cs index 6541824541..fcccc93f25 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISReceiveBinding.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISReceiveBinding.cs @@ -6,11 +6,10 @@ using Speckle.Connectors.Utils; using Speckle.Connectors.Utils.Cancellation; using Speckle.Connectors.Utils.Operations; -using ICancelable = System.Reactive.Disposables.ICancelable; namespace Speckle.Connectors.ArcGIS.Bindings; -public sealed class ArcGISReceiveBinding : IReceiveBinding, ICancelable +public sealed class ArcGISReceiveBinding : IReceiveBinding { public string Name { get; } = "receiveBinding"; private readonly CancellationManager _cancellationManager; @@ -84,11 +83,4 @@ private void OnSendOperationProgress(string modelCardId, string status, double? } public void CancelReceive(string modelCardId) => _cancellationManager.CancelOperation(modelCardId); - - public void Dispose() - { - IsDisposed = true; - } - - public bool IsDisposed { get; private set; } } diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISSendBinding.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISSendBinding.cs index 95a4a0abc5..3773833114 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISSendBinding.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISSendBinding.cs @@ -3,7 +3,6 @@ using Speckle.Connectors.DUI.Bindings; using Speckle.Connectors.DUI.Bridge; using Speckle.Connectors.Utils.Cancellation; -using ICancelable = System.Reactive.Disposables.ICancelable; using Speckle.Connectors.DUI.Models; using Speckle.Connectors.DUI.Models.Card; using Speckle.Connectors.DUI.Models.Card.SendFilter; @@ -21,7 +20,7 @@ namespace Speckle.Connectors.ArcGIS.Bindings; -public sealed class ArcGISSendBinding : ISendBinding, ICancelable +public sealed class ArcGISSendBinding : ISendBinding { public string Name => "sendBinding"; public SendBindingUICommands Commands { get; } @@ -364,11 +363,4 @@ private void OnSendOperationProgress(string modelCardId, string status, double? { Commands.SetModelProgress(modelCardId, new ModelCardProgress(modelCardId, status, progress)); } - - public void Dispose() - { - IsDisposed = true; - } - - public bool IsDisposed { get; private set; } } diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadReceiveBinding.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadReceiveBinding.cs index 7c91a049dd..da2e5b34c0 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadReceiveBinding.cs +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadReceiveBinding.cs @@ -6,11 +6,10 @@ using Speckle.Connectors.DUI.Models.Card; using Speckle.Connectors.Utils; using Speckle.Connectors.Utils.Operations; -using ICancelable = System.Reactive.Disposables.ICancelable; namespace Speckle.Connectors.Autocad.Bindings; -public sealed class AutocadReceiveBinding : IReceiveBinding, ICancelable +public sealed class AutocadReceiveBinding : IReceiveBinding { public string Name => "receiveBinding"; public IBridge Parent { get; } @@ -79,16 +78,4 @@ private void OnSendOperationProgress(string modelCardId, string status, double? { Commands.SetModelProgress(modelCardId, new ModelCardProgress(modelCardId, status, progress)); } - - // POC: JEDD: We should not update the UI until a OperationCancelledException is caught, we don't want to show the UI as cancelled - // until the actual operation is cancelled (thrown exception). - // I think there's room for us to introduce a cancellation pattern for bindings to do this and avoid this _cancellationManager - public void CancelSend(string modelCardId) => _cancellationManager.CancelOperation(modelCardId); - - public void Dispose() - { - IsDisposed = true; - } - - public bool IsDisposed { get; private set; } } diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadSendBinding.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadSendBinding.cs index a994b9eb9f..296dd64359 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadSendBinding.cs +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadSendBinding.cs @@ -10,14 +10,13 @@ using Speckle.Connectors.Autocad.Operations.Send; using Speckle.Connectors.DUI.Exceptions; using Speckle.Connectors.Utils.Operations; -using ICancelable = System.Reactive.Disposables.ICancelable; using Speckle.Connectors.DUI.Models.Card.SendFilter; using Speckle.Connectors.Utils; using Speckle.Connectors.Utils.Caching; namespace Speckle.Connectors.Autocad.Bindings; -public sealed class AutocadSendBinding : ISendBinding, ICancelable +public sealed class AutocadSendBinding : ISendBinding { public string Name { get; } = "sendBinding"; public SendBindingUICommands Commands { get; } @@ -178,11 +177,4 @@ private void OnSendOperationProgress(string modelCardId, string status, double? } public void CancelSend(string modelCardId) => _cancellationManager.CancelOperation(modelCardId); - - public void Dispose() - { - IsDisposed = true; - } - - public bool IsDisposed { get; private set; } } diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/RevitSendBinding.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/RevitSendBinding.cs index bbfa2a815b..da070b51f4 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/RevitSendBinding.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/RevitSendBinding.cs @@ -1,6 +1,5 @@ using Autodesk.Revit.DB; using Speckle.Connectors.DUI.Models.Card.SendFilter; -using Speckle.Connectors.Utils.Cancellation; using Speckle.Connectors.DUI.Bridge; using Speckle.Connectors.Revit.Plugin; using Speckle.Connectors.Utils; @@ -11,20 +10,21 @@ using Speckle.Connectors.DUI.Exceptions; using Speckle.Connectors.DUI.Models; using Speckle.Connectors.Utils.Caching; +using Speckle.Connectors.Utils.Cancellation; using Speckle.Connectors.Utils.Operations; namespace Speckle.Connectors.Revit.Bindings; -internal sealed class RevitSendBinding : RevitBaseBinding, ICancelable, ISendBinding +internal sealed class RevitSendBinding : RevitBaseBinding, ISendBinding { // POC:does it need injecting? - public CancellationManager CancellationManager { get; } = new(); // POC: does it need injecting? private HashSet ChangedObjectIds { get; set; } = new(); private readonly RevitSettings _revitSettings; private readonly IRevitIdleManager _idleManager; + private readonly CancellationManager _cancellationManager; private readonly IUnitOfWorkFactory _unitOfWorkFactory; private readonly ISendConversionCache _sendConversionCache; @@ -32,6 +32,7 @@ public RevitSendBinding( IRevitIdleManager idleManager, RevitContext revitContext, DocumentModelStore store, + CancellationManager cancellationManager, IBridge bridge, IUnitOfWorkFactory unitOfWorkFactory, RevitSettings revitSettings, @@ -40,6 +41,7 @@ ISendConversionCache sendConversionCache : base("sendBinding", store, bridge, revitContext) { _idleManager = idleManager; + _cancellationManager = cancellationManager; _unitOfWorkFactory = unitOfWorkFactory; _revitSettings = revitSettings; _sendConversionCache = sendConversionCache; @@ -48,6 +50,7 @@ ISendConversionCache sendConversionCache // TODO expiry events // TODO filters need refresh events revitContext.UIApplication.NotNull().Application.DocumentChanged += (_, e) => DocChangeHandler(e); + Store.DocumentChanged += (_, _) => OnDocumentChanged(); } public List GetSendFilters() @@ -57,7 +60,7 @@ public List GetSendFilters() public void CancelSend(string modelCardId) { - CancellationManager.CancelOperation(modelCardId); + _cancellationManager.CancelOperation(modelCardId); } public SendBindingUICommands Commands { get; } @@ -75,7 +78,7 @@ public async Task Send(string modelCardId) // POC: probably the CTS SHOULD be injected as InstancePerLifetimeScope and then // it can be injected where needed instead of passing it around like a bomb :D - CancellationTokenSource cts = CancellationManager.InitCancellationTokenSource(modelCardId); + CancellationTokenSource cts = _cancellationManager.InitCancellationTokenSource(modelCardId); using IUnitOfWork> sendOperation = _unitOfWorkFactory.Resolve< SendOperation @@ -178,4 +181,19 @@ private void RunExpirationChecks() Commands.SetModelsExpired(expiredSenderIds); ChangedObjectIds = new HashSet(); } + + // POC: Will be re-addressed later with better UX with host apps that are friendly on async doc operations. + // That's why don't bother for now how to get rid of from dup logic in other bindings. + private void OnDocumentChanged() + { + if (_cancellationManager.NumberOfOperations > 0) + { + _cancellationManager.CancelAllOperations(); + Commands.SetGlobalNotification( + ToastNotificationType.INFO, + "Document Switch", + "Operations cancelled because of document swap!" + ); + } + } } diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoReceiveBinding.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoReceiveBinding.cs index 5b27b6b69e..0314a0f78f 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoReceiveBinding.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoReceiveBinding.cs @@ -10,12 +10,12 @@ namespace Speckle.Connectors.Rhino7.Bindings; -public class RhinoReceiveBinding : IReceiveBinding, ICancelable +public class RhinoReceiveBinding : IReceiveBinding { public string Name { get; set; } = "receiveBinding"; public IBridge Parent { get; set; } - public CancellationManager CancellationManager { get; set; } + private readonly CancellationManager _cancellationManager; private readonly DocumentModelStore _store; private readonly IUnitOfWorkFactory _unitOfWorkFactory; public ReceiveBindingUICommands Commands { get; } @@ -30,11 +30,11 @@ IUnitOfWorkFactory unitOfWorkFactory Parent = parent; _store = store; _unitOfWorkFactory = unitOfWorkFactory; - CancellationManager = cancellationManager; + _cancellationManager = cancellationManager; Commands = new ReceiveBindingUICommands(parent); } - public void CancelReceive(string modelCardId) => CancellationManager.CancelOperation(modelCardId); + public void CancelReceive(string modelCardId) => _cancellationManager.CancelOperation(modelCardId); public async Task Receive(string modelCardId) { @@ -49,7 +49,7 @@ public async Task Receive(string modelCardId) } // Init cancellation token source -> Manager also cancel it if exist before - CancellationTokenSource cts = CancellationManager.InitCancellationTokenSource(modelCardId); + CancellationTokenSource cts = _cancellationManager.InitCancellationTokenSource(modelCardId); // Receive host objects HostObjectBuilderResult conversionResults = await unitOfWork.Service @@ -84,12 +84,5 @@ private void OnSendOperationProgress(string modelCardId, string status, double? Commands.SetModelProgress(modelCardId, new ModelCardProgress(modelCardId, status, progress)); } - public void CancelSend(string modelCardId) => CancellationManager.CancelOperation(modelCardId); - - public void Dispose() - { - IsDisposed = true; - } - - public bool IsDisposed { get; private set; } + public void CancelSend(string modelCardId) => _cancellationManager.CancelOperation(modelCardId); } diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSendBinding.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSendBinding.cs index 6f3b66e6ff..8f8594f193 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSendBinding.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSendBinding.cs @@ -5,7 +5,6 @@ using Speckle.Connectors.DUI.Models.Card; using Speckle.Connectors.Rhino7.HostApp; using Speckle.Connectors.Utils.Cancellation; -using ICancelable = System.Reactive.Disposables.ICancelable; using Speckle.Autofac.DependencyInjection; using Rhino.DocObjects; using Speckle.Connectors.DUI.Exceptions; @@ -17,7 +16,7 @@ namespace Speckle.Connectors.Rhino7.Bindings; -public sealed class RhinoSendBinding : ISendBinding, ICancelable +public sealed class RhinoSendBinding : ISendBinding { public string Name { get; } = "sendBinding"; public SendBindingUICommands Commands { get; } @@ -213,11 +212,4 @@ private void RunExpirationChecks() Commands.SetModelsExpired(expiredSenderIds); ChangedObjectIds = new HashSet(); } - - public void Dispose() - { - IsDisposed = true; - } - - public bool IsDisposed { get; private set; } } diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/IBasicConnectorBinding.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/IBasicConnectorBinding.cs index 2ac4dcb62e..966be49fe2 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/IBasicConnectorBinding.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/IBasicConnectorBinding.cs @@ -32,11 +32,20 @@ public static class BasicConnectorBindingEvents public const string DOCUMENT_CHANGED = "documentChanged"; } +public enum ToastNotificationType +{ + SUCCESS, + WARNING, + DANGER, + INFO +} + public class BasicConnectorBindingCommands { private const string NOTIFY_DOCUMENT_CHANGED_EVENT_NAME = "documentChanged"; private const string SET_MODEL_PROGRESS_UI_COMMAND_NAME = "setModelProgress"; private const string SET_MODEL_ERROR_UI_COMMAND_NAME = "setModelError"; + private const string SET_GLOBAL_NOTIFICATION = "setGlobalNotification"; protected IBridge Bridge { get; } @@ -47,6 +56,25 @@ public BasicConnectorBindingCommands(IBridge bridge) public void NotifyDocumentChanged() => Bridge.Send(NOTIFY_DOCUMENT_CHANGED_EVENT_NAME); + /// + /// Use it whenever you want to send global toast notification to UI. + /// + /// Level of notification, see for types + /// Title of the notification + /// Message in the toast notification. + /// Closes toast notification in set timeout in UI. Default is true. + public void SetGlobalNotification(ToastNotificationType type, string title, string message, bool autoClose = true) => + Bridge.Send( + SET_GLOBAL_NOTIFICATION, + new + { + type, + title, + description = message, + autoClose + } + ); + public void SetModelProgress(string modelCardId, ModelCardProgress progress) => Bridge.Send(SET_MODEL_PROGRESS_UI_COMMAND_NAME, new { modelCardId, progress }); diff --git a/DUI3-DX/Sdk/Speckle.Connectors.Utils/Cancellation/CancellationManager.cs b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Cancellation/CancellationManager.cs index e11dbb781a..0f917fd981 100644 --- a/DUI3-DX/Sdk/Speckle.Connectors.Utils/Cancellation/CancellationManager.cs +++ b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Cancellation/CancellationManager.cs @@ -10,6 +10,8 @@ public class CancellationManager /// private readonly Dictionary _operationsInProgress = new(); + public int NumberOfOperations => _operationsInProgress.Count; + /// /// Get token with registered id. /// @@ -30,6 +32,16 @@ public bool IsExist(string id) return _operationsInProgress.ContainsKey(id); } + public void CancelAllOperations() + { + foreach (var operation in _operationsInProgress) + { + operation.Value.Cancel(); + operation.Value.Dispose(); + } + _operationsInProgress.Clear(); + } + /// /// Initialize a token source for cancellable operation. /// From 6b767fee75b836ce5f6ba3fc9d3dba9220070805 Mon Sep 17 00:00:00 2001 From: Dimitrie Stefanescu Date: Thu, 13 Jun 2024 15:31:47 +0100 Subject: [PATCH 228/261] fix(dui3): corrects IRootObjectBuilder registration (#3505) --- .../DependencyInjection/ArcGISConnectorModule.cs | 2 +- .../DependencyInjection/AutocadConnectorModule.cs | 2 +- .../DependencyInjection/RhinoConnectorModule.cs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/DependencyInjection/ArcGISConnectorModule.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/DependencyInjection/ArcGISConnectorModule.cs index 1c5c0a8559..c76e79c4ab 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/DependencyInjection/ArcGISConnectorModule.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/DependencyInjection/ArcGISConnectorModule.cs @@ -55,7 +55,7 @@ public void Load(SpeckleContainerBuilder builder) // register send operation and dependencies builder.AddScoped>(); builder.AddScoped(); - builder.AddSingleton, ArcGISRootObjectBuilder>(); + builder.AddScoped, ArcGISRootObjectBuilder>(); // register send conversion cache builder.AddSingleton(); diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/DependencyInjection/AutocadConnectorModule.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/DependencyInjection/AutocadConnectorModule.cs index 98733f04d2..f4a970b1d0 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/DependencyInjection/AutocadConnectorModule.cs +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/DependencyInjection/AutocadConnectorModule.cs @@ -44,7 +44,7 @@ public void Load(SpeckleContainerBuilder builder) // Object Builders builder.AddScoped(); - builder.AddSingleton, AutocadRootObjectBuilder>(); + builder.AddScoped, AutocadRootObjectBuilder>(); // Register bindings diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/RhinoConnectorModule.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/RhinoConnectorModule.cs index 96d6aaa56b..a227755c66 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/RhinoConnectorModule.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/RhinoConnectorModule.cs @@ -70,6 +70,6 @@ public void Load(SpeckleContainerBuilder builder) builder.AddScoped>(); builder.AddSingleton(DefaultTraversal.CreateTraversalFunc()); - builder.AddSingleton, RhinoRootObjectBuilder>(); + builder.AddScoped, RhinoRootObjectBuilder>(); } } From 76c6aba5f65c95cdb5aa2b2f4c8473c724ba8d6d Mon Sep 17 00:00:00 2001 From: Adam Hathcock Date: Fri, 14 Jun 2024 09:26:32 +0100 Subject: [PATCH 229/261] Convert revit converters to use proxies for unit testing (#3501) * Initial commit from converter-tests * tests now run * adding more to proxy map * switch to FluentAssertions * fix IRevitLevel conversions * more cast handling * use proxymap for ofclass * update revit interfaces * fmt * add more proxies * better handling for wrapped types * fix the RevitContext * inject interfaces * convert to new way of casting * update and rejigger dependencies * handle null elements * proxy map is also proxy aware * fmt * change namespaces * updates to proxies * more cast changes * another cast issue fixed * update nugets * fmt * add System.IO to make CI happy? --- All.sln | 25 +- Build/Consts.cs | 1 + Build/Program.cs | 5 +- DUI3-DX.slnf | 1 + .../Speckle.Connectors.Revit2023.csproj | 2 +- .../Bindings/BasicConnectorBindingRevit.cs | 2 +- .../Bindings/RevitBaseBinding.cs | 2 +- .../Bindings/RevitSendBinding.cs | 2 +- .../Bindings/SelectionBinding.cs | 2 +- .../DependencyInjection/ProxyMap.cs | 80 +++ .../RevitConnectorModule.cs | 12 +- .../GlobalUsings.cs | 1 + .../Helpers/RevitContext.cs | 4 +- .../Helpers/RevitConversionContextStack.cs | 38 ++ .../HostApp/RevitDocumentStore.cs | 2 +- .../Operations/Send/RevitRootObjectBuilder.cs | 11 +- .../Plugin/RevitExternalApplication.cs | 3 +- .../Plugin/RevitIdleManager.cs | 2 +- .../Plugin/RevitPlugin.cs | 5 +- .../Speckle.Connectors.RevitShared.projitems | 23 +- .../RevitConverterModule.cs | 21 +- ...rters.Revit2023.DependencyInjection.csproj | 3 + .../LocationConversionToSpeckleTests.cs | 85 +++ .../Speckle.Converters.Revit2023.Tests.csproj | 28 + .../packages.lock.json | 549 ++++++++++++++++++ .../RevitVersionConversionHelper.cs | 19 - .../Speckle.Converters.Revit2023.csproj | 3 +- .../Extensions/CategoryExtensions.cs | 8 +- .../Extensions/DefinitionExtensions.cs | 8 +- .../Extensions/ElementExtensions.cs | 23 +- .../Extensions/ForgeTypeIdExtensions.cs | 14 +- .../Extensions/ParameterExtensions.cs | 13 +- .../GlobalUsings.cs | 4 +- .../Helpers/DisplayValueExtractor.cs | 188 +++--- .../Helpers/IRevitConversionContextStack.cs | 13 - .../Helpers/ISlopeArrowExtractor.cs | 10 - .../Helpers/ParameterObjectAssigner.cs | 35 +- .../Helpers/ParameterObjectBuilder.cs | 50 -- .../Helpers/ParameterValueExtractor.cs | 157 ++--- .../Helpers/RevitCategories.cs | 150 ----- .../Helpers/RevitCategoryInfo.cs | 65 --- .../Helpers/RevitConversionContextStack.cs | 28 - .../Helpers/SendSelection.cs | 17 - .../Helpers/SlopeArrowExtractor.cs | 71 ++- .../Helpers/ToSpeckleConvertedObjectsCache.cs | 25 - .../IReferencePointConverter.cs | 6 - .../IRevitVersionConversionHelper.cs | 6 - .../Raw/BeamConversionToSpeckle.cs | 40 +- .../Raw/BoundarySegmentConversionToSpeckle.cs | 13 +- .../Raw/BraceToSpeckleConverter.cs | 15 +- .../Raw/ColumnConversionToSpeckle.cs | 64 +- .../Raw/Geometry/ArcToSpeckleConverter.cs | 42 +- .../BoundingBoxXYZToSpeckleConverter.cs | 26 +- .../Raw/Geometry/CircleToSpeckleConverter.cs | 24 +- ...urveArrArrayToSpecklePolycurveConverter.cs | 27 +- .../Geometry/CurveArrayConversionToSpeckle.cs | 30 +- .../Raw/Geometry/CurveConversionToSpeckle.cs | 67 ++- .../Raw/Geometry/EllipseToSpeckleConverter.cs | 32 +- .../HermiteSplineToSpeckleConverter.cs | 18 +- .../Raw/Geometry/LineConversionToSpeckle.cs | 21 +- .../MeshByMaterialDictionaryToSpeckle.cs | 41 +- .../Raw/Geometry/MeshConversionToSpeckle.cs | 37 +- .../Geometry/NurbsSplineToSpeckleConverter.cs | 27 +- .../Raw/Geometry/PlaneToSpeckleConverter.cs | 19 +- .../Geometry/PointCloudToSpeckleConverter.cs | 41 +- .../Raw/Geometry/PointConversionToSpeckle.cs | 11 +- .../Geometry/PolylineToSpeckleConverter.cs | 15 +- .../Raw/Geometry/SolidConversionToSpeckle.cs | 40 +- .../Raw/Geometry/VectorToSpeckleConverter.cs | 13 +- .../Raw/Geometry/XyzConversionToPoint.cs | 16 +- .../Raw/LevelConversionToSpeckle.cs | 13 +- .../Raw/LocationConversionToSpeckle.cs | 37 +- .../Raw/MaterialConversionToSpeckle.cs | 7 +- .../ModelCurveArrArrayConverterToSpeckle.cs | 30 + .../ModelCurveArrArrayToSpeckleConverter.cs | 28 - .../Raw/ModelCurveArrayToSpeckleConverter.cs | 30 +- .../Raw/ParameterConversionToSpeckle.cs | 27 +- .../Raw/RevitVersionConversionHelper.cs | 23 + .../RevitConstants.cs | 6 + .../RevitConversionSettings.cs | 19 - .../RevitRootToHostConverter.cs | 50 -- .../{ => Services}/ReferencePointConverter.cs | 78 ++- .../Services/RevitToSpeckleUnitConverter.cs | 27 +- .../Services/ScalingServiceToSpeckle.cs | 25 +- .../Speckle.Converters.RevitShared.projitems | 68 +-- .../BaseTopLevelConverterToSpeckle.cs | 2 +- .../CeilingTopLevelConverterToSpeckle.cs | 39 +- .../DirectShapeTopLevelConverterToSpeckle.cs | 22 +- .../ElementTopLevelConverterToSpeckle.cs | 20 +- ...ExtrusionRoofToSpeckleTopLevelConverter.cs | 61 +- ...amilyInstanceTopLevelConverterToSpeckle.cs | 32 +- .../FloorTopLevelConverterToSpeckle.cs | 50 +- ...FootPrintRoofToSpeckleTopLevelConverter.cs | 58 +- .../HostedElementConversionToSpeckle.cs | 20 +- .../ModelCurveToSpeckleTopLevelConverter.cs | 19 +- ...fBaseToSpeckleTopLevelTopLevelConverter.cs | 31 +- .../RoomTopLevelConverterToSpeckle.cs | 39 +- .../TopographyTopLevelConverterToSpeckle.cs | 17 +- .../WallTopLevelConverterToSpeckle.cs | 88 +-- .../ISpeckleContainerContext.cs | 7 + .../SpeckleContainerBuilder.cs | 36 ++ .../ContainerRegistration.cs | 2 +- .../NamedTypeInjector.cs | 22 +- .../RawConversionRegisterer.cs | 23 +- .../ContextWrapper.cs | 2 +- .../ConversionContext.cs | 8 +- .../ConversionContextStack.cs | 9 +- ...Converter.cs => RootToSpeckleConverter.cs} | 20 +- .../Speckle.Converters.Common.csproj | 4 +- 109 files changed, 2070 insertions(+), 1530 deletions(-) create mode 100644 DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/ProxyMap.cs create mode 100644 DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/GlobalUsings.cs rename DUI3-DX/{Converters/Revit/Speckle.Converters.RevitShared => Connectors/Revit/Speckle.Connectors.RevitShared}/Helpers/RevitContext.cs (80%) create mode 100644 DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Helpers/RevitConversionContextStack.cs create mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/LocationConversionToSpeckleTests.cs create mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/Speckle.Converters.Revit2023.Tests.csproj create mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/packages.lock.json delete mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023/RevitVersionConversionHelper.cs delete mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/IRevitConversionContextStack.cs delete mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/ISlopeArrowExtractor.cs delete mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/ParameterObjectBuilder.cs delete mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/RevitCategories.cs delete mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/RevitCategoryInfo.cs delete mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/RevitConversionContextStack.cs delete mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/SendSelection.cs delete mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/ToSpeckleConvertedObjectsCache.cs delete mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/IReferencePointConverter.cs delete mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/IRevitVersionConversionHelper.cs create mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ModelCurveArrArrayConverterToSpeckle.cs delete mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ModelCurveArrArrayToSpeckleConverter.cs create mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/RevitVersionConversionHelper.cs create mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/RevitConstants.cs delete mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/RevitConversionSettings.cs delete mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/RevitRootToHostConverter.cs rename DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/{ => Services}/ReferencePointConverter.cs (50%) create mode 100644 DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/ISpeckleContainerContext.cs rename DUI3-DX/Sdk/Speckle.Converters.Common/{IRootToSpeckleConverter.cs => RootToSpeckleConverter.cs} (55%) diff --git a/All.sln b/All.sln index d62369f249..ff3a26c713 100644 --- a/All.sln +++ b/All.sln @@ -347,6 +347,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution CodeMetricsConfig.txt = CodeMetricsConfig.txt Directory.Build.props = Directory.Build.props Directory.Build.targets = Directory.Build.targets + global.json = global.json EndProjectSection EndProject Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "ConnectorAutocadCivilShared", "ConnectorAutocadCivil\ConnectorAutocadCivil\ConnectorAutocadCivilShared.shproj", "{B47492D9-2EDA-4016-A930-7FA708C85C3D}" @@ -536,7 +537,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Workflows", "Workflows", "{ ProjectSection(SolutionItems) = preProject .github\workflows\ci.yml = .github\workflows\ci.yml .github\workflows\main.yml = .github\workflows\main.yml - .github\workflows\test.yml = .github\workflows\test.yml EndProjectSection EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RevitSharedResources2025", "ConnectorRevit\RevitSharedResources2025\RevitSharedResources2025.csproj", "{7B02BACC-D9B6-4FFE-A450-7ECB5F71F209}" @@ -553,6 +553,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConnectorCivil2025", "Conne EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConverterCivil2025", "Objects\Converters\ConverterAutocadCivil\ConverterCivil2025\ConverterCivil2025.csproj", "{F06E4C37-4076-4272-9CA6-FB505E02CD31}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{B1324D25-C601-40F2-8AE2-6131F492B911}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Speckle.Converters.Revit2023.Tests", "DUI3-DX\Converters\Revit\Speckle.Converters.Revit2023.Tests\Speckle.Converters.Revit2023.Tests.csproj", "{AEC26A0B-25F3-4544-A9D6-A427BFF79250}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug Mac|Any CPU = Debug Mac|Any CPU @@ -2787,6 +2791,22 @@ Global {F06E4C37-4076-4272-9CA6-FB505E02CD31}.Release|Any CPU.Build.0 = Release|Any CPU {F06E4C37-4076-4272-9CA6-FB505E02CD31}.Release|x64.ActiveCfg = Release|Any CPU {F06E4C37-4076-4272-9CA6-FB505E02CD31}.Release|x64.Build.0 = Release|Any CPU + {AEC26A0B-25F3-4544-A9D6-A427BFF79250}.Debug Mac|Any CPU.ActiveCfg = Debug|Any CPU + {AEC26A0B-25F3-4544-A9D6-A427BFF79250}.Debug Mac|Any CPU.Build.0 = Debug|Any CPU + {AEC26A0B-25F3-4544-A9D6-A427BFF79250}.Debug Mac|x64.ActiveCfg = Debug|Any CPU + {AEC26A0B-25F3-4544-A9D6-A427BFF79250}.Debug Mac|x64.Build.0 = Debug|Any CPU + {AEC26A0B-25F3-4544-A9D6-A427BFF79250}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {AEC26A0B-25F3-4544-A9D6-A427BFF79250}.Debug|Any CPU.Build.0 = Debug|Any CPU + {AEC26A0B-25F3-4544-A9D6-A427BFF79250}.Debug|x64.ActiveCfg = Debug|Any CPU + {AEC26A0B-25F3-4544-A9D6-A427BFF79250}.Debug|x64.Build.0 = Debug|Any CPU + {AEC26A0B-25F3-4544-A9D6-A427BFF79250}.Release Mac|Any CPU.ActiveCfg = Debug|Any CPU + {AEC26A0B-25F3-4544-A9D6-A427BFF79250}.Release Mac|Any CPU.Build.0 = Debug|Any CPU + {AEC26A0B-25F3-4544-A9D6-A427BFF79250}.Release Mac|x64.ActiveCfg = Debug|Any CPU + {AEC26A0B-25F3-4544-A9D6-A427BFF79250}.Release Mac|x64.Build.0 = Debug|Any CPU + {AEC26A0B-25F3-4544-A9D6-A427BFF79250}.Release|Any CPU.ActiveCfg = Release|Any CPU + {AEC26A0B-25F3-4544-A9D6-A427BFF79250}.Release|Any CPU.Build.0 = Release|Any CPU + {AEC26A0B-25F3-4544-A9D6-A427BFF79250}.Release|x64.ActiveCfg = Release|Any CPU + {AEC26A0B-25F3-4544-A9D6-A427BFF79250}.Release|x64.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -2964,7 +2984,6 @@ Global {2E00592E-558D-492D-88F9-3ECEE4C0C7DA} = {9DB74760-01DE-4AC1-A81B-BC7784351D22} {01F98733-7352-47AD-A594-537D979DE3DE} = {4838C66E-8677-4FBD-9609-25376042E981} {DC570FFF-6FE5-47BD-8BC1-B471A6067786} = {4838C66E-8677-4FBD-9609-25376042E981} - {E1C43415-3200-45F4-8BF9-A4DD7D7F2ED6} = {D92751C8-1039-4005-90B2-913E55E0B8BD} {83EAD6F0-3CB3-456A-AD81-072127D0DE0E} = {D92751C8-1039-4005-90B2-913E55E0B8BD} {26391930-F86F-47E0-A5F6-B89919E38CE1} = {D92751C8-1039-4005-90B2-913E55E0B8BD} {D81C0B87-F0C1-4297-A147-02F001FB7E1E} = {FD4D6594-D81E-456F-8F2E-35B09E04A755} @@ -2998,6 +3017,8 @@ Global {829688CD-CECE-4F6C-A5A0-032BB39CD9E0} = {BE521908-7944-46F3-98BF-B47D34509934} {70DEAA13-6DC8-44A0-B287-9E806A8054F1} = {890F3257-FCC2-4ED8-9180-22B3641B494C} {F06E4C37-4076-4272-9CA6-FB505E02CD31} = {BE521908-7944-46F3-98BF-B47D34509934} + {E1C43415-3200-45F4-8BF9-A4DD7D7F2ED6} = {D92751C8-1039-4005-90B2-913E55E0B8BD} + {AEC26A0B-25F3-4544-A9D6-A427BFF79250} = {D92751C8-1039-4005-90B2-913E55E0B8BD} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {1D43D91B-4F01-4A78-8250-CC6F9BD93A14} diff --git a/Build/Consts.cs b/Build/Consts.cs index 9c1eab1ff5..48a14139b0 100644 --- a/Build/Consts.cs +++ b/Build/Consts.cs @@ -5,6 +5,7 @@ namespace Build; public static class Consts { public static readonly string[] Solutions = { "DUI3-DX.slnf" }; + public static readonly string[] TestProjects = { "Speckle.Converters.Revit2023.Tests" }; public static readonly InstallerProject[] InstallerManifests = { diff --git a/Build/Program.cs b/Build/Program.cs index 37675e3a64..815a086a70 100644 --- a/Build/Program.cs +++ b/Build/Program.cs @@ -117,14 +117,15 @@ void RemoveDirectory(string d) Target( TEST, DependsOn(BUILD), - () => + Consts.TestProjects, + t => { IEnumerable GetFiles(string d) { return Glob.Files(".", d); } - foreach (var file in GetFiles("**/*.Test.csproj")) + foreach (var file in GetFiles($"**/{t}.csproj")) { Run("dotnet", $"test {file} -c Release --no-restore --verbosity=normal"); } diff --git a/DUI3-DX.slnf b/DUI3-DX.slnf index bd01603c29..80e74b0b65 100644 --- a/DUI3-DX.slnf +++ b/DUI3-DX.slnf @@ -20,6 +20,7 @@ "DUI3-DX\\Converters\\Autocad\\Speckle.Converters.Autocad2023\\Speckle.Converters.Autocad2023.csproj", "DUI3-DX\\Converters\\Autocad\\Speckle.Converters.AutocadShared\\Speckle.Converters.AutocadShared.shproj", "DUI3-DX\\Converters\\Revit\\Speckle.Converters.Revit2023.DependencyInjection\\Speckle.Converters.Revit2023.DependencyInjection.csproj", + "DUI3-DX\\Converters\\Revit\\Speckle.Converters.Revit2023.Tests\\Speckle.Converters.Revit2023.Tests.csproj", "DUI3-DX\\Converters\\Revit\\Speckle.Converters.Revit2023\\Speckle.Converters.Revit2023.csproj", "DUI3-DX\\Converters\\Revit\\Speckle.Converters.RevitShared\\Speckle.Converters.RevitShared.shproj", "DUI3-DX\\Converters\\Rhino\\Speckle.Converters.Rhino7.DependencyInjection\\Speckle.Converters.Rhino7.DependencyInjection.csproj", diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.Revit2023/Speckle.Connectors.Revit2023.csproj b/DUI3-DX/Connectors/Revit/Speckle.Connectors.Revit2023/Speckle.Connectors.Revit2023.csproj index a24cfec381..893a9a4c12 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.Revit2023/Speckle.Connectors.Revit2023.csproj +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.Revit2023/Speckle.Connectors.Revit2023.csproj @@ -3,6 +3,7 @@ net48 x64 true + false @@ -31,7 +32,6 @@ - diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/BasicConnectorBindingRevit.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/BasicConnectorBindingRevit.cs index 3aa6be233f..ff27f05fb4 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/BasicConnectorBindingRevit.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/BasicConnectorBindingRevit.cs @@ -6,8 +6,8 @@ using Speckle.Connectors.DUI.Models; using Speckle.Connectors.DUI.Models.Card; using Speckle.Connectors.Revit.Plugin; +using Speckle.Connectors.RevitShared.Helpers; using Speckle.Connectors.Utils; -using Speckle.Converters.RevitShared.Helpers; using Speckle.Core.Logging; namespace Speckle.Connectors.DUI.Bindings; diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/RevitBaseBinding.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/RevitBaseBinding.cs index 1a18f5ac53..7e1e0afdec 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/RevitBaseBinding.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/RevitBaseBinding.cs @@ -1,7 +1,7 @@ using Speckle.Connectors.DUI.Bindings; using Speckle.Connectors.DUI.Bridge; using Speckle.Connectors.DUI.Models; -using Speckle.Converters.RevitShared.Helpers; +using Speckle.Connectors.RevitShared.Helpers; namespace Speckle.Connectors.Revit.Bindings; diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/RevitSendBinding.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/RevitSendBinding.cs index da070b51f4..ab60430881 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/RevitSendBinding.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/RevitSendBinding.cs @@ -3,12 +3,12 @@ using Speckle.Connectors.DUI.Bridge; using Speckle.Connectors.Revit.Plugin; using Speckle.Connectors.Utils; -using Speckle.Converters.RevitShared.Helpers; using Speckle.Connectors.DUI.Models.Card; using Speckle.Connectors.DUI.Bindings; using Speckle.Autofac.DependencyInjection; using Speckle.Connectors.DUI.Exceptions; using Speckle.Connectors.DUI.Models; +using Speckle.Connectors.RevitShared.Helpers; using Speckle.Connectors.Utils.Caching; using Speckle.Connectors.Utils.Cancellation; using Speckle.Connectors.Utils.Operations; diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SelectionBinding.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SelectionBinding.cs index 9cbf1bcc15..11b7e8e864 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SelectionBinding.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SelectionBinding.cs @@ -2,8 +2,8 @@ using Speckle.Connectors.DUI.Bridge; using Speckle.Connectors.DUI.Models; using Speckle.Connectors.Revit.Plugin; +using Speckle.Connectors.RevitShared.Helpers; using Speckle.Converters.Common; -using Speckle.Converters.RevitShared.Helpers; namespace Speckle.Connectors.Revit.Bindings; diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/ProxyMap.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/ProxyMap.cs new file mode 100644 index 0000000000..2d7f7f8314 --- /dev/null +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/ProxyMap.cs @@ -0,0 +1,80 @@ +using System.Collections.Concurrent; +using System.Diagnostics.CodeAnalysis; +using Speckle.Revit.Api; +using Speckle.Revit.Interfaces; + +namespace Speckle.Connectors.Revit2023.Converters; + +[SuppressMessage("Performance", "CA1810:Initialize reference type static fields inline")] +public class ProxyMap : IProxyMap +{ + private static readonly ConcurrentDictionary s_revitToInterfaceMap = new(); + private static readonly ConcurrentDictionary s_proxyToInterfaceMap = new(); + private static readonly ConcurrentDictionary s_interfaceToRevit = new(); + private static readonly ConcurrentDictionary> s_proxyFactory = new(); + + [SuppressMessage("Maintainability", "CA1506:Avoid excessive class coupling")] + static ProxyMap() + { + Add(x => new ElementProxy(x)); + Add(x => new FamilyInstanceProxy(x)); + Add(x => new CurveProxy(x)); + Add(x => new BoundarySegmentProxy(x)); + Add(x => new LevelProxy(x)); + Add(x => new LocationProxy(x)); + Add(x => new MaterialProxy(x)); + Add(x => new ModelCurveArrayProxy(x)); + Add(x => new ModelCurveArrArrayProxy(x)); + Add(x => new ParameterProxy(x)); + Add(x => new BasePointProxy(x)); + Add(x => new WallProxy(x)); + Add(x => new PanelProxy(x)); + Add(x => new FloorProxy(x)); + Add(x => new CeilingProxy(x)); + Add(x => new FootPrintRoofProxy(x)); + Add(x => new ModelLineProxy(x)); + Add(x => new RoofBaseProxy(x)); + } + + private static void Add(Func f) + where T : class + where TInterface : notnull + where TProxy : TInterface + { + s_revitToInterfaceMap.TryAdd(typeof(T), typeof(TInterface)); + s_proxyToInterfaceMap.TryAdd(typeof(TProxy), typeof(TInterface)); + s_proxyFactory.TryAdd(typeof(TInterface), w => f((T)w)); + s_interfaceToRevit.TryAdd(typeof(TInterface), typeof(T)); + } + + public Type? GetMappedTypeFromHostType(Type type) + { + if (s_revitToInterfaceMap.TryGetValue(type, out var t)) + { + return t; + } + return null; + } + + public Type? GetMappedTypeFromProxyType(Type type) + { + if (s_proxyToInterfaceMap.TryGetValue(type, out var t)) + { + return t; + } + + return null; + } + + public Type? GetHostTypeFromMappedType(Type type) + { + if (s_interfaceToRevit.TryGetValue(type, out var t)) + { + return t; + } + + return null; + } + + public object CreateProxy(Type type, object toWrap) => s_proxyFactory[type](toWrap); +} diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/RevitConnectorModule.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/RevitConnectorModule.cs index ec1bcb5566..83e0a6af57 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/RevitConnectorModule.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/RevitConnectorModule.cs @@ -10,10 +10,15 @@ using Speckle.Connectors.Revit.HostApp; using Speckle.Connectors.Revit.Operations.Send; using Speckle.Connectors.Revit.Plugin; +using Speckle.Connectors.Revit2023.Converters; +using Speckle.Connectors.RevitShared.Helpers; using Speckle.Connectors.Utils; using Speckle.Connectors.Utils.Builders; using Speckle.Connectors.Utils.Caching; using Speckle.Connectors.Utils.Operations; +using Speckle.Converters.Common; +using Speckle.Revit.Api; +using Speckle.Revit.Interfaces; namespace Speckle.Connectors.Revit.DependencyInjection; @@ -25,7 +30,11 @@ public void Load(SpeckleContainerBuilder builder) builder.AddAutofac(); builder.AddConnectorUtils(); builder.AddDUI(); - //builder.AddDUIView(); + builder.AddSingleton(new RevitContext()); + + // POC: the concrete type can come out if we remove all the reference to it + builder.AddScoped, RevitConversionContextStack>(); + builder.ScanAssemblyOfType(); builder.AddSingletonInstance(); @@ -64,5 +73,6 @@ public void Load(SpeckleContainerBuilder builder) // register send conversion cache builder.AddSingleton(); + builder.AddSingleton(); } } diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/GlobalUsings.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/GlobalUsings.cs new file mode 100644 index 0000000000..dec8635815 --- /dev/null +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/GlobalUsings.cs @@ -0,0 +1 @@ +global using DB = Autodesk.Revit.DB; diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/RevitContext.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Helpers/RevitContext.cs similarity index 80% rename from DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/RevitContext.cs rename to DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Helpers/RevitContext.cs index 59c3892a75..3148acc5dc 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/RevitContext.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Helpers/RevitContext.cs @@ -1,6 +1,6 @@ -using Autodesk.Revit.UI; +using Autodesk.Revit.UI; -namespace Speckle.Converters.RevitShared.Helpers; +namespace Speckle.Connectors.RevitShared.Helpers; public class RevitContext { diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Helpers/RevitConversionContextStack.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Helpers/RevitConversionContextStack.cs new file mode 100644 index 0000000000..d5461e7f60 --- /dev/null +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Helpers/RevitConversionContextStack.cs @@ -0,0 +1,38 @@ +using Autodesk.Revit.DB; +using Speckle.Converters.Common; +using Speckle.Revit.Api; +using Speckle.Revit.Interfaces; + +namespace Speckle.Connectors.RevitShared.Helpers; + +[System.Diagnostics.CodeAnalysis.SuppressMessage( + "Naming", + "CA1711:Identifiers should not have incorrect suffix", + Justification = "See base class justification" +)] +// POC: so this should *probably* be Document and NOT UI.UIDocument, the former is Conversion centric +// and the latter is more for connector +public class RevitConversionContextStack + : ConversionContextStack, + IConversionContextStack +{ + public RevitConversionContextStack(RevitContext context, IHostToSpeckleUnitConverter unitConverter) + : base( + // POC: we probably should not get here without a valid document + // so should this perpetuate or do we assume this is valid? + // relting on the context.UIApplication?.ActiveUIDocument is not right + // this should be some IActiveDocument I suspect? + new DocumentProxy( + context.UIApplication?.ActiveUIDocument?.Document + ?? throw new SpeckleConversionException("Active UI document could not be determined") + ), + new ForgeTypeIdProxy( + context.UIApplication.ActiveUIDocument.Document.GetUnits().GetFormatOptions(SpecTypeId.Length).GetUnitTypeId() + ), + unitConverter + ) { } + + ContextWrapper IConversionContextStack.Push( + string speckleUnit + ) => throw new NotImplementedException(); +} diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/RevitDocumentStore.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/RevitDocumentStore.cs index 6d31480be2..1278431790 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/RevitDocumentStore.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/RevitDocumentStore.cs @@ -6,8 +6,8 @@ using Revit.Async; using Speckle.Connectors.DUI.Models; using Speckle.Connectors.Revit.Plugin; +using Speckle.Connectors.RevitShared.Helpers; using Speckle.Connectors.Utils; -using Speckle.Converters.RevitShared.Helpers; using Speckle.Core.Logging; using Speckle.Newtonsoft.Json; diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RevitRootObjectBuilder.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RevitRootObjectBuilder.cs index b22ef0a3ca..63c2144e76 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RevitRootObjectBuilder.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RevitRootObjectBuilder.cs @@ -3,12 +3,13 @@ using Speckle.Core.Models; using Autodesk.Revit.DB; using Speckle.Connectors.DUI.Exceptions; -using Speckle.Converters.RevitShared.Helpers; using Speckle.Connectors.Utils.Builders; using Speckle.Connectors.Utils.Caching; using Speckle.Connectors.Utils.Conversion; using Speckle.Connectors.Utils.Operations; using Speckle.Core.Logging; +using Speckle.Revit.Api; +using Speckle.Revit.Interfaces; namespace Speckle.Connectors.Revit.Operations.Send; @@ -16,14 +17,14 @@ public class RevitRootObjectBuilder : IRootObjectBuilder { // POC: SendSelection and RevitConversionContextStack should be interfaces, former needs interfaces private readonly IRootToSpeckleConverter _converter; - private readonly IRevitConversionContextStack _contextStack; + private readonly IConversionContextStack _contextStack; private readonly Dictionary _collectionCache; private readonly Collection _rootObject; private readonly ISendConversionCache _sendConversionCache; public RevitRootObjectBuilder( IRootToSpeckleConverter converter, - IRevitConversionContextStack contextStack, + IConversionContextStack contextStack, ISendConversionCache sendConversionCache ) { @@ -45,7 +46,7 @@ public RootObjectBuilderResult Build( CancellationToken ct = default ) { - var doc = _contextStack.Current.Document; + var doc = ((DocumentProxy)_contextStack.Current.Document)._Instance; if (doc.IsFamilyDocument) { @@ -56,7 +57,7 @@ public RootObjectBuilderResult Build( foreach (var id in objects) { - var el = _contextStack.Current.Document.GetElement(id); + var el = doc.GetElement(id); if (el != null) { revitElements.Add(el); diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitExternalApplication.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitExternalApplication.cs index c84c839054..1ce923f7c3 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitExternalApplication.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitExternalApplication.cs @@ -1,6 +1,5 @@ using Autodesk.Revit.UI; using Speckle.Autofac.DependencyInjection; -using System.IO; using System.Reflection; using Speckle.Autofac; using Speckle.Connectors.Utils; @@ -33,7 +32,7 @@ public RevitExternalApplication() "2023", "Speckle New UI", "Revit", - new[] { Path.GetDirectoryName(typeof(RevitExternalApplication).Assembly.Location) }, + new[] { System.IO.Path.GetDirectoryName(typeof(RevitExternalApplication).Assembly.Location) }, "Revit Connector", "2023" //POC: app version? ); diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitIdleManager.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitIdleManager.cs index 79bd4408a6..8456ded287 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitIdleManager.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitIdleManager.cs @@ -1,7 +1,7 @@ using System.Collections.Concurrent; using Autodesk.Revit.UI; using Autodesk.Revit.UI.Events; -using Speckle.Converters.RevitShared.Helpers; +using Speckle.Connectors.RevitShared.Helpers; namespace Speckle.Connectors.Revit.Plugin; diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitPlugin.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitPlugin.cs index 13d3500b2f..a46046dd45 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitPlugin.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitPlugin.cs @@ -5,12 +5,11 @@ using Speckle.Connectors.DUI.Bridge; using Speckle.Connectors.DUI.Bindings; using System.Diagnostics; -using Speckle.Converters.RevitShared.Helpers; using Speckle.Core.Logging; using System.Reflection; using System.Windows.Media.Imaging; using System.Windows.Media; -using System.IO; +using Speckle.Connectors.RevitShared.Helpers; namespace Speckle.Connectors.Revit.Plugin; @@ -182,7 +181,7 @@ private void RegisterDockablePane() { try { - var assembly = Assembly.LoadFrom(Path.Combine(path)); + var assembly = Assembly.LoadFrom(System.IO.Path.Combine(path)); var icon = assembly.GetManifestResourceStream(sourceName); PngBitmapDecoder decoder = new(icon, BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.Default); ImageSource source = decoder.Frames[0]; diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Speckle.Connectors.RevitShared.projitems b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Speckle.Connectors.RevitShared.projitems index 8a671aefc9..a479f3189b 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Speckle.Connectors.RevitShared.projitems +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Speckle.Connectors.RevitShared.projitems @@ -16,28 +16,7 @@ - - - - - - - - - - - - - - CefSharpPanel.xaml - - - - - - - - + diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/RevitConverterModule.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/RevitConverterModule.cs index d4e6d197ac..f5ecc652f0 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/RevitConverterModule.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/RevitConverterModule.cs @@ -1,4 +1,3 @@ -using Autodesk.Revit.DB; using Speckle.Autofac.DependencyInjection; using Speckle.Converters.Common; using Speckle.Converters.Common.DependencyInjection; @@ -6,6 +5,7 @@ using Speckle.Converters.RevitShared.Helpers; using Speckle.Converters.RevitShared.Services; using Speckle.Converters.RevitShared.ToSpeckle; +using Speckle.Revit.Interfaces; namespace Speckle.Converters.Revit2023.DependencyInjection; @@ -13,26 +13,21 @@ public class RevitConverterModule : ISpeckleModule { public void Load(SpeckleContainerBuilder builder) { - builder.AddConverterCommon(); - builder.AddSingleton(new RevitContext()); + builder.AddConverterCommon(); // POC: do we need ToSpeckleScalingService as is, do we need to interface it out? - builder.AddScoped(); - - // POC: the concrete type can come out if we remove all the reference to it - builder.AddScoped(); + builder.AddScoped(); builder.AddScoped(); - builder.AddScoped(); + builder.AddScoped(); builder.AddScoped(); - builder.AddScoped(); - builder.AddScoped(); - builder.AddScoped(); - builder.AddScoped(); + builder.AddScoped(); + builder.AddScoped(); + builder.AddScoped(); + builder.AddScoped(); builder.AddScoped(); builder.AddScoped(); - builder.AddScoped(); } } diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/Speckle.Converters.Revit2023.DependencyInjection.csproj b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/Speckle.Converters.Revit2023.DependencyInjection.csproj index 704fef95ed..c390bba29b 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/Speckle.Converters.Revit2023.DependencyInjection.csproj +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/Speckle.Converters.Revit2023.DependencyInjection.csproj @@ -5,6 +5,9 @@ x64 + + + diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/LocationConversionToSpeckleTests.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/LocationConversionToSpeckleTests.cs new file mode 100644 index 0000000000..6fb5ba34d3 --- /dev/null +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/LocationConversionToSpeckleTests.cs @@ -0,0 +1,85 @@ +using FluentAssertions; +using Moq; +using NUnit.Framework; +using Objects; +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; +using Speckle.Converters.RevitShared; +using Speckle.Converters.RevitShared.Services; +using Speckle.Revit.Interfaces; + +namespace Speckle.Converters.Revit2023.Tests; + +public class ModelCurveArrayToSpeckleConverterTests +{ + private readonly MockRepository _repository = new(MockBehavior.Strict); + + private readonly Mock> _revitConversionContextStack; + private readonly Mock _scalingServiceToSpeckle; + private readonly Mock> _curveConverter; + + public ModelCurveArrayToSpeckleConverterTests() + { + _revitConversionContextStack = _repository.Create>(); + _scalingServiceToSpeckle = _repository.Create(); + _curveConverter = _repository.Create>(); + } + + [TearDown] + public void Verify() => _repository.VerifyAll(); + + [Test] + public void Convert_Empty() + { + var sut = new ModelCurveArrayToSpeckleConverter( + _revitConversionContextStack.Object, + _scalingServiceToSpeckle.Object, + _curveConverter.Object + ); + Assert.Throws(() => sut.Convert(new List())); + } + + [Test] + public void Convert() + { + var endpoint1 = _repository.Create(); + var geometry1 = _repository.Create(); + var curve1 = _repository.Create(); + curve1.Setup(x => x.GeometryCurve).Returns(geometry1.Object); + geometry1.Setup(x => x.Length).Returns(2); + geometry1.Setup(x => x.GetEndPoint(0)).Returns(endpoint1.Object); + + var endpoint2 = _repository.Create(); + var geometry2 = _repository.Create(); + var curve2 = _repository.Create(); + curve2.Setup(x => x.GeometryCurve).Returns(geometry2.Object); + geometry2.Setup(x => x.Length).Returns(3); + geometry2.Setup(x => x.GetEndPoint(1)).Returns(endpoint2.Object); + + var context = _repository.Create>(); + _revitConversionContextStack.Setup(x => x.Current).Returns(context.Object); + + var units = "units"; + context.Setup(x => x.SpeckleUnits).Returns(units); + + var scaleLength = 2.2; + _scalingServiceToSpeckle.Setup(x => x.ScaleLength(2 + 3)).Returns(scaleLength); + + endpoint1.Setup(x => x.DistanceTo(endpoint2.Object)).Returns(4.4); + + _curveConverter.Setup(x => x.Convert(geometry1.Object)).Returns(_repository.Create().Object); + _curveConverter.Setup(x => x.Convert(geometry2.Object)).Returns(_repository.Create().Object); + + var sut = new ModelCurveArrayToSpeckleConverter( + _revitConversionContextStack.Object, + _scalingServiceToSpeckle.Object, + _curveConverter.Object + ); + var polycurve = sut.Convert(new List() { curve1.Object, curve2.Object }); + + polycurve.units.Should().Be(units); + polycurve.closed.Should().BeFalse(); + polycurve.length.Should().Be(scaleLength); + polycurve.segments.Count.Should().Be(2); + } +} diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/Speckle.Converters.Revit2023.Tests.csproj b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/Speckle.Converters.Revit2023.Tests.csproj new file mode 100644 index 0000000000..70941da6f7 --- /dev/null +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/Speckle.Converters.Revit2023.Tests.csproj @@ -0,0 +1,28 @@ + + + + net48 + x64 + false + true + + + + + + + + + + + + + + + + + + + + + diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/packages.lock.json b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/packages.lock.json new file mode 100644 index 0000000000..b6ddfa328f --- /dev/null +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/packages.lock.json @@ -0,0 +1,549 @@ +{ + "version": 1, + "dependencies": { + ".NETFramework,Version=v4.8": { + "coverlet.collector": { + "type": "Direct", + "requested": "[6.0.2, )", + "resolved": "6.0.2", + "contentHash": "bJShQ6uWRTQ100ZeyiMqcFlhP7WJ+bCuabUs885dJiBEzMsJMSFr7BOyeCw4rgvQokteGi5rKQTlkhfQPUXg2A==" + }, + "FluentAssertions": { + "type": "Direct", + "requested": "[6.12.0, )", + "resolved": "6.12.0", + "contentHash": "ZXhHT2YwP9lajrwSKbLlFqsmCCvFJMoRSK9t7sImfnCyd0OB3MhgxdoMcVqxbq1iyxD6mD2fiackWmBb7ayiXQ==", + "dependencies": { + "System.Threading.Tasks.Extensions": "4.5.0" + } + }, + "Microsoft.NET.Test.Sdk": { + "type": "Direct", + "requested": "[17.10.0, )", + "resolved": "17.10.0", + "contentHash": "0/2HeACkaHEYU3wc83YlcD2Fi4LMtECJjqrtvw0lPi9DCEa35zSPt1j4fuvM8NagjDqJuh1Ja35WcRtn1Um6/A==", + "dependencies": { + "Microsoft.CodeCoverage": "17.10.0" + } + }, + "Moq": { + "type": "Direct", + "requested": "[4.20.70, )", + "resolved": "4.20.70", + "contentHash": "4rNnAwdpXJBuxqrOCzCyICXHSImOTRktCgCWXWykuF1qwoIsVvEnR7PjbMk/eLOxWvhmj5Kwt+kDV3RGUYcNwg==", + "dependencies": { + "Castle.Core": "5.1.1", + "System.Threading.Tasks.Extensions": "4.5.4" + } + }, + "NUnit": { + "type": "Direct", + "requested": "[4.1.0, )", + "resolved": "4.1.0", + "contentHash": "MT/DpAhjtiytzhTgTqIhBuWx4y26PKfDepYUHUM+5uv4TsryHC2jwFo5e6NhWkApCm/G6kZ80dRjdJFuAxq3rg==", + "dependencies": { + "System.Threading.Tasks.Extensions": "4.5.4" + } + }, + "NUnit.Analyzers": { + "type": "Direct", + "requested": "[4.2.0, )", + "resolved": "4.2.0", + "contentHash": "4fJojPkzdoa4nB2+p6U+fITvPnVvwWSnsmiJ/Dl30xqiL3oxNbYvfeSLVd91hOmEjoUqSwN3Z7j1aFedjqWbUA==" + }, + "PolySharp": { + "type": "Direct", + "requested": "[1.14.1, )", + "resolved": "1.14.1", + "contentHash": "mOOmFYwad3MIOL14VCjj02LljyF1GNw1wP0YVlxtcPvqdxjGGMNdNJJxHptlry3MOd8b40Flm8RPOM8JOlN2sQ==" + }, + "Speckle.InterfaceGenerator": { + "type": "Direct", + "requested": "[0.9.5, )", + "resolved": "0.9.5", + "contentHash": "oU/L7pN1R7q8KkbrpQ3WJnHirPHqn+9DEA7asOcUiggV5dzVg1A/VYs7GOSusD24njxXh03tE3a2oTLOjt3cVg==" + }, + "Speckle.Revit2023.Interfaces": { + "type": "Direct", + "requested": "[0.1.1-preview.0.20, )", + "resolved": "0.1.1-preview.0.20", + "contentHash": "L/8btGlDejt6OCe8Lee05N3ztKV+pz24WAU9fwXRHEeWMgSe+bqq477Jmk641QFcKmcWK25XJlprlHiCh4pAdQ==" + }, + "Castle.Core": { + "type": "Transitive", + "resolved": "5.1.1", + "contentHash": "rpYtIczkzGpf+EkZgDr9CClTdemhsrwA/W5hMoPjLkRFnXzH44zDLoovXeKtmxb1ykXK9aJVODSpiJml8CTw2g==" + }, + "GraphQL.Client": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "8yPNBbuVBpTptivyAlak4GZvbwbUcjeQTL4vN1HKHRuOykZ4r7l5fcLS6vpyPyLn0x8FsL31xbOIKyxbmR9rbA==", + "dependencies": { + "GraphQL.Client.Abstractions": "6.0.0", + "GraphQL.Client.Abstractions.Websocket": "6.0.0", + "System.Net.WebSockets.Client.Managed": "1.0.22", + "System.Reactive": "5.0.0" + } + }, + "GraphQL.Client.Abstractions": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "h7uzWFORHZ+CCjwr/ThAyXMr0DPpzEANDa4Uo54wqCQ+j7qUKwqYTgOrb1W40sqbvNaZm9v/X7It31SUw0maHA==", + "dependencies": { + "GraphQL.Primitives": "6.0.0" + } + }, + "GraphQL.Client.Abstractions.Websocket": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "Nr9bPf8gIOvLuXpqEpqr9z9jslYFJOvd0feHth3/kPqeR3uMbjF5pjiwh4jxyMcxHdr8Pb6QiXkV3hsSyt0v7A==", + "dependencies": { + "GraphQL.Client.Abstractions": "6.0.0" + } + }, + "GraphQL.Primitives": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "yg72rrYDapfsIUrul7aF6wwNnTJBOFvuA9VdDTQpPa8AlAriHbufeXYLBcodKjfUdkCnaiggX1U/nEP08Zb5GA==" + }, + "Microsoft.Bcl.AsyncInterfaces": { + "type": "Transitive", + "resolved": "7.0.0", + "contentHash": "3aeMZ1N0lJoSyzqiP03hqemtb1BijhsJADdobn/4nsMJ8V1H+CrpuduUe4hlRdx+ikBQju1VGjMD1GJ3Sk05Eg==", + "dependencies": { + "System.Threading.Tasks.Extensions": "4.5.4" + } + }, + "Microsoft.CodeCoverage": { + "type": "Transitive", + "resolved": "17.10.0", + "contentHash": "yC7oSlnR54XO5kOuHlVOKtxomNNN1BWXX8lK1G2jaPXT9sUok7kCOoA4Pgs0qyFaCtMrNsprztYMeoEGqCm4uA==" + }, + "Microsoft.CSharp": { + "type": "Transitive", + "resolved": "4.7.0", + "contentHash": "pTj+D3uJWyN3My70i2Hqo+OXixq3Os2D1nJ2x92FFo6sk8fYS1m1WLNTs0Dc1uPaViH0YvEEwvzddQ7y4rhXmA==" + }, + "Microsoft.Data.Sqlite": { + "type": "Transitive", + "resolved": "7.0.5", + "contentHash": "KGxbPeWsQMnmQy43DSBxAFtHz3l2JX8EWBSGUCvT3CuZ8KsuzbkqMIJMDOxWtG8eZSoCDI04aiVQjWuuV8HmSw==", + "dependencies": { + "Microsoft.Data.Sqlite.Core": "7.0.5", + "SQLitePCLRaw.bundle_e_sqlite3": "2.1.4" + } + }, + "Microsoft.Data.Sqlite.Core": { + "type": "Transitive", + "resolved": "7.0.5", + "contentHash": "FTerRmQPqHrCrnoUzhBu+E+1DNGwyrAMLqHkAqOOOu5pGfyMOj8qQUBxI/gDtWtG11p49UxSfWmBzRNlwZqfUg==", + "dependencies": { + "SQLitePCLRaw.core": "2.1.4" + } + }, + "Microsoft.Extensions.DependencyInjection": { + "type": "Transitive", + "resolved": "7.0.0", + "contentHash": "elNeOmkeX3eDVG6pYVeV82p29hr+UKDaBhrZyWvWLw/EVZSYEkZlQdkp0V39k/Xehs2Qa0mvoCvkVj3eQxNQ1Q==", + "dependencies": { + "Microsoft.Bcl.AsyncInterfaces": "7.0.0", + "Microsoft.Extensions.DependencyInjection.Abstractions": "7.0.0", + "System.Threading.Tasks.Extensions": "4.5.4" + } + }, + "Microsoft.Extensions.DependencyInjection.Abstractions": { + "type": "Transitive", + "resolved": "7.0.0", + "contentHash": "h3j/QfmFN4S0w4C2A6X7arXij/M/OVw3uQHSOFxnND4DyAzO1F9eMX7Eti7lU/OkSthEE0WzRsfT/Dmx86jzCw==", + "dependencies": { + "Microsoft.Bcl.AsyncInterfaces": "7.0.0", + "System.Threading.Tasks.Extensions": "4.5.4" + } + }, + "Microsoft.Extensions.Logging": { + "type": "Transitive", + "resolved": "7.0.0", + "contentHash": "Nw2muoNrOG5U5qa2ZekXwudUn2BJcD41e65zwmDHb1fQegTX66UokLWZkJRpqSSHXDOWZ5V0iqhbxOEky91atA==", + "dependencies": { + "Microsoft.Bcl.AsyncInterfaces": "7.0.0", + "Microsoft.Extensions.DependencyInjection": "7.0.0", + "Microsoft.Extensions.DependencyInjection.Abstractions": "7.0.0", + "Microsoft.Extensions.Logging.Abstractions": "7.0.0", + "Microsoft.Extensions.Options": "7.0.0", + "System.Diagnostics.DiagnosticSource": "7.0.0", + "System.ValueTuple": "4.5.0" + } + }, + "Microsoft.Extensions.Logging.Abstractions": { + "type": "Transitive", + "resolved": "7.0.0", + "contentHash": "kmn78+LPVMOWeITUjIlfxUPDsI0R6G0RkeAMBmQxAJ7vBJn4q2dTva7pWi65ceN5vPGjJ9q/Uae2WKgvfktJAw==", + "dependencies": { + "System.Buffers": "4.5.1", + "System.Memory": "4.5.5" + } + }, + "Microsoft.Extensions.Options": { + "type": "Transitive", + "resolved": "7.0.0", + "contentHash": "lP1yBnTTU42cKpMozuafbvNtQ7QcBjr/CcK3bYOGEMH55Fjt+iecXjT6chR7vbgCMqy3PG3aNQSZgo/EuY/9qQ==", + "dependencies": { + "Microsoft.Extensions.DependencyInjection.Abstractions": "7.0.0", + "Microsoft.Extensions.Primitives": "7.0.0" + } + }, + "Microsoft.Extensions.Primitives": { + "type": "Transitive", + "resolved": "7.0.0", + "contentHash": "um1KU5kxcRp3CNuI8o/GrZtD4AIOXDk+RLsytjZ9QPok3ttLUelLKpilVPuaFT3TFjOhSibUAso0odbOaCDj3Q==", + "dependencies": { + "System.Memory": "4.5.5", + "System.Runtime.CompilerServices.Unsafe": "6.0.0" + } + }, + "Polly": { + "type": "Transitive", + "resolved": "7.2.3", + "contentHash": "DeCY0OFbNdNxsjntr1gTXHJ5pKUwYzp04Er2LLeN3g6pWhffsGuKVfMBLe1lw7x76HrPkLxKEFxBlpRxS2nDEQ==" + }, + "Polly.Contrib.WaitAndRetry": { + "type": "Transitive", + "resolved": "1.1.1", + "contentHash": "1MUQLiSo4KDkQe6nzQRhIU05lm9jlexX5BVsbuw0SL82ynZ+GzAHQxJVDPVBboxV37Po3SG077aX8DuSy8TkaA==" + }, + "Polly.Extensions.Http": { + "type": "Transitive", + "resolved": "3.0.0", + "contentHash": "drrG+hB3pYFY7w1c3BD+lSGYvH2oIclH8GRSehgfyP5kjnFnHKQuuBhuHLv+PWyFuaTDyk/vfRpnxOzd11+J8g==", + "dependencies": { + "Polly": "7.1.0" + } + }, + "Sentry": { + "type": "Transitive", + "resolved": "3.33.0", + "contentHash": "8vbD2o6IR2wrRrkSiRbnodWGWUOqIlwYtzpjvPNOb5raJdOf+zxMwfS8f6nx9bmrTTfDj7KrCB8C/5OuicAc8A==", + "dependencies": { + "System.Reflection.Metadata": "5.0.0", + "System.Runtime.InteropServices.RuntimeInformation": "4.3.0", + "System.Text.Json": "5.0.2" + } + }, + "Sentry.Serilog": { + "type": "Transitive", + "resolved": "3.33.0", + "contentHash": "V8BU7QGWg2qLYfNPqtuTBhC1opysny5l+Ifp6J6PhOeAxU0FssR7nYfbJVetrnLIoh2rd3DlJ6hHYYQosQYcUQ==", + "dependencies": { + "Sentry": "3.33.0", + "Serilog": "2.7.1" + } + }, + "Serilog": { + "type": "Transitive", + "resolved": "2.12.0", + "contentHash": "xaiJLIdu6rYMKfQMYUZgTy8YK7SMZjB4Yk50C/u//Z4OsvxkUfSPJy4nknfvwAC34yr13q7kcyh4grbwhSxyZg==" + }, + "Serilog.Enrichers.ClientInfo": { + "type": "Transitive", + "resolved": "1.3.0", + "contentHash": "mTc7PM+wC9Hr7LWSwqt5mmnlAr7RJs+eTb3PGPRhwdOackk95MkhUZognuxXEdlW19HAFNmEBTSBY5DfLwM8jQ==", + "dependencies": { + "Serilog": "2.4.0" + } + }, + "Serilog.Enrichers.GlobalLogContext": { + "type": "Transitive", + "resolved": "3.0.0", + "contentHash": "IIZcj5mAUVhIl/NTA+YI2KC+sPDzcwvs0ZMHH42jsPfl1a4LVX7ohVpw5UK+e3GxuV3Nv239Il5oM2peUIl44g==", + "dependencies": { + "Serilog": "2.12.0" + } + }, + "Serilog.Exceptions": { + "type": "Transitive", + "resolved": "8.4.0", + "contentHash": "nc/+hUw3lsdo0zCj0KMIybAu7perMx79vu72w0za9Nsi6mWyNkGXxYxakAjWB7nEmYL6zdmhEQRB4oJ2ALUeug==", + "dependencies": { + "Serilog": "2.8.0" + } + }, + "Serilog.Extensions.Logging": { + "type": "Transitive", + "resolved": "7.0.0", + "contentHash": "9faU0zNQqU7I6soVhLUMYaGNpgWv6cKlKb2S5AnS8gXxzW/em5Ladm/6FMrWTnX41cdbdGPOWNAo6adi4WaJ6A==", + "dependencies": { + "Microsoft.Extensions.Logging": "7.0.0", + "Serilog": "2.12.0" + } + }, + "Serilog.Formatting.Compact": { + "type": "Transitive", + "resolved": "1.1.0", + "contentHash": "pNroKVjo+rDqlxNG5PXkRLpfSCuDOBY0ri6jp9PLe505ljqwhwZz8ospy2vWhQlFu5GkIesh3FcDs4n7sWZODA==", + "dependencies": { + "Serilog": "2.8.0" + } + }, + "Serilog.Sinks.Console": { + "type": "Transitive", + "resolved": "4.1.0", + "contentHash": "K6N5q+5fetjnJPvCmkWOpJ/V8IEIoMIB1s86OzBrbxwTyHxdx3pmz4H+8+O/Dc/ftUX12DM1aynx/dDowkwzqg==", + "dependencies": { + "Serilog": "2.10.0" + } + }, + "Serilog.Sinks.File": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "uwV5hdhWPwUH1szhO8PJpFiahqXmzPzJT/sOijH/kFgUx+cyoDTMM8MHD0adw9+Iem6itoibbUXHYslzXsLEAg==", + "dependencies": { + "Serilog": "2.10.0" + } + }, + "Serilog.Sinks.PeriodicBatching": { + "type": "Transitive", + "resolved": "3.1.0", + "contentHash": "NDWR7m3PalVlGEq3rzoktrXikjFMLmpwF0HI4sowo8YDdU+gqPlTHlDQiOGxHfB0sTfjPA9JjA7ctKG9zqjGkw==", + "dependencies": { + "Serilog": "2.0.0" + } + }, + "Serilog.Sinks.Seq": { + "type": "Transitive", + "resolved": "5.2.2", + "contentHash": "1Csmo5ua7NKUe0yXUx+zsRefjAniPWcXFhUXxXG8pwo0iMiw2gjn9SOkgYnnxbgWqmlGv236w0N/dHc2v5XwMg==", + "dependencies": { + "Serilog": "2.12.0", + "Serilog.Formatting.Compact": "1.1.0", + "Serilog.Sinks.File": "5.0.0", + "Serilog.Sinks.PeriodicBatching": "3.1.0" + } + }, + "SerilogTimings": { + "type": "Transitive", + "resolved": "3.0.1", + "contentHash": "Zs28eTgszAMwpIrbBnWHBI50yuxL50p/dmAUWmy75+axdZYK/Sjm5/5m1N/CisR8acJUhTVcjPZrsB1P5iv0Uw==", + "dependencies": { + "Serilog": "2.10.0" + } + }, + "Speckle.Newtonsoft.Json": { + "type": "Transitive", + "resolved": "13.0.2", + "contentHash": "g1BejUZwax5PRfL6xHgLEK23sqHWOgOj9hE7RvfRRlN00AGt8GnPYt8HedSK7UB3HiRW8zCA9Pn0iiYxCK24BA==" + }, + "SQLitePCLRaw.bundle_e_sqlite3": { + "type": "Transitive", + "resolved": "2.1.4", + "contentHash": "EWI1olKDjFEBMJu0+3wuxwziIAdWDVMYLhuZ3Qs84rrz+DHwD00RzWPZCa+bLnHCf3oJwuFZIRsHT5p236QXww==", + "dependencies": { + "SQLitePCLRaw.lib.e_sqlite3": "2.1.4", + "SQLitePCLRaw.provider.dynamic_cdecl": "2.1.4" + } + }, + "SQLitePCLRaw.core": { + "type": "Transitive", + "resolved": "2.1.4", + "contentHash": "inBjvSHo9UDKneGNzfUfDjK08JzlcIhn1+SP5Y3m6cgXpCxXKCJDy6Mka7LpgSV+UZmKSnC8rTwB0SQ0xKu5pA==", + "dependencies": { + "System.Memory": "4.5.3" + } + }, + "SQLitePCLRaw.lib.e_sqlite3": { + "type": "Transitive", + "resolved": "2.1.4", + "contentHash": "2C9Q9eX7CPLveJA0rIhf9RXAvu+7nWZu1A2MdG6SD/NOu26TakGgL1nsbc0JAspGijFOo3HoN79xrx8a368fBg==" + }, + "SQLitePCLRaw.provider.dynamic_cdecl": { + "type": "Transitive", + "resolved": "2.1.4", + "contentHash": "ZsaKKhgYF9B1fvcnOGKl3EycNAwd9CRWX7v0rEfuPWhQQ5Jjpvf2VEHahiLIGHio3hxi3EIKFJw9KvyowWOUAw==", + "dependencies": { + "SQLitePCLRaw.core": "2.1.4" + } + }, + "System.Buffers": { + "type": "Transitive", + "resolved": "4.5.1", + "contentHash": "Rw7ijyl1qqRS0YQD/WycNst8hUUMgrMH4FCn1nNm27M4VxchZ1js3fVjQaANHO5f3sN4isvP4a+Met9Y4YomAg==" + }, + "System.Collections.Immutable": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "FXkLXiK0sVVewcso0imKQoOxjoPAj42R8HtjjbSjVPAzwDfzoyoznWxgA3c38LDbN9SJux1xXoXYAhz98j7r2g==", + "dependencies": { + "System.Memory": "4.5.4" + } + }, + "System.Diagnostics.DiagnosticSource": { + "type": "Transitive", + "resolved": "7.0.0", + "contentHash": "9W0ewWDuAyDqS2PigdTxk6jDKonfgscY/hP8hm7VpxYhNHZHKvZTdRckberlFk3VnCmr3xBUyMBut12Q+T2aOw==", + "dependencies": { + "System.Memory": "4.5.5", + "System.Runtime.CompilerServices.Unsafe": "6.0.0" + } + }, + "System.DoubleNumerics": { + "type": "Transitive", + "resolved": "3.1.3", + "contentHash": "KRKEM/L3KBodjA9VOg3EifFVWUY6EOqaMB05UvPEDm7Zeby/kZW+4kdWUEPzW6xtkwf46p661L9NrbeeQhtLzw==", + "dependencies": { + "NETStandard.Library": "1.6.1" + } + }, + "System.Memory": { + "type": "Transitive", + "resolved": "4.5.5", + "contentHash": "XIWiDvKPXaTveaB7HVganDlOCRoj03l+jrwNvcge/t8vhGYKvqV+dMv6G4SAX2NoNmN0wZfVPTAlFwZcZvVOUw==", + "dependencies": { + "System.Buffers": "4.5.1", + "System.Numerics.Vectors": "4.5.0", + "System.Runtime.CompilerServices.Unsafe": "4.5.3" + } + }, + "System.Net.WebSockets.Client.Managed": { + "type": "Transitive", + "resolved": "1.0.22", + "contentHash": "WqEOxPlXjuZrIjUtXNE9NxEfU/n5E35iV2PtoZdJSUC4tlrqwHnTee+wvMIM4OUaJWmwrymeqcgYrE0IkGAgLA==", + "dependencies": { + "System.Buffers": "4.4.0", + "System.Numerics.Vectors": "4.4.0" + } + }, + "System.Numerics.Vectors": { + "type": "Transitive", + "resolved": "4.5.0", + "contentHash": "QQTlPTl06J/iiDbJCiepZ4H//BVraReU4O4EoRw1U02H5TLUIT7xn3GnDp9AXPSlJUDyFs4uWjWafNX6WrAojQ==" + }, + "System.Reactive": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "erBZjkQHWL9jpasCE/0qKAryzVBJFxGHVBAvgRN1bzM0q2s1S4oYREEEL0Vb+1kA/6BKb5FjUZMp5VXmy+gzkQ==", + "dependencies": { + "System.Threading.Tasks.Extensions": "4.5.4" + } + }, + "System.Reflection.Metadata": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "5NecZgXktdGg34rh1OenY1rFNDCI8xSjFr+Z4OU4cU06AQHUdRnIIEeWENu3Wl4YowbzkymAIMvi3WyK9U53pQ==", + "dependencies": { + "System.Collections.Immutable": "5.0.0" + } + }, + "System.Runtime.CompilerServices.Unsafe": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "/iUeP3tq1S0XdNNoMz5C9twLSrM/TH+qElHkXWaPvuNOt+99G75NrV0OS2EqHx5wMN7popYjpc8oTjC1y16DLg==" + }, + "System.Runtime.InteropServices.RuntimeInformation": { + "type": "Transitive", + "resolved": "4.3.0", + "contentHash": "cbz4YJMqRDR7oLeMRbdYv7mYzc++17lNhScCX0goO2XpGWdvAt60CGN+FHdePUEHCe/Jy9jUlvNAiNdM+7jsOw==" + }, + "System.Text.Encodings.Web": { + "type": "Transitive", + "resolved": "5.0.1", + "contentHash": "KmJ+CJXizDofbq6mpqDoRRLcxgOd2z9X3XoFNULSbvbqVRZkFX3istvr+MUjL6Zw1RT+RNdoI4GYidIINtgvqQ==", + "dependencies": { + "System.Buffers": "4.5.1", + "System.Memory": "4.5.4" + } + }, + "System.Text.Json": { + "type": "Transitive", + "resolved": "5.0.2", + "contentHash": "I47dVIGiV6SfAyppphxqupertT/5oZkYLDCX6vC3HpOI4ZLjyoKAreUoem2ie6G0RbRuFrlqz/PcTQjfb2DOfQ==", + "dependencies": { + "Microsoft.Bcl.AsyncInterfaces": "5.0.0", + "System.Buffers": "4.5.1", + "System.Memory": "4.5.4", + "System.Numerics.Vectors": "4.5.0", + "System.Runtime.CompilerServices.Unsafe": "5.0.0", + "System.Text.Encodings.Web": "5.0.1", + "System.Threading.Tasks.Extensions": "4.5.4", + "System.ValueTuple": "4.5.0" + } + }, + "System.Threading.Tasks.Extensions": { + "type": "Transitive", + "resolved": "4.5.4", + "contentHash": "zteT+G8xuGu6mS+mzDzYXbzS7rd3K6Fjb9RiZlYlJPam2/hU7JCBZBVEcywNuR+oZ1ncTvc/cq0faRr3P01OVg==", + "dependencies": { + "System.Runtime.CompilerServices.Unsafe": "4.5.3" + } + }, + "System.ValueTuple": { + "type": "Transitive", + "resolved": "4.5.0", + "contentHash": "okurQJO6NRE/apDIP23ajJ0hpiNmJ+f0BwOlB/cSqTLQlw5upkf+5+96+iG2Jw40G1fCVCyPz/FhIABUjMR+RQ==" + }, + "speckle.autofac": { + "type": "Project", + "dependencies": { + "Microsoft.Extensions.Logging.Abstractions": "[7.0.0, )", + "Speckle.Core": "[2.0.999-local, )" + } + }, + "speckle.connectors.utils": { + "type": "Project", + "dependencies": { + "Serilog.Extensions.Logging": "[7.0.0, )", + "Speckle.Autofac": "[2.0.999-local, )", + "Speckle.Core": "[2.0.999-local, )" + } + }, + "speckle.converters.common": { + "type": "Project", + "dependencies": { + "Speckle.Autofac": "[2.0.999-local, )", + "Speckle.Objects": "[2.0.999-local, )", + "Speckle.Revit2023.Interfaces": "[0.1.1-preview.0.20, )" + } + }, + "speckle.converters.common.dependencyinjection": { + "type": "Project", + "dependencies": { + "Speckle.Autofac": "[2.0.999-local, )", + "Speckle.Converters.Common": "[2.0.999-local, )" + } + }, + "speckle.converters.revit2023": { + "type": "Project", + "dependencies": { + "Speckle.Converters.Common": "[2.0.999-local, )", + "Speckle.Revit2023.Interfaces": "[0.1.1-preview.0.20, )" + } + }, + "Speckle.Core": { + "type": "Project", + "dependencies": { + "GraphQL.Client": "[6.0.0, )", + "Microsoft.CSharp": "[4.7.0, )", + "Microsoft.Data.Sqlite": "[7.0.5, )", + "Polly": "[7.2.3, )", + "Polly.Contrib.WaitAndRetry": "[1.1.1, )", + "Polly.Extensions.Http": "[3.0.0, )", + "Sentry": "[3.33.0, )", + "Sentry.Serilog": "[3.33.0, )", + "Serilog": "[2.12.0, )", + "Serilog.Enrichers.ClientInfo": "[1.3.0, )", + "Serilog.Enrichers.GlobalLogContext": "[3.0.0, )", + "Serilog.Exceptions": "[8.4.0, )", + "Serilog.Sinks.Console": "[4.1.0, )", + "Serilog.Sinks.Seq": "[5.2.2, )", + "SerilogTimings": "[3.0.1, )", + "Speckle.Newtonsoft.Json": "[13.0.2, )", + "System.DoubleNumerics": "[3.1.3, )" + } + }, + "Speckle.Objects": { + "type": "Project", + "dependencies": { + "Speckle.Core": "[2.0.999-local, )" + } + } + } + } +} \ No newline at end of file diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023/RevitVersionConversionHelper.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023/RevitVersionConversionHelper.cs deleted file mode 100644 index 515c2e057f..0000000000 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023/RevitVersionConversionHelper.cs +++ /dev/null @@ -1,19 +0,0 @@ -using Speckle.Converters.RevitShared; - -namespace Speckle.Converters.Revit2023; - -public class RevitVersionConversionHelper : IRevitVersionConversionHelper -{ - public bool IsCurveClosed(DB.NurbSpline nurbsSpline) - { - try - { - return nurbsSpline.IsClosed; - } - catch (Autodesk.Revit.Exceptions.ApplicationException) - { - // POC: is this actually a good assumption? - return true; - } - } -} diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023/Speckle.Converters.Revit2023.csproj b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023/Speckle.Converters.Revit2023.csproj index d304c7cfec..351d1fa2e3 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023/Speckle.Converters.Revit2023.csproj +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023/Speckle.Converters.Revit2023.csproj @@ -3,12 +3,13 @@ net48 x64 + false - + diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Extensions/CategoryExtensions.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Extensions/CategoryExtensions.cs index 9083375a2e..c0acca23c8 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Extensions/CategoryExtensions.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Extensions/CategoryExtensions.cs @@ -1,10 +1,10 @@ -using Autodesk.Revit.DB; +using Speckle.Revit.Interfaces; namespace Speckle.Converters.RevitShared.Extensions; public static class CategoryExtensions { - public static SOBR.RevitCategory GetSchemaBuilderCategoryFromBuiltIn(this DB.BuiltInCategory builtInCategory) + public static SOBR.RevitCategory GetSchemaBuilderCategoryFromBuiltIn(this RevitBuiltInCategory builtInCategory) { // Clean up built-in name "OST_Walls" to be just "WALLS" var cleanName = builtInCategory @@ -23,9 +23,9 @@ public static SOBR.RevitCategory GetSchemaBuilderCategoryFromBuiltIn(this DB.Bui return cat; } - public static BuiltInCategory GetBuiltInCategory(this Category category) + public static RevitBuiltInCategory GetBuiltInCategory(this IRevitCategory category) { - return (BuiltInCategory)category.Id.IntegerValue; + return (RevitBuiltInCategory)category.Id.IntegerValue; } public static string GetBuiltInFromSchemaBuilderCategory(this SOBR.RevitCategory c) diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Extensions/DefinitionExtensions.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Extensions/DefinitionExtensions.cs index 77aff9d11b..1b3a22beda 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Extensions/DefinitionExtensions.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Extensions/DefinitionExtensions.cs @@ -1,16 +1,12 @@ -using Autodesk.Revit.DB; +using Speckle.Revit.Interfaces; namespace Speckle.Converters.RevitShared.Extensions; public static class DefinitionExtensions { // POC: can we just interface these specialisations out and thereby avoid this kind of BS :D - public static string GetUnitTypeString(this Definition definition) + public static string GetUnitTypeString(this IRevitDefinition definition) { -#if REVIT2020 || REVIT2021 - return definition.UnitType.ToString(); -#else return definition.GetDataType().TypeId; -#endif } } diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Extensions/ElementExtensions.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Extensions/ElementExtensions.cs index 468a98fd0f..e8553e34cb 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Extensions/ElementExtensions.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Extensions/ElementExtensions.cs @@ -1,30 +1,31 @@ -using Autodesk.Revit.DB; +using Speckle.Revit.Interfaces; namespace Speckle.Converters.RevitShared.Extensions; public static class ElementExtensions { // POC: should this be an injected service? - public static IList GetHostedElementIds(this Element host) + public static IList GetHostedElementIds(this IRevitElement host, IRevitFilterFactory filterFactory) { - IList ids; - if (host is HostObject hostObject) + IList ids; + var hostObject = host.ToHostObject(); + if (hostObject is not null) { ids = hostObject.FindInserts(true, false, false, false); } else { - var typeFilter = new ElementIsElementTypeFilter(true); - var categoryFilter = new ElementMulticategoryFilter( - new List() + var typeFilter = filterFactory.CreateElementIsElementTypeFilter(true); + var categoryFilter = filterFactory.CreateElementMulticategoryFilter( + new List() { - BuiltInCategory.OST_CLines, - BuiltInCategory.OST_SketchLines, - BuiltInCategory.OST_WeakDims + RevitBuiltInCategory.OST_CLines, + RevitBuiltInCategory.OST_SketchLines, + RevitBuiltInCategory.OST_WeakDims }, true ); - ids = host.GetDependentElements(new LogicalAndFilter(typeFilter, categoryFilter)); + ids = host.GetDependentElements(filterFactory.CreateLogicalAndFilter(typeFilter, categoryFilter)); } // dont include host elementId diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Extensions/ForgeTypeIdExtensions.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Extensions/ForgeTypeIdExtensions.cs index 790e92a07a..1c9d03b5a1 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Extensions/ForgeTypeIdExtensions.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Extensions/ForgeTypeIdExtensions.cs @@ -1,25 +1,25 @@ -using Autodesk.Revit.DB; +using Speckle.Revit.Interfaces; namespace Speckle.Converters.RevitShared.Extensions; public static class ForgeTypeIdExtensions { - public static string? GetSymbol(this ForgeTypeId forgeTypeId) + public static string? GetSymbol(this IRevitForgeTypeId forgeTypeId, IRevitFormatOptionsUtils formatOptionsUtils) { - if (!FormatOptions.CanHaveSymbol(forgeTypeId)) + if (!formatOptionsUtils.CanHaveSymbol(forgeTypeId)) { return null; } - var validSymbols = FormatOptions.GetValidSymbols(forgeTypeId); + var validSymbols = formatOptionsUtils.GetValidSymbols(forgeTypeId); var typeId = validSymbols.Where(x => !x.Empty()); - foreach (DB.ForgeTypeId symbolId in typeId) + foreach (var symbolId in typeId) { - return LabelUtils.GetLabelForSymbol(symbolId); + return formatOptionsUtils.GetLabelForSymbol(symbolId); } return null; } - public static string ToUniqueString(this ForgeTypeId forgeTypeId) + public static string ToUniqueString(this IRevitForgeTypeId forgeTypeId) { return forgeTypeId.TypeId; } diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Extensions/ParameterExtensions.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Extensions/ParameterExtensions.cs index c8ac6f92e8..704eb40484 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Extensions/ParameterExtensions.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Extensions/ParameterExtensions.cs @@ -1,4 +1,5 @@ -using Autodesk.Revit.DB; +using Speckle.Converters.Common; +using Speckle.Revit.Interfaces; namespace Speckle.Converters.RevitShared.Extensions; @@ -10,7 +11,7 @@ public static class ParameterExtensions /// /// /// - public static string GetInternalName(this DB.Parameter rp) + public static string GetInternalName(this IRevitParameter rp) { if (rp.IsShared) { @@ -18,8 +19,8 @@ public static string GetInternalName(this DB.Parameter rp) } else { - var def = (InternalDefinition)rp.Definition; - if (def.BuiltInParameter == BuiltInParameter.INVALID) + var def = rp.Definition.ToInternal().NotNull(); + if (def.BuiltInParameter == RevitBuiltInParameter.INVALID) { return def.Name; } @@ -28,9 +29,9 @@ public static string GetInternalName(this DB.Parameter rp) } } - public static BuiltInParameter? GetBuiltInParameter(this Parameter rp) + public static RevitBuiltInParameter? GetBuiltInParameter(this IRevitParameter rp) { - var def = rp.Definition as InternalDefinition; + var def = rp.Definition.ToInternal(); return def?.BuiltInParameter; } } diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/GlobalUsings.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/GlobalUsings.cs index 5a7a8f20bd..a4a6c2cf0d 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/GlobalUsings.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/GlobalUsings.cs @@ -1,5 +1,3 @@ -global using DB = Autodesk.Revit.DB; -global using DBA = Autodesk.Revit.DB.Architecture; -global using SOG = Objects.Geometry; +global using SOG = Objects.Geometry; global using SOBR = Objects.BuiltElements.Revit; global using SOBE = Objects.BuiltElements; diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/DisplayValueExtractor.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/DisplayValueExtractor.cs index cd65fb5f90..2e5eaa8f4f 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/DisplayValueExtractor.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/DisplayValueExtractor.cs @@ -1,35 +1,50 @@ +using System.Diagnostics.CodeAnalysis; +using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; using Speckle.Core.Logging; +using Speckle.InterfaceGenerator; +using Speckle.Revit.Interfaces; namespace Speckle.Converters.RevitShared.Helpers; // POC: needs breaking down https://spockle.atlassian.net/browse/CNX-9354 -public sealed class DisplayValueExtractor +[GenerateAutoInterface] +public sealed class DisplayValueExtractor : IDisplayValueExtractor { - private readonly ITypedConverter>, List> _meshByMaterialConverter; + private readonly ITypedConverter< + Dictionary>, + List + > _meshByMaterialConverter; + private readonly IRevitOptionsFactory _revitOptionsFactory; + private readonly IRevitSolidUtils _revitSolidUtils; public DisplayValueExtractor( - ITypedConverter>, List> meshByMaterialConverter + ITypedConverter>, List> meshByMaterialConverter, + IRevitOptionsFactory revitOptionsFactory, + IRevitSolidUtils revitSolidUtils ) { _meshByMaterialConverter = meshByMaterialConverter; + _revitOptionsFactory = revitOptionsFactory; + _revitSolidUtils = revitSolidUtils; } public List GetDisplayValue( - DB.Element element, - DB.Options? options = null, + IRevitElement element, + IRevitOptions? options = null, // POC: should this be part of the context? - DB.Transform? transform = null + IRevitTransform? transform = null ) { var displayMeshes = new List(); // test if the element is a group first - if (element is DB.Group g) + var g = element.ToGroup(); + if (g is not null) { foreach (var id in g.GetMemberIds()) { - var groupMeshes = GetDisplayValue(element.Document.GetElement(id), options); + var groupMeshes = GetDisplayValue(element.Document.GetElement(id).NotNull(), options); displayMeshes.AddRange(groupMeshes); } return displayMeshes; @@ -42,18 +57,18 @@ public DisplayValueExtractor( return _meshByMaterialConverter.Convert(meshesByMaterial); } - private static Dictionary> GetMeshesByMaterial( - List meshes, - List solids + private static Dictionary> GetMeshesByMaterial( + List meshes, + List solids ) { - var meshesByMaterial = new Dictionary>(); + var meshesByMaterial = new Dictionary>(); foreach (var mesh in meshes) { var materialId = mesh.MaterialElementId; - if (!meshesByMaterial.TryGetValue(materialId, out List? value)) + if (!meshesByMaterial.TryGetValue(materialId, out List? value)) { - value = new List(); + value = new List(); meshesByMaterial[materialId] = value; } @@ -62,12 +77,12 @@ public DisplayValueExtractor( foreach (var solid in solids) { - foreach (DB.Face face in solid.Faces) + foreach (IRevitFace face in solid.Faces) { var materialId = face.MaterialElementId; - if (!meshesByMaterial.TryGetValue(materialId, out List? value)) + if (!meshesByMaterial.TryGetValue(materialId, out List? value)) { - value = new List(); + value = new List(); meshesByMaterial[materialId] = value; } @@ -78,29 +93,30 @@ public DisplayValueExtractor( return meshesByMaterial; } - private (List, List) GetSolidsAndMeshesFromElement( - DB.Element element, - DB.Options? options, - DB.Transform? transform = null + [SuppressMessage("Design", "CA1031:Do not catch general exception types")] + private (List, List) GetSolidsAndMeshesFromElement( + IRevitElement element, + IRevitOptions? options, + IRevitTransform? transform = null ) { //options = ViewSpecificOptions ?? options ?? new Options() { DetailLevel = DetailLevelSetting }; - options ??= new DB.Options { DetailLevel = DB.ViewDetailLevel.Fine }; + options ??= _revitOptionsFactory.Create(RevitViewDetailLevel.Fine); - DB.GeometryElement geom; + IRevitGeometryElement geom; try { - geom = element.get_Geometry(options); + geom = element.GetGeometry(options); } // POC: should we be trying to continue? - catch (Autodesk.Revit.Exceptions.ArgumentException) + catch (Exception) { options.ComputeReferences = false; - geom = element.get_Geometry(options); + geom = element.GetGeometry(options); } - var solids = new List(); - var meshes = new List(); + var solids = new List(); + var meshes = new List(); if (geom != null) { @@ -128,11 +144,11 @@ public DisplayValueExtractor( /// /// private void SortGeometry( - DB.Element element, - List solids, - List meshes, - DB.GeometryElement geom, - DB.Transform? inverseTransform = null + IRevitElement element, + List solids, + List meshes, + IRevitGeometryElement geom, + IRevitTransform? inverseTransform = null ) { var topLevelSolidsCount = 0; @@ -141,32 +157,36 @@ private void SortGeometry( var topLevelGeomInstanceCount = 0; bool hasSymbolGeometry = false; - foreach (DB.GeometryObject geomObj in geom) + foreach (IRevitGeometryObject geomObj in geom) { // POC: switch could possibly become factory and IIndex<,> pattern and move conversions to // separate IComeConversionInterfaces - switch (geomObj) + var solid = geomObj.ToSolid(); + if (solid is not null) { - case DB.Solid solid: - // skip invalid solid - if ( - solid.Faces.Size == 0 - || Math.Abs(solid.SurfaceArea) == 0 - || IsSkippableGraphicStyle(solid.GraphicsStyleId, element.Document) - ) - { - continue; - } + // skip invalid solid + if ( + solid.Faces.Count == 0 + || Math.Abs(solid.SurfaceArea) == 0 + || IsSkippableGraphicStyle(solid.GraphicsStyleId, element.Document) + ) + { + continue; + } - if (inverseTransform != null) - { - topLevelSolidsCount++; - solid = DB.SolidUtils.CreateTransformed(solid, inverseTransform); - } + if (inverseTransform != null) + { + topLevelSolidsCount++; + solid = _revitSolidUtils.CreateTransformed(solid, inverseTransform); + } - solids.Add(solid); - break; - case DB.Mesh mesh: + solids.Add(solid); + } + else + { + var mesh = geomObj.ToMesh(); + if (mesh is not null) + { if (IsSkippableGraphicStyle(mesh.GraphicsStyleId, element.Document)) { continue; @@ -175,35 +195,46 @@ private void SortGeometry( if (inverseTransform != null) { topLevelMeshesCount++; - mesh = mesh.get_Transformed(inverseTransform); + mesh = mesh.GetTransformed(inverseTransform); } meshes.Add(mesh); - break; - case DB.GeometryInstance instance: - // element transforms should not be carried down into nested geometryInstances. - // Nested geomInstances should have their geom retreived with GetInstanceGeom, not GetSymbolGeom - if (inverseTransform != null) + } + else + { + var instance = geomObj.ToGeometryInstance(); + if (instance is not null) { - topLevelGeomInstanceCount++; - SortGeometry(element, solids, meshes, instance.GetSymbolGeometry()); - if (meshes.Count > 0 || solids.Count > 0) + // element transforms should not be carried down into nested geometryInstances. + // Nested geomInstances should have their geom retreived with GetInstanceGeom, not GetSymbolGeom + if (inverseTransform != null) { - hasSymbolGeometry = true; + topLevelGeomInstanceCount++; + SortGeometry(element, solids, meshes, instance.GetSymbolGeometry()); + if (meshes.Count > 0 || solids.Count > 0) + { + hasSymbolGeometry = true; + } + } + else + { + SortGeometry(element, solids, meshes, instance.GetInstanceGeometry()); } } else { - SortGeometry(element, solids, meshes, instance.GetInstanceGeometry()); - } - break; - case DB.GeometryElement geometryElement: - if (inverseTransform != null) - { - topLevelGeomElementCount++; + var geometryElement = geomObj.ToGeometryElement(); + if (geometryElement is not null) + { + if (inverseTransform != null) + { + topLevelGeomElementCount++; + } + + SortGeometry(element, solids, meshes, geometryElement); + } } - SortGeometry(element, solids, meshes, geometryElement); - break; + } } } @@ -221,7 +252,7 @@ private void SortGeometry( // POC: should be hoovered up with the new reporting, logging, exception philosophy private static void LogInstanceMeshRetrievalWarnings( - DB.Element element, + IRevitElement element, int topLevelSolidsCount, int topLevelMeshesCount, int topLevelGeomElementCount, @@ -263,26 +294,23 @@ bool hasSymbolGeom /// /// We're caching a dictionary of graphic styles and their ids as it can be a costly operation doing Document.GetElement(solid.GraphicsStyleId) for every solid /// - private readonly Dictionary _graphicStyleCache = new(); + private readonly Dictionary _graphicStyleCache = new(); /// /// Exclude light source cones and potentially other geometries by their graphic style /// - /// - /// - /// - private bool IsSkippableGraphicStyle(DB.ElementId id, DB.Document doc) + private bool IsSkippableGraphicStyle(IRevitElementId id, IRevitDocument doc) { if (!_graphicStyleCache.ContainsKey(id.ToString())) { - _graphicStyleCache.Add(id.ToString(), (DB.GraphicsStyle)doc.GetElement(id)); + _graphicStyleCache.Add(id.ToString(), doc.GetElement(id).NotNull().ToGraphicsStyle().NotNull()); } var graphicStyle = _graphicStyleCache[id.ToString()]; if ( graphicStyle != null - && graphicStyle.GraphicsStyleCategory.Id.IntegerValue == (int)DB.BuiltInCategory.OST_LightingFixtureSource + && graphicStyle.GraphicsStyleCategory.Id.IntegerValue == (int)RevitBuiltInCategory.OST_LightingFixtureSource ) { return true; diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/IRevitConversionContextStack.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/IRevitConversionContextStack.cs deleted file mode 100644 index 1cf5d4b80c..0000000000 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/IRevitConversionContextStack.cs +++ /dev/null @@ -1,13 +0,0 @@ -using Autodesk.Revit.DB; -using Speckle.Converters.Common; - -namespace Speckle.Converters.RevitShared.Helpers; - -[System.Diagnostics.CodeAnalysis.SuppressMessage( - "Naming", - "CA1711:Identifiers should not have incorrect suffix", - Justification = "See base class justification" -)] -// POC: so this should *probably* be Document and NOT UI.UIDocument, the former is Conversion centric -// and the latter is more for connector -public interface IRevitConversionContextStack : IConversionContextStack { } diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/ISlopeArrowExtractor.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/ISlopeArrowExtractor.cs deleted file mode 100644 index 750f4d1073..0000000000 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/ISlopeArrowExtractor.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace Speckle.Converters.RevitShared.Helpers; - -public interface ISlopeArrowExtractor -{ - DB.ModelLine? GetSlopeArrow(DB.Element element); - SOG.Point GetSlopeArrowHead(DB.ModelLine slopeArrow); - SOG.Point GetSlopeArrowTail(DB.ModelLine slopeArrow); - double GetSlopeArrowTailOffset(DB.ModelLine slopeArrow); - double GetSlopeArrowHeadOffset(DB.ModelLine slopeArrow, double tailOffset, out double slope); -} diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/ParameterObjectAssigner.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/ParameterObjectAssigner.cs index 2c4f3b2112..5b543a70f2 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/ParameterObjectAssigner.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/ParameterObjectAssigner.cs @@ -1,41 +1,46 @@ -using Autodesk.Revit.DB; -using Speckle.Converters.Common; +using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; using Speckle.Core.Logging; using Speckle.Core.Models; +using Speckle.InterfaceGenerator; +using Speckle.Revit.Interfaces; namespace Speckle.Converters.RevitShared.Helpers; // POC: rationalise whether this and ParameterObjectBuilder are sufficiently different?? // did it go away? -public sealed class ParameterObjectAssigner +[GenerateAutoInterface] +public sealed class ParameterObjectAssigner : IParameterObjectAssigner { - private readonly ITypedConverter _paramConverter; - private readonly ParameterValueExtractor _parameterValueExtractor; + private readonly ITypedConverter _paramConverter; + private readonly IParameterValueExtractor _parameterValueExtractor; + private readonly IRevitElementIdUtils _revitElementIdUtils; public ParameterObjectAssigner( - ITypedConverter paramConverter, - ParameterValueExtractor parameterValueExtractor + ITypedConverter paramConverter, + IParameterValueExtractor parameterValueExtractor, + IRevitElementIdUtils revitElementIdUtils ) { _paramConverter = paramConverter; _parameterValueExtractor = parameterValueExtractor; + _revitElementIdUtils = revitElementIdUtils; } - public void AssignParametersToBase(Element target, Base @base) + public void AssignParametersToBase(IRevitElement target, Base @base) { - Dictionary instanceParameters = _parameterValueExtractor.GetAllRemainingParams(target); - ElementId elementId = target.GetTypeId(); + var instanceParameters = _parameterValueExtractor.GetAllRemainingParams(target); + IRevitElementId elementId = target.GetTypeId(); Base paramBase = new(); AssignSpeckleParamToBaseObject(instanceParameters, paramBase); // POC: Some elements can have an invalid element type ID, I don't think we want to continue here. - if (elementId != ElementId.InvalidElementId && target is not Level) //ignore type props of levels..! + if (elementId != _revitElementIdUtils.InvalidElementId && target is not SOBE.Level) //ignore type props of levels..! { - var elementType = target.Document.GetElement(elementId); + var elementType = target.Document.GetElement(elementId).NotNull(); // I don't think we should be adding the type parameters to the object like this - Dictionary typeParameters = _parameterValueExtractor.GetAllRemainingParams(elementType); + var typeParameters = _parameterValueExtractor.GetAllRemainingParams(elementType); AssignSpeckleParamToBaseObject(typeParameters, paramBase, true); } @@ -46,7 +51,7 @@ public void AssignParametersToBase(Element target, Base @base) } private void AssignSpeckleParamToBaseObject( - IEnumerable> parameters, + IEnumerable> parameters, Base paramBase, bool isTypeParameter = false ) @@ -56,7 +61,7 @@ private void AssignSpeckleParamToBaseObject( { try { - SOBR.Parameter speckleParam = _paramConverter.Convert(kv.Value); + var speckleParam = _paramConverter.Convert(kv.Value); speckleParam.isTypeParameter = isTypeParameter; paramBase[kv.Key] = speckleParam; } diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/ParameterObjectBuilder.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/ParameterObjectBuilder.cs deleted file mode 100644 index 71cf930224..0000000000 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/ParameterObjectBuilder.cs +++ /dev/null @@ -1,50 +0,0 @@ -using System.Collections.Generic; -using System.Linq; -using Autodesk.Revit.DB; -using Speckle.Converters.Common.Objects; -using Speckle.Core.Logging; -using Speckle.Core.Models; - -namespace Speckle.Converters.RevitShared.Helpers; - -public sealed class ParameterObjectAssigner -{ - private readonly IRawConversion _paramConverter; - private readonly ParameterValueExtractor _parameterValueExtractor; - - public ParameterObjectAssigner( - IRawConversion paramConverter, - ParameterValueExtractor parameterValueExtractor - ) - { - _paramConverter = paramConverter; - _parameterValueExtractor = parameterValueExtractor; - } - - public void AssignParametersToBase(Element target, Base @base) - { - Dictionary allParams = _parameterValueExtractor.GetAllRemainingParams(target); - Base paramBase = new(); - //sort by key - foreach (var kv in allParams.OrderBy(x => x.Key)) - { - try - { - paramBase[kv.Key] = _paramConverter.RawConvert(kv.Value); - } - catch (InvalidPropNameException) - { - //ignore - } - catch (SpeckleException ex) - { - SpeckleLog.Logger.Warning(ex, "Error thrown when trying to set property named {propName}", kv.Key); - } - } - - if (paramBase.GetMembers(DynamicBaseMemberType.Dynamic).Count > 0) - { - @base["parameters"] = paramBase; - } - } -} diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/ParameterValueExtractor.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/ParameterValueExtractor.cs index cdc8e69243..b5218980fd 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/ParameterValueExtractor.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/ParameterValueExtractor.cs @@ -1,7 +1,9 @@ -using Autodesk.Revit.DB; +using System.Diagnostics.CodeAnalysis; using Speckle.Converters.Common; using Speckle.Converters.RevitShared.Extensions; using Speckle.Converters.RevitShared.Services; +using Speckle.InterfaceGenerator; +using Speckle.Revit.Interfaces; namespace Speckle.Converters.RevitShared.Helpers; @@ -9,17 +11,18 @@ namespace Speckle.Converters.RevitShared.Helpers; // really if we have to edit a switch statement... // maybe also better as an extension method, but maybe is fine? // POC: there are a lot of public methods here. Maybe consider consolodating -public class ParameterValueExtractor +[GenerateAutoInterface] +public class ParameterValueExtractor : IParameterValueExtractor { - private readonly ScalingServiceToSpeckle _scalingService; - private readonly Dictionary> _uniqueIdToUsedParameterSetMap = new(); + private readonly IScalingServiceToSpeckle _scalingService; + private readonly Dictionary> _uniqueIdToUsedParameterSetMap = new(); - public ParameterValueExtractor(ScalingServiceToSpeckle scalingService) + public ParameterValueExtractor(IScalingServiceToSpeckle scalingService) { _scalingService = scalingService; } - public object? GetValue(Parameter parameter) + public object? GetValue(IRevitParameter parameter) { if (!parameter.HasValue) { @@ -28,32 +31,36 @@ public ParameterValueExtractor(ScalingServiceToSpeckle scalingService) return parameter.StorageType switch { - StorageType.Double => GetValueAsDouble(parameter), - StorageType.Integer => GetValueAsInt(parameter), - StorageType.String => GetValueAsString(parameter), - StorageType.ElementId => GetValueAsElementId(parameter)?.ToString(), - StorageType.None + RevitStorageType.Double => GetValueAsDouble(parameter), + RevitStorageType.Integer => GetValueAsInt(parameter), + RevitStorageType.String => GetValueAsString(parameter), + RevitStorageType.ElementId => GetValueAsElementId(parameter)?.ToString(), + RevitStorageType.None or _ => throw new SpeckleConversionException($"Unsupported parameter storage type {parameter.StorageType}") }; } - public double GetValueAsDouble(Element element, BuiltInParameter builtInParameter) + public double GetValueAsDouble(IRevitElement element, RevitBuiltInParameter builtInParameter) { if (!TryGetValueAsDouble(element, builtInParameter, out double? value)) { throw new SpeckleConversionException($"Failed to get {builtInParameter} as double."); } - return value!.Value; // If TryGet returns true, we succeeded in obtaining the value, and it will not be null. + return value.Value; // If TryGet returns true, we succeeded in obtaining the value, and it will not be null. } - public bool TryGetValueAsDouble(Element element, BuiltInParameter builtInParameter, out double? value) + public bool TryGetValueAsDouble( + IRevitElement element, + RevitBuiltInParameter builtInParameter, + [NotNullWhen(true)] out double? value + ) { var number = GetValueGeneric( element, builtInParameter, - StorageType.Double, + RevitStorageType.Double, (parameter) => _scalingService.Scale(parameter.AsDouble(), parameter.GetUnitTypeId()) ); if (number.HasValue) @@ -66,69 +73,81 @@ public bool TryGetValueAsDouble(Element element, BuiltInParameter builtInParamet return false; } - private double? GetValueAsDouble(Parameter parameter) + private double? GetValueAsDouble(IRevitParameter parameter) { return GetValueGeneric( parameter, - StorageType.Double, + RevitStorageType.Double, (parameter) => _scalingService.Scale(parameter.AsDouble(), parameter.GetUnitTypeId()) ); } - public int GetValueAsInt(Element element, BuiltInParameter builtInParameter) + public int GetValueAsInt(IRevitElement element, RevitBuiltInParameter builtInParameter) { - return GetValueGeneric(element, builtInParameter, StorageType.Integer, (parameter) => parameter.AsInteger()) + return GetValueGeneric( + element, + builtInParameter, + RevitStorageType.Integer, + (parameter) => parameter.AsInteger() + ) ?? throw new SpeckleConversionException( $"Expected int but got null for property {builtInParameter} on element of type {element.GetType()}" ); } - private int? GetValueAsInt(Parameter parameter) + private int? GetValueAsInt(IRevitParameter parameter) { - return GetValueGeneric(parameter, StorageType.Integer, (parameter) => parameter.AsInteger()); + return GetValueGeneric(parameter, RevitStorageType.Integer, (parameter) => parameter.AsInteger()); } - public bool? GetValueAsBool(Element element, BuiltInParameter builtInParameter) + public bool? GetValueAsBool(IRevitElement element, RevitBuiltInParameter builtInParameter) { var intVal = GetValueGeneric( element, builtInParameter, - StorageType.Integer, + RevitStorageType.Integer, (parameter) => parameter.AsInteger() ); return intVal.HasValue ? Convert.ToBoolean(intVal.Value) : null; } - public string? GetValueAsString(Element element, BuiltInParameter builtInParameter) + public string? GetValueAsString(IRevitElement element, RevitBuiltInParameter builtInParameter) { - return GetValueGeneric(element, builtInParameter, StorageType.String, (parameter) => parameter.AsString()); + return GetValueGeneric(element, builtInParameter, RevitStorageType.String, (parameter) => parameter.AsString()); } - private string? GetValueAsString(Parameter parameter) + private string? GetValueAsString(IRevitParameter parameter) { - return GetValueGeneric(parameter, StorageType.String, (parameter) => parameter.AsString()); + return GetValueGeneric(parameter, RevitStorageType.String, (parameter) => parameter.AsString()); } - public ElementId GetValueAsElementId(Element element, BuiltInParameter builtInParameter) + public IRevitElementId GetValueAsElementId(IRevitElement element, RevitBuiltInParameter builtInParameter) { if (TryGetValueAsElementId(element, builtInParameter, out var elementId)) { - return elementId!; + return elementId; } throw new SpeckleConversionException( $"Failed to get {builtInParameter} on element of type {element.GetType()} as ElementId" ); } - public bool TryGetValueAsElementId(Element element, BuiltInParameter builtInParameter, out ElementId? elementId) + public bool TryGetValueAsElementId( + IRevitElement element, + RevitBuiltInParameter builtInParameter, + [NotNullWhen(true)] out IRevitElementId? elementId + ) { - if ( - GetValueGeneric(element, builtInParameter, StorageType.ElementId, (parameter) => parameter.AsElementId()) - is ElementId elementIdNotNull - ) + var generic = GetValueGeneric( + element, + builtInParameter, + RevitStorageType.ElementId, + (parameter) => parameter.AsElementId() + ); + if (generic is not null) { - elementId = elementIdNotNull; + elementId = generic; return true; } @@ -136,62 +155,49 @@ is ElementId elementIdNotNull return false; } - public ElementId? GetValueAsElementId(Parameter parameter) + public IRevitElementId? GetValueAsElementId(IRevitParameter parameter) { - return GetValueGeneric(parameter, StorageType.ElementId, (parameter) => parameter.AsElementId()); + return GetValueGeneric(parameter, RevitStorageType.ElementId, (p) => p.AsElementId()); } - public bool TryGetValueAsDocumentObject(Element element, BuiltInParameter builtInParameter, out T? value) + public IRevitLevel? GetValueAsRevitLevel(IRevitElement element, RevitBuiltInParameter builtInParameter) { if (!TryGetValueAsElementId(element, builtInParameter, out var elementId)) { - value = default; - return false; + throw new SpeckleConversionException(); } - Element paramElement = element.Document.GetElement(elementId); - if (paramElement is not T typedElement) - { - value = default; - return false; - } - - value = typedElement; - return true; - } - - public T GetValueAsDocumentObject(Element element, BuiltInParameter builtInParameter) - where T : class - { - if (!TryGetValueAsDocumentObject(element, builtInParameter, out var value)) - { - throw new SpeckleConversionException($"Failed to get {builtInParameter} as an element of type {typeof(T)}"); - } - - return value!; // If TryGet returns true, we succeeded in obtaining the value, and it will not be null. + var paramElement = element.Document.GetElement(elementId); + return paramElement?.ToLevel(); } private TResult? GetValueGeneric( - Element element, - BuiltInParameter builtInParameter, - StorageType expectedStorageType, - Func getParamValue + IRevitElement element, + RevitBuiltInParameter builtInParameter, + RevitStorageType expectedStorageType, + Func getParamValue ) { - if (!_uniqueIdToUsedParameterSetMap.TryGetValue(element.UniqueId, out HashSet usedParameters)) + if ( + !_uniqueIdToUsedParameterSetMap.TryGetValue(element.UniqueId, out HashSet usedParameters) + ) { usedParameters = new(); _uniqueIdToUsedParameterSetMap[element.UniqueId] = usedParameters; } usedParameters.Add(builtInParameter); - var parameter = element.get_Parameter(builtInParameter); + var parameter = element.GetParameter(builtInParameter); + if (parameter is null) + { + return default; + } return GetValueGeneric(parameter, expectedStorageType, getParamValue); } private TResult? GetValueGeneric( - Parameter parameter, - StorageType expectedStorageType, - Func getParamValue + IRevitParameter parameter, + RevitStorageType expectedStorageType, + Func getParamValue ) { if (parameter == null || !parameter.HasValue) @@ -209,20 +215,20 @@ public T GetValueAsDocumentObject(Element element, BuiltInParameter builtInPa return getParamValue(parameter); } - public Dictionary GetAllRemainingParams(DB.Element revitElement) + public Dictionary GetAllRemainingParams(IRevitElement revitElement) { - var allParams = new Dictionary(); + var allParams = new Dictionary(); AddElementParamsToDict(revitElement, allParams); return allParams; } - private void AddElementParamsToDict(DB.Element element, Dictionary paramDict) + private void AddElementParamsToDict(IRevitElement element, Dictionary paramDict) { - _uniqueIdToUsedParameterSetMap.TryGetValue(element.UniqueId, out HashSet? usedParameters); + _uniqueIdToUsedParameterSetMap.TryGetValue(element.UniqueId, out HashSet? usedParameters); using var parameters = element.Parameters; - foreach (DB.Parameter param in parameters) + foreach (IRevitParameter param in parameters) { var internalName = param.GetInternalName(); if (paramDict.ContainsKey(internalName)) @@ -230,7 +236,8 @@ private void AddElementParamsToDict(DB.Element element, Dictionary -/// Contains predefined categories of revit objects as well as the types that make up the elements -/// in that category -/// -/// -// POC: is quite a messy looking thing, need some review -// might be legit or maybe a bette/cleaner pattern rather than the dictionary of pain, but maybe not -// some whitespace between each at the least! -public static class RevitCategories -{ - public static Dictionary All { get; } - - static RevitCategories() - { - All = new(StringComparer.OrdinalIgnoreCase) - { - { nameof(CableTray), CableTray }, - { nameof(Ceiling), Ceiling }, - { nameof(Column), Column }, - { nameof(Conduit), Conduit }, - { nameof(Door), Door }, - { nameof(Duct), Duct }, - { nameof(FamilyInstance), FamilyInstance }, - { nameof(Floor), Floor }, - { nameof(Furniture), Furniture }, - { nameof(Pipe), Pipe }, - { nameof(PlumbingFixture), PlumbingFixture }, - { nameof(Roof), Roof }, - { nameof(Railing), Railing }, - { nameof(StructuralFraming), StructuralFraming }, - { nameof(Wall), Wall }, - { nameof(Window), Window }, - { nameof(Wire), Wire }, - { nameof(Undefined), Undefined }, - }; - } - - public static RevitCategoryInfo CableTray { get; } = - new( - nameof(CableTray), - typeof(DB.Electrical.CableTray), - typeof(DB.Electrical.CableTrayType), - new List() - ); - public static RevitCategoryInfo Ceiling { get; } = - new(nameof(Ceiling), typeof(DB.Ceiling), typeof(CeilingType), new List()); - public static RevitCategoryInfo Column { get; } = - new( - nameof(Column), - typeof(FamilyInstance), - typeof(FamilySymbol), - new List { BuiltInCategory.OST_Columns, BuiltInCategory.OST_StructuralColumns } - ); - public static RevitCategoryInfo Conduit { get; } = - new(nameof(Conduit), typeof(DB.Electrical.Conduit), typeof(DB.Electrical.ConduitType), new List()); - public static RevitCategoryInfo Door { get; } = - new( - nameof(Door), - typeof(DB.FamilyInstance), - typeof(DB.FamilySymbol), - new List { BuiltInCategory.OST_Doors } - ); - public static RevitCategoryInfo Duct { get; } = - new( - nameof(Duct), - typeof(DB.Mechanical.Duct), - typeof(DB.MEPCurveType), - new List { BuiltInCategory.OST_DuctCurves, BuiltInCategory.OST_FlexDuctCurves } - ); - public static RevitCategoryInfo FamilyInstance { get; } = - new(nameof(FamilyInstance), typeof(DB.FamilyInstance), typeof(DB.FamilySymbol), new List()); - public static RevitCategoryInfo Floor { get; } = - new( - nameof(Floor), - typeof(DB.Floor), - typeof(DB.FloorType), - new List { BuiltInCategory.OST_Floors } - ); - public static RevitCategoryInfo Furniture { get; } = - new( - nameof(Furniture), - typeof(DB.FamilyInstance), - typeof(DB.FamilySymbol), - new List { BuiltInCategory.OST_Furniture } - ); - - //public static RevitCategoryInfo Material { get; } = new( - // nameof(Material), - // typeof(DB.Material), - // null, - // new List - // { - // BuiltInCategory.OST_Materials, - // BuiltInCategory.OST_PipeMaterials, - // BuiltInCategory.OST_WireMaterials - // }); - public static RevitCategoryInfo Pipe { get; } = - new( - nameof(Pipe), - typeof(DB.Plumbing.Pipe), - typeof(DB.MEPCurveType), - new List { BuiltInCategory.OST_PipeCurves, BuiltInCategory.OST_FlexPipeCurves } - ); - public static RevitCategoryInfo PlumbingFixture { get; } = - new( - nameof(PlumbingFixture), - typeof(DB.FamilyInstance), - typeof(DB.FamilySymbol), - new List { BuiltInCategory.OST_PlumbingFixtures } - ); - public static RevitCategoryInfo Roof { get; } = - new( - nameof(Roof), - typeof(DB.RoofBase), - typeof(DB.RoofType), - new List { BuiltInCategory.OST_Roofs, } - ); - public static RevitCategoryInfo Railing { get; } = - new( - nameof(Railing), - typeof(DB.Architecture.Railing), - typeof(DB.Architecture.RailingType), - new List() - ); - public static RevitCategoryInfo StructuralFraming { get; } = - new( - nameof(StructuralFraming), - typeof(DB.FamilyInstance), - typeof(DB.FamilySymbol), - new List { BuiltInCategory.OST_StructuralFraming }, - new List { "beam", "brace", "framing" } - ); - public static RevitCategoryInfo Wall { get; } = - new(nameof(Wall), typeof(DB.Wall), typeof(DB.WallType), new List { BuiltInCategory.OST_Walls }); - public static RevitCategoryInfo Window { get; } = - new( - nameof(Window), - typeof(DB.FamilyInstance), - typeof(DB.FamilySymbol), - new List { BuiltInCategory.OST_Windows } - ); - public static RevitCategoryInfo Wire { get; } = - new(nameof(Wire), typeof(DB.Electrical.Wire), typeof(DB.Electrical.WireType), new List()); - public static RevitCategoryInfo Undefined { get; } = - new(nameof(Undefined), typeof(RevitCategoryInfo), typeof(RevitCategoryInfo), new List()); -} diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/RevitCategoryInfo.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/RevitCategoryInfo.cs deleted file mode 100644 index f883f7c9e8..0000000000 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/RevitCategoryInfo.cs +++ /dev/null @@ -1,65 +0,0 @@ -using System.Diagnostics.CodeAnalysis; -using Autodesk.Revit.DB; - -namespace Speckle.Converters.RevitShared.Helpers; - -// review, maybe it doesn't need injecting, or maybe we inject a factory? -public class RevitCategoryInfo -{ - public RevitCategoryInfo( - string name, - Type instanceType, - Type familyType, - List categories, - List? categoryAliases = null - ) - { - CategoryName = name; - ElementInstanceType = instanceType; - ElementTypeType = familyType; - BuiltInCategories = categories; - CategoryAliases = categoryAliases ?? new List(); - } - - public string CategoryName { get; } - public Type ElementInstanceType { get; } - public Type ElementTypeType { get; } - public ICollection BuiltInCategories { get; } - public List CategoryAliases { get; } - - public bool ContainsRevitCategory(Category category) - { - return BuiltInCategories.Select(x => (int)x).Contains(category.Id.IntegerValue); - } - - public List GetElementTypes(Document document) - { - return GetElementTypes(document); - } - - [SuppressMessage("Reliability", "CA2000:Dispose objects before losing scope")] - public List GetElementTypes(Document document) - where T : ElementType - { - // POC: why is this disabled? surely a using statement is golden here? - var collector = new FilteredElementCollector(document); - - if (BuiltInCategories.Count > 0) - { - using var filter = new ElementMulticategoryFilter(BuiltInCategories); - collector = collector.WherePasses(filter); - } - if (ElementTypeType != null) - { - collector = collector.OfClass(ElementTypeType); - } - var elementTypes = collector.WhereElementIsElementType().Cast().ToList(); - collector.Dispose(); - return elementTypes; - } - - public string GetCategorySpecificTypeName(string typeName) - { - return CategoryName + "_" + typeName; - } -} diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/RevitConversionContextStack.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/RevitConversionContextStack.cs deleted file mode 100644 index ce43a88901..0000000000 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/RevitConversionContextStack.cs +++ /dev/null @@ -1,28 +0,0 @@ -using Autodesk.Revit.DB; -using Speckle.Converters.Common; - -namespace Speckle.Converters.RevitShared.Helpers; - -[System.Diagnostics.CodeAnalysis.SuppressMessage( - "Naming", - "CA1711:Identifiers should not have incorrect suffix", - Justification = "See base class justification" -)] -// POC: so this should *probably* be Document and NOT UI.UIDocument, the former is Conversion centric -// and the latter is more for connector -public class RevitConversionContextStack : ConversionContextStack, IRevitConversionContextStack -{ - public const double TOLERANCE = 0.0164042; // 5mm in ft - - public RevitConversionContextStack(RevitContext context, IHostToSpeckleUnitConverter unitConverter) - : base( - // POC: we probably should not get here without a valid document - // so should this perpetuate or do we assume this is valid? - // relting on the context.UIApplication?.ActiveUIDocument is not right - // this should be some IActiveDocument I suspect? - context.UIApplication?.ActiveUIDocument?.Document - ?? throw new SpeckleConversionException("Active UI document could not be determined"), - context.UIApplication.ActiveUIDocument.Document.GetUnits().GetFormatOptions(SpecTypeId.Length).GetUnitTypeId(), - unitConverter - ) { } -} diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/SendSelection.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/SendSelection.cs deleted file mode 100644 index c6b4590a6d..0000000000 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/SendSelection.cs +++ /dev/null @@ -1,17 +0,0 @@ -namespace Speckle.Converters.RevitShared.Helpers; - -// POC: why do we need this send selection? -// why does conversion need to know about selection in this way? -public class SendSelection -{ - private readonly HashSet _selectedItemIds; - - public SendSelection(IEnumerable selectedItemIds) - { - _selectedItemIds = new HashSet(selectedItemIds); - } - - public bool Contains(string elementId) => _selectedItemIds.Contains(elementId); - - public IReadOnlyCollection SelectedItems => _selectedItemIds.ToList().AsReadOnly(); -} diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/SlopeArrowExtractor.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/SlopeArrowExtractor.cs index 9db6d14583..f1db970430 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/SlopeArrowExtractor.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/SlopeArrowExtractor.cs @@ -1,43 +1,51 @@ +using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; +using Speckle.InterfaceGenerator; +using Speckle.Revit.Interfaces; namespace Speckle.Converters.RevitShared.Helpers; +[GenerateAutoInterface] public class SlopeArrowExtractor : ISlopeArrowExtractor { - private readonly ITypedConverter _pointConverter; - private readonly ParameterValueExtractor _parameterValueExtractor; + private readonly ITypedConverter _pointConverter; + private readonly IParameterValueExtractor _parameterValueExtractor; + private readonly IRevitFilterFactory _revitFilterFactory; public SlopeArrowExtractor( - ITypedConverter pointConverter, - ParameterValueExtractor parameterValueExtractor + ITypedConverter pointConverter, + IParameterValueExtractor parameterValueExtractor, + IRevitFilterFactory revitFilterFactory ) { _pointConverter = pointConverter; _parameterValueExtractor = parameterValueExtractor; + _revitFilterFactory = revitFilterFactory; } - public DB.ModelLine? GetSlopeArrow(DB.Element element) + public IRevitModelLine? GetSlopeArrow(IRevitElement element) { - IList? elementIds = null; - if (element is DB.Floor floor) + IList? elementIds = null; + if (element is IRevitFloor floor) { - elementIds = ((DB.Sketch)floor.Document.GetElement(floor.SketchId)).GetAllElements(); + elementIds = (floor.Document.GetElement(floor.SketchId).NotNull().ToSketch().NotNull()).GetAllElements(); } if (elementIds == null) { - using var modelLineFilter = new DB.ElementCategoryFilter(DB.BuiltInCategory.OST_SketchLines); + using var modelLineFilter = _revitFilterFactory.CreateElementCategoryFilter(RevitBuiltInCategory.OST_SketchLines); elementIds = element.GetDependentElements(modelLineFilter); } foreach (var elementId in elementIds) { - if (element.Document.GetElement(elementId) is not DB.ModelLine line) + var line = element.Document.GetElement(elementId)?.ToModelLine(); + if (line is null) { continue; } - var offsetAtTailParameter = line.get_Parameter(DB.BuiltInParameter.SLOPE_START_HEIGHT); + var offsetAtTailParameter = line.GetParameter(RevitBuiltInParameter.SLOPE_START_HEIGHT); if (offsetAtTailParameter != null) { return line; @@ -46,26 +54,29 @@ ParameterValueExtractor parameterValueExtractor return null; } - public SOG.Point GetSlopeArrowHead(DB.ModelLine slopeArrow) + public SOG.Point GetSlopeArrowHead(IRevitModelLine slopeArrow) { - return _pointConverter.Convert(((DB.LocationCurve)slopeArrow.Location).Curve.GetEndPoint(1)); + return _pointConverter.Convert((slopeArrow.GetLocationAsLocationCurve().NotNull()).Curve.GetEndPoint(1)); } - public SOG.Point GetSlopeArrowTail(DB.ModelLine slopeArrow) + public SOG.Point GetSlopeArrowTail(IRevitModelLine slopeArrow) { - return _pointConverter.Convert(((DB.LocationCurve)slopeArrow.Location).Curve.GetEndPoint(0)); + return _pointConverter.Convert((slopeArrow.GetLocationAsLocationCurve().NotNull()).Curve.GetEndPoint(0)); } - public double GetSlopeArrowTailOffset(DB.ModelLine slopeArrow) + public double GetSlopeArrowTailOffset(IRevitModelLine slopeArrow) { - return _parameterValueExtractor.GetValueAsDouble(slopeArrow, DB.BuiltInParameter.SLOPE_START_HEIGHT); + return _parameterValueExtractor.GetValueAsDouble(slopeArrow, RevitBuiltInParameter.SLOPE_START_HEIGHT); } - public double GetSlopeArrowHeadOffset(DB.ModelLine slopeArrow, double tailOffset, out double slope) + public double GetSlopeArrowHeadOffset(IRevitModelLine slopeArrow, double tailOffset, out double slope) { - var specifyOffset = _parameterValueExtractor.GetValueAsInt(slopeArrow, DB.BuiltInParameter.SPECIFY_SLOPE_OR_OFFSET); + var specifyOffset = _parameterValueExtractor.GetValueAsInt( + slopeArrow, + RevitBuiltInParameter.SPECIFY_SLOPE_OR_OFFSET + ); - var lineLength = _parameterValueExtractor.GetValueAsDouble(slopeArrow, DB.BuiltInParameter.CURVE_ELEM_LENGTH); + var lineLength = _parameterValueExtractor.GetValueAsDouble(slopeArrow, RevitBuiltInParameter.CURVE_ELEM_LENGTH); slope = 0; double headOffset = 0; @@ -73,12 +84,12 @@ public double GetSlopeArrowHeadOffset(DB.ModelLine slopeArrow, double tailOffset if (specifyOffset == 1) { // in this scenario, slope is returned as a percentage. Divide by 100 to get the unitless form - slope = _parameterValueExtractor.GetValueAsDouble(slopeArrow, DB.BuiltInParameter.ROOF_SLOPE) / 100d; + slope = _parameterValueExtractor.GetValueAsDouble(slopeArrow, RevitBuiltInParameter.ROOF_SLOPE) / 100d; headOffset = tailOffset + lineLength * Math.Sin(Math.Atan(slope)); } else if (specifyOffset == 0) // 0 corrospondes to the "height at tail" option { - headOffset = _parameterValueExtractor.GetValueAsDouble(slopeArrow, DB.BuiltInParameter.SLOPE_END_HEIGHT); + headOffset = _parameterValueExtractor.GetValueAsDouble(slopeArrow, RevitBuiltInParameter.SLOPE_END_HEIGHT); slope = (headOffset - tailOffset) / lineLength; } @@ -86,3 +97,19 @@ public double GetSlopeArrowHeadOffset(DB.ModelLine slopeArrow, double tailOffset return headOffset; } } + +// POC: why do we need this send selection? +// why does conversion need to know about selection in this way? +public class SendSelection +{ + private readonly HashSet _selectedItemIds; + + public SendSelection(IEnumerable selectedItemIds) + { + _selectedItemIds = new HashSet(selectedItemIds); + } + + public bool Contains(string elementId) => _selectedItemIds.Contains(elementId); + + public IReadOnlyCollection SelectedItems => _selectedItemIds.ToList().AsReadOnly(); +} diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/ToSpeckleConvertedObjectsCache.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/ToSpeckleConvertedObjectsCache.cs deleted file mode 100644 index c4c91d9fb8..0000000000 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/ToSpeckleConvertedObjectsCache.cs +++ /dev/null @@ -1,25 +0,0 @@ -using Speckle.Core.Models; - -namespace Speckle.Converters.RevitShared.Helpers; - -// POC: review the cache? should this be a common class? -// Does caching work this way everywhere, i.e, string key and base value? -public sealed class ToSpeckleConvertedObjectsCache -{ - private readonly Dictionary _uniqueIdToConvertedBaseDict = new(); - - public void AddConvertedBase(string revitUniqueId, Base b) - { - _uniqueIdToConvertedBaseDict.Add(revitUniqueId, b); - } - - public bool ContainsBaseConvertedFromId(string revitUniqueId) - { - return _uniqueIdToConvertedBaseDict.ContainsKey(revitUniqueId); - } - - public bool TryGetConvertedBase(string revitUniqueId, out Base? value) - { - return _uniqueIdToConvertedBaseDict.TryGetValue(revitUniqueId, out value); - } -} diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/IReferencePointConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/IReferencePointConverter.cs deleted file mode 100644 index f526412336..0000000000 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/IReferencePointConverter.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace Speckle.Converters.RevitShared; - -public interface IReferencePointConverter -{ - DB.XYZ ConvertToExternalCoordindates(DB.XYZ inbound, bool isPoint); -} diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/IRevitVersionConversionHelper.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/IRevitVersionConversionHelper.cs deleted file mode 100644 index 18a593cbbd..0000000000 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/IRevitVersionConversionHelper.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace Speckle.Converters.RevitShared; - -public interface IRevitVersionConversionHelper -{ - bool IsCurveClosed(DB.NurbSpline nurbsSpline); -} diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/BeamConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/BeamConversionToSpeckle.cs index d6ee746e43..8c7d36aea1 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/BeamConversionToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/BeamConversionToSpeckle.cs @@ -1,29 +1,30 @@ -using Objects; +using Objects; using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; using Speckle.Converters.RevitShared.Helpers; using Speckle.Core.Models; +using Speckle.Revit.Interfaces; -namespace Speckle.Converters.RevitShared.ToSpeckle; +namespace Speckle.Converters.RevitShared; // POC: There is no validation on this converter to prevent conversion from "not a Revit Beam" to a Speckle Beam. // This will definitely explode if we tried. Goes back to the `CanConvert` functionality conversation. // As-is, what we are saying is that it can take "any Family Instance" and turn it into a Speckle.RevitBeam, which is far from correct. // CNX-9312 -public class BeamConversionToSpeckle : ITypedConverter +public class BeamConversionToSpeckle : ITypedConverter { - private readonly ITypedConverter _locationConverter; - private readonly ITypedConverter _levelConverter; - private readonly ParameterValueExtractor _parameterValueExtractor; - private readonly DisplayValueExtractor _displayValueExtractor; - private readonly ParameterObjectAssigner _parameterObjectAssigner; + private readonly ITypedConverter _locationConverter; + private readonly ITypedConverter _levelConverter; + private readonly IParameterValueExtractor _parameterValueExtractor; + private readonly IDisplayValueExtractor _displayValueExtractor; + private readonly IParameterObjectAssigner _parameterObjectAssigner; public BeamConversionToSpeckle( - ITypedConverter locationConverter, - ITypedConverter levelConverter, - ParameterValueExtractor parameterValueExtractor, - DisplayValueExtractor displayValueExtractor, - ParameterObjectAssigner parameterObjectAssigner + ITypedConverter locationConverter, + ITypedConverter levelConverter, + IParameterValueExtractor parameterValueExtractor, + IDisplayValueExtractor displayValueExtractor, + IParameterObjectAssigner parameterObjectAssigner ) { _locationConverter = locationConverter; @@ -33,7 +34,7 @@ ParameterObjectAssigner parameterObjectAssigner _parameterObjectAssigner = parameterObjectAssigner; } - public SOBR.RevitBeam Convert(DB.FamilyInstance target) + public SOBR.RevitBeam Convert(IRevitFamilyInstance target) { var baseGeometry = _locationConverter.Convert(target.Location); if (baseGeometry is not ICurve baseCurve) @@ -42,21 +43,22 @@ public SOBR.RevitBeam Convert(DB.FamilyInstance target) $"Beam location conversion did not yield an ICurve, instead it yielded an object of type {baseGeometry.GetType()}" ); } - var symbol = (DB.FamilySymbol)target.Document.GetElement(target.GetTypeId()); + + var symbol = target.Document.GetElement(target.GetTypeId()).NotNull().ToFamilySymbol().NotNull(); SOBR.RevitBeam speckleBeam = new() { family = symbol.FamilyName, - type = target.Document.GetElement(target.GetTypeId()).Name, + type = target.Document.GetElement(target.GetTypeId()).NotNull().Name, baseLine = baseCurve }; - var level = _parameterValueExtractor.GetValueAsDocumentObject( + var level = _parameterValueExtractor.GetValueAsRevitLevel( target, - DB.BuiltInParameter.INSTANCE_REFERENCE_LEVEL_PARAM + RevitBuiltInParameter.INSTANCE_REFERENCE_LEVEL_PARAM ); - speckleBeam.level = _levelConverter.Convert(level); + speckleBeam.level = _levelConverter.Convert(level.NotNull()); speckleBeam.displayValue = _displayValueExtractor.GetDisplayValue(target); diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/BoundarySegmentConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/BoundarySegmentConversionToSpeckle.cs index 8f02d4c345..793e03735e 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/BoundarySegmentConversionToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/BoundarySegmentConversionToSpeckle.cs @@ -1,18 +1,19 @@ using Objects; using Speckle.Converters.Common.Objects; +using Speckle.Revit.Interfaces; -namespace Speckle.Converters.RevitShared.ToSpeckle; +namespace Speckle.Converters.RevitShared; -public class BoundarySegmentConversionToSpeckle : ITypedConverter, SOG.Polycurve> +public class BoundarySegmentConversionToSpeckle : ITypedConverter, SOG.Polycurve> { - private readonly ITypedConverter _curveConverter; + private readonly ITypedConverter _curveConverter; - public BoundarySegmentConversionToSpeckle(ITypedConverter curveConverter) + public BoundarySegmentConversionToSpeckle(ITypedConverter curveConverter) { _curveConverter = curveConverter; } - public SOG.Polycurve Convert(IList target) + public SOG.Polycurve Convert(IList target) { if (target.Count == 0) { @@ -22,7 +23,7 @@ public SOG.Polycurve Convert(IList target) var poly = new SOG.Polycurve(); foreach (var segment in target) { - DB.Curve revitCurve = segment.GetCurve(); + IRevitCurve revitCurve = segment.GetCurve(); var curve = _curveConverter.Convert(revitCurve); // POC: We used to attach the `elementID` of every curve in a PolyCurve as a dynamic property. diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/BraceToSpeckleConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/BraceToSpeckleConverter.cs index ccae249fe5..bcee398c73 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/BraceToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/BraceToSpeckleConverter.cs @@ -1,24 +1,25 @@ -using Speckle.Converters.Common.Objects; +using Speckle.Converters.Common.Objects; using Speckle.Core.Models; +using Speckle.Revit.Interfaces; -namespace Speckle.Converters.RevitShared.ToSpeckle; +namespace Speckle.Converters.RevitShared; // POC: There is no validation on this converter to prevent conversion from "not a Revit Beam" to a Speckle Beam. // This will definitely explode if we tried. Goes back to the `CanConvert` functionality conversation. // As-is, what we are saying is that it can take "any Family Instance" and turn it into a Speckle.RevitBeam, which is far from correct. // CNX-9312 -public class BraceToSpeckleConverter : ITypedConverter +public class BraceToSpeckleConverter : ITypedConverter { - private readonly ITypedConverter _beamConverter; + private readonly ITypedConverter _beamConverter; - public BraceToSpeckleConverter(ITypedConverter beamConverter) + public BraceToSpeckleConverter(ITypedConverter beamConverter) { _beamConverter = beamConverter; } - public SOBR.RevitBrace Convert(DB.FamilyInstance target) + public SOBR.RevitBrace Convert(IRevitFamilyInstance target) { - // POC: we might want some easy one-liner here to FamilyMatchesOrThrow(target, DB.Structure.StructuralType.Brace) or similar + // POC: we might want some easy one-liner here to FamilyMatchesOrThrow(target, IRevitStructure.StructuralType.Brace) or similar // and added in each Convert // POC: this and the beam lost the notes we were returning, though this seems against even the original pattern diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ColumnConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ColumnConversionToSpeckle.cs index 3c5b738aa9..dc12c29082 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ColumnConversionToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ColumnConversionToSpeckle.cs @@ -1,31 +1,30 @@ -using Autodesk.Revit.DB; -using Objects; -using Objects.BuiltElements.Revit; +using Objects; using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; using Speckle.Converters.RevitShared.Helpers; using Speckle.Core.Models; +using Speckle.Revit.Interfaces; -namespace Speckle.Converters.RevitShared.ToSpeckle; +namespace Speckle.Converters.RevitShared; // POC: There is no validation on this converter to prevent conversion from "not a Revit Beam" to a Speckle Beam. // This will definitely explode if we tried. Goes back to the `CanConvert` functionality conversation. -public class ColumnConversionToSpeckle : ITypedConverter +public class ColumnConversionToSpeckle : ITypedConverter { - private readonly ITypedConverter _locationConverter; - private readonly ITypedConverter _levelConverter; - private readonly ParameterValueExtractor _parameterValueExtractor; - private readonly DisplayValueExtractor _displayValueExtractor; - private readonly IRevitConversionContextStack _contextStack; - private readonly ParameterObjectAssigner _parameterObjectAssigner; + private readonly ITypedConverter _locationConverter; + private readonly ITypedConverter _levelConverter; + private readonly IParameterValueExtractor _parameterValueExtractor; + private readonly IDisplayValueExtractor _displayValueExtractor; + private readonly IConversionContextStack _contextStack; + private readonly IParameterObjectAssigner _parameterObjectAssigner; public ColumnConversionToSpeckle( - ITypedConverter locationConverter, - ITypedConverter levelConverter, - ParameterValueExtractor parameterValueExtractor, - DisplayValueExtractor displayValueExtractor, - IRevitConversionContextStack contextStack, - ParameterObjectAssigner parameterObjectAssigner + ITypedConverter locationConverter, + ITypedConverter levelConverter, + IParameterValueExtractor parameterValueExtractor, + IDisplayValueExtractor displayValueExtractor, + IConversionContextStack contextStack, + IParameterObjectAssigner parameterObjectAssigner ) { _locationConverter = locationConverter; @@ -36,40 +35,35 @@ ParameterObjectAssigner parameterObjectAssigner _parameterObjectAssigner = parameterObjectAssigner; } - public RevitColumn Convert(DB.FamilyInstance target) + public SOBR.RevitColumn Convert(IRevitFamilyInstance target) { - FamilySymbol symbol = (FamilySymbol)target.Document.GetElement(target.GetTypeId()); + var symbol = target.Document.GetElement(target.GetTypeId()).NotNull().ToFamilySymbol().NotNull(); - RevitColumn speckleColumn = - new() { family = symbol.FamilyName, type = target.Document.GetElement(target.GetTypeId()).Name }; + SOBR.RevitColumn speckleColumn = + new() { family = symbol.FamilyName, type = target.Document.GetElement(target.GetTypeId()).NotNull().Name }; - Level level = _parameterValueExtractor.GetValueAsDocumentObject( - target, - BuiltInParameter.FAMILY_BASE_LEVEL_PARAM - ); - speckleColumn.level = _levelConverter.Convert(level); + var level = _parameterValueExtractor.GetValueAsRevitLevel(target, RevitBuiltInParameter.FAMILY_BASE_LEVEL_PARAM); + speckleColumn.level = _levelConverter.Convert(level.NotNull()); - Level topLevel = _parameterValueExtractor.GetValueAsDocumentObject( - target, - BuiltInParameter.FAMILY_TOP_LEVEL_PARAM - ); + var topLevel = _parameterValueExtractor.GetValueAsRevitLevel(target, RevitBuiltInParameter.FAMILY_TOP_LEVEL_PARAM); - speckleColumn.topLevel = _levelConverter.Convert(topLevel); + speckleColumn.topLevel = _levelConverter.Convert(topLevel.NotNull()); speckleColumn.baseOffset = _parameterValueExtractor.GetValueAsDouble( target, - DB.BuiltInParameter.FAMILY_BASE_LEVEL_OFFSET_PARAM + RevitBuiltInParameter.FAMILY_BASE_LEVEL_OFFSET_PARAM ); speckleColumn.topOffset = _parameterValueExtractor.GetValueAsDouble( target, - DB.BuiltInParameter.FAMILY_TOP_LEVEL_OFFSET_PARAM + RevitBuiltInParameter.FAMILY_TOP_LEVEL_OFFSET_PARAM ); speckleColumn.facingFlipped = target.FacingFlipped; speckleColumn.handFlipped = target.HandFlipped; speckleColumn.isSlanted = target.IsSlantedColumn; - if (target.Location is LocationPoint locationPoint) + var locationPoint = target.GetLocationAsLocationPoint(); + if (locationPoint is not null) { speckleColumn.rotation = locationPoint.Rotation; } @@ -85,7 +79,7 @@ public RevitColumn Convert(DB.FamilyInstance target) return speckleColumn; } - private ICurve? GetBaseCurve(DB.FamilyInstance target, double topLevelElevation, double topLevelOffset) + private ICurve? GetBaseCurve(IRevitFamilyInstance target, double topLevelElevation, double topLevelOffset) { Base baseGeometry = _locationConverter.Convert(target.Location); ICurve? baseCurve = baseGeometry as ICurve; diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/ArcToSpeckleConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/ArcToSpeckleConverter.cs index d6774a710b..a5830c9c45 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/ArcToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/ArcToSpeckleConverter.cs @@ -1,42 +1,46 @@ -using Objects.Primitive; +using Objects.Primitive; +using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; -using Speckle.Converters.RevitShared.Helpers; using Speckle.Converters.RevitShared.Services; +using Speckle.Revit.Interfaces; namespace Speckle.Converters.RevitShared.ToSpeckle; -public class ArcToSpeckleConverter : ITypedConverter +public class ArcToSpeckleConverter : ITypedConverter { - private readonly IRevitConversionContextStack _contextStack; - private readonly ITypedConverter _xyzToPointConverter; - private readonly ITypedConverter _planeConverter; - private readonly ScalingServiceToSpeckle _scalingService; + private readonly IConversionContextStack _contextStack; + private readonly ITypedConverter _xyzToPointConverter; + private readonly ITypedConverter _planeConverter; + private readonly IScalingServiceToSpeckle _scalingService; + private readonly IRevitPlaneUtils _revitPlaneUtils; public ArcToSpeckleConverter( - IRevitConversionContextStack contextStack, - ITypedConverter xyzToPointConverter, - ITypedConverter planeConverter, - ScalingServiceToSpeckle scalingService + IConversionContextStack contextStack, + ITypedConverter xyzToPointConverter, + ITypedConverter planeConverter, + IScalingServiceToSpeckle scalingService, + IRevitPlaneUtils revitPlaneUtils ) { _contextStack = contextStack; _xyzToPointConverter = xyzToPointConverter; _planeConverter = planeConverter; _scalingService = scalingService; + _revitPlaneUtils = revitPlaneUtils; } - public SOG.Arc Convert(DB.Arc target) + public SOG.Arc Convert(IRevitArc target) { // see https://forums.autodesk.com/t5/revit-api-forum/how-to-retrieve-startangle-and-endangle-of-arc-object/td-p/7637128 - var arcPlane = DB.Plane.CreateByOriginAndBasis(target.Center, target.XDirection, target.YDirection); - DB.XYZ center = target.Center; + var arcPlane = _revitPlaneUtils.CreateByOriginAndBasis(target.Center, target.XDirection, target.YDirection); + IRevitXYZ center = target.Center; - DB.XYZ dir0 = (target.GetEndPoint(0) - center).Normalize(); - DB.XYZ dir1 = (target.GetEndPoint(1) - center).Normalize(); + IRevitXYZ dir0 = (target.GetEndPoint(0).Subtract(center)).Normalize(); + IRevitXYZ dir1 = (target.GetEndPoint(1).Subtract(center)).Normalize(); - DB.XYZ start = target.Evaluate(0, true); - DB.XYZ end = target.Evaluate(1, true); - DB.XYZ mid = target.Evaluate(0.5, true); + IRevitXYZ start = target.Evaluate(0, true); + IRevitXYZ end = target.Evaluate(1, true); + IRevitXYZ mid = target.Evaluate(0.5, true); double startAngle = target.XDirection.AngleOnPlaneTo(dir0, target.Normal); double endAngle = target.XDirection.AngleOnPlaneTo(dir1, target.Normal); diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/BoundingBoxXYZToSpeckleConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/BoundingBoxXYZToSpeckleConverter.cs index a891579ad5..f91deee0cc 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/BoundingBoxXYZToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/BoundingBoxXYZToSpeckleConverter.cs @@ -1,27 +1,31 @@ -using Objects.Primitive; +using Objects.Primitive; +using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; -using Speckle.Converters.RevitShared.Helpers; +using Speckle.Revit.Interfaces; namespace Speckle.Converters.RevitShared.ToSpeckle; -public class BoundingBoxXYZToSpeckleConverter : ITypedConverter +public class BoundingBoxXYZToSpeckleConverter : ITypedConverter { - private readonly IRevitConversionContextStack _contextStack; - private readonly ITypedConverter _xyzToPointConverter; - private readonly ITypedConverter _planeConverter; + private readonly IConversionContextStack _contextStack; + private readonly ITypedConverter _xyzToPointConverter; + private readonly ITypedConverter _planeConverter; + private readonly IRevitPlaneUtils _revitPlaneUtils; public BoundingBoxXYZToSpeckleConverter( - IRevitConversionContextStack contextStack, - ITypedConverter xyzToPointConverter, - ITypedConverter planeConverter + IConversionContextStack contextStack, + ITypedConverter xyzToPointConverter, + ITypedConverter planeConverter, + IRevitPlaneUtils revitPlaneUtils ) { _contextStack = contextStack; _xyzToPointConverter = xyzToPointConverter; _planeConverter = planeConverter; + _revitPlaneUtils = revitPlaneUtils; } - public SOG.Box Convert(DB.BoundingBoxXYZ target) + public SOG.Box Convert(IRevitBoundingBoxXYZ target) { // convert min and max pts to speckle first var min = _xyzToPointConverter.Convert(target.Min); @@ -29,7 +33,7 @@ public SOG.Box Convert(DB.BoundingBoxXYZ target) // get the base plane of the bounding box from the transform var transform = target.Transform; - var plane = DB.Plane.CreateByOriginAndBasis( + var plane = _revitPlaneUtils.CreateByOriginAndBasis( transform.Origin, transform.BasisX.Normalize(), transform.BasisY.Normalize() diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/CircleToSpeckleConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/CircleToSpeckleConverter.cs index 7abdc08cfc..580c223c6b 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/CircleToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/CircleToSpeckleConverter.cs @@ -1,32 +1,36 @@ +using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; -using Speckle.Converters.RevitShared.Helpers; using Speckle.Converters.RevitShared.Services; +using Speckle.Revit.Interfaces; namespace Speckle.Converters.RevitShared.ToSpeckle; -public class CircleToSpeckleConverter : ITypedConverter +public class CircleToSpeckleConverter : ITypedConverter { - private readonly IRevitConversionContextStack _contextStack; - private readonly ITypedConverter _planeConverter; - private readonly ScalingServiceToSpeckle _scalingService; + private readonly IConversionContextStack _contextStack; + private readonly ITypedConverter _planeConverter; + private readonly IScalingServiceToSpeckle _scalingService; + private readonly IRevitPlaneUtils _revitPlaneUtils; public CircleToSpeckleConverter( - IRevitConversionContextStack contextStack, - ITypedConverter planeConverter, - ScalingServiceToSpeckle scalingService + IConversionContextStack contextStack, + ITypedConverter planeConverter, + IScalingServiceToSpeckle scalingService, + IRevitPlaneUtils revitPlaneUtils ) { _contextStack = contextStack; _planeConverter = planeConverter; _scalingService = scalingService; + _revitPlaneUtils = revitPlaneUtils; } - public SOG.Circle Convert(DB.Arc target) + public SOG.Circle Convert(IRevitArc target) { // POC: should we check for arc of 360 and throw? Original CircleToSpeckle did not do this. // see https://forums.autodesk.com/t5/revit-api-forum/how-to-retrieve-startangle-and-endangle-of-arc-object/td-p/7637128 - var arcPlane = DB.Plane.CreateByNormalAndOrigin(target.Normal, target.Center); + var arcPlane = _revitPlaneUtils.CreateByNormalAndOrigin(target.Normal, target.Center); var c = new SOG.Circle() { plane = _planeConverter.Convert(arcPlane), diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/CurveArrArrayToSpecklePolycurveConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/CurveArrArrayToSpecklePolycurveConverter.cs index 4644bc1435..d393d310c6 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/CurveArrArrayToSpecklePolycurveConverter.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/CurveArrArrayToSpecklePolycurveConverter.cs @@ -1,34 +1,25 @@ -using Autodesk.Revit.DB; -using Objects.Geometry; -using Speckle.Converters.Common.Objects; +using Speckle.Converters.Common.Objects; +using Speckle.Revit.Interfaces; -namespace Speckle.Converters.RevitShared.Raw; +namespace Speckle.Converters.RevitShared.ToSpeckle; -internal sealed class CurveArrArrayToSpecklePolycurveConverter : ITypedConverter> +public sealed class CurveArrArrayToSpecklePolycurveConverter : ITypedConverter> { - private readonly ITypedConverter _curveArrayConverter; + private readonly ITypedConverter _curveArrayConverter; - public CurveArrArrayToSpecklePolycurveConverter(ITypedConverter curveArrayConverter) + public CurveArrArrayToSpecklePolycurveConverter(ITypedConverter curveArrayConverter) { _curveArrayConverter = curveArrayConverter; } - public List Convert(CurveArrArray target) + public List Convert(IRevitCurveArrArray target) { - List polycurves = new(); - foreach (var curveArray in GetCurveArrays(target)) + List polycurves = new(target.Count); + foreach (var curveArray in target) { polycurves.Add(_curveArrayConverter.Convert(curveArray)); } return polycurves; } - - private IEnumerable GetCurveArrays(DB.CurveArrArray curveArrArray) - { - for (var i = 0; i < curveArrArray.Size; i++) - { - yield return curveArrArray.get_Item(i); - } - } } diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/CurveArrayConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/CurveArrayConversionToSpeckle.cs index 8ec80fe9f7..afa6ad4830 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/CurveArrayConversionToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/CurveArrayConversionToSpeckle.cs @@ -1,22 +1,21 @@ -using Autodesk.Revit.DB; -using Objects; -using Objects.Geometry; +using Objects; +using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; -using Speckle.Converters.RevitShared.Helpers; using Speckle.Converters.RevitShared.Services; +using Speckle.Revit.Interfaces; namespace Speckle.Converters.RevitShared.ToSpeckle; -public sealed class CurveArrayConversionToSpeckle : ITypedConverter +public sealed class CurveArrayConversionToSpeckle : ITypedConverter { - private readonly IRevitConversionContextStack _contextStack; - private readonly ScalingServiceToSpeckle _scalingService; - private readonly ITypedConverter _curveConverter; + private readonly IConversionContextStack _contextStack; + private readonly IScalingServiceToSpeckle _scalingService; + private readonly ITypedConverter _curveConverter; public CurveArrayConversionToSpeckle( - IRevitConversionContextStack contextStack, - ScalingServiceToSpeckle scalingService, - ITypedConverter curveConverter + IConversionContextStack contextStack, + IScalingServiceToSpeckle scalingService, + ITypedConverter curveConverter ) { _contextStack = contextStack; @@ -24,15 +23,14 @@ public CurveArrayConversionToSpeckle( _curveConverter = curveConverter; } - public Polycurve Convert(CurveArray target) + public SOG.Polycurve Convert(IRevitCurveArray target) { - List curves = target.Cast().ToList(); + List curves = target.Cast().ToList(); - return new Polycurve() + return new SOG.Polycurve() { units = _contextStack.Current.SpeckleUnits, - closed = - curves.First().GetEndPoint(0).DistanceTo(curves.Last().GetEndPoint(1)) < RevitConversionContextStack.TOLERANCE, + closed = curves.First().GetEndPoint(0).DistanceTo(curves.Last().GetEndPoint(1)) < RevitConstants.TOLERANCE, length = _scalingService.ScaleLength(curves.Sum(x => x.Length)), segments = curves.Select(x => _curveConverter.Convert(x)).ToList() }; diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/CurveConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/CurveConversionToSpeckle.cs index 0b034a779c..e165964a28 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/CurveConversionToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/CurveConversionToSpeckle.cs @@ -1,25 +1,26 @@ -using Objects; -using Speckle.Converters.Common.Objects; +using Objects; using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; +using Speckle.Revit.Interfaces; namespace Speckle.Converters.RevitShared.ToSpeckle; -public class CurveConversionToSpeckle : ITypedConverter +public class CurveConversionToSpeckle : ITypedConverter { - private readonly ITypedConverter _lineConverter; - private readonly ITypedConverter _arcConverter; - private readonly ITypedConverter _circleConverter; - private readonly ITypedConverter _ellipseConverter; - private readonly ITypedConverter _nurbsConverter; - private readonly ITypedConverter _hermiteConverter; // POC: should this be ICurve? + private readonly ITypedConverter _lineConverter; + private readonly ITypedConverter _arcConverter; + private readonly ITypedConverter _circleConverter; + private readonly ITypedConverter _ellipseConverter; + private readonly ITypedConverter _nurbsConverter; + private readonly ITypedConverter _hermiteConverter; // POC: should this be ICurve? public CurveConversionToSpeckle( - ITypedConverter lineConverter, - ITypedConverter arcConverter, - ITypedConverter circleConverter, - ITypedConverter ellipseConverter, - ITypedConverter nurbsConverter, - ITypedConverter hermiteConverter + ITypedConverter lineConverter, + ITypedConverter arcConverter, + ITypedConverter circleConverter, + ITypedConverter ellipseConverter, + ITypedConverter nurbsConverter, + ITypedConverter hermiteConverter ) { _lineConverter = lineConverter; @@ -30,18 +31,34 @@ public CurveConversionToSpeckle( _hermiteConverter = hermiteConverter; } - public ICurve Convert(DB.Curve target) + public ICurve Convert(IRevitCurve target) { - return target switch + var line = target.ToLine(); + if (line is not null) + { + return _lineConverter.Convert(line); + } + var arc = target.ToArc(); + if (arc is not null) + { + return arc.IsClosed ? _circleConverter.Convert(arc) : _arcConverter.Convert(arc); + } + var ellipse = target.ToEllipse(); + if (ellipse is not null) + { + return _ellipseConverter.Convert(ellipse); + } + var nurbs = target.ToNurbSpline(); + if (nurbs is not null) + { + return _nurbsConverter.Convert(nurbs); + } + var hermite = target.ToHermiteSpline(); + if (hermite is not null) { - DB.Line line => _lineConverter.Convert(line), - // POC: are maybe arc.IsCyclic ? - DB.Arc arc => arc.IsClosed ? _circleConverter.Convert(arc) : _arcConverter.Convert(arc), - DB.Ellipse ellipse => _ellipseConverter.Convert(ellipse), - DB.NurbSpline nurbs => _nurbsConverter.Convert(nurbs), - DB.HermiteSpline hermite => _hermiteConverter.Convert(hermite), + return _hermiteConverter.Convert(hermite); + } - _ => throw new SpeckleConversionException($"Unsupported curve type {target.GetType()}") - }; + throw new SpeckleConversionException($"Unsupported curve type {target.GetType()}"); } } diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/EllipseToSpeckleConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/EllipseToSpeckleConverter.cs index 96ca62f8f1..7f920e5954 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/EllipseToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/EllipseToSpeckleConverter.cs @@ -1,30 +1,40 @@ -using Objects.Primitive; +using Objects.Primitive; +using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; -using Speckle.Converters.RevitShared.Helpers; using Speckle.Converters.RevitShared.Services; +using Speckle.Revit.Interfaces; namespace Speckle.Converters.RevitShared.ToSpeckle; -public class EllipseToSpeckleConverter : ITypedConverter +public class EllipseToSpeckleConverter : ITypedConverter { - private readonly IRevitConversionContextStack _contextStack; - private readonly ITypedConverter _planeConverter; - private readonly ScalingServiceToSpeckle _scalingService; + private readonly IConversionContextStack _contextStack; + private readonly ITypedConverter _planeConverter; + private readonly IScalingServiceToSpeckle _scalingService; + private readonly IRevitPlaneUtils _revitPlaneUtils; public EllipseToSpeckleConverter( - IRevitConversionContextStack contextStack, - ITypedConverter planeConverter, - ScalingServiceToSpeckle scalingService + IConversionContextStack contextStack, + ITypedConverter planeConverter, + IScalingServiceToSpeckle scalingService, + IRevitPlaneUtils revitPlaneUtils ) { _contextStack = contextStack; _planeConverter = planeConverter; _scalingService = scalingService; + _revitPlaneUtils = revitPlaneUtils; } - public SOG.Ellipse Convert(DB.Ellipse target) + public SOG.Ellipse Convert(IRevitEllipse target) { - using (DB.Plane basePlane = DB.Plane.CreateByOriginAndBasis(target.Center, target.XDirection, target.YDirection)) + using ( + IRevitPlane basePlane = _revitPlaneUtils.CreateByOriginAndBasis( + target.Center, + target.XDirection, + target.YDirection + ) + ) { var trim = target.IsBound ? new Interval(target.GetEndParameter(0), target.GetEndParameter(1)) : null; diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/HermiteSplineToSpeckleConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/HermiteSplineToSpeckleConverter.cs index 5aa2a07ed2..1c364da849 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/HermiteSplineToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/HermiteSplineToSpeckleConverter.cs @@ -1,19 +1,25 @@ -using Speckle.Converters.Common.Objects; +using Speckle.Converters.Common.Objects; +using Speckle.Revit.Interfaces; namespace Speckle.Converters.RevitShared.ToSpeckle; -public class HerminteSplitToSpeckleConverter : ITypedConverter +public class HermiteSplineToSpeckleConverter : ITypedConverter { - private readonly ITypedConverter _splineConverter; + private readonly ITypedConverter _splineConverter; + private readonly IRevitNurbSplineUtils _revitNurbSplineUtils; - public HerminteSplitToSpeckleConverter(ITypedConverter splineConverter) + public HermiteSplineToSpeckleConverter( + ITypedConverter splineConverter, + IRevitNurbSplineUtils revitNurbSplineUtils + ) { _splineConverter = splineConverter; + _revitNurbSplineUtils = revitNurbSplineUtils; } - public SOG.Curve Convert(DB.HermiteSpline target) + public SOG.Curve Convert(IRevitHermiteSpline target) { - var nurbs = DB.NurbSpline.Create(target); + var nurbs = _revitNurbSplineUtils.Create(target); return _splineConverter.Convert(nurbs); } } diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/LineConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/LineConversionToSpeckle.cs index 2405cf0b22..ceddef39b0 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/LineConversionToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/LineConversionToSpeckle.cs @@ -1,20 +1,21 @@ -using Objects.Primitive; +using Objects.Primitive; +using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; -using Speckle.Converters.RevitShared.Helpers; using Speckle.Converters.RevitShared.Services; +using Speckle.Revit.Interfaces; namespace Speckle.Converters.RevitShared.ToSpeckle; -public class LineConversionToSpeckle : ITypedConverter +public class LineConversionToSpeckle : ITypedConverter { - private readonly IRevitConversionContextStack _contextStack; - private readonly ITypedConverter _xyzToPointConverter; - private readonly ScalingServiceToSpeckle _scalingService; + private readonly IConversionContextStack _contextStack; + private readonly ITypedConverter _xyzToPointConverter; + private readonly IScalingServiceToSpeckle _scalingService; public LineConversionToSpeckle( - IRevitConversionContextStack contextStack, - ITypedConverter xyzToPointConverter, - ScalingServiceToSpeckle scalingService + IConversionContextStack contextStack, + ITypedConverter xyzToPointConverter, + IScalingServiceToSpeckle scalingService ) { _contextStack = contextStack; @@ -22,7 +23,7 @@ ScalingServiceToSpeckle scalingService _scalingService = scalingService; } - public SOG.Line Convert(DB.Line target) => + public SOG.Line Convert(IRevitLine target) => new() { units = _contextStack.Current.SpeckleUnits, diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/MeshByMaterialDictionaryToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/MeshByMaterialDictionaryToSpeckle.cs index 29b0bd9f98..22d806277a 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/MeshByMaterialDictionaryToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/MeshByMaterialDictionaryToSpeckle.cs @@ -1,20 +1,21 @@ using Objects.Other; +using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; -using Speckle.Converters.RevitShared.Helpers; +using Speckle.Revit.Interfaces; namespace Speckle.Converters.RevitShared.ToSpeckle; public class MeshByMaterialDictionaryToSpeckle - : ITypedConverter>, List> + : ITypedConverter>, List> { - private readonly IRevitConversionContextStack _contextStack; - private readonly ITypedConverter _xyzToPointConverter; - private readonly ITypedConverter _materialConverter; + private readonly IConversionContextStack _contextStack; + private readonly ITypedConverter _xyzToPointConverter; + private readonly ITypedConverter _materialConverter; public MeshByMaterialDictionaryToSpeckle( - ITypedConverter materialConverter, - IRevitConversionContextStack contextStack, - ITypedConverter xyzToPointConverter + ITypedConverter materialConverter, + IConversionContextStack contextStack, + ITypedConverter xyzToPointConverter ) { _materialConverter = materialConverter; @@ -25,24 +26,24 @@ public MeshByMaterialDictionaryToSpeckle( /// /// Converts a dictionary of Revit meshes, where key is MaterialId, into a list of Speckle meshes. /// - /// A dictionary with DB.ElementId keys and List of DB.Mesh values. + /// A dictionary with IRevitElementId keys and List of IRevitMesh values. /// /// Returns a list of objects where each mesh represents one unique material in the input dictionary. /// /// /// Be aware that this method internally creates a new instance of for each unique material in the input dictionary. /// These meshes are created with an initial capacity based on the size of the vertex and face arrays to avoid unnecessary resizing. - /// Also note that, for each unique material, the method tries to retrieve the related DB.Material from the current document and convert it. If the conversion is successful, + /// Also note that, for each unique material, the method tries to retrieve the related IRevitMaterial from the current document and convert it. If the conversion is successful, /// the material is added to the corresponding Speckle mesh. If the conversion fails, the operation simply continues without the material. /// - public List Convert(Dictionary> target) + public List Convert(Dictionary> target) { var result = new List(target.Keys.Count); foreach (var meshData in target) { - DB.ElementId materialId = meshData.Key; - List meshes = meshData.Value; + IRevitElementId materialId = meshData.Key; + List meshes = meshData.Value; // We compute the final size of the arrays to prevent unnecessary resizing. (int verticesSize, int facesSize) = GetVertexAndFaceListSize(meshes); @@ -55,7 +56,7 @@ public MeshByMaterialDictionaryToSpeckle( ); var doc = _contextStack.Current.Document; - if (doc.GetElement(materialId) is DB.Material material) + if (doc.GetElement(materialId) is IRevitMaterial material) { speckleMesh["renderMaterial"] = _materialConverter.Convert(material); } @@ -72,7 +73,7 @@ public MeshByMaterialDictionaryToSpeckle( return result; } - private void AppendToSpeckleMesh(DB.Mesh mesh, SOG.Mesh speckleMesh) + private void AppendToSpeckleMesh(IRevitMesh mesh, SOG.Mesh speckleMesh) { int faceIndexOffset = speckleMesh.vertices.Count / 3; @@ -86,16 +87,16 @@ private void AppendToSpeckleMesh(DB.Mesh mesh, SOG.Mesh speckleMesh) for (int i = 0; i < mesh.NumTriangles; i++) { - var triangle = mesh.get_Triangle(i); + var triangle = mesh.GetTriangle(i); speckleMesh.faces.Add(3); // TRIANGLE flag - speckleMesh.faces.Add((int)triangle.get_Index(0) + faceIndexOffset); - speckleMesh.faces.Add((int)triangle.get_Index(1) + faceIndexOffset); - speckleMesh.faces.Add((int)triangle.get_Index(2) + faceIndexOffset); + speckleMesh.faces.Add((int)triangle.GetIndex(0) + faceIndexOffset); + speckleMesh.faces.Add((int)triangle.GetIndex(1) + faceIndexOffset); + speckleMesh.faces.Add((int)triangle.GetIndex(2) + faceIndexOffset); } } - private static (int vertexCount, int) GetVertexAndFaceListSize(List meshes) + private static (int vertexCount, int) GetVertexAndFaceListSize(List meshes) { int numberOfVertices = 0; int numberOfFaces = 0; diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/MeshConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/MeshConversionToSpeckle.cs index 2f6c494ba0..093d553cf2 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/MeshConversionToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/MeshConversionToSpeckle.cs @@ -1,19 +1,20 @@ using Objects.Other; +using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; -using Speckle.Converters.RevitShared.Helpers; +using Speckle.Revit.Interfaces; namespace Speckle.Converters.RevitShared.ToSpeckle; -public class MeshConversionToSpeckle : ITypedConverter +public class MeshConversionToSpeckle : ITypedConverter { - private readonly ITypedConverter _xyzToPointConverter; - private readonly ITypedConverter _materialConverter; - private readonly IRevitConversionContextStack _contextStack; + private readonly ITypedConverter _xyzToPointConverter; + private readonly ITypedConverter _materialConverter; + private readonly IConversionContextStack _contextStack; public MeshConversionToSpeckle( - IRevitConversionContextStack contextStack, - ITypedConverter xyzToPointConverter, - ITypedConverter materialConverter + IConversionContextStack contextStack, + ITypedConverter xyzToPointConverter, + ITypedConverter materialConverter ) { _contextStack = contextStack; @@ -21,15 +22,17 @@ public MeshConversionToSpeckle( _materialConverter = materialConverter; } - public SOG.Mesh Convert(DB.Mesh target) + public SOG.Mesh Convert(IRevitMesh target) { var doc = _contextStack.Current.Document; List vertices = GetSpeckleMeshVertexData(target); List faces = GetSpeckleMeshFaceData(target); + var element = doc.GetElement(target.MaterialElementId); + var revitMaterial = element?.ToMaterial(); RenderMaterial? speckleMaterial = null; - if (doc.GetElement(target.MaterialElementId) is DB.Material revitMaterial) + if (revitMaterial is not null) { speckleMaterial = _materialConverter.Convert(revitMaterial); } @@ -40,7 +43,7 @@ public SOG.Mesh Convert(DB.Mesh target) }; } - private List GetSpeckleMeshVertexData(DB.Mesh target) + private List GetSpeckleMeshVertexData(IRevitMesh target) { var vertices = new List(target.Vertices.Count * 3); @@ -52,12 +55,12 @@ private List GetSpeckleMeshVertexData(DB.Mesh target) return vertices; } - private List GetSpeckleMeshFaceData(DB.Mesh target) + private List GetSpeckleMeshFaceData(IRevitMesh target) { var faces = new List(target.NumTriangles * 4); for (int i = 0; i < target.NumTriangles; i++) { - var triangle = target.get_Triangle(i); + var triangle = target.GetTriangle(i); faces.AddRange(GetMeshTriangleData(triangle)); } @@ -73,12 +76,12 @@ private List GetSpeckleMeshFaceData(DB.Mesh target) /// Output format is a 4 item list with format [3, v1, v2, v3]; where the first item is the triangle flag (for speckle) /// and the 3 following numbers are the indices of each vertex in the vertex list. /// - private IReadOnlyList GetMeshTriangleData(DB.MeshTriangle triangle) => + private IReadOnlyList GetMeshTriangleData(IRevitMeshTriangle triangle) => new[] { 3, // The TRIANGLE flag in speckle - (int)triangle.get_Index(0), - (int)triangle.get_Index(1), - (int)triangle.get_Index(2) + (int)triangle.GetIndex(0), + (int)triangle.GetIndex(1), + (int)triangle.GetIndex(2) }; } diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/NurbsSplineToSpeckleConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/NurbsSplineToSpeckleConverter.cs index 7229f639e3..c646f9e6b4 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/NurbsSplineToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/NurbsSplineToSpeckleConverter.cs @@ -1,22 +1,23 @@ -using Objects.Primitive; +using Objects.Primitive; +using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; -using Speckle.Converters.RevitShared.Helpers; using Speckle.Converters.RevitShared.Services; +using Speckle.Revit.Interfaces; namespace Speckle.Converters.RevitShared.ToSpeckle; -public class NurbsSplineToSpeckleConverter : ITypedConverter +public class NurbsSplineToSpeckleConverter : ITypedConverter { private readonly IRevitVersionConversionHelper _conversionHelper; - private readonly IRevitConversionContextStack _contextStack; - private readonly ITypedConverter _xyzToPointConverter; - private readonly ScalingServiceToSpeckle _scalingService; + private readonly IConversionContextStack _contextStack; + private readonly ITypedConverter _xyzToPointConverter; + private readonly IScalingServiceToSpeckle _scalingService; public NurbsSplineToSpeckleConverter( IRevitVersionConversionHelper conversionHelper, - IRevitConversionContextStack contextStack, - ITypedConverter xyzToPointConverter, - ScalingServiceToSpeckle scalingService + IConversionContextStack contextStack, + ITypedConverter xyzToPointConverter, + IScalingServiceToSpeckle scalingService ) { _conversionHelper = conversionHelper; @@ -25,7 +26,7 @@ ScalingServiceToSpeckle scalingService _scalingService = scalingService; } - public SOG.Curve Convert(DB.NurbSpline target) + public SOG.Curve Convert(IRevitNurbSpline target) { var units = _contextStack.Current.SpeckleUnits; @@ -40,12 +41,12 @@ public SOG.Curve Convert(DB.NurbSpline target) return new SOG.Curve() { - weights = target.Weights.Cast().ToList(), + weights = target.Weights.ToList(), points = points, - knots = target.Knots.Cast().ToList(), + knots = target.Knots.ToList(), degree = target.Degree, //speckleCurve.periodic = revitCurve.Period; // POC: already commented out, remove? - rational = target.isRational, + rational = target.IsRational, closed = _conversionHelper.IsCurveClosed(target), units = units, domain = new Interval(target.GetEndParameter(0), target.GetEndParameter(1)), diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/PlaneToSpeckleConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/PlaneToSpeckleConverter.cs index 27cef7bab6..56f098ceda 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/PlaneToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/PlaneToSpeckleConverter.cs @@ -1,18 +1,19 @@ +using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; -using Speckle.Converters.RevitShared.Helpers; +using Speckle.Revit.Interfaces; namespace Speckle.Converters.RevitShared.ToSpeckle; -public class PlaneToSpeckleConverter : ITypedConverter +public class PlaneToSpeckleConverter : ITypedConverter { - private readonly IRevitConversionContextStack _contextStack; - private readonly ITypedConverter _xyzToPointConverter; - private readonly ITypedConverter _xyzToVectorConverter; + private readonly IConversionContextStack _contextStack; + private readonly ITypedConverter _xyzToPointConverter; + private readonly ITypedConverter _xyzToVectorConverter; public PlaneToSpeckleConverter( - IRevitConversionContextStack contextStack, - ITypedConverter xyzToPointConverter, - ITypedConverter xyzToVectorConverter + IConversionContextStack contextStack, + ITypedConverter xyzToPointConverter, + ITypedConverter xyzToVectorConverter ) { _contextStack = contextStack; @@ -20,7 +21,7 @@ public PlaneToSpeckleConverter( _xyzToVectorConverter = xyzToVectorConverter; } - public SOG.Plane Convert(DB.Plane target) + public SOG.Plane Convert(IRevitPlane target) { var origin = _xyzToPointConverter.Convert(target.Origin); var normal = _xyzToVectorConverter.Convert(target.Normal); diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/PointCloudToSpeckleConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/PointCloudToSpeckleConverter.cs index ab86301cd2..ee5b81e95d 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/PointCloudToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/PointCloudToSpeckleConverter.cs @@ -1,39 +1,52 @@ +using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; -using Speckle.Converters.RevitShared.Helpers; +using Speckle.Revit.Interfaces; namespace Speckle.Converters.RevitShared.ToSpeckle; -public class PointCloudToSpeckleConverter : ITypedConverter +public class PointCloudToSpeckleConverter : ITypedConverter { - private readonly IRevitConversionContextStack _contextStack; - private readonly ITypedConverter _xyzToPointConverter; - private readonly ITypedConverter _boundingBoxConverter; + private readonly IConversionContextStack _contextStack; + private readonly ITypedConverter _xyzToPointConverter; + private readonly ITypedConverter _boundingBoxConverter; + private readonly IRevitPlaneUtils _revitPlaneUtils; + private readonly IRevitXYZUtils _revitxyzUtils; + private readonly IRevitFilterFactory _revitFilterFactory; public PointCloudToSpeckleConverter( - IRevitConversionContextStack contextStack, - ITypedConverter xyzToPointConverter, - ITypedConverter boundingBoxConverter + IConversionContextStack contextStack, + ITypedConverter xyzToPointConverter, + ITypedConverter boundingBoxConverter, + IRevitPlaneUtils revitPlaneUtils, + IRevitXYZUtils revitxyzUtils, + IRevitFilterFactory revitFilterFactory ) { _contextStack = contextStack; _xyzToPointConverter = xyzToPointConverter; _boundingBoxConverter = boundingBoxConverter; + _revitPlaneUtils = revitPlaneUtils; + _revitxyzUtils = revitxyzUtils; + _revitFilterFactory = revitFilterFactory; } - public SOG.Pointcloud Convert(DB.PointCloudInstance target) + public SOG.Pointcloud Convert(IRevitPointCloudInstance target) { - var boundingBox = target.get_BoundingBox(null); - using DB.Transform transform = target.GetTransform(); + var boundingBox = target.GetBoundingBox(); + using IRevitTransform transform = target.GetTransform(); { - var minPlane = DB.Plane.CreateByNormalAndOrigin(DB.XYZ.BasisZ, transform.OfPoint(boundingBox.Min)); - var filter = DB.PointClouds.PointCloudFilterFactory.CreateMultiPlaneFilter(new List() { minPlane }); + var minPlane = _revitPlaneUtils.CreateByNormalAndOrigin( + _revitxyzUtils.BasisZ, + transform.OfPoint(boundingBox.Min) + ); + var filter = _revitFilterFactory.CreateMultiPlaneFilter(minPlane); var points = target.GetPoints(filter, 0.0001, 999999); // max limit is 1 mil but 1000000 throws error // POC: complaining about nullability var specklePointCloud = new SOG.Pointcloud { points = points - .Select(o => _xyzToPointConverter.Convert(transform.OfPoint(o))) + .Select(o => _xyzToPointConverter.Convert(transform.OfPoint(o.ToXYZ()))) .SelectMany(o => new List() { o.x, o.y, o.z }) .ToList(), colors = points.Select(o => o.Color).ToList(), diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/PointConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/PointConversionToSpeckle.cs index 8f6ca703db..4da12eafca 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/PointConversionToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/PointConversionToSpeckle.cs @@ -1,15 +1,16 @@ -using Speckle.Converters.Common.Objects; +using Speckle.Converters.Common.Objects; +using Speckle.Revit.Interfaces; namespace Speckle.Converters.RevitShared.ToSpeckle; -public class PointConversionToSpeckle : ITypedConverter +public class PointConversionToSpeckle : ITypedConverter { - private readonly ITypedConverter _xyzToPointConverter; + private readonly ITypedConverter _xyzToPointConverter; - public PointConversionToSpeckle(ITypedConverter xyzToPointConverter) + public PointConversionToSpeckle(ITypedConverter xyzToPointConverter) { _xyzToPointConverter = xyzToPointConverter; } - public SOG.Point Convert(DB.Point target) => _xyzToPointConverter.Convert(target.Coord); + public SOG.Point Convert(IRevitPoint target) => _xyzToPointConverter.Convert(target.Coord); } diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/PolylineToSpeckleConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/PolylineToSpeckleConverter.cs index 5efb22e278..e64b28309b 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/PolylineToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/PolylineToSpeckleConverter.cs @@ -1,23 +1,24 @@ +using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; -using Speckle.Converters.RevitShared.Helpers; +using Speckle.Revit.Interfaces; namespace Speckle.Converters.RevitShared.ToSpeckle; -public class PolylineToSpeckleConverter : ITypedConverter +public class PolylineToSpeckleConverter : ITypedConverter { - private readonly IRevitConversionContextStack _contextStack; - private readonly ITypedConverter _xyzToPointConverter; + private readonly IConversionContextStack _contextStack; + private readonly ITypedConverter _xyzToPointConverter; public PolylineToSpeckleConverter( - IRevitConversionContextStack contextStack, - ITypedConverter xyzToPointConverter + IConversionContextStack contextStack, + ITypedConverter xyzToPointConverter ) { _contextStack = contextStack; _xyzToPointConverter = xyzToPointConverter; } - public SOG.Polyline Convert(DB.PolyLine target) + public SOG.Polyline Convert(IRevitPolyLine target) { var coords = target.GetCoordinates().SelectMany(coord => _xyzToPointConverter.Convert(coord).ToList()).ToList(); return new SOG.Polyline(coords, _contextStack.Current.SpeckleUnits); diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/SolidConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/SolidConversionToSpeckle.cs index e848d3a843..039c706869 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/SolidConversionToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/SolidConversionToSpeckle.cs @@ -1,53 +1,53 @@ -using Speckle.Converters.Common.Objects; -using Speckle.Converters.RevitShared.Helpers; +using Speckle.Converters.Common.Objects; +using Speckle.Revit.Interfaces; namespace Speckle.Converters.RevitShared.ToSpeckle; /// /// Solid conversion is a one->many. For each material used in the solid, a mesh will be returned to reduce the amount of instances created. /// -public class SolidConversionToSpeckle : IRawConversion> +public class SolidConversionToSpeckle : ITypedConverter> { - private readonly RevitConversionContextStack _contextStack; - private readonly IRawConversion>, List> _meshByMaterialConverter; + private readonly ITypedConverter< + Dictionary>, + List + > _meshByMaterialConverter; public SolidConversionToSpeckle( - RevitConversionContextStack contextStack, - IRawConversion>, List> meshByMaterialConverter + ITypedConverter>, List> meshByMaterialConverter ) { - _contextStack = contextStack; _meshByMaterialConverter = meshByMaterialConverter; } /// - /// Converts the input object into a list of . + /// Converts the input object into a list of . /// - /// The input object to be converted. + /// The input object to be converted. /// - /// A list of objects that represent the input object. Each mesh in the list corresponds to a different material in the original solid. + /// A list of objects that represent the input object. Each mesh in the list corresponds to a different material in the original solid. /// /// /// This conversion process first triangulates the input solid by material, and then converts the result to raw meshes individually. /// Be aware that this operation might be computationally intensive for complex solids, due to the need for triangulation. /// - public List RawConvert(DB.Solid target) + public List Convert(IRevitSolid target) { var meshesByMaterial = GetTriangulatedMeshesFromSolidByMaterial(target); - return _meshByMaterialConverter.RawConvert(meshesByMaterial); + return _meshByMaterialConverter.Convert(meshesByMaterial); } - private Dictionary> GetTriangulatedMeshesFromSolidByMaterial(DB.Solid solid) + private Dictionary> GetTriangulatedMeshesFromSolidByMaterial(IRevitSolid solid) { - var result = new Dictionary>(); - foreach (DB.Face face in solid.Faces) + var result = new Dictionary>(); + foreach (IRevitFace face in solid.Faces) { - if (!result.ContainsKey(face.MaterialElementId)) + if (!result.TryGetValue(face.MaterialElementId, out var mat)) { - result[face.MaterialElementId] = new List(); + mat = new List(); + result[face.MaterialElementId] = mat; } - - result[face.MaterialElementId].Add(face.Triangulate()); + mat.Add(face.Triangulate()); } return result; diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/VectorToSpeckleConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/VectorToSpeckleConverter.cs index e97cf962f4..ad04f5d8db 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/VectorToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/VectorToSpeckleConverter.cs @@ -1,27 +1,28 @@ -using Speckle.Converters.Common.Objects; +using Speckle.Converters.Common.Objects; using Speckle.Converters.RevitShared.Services; +using Speckle.Revit.Interfaces; namespace Speckle.Converters.RevitShared.ToSpeckle; -public class VectorToSpeckleConverter : ITypedConverter +public class VectorToSpeckleConverter : ITypedConverter { private readonly IReferencePointConverter _referencePointConverter; - private readonly ScalingServiceToSpeckle _scalingService; + private readonly IScalingServiceToSpeckle _scalingService; public VectorToSpeckleConverter( IReferencePointConverter referencePointConverter, - ScalingServiceToSpeckle scalingService + IScalingServiceToSpeckle scalingService ) { _referencePointConverter = referencePointConverter; _scalingService = scalingService; } - public SOG.Vector Convert(DB.XYZ target) + public SOG.Vector Convert(IRevitXYZ target) { // POC: originally had a concept of not transforming, but this was // optional arg defaulting to false - removing the argument appeared to break nothing - DB.XYZ extPt = _referencePointConverter.ConvertToExternalCoordindates(target, false); + var extPt = _referencePointConverter.ConvertToExternalCoordindates(target, false); var pointToSpeckle = new SOG.Vector( _scalingService.ScaleLength(extPt.X), _scalingService.ScaleLength(extPt.Y), diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/XyzConversionToPoint.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/XyzConversionToPoint.cs index bf250d06c3..4f5996e1e5 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/XyzConversionToPoint.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/XyzConversionToPoint.cs @@ -1,24 +1,26 @@ +using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; -using Speckle.Converters.RevitShared.Helpers; using Speckle.Converters.RevitShared.Services; +using Speckle.Revit.Interfaces; +#pragma warning disable IDE0130 namespace Speckle.Converters.RevitShared.ToSpeckle; -public class XyzConversionToPoint : ITypedConverter +public class XyzConversionToPoint : ITypedConverter { - private readonly ScalingServiceToSpeckle _toSpeckleScalingService; - private readonly IRevitConversionContextStack _contextStack; + private readonly IScalingServiceToSpeckle _toSpeckleScalingService; + private readonly IConversionContextStack _contextStack; public XyzConversionToPoint( - ScalingServiceToSpeckle toSpeckleScalingService, - IRevitConversionContextStack contextStack + IScalingServiceToSpeckle toSpeckleScalingService, + IConversionContextStack contextStack ) { _toSpeckleScalingService = toSpeckleScalingService; _contextStack = contextStack; } - public SOG.Point Convert(DB.XYZ target) + public SOG.Point Convert(IRevitXYZ target) { var pointToSpeckle = new SOG.Point( _toSpeckleScalingService.ScaleLength(target.X), diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/LevelConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/LevelConversionToSpeckle.cs index 33e1d7fea2..bea059ceaa 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/LevelConversionToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/LevelConversionToSpeckle.cs @@ -1,18 +1,19 @@ -using Speckle.Converters.Common.Objects; +using Speckle.Converters.Common.Objects; using Speckle.Converters.RevitShared.Services; +using Speckle.Revit.Interfaces; -namespace Speckle.Converters.RevitShared.ToSpeckle; +namespace Speckle.Converters.RevitShared; -public class LevelConversionToSpeckle : ITypedConverter +public class LevelConversionToSpeckle : ITypedConverter { - private readonly ScalingServiceToSpeckle _scalingService; + private readonly IScalingServiceToSpeckle _scalingService; - public LevelConversionToSpeckle(ScalingServiceToSpeckle scalingService) + public LevelConversionToSpeckle(IScalingServiceToSpeckle scalingService) { _scalingService = scalingService; } - public SOBR.RevitLevel Convert(DB.Level target) + public SOBR.RevitLevel Convert(IRevitLevel target) { SOBR.RevitLevel level = new() diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/LocationConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/LocationConversionToSpeckle.cs index 29d3378103..ffba569ce6 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/LocationConversionToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/LocationConversionToSpeckle.cs @@ -1,34 +1,43 @@ -using Objects; -using Speckle.Converters.Common.Objects; +using Objects; using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; using Speckle.Core.Models; +using Speckle.Revit.Interfaces; -namespace Speckle.Converters.RevitShared.ToSpeckle; +#pragma warning disable IDE0130 +namespace Speckle.Converters.RevitShared; -public class LocationConversionToSpeckle : ITypedConverter +#pragma warning restore IDE0130 + +public class LocationConversionToSpeckle : ITypedConverter { - private readonly ITypedConverter _curveConverter; - private readonly ITypedConverter _xyzConverter; + private readonly ITypedConverter _curveConverter; + private readonly ITypedConverter _xyzConverter; // POC: review IRawConversion which always returns a Base, this is ToSpeckle, so... this breaks // the meaning of IRawConversion, it could be IToSpeckleRawConversion // also a factory type public LocationConversionToSpeckle( - ITypedConverter curveConverter, - ITypedConverter xyzConverter + ITypedConverter curveConverter, + ITypedConverter xyzConverter ) { _curveConverter = curveConverter; _xyzConverter = xyzConverter; } - public Base Convert(DB.Location target) + public Base Convert(IRevitLocation target) { - return target switch + var curve = target.ToLocationCurve(); + if (curve is not null) + { + return (_curveConverter.Convert(curve.Curve) as Base).NotNull(); // POC: ICurve and Base are not related but we know they must be, had to soft cast and then !. + } + var point = target.ToLocationPoint(); + if (point is not null) { - DB.LocationCurve curve => (_curveConverter.Convert(curve.Curve) as Base)!, // POC: ICurve and Base are not related but we know they must be, had to soft cast and then !. - DB.LocationPoint point => _xyzConverter.Convert(point.Point), - _ => throw new SpeckleConversionException($"Unexpected location type {target.GetType()}") - }; + _xyzConverter.Convert(point.Point); + } + throw new SpeckleConversionException($"Unexpected location type {target.GetType()}"); } } diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/MaterialConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/MaterialConversionToSpeckle.cs index f7f48974f7..50062f88fd 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/MaterialConversionToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/MaterialConversionToSpeckle.cs @@ -1,11 +1,12 @@ using Objects.Other; using Speckle.Converters.Common.Objects; +using Speckle.Revit.Interfaces; -namespace Speckle.Converters.RevitShared.ToSpeckle; +namespace Speckle.Converters.RevitShared; -public class MaterialConversionToSpeckle : ITypedConverter +public class MaterialConversionToSpeckle : ITypedConverter { - public RenderMaterial Convert(DB.Material target) => + public RenderMaterial Convert(IRevitMaterial target) => // POC: not sure we should be pulling in System.Drawing - // maybe this isn't a problem as it's part of the netstandard Fwk // ideally we'd have serialiser of our own colour class, i.e. to serialise to an uint diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ModelCurveArrArrayConverterToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ModelCurveArrArrayConverterToSpeckle.cs new file mode 100644 index 0000000000..111e12a42b --- /dev/null +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ModelCurveArrArrayConverterToSpeckle.cs @@ -0,0 +1,30 @@ +using Objects.Geometry; +using Speckle.Converters.Common.Objects; +using Speckle.Revit.Interfaces; +#pragma warning disable IDE0130 +namespace Speckle.Converters.RevitShared; + +internal sealed class ModelCurveArrArrayConverterToSpeckle : ITypedConverter +{ + private readonly ITypedConverter _modelCurveArrayConverter; + + public ModelCurveArrArrayConverterToSpeckle( + ITypedConverter modelCurveArrayConverter + ) + { + _modelCurveArrayConverter = modelCurveArrayConverter; + } + + public Objects.Geometry.Polycurve[] Convert(IRevitModelCurveArrArray target) + { + var polycurves = new Objects.Geometry.Polycurve[target.Count]; + var revitArrays = target.ToArray(); + + for (int i = 0; i < polycurves.Length; i++) + { + polycurves[i] = _modelCurveArrayConverter.Convert(revitArrays[i]); + } + + return polycurves; + } +} diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ModelCurveArrArrayToSpeckleConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ModelCurveArrArrayToSpeckleConverter.cs deleted file mode 100644 index d294360b2d..0000000000 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ModelCurveArrArrayToSpeckleConverter.cs +++ /dev/null @@ -1,28 +0,0 @@ -using Autodesk.Revit.DB; -using Objects.Geometry; -using Speckle.Converters.Common.Objects; - -namespace Speckle.Converters.RevitShared.Raw; - -internal sealed class ModelCurveArrArrayConverterToSpeckle : ITypedConverter -{ - private readonly ITypedConverter _modelCurveArrayConverter; - - public ModelCurveArrArrayConverterToSpeckle(ITypedConverter modelCurveArrayConverter) - { - _modelCurveArrayConverter = modelCurveArrayConverter; - } - - public SOG.Polycurve[] Convert(ModelCurveArrArray target) - { - var polycurves = new Polycurve[target.Size]; - var revitArrays = target.Cast().ToArray(); - - for (int i = 0; i < polycurves.Length; i++) - { - polycurves[i] = _modelCurveArrayConverter.Convert(revitArrays[i]); - } - - return polycurves; - } -} diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ModelCurveArrayToSpeckleConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ModelCurveArrayToSpeckleConverter.cs index 5bfd4d11bb..ce1690ee5d 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ModelCurveArrayToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ModelCurveArrayToSpeckleConverter.cs @@ -1,21 +1,21 @@ -using Objects; +using Objects; using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; -using Speckle.Converters.RevitShared.Helpers; using Speckle.Converters.RevitShared.Services; +using Speckle.Revit.Interfaces; +#pragma warning disable IDE0130 +namespace Speckle.Converters.RevitShared; -namespace Speckle.Converters.RevitShared.Raw; - -internal sealed class ModelCurveArrayToSpeckleConverter : ITypedConverter +public sealed class ModelCurveArrayToSpeckleConverter : ITypedConverter { - private readonly IRevitConversionContextStack _contextStack; - private readonly ScalingServiceToSpeckle _scalingService; - private readonly ITypedConverter _curveConverter; + private readonly IConversionContextStack _contextStack; + private readonly IScalingServiceToSpeckle _scalingService; + private readonly ITypedConverter _curveConverter; public ModelCurveArrayToSpeckleConverter( - IRevitConversionContextStack contextStack, - ScalingServiceToSpeckle scalingService, - ITypedConverter curveConverter + IConversionContextStack contextStack, + IScalingServiceToSpeckle scalingService, + ITypedConverter curveConverter ) { _contextStack = contextStack; @@ -23,10 +23,12 @@ public ModelCurveArrayToSpeckleConverter( _curveConverter = curveConverter; } - public SOG.Polycurve Convert(DB.ModelCurveArray target) + public SOG.Polycurve Convert(IRevitModelCurveArray target) => Convert((IReadOnlyList)target); + + public SOG.Polycurve Convert(IReadOnlyList target) { SOG.Polycurve polycurve = new(); - var curves = target.Cast().Select(mc => mc.GeometryCurve).ToArray(); + var curves = target.Select(mc => mc.GeometryCurve).ToArray(); if (curves.Length == 0) { @@ -36,7 +38,7 @@ public SOG.Polycurve Convert(DB.ModelCurveArray target) var start = curves[0].GetEndPoint(0); var end = curves[^1].GetEndPoint(1); polycurve.units = _contextStack.Current.SpeckleUnits; - polycurve.closed = start.DistanceTo(end) < RevitConversionContextStack.TOLERANCE; + polycurve.closed = start.DistanceTo(end) < RevitConstants.TOLERANCE; polycurve.length = _scalingService.ScaleLength(curves.Sum(x => x.Length)); polycurve.segments.AddRange(curves.Select(x => _curveConverter.Convert(x))); diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ParameterConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ParameterConversionToSpeckle.cs index a0b1f01da5..ae2a9ec5c5 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ParameterConversionToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ParameterConversionToSpeckle.cs @@ -1,30 +1,35 @@ -using Autodesk.Revit.DB; -using Speckle.Converters.Common.Objects; +using Speckle.Converters.Common.Objects; using Speckle.Converters.RevitShared.Extensions; using Speckle.Converters.RevitShared.Helpers; +using Speckle.Revit.Interfaces; -namespace Speckle.Converters.RevitShared.ToSpeckle; +namespace Speckle.Converters.RevitShared; -public class ParameterConversionToSpeckle : ITypedConverter +public class ParameterConversionToSpeckle : ITypedConverter { - private readonly ParameterValueExtractor _valueExtractor; + private readonly IParameterValueExtractor _valueExtractor; + private readonly IRevitFormatOptionsUtils _revitFormatOptionsUtils; - public ParameterConversionToSpeckle(ParameterValueExtractor valueExtractor) + public ParameterConversionToSpeckle( + IParameterValueExtractor valueExtractor, + IRevitFormatOptionsUtils revitFormatOptionsUtils + ) { _valueExtractor = valueExtractor; + _revitFormatOptionsUtils = revitFormatOptionsUtils; } - public SOBR.Parameter Convert(Parameter target) + public SOBR.Parameter Convert(IRevitParameter target) { string internalName = target.GetInternalName(); - ForgeTypeId? unitTypeId = null; - if (target.StorageType is StorageType.Double) + IRevitForgeTypeId? unitTypeId = null; + if (target.StorageType is RevitStorageType.Double) { // according to the api documentation, this method will throw if the storage type is not a VALUE type // however, I've found that it will still throw if StorageType == StorageType.Integer unitTypeId = target.GetUnitTypeId(); } - Definition definition = target.Definition; + IRevitDefinition definition = target.Definition; return new SOBR.Parameter() { @@ -33,7 +38,7 @@ public SOBR.Parameter Convert(Parameter target) isShared = target.IsShared, isReadOnly = target.IsReadOnly, name = definition.Name, - units = unitTypeId?.GetSymbol() ?? "None", + units = unitTypeId?.GetSymbol(_revitFormatOptionsUtils) ?? "None", value = _valueExtractor.GetValue(target) }; } diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/RevitVersionConversionHelper.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/RevitVersionConversionHelper.cs new file mode 100644 index 0000000000..7ebcaf9d95 --- /dev/null +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/RevitVersionConversionHelper.cs @@ -0,0 +1,23 @@ +using System.Diagnostics.CodeAnalysis; +using Speckle.InterfaceGenerator; +using Speckle.Revit.Interfaces; + +namespace Speckle.Converters.RevitShared; + +[GenerateAutoInterface] +public class RevitVersionConversionHelper : IRevitVersionConversionHelper +{ + [SuppressMessage("Design", "CA1031:Do not catch general exception types")] + public bool IsCurveClosed(IRevitNurbSpline nurbsSpline) + { + try + { + return nurbsSpline.IsClosed; + } + catch (Exception) + { + // POC: is this actually a good assumption? + return true; + } + } +} diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/RevitConstants.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/RevitConstants.cs new file mode 100644 index 0000000000..79a6ef167a --- /dev/null +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/RevitConstants.cs @@ -0,0 +1,6 @@ +namespace Speckle.Converters.RevitShared; + +public static class RevitConstants +{ + public const double TOLERANCE = 0.0164042; // 5mm in ft +} diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/RevitConversionSettings.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/RevitConversionSettings.cs deleted file mode 100644 index 3fb4466120..0000000000 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/RevitConversionSettings.cs +++ /dev/null @@ -1,19 +0,0 @@ -namespace Speckle.Converters.RevitShared; - -// POC: probably NOT the right place, probably needs passing in with the send/rcv operation -// not clear how this should get configured or if we should have it, the shape probably needs to change -// this was dragged in because it (or something like it) is required for reference point conversion. -// have made it a strongly typed thing encapsulating a dictionary so as not to rely on injecting a weak type. -// relates to https://spockle.atlassian.net/browse/CNX-9357 -public class RevitConversionSettings -{ - private Dictionary Settings { get; } = new Dictionary(); - - public bool TryGetSettingString(string key, out string value) => Settings.TryGetValue(key, out value); - - public string this[string key] - { - get => Settings[key]; - set => Settings[key] = value; - } -} diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/RevitRootToHostConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/RevitRootToHostConverter.cs deleted file mode 100644 index 78790ee19e..0000000000 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/RevitRootToHostConverter.cs +++ /dev/null @@ -1,50 +0,0 @@ -using Speckle.Converters.Common; -using Speckle.Converters.Common.Objects; -using Speckle.Core.Models; -using Speckle.Converters.RevitShared.Helpers; - -namespace Speckle.Converters.RevitShared; - -// POC: maybe possible to restrict the access so this cannot be created directly? -public class RevitRootToHostConverter : IRootToSpeckleConverter -{ - private readonly IConverterResolver _toSpeckle; - private readonly ParameterValueExtractor _parameterValueExtractor; - - public RevitRootToHostConverter( - IConverterResolver toSpeckle, - ParameterValueExtractor parameterValueExtractor - ) - { - _toSpeckle = toSpeckle; - _parameterValueExtractor = parameterValueExtractor; - } - - // POC: our assumption here is target is valid for conversion - // if it cannot be converted then we should throw - public Base Convert(object target) - { - var objectConverter = _toSpeckle.GetConversionForType(target.GetType()); - - if (objectConverter == null) - { - throw new SpeckleConversionException($"No conversion found for {target.GetType().Name}"); - } - - Base result = - objectConverter.Convert(target) - ?? throw new SpeckleConversionException($"Conversion of object with type {target.GetType()} returned null"); - - // POC : where should logic common to most objects go? - // shouldn't target ALWAYS be DB.Element? - if (target is DB.Element element) - { - // POC: is this the right place? - result.applicationId = element.UniqueId; - - _parameterValueExtractor.RemoveUniqueId(element.UniqueId); - } - - return result; - } -} diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ReferencePointConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Services/ReferencePointConverter.cs similarity index 50% rename from DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ReferencePointConverter.cs rename to DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Services/ReferencePointConverter.cs index 901c5c5572..da8c985834 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ReferencePointConverter.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Services/ReferencePointConverter.cs @@ -1,12 +1,25 @@ using System.Diagnostics.CodeAnalysis; -using Speckle.Converters.RevitShared.Helpers; +using Speckle.Converters.Common; +using Speckle.InterfaceGenerator; +using Speckle.Revit.Interfaces; namespace Speckle.Converters.RevitShared; -// POC: this could perhaps becomes some RevitDocumentService but also... -// This reference point feature needs review. We could do with knowing whether this feature is widely used. -// there's also some bogus disposal happening -// https://spockle.atlassian.net/browse/CNX-9357 +[GenerateAutoInterface] +public class RevitConversionSettings : IRevitConversionSettings +{ + private Dictionary Settings { get; } = new(); + + public bool TryGetSettingString(string key, out string value) => Settings.TryGetValue(key, out value); + + public string this[string key] + { + get => Settings[key]; + set => Settings[key] = value; + } +} + +[GenerateAutoInterface] public class ReferencePointConverter : IReferencePointConverter { // POC: probably not the best place for this @@ -14,21 +27,36 @@ public class ReferencePointConverter : IReferencePointConverter private const string REFPOINT_PROJECT_BASE = "Project Base"; private const string REFPOINT_SURVEY = "Survey"; - private readonly RevitConversionSettings _revitSettings; - private readonly IRevitConversionContextStack _contextStack; - - private readonly Dictionary _docTransforms = new(); - - public ReferencePointConverter(IRevitConversionContextStack contextStack, RevitConversionSettings revitSettings) + private readonly IRevitConversionSettings _revitSettings; + private readonly IConversionContextStack _contextStack; + private readonly IRevitTransformUtils _transformUtils; + private readonly IRevitFilterFactory _revitFilterFactory; + private readonly IRevitXYZUtils _revitXyzUtils; + private readonly IProxyMap _proxyMap; + + private readonly Dictionary _docTransforms = new(); + + public ReferencePointConverter( + IConversionContextStack contextStack, + IRevitConversionSettings revitSettings, + IRevitFilterFactory revitFilterFactory, + IRevitTransformUtils transformUtils, + IRevitXYZUtils revitXyzUtils, + IProxyMap proxyMap + ) { _contextStack = contextStack; _revitSettings = revitSettings; + _revitFilterFactory = revitFilterFactory; + _transformUtils = transformUtils; + _revitXyzUtils = revitXyzUtils; + _proxyMap = proxyMap; } // POC: the original allowed for the document to be passed in // if required, we would probably need to push the stack with a new document if the // doc can change during the lifeycycle of the conversions. This may need some looking into - public DB.XYZ ConvertToExternalCoordindates(DB.XYZ inbound, bool isPoint) + public IRevitXYZ ConvertToExternalCoordindates(IRevitXYZ inbound, bool isPoint) { var rpt = GetDocReferencePointTransform(_contextStack.Current.Document); return isPoint ? rpt.OfPoint(inbound) : rpt.OfVector(inbound); @@ -36,13 +64,13 @@ public DB.XYZ ConvertToExternalCoordindates(DB.XYZ inbound, bool isPoint) // POC: this might be better in some RevitDocumentService // we could probably return that instance instead of the Doc from the context, maybe... - public DB.Transform GetDocReferencePointTransform(DB.Document doc) + public IRevitTransform GetDocReferencePointTransform(IRevitDocument doc) { //linked files are always saved to disc and will have a path name //if the current doc is unsaved it will not, but then it'll be the only one :) var id = doc.PathName; - if (!_docTransforms.TryGetValue(id, out DB.Transform? transform)) + if (!_docTransforms.TryGetValue(id, out IRevitTransform? transform)) { // get from settings var referencePointSetting = _revitSettings.TryGetSettingString("reference-point", out string value) @@ -56,25 +84,25 @@ public DB.Transform GetDocReferencePointTransform(DB.Document doc) } [SuppressMessage("Reliability", "CA2000:Dispose objects before losing scope")] - public DB.Transform GetReferencePointTransform(string referencePointSetting) + public IRevitTransform GetReferencePointTransform(string referencePointSetting) { // first get the main doc base points and reference setting transform - var referencePointTransform = DB.Transform.Identity; + var referencePointTransform = _transformUtils.Identity; // POC: bogus disposal below - var points = new DB.FilteredElementCollector(_contextStack.Current.Document) - .OfClass(typeof(DB.BasePoint)) - .Cast() + var points = _revitFilterFactory + .CreateFilteredElementCollector(_contextStack.Current.Document) + .OfClass(_proxyMap) .ToList(); - var projectPoint = points.FirstOrDefault(o => o.IsShared == false); - var surveyPoint = points.FirstOrDefault(o => o.IsShared); + var projectPoint = NotNullExtensions.NotNull(points.FirstOrDefault(o => o.IsShared == false), "No projectPoint"); + var surveyPoint = NotNullExtensions.NotNull(points.FirstOrDefault(o => o.IsShared), "No surveyPoint"); // POC: it's not clear what support is needed for this switch (referencePointSetting) { case REFPOINT_PROJECT_BASE: // note that the project base (ui) rotation is registered on the survey pt, not on the base point - referencePointTransform = DB.Transform.CreateTranslation(projectPoint.Position); + referencePointTransform = _transformUtils.CreateTranslation(projectPoint.Position); break; case REFPOINT_SURVEY: @@ -82,12 +110,12 @@ public DB.Transform GetReferencePointTransform(string referencePointSetting) // retrieve the survey point rotation from the project point // POC: should a null angle resolve to 0? - var angle = projectPoint.get_Parameter(DB.BuiltInParameter.BASEPOINT_ANGLETON_PARAM)?.AsDouble() ?? 0; + var angle = projectPoint.GetParameter(RevitBuiltInParameter.BASEPOINT_ANGLETON_PARAM)?.AsDouble() ?? 0; // POC: following disposed incorrectly or early or maybe a false negative? - referencePointTransform = DB.Transform + referencePointTransform = _transformUtils .CreateTranslation(surveyPoint.Position) - .Multiply(DB.Transform.CreateRotation(DB.XYZ.BasisZ, angle)); + .Multiply(_transformUtils.CreateRotation(_revitXyzUtils.BasisZ, angle)); break; diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Services/RevitToSpeckleUnitConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Services/RevitToSpeckleUnitConverter.cs index e1d7a7a62b..e6de0840fa 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Services/RevitToSpeckleUnitConverter.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Services/RevitToSpeckleUnitConverter.cs @@ -1,29 +1,30 @@ using Speckle.Converters.Common; using Speckle.Core.Kits; using Speckle.Core.Logging; +using Speckle.Revit.Interfaces; namespace Speckle.Converters.RevitShared.Services; -public sealed class RevitToSpeckleUnitConverter : IHostToSpeckleUnitConverter +public sealed class RevitToSpeckleUnitConverter : IHostToSpeckleUnitConverter { - private readonly Dictionary _unitMapping = new(); + private readonly Dictionary _unitMapping = new(); - public RevitToSpeckleUnitConverter() + public RevitToSpeckleUnitConverter(IRevitUnitUtils revitUnitUtils) { - _unitMapping[DB.UnitTypeId.Millimeters] = Units.Millimeters; - _unitMapping[DB.UnitTypeId.Centimeters] = Units.Centimeters; - _unitMapping[DB.UnitTypeId.Meters] = Units.Meters; - _unitMapping[DB.UnitTypeId.MetersCentimeters] = Units.Meters; - _unitMapping[DB.UnitTypeId.Inches] = Units.Inches; - _unitMapping[DB.UnitTypeId.FractionalInches] = Units.Inches; - _unitMapping[DB.UnitTypeId.Feet] = Units.Feet; - _unitMapping[DB.UnitTypeId.FeetFractionalInches] = Units.Feet; + _unitMapping[revitUnitUtils.Millimeters.TypeId] = Units.Millimeters; + _unitMapping[revitUnitUtils.Centimeters.TypeId] = Units.Centimeters; + _unitMapping[revitUnitUtils.Meters.TypeId] = Units.Meters; + _unitMapping[revitUnitUtils.MetersCentimeters.TypeId] = Units.Meters; + _unitMapping[revitUnitUtils.Inches.TypeId] = Units.Inches; + _unitMapping[revitUnitUtils.FractionalInches.TypeId] = Units.Inches; + _unitMapping[revitUnitUtils.Feet.TypeId] = Units.Feet; + _unitMapping[revitUnitUtils.FeetFractionalInches.TypeId] = Units.Feet; } // POC: maybe just convert, it's not a Try method - public string ConvertOrThrow(DB.ForgeTypeId hostUnit) + public string ConvertOrThrow(IRevitForgeTypeId hostUnit) { - if (_unitMapping.TryGetValue(hostUnit, out string value)) + if (_unitMapping.TryGetValue(hostUnit.TypeId, out string value)) { return value; } diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Services/ScalingServiceToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Services/ScalingServiceToSpeckle.cs index a0c2779048..57ba7be5f2 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Services/ScalingServiceToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Services/ScalingServiceToSpeckle.cs @@ -1,20 +1,27 @@ -using Autodesk.Revit.DB; -using Speckle.Converters.RevitShared.Helpers; +using Speckle.Converters.Common; +using Speckle.InterfaceGenerator; +using Speckle.Revit.Interfaces; namespace Speckle.Converters.RevitShared.Services; // POC: feels like this is a context thing and we should be calculating this occasionally? // needs some thought as to how it could be be done, could leave as is for now -public sealed class ScalingServiceToSpeckle +[GenerateAutoInterface] +public sealed class ScalingServiceToSpeckle : IScalingServiceToSpeckle { private readonly double _defaultLengthConversionFactor; + private readonly IRevitUnitUtils _revitUnitUtils; // POC: this seems like the reverse relationship - public ScalingServiceToSpeckle(IRevitConversionContextStack contextStack) + public ScalingServiceToSpeckle( + IConversionContextStack contextStack, + IRevitUnitUtils revitUnitUtils + ) { + _revitUnitUtils = revitUnitUtils; // POC: this is accurate for the current context stack - Units documentUnits = contextStack.Current.Document.GetUnits(); - FormatOptions formatOptions = documentUnits.GetFormatOptions(SpecTypeId.Length); + var documentUnits = contextStack.Current.Document.GetUnits(); + var formatOptions = documentUnits.GetFormatOptions(_revitUnitUtils.Length); var lengthUnitsTypeId = formatOptions.GetUnitTypeId(); _defaultLengthConversionFactor = ScaleStatic(1, lengthUnitsTypeId); } @@ -26,14 +33,14 @@ public ScalingServiceToSpeckle(IRevitConversionContextStack contextStack) public double ScaleLength(double length) => length * _defaultLengthConversionFactor; // POC: not sure about this??? - public double Scale(double value, ForgeTypeId forgeTypeId) + public double Scale(double value, IRevitForgeTypeId forgeTypeId) { return ScaleStatic(value, forgeTypeId); } // POC: not sure why this is needed??? - private static double ScaleStatic(double value, ForgeTypeId forgeTypeId) + private double ScaleStatic(double value, IRevitForgeTypeId forgeTypeId) { - return UnitUtils.ConvertFromInternalUnits(value, forgeTypeId); + return _revitUnitUtils.ConvertFromInternalUnits(value, forgeTypeId); } } diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Speckle.Converters.RevitShared.projitems b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Speckle.Converters.RevitShared.projitems index 5e5d29480e..575c0093e6 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Speckle.Converters.RevitShared.projitems +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Speckle.Converters.RevitShared.projitems @@ -9,72 +9,6 @@ Speckle.Converters.RevitShared - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + \ No newline at end of file diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/BaseTopLevelConverterToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/BaseTopLevelConverterToSpeckle.cs index f7a94c8d1f..0a246e3b2f 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/BaseTopLevelConverterToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/BaseTopLevelConverterToSpeckle.cs @@ -1,4 +1,4 @@ -using Speckle.Converters.Common; +using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; using Speckle.Core.Models; diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/CeilingTopLevelConverterToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/CeilingTopLevelConverterToSpeckle.cs index c3de2636aa..b757b03215 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/CeilingTopLevelConverterToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/CeilingTopLevelConverterToSpeckle.cs @@ -1,30 +1,31 @@ -using Autodesk.Revit.DB; -using Objects; +using Objects; using Objects.BuiltElements.Revit; using Objects.Geometry; using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; using Speckle.Converters.RevitShared.Helpers; +using Speckle.Revit.Interfaces; namespace Speckle.Converters.RevitShared.ToSpeckle; -[NameAndRankValue(nameof(DB.Ceiling), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -internal sealed class CeilingTopLevelConverterToSpeckle : BaseTopLevelConverterToSpeckle +[NameAndRankValue(nameof(IRevitCeiling), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +internal sealed class CeilingTopLevelConverterToSpeckle + : BaseTopLevelConverterToSpeckle { - private readonly ITypedConverter> _curveArrArrayConverter; - private readonly ITypedConverter _levelConverter; - private readonly ParameterValueExtractor _parameterValueExtractor; - private readonly ParameterObjectAssigner _parameterObjectAssigner; - private readonly DisplayValueExtractor _displayValueExtractor; + private readonly ITypedConverter> _curveArrArrayConverter; + private readonly ITypedConverter _levelConverter; + private readonly IParameterValueExtractor _parameterValueExtractor; + private readonly IParameterObjectAssigner _parameterObjectAssigner; + private readonly IDisplayValueExtractor _displayValueExtractor; //private readonly HostedElementConversionToSpeckle _hostedElementConverter; public CeilingTopLevelConverterToSpeckle( - ITypedConverter> curveArrArrayConverter, - ITypedConverter levelConverter, - ParameterValueExtractor parameterValueExtractor, - ParameterObjectAssigner parameterObjectAssigner, - DisplayValueExtractor displayValueExtractor + ITypedConverter> curveArrArrayConverter, + ITypedConverter levelConverter, + IParameterValueExtractor parameterValueExtractor, + IParameterObjectAssigner parameterObjectAssigner, + IDisplayValueExtractor displayValueExtractor ) { _curveArrArrayConverter = curveArrArrayConverter; @@ -34,14 +35,14 @@ DisplayValueExtractor displayValueExtractor _displayValueExtractor = displayValueExtractor; } - public override RevitCeiling Convert(DB.Ceiling target) + public override RevitCeiling Convert(IRevitCeiling target) { - var sketch = (Sketch)target.Document.GetElement(target.SketchId); + var sketch = target.Document.GetElement(target.SketchId).NotNull().ToSketch().NotNull(); List profiles = _curveArrArrayConverter.Convert(sketch.Profile); var speckleCeiling = new RevitCeiling(); - var elementType = (ElementType)target.Document.GetElement(target.GetTypeId()); + var elementType = target.Document.GetElement(target.GetTypeId()).NotNull().ToType().NotNull(); speckleCeiling.type = elementType.Name; speckleCeiling.family = elementType.FamilyName; @@ -58,8 +59,8 @@ public override RevitCeiling Convert(DB.Ceiling target) // POC: our existing receive operation is checking the "slopeDirection" prop, // but it is never being set. We should be setting it - var level = _parameterValueExtractor.GetValueAsDocumentObject(target, DB.BuiltInParameter.LEVEL_PARAM); - speckleCeiling.level = _levelConverter.Convert(level); + var level = _parameterValueExtractor.GetValueAsRevitLevel(target, RevitBuiltInParameter.LEVEL_PARAM); + speckleCeiling.level = _levelConverter.Convert(level.NotNull()); _parameterObjectAssigner.AssignParametersToBase(target, speckleCeiling); speckleCeiling.displayValue = _displayValueExtractor.GetDisplayValue(target); diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/DirectShapeTopLevelConverterToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/DirectShapeTopLevelConverterToSpeckle.cs index c9c9ca5e14..1f87f63696 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/DirectShapeTopLevelConverterToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/DirectShapeTopLevelConverterToSpeckle.cs @@ -1,22 +1,22 @@ using Speckle.Converters.Common; using Speckle.Converters.RevitShared.Extensions; using Speckle.Converters.RevitShared.Helpers; -using Speckle.Converters.RevitShared.ToSpeckle; using Speckle.Core.Models; +using Speckle.Revit.Interfaces; -namespace Speckle.Converters.Revit2023.ToSpeckle; +namespace Speckle.Converters.RevitShared.ToSpeckle; -[NameAndRankValue(nameof(DB.DirectShape), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class DirectShapeTopLevelConverterToSpeckle : BaseTopLevelConverterToSpeckle +[NameAndRankValue(nameof(IRevitDirectShape), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +public class DirectShapeTopLevelConverterToSpeckle : BaseTopLevelConverterToSpeckle { - private readonly IRevitConversionContextStack _contextStack; - private readonly ParameterObjectAssigner _parameterObjectAssigner; - private readonly DisplayValueExtractor _displayValueExtractor; + private readonly IConversionContextStack _contextStack; + private readonly IParameterObjectAssigner _parameterObjectAssigner; + private readonly IDisplayValueExtractor _displayValueExtractor; public DirectShapeTopLevelConverterToSpeckle( - ParameterObjectAssigner parameterObjectAssigner, - IRevitConversionContextStack contextStack, - DisplayValueExtractor displayValueExtractor + IParameterObjectAssigner parameterObjectAssigner, + IConversionContextStack contextStack, + IDisplayValueExtractor displayValueExtractor ) { _parameterObjectAssigner = parameterObjectAssigner; @@ -24,7 +24,7 @@ DisplayValueExtractor displayValueExtractor _displayValueExtractor = displayValueExtractor; } - public override SOBR.DirectShape Convert(DB.DirectShape target) + public override SOBR.DirectShape Convert(IRevitDirectShape target) { var category = target.Category.GetBuiltInCategory().GetSchemaBuilderCategoryFromBuiltIn(); diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/ElementTopLevelConverterToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/ElementTopLevelConverterToSpeckle.cs index c3b96c9001..cbd1cd9e06 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/ElementTopLevelConverterToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/ElementTopLevelConverterToSpeckle.cs @@ -1,25 +1,27 @@ -using Speckle.Converters.Common; -using Objects.BuiltElements.Revit; +using Speckle.Converters.Common; using Speckle.Converters.RevitShared.Helpers; +using Speckle.Revit.Interfaces; namespace Speckle.Converters.RevitShared.ToSpeckle; // POC: not currently used? clearly some missing pieces -[NameAndRankValue(nameof(DB.Element), 0)] -public class ElementTopLevelConverterToSpeckle : BaseTopLevelConverterToSpeckle +[NameAndRankValue(nameof(IRevitElement), 0)] +public class ElementTopLevelConverterToSpeckle : BaseTopLevelConverterToSpeckle { - private readonly DisplayValueExtractor _displayValueExtractor; + private readonly IDisplayValueExtractor _displayValueExtractor; - public ElementTopLevelConverterToSpeckle(DisplayValueExtractor displayValueExtractor) + public ElementTopLevelConverterToSpeckle(IDisplayValueExtractor displayValueExtractor) { _displayValueExtractor = displayValueExtractor; } - public override RevitElement Convert(DB.Element target) + public override SOBR.RevitElement Convert(IRevitElement target) { - RevitElement speckleElement = new(); + SOBR.RevitElement speckleElement = new(); - if (target.Document.GetElement(target.GetTypeId()) is DB.FamilySymbol symbol) + var element = target.Document.GetElement(target.GetTypeId()); + var symbol = element?.ToFamilySymbol(); + if (symbol is not null) { speckleElement.family = symbol.FamilyName; speckleElement.type = symbol.Name; diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/ExtrusionRoofToSpeckleTopLevelConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/ExtrusionRoofToSpeckleTopLevelConverter.cs index d46c93794f..b02390e933 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/ExtrusionRoofToSpeckleTopLevelConverter.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/ExtrusionRoofToSpeckleTopLevelConverter.cs @@ -1,32 +1,34 @@ -using Objects.BuiltElements.Revit.RevitRoof; -using Speckle.Converters.Common.Objects; +using Objects.BuiltElements.Revit.RevitRoof; using Speckle.Converters.Common; -using Speckle.Converters.RevitShared.Helpers; - +using Speckle.Converters.Common.Objects; using Speckle.Converters.RevitShared.Extensions; +using Speckle.Converters.RevitShared.Helpers; +using Speckle.Revit.Interfaces; namespace Speckle.Converters.RevitShared.ToSpeckle; -[NameAndRankValue(nameof(DB.ExtrusionRoof), 0)] +[NameAndRankValue(nameof(IRevitExtrusionRoof), 0)] public class ExtrusionRoofToSpeckleTopLevelConverter - : BaseTopLevelConverterToSpeckle + : BaseTopLevelConverterToSpeckle { - private readonly ITypedConverter _levelConverter; - private readonly ITypedConverter _modelCurveArrayConverter; - private readonly ITypedConverter _pointConverter; - private readonly ParameterValueExtractor _parameterValueExtractor; - private readonly DisplayValueExtractor _displayValueExtractor; - private readonly HostedElementConversionToSpeckle _hostedElementConverter; - private readonly ParameterObjectAssigner _parameterObjectAssigner; + private readonly ITypedConverter _levelConverter; + private readonly ITypedConverter _modelCurveArrayConverter; + private readonly ITypedConverter _pointConverter; + private readonly IParameterValueExtractor _parameterValueExtractor; + private readonly IDisplayValueExtractor _displayValueExtractor; + private readonly IHostedElementConversionToSpeckle _hostedElementConverter; + private readonly IParameterObjectAssigner _parameterObjectAssigner; + private readonly IRevitFilterFactory _revitFilterFactory; public ExtrusionRoofToSpeckleTopLevelConverter( - ITypedConverter levelConverter, - ITypedConverter modelCurveArrayConverter, - ITypedConverter pointConverter, - ParameterValueExtractor parameterValueExtractor, - DisplayValueExtractor displayValueExtractor, - HostedElementConversionToSpeckle hostedElementConverter, - ParameterObjectAssigner parameterObjectAssigner + ITypedConverter levelConverter, + ITypedConverter modelCurveArrayConverter, + ITypedConverter pointConverter, + IParameterValueExtractor parameterValueExtractor, + IDisplayValueExtractor displayValueExtractor, + IHostedElementConversionToSpeckle hostedElementConverter, + IParameterObjectAssigner parameterObjectAssigner, + IRevitFilterFactory revitFilterFactory ) { _levelConverter = levelConverter; @@ -36,35 +38,36 @@ ParameterObjectAssigner parameterObjectAssigner _displayValueExtractor = displayValueExtractor; _hostedElementConverter = hostedElementConverter; _parameterObjectAssigner = parameterObjectAssigner; + _revitFilterFactory = revitFilterFactory; } - public override RevitExtrusionRoof Convert(DB.ExtrusionRoof target) + public override RevitExtrusionRoof Convert(IRevitExtrusionRoof target) { var speckleExtrusionRoof = new RevitExtrusionRoof { - start = _parameterValueExtractor.GetValueAsDouble(target, DB.BuiltInParameter.EXTRUSION_START_PARAM), - end = _parameterValueExtractor.GetValueAsDouble(target, DB.BuiltInParameter.EXTRUSION_END_PARAM) + start = _parameterValueExtractor.GetValueAsDouble(target, RevitBuiltInParameter.EXTRUSION_START_PARAM), + end = _parameterValueExtractor.GetValueAsDouble(target, RevitBuiltInParameter.EXTRUSION_END_PARAM) }; - var plane = target.GetProfile().get_Item(0).SketchPlane.GetPlane(); + var plane = target.GetProfile()[0].SketchPlane.GetPlane(); speckleExtrusionRoof.referenceLine = new SOG.Line( _pointConverter.Convert(plane.Origin.Add(plane.XVec.Normalize().Negate())), _pointConverter.Convert(plane.Origin) ); - var level = _parameterValueExtractor.GetValueAsDocumentObject( + var level = _parameterValueExtractor.GetValueAsRevitLevel( target, - DB.BuiltInParameter.ROOF_CONSTRAINT_LEVEL_PARAM + RevitBuiltInParameter.ROOF_CONSTRAINT_LEVEL_PARAM ); - speckleExtrusionRoof.level = _levelConverter.Convert(level); + speckleExtrusionRoof.level = _levelConverter.Convert(level.NotNull()); speckleExtrusionRoof.outline = _modelCurveArrayConverter.Convert(target.GetProfile()); - var elementType = (DB.ElementType)target.Document.GetElement(target.GetTypeId()); + var elementType = target.Document.GetElement(target.GetTypeId()).NotNull().ToType().NotNull(); speckleExtrusionRoof.type = elementType.Name; speckleExtrusionRoof.family = elementType.FamilyName; _parameterObjectAssigner.AssignParametersToBase(target, speckleExtrusionRoof); speckleExtrusionRoof.displayValue = _displayValueExtractor.GetDisplayValue(target); speckleExtrusionRoof.elements = _hostedElementConverter - .ConvertHostedElements(target.GetHostedElementIds()) + .ConvertHostedElements(target.GetHostedElementIds(_revitFilterFactory)) .ToList(); return speckleExtrusionRoof; diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/FamilyInstanceTopLevelConverterToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/FamilyInstanceTopLevelConverterToSpeckle.cs index 446dcd4383..b408d104cc 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/FamilyInstanceTopLevelConverterToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/FamilyInstanceTopLevelConverterToSpeckle.cs @@ -1,24 +1,26 @@ -using Speckle.Converters.Common; +using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; using Speckle.Core.Models; +using Speckle.Revit.Interfaces; namespace Speckle.Converters.RevitShared.ToSpeckle; // POC: bin for now? This is also a parent child relationship and may need a pattern for this // so we don't end up with some god FamilyInstanceTopLevelConverterToSpeckle converter -[NameAndRankValue(nameof(DB.FamilyInstance), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public sealed class FamilyInstanceTopLevelConverterToSpeckle : BaseTopLevelConverterToSpeckle +[NameAndRankValue(nameof(IRevitFamilyInstance), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +public sealed class FamilyInstanceTopLevelConverterToSpeckle + : BaseTopLevelConverterToSpeckle { - private readonly ITypedConverter _elementConverter; - private readonly ITypedConverter _beamConversion; - private readonly ITypedConverter _columnConversion; - private readonly ITypedConverter _braceConversion; + private readonly ITypedConverter _elementConverter; + private readonly ITypedConverter _beamConversion; + private readonly ITypedConverter _columnConversion; + private readonly ITypedConverter _braceConversion; public FamilyInstanceTopLevelConverterToSpeckle( - ITypedConverter elementConverter, - ITypedConverter beamConversion, - ITypedConverter columnConversion, - ITypedConverter braceConversion + ITypedConverter elementConverter, + ITypedConverter beamConversion, + ITypedConverter columnConversion, + ITypedConverter braceConversion ) { _elementConverter = elementConverter; @@ -27,13 +29,13 @@ public FamilyInstanceTopLevelConverterToSpeckle( _braceConversion = braceConversion; } - public override Base Convert(DB.FamilyInstance target) + public override Base Convert(IRevitFamilyInstance target) { return target.StructuralType switch { - DB.Structure.StructuralType.Beam => _beamConversion.Convert(target), - DB.Structure.StructuralType.Column => _columnConversion.Convert(target), - DB.Structure.StructuralType.Brace => _braceConversion.Convert(target), + RevitStructuralType.Beam => _beamConversion.Convert(target), + RevitStructuralType.Column => _columnConversion.Convert(target), + RevitStructuralType.Brace => _braceConversion.Convert(target), // POC: return generic element conversion or throw? // diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/FloorTopLevelConverterToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/FloorTopLevelConverterToSpeckle.cs index 13d0d3086f..b6c8ade775 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/FloorTopLevelConverterToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/FloorTopLevelConverterToSpeckle.cs @@ -1,32 +1,33 @@ -using Objects; +using Objects; +using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; using Speckle.Converters.RevitShared.Helpers; -using Speckle.Converters.RevitShared.ToSpeckle; using Speckle.Core.Models; +using Speckle.Revit.Interfaces; -namespace Speckle.Converters.Common; +namespace Speckle.Converters.RevitShared.ToSpeckle; // POC: reminder - writing classes and creating interfaces is a bit like organising your space // if you have a structure for organising things, your interfaces, then finding your stuff, your classes & methods, becomes easy // having a lack of interfaces or large interfaces is a bit like lacking structure, when all of your stuff, your classes & methods // clould be anywhere or all in once place - rooting through box 274 for something you need, when said box has a miriad different // and unrelated items, is no fun. Plus when you need that item, you end up bringing out the whole box/ -[NameAndRankValue(nameof(DB.Floor), 0)] -public class FloorTopLevelConverterToSpeckle : BaseTopLevelConverterToSpeckle +[NameAndRankValue(nameof(IRevitFloor), 0)] +public class FloorTopLevelConverterToSpeckle : BaseTopLevelConverterToSpeckle { - private readonly ITypedConverter> _curveArrArrayConverter; - private readonly ITypedConverter _levelConverter; - private readonly ParameterValueExtractor _parameterValueExtractor; - private readonly ParameterObjectAssigner _parameterObjectAssigner; - private readonly DisplayValueExtractor _displayValueExtractor; + private readonly ITypedConverter> _curveArrArrayConverter; + private readonly ITypedConverter _levelConverter; + private readonly IParameterValueExtractor _parameterValueExtractor; + private readonly IParameterObjectAssigner _parameterObjectAssigner; + private readonly IDisplayValueExtractor _displayValueExtractor; private readonly ISlopeArrowExtractor _slopeArrowExtractor; public FloorTopLevelConverterToSpeckle( - ITypedConverter> curveArrArrayConverter, - ITypedConverter levelConverter, - ParameterValueExtractor parameterValueExtractor, - ParameterObjectAssigner parameterObjectAssigner, - DisplayValueExtractor displayValueExtractor, + ITypedConverter> curveArrArrayConverter, + ITypedConverter levelConverter, + IParameterValueExtractor parameterValueExtractor, + IParameterObjectAssigner parameterObjectAssigner, + IDisplayValueExtractor displayValueExtractor, ISlopeArrowExtractor slopeArrowExtractor ) { @@ -38,14 +39,14 @@ ISlopeArrowExtractor slopeArrowExtractor _slopeArrowExtractor = slopeArrowExtractor; } - public override SOBR.RevitFloor Convert(DB.Floor target) + public override SOBR.RevitFloor Convert(IRevitFloor target) { SOBR.RevitFloor speckleFloor = new(); - var sketch = (DB.Sketch)target.Document.GetElement(target.SketchId); + var sketch = target.Document.GetElement(target.SketchId).NotNull().ToSketch().NotNull(); List profiles = _curveArrArrayConverter.Convert(sketch.Profile); - DB.ElementType type = (DB.ElementType)target.Document.GetElement(target.GetTypeId()); + IRevitElementType type = target.Document.GetElement(target.GetTypeId()).NotNull().ToType().NotNull(); speckleFloor.family = type.FamilyName; speckleFloor.type = type.Name; @@ -61,13 +62,13 @@ public override SOBR.RevitFloor Convert(DB.Floor target) speckleFloor.voids = profiles.Skip(1).ToList(); } - var level = _parameterValueExtractor.GetValueAsDocumentObject(target, DB.BuiltInParameter.LEVEL_PARAM); - speckleFloor.level = _levelConverter.Convert(level); + var level = _parameterValueExtractor.GetValueAsRevitLevel(target, RevitBuiltInParameter.LEVEL_PARAM); + speckleFloor.level = _levelConverter.Convert(level.NotNull()); speckleFloor.structural = - _parameterValueExtractor.GetValueAsBool(target, DB.BuiltInParameter.FLOOR_PARAM_IS_STRUCTURAL) ?? false; + _parameterValueExtractor.GetValueAsBool(target, RevitBuiltInParameter.FLOOR_PARAM_IS_STRUCTURAL) ?? false; double? slopeParam = null; - if (_parameterValueExtractor.TryGetValueAsDouble(target, DB.BuiltInParameter.ROOF_SLOPE, out var slope)) + if (_parameterValueExtractor.TryGetValueAsDouble(target, RevitBuiltInParameter.ROOF_SLOPE, out var slope)) { // Divide by 100 to convert from percentage to unitless ratio (rise over run) slopeParam = slope / 100d; @@ -83,9 +84,10 @@ public override SOBR.RevitFloor Convert(DB.Floor target) return speckleFloor; } - private void TryAssignSlopeFromSlopeArrow(DB.Floor target, SOBR.RevitFloor speckleFloor, double? slopeParam) + private void TryAssignSlopeFromSlopeArrow(IRevitFloor target, SOBR.RevitFloor speckleFloor, double? slopeParam) { - if (_slopeArrowExtractor.GetSlopeArrow(target) is not DB.ModelLine slopeArrow) + var slopeArrow = _slopeArrowExtractor.GetSlopeArrow(target); + if (slopeArrow is null) { return; } diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/FootPrintRoofToSpeckleTopLevelConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/FootPrintRoofToSpeckleTopLevelConverter.cs index 1c8e74bb04..5a51d40f28 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/FootPrintRoofToSpeckleTopLevelConverter.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/FootPrintRoofToSpeckleTopLevelConverter.cs @@ -1,33 +1,33 @@ -using Autodesk.Revit.DB; -using Objects; -using Objects.BuiltElements.Revit; +using Objects; using Objects.BuiltElements.Revit.RevitRoof; -using Objects.Geometry; using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; using Speckle.Converters.RevitShared.Extensions; using Speckle.Converters.RevitShared.Helpers; +using Speckle.Revit.Interfaces; namespace Speckle.Converters.RevitShared.ToSpeckle; -[NameAndRankValue(nameof(DB.FootPrintRoof), 0)] +[NameAndRankValue(nameof(IRevitFootPrintRoof), 0)] public class FootPrintRoofToSpeckleTopLevelConverter - : BaseTopLevelConverterToSpeckle + : BaseTopLevelConverterToSpeckle { - private readonly ITypedConverter _levelConverter; - private readonly ITypedConverter _modelCurveArrArrayConverter; - private readonly ParameterValueExtractor _parameterValueExtractor; - private readonly DisplayValueExtractor _displayValueExtractor; - private readonly HostedElementConversionToSpeckle _hostedElementConverter; - private readonly ParameterObjectAssigner _parameterObjectAssigner; + private readonly ITypedConverter _levelConverter; + private readonly ITypedConverter _modelCurveArrArrayConverter; + private readonly IParameterValueExtractor _parameterValueExtractor; + private readonly IDisplayValueExtractor _displayValueExtractor; + private readonly IHostedElementConversionToSpeckle _hostedElementConverter; + private readonly IParameterObjectAssigner _parameterObjectAssigner; + private readonly IRevitFilterFactory _revitFilterFactory; public FootPrintRoofToSpeckleTopLevelConverter( - ITypedConverter levelConverter, - ITypedConverter modelCurveArrArrayConverter, - ParameterValueExtractor parameterValueExtractor, - DisplayValueExtractor displayValueExtractor, - HostedElementConversionToSpeckle hostedElementConverter, - ParameterObjectAssigner parameterObjectAssigner + ITypedConverter levelConverter, + ITypedConverter modelCurveArrArrayConverter, + IParameterValueExtractor parameterValueExtractor, + IDisplayValueExtractor displayValueExtractor, + IHostedElementConversionToSpeckle hostedElementConverter, + IParameterObjectAssigner parameterObjectAssigner, + IRevitFilterFactory revitFilterFactory ) { _levelConverter = levelConverter; @@ -36,30 +36,24 @@ ParameterObjectAssigner parameterObjectAssigner _displayValueExtractor = displayValueExtractor; _hostedElementConverter = hostedElementConverter; _parameterObjectAssigner = parameterObjectAssigner; + _revitFilterFactory = revitFilterFactory; } - public override RevitFootprintRoof Convert(FootPrintRoof target) + public override RevitFootprintRoof Convert(IRevitFootPrintRoof target) { - var baseLevel = _parameterValueExtractor.GetValueAsDocumentObject( - target, - DB.BuiltInParameter.ROOF_BASE_LEVEL_PARAM - ); + var baseLevel = _parameterValueExtractor.GetValueAsRevitLevel(target, RevitBuiltInParameter.ROOF_BASE_LEVEL_PARAM); // We don't currently validate the success of this TryGet, it is assumed some Roofs don't have a top-level. - _parameterValueExtractor.TryGetValueAsDocumentObject( - target, - DB.BuiltInParameter.ROOF_UPTO_LEVEL_PARAM, - out var topLevel - ); + var topLevel = _parameterValueExtractor.GetValueAsRevitLevel(target, RevitBuiltInParameter.ROOF_UPTO_LEVEL_PARAM); //POC: CNX-9403 can be null if the sides have different slopes. //We currently don't validate the success or failure of this TryGet as it's not necessary, but will be once we start the above ticket. - _parameterValueExtractor.TryGetValueAsDouble(target, DB.BuiltInParameter.ROOF_SLOPE, out var slope); + _parameterValueExtractor.TryGetValueAsDouble(target, RevitBuiltInParameter.ROOF_SLOPE, out var slope); RevitFootprintRoof speckleFootprintRoof = new() { - level = _levelConverter.Convert(baseLevel), + level = _levelConverter.Convert(baseLevel.NotNull()), cutOffLevel = topLevel is not null ? _levelConverter.Convert(topLevel) : null, slope = slope }; @@ -72,7 +66,7 @@ out var topLevel speckleFootprintRoof.outline = profiles.FirstOrDefault(); speckleFootprintRoof.voids = profiles.Skip(1).ToList(); - var elementType = (ElementType)target.Document.GetElement(target.GetTypeId()); + var elementType = target.Document.GetElement(target.GetTypeId()).NotNull().ToType().NotNull(); speckleFootprintRoof.type = elementType.Name; speckleFootprintRoof.family = elementType.FamilyName; @@ -81,7 +75,7 @@ out var topLevel _parameterObjectAssigner.AssignParametersToBase(target, speckleFootprintRoof); speckleFootprintRoof.displayValue = _displayValueExtractor.GetDisplayValue(target); speckleFootprintRoof.elements = _hostedElementConverter - .ConvertHostedElements(target.GetHostedElementIds()) + .ConvertHostedElements(target.GetHostedElementIds(_revitFilterFactory)) .ToList(); return speckleFootprintRoof; diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/HostedElementConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/HostedElementConversionToSpeckle.cs index 53eef628a9..b927329b7e 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/HostedElementConversionToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/HostedElementConversionToSpeckle.cs @@ -1,7 +1,7 @@ -using Autodesk.Revit.DB; -using Speckle.Converters.Common; -using Speckle.Converters.RevitShared.Helpers; +using Speckle.Converters.Common; using Speckle.Core.Models; +using Speckle.InterfaceGenerator; +using Speckle.Revit.Interfaces; namespace Speckle.Converters.RevitShared.ToSpeckle; @@ -9,28 +9,26 @@ namespace Speckle.Converters.RevitShared.ToSpeckle; // opportunity to rethink or confirm hosted element handling? Should this be a connector responsibiliy? // No interfacing out however... // CNX-9414 Re-evaluate hosted element conversions -public class HostedElementConversionToSpeckle +[GenerateAutoInterface] +public class HostedElementConversionToSpeckle : IHostedElementConversionToSpeckle { - private readonly ToSpeckleConvertedObjectsCache _convertedObjectsCache; private readonly IRootToSpeckleConverter _converter; - private readonly IRevitConversionContextStack _contextStack; + private readonly IConversionContextStack _contextStack; public HostedElementConversionToSpeckle( - ToSpeckleConvertedObjectsCache convertedObjectsCache, IRootToSpeckleConverter converter, - IRevitConversionContextStack contextStack + IConversionContextStack contextStack ) { - _convertedObjectsCache = convertedObjectsCache; _converter = converter; _contextStack = contextStack; } - public IEnumerable ConvertHostedElements(IEnumerable hostedElementIds) + public IEnumerable ConvertHostedElements(IEnumerable hostedElementIds) { foreach (var elemId in hostedElementIds) { - Element element = _contextStack.Current.Document.GetElement(elemId); + IRevitElement element = _contextStack.Current.Document.GetElement(elemId).NotNull(); Base @base; try diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/ModelCurveToSpeckleTopLevelConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/ModelCurveToSpeckleTopLevelConverter.cs index 240cbe4713..f305468ece 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/ModelCurveToSpeckleTopLevelConverter.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/ModelCurveToSpeckleTopLevelConverter.cs @@ -1,28 +1,29 @@ -using Objects; +using Objects; using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; -using Speckle.Converters.RevitShared.Helpers; +using Speckle.Revit.Interfaces; namespace Speckle.Converters.RevitShared.ToSpeckle; // POC: ModelCurve looks a bit bogus and we may wish to revise what that is and how it inherits // see https://spockle.atlassian.net/browse/CNX-9381 -[NameAndRankValue(nameof(DB.ModelCurve), 0)] -public class ModelCurveToSpeckleTopLevelConverter : BaseTopLevelConverterToSpeckle +[NameAndRankValue(nameof(IRevitModelCurve), 0)] +public class ModelCurveToSpeckleTopLevelConverter + : BaseTopLevelConverterToSpeckle { - private readonly ITypedConverter _curveConverter; - private readonly IRevitConversionContextStack _conversionContext; + private readonly ITypedConverter _curveConverter; + private readonly IConversionContextStack _conversionContext; public ModelCurveToSpeckleTopLevelConverter( - ITypedConverter curveConverter, - IRevitConversionContextStack conversionContext + ITypedConverter curveConverter, + IConversionContextStack conversionContext ) { _curveConverter = curveConverter; _conversionContext = conversionContext; } - public override SOBR.Curve.ModelCurve Convert(DB.ModelCurve target) + public override SOBR.Curve.ModelCurve Convert(IRevitModelCurve target) { var modelCurve = new SOBR.Curve.ModelCurve() { diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/RoofBaseToSpeckleTopLevelTopLevelConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/RoofBaseToSpeckleTopLevelTopLevelConverter.cs index 77f9ce831c..805671c0a7 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/RoofBaseToSpeckleTopLevelTopLevelConverter.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/RoofBaseToSpeckleTopLevelTopLevelConverter.cs @@ -1,40 +1,45 @@ -using Autodesk.Revit.DB; -using Objects.BuiltElements.Revit.RevitRoof; +using Objects.BuiltElements.Revit.RevitRoof; using Speckle.Converters.Common; using Speckle.Converters.RevitShared.Extensions; using Speckle.Converters.RevitShared.Helpers; +using Speckle.Revit.Interfaces; namespace Speckle.Converters.RevitShared.ToSpeckle; -[NameAndRankValue(nameof(DB.RoofBase), 0)] +[NameAndRankValue(nameof(IRevitRoofBase), 0)] internal sealed class RoofBaseToSpeckleTopLevelTopLevelConverter - : BaseTopLevelConverterToSpeckle + : BaseTopLevelConverterToSpeckle { - private readonly DisplayValueExtractor _displayValueExtractor; - private readonly HostedElementConversionToSpeckle _hostedElementConverter; - private readonly ParameterObjectAssigner _parameterObjectAssigner; + private readonly IDisplayValueExtractor _displayValueExtractor; + private readonly IHostedElementConversionToSpeckle _hostedElementConverter; + private readonly IParameterObjectAssigner _parameterObjectAssigner; + private readonly IRevitFilterFactory _revitFilterFactory; public RoofBaseToSpeckleTopLevelTopLevelConverter( - DisplayValueExtractor displayValueExtractor, - HostedElementConversionToSpeckle hostedElementConverter, - ParameterObjectAssigner parameterObjectAssigner + IDisplayValueExtractor displayValueExtractor, + IHostedElementConversionToSpeckle hostedElementConverter, + IParameterObjectAssigner parameterObjectAssigner, + IRevitFilterFactory revitFilterFactory ) { _displayValueExtractor = displayValueExtractor; _hostedElementConverter = hostedElementConverter; _parameterObjectAssigner = parameterObjectAssigner; + _revitFilterFactory = revitFilterFactory; } - public override RevitRoof Convert(RoofBase target) + public override RevitRoof Convert(IRevitRoofBase target) { RevitRoof revitRoof = new(); - var elementType = (ElementType)target.Document.GetElement(target.GetTypeId()); + var elementType = target.Document.GetElement(target.GetTypeId()).NotNull().ToType().NotNull(); revitRoof.type = elementType.Name; revitRoof.family = elementType.FamilyName; _parameterObjectAssigner.AssignParametersToBase(target, revitRoof); revitRoof.displayValue = _displayValueExtractor.GetDisplayValue(target); - revitRoof.elements = _hostedElementConverter.ConvertHostedElements(target.GetHostedElementIds()).ToList(); + revitRoof.elements = _hostedElementConverter + .ConvertHostedElements(target.GetHostedElementIds(_revitFilterFactory)) + .ToList(); return revitRoof; } diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/RoomTopLevelConverterToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/RoomTopLevelConverterToSpeckle.cs index 6e4e1f91cb..6baaa3d6aa 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/RoomTopLevelConverterToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/RoomTopLevelConverterToSpeckle.cs @@ -3,26 +3,27 @@ using Speckle.Converters.Common.Objects; using Speckle.Converters.RevitShared.Helpers; using Speckle.Core.Models; +using Speckle.Revit.Interfaces; namespace Speckle.Converters.RevitShared.ToSpeckle; -[NameAndRankValue(nameof(DBA.Room), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class RoomTopLevelConverterToSpeckle : BaseTopLevelConverterToSpeckle +[NameAndRankValue(nameof(IRevitRoom), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +public class RoomTopLevelConverterToSpeckle : BaseTopLevelConverterToSpeckle { - private readonly DisplayValueExtractor _displayValueExtractor; - private readonly ParameterObjectAssigner _parameterObjectAssigner; - private readonly ITypedConverter _levelConverter; - private readonly ParameterValueExtractor _parameterValueExtractor; - private readonly ITypedConverter _locationConverter; - private readonly ITypedConverter, SOG.Polycurve> _boundarySegmentConverter; + private readonly IDisplayValueExtractor _displayValueExtractor; + private readonly IParameterObjectAssigner _parameterObjectAssigner; + private readonly ITypedConverter _levelConverter; + private readonly IParameterValueExtractor _parameterValueExtractor; + private readonly ITypedConverter _locationConverter; + private readonly ITypedConverter, SOG.Polycurve> _boundarySegmentConverter; public RoomTopLevelConverterToSpeckle( - DisplayValueExtractor displayValueExtractor, - ParameterObjectAssigner parameterObjectAssigner, - ITypedConverter levelConverter, - ParameterValueExtractor parameterValueExtractor, - ITypedConverter locationConverter, - ITypedConverter, SOG.Polycurve> boundarySegmentConverter + IDisplayValueExtractor displayValueExtractor, + IParameterObjectAssigner parameterObjectAssigner, + ITypedConverter levelConverter, + IParameterValueExtractor parameterValueExtractor, + ITypedConverter locationConverter, + ITypedConverter, SOG.Polycurve> boundarySegmentConverter ) { _displayValueExtractor = displayValueExtractor; @@ -33,19 +34,19 @@ public RoomTopLevelConverterToSpeckle( _boundarySegmentConverter = boundarySegmentConverter; } - public override SOBE.Room Convert(DBA.Room target) + public override SOBE.Room Convert(IRevitRoom target) { var number = target.Number; - var name = _parameterValueExtractor.GetValueAsString(target, DB.BuiltInParameter.ROOM_NAME); - var area = _parameterValueExtractor.GetValueAsDouble(target, DB.BuiltInParameter.ROOM_AREA); + var name = _parameterValueExtractor.GetValueAsString(target, RevitBuiltInParameter.ROOM_NAME); + var area = _parameterValueExtractor.GetValueAsDouble(target, RevitBuiltInParameter.ROOM_AREA); var displayValue = _displayValueExtractor.GetDisplayValue(target); var basePoint = (SOG.Point)_locationConverter.Convert(target.Location); var level = _levelConverter.Convert(target.Level); var profiles = target - .GetBoundarySegments(new DB.SpatialElementBoundaryOptions()) - .Select(c => (ICurve)_boundarySegmentConverter.Convert(c)) + .GetBoundarySegments() + .Select(c => (ICurve)_boundarySegmentConverter.Convert(c.ToList())) .ToList(); var outline = profiles.First(); diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/TopographyTopLevelConverterToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/TopographyTopLevelConverterToSpeckle.cs index eea4ea51c9..ce34b66376 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/TopographyTopLevelConverterToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/TopographyTopLevelConverterToSpeckle.cs @@ -1,27 +1,28 @@ -using Speckle.Converters.Common; +using Speckle.Converters.Common; using Speckle.Converters.RevitShared.Helpers; +using Speckle.Revit.Interfaces; namespace Speckle.Converters.RevitShared.ToSpeckle; // POC: needs review feels, BIG, feels like it could be broken down.. // i.e. GetParams(), GetGeom()? feels like it's doing too much -[NameAndRankValue(nameof(DBA.TopographySurface), 0)] +[NameAndRankValue(nameof(IRevitTopographySurface), 0)] public class TopographyTopLevelConverterToSpeckle - : BaseTopLevelConverterToSpeckle + : BaseTopLevelConverterToSpeckle { - private readonly DisplayValueExtractor _displayValueExtractor; - private readonly ParameterObjectAssigner _parameterObjectAssigner; + private readonly IDisplayValueExtractor _displayValueExtractor; + private readonly IParameterObjectAssigner _parameterObjectAssigner; public TopographyTopLevelConverterToSpeckle( - DisplayValueExtractor displayValueExtractor, - ParameterObjectAssigner parameterObjectAssigner + IDisplayValueExtractor displayValueExtractor, + IParameterObjectAssigner parameterObjectAssigner ) { _displayValueExtractor = displayValueExtractor; _parameterObjectAssigner = parameterObjectAssigner; } - public override SOBR.RevitTopography Convert(DBA.TopographySurface target) + public override SOBR.RevitTopography Convert(IRevitTopographySurface target) { var speckleTopo = new SOBR.RevitTopography { diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/WallTopLevelConverterToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/WallTopLevelConverterToSpeckle.cs index 8e0cce3ba9..3d48ca2ede 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/WallTopLevelConverterToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/WallTopLevelConverterToSpeckle.cs @@ -1,4 +1,4 @@ -using Speckle.Converters.Common.Objects; +using Speckle.Converters.Common.Objects; using Speckle.Converters.Common; using Objects; using Speckle.Converters.RevitShared.Helpers; @@ -6,32 +6,35 @@ using Speckle.Core.Models.Extensions; using Speckle.Converters.RevitShared.Extensions; using Objects.BuiltElements.Revit; +using Speckle.Revit.Interfaces; namespace Speckle.Converters.RevitShared.ToSpeckle; // POC: needs review feels, BIG, feels like it could be broken down.. // i.e. GetParams(), GetGeom()? feels like it's doing too much -[NameAndRankValue(nameof(DB.Wall), 0)] -public class WallTopLevelConverterToSpeckle : BaseTopLevelConverterToSpeckle +[NameAndRankValue(nameof(IRevitWall), 0)] +public class WallTopLevelConverterToSpeckle : BaseTopLevelConverterToSpeckle { - private readonly ITypedConverter _curveConverter; - private readonly ITypedConverter _levelConverter; - private readonly ITypedConverter> _curveArrArrayConverter; - private readonly ParameterValueExtractor _parameterValueExtractor; - private readonly IRevitConversionContextStack _contextStack; - private readonly DisplayValueExtractor _displayValueExtractor; - private readonly ParameterObjectAssigner _parameterObjectAssigner; + private readonly ITypedConverter _curveConverter; + private readonly ITypedConverter _levelConverter; + private readonly ITypedConverter> _curveArrArrayConverter; + private readonly IParameterValueExtractor _parameterValueExtractor; + private readonly IConversionContextStack _contextStack; + private readonly IDisplayValueExtractor _displayValueExtractor; + private readonly IParameterObjectAssigner _parameterObjectAssigner; private readonly IRootToSpeckleConverter _converter; + private readonly IRevitFilterFactory _revitFilterFactory; public WallTopLevelConverterToSpeckle( - ITypedConverter curveConverter, - ITypedConverter levelConverter, - ITypedConverter> curveArrArrayConverter, - IRevitConversionContextStack contextStack, - ParameterValueExtractor parameterValueExtractor, - DisplayValueExtractor displayValueExtractor, - ParameterObjectAssigner parameterObjectAssigner, - IRootToSpeckleConverter converter + ITypedConverter curveConverter, + ITypedConverter levelConverter, + ITypedConverter> curveArrArrayConverter, + IConversionContextStack contextStack, + IParameterValueExtractor parameterValueExtractor, + IDisplayValueExtractor displayValueExtractor, + IParameterObjectAssigner parameterObjectAssigner, + IRootToSpeckleConverter converter, + IRevitFilterFactory revitFilterFactory ) { _curveConverter = curveConverter; @@ -42,9 +45,10 @@ IRootToSpeckleConverter converter _displayValueExtractor = displayValueExtractor; _parameterObjectAssigner = parameterObjectAssigner; _converter = converter; + _revitFilterFactory = revitFilterFactory; } - public override SOBR.RevitWall Convert(DB.Wall target) + public override SOBR.RevitWall Convert(IRevitWall target) { SOBR.RevitWall speckleWall = new() { family = target.WallType.FamilyName.ToString(), type = target.WallType.Name }; @@ -57,9 +61,10 @@ public override SOBR.RevitWall Convert(DB.Wall target) return speckleWall; } - private void AssignSpecificParameters(DB.Wall target, RevitWall speckleWall) + private void AssignSpecificParameters(IRevitWall target, RevitWall speckleWall) { - if (target.Location is not DB.LocationCurve locationCurve) + var locationCurve = target.GetLocationAsLocationCurve(); + if (locationCurve is null) { throw new SpeckleConversionException( "Incorrect assumption was made that all Revit Wall location properties would be of type \"LocationCurve\"" @@ -68,46 +73,41 @@ private void AssignSpecificParameters(DB.Wall target, RevitWall speckleWall) speckleWall.baseLine = _curveConverter.Convert(locationCurve.Curve); - var level = _parameterValueExtractor.GetValueAsDocumentObject( - target, - DB.BuiltInParameter.WALL_BASE_CONSTRAINT - ); - speckleWall.level = _levelConverter.Convert(level); + var level = _parameterValueExtractor.GetValueAsRevitLevel(target, RevitBuiltInParameter.WALL_BASE_CONSTRAINT); + speckleWall.level = _levelConverter.Convert(level.NotNull()); - var topLevel = _parameterValueExtractor.GetValueAsDocumentObject( - target, - DB.BuiltInParameter.WALL_BASE_CONSTRAINT - ); - speckleWall.topLevel = _levelConverter.Convert(topLevel); + var topLevel = _parameterValueExtractor.GetValueAsRevitLevel(target, RevitBuiltInParameter.WALL_BASE_CONSTRAINT); + speckleWall.topLevel = _levelConverter.Convert(topLevel.NotNull()); // POC : what to do if these parameters are unset (instead of assigning default) _ = _parameterValueExtractor.TryGetValueAsDouble( target, - DB.BuiltInParameter.WALL_USER_HEIGHT_PARAM, + RevitBuiltInParameter.WALL_USER_HEIGHT_PARAM, out double? height ); speckleWall.height = height ?? 0; _ = _parameterValueExtractor.TryGetValueAsDouble( target, - DB.BuiltInParameter.WALL_BASE_OFFSET, + RevitBuiltInParameter.WALL_BASE_OFFSET, out double? baseOffset ); speckleWall.baseOffset = baseOffset ?? 0; _ = _parameterValueExtractor.TryGetValueAsDouble( target, - DB.BuiltInParameter.WALL_TOP_OFFSET, + RevitBuiltInParameter.WALL_TOP_OFFSET, out double? topOffset ); speckleWall.topOffset = topOffset ?? 0; speckleWall.structural = - _parameterValueExtractor.GetValueAsBool(target, DB.BuiltInParameter.WALL_STRUCTURAL_SIGNIFICANT) ?? false; + _parameterValueExtractor.GetValueAsBool(target, RevitBuiltInParameter.WALL_STRUCTURAL_SIGNIFICANT) ?? false; speckleWall.flipped = target.Flipped; } - private List GetChildElements(DB.Wall target) + private List GetChildElements(IRevitWall target) { List wallChildren = new(); - if (target.CurtainGrid is DB.CurtainGrid grid) + var grid = target.CurtainGrid; + if (grid is not null) { wallChildren.AddRange(ConvertElements(grid.GetMullionIds())); wallChildren.AddRange(ConvertElements(grid.GetPanelIds())); @@ -116,19 +116,19 @@ private List GetChildElements(DB.Wall target) { wallChildren.AddRange(ConvertElements(target.GetStackedWallMemberIds())); } - wallChildren.AddRange(ConvertElements(target.GetHostedElementIds())); + wallChildren.AddRange(ConvertElements(target.GetHostedElementIds(_revitFilterFactory))); return wallChildren; } - private IEnumerable ConvertElements(IEnumerable elementIds) + private IEnumerable ConvertElements(IEnumerable elementIds) { - foreach (DB.ElementId elementId in elementIds) + foreach (IRevitElementId elementId in elementIds) { - yield return _converter.Convert(_contextStack.Current.Document.GetElement(elementId)); + yield return _converter.Convert(_contextStack.Current.Document.GetElement(elementId).NotNull()); } } - private void AssignDisplayValue(DB.Wall target, RevitWall speckleWall) + private void AssignDisplayValue(IRevitWall target, RevitWall speckleWall) { if (target.CurtainGrid is null) { @@ -159,9 +159,9 @@ private void AssignHostedElements(SOBR.RevitWall speckleWall, List hostedO } } - private void AssignVoids(DB.Wall target, SOBR.RevitWall speckleWall) + private void AssignVoids(IRevitWall target, SOBR.RevitWall speckleWall) { - DB.CurveArrArray? profile = ((DB.Sketch)target.Document.GetElement(target.SketchId))?.Profile; + IRevitCurveArrArray? profile = target.Document.GetElement(target.SketchId)?.ToSketch()?.Profile; if (profile is null) { return; diff --git a/DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/ISpeckleContainerContext.cs b/DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/ISpeckleContainerContext.cs new file mode 100644 index 0000000000..a65698422a --- /dev/null +++ b/DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/ISpeckleContainerContext.cs @@ -0,0 +1,7 @@ +namespace Speckle.Autofac.DependencyInjection; + +public interface ISpeckleContainerContext +{ + T Resolve() + where T : notnull; +} diff --git a/DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/SpeckleContainerBuilder.cs b/DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/SpeckleContainerBuilder.cs index 45c162f3ae..ee71d941e6 100644 --- a/DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/SpeckleContainerBuilder.cs +++ b/DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/SpeckleContainerBuilder.cs @@ -9,6 +9,19 @@ namespace Speckle.Autofac.DependencyInjection; public class SpeckleContainerBuilder { + private readonly struct SpeckleContainerContext : ISpeckleContainerContext + { + private readonly IComponentContext _componentContext; + + public SpeckleContainerContext(IComponentContext componentContext) + { + _componentContext = componentContext; + } + + public T Resolve() + where T : notnull => _componentContext.Resolve(); + } + private static readonly Type s_moduleType = typeof(ISpeckleModule); private readonly IStorageInfo _storageInfo; @@ -161,6 +174,13 @@ public SpeckleContainerBuilder AddScoped() return this; } + public SpeckleContainerBuilder AddScoped(Func action) + where T : notnull + { + ContainerBuilder.Register(c => action(new SpeckleContainerContext(c))).InstancePerLifetimeScope(); + return this; + } + public SpeckleContainerBuilder AddScoped() where T : class { @@ -183,6 +203,22 @@ public SpeckleContainerBuilder AddTransient() return this; } + //Scans assembly for classes that implement the same name interface and registers as transient + public SpeckleContainerBuilder ScanAssembly(Assembly assembly) + { + ContainerBuilder + .RegisterAssemblyTypes(assembly) + .Where(t => t.IsClass) + .As(GetInterfacesWithNameName) + .InstancePerDependency(); + return this; + } + + public SpeckleContainerBuilder ScanAssemblyOfType() => ScanAssembly(typeof(T).Assembly); + + private static IEnumerable GetInterfacesWithNameName(Type type) => + type.GetInterfaces().Where(i => i.Name == "I" + type.Name); + public SpeckleContainer Build() { var container = ContainerBuilder.Build(); diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/ContainerRegistration.cs b/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/ContainerRegistration.cs index 6a5fb37913..189bbcc6e7 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/ContainerRegistration.cs +++ b/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/ContainerRegistration.cs @@ -29,7 +29,7 @@ This will require consolidating across other connectors. builder.AddScoped(); - builder.RegisterRawConversions(); + builder.RegisterConverters(); builder.InjectNamedTypes(); builder.InjectNamedTypes(); } diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/NamedTypeInjector.cs b/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/NamedTypeInjector.cs index c4a0800ce7..1c701cc642 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/NamedTypeInjector.cs +++ b/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/NamedTypeInjector.cs @@ -7,6 +7,8 @@ namespace Speckle.Converters.Common.DependencyInjection; public static class ConversionTypesInjector { + private record NamedType(string Name, int Rank, Type Type); + public static void InjectNamedTypes(this SpeckleContainerBuilder containerBuilder) where T : notnull { @@ -19,33 +21,33 @@ public static void InjectNamedTypes(this SpeckleContainerBuilder containerBui { var nameAndRank = x.GetCustomAttribute(); - return (name: nameAndRank.Name, rank: nameAndRank.Rank, type: x); + return new NamedType(Name: nameAndRank.Name, Rank: nameAndRank.Rank, Type: x); }) .ToList(); // we'll register the types accordingly - var names = byName.Select(x => x.name).Distinct(); + var names = byName.Select(x => x.Name).Distinct(); foreach (string name in names) { - var namedTypes = byName.Where(x => x.name == name).OrderByDescending(y => y.rank).ToList(); + var namedTypes = byName.Where(x => x.Name == name).OrderByDescending(y => y.Rank).ToList(); // first type found var first = namedTypes[0]; // POC: may need to be instance per lifecycle scope - containerBuilder.ContainerBuilder.RegisterType(first.type).Keyed(first.name).InstancePerLifetimeScope(); + containerBuilder.ContainerBuilder.RegisterType(first.Type).Keyed(first.Name).InstancePerLifetimeScope(); // POC: not sure yet if... // * This should be an array of types // * Whether the scope should be modified or modifiable // * Whether this is in the write project... hmmm // POC: IsAssignableFrom() - var secondaryType = first.type.GetInterface(typeof(ITypedConverter<,>).Name); + var secondaryType = first.Type.GetInterface(typeof(ITypedConverter<,>).Name); // POC: should we explode if no found? if (secondaryType != null) { containerBuilder.ContainerBuilder - .RegisterType(first.type) + .RegisterType(first.Type) .As(secondaryType) .PropertiesAutowired(PropertyWiringOptions.AllowCircularDependencies) .InstancePerLifetimeScope(); @@ -57,8 +59,8 @@ public static void InjectNamedTypes(this SpeckleContainerBuilder containerBui { // POC: is this the right scope? containerBuilder.ContainerBuilder - .RegisterType(other.type) - .Keyed($"{other.name}|{other.rank}") + .RegisterType(other.Type) + .Keyed($"{other.Name}|{other.Rank}") .InstancePerLifetimeScope(); // POC: not sure yet if... @@ -67,11 +69,11 @@ public static void InjectNamedTypes(this SpeckleContainerBuilder containerBui // * Whether this is in the write project... hmmm // POC: IsAssignableFrom() // NOT very DRY - secondaryType = first.type.GetInterface(typeof(ITypedConverter<,>).Name); + secondaryType = first.Type.GetInterface(typeof(ITypedConverter<,>).Name); // POC: should we explode if no found? if (secondaryType != null) { - containerBuilder.ContainerBuilder.RegisterType(first.type).As(secondaryType).InstancePerLifetimeScope(); + containerBuilder.ContainerBuilder.RegisterType(first.Type).As(secondaryType).InstancePerLifetimeScope(); } } } diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/RawConversionRegisterer.cs b/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/RawConversionRegisterer.cs index 73745af1f7..7b8743151e 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/RawConversionRegisterer.cs +++ b/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/RawConversionRegisterer.cs @@ -6,22 +6,29 @@ namespace Speckle.Converters.Common.DependencyInjection; // POC: review and see if it can be made more generic, related to the // NameAndRankAttribute work that needs doing -public static class RawConversionRegisterer +public static class ConverterRegistration { - public static void RegisterRawConversions(this SpeckleContainerBuilder containerBuilder) + public static void RegisterConverters(this SpeckleContainerBuilder containerBuilder) { // POC: hard-coding speckle... :/ foreach (Type speckleType in containerBuilder.SpeckleTypes) { - RegisterRawConversionsForType(containerBuilder.ContainerBuilder, speckleType); + foreach (var conversionInterface in RegisterConversionsForType(speckleType)) + { + containerBuilder.ContainerBuilder + .RegisterType(speckleType) + .As(conversionInterface) + .PropertiesAutowired(PropertyWiringOptions.AllowCircularDependencies) + .InstancePerLifetimeScope(); + } } } - private static void RegisterRawConversionsForType(ContainerBuilder containerBuilder, Type type) + private static IEnumerable RegisterConversionsForType(Type type) { if (!type.IsClass || type.IsAbstract) { - return; + yield break; } var rawConversionInterfaces = type.GetInterfaces() @@ -29,11 +36,7 @@ private static void RegisterRawConversionsForType(ContainerBuilder containerBuil foreach (var conversionInterface in rawConversionInterfaces) { - containerBuilder - .RegisterType(type) - .As(conversionInterface) - .PropertiesAutowired(PropertyWiringOptions.AllowCircularDependencies) - .InstancePerLifetimeScope(); + yield return conversionInterface.NotNull(); } } } diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common/ContextWrapper.cs b/DUI3-DX/Sdk/Speckle.Converters.Common/ContextWrapper.cs index 02088f06bb..97d77a3389 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common/ContextWrapper.cs +++ b/DUI3-DX/Sdk/Speckle.Converters.Common/ContextWrapper.cs @@ -5,7 +5,7 @@ public class ContextWrapper : IDisposable { private IConversionContextStack? _stack; - public ConversionContext? Context { get; private set; } + public IConversionContext? Context { get; private set; } public ContextWrapper(IConversionContextStack stack) { diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common/ConversionContext.cs b/DUI3-DX/Sdk/Speckle.Converters.Common/ConversionContext.cs index 723877d0b9..c4423c1cc2 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common/ConversionContext.cs +++ b/DUI3-DX/Sdk/Speckle.Converters.Common/ConversionContext.cs @@ -1,7 +1,9 @@ -namespace Speckle.Converters.Common; +using Speckle.InterfaceGenerator; -// POC: record? -public class ConversionContext +namespace Speckle.Converters.Common; + +[GenerateAutoInterface] +public class ConversionContext : IConversionContext where TDocument : class { public ConversionContext(TDocument doc, string speckleUnits) diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common/ConversionContextStack.cs b/DUI3-DX/Sdk/Speckle.Converters.Common/ConversionContextStack.cs index 918a29d3c1..4575c4da49 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common/ConversionContextStack.cs +++ b/DUI3-DX/Sdk/Speckle.Converters.Common/ConversionContextStack.cs @@ -28,9 +28,9 @@ IHostToSpeckleUnitConverter unitConverter _stack.Push(new ConversionContext(_document, _unitConverter.ConvertOrThrow(hostUnit))); } - private readonly Stack> _stack = new(); + private readonly Stack> _stack = new(); - public ConversionContext Current => _stack.Peek(); + public IConversionContext Current => _stack.Peek(); public ContextWrapper Push(string speckleUnit) { @@ -39,10 +39,7 @@ public ContextWrapper Push(string speckleUnit) return new ContextWrapper(this); } - public ContextWrapper Push(THostUnit hostUnit) - { - return Push(_unitConverter.ConvertOrThrow(hostUnit)); - } + public ContextWrapper Push(THostUnit hostUnit) => Push(_unitConverter.ConvertOrThrow(hostUnit)); public void Pop() => _stack.Pop(); } diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common/IRootToSpeckleConverter.cs b/DUI3-DX/Sdk/Speckle.Converters.Common/RootToSpeckleConverter.cs similarity index 55% rename from DUI3-DX/Sdk/Speckle.Converters.Common/IRootToSpeckleConverter.cs rename to DUI3-DX/Sdk/Speckle.Converters.Common/RootToSpeckleConverter.cs index 6a19ebb13a..65ea7156a2 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common/IRootToSpeckleConverter.cs +++ b/DUI3-DX/Sdk/Speckle.Converters.Common/RootToSpeckleConverter.cs @@ -2,6 +2,7 @@ using Speckle.Converters.Common.Objects; using Speckle.Core.Models; using Speckle.InterfaceGenerator; +using Speckle.Revit.Interfaces; namespace Speckle.Converters.Common; @@ -9,25 +10,32 @@ namespace Speckle.Converters.Common; public class RootToSpeckleConverter : IRootToSpeckleConverter { private readonly IFactory _toSpeckle; + private readonly IProxyMap _proxyMap; - public RootToSpeckleConverter(IFactory toSpeckle) + public RootToSpeckleConverter(IFactory toSpeckle, IProxyMap proxyMap) { _toSpeckle = toSpeckle; + _proxyMap = proxyMap; } public Base Convert(object target) { - Type type = target.GetType(); - + Type revitType = target.GetType(); + var wrapper = _proxyMap.WrapIfExists(revitType, target); + if (wrapper == null) + { + throw new NotSupportedException($"No wrapper found for Revit type: {revitType.Name}"); + } + var (wrappedType, wrappedObject) = wrapper.Value; try { - var objectConverter = _toSpeckle.ResolveInstance(type.Name); //poc: would be nice to have supertypes resolve + var objectConverter = _toSpeckle.ResolveInstance(wrappedType.Name); //poc: would be nice to have supertypes resolve if (objectConverter == null) { - throw new NotSupportedException($"No conversion found for {type.Name}"); + throw new NotSupportedException($"No conversion found for {wrappedType.Name}"); } - var convertedObject = objectConverter.Convert(target); + var convertedObject = objectConverter.Convert(wrappedObject); return convertedObject; } diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common/Speckle.Converters.Common.csproj b/DUI3-DX/Sdk/Speckle.Converters.Common/Speckle.Converters.Common.csproj index 7c611c401a..7fb8e9d333 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common/Speckle.Converters.Common.csproj +++ b/DUI3-DX/Sdk/Speckle.Converters.Common/Speckle.Converters.Common.csproj @@ -3,7 +3,9 @@ netstandard2.0 - + + + From a18cba1f37953a00f569910e49cf7804999afa08 Mon Sep 17 00:00:00 2001 From: Adam Hathcock Date: Fri, 14 Jun 2024 09:44:14 +0100 Subject: [PATCH 230/261] Use ProxyMap class that is source generated (#3507) * Initial commit from converter-tests * tests now run * adding more to proxy map * switch to FluentAssertions * fix IRevitLevel conversions * more cast handling * use proxymap for ofclass * update revit interfaces * fmt * add more proxies * better handling for wrapped types * fix the RevitContext * inject interfaces * convert to new way of casting * update and rejigger dependencies * handle null elements * proxy map is also proxy aware * fmt * change namespaces * updates to proxies * more cast changes * another cast issue fixed * update nugets * fmt * add System.IO to make CI happy? * Bumping proxy API and using source gen ProxyMap * fmt * putting root back * use IProxyMapper in root converter * bump host apis * revert registration change * remove sendselection --- .../DependencyInjection/ProxyMap.cs | 80 ------------------- .../RevitConnectorModule.cs | 2 - .../GlobalUsings.cs | 1 - .../Operations/Send/RevitRootObjectBuilder.cs | 2 +- .../RevitConverterModule.cs | 1 - ...rters.Revit2023.DependencyInjection.csproj | 2 +- .../Speckle.Converters.Revit2023.Tests.csproj | 2 +- .../packages.lock.json | 10 +-- .../Speckle.Converters.Revit2023.csproj | 2 +- .../Helpers/SlopeArrowExtractor.cs | 16 ---- .../Services/ReferencePointConverter.cs | 9 +-- .../RootToSpeckleConverter.cs | 8 +- .../Speckle.Converters.Common.csproj | 4 +- 13 files changed, 18 insertions(+), 121 deletions(-) delete mode 100644 DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/ProxyMap.cs delete mode 100644 DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/GlobalUsings.cs diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/ProxyMap.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/ProxyMap.cs deleted file mode 100644 index 2d7f7f8314..0000000000 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/ProxyMap.cs +++ /dev/null @@ -1,80 +0,0 @@ -using System.Collections.Concurrent; -using System.Diagnostics.CodeAnalysis; -using Speckle.Revit.Api; -using Speckle.Revit.Interfaces; - -namespace Speckle.Connectors.Revit2023.Converters; - -[SuppressMessage("Performance", "CA1810:Initialize reference type static fields inline")] -public class ProxyMap : IProxyMap -{ - private static readonly ConcurrentDictionary s_revitToInterfaceMap = new(); - private static readonly ConcurrentDictionary s_proxyToInterfaceMap = new(); - private static readonly ConcurrentDictionary s_interfaceToRevit = new(); - private static readonly ConcurrentDictionary> s_proxyFactory = new(); - - [SuppressMessage("Maintainability", "CA1506:Avoid excessive class coupling")] - static ProxyMap() - { - Add(x => new ElementProxy(x)); - Add(x => new FamilyInstanceProxy(x)); - Add(x => new CurveProxy(x)); - Add(x => new BoundarySegmentProxy(x)); - Add(x => new LevelProxy(x)); - Add(x => new LocationProxy(x)); - Add(x => new MaterialProxy(x)); - Add(x => new ModelCurveArrayProxy(x)); - Add(x => new ModelCurveArrArrayProxy(x)); - Add(x => new ParameterProxy(x)); - Add(x => new BasePointProxy(x)); - Add(x => new WallProxy(x)); - Add(x => new PanelProxy(x)); - Add(x => new FloorProxy(x)); - Add(x => new CeilingProxy(x)); - Add(x => new FootPrintRoofProxy(x)); - Add(x => new ModelLineProxy(x)); - Add(x => new RoofBaseProxy(x)); - } - - private static void Add(Func f) - where T : class - where TInterface : notnull - where TProxy : TInterface - { - s_revitToInterfaceMap.TryAdd(typeof(T), typeof(TInterface)); - s_proxyToInterfaceMap.TryAdd(typeof(TProxy), typeof(TInterface)); - s_proxyFactory.TryAdd(typeof(TInterface), w => f((T)w)); - s_interfaceToRevit.TryAdd(typeof(TInterface), typeof(T)); - } - - public Type? GetMappedTypeFromHostType(Type type) - { - if (s_revitToInterfaceMap.TryGetValue(type, out var t)) - { - return t; - } - return null; - } - - public Type? GetMappedTypeFromProxyType(Type type) - { - if (s_proxyToInterfaceMap.TryGetValue(type, out var t)) - { - return t; - } - - return null; - } - - public Type? GetHostTypeFromMappedType(Type type) - { - if (s_interfaceToRevit.TryGetValue(type, out var t)) - { - return t; - } - - return null; - } - - public object CreateProxy(Type type, object toWrap) => s_proxyFactory[type](toWrap); -} diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/RevitConnectorModule.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/RevitConnectorModule.cs index 83e0a6af57..879bf05041 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/RevitConnectorModule.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/RevitConnectorModule.cs @@ -10,7 +10,6 @@ using Speckle.Connectors.Revit.HostApp; using Speckle.Connectors.Revit.Operations.Send; using Speckle.Connectors.Revit.Plugin; -using Speckle.Connectors.Revit2023.Converters; using Speckle.Connectors.RevitShared.Helpers; using Speckle.Connectors.Utils; using Speckle.Connectors.Utils.Builders; @@ -73,6 +72,5 @@ public void Load(SpeckleContainerBuilder builder) // register send conversion cache builder.AddSingleton(); - builder.AddSingleton(); } } diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/GlobalUsings.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/GlobalUsings.cs deleted file mode 100644 index dec8635815..0000000000 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/GlobalUsings.cs +++ /dev/null @@ -1 +0,0 @@ -global using DB = Autodesk.Revit.DB; diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RevitRootObjectBuilder.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RevitRootObjectBuilder.cs index 63c2144e76..6652aad320 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RevitRootObjectBuilder.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RevitRootObjectBuilder.cs @@ -53,7 +53,7 @@ public RootObjectBuilderResult Build( throw new SpeckleException("Family Environment documents are not supported."); } - var revitElements = new List(); // = _contextStack.Current.Document.GetElements(sendSelection.SelectedItems).ToList(); + var revitElements = new List(); foreach (var id in objects) { diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/RevitConverterModule.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/RevitConverterModule.cs index f5ecc652f0..533baf679e 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/RevitConverterModule.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/RevitConverterModule.cs @@ -28,6 +28,5 @@ public void Load(SpeckleContainerBuilder builder) builder.AddScoped(); builder.AddScoped(); builder.AddScoped(); - builder.AddScoped(); } } diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/Speckle.Converters.Revit2023.DependencyInjection.csproj b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/Speckle.Converters.Revit2023.DependencyInjection.csproj index c390bba29b..810abe8b3f 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/Speckle.Converters.Revit2023.DependencyInjection.csproj +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/Speckle.Converters.Revit2023.DependencyInjection.csproj @@ -6,7 +6,7 @@ - + diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/Speckle.Converters.Revit2023.Tests.csproj b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/Speckle.Converters.Revit2023.Tests.csproj index 70941da6f7..eabdeb030a 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/Speckle.Converters.Revit2023.Tests.csproj +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/Speckle.Converters.Revit2023.Tests.csproj @@ -14,7 +14,7 @@ - + diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/packages.lock.json b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/packages.lock.json index b6ddfa328f..b5cef2200d 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/packages.lock.json +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/packages.lock.json @@ -65,9 +65,9 @@ }, "Speckle.Revit2023.Interfaces": { "type": "Direct", - "requested": "[0.1.1-preview.0.20, )", - "resolved": "0.1.1-preview.0.20", - "contentHash": "L/8btGlDejt6OCe8Lee05N3ztKV+pz24WAU9fwXRHEeWMgSe+bqq477Jmk641QFcKmcWK25XJlprlHiCh4pAdQ==" + "requested": "[0.1.1-preview.0.22, )", + "resolved": "0.1.1-preview.0.22", + "contentHash": "Z6bfEIKFYJtXPjHQYlGBjiQLekVOU7L//H9gaQIw3ba9jqJeYHx5AV0z6S83g04eGBKkNJC6EwBr+fspsK0f+w==" }, "Castle.Core": { "type": "Transitive", @@ -499,7 +499,7 @@ "dependencies": { "Speckle.Autofac": "[2.0.999-local, )", "Speckle.Objects": "[2.0.999-local, )", - "Speckle.Revit2023.Interfaces": "[0.1.1-preview.0.20, )" + "Speckle.Revit2023.Interfaces": "[0.1.1-preview.0.22, )" } }, "speckle.converters.common.dependencyinjection": { @@ -513,7 +513,7 @@ "type": "Project", "dependencies": { "Speckle.Converters.Common": "[2.0.999-local, )", - "Speckle.Revit2023.Interfaces": "[0.1.1-preview.0.20, )" + "Speckle.Revit2023.Interfaces": "[0.1.1-preview.0.22, )" } }, "Speckle.Core": { diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023/Speckle.Converters.Revit2023.csproj b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023/Speckle.Converters.Revit2023.csproj index 351d1fa2e3..7fe5bd12ca 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023/Speckle.Converters.Revit2023.csproj +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023/Speckle.Converters.Revit2023.csproj @@ -9,7 +9,7 @@ - + diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/SlopeArrowExtractor.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/SlopeArrowExtractor.cs index f1db970430..1ae02630be 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/SlopeArrowExtractor.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/SlopeArrowExtractor.cs @@ -97,19 +97,3 @@ public double GetSlopeArrowHeadOffset(IRevitModelLine slopeArrow, double tailOff return headOffset; } } - -// POC: why do we need this send selection? -// why does conversion need to know about selection in this way? -public class SendSelection -{ - private readonly HashSet _selectedItemIds; - - public SendSelection(IEnumerable selectedItemIds) - { - _selectedItemIds = new HashSet(selectedItemIds); - } - - public bool Contains(string elementId) => _selectedItemIds.Contains(elementId); - - public IReadOnlyCollection SelectedItems => _selectedItemIds.ToList().AsReadOnly(); -} diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Services/ReferencePointConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Services/ReferencePointConverter.cs index da8c985834..4eef722c25 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Services/ReferencePointConverter.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Services/ReferencePointConverter.cs @@ -1,4 +1,4 @@ -using System.Diagnostics.CodeAnalysis; +using System.Diagnostics.CodeAnalysis; using Speckle.Converters.Common; using Speckle.InterfaceGenerator; using Speckle.Revit.Interfaces; @@ -32,7 +32,6 @@ public class ReferencePointConverter : IReferencePointConverter private readonly IRevitTransformUtils _transformUtils; private readonly IRevitFilterFactory _revitFilterFactory; private readonly IRevitXYZUtils _revitXyzUtils; - private readonly IProxyMap _proxyMap; private readonly Dictionary _docTransforms = new(); @@ -41,8 +40,7 @@ public ReferencePointConverter( IRevitConversionSettings revitSettings, IRevitFilterFactory revitFilterFactory, IRevitTransformUtils transformUtils, - IRevitXYZUtils revitXyzUtils, - IProxyMap proxyMap + IRevitXYZUtils revitXyzUtils ) { _contextStack = contextStack; @@ -50,7 +48,6 @@ IProxyMap proxyMap _revitFilterFactory = revitFilterFactory; _transformUtils = transformUtils; _revitXyzUtils = revitXyzUtils; - _proxyMap = proxyMap; } // POC: the original allowed for the document to be passed in @@ -92,7 +89,7 @@ public IRevitTransform GetReferencePointTransform(string referencePointSetting) // POC: bogus disposal below var points = _revitFilterFactory .CreateFilteredElementCollector(_contextStack.Current.Document) - .OfClass(_proxyMap) + .OfClass() .ToList(); var projectPoint = NotNullExtensions.NotNull(points.FirstOrDefault(o => o.IsShared == false), "No projectPoint"); diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common/RootToSpeckleConverter.cs b/DUI3-DX/Sdk/Speckle.Converters.Common/RootToSpeckleConverter.cs index 65ea7156a2..04d87e8349 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common/RootToSpeckleConverter.cs +++ b/DUI3-DX/Sdk/Speckle.Converters.Common/RootToSpeckleConverter.cs @@ -10,18 +10,18 @@ namespace Speckle.Converters.Common; public class RootToSpeckleConverter : IRootToSpeckleConverter { private readonly IFactory _toSpeckle; - private readonly IProxyMap _proxyMap; + private readonly IProxyMapper _proxyMapper; - public RootToSpeckleConverter(IFactory toSpeckle, IProxyMap proxyMap) + public RootToSpeckleConverter(IFactory toSpeckle, IProxyMapper proxyMapper) { _toSpeckle = toSpeckle; - _proxyMap = proxyMap; + _proxyMapper = proxyMapper; } public Base Convert(object target) { Type revitType = target.GetType(); - var wrapper = _proxyMap.WrapIfExists(revitType, target); + var wrapper = _proxyMapper.WrapIfExists(revitType, target); if (wrapper == null) { throw new NotSupportedException($"No wrapper found for Revit type: {revitType.Name}"); diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common/Speckle.Converters.Common.csproj b/DUI3-DX/Sdk/Speckle.Converters.Common/Speckle.Converters.Common.csproj index 7fb8e9d333..f9162e3030 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common/Speckle.Converters.Common.csproj +++ b/DUI3-DX/Sdk/Speckle.Converters.Common/Speckle.Converters.Common.csproj @@ -1,10 +1,10 @@ - + netstandard2.0 - + From 9203263792fb17b14c52eebed6b0fc57e369bfce Mon Sep 17 00:00:00 2001 From: Adam Hathcock Date: Fri, 14 Jun 2024 13:44:35 +0100 Subject: [PATCH 231/261] DUI3-149 Skippable GraphicsStyle clean up (#3508) * DUI3-149 Skippable GraphicsStyle clean up * forgot a return! --- ...erters.Revit2023.DependencyInjection.csproj | 2 +- .../Speckle.Converters.Revit2023.Tests.csproj | 2 +- .../packages.lock.json | 10 +++++----- .../Speckle.Converters.Revit2023.csproj | 2 +- .../Helpers/DisplayValueExtractor.cs | 18 +++++++++--------- .../Helpers/ParameterObjectAssigner.cs | 2 +- .../Raw/LocationConversionToSpeckle.cs | 2 +- .../Speckle.Converters.Common.csproj | 2 +- 8 files changed, 20 insertions(+), 20 deletions(-) diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/Speckle.Converters.Revit2023.DependencyInjection.csproj b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/Speckle.Converters.Revit2023.DependencyInjection.csproj index 810abe8b3f..8458d1fdaa 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/Speckle.Converters.Revit2023.DependencyInjection.csproj +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/Speckle.Converters.Revit2023.DependencyInjection.csproj @@ -6,7 +6,7 @@ - + diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/Speckle.Converters.Revit2023.Tests.csproj b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/Speckle.Converters.Revit2023.Tests.csproj index eabdeb030a..23e43c993c 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/Speckle.Converters.Revit2023.Tests.csproj +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/Speckle.Converters.Revit2023.Tests.csproj @@ -14,7 +14,7 @@ - + diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/packages.lock.json b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/packages.lock.json index b5cef2200d..6fdd69eb66 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/packages.lock.json +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/packages.lock.json @@ -65,9 +65,9 @@ }, "Speckle.Revit2023.Interfaces": { "type": "Direct", - "requested": "[0.1.1-preview.0.22, )", - "resolved": "0.1.1-preview.0.22", - "contentHash": "Z6bfEIKFYJtXPjHQYlGBjiQLekVOU7L//H9gaQIw3ba9jqJeYHx5AV0z6S83g04eGBKkNJC6EwBr+fspsK0f+w==" + "requested": "[0.1.1-preview.0.23, )", + "resolved": "0.1.1-preview.0.23", + "contentHash": "H66I9JRUGt1l1YS8aOdniRPDOixRPqua9puGrhGnTEKJ26kVlgkM3FpKfdAMFea4hf03hdqhnFVmNEwgA6mPHA==" }, "Castle.Core": { "type": "Transitive", @@ -499,7 +499,7 @@ "dependencies": { "Speckle.Autofac": "[2.0.999-local, )", "Speckle.Objects": "[2.0.999-local, )", - "Speckle.Revit2023.Interfaces": "[0.1.1-preview.0.22, )" + "Speckle.Revit2023.Interfaces": "[0.1.1-preview.0.23, )" } }, "speckle.converters.common.dependencyinjection": { @@ -513,7 +513,7 @@ "type": "Project", "dependencies": { "Speckle.Converters.Common": "[2.0.999-local, )", - "Speckle.Revit2023.Interfaces": "[0.1.1-preview.0.22, )" + "Speckle.Revit2023.Interfaces": "[0.1.1-preview.0.23, )" } }, "Speckle.Core": { diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023/Speckle.Converters.Revit2023.csproj b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023/Speckle.Converters.Revit2023.csproj index 7fe5bd12ca..f2fe665f57 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023/Speckle.Converters.Revit2023.csproj +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023/Speckle.Converters.Revit2023.csproj @@ -9,7 +9,7 @@ - + diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/DisplayValueExtractor.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/DisplayValueExtractor.cs index 2e5eaa8f4f..83cd6a4dd6 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/DisplayValueExtractor.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/DisplayValueExtractor.cs @@ -294,24 +294,24 @@ bool hasSymbolGeom /// /// We're caching a dictionary of graphic styles and their ids as it can be a costly operation doing Document.GetElement(solid.GraphicsStyleId) for every solid /// - private readonly Dictionary _graphicStyleCache = new(); + private readonly Dictionary _graphicStyleCache = new(); /// /// Exclude light source cones and potentially other geometries by their graphic style /// private bool IsSkippableGraphicStyle(IRevitElementId id, IRevitDocument doc) { - if (!_graphicStyleCache.ContainsKey(id.ToString())) + var graphicStyle = doc.GetElement(id)?.ToGraphicsStyle(); + if (graphicStyle is null) { - _graphicStyleCache.Add(id.ToString(), doc.GetElement(id).NotNull().ToGraphicsStyle().NotNull()); + return false; + } + if (!_graphicStyleCache.ContainsKey(id.IntegerValue)) + { + _graphicStyleCache.Add(id.IntegerValue, graphicStyle); } - var graphicStyle = _graphicStyleCache[id.ToString()]; - - if ( - graphicStyle != null - && graphicStyle.GraphicsStyleCategory.Id.IntegerValue == (int)RevitBuiltInCategory.OST_LightingFixtureSource - ) + if (graphicStyle.GraphicsStyleCategory.Id.IntegerValue == (int)RevitBuiltInCategory.OST_LightingFixtureSource) { return true; } diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/ParameterObjectAssigner.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/ParameterObjectAssigner.cs index 5b543a70f2..b7b493d064 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/ParameterObjectAssigner.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/ParameterObjectAssigner.cs @@ -36,7 +36,7 @@ public void AssignParametersToBase(IRevitElement target, Base @base) AssignSpeckleParamToBaseObject(instanceParameters, paramBase); // POC: Some elements can have an invalid element type ID, I don't think we want to continue here. - if (elementId != _revitElementIdUtils.InvalidElementId && target is not SOBE.Level) //ignore type props of levels..! + if (elementId.IntegerValue != _revitElementIdUtils.InvalidElementId.IntegerValue && target is not SOBE.Level) //ignore type props of levels..! { var elementType = target.Document.GetElement(elementId).NotNull(); // I don't think we should be adding the type parameters to the object like this diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/LocationConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/LocationConversionToSpeckle.cs index ffba569ce6..ac47cb38cf 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/LocationConversionToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/LocationConversionToSpeckle.cs @@ -36,7 +36,7 @@ public Base Convert(IRevitLocation target) var point = target.ToLocationPoint(); if (point is not null) { - _xyzConverter.Convert(point.Point); + return _xyzConverter.Convert(point.Point); } throw new SpeckleConversionException($"Unexpected location type {target.GetType()}"); } diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common/Speckle.Converters.Common.csproj b/DUI3-DX/Sdk/Speckle.Converters.Common/Speckle.Converters.Common.csproj index f9162e3030..761f021575 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common/Speckle.Converters.Common.csproj +++ b/DUI3-DX/Sdk/Speckle.Converters.Common/Speckle.Converters.Common.csproj @@ -4,7 +4,7 @@ netstandard2.0 - + From 3219fed8a2b92fa53961abcb0f65ea44e905f047 Mon Sep 17 00:00:00 2001 From: Adam Hathcock Date: Fri, 14 Jun 2024 15:13:24 +0100 Subject: [PATCH 232/261] DUI3-149 Level conversions should be optional? Not all! (#3509) * DUI3-149 Level conversions should be optional? Not all! * Back to old except for FootPrintRoof * column converter should use optional level --- .../Helpers/IParameterValueExtractor.cs | 30 +++++++++++++++++++ .../Helpers/ParameterValueExtractor.cs | 24 ++++++++++++--- .../Raw/BeamConversionToSpeckle.cs | 4 +-- .../Raw/ColumnConversionToSpeckle.cs | 14 +++++++-- .../CeilingTopLevelConverterToSpeckle.cs | 4 +-- ...ExtrusionRoofToSpeckleTopLevelConverter.cs | 4 +-- .../FloorTopLevelConverterToSpeckle.cs | 2 +- ...FootPrintRoofToSpeckleTopLevelConverter.cs | 5 ++-- .../WallTopLevelConverterToSpeckle.cs | 6 ++-- 9 files changed, 74 insertions(+), 19 deletions(-) create mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/IParameterValueExtractor.cs diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/IParameterValueExtractor.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/IParameterValueExtractor.cs new file mode 100644 index 0000000000..2bfdd4dbae --- /dev/null +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/IParameterValueExtractor.cs @@ -0,0 +1,30 @@ +using System.Diagnostics.CodeAnalysis; +using Speckle.Revit.Interfaces; + +namespace Speckle.Converters.RevitShared.Helpers; + +//not auto because of NotNullWhen +public interface IParameterValueExtractor +{ + object? GetValue(IRevitParameter parameter); + double GetValueAsDouble(IRevitElement element, RevitBuiltInParameter builtInParameter); + bool TryGetValueAsDouble(IRevitElement element, RevitBuiltInParameter builtInParameter, out double? value); + int GetValueAsInt(IRevitElement element, RevitBuiltInParameter builtInParameter); + bool? GetValueAsBool(IRevitElement element, RevitBuiltInParameter builtInParameter); + string? GetValueAsString(IRevitElement element, RevitBuiltInParameter builtInParameter); + IRevitElementId GetValueAsElementId(IRevitElement element, RevitBuiltInParameter builtInParameter); + bool TryGetValueAsElementId( + IRevitElement element, + RevitBuiltInParameter builtInParameter, + out IRevitElementId? elementId + ); + IRevitElementId? GetValueAsElementId(IRevitParameter parameter); + IRevitLevel GetValueAsRevitLevel(IRevitElement element, RevitBuiltInParameter builtInParameter); + bool TryGetValueAsRevitLevel( + IRevitElement element, + RevitBuiltInParameter builtInParameter, + [NotNullWhen(true)] out IRevitLevel? revitLevel + ); + Dictionary GetAllRemainingParams(IRevitElement revitElement); + void RemoveUniqueId(string uniqueId); +} diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/ParameterValueExtractor.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/ParameterValueExtractor.cs index b5218980fd..2f5a71a853 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/ParameterValueExtractor.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/ParameterValueExtractor.cs @@ -2,7 +2,6 @@ using Speckle.Converters.Common; using Speckle.Converters.RevitShared.Extensions; using Speckle.Converters.RevitShared.Services; -using Speckle.InterfaceGenerator; using Speckle.Revit.Interfaces; namespace Speckle.Converters.RevitShared.Helpers; @@ -11,7 +10,7 @@ namespace Speckle.Converters.RevitShared.Helpers; // really if we have to edit a switch statement... // maybe also better as an extension method, but maybe is fine? // POC: there are a lot of public methods here. Maybe consider consolodating -[GenerateAutoInterface] + public class ParameterValueExtractor : IParameterValueExtractor { private readonly IScalingServiceToSpeckle _scalingService; @@ -160,7 +159,7 @@ public bool TryGetValueAsElementId( return GetValueGeneric(parameter, RevitStorageType.ElementId, (p) => p.AsElementId()); } - public IRevitLevel? GetValueAsRevitLevel(IRevitElement element, RevitBuiltInParameter builtInParameter) + public IRevitLevel GetValueAsRevitLevel(IRevitElement element, RevitBuiltInParameter builtInParameter) { if (!TryGetValueAsElementId(element, builtInParameter, out var elementId)) { @@ -168,7 +167,24 @@ public bool TryGetValueAsElementId( } var paramElement = element.Document.GetElement(elementId); - return paramElement?.ToLevel(); + return (paramElement?.ToLevel()).NotNull(); + } + + public bool TryGetValueAsRevitLevel( + IRevitElement element, + RevitBuiltInParameter builtInParameter, + [NotNullWhen(true)] out IRevitLevel? revitLevel + ) + { + if (!TryGetValueAsElementId(element, builtInParameter, out var elementId)) + { + revitLevel = null; + return false; + } + + var paramElement = element.Document.GetElement(elementId); + revitLevel = paramElement?.ToLevel(); + return revitLevel is not null; } private TResult? GetValueGeneric( diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/BeamConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/BeamConversionToSpeckle.cs index 8c7d36aea1..59f790664f 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/BeamConversionToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/BeamConversionToSpeckle.cs @@ -1,4 +1,4 @@ -using Objects; +using Objects; using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; using Speckle.Converters.RevitShared.Helpers; @@ -58,7 +58,7 @@ public SOBR.RevitBeam Convert(IRevitFamilyInstance target) target, RevitBuiltInParameter.INSTANCE_REFERENCE_LEVEL_PARAM ); - speckleBeam.level = _levelConverter.Convert(level.NotNull()); + speckleBeam.level = _levelConverter.Convert(level); speckleBeam.displayValue = _displayValueExtractor.GetDisplayValue(target); diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ColumnConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ColumnConversionToSpeckle.cs index dc12c29082..f1e5b11c35 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ColumnConversionToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ColumnConversionToSpeckle.cs @@ -42,12 +42,20 @@ public SOBR.RevitColumn Convert(IRevitFamilyInstance target) SOBR.RevitColumn speckleColumn = new() { family = symbol.FamilyName, type = target.Document.GetElement(target.GetTypeId()).NotNull().Name }; - var level = _parameterValueExtractor.GetValueAsRevitLevel(target, RevitBuiltInParameter.FAMILY_BASE_LEVEL_PARAM); - speckleColumn.level = _levelConverter.Convert(level.NotNull()); + if ( + _parameterValueExtractor.TryGetValueAsRevitLevel( + target, + RevitBuiltInParameter.FAMILY_BASE_LEVEL_PARAM, + out var level + ) + ) + { + speckleColumn.level = _levelConverter.Convert(level); + } var topLevel = _parameterValueExtractor.GetValueAsRevitLevel(target, RevitBuiltInParameter.FAMILY_TOP_LEVEL_PARAM); - speckleColumn.topLevel = _levelConverter.Convert(topLevel.NotNull()); + speckleColumn.topLevel = _levelConverter.Convert(topLevel); speckleColumn.baseOffset = _parameterValueExtractor.GetValueAsDouble( target, RevitBuiltInParameter.FAMILY_BASE_LEVEL_OFFSET_PARAM diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/CeilingTopLevelConverterToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/CeilingTopLevelConverterToSpeckle.cs index b757b03215..3dd7ed8cb6 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/CeilingTopLevelConverterToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/CeilingTopLevelConverterToSpeckle.cs @@ -1,4 +1,4 @@ -using Objects; +using Objects; using Objects.BuiltElements.Revit; using Objects.Geometry; using Speckle.Converters.Common; @@ -60,7 +60,7 @@ public override RevitCeiling Convert(IRevitCeiling target) // but it is never being set. We should be setting it var level = _parameterValueExtractor.GetValueAsRevitLevel(target, RevitBuiltInParameter.LEVEL_PARAM); - speckleCeiling.level = _levelConverter.Convert(level.NotNull()); + speckleCeiling.level = _levelConverter.Convert(level); _parameterObjectAssigner.AssignParametersToBase(target, speckleCeiling); speckleCeiling.displayValue = _displayValueExtractor.GetDisplayValue(target); diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/ExtrusionRoofToSpeckleTopLevelConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/ExtrusionRoofToSpeckleTopLevelConverter.cs index b02390e933..8dfeb7907a 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/ExtrusionRoofToSpeckleTopLevelConverter.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/ExtrusionRoofToSpeckleTopLevelConverter.cs @@ -1,4 +1,4 @@ -using Objects.BuiltElements.Revit.RevitRoof; +using Objects.BuiltElements.Revit.RevitRoof; using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; using Speckle.Converters.RevitShared.Extensions; @@ -57,7 +57,7 @@ public override RevitExtrusionRoof Convert(IRevitExtrusionRoof target) target, RevitBuiltInParameter.ROOF_CONSTRAINT_LEVEL_PARAM ); - speckleExtrusionRoof.level = _levelConverter.Convert(level.NotNull()); + speckleExtrusionRoof.level = _levelConverter.Convert(level); speckleExtrusionRoof.outline = _modelCurveArrayConverter.Convert(target.GetProfile()); var elementType = target.Document.GetElement(target.GetTypeId()).NotNull().ToType().NotNull(); diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/FloorTopLevelConverterToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/FloorTopLevelConverterToSpeckle.cs index b6c8ade775..eb292cae5b 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/FloorTopLevelConverterToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/FloorTopLevelConverterToSpeckle.cs @@ -1,4 +1,4 @@ -using Objects; +using Objects; using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; using Speckle.Converters.RevitShared.Helpers; diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/FootPrintRoofToSpeckleTopLevelConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/FootPrintRoofToSpeckleTopLevelConverter.cs index 5a51d40f28..78600db3ff 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/FootPrintRoofToSpeckleTopLevelConverter.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/FootPrintRoofToSpeckleTopLevelConverter.cs @@ -44,7 +44,8 @@ public override RevitFootprintRoof Convert(IRevitFootPrintRoof target) var baseLevel = _parameterValueExtractor.GetValueAsRevitLevel(target, RevitBuiltInParameter.ROOF_BASE_LEVEL_PARAM); // We don't currently validate the success of this TryGet, it is assumed some Roofs don't have a top-level. - var topLevel = _parameterValueExtractor.GetValueAsRevitLevel(target, RevitBuiltInParameter.ROOF_UPTO_LEVEL_PARAM); + IRevitLevel? topLevel; + _parameterValueExtractor.TryGetValueAsRevitLevel(target, RevitBuiltInParameter.ROOF_UPTO_LEVEL_PARAM, out topLevel); //POC: CNX-9403 can be null if the sides have different slopes. //We currently don't validate the success or failure of this TryGet as it's not necessary, but will be once we start the above ticket. @@ -53,7 +54,7 @@ public override RevitFootprintRoof Convert(IRevitFootPrintRoof target) RevitFootprintRoof speckleFootprintRoof = new() { - level = _levelConverter.Convert(baseLevel.NotNull()), + level = _levelConverter.Convert(baseLevel), cutOffLevel = topLevel is not null ? _levelConverter.Convert(topLevel) : null, slope = slope }; diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/WallTopLevelConverterToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/WallTopLevelConverterToSpeckle.cs index 3d48ca2ede..e9a0dbafc1 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/WallTopLevelConverterToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/WallTopLevelConverterToSpeckle.cs @@ -1,4 +1,4 @@ -using Speckle.Converters.Common.Objects; +using Speckle.Converters.Common.Objects; using Speckle.Converters.Common; using Objects; using Speckle.Converters.RevitShared.Helpers; @@ -74,10 +74,10 @@ private void AssignSpecificParameters(IRevitWall target, RevitWall speckleWall) speckleWall.baseLine = _curveConverter.Convert(locationCurve.Curve); var level = _parameterValueExtractor.GetValueAsRevitLevel(target, RevitBuiltInParameter.WALL_BASE_CONSTRAINT); - speckleWall.level = _levelConverter.Convert(level.NotNull()); + speckleWall.level = _levelConverter.Convert(level); var topLevel = _parameterValueExtractor.GetValueAsRevitLevel(target, RevitBuiltInParameter.WALL_BASE_CONSTRAINT); - speckleWall.topLevel = _levelConverter.Convert(topLevel.NotNull()); + speckleWall.topLevel = _levelConverter.Convert(topLevel); // POC : what to do if these parameters are unset (instead of assigning default) _ = _parameterValueExtractor.TryGetValueAsDouble( From 28656e592521c907b969b8820c07fc84ed679c1e Mon Sep 17 00:00:00 2001 From: KatKatKateryna <89912278+KatKatKateryna@users.noreply.github.com> Date: Mon, 17 Jun 2024 17:55:02 +0800 Subject: [PATCH 233/261] Nesting arc gis layers on receive (#3506) * nesting * dict key by string, not list * fix * add GroupLayers to modelCard bakedIds, but NOT select them on highlight --- .../Bindings/BasicConnectorBinding.cs | 5 +- .../Operations/Receive/HostObjectBuilder.cs | 64 ++++++++++++++++--- 2 files changed, 60 insertions(+), 9 deletions(-) diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/BasicConnectorBinding.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/BasicConnectorBinding.cs index dd2fa19efa..649691a526 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/BasicConnectorBinding.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/BasicConnectorBinding.cs @@ -163,7 +163,10 @@ private void SelectMapMembersInTOC(List mapMembers) { if (member is Layer layer) { - layers.Add(layer); + if (member is not GroupLayer) // group layer selection clears other layers selection + { + layers.Add(layer); + } } else if (member is StandaloneTable table) { diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Receive/HostObjectBuilder.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Receive/HostObjectBuilder.cs index a681f5317a..e3a3b6300e 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Receive/HostObjectBuilder.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Receive/HostObjectBuilder.cs @@ -70,7 +70,7 @@ CancellationToken cancellationToken { if (IsGISType(obj)) { - string nestedLayerPath = $"{string.Join("\\", path)}\\{((Collection)obj).name}"; + string nestedLayerPath = $"{string.Join("\\", path)}"; string datasetId = (string)_converter.Convert(obj); conversionTracker[ctx] = new ObjectConversionTracker(obj, nestedLayerPath, datasetId); } @@ -92,10 +92,17 @@ CancellationToken cancellationToken onOperationProgressed?.Invoke("Writing to Database", null); _nonGisFeaturesUtils.WriteGeometriesToDatasets(conversionTracker); + // Create main group layer + Dictionary createdLayerGroups = new(); + Map map = _contextStack.Current.Document.Map; + GroupLayer groupLayer = LayerFactory.Instance.CreateGroupLayer(map, 0, $"{projectName}: {modelName}"); + createdLayerGroups["Basic Speckle Group"] = groupLayer; // key doesn't really matter here + // 3. add layer and tables to the Table Of Content int bakeCount = 0; Dictionary bakedMapMembers = new(); onOperationProgressed?.Invoke("Adding to Map", bakeCount); + foreach (var item in conversionTracker) { cancellationToken.ThrowIfCancellationRequested(); @@ -120,7 +127,7 @@ CancellationToken cancellationToken else { // add layer and layer URI to tracker - MapMember mapMember = AddDatasetsToMap(trackerItem); + MapMember mapMember = AddDatasetsToMap(trackerItem, createdLayerGroups); trackerItem.AddConvertedMapMember(mapMember); trackerItem.AddLayerURI(mapMember.URI); conversionTracker[item.Key] = trackerItem; @@ -133,6 +140,7 @@ CancellationToken cancellationToken } onOperationProgressed?.Invoke("Adding to Map", (double)++bakeCount / conversionTracker.Count); } + bakedObjectIds.AddRange(createdLayerGroups.Values.Select(x => x.URI)); // TODO: validated a correct set regarding bakedobject ids return new(bakedObjectIds, results); @@ -160,13 +168,21 @@ private void AddResultsFromTracker(ObjectConversionTracker trackerItem, List createdLayerGroups + ) { + // get layer details string? datasetId = trackerItem.DatasetId; // should not ne null here + Uri uri = new($"{_contextStack.Current.Document.SpeckleDatabasePath.AbsolutePath.Replace('/', '\\')}\\{datasetId}"); string nestedLayerName = trackerItem.NestedLayerName; - Uri uri = new($"{_contextStack.Current.Document.SpeckleDatabasePath.AbsolutePath.Replace('/', '\\')}\\{datasetId}"); - Map map = _contextStack.Current.Document.Map; + // add group for the current layer + string shortName = nestedLayerName.Split("\\")[^1]; + string nestedLayerPath = string.Join("\\", nestedLayerName.Split("\\").SkipLast(1)); + + GroupLayer groupLayer = CreateNestedGroupLayer(nestedLayerPath, createdLayerGroups); // Most of the Speckle-written datasets will be containing geometry and added as Layers // although, some datasets might be just tables (e.g. native GIS Tables, in the future maybe Revit schedules etc. @@ -174,23 +190,55 @@ private MapMember AddDatasetsToMap(ObjectConversionTracker trackerItem) // expensive, than assuming by default that it's a layer with geometry (which in most cases it's expected to be) try { - var layer = LayerFactory.Instance.CreateLayer(uri, map, layerName: nestedLayerName); + var layer = LayerFactory.Instance.CreateLayer(uri, groupLayer, layerName: shortName); + layer.SetExpanded(true); return layer; } catch (ArgumentException) { - var table = StandaloneTableFactory.Instance.CreateStandaloneTable(uri, map, tableName: nestedLayerName); + var table = StandaloneTableFactory.Instance.CreateStandaloneTable(uri, groupLayer, tableName: shortName); return table; } } + private GroupLayer CreateNestedGroupLayer(string nestedLayerPath, Dictionary createdLayerGroups) + { + GroupLayer lastGroup = createdLayerGroups.FirstOrDefault().Value; + if (lastGroup == null) // if layer not found + { + throw new InvalidOperationException("Speckle Layer Group not found"); + } + + // iterate through each nested level + string createdGroupPath = ""; + var allPathElements = nestedLayerPath.Split("\\").Where(x => !string.IsNullOrEmpty(x)); + foreach (string pathElement in allPathElements) + { + createdGroupPath += "\\" + pathElement; + if (createdLayerGroups.TryGetValue(createdGroupPath, out var existingGroupLayer)) + { + lastGroup = existingGroupLayer; + } + else + { + // create new GroupLayer under last found Group, named with last pathElement + lastGroup = LayerFactory.Instance.CreateGroupLayer(lastGroup, 0, pathElement); + lastGroup.SetExpanded(true); + } + createdLayerGroups[createdGroupPath] = lastGroup; + } + return lastGroup; + } + [Pure] private static string[] GetLayerPath(TraversalContext context) { string[] collectionBasedPath = context.GetAscendantOfType().Select(c => c.name).ToArray(); string[] reverseOrderPath = collectionBasedPath.Length != 0 ? collectionBasedPath : context.GetPropertyPath().ToArray(); - return reverseOrderPath.Reverse().ToArray(); + + var originalPath = reverseOrderPath.Reverse().ToArray(); + return originalPath.Where(x => !string.IsNullOrEmpty(x)).ToArray(); } [Pure] From d2afa7a317d05fe3523809399634f7e47f86898e Mon Sep 17 00:00:00 2001 From: Adam Hathcock Date: Mon, 17 Jun 2024 15:11:26 +0100 Subject: [PATCH 234/261] Add legacy root converter for non proxied converters (#3518) --- .../ArcGISConverterModule.cs | 2 +- .../RhinoConverterModule.cs | 2 +- .../LegacyRootToSpeckleConverter.cs | 37 +++++++++++++++++++ 3 files changed, 39 insertions(+), 2 deletions(-) create mode 100644 DUI3-DX/Sdk/Speckle.Converters.Common/LegacyRootToSpeckleConverter.cs diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3.DependencyInjection/ArcGISConverterModule.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3.DependencyInjection/ArcGISConverterModule.cs index 30a739310b..88d26d8166 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3.DependencyInjection/ArcGISConverterModule.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3.DependencyInjection/ArcGISConverterModule.cs @@ -11,7 +11,7 @@ public class ArcGISConverterModule : ISpeckleModule public void Load(SpeckleContainerBuilder builder) { //don't need a host specific RootToSpeckleConverter - builder.AddConverterCommon(); + builder.AddConverterCommon(); // most things should be InstancePerLifetimeScope so we get one per operation builder.AddScoped(); builder.AddScoped(); diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/RhinoConverterModule.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/RhinoConverterModule.cs index 9117848c90..088b93cc10 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/RhinoConverterModule.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/RhinoConverterModule.cs @@ -9,7 +9,7 @@ public class RhinoConverterModule : ISpeckleModule { public void Load(SpeckleContainerBuilder builder) { - builder.AddConverterCommon(); + builder.AddConverterCommon(); // single stack per conversion builder.AddScoped, RhinoConversionContextStack>(); } diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common/LegacyRootToSpeckleConverter.cs b/DUI3-DX/Sdk/Speckle.Converters.Common/LegacyRootToSpeckleConverter.cs new file mode 100644 index 0000000000..34cd5576a2 --- /dev/null +++ b/DUI3-DX/Sdk/Speckle.Converters.Common/LegacyRootToSpeckleConverter.cs @@ -0,0 +1,37 @@ +using Speckle.Autofac.DependencyInjection; +using Speckle.Converters.Common.Objects; +using Speckle.Core.Models; + +namespace Speckle.Converters.Common; + +public class LegacyRootToSpeckleConverter : IRootToSpeckleConverter +{ + private readonly IFactory _toSpeckle; + + public LegacyRootToSpeckleConverter(IFactory toSpeckle) + { + _toSpeckle = toSpeckle; + } + + public Base Convert(object target) + { + Type type = target.GetType(); + try + { + var objectConverter = _toSpeckle.ResolveInstance(type.Name); //poc: would be nice to have supertypes resolve + + if (objectConverter == null) + { + throw new NotSupportedException($"No conversion found for {type.Name}"); + } + var convertedObject = objectConverter.Convert(target); + + return convertedObject; + } + catch (SpeckleConversionException e) + { + Console.WriteLine(e); + throw; // Just rethrowing for now, Logs may be needed here. + } + } +} From 840513525ba032ba183d855be3d0f8335f8da070 Mon Sep 17 00:00:00 2001 From: Jedd Morgan <45512892+JR-Morgan@users.noreply.github.com> Date: Mon, 17 Jun 2024 16:15:25 +0100 Subject: [PATCH 235/261] =?UTF-8?q?extracting=20some=20non-controversial?= =?UTF-8?q?=20changes=20to=20be=20merged=20first=20for=20clea=E2=80=A6=20(?= =?UTF-8?q?#3517)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * extracting some non-controversial changes to be merged first for cleaner diff * More binding alighment * formatting * fix merge mistake * removed lies --- Core/Core/Core.csproj | 1 - .../Bindings/ArcGISSelectionBinding.cs | 6 +++--- .../Bindings/AutocadSelectionBinding.cs | 14 ++++++-------- .../Bindings/AutocadSendBinding.cs | 2 +- .../Bindings/RevitBaseBinding.cs | 6 +++--- .../Bindings/RhinoBasicConnectorBinding.cs | 4 ++-- .../Bindings/RhinoReceiveBinding.cs | 4 ++-- .../Bindings/RhinoSendBinding.cs | 4 ++-- .../packages.lock.json | 9 --------- .../Bindings/AccountBinding.cs | 4 ++-- .../Speckle.Connectors.DUI/Bindings/TestBinding.cs | 4 ++-- .../Speckle.Connectors.Utils/NotNullExtensions.cs | 8 ++++++++ 12 files changed, 31 insertions(+), 35 deletions(-) diff --git a/Core/Core/Core.csproj b/Core/Core/Core.csproj index 275dcc12cc..caaa2ab93a 100644 --- a/Core/Core/Core.csproj +++ b/Core/Core/Core.csproj @@ -51,7 +51,6 @@ - diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISSelectionBinding.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISSelectionBinding.cs index ddc096b629..157bad2797 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISSelectionBinding.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISSelectionBinding.cs @@ -7,8 +7,8 @@ namespace Speckle.Connectors.ArcGIS.Bindings; public class ArcGISSelectionBinding : ISelectionBinding { - public string Name { get; } = "selectionBinding"; - public IBridge Parent { get; set; } + public string Name => "selectionBinding"; + public IBridge Parent { get; } public ArcGISSelectionBinding(IBridge parent) { @@ -22,7 +22,7 @@ public ArcGISSelectionBinding(IBridge parent) private void OnSelectionChanged(MapViewEventArgs args) { SelectionInfo selInfo = GetSelection(); - Parent?.Send(SelectionBindingEvents.SET_SELECTION, selInfo); + Parent.Send(SelectionBindingEvents.SET_SELECTION, selInfo); } public SelectionInfo GetSelection() diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadSelectionBinding.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadSelectionBinding.cs index b52fcba337..1da7250ceb 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadSelectionBinding.cs +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadSelectionBinding.cs @@ -9,10 +9,8 @@ public class AutocadSelectionBinding : ISelectionBinding { private const string SELECTION_EVENT = "setSelection"; - private readonly List _visitedDocuments = new(); - - public string Name { get; set; } = "selectionBinding"; - + private readonly HashSet _visitedDocuments = new(); + public string Name => "selectionBinding"; public IBridge Parent { get; } public AutocadSelectionBinding(IBridge parent) @@ -26,9 +24,9 @@ public AutocadSelectionBinding(IBridge parent) Application.DocumentManager.DocumentActivated += (sender, e) => OnDocumentChanged(e.Document); } - private void OnDocumentChanged(Document document) => TryRegisterDocumentForSelection(document); + private void OnDocumentChanged(Document? document) => TryRegisterDocumentForSelection(document); - private void TryRegisterDocumentForSelection(Document document) + private void TryRegisterDocumentForSelection(Document? document) { if (document == null) { @@ -49,13 +47,13 @@ private void TryRegisterDocumentForSelection(Document document) private void OnSelectionChanged() { SelectionInfo selInfo = GetSelection(); - Parent?.Send(SELECTION_EVENT, selInfo); + Parent.Send(SELECTION_EVENT, selInfo); } public SelectionInfo GetSelection() { // POC: Will be addressed to move it into AutocadContext! https://spockle.atlassian.net/browse/CNX-9319 - Document doc = Application.DocumentManager.MdiActiveDocument; + Document? doc = Application.DocumentManager.MdiActiveDocument; List objs = new(); List objectTypes = new(); if (doc != null) diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadSendBinding.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadSendBinding.cs index 296dd64359..8ebb187279 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadSendBinding.cs +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadSendBinding.cs @@ -18,7 +18,7 @@ namespace Speckle.Connectors.Autocad.Bindings; public sealed class AutocadSendBinding : ISendBinding { - public string Name { get; } = "sendBinding"; + public string Name => "sendBinding"; public SendBindingUICommands Commands { get; } public IBridge Parent { get; } diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/RevitBaseBinding.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/RevitBaseBinding.cs index 7e1e0afdec..566cc9c41a 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/RevitBaseBinding.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/RevitBaseBinding.cs @@ -8,13 +8,13 @@ namespace Speckle.Connectors.Revit.Bindings; internal abstract class RevitBaseBinding : IBinding { // POC: name and bridge might be better for them to be protected props? - public string Name { get; protected set; } - public IBridge Parent { get; protected set; } + public string Name { get; } + public IBridge Parent { get; } protected readonly DocumentModelStore Store; protected readonly RevitContext RevitContext; - public RevitBaseBinding(string name, DocumentModelStore store, IBridge bridge, RevitContext revitContext) + protected RevitBaseBinding(string name, DocumentModelStore store, IBridge bridge, RevitContext revitContext) { Name = name; Parent = bridge; diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoBasicConnectorBinding.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoBasicConnectorBinding.cs index 4154665c7b..1ceb31b69a 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoBasicConnectorBinding.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoBasicConnectorBinding.cs @@ -14,8 +14,8 @@ namespace Speckle.Connectors.Rhino7.Bindings; public class RhinoBasicConnectorBinding : IBasicConnectorBinding { - public string Name { get; set; } = "baseBinding"; - public IBridge Parent { get; set; } + public string Name => "baseBinding"; + public IBridge Parent { get; } public BasicConnectorBindingCommands Commands { get; } private readonly DocumentModelStore _store; diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoReceiveBinding.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoReceiveBinding.cs index 0314a0f78f..951ff40f6f 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoReceiveBinding.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoReceiveBinding.cs @@ -12,8 +12,8 @@ namespace Speckle.Connectors.Rhino7.Bindings; public class RhinoReceiveBinding : IReceiveBinding { - public string Name { get; set; } = "receiveBinding"; - public IBridge Parent { get; set; } + public string Name => "receiveBinding"; + public IBridge Parent { get; } private readonly CancellationManager _cancellationManager; private readonly DocumentModelStore _store; diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSendBinding.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSendBinding.cs index 8f8594f193..b2c2ab1a20 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSendBinding.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSendBinding.cs @@ -18,9 +18,9 @@ namespace Speckle.Connectors.Rhino7.Bindings; public sealed class RhinoSendBinding : ISendBinding { - public string Name { get; } = "sendBinding"; + public string Name => "sendBinding"; public SendBindingUICommands Commands { get; } - public IBridge Parent { get; set; } + public IBridge Parent { get; } private readonly DocumentModelStore _store; private readonly RhinoIdleManager _idleManager; diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/packages.lock.json b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/packages.lock.json index 6fdd69eb66..8fd5af7998 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/packages.lock.json +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/packages.lock.json @@ -251,14 +251,6 @@ "Serilog": "2.4.0" } }, - "Serilog.Enrichers.GlobalLogContext": { - "type": "Transitive", - "resolved": "3.0.0", - "contentHash": "IIZcj5mAUVhIl/NTA+YI2KC+sPDzcwvs0ZMHH42jsPfl1a4LVX7ohVpw5UK+e3GxuV3Nv239Il5oM2peUIl44g==", - "dependencies": { - "Serilog": "2.12.0" - } - }, "Serilog.Exceptions": { "type": "Transitive", "resolved": "8.4.0", @@ -529,7 +521,6 @@ "Sentry.Serilog": "[3.33.0, )", "Serilog": "[2.12.0, )", "Serilog.Enrichers.ClientInfo": "[1.3.0, )", - "Serilog.Enrichers.GlobalLogContext": "[3.0.0, )", "Serilog.Exceptions": "[8.4.0, )", "Serilog.Sinks.Console": "[4.1.0, )", "Serilog.Sinks.Seq": "[5.2.2, )", diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/AccountBinding.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/AccountBinding.cs index ffd61239c1..6357195a43 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/AccountBinding.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/AccountBinding.cs @@ -5,8 +5,8 @@ namespace Speckle.Connectors.DUI.Bindings; public class AccountBinding : IBinding { - public string Name { get; set; } = "accountsBinding"; - public IBridge Parent { get; private set; } + public string Name => "accountsBinding"; + public IBridge Parent { get; } public AccountBinding(IBridge bridge) { diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/TestBinding.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/TestBinding.cs index e4676053e0..f0523db541 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/TestBinding.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/TestBinding.cs @@ -9,8 +9,8 @@ namespace Speckle.Connectors.DUI.Bindings; /// public class TestBinding : IBinding { - public string Name { get; set; } = "testBinding"; - public IBridge Parent { get; private set; } + public string Name => "testBinding"; + public IBridge Parent { get; } public TestBinding(IBridge bridge) { diff --git a/DUI3-DX/Sdk/Speckle.Connectors.Utils/NotNullExtensions.cs b/DUI3-DX/Sdk/Speckle.Connectors.Utils/NotNullExtensions.cs index a34d6dd671..59d9f2b3c0 100644 --- a/DUI3-DX/Sdk/Speckle.Connectors.Utils/NotNullExtensions.cs +++ b/DUI3-DX/Sdk/Speckle.Connectors.Utils/NotNullExtensions.cs @@ -5,6 +5,7 @@ namespace Speckle.Connectors.Utils; public static class NotNullExtensions { + /// public static async Task NotNull( this Task task, [CallerArgumentExpression(nameof(task))] string? message = null @@ -19,6 +20,7 @@ public static async Task NotNull( return x; } + /// public static async Task NotNull( this Task task, [CallerArgumentExpression(nameof(task))] string? message = null @@ -33,6 +35,11 @@ public static async Task NotNull( return x.Value; } + /// the object to check for null + /// see + /// type + /// A non null value + /// was null public static T NotNull([NotNull] this T? obj, [CallerArgumentExpression(nameof(obj))] string? paramName = null) where T : class { @@ -43,6 +50,7 @@ public static T NotNull([NotNull] this T? obj, [CallerArgumentExpression(name return obj; } + /// public static T NotNull([NotNull] this T? obj, [CallerArgumentExpression(nameof(obj))] string? paramName = null) where T : struct { From 77829a5faf9781ca563b0dbbfd6c5ed440c434d4 Mon Sep 17 00:00:00 2001 From: Adam Hathcock Date: Wed, 19 Jun 2024 15:39:29 +0100 Subject: [PATCH 236/261] Revit fallback to Element Converter (#3512) * add root converter with fallback and tests * proper references * Converters work * fmt * added test! * fmt --- All.sln | 19 + DUI3-DX.slnf | 1 + .../Operations/Send/RevitRootObjectBuilder.cs | 4 +- .../RevitConverterModule.cs | 2 + ...rters.Revit2023.DependencyInjection.csproj | 2 +- .../Speckle.Converters.Revit2023.Tests.csproj | 2 +- .../XyzConversionToPointTests.cs | 61 +++ .../packages.lock.json | 10 +- .../Speckle.Converters.Revit2023.csproj | 2 +- .../Helpers/DisplayValueExtractor.cs | 2 +- .../Helpers/IParameterValueExtractor.cs | 6 +- .../Raw/ColumnConversionToSpeckle.cs | 57 ++- .../Geometry/PointCloudToSpeckleConverter.cs | 2 +- .../RevitRootElementProvider.cs | 11 + .../FakeType.cs | 109 +++++ .../RootToSpeckleConverterTests.cs | 67 +++ .../Speckle.Converters.Common.Tests.csproj | 25 + .../packages.lock.json | 458 ++++++++++++++++++ .../IRootElementProvider.cs | 6 + .../RootConvertManager.cs | 42 ++ .../RootToSpeckleConverter.cs | 45 +- .../Speckle.Converters.Common.csproj | 7 +- 22 files changed, 887 insertions(+), 53 deletions(-) create mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/XyzConversionToPointTests.cs create mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/RevitRootElementProvider.cs create mode 100644 DUI3-DX/Sdk/Speckle.Converters.Common.Tests/FakeType.cs create mode 100644 DUI3-DX/Sdk/Speckle.Converters.Common.Tests/RootToSpeckleConverterTests.cs create mode 100644 DUI3-DX/Sdk/Speckle.Converters.Common.Tests/Speckle.Converters.Common.Tests.csproj create mode 100644 DUI3-DX/Sdk/Speckle.Converters.Common.Tests/packages.lock.json create mode 100644 DUI3-DX/Sdk/Speckle.Converters.Common/IRootElementProvider.cs create mode 100644 DUI3-DX/Sdk/Speckle.Converters.Common/RootConvertManager.cs diff --git a/All.sln b/All.sln index ff3a26c713..1365d9e652 100644 --- a/All.sln +++ b/All.sln @@ -557,6 +557,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{B1324D25 EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Speckle.Converters.Revit2023.Tests", "DUI3-DX\Converters\Revit\Speckle.Converters.Revit2023.Tests\Speckle.Converters.Revit2023.Tests.csproj", "{AEC26A0B-25F3-4544-A9D6-A427BFF79250}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Speckle.Converters.Common.Tests", "DUI3-DX\Sdk\Speckle.Converters.Common.Tests\Speckle.Converters.Common.Tests.csproj", "{95E23A97-E5EA-4506-A52C-D3DA9012DA02}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug Mac|Any CPU = Debug Mac|Any CPU @@ -2807,6 +2809,22 @@ Global {AEC26A0B-25F3-4544-A9D6-A427BFF79250}.Release|Any CPU.Build.0 = Release|Any CPU {AEC26A0B-25F3-4544-A9D6-A427BFF79250}.Release|x64.ActiveCfg = Release|Any CPU {AEC26A0B-25F3-4544-A9D6-A427BFF79250}.Release|x64.Build.0 = Release|Any CPU + {95E23A97-E5EA-4506-A52C-D3DA9012DA02}.Debug Mac|Any CPU.ActiveCfg = Debug|Any CPU + {95E23A97-E5EA-4506-A52C-D3DA9012DA02}.Debug Mac|Any CPU.Build.0 = Debug|Any CPU + {95E23A97-E5EA-4506-A52C-D3DA9012DA02}.Debug Mac|x64.ActiveCfg = Debug|Any CPU + {95E23A97-E5EA-4506-A52C-D3DA9012DA02}.Debug Mac|x64.Build.0 = Debug|Any CPU + {95E23A97-E5EA-4506-A52C-D3DA9012DA02}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {95E23A97-E5EA-4506-A52C-D3DA9012DA02}.Debug|Any CPU.Build.0 = Debug|Any CPU + {95E23A97-E5EA-4506-A52C-D3DA9012DA02}.Debug|x64.ActiveCfg = Debug|Any CPU + {95E23A97-E5EA-4506-A52C-D3DA9012DA02}.Debug|x64.Build.0 = Debug|Any CPU + {95E23A97-E5EA-4506-A52C-D3DA9012DA02}.Release Mac|Any CPU.ActiveCfg = Debug|Any CPU + {95E23A97-E5EA-4506-A52C-D3DA9012DA02}.Release Mac|Any CPU.Build.0 = Debug|Any CPU + {95E23A97-E5EA-4506-A52C-D3DA9012DA02}.Release Mac|x64.ActiveCfg = Debug|Any CPU + {95E23A97-E5EA-4506-A52C-D3DA9012DA02}.Release Mac|x64.Build.0 = Debug|Any CPU + {95E23A97-E5EA-4506-A52C-D3DA9012DA02}.Release|Any CPU.ActiveCfg = Release|Any CPU + {95E23A97-E5EA-4506-A52C-D3DA9012DA02}.Release|Any CPU.Build.0 = Release|Any CPU + {95E23A97-E5EA-4506-A52C-D3DA9012DA02}.Release|x64.ActiveCfg = Release|Any CPU + {95E23A97-E5EA-4506-A52C-D3DA9012DA02}.Release|x64.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -3019,6 +3037,7 @@ Global {F06E4C37-4076-4272-9CA6-FB505E02CD31} = {BE521908-7944-46F3-98BF-B47D34509934} {E1C43415-3200-45F4-8BF9-A4DD7D7F2ED6} = {D92751C8-1039-4005-90B2-913E55E0B8BD} {AEC26A0B-25F3-4544-A9D6-A427BFF79250} = {D92751C8-1039-4005-90B2-913E55E0B8BD} + {95E23A97-E5EA-4506-A52C-D3DA9012DA02} = {2E00592E-558D-492D-88F9-3ECEE4C0C7DA} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {1D43D91B-4F01-4A78-8250-CC6F9BD93A14} diff --git a/DUI3-DX.slnf b/DUI3-DX.slnf index 80e74b0b65..483d0c9d43 100644 --- a/DUI3-DX.slnf +++ b/DUI3-DX.slnf @@ -30,6 +30,7 @@ "DUI3-DX\\Sdk\\Speckle.Autofac\\Speckle.Autofac.csproj", "DUI3-DX\\Sdk\\Speckle.Connectors.Utils\\Speckle.Connectors.Utils.csproj", "DUI3-DX\\Sdk\\Speckle.Converters.Common.DependencyInjection\\Speckle.Converters.Common.DependencyInjection.csproj", + "DUI3-DX\\Sdk\\Speckle.Converters.Common.Tests\\Speckle.Converters.Common.Tests.csproj", "DUI3-DX\\Sdk\\Speckle.Converters.Common\\Speckle.Converters.Common.csproj", "Objects\\Objects\\Objects.csproj", "Objects\\Tests\\Objects.Tests.Unit\\Objects.Tests.Unit.csproj" diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RevitRootObjectBuilder.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RevitRootObjectBuilder.cs index 6652aad320..417478e952 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RevitRootObjectBuilder.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RevitRootObjectBuilder.cs @@ -72,12 +72,14 @@ public RootObjectBuilderResult Build( var countProgress = 0; // because for(int i = 0; ...) loops are so last year var cacheHitCount = 0; List results = new(revitElements.Count); + var path = new string[2]; foreach (Element revitElement in revitElements) { ct.ThrowIfCancellationRequested(); var cat = revitElement.Category.Name; - var path = new[] { doc.GetElement(revitElement.LevelId) is not Level level ? "No level" : level.Name, cat }; + path[0] = doc.GetElement(revitElement.LevelId) is not Level level ? "No level" : level.Name; + path[1] = cat; var collection = GetAndCreateObjectHostCollection(path); var applicationId = revitElement.Id.ToString(); diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/RevitConverterModule.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/RevitConverterModule.cs index 533baf679e..1c7eae1e2f 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/RevitConverterModule.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/RevitConverterModule.cs @@ -14,6 +14,7 @@ public class RevitConverterModule : ISpeckleModule public void Load(SpeckleContainerBuilder builder) { builder.AddConverterCommon(); + builder.ScanAssemblyOfType(); // POC: do we need ToSpeckleScalingService as is, do we need to interface it out? builder.AddScoped(); @@ -28,5 +29,6 @@ public void Load(SpeckleContainerBuilder builder) builder.AddScoped(); builder.AddScoped(); builder.AddScoped(); + builder.AddScoped(); } } diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/Speckle.Converters.Revit2023.DependencyInjection.csproj b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/Speckle.Converters.Revit2023.DependencyInjection.csproj index 8458d1fdaa..ae4703a46f 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/Speckle.Converters.Revit2023.DependencyInjection.csproj +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/Speckle.Converters.Revit2023.DependencyInjection.csproj @@ -6,7 +6,7 @@ - + diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/Speckle.Converters.Revit2023.Tests.csproj b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/Speckle.Converters.Revit2023.Tests.csproj index 23e43c993c..296350ca71 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/Speckle.Converters.Revit2023.Tests.csproj +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/Speckle.Converters.Revit2023.Tests.csproj @@ -14,7 +14,7 @@ - + diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/XyzConversionToPointTests.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/XyzConversionToPointTests.cs new file mode 100644 index 0000000000..dee5979761 --- /dev/null +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/XyzConversionToPointTests.cs @@ -0,0 +1,61 @@ +using FluentAssertions; +using Moq; +using NUnit.Framework; +using Objects; +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; +using Speckle.Converters.RevitShared.Services; +using Speckle.Converters.RevitShared.ToSpeckle; +using Speckle.Revit.Interfaces; + +namespace Speckle.Converters.Revit2023.Tests; + +public class XyzConversionToPointTests +{ + private readonly MockRepository _repository = new(MockBehavior.Strict); + + private readonly Mock> _revitConversionContextStack; + private readonly Mock _scalingServiceToSpeckle; + + public XyzConversionToPointTests() + { + _revitConversionContextStack = _repository.Create>(); + _scalingServiceToSpeckle = _repository.Create(); + } + + [TearDown] + public void Verify() => _repository.VerifyAll(); + + [Test] + public void Convert_Point() + { + var x = 3.1; + var y = 3.2; + var z = 3.3; + var xScaled = 4.1; + var yScaled = 4.2; + var zScaled = 4.3; + var xyz = _repository.Create(); + xyz.Setup(x => x.X).Returns(x); + xyz.Setup(x => x.Y).Returns(y); + xyz.Setup(x => x.Z).Returns(z); + + var units = "units"; + var conversionContext = _repository.Create>(); + conversionContext.Setup(x => x.SpeckleUnits).Returns(units); + + _scalingServiceToSpeckle.Setup(a => a.ScaleLength(x)).Returns(xScaled); + _scalingServiceToSpeckle.Setup(a => a.ScaleLength(y)).Returns(yScaled); + _scalingServiceToSpeckle.Setup(a => a.ScaleLength(z)).Returns(zScaled); + + _revitConversionContextStack.Setup(x => x.Current).Returns(conversionContext.Object); + + var converter = new XyzConversionToPoint(_scalingServiceToSpeckle.Object, _revitConversionContextStack.Object); + var point = converter.Convert(xyz.Object); + + point.x.Should().Be(xScaled); + point.y.Should().Be(yScaled); + point.z.Should().Be(zScaled); + point.units.Should().Be(units); + } +} diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/packages.lock.json b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/packages.lock.json index 8fd5af7998..256510d436 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/packages.lock.json +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/packages.lock.json @@ -65,9 +65,9 @@ }, "Speckle.Revit2023.Interfaces": { "type": "Direct", - "requested": "[0.1.1-preview.0.23, )", - "resolved": "0.1.1-preview.0.23", - "contentHash": "H66I9JRUGt1l1YS8aOdniRPDOixRPqua9puGrhGnTEKJ26kVlgkM3FpKfdAMFea4hf03hdqhnFVmNEwgA6mPHA==" + "requested": "[0.1.1-preview.0.24, )", + "resolved": "0.1.1-preview.0.24", + "contentHash": "BSVpOUJc9g6ISrw8GxvtkglTlITpHEDYNOhxv1ZPbckBsI0yO36JiphhQV4q57ERqD9PpCozUJkVhlCaxWeS6A==" }, "Castle.Core": { "type": "Transitive", @@ -491,7 +491,7 @@ "dependencies": { "Speckle.Autofac": "[2.0.999-local, )", "Speckle.Objects": "[2.0.999-local, )", - "Speckle.Revit2023.Interfaces": "[0.1.1-preview.0.23, )" + "Speckle.Revit2023.Interfaces": "[0.1.1-preview.0.24, )" } }, "speckle.converters.common.dependencyinjection": { @@ -505,7 +505,7 @@ "type": "Project", "dependencies": { "Speckle.Converters.Common": "[2.0.999-local, )", - "Speckle.Revit2023.Interfaces": "[0.1.1-preview.0.23, )" + "Speckle.Revit2023.Interfaces": "[0.1.1-preview.0.24, )" } }, "Speckle.Core": { diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023/Speckle.Converters.Revit2023.csproj b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023/Speckle.Converters.Revit2023.csproj index f2fe665f57..01dc874c3f 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023/Speckle.Converters.Revit2023.csproj +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023/Speckle.Converters.Revit2023.csproj @@ -9,7 +9,7 @@ - + diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/DisplayValueExtractor.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/DisplayValueExtractor.cs index 83cd6a4dd6..9dd899678a 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/DisplayValueExtractor.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/DisplayValueExtractor.cs @@ -103,7 +103,7 @@ List solids //options = ViewSpecificOptions ?? options ?? new Options() { DetailLevel = DetailLevelSetting }; options ??= _revitOptionsFactory.Create(RevitViewDetailLevel.Fine); - IRevitGeometryElement geom; + IRevitGeometryElement? geom; try { geom = element.GetGeometry(options); diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/IParameterValueExtractor.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/IParameterValueExtractor.cs index 2bfdd4dbae..7366b0d055 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/IParameterValueExtractor.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/IParameterValueExtractor.cs @@ -8,7 +8,11 @@ public interface IParameterValueExtractor { object? GetValue(IRevitParameter parameter); double GetValueAsDouble(IRevitElement element, RevitBuiltInParameter builtInParameter); - bool TryGetValueAsDouble(IRevitElement element, RevitBuiltInParameter builtInParameter, out double? value); + bool TryGetValueAsDouble( + IRevitElement element, + RevitBuiltInParameter builtInParameter, + [NotNullWhen(true)] out double? value + ); int GetValueAsInt(IRevitElement element, RevitBuiltInParameter builtInParameter); bool? GetValueAsBool(IRevitElement element, RevitBuiltInParameter builtInParameter); string? GetValueAsString(IRevitElement element, RevitBuiltInParameter builtInParameter); diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ColumnConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ColumnConversionToSpeckle.cs index f1e5b11c35..afcf6f27eb 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ColumnConversionToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ColumnConversionToSpeckle.cs @@ -42,6 +42,7 @@ public SOBR.RevitColumn Convert(IRevitFamilyInstance target) SOBR.RevitColumn speckleColumn = new() { family = symbol.FamilyName, type = target.Document.GetElement(target.GetTypeId()).NotNull().Name }; + //should these all be try? if ( _parameterValueExtractor.TryGetValueAsRevitLevel( target, @@ -52,20 +53,41 @@ out var level { speckleColumn.level = _levelConverter.Convert(level); } + //should these all be try? + if ( + _parameterValueExtractor.TryGetValueAsRevitLevel( + target, + RevitBuiltInParameter.FAMILY_TOP_LEVEL_PARAM, + out var topLevel + ) + ) + { + speckleColumn.topLevel = _levelConverter.Convert(topLevel); + } - var topLevel = _parameterValueExtractor.GetValueAsRevitLevel(target, RevitBuiltInParameter.FAMILY_TOP_LEVEL_PARAM); - - speckleColumn.topLevel = _levelConverter.Convert(topLevel); - speckleColumn.baseOffset = _parameterValueExtractor.GetValueAsDouble( - target, - RevitBuiltInParameter.FAMILY_BASE_LEVEL_OFFSET_PARAM - ); - - speckleColumn.topOffset = _parameterValueExtractor.GetValueAsDouble( - target, - RevitBuiltInParameter.FAMILY_TOP_LEVEL_OFFSET_PARAM - ); + //should these all be try? + if ( + _parameterValueExtractor.TryGetValueAsDouble( + target, + RevitBuiltInParameter.FAMILY_BASE_LEVEL_OFFSET_PARAM, + out var baseOffset + ) + ) + { + speckleColumn.baseOffset = baseOffset.Value; + } + //should these all be try? + if ( + _parameterValueExtractor.TryGetValueAsDouble( + target, + RevitBuiltInParameter.FAMILY_TOP_LEVEL_OFFSET_PARAM, + out var topOffset + ) + ) + { + speckleColumn.topOffset = topOffset.Value; + } speckleColumn.facingFlipped = target.FacingFlipped; speckleColumn.handFlipped = target.HandFlipped; speckleColumn.isSlanted = target.IsSlantedColumn; @@ -77,7 +99,7 @@ out var level } speckleColumn.baseLine = - GetBaseCurve(target, speckleColumn.topLevel.elevation, speckleColumn.topOffset) + GetBaseCurve(target, speckleColumn.topLevel?.elevation, speckleColumn.topOffset) ?? throw new SpeckleConversionException("Unable to find a valid baseCurve for column"); speckleColumn.displayValue = _displayValueExtractor.GetDisplayValue(target); @@ -87,7 +109,7 @@ out var level return speckleColumn; } - private ICurve? GetBaseCurve(IRevitFamilyInstance target, double topLevelElevation, double topLevelOffset) + private ICurve? GetBaseCurve(IRevitFamilyInstance target, double? topLevelElevation, double topLevelOffset) { Base baseGeometry = _locationConverter.Convert(target.Location); ICurve? baseCurve = baseGeometry as ICurve; @@ -110,7 +132,12 @@ out var level return new SOG.Line( basePoint, - new SOG.Point(basePoint.x, basePoint.y, topLevelElevation + topLevelOffset, _contextStack.Current.SpeckleUnits), + new SOG.Point( + basePoint.x, + basePoint.y, + topLevelElevation ?? 0 + topLevelOffset, + _contextStack.Current.SpeckleUnits + ), _contextStack.Current.SpeckleUnits ); } diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/PointCloudToSpeckleConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/PointCloudToSpeckleConverter.cs index ee5b81e95d..c552e7dbdf 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/PointCloudToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/PointCloudToSpeckleConverter.cs @@ -37,7 +37,7 @@ public SOG.Pointcloud Convert(IRevitPointCloudInstance target) { var minPlane = _revitPlaneUtils.CreateByNormalAndOrigin( _revitxyzUtils.BasisZ, - transform.OfPoint(boundingBox.Min) + transform.OfPoint(boundingBox.NotNull().Min) ); var filter = _revitFilterFactory.CreateMultiPlaneFilter(minPlane); var points = target.GetPoints(filter, 0.0001, 999999); // max limit is 1 mil but 1000000 throws error diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/RevitRootElementProvider.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/RevitRootElementProvider.cs new file mode 100644 index 0000000000..65aeca21da --- /dev/null +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/RevitRootElementProvider.cs @@ -0,0 +1,11 @@ +using Speckle.Converters.Common; +using Speckle.Revit.Interfaces; + +namespace Speckle.Converters.RevitShared; + +public class RevitRootElementProvider : IRootElementProvider +{ + private static readonly Type s_wrappedElementType = typeof(IRevitElement); + + public Type GetRootType() => s_wrappedElementType; +} diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common.Tests/FakeType.cs b/DUI3-DX/Sdk/Speckle.Converters.Common.Tests/FakeType.cs new file mode 100644 index 0000000000..517313bd4b --- /dev/null +++ b/DUI3-DX/Sdk/Speckle.Converters.Common.Tests/FakeType.cs @@ -0,0 +1,109 @@ +using System.Diagnostics.CodeAnalysis; +using System.Globalization; +using System.Reflection; + +namespace Speckle.Converters.Common.Tests; + +public class FakeType : Type +{ + public FakeType(string name) + { + Name = name; + } + + public override object[] GetCustomAttributes(bool inherit) => throw new NotImplementedException(); + + public override bool IsDefined(Type attributeType, bool inherit) => throw new NotImplementedException(); + + public override ConstructorInfo[] GetConstructors(BindingFlags bindingAttr) => throw new NotImplementedException(); + + public override Type GetInterface(string name, bool ignoreCase) => throw new NotImplementedException(); + + public override Type[] GetInterfaces() => throw new NotImplementedException(); + + public override EventInfo GetEvent(string name, BindingFlags bindingAttr) => throw new NotImplementedException(); + + public override EventInfo[] GetEvents(BindingFlags bindingAttr) => throw new NotImplementedException(); + + public override Type[] GetNestedTypes(BindingFlags bindingAttr) => throw new NotImplementedException(); + + public override Type GetNestedType(string name, BindingFlags bindingAttr) => throw new NotImplementedException(); + + public override Type GetElementType() => throw new NotImplementedException(); + + protected override bool HasElementTypeImpl() => throw new NotImplementedException(); + + protected override PropertyInfo GetPropertyImpl( + string name, + BindingFlags bindingAttr, + Binder binder, + Type returnType, + Type[] types, + ParameterModifier[] modifiers + ) => throw new NotImplementedException(); + + public override PropertyInfo[] GetProperties(BindingFlags bindingAttr) => throw new NotImplementedException(); + + protected override MethodInfo GetMethodImpl( + string name, + BindingFlags bindingAttr, + Binder binder, + CallingConventions callConvention, + Type[] types, + ParameterModifier[] modifiers + ) => throw new NotImplementedException(); + + public override MethodInfo[] GetMethods(BindingFlags bindingAttr) => throw new NotImplementedException(); + + public override FieldInfo GetField(string name, BindingFlags bindingAttr) => throw new NotImplementedException(); + + public override FieldInfo[] GetFields(BindingFlags bindingAttr) => throw new NotImplementedException(); + + public override MemberInfo[] GetMembers(BindingFlags bindingAttr) => throw new NotImplementedException(); + + protected override TypeAttributes GetAttributeFlagsImpl() => throw new NotImplementedException(); + + protected override bool IsArrayImpl() => throw new NotImplementedException(); + + protected override bool IsByRefImpl() => throw new NotImplementedException(); + + protected override bool IsPointerImpl() => throw new NotImplementedException(); + + protected override bool IsPrimitiveImpl() => throw new NotImplementedException(); + + protected override bool IsCOMObjectImpl() => throw new NotImplementedException(); + + public override object InvokeMember( + string name, + BindingFlags invokeAttr, + Binder binder, + object target, + object[] args, + ParameterModifier[] modifiers, + CultureInfo culture, + string[] namedParameters + ) => throw new NotImplementedException(); + + public override Type UnderlyingSystemType { get; } + + protected override ConstructorInfo GetConstructorImpl( + BindingFlags bindingAttr, + Binder binder, + CallingConventions callConvention, + Type[] types, + ParameterModifier[] modifiers + ) => throw new NotImplementedException(); + + public override string Name { get; } + + [SuppressMessage("Naming", "CA1720:Identifier contains type name")] + public override Guid GUID { get; } = Guid.Empty; + public override Module Module { get; } + public override Assembly Assembly { get; } + public override string FullName { get; } + public override string Namespace { get; } + public override string AssemblyQualifiedName { get; } + public override Type BaseType { get; } + + public override object[] GetCustomAttributes(Type attributeType, bool inherit) => throw new NotImplementedException(); +} diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common.Tests/RootToSpeckleConverterTests.cs b/DUI3-DX/Sdk/Speckle.Converters.Common.Tests/RootToSpeckleConverterTests.cs new file mode 100644 index 0000000000..a94bf874e4 --- /dev/null +++ b/DUI3-DX/Sdk/Speckle.Converters.Common.Tests/RootToSpeckleConverterTests.cs @@ -0,0 +1,67 @@ +using FluentAssertions; +using Moq; +using NUnit.Framework; +using Speckle.Core.Models; +using Speckle.Revit.Interfaces; + +namespace Speckle.Converters.Common.Tests; + +public class RootToSpeckleConverterTests +{ + private readonly MockRepository _repository = new(MockBehavior.Strict); + + private readonly Mock _rootConvertManager; + private readonly Mock _proxyMapper; + private readonly Mock _rootElementProvider; + + public RootToSpeckleConverterTests() + { + _rootConvertManager = _repository.Create(); + _proxyMapper = _repository.Create(); + _rootElementProvider = _repository.Create(); + } + + [TearDown] + public void Verify() => _repository.VerifyAll(); + + [Test] + public void Convert_BaseType() + { + try + { + Type baseType = new FakeType("baseType"); + Type hostType = new FakeType("hostType"); + + object target = new(); + Type targetType = new FakeType("targetType"); + + object wrappedTarget = new(); + Base converted = new(); + + _rootConvertManager.Setup(x => x.GetTargetType(target)).Returns(targetType); + _rootElementProvider.Setup(x => x.GetRootType()).Returns(baseType); + _proxyMapper.Setup(x => x.GetHostTypeFromMappedType(baseType)).Returns(hostType); + + _proxyMapper.Setup(x => x.GetMappedTypeFromHostType(targetType)).Returns((Type?)null); + _proxyMapper.Setup(x => x.GetMappedTypeFromProxyType(targetType)).Returns((Type?)null); + + _rootConvertManager.Setup(x => x.IsSubClass(baseType, targetType)).Returns(true); + _proxyMapper.Setup(x => x.CreateProxy(baseType, target)).Returns(wrappedTarget); + _rootConvertManager.Setup(x => x.Convert(baseType, wrappedTarget)).Returns(converted); + + var rootToSpeckleConverter = new RootToSpeckleConverter( + _proxyMapper.Object, + _rootConvertManager.Object, + _rootElementProvider.Object + ); + var testConverted = rootToSpeckleConverter.Convert(target); + + testConverted.Should().BeSameAs(converted); + } + catch (Exception e) + { + Console.WriteLine(e); + throw; + } + } +} diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common.Tests/Speckle.Converters.Common.Tests.csproj b/DUI3-DX/Sdk/Speckle.Converters.Common.Tests/Speckle.Converters.Common.Tests.csproj new file mode 100644 index 0000000000..e687d74095 --- /dev/null +++ b/DUI3-DX/Sdk/Speckle.Converters.Common.Tests/Speckle.Converters.Common.Tests.csproj @@ -0,0 +1,25 @@ + + + + net48 + x64 + false + true + + + + + + + + + + + + + + + + + + diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common.Tests/packages.lock.json b/DUI3-DX/Sdk/Speckle.Converters.Common.Tests/packages.lock.json new file mode 100644 index 0000000000..745cd3ba1e --- /dev/null +++ b/DUI3-DX/Sdk/Speckle.Converters.Common.Tests/packages.lock.json @@ -0,0 +1,458 @@ +{ + "version": 1, + "dependencies": { + ".NETFramework,Version=v4.8": { + "coverlet.collector": { + "type": "Direct", + "requested": "[6.0.2, )", + "resolved": "6.0.2", + "contentHash": "bJShQ6uWRTQ100ZeyiMqcFlhP7WJ+bCuabUs885dJiBEzMsJMSFr7BOyeCw4rgvQokteGi5rKQTlkhfQPUXg2A==" + }, + "FluentAssertions": { + "type": "Direct", + "requested": "[6.12.0, )", + "resolved": "6.12.0", + "contentHash": "ZXhHT2YwP9lajrwSKbLlFqsmCCvFJMoRSK9t7sImfnCyd0OB3MhgxdoMcVqxbq1iyxD6mD2fiackWmBb7ayiXQ==", + "dependencies": { + "System.Threading.Tasks.Extensions": "4.5.0" + } + }, + "Microsoft.NET.Test.Sdk": { + "type": "Direct", + "requested": "[17.10.0, )", + "resolved": "17.10.0", + "contentHash": "0/2HeACkaHEYU3wc83YlcD2Fi4LMtECJjqrtvw0lPi9DCEa35zSPt1j4fuvM8NagjDqJuh1Ja35WcRtn1Um6/A==", + "dependencies": { + "Microsoft.CodeCoverage": "17.10.0" + } + }, + "Moq": { + "type": "Direct", + "requested": "[4.20.70, )", + "resolved": "4.20.70", + "contentHash": "4rNnAwdpXJBuxqrOCzCyICXHSImOTRktCgCWXWykuF1qwoIsVvEnR7PjbMk/eLOxWvhmj5Kwt+kDV3RGUYcNwg==", + "dependencies": { + "Castle.Core": "5.1.1", + "System.Threading.Tasks.Extensions": "4.5.4" + } + }, + "NUnit": { + "type": "Direct", + "requested": "[4.1.0, )", + "resolved": "4.1.0", + "contentHash": "MT/DpAhjtiytzhTgTqIhBuWx4y26PKfDepYUHUM+5uv4TsryHC2jwFo5e6NhWkApCm/G6kZ80dRjdJFuAxq3rg==", + "dependencies": { + "System.Threading.Tasks.Extensions": "4.5.4" + } + }, + "NUnit.Analyzers": { + "type": "Direct", + "requested": "[4.2.0, )", + "resolved": "4.2.0", + "contentHash": "4fJojPkzdoa4nB2+p6U+fITvPnVvwWSnsmiJ/Dl30xqiL3oxNbYvfeSLVd91hOmEjoUqSwN3Z7j1aFedjqWbUA==" + }, + "PolySharp": { + "type": "Direct", + "requested": "[1.14.1, )", + "resolved": "1.14.1", + "contentHash": "mOOmFYwad3MIOL14VCjj02LljyF1GNw1wP0YVlxtcPvqdxjGGMNdNJJxHptlry3MOd8b40Flm8RPOM8JOlN2sQ==" + }, + "Speckle.InterfaceGenerator": { + "type": "Direct", + "requested": "[0.9.5, )", + "resolved": "0.9.5", + "contentHash": "oU/L7pN1R7q8KkbrpQ3WJnHirPHqn+9DEA7asOcUiggV5dzVg1A/VYs7GOSusD24njxXh03tE3a2oTLOjt3cVg==" + }, + "Speckle.Revit2023.Interfaces": { + "type": "Direct", + "requested": "[0.1.1-preview.0.24, )", + "resolved": "0.1.1-preview.0.24", + "contentHash": "BSVpOUJc9g6ISrw8GxvtkglTlITpHEDYNOhxv1ZPbckBsI0yO36JiphhQV4q57ERqD9PpCozUJkVhlCaxWeS6A==" + }, + "Castle.Core": { + "type": "Transitive", + "resolved": "5.1.1", + "contentHash": "rpYtIczkzGpf+EkZgDr9CClTdemhsrwA/W5hMoPjLkRFnXzH44zDLoovXeKtmxb1ykXK9aJVODSpiJml8CTw2g==" + }, + "GraphQL.Client": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "8yPNBbuVBpTptivyAlak4GZvbwbUcjeQTL4vN1HKHRuOykZ4r7l5fcLS6vpyPyLn0x8FsL31xbOIKyxbmR9rbA==", + "dependencies": { + "GraphQL.Client.Abstractions": "6.0.0", + "GraphQL.Client.Abstractions.Websocket": "6.0.0", + "System.Net.WebSockets.Client.Managed": "1.0.22", + "System.Reactive": "5.0.0" + } + }, + "GraphQL.Client.Abstractions": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "h7uzWFORHZ+CCjwr/ThAyXMr0DPpzEANDa4Uo54wqCQ+j7qUKwqYTgOrb1W40sqbvNaZm9v/X7It31SUw0maHA==", + "dependencies": { + "GraphQL.Primitives": "6.0.0" + } + }, + "GraphQL.Client.Abstractions.Websocket": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "Nr9bPf8gIOvLuXpqEpqr9z9jslYFJOvd0feHth3/kPqeR3uMbjF5pjiwh4jxyMcxHdr8Pb6QiXkV3hsSyt0v7A==", + "dependencies": { + "GraphQL.Client.Abstractions": "6.0.0" + } + }, + "GraphQL.Primitives": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "yg72rrYDapfsIUrul7aF6wwNnTJBOFvuA9VdDTQpPa8AlAriHbufeXYLBcodKjfUdkCnaiggX1U/nEP08Zb5GA==" + }, + "Microsoft.Bcl.AsyncInterfaces": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "W8DPQjkMScOMTtJbPwmPyj9c3zYSFGawDW3jwlBOOsnY+EzZFLgNQ/UMkK35JmkNOVPdCyPr2Tw7Vv9N+KA3ZQ==", + "dependencies": { + "System.Threading.Tasks.Extensions": "4.5.4" + } + }, + "Microsoft.CodeCoverage": { + "type": "Transitive", + "resolved": "17.10.0", + "contentHash": "yC7oSlnR54XO5kOuHlVOKtxomNNN1BWXX8lK1G2jaPXT9sUok7kCOoA4Pgs0qyFaCtMrNsprztYMeoEGqCm4uA==" + }, + "Microsoft.CSharp": { + "type": "Transitive", + "resolved": "4.7.0", + "contentHash": "pTj+D3uJWyN3My70i2Hqo+OXixq3Os2D1nJ2x92FFo6sk8fYS1m1WLNTs0Dc1uPaViH0YvEEwvzddQ7y4rhXmA==" + }, + "Microsoft.Data.Sqlite": { + "type": "Transitive", + "resolved": "7.0.5", + "contentHash": "KGxbPeWsQMnmQy43DSBxAFtHz3l2JX8EWBSGUCvT3CuZ8KsuzbkqMIJMDOxWtG8eZSoCDI04aiVQjWuuV8HmSw==", + "dependencies": { + "Microsoft.Data.Sqlite.Core": "7.0.5", + "SQLitePCLRaw.bundle_e_sqlite3": "2.1.4" + } + }, + "Microsoft.Data.Sqlite.Core": { + "type": "Transitive", + "resolved": "7.0.5", + "contentHash": "FTerRmQPqHrCrnoUzhBu+E+1DNGwyrAMLqHkAqOOOu5pGfyMOj8qQUBxI/gDtWtG11p49UxSfWmBzRNlwZqfUg==", + "dependencies": { + "SQLitePCLRaw.core": "2.1.4" + } + }, + "Microsoft.Extensions.Logging.Abstractions": { + "type": "Transitive", + "resolved": "7.0.0", + "contentHash": "kmn78+LPVMOWeITUjIlfxUPDsI0R6G0RkeAMBmQxAJ7vBJn4q2dTva7pWi65ceN5vPGjJ9q/Uae2WKgvfktJAw==", + "dependencies": { + "System.Buffers": "4.5.1", + "System.Memory": "4.5.5" + } + }, + "Polly": { + "type": "Transitive", + "resolved": "7.2.3", + "contentHash": "DeCY0OFbNdNxsjntr1gTXHJ5pKUwYzp04Er2LLeN3g6pWhffsGuKVfMBLe1lw7x76HrPkLxKEFxBlpRxS2nDEQ==" + }, + "Polly.Contrib.WaitAndRetry": { + "type": "Transitive", + "resolved": "1.1.1", + "contentHash": "1MUQLiSo4KDkQe6nzQRhIU05lm9jlexX5BVsbuw0SL82ynZ+GzAHQxJVDPVBboxV37Po3SG077aX8DuSy8TkaA==" + }, + "Polly.Extensions.Http": { + "type": "Transitive", + "resolved": "3.0.0", + "contentHash": "drrG+hB3pYFY7w1c3BD+lSGYvH2oIclH8GRSehgfyP5kjnFnHKQuuBhuHLv+PWyFuaTDyk/vfRpnxOzd11+J8g==", + "dependencies": { + "Polly": "7.1.0" + } + }, + "Sentry": { + "type": "Transitive", + "resolved": "3.33.0", + "contentHash": "8vbD2o6IR2wrRrkSiRbnodWGWUOqIlwYtzpjvPNOb5raJdOf+zxMwfS8f6nx9bmrTTfDj7KrCB8C/5OuicAc8A==", + "dependencies": { + "System.Reflection.Metadata": "5.0.0", + "System.Runtime.InteropServices.RuntimeInformation": "4.3.0", + "System.Text.Json": "5.0.2" + } + }, + "Sentry.Serilog": { + "type": "Transitive", + "resolved": "3.33.0", + "contentHash": "V8BU7QGWg2qLYfNPqtuTBhC1opysny5l+Ifp6J6PhOeAxU0FssR7nYfbJVetrnLIoh2rd3DlJ6hHYYQosQYcUQ==", + "dependencies": { + "Sentry": "3.33.0", + "Serilog": "2.7.1" + } + }, + "Serilog": { + "type": "Transitive", + "resolved": "2.12.0", + "contentHash": "xaiJLIdu6rYMKfQMYUZgTy8YK7SMZjB4Yk50C/u//Z4OsvxkUfSPJy4nknfvwAC34yr13q7kcyh4grbwhSxyZg==" + }, + "Serilog.Enrichers.ClientInfo": { + "type": "Transitive", + "resolved": "1.3.0", + "contentHash": "mTc7PM+wC9Hr7LWSwqt5mmnlAr7RJs+eTb3PGPRhwdOackk95MkhUZognuxXEdlW19HAFNmEBTSBY5DfLwM8jQ==", + "dependencies": { + "Serilog": "2.4.0" + } + }, + "Serilog.Enrichers.GlobalLogContext": { + "type": "Transitive", + "resolved": "3.0.0", + "contentHash": "IIZcj5mAUVhIl/NTA+YI2KC+sPDzcwvs0ZMHH42jsPfl1a4LVX7ohVpw5UK+e3GxuV3Nv239Il5oM2peUIl44g==", + "dependencies": { + "Serilog": "2.12.0" + } + }, + "Serilog.Exceptions": { + "type": "Transitive", + "resolved": "8.4.0", + "contentHash": "nc/+hUw3lsdo0zCj0KMIybAu7perMx79vu72w0za9Nsi6mWyNkGXxYxakAjWB7nEmYL6zdmhEQRB4oJ2ALUeug==", + "dependencies": { + "Serilog": "2.8.0" + } + }, + "Serilog.Formatting.Compact": { + "type": "Transitive", + "resolved": "1.1.0", + "contentHash": "pNroKVjo+rDqlxNG5PXkRLpfSCuDOBY0ri6jp9PLe505ljqwhwZz8ospy2vWhQlFu5GkIesh3FcDs4n7sWZODA==", + "dependencies": { + "Serilog": "2.8.0" + } + }, + "Serilog.Sinks.Console": { + "type": "Transitive", + "resolved": "4.1.0", + "contentHash": "K6N5q+5fetjnJPvCmkWOpJ/V8IEIoMIB1s86OzBrbxwTyHxdx3pmz4H+8+O/Dc/ftUX12DM1aynx/dDowkwzqg==", + "dependencies": { + "Serilog": "2.10.0" + } + }, + "Serilog.Sinks.File": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "uwV5hdhWPwUH1szhO8PJpFiahqXmzPzJT/sOijH/kFgUx+cyoDTMM8MHD0adw9+Iem6itoibbUXHYslzXsLEAg==", + "dependencies": { + "Serilog": "2.10.0" + } + }, + "Serilog.Sinks.PeriodicBatching": { + "type": "Transitive", + "resolved": "3.1.0", + "contentHash": "NDWR7m3PalVlGEq3rzoktrXikjFMLmpwF0HI4sowo8YDdU+gqPlTHlDQiOGxHfB0sTfjPA9JjA7ctKG9zqjGkw==", + "dependencies": { + "Serilog": "2.0.0" + } + }, + "Serilog.Sinks.Seq": { + "type": "Transitive", + "resolved": "5.2.2", + "contentHash": "1Csmo5ua7NKUe0yXUx+zsRefjAniPWcXFhUXxXG8pwo0iMiw2gjn9SOkgYnnxbgWqmlGv236w0N/dHc2v5XwMg==", + "dependencies": { + "Serilog": "2.12.0", + "Serilog.Formatting.Compact": "1.1.0", + "Serilog.Sinks.File": "5.0.0", + "Serilog.Sinks.PeriodicBatching": "3.1.0" + } + }, + "SerilogTimings": { + "type": "Transitive", + "resolved": "3.0.1", + "contentHash": "Zs28eTgszAMwpIrbBnWHBI50yuxL50p/dmAUWmy75+axdZYK/Sjm5/5m1N/CisR8acJUhTVcjPZrsB1P5iv0Uw==", + "dependencies": { + "Serilog": "2.10.0" + } + }, + "Speckle.Newtonsoft.Json": { + "type": "Transitive", + "resolved": "13.0.2", + "contentHash": "g1BejUZwax5PRfL6xHgLEK23sqHWOgOj9hE7RvfRRlN00AGt8GnPYt8HedSK7UB3HiRW8zCA9Pn0iiYxCK24BA==" + }, + "SQLitePCLRaw.bundle_e_sqlite3": { + "type": "Transitive", + "resolved": "2.1.4", + "contentHash": "EWI1olKDjFEBMJu0+3wuxwziIAdWDVMYLhuZ3Qs84rrz+DHwD00RzWPZCa+bLnHCf3oJwuFZIRsHT5p236QXww==", + "dependencies": { + "SQLitePCLRaw.lib.e_sqlite3": "2.1.4", + "SQLitePCLRaw.provider.dynamic_cdecl": "2.1.4" + } + }, + "SQLitePCLRaw.core": { + "type": "Transitive", + "resolved": "2.1.4", + "contentHash": "inBjvSHo9UDKneGNzfUfDjK08JzlcIhn1+SP5Y3m6cgXpCxXKCJDy6Mka7LpgSV+UZmKSnC8rTwB0SQ0xKu5pA==", + "dependencies": { + "System.Memory": "4.5.3" + } + }, + "SQLitePCLRaw.lib.e_sqlite3": { + "type": "Transitive", + "resolved": "2.1.4", + "contentHash": "2C9Q9eX7CPLveJA0rIhf9RXAvu+7nWZu1A2MdG6SD/NOu26TakGgL1nsbc0JAspGijFOo3HoN79xrx8a368fBg==" + }, + "SQLitePCLRaw.provider.dynamic_cdecl": { + "type": "Transitive", + "resolved": "2.1.4", + "contentHash": "ZsaKKhgYF9B1fvcnOGKl3EycNAwd9CRWX7v0rEfuPWhQQ5Jjpvf2VEHahiLIGHio3hxi3EIKFJw9KvyowWOUAw==", + "dependencies": { + "SQLitePCLRaw.core": "2.1.4" + } + }, + "System.Buffers": { + "type": "Transitive", + "resolved": "4.5.1", + "contentHash": "Rw7ijyl1qqRS0YQD/WycNst8hUUMgrMH4FCn1nNm27M4VxchZ1js3fVjQaANHO5f3sN4isvP4a+Met9Y4YomAg==" + }, + "System.Collections.Immutable": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "FXkLXiK0sVVewcso0imKQoOxjoPAj42R8HtjjbSjVPAzwDfzoyoznWxgA3c38LDbN9SJux1xXoXYAhz98j7r2g==", + "dependencies": { + "System.Memory": "4.5.4" + } + }, + "System.DoubleNumerics": { + "type": "Transitive", + "resolved": "3.1.3", + "contentHash": "KRKEM/L3KBodjA9VOg3EifFVWUY6EOqaMB05UvPEDm7Zeby/kZW+4kdWUEPzW6xtkwf46p661L9NrbeeQhtLzw==", + "dependencies": { + "NETStandard.Library": "1.6.1" + } + }, + "System.Memory": { + "type": "Transitive", + "resolved": "4.5.5", + "contentHash": "XIWiDvKPXaTveaB7HVganDlOCRoj03l+jrwNvcge/t8vhGYKvqV+dMv6G4SAX2NoNmN0wZfVPTAlFwZcZvVOUw==", + "dependencies": { + "System.Buffers": "4.5.1", + "System.Numerics.Vectors": "4.5.0", + "System.Runtime.CompilerServices.Unsafe": "4.5.3" + } + }, + "System.Net.WebSockets.Client.Managed": { + "type": "Transitive", + "resolved": "1.0.22", + "contentHash": "WqEOxPlXjuZrIjUtXNE9NxEfU/n5E35iV2PtoZdJSUC4tlrqwHnTee+wvMIM4OUaJWmwrymeqcgYrE0IkGAgLA==", + "dependencies": { + "System.Buffers": "4.4.0", + "System.Numerics.Vectors": "4.4.0" + } + }, + "System.Numerics.Vectors": { + "type": "Transitive", + "resolved": "4.5.0", + "contentHash": "QQTlPTl06J/iiDbJCiepZ4H//BVraReU4O4EoRw1U02H5TLUIT7xn3GnDp9AXPSlJUDyFs4uWjWafNX6WrAojQ==" + }, + "System.Reactive": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "erBZjkQHWL9jpasCE/0qKAryzVBJFxGHVBAvgRN1bzM0q2s1S4oYREEEL0Vb+1kA/6BKb5FjUZMp5VXmy+gzkQ==", + "dependencies": { + "System.Threading.Tasks.Extensions": "4.5.4" + } + }, + "System.Reflection.Metadata": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "5NecZgXktdGg34rh1OenY1rFNDCI8xSjFr+Z4OU4cU06AQHUdRnIIEeWENu3Wl4YowbzkymAIMvi3WyK9U53pQ==", + "dependencies": { + "System.Collections.Immutable": "5.0.0" + } + }, + "System.Runtime.CompilerServices.Unsafe": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "ZD9TMpsmYJLrxbbmdvhwt9YEgG5WntEnZ/d1eH8JBX9LBp+Ju8BSBhUGbZMNVHHomWo2KVImJhTDl2hIgw/6MA==" + }, + "System.Runtime.InteropServices.RuntimeInformation": { + "type": "Transitive", + "resolved": "4.3.0", + "contentHash": "cbz4YJMqRDR7oLeMRbdYv7mYzc++17lNhScCX0goO2XpGWdvAt60CGN+FHdePUEHCe/Jy9jUlvNAiNdM+7jsOw==" + }, + "System.Text.Encodings.Web": { + "type": "Transitive", + "resolved": "5.0.1", + "contentHash": "KmJ+CJXizDofbq6mpqDoRRLcxgOd2z9X3XoFNULSbvbqVRZkFX3istvr+MUjL6Zw1RT+RNdoI4GYidIINtgvqQ==", + "dependencies": { + "System.Buffers": "4.5.1", + "System.Memory": "4.5.4" + } + }, + "System.Text.Json": { + "type": "Transitive", + "resolved": "5.0.2", + "contentHash": "I47dVIGiV6SfAyppphxqupertT/5oZkYLDCX6vC3HpOI4ZLjyoKAreUoem2ie6G0RbRuFrlqz/PcTQjfb2DOfQ==", + "dependencies": { + "Microsoft.Bcl.AsyncInterfaces": "5.0.0", + "System.Buffers": "4.5.1", + "System.Memory": "4.5.4", + "System.Numerics.Vectors": "4.5.0", + "System.Runtime.CompilerServices.Unsafe": "5.0.0", + "System.Text.Encodings.Web": "5.0.1", + "System.Threading.Tasks.Extensions": "4.5.4", + "System.ValueTuple": "4.5.0" + } + }, + "System.Threading.Tasks.Extensions": { + "type": "Transitive", + "resolved": "4.5.4", + "contentHash": "zteT+G8xuGu6mS+mzDzYXbzS7rd3K6Fjb9RiZlYlJPam2/hU7JCBZBVEcywNuR+oZ1ncTvc/cq0faRr3P01OVg==", + "dependencies": { + "System.Runtime.CompilerServices.Unsafe": "4.5.3" + } + }, + "System.ValueTuple": { + "type": "Transitive", + "resolved": "4.5.0", + "contentHash": "okurQJO6NRE/apDIP23ajJ0hpiNmJ+f0BwOlB/cSqTLQlw5upkf+5+96+iG2Jw40G1fCVCyPz/FhIABUjMR+RQ==" + }, + "speckle.autofac": { + "type": "Project", + "dependencies": { + "Microsoft.Extensions.Logging.Abstractions": "[7.0.0, )", + "Speckle.Core": "[2.0.999-local, )" + } + }, + "speckle.converters.common": { + "type": "Project", + "dependencies": { + "Speckle.Autofac": "[2.0.999-local, )", + "Speckle.Objects": "[2.0.999-local, )", + "Speckle.Revit2023.Interfaces": "[0.1.1-preview.0.24, )" + } + }, + "Speckle.Core": { + "type": "Project", + "dependencies": { + "GraphQL.Client": "[6.0.0, )", + "Microsoft.CSharp": "[4.7.0, )", + "Microsoft.Data.Sqlite": "[7.0.5, )", + "Polly": "[7.2.3, )", + "Polly.Contrib.WaitAndRetry": "[1.1.1, )", + "Polly.Extensions.Http": "[3.0.0, )", + "Sentry": "[3.33.0, )", + "Sentry.Serilog": "[3.33.0, )", + "Serilog": "[2.12.0, )", + "Serilog.Enrichers.ClientInfo": "[1.3.0, )", + "Serilog.Enrichers.GlobalLogContext": "[3.0.0, )", + "Serilog.Exceptions": "[8.4.0, )", + "Serilog.Sinks.Console": "[4.1.0, )", + "Serilog.Sinks.Seq": "[5.2.2, )", + "SerilogTimings": "[3.0.1, )", + "Speckle.Newtonsoft.Json": "[13.0.2, )", + "System.DoubleNumerics": "[3.1.3, )" + } + }, + "Speckle.Objects": { + "type": "Project", + "dependencies": { + "Speckle.Core": "[2.0.999-local, )" + } + } + } + } +} \ No newline at end of file diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common/IRootElementProvider.cs b/DUI3-DX/Sdk/Speckle.Converters.Common/IRootElementProvider.cs new file mode 100644 index 0000000000..e183c154af --- /dev/null +++ b/DUI3-DX/Sdk/Speckle.Converters.Common/IRootElementProvider.cs @@ -0,0 +1,6 @@ +namespace Speckle.Converters.Common; + +public interface IRootElementProvider +{ + Type GetRootType(); +} diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common/RootConvertManager.cs b/DUI3-DX/Sdk/Speckle.Converters.Common/RootConvertManager.cs new file mode 100644 index 0000000000..4ae930fa1c --- /dev/null +++ b/DUI3-DX/Sdk/Speckle.Converters.Common/RootConvertManager.cs @@ -0,0 +1,42 @@ +using Speckle.Autofac.DependencyInjection; +using Speckle.Converters.Common.Objects; +using Speckle.Core.Models; +using Speckle.InterfaceGenerator; + +namespace Speckle.Converters.Common; + +[GenerateAutoInterface] +public class RootConvertManager : IRootConvertManager +{ + private readonly IFactory _toSpeckle; + + public RootConvertManager(IFactory toSpeckle) + { + _toSpeckle = toSpeckle; + } + + public Type GetTargetType(object target) => target.GetType(); + + public bool IsSubClass(Type baseType, Type childType) => baseType.IsAssignableFrom(childType); + + public Base Convert(Type type, object obj) + { + try + { + var objectConverter = _toSpeckle.ResolveInstance(type.Name); //poc: would be nice to have supertypes resolve + + if (objectConverter == null) + { + throw new NotSupportedException($"No conversion found for {type.Name}"); + } + var convertedObject = objectConverter.Convert(obj); + + return convertedObject; + } + catch (SpeckleConversionException e) + { + Console.WriteLine(e); + throw; // Just rethrowing for now, Logs may be needed here. + } + } +} diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common/RootToSpeckleConverter.cs b/DUI3-DX/Sdk/Speckle.Converters.Common/RootToSpeckleConverter.cs index 04d87e8349..fac0af321d 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common/RootToSpeckleConverter.cs +++ b/DUI3-DX/Sdk/Speckle.Converters.Common/RootToSpeckleConverter.cs @@ -1,5 +1,3 @@ -using Speckle.Autofac.DependencyInjection; -using Speckle.Converters.Common.Objects; using Speckle.Core.Models; using Speckle.InterfaceGenerator; using Speckle.Revit.Interfaces; @@ -9,40 +7,41 @@ namespace Speckle.Converters.Common; [GenerateAutoInterface] public class RootToSpeckleConverter : IRootToSpeckleConverter { - private readonly IFactory _toSpeckle; + private readonly IRootConvertManager _rootConvertManager; private readonly IProxyMapper _proxyMapper; + private readonly IRootElementProvider _rootElementProvider; - public RootToSpeckleConverter(IFactory toSpeckle, IProxyMapper proxyMapper) + private readonly Type _revitElementType; + + public RootToSpeckleConverter( + IProxyMapper proxyMapper, + IRootConvertManager rootConvertManager, + IRootElementProvider rootElementProvider + ) { - _toSpeckle = toSpeckle; _proxyMapper = proxyMapper; + _rootConvertManager = rootConvertManager; + _rootElementProvider = rootElementProvider; + _revitElementType = _proxyMapper.GetHostTypeFromMappedType(_rootElementProvider.GetRootType()).NotNull(); } public Base Convert(object target) { - Type revitType = target.GetType(); + Type revitType = _rootConvertManager.GetTargetType(target); var wrapper = _proxyMapper.WrapIfExists(revitType, target); if (wrapper == null) { - throw new NotSupportedException($"No wrapper found for Revit type: {revitType.Name}"); - } - var (wrappedType, wrappedObject) = wrapper.Value; - try - { - var objectConverter = _toSpeckle.ResolveInstance(wrappedType.Name); //poc: would be nice to have supertypes resolve - - if (objectConverter == null) + //try to fallback to element type + if (_rootConvertManager.IsSubClass(_revitElementType, revitType)) { - throw new NotSupportedException($"No conversion found for {wrappedType.Name}"); + return _rootConvertManager.Convert( + _rootElementProvider.GetRootType(), + _proxyMapper.CreateProxy(_rootElementProvider.GetRootType(), target) + ); } - var convertedObject = objectConverter.Convert(wrappedObject); - - return convertedObject; - } - catch (SpeckleConversionException e) - { - Console.WriteLine(e); - throw; // Just rethrowing for now, Logs may be needed here. + throw new NotSupportedException($"No wrapper found for Revit type: {revitType.Name}"); } + var (wrappedType, wrappedObject) = wrapper; + return _rootConvertManager.Convert(wrappedType, wrappedObject); } } diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common/Speckle.Converters.Common.csproj b/DUI3-DX/Sdk/Speckle.Converters.Common/Speckle.Converters.Common.csproj index 761f021575..07793ee159 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common/Speckle.Converters.Common.csproj +++ b/DUI3-DX/Sdk/Speckle.Converters.Common/Speckle.Converters.Common.csproj @@ -3,12 +3,13 @@ netstandard2.0 - - - + + + + From e31969f19985fb3fdc00ed8d1e49951d9e3d52fb Mon Sep 17 00:00:00 2001 From: KatKatKateryna <89912278+KatKatKateryna@users.noreply.github.com> Date: Wed, 19 Jun 2024 22:43:56 +0800 Subject: [PATCH 237/261] better fallback reporting (#3522) * better fallback reporting * avoid Chars being recognized as IEnumerable --- .../ToHost/ConverterWithFallback.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/ToHost/ConverterWithFallback.cs b/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/ToHost/ConverterWithFallback.cs index 9d972cdd99..1d143ef8f9 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/ToHost/ConverterWithFallback.cs +++ b/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/ToHost/ConverterWithFallback.cs @@ -1,4 +1,5 @@ -using Speckle.Converters.Common.Objects; +using System.Collections; +using Speckle.Converters.Common.Objects; using Speckle.Core.Models; using Speckle.Core.Models.Extensions; @@ -49,6 +50,10 @@ public object Convert(Base target) var displayValue = target.TryGetDisplayValue(); if (displayValue != null) { + if (displayValue is IList && !displayValue.Any()) + { + throw new NotSupportedException($"No display value found for {type}"); + } return FallbackToDisplayValue(displayValue); } From cc81dc2de880d72332ee1d2e49113a1d67ea421d Mon Sep 17 00:00:00 2001 From: Adam Hathcock Date: Thu, 20 Jun 2024 10:00:24 +0100 Subject: [PATCH 238/261] enable lock files for dui3 (#3510) --- .github/workflows/ci.yml | 15 +- Build/Program.cs | 2 +- .../packages.lock.json | 486 ++++++++++ .../packages.lock.json | 530 +++++++++++ .../packages.lock.json | 573 ++++++++++++ .../packages.lock.json | 530 +++++++++++ .../packages.lock.json | 409 ++++++++ .../packages.lock.json | 390 ++++++++ .../packages.lock.json | 417 +++++++++ .../packages.lock.json | 395 ++++++++ .../packages.lock.json | 439 +++++++++ .../packages.lock.json | 390 ++++++++ .../packages.lock.json | 409 ++++++++ .../packages.lock.json | 395 ++++++++ .../packages.lock.json | 878 ++++++++++++++++++ .../Speckle.Connectors.DUI/packages.lock.json | 533 +++++++++++ DUI3-DX/Directory.Build.props | 1 + .../Sdk/Speckle.Autofac/packages.lock.json | 470 ++++++++++ .../packages.lock.json | 519 +++++++++++ .../packages.lock.json | 495 ++++++++++ .../packages.lock.json | 9 - .../packages.lock.json | 479 ++++++++++ 22 files changed, 8751 insertions(+), 13 deletions(-) create mode 100644 DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/packages.lock.json create mode 100644 DUI3-DX/Connectors/Autocad/Speckle.Connectors.Autocad2023/packages.lock.json create mode 100644 DUI3-DX/Connectors/Revit/Speckle.Connectors.Revit2023/packages.lock.json create mode 100644 DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/packages.lock.json create mode 100644 DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3.DependencyInjection/packages.lock.json create mode 100644 DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/packages.lock.json create mode 100644 DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2023.DependencyInjection/packages.lock.json create mode 100644 DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2023/packages.lock.json create mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/packages.lock.json create mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023/packages.lock.json create mode 100644 DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/packages.lock.json create mode 100644 DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/packages.lock.json create mode 100644 DUI3-DX/DUI3/Speckle.Connectors.DUI.WebView/packages.lock.json create mode 100644 DUI3-DX/DUI3/Speckle.Connectors.DUI/packages.lock.json create mode 100644 DUI3-DX/Sdk/Speckle.Autofac/packages.lock.json create mode 100644 DUI3-DX/Sdk/Speckle.Connectors.Utils/packages.lock.json create mode 100644 DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/packages.lock.json create mode 100644 DUI3-DX/Sdk/Speckle.Converters.Common/packages.lock.json diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a375a63a3a..9444fbb667 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,7 +12,7 @@ on: jobs: build: - runs-on: ubuntu-latest + runs-on: windows-latest outputs: version: ${{ steps.set-version.outputs.version }} steps: @@ -25,11 +25,20 @@ jobs: uses: actions/setup-dotnet@v4 with: dotnet-version: 8.0.2xx # Align with global.json (including roll forward rules) + + - name: Cache Nuget + uses: actions/cache@v4 + with: + path: ~/.nuget/packages + key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }} + restore-keys: | + ${{ runner.os }}-nuget- + - name: ⚒️ Run GitVersion - run: ./build.sh build-server-version + run: ./build.ps1 build-server-version - name: ⚒️ Run build - run: ./build.sh + run: ./build.ps1 - name: ⬆️ Upload artifacts uses: actions/upload-artifact@v4 diff --git a/Build/Program.cs b/Build/Program.cs index 815a086a70..a6d5ff9bc1 100644 --- a/Build/Program.cs +++ b/Build/Program.cs @@ -85,7 +85,7 @@ void RemoveDirectory(string d) Consts.Solutions, s => { - Run("dotnet", $"restore {s}"); + Run("dotnet", $"restore {s} --locked-mode"); } ); diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/packages.lock.json b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/packages.lock.json new file mode 100644 index 0000000000..3b14166e57 --- /dev/null +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/packages.lock.json @@ -0,0 +1,486 @@ +{ + "version": 1, + "dependencies": { + "net6.0-windows7.0": { + "Esri.ArcGISPro.Extensions30": { + "type": "Direct", + "requested": "[3.2.0.49743, )", + "resolved": "3.2.0.49743", + "contentHash": "fmnYm+mD14Cz0Uqh1ij37SfLJerkyFHK5581y5tXT/l3H2ZvUmVuuxjYquXzyzj9p7IexQzMW4xCpxe+mD922g==" + }, + "Microsoft.Extensions.Logging.Abstractions": { + "type": "Direct", + "requested": "[7.0.0, )", + "resolved": "7.0.0", + "contentHash": "kmn78+LPVMOWeITUjIlfxUPDsI0R6G0RkeAMBmQxAJ7vBJn4q2dTva7pWi65ceN5vPGjJ9q/Uae2WKgvfktJAw==" + }, + "PolySharp": { + "type": "Direct", + "requested": "[1.14.1, )", + "resolved": "1.14.1", + "contentHash": "mOOmFYwad3MIOL14VCjj02LljyF1GNw1wP0YVlxtcPvqdxjGGMNdNJJxHptlry3MOd8b40Flm8RPOM8JOlN2sQ==" + }, + "Speckle.InterfaceGenerator": { + "type": "Direct", + "requested": "[0.9.5, )", + "resolved": "0.9.5", + "contentHash": "oU/L7pN1R7q8KkbrpQ3WJnHirPHqn+9DEA7asOcUiggV5dzVg1A/VYs7GOSusD24njxXh03tE3a2oTLOjt3cVg==" + }, + "Autofac": { + "type": "Transitive", + "resolved": "5.2.0", + "contentHash": "V8dBH0dsv75uDzl7Sw+HkhKDPUw2eXnlMjcSVMH+tLo2s67MpTKGyDj1pDcpR+IF2u4YRs0s3/x7R88YJzIWvg==" + }, + "GraphQL.Client": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "8yPNBbuVBpTptivyAlak4GZvbwbUcjeQTL4vN1HKHRuOykZ4r7l5fcLS6vpyPyLn0x8FsL31xbOIKyxbmR9rbA==", + "dependencies": { + "GraphQL.Client.Abstractions": "6.0.0", + "GraphQL.Client.Abstractions.Websocket": "6.0.0", + "System.Reactive": "5.0.0" + } + }, + "GraphQL.Client.Abstractions": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "h7uzWFORHZ+CCjwr/ThAyXMr0DPpzEANDa4Uo54wqCQ+j7qUKwqYTgOrb1W40sqbvNaZm9v/X7It31SUw0maHA==", + "dependencies": { + "GraphQL.Primitives": "6.0.0" + } + }, + "GraphQL.Client.Abstractions.Websocket": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "Nr9bPf8gIOvLuXpqEpqr9z9jslYFJOvd0feHth3/kPqeR3uMbjF5pjiwh4jxyMcxHdr8Pb6QiXkV3hsSyt0v7A==", + "dependencies": { + "GraphQL.Client.Abstractions": "6.0.0" + } + }, + "GraphQL.Primitives": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "yg72rrYDapfsIUrul7aF6wwNnTJBOFvuA9VdDTQpPa8AlAriHbufeXYLBcodKjfUdkCnaiggX1U/nEP08Zb5GA==" + }, + "Microsoft.AspNetCore.Http": { + "type": "Transitive", + "resolved": "2.2.2", + "contentHash": "BAibpoItxI5puk7YJbIGj95arZueM8B8M5xT1fXBn3hb3L2G3ucrZcYXv1gXdaroLbntUs8qeV8iuBrpjQsrKw==", + "dependencies": { + "Microsoft.AspNetCore.Http.Abstractions": "2.2.0", + "Microsoft.AspNetCore.WebUtilities": "2.2.0", + "Microsoft.Extensions.ObjectPool": "2.2.0", + "Microsoft.Extensions.Options": "2.2.0", + "Microsoft.Net.Http.Headers": "2.2.0" + } + }, + "Microsoft.AspNetCore.Http.Abstractions": { + "type": "Transitive", + "resolved": "2.2.0", + "contentHash": "Nxs7Z1q3f1STfLYKJSVXCs1iBl+Ya6E8o4Oy1bCxJ/rNI44E/0f6tbsrVqAWfB7jlnJfyaAtIalBVxPKUPQb4Q==", + "dependencies": { + "Microsoft.AspNetCore.Http.Features": "2.2.0", + "System.Text.Encodings.Web": "4.5.0" + } + }, + "Microsoft.AspNetCore.Http.Features": { + "type": "Transitive", + "resolved": "2.2.0", + "contentHash": "ziFz5zH8f33En4dX81LW84I6XrYXKf9jg6aM39cM+LffN9KJahViKZ61dGMSO2gd3e+qe5yBRwsesvyqlZaSMg==", + "dependencies": { + "Microsoft.Extensions.Primitives": "2.2.0" + } + }, + "Microsoft.AspNetCore.WebUtilities": { + "type": "Transitive", + "resolved": "2.2.0", + "contentHash": "9ErxAAKaDzxXASB/b5uLEkLgUWv1QbeVxyJYEHQwMaxXOeFFVkQxiq8RyfVcifLU7NR0QY0p3acqx4ZpYfhHDg==", + "dependencies": { + "Microsoft.Net.Http.Headers": "2.2.0", + "System.Text.Encodings.Web": "4.5.0" + } + }, + "Microsoft.CSharp": { + "type": "Transitive", + "resolved": "4.7.0", + "contentHash": "pTj+D3uJWyN3My70i2Hqo+OXixq3Os2D1nJ2x92FFo6sk8fYS1m1WLNTs0Dc1uPaViH0YvEEwvzddQ7y4rhXmA==" + }, + "Microsoft.Data.Sqlite": { + "type": "Transitive", + "resolved": "7.0.5", + "contentHash": "KGxbPeWsQMnmQy43DSBxAFtHz3l2JX8EWBSGUCvT3CuZ8KsuzbkqMIJMDOxWtG8eZSoCDI04aiVQjWuuV8HmSw==", + "dependencies": { + "Microsoft.Data.Sqlite.Core": "7.0.5", + "SQLitePCLRaw.bundle_e_sqlite3": "2.1.4" + } + }, + "Microsoft.Data.Sqlite.Core": { + "type": "Transitive", + "resolved": "7.0.5", + "contentHash": "FTerRmQPqHrCrnoUzhBu+E+1DNGwyrAMLqHkAqOOOu5pGfyMOj8qQUBxI/gDtWtG11p49UxSfWmBzRNlwZqfUg==", + "dependencies": { + "SQLitePCLRaw.core": "2.1.4" + } + }, + "Microsoft.Extensions.DependencyInjection": { + "type": "Transitive", + "resolved": "7.0.0", + "contentHash": "elNeOmkeX3eDVG6pYVeV82p29hr+UKDaBhrZyWvWLw/EVZSYEkZlQdkp0V39k/Xehs2Qa0mvoCvkVj3eQxNQ1Q==", + "dependencies": { + "Microsoft.Extensions.DependencyInjection.Abstractions": "7.0.0" + } + }, + "Microsoft.Extensions.DependencyInjection.Abstractions": { + "type": "Transitive", + "resolved": "7.0.0", + "contentHash": "h3j/QfmFN4S0w4C2A6X7arXij/M/OVw3uQHSOFxnND4DyAzO1F9eMX7Eti7lU/OkSthEE0WzRsfT/Dmx86jzCw==" + }, + "Microsoft.Extensions.Logging": { + "type": "Transitive", + "resolved": "7.0.0", + "contentHash": "Nw2muoNrOG5U5qa2ZekXwudUn2BJcD41e65zwmDHb1fQegTX66UokLWZkJRpqSSHXDOWZ5V0iqhbxOEky91atA==", + "dependencies": { + "Microsoft.Extensions.DependencyInjection": "7.0.0", + "Microsoft.Extensions.DependencyInjection.Abstractions": "7.0.0", + "Microsoft.Extensions.Logging.Abstractions": "7.0.0", + "Microsoft.Extensions.Options": "7.0.0" + } + }, + "Microsoft.Extensions.ObjectPool": { + "type": "Transitive", + "resolved": "2.2.0", + "contentHash": "gA8H7uQOnM5gb+L0uTNjViHYr+hRDqCdfugheGo/MxQnuHzmhhzCBTIPm19qL1z1Xe0NEMabfcOBGv9QghlZ8g==" + }, + "Microsoft.Extensions.Options": { + "type": "Transitive", + "resolved": "7.0.0", + "contentHash": "lP1yBnTTU42cKpMozuafbvNtQ7QcBjr/CcK3bYOGEMH55Fjt+iecXjT6chR7vbgCMqy3PG3aNQSZgo/EuY/9qQ==", + "dependencies": { + "Microsoft.Extensions.DependencyInjection.Abstractions": "7.0.0", + "Microsoft.Extensions.Primitives": "7.0.0" + } + }, + "Microsoft.Extensions.Primitives": { + "type": "Transitive", + "resolved": "7.0.0", + "contentHash": "um1KU5kxcRp3CNuI8o/GrZtD4AIOXDk+RLsytjZ9QPok3ttLUelLKpilVPuaFT3TFjOhSibUAso0odbOaCDj3Q==", + "dependencies": { + "System.Runtime.CompilerServices.Unsafe": "6.0.0" + } + }, + "Microsoft.Net.Http.Headers": { + "type": "Transitive", + "resolved": "2.2.0", + "contentHash": "iZNkjYqlo8sIOI0bQfpsSoMTmB/kyvmV2h225ihyZT33aTp48ZpF6qYnXxzSXmHt8DpBAwBTX+1s1UFLbYfZKg==", + "dependencies": { + "Microsoft.Extensions.Primitives": "2.2.0", + "System.Buffers": "4.5.0" + } + }, + "Microsoft.Web.WebView2": { + "type": "Transitive", + "resolved": "1.0.1823.32", + "contentHash": "ppRcWBUNggFIqyJp7PfgS4Oe8/7yli/mHcTNDOaqo3ZzJWnv9AOr0WE9ceEP5SPs1M7CQ3QvdGMR7KNz0v09EA==" + }, + "Polly": { + "type": "Transitive", + "resolved": "7.2.3", + "contentHash": "DeCY0OFbNdNxsjntr1gTXHJ5pKUwYzp04Er2LLeN3g6pWhffsGuKVfMBLe1lw7x76HrPkLxKEFxBlpRxS2nDEQ==" + }, + "Polly.Contrib.WaitAndRetry": { + "type": "Transitive", + "resolved": "1.1.1", + "contentHash": "1MUQLiSo4KDkQe6nzQRhIU05lm9jlexX5BVsbuw0SL82ynZ+GzAHQxJVDPVBboxV37Po3SG077aX8DuSy8TkaA==" + }, + "Polly.Extensions.Http": { + "type": "Transitive", + "resolved": "3.0.0", + "contentHash": "drrG+hB3pYFY7w1c3BD+lSGYvH2oIclH8GRSehgfyP5kjnFnHKQuuBhuHLv+PWyFuaTDyk/vfRpnxOzd11+J8g==", + "dependencies": { + "Polly": "7.1.0" + } + }, + "Sentry": { + "type": "Transitive", + "resolved": "3.33.0", + "contentHash": "8vbD2o6IR2wrRrkSiRbnodWGWUOqIlwYtzpjvPNOb5raJdOf+zxMwfS8f6nx9bmrTTfDj7KrCB8C/5OuicAc8A==" + }, + "Sentry.Serilog": { + "type": "Transitive", + "resolved": "3.33.0", + "contentHash": "V8BU7QGWg2qLYfNPqtuTBhC1opysny5l+Ifp6J6PhOeAxU0FssR7nYfbJVetrnLIoh2rd3DlJ6hHYYQosQYcUQ==", + "dependencies": { + "Sentry": "3.33.0", + "Serilog": "2.10.0" + } + }, + "Serilog": { + "type": "Transitive", + "resolved": "2.12.0", + "contentHash": "xaiJLIdu6rYMKfQMYUZgTy8YK7SMZjB4Yk50C/u//Z4OsvxkUfSPJy4nknfvwAC34yr13q7kcyh4grbwhSxyZg==" + }, + "Serilog.Enrichers.ClientInfo": { + "type": "Transitive", + "resolved": "1.3.0", + "contentHash": "mTc7PM+wC9Hr7LWSwqt5mmnlAr7RJs+eTb3PGPRhwdOackk95MkhUZognuxXEdlW19HAFNmEBTSBY5DfLwM8jQ==", + "dependencies": { + "Microsoft.AspNetCore.Http": "2.2.2", + "Serilog": "2.9.0" + } + }, + "Serilog.Exceptions": { + "type": "Transitive", + "resolved": "8.4.0", + "contentHash": "nc/+hUw3lsdo0zCj0KMIybAu7perMx79vu72w0za9Nsi6mWyNkGXxYxakAjWB7nEmYL6zdmhEQRB4oJ2ALUeug==", + "dependencies": { + "Serilog": "2.8.0", + "System.Reflection.TypeExtensions": "4.7.0" + } + }, + "Serilog.Extensions.Logging": { + "type": "Transitive", + "resolved": "7.0.0", + "contentHash": "9faU0zNQqU7I6soVhLUMYaGNpgWv6cKlKb2S5AnS8gXxzW/em5Ladm/6FMrWTnX41cdbdGPOWNAo6adi4WaJ6A==", + "dependencies": { + "Microsoft.Extensions.Logging": "7.0.0", + "Serilog": "2.12.0" + } + }, + "Serilog.Formatting.Compact": { + "type": "Transitive", + "resolved": "1.1.0", + "contentHash": "pNroKVjo+rDqlxNG5PXkRLpfSCuDOBY0ri6jp9PLe505ljqwhwZz8ospy2vWhQlFu5GkIesh3FcDs4n7sWZODA==", + "dependencies": { + "Serilog": "2.8.0" + } + }, + "Serilog.Sinks.Console": { + "type": "Transitive", + "resolved": "4.1.0", + "contentHash": "K6N5q+5fetjnJPvCmkWOpJ/V8IEIoMIB1s86OzBrbxwTyHxdx3pmz4H+8+O/Dc/ftUX12DM1aynx/dDowkwzqg==", + "dependencies": { + "Serilog": "2.10.0" + } + }, + "Serilog.Sinks.File": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "uwV5hdhWPwUH1szhO8PJpFiahqXmzPzJT/sOijH/kFgUx+cyoDTMM8MHD0adw9+Iem6itoibbUXHYslzXsLEAg==", + "dependencies": { + "Serilog": "2.10.0" + } + }, + "Serilog.Sinks.PeriodicBatching": { + "type": "Transitive", + "resolved": "3.1.0", + "contentHash": "NDWR7m3PalVlGEq3rzoktrXikjFMLmpwF0HI4sowo8YDdU+gqPlTHlDQiOGxHfB0sTfjPA9JjA7ctKG9zqjGkw==", + "dependencies": { + "Serilog": "2.0.0" + } + }, + "Serilog.Sinks.Seq": { + "type": "Transitive", + "resolved": "5.2.2", + "contentHash": "1Csmo5ua7NKUe0yXUx+zsRefjAniPWcXFhUXxXG8pwo0iMiw2gjn9SOkgYnnxbgWqmlGv236w0N/dHc2v5XwMg==", + "dependencies": { + "Serilog": "2.12.0", + "Serilog.Formatting.Compact": "1.1.0", + "Serilog.Sinks.File": "5.0.0", + "Serilog.Sinks.PeriodicBatching": "3.1.0" + } + }, + "SerilogTimings": { + "type": "Transitive", + "resolved": "3.0.1", + "contentHash": "Zs28eTgszAMwpIrbBnWHBI50yuxL50p/dmAUWmy75+axdZYK/Sjm5/5m1N/CisR8acJUhTVcjPZrsB1P5iv0Uw==", + "dependencies": { + "Serilog": "2.10.0" + } + }, + "Speckle.Newtonsoft.Json": { + "type": "Transitive", + "resolved": "13.0.2", + "contentHash": "g1BejUZwax5PRfL6xHgLEK23sqHWOgOj9hE7RvfRRlN00AGt8GnPYt8HedSK7UB3HiRW8zCA9Pn0iiYxCK24BA==" + }, + "Speckle.Revit2023.Interfaces": { + "type": "Transitive", + "resolved": "0.1.1-preview.0.24", + "contentHash": "BSVpOUJc9g6ISrw8GxvtkglTlITpHEDYNOhxv1ZPbckBsI0yO36JiphhQV4q57ERqD9PpCozUJkVhlCaxWeS6A==" + }, + "SQLitePCLRaw.bundle_e_sqlite3": { + "type": "Transitive", + "resolved": "2.1.4", + "contentHash": "EWI1olKDjFEBMJu0+3wuxwziIAdWDVMYLhuZ3Qs84rrz+DHwD00RzWPZCa+bLnHCf3oJwuFZIRsHT5p236QXww==", + "dependencies": { + "SQLitePCLRaw.lib.e_sqlite3": "2.1.4", + "SQLitePCLRaw.provider.e_sqlite3": "2.1.4" + } + }, + "SQLitePCLRaw.core": { + "type": "Transitive", + "resolved": "2.1.4", + "contentHash": "inBjvSHo9UDKneGNzfUfDjK08JzlcIhn1+SP5Y3m6cgXpCxXKCJDy6Mka7LpgSV+UZmKSnC8rTwB0SQ0xKu5pA==", + "dependencies": { + "System.Memory": "4.5.3" + } + }, + "SQLitePCLRaw.lib.e_sqlite3": { + "type": "Transitive", + "resolved": "2.1.4", + "contentHash": "2C9Q9eX7CPLveJA0rIhf9RXAvu+7nWZu1A2MdG6SD/NOu26TakGgL1nsbc0JAspGijFOo3HoN79xrx8a368fBg==" + }, + "SQLitePCLRaw.provider.e_sqlite3": { + "type": "Transitive", + "resolved": "2.1.4", + "contentHash": "CSlb5dUp1FMIkez9Iv5EXzpeq7rHryVNqwJMWnpq87j9zWZexaEMdisDktMsnnrzKM6ahNrsTkjqNodTBPBxtQ==", + "dependencies": { + "SQLitePCLRaw.core": "2.1.4" + } + }, + "System.Buffers": { + "type": "Transitive", + "resolved": "4.5.0", + "contentHash": "pL2ChpaRRWI/p4LXyy4RgeWlYF2sgfj/pnVMvBqwNFr5cXg7CXNnWZWxrOONLg8VGdFB8oB+EG2Qw4MLgTOe+A==" + }, + "System.DoubleNumerics": { + "type": "Transitive", + "resolved": "3.1.3", + "contentHash": "KRKEM/L3KBodjA9VOg3EifFVWUY6EOqaMB05UvPEDm7Zeby/kZW+4kdWUEPzW6xtkwf46p661L9NrbeeQhtLzw==", + "dependencies": { + "NETStandard.Library": "1.6.1" + } + }, + "System.Memory": { + "type": "Transitive", + "resolved": "4.5.3", + "contentHash": "3oDzvc/zzetpTKWMShs1AADwZjQ/36HnsufHRPcOjyRAAMLDlu2iD33MBI2opxnezcVUtXyqDXXjoFMOU9c7SA==" + }, + "System.Reactive": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "erBZjkQHWL9jpasCE/0qKAryzVBJFxGHVBAvgRN1bzM0q2s1S4oYREEEL0Vb+1kA/6BKb5FjUZMp5VXmy+gzkQ==" + }, + "System.Reflection.TypeExtensions": { + "type": "Transitive", + "resolved": "4.7.0", + "contentHash": "VybpaOQQhqE6siHppMktjfGBw1GCwvCqiufqmP8F1nj7fTUNtW35LOEt3UZTEsECfo+ELAl/9o9nJx3U91i7vA==" + }, + "System.Runtime.CompilerServices.Unsafe": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "/iUeP3tq1S0XdNNoMz5C9twLSrM/TH+qElHkXWaPvuNOt+99G75NrV0OS2EqHx5wMN7popYjpc8oTjC1y16DLg==" + }, + "System.Text.Encodings.Web": { + "type": "Transitive", + "resolved": "4.5.0", + "contentHash": "Xg4G4Indi4dqP1iuAiMSwpiWS54ZghzR644OtsRCm/m/lBMG8dUBhLVN7hLm8NNrNTR+iGbshCPTwrvxZPlm4g==" + }, + "System.Threading.Tasks.Dataflow": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "+tyDCU3/B1lDdOOAJywHQoFwyXIUghIaP2BxG79uvhfTnO+D9qIgjVlL/JV2NTliYbMHpd6eKDmHp2VHpij7MA==" + }, + "speckle.autofac": { + "type": "Project", + "dependencies": { + "Microsoft.Extensions.Logging.Abstractions": "[7.0.0, )", + "Speckle.Core": "[2.0.999-local, )" + } + }, + "speckle.connectors.dui": { + "type": "Project", + "dependencies": { + "Microsoft.Extensions.Logging.Abstractions": "[7.0.0, )", + "Speckle.Autofac": "[2.0.999-local, )", + "Speckle.Connectors.Utils": "[2.0.999-local, )", + "Speckle.Core": "[2.0.999-local, )", + "System.Threading.Tasks.Dataflow": "[6.0.0, )" + } + }, + "speckle.connectors.dui.webview": { + "type": "Project", + "dependencies": { + "Microsoft.Web.WebView2": "[1.0.1823.32, )", + "Speckle.Connectors.DUI": "[2.0.999-local, )" + } + }, + "speckle.connectors.utils": { + "type": "Project", + "dependencies": { + "Serilog.Extensions.Logging": "[7.0.0, )", + "Speckle.Autofac": "[2.0.999-local, )", + "Speckle.Core": "[2.0.999-local, )" + } + }, + "speckle.converters.arcgis3": { + "type": "Project", + "dependencies": { + "Esri.ArcGISPro.Extensions30": "[3.2.0.49743, )", + "Speckle.Converters.Common": "[2.0.999-local, )" + } + }, + "speckle.converters.arcgis3.dependencyinjection": { + "type": "Project", + "dependencies": { + "Autofac": "[5.2.0, )", + "Speckle.Converters.ArcGIS3": "[2.0.999-local, )", + "Speckle.Converters.Common.DependencyInjection": "[2.0.999-local, )" + } + }, + "speckle.converters.common": { + "type": "Project", + "dependencies": { + "Speckle.Autofac": "[2.0.999-local, )", + "Speckle.Objects": "[2.0.999-local, )", + "Speckle.Revit2023.Interfaces": "[0.1.1-preview.0.24, )" + } + }, + "speckle.converters.common.dependencyinjection": { + "type": "Project", + "dependencies": { + "Speckle.Autofac": "[2.0.999-local, )", + "Speckle.Converters.Common": "[2.0.999-local, )" + } + }, + "Speckle.Core": { + "type": "Project", + "dependencies": { + "GraphQL.Client": "[6.0.0, )", + "Microsoft.CSharp": "[4.7.0, )", + "Microsoft.Data.Sqlite": "[7.0.5, )", + "Polly": "[7.2.3, )", + "Polly.Contrib.WaitAndRetry": "[1.1.1, )", + "Polly.Extensions.Http": "[3.0.0, )", + "Sentry": "[3.33.0, )", + "Sentry.Serilog": "[3.33.0, )", + "Serilog": "[2.12.0, )", + "Serilog.Enrichers.ClientInfo": "[1.3.0, )", + "Serilog.Exceptions": "[8.4.0, )", + "Serilog.Sinks.Console": "[4.1.0, )", + "Serilog.Sinks.Seq": "[5.2.2, )", + "SerilogTimings": "[3.0.1, )", + "Speckle.Newtonsoft.Json": "[13.0.2, )", + "System.DoubleNumerics": "[3.1.3, )" + } + }, + "Speckle.Objects": { + "type": "Project", + "dependencies": { + "Speckle.Core": "[2.0.999-local, )" + } + } + }, + "net6.0-windows7.0/win-x64": { + "Microsoft.Web.WebView2": { + "type": "Transitive", + "resolved": "1.0.1823.32", + "contentHash": "ppRcWBUNggFIqyJp7PfgS4Oe8/7yli/mHcTNDOaqo3ZzJWnv9AOr0WE9ceEP5SPs1M7CQ3QvdGMR7KNz0v09EA==" + }, + "SQLitePCLRaw.lib.e_sqlite3": { + "type": "Transitive", + "resolved": "2.1.4", + "contentHash": "2C9Q9eX7CPLveJA0rIhf9RXAvu+7nWZu1A2MdG6SD/NOu26TakGgL1nsbc0JAspGijFOo3HoN79xrx8a368fBg==" + } + } + } +} \ No newline at end of file diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.Autocad2023/packages.lock.json b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.Autocad2023/packages.lock.json new file mode 100644 index 0000000000..b584dc45f9 --- /dev/null +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.Autocad2023/packages.lock.json @@ -0,0 +1,530 @@ +{ + "version": 1, + "dependencies": { + ".NETFramework,Version=v4.8": { + "Microsoft.Extensions.Logging.Abstractions": { + "type": "Direct", + "requested": "[7.0.0, )", + "resolved": "7.0.0", + "contentHash": "kmn78+LPVMOWeITUjIlfxUPDsI0R6G0RkeAMBmQxAJ7vBJn4q2dTva7pWi65ceN5vPGjJ9q/Uae2WKgvfktJAw==", + "dependencies": { + "System.Buffers": "4.5.1", + "System.Memory": "4.5.5" + } + }, + "PolySharp": { + "type": "Direct", + "requested": "[1.14.1, )", + "resolved": "1.14.1", + "contentHash": "mOOmFYwad3MIOL14VCjj02LljyF1GNw1wP0YVlxtcPvqdxjGGMNdNJJxHptlry3MOd8b40Flm8RPOM8JOlN2sQ==" + }, + "Speckle.AutoCAD.API": { + "type": "Direct", + "requested": "[2023.0.0, )", + "resolved": "2023.0.0", + "contentHash": "aNfiNw9zRW8pCl8AAQK7afEJuea4bJ4sFNsGVSDrdq1egaonZrwALU01dSyFNCE8tne86eVjlprpOGG6r0+G/A==" + }, + "Speckle.InterfaceGenerator": { + "type": "Direct", + "requested": "[0.9.5, )", + "resolved": "0.9.5", + "contentHash": "oU/L7pN1R7q8KkbrpQ3WJnHirPHqn+9DEA7asOcUiggV5dzVg1A/VYs7GOSusD24njxXh03tE3a2oTLOjt3cVg==" + }, + "Autofac": { + "type": "Transitive", + "resolved": "5.2.0", + "contentHash": "V8dBH0dsv75uDzl7Sw+HkhKDPUw2eXnlMjcSVMH+tLo2s67MpTKGyDj1pDcpR+IF2u4YRs0s3/x7R88YJzIWvg==", + "dependencies": { + "Microsoft.Bcl.AsyncInterfaces": "1.1.0" + } + }, + "GraphQL.Client": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "8yPNBbuVBpTptivyAlak4GZvbwbUcjeQTL4vN1HKHRuOykZ4r7l5fcLS6vpyPyLn0x8FsL31xbOIKyxbmR9rbA==", + "dependencies": { + "GraphQL.Client.Abstractions": "6.0.0", + "GraphQL.Client.Abstractions.Websocket": "6.0.0", + "System.Net.WebSockets.Client.Managed": "1.0.22", + "System.Reactive": "5.0.0" + } + }, + "GraphQL.Client.Abstractions": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "h7uzWFORHZ+CCjwr/ThAyXMr0DPpzEANDa4Uo54wqCQ+j7qUKwqYTgOrb1W40sqbvNaZm9v/X7It31SUw0maHA==", + "dependencies": { + "GraphQL.Primitives": "6.0.0" + } + }, + "GraphQL.Client.Abstractions.Websocket": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "Nr9bPf8gIOvLuXpqEpqr9z9jslYFJOvd0feHth3/kPqeR3uMbjF5pjiwh4jxyMcxHdr8Pb6QiXkV3hsSyt0v7A==", + "dependencies": { + "GraphQL.Client.Abstractions": "6.0.0" + } + }, + "GraphQL.Primitives": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "yg72rrYDapfsIUrul7aF6wwNnTJBOFvuA9VdDTQpPa8AlAriHbufeXYLBcodKjfUdkCnaiggX1U/nEP08Zb5GA==" + }, + "Microsoft.Bcl.AsyncInterfaces": { + "type": "Transitive", + "resolved": "7.0.0", + "contentHash": "3aeMZ1N0lJoSyzqiP03hqemtb1BijhsJADdobn/4nsMJ8V1H+CrpuduUe4hlRdx+ikBQju1VGjMD1GJ3Sk05Eg==", + "dependencies": { + "System.Threading.Tasks.Extensions": "4.5.4" + } + }, + "Microsoft.CSharp": { + "type": "Transitive", + "resolved": "4.7.0", + "contentHash": "pTj+D3uJWyN3My70i2Hqo+OXixq3Os2D1nJ2x92FFo6sk8fYS1m1WLNTs0Dc1uPaViH0YvEEwvzddQ7y4rhXmA==" + }, + "Microsoft.Data.Sqlite": { + "type": "Transitive", + "resolved": "7.0.5", + "contentHash": "KGxbPeWsQMnmQy43DSBxAFtHz3l2JX8EWBSGUCvT3CuZ8KsuzbkqMIJMDOxWtG8eZSoCDI04aiVQjWuuV8HmSw==", + "dependencies": { + "Microsoft.Data.Sqlite.Core": "7.0.5", + "SQLitePCLRaw.bundle_e_sqlite3": "2.1.4" + } + }, + "Microsoft.Data.Sqlite.Core": { + "type": "Transitive", + "resolved": "7.0.5", + "contentHash": "FTerRmQPqHrCrnoUzhBu+E+1DNGwyrAMLqHkAqOOOu5pGfyMOj8qQUBxI/gDtWtG11p49UxSfWmBzRNlwZqfUg==", + "dependencies": { + "SQLitePCLRaw.core": "2.1.4" + } + }, + "Microsoft.Extensions.DependencyInjection": { + "type": "Transitive", + "resolved": "7.0.0", + "contentHash": "elNeOmkeX3eDVG6pYVeV82p29hr+UKDaBhrZyWvWLw/EVZSYEkZlQdkp0V39k/Xehs2Qa0mvoCvkVj3eQxNQ1Q==", + "dependencies": { + "Microsoft.Bcl.AsyncInterfaces": "7.0.0", + "Microsoft.Extensions.DependencyInjection.Abstractions": "7.0.0", + "System.Threading.Tasks.Extensions": "4.5.4" + } + }, + "Microsoft.Extensions.DependencyInjection.Abstractions": { + "type": "Transitive", + "resolved": "7.0.0", + "contentHash": "h3j/QfmFN4S0w4C2A6X7arXij/M/OVw3uQHSOFxnND4DyAzO1F9eMX7Eti7lU/OkSthEE0WzRsfT/Dmx86jzCw==", + "dependencies": { + "Microsoft.Bcl.AsyncInterfaces": "7.0.0", + "System.Threading.Tasks.Extensions": "4.5.4" + } + }, + "Microsoft.Extensions.Logging": { + "type": "Transitive", + "resolved": "7.0.0", + "contentHash": "Nw2muoNrOG5U5qa2ZekXwudUn2BJcD41e65zwmDHb1fQegTX66UokLWZkJRpqSSHXDOWZ5V0iqhbxOEky91atA==", + "dependencies": { + "Microsoft.Bcl.AsyncInterfaces": "7.0.0", + "Microsoft.Extensions.DependencyInjection": "7.0.0", + "Microsoft.Extensions.DependencyInjection.Abstractions": "7.0.0", + "Microsoft.Extensions.Logging.Abstractions": "7.0.0", + "Microsoft.Extensions.Options": "7.0.0", + "System.Diagnostics.DiagnosticSource": "7.0.0", + "System.ValueTuple": "4.5.0" + } + }, + "Microsoft.Extensions.Options": { + "type": "Transitive", + "resolved": "7.0.0", + "contentHash": "lP1yBnTTU42cKpMozuafbvNtQ7QcBjr/CcK3bYOGEMH55Fjt+iecXjT6chR7vbgCMqy3PG3aNQSZgo/EuY/9qQ==", + "dependencies": { + "Microsoft.Extensions.DependencyInjection.Abstractions": "7.0.0", + "Microsoft.Extensions.Primitives": "7.0.0" + } + }, + "Microsoft.Extensions.Primitives": { + "type": "Transitive", + "resolved": "7.0.0", + "contentHash": "um1KU5kxcRp3CNuI8o/GrZtD4AIOXDk+RLsytjZ9QPok3ttLUelLKpilVPuaFT3TFjOhSibUAso0odbOaCDj3Q==", + "dependencies": { + "System.Memory": "4.5.5", + "System.Runtime.CompilerServices.Unsafe": "6.0.0" + } + }, + "Microsoft.Web.WebView2": { + "type": "Transitive", + "resolved": "1.0.1823.32", + "contentHash": "ppRcWBUNggFIqyJp7PfgS4Oe8/7yli/mHcTNDOaqo3ZzJWnv9AOr0WE9ceEP5SPs1M7CQ3QvdGMR7KNz0v09EA==" + }, + "Polly": { + "type": "Transitive", + "resolved": "7.2.3", + "contentHash": "DeCY0OFbNdNxsjntr1gTXHJ5pKUwYzp04Er2LLeN3g6pWhffsGuKVfMBLe1lw7x76HrPkLxKEFxBlpRxS2nDEQ==" + }, + "Polly.Contrib.WaitAndRetry": { + "type": "Transitive", + "resolved": "1.1.1", + "contentHash": "1MUQLiSo4KDkQe6nzQRhIU05lm9jlexX5BVsbuw0SL82ynZ+GzAHQxJVDPVBboxV37Po3SG077aX8DuSy8TkaA==" + }, + "Polly.Extensions.Http": { + "type": "Transitive", + "resolved": "3.0.0", + "contentHash": "drrG+hB3pYFY7w1c3BD+lSGYvH2oIclH8GRSehgfyP5kjnFnHKQuuBhuHLv+PWyFuaTDyk/vfRpnxOzd11+J8g==", + "dependencies": { + "Polly": "7.1.0" + } + }, + "Sentry": { + "type": "Transitive", + "resolved": "3.33.0", + "contentHash": "8vbD2o6IR2wrRrkSiRbnodWGWUOqIlwYtzpjvPNOb5raJdOf+zxMwfS8f6nx9bmrTTfDj7KrCB8C/5OuicAc8A==", + "dependencies": { + "System.Reflection.Metadata": "5.0.0", + "System.Runtime.InteropServices.RuntimeInformation": "4.3.0", + "System.Text.Json": "5.0.2" + } + }, + "Sentry.Serilog": { + "type": "Transitive", + "resolved": "3.33.0", + "contentHash": "V8BU7QGWg2qLYfNPqtuTBhC1opysny5l+Ifp6J6PhOeAxU0FssR7nYfbJVetrnLIoh2rd3DlJ6hHYYQosQYcUQ==", + "dependencies": { + "Sentry": "3.33.0", + "Serilog": "2.7.1" + } + }, + "Serilog": { + "type": "Transitive", + "resolved": "2.12.0", + "contentHash": "xaiJLIdu6rYMKfQMYUZgTy8YK7SMZjB4Yk50C/u//Z4OsvxkUfSPJy4nknfvwAC34yr13q7kcyh4grbwhSxyZg==" + }, + "Serilog.Enrichers.ClientInfo": { + "type": "Transitive", + "resolved": "1.3.0", + "contentHash": "mTc7PM+wC9Hr7LWSwqt5mmnlAr7RJs+eTb3PGPRhwdOackk95MkhUZognuxXEdlW19HAFNmEBTSBY5DfLwM8jQ==", + "dependencies": { + "Serilog": "2.4.0" + } + }, + "Serilog.Exceptions": { + "type": "Transitive", + "resolved": "8.4.0", + "contentHash": "nc/+hUw3lsdo0zCj0KMIybAu7perMx79vu72w0za9Nsi6mWyNkGXxYxakAjWB7nEmYL6zdmhEQRB4oJ2ALUeug==", + "dependencies": { + "Serilog": "2.8.0" + } + }, + "Serilog.Extensions.Logging": { + "type": "Transitive", + "resolved": "7.0.0", + "contentHash": "9faU0zNQqU7I6soVhLUMYaGNpgWv6cKlKb2S5AnS8gXxzW/em5Ladm/6FMrWTnX41cdbdGPOWNAo6adi4WaJ6A==", + "dependencies": { + "Microsoft.Extensions.Logging": "7.0.0", + "Serilog": "2.12.0" + } + }, + "Serilog.Formatting.Compact": { + "type": "Transitive", + "resolved": "1.1.0", + "contentHash": "pNroKVjo+rDqlxNG5PXkRLpfSCuDOBY0ri6jp9PLe505ljqwhwZz8ospy2vWhQlFu5GkIesh3FcDs4n7sWZODA==", + "dependencies": { + "Serilog": "2.8.0" + } + }, + "Serilog.Sinks.Console": { + "type": "Transitive", + "resolved": "4.1.0", + "contentHash": "K6N5q+5fetjnJPvCmkWOpJ/V8IEIoMIB1s86OzBrbxwTyHxdx3pmz4H+8+O/Dc/ftUX12DM1aynx/dDowkwzqg==", + "dependencies": { + "Serilog": "2.10.0" + } + }, + "Serilog.Sinks.File": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "uwV5hdhWPwUH1szhO8PJpFiahqXmzPzJT/sOijH/kFgUx+cyoDTMM8MHD0adw9+Iem6itoibbUXHYslzXsLEAg==", + "dependencies": { + "Serilog": "2.10.0" + } + }, + "Serilog.Sinks.PeriodicBatching": { + "type": "Transitive", + "resolved": "3.1.0", + "contentHash": "NDWR7m3PalVlGEq3rzoktrXikjFMLmpwF0HI4sowo8YDdU+gqPlTHlDQiOGxHfB0sTfjPA9JjA7ctKG9zqjGkw==", + "dependencies": { + "Serilog": "2.0.0" + } + }, + "Serilog.Sinks.Seq": { + "type": "Transitive", + "resolved": "5.2.2", + "contentHash": "1Csmo5ua7NKUe0yXUx+zsRefjAniPWcXFhUXxXG8pwo0iMiw2gjn9SOkgYnnxbgWqmlGv236w0N/dHc2v5XwMg==", + "dependencies": { + "Serilog": "2.12.0", + "Serilog.Formatting.Compact": "1.1.0", + "Serilog.Sinks.File": "5.0.0", + "Serilog.Sinks.PeriodicBatching": "3.1.0" + } + }, + "SerilogTimings": { + "type": "Transitive", + "resolved": "3.0.1", + "contentHash": "Zs28eTgszAMwpIrbBnWHBI50yuxL50p/dmAUWmy75+axdZYK/Sjm5/5m1N/CisR8acJUhTVcjPZrsB1P5iv0Uw==", + "dependencies": { + "Serilog": "2.10.0" + } + }, + "Speckle.Newtonsoft.Json": { + "type": "Transitive", + "resolved": "13.0.2", + "contentHash": "g1BejUZwax5PRfL6xHgLEK23sqHWOgOj9hE7RvfRRlN00AGt8GnPYt8HedSK7UB3HiRW8zCA9Pn0iiYxCK24BA==" + }, + "Speckle.Revit2023.Interfaces": { + "type": "Transitive", + "resolved": "0.1.1-preview.0.24", + "contentHash": "BSVpOUJc9g6ISrw8GxvtkglTlITpHEDYNOhxv1ZPbckBsI0yO36JiphhQV4q57ERqD9PpCozUJkVhlCaxWeS6A==" + }, + "SQLitePCLRaw.bundle_e_sqlite3": { + "type": "Transitive", + "resolved": "2.1.4", + "contentHash": "EWI1olKDjFEBMJu0+3wuxwziIAdWDVMYLhuZ3Qs84rrz+DHwD00RzWPZCa+bLnHCf3oJwuFZIRsHT5p236QXww==", + "dependencies": { + "SQLitePCLRaw.lib.e_sqlite3": "2.1.4", + "SQLitePCLRaw.provider.dynamic_cdecl": "2.1.4" + } + }, + "SQLitePCLRaw.core": { + "type": "Transitive", + "resolved": "2.1.4", + "contentHash": "inBjvSHo9UDKneGNzfUfDjK08JzlcIhn1+SP5Y3m6cgXpCxXKCJDy6Mka7LpgSV+UZmKSnC8rTwB0SQ0xKu5pA==", + "dependencies": { + "System.Memory": "4.5.3" + } + }, + "SQLitePCLRaw.lib.e_sqlite3": { + "type": "Transitive", + "resolved": "2.1.4", + "contentHash": "2C9Q9eX7CPLveJA0rIhf9RXAvu+7nWZu1A2MdG6SD/NOu26TakGgL1nsbc0JAspGijFOo3HoN79xrx8a368fBg==" + }, + "SQLitePCLRaw.provider.dynamic_cdecl": { + "type": "Transitive", + "resolved": "2.1.4", + "contentHash": "ZsaKKhgYF9B1fvcnOGKl3EycNAwd9CRWX7v0rEfuPWhQQ5Jjpvf2VEHahiLIGHio3hxi3EIKFJw9KvyowWOUAw==", + "dependencies": { + "SQLitePCLRaw.core": "2.1.4" + } + }, + "System.Buffers": { + "type": "Transitive", + "resolved": "4.5.1", + "contentHash": "Rw7ijyl1qqRS0YQD/WycNst8hUUMgrMH4FCn1nNm27M4VxchZ1js3fVjQaANHO5f3sN4isvP4a+Met9Y4YomAg==" + }, + "System.Collections.Immutable": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "FXkLXiK0sVVewcso0imKQoOxjoPAj42R8HtjjbSjVPAzwDfzoyoznWxgA3c38LDbN9SJux1xXoXYAhz98j7r2g==", + "dependencies": { + "System.Memory": "4.5.4" + } + }, + "System.Diagnostics.DiagnosticSource": { + "type": "Transitive", + "resolved": "7.0.0", + "contentHash": "9W0ewWDuAyDqS2PigdTxk6jDKonfgscY/hP8hm7VpxYhNHZHKvZTdRckberlFk3VnCmr3xBUyMBut12Q+T2aOw==", + "dependencies": { + "System.Memory": "4.5.5", + "System.Runtime.CompilerServices.Unsafe": "6.0.0" + } + }, + "System.DoubleNumerics": { + "type": "Transitive", + "resolved": "3.1.3", + "contentHash": "KRKEM/L3KBodjA9VOg3EifFVWUY6EOqaMB05UvPEDm7Zeby/kZW+4kdWUEPzW6xtkwf46p661L9NrbeeQhtLzw==", + "dependencies": { + "NETStandard.Library": "1.6.1" + } + }, + "System.Memory": { + "type": "Transitive", + "resolved": "4.5.5", + "contentHash": "XIWiDvKPXaTveaB7HVganDlOCRoj03l+jrwNvcge/t8vhGYKvqV+dMv6G4SAX2NoNmN0wZfVPTAlFwZcZvVOUw==", + "dependencies": { + "System.Buffers": "4.5.1", + "System.Numerics.Vectors": "4.5.0", + "System.Runtime.CompilerServices.Unsafe": "4.5.3" + } + }, + "System.Net.WebSockets.Client.Managed": { + "type": "Transitive", + "resolved": "1.0.22", + "contentHash": "WqEOxPlXjuZrIjUtXNE9NxEfU/n5E35iV2PtoZdJSUC4tlrqwHnTee+wvMIM4OUaJWmwrymeqcgYrE0IkGAgLA==", + "dependencies": { + "System.Buffers": "4.4.0", + "System.Numerics.Vectors": "4.4.0" + } + }, + "System.Numerics.Vectors": { + "type": "Transitive", + "resolved": "4.5.0", + "contentHash": "QQTlPTl06J/iiDbJCiepZ4H//BVraReU4O4EoRw1U02H5TLUIT7xn3GnDp9AXPSlJUDyFs4uWjWafNX6WrAojQ==" + }, + "System.Reactive": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "erBZjkQHWL9jpasCE/0qKAryzVBJFxGHVBAvgRN1bzM0q2s1S4oYREEEL0Vb+1kA/6BKb5FjUZMp5VXmy+gzkQ==", + "dependencies": { + "System.Threading.Tasks.Extensions": "4.5.4" + } + }, + "System.Reflection.Metadata": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "5NecZgXktdGg34rh1OenY1rFNDCI8xSjFr+Z4OU4cU06AQHUdRnIIEeWENu3Wl4YowbzkymAIMvi3WyK9U53pQ==", + "dependencies": { + "System.Collections.Immutable": "5.0.0" + } + }, + "System.Runtime.CompilerServices.Unsafe": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "/iUeP3tq1S0XdNNoMz5C9twLSrM/TH+qElHkXWaPvuNOt+99G75NrV0OS2EqHx5wMN7popYjpc8oTjC1y16DLg==" + }, + "System.Runtime.InteropServices.RuntimeInformation": { + "type": "Transitive", + "resolved": "4.3.0", + "contentHash": "cbz4YJMqRDR7oLeMRbdYv7mYzc++17lNhScCX0goO2XpGWdvAt60CGN+FHdePUEHCe/Jy9jUlvNAiNdM+7jsOw==" + }, + "System.Text.Encodings.Web": { + "type": "Transitive", + "resolved": "5.0.1", + "contentHash": "KmJ+CJXizDofbq6mpqDoRRLcxgOd2z9X3XoFNULSbvbqVRZkFX3istvr+MUjL6Zw1RT+RNdoI4GYidIINtgvqQ==", + "dependencies": { + "System.Buffers": "4.5.1", + "System.Memory": "4.5.4" + } + }, + "System.Text.Json": { + "type": "Transitive", + "resolved": "5.0.2", + "contentHash": "I47dVIGiV6SfAyppphxqupertT/5oZkYLDCX6vC3HpOI4ZLjyoKAreUoem2ie6G0RbRuFrlqz/PcTQjfb2DOfQ==", + "dependencies": { + "Microsoft.Bcl.AsyncInterfaces": "5.0.0", + "System.Buffers": "4.5.1", + "System.Memory": "4.5.4", + "System.Numerics.Vectors": "4.5.0", + "System.Runtime.CompilerServices.Unsafe": "5.0.0", + "System.Text.Encodings.Web": "5.0.1", + "System.Threading.Tasks.Extensions": "4.5.4", + "System.ValueTuple": "4.5.0" + } + }, + "System.Threading.Tasks.Dataflow": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "+tyDCU3/B1lDdOOAJywHQoFwyXIUghIaP2BxG79uvhfTnO+D9qIgjVlL/JV2NTliYbMHpd6eKDmHp2VHpij7MA==" + }, + "System.Threading.Tasks.Extensions": { + "type": "Transitive", + "resolved": "4.5.4", + "contentHash": "zteT+G8xuGu6mS+mzDzYXbzS7rd3K6Fjb9RiZlYlJPam2/hU7JCBZBVEcywNuR+oZ1ncTvc/cq0faRr3P01OVg==", + "dependencies": { + "System.Runtime.CompilerServices.Unsafe": "4.5.3" + } + }, + "System.ValueTuple": { + "type": "Transitive", + "resolved": "4.5.0", + "contentHash": "okurQJO6NRE/apDIP23ajJ0hpiNmJ+f0BwOlB/cSqTLQlw5upkf+5+96+iG2Jw40G1fCVCyPz/FhIABUjMR+RQ==" + }, + "speckle.autofac": { + "type": "Project", + "dependencies": { + "Microsoft.Extensions.Logging.Abstractions": "[7.0.0, )", + "Speckle.Core": "[2.0.999-local, )" + } + }, + "speckle.connectors.dui": { + "type": "Project", + "dependencies": { + "Microsoft.Extensions.Logging.Abstractions": "[7.0.0, )", + "Speckle.Autofac": "[2.0.999-local, )", + "Speckle.Connectors.Utils": "[2.0.999-local, )", + "Speckle.Core": "[2.0.999-local, )", + "System.Threading.Tasks.Dataflow": "[6.0.0, )" + } + }, + "speckle.connectors.dui.webview": { + "type": "Project", + "dependencies": { + "Microsoft.Web.WebView2": "[1.0.1823.32, )", + "Speckle.Connectors.DUI": "[2.0.999-local, )" + } + }, + "speckle.connectors.utils": { + "type": "Project", + "dependencies": { + "Serilog.Extensions.Logging": "[7.0.0, )", + "Speckle.Autofac": "[2.0.999-local, )", + "Speckle.Core": "[2.0.999-local, )" + } + }, + "speckle.converters.autocad2023": { + "type": "Project", + "dependencies": { + "Speckle.AutoCAD.API": "[2023.0.0, )", + "Speckle.Converters.Common": "[2.0.999-local, )" + } + }, + "speckle.converters.autocad2023.dependencyinjection": { + "type": "Project", + "dependencies": { + "Autofac": "[5.2.0, )", + "Speckle.Converters.Autocad2023": "[2.0.999-local, )", + "Speckle.Converters.Common.DependencyInjection": "[2.0.999-local, )" + } + }, + "speckle.converters.common": { + "type": "Project", + "dependencies": { + "Speckle.Autofac": "[2.0.999-local, )", + "Speckle.Objects": "[2.0.999-local, )", + "Speckle.Revit2023.Interfaces": "[0.1.1-preview.0.24, )" + } + }, + "speckle.converters.common.dependencyinjection": { + "type": "Project", + "dependencies": { + "Speckle.Autofac": "[2.0.999-local, )", + "Speckle.Converters.Common": "[2.0.999-local, )" + } + }, + "Speckle.Core": { + "type": "Project", + "dependencies": { + "GraphQL.Client": "[6.0.0, )", + "Microsoft.CSharp": "[4.7.0, )", + "Microsoft.Data.Sqlite": "[7.0.5, )", + "Polly": "[7.2.3, )", + "Polly.Contrib.WaitAndRetry": "[1.1.1, )", + "Polly.Extensions.Http": "[3.0.0, )", + "Sentry": "[3.33.0, )", + "Sentry.Serilog": "[3.33.0, )", + "Serilog": "[2.12.0, )", + "Serilog.Enrichers.ClientInfo": "[1.3.0, )", + "Serilog.Exceptions": "[8.4.0, )", + "Serilog.Sinks.Console": "[4.1.0, )", + "Serilog.Sinks.Seq": "[5.2.2, )", + "SerilogTimings": "[3.0.1, )", + "Speckle.Newtonsoft.Json": "[13.0.2, )", + "System.DoubleNumerics": "[3.1.3, )" + } + }, + "Speckle.Objects": { + "type": "Project", + "dependencies": { + "Speckle.Core": "[2.0.999-local, )" + } + } + } + } +} \ No newline at end of file diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.Revit2023/packages.lock.json b/DUI3-DX/Connectors/Revit/Speckle.Connectors.Revit2023/packages.lock.json new file mode 100644 index 0000000000..9039fbd17b --- /dev/null +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.Revit2023/packages.lock.json @@ -0,0 +1,573 @@ +{ + "version": 1, + "dependencies": { + ".NETFramework,Version=v4.8": { + "CefSharp.Wpf": { + "type": "Direct", + "requested": "[92.0.260, )", + "resolved": "92.0.260", + "contentHash": "b0TW/HpHsvz2x3M1IQa/8fbCIRKShOgpmSqj5gKiibXY0v2cHgnWssfEX+3Q3UCpizkBJBQ+0fVp+fN8JCPcNQ==", + "dependencies": { + "CefSharp.Common": "[92.0.260]" + } + }, + "PolySharp": { + "type": "Direct", + "requested": "[1.14.1, )", + "resolved": "1.14.1", + "contentHash": "mOOmFYwad3MIOL14VCjj02LljyF1GNw1wP0YVlxtcPvqdxjGGMNdNJJxHptlry3MOd8b40Flm8RPOM8JOlN2sQ==" + }, + "Revit.Async": { + "type": "Direct", + "requested": "[2.0.1, )", + "resolved": "2.0.1", + "contentHash": "B7D5zXznqgxMryBYdGgWob20ALfGSP7hJ6+bh9JdLM/LRkYN5dNf0AaI0+7VID9X7e8MA0koAxv9fIijJnmSnw==" + }, + "Speckle.InterfaceGenerator": { + "type": "Direct", + "requested": "[0.9.5, )", + "resolved": "0.9.5", + "contentHash": "oU/L7pN1R7q8KkbrpQ3WJnHirPHqn+9DEA7asOcUiggV5dzVg1A/VYs7GOSusD24njxXh03tE3a2oTLOjt3cVg==" + }, + "cef.redist.x64": { + "type": "Transitive", + "resolved": "92.0.26", + "contentHash": "wwwSGVgO9sdlj5TRnjVdzuCkNuYpTOXT90Z+dasnqGrnihrxKU+1UvulxxJa83O2k+l3kaNlAU9uBhiwGX7YyQ==" + }, + "cef.redist.x86": { + "type": "Transitive", + "resolved": "92.0.26", + "contentHash": "VT93sU6hH7LoUILjfaAxWbLc+m+b9QafeeRkuulnj3twJnb0PQ7nXd8PMUeOmYg96NzZi14G7qBYSY0dkxqztg==" + }, + "CefSharp.Common": { + "type": "Transitive", + "resolved": "92.0.260", + "contentHash": "0KS5z+kqg+mmB1X2KM17w3S7KQI5UTuJv+UOIQauJPvFYfRGWwTqmBbBxL3kCklGx8WSkaeBjPdSFxdzzXCSew==", + "dependencies": { + "cef.redist.x64": "[92.0.26]", + "cef.redist.x86": "[92.0.26]" + } + }, + "GraphQL.Client": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "8yPNBbuVBpTptivyAlak4GZvbwbUcjeQTL4vN1HKHRuOykZ4r7l5fcLS6vpyPyLn0x8FsL31xbOIKyxbmR9rbA==", + "dependencies": { + "GraphQL.Client.Abstractions": "6.0.0", + "GraphQL.Client.Abstractions.Websocket": "6.0.0", + "System.Net.WebSockets.Client.Managed": "1.0.22", + "System.Reactive": "5.0.0" + } + }, + "GraphQL.Client.Abstractions": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "h7uzWFORHZ+CCjwr/ThAyXMr0DPpzEANDa4Uo54wqCQ+j7qUKwqYTgOrb1W40sqbvNaZm9v/X7It31SUw0maHA==", + "dependencies": { + "GraphQL.Primitives": "6.0.0" + } + }, + "GraphQL.Client.Abstractions.Websocket": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "Nr9bPf8gIOvLuXpqEpqr9z9jslYFJOvd0feHth3/kPqeR3uMbjF5pjiwh4jxyMcxHdr8Pb6QiXkV3hsSyt0v7A==", + "dependencies": { + "GraphQL.Client.Abstractions": "6.0.0" + } + }, + "GraphQL.Primitives": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "yg72rrYDapfsIUrul7aF6wwNnTJBOFvuA9VdDTQpPa8AlAriHbufeXYLBcodKjfUdkCnaiggX1U/nEP08Zb5GA==" + }, + "Mapster": { + "type": "Transitive", + "resolved": "7.3.0", + "contentHash": "NrCUX/rJa5PTyo6iW4AL5dZLU9PDNlYnrJOVjgdpo5OQM9EtWH2CMHnC5sSuJWC0d0b0SnmeRrIviEem6WxtuQ==", + "dependencies": { + "Mapster.Core": "1.2.0", + "Microsoft.CSharp": "4.3.0", + "System.Reflection.Emit": "4.3.0" + } + }, + "Mapster.Core": { + "type": "Transitive", + "resolved": "1.2.0", + "contentHash": "TNdqZk2zAuBYfJF88D/3clQTOyOdqr1crU81yZQtlGa+e7FYWhJdK/buBWT+TpM3qQko9UzmzfOT4iq3JCs/ZA==" + }, + "Microsoft.Bcl.AsyncInterfaces": { + "type": "Transitive", + "resolved": "7.0.0", + "contentHash": "3aeMZ1N0lJoSyzqiP03hqemtb1BijhsJADdobn/4nsMJ8V1H+CrpuduUe4hlRdx+ikBQju1VGjMD1GJ3Sk05Eg==", + "dependencies": { + "System.Threading.Tasks.Extensions": "4.5.4" + } + }, + "Microsoft.CSharp": { + "type": "Transitive", + "resolved": "4.7.0", + "contentHash": "pTj+D3uJWyN3My70i2Hqo+OXixq3Os2D1nJ2x92FFo6sk8fYS1m1WLNTs0Dc1uPaViH0YvEEwvzddQ7y4rhXmA==" + }, + "Microsoft.Data.Sqlite": { + "type": "Transitive", + "resolved": "7.0.5", + "contentHash": "KGxbPeWsQMnmQy43DSBxAFtHz3l2JX8EWBSGUCvT3CuZ8KsuzbkqMIJMDOxWtG8eZSoCDI04aiVQjWuuV8HmSw==", + "dependencies": { + "Microsoft.Data.Sqlite.Core": "7.0.5", + "SQLitePCLRaw.bundle_e_sqlite3": "2.1.4" + } + }, + "Microsoft.Data.Sqlite.Core": { + "type": "Transitive", + "resolved": "7.0.5", + "contentHash": "FTerRmQPqHrCrnoUzhBu+E+1DNGwyrAMLqHkAqOOOu5pGfyMOj8qQUBxI/gDtWtG11p49UxSfWmBzRNlwZqfUg==", + "dependencies": { + "SQLitePCLRaw.core": "2.1.4" + } + }, + "Microsoft.Extensions.DependencyInjection": { + "type": "Transitive", + "resolved": "7.0.0", + "contentHash": "elNeOmkeX3eDVG6pYVeV82p29hr+UKDaBhrZyWvWLw/EVZSYEkZlQdkp0V39k/Xehs2Qa0mvoCvkVj3eQxNQ1Q==", + "dependencies": { + "Microsoft.Bcl.AsyncInterfaces": "7.0.0", + "Microsoft.Extensions.DependencyInjection.Abstractions": "7.0.0", + "System.Threading.Tasks.Extensions": "4.5.4" + } + }, + "Microsoft.Extensions.DependencyInjection.Abstractions": { + "type": "Transitive", + "resolved": "7.0.0", + "contentHash": "h3j/QfmFN4S0w4C2A6X7arXij/M/OVw3uQHSOFxnND4DyAzO1F9eMX7Eti7lU/OkSthEE0WzRsfT/Dmx86jzCw==", + "dependencies": { + "Microsoft.Bcl.AsyncInterfaces": "7.0.0", + "System.Threading.Tasks.Extensions": "4.5.4" + } + }, + "Microsoft.Extensions.Logging": { + "type": "Transitive", + "resolved": "7.0.0", + "contentHash": "Nw2muoNrOG5U5qa2ZekXwudUn2BJcD41e65zwmDHb1fQegTX66UokLWZkJRpqSSHXDOWZ5V0iqhbxOEky91atA==", + "dependencies": { + "Microsoft.Bcl.AsyncInterfaces": "7.0.0", + "Microsoft.Extensions.DependencyInjection": "7.0.0", + "Microsoft.Extensions.DependencyInjection.Abstractions": "7.0.0", + "Microsoft.Extensions.Logging.Abstractions": "7.0.0", + "Microsoft.Extensions.Options": "7.0.0", + "System.Diagnostics.DiagnosticSource": "7.0.0", + "System.ValueTuple": "4.5.0" + } + }, + "Microsoft.Extensions.Logging.Abstractions": { + "type": "Transitive", + "resolved": "7.0.0", + "contentHash": "kmn78+LPVMOWeITUjIlfxUPDsI0R6G0RkeAMBmQxAJ7vBJn4q2dTva7pWi65ceN5vPGjJ9q/Uae2WKgvfktJAw==", + "dependencies": { + "System.Buffers": "4.5.1", + "System.Memory": "4.5.5" + } + }, + "Microsoft.Extensions.Options": { + "type": "Transitive", + "resolved": "7.0.0", + "contentHash": "lP1yBnTTU42cKpMozuafbvNtQ7QcBjr/CcK3bYOGEMH55Fjt+iecXjT6chR7vbgCMqy3PG3aNQSZgo/EuY/9qQ==", + "dependencies": { + "Microsoft.Extensions.DependencyInjection.Abstractions": "7.0.0", + "Microsoft.Extensions.Primitives": "7.0.0" + } + }, + "Microsoft.Extensions.Primitives": { + "type": "Transitive", + "resolved": "7.0.0", + "contentHash": "um1KU5kxcRp3CNuI8o/GrZtD4AIOXDk+RLsytjZ9QPok3ttLUelLKpilVPuaFT3TFjOhSibUAso0odbOaCDj3Q==", + "dependencies": { + "System.Memory": "4.5.5", + "System.Runtime.CompilerServices.Unsafe": "6.0.0" + } + }, + "Polly": { + "type": "Transitive", + "resolved": "7.2.3", + "contentHash": "DeCY0OFbNdNxsjntr1gTXHJ5pKUwYzp04Er2LLeN3g6pWhffsGuKVfMBLe1lw7x76HrPkLxKEFxBlpRxS2nDEQ==" + }, + "Polly.Contrib.WaitAndRetry": { + "type": "Transitive", + "resolved": "1.1.1", + "contentHash": "1MUQLiSo4KDkQe6nzQRhIU05lm9jlexX5BVsbuw0SL82ynZ+GzAHQxJVDPVBboxV37Po3SG077aX8DuSy8TkaA==" + }, + "Polly.Extensions.Http": { + "type": "Transitive", + "resolved": "3.0.0", + "contentHash": "drrG+hB3pYFY7w1c3BD+lSGYvH2oIclH8GRSehgfyP5kjnFnHKQuuBhuHLv+PWyFuaTDyk/vfRpnxOzd11+J8g==", + "dependencies": { + "Polly": "7.1.0" + } + }, + "Sentry": { + "type": "Transitive", + "resolved": "3.33.0", + "contentHash": "8vbD2o6IR2wrRrkSiRbnodWGWUOqIlwYtzpjvPNOb5raJdOf+zxMwfS8f6nx9bmrTTfDj7KrCB8C/5OuicAc8A==", + "dependencies": { + "System.Reflection.Metadata": "5.0.0", + "System.Runtime.InteropServices.RuntimeInformation": "4.3.0", + "System.Text.Json": "5.0.2" + } + }, + "Sentry.Serilog": { + "type": "Transitive", + "resolved": "3.33.0", + "contentHash": "V8BU7QGWg2qLYfNPqtuTBhC1opysny5l+Ifp6J6PhOeAxU0FssR7nYfbJVetrnLIoh2rd3DlJ6hHYYQosQYcUQ==", + "dependencies": { + "Sentry": "3.33.0", + "Serilog": "2.7.1" + } + }, + "Serilog": { + "type": "Transitive", + "resolved": "2.12.0", + "contentHash": "xaiJLIdu6rYMKfQMYUZgTy8YK7SMZjB4Yk50C/u//Z4OsvxkUfSPJy4nknfvwAC34yr13q7kcyh4grbwhSxyZg==" + }, + "Serilog.Enrichers.ClientInfo": { + "type": "Transitive", + "resolved": "1.3.0", + "contentHash": "mTc7PM+wC9Hr7LWSwqt5mmnlAr7RJs+eTb3PGPRhwdOackk95MkhUZognuxXEdlW19HAFNmEBTSBY5DfLwM8jQ==", + "dependencies": { + "Serilog": "2.4.0" + } + }, + "Serilog.Exceptions": { + "type": "Transitive", + "resolved": "8.4.0", + "contentHash": "nc/+hUw3lsdo0zCj0KMIybAu7perMx79vu72w0za9Nsi6mWyNkGXxYxakAjWB7nEmYL6zdmhEQRB4oJ2ALUeug==", + "dependencies": { + "Serilog": "2.8.0" + } + }, + "Serilog.Extensions.Logging": { + "type": "Transitive", + "resolved": "7.0.0", + "contentHash": "9faU0zNQqU7I6soVhLUMYaGNpgWv6cKlKb2S5AnS8gXxzW/em5Ladm/6FMrWTnX41cdbdGPOWNAo6adi4WaJ6A==", + "dependencies": { + "Microsoft.Extensions.Logging": "7.0.0", + "Serilog": "2.12.0" + } + }, + "Serilog.Formatting.Compact": { + "type": "Transitive", + "resolved": "1.1.0", + "contentHash": "pNroKVjo+rDqlxNG5PXkRLpfSCuDOBY0ri6jp9PLe505ljqwhwZz8ospy2vWhQlFu5GkIesh3FcDs4n7sWZODA==", + "dependencies": { + "Serilog": "2.8.0" + } + }, + "Serilog.Sinks.Console": { + "type": "Transitive", + "resolved": "4.1.0", + "contentHash": "K6N5q+5fetjnJPvCmkWOpJ/V8IEIoMIB1s86OzBrbxwTyHxdx3pmz4H+8+O/Dc/ftUX12DM1aynx/dDowkwzqg==", + "dependencies": { + "Serilog": "2.10.0" + } + }, + "Serilog.Sinks.File": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "uwV5hdhWPwUH1szhO8PJpFiahqXmzPzJT/sOijH/kFgUx+cyoDTMM8MHD0adw9+Iem6itoibbUXHYslzXsLEAg==", + "dependencies": { + "Serilog": "2.10.0" + } + }, + "Serilog.Sinks.PeriodicBatching": { + "type": "Transitive", + "resolved": "3.1.0", + "contentHash": "NDWR7m3PalVlGEq3rzoktrXikjFMLmpwF0HI4sowo8YDdU+gqPlTHlDQiOGxHfB0sTfjPA9JjA7ctKG9zqjGkw==", + "dependencies": { + "Serilog": "2.0.0" + } + }, + "Serilog.Sinks.Seq": { + "type": "Transitive", + "resolved": "5.2.2", + "contentHash": "1Csmo5ua7NKUe0yXUx+zsRefjAniPWcXFhUXxXG8pwo0iMiw2gjn9SOkgYnnxbgWqmlGv236w0N/dHc2v5XwMg==", + "dependencies": { + "Serilog": "2.12.0", + "Serilog.Formatting.Compact": "1.1.0", + "Serilog.Sinks.File": "5.0.0", + "Serilog.Sinks.PeriodicBatching": "3.1.0" + } + }, + "SerilogTimings": { + "type": "Transitive", + "resolved": "3.0.1", + "contentHash": "Zs28eTgszAMwpIrbBnWHBI50yuxL50p/dmAUWmy75+axdZYK/Sjm5/5m1N/CisR8acJUhTVcjPZrsB1P5iv0Uw==", + "dependencies": { + "Serilog": "2.10.0" + } + }, + "Speckle.Newtonsoft.Json": { + "type": "Transitive", + "resolved": "13.0.2", + "contentHash": "g1BejUZwax5PRfL6xHgLEK23sqHWOgOj9hE7RvfRRlN00AGt8GnPYt8HedSK7UB3HiRW8zCA9Pn0iiYxCK24BA==" + }, + "Speckle.Revit.API": { + "type": "Transitive", + "resolved": "2023.0.0", + "contentHash": "tq40eD7psgTbV+epNouYyqfo6+hEi7FmXZqcxEOsAV7zfYyWhL6Rt3vmojkWGNuerGbH6oRI6KIIxrnlCNb8Hw==" + }, + "Speckle.Revit2023.Api": { + "type": "Transitive", + "resolved": "0.1.1-preview.0.24", + "contentHash": "hPRXbyvgmealdPPWTxjHbpBRTsyt67DddoIs09M0n319eHh/eONnPC+SgBzJmmB834TtzzayMVk06S1cMT0Iow==", + "dependencies": { + "Mapster": "7.3.0", + "Speckle.Revit.API": "2023.0.0", + "Speckle.Revit2023.Interfaces": "0.1.1-preview.0.24" + } + }, + "Speckle.Revit2023.Interfaces": { + "type": "Transitive", + "resolved": "0.1.1-preview.0.24", + "contentHash": "BSVpOUJc9g6ISrw8GxvtkglTlITpHEDYNOhxv1ZPbckBsI0yO36JiphhQV4q57ERqD9PpCozUJkVhlCaxWeS6A==" + }, + "SQLitePCLRaw.bundle_e_sqlite3": { + "type": "Transitive", + "resolved": "2.1.4", + "contentHash": "EWI1olKDjFEBMJu0+3wuxwziIAdWDVMYLhuZ3Qs84rrz+DHwD00RzWPZCa+bLnHCf3oJwuFZIRsHT5p236QXww==", + "dependencies": { + "SQLitePCLRaw.lib.e_sqlite3": "2.1.4", + "SQLitePCLRaw.provider.dynamic_cdecl": "2.1.4" + } + }, + "SQLitePCLRaw.core": { + "type": "Transitive", + "resolved": "2.1.4", + "contentHash": "inBjvSHo9UDKneGNzfUfDjK08JzlcIhn1+SP5Y3m6cgXpCxXKCJDy6Mka7LpgSV+UZmKSnC8rTwB0SQ0xKu5pA==", + "dependencies": { + "System.Memory": "4.5.3" + } + }, + "SQLitePCLRaw.lib.e_sqlite3": { + "type": "Transitive", + "resolved": "2.1.4", + "contentHash": "2C9Q9eX7CPLveJA0rIhf9RXAvu+7nWZu1A2MdG6SD/NOu26TakGgL1nsbc0JAspGijFOo3HoN79xrx8a368fBg==" + }, + "SQLitePCLRaw.provider.dynamic_cdecl": { + "type": "Transitive", + "resolved": "2.1.4", + "contentHash": "ZsaKKhgYF9B1fvcnOGKl3EycNAwd9CRWX7v0rEfuPWhQQ5Jjpvf2VEHahiLIGHio3hxi3EIKFJw9KvyowWOUAw==", + "dependencies": { + "SQLitePCLRaw.core": "2.1.4" + } + }, + "System.Buffers": { + "type": "Transitive", + "resolved": "4.5.1", + "contentHash": "Rw7ijyl1qqRS0YQD/WycNst8hUUMgrMH4FCn1nNm27M4VxchZ1js3fVjQaANHO5f3sN4isvP4a+Met9Y4YomAg==" + }, + "System.Collections.Immutable": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "FXkLXiK0sVVewcso0imKQoOxjoPAj42R8HtjjbSjVPAzwDfzoyoznWxgA3c38LDbN9SJux1xXoXYAhz98j7r2g==", + "dependencies": { + "System.Memory": "4.5.4" + } + }, + "System.Diagnostics.DiagnosticSource": { + "type": "Transitive", + "resolved": "7.0.0", + "contentHash": "9W0ewWDuAyDqS2PigdTxk6jDKonfgscY/hP8hm7VpxYhNHZHKvZTdRckberlFk3VnCmr3xBUyMBut12Q+T2aOw==", + "dependencies": { + "System.Memory": "4.5.5", + "System.Runtime.CompilerServices.Unsafe": "6.0.0" + } + }, + "System.DoubleNumerics": { + "type": "Transitive", + "resolved": "3.1.3", + "contentHash": "KRKEM/L3KBodjA9VOg3EifFVWUY6EOqaMB05UvPEDm7Zeby/kZW+4kdWUEPzW6xtkwf46p661L9NrbeeQhtLzw==", + "dependencies": { + "NETStandard.Library": "1.6.1" + } + }, + "System.Memory": { + "type": "Transitive", + "resolved": "4.5.5", + "contentHash": "XIWiDvKPXaTveaB7HVganDlOCRoj03l+jrwNvcge/t8vhGYKvqV+dMv6G4SAX2NoNmN0wZfVPTAlFwZcZvVOUw==", + "dependencies": { + "System.Buffers": "4.5.1", + "System.Numerics.Vectors": "4.5.0", + "System.Runtime.CompilerServices.Unsafe": "4.5.3" + } + }, + "System.Net.WebSockets.Client.Managed": { + "type": "Transitive", + "resolved": "1.0.22", + "contentHash": "WqEOxPlXjuZrIjUtXNE9NxEfU/n5E35iV2PtoZdJSUC4tlrqwHnTee+wvMIM4OUaJWmwrymeqcgYrE0IkGAgLA==", + "dependencies": { + "System.Buffers": "4.4.0", + "System.Numerics.Vectors": "4.4.0" + } + }, + "System.Numerics.Vectors": { + "type": "Transitive", + "resolved": "4.5.0", + "contentHash": "QQTlPTl06J/iiDbJCiepZ4H//BVraReU4O4EoRw1U02H5TLUIT7xn3GnDp9AXPSlJUDyFs4uWjWafNX6WrAojQ==" + }, + "System.Reactive": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "erBZjkQHWL9jpasCE/0qKAryzVBJFxGHVBAvgRN1bzM0q2s1S4oYREEEL0Vb+1kA/6BKb5FjUZMp5VXmy+gzkQ==", + "dependencies": { + "System.Threading.Tasks.Extensions": "4.5.4" + } + }, + "System.Reflection.Emit": { + "type": "Transitive", + "resolved": "4.3.0", + "contentHash": "228FG0jLcIwTVJyz8CLFKueVqQK36ANazUManGaJHkO0icjiIypKW7YLWLIWahyIkdh5M7mV2dJepllLyA1SKg==" + }, + "System.Reflection.Metadata": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "5NecZgXktdGg34rh1OenY1rFNDCI8xSjFr+Z4OU4cU06AQHUdRnIIEeWENu3Wl4YowbzkymAIMvi3WyK9U53pQ==", + "dependencies": { + "System.Collections.Immutable": "5.0.0" + } + }, + "System.Runtime.CompilerServices.Unsafe": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "/iUeP3tq1S0XdNNoMz5C9twLSrM/TH+qElHkXWaPvuNOt+99G75NrV0OS2EqHx5wMN7popYjpc8oTjC1y16DLg==" + }, + "System.Runtime.InteropServices.RuntimeInformation": { + "type": "Transitive", + "resolved": "4.3.0", + "contentHash": "cbz4YJMqRDR7oLeMRbdYv7mYzc++17lNhScCX0goO2XpGWdvAt60CGN+FHdePUEHCe/Jy9jUlvNAiNdM+7jsOw==" + }, + "System.Text.Encodings.Web": { + "type": "Transitive", + "resolved": "5.0.1", + "contentHash": "KmJ+CJXizDofbq6mpqDoRRLcxgOd2z9X3XoFNULSbvbqVRZkFX3istvr+MUjL6Zw1RT+RNdoI4GYidIINtgvqQ==", + "dependencies": { + "System.Buffers": "4.5.1", + "System.Memory": "4.5.4" + } + }, + "System.Text.Json": { + "type": "Transitive", + "resolved": "5.0.2", + "contentHash": "I47dVIGiV6SfAyppphxqupertT/5oZkYLDCX6vC3HpOI4ZLjyoKAreUoem2ie6G0RbRuFrlqz/PcTQjfb2DOfQ==", + "dependencies": { + "Microsoft.Bcl.AsyncInterfaces": "5.0.0", + "System.Buffers": "4.5.1", + "System.Memory": "4.5.4", + "System.Numerics.Vectors": "4.5.0", + "System.Runtime.CompilerServices.Unsafe": "5.0.0", + "System.Text.Encodings.Web": "5.0.1", + "System.Threading.Tasks.Extensions": "4.5.4", + "System.ValueTuple": "4.5.0" + } + }, + "System.Threading.Tasks.Dataflow": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "+tyDCU3/B1lDdOOAJywHQoFwyXIUghIaP2BxG79uvhfTnO+D9qIgjVlL/JV2NTliYbMHpd6eKDmHp2VHpij7MA==" + }, + "System.Threading.Tasks.Extensions": { + "type": "Transitive", + "resolved": "4.5.4", + "contentHash": "zteT+G8xuGu6mS+mzDzYXbzS7rd3K6Fjb9RiZlYlJPam2/hU7JCBZBVEcywNuR+oZ1ncTvc/cq0faRr3P01OVg==", + "dependencies": { + "System.Runtime.CompilerServices.Unsafe": "4.5.3" + } + }, + "System.ValueTuple": { + "type": "Transitive", + "resolved": "4.5.0", + "contentHash": "okurQJO6NRE/apDIP23ajJ0hpiNmJ+f0BwOlB/cSqTLQlw5upkf+5+96+iG2Jw40G1fCVCyPz/FhIABUjMR+RQ==" + }, + "speckle.autofac": { + "type": "Project", + "dependencies": { + "Microsoft.Extensions.Logging.Abstractions": "[7.0.0, )", + "Speckle.Core": "[2.0.999-local, )" + } + }, + "speckle.connectors.dui": { + "type": "Project", + "dependencies": { + "Microsoft.Extensions.Logging.Abstractions": "[7.0.0, )", + "Speckle.Autofac": "[2.0.999-local, )", + "Speckle.Connectors.Utils": "[2.0.999-local, )", + "Speckle.Core": "[2.0.999-local, )", + "System.Threading.Tasks.Dataflow": "[6.0.0, )" + } + }, + "speckle.connectors.utils": { + "type": "Project", + "dependencies": { + "Serilog.Extensions.Logging": "[7.0.0, )", + "Speckle.Autofac": "[2.0.999-local, )", + "Speckle.Core": "[2.0.999-local, )" + } + }, + "speckle.converters.common": { + "type": "Project", + "dependencies": { + "Speckle.Autofac": "[2.0.999-local, )", + "Speckle.Objects": "[2.0.999-local, )", + "Speckle.Revit2023.Interfaces": "[0.1.1-preview.0.24, )" + } + }, + "speckle.converters.common.dependencyinjection": { + "type": "Project", + "dependencies": { + "Speckle.Autofac": "[2.0.999-local, )", + "Speckle.Converters.Common": "[2.0.999-local, )" + } + }, + "speckle.converters.revit2023": { + "type": "Project", + "dependencies": { + "Speckle.Converters.Common": "[2.0.999-local, )", + "Speckle.Revit2023.Interfaces": "[0.1.1-preview.0.24, )" + } + }, + "speckle.converters.revit2023.dependencyinjection": { + "type": "Project", + "dependencies": { + "Speckle.Converters.Common": "[2.0.999-local, )", + "Speckle.Converters.Common.DependencyInjection": "[2.0.999-local, )", + "Speckle.Converters.Revit2023": "[2.0.999-local, )", + "Speckle.Revit2023.Api": "[0.1.1-preview.0.24, )" + } + }, + "Speckle.Core": { + "type": "Project", + "dependencies": { + "GraphQL.Client": "[6.0.0, )", + "Microsoft.CSharp": "[4.7.0, )", + "Microsoft.Data.Sqlite": "[7.0.5, )", + "Polly": "[7.2.3, )", + "Polly.Contrib.WaitAndRetry": "[1.1.1, )", + "Polly.Extensions.Http": "[3.0.0, )", + "Sentry": "[3.33.0, )", + "Sentry.Serilog": "[3.33.0, )", + "Serilog": "[2.12.0, )", + "Serilog.Enrichers.ClientInfo": "[1.3.0, )", + "Serilog.Exceptions": "[8.4.0, )", + "Serilog.Sinks.Console": "[4.1.0, )", + "Serilog.Sinks.Seq": "[5.2.2, )", + "SerilogTimings": "[3.0.1, )", + "Speckle.Newtonsoft.Json": "[13.0.2, )", + "System.DoubleNumerics": "[3.1.3, )" + } + }, + "Speckle.Objects": { + "type": "Project", + "dependencies": { + "Speckle.Core": "[2.0.999-local, )" + } + } + } + } +} \ No newline at end of file diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/packages.lock.json b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/packages.lock.json new file mode 100644 index 0000000000..df37836fb8 --- /dev/null +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/packages.lock.json @@ -0,0 +1,530 @@ +{ + "version": 1, + "dependencies": { + ".NETFramework,Version=v4.8": { + "PolySharp": { + "type": "Direct", + "requested": "[1.14.1, )", + "resolved": "1.14.1", + "contentHash": "mOOmFYwad3MIOL14VCjj02LljyF1GNw1wP0YVlxtcPvqdxjGGMNdNJJxHptlry3MOd8b40Flm8RPOM8JOlN2sQ==" + }, + "RhinoCommon": { + "type": "Direct", + "requested": "[7.13.21348.13001, )", + "resolved": "7.13.21348.13001", + "contentHash": "JQdaNw61ddBqIe08E9O4N/grwrN1hjDHcYW7tWylwCZyFR7SepoCD4NS+6LN6+oSQhNbhLi9Bf+hQOFYFdRAEA==" + }, + "RhinoWindows": { + "type": "Direct", + "requested": "[7.13.21348.13001, )", + "resolved": "7.13.21348.13001", + "contentHash": "V94T8emmJmFfmbd5cu+uTNS0neZApx1Q5MXvsQGFtt/mEGEbdHE+dFOETNgbOOJXSdNboAnCR3uo0GosOFX+/g==", + "dependencies": { + "RhinoCommon": "[7.13.21348.13001]" + } + }, + "Speckle.InterfaceGenerator": { + "type": "Direct", + "requested": "[0.9.5, )", + "resolved": "0.9.5", + "contentHash": "oU/L7pN1R7q8KkbrpQ3WJnHirPHqn+9DEA7asOcUiggV5dzVg1A/VYs7GOSusD24njxXh03tE3a2oTLOjt3cVg==" + }, + "System.Resources.Extensions": { + "type": "Direct", + "requested": "[7.0.0, )", + "resolved": "7.0.0", + "contentHash": "65ufm9ABXvxRkQ//hMcUDrQXbGWkC7z0WWZAvHlQ6Qv+JmrIwHH1lmX8aXlNlXpIrT9KxDpuZPqJTVqqwzMD8Q==", + "dependencies": { + "System.Memory": "4.5.5" + } + }, + "GraphQL.Client": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "8yPNBbuVBpTptivyAlak4GZvbwbUcjeQTL4vN1HKHRuOykZ4r7l5fcLS6vpyPyLn0x8FsL31xbOIKyxbmR9rbA==", + "dependencies": { + "GraphQL.Client.Abstractions": "6.0.0", + "GraphQL.Client.Abstractions.Websocket": "6.0.0", + "System.Net.WebSockets.Client.Managed": "1.0.22", + "System.Reactive": "5.0.0" + } + }, + "GraphQL.Client.Abstractions": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "h7uzWFORHZ+CCjwr/ThAyXMr0DPpzEANDa4Uo54wqCQ+j7qUKwqYTgOrb1W40sqbvNaZm9v/X7It31SUw0maHA==", + "dependencies": { + "GraphQL.Primitives": "6.0.0" + } + }, + "GraphQL.Client.Abstractions.Websocket": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "Nr9bPf8gIOvLuXpqEpqr9z9jslYFJOvd0feHth3/kPqeR3uMbjF5pjiwh4jxyMcxHdr8Pb6QiXkV3hsSyt0v7A==", + "dependencies": { + "GraphQL.Client.Abstractions": "6.0.0" + } + }, + "GraphQL.Primitives": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "yg72rrYDapfsIUrul7aF6wwNnTJBOFvuA9VdDTQpPa8AlAriHbufeXYLBcodKjfUdkCnaiggX1U/nEP08Zb5GA==" + }, + "Microsoft.Bcl.AsyncInterfaces": { + "type": "Transitive", + "resolved": "7.0.0", + "contentHash": "3aeMZ1N0lJoSyzqiP03hqemtb1BijhsJADdobn/4nsMJ8V1H+CrpuduUe4hlRdx+ikBQju1VGjMD1GJ3Sk05Eg==", + "dependencies": { + "System.Threading.Tasks.Extensions": "4.5.4" + } + }, + "Microsoft.CSharp": { + "type": "Transitive", + "resolved": "4.7.0", + "contentHash": "pTj+D3uJWyN3My70i2Hqo+OXixq3Os2D1nJ2x92FFo6sk8fYS1m1WLNTs0Dc1uPaViH0YvEEwvzddQ7y4rhXmA==" + }, + "Microsoft.Data.Sqlite": { + "type": "Transitive", + "resolved": "7.0.5", + "contentHash": "KGxbPeWsQMnmQy43DSBxAFtHz3l2JX8EWBSGUCvT3CuZ8KsuzbkqMIJMDOxWtG8eZSoCDI04aiVQjWuuV8HmSw==", + "dependencies": { + "Microsoft.Data.Sqlite.Core": "7.0.5", + "SQLitePCLRaw.bundle_e_sqlite3": "2.1.4" + } + }, + "Microsoft.Data.Sqlite.Core": { + "type": "Transitive", + "resolved": "7.0.5", + "contentHash": "FTerRmQPqHrCrnoUzhBu+E+1DNGwyrAMLqHkAqOOOu5pGfyMOj8qQUBxI/gDtWtG11p49UxSfWmBzRNlwZqfUg==", + "dependencies": { + "SQLitePCLRaw.core": "2.1.4" + } + }, + "Microsoft.Extensions.DependencyInjection": { + "type": "Transitive", + "resolved": "7.0.0", + "contentHash": "elNeOmkeX3eDVG6pYVeV82p29hr+UKDaBhrZyWvWLw/EVZSYEkZlQdkp0V39k/Xehs2Qa0mvoCvkVj3eQxNQ1Q==", + "dependencies": { + "Microsoft.Bcl.AsyncInterfaces": "7.0.0", + "Microsoft.Extensions.DependencyInjection.Abstractions": "7.0.0", + "System.Threading.Tasks.Extensions": "4.5.4" + } + }, + "Microsoft.Extensions.DependencyInjection.Abstractions": { + "type": "Transitive", + "resolved": "7.0.0", + "contentHash": "h3j/QfmFN4S0w4C2A6X7arXij/M/OVw3uQHSOFxnND4DyAzO1F9eMX7Eti7lU/OkSthEE0WzRsfT/Dmx86jzCw==", + "dependencies": { + "Microsoft.Bcl.AsyncInterfaces": "7.0.0", + "System.Threading.Tasks.Extensions": "4.5.4" + } + }, + "Microsoft.Extensions.Logging": { + "type": "Transitive", + "resolved": "7.0.0", + "contentHash": "Nw2muoNrOG5U5qa2ZekXwudUn2BJcD41e65zwmDHb1fQegTX66UokLWZkJRpqSSHXDOWZ5V0iqhbxOEky91atA==", + "dependencies": { + "Microsoft.Bcl.AsyncInterfaces": "7.0.0", + "Microsoft.Extensions.DependencyInjection": "7.0.0", + "Microsoft.Extensions.DependencyInjection.Abstractions": "7.0.0", + "Microsoft.Extensions.Logging.Abstractions": "7.0.0", + "Microsoft.Extensions.Options": "7.0.0", + "System.Diagnostics.DiagnosticSource": "7.0.0", + "System.ValueTuple": "4.5.0" + } + }, + "Microsoft.Extensions.Logging.Abstractions": { + "type": "Transitive", + "resolved": "7.0.0", + "contentHash": "kmn78+LPVMOWeITUjIlfxUPDsI0R6G0RkeAMBmQxAJ7vBJn4q2dTva7pWi65ceN5vPGjJ9q/Uae2WKgvfktJAw==", + "dependencies": { + "System.Buffers": "4.5.1", + "System.Memory": "4.5.5" + } + }, + "Microsoft.Extensions.Options": { + "type": "Transitive", + "resolved": "7.0.0", + "contentHash": "lP1yBnTTU42cKpMozuafbvNtQ7QcBjr/CcK3bYOGEMH55Fjt+iecXjT6chR7vbgCMqy3PG3aNQSZgo/EuY/9qQ==", + "dependencies": { + "Microsoft.Extensions.DependencyInjection.Abstractions": "7.0.0", + "Microsoft.Extensions.Primitives": "7.0.0" + } + }, + "Microsoft.Extensions.Primitives": { + "type": "Transitive", + "resolved": "7.0.0", + "contentHash": "um1KU5kxcRp3CNuI8o/GrZtD4AIOXDk+RLsytjZ9QPok3ttLUelLKpilVPuaFT3TFjOhSibUAso0odbOaCDj3Q==", + "dependencies": { + "System.Memory": "4.5.5", + "System.Runtime.CompilerServices.Unsafe": "6.0.0" + } + }, + "Microsoft.Web.WebView2": { + "type": "Transitive", + "resolved": "1.0.1823.32", + "contentHash": "ppRcWBUNggFIqyJp7PfgS4Oe8/7yli/mHcTNDOaqo3ZzJWnv9AOr0WE9ceEP5SPs1M7CQ3QvdGMR7KNz0v09EA==" + }, + "Polly": { + "type": "Transitive", + "resolved": "7.2.3", + "contentHash": "DeCY0OFbNdNxsjntr1gTXHJ5pKUwYzp04Er2LLeN3g6pWhffsGuKVfMBLe1lw7x76HrPkLxKEFxBlpRxS2nDEQ==" + }, + "Polly.Contrib.WaitAndRetry": { + "type": "Transitive", + "resolved": "1.1.1", + "contentHash": "1MUQLiSo4KDkQe6nzQRhIU05lm9jlexX5BVsbuw0SL82ynZ+GzAHQxJVDPVBboxV37Po3SG077aX8DuSy8TkaA==" + }, + "Polly.Extensions.Http": { + "type": "Transitive", + "resolved": "3.0.0", + "contentHash": "drrG+hB3pYFY7w1c3BD+lSGYvH2oIclH8GRSehgfyP5kjnFnHKQuuBhuHLv+PWyFuaTDyk/vfRpnxOzd11+J8g==", + "dependencies": { + "Polly": "7.1.0" + } + }, + "Sentry": { + "type": "Transitive", + "resolved": "3.33.0", + "contentHash": "8vbD2o6IR2wrRrkSiRbnodWGWUOqIlwYtzpjvPNOb5raJdOf+zxMwfS8f6nx9bmrTTfDj7KrCB8C/5OuicAc8A==", + "dependencies": { + "System.Reflection.Metadata": "5.0.0", + "System.Runtime.InteropServices.RuntimeInformation": "4.3.0", + "System.Text.Json": "5.0.2" + } + }, + "Sentry.Serilog": { + "type": "Transitive", + "resolved": "3.33.0", + "contentHash": "V8BU7QGWg2qLYfNPqtuTBhC1opysny5l+Ifp6J6PhOeAxU0FssR7nYfbJVetrnLIoh2rd3DlJ6hHYYQosQYcUQ==", + "dependencies": { + "Sentry": "3.33.0", + "Serilog": "2.7.1" + } + }, + "Serilog": { + "type": "Transitive", + "resolved": "2.12.0", + "contentHash": "xaiJLIdu6rYMKfQMYUZgTy8YK7SMZjB4Yk50C/u//Z4OsvxkUfSPJy4nknfvwAC34yr13q7kcyh4grbwhSxyZg==" + }, + "Serilog.Enrichers.ClientInfo": { + "type": "Transitive", + "resolved": "1.3.0", + "contentHash": "mTc7PM+wC9Hr7LWSwqt5mmnlAr7RJs+eTb3PGPRhwdOackk95MkhUZognuxXEdlW19HAFNmEBTSBY5DfLwM8jQ==", + "dependencies": { + "Serilog": "2.4.0" + } + }, + "Serilog.Exceptions": { + "type": "Transitive", + "resolved": "8.4.0", + "contentHash": "nc/+hUw3lsdo0zCj0KMIybAu7perMx79vu72w0za9Nsi6mWyNkGXxYxakAjWB7nEmYL6zdmhEQRB4oJ2ALUeug==", + "dependencies": { + "Serilog": "2.8.0" + } + }, + "Serilog.Extensions.Logging": { + "type": "Transitive", + "resolved": "7.0.0", + "contentHash": "9faU0zNQqU7I6soVhLUMYaGNpgWv6cKlKb2S5AnS8gXxzW/em5Ladm/6FMrWTnX41cdbdGPOWNAo6adi4WaJ6A==", + "dependencies": { + "Microsoft.Extensions.Logging": "7.0.0", + "Serilog": "2.12.0" + } + }, + "Serilog.Formatting.Compact": { + "type": "Transitive", + "resolved": "1.1.0", + "contentHash": "pNroKVjo+rDqlxNG5PXkRLpfSCuDOBY0ri6jp9PLe505ljqwhwZz8ospy2vWhQlFu5GkIesh3FcDs4n7sWZODA==", + "dependencies": { + "Serilog": "2.8.0" + } + }, + "Serilog.Sinks.Console": { + "type": "Transitive", + "resolved": "4.1.0", + "contentHash": "K6N5q+5fetjnJPvCmkWOpJ/V8IEIoMIB1s86OzBrbxwTyHxdx3pmz4H+8+O/Dc/ftUX12DM1aynx/dDowkwzqg==", + "dependencies": { + "Serilog": "2.10.0" + } + }, + "Serilog.Sinks.File": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "uwV5hdhWPwUH1szhO8PJpFiahqXmzPzJT/sOijH/kFgUx+cyoDTMM8MHD0adw9+Iem6itoibbUXHYslzXsLEAg==", + "dependencies": { + "Serilog": "2.10.0" + } + }, + "Serilog.Sinks.PeriodicBatching": { + "type": "Transitive", + "resolved": "3.1.0", + "contentHash": "NDWR7m3PalVlGEq3rzoktrXikjFMLmpwF0HI4sowo8YDdU+gqPlTHlDQiOGxHfB0sTfjPA9JjA7ctKG9zqjGkw==", + "dependencies": { + "Serilog": "2.0.0" + } + }, + "Serilog.Sinks.Seq": { + "type": "Transitive", + "resolved": "5.2.2", + "contentHash": "1Csmo5ua7NKUe0yXUx+zsRefjAniPWcXFhUXxXG8pwo0iMiw2gjn9SOkgYnnxbgWqmlGv236w0N/dHc2v5XwMg==", + "dependencies": { + "Serilog": "2.12.0", + "Serilog.Formatting.Compact": "1.1.0", + "Serilog.Sinks.File": "5.0.0", + "Serilog.Sinks.PeriodicBatching": "3.1.0" + } + }, + "SerilogTimings": { + "type": "Transitive", + "resolved": "3.0.1", + "contentHash": "Zs28eTgszAMwpIrbBnWHBI50yuxL50p/dmAUWmy75+axdZYK/Sjm5/5m1N/CisR8acJUhTVcjPZrsB1P5iv0Uw==", + "dependencies": { + "Serilog": "2.10.0" + } + }, + "Speckle.Newtonsoft.Json": { + "type": "Transitive", + "resolved": "13.0.2", + "contentHash": "g1BejUZwax5PRfL6xHgLEK23sqHWOgOj9hE7RvfRRlN00AGt8GnPYt8HedSK7UB3HiRW8zCA9Pn0iiYxCK24BA==" + }, + "Speckle.Revit2023.Interfaces": { + "type": "Transitive", + "resolved": "0.1.1-preview.0.24", + "contentHash": "BSVpOUJc9g6ISrw8GxvtkglTlITpHEDYNOhxv1ZPbckBsI0yO36JiphhQV4q57ERqD9PpCozUJkVhlCaxWeS6A==" + }, + "SQLitePCLRaw.bundle_e_sqlite3": { + "type": "Transitive", + "resolved": "2.1.4", + "contentHash": "EWI1olKDjFEBMJu0+3wuxwziIAdWDVMYLhuZ3Qs84rrz+DHwD00RzWPZCa+bLnHCf3oJwuFZIRsHT5p236QXww==", + "dependencies": { + "SQLitePCLRaw.lib.e_sqlite3": "2.1.4", + "SQLitePCLRaw.provider.dynamic_cdecl": "2.1.4" + } + }, + "SQLitePCLRaw.core": { + "type": "Transitive", + "resolved": "2.1.4", + "contentHash": "inBjvSHo9UDKneGNzfUfDjK08JzlcIhn1+SP5Y3m6cgXpCxXKCJDy6Mka7LpgSV+UZmKSnC8rTwB0SQ0xKu5pA==", + "dependencies": { + "System.Memory": "4.5.3" + } + }, + "SQLitePCLRaw.lib.e_sqlite3": { + "type": "Transitive", + "resolved": "2.1.4", + "contentHash": "2C9Q9eX7CPLveJA0rIhf9RXAvu+7nWZu1A2MdG6SD/NOu26TakGgL1nsbc0JAspGijFOo3HoN79xrx8a368fBg==" + }, + "SQLitePCLRaw.provider.dynamic_cdecl": { + "type": "Transitive", + "resolved": "2.1.4", + "contentHash": "ZsaKKhgYF9B1fvcnOGKl3EycNAwd9CRWX7v0rEfuPWhQQ5Jjpvf2VEHahiLIGHio3hxi3EIKFJw9KvyowWOUAw==", + "dependencies": { + "SQLitePCLRaw.core": "2.1.4" + } + }, + "System.Buffers": { + "type": "Transitive", + "resolved": "4.5.1", + "contentHash": "Rw7ijyl1qqRS0YQD/WycNst8hUUMgrMH4FCn1nNm27M4VxchZ1js3fVjQaANHO5f3sN4isvP4a+Met9Y4YomAg==" + }, + "System.Collections.Immutable": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "FXkLXiK0sVVewcso0imKQoOxjoPAj42R8HtjjbSjVPAzwDfzoyoznWxgA3c38LDbN9SJux1xXoXYAhz98j7r2g==", + "dependencies": { + "System.Memory": "4.5.4" + } + }, + "System.Diagnostics.DiagnosticSource": { + "type": "Transitive", + "resolved": "7.0.0", + "contentHash": "9W0ewWDuAyDqS2PigdTxk6jDKonfgscY/hP8hm7VpxYhNHZHKvZTdRckberlFk3VnCmr3xBUyMBut12Q+T2aOw==", + "dependencies": { + "System.Memory": "4.5.5", + "System.Runtime.CompilerServices.Unsafe": "6.0.0" + } + }, + "System.DoubleNumerics": { + "type": "Transitive", + "resolved": "3.1.3", + "contentHash": "KRKEM/L3KBodjA9VOg3EifFVWUY6EOqaMB05UvPEDm7Zeby/kZW+4kdWUEPzW6xtkwf46p661L9NrbeeQhtLzw==", + "dependencies": { + "NETStandard.Library": "1.6.1" + } + }, + "System.Memory": { + "type": "Transitive", + "resolved": "4.5.5", + "contentHash": "XIWiDvKPXaTveaB7HVganDlOCRoj03l+jrwNvcge/t8vhGYKvqV+dMv6G4SAX2NoNmN0wZfVPTAlFwZcZvVOUw==", + "dependencies": { + "System.Buffers": "4.5.1", + "System.Numerics.Vectors": "4.5.0", + "System.Runtime.CompilerServices.Unsafe": "4.5.3" + } + }, + "System.Net.WebSockets.Client.Managed": { + "type": "Transitive", + "resolved": "1.0.22", + "contentHash": "WqEOxPlXjuZrIjUtXNE9NxEfU/n5E35iV2PtoZdJSUC4tlrqwHnTee+wvMIM4OUaJWmwrymeqcgYrE0IkGAgLA==", + "dependencies": { + "System.Buffers": "4.4.0", + "System.Numerics.Vectors": "4.4.0" + } + }, + "System.Numerics.Vectors": { + "type": "Transitive", + "resolved": "4.5.0", + "contentHash": "QQTlPTl06J/iiDbJCiepZ4H//BVraReU4O4EoRw1U02H5TLUIT7xn3GnDp9AXPSlJUDyFs4uWjWafNX6WrAojQ==" + }, + "System.Reactive": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "erBZjkQHWL9jpasCE/0qKAryzVBJFxGHVBAvgRN1bzM0q2s1S4oYREEEL0Vb+1kA/6BKb5FjUZMp5VXmy+gzkQ==", + "dependencies": { + "System.Threading.Tasks.Extensions": "4.5.4" + } + }, + "System.Reflection.Metadata": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "5NecZgXktdGg34rh1OenY1rFNDCI8xSjFr+Z4OU4cU06AQHUdRnIIEeWENu3Wl4YowbzkymAIMvi3WyK9U53pQ==", + "dependencies": { + "System.Collections.Immutable": "5.0.0" + } + }, + "System.Runtime.CompilerServices.Unsafe": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "/iUeP3tq1S0XdNNoMz5C9twLSrM/TH+qElHkXWaPvuNOt+99G75NrV0OS2EqHx5wMN7popYjpc8oTjC1y16DLg==" + }, + "System.Runtime.InteropServices.RuntimeInformation": { + "type": "Transitive", + "resolved": "4.3.0", + "contentHash": "cbz4YJMqRDR7oLeMRbdYv7mYzc++17lNhScCX0goO2XpGWdvAt60CGN+FHdePUEHCe/Jy9jUlvNAiNdM+7jsOw==" + }, + "System.Text.Encodings.Web": { + "type": "Transitive", + "resolved": "5.0.1", + "contentHash": "KmJ+CJXizDofbq6mpqDoRRLcxgOd2z9X3XoFNULSbvbqVRZkFX3istvr+MUjL6Zw1RT+RNdoI4GYidIINtgvqQ==", + "dependencies": { + "System.Buffers": "4.5.1", + "System.Memory": "4.5.4" + } + }, + "System.Text.Json": { + "type": "Transitive", + "resolved": "5.0.2", + "contentHash": "I47dVIGiV6SfAyppphxqupertT/5oZkYLDCX6vC3HpOI4ZLjyoKAreUoem2ie6G0RbRuFrlqz/PcTQjfb2DOfQ==", + "dependencies": { + "Microsoft.Bcl.AsyncInterfaces": "5.0.0", + "System.Buffers": "4.5.1", + "System.Memory": "4.5.4", + "System.Numerics.Vectors": "4.5.0", + "System.Runtime.CompilerServices.Unsafe": "5.0.0", + "System.Text.Encodings.Web": "5.0.1", + "System.Threading.Tasks.Extensions": "4.5.4", + "System.ValueTuple": "4.5.0" + } + }, + "System.Threading.Tasks.Dataflow": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "+tyDCU3/B1lDdOOAJywHQoFwyXIUghIaP2BxG79uvhfTnO+D9qIgjVlL/JV2NTliYbMHpd6eKDmHp2VHpij7MA==" + }, + "System.Threading.Tasks.Extensions": { + "type": "Transitive", + "resolved": "4.5.4", + "contentHash": "zteT+G8xuGu6mS+mzDzYXbzS7rd3K6Fjb9RiZlYlJPam2/hU7JCBZBVEcywNuR+oZ1ncTvc/cq0faRr3P01OVg==", + "dependencies": { + "System.Runtime.CompilerServices.Unsafe": "4.5.3" + } + }, + "System.ValueTuple": { + "type": "Transitive", + "resolved": "4.5.0", + "contentHash": "okurQJO6NRE/apDIP23ajJ0hpiNmJ+f0BwOlB/cSqTLQlw5upkf+5+96+iG2Jw40G1fCVCyPz/FhIABUjMR+RQ==" + }, + "speckle.autofac": { + "type": "Project", + "dependencies": { + "Microsoft.Extensions.Logging.Abstractions": "[7.0.0, )", + "Speckle.Core": "[2.0.999-local, )" + } + }, + "speckle.connectors.dui": { + "type": "Project", + "dependencies": { + "Microsoft.Extensions.Logging.Abstractions": "[7.0.0, )", + "Speckle.Autofac": "[2.0.999-local, )", + "Speckle.Connectors.Utils": "[2.0.999-local, )", + "Speckle.Core": "[2.0.999-local, )", + "System.Threading.Tasks.Dataflow": "[6.0.0, )" + } + }, + "speckle.connectors.dui.webview": { + "type": "Project", + "dependencies": { + "Microsoft.Web.WebView2": "[1.0.1823.32, )", + "Speckle.Connectors.DUI": "[2.0.999-local, )" + } + }, + "speckle.connectors.utils": { + "type": "Project", + "dependencies": { + "Serilog.Extensions.Logging": "[7.0.0, )", + "Speckle.Autofac": "[2.0.999-local, )", + "Speckle.Core": "[2.0.999-local, )" + } + }, + "speckle.converters.common": { + "type": "Project", + "dependencies": { + "Speckle.Autofac": "[2.0.999-local, )", + "Speckle.Objects": "[2.0.999-local, )", + "Speckle.Revit2023.Interfaces": "[0.1.1-preview.0.24, )" + } + }, + "speckle.converters.common.dependencyinjection": { + "type": "Project", + "dependencies": { + "Speckle.Autofac": "[2.0.999-local, )", + "Speckle.Converters.Common": "[2.0.999-local, )" + } + }, + "speckle.converters.rhino7.dependencyinjection": { + "type": "Project", + "dependencies": { + "RhinoCommon": "[7.13.21348.13001, )" + } + }, + "Speckle.Core": { + "type": "Project", + "dependencies": { + "GraphQL.Client": "[6.0.0, )", + "Microsoft.CSharp": "[4.7.0, )", + "Microsoft.Data.Sqlite": "[7.0.5, )", + "Polly": "[7.2.3, )", + "Polly.Contrib.WaitAndRetry": "[1.1.1, )", + "Polly.Extensions.Http": "[3.0.0, )", + "Sentry": "[3.33.0, )", + "Sentry.Serilog": "[3.33.0, )", + "Serilog": "[2.12.0, )", + "Serilog.Enrichers.ClientInfo": "[1.3.0, )", + "Serilog.Exceptions": "[8.4.0, )", + "Serilog.Sinks.Console": "[4.1.0, )", + "Serilog.Sinks.Seq": "[5.2.2, )", + "SerilogTimings": "[3.0.1, )", + "Speckle.Newtonsoft.Json": "[13.0.2, )", + "System.DoubleNumerics": "[3.1.3, )" + } + }, + "Speckle.Objects": { + "type": "Project", + "dependencies": { + "Speckle.Core": "[2.0.999-local, )" + } + } + } + } +} \ No newline at end of file diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3.DependencyInjection/packages.lock.json b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3.DependencyInjection/packages.lock.json new file mode 100644 index 0000000000..308e61b7c6 --- /dev/null +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3.DependencyInjection/packages.lock.json @@ -0,0 +1,409 @@ +{ + "version": 1, + "dependencies": { + "net6.0-windows7.0": { + "Autofac": { + "type": "Direct", + "requested": "[5.2.0, )", + "resolved": "5.2.0", + "contentHash": "V8dBH0dsv75uDzl7Sw+HkhKDPUw2eXnlMjcSVMH+tLo2s67MpTKGyDj1pDcpR+IF2u4YRs0s3/x7R88YJzIWvg==" + }, + "PolySharp": { + "type": "Direct", + "requested": "[1.14.1, )", + "resolved": "1.14.1", + "contentHash": "mOOmFYwad3MIOL14VCjj02LljyF1GNw1wP0YVlxtcPvqdxjGGMNdNJJxHptlry3MOd8b40Flm8RPOM8JOlN2sQ==" + }, + "Speckle.InterfaceGenerator": { + "type": "Direct", + "requested": "[0.9.5, )", + "resolved": "0.9.5", + "contentHash": "oU/L7pN1R7q8KkbrpQ3WJnHirPHqn+9DEA7asOcUiggV5dzVg1A/VYs7GOSusD24njxXh03tE3a2oTLOjt3cVg==" + }, + "Esri.ArcGISPro.Extensions30": { + "type": "Transitive", + "resolved": "3.2.0.49743", + "contentHash": "fmnYm+mD14Cz0Uqh1ij37SfLJerkyFHK5581y5tXT/l3H2ZvUmVuuxjYquXzyzj9p7IexQzMW4xCpxe+mD922g==" + }, + "GraphQL.Client": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "8yPNBbuVBpTptivyAlak4GZvbwbUcjeQTL4vN1HKHRuOykZ4r7l5fcLS6vpyPyLn0x8FsL31xbOIKyxbmR9rbA==", + "dependencies": { + "GraphQL.Client.Abstractions": "6.0.0", + "GraphQL.Client.Abstractions.Websocket": "6.0.0", + "System.Reactive": "5.0.0" + } + }, + "GraphQL.Client.Abstractions": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "h7uzWFORHZ+CCjwr/ThAyXMr0DPpzEANDa4Uo54wqCQ+j7qUKwqYTgOrb1W40sqbvNaZm9v/X7It31SUw0maHA==", + "dependencies": { + "GraphQL.Primitives": "6.0.0" + } + }, + "GraphQL.Client.Abstractions.Websocket": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "Nr9bPf8gIOvLuXpqEpqr9z9jslYFJOvd0feHth3/kPqeR3uMbjF5pjiwh4jxyMcxHdr8Pb6QiXkV3hsSyt0v7A==", + "dependencies": { + "GraphQL.Client.Abstractions": "6.0.0" + } + }, + "GraphQL.Primitives": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "yg72rrYDapfsIUrul7aF6wwNnTJBOFvuA9VdDTQpPa8AlAriHbufeXYLBcodKjfUdkCnaiggX1U/nEP08Zb5GA==" + }, + "Microsoft.AspNetCore.Http": { + "type": "Transitive", + "resolved": "2.2.2", + "contentHash": "BAibpoItxI5puk7YJbIGj95arZueM8B8M5xT1fXBn3hb3L2G3ucrZcYXv1gXdaroLbntUs8qeV8iuBrpjQsrKw==", + "dependencies": { + "Microsoft.AspNetCore.Http.Abstractions": "2.2.0", + "Microsoft.AspNetCore.WebUtilities": "2.2.0", + "Microsoft.Extensions.ObjectPool": "2.2.0", + "Microsoft.Extensions.Options": "2.2.0", + "Microsoft.Net.Http.Headers": "2.2.0" + } + }, + "Microsoft.AspNetCore.Http.Abstractions": { + "type": "Transitive", + "resolved": "2.2.0", + "contentHash": "Nxs7Z1q3f1STfLYKJSVXCs1iBl+Ya6E8o4Oy1bCxJ/rNI44E/0f6tbsrVqAWfB7jlnJfyaAtIalBVxPKUPQb4Q==", + "dependencies": { + "Microsoft.AspNetCore.Http.Features": "2.2.0", + "System.Text.Encodings.Web": "4.5.0" + } + }, + "Microsoft.AspNetCore.Http.Features": { + "type": "Transitive", + "resolved": "2.2.0", + "contentHash": "ziFz5zH8f33En4dX81LW84I6XrYXKf9jg6aM39cM+LffN9KJahViKZ61dGMSO2gd3e+qe5yBRwsesvyqlZaSMg==", + "dependencies": { + "Microsoft.Extensions.Primitives": "2.2.0" + } + }, + "Microsoft.AspNetCore.WebUtilities": { + "type": "Transitive", + "resolved": "2.2.0", + "contentHash": "9ErxAAKaDzxXASB/b5uLEkLgUWv1QbeVxyJYEHQwMaxXOeFFVkQxiq8RyfVcifLU7NR0QY0p3acqx4ZpYfhHDg==", + "dependencies": { + "Microsoft.Net.Http.Headers": "2.2.0", + "System.Text.Encodings.Web": "4.5.0" + } + }, + "Microsoft.CSharp": { + "type": "Transitive", + "resolved": "4.7.0", + "contentHash": "pTj+D3uJWyN3My70i2Hqo+OXixq3Os2D1nJ2x92FFo6sk8fYS1m1WLNTs0Dc1uPaViH0YvEEwvzddQ7y4rhXmA==" + }, + "Microsoft.Data.Sqlite": { + "type": "Transitive", + "resolved": "7.0.5", + "contentHash": "KGxbPeWsQMnmQy43DSBxAFtHz3l2JX8EWBSGUCvT3CuZ8KsuzbkqMIJMDOxWtG8eZSoCDI04aiVQjWuuV8HmSw==", + "dependencies": { + "Microsoft.Data.Sqlite.Core": "7.0.5", + "SQLitePCLRaw.bundle_e_sqlite3": "2.1.4" + } + }, + "Microsoft.Data.Sqlite.Core": { + "type": "Transitive", + "resolved": "7.0.5", + "contentHash": "FTerRmQPqHrCrnoUzhBu+E+1DNGwyrAMLqHkAqOOOu5pGfyMOj8qQUBxI/gDtWtG11p49UxSfWmBzRNlwZqfUg==", + "dependencies": { + "SQLitePCLRaw.core": "2.1.4" + } + }, + "Microsoft.Extensions.DependencyInjection.Abstractions": { + "type": "Transitive", + "resolved": "2.2.0", + "contentHash": "f9hstgjVmr6rmrfGSpfsVOl2irKAgr1QjrSi3FgnS7kulxband50f2brRLwySAQTADPZeTdow0mpSMcoAdadCw==" + }, + "Microsoft.Extensions.Logging.Abstractions": { + "type": "Transitive", + "resolved": "7.0.0", + "contentHash": "kmn78+LPVMOWeITUjIlfxUPDsI0R6G0RkeAMBmQxAJ7vBJn4q2dTva7pWi65ceN5vPGjJ9q/Uae2WKgvfktJAw==" + }, + "Microsoft.Extensions.ObjectPool": { + "type": "Transitive", + "resolved": "2.2.0", + "contentHash": "gA8H7uQOnM5gb+L0uTNjViHYr+hRDqCdfugheGo/MxQnuHzmhhzCBTIPm19qL1z1Xe0NEMabfcOBGv9QghlZ8g==" + }, + "Microsoft.Extensions.Options": { + "type": "Transitive", + "resolved": "2.2.0", + "contentHash": "UpZLNLBpIZ0GTebShui7xXYh6DmBHjWM8NxGxZbdQh/bPZ5e6YswqI+bru6BnEL5eWiOdodsXtEz3FROcgi/qg==", + "dependencies": { + "Microsoft.Extensions.DependencyInjection.Abstractions": "2.2.0", + "Microsoft.Extensions.Primitives": "2.2.0", + "System.ComponentModel.Annotations": "4.5.0" + } + }, + "Microsoft.Extensions.Primitives": { + "type": "Transitive", + "resolved": "2.2.0", + "contentHash": "azyQtqbm4fSaDzZHD/J+V6oWMFaf2tWP4WEGIYePLCMw3+b2RQdj9ybgbQyjCshcitQKQ4lEDOZjmSlTTrHxUg==", + "dependencies": { + "System.Memory": "4.5.1", + "System.Runtime.CompilerServices.Unsafe": "4.5.1" + } + }, + "Microsoft.Net.Http.Headers": { + "type": "Transitive", + "resolved": "2.2.0", + "contentHash": "iZNkjYqlo8sIOI0bQfpsSoMTmB/kyvmV2h225ihyZT33aTp48ZpF6qYnXxzSXmHt8DpBAwBTX+1s1UFLbYfZKg==", + "dependencies": { + "Microsoft.Extensions.Primitives": "2.2.0", + "System.Buffers": "4.5.0" + } + }, + "Polly": { + "type": "Transitive", + "resolved": "7.2.3", + "contentHash": "DeCY0OFbNdNxsjntr1gTXHJ5pKUwYzp04Er2LLeN3g6pWhffsGuKVfMBLe1lw7x76HrPkLxKEFxBlpRxS2nDEQ==" + }, + "Polly.Contrib.WaitAndRetry": { + "type": "Transitive", + "resolved": "1.1.1", + "contentHash": "1MUQLiSo4KDkQe6nzQRhIU05lm9jlexX5BVsbuw0SL82ynZ+GzAHQxJVDPVBboxV37Po3SG077aX8DuSy8TkaA==" + }, + "Polly.Extensions.Http": { + "type": "Transitive", + "resolved": "3.0.0", + "contentHash": "drrG+hB3pYFY7w1c3BD+lSGYvH2oIclH8GRSehgfyP5kjnFnHKQuuBhuHLv+PWyFuaTDyk/vfRpnxOzd11+J8g==", + "dependencies": { + "Polly": "7.1.0" + } + }, + "Sentry": { + "type": "Transitive", + "resolved": "3.33.0", + "contentHash": "8vbD2o6IR2wrRrkSiRbnodWGWUOqIlwYtzpjvPNOb5raJdOf+zxMwfS8f6nx9bmrTTfDj7KrCB8C/5OuicAc8A==" + }, + "Sentry.Serilog": { + "type": "Transitive", + "resolved": "3.33.0", + "contentHash": "V8BU7QGWg2qLYfNPqtuTBhC1opysny5l+Ifp6J6PhOeAxU0FssR7nYfbJVetrnLIoh2rd3DlJ6hHYYQosQYcUQ==", + "dependencies": { + "Sentry": "3.33.0", + "Serilog": "2.10.0" + } + }, + "Serilog": { + "type": "Transitive", + "resolved": "2.12.0", + "contentHash": "xaiJLIdu6rYMKfQMYUZgTy8YK7SMZjB4Yk50C/u//Z4OsvxkUfSPJy4nknfvwAC34yr13q7kcyh4grbwhSxyZg==" + }, + "Serilog.Enrichers.ClientInfo": { + "type": "Transitive", + "resolved": "1.3.0", + "contentHash": "mTc7PM+wC9Hr7LWSwqt5mmnlAr7RJs+eTb3PGPRhwdOackk95MkhUZognuxXEdlW19HAFNmEBTSBY5DfLwM8jQ==", + "dependencies": { + "Microsoft.AspNetCore.Http": "2.2.2", + "Serilog": "2.9.0" + } + }, + "Serilog.Exceptions": { + "type": "Transitive", + "resolved": "8.4.0", + "contentHash": "nc/+hUw3lsdo0zCj0KMIybAu7perMx79vu72w0za9Nsi6mWyNkGXxYxakAjWB7nEmYL6zdmhEQRB4oJ2ALUeug==", + "dependencies": { + "Serilog": "2.8.0", + "System.Reflection.TypeExtensions": "4.7.0" + } + }, + "Serilog.Formatting.Compact": { + "type": "Transitive", + "resolved": "1.1.0", + "contentHash": "pNroKVjo+rDqlxNG5PXkRLpfSCuDOBY0ri6jp9PLe505ljqwhwZz8ospy2vWhQlFu5GkIesh3FcDs4n7sWZODA==", + "dependencies": { + "Serilog": "2.8.0" + } + }, + "Serilog.Sinks.Console": { + "type": "Transitive", + "resolved": "4.1.0", + "contentHash": "K6N5q+5fetjnJPvCmkWOpJ/V8IEIoMIB1s86OzBrbxwTyHxdx3pmz4H+8+O/Dc/ftUX12DM1aynx/dDowkwzqg==", + "dependencies": { + "Serilog": "2.10.0" + } + }, + "Serilog.Sinks.File": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "uwV5hdhWPwUH1szhO8PJpFiahqXmzPzJT/sOijH/kFgUx+cyoDTMM8MHD0adw9+Iem6itoibbUXHYslzXsLEAg==", + "dependencies": { + "Serilog": "2.10.0" + } + }, + "Serilog.Sinks.PeriodicBatching": { + "type": "Transitive", + "resolved": "3.1.0", + "contentHash": "NDWR7m3PalVlGEq3rzoktrXikjFMLmpwF0HI4sowo8YDdU+gqPlTHlDQiOGxHfB0sTfjPA9JjA7ctKG9zqjGkw==", + "dependencies": { + "Serilog": "2.0.0" + } + }, + "Serilog.Sinks.Seq": { + "type": "Transitive", + "resolved": "5.2.2", + "contentHash": "1Csmo5ua7NKUe0yXUx+zsRefjAniPWcXFhUXxXG8pwo0iMiw2gjn9SOkgYnnxbgWqmlGv236w0N/dHc2v5XwMg==", + "dependencies": { + "Serilog": "2.12.0", + "Serilog.Formatting.Compact": "1.1.0", + "Serilog.Sinks.File": "5.0.0", + "Serilog.Sinks.PeriodicBatching": "3.1.0" + } + }, + "SerilogTimings": { + "type": "Transitive", + "resolved": "3.0.1", + "contentHash": "Zs28eTgszAMwpIrbBnWHBI50yuxL50p/dmAUWmy75+axdZYK/Sjm5/5m1N/CisR8acJUhTVcjPZrsB1P5iv0Uw==", + "dependencies": { + "Serilog": "2.10.0" + } + }, + "Speckle.Newtonsoft.Json": { + "type": "Transitive", + "resolved": "13.0.2", + "contentHash": "g1BejUZwax5PRfL6xHgLEK23sqHWOgOj9hE7RvfRRlN00AGt8GnPYt8HedSK7UB3HiRW8zCA9Pn0iiYxCK24BA==" + }, + "Speckle.Revit2023.Interfaces": { + "type": "Transitive", + "resolved": "0.1.1-preview.0.24", + "contentHash": "BSVpOUJc9g6ISrw8GxvtkglTlITpHEDYNOhxv1ZPbckBsI0yO36JiphhQV4q57ERqD9PpCozUJkVhlCaxWeS6A==" + }, + "SQLitePCLRaw.bundle_e_sqlite3": { + "type": "Transitive", + "resolved": "2.1.4", + "contentHash": "EWI1olKDjFEBMJu0+3wuxwziIAdWDVMYLhuZ3Qs84rrz+DHwD00RzWPZCa+bLnHCf3oJwuFZIRsHT5p236QXww==", + "dependencies": { + "SQLitePCLRaw.lib.e_sqlite3": "2.1.4", + "SQLitePCLRaw.provider.e_sqlite3": "2.1.4" + } + }, + "SQLitePCLRaw.core": { + "type": "Transitive", + "resolved": "2.1.4", + "contentHash": "inBjvSHo9UDKneGNzfUfDjK08JzlcIhn1+SP5Y3m6cgXpCxXKCJDy6Mka7LpgSV+UZmKSnC8rTwB0SQ0xKu5pA==", + "dependencies": { + "System.Memory": "4.5.3" + } + }, + "SQLitePCLRaw.lib.e_sqlite3": { + "type": "Transitive", + "resolved": "2.1.4", + "contentHash": "2C9Q9eX7CPLveJA0rIhf9RXAvu+7nWZu1A2MdG6SD/NOu26TakGgL1nsbc0JAspGijFOo3HoN79xrx8a368fBg==" + }, + "SQLitePCLRaw.provider.e_sqlite3": { + "type": "Transitive", + "resolved": "2.1.4", + "contentHash": "CSlb5dUp1FMIkez9Iv5EXzpeq7rHryVNqwJMWnpq87j9zWZexaEMdisDktMsnnrzKM6ahNrsTkjqNodTBPBxtQ==", + "dependencies": { + "SQLitePCLRaw.core": "2.1.4" + } + }, + "System.Buffers": { + "type": "Transitive", + "resolved": "4.5.0", + "contentHash": "pL2ChpaRRWI/p4LXyy4RgeWlYF2sgfj/pnVMvBqwNFr5cXg7CXNnWZWxrOONLg8VGdFB8oB+EG2Qw4MLgTOe+A==" + }, + "System.ComponentModel.Annotations": { + "type": "Transitive", + "resolved": "4.5.0", + "contentHash": "UxYQ3FGUOtzJ7LfSdnYSFd7+oEv6M8NgUatatIN2HxNtDdlcvFAf+VIq4Of9cDMJEJC0aSRv/x898RYhB4Yppg==" + }, + "System.DoubleNumerics": { + "type": "Transitive", + "resolved": "3.1.3", + "contentHash": "KRKEM/L3KBodjA9VOg3EifFVWUY6EOqaMB05UvPEDm7Zeby/kZW+4kdWUEPzW6xtkwf46p661L9NrbeeQhtLzw==", + "dependencies": { + "NETStandard.Library": "1.6.1" + } + }, + "System.Memory": { + "type": "Transitive", + "resolved": "4.5.3", + "contentHash": "3oDzvc/zzetpTKWMShs1AADwZjQ/36HnsufHRPcOjyRAAMLDlu2iD33MBI2opxnezcVUtXyqDXXjoFMOU9c7SA==" + }, + "System.Reactive": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "erBZjkQHWL9jpasCE/0qKAryzVBJFxGHVBAvgRN1bzM0q2s1S4oYREEEL0Vb+1kA/6BKb5FjUZMp5VXmy+gzkQ==" + }, + "System.Reflection.TypeExtensions": { + "type": "Transitive", + "resolved": "4.7.0", + "contentHash": "VybpaOQQhqE6siHppMktjfGBw1GCwvCqiufqmP8F1nj7fTUNtW35LOEt3UZTEsECfo+ELAl/9o9nJx3U91i7vA==" + }, + "System.Runtime.CompilerServices.Unsafe": { + "type": "Transitive", + "resolved": "4.5.1", + "contentHash": "Zh8t8oqolRaFa9vmOZfdQm/qKejdqz0J9kr7o2Fu0vPeoH3BL1EOXipKWwkWtLT1JPzjByrF19fGuFlNbmPpiw==" + }, + "System.Text.Encodings.Web": { + "type": "Transitive", + "resolved": "4.5.0", + "contentHash": "Xg4G4Indi4dqP1iuAiMSwpiWS54ZghzR644OtsRCm/m/lBMG8dUBhLVN7hLm8NNrNTR+iGbshCPTwrvxZPlm4g==" + }, + "speckle.autofac": { + "type": "Project", + "dependencies": { + "Microsoft.Extensions.Logging.Abstractions": "[7.0.0, )", + "Speckle.Core": "[2.0.999-local, )" + } + }, + "speckle.converters.arcgis3": { + "type": "Project", + "dependencies": { + "Esri.ArcGISPro.Extensions30": "[3.2.0.49743, )", + "Speckle.Converters.Common": "[2.0.999-local, )" + } + }, + "speckle.converters.common": { + "type": "Project", + "dependencies": { + "Speckle.Autofac": "[2.0.999-local, )", + "Speckle.Objects": "[2.0.999-local, )", + "Speckle.Revit2023.Interfaces": "[0.1.1-preview.0.24, )" + } + }, + "speckle.converters.common.dependencyinjection": { + "type": "Project", + "dependencies": { + "Speckle.Autofac": "[2.0.999-local, )", + "Speckle.Converters.Common": "[2.0.999-local, )" + } + }, + "Speckle.Core": { + "type": "Project", + "dependencies": { + "GraphQL.Client": "[6.0.0, )", + "Microsoft.CSharp": "[4.7.0, )", + "Microsoft.Data.Sqlite": "[7.0.5, )", + "Polly": "[7.2.3, )", + "Polly.Contrib.WaitAndRetry": "[1.1.1, )", + "Polly.Extensions.Http": "[3.0.0, )", + "Sentry": "[3.33.0, )", + "Sentry.Serilog": "[3.33.0, )", + "Serilog": "[2.12.0, )", + "Serilog.Enrichers.ClientInfo": "[1.3.0, )", + "Serilog.Exceptions": "[8.4.0, )", + "Serilog.Sinks.Console": "[4.1.0, )", + "Serilog.Sinks.Seq": "[5.2.2, )", + "SerilogTimings": "[3.0.1, )", + "Speckle.Newtonsoft.Json": "[13.0.2, )", + "System.DoubleNumerics": "[3.1.3, )" + } + }, + "Speckle.Objects": { + "type": "Project", + "dependencies": { + "Speckle.Core": "[2.0.999-local, )" + } + } + } + } +} \ No newline at end of file diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/packages.lock.json b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/packages.lock.json new file mode 100644 index 0000000000..25847a4ec6 --- /dev/null +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/packages.lock.json @@ -0,0 +1,390 @@ +{ + "version": 1, + "dependencies": { + "net6.0-windows7.0": { + "Esri.ArcGISPro.Extensions30": { + "type": "Direct", + "requested": "[3.2.0.49743, )", + "resolved": "3.2.0.49743", + "contentHash": "fmnYm+mD14Cz0Uqh1ij37SfLJerkyFHK5581y5tXT/l3H2ZvUmVuuxjYquXzyzj9p7IexQzMW4xCpxe+mD922g==" + }, + "PolySharp": { + "type": "Direct", + "requested": "[1.14.1, )", + "resolved": "1.14.1", + "contentHash": "mOOmFYwad3MIOL14VCjj02LljyF1GNw1wP0YVlxtcPvqdxjGGMNdNJJxHptlry3MOd8b40Flm8RPOM8JOlN2sQ==" + }, + "Speckle.InterfaceGenerator": { + "type": "Direct", + "requested": "[0.9.5, )", + "resolved": "0.9.5", + "contentHash": "oU/L7pN1R7q8KkbrpQ3WJnHirPHqn+9DEA7asOcUiggV5dzVg1A/VYs7GOSusD24njxXh03tE3a2oTLOjt3cVg==" + }, + "GraphQL.Client": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "8yPNBbuVBpTptivyAlak4GZvbwbUcjeQTL4vN1HKHRuOykZ4r7l5fcLS6vpyPyLn0x8FsL31xbOIKyxbmR9rbA==", + "dependencies": { + "GraphQL.Client.Abstractions": "6.0.0", + "GraphQL.Client.Abstractions.Websocket": "6.0.0", + "System.Reactive": "5.0.0" + } + }, + "GraphQL.Client.Abstractions": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "h7uzWFORHZ+CCjwr/ThAyXMr0DPpzEANDa4Uo54wqCQ+j7qUKwqYTgOrb1W40sqbvNaZm9v/X7It31SUw0maHA==", + "dependencies": { + "GraphQL.Primitives": "6.0.0" + } + }, + "GraphQL.Client.Abstractions.Websocket": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "Nr9bPf8gIOvLuXpqEpqr9z9jslYFJOvd0feHth3/kPqeR3uMbjF5pjiwh4jxyMcxHdr8Pb6QiXkV3hsSyt0v7A==", + "dependencies": { + "GraphQL.Client.Abstractions": "6.0.0" + } + }, + "GraphQL.Primitives": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "yg72rrYDapfsIUrul7aF6wwNnTJBOFvuA9VdDTQpPa8AlAriHbufeXYLBcodKjfUdkCnaiggX1U/nEP08Zb5GA==" + }, + "Microsoft.AspNetCore.Http": { + "type": "Transitive", + "resolved": "2.2.2", + "contentHash": "BAibpoItxI5puk7YJbIGj95arZueM8B8M5xT1fXBn3hb3L2G3ucrZcYXv1gXdaroLbntUs8qeV8iuBrpjQsrKw==", + "dependencies": { + "Microsoft.AspNetCore.Http.Abstractions": "2.2.0", + "Microsoft.AspNetCore.WebUtilities": "2.2.0", + "Microsoft.Extensions.ObjectPool": "2.2.0", + "Microsoft.Extensions.Options": "2.2.0", + "Microsoft.Net.Http.Headers": "2.2.0" + } + }, + "Microsoft.AspNetCore.Http.Abstractions": { + "type": "Transitive", + "resolved": "2.2.0", + "contentHash": "Nxs7Z1q3f1STfLYKJSVXCs1iBl+Ya6E8o4Oy1bCxJ/rNI44E/0f6tbsrVqAWfB7jlnJfyaAtIalBVxPKUPQb4Q==", + "dependencies": { + "Microsoft.AspNetCore.Http.Features": "2.2.0", + "System.Text.Encodings.Web": "4.5.0" + } + }, + "Microsoft.AspNetCore.Http.Features": { + "type": "Transitive", + "resolved": "2.2.0", + "contentHash": "ziFz5zH8f33En4dX81LW84I6XrYXKf9jg6aM39cM+LffN9KJahViKZ61dGMSO2gd3e+qe5yBRwsesvyqlZaSMg==", + "dependencies": { + "Microsoft.Extensions.Primitives": "2.2.0" + } + }, + "Microsoft.AspNetCore.WebUtilities": { + "type": "Transitive", + "resolved": "2.2.0", + "contentHash": "9ErxAAKaDzxXASB/b5uLEkLgUWv1QbeVxyJYEHQwMaxXOeFFVkQxiq8RyfVcifLU7NR0QY0p3acqx4ZpYfhHDg==", + "dependencies": { + "Microsoft.Net.Http.Headers": "2.2.0", + "System.Text.Encodings.Web": "4.5.0" + } + }, + "Microsoft.CSharp": { + "type": "Transitive", + "resolved": "4.7.0", + "contentHash": "pTj+D3uJWyN3My70i2Hqo+OXixq3Os2D1nJ2x92FFo6sk8fYS1m1WLNTs0Dc1uPaViH0YvEEwvzddQ7y4rhXmA==" + }, + "Microsoft.Data.Sqlite": { + "type": "Transitive", + "resolved": "7.0.5", + "contentHash": "KGxbPeWsQMnmQy43DSBxAFtHz3l2JX8EWBSGUCvT3CuZ8KsuzbkqMIJMDOxWtG8eZSoCDI04aiVQjWuuV8HmSw==", + "dependencies": { + "Microsoft.Data.Sqlite.Core": "7.0.5", + "SQLitePCLRaw.bundle_e_sqlite3": "2.1.4" + } + }, + "Microsoft.Data.Sqlite.Core": { + "type": "Transitive", + "resolved": "7.0.5", + "contentHash": "FTerRmQPqHrCrnoUzhBu+E+1DNGwyrAMLqHkAqOOOu5pGfyMOj8qQUBxI/gDtWtG11p49UxSfWmBzRNlwZqfUg==", + "dependencies": { + "SQLitePCLRaw.core": "2.1.4" + } + }, + "Microsoft.Extensions.DependencyInjection.Abstractions": { + "type": "Transitive", + "resolved": "2.2.0", + "contentHash": "f9hstgjVmr6rmrfGSpfsVOl2irKAgr1QjrSi3FgnS7kulxband50f2brRLwySAQTADPZeTdow0mpSMcoAdadCw==" + }, + "Microsoft.Extensions.Logging.Abstractions": { + "type": "Transitive", + "resolved": "7.0.0", + "contentHash": "kmn78+LPVMOWeITUjIlfxUPDsI0R6G0RkeAMBmQxAJ7vBJn4q2dTva7pWi65ceN5vPGjJ9q/Uae2WKgvfktJAw==" + }, + "Microsoft.Extensions.ObjectPool": { + "type": "Transitive", + "resolved": "2.2.0", + "contentHash": "gA8H7uQOnM5gb+L0uTNjViHYr+hRDqCdfugheGo/MxQnuHzmhhzCBTIPm19qL1z1Xe0NEMabfcOBGv9QghlZ8g==" + }, + "Microsoft.Extensions.Options": { + "type": "Transitive", + "resolved": "2.2.0", + "contentHash": "UpZLNLBpIZ0GTebShui7xXYh6DmBHjWM8NxGxZbdQh/bPZ5e6YswqI+bru6BnEL5eWiOdodsXtEz3FROcgi/qg==", + "dependencies": { + "Microsoft.Extensions.DependencyInjection.Abstractions": "2.2.0", + "Microsoft.Extensions.Primitives": "2.2.0", + "System.ComponentModel.Annotations": "4.5.0" + } + }, + "Microsoft.Extensions.Primitives": { + "type": "Transitive", + "resolved": "2.2.0", + "contentHash": "azyQtqbm4fSaDzZHD/J+V6oWMFaf2tWP4WEGIYePLCMw3+b2RQdj9ybgbQyjCshcitQKQ4lEDOZjmSlTTrHxUg==", + "dependencies": { + "System.Memory": "4.5.1", + "System.Runtime.CompilerServices.Unsafe": "4.5.1" + } + }, + "Microsoft.Net.Http.Headers": { + "type": "Transitive", + "resolved": "2.2.0", + "contentHash": "iZNkjYqlo8sIOI0bQfpsSoMTmB/kyvmV2h225ihyZT33aTp48ZpF6qYnXxzSXmHt8DpBAwBTX+1s1UFLbYfZKg==", + "dependencies": { + "Microsoft.Extensions.Primitives": "2.2.0", + "System.Buffers": "4.5.0" + } + }, + "Polly": { + "type": "Transitive", + "resolved": "7.2.3", + "contentHash": "DeCY0OFbNdNxsjntr1gTXHJ5pKUwYzp04Er2LLeN3g6pWhffsGuKVfMBLe1lw7x76HrPkLxKEFxBlpRxS2nDEQ==" + }, + "Polly.Contrib.WaitAndRetry": { + "type": "Transitive", + "resolved": "1.1.1", + "contentHash": "1MUQLiSo4KDkQe6nzQRhIU05lm9jlexX5BVsbuw0SL82ynZ+GzAHQxJVDPVBboxV37Po3SG077aX8DuSy8TkaA==" + }, + "Polly.Extensions.Http": { + "type": "Transitive", + "resolved": "3.0.0", + "contentHash": "drrG+hB3pYFY7w1c3BD+lSGYvH2oIclH8GRSehgfyP5kjnFnHKQuuBhuHLv+PWyFuaTDyk/vfRpnxOzd11+J8g==", + "dependencies": { + "Polly": "7.1.0" + } + }, + "Sentry": { + "type": "Transitive", + "resolved": "3.33.0", + "contentHash": "8vbD2o6IR2wrRrkSiRbnodWGWUOqIlwYtzpjvPNOb5raJdOf+zxMwfS8f6nx9bmrTTfDj7KrCB8C/5OuicAc8A==" + }, + "Sentry.Serilog": { + "type": "Transitive", + "resolved": "3.33.0", + "contentHash": "V8BU7QGWg2qLYfNPqtuTBhC1opysny5l+Ifp6J6PhOeAxU0FssR7nYfbJVetrnLIoh2rd3DlJ6hHYYQosQYcUQ==", + "dependencies": { + "Sentry": "3.33.0", + "Serilog": "2.10.0" + } + }, + "Serilog": { + "type": "Transitive", + "resolved": "2.12.0", + "contentHash": "xaiJLIdu6rYMKfQMYUZgTy8YK7SMZjB4Yk50C/u//Z4OsvxkUfSPJy4nknfvwAC34yr13q7kcyh4grbwhSxyZg==" + }, + "Serilog.Enrichers.ClientInfo": { + "type": "Transitive", + "resolved": "1.3.0", + "contentHash": "mTc7PM+wC9Hr7LWSwqt5mmnlAr7RJs+eTb3PGPRhwdOackk95MkhUZognuxXEdlW19HAFNmEBTSBY5DfLwM8jQ==", + "dependencies": { + "Microsoft.AspNetCore.Http": "2.2.2", + "Serilog": "2.9.0" + } + }, + "Serilog.Exceptions": { + "type": "Transitive", + "resolved": "8.4.0", + "contentHash": "nc/+hUw3lsdo0zCj0KMIybAu7perMx79vu72w0za9Nsi6mWyNkGXxYxakAjWB7nEmYL6zdmhEQRB4oJ2ALUeug==", + "dependencies": { + "Serilog": "2.8.0", + "System.Reflection.TypeExtensions": "4.7.0" + } + }, + "Serilog.Formatting.Compact": { + "type": "Transitive", + "resolved": "1.1.0", + "contentHash": "pNroKVjo+rDqlxNG5PXkRLpfSCuDOBY0ri6jp9PLe505ljqwhwZz8ospy2vWhQlFu5GkIesh3FcDs4n7sWZODA==", + "dependencies": { + "Serilog": "2.8.0" + } + }, + "Serilog.Sinks.Console": { + "type": "Transitive", + "resolved": "4.1.0", + "contentHash": "K6N5q+5fetjnJPvCmkWOpJ/V8IEIoMIB1s86OzBrbxwTyHxdx3pmz4H+8+O/Dc/ftUX12DM1aynx/dDowkwzqg==", + "dependencies": { + "Serilog": "2.10.0" + } + }, + "Serilog.Sinks.File": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "uwV5hdhWPwUH1szhO8PJpFiahqXmzPzJT/sOijH/kFgUx+cyoDTMM8MHD0adw9+Iem6itoibbUXHYslzXsLEAg==", + "dependencies": { + "Serilog": "2.10.0" + } + }, + "Serilog.Sinks.PeriodicBatching": { + "type": "Transitive", + "resolved": "3.1.0", + "contentHash": "NDWR7m3PalVlGEq3rzoktrXikjFMLmpwF0HI4sowo8YDdU+gqPlTHlDQiOGxHfB0sTfjPA9JjA7ctKG9zqjGkw==", + "dependencies": { + "Serilog": "2.0.0" + } + }, + "Serilog.Sinks.Seq": { + "type": "Transitive", + "resolved": "5.2.2", + "contentHash": "1Csmo5ua7NKUe0yXUx+zsRefjAniPWcXFhUXxXG8pwo0iMiw2gjn9SOkgYnnxbgWqmlGv236w0N/dHc2v5XwMg==", + "dependencies": { + "Serilog": "2.12.0", + "Serilog.Formatting.Compact": "1.1.0", + "Serilog.Sinks.File": "5.0.0", + "Serilog.Sinks.PeriodicBatching": "3.1.0" + } + }, + "SerilogTimings": { + "type": "Transitive", + "resolved": "3.0.1", + "contentHash": "Zs28eTgszAMwpIrbBnWHBI50yuxL50p/dmAUWmy75+axdZYK/Sjm5/5m1N/CisR8acJUhTVcjPZrsB1P5iv0Uw==", + "dependencies": { + "Serilog": "2.10.0" + } + }, + "Speckle.Newtonsoft.Json": { + "type": "Transitive", + "resolved": "13.0.2", + "contentHash": "g1BejUZwax5PRfL6xHgLEK23sqHWOgOj9hE7RvfRRlN00AGt8GnPYt8HedSK7UB3HiRW8zCA9Pn0iiYxCK24BA==" + }, + "Speckle.Revit2023.Interfaces": { + "type": "Transitive", + "resolved": "0.1.1-preview.0.24", + "contentHash": "BSVpOUJc9g6ISrw8GxvtkglTlITpHEDYNOhxv1ZPbckBsI0yO36JiphhQV4q57ERqD9PpCozUJkVhlCaxWeS6A==" + }, + "SQLitePCLRaw.bundle_e_sqlite3": { + "type": "Transitive", + "resolved": "2.1.4", + "contentHash": "EWI1olKDjFEBMJu0+3wuxwziIAdWDVMYLhuZ3Qs84rrz+DHwD00RzWPZCa+bLnHCf3oJwuFZIRsHT5p236QXww==", + "dependencies": { + "SQLitePCLRaw.lib.e_sqlite3": "2.1.4", + "SQLitePCLRaw.provider.e_sqlite3": "2.1.4" + } + }, + "SQLitePCLRaw.core": { + "type": "Transitive", + "resolved": "2.1.4", + "contentHash": "inBjvSHo9UDKneGNzfUfDjK08JzlcIhn1+SP5Y3m6cgXpCxXKCJDy6Mka7LpgSV+UZmKSnC8rTwB0SQ0xKu5pA==", + "dependencies": { + "System.Memory": "4.5.3" + } + }, + "SQLitePCLRaw.lib.e_sqlite3": { + "type": "Transitive", + "resolved": "2.1.4", + "contentHash": "2C9Q9eX7CPLveJA0rIhf9RXAvu+7nWZu1A2MdG6SD/NOu26TakGgL1nsbc0JAspGijFOo3HoN79xrx8a368fBg==" + }, + "SQLitePCLRaw.provider.e_sqlite3": { + "type": "Transitive", + "resolved": "2.1.4", + "contentHash": "CSlb5dUp1FMIkez9Iv5EXzpeq7rHryVNqwJMWnpq87j9zWZexaEMdisDktMsnnrzKM6ahNrsTkjqNodTBPBxtQ==", + "dependencies": { + "SQLitePCLRaw.core": "2.1.4" + } + }, + "System.Buffers": { + "type": "Transitive", + "resolved": "4.5.0", + "contentHash": "pL2ChpaRRWI/p4LXyy4RgeWlYF2sgfj/pnVMvBqwNFr5cXg7CXNnWZWxrOONLg8VGdFB8oB+EG2Qw4MLgTOe+A==" + }, + "System.ComponentModel.Annotations": { + "type": "Transitive", + "resolved": "4.5.0", + "contentHash": "UxYQ3FGUOtzJ7LfSdnYSFd7+oEv6M8NgUatatIN2HxNtDdlcvFAf+VIq4Of9cDMJEJC0aSRv/x898RYhB4Yppg==" + }, + "System.DoubleNumerics": { + "type": "Transitive", + "resolved": "3.1.3", + "contentHash": "KRKEM/L3KBodjA9VOg3EifFVWUY6EOqaMB05UvPEDm7Zeby/kZW+4kdWUEPzW6xtkwf46p661L9NrbeeQhtLzw==", + "dependencies": { + "NETStandard.Library": "1.6.1" + } + }, + "System.Memory": { + "type": "Transitive", + "resolved": "4.5.3", + "contentHash": "3oDzvc/zzetpTKWMShs1AADwZjQ/36HnsufHRPcOjyRAAMLDlu2iD33MBI2opxnezcVUtXyqDXXjoFMOU9c7SA==" + }, + "System.Reactive": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "erBZjkQHWL9jpasCE/0qKAryzVBJFxGHVBAvgRN1bzM0q2s1S4oYREEEL0Vb+1kA/6BKb5FjUZMp5VXmy+gzkQ==" + }, + "System.Reflection.TypeExtensions": { + "type": "Transitive", + "resolved": "4.7.0", + "contentHash": "VybpaOQQhqE6siHppMktjfGBw1GCwvCqiufqmP8F1nj7fTUNtW35LOEt3UZTEsECfo+ELAl/9o9nJx3U91i7vA==" + }, + "System.Runtime.CompilerServices.Unsafe": { + "type": "Transitive", + "resolved": "4.5.1", + "contentHash": "Zh8t8oqolRaFa9vmOZfdQm/qKejdqz0J9kr7o2Fu0vPeoH3BL1EOXipKWwkWtLT1JPzjByrF19fGuFlNbmPpiw==" + }, + "System.Text.Encodings.Web": { + "type": "Transitive", + "resolved": "4.5.0", + "contentHash": "Xg4G4Indi4dqP1iuAiMSwpiWS54ZghzR644OtsRCm/m/lBMG8dUBhLVN7hLm8NNrNTR+iGbshCPTwrvxZPlm4g==" + }, + "speckle.autofac": { + "type": "Project", + "dependencies": { + "Microsoft.Extensions.Logging.Abstractions": "[7.0.0, )", + "Speckle.Core": "[2.0.999-local, )" + } + }, + "speckle.converters.common": { + "type": "Project", + "dependencies": { + "Speckle.Autofac": "[2.0.999-local, )", + "Speckle.Objects": "[2.0.999-local, )", + "Speckle.Revit2023.Interfaces": "[0.1.1-preview.0.24, )" + } + }, + "Speckle.Core": { + "type": "Project", + "dependencies": { + "GraphQL.Client": "[6.0.0, )", + "Microsoft.CSharp": "[4.7.0, )", + "Microsoft.Data.Sqlite": "[7.0.5, )", + "Polly": "[7.2.3, )", + "Polly.Contrib.WaitAndRetry": "[1.1.1, )", + "Polly.Extensions.Http": "[3.0.0, )", + "Sentry": "[3.33.0, )", + "Sentry.Serilog": "[3.33.0, )", + "Serilog": "[2.12.0, )", + "Serilog.Enrichers.ClientInfo": "[1.3.0, )", + "Serilog.Exceptions": "[8.4.0, )", + "Serilog.Sinks.Console": "[4.1.0, )", + "Serilog.Sinks.Seq": "[5.2.2, )", + "SerilogTimings": "[3.0.1, )", + "Speckle.Newtonsoft.Json": "[13.0.2, )", + "System.DoubleNumerics": "[3.1.3, )" + } + }, + "Speckle.Objects": { + "type": "Project", + "dependencies": { + "Speckle.Core": "[2.0.999-local, )" + } + } + } + } +} \ No newline at end of file diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2023.DependencyInjection/packages.lock.json b/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2023.DependencyInjection/packages.lock.json new file mode 100644 index 0000000000..a7f09e4723 --- /dev/null +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2023.DependencyInjection/packages.lock.json @@ -0,0 +1,417 @@ +{ + "version": 1, + "dependencies": { + ".NETFramework,Version=v4.8": { + "Autofac": { + "type": "Direct", + "requested": "[5.2.0, )", + "resolved": "5.2.0", + "contentHash": "V8dBH0dsv75uDzl7Sw+HkhKDPUw2eXnlMjcSVMH+tLo2s67MpTKGyDj1pDcpR+IF2u4YRs0s3/x7R88YJzIWvg==", + "dependencies": { + "Microsoft.Bcl.AsyncInterfaces": "1.1.0" + } + }, + "PolySharp": { + "type": "Direct", + "requested": "[1.14.1, )", + "resolved": "1.14.1", + "contentHash": "mOOmFYwad3MIOL14VCjj02LljyF1GNw1wP0YVlxtcPvqdxjGGMNdNJJxHptlry3MOd8b40Flm8RPOM8JOlN2sQ==" + }, + "Speckle.InterfaceGenerator": { + "type": "Direct", + "requested": "[0.9.5, )", + "resolved": "0.9.5", + "contentHash": "oU/L7pN1R7q8KkbrpQ3WJnHirPHqn+9DEA7asOcUiggV5dzVg1A/VYs7GOSusD24njxXh03tE3a2oTLOjt3cVg==" + }, + "GraphQL.Client": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "8yPNBbuVBpTptivyAlak4GZvbwbUcjeQTL4vN1HKHRuOykZ4r7l5fcLS6vpyPyLn0x8FsL31xbOIKyxbmR9rbA==", + "dependencies": { + "GraphQL.Client.Abstractions": "6.0.0", + "GraphQL.Client.Abstractions.Websocket": "6.0.0", + "System.Net.WebSockets.Client.Managed": "1.0.22", + "System.Reactive": "5.0.0" + } + }, + "GraphQL.Client.Abstractions": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "h7uzWFORHZ+CCjwr/ThAyXMr0DPpzEANDa4Uo54wqCQ+j7qUKwqYTgOrb1W40sqbvNaZm9v/X7It31SUw0maHA==", + "dependencies": { + "GraphQL.Primitives": "6.0.0" + } + }, + "GraphQL.Client.Abstractions.Websocket": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "Nr9bPf8gIOvLuXpqEpqr9z9jslYFJOvd0feHth3/kPqeR3uMbjF5pjiwh4jxyMcxHdr8Pb6QiXkV3hsSyt0v7A==", + "dependencies": { + "GraphQL.Client.Abstractions": "6.0.0" + } + }, + "GraphQL.Primitives": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "yg72rrYDapfsIUrul7aF6wwNnTJBOFvuA9VdDTQpPa8AlAriHbufeXYLBcodKjfUdkCnaiggX1U/nEP08Zb5GA==" + }, + "Microsoft.Bcl.AsyncInterfaces": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "W8DPQjkMScOMTtJbPwmPyj9c3zYSFGawDW3jwlBOOsnY+EzZFLgNQ/UMkK35JmkNOVPdCyPr2Tw7Vv9N+KA3ZQ==", + "dependencies": { + "System.Threading.Tasks.Extensions": "4.5.4" + } + }, + "Microsoft.CSharp": { + "type": "Transitive", + "resolved": "4.7.0", + "contentHash": "pTj+D3uJWyN3My70i2Hqo+OXixq3Os2D1nJ2x92FFo6sk8fYS1m1WLNTs0Dc1uPaViH0YvEEwvzddQ7y4rhXmA==" + }, + "Microsoft.Data.Sqlite": { + "type": "Transitive", + "resolved": "7.0.5", + "contentHash": "KGxbPeWsQMnmQy43DSBxAFtHz3l2JX8EWBSGUCvT3CuZ8KsuzbkqMIJMDOxWtG8eZSoCDI04aiVQjWuuV8HmSw==", + "dependencies": { + "Microsoft.Data.Sqlite.Core": "7.0.5", + "SQLitePCLRaw.bundle_e_sqlite3": "2.1.4" + } + }, + "Microsoft.Data.Sqlite.Core": { + "type": "Transitive", + "resolved": "7.0.5", + "contentHash": "FTerRmQPqHrCrnoUzhBu+E+1DNGwyrAMLqHkAqOOOu5pGfyMOj8qQUBxI/gDtWtG11p49UxSfWmBzRNlwZqfUg==", + "dependencies": { + "SQLitePCLRaw.core": "2.1.4" + } + }, + "Microsoft.Extensions.Logging.Abstractions": { + "type": "Transitive", + "resolved": "7.0.0", + "contentHash": "kmn78+LPVMOWeITUjIlfxUPDsI0R6G0RkeAMBmQxAJ7vBJn4q2dTva7pWi65ceN5vPGjJ9q/Uae2WKgvfktJAw==", + "dependencies": { + "System.Buffers": "4.5.1", + "System.Memory": "4.5.5" + } + }, + "Polly": { + "type": "Transitive", + "resolved": "7.2.3", + "contentHash": "DeCY0OFbNdNxsjntr1gTXHJ5pKUwYzp04Er2LLeN3g6pWhffsGuKVfMBLe1lw7x76HrPkLxKEFxBlpRxS2nDEQ==" + }, + "Polly.Contrib.WaitAndRetry": { + "type": "Transitive", + "resolved": "1.1.1", + "contentHash": "1MUQLiSo4KDkQe6nzQRhIU05lm9jlexX5BVsbuw0SL82ynZ+GzAHQxJVDPVBboxV37Po3SG077aX8DuSy8TkaA==" + }, + "Polly.Extensions.Http": { + "type": "Transitive", + "resolved": "3.0.0", + "contentHash": "drrG+hB3pYFY7w1c3BD+lSGYvH2oIclH8GRSehgfyP5kjnFnHKQuuBhuHLv+PWyFuaTDyk/vfRpnxOzd11+J8g==", + "dependencies": { + "Polly": "7.1.0" + } + }, + "Sentry": { + "type": "Transitive", + "resolved": "3.33.0", + "contentHash": "8vbD2o6IR2wrRrkSiRbnodWGWUOqIlwYtzpjvPNOb5raJdOf+zxMwfS8f6nx9bmrTTfDj7KrCB8C/5OuicAc8A==", + "dependencies": { + "System.Reflection.Metadata": "5.0.0", + "System.Runtime.InteropServices.RuntimeInformation": "4.3.0", + "System.Text.Json": "5.0.2" + } + }, + "Sentry.Serilog": { + "type": "Transitive", + "resolved": "3.33.0", + "contentHash": "V8BU7QGWg2qLYfNPqtuTBhC1opysny5l+Ifp6J6PhOeAxU0FssR7nYfbJVetrnLIoh2rd3DlJ6hHYYQosQYcUQ==", + "dependencies": { + "Sentry": "3.33.0", + "Serilog": "2.7.1" + } + }, + "Serilog": { + "type": "Transitive", + "resolved": "2.12.0", + "contentHash": "xaiJLIdu6rYMKfQMYUZgTy8YK7SMZjB4Yk50C/u//Z4OsvxkUfSPJy4nknfvwAC34yr13q7kcyh4grbwhSxyZg==" + }, + "Serilog.Enrichers.ClientInfo": { + "type": "Transitive", + "resolved": "1.3.0", + "contentHash": "mTc7PM+wC9Hr7LWSwqt5mmnlAr7RJs+eTb3PGPRhwdOackk95MkhUZognuxXEdlW19HAFNmEBTSBY5DfLwM8jQ==", + "dependencies": { + "Serilog": "2.4.0" + } + }, + "Serilog.Exceptions": { + "type": "Transitive", + "resolved": "8.4.0", + "contentHash": "nc/+hUw3lsdo0zCj0KMIybAu7perMx79vu72w0za9Nsi6mWyNkGXxYxakAjWB7nEmYL6zdmhEQRB4oJ2ALUeug==", + "dependencies": { + "Serilog": "2.8.0" + } + }, + "Serilog.Formatting.Compact": { + "type": "Transitive", + "resolved": "1.1.0", + "contentHash": "pNroKVjo+rDqlxNG5PXkRLpfSCuDOBY0ri6jp9PLe505ljqwhwZz8ospy2vWhQlFu5GkIesh3FcDs4n7sWZODA==", + "dependencies": { + "Serilog": "2.8.0" + } + }, + "Serilog.Sinks.Console": { + "type": "Transitive", + "resolved": "4.1.0", + "contentHash": "K6N5q+5fetjnJPvCmkWOpJ/V8IEIoMIB1s86OzBrbxwTyHxdx3pmz4H+8+O/Dc/ftUX12DM1aynx/dDowkwzqg==", + "dependencies": { + "Serilog": "2.10.0" + } + }, + "Serilog.Sinks.File": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "uwV5hdhWPwUH1szhO8PJpFiahqXmzPzJT/sOijH/kFgUx+cyoDTMM8MHD0adw9+Iem6itoibbUXHYslzXsLEAg==", + "dependencies": { + "Serilog": "2.10.0" + } + }, + "Serilog.Sinks.PeriodicBatching": { + "type": "Transitive", + "resolved": "3.1.0", + "contentHash": "NDWR7m3PalVlGEq3rzoktrXikjFMLmpwF0HI4sowo8YDdU+gqPlTHlDQiOGxHfB0sTfjPA9JjA7ctKG9zqjGkw==", + "dependencies": { + "Serilog": "2.0.0" + } + }, + "Serilog.Sinks.Seq": { + "type": "Transitive", + "resolved": "5.2.2", + "contentHash": "1Csmo5ua7NKUe0yXUx+zsRefjAniPWcXFhUXxXG8pwo0iMiw2gjn9SOkgYnnxbgWqmlGv236w0N/dHc2v5XwMg==", + "dependencies": { + "Serilog": "2.12.0", + "Serilog.Formatting.Compact": "1.1.0", + "Serilog.Sinks.File": "5.0.0", + "Serilog.Sinks.PeriodicBatching": "3.1.0" + } + }, + "SerilogTimings": { + "type": "Transitive", + "resolved": "3.0.1", + "contentHash": "Zs28eTgszAMwpIrbBnWHBI50yuxL50p/dmAUWmy75+axdZYK/Sjm5/5m1N/CisR8acJUhTVcjPZrsB1P5iv0Uw==", + "dependencies": { + "Serilog": "2.10.0" + } + }, + "Speckle.AutoCAD.API": { + "type": "Transitive", + "resolved": "2023.0.0", + "contentHash": "aNfiNw9zRW8pCl8AAQK7afEJuea4bJ4sFNsGVSDrdq1egaonZrwALU01dSyFNCE8tne86eVjlprpOGG6r0+G/A==" + }, + "Speckle.Newtonsoft.Json": { + "type": "Transitive", + "resolved": "13.0.2", + "contentHash": "g1BejUZwax5PRfL6xHgLEK23sqHWOgOj9hE7RvfRRlN00AGt8GnPYt8HedSK7UB3HiRW8zCA9Pn0iiYxCK24BA==" + }, + "Speckle.Revit2023.Interfaces": { + "type": "Transitive", + "resolved": "0.1.1-preview.0.24", + "contentHash": "BSVpOUJc9g6ISrw8GxvtkglTlITpHEDYNOhxv1ZPbckBsI0yO36JiphhQV4q57ERqD9PpCozUJkVhlCaxWeS6A==" + }, + "SQLitePCLRaw.bundle_e_sqlite3": { + "type": "Transitive", + "resolved": "2.1.4", + "contentHash": "EWI1olKDjFEBMJu0+3wuxwziIAdWDVMYLhuZ3Qs84rrz+DHwD00RzWPZCa+bLnHCf3oJwuFZIRsHT5p236QXww==", + "dependencies": { + "SQLitePCLRaw.lib.e_sqlite3": "2.1.4", + "SQLitePCLRaw.provider.dynamic_cdecl": "2.1.4" + } + }, + "SQLitePCLRaw.core": { + "type": "Transitive", + "resolved": "2.1.4", + "contentHash": "inBjvSHo9UDKneGNzfUfDjK08JzlcIhn1+SP5Y3m6cgXpCxXKCJDy6Mka7LpgSV+UZmKSnC8rTwB0SQ0xKu5pA==", + "dependencies": { + "System.Memory": "4.5.3" + } + }, + "SQLitePCLRaw.lib.e_sqlite3": { + "type": "Transitive", + "resolved": "2.1.4", + "contentHash": "2C9Q9eX7CPLveJA0rIhf9RXAvu+7nWZu1A2MdG6SD/NOu26TakGgL1nsbc0JAspGijFOo3HoN79xrx8a368fBg==" + }, + "SQLitePCLRaw.provider.dynamic_cdecl": { + "type": "Transitive", + "resolved": "2.1.4", + "contentHash": "ZsaKKhgYF9B1fvcnOGKl3EycNAwd9CRWX7v0rEfuPWhQQ5Jjpvf2VEHahiLIGHio3hxi3EIKFJw9KvyowWOUAw==", + "dependencies": { + "SQLitePCLRaw.core": "2.1.4" + } + }, + "System.Buffers": { + "type": "Transitive", + "resolved": "4.5.1", + "contentHash": "Rw7ijyl1qqRS0YQD/WycNst8hUUMgrMH4FCn1nNm27M4VxchZ1js3fVjQaANHO5f3sN4isvP4a+Met9Y4YomAg==" + }, + "System.Collections.Immutable": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "FXkLXiK0sVVewcso0imKQoOxjoPAj42R8HtjjbSjVPAzwDfzoyoznWxgA3c38LDbN9SJux1xXoXYAhz98j7r2g==", + "dependencies": { + "System.Memory": "4.5.4" + } + }, + "System.DoubleNumerics": { + "type": "Transitive", + "resolved": "3.1.3", + "contentHash": "KRKEM/L3KBodjA9VOg3EifFVWUY6EOqaMB05UvPEDm7Zeby/kZW+4kdWUEPzW6xtkwf46p661L9NrbeeQhtLzw==", + "dependencies": { + "NETStandard.Library": "1.6.1" + } + }, + "System.Memory": { + "type": "Transitive", + "resolved": "4.5.5", + "contentHash": "XIWiDvKPXaTveaB7HVganDlOCRoj03l+jrwNvcge/t8vhGYKvqV+dMv6G4SAX2NoNmN0wZfVPTAlFwZcZvVOUw==", + "dependencies": { + "System.Buffers": "4.5.1", + "System.Numerics.Vectors": "4.5.0", + "System.Runtime.CompilerServices.Unsafe": "4.5.3" + } + }, + "System.Net.WebSockets.Client.Managed": { + "type": "Transitive", + "resolved": "1.0.22", + "contentHash": "WqEOxPlXjuZrIjUtXNE9NxEfU/n5E35iV2PtoZdJSUC4tlrqwHnTee+wvMIM4OUaJWmwrymeqcgYrE0IkGAgLA==", + "dependencies": { + "System.Buffers": "4.4.0", + "System.Numerics.Vectors": "4.4.0" + } + }, + "System.Numerics.Vectors": { + "type": "Transitive", + "resolved": "4.5.0", + "contentHash": "QQTlPTl06J/iiDbJCiepZ4H//BVraReU4O4EoRw1U02H5TLUIT7xn3GnDp9AXPSlJUDyFs4uWjWafNX6WrAojQ==" + }, + "System.Reactive": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "erBZjkQHWL9jpasCE/0qKAryzVBJFxGHVBAvgRN1bzM0q2s1S4oYREEEL0Vb+1kA/6BKb5FjUZMp5VXmy+gzkQ==", + "dependencies": { + "System.Threading.Tasks.Extensions": "4.5.4" + } + }, + "System.Reflection.Metadata": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "5NecZgXktdGg34rh1OenY1rFNDCI8xSjFr+Z4OU4cU06AQHUdRnIIEeWENu3Wl4YowbzkymAIMvi3WyK9U53pQ==", + "dependencies": { + "System.Collections.Immutable": "5.0.0" + } + }, + "System.Runtime.CompilerServices.Unsafe": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "ZD9TMpsmYJLrxbbmdvhwt9YEgG5WntEnZ/d1eH8JBX9LBp+Ju8BSBhUGbZMNVHHomWo2KVImJhTDl2hIgw/6MA==" + }, + "System.Runtime.InteropServices.RuntimeInformation": { + "type": "Transitive", + "resolved": "4.3.0", + "contentHash": "cbz4YJMqRDR7oLeMRbdYv7mYzc++17lNhScCX0goO2XpGWdvAt60CGN+FHdePUEHCe/Jy9jUlvNAiNdM+7jsOw==" + }, + "System.Text.Encodings.Web": { + "type": "Transitive", + "resolved": "5.0.1", + "contentHash": "KmJ+CJXizDofbq6mpqDoRRLcxgOd2z9X3XoFNULSbvbqVRZkFX3istvr+MUjL6Zw1RT+RNdoI4GYidIINtgvqQ==", + "dependencies": { + "System.Buffers": "4.5.1", + "System.Memory": "4.5.4" + } + }, + "System.Text.Json": { + "type": "Transitive", + "resolved": "5.0.2", + "contentHash": "I47dVIGiV6SfAyppphxqupertT/5oZkYLDCX6vC3HpOI4ZLjyoKAreUoem2ie6G0RbRuFrlqz/PcTQjfb2DOfQ==", + "dependencies": { + "Microsoft.Bcl.AsyncInterfaces": "5.0.0", + "System.Buffers": "4.5.1", + "System.Memory": "4.5.4", + "System.Numerics.Vectors": "4.5.0", + "System.Runtime.CompilerServices.Unsafe": "5.0.0", + "System.Text.Encodings.Web": "5.0.1", + "System.Threading.Tasks.Extensions": "4.5.4", + "System.ValueTuple": "4.5.0" + } + }, + "System.Threading.Tasks.Extensions": { + "type": "Transitive", + "resolved": "4.5.4", + "contentHash": "zteT+G8xuGu6mS+mzDzYXbzS7rd3K6Fjb9RiZlYlJPam2/hU7JCBZBVEcywNuR+oZ1ncTvc/cq0faRr3P01OVg==", + "dependencies": { + "System.Runtime.CompilerServices.Unsafe": "4.5.3" + } + }, + "System.ValueTuple": { + "type": "Transitive", + "resolved": "4.5.0", + "contentHash": "okurQJO6NRE/apDIP23ajJ0hpiNmJ+f0BwOlB/cSqTLQlw5upkf+5+96+iG2Jw40G1fCVCyPz/FhIABUjMR+RQ==" + }, + "speckle.autofac": { + "type": "Project", + "dependencies": { + "Microsoft.Extensions.Logging.Abstractions": "[7.0.0, )", + "Speckle.Core": "[2.0.999-local, )" + } + }, + "speckle.converters.autocad2023": { + "type": "Project", + "dependencies": { + "Speckle.AutoCAD.API": "[2023.0.0, )", + "Speckle.Converters.Common": "[2.0.999-local, )" + } + }, + "speckle.converters.common": { + "type": "Project", + "dependencies": { + "Speckle.Autofac": "[2.0.999-local, )", + "Speckle.Objects": "[2.0.999-local, )", + "Speckle.Revit2023.Interfaces": "[0.1.1-preview.0.24, )" + } + }, + "speckle.converters.common.dependencyinjection": { + "type": "Project", + "dependencies": { + "Speckle.Autofac": "[2.0.999-local, )", + "Speckle.Converters.Common": "[2.0.999-local, )" + } + }, + "Speckle.Core": { + "type": "Project", + "dependencies": { + "GraphQL.Client": "[6.0.0, )", + "Microsoft.CSharp": "[4.7.0, )", + "Microsoft.Data.Sqlite": "[7.0.5, )", + "Polly": "[7.2.3, )", + "Polly.Contrib.WaitAndRetry": "[1.1.1, )", + "Polly.Extensions.Http": "[3.0.0, )", + "Sentry": "[3.33.0, )", + "Sentry.Serilog": "[3.33.0, )", + "Serilog": "[2.12.0, )", + "Serilog.Enrichers.ClientInfo": "[1.3.0, )", + "Serilog.Exceptions": "[8.4.0, )", + "Serilog.Sinks.Console": "[4.1.0, )", + "Serilog.Sinks.Seq": "[5.2.2, )", + "SerilogTimings": "[3.0.1, )", + "Speckle.Newtonsoft.Json": "[13.0.2, )", + "System.DoubleNumerics": "[3.1.3, )" + } + }, + "Speckle.Objects": { + "type": "Project", + "dependencies": { + "Speckle.Core": "[2.0.999-local, )" + } + } + } + } +} \ No newline at end of file diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2023/packages.lock.json b/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2023/packages.lock.json new file mode 100644 index 0000000000..66bbf8290c --- /dev/null +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2023/packages.lock.json @@ -0,0 +1,395 @@ +{ + "version": 1, + "dependencies": { + ".NETFramework,Version=v4.8": { + "PolySharp": { + "type": "Direct", + "requested": "[1.14.1, )", + "resolved": "1.14.1", + "contentHash": "mOOmFYwad3MIOL14VCjj02LljyF1GNw1wP0YVlxtcPvqdxjGGMNdNJJxHptlry3MOd8b40Flm8RPOM8JOlN2sQ==" + }, + "Speckle.AutoCAD.API": { + "type": "Direct", + "requested": "[2023.0.0, )", + "resolved": "2023.0.0", + "contentHash": "aNfiNw9zRW8pCl8AAQK7afEJuea4bJ4sFNsGVSDrdq1egaonZrwALU01dSyFNCE8tne86eVjlprpOGG6r0+G/A==" + }, + "Speckle.InterfaceGenerator": { + "type": "Direct", + "requested": "[0.9.5, )", + "resolved": "0.9.5", + "contentHash": "oU/L7pN1R7q8KkbrpQ3WJnHirPHqn+9DEA7asOcUiggV5dzVg1A/VYs7GOSusD24njxXh03tE3a2oTLOjt3cVg==" + }, + "GraphQL.Client": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "8yPNBbuVBpTptivyAlak4GZvbwbUcjeQTL4vN1HKHRuOykZ4r7l5fcLS6vpyPyLn0x8FsL31xbOIKyxbmR9rbA==", + "dependencies": { + "GraphQL.Client.Abstractions": "6.0.0", + "GraphQL.Client.Abstractions.Websocket": "6.0.0", + "System.Net.WebSockets.Client.Managed": "1.0.22", + "System.Reactive": "5.0.0" + } + }, + "GraphQL.Client.Abstractions": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "h7uzWFORHZ+CCjwr/ThAyXMr0DPpzEANDa4Uo54wqCQ+j7qUKwqYTgOrb1W40sqbvNaZm9v/X7It31SUw0maHA==", + "dependencies": { + "GraphQL.Primitives": "6.0.0" + } + }, + "GraphQL.Client.Abstractions.Websocket": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "Nr9bPf8gIOvLuXpqEpqr9z9jslYFJOvd0feHth3/kPqeR3uMbjF5pjiwh4jxyMcxHdr8Pb6QiXkV3hsSyt0v7A==", + "dependencies": { + "GraphQL.Client.Abstractions": "6.0.0" + } + }, + "GraphQL.Primitives": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "yg72rrYDapfsIUrul7aF6wwNnTJBOFvuA9VdDTQpPa8AlAriHbufeXYLBcodKjfUdkCnaiggX1U/nEP08Zb5GA==" + }, + "Microsoft.Bcl.AsyncInterfaces": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "W8DPQjkMScOMTtJbPwmPyj9c3zYSFGawDW3jwlBOOsnY+EzZFLgNQ/UMkK35JmkNOVPdCyPr2Tw7Vv9N+KA3ZQ==", + "dependencies": { + "System.Threading.Tasks.Extensions": "4.5.4" + } + }, + "Microsoft.CSharp": { + "type": "Transitive", + "resolved": "4.7.0", + "contentHash": "pTj+D3uJWyN3My70i2Hqo+OXixq3Os2D1nJ2x92FFo6sk8fYS1m1WLNTs0Dc1uPaViH0YvEEwvzddQ7y4rhXmA==" + }, + "Microsoft.Data.Sqlite": { + "type": "Transitive", + "resolved": "7.0.5", + "contentHash": "KGxbPeWsQMnmQy43DSBxAFtHz3l2JX8EWBSGUCvT3CuZ8KsuzbkqMIJMDOxWtG8eZSoCDI04aiVQjWuuV8HmSw==", + "dependencies": { + "Microsoft.Data.Sqlite.Core": "7.0.5", + "SQLitePCLRaw.bundle_e_sqlite3": "2.1.4" + } + }, + "Microsoft.Data.Sqlite.Core": { + "type": "Transitive", + "resolved": "7.0.5", + "contentHash": "FTerRmQPqHrCrnoUzhBu+E+1DNGwyrAMLqHkAqOOOu5pGfyMOj8qQUBxI/gDtWtG11p49UxSfWmBzRNlwZqfUg==", + "dependencies": { + "SQLitePCLRaw.core": "2.1.4" + } + }, + "Microsoft.Extensions.Logging.Abstractions": { + "type": "Transitive", + "resolved": "7.0.0", + "contentHash": "kmn78+LPVMOWeITUjIlfxUPDsI0R6G0RkeAMBmQxAJ7vBJn4q2dTva7pWi65ceN5vPGjJ9q/Uae2WKgvfktJAw==", + "dependencies": { + "System.Buffers": "4.5.1", + "System.Memory": "4.5.5" + } + }, + "Polly": { + "type": "Transitive", + "resolved": "7.2.3", + "contentHash": "DeCY0OFbNdNxsjntr1gTXHJ5pKUwYzp04Er2LLeN3g6pWhffsGuKVfMBLe1lw7x76HrPkLxKEFxBlpRxS2nDEQ==" + }, + "Polly.Contrib.WaitAndRetry": { + "type": "Transitive", + "resolved": "1.1.1", + "contentHash": "1MUQLiSo4KDkQe6nzQRhIU05lm9jlexX5BVsbuw0SL82ynZ+GzAHQxJVDPVBboxV37Po3SG077aX8DuSy8TkaA==" + }, + "Polly.Extensions.Http": { + "type": "Transitive", + "resolved": "3.0.0", + "contentHash": "drrG+hB3pYFY7w1c3BD+lSGYvH2oIclH8GRSehgfyP5kjnFnHKQuuBhuHLv+PWyFuaTDyk/vfRpnxOzd11+J8g==", + "dependencies": { + "Polly": "7.1.0" + } + }, + "Sentry": { + "type": "Transitive", + "resolved": "3.33.0", + "contentHash": "8vbD2o6IR2wrRrkSiRbnodWGWUOqIlwYtzpjvPNOb5raJdOf+zxMwfS8f6nx9bmrTTfDj7KrCB8C/5OuicAc8A==", + "dependencies": { + "System.Reflection.Metadata": "5.0.0", + "System.Runtime.InteropServices.RuntimeInformation": "4.3.0", + "System.Text.Json": "5.0.2" + } + }, + "Sentry.Serilog": { + "type": "Transitive", + "resolved": "3.33.0", + "contentHash": "V8BU7QGWg2qLYfNPqtuTBhC1opysny5l+Ifp6J6PhOeAxU0FssR7nYfbJVetrnLIoh2rd3DlJ6hHYYQosQYcUQ==", + "dependencies": { + "Sentry": "3.33.0", + "Serilog": "2.7.1" + } + }, + "Serilog": { + "type": "Transitive", + "resolved": "2.12.0", + "contentHash": "xaiJLIdu6rYMKfQMYUZgTy8YK7SMZjB4Yk50C/u//Z4OsvxkUfSPJy4nknfvwAC34yr13q7kcyh4grbwhSxyZg==" + }, + "Serilog.Enrichers.ClientInfo": { + "type": "Transitive", + "resolved": "1.3.0", + "contentHash": "mTc7PM+wC9Hr7LWSwqt5mmnlAr7RJs+eTb3PGPRhwdOackk95MkhUZognuxXEdlW19HAFNmEBTSBY5DfLwM8jQ==", + "dependencies": { + "Serilog": "2.4.0" + } + }, + "Serilog.Exceptions": { + "type": "Transitive", + "resolved": "8.4.0", + "contentHash": "nc/+hUw3lsdo0zCj0KMIybAu7perMx79vu72w0za9Nsi6mWyNkGXxYxakAjWB7nEmYL6zdmhEQRB4oJ2ALUeug==", + "dependencies": { + "Serilog": "2.8.0" + } + }, + "Serilog.Formatting.Compact": { + "type": "Transitive", + "resolved": "1.1.0", + "contentHash": "pNroKVjo+rDqlxNG5PXkRLpfSCuDOBY0ri6jp9PLe505ljqwhwZz8ospy2vWhQlFu5GkIesh3FcDs4n7sWZODA==", + "dependencies": { + "Serilog": "2.8.0" + } + }, + "Serilog.Sinks.Console": { + "type": "Transitive", + "resolved": "4.1.0", + "contentHash": "K6N5q+5fetjnJPvCmkWOpJ/V8IEIoMIB1s86OzBrbxwTyHxdx3pmz4H+8+O/Dc/ftUX12DM1aynx/dDowkwzqg==", + "dependencies": { + "Serilog": "2.10.0" + } + }, + "Serilog.Sinks.File": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "uwV5hdhWPwUH1szhO8PJpFiahqXmzPzJT/sOijH/kFgUx+cyoDTMM8MHD0adw9+Iem6itoibbUXHYslzXsLEAg==", + "dependencies": { + "Serilog": "2.10.0" + } + }, + "Serilog.Sinks.PeriodicBatching": { + "type": "Transitive", + "resolved": "3.1.0", + "contentHash": "NDWR7m3PalVlGEq3rzoktrXikjFMLmpwF0HI4sowo8YDdU+gqPlTHlDQiOGxHfB0sTfjPA9JjA7ctKG9zqjGkw==", + "dependencies": { + "Serilog": "2.0.0" + } + }, + "Serilog.Sinks.Seq": { + "type": "Transitive", + "resolved": "5.2.2", + "contentHash": "1Csmo5ua7NKUe0yXUx+zsRefjAniPWcXFhUXxXG8pwo0iMiw2gjn9SOkgYnnxbgWqmlGv236w0N/dHc2v5XwMg==", + "dependencies": { + "Serilog": "2.12.0", + "Serilog.Formatting.Compact": "1.1.0", + "Serilog.Sinks.File": "5.0.0", + "Serilog.Sinks.PeriodicBatching": "3.1.0" + } + }, + "SerilogTimings": { + "type": "Transitive", + "resolved": "3.0.1", + "contentHash": "Zs28eTgszAMwpIrbBnWHBI50yuxL50p/dmAUWmy75+axdZYK/Sjm5/5m1N/CisR8acJUhTVcjPZrsB1P5iv0Uw==", + "dependencies": { + "Serilog": "2.10.0" + } + }, + "Speckle.Newtonsoft.Json": { + "type": "Transitive", + "resolved": "13.0.2", + "contentHash": "g1BejUZwax5PRfL6xHgLEK23sqHWOgOj9hE7RvfRRlN00AGt8GnPYt8HedSK7UB3HiRW8zCA9Pn0iiYxCK24BA==" + }, + "Speckle.Revit2023.Interfaces": { + "type": "Transitive", + "resolved": "0.1.1-preview.0.24", + "contentHash": "BSVpOUJc9g6ISrw8GxvtkglTlITpHEDYNOhxv1ZPbckBsI0yO36JiphhQV4q57ERqD9PpCozUJkVhlCaxWeS6A==" + }, + "SQLitePCLRaw.bundle_e_sqlite3": { + "type": "Transitive", + "resolved": "2.1.4", + "contentHash": "EWI1olKDjFEBMJu0+3wuxwziIAdWDVMYLhuZ3Qs84rrz+DHwD00RzWPZCa+bLnHCf3oJwuFZIRsHT5p236QXww==", + "dependencies": { + "SQLitePCLRaw.lib.e_sqlite3": "2.1.4", + "SQLitePCLRaw.provider.dynamic_cdecl": "2.1.4" + } + }, + "SQLitePCLRaw.core": { + "type": "Transitive", + "resolved": "2.1.4", + "contentHash": "inBjvSHo9UDKneGNzfUfDjK08JzlcIhn1+SP5Y3m6cgXpCxXKCJDy6Mka7LpgSV+UZmKSnC8rTwB0SQ0xKu5pA==", + "dependencies": { + "System.Memory": "4.5.3" + } + }, + "SQLitePCLRaw.lib.e_sqlite3": { + "type": "Transitive", + "resolved": "2.1.4", + "contentHash": "2C9Q9eX7CPLveJA0rIhf9RXAvu+7nWZu1A2MdG6SD/NOu26TakGgL1nsbc0JAspGijFOo3HoN79xrx8a368fBg==" + }, + "SQLitePCLRaw.provider.dynamic_cdecl": { + "type": "Transitive", + "resolved": "2.1.4", + "contentHash": "ZsaKKhgYF9B1fvcnOGKl3EycNAwd9CRWX7v0rEfuPWhQQ5Jjpvf2VEHahiLIGHio3hxi3EIKFJw9KvyowWOUAw==", + "dependencies": { + "SQLitePCLRaw.core": "2.1.4" + } + }, + "System.Buffers": { + "type": "Transitive", + "resolved": "4.5.1", + "contentHash": "Rw7ijyl1qqRS0YQD/WycNst8hUUMgrMH4FCn1nNm27M4VxchZ1js3fVjQaANHO5f3sN4isvP4a+Met9Y4YomAg==" + }, + "System.Collections.Immutable": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "FXkLXiK0sVVewcso0imKQoOxjoPAj42R8HtjjbSjVPAzwDfzoyoznWxgA3c38LDbN9SJux1xXoXYAhz98j7r2g==", + "dependencies": { + "System.Memory": "4.5.4" + } + }, + "System.DoubleNumerics": { + "type": "Transitive", + "resolved": "3.1.3", + "contentHash": "KRKEM/L3KBodjA9VOg3EifFVWUY6EOqaMB05UvPEDm7Zeby/kZW+4kdWUEPzW6xtkwf46p661L9NrbeeQhtLzw==", + "dependencies": { + "NETStandard.Library": "1.6.1" + } + }, + "System.Memory": { + "type": "Transitive", + "resolved": "4.5.5", + "contentHash": "XIWiDvKPXaTveaB7HVganDlOCRoj03l+jrwNvcge/t8vhGYKvqV+dMv6G4SAX2NoNmN0wZfVPTAlFwZcZvVOUw==", + "dependencies": { + "System.Buffers": "4.5.1", + "System.Numerics.Vectors": "4.5.0", + "System.Runtime.CompilerServices.Unsafe": "4.5.3" + } + }, + "System.Net.WebSockets.Client.Managed": { + "type": "Transitive", + "resolved": "1.0.22", + "contentHash": "WqEOxPlXjuZrIjUtXNE9NxEfU/n5E35iV2PtoZdJSUC4tlrqwHnTee+wvMIM4OUaJWmwrymeqcgYrE0IkGAgLA==", + "dependencies": { + "System.Buffers": "4.4.0", + "System.Numerics.Vectors": "4.4.0" + } + }, + "System.Numerics.Vectors": { + "type": "Transitive", + "resolved": "4.5.0", + "contentHash": "QQTlPTl06J/iiDbJCiepZ4H//BVraReU4O4EoRw1U02H5TLUIT7xn3GnDp9AXPSlJUDyFs4uWjWafNX6WrAojQ==" + }, + "System.Reactive": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "erBZjkQHWL9jpasCE/0qKAryzVBJFxGHVBAvgRN1bzM0q2s1S4oYREEEL0Vb+1kA/6BKb5FjUZMp5VXmy+gzkQ==", + "dependencies": { + "System.Threading.Tasks.Extensions": "4.5.4" + } + }, + "System.Reflection.Metadata": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "5NecZgXktdGg34rh1OenY1rFNDCI8xSjFr+Z4OU4cU06AQHUdRnIIEeWENu3Wl4YowbzkymAIMvi3WyK9U53pQ==", + "dependencies": { + "System.Collections.Immutable": "5.0.0" + } + }, + "System.Runtime.CompilerServices.Unsafe": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "ZD9TMpsmYJLrxbbmdvhwt9YEgG5WntEnZ/d1eH8JBX9LBp+Ju8BSBhUGbZMNVHHomWo2KVImJhTDl2hIgw/6MA==" + }, + "System.Runtime.InteropServices.RuntimeInformation": { + "type": "Transitive", + "resolved": "4.3.0", + "contentHash": "cbz4YJMqRDR7oLeMRbdYv7mYzc++17lNhScCX0goO2XpGWdvAt60CGN+FHdePUEHCe/Jy9jUlvNAiNdM+7jsOw==" + }, + "System.Text.Encodings.Web": { + "type": "Transitive", + "resolved": "5.0.1", + "contentHash": "KmJ+CJXizDofbq6mpqDoRRLcxgOd2z9X3XoFNULSbvbqVRZkFX3istvr+MUjL6Zw1RT+RNdoI4GYidIINtgvqQ==", + "dependencies": { + "System.Buffers": "4.5.1", + "System.Memory": "4.5.4" + } + }, + "System.Text.Json": { + "type": "Transitive", + "resolved": "5.0.2", + "contentHash": "I47dVIGiV6SfAyppphxqupertT/5oZkYLDCX6vC3HpOI4ZLjyoKAreUoem2ie6G0RbRuFrlqz/PcTQjfb2DOfQ==", + "dependencies": { + "Microsoft.Bcl.AsyncInterfaces": "5.0.0", + "System.Buffers": "4.5.1", + "System.Memory": "4.5.4", + "System.Numerics.Vectors": "4.5.0", + "System.Runtime.CompilerServices.Unsafe": "5.0.0", + "System.Text.Encodings.Web": "5.0.1", + "System.Threading.Tasks.Extensions": "4.5.4", + "System.ValueTuple": "4.5.0" + } + }, + "System.Threading.Tasks.Extensions": { + "type": "Transitive", + "resolved": "4.5.4", + "contentHash": "zteT+G8xuGu6mS+mzDzYXbzS7rd3K6Fjb9RiZlYlJPam2/hU7JCBZBVEcywNuR+oZ1ncTvc/cq0faRr3P01OVg==", + "dependencies": { + "System.Runtime.CompilerServices.Unsafe": "4.5.3" + } + }, + "System.ValueTuple": { + "type": "Transitive", + "resolved": "4.5.0", + "contentHash": "okurQJO6NRE/apDIP23ajJ0hpiNmJ+f0BwOlB/cSqTLQlw5upkf+5+96+iG2Jw40G1fCVCyPz/FhIABUjMR+RQ==" + }, + "speckle.autofac": { + "type": "Project", + "dependencies": { + "Microsoft.Extensions.Logging.Abstractions": "[7.0.0, )", + "Speckle.Core": "[2.0.999-local, )" + } + }, + "speckle.converters.common": { + "type": "Project", + "dependencies": { + "Speckle.Autofac": "[2.0.999-local, )", + "Speckle.Objects": "[2.0.999-local, )", + "Speckle.Revit2023.Interfaces": "[0.1.1-preview.0.24, )" + } + }, + "Speckle.Core": { + "type": "Project", + "dependencies": { + "GraphQL.Client": "[6.0.0, )", + "Microsoft.CSharp": "[4.7.0, )", + "Microsoft.Data.Sqlite": "[7.0.5, )", + "Polly": "[7.2.3, )", + "Polly.Contrib.WaitAndRetry": "[1.1.1, )", + "Polly.Extensions.Http": "[3.0.0, )", + "Sentry": "[3.33.0, )", + "Sentry.Serilog": "[3.33.0, )", + "Serilog": "[2.12.0, )", + "Serilog.Enrichers.ClientInfo": "[1.3.0, )", + "Serilog.Exceptions": "[8.4.0, )", + "Serilog.Sinks.Console": "[4.1.0, )", + "Serilog.Sinks.Seq": "[5.2.2, )", + "SerilogTimings": "[3.0.1, )", + "Speckle.Newtonsoft.Json": "[13.0.2, )", + "System.DoubleNumerics": "[3.1.3, )" + } + }, + "Speckle.Objects": { + "type": "Project", + "dependencies": { + "Speckle.Core": "[2.0.999-local, )" + } + } + } + } +} \ No newline at end of file diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/packages.lock.json b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/packages.lock.json new file mode 100644 index 0000000000..48eed8707b --- /dev/null +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/packages.lock.json @@ -0,0 +1,439 @@ +{ + "version": 1, + "dependencies": { + ".NETFramework,Version=v4.8": { + "PolySharp": { + "type": "Direct", + "requested": "[1.14.1, )", + "resolved": "1.14.1", + "contentHash": "mOOmFYwad3MIOL14VCjj02LljyF1GNw1wP0YVlxtcPvqdxjGGMNdNJJxHptlry3MOd8b40Flm8RPOM8JOlN2sQ==" + }, + "Speckle.InterfaceGenerator": { + "type": "Direct", + "requested": "[0.9.5, )", + "resolved": "0.9.5", + "contentHash": "oU/L7pN1R7q8KkbrpQ3WJnHirPHqn+9DEA7asOcUiggV5dzVg1A/VYs7GOSusD24njxXh03tE3a2oTLOjt3cVg==" + }, + "Speckle.Revit2023.Api": { + "type": "Direct", + "requested": "[0.1.1-preview.0.24, )", + "resolved": "0.1.1-preview.0.24", + "contentHash": "hPRXbyvgmealdPPWTxjHbpBRTsyt67DddoIs09M0n319eHh/eONnPC+SgBzJmmB834TtzzayMVk06S1cMT0Iow==", + "dependencies": { + "Mapster": "7.3.0", + "Speckle.Revit.API": "2023.0.0", + "Speckle.Revit2023.Interfaces": "0.1.1-preview.0.24" + } + }, + "GraphQL.Client": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "8yPNBbuVBpTptivyAlak4GZvbwbUcjeQTL4vN1HKHRuOykZ4r7l5fcLS6vpyPyLn0x8FsL31xbOIKyxbmR9rbA==", + "dependencies": { + "GraphQL.Client.Abstractions": "6.0.0", + "GraphQL.Client.Abstractions.Websocket": "6.0.0", + "System.Net.WebSockets.Client.Managed": "1.0.22", + "System.Reactive": "5.0.0" + } + }, + "GraphQL.Client.Abstractions": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "h7uzWFORHZ+CCjwr/ThAyXMr0DPpzEANDa4Uo54wqCQ+j7qUKwqYTgOrb1W40sqbvNaZm9v/X7It31SUw0maHA==", + "dependencies": { + "GraphQL.Primitives": "6.0.0" + } + }, + "GraphQL.Client.Abstractions.Websocket": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "Nr9bPf8gIOvLuXpqEpqr9z9jslYFJOvd0feHth3/kPqeR3uMbjF5pjiwh4jxyMcxHdr8Pb6QiXkV3hsSyt0v7A==", + "dependencies": { + "GraphQL.Client.Abstractions": "6.0.0" + } + }, + "GraphQL.Primitives": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "yg72rrYDapfsIUrul7aF6wwNnTJBOFvuA9VdDTQpPa8AlAriHbufeXYLBcodKjfUdkCnaiggX1U/nEP08Zb5GA==" + }, + "Mapster": { + "type": "Transitive", + "resolved": "7.3.0", + "contentHash": "NrCUX/rJa5PTyo6iW4AL5dZLU9PDNlYnrJOVjgdpo5OQM9EtWH2CMHnC5sSuJWC0d0b0SnmeRrIviEem6WxtuQ==", + "dependencies": { + "Mapster.Core": "1.2.0", + "Microsoft.CSharp": "4.3.0", + "System.Reflection.Emit": "4.3.0" + } + }, + "Mapster.Core": { + "type": "Transitive", + "resolved": "1.2.0", + "contentHash": "TNdqZk2zAuBYfJF88D/3clQTOyOdqr1crU81yZQtlGa+e7FYWhJdK/buBWT+TpM3qQko9UzmzfOT4iq3JCs/ZA==" + }, + "Microsoft.Bcl.AsyncInterfaces": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "W8DPQjkMScOMTtJbPwmPyj9c3zYSFGawDW3jwlBOOsnY+EzZFLgNQ/UMkK35JmkNOVPdCyPr2Tw7Vv9N+KA3ZQ==", + "dependencies": { + "System.Threading.Tasks.Extensions": "4.5.4" + } + }, + "Microsoft.CSharp": { + "type": "Transitive", + "resolved": "4.7.0", + "contentHash": "pTj+D3uJWyN3My70i2Hqo+OXixq3Os2D1nJ2x92FFo6sk8fYS1m1WLNTs0Dc1uPaViH0YvEEwvzddQ7y4rhXmA==" + }, + "Microsoft.Data.Sqlite": { + "type": "Transitive", + "resolved": "7.0.5", + "contentHash": "KGxbPeWsQMnmQy43DSBxAFtHz3l2JX8EWBSGUCvT3CuZ8KsuzbkqMIJMDOxWtG8eZSoCDI04aiVQjWuuV8HmSw==", + "dependencies": { + "Microsoft.Data.Sqlite.Core": "7.0.5", + "SQLitePCLRaw.bundle_e_sqlite3": "2.1.4" + } + }, + "Microsoft.Data.Sqlite.Core": { + "type": "Transitive", + "resolved": "7.0.5", + "contentHash": "FTerRmQPqHrCrnoUzhBu+E+1DNGwyrAMLqHkAqOOOu5pGfyMOj8qQUBxI/gDtWtG11p49UxSfWmBzRNlwZqfUg==", + "dependencies": { + "SQLitePCLRaw.core": "2.1.4" + } + }, + "Microsoft.Extensions.Logging.Abstractions": { + "type": "Transitive", + "resolved": "7.0.0", + "contentHash": "kmn78+LPVMOWeITUjIlfxUPDsI0R6G0RkeAMBmQxAJ7vBJn4q2dTva7pWi65ceN5vPGjJ9q/Uae2WKgvfktJAw==", + "dependencies": { + "System.Buffers": "4.5.1", + "System.Memory": "4.5.5" + } + }, + "Polly": { + "type": "Transitive", + "resolved": "7.2.3", + "contentHash": "DeCY0OFbNdNxsjntr1gTXHJ5pKUwYzp04Er2LLeN3g6pWhffsGuKVfMBLe1lw7x76HrPkLxKEFxBlpRxS2nDEQ==" + }, + "Polly.Contrib.WaitAndRetry": { + "type": "Transitive", + "resolved": "1.1.1", + "contentHash": "1MUQLiSo4KDkQe6nzQRhIU05lm9jlexX5BVsbuw0SL82ynZ+GzAHQxJVDPVBboxV37Po3SG077aX8DuSy8TkaA==" + }, + "Polly.Extensions.Http": { + "type": "Transitive", + "resolved": "3.0.0", + "contentHash": "drrG+hB3pYFY7w1c3BD+lSGYvH2oIclH8GRSehgfyP5kjnFnHKQuuBhuHLv+PWyFuaTDyk/vfRpnxOzd11+J8g==", + "dependencies": { + "Polly": "7.1.0" + } + }, + "Sentry": { + "type": "Transitive", + "resolved": "3.33.0", + "contentHash": "8vbD2o6IR2wrRrkSiRbnodWGWUOqIlwYtzpjvPNOb5raJdOf+zxMwfS8f6nx9bmrTTfDj7KrCB8C/5OuicAc8A==", + "dependencies": { + "System.Reflection.Metadata": "5.0.0", + "System.Runtime.InteropServices.RuntimeInformation": "4.3.0", + "System.Text.Json": "5.0.2" + } + }, + "Sentry.Serilog": { + "type": "Transitive", + "resolved": "3.33.0", + "contentHash": "V8BU7QGWg2qLYfNPqtuTBhC1opysny5l+Ifp6J6PhOeAxU0FssR7nYfbJVetrnLIoh2rd3DlJ6hHYYQosQYcUQ==", + "dependencies": { + "Sentry": "3.33.0", + "Serilog": "2.7.1" + } + }, + "Serilog": { + "type": "Transitive", + "resolved": "2.12.0", + "contentHash": "xaiJLIdu6rYMKfQMYUZgTy8YK7SMZjB4Yk50C/u//Z4OsvxkUfSPJy4nknfvwAC34yr13q7kcyh4grbwhSxyZg==" + }, + "Serilog.Enrichers.ClientInfo": { + "type": "Transitive", + "resolved": "1.3.0", + "contentHash": "mTc7PM+wC9Hr7LWSwqt5mmnlAr7RJs+eTb3PGPRhwdOackk95MkhUZognuxXEdlW19HAFNmEBTSBY5DfLwM8jQ==", + "dependencies": { + "Serilog": "2.4.0" + } + }, + "Serilog.Exceptions": { + "type": "Transitive", + "resolved": "8.4.0", + "contentHash": "nc/+hUw3lsdo0zCj0KMIybAu7perMx79vu72w0za9Nsi6mWyNkGXxYxakAjWB7nEmYL6zdmhEQRB4oJ2ALUeug==", + "dependencies": { + "Serilog": "2.8.0" + } + }, + "Serilog.Formatting.Compact": { + "type": "Transitive", + "resolved": "1.1.0", + "contentHash": "pNroKVjo+rDqlxNG5PXkRLpfSCuDOBY0ri6jp9PLe505ljqwhwZz8ospy2vWhQlFu5GkIesh3FcDs4n7sWZODA==", + "dependencies": { + "Serilog": "2.8.0" + } + }, + "Serilog.Sinks.Console": { + "type": "Transitive", + "resolved": "4.1.0", + "contentHash": "K6N5q+5fetjnJPvCmkWOpJ/V8IEIoMIB1s86OzBrbxwTyHxdx3pmz4H+8+O/Dc/ftUX12DM1aynx/dDowkwzqg==", + "dependencies": { + "Serilog": "2.10.0" + } + }, + "Serilog.Sinks.File": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "uwV5hdhWPwUH1szhO8PJpFiahqXmzPzJT/sOijH/kFgUx+cyoDTMM8MHD0adw9+Iem6itoibbUXHYslzXsLEAg==", + "dependencies": { + "Serilog": "2.10.0" + } + }, + "Serilog.Sinks.PeriodicBatching": { + "type": "Transitive", + "resolved": "3.1.0", + "contentHash": "NDWR7m3PalVlGEq3rzoktrXikjFMLmpwF0HI4sowo8YDdU+gqPlTHlDQiOGxHfB0sTfjPA9JjA7ctKG9zqjGkw==", + "dependencies": { + "Serilog": "2.0.0" + } + }, + "Serilog.Sinks.Seq": { + "type": "Transitive", + "resolved": "5.2.2", + "contentHash": "1Csmo5ua7NKUe0yXUx+zsRefjAniPWcXFhUXxXG8pwo0iMiw2gjn9SOkgYnnxbgWqmlGv236w0N/dHc2v5XwMg==", + "dependencies": { + "Serilog": "2.12.0", + "Serilog.Formatting.Compact": "1.1.0", + "Serilog.Sinks.File": "5.0.0", + "Serilog.Sinks.PeriodicBatching": "3.1.0" + } + }, + "SerilogTimings": { + "type": "Transitive", + "resolved": "3.0.1", + "contentHash": "Zs28eTgszAMwpIrbBnWHBI50yuxL50p/dmAUWmy75+axdZYK/Sjm5/5m1N/CisR8acJUhTVcjPZrsB1P5iv0Uw==", + "dependencies": { + "Serilog": "2.10.0" + } + }, + "Speckle.Newtonsoft.Json": { + "type": "Transitive", + "resolved": "13.0.2", + "contentHash": "g1BejUZwax5PRfL6xHgLEK23sqHWOgOj9hE7RvfRRlN00AGt8GnPYt8HedSK7UB3HiRW8zCA9Pn0iiYxCK24BA==" + }, + "Speckle.Revit.API": { + "type": "Transitive", + "resolved": "2023.0.0", + "contentHash": "tq40eD7psgTbV+epNouYyqfo6+hEi7FmXZqcxEOsAV7zfYyWhL6Rt3vmojkWGNuerGbH6oRI6KIIxrnlCNb8Hw==" + }, + "Speckle.Revit2023.Interfaces": { + "type": "Transitive", + "resolved": "0.1.1-preview.0.24", + "contentHash": "BSVpOUJc9g6ISrw8GxvtkglTlITpHEDYNOhxv1ZPbckBsI0yO36JiphhQV4q57ERqD9PpCozUJkVhlCaxWeS6A==" + }, + "SQLitePCLRaw.bundle_e_sqlite3": { + "type": "Transitive", + "resolved": "2.1.4", + "contentHash": "EWI1olKDjFEBMJu0+3wuxwziIAdWDVMYLhuZ3Qs84rrz+DHwD00RzWPZCa+bLnHCf3oJwuFZIRsHT5p236QXww==", + "dependencies": { + "SQLitePCLRaw.lib.e_sqlite3": "2.1.4", + "SQLitePCLRaw.provider.dynamic_cdecl": "2.1.4" + } + }, + "SQLitePCLRaw.core": { + "type": "Transitive", + "resolved": "2.1.4", + "contentHash": "inBjvSHo9UDKneGNzfUfDjK08JzlcIhn1+SP5Y3m6cgXpCxXKCJDy6Mka7LpgSV+UZmKSnC8rTwB0SQ0xKu5pA==", + "dependencies": { + "System.Memory": "4.5.3" + } + }, + "SQLitePCLRaw.lib.e_sqlite3": { + "type": "Transitive", + "resolved": "2.1.4", + "contentHash": "2C9Q9eX7CPLveJA0rIhf9RXAvu+7nWZu1A2MdG6SD/NOu26TakGgL1nsbc0JAspGijFOo3HoN79xrx8a368fBg==" + }, + "SQLitePCLRaw.provider.dynamic_cdecl": { + "type": "Transitive", + "resolved": "2.1.4", + "contentHash": "ZsaKKhgYF9B1fvcnOGKl3EycNAwd9CRWX7v0rEfuPWhQQ5Jjpvf2VEHahiLIGHio3hxi3EIKFJw9KvyowWOUAw==", + "dependencies": { + "SQLitePCLRaw.core": "2.1.4" + } + }, + "System.Buffers": { + "type": "Transitive", + "resolved": "4.5.1", + "contentHash": "Rw7ijyl1qqRS0YQD/WycNst8hUUMgrMH4FCn1nNm27M4VxchZ1js3fVjQaANHO5f3sN4isvP4a+Met9Y4YomAg==" + }, + "System.Collections.Immutable": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "FXkLXiK0sVVewcso0imKQoOxjoPAj42R8HtjjbSjVPAzwDfzoyoznWxgA3c38LDbN9SJux1xXoXYAhz98j7r2g==", + "dependencies": { + "System.Memory": "4.5.4" + } + }, + "System.DoubleNumerics": { + "type": "Transitive", + "resolved": "3.1.3", + "contentHash": "KRKEM/L3KBodjA9VOg3EifFVWUY6EOqaMB05UvPEDm7Zeby/kZW+4kdWUEPzW6xtkwf46p661L9NrbeeQhtLzw==", + "dependencies": { + "NETStandard.Library": "1.6.1" + } + }, + "System.Memory": { + "type": "Transitive", + "resolved": "4.5.5", + "contentHash": "XIWiDvKPXaTveaB7HVganDlOCRoj03l+jrwNvcge/t8vhGYKvqV+dMv6G4SAX2NoNmN0wZfVPTAlFwZcZvVOUw==", + "dependencies": { + "System.Buffers": "4.5.1", + "System.Numerics.Vectors": "4.5.0", + "System.Runtime.CompilerServices.Unsafe": "4.5.3" + } + }, + "System.Net.WebSockets.Client.Managed": { + "type": "Transitive", + "resolved": "1.0.22", + "contentHash": "WqEOxPlXjuZrIjUtXNE9NxEfU/n5E35iV2PtoZdJSUC4tlrqwHnTee+wvMIM4OUaJWmwrymeqcgYrE0IkGAgLA==", + "dependencies": { + "System.Buffers": "4.4.0", + "System.Numerics.Vectors": "4.4.0" + } + }, + "System.Numerics.Vectors": { + "type": "Transitive", + "resolved": "4.5.0", + "contentHash": "QQTlPTl06J/iiDbJCiepZ4H//BVraReU4O4EoRw1U02H5TLUIT7xn3GnDp9AXPSlJUDyFs4uWjWafNX6WrAojQ==" + }, + "System.Reactive": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "erBZjkQHWL9jpasCE/0qKAryzVBJFxGHVBAvgRN1bzM0q2s1S4oYREEEL0Vb+1kA/6BKb5FjUZMp5VXmy+gzkQ==", + "dependencies": { + "System.Threading.Tasks.Extensions": "4.5.4" + } + }, + "System.Reflection.Emit": { + "type": "Transitive", + "resolved": "4.3.0", + "contentHash": "228FG0jLcIwTVJyz8CLFKueVqQK36ANazUManGaJHkO0icjiIypKW7YLWLIWahyIkdh5M7mV2dJepllLyA1SKg==" + }, + "System.Reflection.Metadata": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "5NecZgXktdGg34rh1OenY1rFNDCI8xSjFr+Z4OU4cU06AQHUdRnIIEeWENu3Wl4YowbzkymAIMvi3WyK9U53pQ==", + "dependencies": { + "System.Collections.Immutable": "5.0.0" + } + }, + "System.Runtime.CompilerServices.Unsafe": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "ZD9TMpsmYJLrxbbmdvhwt9YEgG5WntEnZ/d1eH8JBX9LBp+Ju8BSBhUGbZMNVHHomWo2KVImJhTDl2hIgw/6MA==" + }, + "System.Runtime.InteropServices.RuntimeInformation": { + "type": "Transitive", + "resolved": "4.3.0", + "contentHash": "cbz4YJMqRDR7oLeMRbdYv7mYzc++17lNhScCX0goO2XpGWdvAt60CGN+FHdePUEHCe/Jy9jUlvNAiNdM+7jsOw==" + }, + "System.Text.Encodings.Web": { + "type": "Transitive", + "resolved": "5.0.1", + "contentHash": "KmJ+CJXizDofbq6mpqDoRRLcxgOd2z9X3XoFNULSbvbqVRZkFX3istvr+MUjL6Zw1RT+RNdoI4GYidIINtgvqQ==", + "dependencies": { + "System.Buffers": "4.5.1", + "System.Memory": "4.5.4" + } + }, + "System.Text.Json": { + "type": "Transitive", + "resolved": "5.0.2", + "contentHash": "I47dVIGiV6SfAyppphxqupertT/5oZkYLDCX6vC3HpOI4ZLjyoKAreUoem2ie6G0RbRuFrlqz/PcTQjfb2DOfQ==", + "dependencies": { + "Microsoft.Bcl.AsyncInterfaces": "5.0.0", + "System.Buffers": "4.5.1", + "System.Memory": "4.5.4", + "System.Numerics.Vectors": "4.5.0", + "System.Runtime.CompilerServices.Unsafe": "5.0.0", + "System.Text.Encodings.Web": "5.0.1", + "System.Threading.Tasks.Extensions": "4.5.4", + "System.ValueTuple": "4.5.0" + } + }, + "System.Threading.Tasks.Extensions": { + "type": "Transitive", + "resolved": "4.5.4", + "contentHash": "zteT+G8xuGu6mS+mzDzYXbzS7rd3K6Fjb9RiZlYlJPam2/hU7JCBZBVEcywNuR+oZ1ncTvc/cq0faRr3P01OVg==", + "dependencies": { + "System.Runtime.CompilerServices.Unsafe": "4.5.3" + } + }, + "System.ValueTuple": { + "type": "Transitive", + "resolved": "4.5.0", + "contentHash": "okurQJO6NRE/apDIP23ajJ0hpiNmJ+f0BwOlB/cSqTLQlw5upkf+5+96+iG2Jw40G1fCVCyPz/FhIABUjMR+RQ==" + }, + "speckle.autofac": { + "type": "Project", + "dependencies": { + "Microsoft.Extensions.Logging.Abstractions": "[7.0.0, )", + "Speckle.Core": "[2.0.999-local, )" + } + }, + "speckle.converters.common": { + "type": "Project", + "dependencies": { + "Speckle.Autofac": "[2.0.999-local, )", + "Speckle.Objects": "[2.0.999-local, )", + "Speckle.Revit2023.Interfaces": "[0.1.1-preview.0.24, )" + } + }, + "speckle.converters.common.dependencyinjection": { + "type": "Project", + "dependencies": { + "Speckle.Autofac": "[2.0.999-local, )", + "Speckle.Converters.Common": "[2.0.999-local, )" + } + }, + "speckle.converters.revit2023": { + "type": "Project", + "dependencies": { + "Speckle.Converters.Common": "[2.0.999-local, )", + "Speckle.Revit2023.Interfaces": "[0.1.1-preview.0.24, )" + } + }, + "Speckle.Core": { + "type": "Project", + "dependencies": { + "GraphQL.Client": "[6.0.0, )", + "Microsoft.CSharp": "[4.7.0, )", + "Microsoft.Data.Sqlite": "[7.0.5, )", + "Polly": "[7.2.3, )", + "Polly.Contrib.WaitAndRetry": "[1.1.1, )", + "Polly.Extensions.Http": "[3.0.0, )", + "Sentry": "[3.33.0, )", + "Sentry.Serilog": "[3.33.0, )", + "Serilog": "[2.12.0, )", + "Serilog.Enrichers.ClientInfo": "[1.3.0, )", + "Serilog.Exceptions": "[8.4.0, )", + "Serilog.Sinks.Console": "[4.1.0, )", + "Serilog.Sinks.Seq": "[5.2.2, )", + "SerilogTimings": "[3.0.1, )", + "Speckle.Newtonsoft.Json": "[13.0.2, )", + "System.DoubleNumerics": "[3.1.3, )" + } + }, + "Speckle.Objects": { + "type": "Project", + "dependencies": { + "Speckle.Core": "[2.0.999-local, )" + } + } + } + } +} \ No newline at end of file diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023/packages.lock.json b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023/packages.lock.json new file mode 100644 index 0000000000..b021d0f201 --- /dev/null +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023/packages.lock.json @@ -0,0 +1,390 @@ +{ + "version": 1, + "dependencies": { + ".NETFramework,Version=v4.8": { + "PolySharp": { + "type": "Direct", + "requested": "[1.14.1, )", + "resolved": "1.14.1", + "contentHash": "mOOmFYwad3MIOL14VCjj02LljyF1GNw1wP0YVlxtcPvqdxjGGMNdNJJxHptlry3MOd8b40Flm8RPOM8JOlN2sQ==" + }, + "Speckle.InterfaceGenerator": { + "type": "Direct", + "requested": "[0.9.5, )", + "resolved": "0.9.5", + "contentHash": "oU/L7pN1R7q8KkbrpQ3WJnHirPHqn+9DEA7asOcUiggV5dzVg1A/VYs7GOSusD24njxXh03tE3a2oTLOjt3cVg==" + }, + "Speckle.Revit2023.Interfaces": { + "type": "Direct", + "requested": "[0.1.1-preview.0.24, )", + "resolved": "0.1.1-preview.0.24", + "contentHash": "BSVpOUJc9g6ISrw8GxvtkglTlITpHEDYNOhxv1ZPbckBsI0yO36JiphhQV4q57ERqD9PpCozUJkVhlCaxWeS6A==" + }, + "GraphQL.Client": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "8yPNBbuVBpTptivyAlak4GZvbwbUcjeQTL4vN1HKHRuOykZ4r7l5fcLS6vpyPyLn0x8FsL31xbOIKyxbmR9rbA==", + "dependencies": { + "GraphQL.Client.Abstractions": "6.0.0", + "GraphQL.Client.Abstractions.Websocket": "6.0.0", + "System.Net.WebSockets.Client.Managed": "1.0.22", + "System.Reactive": "5.0.0" + } + }, + "GraphQL.Client.Abstractions": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "h7uzWFORHZ+CCjwr/ThAyXMr0DPpzEANDa4Uo54wqCQ+j7qUKwqYTgOrb1W40sqbvNaZm9v/X7It31SUw0maHA==", + "dependencies": { + "GraphQL.Primitives": "6.0.0" + } + }, + "GraphQL.Client.Abstractions.Websocket": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "Nr9bPf8gIOvLuXpqEpqr9z9jslYFJOvd0feHth3/kPqeR3uMbjF5pjiwh4jxyMcxHdr8Pb6QiXkV3hsSyt0v7A==", + "dependencies": { + "GraphQL.Client.Abstractions": "6.0.0" + } + }, + "GraphQL.Primitives": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "yg72rrYDapfsIUrul7aF6wwNnTJBOFvuA9VdDTQpPa8AlAriHbufeXYLBcodKjfUdkCnaiggX1U/nEP08Zb5GA==" + }, + "Microsoft.Bcl.AsyncInterfaces": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "W8DPQjkMScOMTtJbPwmPyj9c3zYSFGawDW3jwlBOOsnY+EzZFLgNQ/UMkK35JmkNOVPdCyPr2Tw7Vv9N+KA3ZQ==", + "dependencies": { + "System.Threading.Tasks.Extensions": "4.5.4" + } + }, + "Microsoft.CSharp": { + "type": "Transitive", + "resolved": "4.7.0", + "contentHash": "pTj+D3uJWyN3My70i2Hqo+OXixq3Os2D1nJ2x92FFo6sk8fYS1m1WLNTs0Dc1uPaViH0YvEEwvzddQ7y4rhXmA==" + }, + "Microsoft.Data.Sqlite": { + "type": "Transitive", + "resolved": "7.0.5", + "contentHash": "KGxbPeWsQMnmQy43DSBxAFtHz3l2JX8EWBSGUCvT3CuZ8KsuzbkqMIJMDOxWtG8eZSoCDI04aiVQjWuuV8HmSw==", + "dependencies": { + "Microsoft.Data.Sqlite.Core": "7.0.5", + "SQLitePCLRaw.bundle_e_sqlite3": "2.1.4" + } + }, + "Microsoft.Data.Sqlite.Core": { + "type": "Transitive", + "resolved": "7.0.5", + "contentHash": "FTerRmQPqHrCrnoUzhBu+E+1DNGwyrAMLqHkAqOOOu5pGfyMOj8qQUBxI/gDtWtG11p49UxSfWmBzRNlwZqfUg==", + "dependencies": { + "SQLitePCLRaw.core": "2.1.4" + } + }, + "Microsoft.Extensions.Logging.Abstractions": { + "type": "Transitive", + "resolved": "7.0.0", + "contentHash": "kmn78+LPVMOWeITUjIlfxUPDsI0R6G0RkeAMBmQxAJ7vBJn4q2dTva7pWi65ceN5vPGjJ9q/Uae2WKgvfktJAw==", + "dependencies": { + "System.Buffers": "4.5.1", + "System.Memory": "4.5.5" + } + }, + "Polly": { + "type": "Transitive", + "resolved": "7.2.3", + "contentHash": "DeCY0OFbNdNxsjntr1gTXHJ5pKUwYzp04Er2LLeN3g6pWhffsGuKVfMBLe1lw7x76HrPkLxKEFxBlpRxS2nDEQ==" + }, + "Polly.Contrib.WaitAndRetry": { + "type": "Transitive", + "resolved": "1.1.1", + "contentHash": "1MUQLiSo4KDkQe6nzQRhIU05lm9jlexX5BVsbuw0SL82ynZ+GzAHQxJVDPVBboxV37Po3SG077aX8DuSy8TkaA==" + }, + "Polly.Extensions.Http": { + "type": "Transitive", + "resolved": "3.0.0", + "contentHash": "drrG+hB3pYFY7w1c3BD+lSGYvH2oIclH8GRSehgfyP5kjnFnHKQuuBhuHLv+PWyFuaTDyk/vfRpnxOzd11+J8g==", + "dependencies": { + "Polly": "7.1.0" + } + }, + "Sentry": { + "type": "Transitive", + "resolved": "3.33.0", + "contentHash": "8vbD2o6IR2wrRrkSiRbnodWGWUOqIlwYtzpjvPNOb5raJdOf+zxMwfS8f6nx9bmrTTfDj7KrCB8C/5OuicAc8A==", + "dependencies": { + "System.Reflection.Metadata": "5.0.0", + "System.Runtime.InteropServices.RuntimeInformation": "4.3.0", + "System.Text.Json": "5.0.2" + } + }, + "Sentry.Serilog": { + "type": "Transitive", + "resolved": "3.33.0", + "contentHash": "V8BU7QGWg2qLYfNPqtuTBhC1opysny5l+Ifp6J6PhOeAxU0FssR7nYfbJVetrnLIoh2rd3DlJ6hHYYQosQYcUQ==", + "dependencies": { + "Sentry": "3.33.0", + "Serilog": "2.7.1" + } + }, + "Serilog": { + "type": "Transitive", + "resolved": "2.12.0", + "contentHash": "xaiJLIdu6rYMKfQMYUZgTy8YK7SMZjB4Yk50C/u//Z4OsvxkUfSPJy4nknfvwAC34yr13q7kcyh4grbwhSxyZg==" + }, + "Serilog.Enrichers.ClientInfo": { + "type": "Transitive", + "resolved": "1.3.0", + "contentHash": "mTc7PM+wC9Hr7LWSwqt5mmnlAr7RJs+eTb3PGPRhwdOackk95MkhUZognuxXEdlW19HAFNmEBTSBY5DfLwM8jQ==", + "dependencies": { + "Serilog": "2.4.0" + } + }, + "Serilog.Exceptions": { + "type": "Transitive", + "resolved": "8.4.0", + "contentHash": "nc/+hUw3lsdo0zCj0KMIybAu7perMx79vu72w0za9Nsi6mWyNkGXxYxakAjWB7nEmYL6zdmhEQRB4oJ2ALUeug==", + "dependencies": { + "Serilog": "2.8.0" + } + }, + "Serilog.Formatting.Compact": { + "type": "Transitive", + "resolved": "1.1.0", + "contentHash": "pNroKVjo+rDqlxNG5PXkRLpfSCuDOBY0ri6jp9PLe505ljqwhwZz8ospy2vWhQlFu5GkIesh3FcDs4n7sWZODA==", + "dependencies": { + "Serilog": "2.8.0" + } + }, + "Serilog.Sinks.Console": { + "type": "Transitive", + "resolved": "4.1.0", + "contentHash": "K6N5q+5fetjnJPvCmkWOpJ/V8IEIoMIB1s86OzBrbxwTyHxdx3pmz4H+8+O/Dc/ftUX12DM1aynx/dDowkwzqg==", + "dependencies": { + "Serilog": "2.10.0" + } + }, + "Serilog.Sinks.File": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "uwV5hdhWPwUH1szhO8PJpFiahqXmzPzJT/sOijH/kFgUx+cyoDTMM8MHD0adw9+Iem6itoibbUXHYslzXsLEAg==", + "dependencies": { + "Serilog": "2.10.0" + } + }, + "Serilog.Sinks.PeriodicBatching": { + "type": "Transitive", + "resolved": "3.1.0", + "contentHash": "NDWR7m3PalVlGEq3rzoktrXikjFMLmpwF0HI4sowo8YDdU+gqPlTHlDQiOGxHfB0sTfjPA9JjA7ctKG9zqjGkw==", + "dependencies": { + "Serilog": "2.0.0" + } + }, + "Serilog.Sinks.Seq": { + "type": "Transitive", + "resolved": "5.2.2", + "contentHash": "1Csmo5ua7NKUe0yXUx+zsRefjAniPWcXFhUXxXG8pwo0iMiw2gjn9SOkgYnnxbgWqmlGv236w0N/dHc2v5XwMg==", + "dependencies": { + "Serilog": "2.12.0", + "Serilog.Formatting.Compact": "1.1.0", + "Serilog.Sinks.File": "5.0.0", + "Serilog.Sinks.PeriodicBatching": "3.1.0" + } + }, + "SerilogTimings": { + "type": "Transitive", + "resolved": "3.0.1", + "contentHash": "Zs28eTgszAMwpIrbBnWHBI50yuxL50p/dmAUWmy75+axdZYK/Sjm5/5m1N/CisR8acJUhTVcjPZrsB1P5iv0Uw==", + "dependencies": { + "Serilog": "2.10.0" + } + }, + "Speckle.Newtonsoft.Json": { + "type": "Transitive", + "resolved": "13.0.2", + "contentHash": "g1BejUZwax5PRfL6xHgLEK23sqHWOgOj9hE7RvfRRlN00AGt8GnPYt8HedSK7UB3HiRW8zCA9Pn0iiYxCK24BA==" + }, + "SQLitePCLRaw.bundle_e_sqlite3": { + "type": "Transitive", + "resolved": "2.1.4", + "contentHash": "EWI1olKDjFEBMJu0+3wuxwziIAdWDVMYLhuZ3Qs84rrz+DHwD00RzWPZCa+bLnHCf3oJwuFZIRsHT5p236QXww==", + "dependencies": { + "SQLitePCLRaw.lib.e_sqlite3": "2.1.4", + "SQLitePCLRaw.provider.dynamic_cdecl": "2.1.4" + } + }, + "SQLitePCLRaw.core": { + "type": "Transitive", + "resolved": "2.1.4", + "contentHash": "inBjvSHo9UDKneGNzfUfDjK08JzlcIhn1+SP5Y3m6cgXpCxXKCJDy6Mka7LpgSV+UZmKSnC8rTwB0SQ0xKu5pA==", + "dependencies": { + "System.Memory": "4.5.3" + } + }, + "SQLitePCLRaw.lib.e_sqlite3": { + "type": "Transitive", + "resolved": "2.1.4", + "contentHash": "2C9Q9eX7CPLveJA0rIhf9RXAvu+7nWZu1A2MdG6SD/NOu26TakGgL1nsbc0JAspGijFOo3HoN79xrx8a368fBg==" + }, + "SQLitePCLRaw.provider.dynamic_cdecl": { + "type": "Transitive", + "resolved": "2.1.4", + "contentHash": "ZsaKKhgYF9B1fvcnOGKl3EycNAwd9CRWX7v0rEfuPWhQQ5Jjpvf2VEHahiLIGHio3hxi3EIKFJw9KvyowWOUAw==", + "dependencies": { + "SQLitePCLRaw.core": "2.1.4" + } + }, + "System.Buffers": { + "type": "Transitive", + "resolved": "4.5.1", + "contentHash": "Rw7ijyl1qqRS0YQD/WycNst8hUUMgrMH4FCn1nNm27M4VxchZ1js3fVjQaANHO5f3sN4isvP4a+Met9Y4YomAg==" + }, + "System.Collections.Immutable": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "FXkLXiK0sVVewcso0imKQoOxjoPAj42R8HtjjbSjVPAzwDfzoyoznWxgA3c38LDbN9SJux1xXoXYAhz98j7r2g==", + "dependencies": { + "System.Memory": "4.5.4" + } + }, + "System.DoubleNumerics": { + "type": "Transitive", + "resolved": "3.1.3", + "contentHash": "KRKEM/L3KBodjA9VOg3EifFVWUY6EOqaMB05UvPEDm7Zeby/kZW+4kdWUEPzW6xtkwf46p661L9NrbeeQhtLzw==", + "dependencies": { + "NETStandard.Library": "1.6.1" + } + }, + "System.Memory": { + "type": "Transitive", + "resolved": "4.5.5", + "contentHash": "XIWiDvKPXaTveaB7HVganDlOCRoj03l+jrwNvcge/t8vhGYKvqV+dMv6G4SAX2NoNmN0wZfVPTAlFwZcZvVOUw==", + "dependencies": { + "System.Buffers": "4.5.1", + "System.Numerics.Vectors": "4.5.0", + "System.Runtime.CompilerServices.Unsafe": "4.5.3" + } + }, + "System.Net.WebSockets.Client.Managed": { + "type": "Transitive", + "resolved": "1.0.22", + "contentHash": "WqEOxPlXjuZrIjUtXNE9NxEfU/n5E35iV2PtoZdJSUC4tlrqwHnTee+wvMIM4OUaJWmwrymeqcgYrE0IkGAgLA==", + "dependencies": { + "System.Buffers": "4.4.0", + "System.Numerics.Vectors": "4.4.0" + } + }, + "System.Numerics.Vectors": { + "type": "Transitive", + "resolved": "4.5.0", + "contentHash": "QQTlPTl06J/iiDbJCiepZ4H//BVraReU4O4EoRw1U02H5TLUIT7xn3GnDp9AXPSlJUDyFs4uWjWafNX6WrAojQ==" + }, + "System.Reactive": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "erBZjkQHWL9jpasCE/0qKAryzVBJFxGHVBAvgRN1bzM0q2s1S4oYREEEL0Vb+1kA/6BKb5FjUZMp5VXmy+gzkQ==", + "dependencies": { + "System.Threading.Tasks.Extensions": "4.5.4" + } + }, + "System.Reflection.Metadata": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "5NecZgXktdGg34rh1OenY1rFNDCI8xSjFr+Z4OU4cU06AQHUdRnIIEeWENu3Wl4YowbzkymAIMvi3WyK9U53pQ==", + "dependencies": { + "System.Collections.Immutable": "5.0.0" + } + }, + "System.Runtime.CompilerServices.Unsafe": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "ZD9TMpsmYJLrxbbmdvhwt9YEgG5WntEnZ/d1eH8JBX9LBp+Ju8BSBhUGbZMNVHHomWo2KVImJhTDl2hIgw/6MA==" + }, + "System.Runtime.InteropServices.RuntimeInformation": { + "type": "Transitive", + "resolved": "4.3.0", + "contentHash": "cbz4YJMqRDR7oLeMRbdYv7mYzc++17lNhScCX0goO2XpGWdvAt60CGN+FHdePUEHCe/Jy9jUlvNAiNdM+7jsOw==" + }, + "System.Text.Encodings.Web": { + "type": "Transitive", + "resolved": "5.0.1", + "contentHash": "KmJ+CJXizDofbq6mpqDoRRLcxgOd2z9X3XoFNULSbvbqVRZkFX3istvr+MUjL6Zw1RT+RNdoI4GYidIINtgvqQ==", + "dependencies": { + "System.Buffers": "4.5.1", + "System.Memory": "4.5.4" + } + }, + "System.Text.Json": { + "type": "Transitive", + "resolved": "5.0.2", + "contentHash": "I47dVIGiV6SfAyppphxqupertT/5oZkYLDCX6vC3HpOI4ZLjyoKAreUoem2ie6G0RbRuFrlqz/PcTQjfb2DOfQ==", + "dependencies": { + "Microsoft.Bcl.AsyncInterfaces": "5.0.0", + "System.Buffers": "4.5.1", + "System.Memory": "4.5.4", + "System.Numerics.Vectors": "4.5.0", + "System.Runtime.CompilerServices.Unsafe": "5.0.0", + "System.Text.Encodings.Web": "5.0.1", + "System.Threading.Tasks.Extensions": "4.5.4", + "System.ValueTuple": "4.5.0" + } + }, + "System.Threading.Tasks.Extensions": { + "type": "Transitive", + "resolved": "4.5.4", + "contentHash": "zteT+G8xuGu6mS+mzDzYXbzS7rd3K6Fjb9RiZlYlJPam2/hU7JCBZBVEcywNuR+oZ1ncTvc/cq0faRr3P01OVg==", + "dependencies": { + "System.Runtime.CompilerServices.Unsafe": "4.5.3" + } + }, + "System.ValueTuple": { + "type": "Transitive", + "resolved": "4.5.0", + "contentHash": "okurQJO6NRE/apDIP23ajJ0hpiNmJ+f0BwOlB/cSqTLQlw5upkf+5+96+iG2Jw40G1fCVCyPz/FhIABUjMR+RQ==" + }, + "speckle.autofac": { + "type": "Project", + "dependencies": { + "Microsoft.Extensions.Logging.Abstractions": "[7.0.0, )", + "Speckle.Core": "[2.0.999-local, )" + } + }, + "speckle.converters.common": { + "type": "Project", + "dependencies": { + "Speckle.Autofac": "[2.0.999-local, )", + "Speckle.Objects": "[2.0.999-local, )", + "Speckle.Revit2023.Interfaces": "[0.1.1-preview.0.24, )" + } + }, + "Speckle.Core": { + "type": "Project", + "dependencies": { + "GraphQL.Client": "[6.0.0, )", + "Microsoft.CSharp": "[4.7.0, )", + "Microsoft.Data.Sqlite": "[7.0.5, )", + "Polly": "[7.2.3, )", + "Polly.Contrib.WaitAndRetry": "[1.1.1, )", + "Polly.Extensions.Http": "[3.0.0, )", + "Sentry": "[3.33.0, )", + "Sentry.Serilog": "[3.33.0, )", + "Serilog": "[2.12.0, )", + "Serilog.Enrichers.ClientInfo": "[1.3.0, )", + "Serilog.Exceptions": "[8.4.0, )", + "Serilog.Sinks.Console": "[4.1.0, )", + "Serilog.Sinks.Seq": "[5.2.2, )", + "SerilogTimings": "[3.0.1, )", + "Speckle.Newtonsoft.Json": "[13.0.2, )", + "System.DoubleNumerics": "[3.1.3, )" + } + }, + "Speckle.Objects": { + "type": "Project", + "dependencies": { + "Speckle.Core": "[2.0.999-local, )" + } + } + } + } +} \ No newline at end of file diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/packages.lock.json b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/packages.lock.json new file mode 100644 index 0000000000..590b6f9e6c --- /dev/null +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/packages.lock.json @@ -0,0 +1,409 @@ +{ + "version": 1, + "dependencies": { + ".NETFramework,Version=v4.8": { + "PolySharp": { + "type": "Direct", + "requested": "[1.14.1, )", + "resolved": "1.14.1", + "contentHash": "mOOmFYwad3MIOL14VCjj02LljyF1GNw1wP0YVlxtcPvqdxjGGMNdNJJxHptlry3MOd8b40Flm8RPOM8JOlN2sQ==" + }, + "RhinoCommon": { + "type": "Direct", + "requested": "[7.13.21348.13001, )", + "resolved": "7.13.21348.13001", + "contentHash": "JQdaNw61ddBqIe08E9O4N/grwrN1hjDHcYW7tWylwCZyFR7SepoCD4NS+6LN6+oSQhNbhLi9Bf+hQOFYFdRAEA==" + }, + "Speckle.InterfaceGenerator": { + "type": "Direct", + "requested": "[0.9.5, )", + "resolved": "0.9.5", + "contentHash": "oU/L7pN1R7q8KkbrpQ3WJnHirPHqn+9DEA7asOcUiggV5dzVg1A/VYs7GOSusD24njxXh03tE3a2oTLOjt3cVg==" + }, + "GraphQL.Client": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "8yPNBbuVBpTptivyAlak4GZvbwbUcjeQTL4vN1HKHRuOykZ4r7l5fcLS6vpyPyLn0x8FsL31xbOIKyxbmR9rbA==", + "dependencies": { + "GraphQL.Client.Abstractions": "6.0.0", + "GraphQL.Client.Abstractions.Websocket": "6.0.0", + "System.Net.WebSockets.Client.Managed": "1.0.22", + "System.Reactive": "5.0.0" + } + }, + "GraphQL.Client.Abstractions": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "h7uzWFORHZ+CCjwr/ThAyXMr0DPpzEANDa4Uo54wqCQ+j7qUKwqYTgOrb1W40sqbvNaZm9v/X7It31SUw0maHA==", + "dependencies": { + "GraphQL.Primitives": "6.0.0" + } + }, + "GraphQL.Client.Abstractions.Websocket": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "Nr9bPf8gIOvLuXpqEpqr9z9jslYFJOvd0feHth3/kPqeR3uMbjF5pjiwh4jxyMcxHdr8Pb6QiXkV3hsSyt0v7A==", + "dependencies": { + "GraphQL.Client.Abstractions": "6.0.0" + } + }, + "GraphQL.Primitives": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "yg72rrYDapfsIUrul7aF6wwNnTJBOFvuA9VdDTQpPa8AlAriHbufeXYLBcodKjfUdkCnaiggX1U/nEP08Zb5GA==" + }, + "Microsoft.Bcl.AsyncInterfaces": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "W8DPQjkMScOMTtJbPwmPyj9c3zYSFGawDW3jwlBOOsnY+EzZFLgNQ/UMkK35JmkNOVPdCyPr2Tw7Vv9N+KA3ZQ==", + "dependencies": { + "System.Threading.Tasks.Extensions": "4.5.4" + } + }, + "Microsoft.CSharp": { + "type": "Transitive", + "resolved": "4.7.0", + "contentHash": "pTj+D3uJWyN3My70i2Hqo+OXixq3Os2D1nJ2x92FFo6sk8fYS1m1WLNTs0Dc1uPaViH0YvEEwvzddQ7y4rhXmA==" + }, + "Microsoft.Data.Sqlite": { + "type": "Transitive", + "resolved": "7.0.5", + "contentHash": "KGxbPeWsQMnmQy43DSBxAFtHz3l2JX8EWBSGUCvT3CuZ8KsuzbkqMIJMDOxWtG8eZSoCDI04aiVQjWuuV8HmSw==", + "dependencies": { + "Microsoft.Data.Sqlite.Core": "7.0.5", + "SQLitePCLRaw.bundle_e_sqlite3": "2.1.4" + } + }, + "Microsoft.Data.Sqlite.Core": { + "type": "Transitive", + "resolved": "7.0.5", + "contentHash": "FTerRmQPqHrCrnoUzhBu+E+1DNGwyrAMLqHkAqOOOu5pGfyMOj8qQUBxI/gDtWtG11p49UxSfWmBzRNlwZqfUg==", + "dependencies": { + "SQLitePCLRaw.core": "2.1.4" + } + }, + "Microsoft.Extensions.Logging.Abstractions": { + "type": "Transitive", + "resolved": "7.0.0", + "contentHash": "kmn78+LPVMOWeITUjIlfxUPDsI0R6G0RkeAMBmQxAJ7vBJn4q2dTva7pWi65ceN5vPGjJ9q/Uae2WKgvfktJAw==", + "dependencies": { + "System.Buffers": "4.5.1", + "System.Memory": "4.5.5" + } + }, + "Polly": { + "type": "Transitive", + "resolved": "7.2.3", + "contentHash": "DeCY0OFbNdNxsjntr1gTXHJ5pKUwYzp04Er2LLeN3g6pWhffsGuKVfMBLe1lw7x76HrPkLxKEFxBlpRxS2nDEQ==" + }, + "Polly.Contrib.WaitAndRetry": { + "type": "Transitive", + "resolved": "1.1.1", + "contentHash": "1MUQLiSo4KDkQe6nzQRhIU05lm9jlexX5BVsbuw0SL82ynZ+GzAHQxJVDPVBboxV37Po3SG077aX8DuSy8TkaA==" + }, + "Polly.Extensions.Http": { + "type": "Transitive", + "resolved": "3.0.0", + "contentHash": "drrG+hB3pYFY7w1c3BD+lSGYvH2oIclH8GRSehgfyP5kjnFnHKQuuBhuHLv+PWyFuaTDyk/vfRpnxOzd11+J8g==", + "dependencies": { + "Polly": "7.1.0" + } + }, + "Sentry": { + "type": "Transitive", + "resolved": "3.33.0", + "contentHash": "8vbD2o6IR2wrRrkSiRbnodWGWUOqIlwYtzpjvPNOb5raJdOf+zxMwfS8f6nx9bmrTTfDj7KrCB8C/5OuicAc8A==", + "dependencies": { + "System.Reflection.Metadata": "5.0.0", + "System.Runtime.InteropServices.RuntimeInformation": "4.3.0", + "System.Text.Json": "5.0.2" + } + }, + "Sentry.Serilog": { + "type": "Transitive", + "resolved": "3.33.0", + "contentHash": "V8BU7QGWg2qLYfNPqtuTBhC1opysny5l+Ifp6J6PhOeAxU0FssR7nYfbJVetrnLIoh2rd3DlJ6hHYYQosQYcUQ==", + "dependencies": { + "Sentry": "3.33.0", + "Serilog": "2.7.1" + } + }, + "Serilog": { + "type": "Transitive", + "resolved": "2.12.0", + "contentHash": "xaiJLIdu6rYMKfQMYUZgTy8YK7SMZjB4Yk50C/u//Z4OsvxkUfSPJy4nknfvwAC34yr13q7kcyh4grbwhSxyZg==" + }, + "Serilog.Enrichers.ClientInfo": { + "type": "Transitive", + "resolved": "1.3.0", + "contentHash": "mTc7PM+wC9Hr7LWSwqt5mmnlAr7RJs+eTb3PGPRhwdOackk95MkhUZognuxXEdlW19HAFNmEBTSBY5DfLwM8jQ==", + "dependencies": { + "Serilog": "2.4.0" + } + }, + "Serilog.Exceptions": { + "type": "Transitive", + "resolved": "8.4.0", + "contentHash": "nc/+hUw3lsdo0zCj0KMIybAu7perMx79vu72w0za9Nsi6mWyNkGXxYxakAjWB7nEmYL6zdmhEQRB4oJ2ALUeug==", + "dependencies": { + "Serilog": "2.8.0" + } + }, + "Serilog.Formatting.Compact": { + "type": "Transitive", + "resolved": "1.1.0", + "contentHash": "pNroKVjo+rDqlxNG5PXkRLpfSCuDOBY0ri6jp9PLe505ljqwhwZz8ospy2vWhQlFu5GkIesh3FcDs4n7sWZODA==", + "dependencies": { + "Serilog": "2.8.0" + } + }, + "Serilog.Sinks.Console": { + "type": "Transitive", + "resolved": "4.1.0", + "contentHash": "K6N5q+5fetjnJPvCmkWOpJ/V8IEIoMIB1s86OzBrbxwTyHxdx3pmz4H+8+O/Dc/ftUX12DM1aynx/dDowkwzqg==", + "dependencies": { + "Serilog": "2.10.0" + } + }, + "Serilog.Sinks.File": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "uwV5hdhWPwUH1szhO8PJpFiahqXmzPzJT/sOijH/kFgUx+cyoDTMM8MHD0adw9+Iem6itoibbUXHYslzXsLEAg==", + "dependencies": { + "Serilog": "2.10.0" + } + }, + "Serilog.Sinks.PeriodicBatching": { + "type": "Transitive", + "resolved": "3.1.0", + "contentHash": "NDWR7m3PalVlGEq3rzoktrXikjFMLmpwF0HI4sowo8YDdU+gqPlTHlDQiOGxHfB0sTfjPA9JjA7ctKG9zqjGkw==", + "dependencies": { + "Serilog": "2.0.0" + } + }, + "Serilog.Sinks.Seq": { + "type": "Transitive", + "resolved": "5.2.2", + "contentHash": "1Csmo5ua7NKUe0yXUx+zsRefjAniPWcXFhUXxXG8pwo0iMiw2gjn9SOkgYnnxbgWqmlGv236w0N/dHc2v5XwMg==", + "dependencies": { + "Serilog": "2.12.0", + "Serilog.Formatting.Compact": "1.1.0", + "Serilog.Sinks.File": "5.0.0", + "Serilog.Sinks.PeriodicBatching": "3.1.0" + } + }, + "SerilogTimings": { + "type": "Transitive", + "resolved": "3.0.1", + "contentHash": "Zs28eTgszAMwpIrbBnWHBI50yuxL50p/dmAUWmy75+axdZYK/Sjm5/5m1N/CisR8acJUhTVcjPZrsB1P5iv0Uw==", + "dependencies": { + "Serilog": "2.10.0" + } + }, + "Speckle.Newtonsoft.Json": { + "type": "Transitive", + "resolved": "13.0.2", + "contentHash": "g1BejUZwax5PRfL6xHgLEK23sqHWOgOj9hE7RvfRRlN00AGt8GnPYt8HedSK7UB3HiRW8zCA9Pn0iiYxCK24BA==" + }, + "Speckle.Revit2023.Interfaces": { + "type": "Transitive", + "resolved": "0.1.1-preview.0.24", + "contentHash": "BSVpOUJc9g6ISrw8GxvtkglTlITpHEDYNOhxv1ZPbckBsI0yO36JiphhQV4q57ERqD9PpCozUJkVhlCaxWeS6A==" + }, + "SQLitePCLRaw.bundle_e_sqlite3": { + "type": "Transitive", + "resolved": "2.1.4", + "contentHash": "EWI1olKDjFEBMJu0+3wuxwziIAdWDVMYLhuZ3Qs84rrz+DHwD00RzWPZCa+bLnHCf3oJwuFZIRsHT5p236QXww==", + "dependencies": { + "SQLitePCLRaw.lib.e_sqlite3": "2.1.4", + "SQLitePCLRaw.provider.dynamic_cdecl": "2.1.4" + } + }, + "SQLitePCLRaw.core": { + "type": "Transitive", + "resolved": "2.1.4", + "contentHash": "inBjvSHo9UDKneGNzfUfDjK08JzlcIhn1+SP5Y3m6cgXpCxXKCJDy6Mka7LpgSV+UZmKSnC8rTwB0SQ0xKu5pA==", + "dependencies": { + "System.Memory": "4.5.3" + } + }, + "SQLitePCLRaw.lib.e_sqlite3": { + "type": "Transitive", + "resolved": "2.1.4", + "contentHash": "2C9Q9eX7CPLveJA0rIhf9RXAvu+7nWZu1A2MdG6SD/NOu26TakGgL1nsbc0JAspGijFOo3HoN79xrx8a368fBg==" + }, + "SQLitePCLRaw.provider.dynamic_cdecl": { + "type": "Transitive", + "resolved": "2.1.4", + "contentHash": "ZsaKKhgYF9B1fvcnOGKl3EycNAwd9CRWX7v0rEfuPWhQQ5Jjpvf2VEHahiLIGHio3hxi3EIKFJw9KvyowWOUAw==", + "dependencies": { + "SQLitePCLRaw.core": "2.1.4" + } + }, + "System.Buffers": { + "type": "Transitive", + "resolved": "4.5.1", + "contentHash": "Rw7ijyl1qqRS0YQD/WycNst8hUUMgrMH4FCn1nNm27M4VxchZ1js3fVjQaANHO5f3sN4isvP4a+Met9Y4YomAg==" + }, + "System.Collections.Immutable": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "FXkLXiK0sVVewcso0imKQoOxjoPAj42R8HtjjbSjVPAzwDfzoyoznWxgA3c38LDbN9SJux1xXoXYAhz98j7r2g==", + "dependencies": { + "System.Memory": "4.5.4" + } + }, + "System.DoubleNumerics": { + "type": "Transitive", + "resolved": "3.1.3", + "contentHash": "KRKEM/L3KBodjA9VOg3EifFVWUY6EOqaMB05UvPEDm7Zeby/kZW+4kdWUEPzW6xtkwf46p661L9NrbeeQhtLzw==", + "dependencies": { + "NETStandard.Library": "1.6.1" + } + }, + "System.Memory": { + "type": "Transitive", + "resolved": "4.5.5", + "contentHash": "XIWiDvKPXaTveaB7HVganDlOCRoj03l+jrwNvcge/t8vhGYKvqV+dMv6G4SAX2NoNmN0wZfVPTAlFwZcZvVOUw==", + "dependencies": { + "System.Buffers": "4.5.1", + "System.Numerics.Vectors": "4.5.0", + "System.Runtime.CompilerServices.Unsafe": "4.5.3" + } + }, + "System.Net.WebSockets.Client.Managed": { + "type": "Transitive", + "resolved": "1.0.22", + "contentHash": "WqEOxPlXjuZrIjUtXNE9NxEfU/n5E35iV2PtoZdJSUC4tlrqwHnTee+wvMIM4OUaJWmwrymeqcgYrE0IkGAgLA==", + "dependencies": { + "System.Buffers": "4.4.0", + "System.Numerics.Vectors": "4.4.0" + } + }, + "System.Numerics.Vectors": { + "type": "Transitive", + "resolved": "4.5.0", + "contentHash": "QQTlPTl06J/iiDbJCiepZ4H//BVraReU4O4EoRw1U02H5TLUIT7xn3GnDp9AXPSlJUDyFs4uWjWafNX6WrAojQ==" + }, + "System.Reactive": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "erBZjkQHWL9jpasCE/0qKAryzVBJFxGHVBAvgRN1bzM0q2s1S4oYREEEL0Vb+1kA/6BKb5FjUZMp5VXmy+gzkQ==", + "dependencies": { + "System.Threading.Tasks.Extensions": "4.5.4" + } + }, + "System.Reflection.Metadata": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "5NecZgXktdGg34rh1OenY1rFNDCI8xSjFr+Z4OU4cU06AQHUdRnIIEeWENu3Wl4YowbzkymAIMvi3WyK9U53pQ==", + "dependencies": { + "System.Collections.Immutable": "5.0.0" + } + }, + "System.Runtime.CompilerServices.Unsafe": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "ZD9TMpsmYJLrxbbmdvhwt9YEgG5WntEnZ/d1eH8JBX9LBp+Ju8BSBhUGbZMNVHHomWo2KVImJhTDl2hIgw/6MA==" + }, + "System.Runtime.InteropServices.RuntimeInformation": { + "type": "Transitive", + "resolved": "4.3.0", + "contentHash": "cbz4YJMqRDR7oLeMRbdYv7mYzc++17lNhScCX0goO2XpGWdvAt60CGN+FHdePUEHCe/Jy9jUlvNAiNdM+7jsOw==" + }, + "System.Text.Encodings.Web": { + "type": "Transitive", + "resolved": "5.0.1", + "contentHash": "KmJ+CJXizDofbq6mpqDoRRLcxgOd2z9X3XoFNULSbvbqVRZkFX3istvr+MUjL6Zw1RT+RNdoI4GYidIINtgvqQ==", + "dependencies": { + "System.Buffers": "4.5.1", + "System.Memory": "4.5.4" + } + }, + "System.Text.Json": { + "type": "Transitive", + "resolved": "5.0.2", + "contentHash": "I47dVIGiV6SfAyppphxqupertT/5oZkYLDCX6vC3HpOI4ZLjyoKAreUoem2ie6G0RbRuFrlqz/PcTQjfb2DOfQ==", + "dependencies": { + "Microsoft.Bcl.AsyncInterfaces": "5.0.0", + "System.Buffers": "4.5.1", + "System.Memory": "4.5.4", + "System.Numerics.Vectors": "4.5.0", + "System.Runtime.CompilerServices.Unsafe": "5.0.0", + "System.Text.Encodings.Web": "5.0.1", + "System.Threading.Tasks.Extensions": "4.5.4", + "System.ValueTuple": "4.5.0" + } + }, + "System.Threading.Tasks.Extensions": { + "type": "Transitive", + "resolved": "4.5.4", + "contentHash": "zteT+G8xuGu6mS+mzDzYXbzS7rd3K6Fjb9RiZlYlJPam2/hU7JCBZBVEcywNuR+oZ1ncTvc/cq0faRr3P01OVg==", + "dependencies": { + "System.Runtime.CompilerServices.Unsafe": "4.5.3" + } + }, + "System.ValueTuple": { + "type": "Transitive", + "resolved": "4.5.0", + "contentHash": "okurQJO6NRE/apDIP23ajJ0hpiNmJ+f0BwOlB/cSqTLQlw5upkf+5+96+iG2Jw40G1fCVCyPz/FhIABUjMR+RQ==" + }, + "speckle.autofac": { + "type": "Project", + "dependencies": { + "Microsoft.Extensions.Logging.Abstractions": "[7.0.0, )", + "Speckle.Core": "[2.0.999-local, )" + } + }, + "speckle.converters.common": { + "type": "Project", + "dependencies": { + "Speckle.Autofac": "[2.0.999-local, )", + "Speckle.Objects": "[2.0.999-local, )", + "Speckle.Revit2023.Interfaces": "[0.1.1-preview.0.24, )" + } + }, + "speckle.converters.common.dependencyinjection": { + "type": "Project", + "dependencies": { + "Speckle.Autofac": "[2.0.999-local, )", + "Speckle.Converters.Common": "[2.0.999-local, )" + } + }, + "speckle.converters.rhino7": { + "type": "Project", + "dependencies": { + "RhinoCommon": "[7.13.21348.13001, )", + "Speckle.Converters.Common": "[2.0.999-local, )" + } + }, + "Speckle.Core": { + "type": "Project", + "dependencies": { + "GraphQL.Client": "[6.0.0, )", + "Microsoft.CSharp": "[4.7.0, )", + "Microsoft.Data.Sqlite": "[7.0.5, )", + "Polly": "[7.2.3, )", + "Polly.Contrib.WaitAndRetry": "[1.1.1, )", + "Polly.Extensions.Http": "[3.0.0, )", + "Sentry": "[3.33.0, )", + "Sentry.Serilog": "[3.33.0, )", + "Serilog": "[2.12.0, )", + "Serilog.Enrichers.ClientInfo": "[1.3.0, )", + "Serilog.Exceptions": "[8.4.0, )", + "Serilog.Sinks.Console": "[4.1.0, )", + "Serilog.Sinks.Seq": "[5.2.2, )", + "SerilogTimings": "[3.0.1, )", + "Speckle.Newtonsoft.Json": "[13.0.2, )", + "System.DoubleNumerics": "[3.1.3, )" + } + }, + "Speckle.Objects": { + "type": "Project", + "dependencies": { + "Speckle.Core": "[2.0.999-local, )" + } + } + } + } +} \ No newline at end of file diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/packages.lock.json b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/packages.lock.json new file mode 100644 index 0000000000..2512d2a6e6 --- /dev/null +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/packages.lock.json @@ -0,0 +1,395 @@ +{ + "version": 1, + "dependencies": { + ".NETFramework,Version=v4.8": { + "PolySharp": { + "type": "Direct", + "requested": "[1.14.1, )", + "resolved": "1.14.1", + "contentHash": "mOOmFYwad3MIOL14VCjj02LljyF1GNw1wP0YVlxtcPvqdxjGGMNdNJJxHptlry3MOd8b40Flm8RPOM8JOlN2sQ==" + }, + "RhinoCommon": { + "type": "Direct", + "requested": "[7.13.21348.13001, )", + "resolved": "7.13.21348.13001", + "contentHash": "JQdaNw61ddBqIe08E9O4N/grwrN1hjDHcYW7tWylwCZyFR7SepoCD4NS+6LN6+oSQhNbhLi9Bf+hQOFYFdRAEA==" + }, + "Speckle.InterfaceGenerator": { + "type": "Direct", + "requested": "[0.9.5, )", + "resolved": "0.9.5", + "contentHash": "oU/L7pN1R7q8KkbrpQ3WJnHirPHqn+9DEA7asOcUiggV5dzVg1A/VYs7GOSusD24njxXh03tE3a2oTLOjt3cVg==" + }, + "GraphQL.Client": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "8yPNBbuVBpTptivyAlak4GZvbwbUcjeQTL4vN1HKHRuOykZ4r7l5fcLS6vpyPyLn0x8FsL31xbOIKyxbmR9rbA==", + "dependencies": { + "GraphQL.Client.Abstractions": "6.0.0", + "GraphQL.Client.Abstractions.Websocket": "6.0.0", + "System.Net.WebSockets.Client.Managed": "1.0.22", + "System.Reactive": "5.0.0" + } + }, + "GraphQL.Client.Abstractions": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "h7uzWFORHZ+CCjwr/ThAyXMr0DPpzEANDa4Uo54wqCQ+j7qUKwqYTgOrb1W40sqbvNaZm9v/X7It31SUw0maHA==", + "dependencies": { + "GraphQL.Primitives": "6.0.0" + } + }, + "GraphQL.Client.Abstractions.Websocket": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "Nr9bPf8gIOvLuXpqEpqr9z9jslYFJOvd0feHth3/kPqeR3uMbjF5pjiwh4jxyMcxHdr8Pb6QiXkV3hsSyt0v7A==", + "dependencies": { + "GraphQL.Client.Abstractions": "6.0.0" + } + }, + "GraphQL.Primitives": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "yg72rrYDapfsIUrul7aF6wwNnTJBOFvuA9VdDTQpPa8AlAriHbufeXYLBcodKjfUdkCnaiggX1U/nEP08Zb5GA==" + }, + "Microsoft.Bcl.AsyncInterfaces": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "W8DPQjkMScOMTtJbPwmPyj9c3zYSFGawDW3jwlBOOsnY+EzZFLgNQ/UMkK35JmkNOVPdCyPr2Tw7Vv9N+KA3ZQ==", + "dependencies": { + "System.Threading.Tasks.Extensions": "4.5.4" + } + }, + "Microsoft.CSharp": { + "type": "Transitive", + "resolved": "4.7.0", + "contentHash": "pTj+D3uJWyN3My70i2Hqo+OXixq3Os2D1nJ2x92FFo6sk8fYS1m1WLNTs0Dc1uPaViH0YvEEwvzddQ7y4rhXmA==" + }, + "Microsoft.Data.Sqlite": { + "type": "Transitive", + "resolved": "7.0.5", + "contentHash": "KGxbPeWsQMnmQy43DSBxAFtHz3l2JX8EWBSGUCvT3CuZ8KsuzbkqMIJMDOxWtG8eZSoCDI04aiVQjWuuV8HmSw==", + "dependencies": { + "Microsoft.Data.Sqlite.Core": "7.0.5", + "SQLitePCLRaw.bundle_e_sqlite3": "2.1.4" + } + }, + "Microsoft.Data.Sqlite.Core": { + "type": "Transitive", + "resolved": "7.0.5", + "contentHash": "FTerRmQPqHrCrnoUzhBu+E+1DNGwyrAMLqHkAqOOOu5pGfyMOj8qQUBxI/gDtWtG11p49UxSfWmBzRNlwZqfUg==", + "dependencies": { + "SQLitePCLRaw.core": "2.1.4" + } + }, + "Microsoft.Extensions.Logging.Abstractions": { + "type": "Transitive", + "resolved": "7.0.0", + "contentHash": "kmn78+LPVMOWeITUjIlfxUPDsI0R6G0RkeAMBmQxAJ7vBJn4q2dTva7pWi65ceN5vPGjJ9q/Uae2WKgvfktJAw==", + "dependencies": { + "System.Buffers": "4.5.1", + "System.Memory": "4.5.5" + } + }, + "Polly": { + "type": "Transitive", + "resolved": "7.2.3", + "contentHash": "DeCY0OFbNdNxsjntr1gTXHJ5pKUwYzp04Er2LLeN3g6pWhffsGuKVfMBLe1lw7x76HrPkLxKEFxBlpRxS2nDEQ==" + }, + "Polly.Contrib.WaitAndRetry": { + "type": "Transitive", + "resolved": "1.1.1", + "contentHash": "1MUQLiSo4KDkQe6nzQRhIU05lm9jlexX5BVsbuw0SL82ynZ+GzAHQxJVDPVBboxV37Po3SG077aX8DuSy8TkaA==" + }, + "Polly.Extensions.Http": { + "type": "Transitive", + "resolved": "3.0.0", + "contentHash": "drrG+hB3pYFY7w1c3BD+lSGYvH2oIclH8GRSehgfyP5kjnFnHKQuuBhuHLv+PWyFuaTDyk/vfRpnxOzd11+J8g==", + "dependencies": { + "Polly": "7.1.0" + } + }, + "Sentry": { + "type": "Transitive", + "resolved": "3.33.0", + "contentHash": "8vbD2o6IR2wrRrkSiRbnodWGWUOqIlwYtzpjvPNOb5raJdOf+zxMwfS8f6nx9bmrTTfDj7KrCB8C/5OuicAc8A==", + "dependencies": { + "System.Reflection.Metadata": "5.0.0", + "System.Runtime.InteropServices.RuntimeInformation": "4.3.0", + "System.Text.Json": "5.0.2" + } + }, + "Sentry.Serilog": { + "type": "Transitive", + "resolved": "3.33.0", + "contentHash": "V8BU7QGWg2qLYfNPqtuTBhC1opysny5l+Ifp6J6PhOeAxU0FssR7nYfbJVetrnLIoh2rd3DlJ6hHYYQosQYcUQ==", + "dependencies": { + "Sentry": "3.33.0", + "Serilog": "2.7.1" + } + }, + "Serilog": { + "type": "Transitive", + "resolved": "2.12.0", + "contentHash": "xaiJLIdu6rYMKfQMYUZgTy8YK7SMZjB4Yk50C/u//Z4OsvxkUfSPJy4nknfvwAC34yr13q7kcyh4grbwhSxyZg==" + }, + "Serilog.Enrichers.ClientInfo": { + "type": "Transitive", + "resolved": "1.3.0", + "contentHash": "mTc7PM+wC9Hr7LWSwqt5mmnlAr7RJs+eTb3PGPRhwdOackk95MkhUZognuxXEdlW19HAFNmEBTSBY5DfLwM8jQ==", + "dependencies": { + "Serilog": "2.4.0" + } + }, + "Serilog.Exceptions": { + "type": "Transitive", + "resolved": "8.4.0", + "contentHash": "nc/+hUw3lsdo0zCj0KMIybAu7perMx79vu72w0za9Nsi6mWyNkGXxYxakAjWB7nEmYL6zdmhEQRB4oJ2ALUeug==", + "dependencies": { + "Serilog": "2.8.0" + } + }, + "Serilog.Formatting.Compact": { + "type": "Transitive", + "resolved": "1.1.0", + "contentHash": "pNroKVjo+rDqlxNG5PXkRLpfSCuDOBY0ri6jp9PLe505ljqwhwZz8ospy2vWhQlFu5GkIesh3FcDs4n7sWZODA==", + "dependencies": { + "Serilog": "2.8.0" + } + }, + "Serilog.Sinks.Console": { + "type": "Transitive", + "resolved": "4.1.0", + "contentHash": "K6N5q+5fetjnJPvCmkWOpJ/V8IEIoMIB1s86OzBrbxwTyHxdx3pmz4H+8+O/Dc/ftUX12DM1aynx/dDowkwzqg==", + "dependencies": { + "Serilog": "2.10.0" + } + }, + "Serilog.Sinks.File": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "uwV5hdhWPwUH1szhO8PJpFiahqXmzPzJT/sOijH/kFgUx+cyoDTMM8MHD0adw9+Iem6itoibbUXHYslzXsLEAg==", + "dependencies": { + "Serilog": "2.10.0" + } + }, + "Serilog.Sinks.PeriodicBatching": { + "type": "Transitive", + "resolved": "3.1.0", + "contentHash": "NDWR7m3PalVlGEq3rzoktrXikjFMLmpwF0HI4sowo8YDdU+gqPlTHlDQiOGxHfB0sTfjPA9JjA7ctKG9zqjGkw==", + "dependencies": { + "Serilog": "2.0.0" + } + }, + "Serilog.Sinks.Seq": { + "type": "Transitive", + "resolved": "5.2.2", + "contentHash": "1Csmo5ua7NKUe0yXUx+zsRefjAniPWcXFhUXxXG8pwo0iMiw2gjn9SOkgYnnxbgWqmlGv236w0N/dHc2v5XwMg==", + "dependencies": { + "Serilog": "2.12.0", + "Serilog.Formatting.Compact": "1.1.0", + "Serilog.Sinks.File": "5.0.0", + "Serilog.Sinks.PeriodicBatching": "3.1.0" + } + }, + "SerilogTimings": { + "type": "Transitive", + "resolved": "3.0.1", + "contentHash": "Zs28eTgszAMwpIrbBnWHBI50yuxL50p/dmAUWmy75+axdZYK/Sjm5/5m1N/CisR8acJUhTVcjPZrsB1P5iv0Uw==", + "dependencies": { + "Serilog": "2.10.0" + } + }, + "Speckle.Newtonsoft.Json": { + "type": "Transitive", + "resolved": "13.0.2", + "contentHash": "g1BejUZwax5PRfL6xHgLEK23sqHWOgOj9hE7RvfRRlN00AGt8GnPYt8HedSK7UB3HiRW8zCA9Pn0iiYxCK24BA==" + }, + "Speckle.Revit2023.Interfaces": { + "type": "Transitive", + "resolved": "0.1.1-preview.0.24", + "contentHash": "BSVpOUJc9g6ISrw8GxvtkglTlITpHEDYNOhxv1ZPbckBsI0yO36JiphhQV4q57ERqD9PpCozUJkVhlCaxWeS6A==" + }, + "SQLitePCLRaw.bundle_e_sqlite3": { + "type": "Transitive", + "resolved": "2.1.4", + "contentHash": "EWI1olKDjFEBMJu0+3wuxwziIAdWDVMYLhuZ3Qs84rrz+DHwD00RzWPZCa+bLnHCf3oJwuFZIRsHT5p236QXww==", + "dependencies": { + "SQLitePCLRaw.lib.e_sqlite3": "2.1.4", + "SQLitePCLRaw.provider.dynamic_cdecl": "2.1.4" + } + }, + "SQLitePCLRaw.core": { + "type": "Transitive", + "resolved": "2.1.4", + "contentHash": "inBjvSHo9UDKneGNzfUfDjK08JzlcIhn1+SP5Y3m6cgXpCxXKCJDy6Mka7LpgSV+UZmKSnC8rTwB0SQ0xKu5pA==", + "dependencies": { + "System.Memory": "4.5.3" + } + }, + "SQLitePCLRaw.lib.e_sqlite3": { + "type": "Transitive", + "resolved": "2.1.4", + "contentHash": "2C9Q9eX7CPLveJA0rIhf9RXAvu+7nWZu1A2MdG6SD/NOu26TakGgL1nsbc0JAspGijFOo3HoN79xrx8a368fBg==" + }, + "SQLitePCLRaw.provider.dynamic_cdecl": { + "type": "Transitive", + "resolved": "2.1.4", + "contentHash": "ZsaKKhgYF9B1fvcnOGKl3EycNAwd9CRWX7v0rEfuPWhQQ5Jjpvf2VEHahiLIGHio3hxi3EIKFJw9KvyowWOUAw==", + "dependencies": { + "SQLitePCLRaw.core": "2.1.4" + } + }, + "System.Buffers": { + "type": "Transitive", + "resolved": "4.5.1", + "contentHash": "Rw7ijyl1qqRS0YQD/WycNst8hUUMgrMH4FCn1nNm27M4VxchZ1js3fVjQaANHO5f3sN4isvP4a+Met9Y4YomAg==" + }, + "System.Collections.Immutable": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "FXkLXiK0sVVewcso0imKQoOxjoPAj42R8HtjjbSjVPAzwDfzoyoznWxgA3c38LDbN9SJux1xXoXYAhz98j7r2g==", + "dependencies": { + "System.Memory": "4.5.4" + } + }, + "System.DoubleNumerics": { + "type": "Transitive", + "resolved": "3.1.3", + "contentHash": "KRKEM/L3KBodjA9VOg3EifFVWUY6EOqaMB05UvPEDm7Zeby/kZW+4kdWUEPzW6xtkwf46p661L9NrbeeQhtLzw==", + "dependencies": { + "NETStandard.Library": "1.6.1" + } + }, + "System.Memory": { + "type": "Transitive", + "resolved": "4.5.5", + "contentHash": "XIWiDvKPXaTveaB7HVganDlOCRoj03l+jrwNvcge/t8vhGYKvqV+dMv6G4SAX2NoNmN0wZfVPTAlFwZcZvVOUw==", + "dependencies": { + "System.Buffers": "4.5.1", + "System.Numerics.Vectors": "4.5.0", + "System.Runtime.CompilerServices.Unsafe": "4.5.3" + } + }, + "System.Net.WebSockets.Client.Managed": { + "type": "Transitive", + "resolved": "1.0.22", + "contentHash": "WqEOxPlXjuZrIjUtXNE9NxEfU/n5E35iV2PtoZdJSUC4tlrqwHnTee+wvMIM4OUaJWmwrymeqcgYrE0IkGAgLA==", + "dependencies": { + "System.Buffers": "4.4.0", + "System.Numerics.Vectors": "4.4.0" + } + }, + "System.Numerics.Vectors": { + "type": "Transitive", + "resolved": "4.5.0", + "contentHash": "QQTlPTl06J/iiDbJCiepZ4H//BVraReU4O4EoRw1U02H5TLUIT7xn3GnDp9AXPSlJUDyFs4uWjWafNX6WrAojQ==" + }, + "System.Reactive": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "erBZjkQHWL9jpasCE/0qKAryzVBJFxGHVBAvgRN1bzM0q2s1S4oYREEEL0Vb+1kA/6BKb5FjUZMp5VXmy+gzkQ==", + "dependencies": { + "System.Threading.Tasks.Extensions": "4.5.4" + } + }, + "System.Reflection.Metadata": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "5NecZgXktdGg34rh1OenY1rFNDCI8xSjFr+Z4OU4cU06AQHUdRnIIEeWENu3Wl4YowbzkymAIMvi3WyK9U53pQ==", + "dependencies": { + "System.Collections.Immutable": "5.0.0" + } + }, + "System.Runtime.CompilerServices.Unsafe": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "ZD9TMpsmYJLrxbbmdvhwt9YEgG5WntEnZ/d1eH8JBX9LBp+Ju8BSBhUGbZMNVHHomWo2KVImJhTDl2hIgw/6MA==" + }, + "System.Runtime.InteropServices.RuntimeInformation": { + "type": "Transitive", + "resolved": "4.3.0", + "contentHash": "cbz4YJMqRDR7oLeMRbdYv7mYzc++17lNhScCX0goO2XpGWdvAt60CGN+FHdePUEHCe/Jy9jUlvNAiNdM+7jsOw==" + }, + "System.Text.Encodings.Web": { + "type": "Transitive", + "resolved": "5.0.1", + "contentHash": "KmJ+CJXizDofbq6mpqDoRRLcxgOd2z9X3XoFNULSbvbqVRZkFX3istvr+MUjL6Zw1RT+RNdoI4GYidIINtgvqQ==", + "dependencies": { + "System.Buffers": "4.5.1", + "System.Memory": "4.5.4" + } + }, + "System.Text.Json": { + "type": "Transitive", + "resolved": "5.0.2", + "contentHash": "I47dVIGiV6SfAyppphxqupertT/5oZkYLDCX6vC3HpOI4ZLjyoKAreUoem2ie6G0RbRuFrlqz/PcTQjfb2DOfQ==", + "dependencies": { + "Microsoft.Bcl.AsyncInterfaces": "5.0.0", + "System.Buffers": "4.5.1", + "System.Memory": "4.5.4", + "System.Numerics.Vectors": "4.5.0", + "System.Runtime.CompilerServices.Unsafe": "5.0.0", + "System.Text.Encodings.Web": "5.0.1", + "System.Threading.Tasks.Extensions": "4.5.4", + "System.ValueTuple": "4.5.0" + } + }, + "System.Threading.Tasks.Extensions": { + "type": "Transitive", + "resolved": "4.5.4", + "contentHash": "zteT+G8xuGu6mS+mzDzYXbzS7rd3K6Fjb9RiZlYlJPam2/hU7JCBZBVEcywNuR+oZ1ncTvc/cq0faRr3P01OVg==", + "dependencies": { + "System.Runtime.CompilerServices.Unsafe": "4.5.3" + } + }, + "System.ValueTuple": { + "type": "Transitive", + "resolved": "4.5.0", + "contentHash": "okurQJO6NRE/apDIP23ajJ0hpiNmJ+f0BwOlB/cSqTLQlw5upkf+5+96+iG2Jw40G1fCVCyPz/FhIABUjMR+RQ==" + }, + "speckle.autofac": { + "type": "Project", + "dependencies": { + "Microsoft.Extensions.Logging.Abstractions": "[7.0.0, )", + "Speckle.Core": "[2.0.999-local, )" + } + }, + "speckle.converters.common": { + "type": "Project", + "dependencies": { + "Speckle.Autofac": "[2.0.999-local, )", + "Speckle.Objects": "[2.0.999-local, )", + "Speckle.Revit2023.Interfaces": "[0.1.1-preview.0.24, )" + } + }, + "Speckle.Core": { + "type": "Project", + "dependencies": { + "GraphQL.Client": "[6.0.0, )", + "Microsoft.CSharp": "[4.7.0, )", + "Microsoft.Data.Sqlite": "[7.0.5, )", + "Polly": "[7.2.3, )", + "Polly.Contrib.WaitAndRetry": "[1.1.1, )", + "Polly.Extensions.Http": "[3.0.0, )", + "Sentry": "[3.33.0, )", + "Sentry.Serilog": "[3.33.0, )", + "Serilog": "[2.12.0, )", + "Serilog.Enrichers.ClientInfo": "[1.3.0, )", + "Serilog.Exceptions": "[8.4.0, )", + "Serilog.Sinks.Console": "[4.1.0, )", + "Serilog.Sinks.Seq": "[5.2.2, )", + "SerilogTimings": "[3.0.1, )", + "Speckle.Newtonsoft.Json": "[13.0.2, )", + "System.DoubleNumerics": "[3.1.3, )" + } + }, + "Speckle.Objects": { + "type": "Project", + "dependencies": { + "Speckle.Core": "[2.0.999-local, )" + } + } + } + } +} \ No newline at end of file diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI.WebView/packages.lock.json b/DUI3-DX/DUI3/Speckle.Connectors.DUI.WebView/packages.lock.json new file mode 100644 index 0000000000..2f687deb37 --- /dev/null +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI.WebView/packages.lock.json @@ -0,0 +1,878 @@ +{ + "version": 1, + "dependencies": { + ".NETFramework,Version=v4.8": { + "Microsoft.Web.WebView2": { + "type": "Direct", + "requested": "[1.0.1823.32, )", + "resolved": "1.0.1823.32", + "contentHash": "ppRcWBUNggFIqyJp7PfgS4Oe8/7yli/mHcTNDOaqo3ZzJWnv9AOr0WE9ceEP5SPs1M7CQ3QvdGMR7KNz0v09EA==" + }, + "PolySharp": { + "type": "Direct", + "requested": "[1.14.1, )", + "resolved": "1.14.1", + "contentHash": "mOOmFYwad3MIOL14VCjj02LljyF1GNw1wP0YVlxtcPvqdxjGGMNdNJJxHptlry3MOd8b40Flm8RPOM8JOlN2sQ==" + }, + "Speckle.InterfaceGenerator": { + "type": "Direct", + "requested": "[0.9.5, )", + "resolved": "0.9.5", + "contentHash": "oU/L7pN1R7q8KkbrpQ3WJnHirPHqn+9DEA7asOcUiggV5dzVg1A/VYs7GOSusD24njxXh03tE3a2oTLOjt3cVg==" + }, + "GraphQL.Client": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "8yPNBbuVBpTptivyAlak4GZvbwbUcjeQTL4vN1HKHRuOykZ4r7l5fcLS6vpyPyLn0x8FsL31xbOIKyxbmR9rbA==", + "dependencies": { + "GraphQL.Client.Abstractions": "6.0.0", + "GraphQL.Client.Abstractions.Websocket": "6.0.0", + "System.Net.WebSockets.Client.Managed": "1.0.22", + "System.Reactive": "5.0.0" + } + }, + "GraphQL.Client.Abstractions": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "h7uzWFORHZ+CCjwr/ThAyXMr0DPpzEANDa4Uo54wqCQ+j7qUKwqYTgOrb1W40sqbvNaZm9v/X7It31SUw0maHA==", + "dependencies": { + "GraphQL.Primitives": "6.0.0" + } + }, + "GraphQL.Client.Abstractions.Websocket": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "Nr9bPf8gIOvLuXpqEpqr9z9jslYFJOvd0feHth3/kPqeR3uMbjF5pjiwh4jxyMcxHdr8Pb6QiXkV3hsSyt0v7A==", + "dependencies": { + "GraphQL.Client.Abstractions": "6.0.0" + } + }, + "GraphQL.Primitives": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "yg72rrYDapfsIUrul7aF6wwNnTJBOFvuA9VdDTQpPa8AlAriHbufeXYLBcodKjfUdkCnaiggX1U/nEP08Zb5GA==" + }, + "Microsoft.Bcl.AsyncInterfaces": { + "type": "Transitive", + "resolved": "7.0.0", + "contentHash": "3aeMZ1N0lJoSyzqiP03hqemtb1BijhsJADdobn/4nsMJ8V1H+CrpuduUe4hlRdx+ikBQju1VGjMD1GJ3Sk05Eg==", + "dependencies": { + "System.Threading.Tasks.Extensions": "4.5.4" + } + }, + "Microsoft.CSharp": { + "type": "Transitive", + "resolved": "4.7.0", + "contentHash": "pTj+D3uJWyN3My70i2Hqo+OXixq3Os2D1nJ2x92FFo6sk8fYS1m1WLNTs0Dc1uPaViH0YvEEwvzddQ7y4rhXmA==" + }, + "Microsoft.Data.Sqlite": { + "type": "Transitive", + "resolved": "7.0.5", + "contentHash": "KGxbPeWsQMnmQy43DSBxAFtHz3l2JX8EWBSGUCvT3CuZ8KsuzbkqMIJMDOxWtG8eZSoCDI04aiVQjWuuV8HmSw==", + "dependencies": { + "Microsoft.Data.Sqlite.Core": "7.0.5", + "SQLitePCLRaw.bundle_e_sqlite3": "2.1.4" + } + }, + "Microsoft.Data.Sqlite.Core": { + "type": "Transitive", + "resolved": "7.0.5", + "contentHash": "FTerRmQPqHrCrnoUzhBu+E+1DNGwyrAMLqHkAqOOOu5pGfyMOj8qQUBxI/gDtWtG11p49UxSfWmBzRNlwZqfUg==", + "dependencies": { + "SQLitePCLRaw.core": "2.1.4" + } + }, + "Microsoft.Extensions.DependencyInjection": { + "type": "Transitive", + "resolved": "7.0.0", + "contentHash": "elNeOmkeX3eDVG6pYVeV82p29hr+UKDaBhrZyWvWLw/EVZSYEkZlQdkp0V39k/Xehs2Qa0mvoCvkVj3eQxNQ1Q==", + "dependencies": { + "Microsoft.Bcl.AsyncInterfaces": "7.0.0", + "Microsoft.Extensions.DependencyInjection.Abstractions": "7.0.0", + "System.Threading.Tasks.Extensions": "4.5.4" + } + }, + "Microsoft.Extensions.DependencyInjection.Abstractions": { + "type": "Transitive", + "resolved": "7.0.0", + "contentHash": "h3j/QfmFN4S0w4C2A6X7arXij/M/OVw3uQHSOFxnND4DyAzO1F9eMX7Eti7lU/OkSthEE0WzRsfT/Dmx86jzCw==", + "dependencies": { + "Microsoft.Bcl.AsyncInterfaces": "7.0.0", + "System.Threading.Tasks.Extensions": "4.5.4" + } + }, + "Microsoft.Extensions.Logging": { + "type": "Transitive", + "resolved": "7.0.0", + "contentHash": "Nw2muoNrOG5U5qa2ZekXwudUn2BJcD41e65zwmDHb1fQegTX66UokLWZkJRpqSSHXDOWZ5V0iqhbxOEky91atA==", + "dependencies": { + "Microsoft.Bcl.AsyncInterfaces": "7.0.0", + "Microsoft.Extensions.DependencyInjection": "7.0.0", + "Microsoft.Extensions.DependencyInjection.Abstractions": "7.0.0", + "Microsoft.Extensions.Logging.Abstractions": "7.0.0", + "Microsoft.Extensions.Options": "7.0.0", + "System.Diagnostics.DiagnosticSource": "7.0.0", + "System.ValueTuple": "4.5.0" + } + }, + "Microsoft.Extensions.Logging.Abstractions": { + "type": "Transitive", + "resolved": "7.0.0", + "contentHash": "kmn78+LPVMOWeITUjIlfxUPDsI0R6G0RkeAMBmQxAJ7vBJn4q2dTva7pWi65ceN5vPGjJ9q/Uae2WKgvfktJAw==", + "dependencies": { + "System.Buffers": "4.5.1", + "System.Memory": "4.5.5" + } + }, + "Microsoft.Extensions.Options": { + "type": "Transitive", + "resolved": "7.0.0", + "contentHash": "lP1yBnTTU42cKpMozuafbvNtQ7QcBjr/CcK3bYOGEMH55Fjt+iecXjT6chR7vbgCMqy3PG3aNQSZgo/EuY/9qQ==", + "dependencies": { + "Microsoft.Extensions.DependencyInjection.Abstractions": "7.0.0", + "Microsoft.Extensions.Primitives": "7.0.0" + } + }, + "Microsoft.Extensions.Primitives": { + "type": "Transitive", + "resolved": "7.0.0", + "contentHash": "um1KU5kxcRp3CNuI8o/GrZtD4AIOXDk+RLsytjZ9QPok3ttLUelLKpilVPuaFT3TFjOhSibUAso0odbOaCDj3Q==", + "dependencies": { + "System.Memory": "4.5.5", + "System.Runtime.CompilerServices.Unsafe": "6.0.0" + } + }, + "Polly": { + "type": "Transitive", + "resolved": "7.2.3", + "contentHash": "DeCY0OFbNdNxsjntr1gTXHJ5pKUwYzp04Er2LLeN3g6pWhffsGuKVfMBLe1lw7x76HrPkLxKEFxBlpRxS2nDEQ==" + }, + "Polly.Contrib.WaitAndRetry": { + "type": "Transitive", + "resolved": "1.1.1", + "contentHash": "1MUQLiSo4KDkQe6nzQRhIU05lm9jlexX5BVsbuw0SL82ynZ+GzAHQxJVDPVBboxV37Po3SG077aX8DuSy8TkaA==" + }, + "Polly.Extensions.Http": { + "type": "Transitive", + "resolved": "3.0.0", + "contentHash": "drrG+hB3pYFY7w1c3BD+lSGYvH2oIclH8GRSehgfyP5kjnFnHKQuuBhuHLv+PWyFuaTDyk/vfRpnxOzd11+J8g==", + "dependencies": { + "Polly": "7.1.0" + } + }, + "Sentry": { + "type": "Transitive", + "resolved": "3.33.0", + "contentHash": "8vbD2o6IR2wrRrkSiRbnodWGWUOqIlwYtzpjvPNOb5raJdOf+zxMwfS8f6nx9bmrTTfDj7KrCB8C/5OuicAc8A==", + "dependencies": { + "System.Reflection.Metadata": "5.0.0", + "System.Runtime.InteropServices.RuntimeInformation": "4.3.0", + "System.Text.Json": "5.0.2" + } + }, + "Sentry.Serilog": { + "type": "Transitive", + "resolved": "3.33.0", + "contentHash": "V8BU7QGWg2qLYfNPqtuTBhC1opysny5l+Ifp6J6PhOeAxU0FssR7nYfbJVetrnLIoh2rd3DlJ6hHYYQosQYcUQ==", + "dependencies": { + "Sentry": "3.33.0", + "Serilog": "2.7.1" + } + }, + "Serilog": { + "type": "Transitive", + "resolved": "2.12.0", + "contentHash": "xaiJLIdu6rYMKfQMYUZgTy8YK7SMZjB4Yk50C/u//Z4OsvxkUfSPJy4nknfvwAC34yr13q7kcyh4grbwhSxyZg==" + }, + "Serilog.Enrichers.ClientInfo": { + "type": "Transitive", + "resolved": "1.3.0", + "contentHash": "mTc7PM+wC9Hr7LWSwqt5mmnlAr7RJs+eTb3PGPRhwdOackk95MkhUZognuxXEdlW19HAFNmEBTSBY5DfLwM8jQ==", + "dependencies": { + "Serilog": "2.4.0" + } + }, + "Serilog.Exceptions": { + "type": "Transitive", + "resolved": "8.4.0", + "contentHash": "nc/+hUw3lsdo0zCj0KMIybAu7perMx79vu72w0za9Nsi6mWyNkGXxYxakAjWB7nEmYL6zdmhEQRB4oJ2ALUeug==", + "dependencies": { + "Serilog": "2.8.0" + } + }, + "Serilog.Extensions.Logging": { + "type": "Transitive", + "resolved": "7.0.0", + "contentHash": "9faU0zNQqU7I6soVhLUMYaGNpgWv6cKlKb2S5AnS8gXxzW/em5Ladm/6FMrWTnX41cdbdGPOWNAo6adi4WaJ6A==", + "dependencies": { + "Microsoft.Extensions.Logging": "7.0.0", + "Serilog": "2.12.0" + } + }, + "Serilog.Formatting.Compact": { + "type": "Transitive", + "resolved": "1.1.0", + "contentHash": "pNroKVjo+rDqlxNG5PXkRLpfSCuDOBY0ri6jp9PLe505ljqwhwZz8ospy2vWhQlFu5GkIesh3FcDs4n7sWZODA==", + "dependencies": { + "Serilog": "2.8.0" + } + }, + "Serilog.Sinks.Console": { + "type": "Transitive", + "resolved": "4.1.0", + "contentHash": "K6N5q+5fetjnJPvCmkWOpJ/V8IEIoMIB1s86OzBrbxwTyHxdx3pmz4H+8+O/Dc/ftUX12DM1aynx/dDowkwzqg==", + "dependencies": { + "Serilog": "2.10.0" + } + }, + "Serilog.Sinks.File": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "uwV5hdhWPwUH1szhO8PJpFiahqXmzPzJT/sOijH/kFgUx+cyoDTMM8MHD0adw9+Iem6itoibbUXHYslzXsLEAg==", + "dependencies": { + "Serilog": "2.10.0" + } + }, + "Serilog.Sinks.PeriodicBatching": { + "type": "Transitive", + "resolved": "3.1.0", + "contentHash": "NDWR7m3PalVlGEq3rzoktrXikjFMLmpwF0HI4sowo8YDdU+gqPlTHlDQiOGxHfB0sTfjPA9JjA7ctKG9zqjGkw==", + "dependencies": { + "Serilog": "2.0.0" + } + }, + "Serilog.Sinks.Seq": { + "type": "Transitive", + "resolved": "5.2.2", + "contentHash": "1Csmo5ua7NKUe0yXUx+zsRefjAniPWcXFhUXxXG8pwo0iMiw2gjn9SOkgYnnxbgWqmlGv236w0N/dHc2v5XwMg==", + "dependencies": { + "Serilog": "2.12.0", + "Serilog.Formatting.Compact": "1.1.0", + "Serilog.Sinks.File": "5.0.0", + "Serilog.Sinks.PeriodicBatching": "3.1.0" + } + }, + "SerilogTimings": { + "type": "Transitive", + "resolved": "3.0.1", + "contentHash": "Zs28eTgszAMwpIrbBnWHBI50yuxL50p/dmAUWmy75+axdZYK/Sjm5/5m1N/CisR8acJUhTVcjPZrsB1P5iv0Uw==", + "dependencies": { + "Serilog": "2.10.0" + } + }, + "Speckle.Newtonsoft.Json": { + "type": "Transitive", + "resolved": "13.0.2", + "contentHash": "g1BejUZwax5PRfL6xHgLEK23sqHWOgOj9hE7RvfRRlN00AGt8GnPYt8HedSK7UB3HiRW8zCA9Pn0iiYxCK24BA==" + }, + "SQLitePCLRaw.bundle_e_sqlite3": { + "type": "Transitive", + "resolved": "2.1.4", + "contentHash": "EWI1olKDjFEBMJu0+3wuxwziIAdWDVMYLhuZ3Qs84rrz+DHwD00RzWPZCa+bLnHCf3oJwuFZIRsHT5p236QXww==", + "dependencies": { + "SQLitePCLRaw.lib.e_sqlite3": "2.1.4", + "SQLitePCLRaw.provider.dynamic_cdecl": "2.1.4" + } + }, + "SQLitePCLRaw.core": { + "type": "Transitive", + "resolved": "2.1.4", + "contentHash": "inBjvSHo9UDKneGNzfUfDjK08JzlcIhn1+SP5Y3m6cgXpCxXKCJDy6Mka7LpgSV+UZmKSnC8rTwB0SQ0xKu5pA==", + "dependencies": { + "System.Memory": "4.5.3" + } + }, + "SQLitePCLRaw.lib.e_sqlite3": { + "type": "Transitive", + "resolved": "2.1.4", + "contentHash": "2C9Q9eX7CPLveJA0rIhf9RXAvu+7nWZu1A2MdG6SD/NOu26TakGgL1nsbc0JAspGijFOo3HoN79xrx8a368fBg==" + }, + "SQLitePCLRaw.provider.dynamic_cdecl": { + "type": "Transitive", + "resolved": "2.1.4", + "contentHash": "ZsaKKhgYF9B1fvcnOGKl3EycNAwd9CRWX7v0rEfuPWhQQ5Jjpvf2VEHahiLIGHio3hxi3EIKFJw9KvyowWOUAw==", + "dependencies": { + "SQLitePCLRaw.core": "2.1.4" + } + }, + "System.Buffers": { + "type": "Transitive", + "resolved": "4.5.1", + "contentHash": "Rw7ijyl1qqRS0YQD/WycNst8hUUMgrMH4FCn1nNm27M4VxchZ1js3fVjQaANHO5f3sN4isvP4a+Met9Y4YomAg==" + }, + "System.Collections.Immutable": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "FXkLXiK0sVVewcso0imKQoOxjoPAj42R8HtjjbSjVPAzwDfzoyoznWxgA3c38LDbN9SJux1xXoXYAhz98j7r2g==", + "dependencies": { + "System.Memory": "4.5.4" + } + }, + "System.Diagnostics.DiagnosticSource": { + "type": "Transitive", + "resolved": "7.0.0", + "contentHash": "9W0ewWDuAyDqS2PigdTxk6jDKonfgscY/hP8hm7VpxYhNHZHKvZTdRckberlFk3VnCmr3xBUyMBut12Q+T2aOw==", + "dependencies": { + "System.Memory": "4.5.5", + "System.Runtime.CompilerServices.Unsafe": "6.0.0" + } + }, + "System.DoubleNumerics": { + "type": "Transitive", + "resolved": "3.1.3", + "contentHash": "KRKEM/L3KBodjA9VOg3EifFVWUY6EOqaMB05UvPEDm7Zeby/kZW+4kdWUEPzW6xtkwf46p661L9NrbeeQhtLzw==", + "dependencies": { + "NETStandard.Library": "1.6.1" + } + }, + "System.Memory": { + "type": "Transitive", + "resolved": "4.5.5", + "contentHash": "XIWiDvKPXaTveaB7HVganDlOCRoj03l+jrwNvcge/t8vhGYKvqV+dMv6G4SAX2NoNmN0wZfVPTAlFwZcZvVOUw==", + "dependencies": { + "System.Buffers": "4.5.1", + "System.Numerics.Vectors": "4.5.0", + "System.Runtime.CompilerServices.Unsafe": "4.5.3" + } + }, + "System.Net.WebSockets.Client.Managed": { + "type": "Transitive", + "resolved": "1.0.22", + "contentHash": "WqEOxPlXjuZrIjUtXNE9NxEfU/n5E35iV2PtoZdJSUC4tlrqwHnTee+wvMIM4OUaJWmwrymeqcgYrE0IkGAgLA==", + "dependencies": { + "System.Buffers": "4.4.0", + "System.Numerics.Vectors": "4.4.0" + } + }, + "System.Numerics.Vectors": { + "type": "Transitive", + "resolved": "4.5.0", + "contentHash": "QQTlPTl06J/iiDbJCiepZ4H//BVraReU4O4EoRw1U02H5TLUIT7xn3GnDp9AXPSlJUDyFs4uWjWafNX6WrAojQ==" + }, + "System.Reactive": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "erBZjkQHWL9jpasCE/0qKAryzVBJFxGHVBAvgRN1bzM0q2s1S4oYREEEL0Vb+1kA/6BKb5FjUZMp5VXmy+gzkQ==", + "dependencies": { + "System.Threading.Tasks.Extensions": "4.5.4" + } + }, + "System.Reflection.Metadata": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "5NecZgXktdGg34rh1OenY1rFNDCI8xSjFr+Z4OU4cU06AQHUdRnIIEeWENu3Wl4YowbzkymAIMvi3WyK9U53pQ==", + "dependencies": { + "System.Collections.Immutable": "5.0.0" + } + }, + "System.Runtime.CompilerServices.Unsafe": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "/iUeP3tq1S0XdNNoMz5C9twLSrM/TH+qElHkXWaPvuNOt+99G75NrV0OS2EqHx5wMN7popYjpc8oTjC1y16DLg==" + }, + "System.Runtime.InteropServices.RuntimeInformation": { + "type": "Transitive", + "resolved": "4.3.0", + "contentHash": "cbz4YJMqRDR7oLeMRbdYv7mYzc++17lNhScCX0goO2XpGWdvAt60CGN+FHdePUEHCe/Jy9jUlvNAiNdM+7jsOw==" + }, + "System.Text.Encodings.Web": { + "type": "Transitive", + "resolved": "5.0.1", + "contentHash": "KmJ+CJXizDofbq6mpqDoRRLcxgOd2z9X3XoFNULSbvbqVRZkFX3istvr+MUjL6Zw1RT+RNdoI4GYidIINtgvqQ==", + "dependencies": { + "System.Buffers": "4.5.1", + "System.Memory": "4.5.4" + } + }, + "System.Text.Json": { + "type": "Transitive", + "resolved": "5.0.2", + "contentHash": "I47dVIGiV6SfAyppphxqupertT/5oZkYLDCX6vC3HpOI4ZLjyoKAreUoem2ie6G0RbRuFrlqz/PcTQjfb2DOfQ==", + "dependencies": { + "Microsoft.Bcl.AsyncInterfaces": "5.0.0", + "System.Buffers": "4.5.1", + "System.Memory": "4.5.4", + "System.Numerics.Vectors": "4.5.0", + "System.Runtime.CompilerServices.Unsafe": "5.0.0", + "System.Text.Encodings.Web": "5.0.1", + "System.Threading.Tasks.Extensions": "4.5.4", + "System.ValueTuple": "4.5.0" + } + }, + "System.Threading.Tasks.Dataflow": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "+tyDCU3/B1lDdOOAJywHQoFwyXIUghIaP2BxG79uvhfTnO+D9qIgjVlL/JV2NTliYbMHpd6eKDmHp2VHpij7MA==" + }, + "System.Threading.Tasks.Extensions": { + "type": "Transitive", + "resolved": "4.5.4", + "contentHash": "zteT+G8xuGu6mS+mzDzYXbzS7rd3K6Fjb9RiZlYlJPam2/hU7JCBZBVEcywNuR+oZ1ncTvc/cq0faRr3P01OVg==", + "dependencies": { + "System.Runtime.CompilerServices.Unsafe": "4.5.3" + } + }, + "System.ValueTuple": { + "type": "Transitive", + "resolved": "4.5.0", + "contentHash": "okurQJO6NRE/apDIP23ajJ0hpiNmJ+f0BwOlB/cSqTLQlw5upkf+5+96+iG2Jw40G1fCVCyPz/FhIABUjMR+RQ==" + }, + "speckle.autofac": { + "type": "Project", + "dependencies": { + "Microsoft.Extensions.Logging.Abstractions": "[7.0.0, )", + "Speckle.Core": "[2.0.999-local, )" + } + }, + "speckle.connectors.dui": { + "type": "Project", + "dependencies": { + "Microsoft.Extensions.Logging.Abstractions": "[7.0.0, )", + "Speckle.Autofac": "[2.0.999-local, )", + "Speckle.Connectors.Utils": "[2.0.999-local, )", + "Speckle.Core": "[2.0.999-local, )", + "System.Threading.Tasks.Dataflow": "[6.0.0, )" + } + }, + "speckle.connectors.utils": { + "type": "Project", + "dependencies": { + "Serilog.Extensions.Logging": "[7.0.0, )", + "Speckle.Autofac": "[2.0.999-local, )", + "Speckle.Core": "[2.0.999-local, )" + } + }, + "Speckle.Core": { + "type": "Project", + "dependencies": { + "GraphQL.Client": "[6.0.0, )", + "Microsoft.CSharp": "[4.7.0, )", + "Microsoft.Data.Sqlite": "[7.0.5, )", + "Polly": "[7.2.3, )", + "Polly.Contrib.WaitAndRetry": "[1.1.1, )", + "Polly.Extensions.Http": "[3.0.0, )", + "Sentry": "[3.33.0, )", + "Sentry.Serilog": "[3.33.0, )", + "Serilog": "[2.12.0, )", + "Serilog.Enrichers.ClientInfo": "[1.3.0, )", + "Serilog.Exceptions": "[8.4.0, )", + "Serilog.Sinks.Console": "[4.1.0, )", + "Serilog.Sinks.Seq": "[5.2.2, )", + "SerilogTimings": "[3.0.1, )", + "Speckle.Newtonsoft.Json": "[13.0.2, )", + "System.DoubleNumerics": "[3.1.3, )" + } + } + }, + "net6.0-windows7.0": { + "Microsoft.Web.WebView2": { + "type": "Direct", + "requested": "[1.0.1823.32, )", + "resolved": "1.0.1823.32", + "contentHash": "ppRcWBUNggFIqyJp7PfgS4Oe8/7yli/mHcTNDOaqo3ZzJWnv9AOr0WE9ceEP5SPs1M7CQ3QvdGMR7KNz0v09EA==" + }, + "PolySharp": { + "type": "Direct", + "requested": "[1.14.1, )", + "resolved": "1.14.1", + "contentHash": "mOOmFYwad3MIOL14VCjj02LljyF1GNw1wP0YVlxtcPvqdxjGGMNdNJJxHptlry3MOd8b40Flm8RPOM8JOlN2sQ==" + }, + "Speckle.InterfaceGenerator": { + "type": "Direct", + "requested": "[0.9.5, )", + "resolved": "0.9.5", + "contentHash": "oU/L7pN1R7q8KkbrpQ3WJnHirPHqn+9DEA7asOcUiggV5dzVg1A/VYs7GOSusD24njxXh03tE3a2oTLOjt3cVg==" + }, + "GraphQL.Client": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "8yPNBbuVBpTptivyAlak4GZvbwbUcjeQTL4vN1HKHRuOykZ4r7l5fcLS6vpyPyLn0x8FsL31xbOIKyxbmR9rbA==", + "dependencies": { + "GraphQL.Client.Abstractions": "6.0.0", + "GraphQL.Client.Abstractions.Websocket": "6.0.0", + "System.Reactive": "5.0.0" + } + }, + "GraphQL.Client.Abstractions": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "h7uzWFORHZ+CCjwr/ThAyXMr0DPpzEANDa4Uo54wqCQ+j7qUKwqYTgOrb1W40sqbvNaZm9v/X7It31SUw0maHA==", + "dependencies": { + "GraphQL.Primitives": "6.0.0" + } + }, + "GraphQL.Client.Abstractions.Websocket": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "Nr9bPf8gIOvLuXpqEpqr9z9jslYFJOvd0feHth3/kPqeR3uMbjF5pjiwh4jxyMcxHdr8Pb6QiXkV3hsSyt0v7A==", + "dependencies": { + "GraphQL.Client.Abstractions": "6.0.0" + } + }, + "GraphQL.Primitives": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "yg72rrYDapfsIUrul7aF6wwNnTJBOFvuA9VdDTQpPa8AlAriHbufeXYLBcodKjfUdkCnaiggX1U/nEP08Zb5GA==" + }, + "Microsoft.AspNetCore.Http": { + "type": "Transitive", + "resolved": "2.2.2", + "contentHash": "BAibpoItxI5puk7YJbIGj95arZueM8B8M5xT1fXBn3hb3L2G3ucrZcYXv1gXdaroLbntUs8qeV8iuBrpjQsrKw==", + "dependencies": { + "Microsoft.AspNetCore.Http.Abstractions": "2.2.0", + "Microsoft.AspNetCore.WebUtilities": "2.2.0", + "Microsoft.Extensions.ObjectPool": "2.2.0", + "Microsoft.Extensions.Options": "2.2.0", + "Microsoft.Net.Http.Headers": "2.2.0" + } + }, + "Microsoft.AspNetCore.Http.Abstractions": { + "type": "Transitive", + "resolved": "2.2.0", + "contentHash": "Nxs7Z1q3f1STfLYKJSVXCs1iBl+Ya6E8o4Oy1bCxJ/rNI44E/0f6tbsrVqAWfB7jlnJfyaAtIalBVxPKUPQb4Q==", + "dependencies": { + "Microsoft.AspNetCore.Http.Features": "2.2.0", + "System.Text.Encodings.Web": "4.5.0" + } + }, + "Microsoft.AspNetCore.Http.Features": { + "type": "Transitive", + "resolved": "2.2.0", + "contentHash": "ziFz5zH8f33En4dX81LW84I6XrYXKf9jg6aM39cM+LffN9KJahViKZ61dGMSO2gd3e+qe5yBRwsesvyqlZaSMg==", + "dependencies": { + "Microsoft.Extensions.Primitives": "2.2.0" + } + }, + "Microsoft.AspNetCore.WebUtilities": { + "type": "Transitive", + "resolved": "2.2.0", + "contentHash": "9ErxAAKaDzxXASB/b5uLEkLgUWv1QbeVxyJYEHQwMaxXOeFFVkQxiq8RyfVcifLU7NR0QY0p3acqx4ZpYfhHDg==", + "dependencies": { + "Microsoft.Net.Http.Headers": "2.2.0", + "System.Text.Encodings.Web": "4.5.0" + } + }, + "Microsoft.CSharp": { + "type": "Transitive", + "resolved": "4.7.0", + "contentHash": "pTj+D3uJWyN3My70i2Hqo+OXixq3Os2D1nJ2x92FFo6sk8fYS1m1WLNTs0Dc1uPaViH0YvEEwvzddQ7y4rhXmA==" + }, + "Microsoft.Data.Sqlite": { + "type": "Transitive", + "resolved": "7.0.5", + "contentHash": "KGxbPeWsQMnmQy43DSBxAFtHz3l2JX8EWBSGUCvT3CuZ8KsuzbkqMIJMDOxWtG8eZSoCDI04aiVQjWuuV8HmSw==", + "dependencies": { + "Microsoft.Data.Sqlite.Core": "7.0.5", + "SQLitePCLRaw.bundle_e_sqlite3": "2.1.4" + } + }, + "Microsoft.Data.Sqlite.Core": { + "type": "Transitive", + "resolved": "7.0.5", + "contentHash": "FTerRmQPqHrCrnoUzhBu+E+1DNGwyrAMLqHkAqOOOu5pGfyMOj8qQUBxI/gDtWtG11p49UxSfWmBzRNlwZqfUg==", + "dependencies": { + "SQLitePCLRaw.core": "2.1.4" + } + }, + "Microsoft.Extensions.DependencyInjection": { + "type": "Transitive", + "resolved": "7.0.0", + "contentHash": "elNeOmkeX3eDVG6pYVeV82p29hr+UKDaBhrZyWvWLw/EVZSYEkZlQdkp0V39k/Xehs2Qa0mvoCvkVj3eQxNQ1Q==", + "dependencies": { + "Microsoft.Extensions.DependencyInjection.Abstractions": "7.0.0" + } + }, + "Microsoft.Extensions.DependencyInjection.Abstractions": { + "type": "Transitive", + "resolved": "7.0.0", + "contentHash": "h3j/QfmFN4S0w4C2A6X7arXij/M/OVw3uQHSOFxnND4DyAzO1F9eMX7Eti7lU/OkSthEE0WzRsfT/Dmx86jzCw==" + }, + "Microsoft.Extensions.Logging": { + "type": "Transitive", + "resolved": "7.0.0", + "contentHash": "Nw2muoNrOG5U5qa2ZekXwudUn2BJcD41e65zwmDHb1fQegTX66UokLWZkJRpqSSHXDOWZ5V0iqhbxOEky91atA==", + "dependencies": { + "Microsoft.Extensions.DependencyInjection": "7.0.0", + "Microsoft.Extensions.DependencyInjection.Abstractions": "7.0.0", + "Microsoft.Extensions.Logging.Abstractions": "7.0.0", + "Microsoft.Extensions.Options": "7.0.0" + } + }, + "Microsoft.Extensions.Logging.Abstractions": { + "type": "Transitive", + "resolved": "7.0.0", + "contentHash": "kmn78+LPVMOWeITUjIlfxUPDsI0R6G0RkeAMBmQxAJ7vBJn4q2dTva7pWi65ceN5vPGjJ9q/Uae2WKgvfktJAw==" + }, + "Microsoft.Extensions.ObjectPool": { + "type": "Transitive", + "resolved": "2.2.0", + "contentHash": "gA8H7uQOnM5gb+L0uTNjViHYr+hRDqCdfugheGo/MxQnuHzmhhzCBTIPm19qL1z1Xe0NEMabfcOBGv9QghlZ8g==" + }, + "Microsoft.Extensions.Options": { + "type": "Transitive", + "resolved": "7.0.0", + "contentHash": "lP1yBnTTU42cKpMozuafbvNtQ7QcBjr/CcK3bYOGEMH55Fjt+iecXjT6chR7vbgCMqy3PG3aNQSZgo/EuY/9qQ==", + "dependencies": { + "Microsoft.Extensions.DependencyInjection.Abstractions": "7.0.0", + "Microsoft.Extensions.Primitives": "7.0.0" + } + }, + "Microsoft.Extensions.Primitives": { + "type": "Transitive", + "resolved": "7.0.0", + "contentHash": "um1KU5kxcRp3CNuI8o/GrZtD4AIOXDk+RLsytjZ9QPok3ttLUelLKpilVPuaFT3TFjOhSibUAso0odbOaCDj3Q==", + "dependencies": { + "System.Runtime.CompilerServices.Unsafe": "6.0.0" + } + }, + "Microsoft.Net.Http.Headers": { + "type": "Transitive", + "resolved": "2.2.0", + "contentHash": "iZNkjYqlo8sIOI0bQfpsSoMTmB/kyvmV2h225ihyZT33aTp48ZpF6qYnXxzSXmHt8DpBAwBTX+1s1UFLbYfZKg==", + "dependencies": { + "Microsoft.Extensions.Primitives": "2.2.0", + "System.Buffers": "4.5.0" + } + }, + "Polly": { + "type": "Transitive", + "resolved": "7.2.3", + "contentHash": "DeCY0OFbNdNxsjntr1gTXHJ5pKUwYzp04Er2LLeN3g6pWhffsGuKVfMBLe1lw7x76HrPkLxKEFxBlpRxS2nDEQ==" + }, + "Polly.Contrib.WaitAndRetry": { + "type": "Transitive", + "resolved": "1.1.1", + "contentHash": "1MUQLiSo4KDkQe6nzQRhIU05lm9jlexX5BVsbuw0SL82ynZ+GzAHQxJVDPVBboxV37Po3SG077aX8DuSy8TkaA==" + }, + "Polly.Extensions.Http": { + "type": "Transitive", + "resolved": "3.0.0", + "contentHash": "drrG+hB3pYFY7w1c3BD+lSGYvH2oIclH8GRSehgfyP5kjnFnHKQuuBhuHLv+PWyFuaTDyk/vfRpnxOzd11+J8g==", + "dependencies": { + "Polly": "7.1.0" + } + }, + "Sentry": { + "type": "Transitive", + "resolved": "3.33.0", + "contentHash": "8vbD2o6IR2wrRrkSiRbnodWGWUOqIlwYtzpjvPNOb5raJdOf+zxMwfS8f6nx9bmrTTfDj7KrCB8C/5OuicAc8A==" + }, + "Sentry.Serilog": { + "type": "Transitive", + "resolved": "3.33.0", + "contentHash": "V8BU7QGWg2qLYfNPqtuTBhC1opysny5l+Ifp6J6PhOeAxU0FssR7nYfbJVetrnLIoh2rd3DlJ6hHYYQosQYcUQ==", + "dependencies": { + "Sentry": "3.33.0", + "Serilog": "2.10.0" + } + }, + "Serilog": { + "type": "Transitive", + "resolved": "2.12.0", + "contentHash": "xaiJLIdu6rYMKfQMYUZgTy8YK7SMZjB4Yk50C/u//Z4OsvxkUfSPJy4nknfvwAC34yr13q7kcyh4grbwhSxyZg==" + }, + "Serilog.Enrichers.ClientInfo": { + "type": "Transitive", + "resolved": "1.3.0", + "contentHash": "mTc7PM+wC9Hr7LWSwqt5mmnlAr7RJs+eTb3PGPRhwdOackk95MkhUZognuxXEdlW19HAFNmEBTSBY5DfLwM8jQ==", + "dependencies": { + "Microsoft.AspNetCore.Http": "2.2.2", + "Serilog": "2.9.0" + } + }, + "Serilog.Exceptions": { + "type": "Transitive", + "resolved": "8.4.0", + "contentHash": "nc/+hUw3lsdo0zCj0KMIybAu7perMx79vu72w0za9Nsi6mWyNkGXxYxakAjWB7nEmYL6zdmhEQRB4oJ2ALUeug==", + "dependencies": { + "Serilog": "2.8.0", + "System.Reflection.TypeExtensions": "4.7.0" + } + }, + "Serilog.Extensions.Logging": { + "type": "Transitive", + "resolved": "7.0.0", + "contentHash": "9faU0zNQqU7I6soVhLUMYaGNpgWv6cKlKb2S5AnS8gXxzW/em5Ladm/6FMrWTnX41cdbdGPOWNAo6adi4WaJ6A==", + "dependencies": { + "Microsoft.Extensions.Logging": "7.0.0", + "Serilog": "2.12.0" + } + }, + "Serilog.Formatting.Compact": { + "type": "Transitive", + "resolved": "1.1.0", + "contentHash": "pNroKVjo+rDqlxNG5PXkRLpfSCuDOBY0ri6jp9PLe505ljqwhwZz8ospy2vWhQlFu5GkIesh3FcDs4n7sWZODA==", + "dependencies": { + "Serilog": "2.8.0" + } + }, + "Serilog.Sinks.Console": { + "type": "Transitive", + "resolved": "4.1.0", + "contentHash": "K6N5q+5fetjnJPvCmkWOpJ/V8IEIoMIB1s86OzBrbxwTyHxdx3pmz4H+8+O/Dc/ftUX12DM1aynx/dDowkwzqg==", + "dependencies": { + "Serilog": "2.10.0" + } + }, + "Serilog.Sinks.File": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "uwV5hdhWPwUH1szhO8PJpFiahqXmzPzJT/sOijH/kFgUx+cyoDTMM8MHD0adw9+Iem6itoibbUXHYslzXsLEAg==", + "dependencies": { + "Serilog": "2.10.0" + } + }, + "Serilog.Sinks.PeriodicBatching": { + "type": "Transitive", + "resolved": "3.1.0", + "contentHash": "NDWR7m3PalVlGEq3rzoktrXikjFMLmpwF0HI4sowo8YDdU+gqPlTHlDQiOGxHfB0sTfjPA9JjA7ctKG9zqjGkw==", + "dependencies": { + "Serilog": "2.0.0" + } + }, + "Serilog.Sinks.Seq": { + "type": "Transitive", + "resolved": "5.2.2", + "contentHash": "1Csmo5ua7NKUe0yXUx+zsRefjAniPWcXFhUXxXG8pwo0iMiw2gjn9SOkgYnnxbgWqmlGv236w0N/dHc2v5XwMg==", + "dependencies": { + "Serilog": "2.12.0", + "Serilog.Formatting.Compact": "1.1.0", + "Serilog.Sinks.File": "5.0.0", + "Serilog.Sinks.PeriodicBatching": "3.1.0" + } + }, + "SerilogTimings": { + "type": "Transitive", + "resolved": "3.0.1", + "contentHash": "Zs28eTgszAMwpIrbBnWHBI50yuxL50p/dmAUWmy75+axdZYK/Sjm5/5m1N/CisR8acJUhTVcjPZrsB1P5iv0Uw==", + "dependencies": { + "Serilog": "2.10.0" + } + }, + "Speckle.Newtonsoft.Json": { + "type": "Transitive", + "resolved": "13.0.2", + "contentHash": "g1BejUZwax5PRfL6xHgLEK23sqHWOgOj9hE7RvfRRlN00AGt8GnPYt8HedSK7UB3HiRW8zCA9Pn0iiYxCK24BA==" + }, + "SQLitePCLRaw.bundle_e_sqlite3": { + "type": "Transitive", + "resolved": "2.1.4", + "contentHash": "EWI1olKDjFEBMJu0+3wuxwziIAdWDVMYLhuZ3Qs84rrz+DHwD00RzWPZCa+bLnHCf3oJwuFZIRsHT5p236QXww==", + "dependencies": { + "SQLitePCLRaw.lib.e_sqlite3": "2.1.4", + "SQLitePCLRaw.provider.e_sqlite3": "2.1.4" + } + }, + "SQLitePCLRaw.core": { + "type": "Transitive", + "resolved": "2.1.4", + "contentHash": "inBjvSHo9UDKneGNzfUfDjK08JzlcIhn1+SP5Y3m6cgXpCxXKCJDy6Mka7LpgSV+UZmKSnC8rTwB0SQ0xKu5pA==", + "dependencies": { + "System.Memory": "4.5.3" + } + }, + "SQLitePCLRaw.lib.e_sqlite3": { + "type": "Transitive", + "resolved": "2.1.4", + "contentHash": "2C9Q9eX7CPLveJA0rIhf9RXAvu+7nWZu1A2MdG6SD/NOu26TakGgL1nsbc0JAspGijFOo3HoN79xrx8a368fBg==" + }, + "SQLitePCLRaw.provider.e_sqlite3": { + "type": "Transitive", + "resolved": "2.1.4", + "contentHash": "CSlb5dUp1FMIkez9Iv5EXzpeq7rHryVNqwJMWnpq87j9zWZexaEMdisDktMsnnrzKM6ahNrsTkjqNodTBPBxtQ==", + "dependencies": { + "SQLitePCLRaw.core": "2.1.4" + } + }, + "System.Buffers": { + "type": "Transitive", + "resolved": "4.5.0", + "contentHash": "pL2ChpaRRWI/p4LXyy4RgeWlYF2sgfj/pnVMvBqwNFr5cXg7CXNnWZWxrOONLg8VGdFB8oB+EG2Qw4MLgTOe+A==" + }, + "System.DoubleNumerics": { + "type": "Transitive", + "resolved": "3.1.3", + "contentHash": "KRKEM/L3KBodjA9VOg3EifFVWUY6EOqaMB05UvPEDm7Zeby/kZW+4kdWUEPzW6xtkwf46p661L9NrbeeQhtLzw==", + "dependencies": { + "NETStandard.Library": "1.6.1" + } + }, + "System.Memory": { + "type": "Transitive", + "resolved": "4.5.3", + "contentHash": "3oDzvc/zzetpTKWMShs1AADwZjQ/36HnsufHRPcOjyRAAMLDlu2iD33MBI2opxnezcVUtXyqDXXjoFMOU9c7SA==" + }, + "System.Reactive": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "erBZjkQHWL9jpasCE/0qKAryzVBJFxGHVBAvgRN1bzM0q2s1S4oYREEEL0Vb+1kA/6BKb5FjUZMp5VXmy+gzkQ==" + }, + "System.Reflection.TypeExtensions": { + "type": "Transitive", + "resolved": "4.7.0", + "contentHash": "VybpaOQQhqE6siHppMktjfGBw1GCwvCqiufqmP8F1nj7fTUNtW35LOEt3UZTEsECfo+ELAl/9o9nJx3U91i7vA==" + }, + "System.Runtime.CompilerServices.Unsafe": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "/iUeP3tq1S0XdNNoMz5C9twLSrM/TH+qElHkXWaPvuNOt+99G75NrV0OS2EqHx5wMN7popYjpc8oTjC1y16DLg==" + }, + "System.Text.Encodings.Web": { + "type": "Transitive", + "resolved": "4.5.0", + "contentHash": "Xg4G4Indi4dqP1iuAiMSwpiWS54ZghzR644OtsRCm/m/lBMG8dUBhLVN7hLm8NNrNTR+iGbshCPTwrvxZPlm4g==" + }, + "System.Threading.Tasks.Dataflow": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "+tyDCU3/B1lDdOOAJywHQoFwyXIUghIaP2BxG79uvhfTnO+D9qIgjVlL/JV2NTliYbMHpd6eKDmHp2VHpij7MA==" + }, + "speckle.autofac": { + "type": "Project", + "dependencies": { + "Microsoft.Extensions.Logging.Abstractions": "[7.0.0, )", + "Speckle.Core": "[2.0.999-local, )" + } + }, + "speckle.connectors.dui": { + "type": "Project", + "dependencies": { + "Microsoft.Extensions.Logging.Abstractions": "[7.0.0, )", + "Speckle.Autofac": "[2.0.999-local, )", + "Speckle.Connectors.Utils": "[2.0.999-local, )", + "Speckle.Core": "[2.0.999-local, )", + "System.Threading.Tasks.Dataflow": "[6.0.0, )" + } + }, + "speckle.connectors.utils": { + "type": "Project", + "dependencies": { + "Serilog.Extensions.Logging": "[7.0.0, )", + "Speckle.Autofac": "[2.0.999-local, )", + "Speckle.Core": "[2.0.999-local, )" + } + }, + "Speckle.Core": { + "type": "Project", + "dependencies": { + "GraphQL.Client": "[6.0.0, )", + "Microsoft.CSharp": "[4.7.0, )", + "Microsoft.Data.Sqlite": "[7.0.5, )", + "Polly": "[7.2.3, )", + "Polly.Contrib.WaitAndRetry": "[1.1.1, )", + "Polly.Extensions.Http": "[3.0.0, )", + "Sentry": "[3.33.0, )", + "Sentry.Serilog": "[3.33.0, )", + "Serilog": "[2.12.0, )", + "Serilog.Enrichers.ClientInfo": "[1.3.0, )", + "Serilog.Exceptions": "[8.4.0, )", + "Serilog.Sinks.Console": "[4.1.0, )", + "Serilog.Sinks.Seq": "[5.2.2, )", + "SerilogTimings": "[3.0.1, )", + "Speckle.Newtonsoft.Json": "[13.0.2, )", + "System.DoubleNumerics": "[3.1.3, )" + } + } + } + } +} \ No newline at end of file diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/packages.lock.json b/DUI3-DX/DUI3/Speckle.Connectors.DUI/packages.lock.json new file mode 100644 index 0000000000..5f57ceb468 --- /dev/null +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/packages.lock.json @@ -0,0 +1,533 @@ +{ + "version": 1, + "dependencies": { + ".NETStandard,Version=v2.0": { + "Microsoft.Extensions.Logging.Abstractions": { + "type": "Direct", + "requested": "[7.0.0, )", + "resolved": "7.0.0", + "contentHash": "kmn78+LPVMOWeITUjIlfxUPDsI0R6G0RkeAMBmQxAJ7vBJn4q2dTva7pWi65ceN5vPGjJ9q/Uae2WKgvfktJAw==", + "dependencies": { + "System.Buffers": "4.5.1", + "System.Memory": "4.5.5" + } + }, + "NETStandard.Library": { + "type": "Direct", + "requested": "[2.0.3, )", + "resolved": "2.0.3", + "contentHash": "st47PosZSHrjECdjeIzZQbzivYBJFv6P2nv4cj2ypdI204DO+vZ7l5raGMiX4eXMJ53RfOIg+/s4DHVZ54Nu2A==", + "dependencies": { + "Microsoft.NETCore.Platforms": "1.1.0" + } + }, + "PolySharp": { + "type": "Direct", + "requested": "[1.14.1, )", + "resolved": "1.14.1", + "contentHash": "mOOmFYwad3MIOL14VCjj02LljyF1GNw1wP0YVlxtcPvqdxjGGMNdNJJxHptlry3MOd8b40Flm8RPOM8JOlN2sQ==" + }, + "Speckle.InterfaceGenerator": { + "type": "Direct", + "requested": "[0.9.5, )", + "resolved": "0.9.5", + "contentHash": "oU/L7pN1R7q8KkbrpQ3WJnHirPHqn+9DEA7asOcUiggV5dzVg1A/VYs7GOSusD24njxXh03tE3a2oTLOjt3cVg==" + }, + "System.Threading.Tasks.Dataflow": { + "type": "Direct", + "requested": "[6.0.0, )", + "resolved": "6.0.0", + "contentHash": "+tyDCU3/B1lDdOOAJywHQoFwyXIUghIaP2BxG79uvhfTnO+D9qIgjVlL/JV2NTliYbMHpd6eKDmHp2VHpij7MA==" + }, + "GraphQL.Client": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "8yPNBbuVBpTptivyAlak4GZvbwbUcjeQTL4vN1HKHRuOykZ4r7l5fcLS6vpyPyLn0x8FsL31xbOIKyxbmR9rbA==", + "dependencies": { + "GraphQL.Client.Abstractions": "6.0.0", + "GraphQL.Client.Abstractions.Websocket": "6.0.0", + "System.Reactive": "5.0.0" + } + }, + "GraphQL.Client.Abstractions": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "h7uzWFORHZ+CCjwr/ThAyXMr0DPpzEANDa4Uo54wqCQ+j7qUKwqYTgOrb1W40sqbvNaZm9v/X7It31SUw0maHA==", + "dependencies": { + "GraphQL.Primitives": "6.0.0" + } + }, + "GraphQL.Client.Abstractions.Websocket": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "Nr9bPf8gIOvLuXpqEpqr9z9jslYFJOvd0feHth3/kPqeR3uMbjF5pjiwh4jxyMcxHdr8Pb6QiXkV3hsSyt0v7A==", + "dependencies": { + "GraphQL.Client.Abstractions": "6.0.0" + } + }, + "GraphQL.Primitives": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "yg72rrYDapfsIUrul7aF6wwNnTJBOFvuA9VdDTQpPa8AlAriHbufeXYLBcodKjfUdkCnaiggX1U/nEP08Zb5GA==" + }, + "Microsoft.AspNetCore.Http": { + "type": "Transitive", + "resolved": "2.1.1", + "contentHash": "pPDcCW8spnyibK3krpxrOpaFHf5fjV6k1Hsl6gfh77N/8gRYlLU7MOQDUnjpEwdlHmtxwJKQJNxZqVQOmJGRUw==", + "dependencies": { + "Microsoft.AspNetCore.Http.Abstractions": "2.1.1", + "Microsoft.AspNetCore.WebUtilities": "2.1.1", + "Microsoft.Extensions.ObjectPool": "2.1.1", + "Microsoft.Extensions.Options": "2.1.1", + "Microsoft.Net.Http.Headers": "2.1.1" + } + }, + "Microsoft.AspNetCore.Http.Abstractions": { + "type": "Transitive", + "resolved": "2.1.1", + "contentHash": "kQUEVOU4loc8CPSb2WoHFTESqwIa8Ik7ysCBfTwzHAd0moWovc9JQLmhDIHlYLjHbyexqZAlkq/FPRUZqokebw==", + "dependencies": { + "Microsoft.AspNetCore.Http.Features": "2.1.1", + "System.Text.Encodings.Web": "4.5.0" + } + }, + "Microsoft.AspNetCore.Http.Features": { + "type": "Transitive", + "resolved": "2.1.1", + "contentHash": "VklZ7hWgSvHBcDtwYYkdMdI/adlf7ebxTZ9kdzAhX+gUs5jSHE9mZlTamdgf9miSsxc1QjNazHXTDJdVPZKKTw==", + "dependencies": { + "Microsoft.Extensions.Primitives": "2.1.1" + } + }, + "Microsoft.AspNetCore.WebUtilities": { + "type": "Transitive", + "resolved": "2.1.1", + "contentHash": "PGKIZt4+412Z/XPoSjvYu/QIbTxcAQuEFNoA1Pw8a9mgmO0ZhNBmfaNyhgXFf7Rq62kP0tT/2WXpxdcQhkFUPA==", + "dependencies": { + "Microsoft.Net.Http.Headers": "2.1.1", + "System.Text.Encodings.Web": "4.5.0" + } + }, + "Microsoft.Bcl.AsyncInterfaces": { + "type": "Transitive", + "resolved": "7.0.0", + "contentHash": "3aeMZ1N0lJoSyzqiP03hqemtb1BijhsJADdobn/4nsMJ8V1H+CrpuduUe4hlRdx+ikBQju1VGjMD1GJ3Sk05Eg==", + "dependencies": { + "System.Threading.Tasks.Extensions": "4.5.4" + } + }, + "Microsoft.CSharp": { + "type": "Transitive", + "resolved": "4.7.0", + "contentHash": "pTj+D3uJWyN3My70i2Hqo+OXixq3Os2D1nJ2x92FFo6sk8fYS1m1WLNTs0Dc1uPaViH0YvEEwvzddQ7y4rhXmA==" + }, + "Microsoft.Data.Sqlite": { + "type": "Transitive", + "resolved": "7.0.5", + "contentHash": "KGxbPeWsQMnmQy43DSBxAFtHz3l2JX8EWBSGUCvT3CuZ8KsuzbkqMIJMDOxWtG8eZSoCDI04aiVQjWuuV8HmSw==", + "dependencies": { + "Microsoft.Data.Sqlite.Core": "7.0.5", + "SQLitePCLRaw.bundle_e_sqlite3": "2.1.4" + } + }, + "Microsoft.Data.Sqlite.Core": { + "type": "Transitive", + "resolved": "7.0.5", + "contentHash": "FTerRmQPqHrCrnoUzhBu+E+1DNGwyrAMLqHkAqOOOu5pGfyMOj8qQUBxI/gDtWtG11p49UxSfWmBzRNlwZqfUg==", + "dependencies": { + "SQLitePCLRaw.core": "2.1.4" + } + }, + "Microsoft.Extensions.DependencyInjection": { + "type": "Transitive", + "resolved": "7.0.0", + "contentHash": "elNeOmkeX3eDVG6pYVeV82p29hr+UKDaBhrZyWvWLw/EVZSYEkZlQdkp0V39k/Xehs2Qa0mvoCvkVj3eQxNQ1Q==", + "dependencies": { + "Microsoft.Bcl.AsyncInterfaces": "7.0.0", + "Microsoft.Extensions.DependencyInjection.Abstractions": "7.0.0", + "System.Threading.Tasks.Extensions": "4.5.4" + } + }, + "Microsoft.Extensions.DependencyInjection.Abstractions": { + "type": "Transitive", + "resolved": "7.0.0", + "contentHash": "h3j/QfmFN4S0w4C2A6X7arXij/M/OVw3uQHSOFxnND4DyAzO1F9eMX7Eti7lU/OkSthEE0WzRsfT/Dmx86jzCw==", + "dependencies": { + "Microsoft.Bcl.AsyncInterfaces": "7.0.0", + "System.Threading.Tasks.Extensions": "4.5.4" + } + }, + "Microsoft.Extensions.Logging": { + "type": "Transitive", + "resolved": "7.0.0", + "contentHash": "Nw2muoNrOG5U5qa2ZekXwudUn2BJcD41e65zwmDHb1fQegTX66UokLWZkJRpqSSHXDOWZ5V0iqhbxOEky91atA==", + "dependencies": { + "Microsoft.Bcl.AsyncInterfaces": "7.0.0", + "Microsoft.Extensions.DependencyInjection": "7.0.0", + "Microsoft.Extensions.DependencyInjection.Abstractions": "7.0.0", + "Microsoft.Extensions.Logging.Abstractions": "7.0.0", + "Microsoft.Extensions.Options": "7.0.0", + "System.Diagnostics.DiagnosticSource": "7.0.0" + } + }, + "Microsoft.Extensions.ObjectPool": { + "type": "Transitive", + "resolved": "2.1.1", + "contentHash": "SErON45qh4ogDp6lr6UvVmFYW0FERihW+IQ+2JyFv1PUyWktcJytFaWH5zarufJvZwhci7Rf1IyGXr9pVEadTw==" + }, + "Microsoft.Extensions.Options": { + "type": "Transitive", + "resolved": "7.0.0", + "contentHash": "lP1yBnTTU42cKpMozuafbvNtQ7QcBjr/CcK3bYOGEMH55Fjt+iecXjT6chR7vbgCMqy3PG3aNQSZgo/EuY/9qQ==", + "dependencies": { + "Microsoft.Extensions.DependencyInjection.Abstractions": "7.0.0", + "Microsoft.Extensions.Primitives": "7.0.0", + "System.ComponentModel.Annotations": "5.0.0" + } + }, + "Microsoft.Extensions.Primitives": { + "type": "Transitive", + "resolved": "7.0.0", + "contentHash": "um1KU5kxcRp3CNuI8o/GrZtD4AIOXDk+RLsytjZ9QPok3ttLUelLKpilVPuaFT3TFjOhSibUAso0odbOaCDj3Q==", + "dependencies": { + "System.Memory": "4.5.5", + "System.Runtime.CompilerServices.Unsafe": "6.0.0" + } + }, + "Microsoft.Net.Http.Headers": { + "type": "Transitive", + "resolved": "2.1.1", + "contentHash": "lPNIphl8b2EuhOE9dMH6EZDmu7pS882O+HMi5BJNsigxHaWlBrYxZHFZgE18cyaPp6SSZcTkKkuzfjV/RRQKlA==", + "dependencies": { + "Microsoft.Extensions.Primitives": "2.1.1", + "System.Buffers": "4.5.0" + } + }, + "Microsoft.NETCore.Platforms": { + "type": "Transitive", + "resolved": "1.1.0", + "contentHash": "kz0PEW2lhqygehI/d6XsPCQzD7ff7gUJaVGPVETX611eadGsA3A877GdSlU0LRVMCTH/+P3o2iDTak+S08V2+A==" + }, + "Microsoft.NETCore.Targets": { + "type": "Transitive", + "resolved": "1.1.0", + "contentHash": "aOZA3BWfz9RXjpzt0sRJJMjAscAUm3Hoa4UWAfceV9UTYxgwZ1lZt5nO2myFf+/jetYQo4uTP7zS8sJY67BBxg==" + }, + "Polly": { + "type": "Transitive", + "resolved": "7.2.3", + "contentHash": "DeCY0OFbNdNxsjntr1gTXHJ5pKUwYzp04Er2LLeN3g6pWhffsGuKVfMBLe1lw7x76HrPkLxKEFxBlpRxS2nDEQ==" + }, + "Polly.Contrib.WaitAndRetry": { + "type": "Transitive", + "resolved": "1.1.1", + "contentHash": "1MUQLiSo4KDkQe6nzQRhIU05lm9jlexX5BVsbuw0SL82ynZ+GzAHQxJVDPVBboxV37Po3SG077aX8DuSy8TkaA==" + }, + "Polly.Extensions.Http": { + "type": "Transitive", + "resolved": "3.0.0", + "contentHash": "drrG+hB3pYFY7w1c3BD+lSGYvH2oIclH8GRSehgfyP5kjnFnHKQuuBhuHLv+PWyFuaTDyk/vfRpnxOzd11+J8g==", + "dependencies": { + "Polly": "7.1.0" + } + }, + "Sentry": { + "type": "Transitive", + "resolved": "3.33.0", + "contentHash": "8vbD2o6IR2wrRrkSiRbnodWGWUOqIlwYtzpjvPNOb5raJdOf+zxMwfS8f6nx9bmrTTfDj7KrCB8C/5OuicAc8A==", + "dependencies": { + "System.Reflection.Metadata": "5.0.0", + "System.Text.Json": "5.0.2" + } + }, + "Sentry.Serilog": { + "type": "Transitive", + "resolved": "3.33.0", + "contentHash": "V8BU7QGWg2qLYfNPqtuTBhC1opysny5l+Ifp6J6PhOeAxU0FssR7nYfbJVetrnLIoh2rd3DlJ6hHYYQosQYcUQ==", + "dependencies": { + "Sentry": "3.33.0", + "Serilog": "2.7.1" + } + }, + "Serilog": { + "type": "Transitive", + "resolved": "2.12.0", + "contentHash": "xaiJLIdu6rYMKfQMYUZgTy8YK7SMZjB4Yk50C/u//Z4OsvxkUfSPJy4nknfvwAC34yr13q7kcyh4grbwhSxyZg==" + }, + "Serilog.Enrichers.ClientInfo": { + "type": "Transitive", + "resolved": "1.3.0", + "contentHash": "mTc7PM+wC9Hr7LWSwqt5mmnlAr7RJs+eTb3PGPRhwdOackk95MkhUZognuxXEdlW19HAFNmEBTSBY5DfLwM8jQ==", + "dependencies": { + "Microsoft.AspNetCore.Http": "2.1.1", + "Serilog": "2.7.1" + } + }, + "Serilog.Exceptions": { + "type": "Transitive", + "resolved": "8.4.0", + "contentHash": "nc/+hUw3lsdo0zCj0KMIybAu7perMx79vu72w0za9Nsi6mWyNkGXxYxakAjWB7nEmYL6zdmhEQRB4oJ2ALUeug==", + "dependencies": { + "Serilog": "2.8.0", + "System.Reflection.TypeExtensions": "4.7.0" + } + }, + "Serilog.Extensions.Logging": { + "type": "Transitive", + "resolved": "7.0.0", + "contentHash": "9faU0zNQqU7I6soVhLUMYaGNpgWv6cKlKb2S5AnS8gXxzW/em5Ladm/6FMrWTnX41cdbdGPOWNAo6adi4WaJ6A==", + "dependencies": { + "Microsoft.Extensions.Logging": "7.0.0", + "Serilog": "2.12.0" + } + }, + "Serilog.Formatting.Compact": { + "type": "Transitive", + "resolved": "1.1.0", + "contentHash": "pNroKVjo+rDqlxNG5PXkRLpfSCuDOBY0ri6jp9PLe505ljqwhwZz8ospy2vWhQlFu5GkIesh3FcDs4n7sWZODA==", + "dependencies": { + "Serilog": "2.8.0" + } + }, + "Serilog.Sinks.Console": { + "type": "Transitive", + "resolved": "4.1.0", + "contentHash": "K6N5q+5fetjnJPvCmkWOpJ/V8IEIoMIB1s86OzBrbxwTyHxdx3pmz4H+8+O/Dc/ftUX12DM1aynx/dDowkwzqg==", + "dependencies": { + "Serilog": "2.10.0" + } + }, + "Serilog.Sinks.File": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "uwV5hdhWPwUH1szhO8PJpFiahqXmzPzJT/sOijH/kFgUx+cyoDTMM8MHD0adw9+Iem6itoibbUXHYslzXsLEAg==", + "dependencies": { + "Serilog": "2.10.0" + } + }, + "Serilog.Sinks.PeriodicBatching": { + "type": "Transitive", + "resolved": "3.1.0", + "contentHash": "NDWR7m3PalVlGEq3rzoktrXikjFMLmpwF0HI4sowo8YDdU+gqPlTHlDQiOGxHfB0sTfjPA9JjA7ctKG9zqjGkw==", + "dependencies": { + "Serilog": "2.0.0" + } + }, + "Serilog.Sinks.Seq": { + "type": "Transitive", + "resolved": "5.2.2", + "contentHash": "1Csmo5ua7NKUe0yXUx+zsRefjAniPWcXFhUXxXG8pwo0iMiw2gjn9SOkgYnnxbgWqmlGv236w0N/dHc2v5XwMg==", + "dependencies": { + "Serilog": "2.12.0", + "Serilog.Formatting.Compact": "1.1.0", + "Serilog.Sinks.File": "5.0.0", + "Serilog.Sinks.PeriodicBatching": "3.1.0" + } + }, + "SerilogTimings": { + "type": "Transitive", + "resolved": "3.0.1", + "contentHash": "Zs28eTgszAMwpIrbBnWHBI50yuxL50p/dmAUWmy75+axdZYK/Sjm5/5m1N/CisR8acJUhTVcjPZrsB1P5iv0Uw==", + "dependencies": { + "Serilog": "2.10.0" + } + }, + "Speckle.Newtonsoft.Json": { + "type": "Transitive", + "resolved": "13.0.2", + "contentHash": "g1BejUZwax5PRfL6xHgLEK23sqHWOgOj9hE7RvfRRlN00AGt8GnPYt8HedSK7UB3HiRW8zCA9Pn0iiYxCK24BA==" + }, + "SQLitePCLRaw.bundle_e_sqlite3": { + "type": "Transitive", + "resolved": "2.1.4", + "contentHash": "EWI1olKDjFEBMJu0+3wuxwziIAdWDVMYLhuZ3Qs84rrz+DHwD00RzWPZCa+bLnHCf3oJwuFZIRsHT5p236QXww==", + "dependencies": { + "SQLitePCLRaw.lib.e_sqlite3": "2.1.4", + "SQLitePCLRaw.provider.e_sqlite3": "2.1.4" + } + }, + "SQLitePCLRaw.core": { + "type": "Transitive", + "resolved": "2.1.4", + "contentHash": "inBjvSHo9UDKneGNzfUfDjK08JzlcIhn1+SP5Y3m6cgXpCxXKCJDy6Mka7LpgSV+UZmKSnC8rTwB0SQ0xKu5pA==", + "dependencies": { + "System.Memory": "4.5.3" + } + }, + "SQLitePCLRaw.lib.e_sqlite3": { + "type": "Transitive", + "resolved": "2.1.4", + "contentHash": "2C9Q9eX7CPLveJA0rIhf9RXAvu+7nWZu1A2MdG6SD/NOu26TakGgL1nsbc0JAspGijFOo3HoN79xrx8a368fBg==" + }, + "SQLitePCLRaw.provider.e_sqlite3": { + "type": "Transitive", + "resolved": "2.1.4", + "contentHash": "CSlb5dUp1FMIkez9Iv5EXzpeq7rHryVNqwJMWnpq87j9zWZexaEMdisDktMsnnrzKM6ahNrsTkjqNodTBPBxtQ==", + "dependencies": { + "SQLitePCLRaw.core": "2.1.4" + } + }, + "System.Buffers": { + "type": "Transitive", + "resolved": "4.5.1", + "contentHash": "Rw7ijyl1qqRS0YQD/WycNst8hUUMgrMH4FCn1nNm27M4VxchZ1js3fVjQaANHO5f3sN4isvP4a+Met9Y4YomAg==" + }, + "System.Collections.Immutable": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "FXkLXiK0sVVewcso0imKQoOxjoPAj42R8HtjjbSjVPAzwDfzoyoznWxgA3c38LDbN9SJux1xXoXYAhz98j7r2g==", + "dependencies": { + "System.Memory": "4.5.4" + } + }, + "System.ComponentModel.Annotations": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "dMkqfy2el8A8/I76n2Hi1oBFEbG1SfxD2l5nhwXV3XjlnOmwxJlQbYpJH4W51odnU9sARCSAgv7S3CyAFMkpYg==" + }, + "System.Diagnostics.DiagnosticSource": { + "type": "Transitive", + "resolved": "7.0.0", + "contentHash": "9W0ewWDuAyDqS2PigdTxk6jDKonfgscY/hP8hm7VpxYhNHZHKvZTdRckberlFk3VnCmr3xBUyMBut12Q+T2aOw==", + "dependencies": { + "System.Memory": "4.5.5", + "System.Runtime.CompilerServices.Unsafe": "6.0.0" + } + }, + "System.DoubleNumerics": { + "type": "Transitive", + "resolved": "3.1.3", + "contentHash": "KRKEM/L3KBodjA9VOg3EifFVWUY6EOqaMB05UvPEDm7Zeby/kZW+4kdWUEPzW6xtkwf46p661L9NrbeeQhtLzw==", + "dependencies": { + "NETStandard.Library": "1.6.1" + } + }, + "System.Memory": { + "type": "Transitive", + "resolved": "4.5.5", + "contentHash": "XIWiDvKPXaTveaB7HVganDlOCRoj03l+jrwNvcge/t8vhGYKvqV+dMv6G4SAX2NoNmN0wZfVPTAlFwZcZvVOUw==", + "dependencies": { + "System.Buffers": "4.5.1", + "System.Numerics.Vectors": "4.4.0", + "System.Runtime.CompilerServices.Unsafe": "4.5.3" + } + }, + "System.Numerics.Vectors": { + "type": "Transitive", + "resolved": "4.5.0", + "contentHash": "QQTlPTl06J/iiDbJCiepZ4H//BVraReU4O4EoRw1U02H5TLUIT7xn3GnDp9AXPSlJUDyFs4uWjWafNX6WrAojQ==" + }, + "System.Reactive": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "erBZjkQHWL9jpasCE/0qKAryzVBJFxGHVBAvgRN1bzM0q2s1S4oYREEEL0Vb+1kA/6BKb5FjUZMp5VXmy+gzkQ==", + "dependencies": { + "System.Runtime.InteropServices.WindowsRuntime": "4.3.0", + "System.Threading.Tasks.Extensions": "4.5.4" + } + }, + "System.Reflection.Metadata": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "5NecZgXktdGg34rh1OenY1rFNDCI8xSjFr+Z4OU4cU06AQHUdRnIIEeWENu3Wl4YowbzkymAIMvi3WyK9U53pQ==", + "dependencies": { + "System.Collections.Immutable": "5.0.0" + } + }, + "System.Reflection.TypeExtensions": { + "type": "Transitive", + "resolved": "4.7.0", + "contentHash": "VybpaOQQhqE6siHppMktjfGBw1GCwvCqiufqmP8F1nj7fTUNtW35LOEt3UZTEsECfo+ELAl/9o9nJx3U91i7vA==" + }, + "System.Runtime": { + "type": "Transitive", + "resolved": "4.3.0", + "contentHash": "JufQi0vPQ0xGnAczR13AUFglDyVYt4Kqnz1AZaiKZ5+GICq0/1MH/mO/eAJHt/mHW1zjKBJd7kV26SrxddAhiw==", + "dependencies": { + "Microsoft.NETCore.Platforms": "1.1.0", + "Microsoft.NETCore.Targets": "1.1.0" + } + }, + "System.Runtime.CompilerServices.Unsafe": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "/iUeP3tq1S0XdNNoMz5C9twLSrM/TH+qElHkXWaPvuNOt+99G75NrV0OS2EqHx5wMN7popYjpc8oTjC1y16DLg==" + }, + "System.Runtime.InteropServices.WindowsRuntime": { + "type": "Transitive", + "resolved": "4.3.0", + "contentHash": "J4GUi3xZQLUBasNwZnjrffN8i5wpHrBtZoLG+OhRyGo/+YunMRWWtwoMDlUAIdmX0uRfpHIBDSV6zyr3yf00TA==", + "dependencies": { + "System.Runtime": "4.3.0" + } + }, + "System.Text.Encodings.Web": { + "type": "Transitive", + "resolved": "5.0.1", + "contentHash": "KmJ+CJXizDofbq6mpqDoRRLcxgOd2z9X3XoFNULSbvbqVRZkFX3istvr+MUjL6Zw1RT+RNdoI4GYidIINtgvqQ==", + "dependencies": { + "System.Buffers": "4.5.1", + "System.Memory": "4.5.4" + } + }, + "System.Text.Json": { + "type": "Transitive", + "resolved": "5.0.2", + "contentHash": "I47dVIGiV6SfAyppphxqupertT/5oZkYLDCX6vC3HpOI4ZLjyoKAreUoem2ie6G0RbRuFrlqz/PcTQjfb2DOfQ==", + "dependencies": { + "Microsoft.Bcl.AsyncInterfaces": "5.0.0", + "System.Buffers": "4.5.1", + "System.Memory": "4.5.4", + "System.Numerics.Vectors": "4.5.0", + "System.Runtime.CompilerServices.Unsafe": "5.0.0", + "System.Text.Encodings.Web": "5.0.1", + "System.Threading.Tasks.Extensions": "4.5.4" + } + }, + "System.Threading.Tasks.Extensions": { + "type": "Transitive", + "resolved": "4.5.4", + "contentHash": "zteT+G8xuGu6mS+mzDzYXbzS7rd3K6Fjb9RiZlYlJPam2/hU7JCBZBVEcywNuR+oZ1ncTvc/cq0faRr3P01OVg==", + "dependencies": { + "System.Runtime.CompilerServices.Unsafe": "4.5.3" + } + }, + "speckle.autofac": { + "type": "Project", + "dependencies": { + "Microsoft.Extensions.Logging.Abstractions": "[7.0.0, )", + "Speckle.Core": "[2.0.999-local, )" + } + }, + "speckle.connectors.utils": { + "type": "Project", + "dependencies": { + "Serilog.Extensions.Logging": "[7.0.0, )", + "Speckle.Autofac": "[2.0.999-local, )", + "Speckle.Core": "[2.0.999-local, )" + } + }, + "Speckle.Core": { + "type": "Project", + "dependencies": { + "GraphQL.Client": "[6.0.0, )", + "Microsoft.CSharp": "[4.7.0, )", + "Microsoft.Data.Sqlite": "[7.0.5, )", + "Polly": "[7.2.3, )", + "Polly.Contrib.WaitAndRetry": "[1.1.1, )", + "Polly.Extensions.Http": "[3.0.0, )", + "Sentry": "[3.33.0, )", + "Sentry.Serilog": "[3.33.0, )", + "Serilog": "[2.12.0, )", + "Serilog.Enrichers.ClientInfo": "[1.3.0, )", + "Serilog.Exceptions": "[8.4.0, )", + "Serilog.Sinks.Console": "[4.1.0, )", + "Serilog.Sinks.Seq": "[5.2.2, )", + "SerilogTimings": "[3.0.1, )", + "Speckle.Newtonsoft.Json": "[13.0.2, )", + "System.DoubleNumerics": "[3.1.3, )" + } + } + } + } +} \ No newline at end of file diff --git a/DUI3-DX/Directory.Build.props b/DUI3-DX/Directory.Build.props index 56a58f6ad6..ecc6709aba 100644 --- a/DUI3-DX/Directory.Build.props +++ b/DUI3-DX/Directory.Build.props @@ -6,6 +6,7 @@ enable true false + true diff --git a/DUI3-DX/Sdk/Speckle.Autofac/packages.lock.json b/DUI3-DX/Sdk/Speckle.Autofac/packages.lock.json new file mode 100644 index 0000000000..c4cbeb83cb --- /dev/null +++ b/DUI3-DX/Sdk/Speckle.Autofac/packages.lock.json @@ -0,0 +1,470 @@ +{ + "version": 1, + "dependencies": { + ".NETStandard,Version=v2.0": { + "Autofac": { + "type": "Direct", + "requested": "[5.2.0, )", + "resolved": "5.2.0", + "contentHash": "V8dBH0dsv75uDzl7Sw+HkhKDPUw2eXnlMjcSVMH+tLo2s67MpTKGyDj1pDcpR+IF2u4YRs0s3/x7R88YJzIWvg==", + "dependencies": { + "Microsoft.Bcl.AsyncInterfaces": "1.1.0" + } + }, + "Microsoft.Extensions.Logging.Abstractions": { + "type": "Direct", + "requested": "[7.0.0, )", + "resolved": "7.0.0", + "contentHash": "kmn78+LPVMOWeITUjIlfxUPDsI0R6G0RkeAMBmQxAJ7vBJn4q2dTva7pWi65ceN5vPGjJ9q/Uae2WKgvfktJAw==", + "dependencies": { + "System.Buffers": "4.5.1", + "System.Memory": "4.5.5" + } + }, + "NETStandard.Library": { + "type": "Direct", + "requested": "[2.0.3, )", + "resolved": "2.0.3", + "contentHash": "st47PosZSHrjECdjeIzZQbzivYBJFv6P2nv4cj2ypdI204DO+vZ7l5raGMiX4eXMJ53RfOIg+/s4DHVZ54Nu2A==", + "dependencies": { + "Microsoft.NETCore.Platforms": "1.1.0" + } + }, + "PolySharp": { + "type": "Direct", + "requested": "[1.14.1, )", + "resolved": "1.14.1", + "contentHash": "mOOmFYwad3MIOL14VCjj02LljyF1GNw1wP0YVlxtcPvqdxjGGMNdNJJxHptlry3MOd8b40Flm8RPOM8JOlN2sQ==" + }, + "Speckle.InterfaceGenerator": { + "type": "Direct", + "requested": "[0.9.5, )", + "resolved": "0.9.5", + "contentHash": "oU/L7pN1R7q8KkbrpQ3WJnHirPHqn+9DEA7asOcUiggV5dzVg1A/VYs7GOSusD24njxXh03tE3a2oTLOjt3cVg==" + }, + "GraphQL.Client": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "8yPNBbuVBpTptivyAlak4GZvbwbUcjeQTL4vN1HKHRuOykZ4r7l5fcLS6vpyPyLn0x8FsL31xbOIKyxbmR9rbA==", + "dependencies": { + "GraphQL.Client.Abstractions": "6.0.0", + "GraphQL.Client.Abstractions.Websocket": "6.0.0", + "System.Reactive": "5.0.0" + } + }, + "GraphQL.Client.Abstractions": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "h7uzWFORHZ+CCjwr/ThAyXMr0DPpzEANDa4Uo54wqCQ+j7qUKwqYTgOrb1W40sqbvNaZm9v/X7It31SUw0maHA==", + "dependencies": { + "GraphQL.Primitives": "6.0.0" + } + }, + "GraphQL.Client.Abstractions.Websocket": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "Nr9bPf8gIOvLuXpqEpqr9z9jslYFJOvd0feHth3/kPqeR3uMbjF5pjiwh4jxyMcxHdr8Pb6QiXkV3hsSyt0v7A==", + "dependencies": { + "GraphQL.Client.Abstractions": "6.0.0" + } + }, + "GraphQL.Primitives": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "yg72rrYDapfsIUrul7aF6wwNnTJBOFvuA9VdDTQpPa8AlAriHbufeXYLBcodKjfUdkCnaiggX1U/nEP08Zb5GA==" + }, + "Microsoft.AspNetCore.Http": { + "type": "Transitive", + "resolved": "2.1.1", + "contentHash": "pPDcCW8spnyibK3krpxrOpaFHf5fjV6k1Hsl6gfh77N/8gRYlLU7MOQDUnjpEwdlHmtxwJKQJNxZqVQOmJGRUw==", + "dependencies": { + "Microsoft.AspNetCore.Http.Abstractions": "2.1.1", + "Microsoft.AspNetCore.WebUtilities": "2.1.1", + "Microsoft.Extensions.ObjectPool": "2.1.1", + "Microsoft.Extensions.Options": "2.1.1", + "Microsoft.Net.Http.Headers": "2.1.1" + } + }, + "Microsoft.AspNetCore.Http.Abstractions": { + "type": "Transitive", + "resolved": "2.1.1", + "contentHash": "kQUEVOU4loc8CPSb2WoHFTESqwIa8Ik7ysCBfTwzHAd0moWovc9JQLmhDIHlYLjHbyexqZAlkq/FPRUZqokebw==", + "dependencies": { + "Microsoft.AspNetCore.Http.Features": "2.1.1", + "System.Text.Encodings.Web": "4.5.0" + } + }, + "Microsoft.AspNetCore.Http.Features": { + "type": "Transitive", + "resolved": "2.1.1", + "contentHash": "VklZ7hWgSvHBcDtwYYkdMdI/adlf7ebxTZ9kdzAhX+gUs5jSHE9mZlTamdgf9miSsxc1QjNazHXTDJdVPZKKTw==", + "dependencies": { + "Microsoft.Extensions.Primitives": "2.1.1" + } + }, + "Microsoft.AspNetCore.WebUtilities": { + "type": "Transitive", + "resolved": "2.1.1", + "contentHash": "PGKIZt4+412Z/XPoSjvYu/QIbTxcAQuEFNoA1Pw8a9mgmO0ZhNBmfaNyhgXFf7Rq62kP0tT/2WXpxdcQhkFUPA==", + "dependencies": { + "Microsoft.Net.Http.Headers": "2.1.1", + "System.Text.Encodings.Web": "4.5.0" + } + }, + "Microsoft.Bcl.AsyncInterfaces": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "W8DPQjkMScOMTtJbPwmPyj9c3zYSFGawDW3jwlBOOsnY+EzZFLgNQ/UMkK35JmkNOVPdCyPr2Tw7Vv9N+KA3ZQ==", + "dependencies": { + "System.Threading.Tasks.Extensions": "4.5.4" + } + }, + "Microsoft.CSharp": { + "type": "Transitive", + "resolved": "4.7.0", + "contentHash": "pTj+D3uJWyN3My70i2Hqo+OXixq3Os2D1nJ2x92FFo6sk8fYS1m1WLNTs0Dc1uPaViH0YvEEwvzddQ7y4rhXmA==" + }, + "Microsoft.Data.Sqlite": { + "type": "Transitive", + "resolved": "7.0.5", + "contentHash": "KGxbPeWsQMnmQy43DSBxAFtHz3l2JX8EWBSGUCvT3CuZ8KsuzbkqMIJMDOxWtG8eZSoCDI04aiVQjWuuV8HmSw==", + "dependencies": { + "Microsoft.Data.Sqlite.Core": "7.0.5", + "SQLitePCLRaw.bundle_e_sqlite3": "2.1.4" + } + }, + "Microsoft.Data.Sqlite.Core": { + "type": "Transitive", + "resolved": "7.0.5", + "contentHash": "FTerRmQPqHrCrnoUzhBu+E+1DNGwyrAMLqHkAqOOOu5pGfyMOj8qQUBxI/gDtWtG11p49UxSfWmBzRNlwZqfUg==", + "dependencies": { + "SQLitePCLRaw.core": "2.1.4" + } + }, + "Microsoft.Extensions.DependencyInjection.Abstractions": { + "type": "Transitive", + "resolved": "2.1.1", + "contentHash": "MgYpU5cwZohUMKKg3sbPhvGG+eAZ/59E9UwPwlrUkyXU+PGzqwZg9yyQNjhxuAWmoNoFReoemeCku50prYSGzA==" + }, + "Microsoft.Extensions.ObjectPool": { + "type": "Transitive", + "resolved": "2.1.1", + "contentHash": "SErON45qh4ogDp6lr6UvVmFYW0FERihW+IQ+2JyFv1PUyWktcJytFaWH5zarufJvZwhci7Rf1IyGXr9pVEadTw==" + }, + "Microsoft.Extensions.Options": { + "type": "Transitive", + "resolved": "2.1.1", + "contentHash": "V7lXCU78lAbzaulCGFKojcCyG8RTJicEbiBkPJjFqiqXwndEBBIehdXRMWEVU3UtzQ1yDvphiWUL9th6/4gJ7w==", + "dependencies": { + "Microsoft.Extensions.DependencyInjection.Abstractions": "2.1.1", + "Microsoft.Extensions.Primitives": "2.1.1" + } + }, + "Microsoft.Extensions.Primitives": { + "type": "Transitive", + "resolved": "2.1.1", + "contentHash": "scJ1GZNIxMmjpENh0UZ8XCQ6vzr/LzeF9WvEA51Ix2OQGAs9WPgPu8ABVUdvpKPLuor/t05gm6menJK3PwqOXg==", + "dependencies": { + "System.Memory": "4.5.1", + "System.Runtime.CompilerServices.Unsafe": "4.5.1" + } + }, + "Microsoft.Net.Http.Headers": { + "type": "Transitive", + "resolved": "2.1.1", + "contentHash": "lPNIphl8b2EuhOE9dMH6EZDmu7pS882O+HMi5BJNsigxHaWlBrYxZHFZgE18cyaPp6SSZcTkKkuzfjV/RRQKlA==", + "dependencies": { + "Microsoft.Extensions.Primitives": "2.1.1", + "System.Buffers": "4.5.0" + } + }, + "Microsoft.NETCore.Platforms": { + "type": "Transitive", + "resolved": "1.1.0", + "contentHash": "kz0PEW2lhqygehI/d6XsPCQzD7ff7gUJaVGPVETX611eadGsA3A877GdSlU0LRVMCTH/+P3o2iDTak+S08V2+A==" + }, + "Microsoft.NETCore.Targets": { + "type": "Transitive", + "resolved": "1.1.0", + "contentHash": "aOZA3BWfz9RXjpzt0sRJJMjAscAUm3Hoa4UWAfceV9UTYxgwZ1lZt5nO2myFf+/jetYQo4uTP7zS8sJY67BBxg==" + }, + "Polly": { + "type": "Transitive", + "resolved": "7.2.3", + "contentHash": "DeCY0OFbNdNxsjntr1gTXHJ5pKUwYzp04Er2LLeN3g6pWhffsGuKVfMBLe1lw7x76HrPkLxKEFxBlpRxS2nDEQ==" + }, + "Polly.Contrib.WaitAndRetry": { + "type": "Transitive", + "resolved": "1.1.1", + "contentHash": "1MUQLiSo4KDkQe6nzQRhIU05lm9jlexX5BVsbuw0SL82ynZ+GzAHQxJVDPVBboxV37Po3SG077aX8DuSy8TkaA==" + }, + "Polly.Extensions.Http": { + "type": "Transitive", + "resolved": "3.0.0", + "contentHash": "drrG+hB3pYFY7w1c3BD+lSGYvH2oIclH8GRSehgfyP5kjnFnHKQuuBhuHLv+PWyFuaTDyk/vfRpnxOzd11+J8g==", + "dependencies": { + "Polly": "7.1.0" + } + }, + "Sentry": { + "type": "Transitive", + "resolved": "3.33.0", + "contentHash": "8vbD2o6IR2wrRrkSiRbnodWGWUOqIlwYtzpjvPNOb5raJdOf+zxMwfS8f6nx9bmrTTfDj7KrCB8C/5OuicAc8A==", + "dependencies": { + "System.Reflection.Metadata": "5.0.0", + "System.Text.Json": "5.0.2" + } + }, + "Sentry.Serilog": { + "type": "Transitive", + "resolved": "3.33.0", + "contentHash": "V8BU7QGWg2qLYfNPqtuTBhC1opysny5l+Ifp6J6PhOeAxU0FssR7nYfbJVetrnLIoh2rd3DlJ6hHYYQosQYcUQ==", + "dependencies": { + "Sentry": "3.33.0", + "Serilog": "2.7.1" + } + }, + "Serilog": { + "type": "Transitive", + "resolved": "2.12.0", + "contentHash": "xaiJLIdu6rYMKfQMYUZgTy8YK7SMZjB4Yk50C/u//Z4OsvxkUfSPJy4nknfvwAC34yr13q7kcyh4grbwhSxyZg==" + }, + "Serilog.Enrichers.ClientInfo": { + "type": "Transitive", + "resolved": "1.3.0", + "contentHash": "mTc7PM+wC9Hr7LWSwqt5mmnlAr7RJs+eTb3PGPRhwdOackk95MkhUZognuxXEdlW19HAFNmEBTSBY5DfLwM8jQ==", + "dependencies": { + "Microsoft.AspNetCore.Http": "2.1.1", + "Serilog": "2.7.1" + } + }, + "Serilog.Exceptions": { + "type": "Transitive", + "resolved": "8.4.0", + "contentHash": "nc/+hUw3lsdo0zCj0KMIybAu7perMx79vu72w0za9Nsi6mWyNkGXxYxakAjWB7nEmYL6zdmhEQRB4oJ2ALUeug==", + "dependencies": { + "Serilog": "2.8.0", + "System.Reflection.TypeExtensions": "4.7.0" + } + }, + "Serilog.Formatting.Compact": { + "type": "Transitive", + "resolved": "1.1.0", + "contentHash": "pNroKVjo+rDqlxNG5PXkRLpfSCuDOBY0ri6jp9PLe505ljqwhwZz8ospy2vWhQlFu5GkIesh3FcDs4n7sWZODA==", + "dependencies": { + "Serilog": "2.8.0" + } + }, + "Serilog.Sinks.Console": { + "type": "Transitive", + "resolved": "4.1.0", + "contentHash": "K6N5q+5fetjnJPvCmkWOpJ/V8IEIoMIB1s86OzBrbxwTyHxdx3pmz4H+8+O/Dc/ftUX12DM1aynx/dDowkwzqg==", + "dependencies": { + "Serilog": "2.10.0" + } + }, + "Serilog.Sinks.File": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "uwV5hdhWPwUH1szhO8PJpFiahqXmzPzJT/sOijH/kFgUx+cyoDTMM8MHD0adw9+Iem6itoibbUXHYslzXsLEAg==", + "dependencies": { + "Serilog": "2.10.0" + } + }, + "Serilog.Sinks.PeriodicBatching": { + "type": "Transitive", + "resolved": "3.1.0", + "contentHash": "NDWR7m3PalVlGEq3rzoktrXikjFMLmpwF0HI4sowo8YDdU+gqPlTHlDQiOGxHfB0sTfjPA9JjA7ctKG9zqjGkw==", + "dependencies": { + "Serilog": "2.0.0" + } + }, + "Serilog.Sinks.Seq": { + "type": "Transitive", + "resolved": "5.2.2", + "contentHash": "1Csmo5ua7NKUe0yXUx+zsRefjAniPWcXFhUXxXG8pwo0iMiw2gjn9SOkgYnnxbgWqmlGv236w0N/dHc2v5XwMg==", + "dependencies": { + "Serilog": "2.12.0", + "Serilog.Formatting.Compact": "1.1.0", + "Serilog.Sinks.File": "5.0.0", + "Serilog.Sinks.PeriodicBatching": "3.1.0" + } + }, + "SerilogTimings": { + "type": "Transitive", + "resolved": "3.0.1", + "contentHash": "Zs28eTgszAMwpIrbBnWHBI50yuxL50p/dmAUWmy75+axdZYK/Sjm5/5m1N/CisR8acJUhTVcjPZrsB1P5iv0Uw==", + "dependencies": { + "Serilog": "2.10.0" + } + }, + "Speckle.Newtonsoft.Json": { + "type": "Transitive", + "resolved": "13.0.2", + "contentHash": "g1BejUZwax5PRfL6xHgLEK23sqHWOgOj9hE7RvfRRlN00AGt8GnPYt8HedSK7UB3HiRW8zCA9Pn0iiYxCK24BA==" + }, + "SQLitePCLRaw.bundle_e_sqlite3": { + "type": "Transitive", + "resolved": "2.1.4", + "contentHash": "EWI1olKDjFEBMJu0+3wuxwziIAdWDVMYLhuZ3Qs84rrz+DHwD00RzWPZCa+bLnHCf3oJwuFZIRsHT5p236QXww==", + "dependencies": { + "SQLitePCLRaw.lib.e_sqlite3": "2.1.4", + "SQLitePCLRaw.provider.e_sqlite3": "2.1.4" + } + }, + "SQLitePCLRaw.core": { + "type": "Transitive", + "resolved": "2.1.4", + "contentHash": "inBjvSHo9UDKneGNzfUfDjK08JzlcIhn1+SP5Y3m6cgXpCxXKCJDy6Mka7LpgSV+UZmKSnC8rTwB0SQ0xKu5pA==", + "dependencies": { + "System.Memory": "4.5.3" + } + }, + "SQLitePCLRaw.lib.e_sqlite3": { + "type": "Transitive", + "resolved": "2.1.4", + "contentHash": "2C9Q9eX7CPLveJA0rIhf9RXAvu+7nWZu1A2MdG6SD/NOu26TakGgL1nsbc0JAspGijFOo3HoN79xrx8a368fBg==" + }, + "SQLitePCLRaw.provider.e_sqlite3": { + "type": "Transitive", + "resolved": "2.1.4", + "contentHash": "CSlb5dUp1FMIkez9Iv5EXzpeq7rHryVNqwJMWnpq87j9zWZexaEMdisDktMsnnrzKM6ahNrsTkjqNodTBPBxtQ==", + "dependencies": { + "SQLitePCLRaw.core": "2.1.4" + } + }, + "System.Buffers": { + "type": "Transitive", + "resolved": "4.5.1", + "contentHash": "Rw7ijyl1qqRS0YQD/WycNst8hUUMgrMH4FCn1nNm27M4VxchZ1js3fVjQaANHO5f3sN4isvP4a+Met9Y4YomAg==" + }, + "System.Collections.Immutable": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "FXkLXiK0sVVewcso0imKQoOxjoPAj42R8HtjjbSjVPAzwDfzoyoznWxgA3c38LDbN9SJux1xXoXYAhz98j7r2g==", + "dependencies": { + "System.Memory": "4.5.4" + } + }, + "System.DoubleNumerics": { + "type": "Transitive", + "resolved": "3.1.3", + "contentHash": "KRKEM/L3KBodjA9VOg3EifFVWUY6EOqaMB05UvPEDm7Zeby/kZW+4kdWUEPzW6xtkwf46p661L9NrbeeQhtLzw==", + "dependencies": { + "NETStandard.Library": "1.6.1" + } + }, + "System.Memory": { + "type": "Transitive", + "resolved": "4.5.5", + "contentHash": "XIWiDvKPXaTveaB7HVganDlOCRoj03l+jrwNvcge/t8vhGYKvqV+dMv6G4SAX2NoNmN0wZfVPTAlFwZcZvVOUw==", + "dependencies": { + "System.Buffers": "4.5.1", + "System.Numerics.Vectors": "4.4.0", + "System.Runtime.CompilerServices.Unsafe": "4.5.3" + } + }, + "System.Numerics.Vectors": { + "type": "Transitive", + "resolved": "4.5.0", + "contentHash": "QQTlPTl06J/iiDbJCiepZ4H//BVraReU4O4EoRw1U02H5TLUIT7xn3GnDp9AXPSlJUDyFs4uWjWafNX6WrAojQ==" + }, + "System.Reactive": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "erBZjkQHWL9jpasCE/0qKAryzVBJFxGHVBAvgRN1bzM0q2s1S4oYREEEL0Vb+1kA/6BKb5FjUZMp5VXmy+gzkQ==", + "dependencies": { + "System.Runtime.InteropServices.WindowsRuntime": "4.3.0", + "System.Threading.Tasks.Extensions": "4.5.4" + } + }, + "System.Reflection.Metadata": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "5NecZgXktdGg34rh1OenY1rFNDCI8xSjFr+Z4OU4cU06AQHUdRnIIEeWENu3Wl4YowbzkymAIMvi3WyK9U53pQ==", + "dependencies": { + "System.Collections.Immutable": "5.0.0" + } + }, + "System.Reflection.TypeExtensions": { + "type": "Transitive", + "resolved": "4.7.0", + "contentHash": "VybpaOQQhqE6siHppMktjfGBw1GCwvCqiufqmP8F1nj7fTUNtW35LOEt3UZTEsECfo+ELAl/9o9nJx3U91i7vA==" + }, + "System.Runtime": { + "type": "Transitive", + "resolved": "4.3.0", + "contentHash": "JufQi0vPQ0xGnAczR13AUFglDyVYt4Kqnz1AZaiKZ5+GICq0/1MH/mO/eAJHt/mHW1zjKBJd7kV26SrxddAhiw==", + "dependencies": { + "Microsoft.NETCore.Platforms": "1.1.0", + "Microsoft.NETCore.Targets": "1.1.0" + } + }, + "System.Runtime.CompilerServices.Unsafe": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "ZD9TMpsmYJLrxbbmdvhwt9YEgG5WntEnZ/d1eH8JBX9LBp+Ju8BSBhUGbZMNVHHomWo2KVImJhTDl2hIgw/6MA==" + }, + "System.Runtime.InteropServices.WindowsRuntime": { + "type": "Transitive", + "resolved": "4.3.0", + "contentHash": "J4GUi3xZQLUBasNwZnjrffN8i5wpHrBtZoLG+OhRyGo/+YunMRWWtwoMDlUAIdmX0uRfpHIBDSV6zyr3yf00TA==", + "dependencies": { + "System.Runtime": "4.3.0" + } + }, + "System.Text.Encodings.Web": { + "type": "Transitive", + "resolved": "5.0.1", + "contentHash": "KmJ+CJXizDofbq6mpqDoRRLcxgOd2z9X3XoFNULSbvbqVRZkFX3istvr+MUjL6Zw1RT+RNdoI4GYidIINtgvqQ==", + "dependencies": { + "System.Buffers": "4.5.1", + "System.Memory": "4.5.4" + } + }, + "System.Text.Json": { + "type": "Transitive", + "resolved": "5.0.2", + "contentHash": "I47dVIGiV6SfAyppphxqupertT/5oZkYLDCX6vC3HpOI4ZLjyoKAreUoem2ie6G0RbRuFrlqz/PcTQjfb2DOfQ==", + "dependencies": { + "Microsoft.Bcl.AsyncInterfaces": "5.0.0", + "System.Buffers": "4.5.1", + "System.Memory": "4.5.4", + "System.Numerics.Vectors": "4.5.0", + "System.Runtime.CompilerServices.Unsafe": "5.0.0", + "System.Text.Encodings.Web": "5.0.1", + "System.Threading.Tasks.Extensions": "4.5.4" + } + }, + "System.Threading.Tasks.Extensions": { + "type": "Transitive", + "resolved": "4.5.4", + "contentHash": "zteT+G8xuGu6mS+mzDzYXbzS7rd3K6Fjb9RiZlYlJPam2/hU7JCBZBVEcywNuR+oZ1ncTvc/cq0faRr3P01OVg==", + "dependencies": { + "System.Runtime.CompilerServices.Unsafe": "4.5.3" + } + }, + "Speckle.Core": { + "type": "Project", + "dependencies": { + "GraphQL.Client": "[6.0.0, )", + "Microsoft.CSharp": "[4.7.0, )", + "Microsoft.Data.Sqlite": "[7.0.5, )", + "Polly": "[7.2.3, )", + "Polly.Contrib.WaitAndRetry": "[1.1.1, )", + "Polly.Extensions.Http": "[3.0.0, )", + "Sentry": "[3.33.0, )", + "Sentry.Serilog": "[3.33.0, )", + "Serilog": "[2.12.0, )", + "Serilog.Enrichers.ClientInfo": "[1.3.0, )", + "Serilog.Exceptions": "[8.4.0, )", + "Serilog.Sinks.Console": "[4.1.0, )", + "Serilog.Sinks.Seq": "[5.2.2, )", + "SerilogTimings": "[3.0.1, )", + "Speckle.Newtonsoft.Json": "[13.0.2, )", + "System.DoubleNumerics": "[3.1.3, )" + } + } + } + } +} \ No newline at end of file diff --git a/DUI3-DX/Sdk/Speckle.Connectors.Utils/packages.lock.json b/DUI3-DX/Sdk/Speckle.Connectors.Utils/packages.lock.json new file mode 100644 index 0000000000..c23420da56 --- /dev/null +++ b/DUI3-DX/Sdk/Speckle.Connectors.Utils/packages.lock.json @@ -0,0 +1,519 @@ +{ + "version": 1, + "dependencies": { + ".NETStandard,Version=v2.0": { + "NETStandard.Library": { + "type": "Direct", + "requested": "[2.0.3, )", + "resolved": "2.0.3", + "contentHash": "st47PosZSHrjECdjeIzZQbzivYBJFv6P2nv4cj2ypdI204DO+vZ7l5raGMiX4eXMJ53RfOIg+/s4DHVZ54Nu2A==", + "dependencies": { + "Microsoft.NETCore.Platforms": "1.1.0" + } + }, + "PolySharp": { + "type": "Direct", + "requested": "[1.14.1, )", + "resolved": "1.14.1", + "contentHash": "mOOmFYwad3MIOL14VCjj02LljyF1GNw1wP0YVlxtcPvqdxjGGMNdNJJxHptlry3MOd8b40Flm8RPOM8JOlN2sQ==" + }, + "Serilog.Extensions.Logging": { + "type": "Direct", + "requested": "[7.0.0, )", + "resolved": "7.0.0", + "contentHash": "9faU0zNQqU7I6soVhLUMYaGNpgWv6cKlKb2S5AnS8gXxzW/em5Ladm/6FMrWTnX41cdbdGPOWNAo6adi4WaJ6A==", + "dependencies": { + "Microsoft.Extensions.Logging": "7.0.0", + "Serilog": "2.12.0" + } + }, + "Speckle.InterfaceGenerator": { + "type": "Direct", + "requested": "[0.9.5, )", + "resolved": "0.9.5", + "contentHash": "oU/L7pN1R7q8KkbrpQ3WJnHirPHqn+9DEA7asOcUiggV5dzVg1A/VYs7GOSusD24njxXh03tE3a2oTLOjt3cVg==" + }, + "GraphQL.Client": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "8yPNBbuVBpTptivyAlak4GZvbwbUcjeQTL4vN1HKHRuOykZ4r7l5fcLS6vpyPyLn0x8FsL31xbOIKyxbmR9rbA==", + "dependencies": { + "GraphQL.Client.Abstractions": "6.0.0", + "GraphQL.Client.Abstractions.Websocket": "6.0.0", + "System.Reactive": "5.0.0" + } + }, + "GraphQL.Client.Abstractions": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "h7uzWFORHZ+CCjwr/ThAyXMr0DPpzEANDa4Uo54wqCQ+j7qUKwqYTgOrb1W40sqbvNaZm9v/X7It31SUw0maHA==", + "dependencies": { + "GraphQL.Primitives": "6.0.0" + } + }, + "GraphQL.Client.Abstractions.Websocket": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "Nr9bPf8gIOvLuXpqEpqr9z9jslYFJOvd0feHth3/kPqeR3uMbjF5pjiwh4jxyMcxHdr8Pb6QiXkV3hsSyt0v7A==", + "dependencies": { + "GraphQL.Client.Abstractions": "6.0.0" + } + }, + "GraphQL.Primitives": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "yg72rrYDapfsIUrul7aF6wwNnTJBOFvuA9VdDTQpPa8AlAriHbufeXYLBcodKjfUdkCnaiggX1U/nEP08Zb5GA==" + }, + "Microsoft.AspNetCore.Http": { + "type": "Transitive", + "resolved": "2.1.1", + "contentHash": "pPDcCW8spnyibK3krpxrOpaFHf5fjV6k1Hsl6gfh77N/8gRYlLU7MOQDUnjpEwdlHmtxwJKQJNxZqVQOmJGRUw==", + "dependencies": { + "Microsoft.AspNetCore.Http.Abstractions": "2.1.1", + "Microsoft.AspNetCore.WebUtilities": "2.1.1", + "Microsoft.Extensions.ObjectPool": "2.1.1", + "Microsoft.Extensions.Options": "2.1.1", + "Microsoft.Net.Http.Headers": "2.1.1" + } + }, + "Microsoft.AspNetCore.Http.Abstractions": { + "type": "Transitive", + "resolved": "2.1.1", + "contentHash": "kQUEVOU4loc8CPSb2WoHFTESqwIa8Ik7ysCBfTwzHAd0moWovc9JQLmhDIHlYLjHbyexqZAlkq/FPRUZqokebw==", + "dependencies": { + "Microsoft.AspNetCore.Http.Features": "2.1.1", + "System.Text.Encodings.Web": "4.5.0" + } + }, + "Microsoft.AspNetCore.Http.Features": { + "type": "Transitive", + "resolved": "2.1.1", + "contentHash": "VklZ7hWgSvHBcDtwYYkdMdI/adlf7ebxTZ9kdzAhX+gUs5jSHE9mZlTamdgf9miSsxc1QjNazHXTDJdVPZKKTw==", + "dependencies": { + "Microsoft.Extensions.Primitives": "2.1.1" + } + }, + "Microsoft.AspNetCore.WebUtilities": { + "type": "Transitive", + "resolved": "2.1.1", + "contentHash": "PGKIZt4+412Z/XPoSjvYu/QIbTxcAQuEFNoA1Pw8a9mgmO0ZhNBmfaNyhgXFf7Rq62kP0tT/2WXpxdcQhkFUPA==", + "dependencies": { + "Microsoft.Net.Http.Headers": "2.1.1", + "System.Text.Encodings.Web": "4.5.0" + } + }, + "Microsoft.Bcl.AsyncInterfaces": { + "type": "Transitive", + "resolved": "7.0.0", + "contentHash": "3aeMZ1N0lJoSyzqiP03hqemtb1BijhsJADdobn/4nsMJ8V1H+CrpuduUe4hlRdx+ikBQju1VGjMD1GJ3Sk05Eg==", + "dependencies": { + "System.Threading.Tasks.Extensions": "4.5.4" + } + }, + "Microsoft.CSharp": { + "type": "Transitive", + "resolved": "4.7.0", + "contentHash": "pTj+D3uJWyN3My70i2Hqo+OXixq3Os2D1nJ2x92FFo6sk8fYS1m1WLNTs0Dc1uPaViH0YvEEwvzddQ7y4rhXmA==" + }, + "Microsoft.Data.Sqlite": { + "type": "Transitive", + "resolved": "7.0.5", + "contentHash": "KGxbPeWsQMnmQy43DSBxAFtHz3l2JX8EWBSGUCvT3CuZ8KsuzbkqMIJMDOxWtG8eZSoCDI04aiVQjWuuV8HmSw==", + "dependencies": { + "Microsoft.Data.Sqlite.Core": "7.0.5", + "SQLitePCLRaw.bundle_e_sqlite3": "2.1.4" + } + }, + "Microsoft.Data.Sqlite.Core": { + "type": "Transitive", + "resolved": "7.0.5", + "contentHash": "FTerRmQPqHrCrnoUzhBu+E+1DNGwyrAMLqHkAqOOOu5pGfyMOj8qQUBxI/gDtWtG11p49UxSfWmBzRNlwZqfUg==", + "dependencies": { + "SQLitePCLRaw.core": "2.1.4" + } + }, + "Microsoft.Extensions.DependencyInjection": { + "type": "Transitive", + "resolved": "7.0.0", + "contentHash": "elNeOmkeX3eDVG6pYVeV82p29hr+UKDaBhrZyWvWLw/EVZSYEkZlQdkp0V39k/Xehs2Qa0mvoCvkVj3eQxNQ1Q==", + "dependencies": { + "Microsoft.Bcl.AsyncInterfaces": "7.0.0", + "Microsoft.Extensions.DependencyInjection.Abstractions": "7.0.0", + "System.Threading.Tasks.Extensions": "4.5.4" + } + }, + "Microsoft.Extensions.DependencyInjection.Abstractions": { + "type": "Transitive", + "resolved": "7.0.0", + "contentHash": "h3j/QfmFN4S0w4C2A6X7arXij/M/OVw3uQHSOFxnND4DyAzO1F9eMX7Eti7lU/OkSthEE0WzRsfT/Dmx86jzCw==", + "dependencies": { + "Microsoft.Bcl.AsyncInterfaces": "7.0.0", + "System.Threading.Tasks.Extensions": "4.5.4" + } + }, + "Microsoft.Extensions.Logging": { + "type": "Transitive", + "resolved": "7.0.0", + "contentHash": "Nw2muoNrOG5U5qa2ZekXwudUn2BJcD41e65zwmDHb1fQegTX66UokLWZkJRpqSSHXDOWZ5V0iqhbxOEky91atA==", + "dependencies": { + "Microsoft.Bcl.AsyncInterfaces": "7.0.0", + "Microsoft.Extensions.DependencyInjection": "7.0.0", + "Microsoft.Extensions.DependencyInjection.Abstractions": "7.0.0", + "Microsoft.Extensions.Logging.Abstractions": "7.0.0", + "Microsoft.Extensions.Options": "7.0.0", + "System.Diagnostics.DiagnosticSource": "7.0.0" + } + }, + "Microsoft.Extensions.Logging.Abstractions": { + "type": "Transitive", + "resolved": "7.0.0", + "contentHash": "kmn78+LPVMOWeITUjIlfxUPDsI0R6G0RkeAMBmQxAJ7vBJn4q2dTva7pWi65ceN5vPGjJ9q/Uae2WKgvfktJAw==", + "dependencies": { + "System.Buffers": "4.5.1", + "System.Memory": "4.5.5" + } + }, + "Microsoft.Extensions.ObjectPool": { + "type": "Transitive", + "resolved": "2.1.1", + "contentHash": "SErON45qh4ogDp6lr6UvVmFYW0FERihW+IQ+2JyFv1PUyWktcJytFaWH5zarufJvZwhci7Rf1IyGXr9pVEadTw==" + }, + "Microsoft.Extensions.Options": { + "type": "Transitive", + "resolved": "7.0.0", + "contentHash": "lP1yBnTTU42cKpMozuafbvNtQ7QcBjr/CcK3bYOGEMH55Fjt+iecXjT6chR7vbgCMqy3PG3aNQSZgo/EuY/9qQ==", + "dependencies": { + "Microsoft.Extensions.DependencyInjection.Abstractions": "7.0.0", + "Microsoft.Extensions.Primitives": "7.0.0", + "System.ComponentModel.Annotations": "5.0.0" + } + }, + "Microsoft.Extensions.Primitives": { + "type": "Transitive", + "resolved": "7.0.0", + "contentHash": "um1KU5kxcRp3CNuI8o/GrZtD4AIOXDk+RLsytjZ9QPok3ttLUelLKpilVPuaFT3TFjOhSibUAso0odbOaCDj3Q==", + "dependencies": { + "System.Memory": "4.5.5", + "System.Runtime.CompilerServices.Unsafe": "6.0.0" + } + }, + "Microsoft.Net.Http.Headers": { + "type": "Transitive", + "resolved": "2.1.1", + "contentHash": "lPNIphl8b2EuhOE9dMH6EZDmu7pS882O+HMi5BJNsigxHaWlBrYxZHFZgE18cyaPp6SSZcTkKkuzfjV/RRQKlA==", + "dependencies": { + "Microsoft.Extensions.Primitives": "2.1.1", + "System.Buffers": "4.5.0" + } + }, + "Microsoft.NETCore.Platforms": { + "type": "Transitive", + "resolved": "1.1.0", + "contentHash": "kz0PEW2lhqygehI/d6XsPCQzD7ff7gUJaVGPVETX611eadGsA3A877GdSlU0LRVMCTH/+P3o2iDTak+S08V2+A==" + }, + "Microsoft.NETCore.Targets": { + "type": "Transitive", + "resolved": "1.1.0", + "contentHash": "aOZA3BWfz9RXjpzt0sRJJMjAscAUm3Hoa4UWAfceV9UTYxgwZ1lZt5nO2myFf+/jetYQo4uTP7zS8sJY67BBxg==" + }, + "Polly": { + "type": "Transitive", + "resolved": "7.2.3", + "contentHash": "DeCY0OFbNdNxsjntr1gTXHJ5pKUwYzp04Er2LLeN3g6pWhffsGuKVfMBLe1lw7x76HrPkLxKEFxBlpRxS2nDEQ==" + }, + "Polly.Contrib.WaitAndRetry": { + "type": "Transitive", + "resolved": "1.1.1", + "contentHash": "1MUQLiSo4KDkQe6nzQRhIU05lm9jlexX5BVsbuw0SL82ynZ+GzAHQxJVDPVBboxV37Po3SG077aX8DuSy8TkaA==" + }, + "Polly.Extensions.Http": { + "type": "Transitive", + "resolved": "3.0.0", + "contentHash": "drrG+hB3pYFY7w1c3BD+lSGYvH2oIclH8GRSehgfyP5kjnFnHKQuuBhuHLv+PWyFuaTDyk/vfRpnxOzd11+J8g==", + "dependencies": { + "Polly": "7.1.0" + } + }, + "Sentry": { + "type": "Transitive", + "resolved": "3.33.0", + "contentHash": "8vbD2o6IR2wrRrkSiRbnodWGWUOqIlwYtzpjvPNOb5raJdOf+zxMwfS8f6nx9bmrTTfDj7KrCB8C/5OuicAc8A==", + "dependencies": { + "System.Reflection.Metadata": "5.0.0", + "System.Text.Json": "5.0.2" + } + }, + "Sentry.Serilog": { + "type": "Transitive", + "resolved": "3.33.0", + "contentHash": "V8BU7QGWg2qLYfNPqtuTBhC1opysny5l+Ifp6J6PhOeAxU0FssR7nYfbJVetrnLIoh2rd3DlJ6hHYYQosQYcUQ==", + "dependencies": { + "Sentry": "3.33.0", + "Serilog": "2.7.1" + } + }, + "Serilog": { + "type": "Transitive", + "resolved": "2.12.0", + "contentHash": "xaiJLIdu6rYMKfQMYUZgTy8YK7SMZjB4Yk50C/u//Z4OsvxkUfSPJy4nknfvwAC34yr13q7kcyh4grbwhSxyZg==" + }, + "Serilog.Enrichers.ClientInfo": { + "type": "Transitive", + "resolved": "1.3.0", + "contentHash": "mTc7PM+wC9Hr7LWSwqt5mmnlAr7RJs+eTb3PGPRhwdOackk95MkhUZognuxXEdlW19HAFNmEBTSBY5DfLwM8jQ==", + "dependencies": { + "Microsoft.AspNetCore.Http": "2.1.1", + "Serilog": "2.7.1" + } + }, + "Serilog.Exceptions": { + "type": "Transitive", + "resolved": "8.4.0", + "contentHash": "nc/+hUw3lsdo0zCj0KMIybAu7perMx79vu72w0za9Nsi6mWyNkGXxYxakAjWB7nEmYL6zdmhEQRB4oJ2ALUeug==", + "dependencies": { + "Serilog": "2.8.0", + "System.Reflection.TypeExtensions": "4.7.0" + } + }, + "Serilog.Formatting.Compact": { + "type": "Transitive", + "resolved": "1.1.0", + "contentHash": "pNroKVjo+rDqlxNG5PXkRLpfSCuDOBY0ri6jp9PLe505ljqwhwZz8ospy2vWhQlFu5GkIesh3FcDs4n7sWZODA==", + "dependencies": { + "Serilog": "2.8.0" + } + }, + "Serilog.Sinks.Console": { + "type": "Transitive", + "resolved": "4.1.0", + "contentHash": "K6N5q+5fetjnJPvCmkWOpJ/V8IEIoMIB1s86OzBrbxwTyHxdx3pmz4H+8+O/Dc/ftUX12DM1aynx/dDowkwzqg==", + "dependencies": { + "Serilog": "2.10.0" + } + }, + "Serilog.Sinks.File": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "uwV5hdhWPwUH1szhO8PJpFiahqXmzPzJT/sOijH/kFgUx+cyoDTMM8MHD0adw9+Iem6itoibbUXHYslzXsLEAg==", + "dependencies": { + "Serilog": "2.10.0" + } + }, + "Serilog.Sinks.PeriodicBatching": { + "type": "Transitive", + "resolved": "3.1.0", + "contentHash": "NDWR7m3PalVlGEq3rzoktrXikjFMLmpwF0HI4sowo8YDdU+gqPlTHlDQiOGxHfB0sTfjPA9JjA7ctKG9zqjGkw==", + "dependencies": { + "Serilog": "2.0.0" + } + }, + "Serilog.Sinks.Seq": { + "type": "Transitive", + "resolved": "5.2.2", + "contentHash": "1Csmo5ua7NKUe0yXUx+zsRefjAniPWcXFhUXxXG8pwo0iMiw2gjn9SOkgYnnxbgWqmlGv236w0N/dHc2v5XwMg==", + "dependencies": { + "Serilog": "2.12.0", + "Serilog.Formatting.Compact": "1.1.0", + "Serilog.Sinks.File": "5.0.0", + "Serilog.Sinks.PeriodicBatching": "3.1.0" + } + }, + "SerilogTimings": { + "type": "Transitive", + "resolved": "3.0.1", + "contentHash": "Zs28eTgszAMwpIrbBnWHBI50yuxL50p/dmAUWmy75+axdZYK/Sjm5/5m1N/CisR8acJUhTVcjPZrsB1P5iv0Uw==", + "dependencies": { + "Serilog": "2.10.0" + } + }, + "Speckle.Newtonsoft.Json": { + "type": "Transitive", + "resolved": "13.0.2", + "contentHash": "g1BejUZwax5PRfL6xHgLEK23sqHWOgOj9hE7RvfRRlN00AGt8GnPYt8HedSK7UB3HiRW8zCA9Pn0iiYxCK24BA==" + }, + "SQLitePCLRaw.bundle_e_sqlite3": { + "type": "Transitive", + "resolved": "2.1.4", + "contentHash": "EWI1olKDjFEBMJu0+3wuxwziIAdWDVMYLhuZ3Qs84rrz+DHwD00RzWPZCa+bLnHCf3oJwuFZIRsHT5p236QXww==", + "dependencies": { + "SQLitePCLRaw.lib.e_sqlite3": "2.1.4", + "SQLitePCLRaw.provider.e_sqlite3": "2.1.4" + } + }, + "SQLitePCLRaw.core": { + "type": "Transitive", + "resolved": "2.1.4", + "contentHash": "inBjvSHo9UDKneGNzfUfDjK08JzlcIhn1+SP5Y3m6cgXpCxXKCJDy6Mka7LpgSV+UZmKSnC8rTwB0SQ0xKu5pA==", + "dependencies": { + "System.Memory": "4.5.3" + } + }, + "SQLitePCLRaw.lib.e_sqlite3": { + "type": "Transitive", + "resolved": "2.1.4", + "contentHash": "2C9Q9eX7CPLveJA0rIhf9RXAvu+7nWZu1A2MdG6SD/NOu26TakGgL1nsbc0JAspGijFOo3HoN79xrx8a368fBg==" + }, + "SQLitePCLRaw.provider.e_sqlite3": { + "type": "Transitive", + "resolved": "2.1.4", + "contentHash": "CSlb5dUp1FMIkez9Iv5EXzpeq7rHryVNqwJMWnpq87j9zWZexaEMdisDktMsnnrzKM6ahNrsTkjqNodTBPBxtQ==", + "dependencies": { + "SQLitePCLRaw.core": "2.1.4" + } + }, + "System.Buffers": { + "type": "Transitive", + "resolved": "4.5.1", + "contentHash": "Rw7ijyl1qqRS0YQD/WycNst8hUUMgrMH4FCn1nNm27M4VxchZ1js3fVjQaANHO5f3sN4isvP4a+Met9Y4YomAg==" + }, + "System.Collections.Immutable": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "FXkLXiK0sVVewcso0imKQoOxjoPAj42R8HtjjbSjVPAzwDfzoyoznWxgA3c38LDbN9SJux1xXoXYAhz98j7r2g==", + "dependencies": { + "System.Memory": "4.5.4" + } + }, + "System.ComponentModel.Annotations": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "dMkqfy2el8A8/I76n2Hi1oBFEbG1SfxD2l5nhwXV3XjlnOmwxJlQbYpJH4W51odnU9sARCSAgv7S3CyAFMkpYg==" + }, + "System.Diagnostics.DiagnosticSource": { + "type": "Transitive", + "resolved": "7.0.0", + "contentHash": "9W0ewWDuAyDqS2PigdTxk6jDKonfgscY/hP8hm7VpxYhNHZHKvZTdRckberlFk3VnCmr3xBUyMBut12Q+T2aOw==", + "dependencies": { + "System.Memory": "4.5.5", + "System.Runtime.CompilerServices.Unsafe": "6.0.0" + } + }, + "System.DoubleNumerics": { + "type": "Transitive", + "resolved": "3.1.3", + "contentHash": "KRKEM/L3KBodjA9VOg3EifFVWUY6EOqaMB05UvPEDm7Zeby/kZW+4kdWUEPzW6xtkwf46p661L9NrbeeQhtLzw==", + "dependencies": { + "NETStandard.Library": "1.6.1" + } + }, + "System.Memory": { + "type": "Transitive", + "resolved": "4.5.5", + "contentHash": "XIWiDvKPXaTveaB7HVganDlOCRoj03l+jrwNvcge/t8vhGYKvqV+dMv6G4SAX2NoNmN0wZfVPTAlFwZcZvVOUw==", + "dependencies": { + "System.Buffers": "4.5.1", + "System.Numerics.Vectors": "4.4.0", + "System.Runtime.CompilerServices.Unsafe": "4.5.3" + } + }, + "System.Numerics.Vectors": { + "type": "Transitive", + "resolved": "4.5.0", + "contentHash": "QQTlPTl06J/iiDbJCiepZ4H//BVraReU4O4EoRw1U02H5TLUIT7xn3GnDp9AXPSlJUDyFs4uWjWafNX6WrAojQ==" + }, + "System.Reactive": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "erBZjkQHWL9jpasCE/0qKAryzVBJFxGHVBAvgRN1bzM0q2s1S4oYREEEL0Vb+1kA/6BKb5FjUZMp5VXmy+gzkQ==", + "dependencies": { + "System.Runtime.InteropServices.WindowsRuntime": "4.3.0", + "System.Threading.Tasks.Extensions": "4.5.4" + } + }, + "System.Reflection.Metadata": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "5NecZgXktdGg34rh1OenY1rFNDCI8xSjFr+Z4OU4cU06AQHUdRnIIEeWENu3Wl4YowbzkymAIMvi3WyK9U53pQ==", + "dependencies": { + "System.Collections.Immutable": "5.0.0" + } + }, + "System.Reflection.TypeExtensions": { + "type": "Transitive", + "resolved": "4.7.0", + "contentHash": "VybpaOQQhqE6siHppMktjfGBw1GCwvCqiufqmP8F1nj7fTUNtW35LOEt3UZTEsECfo+ELAl/9o9nJx3U91i7vA==" + }, + "System.Runtime": { + "type": "Transitive", + "resolved": "4.3.0", + "contentHash": "JufQi0vPQ0xGnAczR13AUFglDyVYt4Kqnz1AZaiKZ5+GICq0/1MH/mO/eAJHt/mHW1zjKBJd7kV26SrxddAhiw==", + "dependencies": { + "Microsoft.NETCore.Platforms": "1.1.0", + "Microsoft.NETCore.Targets": "1.1.0" + } + }, + "System.Runtime.CompilerServices.Unsafe": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "/iUeP3tq1S0XdNNoMz5C9twLSrM/TH+qElHkXWaPvuNOt+99G75NrV0OS2EqHx5wMN7popYjpc8oTjC1y16DLg==" + }, + "System.Runtime.InteropServices.WindowsRuntime": { + "type": "Transitive", + "resolved": "4.3.0", + "contentHash": "J4GUi3xZQLUBasNwZnjrffN8i5wpHrBtZoLG+OhRyGo/+YunMRWWtwoMDlUAIdmX0uRfpHIBDSV6zyr3yf00TA==", + "dependencies": { + "System.Runtime": "4.3.0" + } + }, + "System.Text.Encodings.Web": { + "type": "Transitive", + "resolved": "5.0.1", + "contentHash": "KmJ+CJXizDofbq6mpqDoRRLcxgOd2z9X3XoFNULSbvbqVRZkFX3istvr+MUjL6Zw1RT+RNdoI4GYidIINtgvqQ==", + "dependencies": { + "System.Buffers": "4.5.1", + "System.Memory": "4.5.4" + } + }, + "System.Text.Json": { + "type": "Transitive", + "resolved": "5.0.2", + "contentHash": "I47dVIGiV6SfAyppphxqupertT/5oZkYLDCX6vC3HpOI4ZLjyoKAreUoem2ie6G0RbRuFrlqz/PcTQjfb2DOfQ==", + "dependencies": { + "Microsoft.Bcl.AsyncInterfaces": "5.0.0", + "System.Buffers": "4.5.1", + "System.Memory": "4.5.4", + "System.Numerics.Vectors": "4.5.0", + "System.Runtime.CompilerServices.Unsafe": "5.0.0", + "System.Text.Encodings.Web": "5.0.1", + "System.Threading.Tasks.Extensions": "4.5.4" + } + }, + "System.Threading.Tasks.Extensions": { + "type": "Transitive", + "resolved": "4.5.4", + "contentHash": "zteT+G8xuGu6mS+mzDzYXbzS7rd3K6Fjb9RiZlYlJPam2/hU7JCBZBVEcywNuR+oZ1ncTvc/cq0faRr3P01OVg==", + "dependencies": { + "System.Runtime.CompilerServices.Unsafe": "4.5.3" + } + }, + "speckle.autofac": { + "type": "Project", + "dependencies": { + "Microsoft.Extensions.Logging.Abstractions": "[7.0.0, )", + "Speckle.Core": "[2.0.999-local, )" + } + }, + "Speckle.Core": { + "type": "Project", + "dependencies": { + "GraphQL.Client": "[6.0.0, )", + "Microsoft.CSharp": "[4.7.0, )", + "Microsoft.Data.Sqlite": "[7.0.5, )", + "Polly": "[7.2.3, )", + "Polly.Contrib.WaitAndRetry": "[1.1.1, )", + "Polly.Extensions.Http": "[3.0.0, )", + "Sentry": "[3.33.0, )", + "Sentry.Serilog": "[3.33.0, )", + "Serilog": "[2.12.0, )", + "Serilog.Enrichers.ClientInfo": "[1.3.0, )", + "Serilog.Exceptions": "[8.4.0, )", + "Serilog.Sinks.Console": "[4.1.0, )", + "Serilog.Sinks.Seq": "[5.2.2, )", + "SerilogTimings": "[3.0.1, )", + "Speckle.Newtonsoft.Json": "[13.0.2, )", + "System.DoubleNumerics": "[3.1.3, )" + } + } + } + } +} \ No newline at end of file diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/packages.lock.json b/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/packages.lock.json new file mode 100644 index 0000000000..326fdefd15 --- /dev/null +++ b/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/packages.lock.json @@ -0,0 +1,495 @@ +{ + "version": 1, + "dependencies": { + ".NETStandard,Version=v2.0": { + "Autofac": { + "type": "Direct", + "requested": "[5.2.0, )", + "resolved": "5.2.0", + "contentHash": "V8dBH0dsv75uDzl7Sw+HkhKDPUw2eXnlMjcSVMH+tLo2s67MpTKGyDj1pDcpR+IF2u4YRs0s3/x7R88YJzIWvg==", + "dependencies": { + "Microsoft.Bcl.AsyncInterfaces": "1.1.0" + } + }, + "NETStandard.Library": { + "type": "Direct", + "requested": "[2.0.3, )", + "resolved": "2.0.3", + "contentHash": "st47PosZSHrjECdjeIzZQbzivYBJFv6P2nv4cj2ypdI204DO+vZ7l5raGMiX4eXMJ53RfOIg+/s4DHVZ54Nu2A==", + "dependencies": { + "Microsoft.NETCore.Platforms": "1.1.0" + } + }, + "PolySharp": { + "type": "Direct", + "requested": "[1.14.1, )", + "resolved": "1.14.1", + "contentHash": "mOOmFYwad3MIOL14VCjj02LljyF1GNw1wP0YVlxtcPvqdxjGGMNdNJJxHptlry3MOd8b40Flm8RPOM8JOlN2sQ==" + }, + "Speckle.InterfaceGenerator": { + "type": "Direct", + "requested": "[0.9.5, )", + "resolved": "0.9.5", + "contentHash": "oU/L7pN1R7q8KkbrpQ3WJnHirPHqn+9DEA7asOcUiggV5dzVg1A/VYs7GOSusD24njxXh03tE3a2oTLOjt3cVg==" + }, + "GraphQL.Client": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "8yPNBbuVBpTptivyAlak4GZvbwbUcjeQTL4vN1HKHRuOykZ4r7l5fcLS6vpyPyLn0x8FsL31xbOIKyxbmR9rbA==", + "dependencies": { + "GraphQL.Client.Abstractions": "6.0.0", + "GraphQL.Client.Abstractions.Websocket": "6.0.0", + "System.Reactive": "5.0.0" + } + }, + "GraphQL.Client.Abstractions": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "h7uzWFORHZ+CCjwr/ThAyXMr0DPpzEANDa4Uo54wqCQ+j7qUKwqYTgOrb1W40sqbvNaZm9v/X7It31SUw0maHA==", + "dependencies": { + "GraphQL.Primitives": "6.0.0" + } + }, + "GraphQL.Client.Abstractions.Websocket": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "Nr9bPf8gIOvLuXpqEpqr9z9jslYFJOvd0feHth3/kPqeR3uMbjF5pjiwh4jxyMcxHdr8Pb6QiXkV3hsSyt0v7A==", + "dependencies": { + "GraphQL.Client.Abstractions": "6.0.0" + } + }, + "GraphQL.Primitives": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "yg72rrYDapfsIUrul7aF6wwNnTJBOFvuA9VdDTQpPa8AlAriHbufeXYLBcodKjfUdkCnaiggX1U/nEP08Zb5GA==" + }, + "Microsoft.AspNetCore.Http": { + "type": "Transitive", + "resolved": "2.1.1", + "contentHash": "pPDcCW8spnyibK3krpxrOpaFHf5fjV6k1Hsl6gfh77N/8gRYlLU7MOQDUnjpEwdlHmtxwJKQJNxZqVQOmJGRUw==", + "dependencies": { + "Microsoft.AspNetCore.Http.Abstractions": "2.1.1", + "Microsoft.AspNetCore.WebUtilities": "2.1.1", + "Microsoft.Extensions.ObjectPool": "2.1.1", + "Microsoft.Extensions.Options": "2.1.1", + "Microsoft.Net.Http.Headers": "2.1.1" + } + }, + "Microsoft.AspNetCore.Http.Abstractions": { + "type": "Transitive", + "resolved": "2.1.1", + "contentHash": "kQUEVOU4loc8CPSb2WoHFTESqwIa8Ik7ysCBfTwzHAd0moWovc9JQLmhDIHlYLjHbyexqZAlkq/FPRUZqokebw==", + "dependencies": { + "Microsoft.AspNetCore.Http.Features": "2.1.1", + "System.Text.Encodings.Web": "4.5.0" + } + }, + "Microsoft.AspNetCore.Http.Features": { + "type": "Transitive", + "resolved": "2.1.1", + "contentHash": "VklZ7hWgSvHBcDtwYYkdMdI/adlf7ebxTZ9kdzAhX+gUs5jSHE9mZlTamdgf9miSsxc1QjNazHXTDJdVPZKKTw==", + "dependencies": { + "Microsoft.Extensions.Primitives": "2.1.1" + } + }, + "Microsoft.AspNetCore.WebUtilities": { + "type": "Transitive", + "resolved": "2.1.1", + "contentHash": "PGKIZt4+412Z/XPoSjvYu/QIbTxcAQuEFNoA1Pw8a9mgmO0ZhNBmfaNyhgXFf7Rq62kP0tT/2WXpxdcQhkFUPA==", + "dependencies": { + "Microsoft.Net.Http.Headers": "2.1.1", + "System.Text.Encodings.Web": "4.5.0" + } + }, + "Microsoft.Bcl.AsyncInterfaces": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "W8DPQjkMScOMTtJbPwmPyj9c3zYSFGawDW3jwlBOOsnY+EzZFLgNQ/UMkK35JmkNOVPdCyPr2Tw7Vv9N+KA3ZQ==", + "dependencies": { + "System.Threading.Tasks.Extensions": "4.5.4" + } + }, + "Microsoft.CSharp": { + "type": "Transitive", + "resolved": "4.7.0", + "contentHash": "pTj+D3uJWyN3My70i2Hqo+OXixq3Os2D1nJ2x92FFo6sk8fYS1m1WLNTs0Dc1uPaViH0YvEEwvzddQ7y4rhXmA==" + }, + "Microsoft.Data.Sqlite": { + "type": "Transitive", + "resolved": "7.0.5", + "contentHash": "KGxbPeWsQMnmQy43DSBxAFtHz3l2JX8EWBSGUCvT3CuZ8KsuzbkqMIJMDOxWtG8eZSoCDI04aiVQjWuuV8HmSw==", + "dependencies": { + "Microsoft.Data.Sqlite.Core": "7.0.5", + "SQLitePCLRaw.bundle_e_sqlite3": "2.1.4" + } + }, + "Microsoft.Data.Sqlite.Core": { + "type": "Transitive", + "resolved": "7.0.5", + "contentHash": "FTerRmQPqHrCrnoUzhBu+E+1DNGwyrAMLqHkAqOOOu5pGfyMOj8qQUBxI/gDtWtG11p49UxSfWmBzRNlwZqfUg==", + "dependencies": { + "SQLitePCLRaw.core": "2.1.4" + } + }, + "Microsoft.Extensions.DependencyInjection.Abstractions": { + "type": "Transitive", + "resolved": "2.1.1", + "contentHash": "MgYpU5cwZohUMKKg3sbPhvGG+eAZ/59E9UwPwlrUkyXU+PGzqwZg9yyQNjhxuAWmoNoFReoemeCku50prYSGzA==" + }, + "Microsoft.Extensions.Logging.Abstractions": { + "type": "Transitive", + "resolved": "7.0.0", + "contentHash": "kmn78+LPVMOWeITUjIlfxUPDsI0R6G0RkeAMBmQxAJ7vBJn4q2dTva7pWi65ceN5vPGjJ9q/Uae2WKgvfktJAw==", + "dependencies": { + "System.Buffers": "4.5.1", + "System.Memory": "4.5.5" + } + }, + "Microsoft.Extensions.ObjectPool": { + "type": "Transitive", + "resolved": "2.1.1", + "contentHash": "SErON45qh4ogDp6lr6UvVmFYW0FERihW+IQ+2JyFv1PUyWktcJytFaWH5zarufJvZwhci7Rf1IyGXr9pVEadTw==" + }, + "Microsoft.Extensions.Options": { + "type": "Transitive", + "resolved": "2.1.1", + "contentHash": "V7lXCU78lAbzaulCGFKojcCyG8RTJicEbiBkPJjFqiqXwndEBBIehdXRMWEVU3UtzQ1yDvphiWUL9th6/4gJ7w==", + "dependencies": { + "Microsoft.Extensions.DependencyInjection.Abstractions": "2.1.1", + "Microsoft.Extensions.Primitives": "2.1.1" + } + }, + "Microsoft.Extensions.Primitives": { + "type": "Transitive", + "resolved": "2.1.1", + "contentHash": "scJ1GZNIxMmjpENh0UZ8XCQ6vzr/LzeF9WvEA51Ix2OQGAs9WPgPu8ABVUdvpKPLuor/t05gm6menJK3PwqOXg==", + "dependencies": { + "System.Memory": "4.5.1", + "System.Runtime.CompilerServices.Unsafe": "4.5.1" + } + }, + "Microsoft.Net.Http.Headers": { + "type": "Transitive", + "resolved": "2.1.1", + "contentHash": "lPNIphl8b2EuhOE9dMH6EZDmu7pS882O+HMi5BJNsigxHaWlBrYxZHFZgE18cyaPp6SSZcTkKkuzfjV/RRQKlA==", + "dependencies": { + "Microsoft.Extensions.Primitives": "2.1.1", + "System.Buffers": "4.5.0" + } + }, + "Microsoft.NETCore.Platforms": { + "type": "Transitive", + "resolved": "1.1.0", + "contentHash": "kz0PEW2lhqygehI/d6XsPCQzD7ff7gUJaVGPVETX611eadGsA3A877GdSlU0LRVMCTH/+P3o2iDTak+S08V2+A==" + }, + "Microsoft.NETCore.Targets": { + "type": "Transitive", + "resolved": "1.1.0", + "contentHash": "aOZA3BWfz9RXjpzt0sRJJMjAscAUm3Hoa4UWAfceV9UTYxgwZ1lZt5nO2myFf+/jetYQo4uTP7zS8sJY67BBxg==" + }, + "Polly": { + "type": "Transitive", + "resolved": "7.2.3", + "contentHash": "DeCY0OFbNdNxsjntr1gTXHJ5pKUwYzp04Er2LLeN3g6pWhffsGuKVfMBLe1lw7x76HrPkLxKEFxBlpRxS2nDEQ==" + }, + "Polly.Contrib.WaitAndRetry": { + "type": "Transitive", + "resolved": "1.1.1", + "contentHash": "1MUQLiSo4KDkQe6nzQRhIU05lm9jlexX5BVsbuw0SL82ynZ+GzAHQxJVDPVBboxV37Po3SG077aX8DuSy8TkaA==" + }, + "Polly.Extensions.Http": { + "type": "Transitive", + "resolved": "3.0.0", + "contentHash": "drrG+hB3pYFY7w1c3BD+lSGYvH2oIclH8GRSehgfyP5kjnFnHKQuuBhuHLv+PWyFuaTDyk/vfRpnxOzd11+J8g==", + "dependencies": { + "Polly": "7.1.0" + } + }, + "Sentry": { + "type": "Transitive", + "resolved": "3.33.0", + "contentHash": "8vbD2o6IR2wrRrkSiRbnodWGWUOqIlwYtzpjvPNOb5raJdOf+zxMwfS8f6nx9bmrTTfDj7KrCB8C/5OuicAc8A==", + "dependencies": { + "System.Reflection.Metadata": "5.0.0", + "System.Text.Json": "5.0.2" + } + }, + "Sentry.Serilog": { + "type": "Transitive", + "resolved": "3.33.0", + "contentHash": "V8BU7QGWg2qLYfNPqtuTBhC1opysny5l+Ifp6J6PhOeAxU0FssR7nYfbJVetrnLIoh2rd3DlJ6hHYYQosQYcUQ==", + "dependencies": { + "Sentry": "3.33.0", + "Serilog": "2.7.1" + } + }, + "Serilog": { + "type": "Transitive", + "resolved": "2.12.0", + "contentHash": "xaiJLIdu6rYMKfQMYUZgTy8YK7SMZjB4Yk50C/u//Z4OsvxkUfSPJy4nknfvwAC34yr13q7kcyh4grbwhSxyZg==" + }, + "Serilog.Enrichers.ClientInfo": { + "type": "Transitive", + "resolved": "1.3.0", + "contentHash": "mTc7PM+wC9Hr7LWSwqt5mmnlAr7RJs+eTb3PGPRhwdOackk95MkhUZognuxXEdlW19HAFNmEBTSBY5DfLwM8jQ==", + "dependencies": { + "Microsoft.AspNetCore.Http": "2.1.1", + "Serilog": "2.7.1" + } + }, + "Serilog.Exceptions": { + "type": "Transitive", + "resolved": "8.4.0", + "contentHash": "nc/+hUw3lsdo0zCj0KMIybAu7perMx79vu72w0za9Nsi6mWyNkGXxYxakAjWB7nEmYL6zdmhEQRB4oJ2ALUeug==", + "dependencies": { + "Serilog": "2.8.0", + "System.Reflection.TypeExtensions": "4.7.0" + } + }, + "Serilog.Formatting.Compact": { + "type": "Transitive", + "resolved": "1.1.0", + "contentHash": "pNroKVjo+rDqlxNG5PXkRLpfSCuDOBY0ri6jp9PLe505ljqwhwZz8ospy2vWhQlFu5GkIesh3FcDs4n7sWZODA==", + "dependencies": { + "Serilog": "2.8.0" + } + }, + "Serilog.Sinks.Console": { + "type": "Transitive", + "resolved": "4.1.0", + "contentHash": "K6N5q+5fetjnJPvCmkWOpJ/V8IEIoMIB1s86OzBrbxwTyHxdx3pmz4H+8+O/Dc/ftUX12DM1aynx/dDowkwzqg==", + "dependencies": { + "Serilog": "2.10.0" + } + }, + "Serilog.Sinks.File": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "uwV5hdhWPwUH1szhO8PJpFiahqXmzPzJT/sOijH/kFgUx+cyoDTMM8MHD0adw9+Iem6itoibbUXHYslzXsLEAg==", + "dependencies": { + "Serilog": "2.10.0" + } + }, + "Serilog.Sinks.PeriodicBatching": { + "type": "Transitive", + "resolved": "3.1.0", + "contentHash": "NDWR7m3PalVlGEq3rzoktrXikjFMLmpwF0HI4sowo8YDdU+gqPlTHlDQiOGxHfB0sTfjPA9JjA7ctKG9zqjGkw==", + "dependencies": { + "Serilog": "2.0.0" + } + }, + "Serilog.Sinks.Seq": { + "type": "Transitive", + "resolved": "5.2.2", + "contentHash": "1Csmo5ua7NKUe0yXUx+zsRefjAniPWcXFhUXxXG8pwo0iMiw2gjn9SOkgYnnxbgWqmlGv236w0N/dHc2v5XwMg==", + "dependencies": { + "Serilog": "2.12.0", + "Serilog.Formatting.Compact": "1.1.0", + "Serilog.Sinks.File": "5.0.0", + "Serilog.Sinks.PeriodicBatching": "3.1.0" + } + }, + "SerilogTimings": { + "type": "Transitive", + "resolved": "3.0.1", + "contentHash": "Zs28eTgszAMwpIrbBnWHBI50yuxL50p/dmAUWmy75+axdZYK/Sjm5/5m1N/CisR8acJUhTVcjPZrsB1P5iv0Uw==", + "dependencies": { + "Serilog": "2.10.0" + } + }, + "Speckle.Newtonsoft.Json": { + "type": "Transitive", + "resolved": "13.0.2", + "contentHash": "g1BejUZwax5PRfL6xHgLEK23sqHWOgOj9hE7RvfRRlN00AGt8GnPYt8HedSK7UB3HiRW8zCA9Pn0iiYxCK24BA==" + }, + "Speckle.Revit2023.Interfaces": { + "type": "Transitive", + "resolved": "0.1.1-preview.0.24", + "contentHash": "BSVpOUJc9g6ISrw8GxvtkglTlITpHEDYNOhxv1ZPbckBsI0yO36JiphhQV4q57ERqD9PpCozUJkVhlCaxWeS6A==" + }, + "SQLitePCLRaw.bundle_e_sqlite3": { + "type": "Transitive", + "resolved": "2.1.4", + "contentHash": "EWI1olKDjFEBMJu0+3wuxwziIAdWDVMYLhuZ3Qs84rrz+DHwD00RzWPZCa+bLnHCf3oJwuFZIRsHT5p236QXww==", + "dependencies": { + "SQLitePCLRaw.lib.e_sqlite3": "2.1.4", + "SQLitePCLRaw.provider.e_sqlite3": "2.1.4" + } + }, + "SQLitePCLRaw.core": { + "type": "Transitive", + "resolved": "2.1.4", + "contentHash": "inBjvSHo9UDKneGNzfUfDjK08JzlcIhn1+SP5Y3m6cgXpCxXKCJDy6Mka7LpgSV+UZmKSnC8rTwB0SQ0xKu5pA==", + "dependencies": { + "System.Memory": "4.5.3" + } + }, + "SQLitePCLRaw.lib.e_sqlite3": { + "type": "Transitive", + "resolved": "2.1.4", + "contentHash": "2C9Q9eX7CPLveJA0rIhf9RXAvu+7nWZu1A2MdG6SD/NOu26TakGgL1nsbc0JAspGijFOo3HoN79xrx8a368fBg==" + }, + "SQLitePCLRaw.provider.e_sqlite3": { + "type": "Transitive", + "resolved": "2.1.4", + "contentHash": "CSlb5dUp1FMIkez9Iv5EXzpeq7rHryVNqwJMWnpq87j9zWZexaEMdisDktMsnnrzKM6ahNrsTkjqNodTBPBxtQ==", + "dependencies": { + "SQLitePCLRaw.core": "2.1.4" + } + }, + "System.Buffers": { + "type": "Transitive", + "resolved": "4.5.1", + "contentHash": "Rw7ijyl1qqRS0YQD/WycNst8hUUMgrMH4FCn1nNm27M4VxchZ1js3fVjQaANHO5f3sN4isvP4a+Met9Y4YomAg==" + }, + "System.Collections.Immutable": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "FXkLXiK0sVVewcso0imKQoOxjoPAj42R8HtjjbSjVPAzwDfzoyoznWxgA3c38LDbN9SJux1xXoXYAhz98j7r2g==", + "dependencies": { + "System.Memory": "4.5.4" + } + }, + "System.DoubleNumerics": { + "type": "Transitive", + "resolved": "3.1.3", + "contentHash": "KRKEM/L3KBodjA9VOg3EifFVWUY6EOqaMB05UvPEDm7Zeby/kZW+4kdWUEPzW6xtkwf46p661L9NrbeeQhtLzw==", + "dependencies": { + "NETStandard.Library": "1.6.1" + } + }, + "System.Memory": { + "type": "Transitive", + "resolved": "4.5.5", + "contentHash": "XIWiDvKPXaTveaB7HVganDlOCRoj03l+jrwNvcge/t8vhGYKvqV+dMv6G4SAX2NoNmN0wZfVPTAlFwZcZvVOUw==", + "dependencies": { + "System.Buffers": "4.5.1", + "System.Numerics.Vectors": "4.4.0", + "System.Runtime.CompilerServices.Unsafe": "4.5.3" + } + }, + "System.Numerics.Vectors": { + "type": "Transitive", + "resolved": "4.5.0", + "contentHash": "QQTlPTl06J/iiDbJCiepZ4H//BVraReU4O4EoRw1U02H5TLUIT7xn3GnDp9AXPSlJUDyFs4uWjWafNX6WrAojQ==" + }, + "System.Reactive": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "erBZjkQHWL9jpasCE/0qKAryzVBJFxGHVBAvgRN1bzM0q2s1S4oYREEEL0Vb+1kA/6BKb5FjUZMp5VXmy+gzkQ==", + "dependencies": { + "System.Runtime.InteropServices.WindowsRuntime": "4.3.0", + "System.Threading.Tasks.Extensions": "4.5.4" + } + }, + "System.Reflection.Metadata": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "5NecZgXktdGg34rh1OenY1rFNDCI8xSjFr+Z4OU4cU06AQHUdRnIIEeWENu3Wl4YowbzkymAIMvi3WyK9U53pQ==", + "dependencies": { + "System.Collections.Immutable": "5.0.0" + } + }, + "System.Reflection.TypeExtensions": { + "type": "Transitive", + "resolved": "4.7.0", + "contentHash": "VybpaOQQhqE6siHppMktjfGBw1GCwvCqiufqmP8F1nj7fTUNtW35LOEt3UZTEsECfo+ELAl/9o9nJx3U91i7vA==" + }, + "System.Runtime": { + "type": "Transitive", + "resolved": "4.3.0", + "contentHash": "JufQi0vPQ0xGnAczR13AUFglDyVYt4Kqnz1AZaiKZ5+GICq0/1MH/mO/eAJHt/mHW1zjKBJd7kV26SrxddAhiw==", + "dependencies": { + "Microsoft.NETCore.Platforms": "1.1.0", + "Microsoft.NETCore.Targets": "1.1.0" + } + }, + "System.Runtime.CompilerServices.Unsafe": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "ZD9TMpsmYJLrxbbmdvhwt9YEgG5WntEnZ/d1eH8JBX9LBp+Ju8BSBhUGbZMNVHHomWo2KVImJhTDl2hIgw/6MA==" + }, + "System.Runtime.InteropServices.WindowsRuntime": { + "type": "Transitive", + "resolved": "4.3.0", + "contentHash": "J4GUi3xZQLUBasNwZnjrffN8i5wpHrBtZoLG+OhRyGo/+YunMRWWtwoMDlUAIdmX0uRfpHIBDSV6zyr3yf00TA==", + "dependencies": { + "System.Runtime": "4.3.0" + } + }, + "System.Text.Encodings.Web": { + "type": "Transitive", + "resolved": "5.0.1", + "contentHash": "KmJ+CJXizDofbq6mpqDoRRLcxgOd2z9X3XoFNULSbvbqVRZkFX3istvr+MUjL6Zw1RT+RNdoI4GYidIINtgvqQ==", + "dependencies": { + "System.Buffers": "4.5.1", + "System.Memory": "4.5.4" + } + }, + "System.Text.Json": { + "type": "Transitive", + "resolved": "5.0.2", + "contentHash": "I47dVIGiV6SfAyppphxqupertT/5oZkYLDCX6vC3HpOI4ZLjyoKAreUoem2ie6G0RbRuFrlqz/PcTQjfb2DOfQ==", + "dependencies": { + "Microsoft.Bcl.AsyncInterfaces": "5.0.0", + "System.Buffers": "4.5.1", + "System.Memory": "4.5.4", + "System.Numerics.Vectors": "4.5.0", + "System.Runtime.CompilerServices.Unsafe": "5.0.0", + "System.Text.Encodings.Web": "5.0.1", + "System.Threading.Tasks.Extensions": "4.5.4" + } + }, + "System.Threading.Tasks.Extensions": { + "type": "Transitive", + "resolved": "4.5.4", + "contentHash": "zteT+G8xuGu6mS+mzDzYXbzS7rd3K6Fjb9RiZlYlJPam2/hU7JCBZBVEcywNuR+oZ1ncTvc/cq0faRr3P01OVg==", + "dependencies": { + "System.Runtime.CompilerServices.Unsafe": "4.5.3" + } + }, + "speckle.autofac": { + "type": "Project", + "dependencies": { + "Microsoft.Extensions.Logging.Abstractions": "[7.0.0, )", + "Speckle.Core": "[2.0.999-local, )" + } + }, + "speckle.converters.common": { + "type": "Project", + "dependencies": { + "Speckle.Autofac": "[2.0.999-local, )", + "Speckle.Objects": "[2.0.999-local, )", + "Speckle.Revit2023.Interfaces": "[0.1.1-preview.0.24, )" + } + }, + "Speckle.Core": { + "type": "Project", + "dependencies": { + "GraphQL.Client": "[6.0.0, )", + "Microsoft.CSharp": "[4.7.0, )", + "Microsoft.Data.Sqlite": "[7.0.5, )", + "Polly": "[7.2.3, )", + "Polly.Contrib.WaitAndRetry": "[1.1.1, )", + "Polly.Extensions.Http": "[3.0.0, )", + "Sentry": "[3.33.0, )", + "Sentry.Serilog": "[3.33.0, )", + "Serilog": "[2.12.0, )", + "Serilog.Enrichers.ClientInfo": "[1.3.0, )", + "Serilog.Exceptions": "[8.4.0, )", + "Serilog.Sinks.Console": "[4.1.0, )", + "Serilog.Sinks.Seq": "[5.2.2, )", + "SerilogTimings": "[3.0.1, )", + "Speckle.Newtonsoft.Json": "[13.0.2, )", + "System.DoubleNumerics": "[3.1.3, )" + } + }, + "Speckle.Objects": { + "type": "Project", + "dependencies": { + "Speckle.Core": "[2.0.999-local, )" + } + } + } + } +} \ No newline at end of file diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common.Tests/packages.lock.json b/DUI3-DX/Sdk/Speckle.Converters.Common.Tests/packages.lock.json index 745cd3ba1e..c0e6585eb9 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common.Tests/packages.lock.json +++ b/DUI3-DX/Sdk/Speckle.Converters.Common.Tests/packages.lock.json @@ -200,14 +200,6 @@ "Serilog": "2.4.0" } }, - "Serilog.Enrichers.GlobalLogContext": { - "type": "Transitive", - "resolved": "3.0.0", - "contentHash": "IIZcj5mAUVhIl/NTA+YI2KC+sPDzcwvs0ZMHH42jsPfl1a4LVX7ohVpw5UK+e3GxuV3Nv239Il5oM2peUIl44g==", - "dependencies": { - "Serilog": "2.12.0" - } - }, "Serilog.Exceptions": { "type": "Transitive", "resolved": "8.4.0", @@ -438,7 +430,6 @@ "Sentry.Serilog": "[3.33.0, )", "Serilog": "[2.12.0, )", "Serilog.Enrichers.ClientInfo": "[1.3.0, )", - "Serilog.Enrichers.GlobalLogContext": "[3.0.0, )", "Serilog.Exceptions": "[8.4.0, )", "Serilog.Sinks.Console": "[4.1.0, )", "Serilog.Sinks.Seq": "[5.2.2, )", diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common/packages.lock.json b/DUI3-DX/Sdk/Speckle.Converters.Common/packages.lock.json new file mode 100644 index 0000000000..c3d43a1f8a --- /dev/null +++ b/DUI3-DX/Sdk/Speckle.Converters.Common/packages.lock.json @@ -0,0 +1,479 @@ +{ + "version": 1, + "dependencies": { + ".NETStandard,Version=v2.0": { + "NETStandard.Library": { + "type": "Direct", + "requested": "[2.0.3, )", + "resolved": "2.0.3", + "contentHash": "st47PosZSHrjECdjeIzZQbzivYBJFv6P2nv4cj2ypdI204DO+vZ7l5raGMiX4eXMJ53RfOIg+/s4DHVZ54Nu2A==", + "dependencies": { + "Microsoft.NETCore.Platforms": "1.1.0" + } + }, + "PolySharp": { + "type": "Direct", + "requested": "[1.14.1, )", + "resolved": "1.14.1", + "contentHash": "mOOmFYwad3MIOL14VCjj02LljyF1GNw1wP0YVlxtcPvqdxjGGMNdNJJxHptlry3MOd8b40Flm8RPOM8JOlN2sQ==" + }, + "Speckle.InterfaceGenerator": { + "type": "Direct", + "requested": "[0.9.5, )", + "resolved": "0.9.5", + "contentHash": "oU/L7pN1R7q8KkbrpQ3WJnHirPHqn+9DEA7asOcUiggV5dzVg1A/VYs7GOSusD24njxXh03tE3a2oTLOjt3cVg==" + }, + "Speckle.Revit2023.Interfaces": { + "type": "Direct", + "requested": "[0.1.1-preview.0.24, )", + "resolved": "0.1.1-preview.0.24", + "contentHash": "BSVpOUJc9g6ISrw8GxvtkglTlITpHEDYNOhxv1ZPbckBsI0yO36JiphhQV4q57ERqD9PpCozUJkVhlCaxWeS6A==" + }, + "GraphQL.Client": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "8yPNBbuVBpTptivyAlak4GZvbwbUcjeQTL4vN1HKHRuOykZ4r7l5fcLS6vpyPyLn0x8FsL31xbOIKyxbmR9rbA==", + "dependencies": { + "GraphQL.Client.Abstractions": "6.0.0", + "GraphQL.Client.Abstractions.Websocket": "6.0.0", + "System.Reactive": "5.0.0" + } + }, + "GraphQL.Client.Abstractions": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "h7uzWFORHZ+CCjwr/ThAyXMr0DPpzEANDa4Uo54wqCQ+j7qUKwqYTgOrb1W40sqbvNaZm9v/X7It31SUw0maHA==", + "dependencies": { + "GraphQL.Primitives": "6.0.0" + } + }, + "GraphQL.Client.Abstractions.Websocket": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "Nr9bPf8gIOvLuXpqEpqr9z9jslYFJOvd0feHth3/kPqeR3uMbjF5pjiwh4jxyMcxHdr8Pb6QiXkV3hsSyt0v7A==", + "dependencies": { + "GraphQL.Client.Abstractions": "6.0.0" + } + }, + "GraphQL.Primitives": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "yg72rrYDapfsIUrul7aF6wwNnTJBOFvuA9VdDTQpPa8AlAriHbufeXYLBcodKjfUdkCnaiggX1U/nEP08Zb5GA==" + }, + "Microsoft.AspNetCore.Http": { + "type": "Transitive", + "resolved": "2.1.1", + "contentHash": "pPDcCW8spnyibK3krpxrOpaFHf5fjV6k1Hsl6gfh77N/8gRYlLU7MOQDUnjpEwdlHmtxwJKQJNxZqVQOmJGRUw==", + "dependencies": { + "Microsoft.AspNetCore.Http.Abstractions": "2.1.1", + "Microsoft.AspNetCore.WebUtilities": "2.1.1", + "Microsoft.Extensions.ObjectPool": "2.1.1", + "Microsoft.Extensions.Options": "2.1.1", + "Microsoft.Net.Http.Headers": "2.1.1" + } + }, + "Microsoft.AspNetCore.Http.Abstractions": { + "type": "Transitive", + "resolved": "2.1.1", + "contentHash": "kQUEVOU4loc8CPSb2WoHFTESqwIa8Ik7ysCBfTwzHAd0moWovc9JQLmhDIHlYLjHbyexqZAlkq/FPRUZqokebw==", + "dependencies": { + "Microsoft.AspNetCore.Http.Features": "2.1.1", + "System.Text.Encodings.Web": "4.5.0" + } + }, + "Microsoft.AspNetCore.Http.Features": { + "type": "Transitive", + "resolved": "2.1.1", + "contentHash": "VklZ7hWgSvHBcDtwYYkdMdI/adlf7ebxTZ9kdzAhX+gUs5jSHE9mZlTamdgf9miSsxc1QjNazHXTDJdVPZKKTw==", + "dependencies": { + "Microsoft.Extensions.Primitives": "2.1.1" + } + }, + "Microsoft.AspNetCore.WebUtilities": { + "type": "Transitive", + "resolved": "2.1.1", + "contentHash": "PGKIZt4+412Z/XPoSjvYu/QIbTxcAQuEFNoA1Pw8a9mgmO0ZhNBmfaNyhgXFf7Rq62kP0tT/2WXpxdcQhkFUPA==", + "dependencies": { + "Microsoft.Net.Http.Headers": "2.1.1", + "System.Text.Encodings.Web": "4.5.0" + } + }, + "Microsoft.Bcl.AsyncInterfaces": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "W8DPQjkMScOMTtJbPwmPyj9c3zYSFGawDW3jwlBOOsnY+EzZFLgNQ/UMkK35JmkNOVPdCyPr2Tw7Vv9N+KA3ZQ==", + "dependencies": { + "System.Threading.Tasks.Extensions": "4.5.4" + } + }, + "Microsoft.CSharp": { + "type": "Transitive", + "resolved": "4.7.0", + "contentHash": "pTj+D3uJWyN3My70i2Hqo+OXixq3Os2D1nJ2x92FFo6sk8fYS1m1WLNTs0Dc1uPaViH0YvEEwvzddQ7y4rhXmA==" + }, + "Microsoft.Data.Sqlite": { + "type": "Transitive", + "resolved": "7.0.5", + "contentHash": "KGxbPeWsQMnmQy43DSBxAFtHz3l2JX8EWBSGUCvT3CuZ8KsuzbkqMIJMDOxWtG8eZSoCDI04aiVQjWuuV8HmSw==", + "dependencies": { + "Microsoft.Data.Sqlite.Core": "7.0.5", + "SQLitePCLRaw.bundle_e_sqlite3": "2.1.4" + } + }, + "Microsoft.Data.Sqlite.Core": { + "type": "Transitive", + "resolved": "7.0.5", + "contentHash": "FTerRmQPqHrCrnoUzhBu+E+1DNGwyrAMLqHkAqOOOu5pGfyMOj8qQUBxI/gDtWtG11p49UxSfWmBzRNlwZqfUg==", + "dependencies": { + "SQLitePCLRaw.core": "2.1.4" + } + }, + "Microsoft.Extensions.DependencyInjection.Abstractions": { + "type": "Transitive", + "resolved": "2.1.1", + "contentHash": "MgYpU5cwZohUMKKg3sbPhvGG+eAZ/59E9UwPwlrUkyXU+PGzqwZg9yyQNjhxuAWmoNoFReoemeCku50prYSGzA==" + }, + "Microsoft.Extensions.Logging.Abstractions": { + "type": "Transitive", + "resolved": "7.0.0", + "contentHash": "kmn78+LPVMOWeITUjIlfxUPDsI0R6G0RkeAMBmQxAJ7vBJn4q2dTva7pWi65ceN5vPGjJ9q/Uae2WKgvfktJAw==", + "dependencies": { + "System.Buffers": "4.5.1", + "System.Memory": "4.5.5" + } + }, + "Microsoft.Extensions.ObjectPool": { + "type": "Transitive", + "resolved": "2.1.1", + "contentHash": "SErON45qh4ogDp6lr6UvVmFYW0FERihW+IQ+2JyFv1PUyWktcJytFaWH5zarufJvZwhci7Rf1IyGXr9pVEadTw==" + }, + "Microsoft.Extensions.Options": { + "type": "Transitive", + "resolved": "2.1.1", + "contentHash": "V7lXCU78lAbzaulCGFKojcCyG8RTJicEbiBkPJjFqiqXwndEBBIehdXRMWEVU3UtzQ1yDvphiWUL9th6/4gJ7w==", + "dependencies": { + "Microsoft.Extensions.DependencyInjection.Abstractions": "2.1.1", + "Microsoft.Extensions.Primitives": "2.1.1" + } + }, + "Microsoft.Extensions.Primitives": { + "type": "Transitive", + "resolved": "2.1.1", + "contentHash": "scJ1GZNIxMmjpENh0UZ8XCQ6vzr/LzeF9WvEA51Ix2OQGAs9WPgPu8ABVUdvpKPLuor/t05gm6menJK3PwqOXg==", + "dependencies": { + "System.Memory": "4.5.1", + "System.Runtime.CompilerServices.Unsafe": "4.5.1" + } + }, + "Microsoft.Net.Http.Headers": { + "type": "Transitive", + "resolved": "2.1.1", + "contentHash": "lPNIphl8b2EuhOE9dMH6EZDmu7pS882O+HMi5BJNsigxHaWlBrYxZHFZgE18cyaPp6SSZcTkKkuzfjV/RRQKlA==", + "dependencies": { + "Microsoft.Extensions.Primitives": "2.1.1", + "System.Buffers": "4.5.0" + } + }, + "Microsoft.NETCore.Platforms": { + "type": "Transitive", + "resolved": "1.1.0", + "contentHash": "kz0PEW2lhqygehI/d6XsPCQzD7ff7gUJaVGPVETX611eadGsA3A877GdSlU0LRVMCTH/+P3o2iDTak+S08V2+A==" + }, + "Microsoft.NETCore.Targets": { + "type": "Transitive", + "resolved": "1.1.0", + "contentHash": "aOZA3BWfz9RXjpzt0sRJJMjAscAUm3Hoa4UWAfceV9UTYxgwZ1lZt5nO2myFf+/jetYQo4uTP7zS8sJY67BBxg==" + }, + "Polly": { + "type": "Transitive", + "resolved": "7.2.3", + "contentHash": "DeCY0OFbNdNxsjntr1gTXHJ5pKUwYzp04Er2LLeN3g6pWhffsGuKVfMBLe1lw7x76HrPkLxKEFxBlpRxS2nDEQ==" + }, + "Polly.Contrib.WaitAndRetry": { + "type": "Transitive", + "resolved": "1.1.1", + "contentHash": "1MUQLiSo4KDkQe6nzQRhIU05lm9jlexX5BVsbuw0SL82ynZ+GzAHQxJVDPVBboxV37Po3SG077aX8DuSy8TkaA==" + }, + "Polly.Extensions.Http": { + "type": "Transitive", + "resolved": "3.0.0", + "contentHash": "drrG+hB3pYFY7w1c3BD+lSGYvH2oIclH8GRSehgfyP5kjnFnHKQuuBhuHLv+PWyFuaTDyk/vfRpnxOzd11+J8g==", + "dependencies": { + "Polly": "7.1.0" + } + }, + "Sentry": { + "type": "Transitive", + "resolved": "3.33.0", + "contentHash": "8vbD2o6IR2wrRrkSiRbnodWGWUOqIlwYtzpjvPNOb5raJdOf+zxMwfS8f6nx9bmrTTfDj7KrCB8C/5OuicAc8A==", + "dependencies": { + "System.Reflection.Metadata": "5.0.0", + "System.Text.Json": "5.0.2" + } + }, + "Sentry.Serilog": { + "type": "Transitive", + "resolved": "3.33.0", + "contentHash": "V8BU7QGWg2qLYfNPqtuTBhC1opysny5l+Ifp6J6PhOeAxU0FssR7nYfbJVetrnLIoh2rd3DlJ6hHYYQosQYcUQ==", + "dependencies": { + "Sentry": "3.33.0", + "Serilog": "2.7.1" + } + }, + "Serilog": { + "type": "Transitive", + "resolved": "2.12.0", + "contentHash": "xaiJLIdu6rYMKfQMYUZgTy8YK7SMZjB4Yk50C/u//Z4OsvxkUfSPJy4nknfvwAC34yr13q7kcyh4grbwhSxyZg==" + }, + "Serilog.Enrichers.ClientInfo": { + "type": "Transitive", + "resolved": "1.3.0", + "contentHash": "mTc7PM+wC9Hr7LWSwqt5mmnlAr7RJs+eTb3PGPRhwdOackk95MkhUZognuxXEdlW19HAFNmEBTSBY5DfLwM8jQ==", + "dependencies": { + "Microsoft.AspNetCore.Http": "2.1.1", + "Serilog": "2.7.1" + } + }, + "Serilog.Exceptions": { + "type": "Transitive", + "resolved": "8.4.0", + "contentHash": "nc/+hUw3lsdo0zCj0KMIybAu7perMx79vu72w0za9Nsi6mWyNkGXxYxakAjWB7nEmYL6zdmhEQRB4oJ2ALUeug==", + "dependencies": { + "Serilog": "2.8.0", + "System.Reflection.TypeExtensions": "4.7.0" + } + }, + "Serilog.Formatting.Compact": { + "type": "Transitive", + "resolved": "1.1.0", + "contentHash": "pNroKVjo+rDqlxNG5PXkRLpfSCuDOBY0ri6jp9PLe505ljqwhwZz8ospy2vWhQlFu5GkIesh3FcDs4n7sWZODA==", + "dependencies": { + "Serilog": "2.8.0" + } + }, + "Serilog.Sinks.Console": { + "type": "Transitive", + "resolved": "4.1.0", + "contentHash": "K6N5q+5fetjnJPvCmkWOpJ/V8IEIoMIB1s86OzBrbxwTyHxdx3pmz4H+8+O/Dc/ftUX12DM1aynx/dDowkwzqg==", + "dependencies": { + "Serilog": "2.10.0" + } + }, + "Serilog.Sinks.File": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "uwV5hdhWPwUH1szhO8PJpFiahqXmzPzJT/sOijH/kFgUx+cyoDTMM8MHD0adw9+Iem6itoibbUXHYslzXsLEAg==", + "dependencies": { + "Serilog": "2.10.0" + } + }, + "Serilog.Sinks.PeriodicBatching": { + "type": "Transitive", + "resolved": "3.1.0", + "contentHash": "NDWR7m3PalVlGEq3rzoktrXikjFMLmpwF0HI4sowo8YDdU+gqPlTHlDQiOGxHfB0sTfjPA9JjA7ctKG9zqjGkw==", + "dependencies": { + "Serilog": "2.0.0" + } + }, + "Serilog.Sinks.Seq": { + "type": "Transitive", + "resolved": "5.2.2", + "contentHash": "1Csmo5ua7NKUe0yXUx+zsRefjAniPWcXFhUXxXG8pwo0iMiw2gjn9SOkgYnnxbgWqmlGv236w0N/dHc2v5XwMg==", + "dependencies": { + "Serilog": "2.12.0", + "Serilog.Formatting.Compact": "1.1.0", + "Serilog.Sinks.File": "5.0.0", + "Serilog.Sinks.PeriodicBatching": "3.1.0" + } + }, + "SerilogTimings": { + "type": "Transitive", + "resolved": "3.0.1", + "contentHash": "Zs28eTgszAMwpIrbBnWHBI50yuxL50p/dmAUWmy75+axdZYK/Sjm5/5m1N/CisR8acJUhTVcjPZrsB1P5iv0Uw==", + "dependencies": { + "Serilog": "2.10.0" + } + }, + "Speckle.Newtonsoft.Json": { + "type": "Transitive", + "resolved": "13.0.2", + "contentHash": "g1BejUZwax5PRfL6xHgLEK23sqHWOgOj9hE7RvfRRlN00AGt8GnPYt8HedSK7UB3HiRW8zCA9Pn0iiYxCK24BA==" + }, + "SQLitePCLRaw.bundle_e_sqlite3": { + "type": "Transitive", + "resolved": "2.1.4", + "contentHash": "EWI1olKDjFEBMJu0+3wuxwziIAdWDVMYLhuZ3Qs84rrz+DHwD00RzWPZCa+bLnHCf3oJwuFZIRsHT5p236QXww==", + "dependencies": { + "SQLitePCLRaw.lib.e_sqlite3": "2.1.4", + "SQLitePCLRaw.provider.e_sqlite3": "2.1.4" + } + }, + "SQLitePCLRaw.core": { + "type": "Transitive", + "resolved": "2.1.4", + "contentHash": "inBjvSHo9UDKneGNzfUfDjK08JzlcIhn1+SP5Y3m6cgXpCxXKCJDy6Mka7LpgSV+UZmKSnC8rTwB0SQ0xKu5pA==", + "dependencies": { + "System.Memory": "4.5.3" + } + }, + "SQLitePCLRaw.lib.e_sqlite3": { + "type": "Transitive", + "resolved": "2.1.4", + "contentHash": "2C9Q9eX7CPLveJA0rIhf9RXAvu+7nWZu1A2MdG6SD/NOu26TakGgL1nsbc0JAspGijFOo3HoN79xrx8a368fBg==" + }, + "SQLitePCLRaw.provider.e_sqlite3": { + "type": "Transitive", + "resolved": "2.1.4", + "contentHash": "CSlb5dUp1FMIkez9Iv5EXzpeq7rHryVNqwJMWnpq87j9zWZexaEMdisDktMsnnrzKM6ahNrsTkjqNodTBPBxtQ==", + "dependencies": { + "SQLitePCLRaw.core": "2.1.4" + } + }, + "System.Buffers": { + "type": "Transitive", + "resolved": "4.5.1", + "contentHash": "Rw7ijyl1qqRS0YQD/WycNst8hUUMgrMH4FCn1nNm27M4VxchZ1js3fVjQaANHO5f3sN4isvP4a+Met9Y4YomAg==" + }, + "System.Collections.Immutable": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "FXkLXiK0sVVewcso0imKQoOxjoPAj42R8HtjjbSjVPAzwDfzoyoznWxgA3c38LDbN9SJux1xXoXYAhz98j7r2g==", + "dependencies": { + "System.Memory": "4.5.4" + } + }, + "System.DoubleNumerics": { + "type": "Transitive", + "resolved": "3.1.3", + "contentHash": "KRKEM/L3KBodjA9VOg3EifFVWUY6EOqaMB05UvPEDm7Zeby/kZW+4kdWUEPzW6xtkwf46p661L9NrbeeQhtLzw==", + "dependencies": { + "NETStandard.Library": "1.6.1" + } + }, + "System.Memory": { + "type": "Transitive", + "resolved": "4.5.5", + "contentHash": "XIWiDvKPXaTveaB7HVganDlOCRoj03l+jrwNvcge/t8vhGYKvqV+dMv6G4SAX2NoNmN0wZfVPTAlFwZcZvVOUw==", + "dependencies": { + "System.Buffers": "4.5.1", + "System.Numerics.Vectors": "4.4.0", + "System.Runtime.CompilerServices.Unsafe": "4.5.3" + } + }, + "System.Numerics.Vectors": { + "type": "Transitive", + "resolved": "4.5.0", + "contentHash": "QQTlPTl06J/iiDbJCiepZ4H//BVraReU4O4EoRw1U02H5TLUIT7xn3GnDp9AXPSlJUDyFs4uWjWafNX6WrAojQ==" + }, + "System.Reactive": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "erBZjkQHWL9jpasCE/0qKAryzVBJFxGHVBAvgRN1bzM0q2s1S4oYREEEL0Vb+1kA/6BKb5FjUZMp5VXmy+gzkQ==", + "dependencies": { + "System.Runtime.InteropServices.WindowsRuntime": "4.3.0", + "System.Threading.Tasks.Extensions": "4.5.4" + } + }, + "System.Reflection.Metadata": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "5NecZgXktdGg34rh1OenY1rFNDCI8xSjFr+Z4OU4cU06AQHUdRnIIEeWENu3Wl4YowbzkymAIMvi3WyK9U53pQ==", + "dependencies": { + "System.Collections.Immutable": "5.0.0" + } + }, + "System.Reflection.TypeExtensions": { + "type": "Transitive", + "resolved": "4.7.0", + "contentHash": "VybpaOQQhqE6siHppMktjfGBw1GCwvCqiufqmP8F1nj7fTUNtW35LOEt3UZTEsECfo+ELAl/9o9nJx3U91i7vA==" + }, + "System.Runtime": { + "type": "Transitive", + "resolved": "4.3.0", + "contentHash": "JufQi0vPQ0xGnAczR13AUFglDyVYt4Kqnz1AZaiKZ5+GICq0/1MH/mO/eAJHt/mHW1zjKBJd7kV26SrxddAhiw==", + "dependencies": { + "Microsoft.NETCore.Platforms": "1.1.0", + "Microsoft.NETCore.Targets": "1.1.0" + } + }, + "System.Runtime.CompilerServices.Unsafe": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "ZD9TMpsmYJLrxbbmdvhwt9YEgG5WntEnZ/d1eH8JBX9LBp+Ju8BSBhUGbZMNVHHomWo2KVImJhTDl2hIgw/6MA==" + }, + "System.Runtime.InteropServices.WindowsRuntime": { + "type": "Transitive", + "resolved": "4.3.0", + "contentHash": "J4GUi3xZQLUBasNwZnjrffN8i5wpHrBtZoLG+OhRyGo/+YunMRWWtwoMDlUAIdmX0uRfpHIBDSV6zyr3yf00TA==", + "dependencies": { + "System.Runtime": "4.3.0" + } + }, + "System.Text.Encodings.Web": { + "type": "Transitive", + "resolved": "5.0.1", + "contentHash": "KmJ+CJXizDofbq6mpqDoRRLcxgOd2z9X3XoFNULSbvbqVRZkFX3istvr+MUjL6Zw1RT+RNdoI4GYidIINtgvqQ==", + "dependencies": { + "System.Buffers": "4.5.1", + "System.Memory": "4.5.4" + } + }, + "System.Text.Json": { + "type": "Transitive", + "resolved": "5.0.2", + "contentHash": "I47dVIGiV6SfAyppphxqupertT/5oZkYLDCX6vC3HpOI4ZLjyoKAreUoem2ie6G0RbRuFrlqz/PcTQjfb2DOfQ==", + "dependencies": { + "Microsoft.Bcl.AsyncInterfaces": "5.0.0", + "System.Buffers": "4.5.1", + "System.Memory": "4.5.4", + "System.Numerics.Vectors": "4.5.0", + "System.Runtime.CompilerServices.Unsafe": "5.0.0", + "System.Text.Encodings.Web": "5.0.1", + "System.Threading.Tasks.Extensions": "4.5.4" + } + }, + "System.Threading.Tasks.Extensions": { + "type": "Transitive", + "resolved": "4.5.4", + "contentHash": "zteT+G8xuGu6mS+mzDzYXbzS7rd3K6Fjb9RiZlYlJPam2/hU7JCBZBVEcywNuR+oZ1ncTvc/cq0faRr3P01OVg==", + "dependencies": { + "System.Runtime.CompilerServices.Unsafe": "4.5.3" + } + }, + "speckle.autofac": { + "type": "Project", + "dependencies": { + "Microsoft.Extensions.Logging.Abstractions": "[7.0.0, )", + "Speckle.Core": "[2.0.999-local, )" + } + }, + "Speckle.Core": { + "type": "Project", + "dependencies": { + "GraphQL.Client": "[6.0.0, )", + "Microsoft.CSharp": "[4.7.0, )", + "Microsoft.Data.Sqlite": "[7.0.5, )", + "Polly": "[7.2.3, )", + "Polly.Contrib.WaitAndRetry": "[1.1.1, )", + "Polly.Extensions.Http": "[3.0.0, )", + "Sentry": "[3.33.0, )", + "Sentry.Serilog": "[3.33.0, )", + "Serilog": "[2.12.0, )", + "Serilog.Enrichers.ClientInfo": "[1.3.0, )", + "Serilog.Exceptions": "[8.4.0, )", + "Serilog.Sinks.Console": "[4.1.0, )", + "Serilog.Sinks.Seq": "[5.2.2, )", + "SerilogTimings": "[3.0.1, )", + "Speckle.Newtonsoft.Json": "[13.0.2, )", + "System.DoubleNumerics": "[3.1.3, )" + } + }, + "Speckle.Objects": { + "type": "Project", + "dependencies": { + "Speckle.Core": "[2.0.999-local, )" + } + } + } + } +} \ No newline at end of file From a184d0cf4c42066aca4d57c493970c8a0c306695 Mon Sep 17 00:00:00 2001 From: KatKatKateryna <89912278+KatKatKateryna@users.noreply.github.com> Date: Thu, 20 Jun 2024 19:07:05 +0800 Subject: [PATCH 239/261] Agis speed improvement (#3527) * don't add already existing layers * speed up check for existing datasets * only search for existing Tables if Feature Class wasn't already deleted * don't subscribe to unnecessary MapMember events --- .../Bindings/ArcGISSendBinding.cs | 29 +++++++++++++++++-- .../Operations/Receive/HostObjectBuilder.cs | 3 ++ .../Utils/NonNativeFeaturesUtils.cs | 21 +++++++++++--- 3 files changed, 46 insertions(+), 7 deletions(-) diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISSendBinding.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISSendBinding.cs index 3773833114..ef05b43288 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISSendBinding.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISSendBinding.cs @@ -228,11 +228,34 @@ private void GetIdsForStandaloneTablesAddedEvent(StandaloneTableEventArgs args) private void GetIdsForMapMemberPropertiesChangedEvent(MapMemberPropertiesChangedEventArgs args) { - foreach (MapMember member in args.MapMembers) + // don't subscribe to all events (e.g. expanding group, changing visibility etc.) + bool validEvent = false; + foreach (var hint in args.EventHints) { - ChangedObjectIds.Add(member.URI); + if ( + hint == MapMemberEventHint.DataSource + || hint == MapMemberEventHint.DefinitionQuery + || hint == MapMemberEventHint.LabelClasses + || hint == MapMemberEventHint.LabelVisibility + || hint == MapMemberEventHint.Name + || hint == MapMemberEventHint.Renderer + || hint == MapMemberEventHint.SceneLayerType + || hint == MapMemberEventHint.URL + ) + { + validEvent = true; + break; + } + } + + if (validEvent) + { + foreach (MapMember member in args.MapMembers) + { + ChangedObjectIds.Add(member.URI); + } + RunExpirationChecks(false); } - RunExpirationChecks(false); } public List GetSendFilters() => _sendFilters; diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Receive/HostObjectBuilder.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Receive/HostObjectBuilder.cs index e3a3b6300e..3e22f2d85d 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Receive/HostObjectBuilder.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Receive/HostObjectBuilder.cs @@ -135,6 +135,9 @@ CancellationToken cancellationToken // add layer URI to bakedIds bakedObjectIds.Add(trackerItem.MappedLayerURI == null ? "" : trackerItem.MappedLayerURI); + // mark dataset as already created + bakedMapMembers[trackerItem.DatasetId] = mapMember; + // add report item AddResultsFromTracker(trackerItem, results); } diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/NonNativeFeaturesUtils.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/NonNativeFeaturesUtils.cs index 7f91dbbf32..0d458029bf 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/NonNativeFeaturesUtils.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/NonNativeFeaturesUtils.cs @@ -119,15 +119,28 @@ private void CreateDatasetInDatabase(string featureClassName, List List fields = new(); // _fieldsUtils.GetFieldsFromSpeckleLayer(target); // delete FeatureClass if already exists - foreach (FeatureClassDefinition fClassDefinition in geodatabase.GetDefinitions()) + try + { + FeatureClassDefinition fClassDefinition = geodatabase.GetDefinition(featureClassName); + FeatureClassDescription existingDescription = new(fClassDefinition); + schemaBuilder.Delete(existingDescription); + schemaBuilder.Build(); + } + catch (Exception ex) when (!ex.IsFatal()) //(GeodatabaseTableException) { - // will cause GeodatabaseCatalogDatasetException if doesn't exist in the database - if (fClassDefinition.GetName() == featureClassName) + // "The table was not found." + // delete Table if already exists + try { - FeatureClassDescription existingDescription = new(fClassDefinition); + TableDefinition fClassDefinition = geodatabase.GetDefinition(featureClassName); + TableDescription existingDescription = new(fClassDefinition); schemaBuilder.Delete(existingDescription); schemaBuilder.Build(); } + catch (Exception ex2) when (!ex2.IsFatal()) //(GeodatabaseTableException) + { + // "The table was not found.", do nothing + } } // Create FeatureClass From b58c348b831c8bdef6e2fa352c93964fa35a5e62 Mon Sep 17 00:00:00 2001 From: Claire Kuang Date: Thu, 20 Jun 2024 13:11:29 +0100 Subject: [PATCH 240/261] DUI3-173: adds send and receive cancellation on document switch (#3499) * adds send and receive cancellation on document switch * op in progress cancellation event with global toast notification * Update AutocadSendBinding.cs * disables document activation during send and receive operation * removes todo * reverts send to run on main thread --- .../Bindings/AutocadReceiveBinding.cs | 10 ++++++++++ .../Bindings/AutocadSendBinding.cs | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadReceiveBinding.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadReceiveBinding.cs index da2e5b34c0..2faf89f7ad 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadReceiveBinding.cs +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadReceiveBinding.cs @@ -51,6 +51,11 @@ public async Task Receive(string modelCardId) // Init cancellation token source -> Manager also cancel it if exist before CancellationTokenSource cts = _cancellationManager.InitCancellationTokenSource(modelCardId); + // Disable document activation (document creation and document switch) + // Not disabling results in DUI model card being out of sync with the active document + // The DocumentActivated event isn't usable probably because it is pushed to back of main thread queue + Application.DocumentManager.DocumentActivationEnabled = false; + // Receive host objects var operationResults = await unitOfWork.Service .Execute( @@ -72,6 +77,11 @@ public async Task Receive(string modelCardId) // SWALLOW -> UI handles it immediately, so we do not need to handle anything return; } + finally + { + // renable document activation + Application.DocumentManager.DocumentActivationEnabled = true; + } } private void OnSendOperationProgress(string modelCardId, string status, double? progress) diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadSendBinding.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadSendBinding.cs index 8ebb187279..4d580c6aed 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadSendBinding.cs +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadSendBinding.cs @@ -130,6 +130,11 @@ private async Task SendInternal(string modelCardId) // Init cancellation token source -> Manager also cancel it if exist before CancellationTokenSource cts = _cancellationManager.InitCancellationTokenSource(modelCardId); + // Disable document activation (document creation and document switch) + // Not disabling results in DUI model card being out of sync with the active document + // The DocumentActivated event isn't usable probably because it is pushed to back of main thread queue + Application.DocumentManager.DocumentActivationEnabled = false; + // Get elements to convert List autocadObjects = Application.DocumentManager.CurrentDocument.GetObjects( modelCard.SendFilter.NotNull().GetObjectIds() @@ -169,6 +174,11 @@ private async Task SendInternal(string modelCardId) { Commands.SetModelError(modelCardId, e); } + finally + { + // renable document activation + Application.DocumentManager.DocumentActivationEnabled = true; + } } private void OnSendOperationProgress(string modelCardId, string status, double? progress) From 2930bcf90c50f2c64138259e8482cc35b8888460 Mon Sep 17 00:00:00 2001 From: KatKatKateryna <89912278+KatKatKateryna@users.noreply.github.com> Date: Fri, 21 Jun 2024 18:45:54 +0800 Subject: [PATCH 241/261] D ui3 123 receiving non native attributes revit params gh attributes etc (#3526) * collect attributes as strings (Brep randomly fails) * pass function to get object attributes * update passed function; add traversal for Revit parameter wrapper Base * remove stackOverflowException * fix field path functions * don't add already existing layers * add Rhino userStrings; get only dynamic values from Objects.Geometry; prepare to get correct FieldType * some restructuring * speed up check for existing datasets * only use "parameters" Base obj, if the elements are actually RevitParameters * only search for existing Tables if Feature Class wasn't already deleted * get FieldType from actual values, default to String if needed * cast bool to string * receive only Typed primitive properties from non-native apps * typo * skip the properties for now * Revert "skip the properties for now" This reverts commit c6a103146d3200d65e09644ef074f22de8e8445e. * Revert "typo" This reverts commit 37f6b9a41b03c39bfee77d4fe3cb3a8ce932b646. * Revert "receive only Typed primitive properties from non-native apps" This reverts commit 9754ac58759eba077a12f3c77dee9b19f513f742. * cast to string * option for dealing with nullable types (#3528) * option for dealing with nullable types * fmt * remove unnecessary null check * default to null, if cast to string fails --------- Co-authored-by: Adam Hathcock --- .../Utils/ArcGISFieldUtils.cs | 225 ++++++++++++++++-- .../Utils/FeatureClassUtils.cs | 45 +++- .../Utils/GISAttributeFieldType.cs | 38 ++- .../Utils/IArcGISFieldUtils.cs | 9 +- .../Utils/IFeatureClassUtils.cs | 4 +- .../Utils/NonNativeFeaturesUtils.cs | 39 +-- 6 files changed, 306 insertions(+), 54 deletions(-) diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/ArcGISFieldUtils.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/ArcGISFieldUtils.cs index 1f98758611..aff09a3d2c 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/ArcGISFieldUtils.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/ArcGISFieldUtils.cs @@ -1,6 +1,8 @@ +using System.Collections; using ArcGIS.Core.Data; using ArcGIS.Core.Data.Exceptions; using Objects.GIS; +using Speckle.Core.Logging; using Speckle.Core.Models; using FieldDescription = ArcGIS.Core.Data.DDL.FieldDescription; @@ -16,38 +18,39 @@ public ArcGISFieldUtils(ICharacterCleaner characterCleaner) _characterCleaner = characterCleaner; } - public RowBuffer AssignFieldValuesToRow(RowBuffer rowBuffer, List fields, GisFeature feat) + public RowBuffer AssignFieldValuesToRow( + RowBuffer rowBuffer, + List fields, + Dictionary attributes + ) { foreach (FieldDescription field in fields) { // try to assign values to writeable fields - if (feat.attributes is not null) + if (attributes is not null) { string key = field.AliasName; // use Alias, as Name is simplified to alphanumeric FieldType fieldType = field.FieldType; - var value = feat.attributes[key]; - if (value is not null) + var value = attributes[key]; + + try { - // POC: get all values in a correct format - try - { - rowBuffer[key] = GISAttributeFieldType.SpeckleValueToNativeFieldType(fieldType, value); - } - catch (GeodatabaseFeatureException) - { - //'The value type is incompatible.' - // log error! - rowBuffer[key] = null; - } - catch (GeodatabaseFieldException) - { - // non-editable Field, do nothing - } + rowBuffer[key] = GISAttributeFieldType.SpeckleValueToNativeFieldType(fieldType, value); } - else + catch (GeodatabaseFeatureException) { + //'The value type is incompatible.' + // log error! rowBuffer[key] = null; } + catch (GeodatabaseFieldException) + { + // non-editable Field, do nothing + } + catch (GeodatabaseGeneralException) + { + // The index passed was not within the valid range. // unclear reason of the error + } } } return rowBuffer; @@ -88,4 +91,186 @@ public List GetFieldsFromSpeckleLayer(VectorLayer target) } return fields; } + + public List<(FieldDescription, Func)> CreateFieldsFromListOfBase(List target) + { + List<(FieldDescription, Func)> fieldsAndFunctions = new(); + List fieldAdded = new(); + + foreach (var baseObj in target) + { + // get all members by default, but only Dynamic ones from the basic geometry + Dictionary members = new(); + + // leave out until we decide which properties to support on Receive + /* + if (baseObj.speckle_type.StartsWith("Objects.Geometry")) + { + members = baseObj.GetMembers(DynamicBaseMemberType.Dynamic); + } + else + { + members = baseObj.GetMembers(DynamicBaseMemberType.All); + } + */ + + foreach (KeyValuePair field in members) + { + // POC: TODO check for the forbidden characters/combinations: https://support.esri.com/en-us/knowledge-base/what-characters-should-not-be-used-in-arcgis-for-field--000005588 + Func function = x => x[field.Key]; + TraverseAttributes(field, function, fieldsAndFunctions, fieldAdded); + } + } + + // change all FieldType.Blob to String + // "Blob" will never be used on receive, so it is a placeholder for non-properly identified fields + for (int i = 0; i < fieldsAndFunctions.Count; i++) + { + (FieldDescription description, Func function) = fieldsAndFunctions[i]; + if (description.FieldType is FieldType.Blob) + { + fieldsAndFunctions[i] = new( + new FieldDescription(description.Name, FieldType.String) { AliasName = description.AliasName }, + function + ); + } + } + + return fieldsAndFunctions; + } + + private void TraverseAttributes( + KeyValuePair field, + Func function, + List<(FieldDescription, Func)> fieldsAndFunctions, + List fieldAdded + ) + { + if (field.Value is Base attributeBase) + { + // only traverse Base if it's Rhino userStrings, or Revit parameter, or Base containing Revit parameters + if (field.Key == "parameters") + { + foreach (KeyValuePair attributField in attributeBase.GetMembers(DynamicBaseMemberType.Dynamic)) + { + // only iterate through elements if they are actually Revit Parameters or parameter IDs + if ( + attributField.Value is Objects.BuiltElements.Revit.Parameter + || attributField.Key == "applicationId" + || attributField.Key == "id" + ) + { + KeyValuePair newAttributField = + new($"{field.Key}.{attributField.Key}", attributField.Value); + Func functionAdded = x => (function(x) as Base)?[attributField.Key]; + TraverseAttributes(newAttributField, functionAdded, fieldsAndFunctions, fieldAdded); + } + } + } + else if (field.Key == "userStrings") + { + foreach (KeyValuePair attributField in attributeBase.GetMembers(DynamicBaseMemberType.Dynamic)) + { + KeyValuePair newAttributField = new($"{field.Key}.{attributField.Key}", attributField.Value); + Func functionAdded = x => (function(x) as Base)?[attributField.Key]; + TraverseAttributes(newAttributField, functionAdded, fieldsAndFunctions, fieldAdded); + } + } + else if (field.Value is Objects.BuiltElements.Revit.Parameter) + { + foreach ( + KeyValuePair attributField in attributeBase.GetMembers(DynamicBaseMemberType.Instance) + ) + { + KeyValuePair newAttributField = new($"{field.Key}.{attributField.Key}", attributField.Value); + Func functionAdded = x => (function(x) as Base)?[attributField.Key]; + TraverseAttributes(newAttributField, functionAdded, fieldsAndFunctions, fieldAdded); + } + } + else + { + // for now, ignore all other properties of Base type + } + } + else if (field.Value is IList attributeList) + { + int count = 0; + foreach (var attributField in attributeList) + { + KeyValuePair newAttributField = new($"{field.Key}[{count}]", attributField); + Func functionAdded = x => (function(x) as List)?[count]; + TraverseAttributes(newAttributField, functionAdded, fieldsAndFunctions, fieldAdded); + count += 1; + } + } + else + { + TryAddField(field, function, fieldsAndFunctions, fieldAdded); + } + } + + private void TryAddField( + KeyValuePair field, + Func function, + List<(FieldDescription, Func)> fieldsAndFunctions, + List fieldAdded + ) + { + try + { + string key = field.Key; + string cleanKey = _characterCleaner.CleanCharacters(key); + + if (cleanKey == FID_FIELD_NAME) // we cannot add field with reserved name + { + return; + } + + if (!fieldAdded.Contains(cleanKey)) + { + // use field.Value to define FieldType + FieldType fieldType = GISAttributeFieldType.GetFieldTypeFromRawValue(field.Value); + + FieldDescription fieldDescription = new(cleanKey, fieldType) { AliasName = key }; + fieldsAndFunctions.Add((fieldDescription, function)); + fieldAdded.Add(cleanKey); + } + else + { + // if field exists, check field.Value again, and revise FieldType if needed + int index = fieldsAndFunctions.TakeWhile(x => x.Item1.Name != cleanKey).Count(); + + (FieldDescription, Func) itemInList; + try + { + itemInList = fieldsAndFunctions[index]; + } + catch (Exception ex) when (!ex.IsFatal()) + { + return; + } + + FieldType existingFieldType = itemInList.Item1.FieldType; + FieldType newFieldType = GISAttributeFieldType.GetFieldTypeFromRawValue(field.Value); + + // adjust FieldType if needed, default everything to Strings if fields types differ: + // 1. change to NewType, if old type was undefined ("Blob") + // 2. change to NewType if it's String (and the old one is not) + if ( + newFieldType != FieldType.Blob && existingFieldType == FieldType.Blob + || (newFieldType == FieldType.String && existingFieldType != FieldType.String) + ) + { + fieldsAndFunctions[index] = ( + new FieldDescription(itemInList.Item1.Name, newFieldType) { AliasName = itemInList.Item1.AliasName }, + itemInList.Item2 + ); + } + } + } + catch (GeodatabaseFieldException) + { + // do nothing + } + } } diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/FeatureClassUtils.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/FeatureClassUtils.cs index dce6ce6853..c80b8473f1 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/FeatureClassUtils.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/FeatureClassUtils.cs @@ -22,7 +22,15 @@ public void AddFeaturesToTable(Table newFeatureClass, List gisFeatur { using (RowBuffer rowBuffer = newFeatureClass.CreateRowBuffer()) { - newFeatureClass.CreateRow(_fieldsUtils.AssignFieldValuesToRow(rowBuffer, fields, feat)).Dispose(); + newFeatureClass + .CreateRow( + _fieldsUtils.AssignFieldValuesToRow( + rowBuffer, + fields, + feat.attributes.GetMembers(DynamicBaseMemberType.Dynamic) + ) + ) + .Dispose(); } } } @@ -50,22 +58,32 @@ public void AddFeaturesToFeatureClass( } // get attributes - newFeatureClass.CreateRow(_fieldsUtils.AssignFieldValuesToRow(rowBuffer, fields, feat)).Dispose(); + newFeatureClass + .CreateRow( + _fieldsUtils.AssignFieldValuesToRow( + rowBuffer, + fields, + feat.attributes.GetMembers(DynamicBaseMemberType.Dynamic) + ) + ) + .Dispose(); } } } public void AddNonGISFeaturesToFeatureClass( FeatureClass newFeatureClass, - List features, - List fields + List<(Base baseObj, ACG.Geometry convertedGeom)> featuresTuples, + List<(FieldDescription, Func)> fieldsAndFunctions ) { - foreach (ACG.Geometry geom in features) + foreach ((Base baseObj, ACG.Geometry geom) in featuresTuples) { using (RowBuffer rowBuffer = newFeatureClass.CreateRowBuffer()) { ACG.Geometry newGeom = geom; + + // exception for Points: turn into MultiPoint layer if (geom is ACG.MapPoint pointGeom) { newGeom = new ACG.MultipointBuilderEx( @@ -73,11 +91,22 @@ List fields ACG.AttributeFlags.HasZ ).ToGeometry(); } + rowBuffer[newFeatureClass.GetDefinition().GetShapeField()] = newGeom; - // TODO: get attributes - // newFeatureClass.CreateRow(_fieldsUtils.AssignFieldValuesToRow(rowBuffer, fields, feat)).Dispose(); - newFeatureClass.CreateRow(rowBuffer).Dispose(); + // set and pass attributes + Dictionary attributes = new(); + foreach ((FieldDescription field, Func function) in fieldsAndFunctions) + { + string key = field.AliasName; + attributes[key] = function(baseObj); + } + // newFeatureClass.CreateRow(rowBuffer).Dispose(); // without extra attributes + newFeatureClass + .CreateRow( + _fieldsUtils.AssignFieldValuesToRow(rowBuffer, fieldsAndFunctions.Select(x => x.Item1).ToList(), attributes) + ) + .Dispose(); } } } diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/GISAttributeFieldType.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/GISAttributeFieldType.cs index 332a6d077a..4da3d09004 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/GISAttributeFieldType.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/GISAttributeFieldType.cs @@ -90,30 +90,52 @@ public static FieldType FieldTypeToNative(object fieldType) return value; } - if (value is not null) + if (value != null) { try { + static object? GetValue(string? s, Func func) => s is null ? null : func(s); return fieldType switch { - FieldType.String => (string)value, + FieldType.String => Convert.ToString(value), FieldType.Single => Convert.ToSingle(value), FieldType.Integer => Convert.ToInt32(value), // need this step because sent "ints" seem to be received as "longs" FieldType.BigInteger => Convert.ToInt64(value), FieldType.SmallInteger => Convert.ToInt16(value), FieldType.Double => Convert.ToDouble(value), - FieldType.Date => DateTime.Parse((string)value, null), - FieldType.DateOnly => DateOnly.Parse((string)value), - FieldType.TimeOnly => TimeOnly.Parse((string)value), + FieldType.Date => GetValue(value.ToString(), s => DateTime.Parse(s, null)), + FieldType.DateOnly => GetValue(value.ToString(), s => DateOnly.Parse(s, null)), + FieldType.TimeOnly => GetValue(value.ToString(), s => TimeOnly.Parse(s, null)), _ => value, }; } - catch (InvalidCastException) + catch (Exception ex) when (ex is InvalidCastException or FormatException or ArgumentNullException) { - return value; + return null; } } + else + { + return null; + } + } + + public static FieldType GetFieldTypeFromRawValue(object? value) + { + // using "Blob" as a placeholder for unrecognized values/nulls. + // Once all elements are iterated, FieldType.Blob will be replaced with FieldType.String if no better type found + if (value is not null) + { + return value switch + { + string => FieldType.String, + int => FieldType.Integer, + long => FieldType.BigInteger, + double => FieldType.Double, + _ => FieldType.Blob, + }; + } - return value; + return FieldType.Blob; } } diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/IArcGISFieldUtils.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/IArcGISFieldUtils.cs index 959e9793fe..6bda9e1bff 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/IArcGISFieldUtils.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/IArcGISFieldUtils.cs @@ -1,11 +1,18 @@ using ArcGIS.Core.Data; using Objects.GIS; +using Speckle.Core.Models; using FieldDescription = ArcGIS.Core.Data.DDL.FieldDescription; namespace Speckle.Converters.ArcGIS3.Utils; public interface IArcGISFieldUtils { - public RowBuffer AssignFieldValuesToRow(RowBuffer rowBuffer, List fields, GisFeature feat); + public RowBuffer AssignFieldValuesToRow( + RowBuffer rowBuffer, + List fields, + Dictionary attributes + ); public List GetFieldsFromSpeckleLayer(VectorLayer target); + + public List<(FieldDescription, Func)> CreateFieldsFromListOfBase(List target); } diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/IFeatureClassUtils.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/IFeatureClassUtils.cs index 289c05eeb6..b60cf4bfea 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/IFeatureClassUtils.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/IFeatureClassUtils.cs @@ -16,8 +16,8 @@ void AddFeaturesToFeatureClass( ); void AddNonGISFeaturesToFeatureClass( FeatureClass newFeatureClass, - List features, - List fields + List<(Base baseObj, ACG.Geometry convertedGeom)> featuresTuples, + List<(FieldDescription, Func)> fieldsAndFunctions ); void AddFeaturesToTable(Table newFeatureClass, List gisFeatures, List fields); public ACG.GeometryType GetLayerGeometryType(VectorLayer target); diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/NonNativeFeaturesUtils.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/NonNativeFeaturesUtils.cs index 0d458029bf..3a17ff8796 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/NonNativeFeaturesUtils.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/NonNativeFeaturesUtils.cs @@ -6,6 +6,7 @@ using FieldDescription = ArcGIS.Core.Data.DDL.FieldDescription; using Speckle.Core.Logging; using Speckle.Core.Models.GraphTraversal; +using Speckle.Core.Models; namespace Speckle.Converters.ArcGIS3.Utils; @@ -13,14 +14,17 @@ public class NonNativeFeaturesUtils : INonNativeFeaturesUtils { private readonly IFeatureClassUtils _featureClassUtils; private readonly IConversionContextStack _contextStack; + private readonly IArcGISFieldUtils _fieldUtils; public NonNativeFeaturesUtils( IFeatureClassUtils featureClassUtils, - IConversionContextStack contextStack + IConversionContextStack contextStack, + IArcGISFieldUtils fieldUtils ) { _featureClassUtils = featureClassUtils; _contextStack = contextStack; + _fieldUtils = fieldUtils; } public void WriteGeometriesToDatasets( @@ -29,7 +33,7 @@ Dictionary conversionTracker ) { // 1. Sort features into groups by path and geom type - Dictionary> geometryGroups = new(); + Dictionary> geometryGroups = new(); foreach (var item in conversionTracker) { try @@ -40,9 +44,7 @@ Dictionary conversionTracker string? datasetId = trackerItem.DatasetId; if (geom != null && datasetId == null) // only non-native geomerties, not written into a dataset yet { - string nestedParentPath = trackerItem.NestedLayerName; - string speckle_type = nestedParentPath.Split('\\')[^1]; - + string speckle_type = trackerItem.Base.speckle_type.Split(".")[^1]; string? parentId = context.Parent?.Current.id; // add dictionnary item if doesn't exist yet @@ -50,10 +52,10 @@ Dictionary conversionTracker string uniqueKey = $"speckleTYPE_{speckle_type}_speckleID_{parentId}"; if (!geometryGroups.TryGetValue(uniqueKey, out _)) { - geometryGroups[uniqueKey] = new List(); + geometryGroups[uniqueKey] = new(); } - geometryGroups[uniqueKey].Add(geom); + geometryGroups[uniqueKey].Add((trackerItem.Base, geom)); // record changes in conversion tracker trackerItem.AddDatasetId(uniqueKey); @@ -83,10 +85,10 @@ Dictionary conversionTracker foreach (var item in geometryGroups) { string uniqueKey = item.Key; - List geomList = item.Value; + List<(Base, ACG.Geometry)> listOfGeometryTuples = item.Value; try { - CreateDatasetInDatabase(uniqueKey, geomList); + CreateDatasetInDatabase(uniqueKey, listOfGeometryTuples); } catch (GeodatabaseGeometryException ex) { @@ -105,7 +107,10 @@ Dictionary conversionTracker } } - private void CreateDatasetInDatabase(string featureClassName, List geomList) + private void CreateDatasetInDatabase( + string featureClassName, + List<(Base baseObj, ACG.Geometry convertedGeom)> listOfGeometryTuples + ) { FileGeodatabaseConnectionPath fileGeodatabaseConnectionPath = new(_contextStack.Current.Document.SpeckleDatabasePath); @@ -115,8 +120,10 @@ private void CreateDatasetInDatabase(string featureClassName, List // get Spatial Reference from the document ACG.SpatialReference spatialRef = _contextStack.Current.Document.Map.SpatialReference; - // TODO: create Fields - List fields = new(); // _fieldsUtils.GetFieldsFromSpeckleLayer(target); + // create Fields + List<(FieldDescription, Func)> fieldsAndFunctions = _fieldUtils.CreateFieldsFromListOfBase( + listOfGeometryTuples.Select(x => x.baseObj).ToList() + ); // delete FeatureClass if already exists try @@ -147,14 +154,16 @@ private void CreateDatasetInDatabase(string featureClassName, List try { // POC: make sure class has a valid crs - ACG.GeometryType geomType = geomList[0].GeometryType; + ACG.GeometryType geomType = listOfGeometryTuples[0].convertedGeom.GeometryType; ShapeDescription shpDescription = new(geomType, spatialRef) { HasZ = true }; - FeatureClassDescription featureClassDescription = new(featureClassName, fields, shpDescription); + FeatureClassDescription featureClassDescription = + new(featureClassName, fieldsAndFunctions.Select(x => x.Item1), shpDescription); FeatureClassToken featureClassToken = schemaBuilder.Create(featureClassDescription); } catch (ArgumentException ex) { // if name has invalid characters/combinations + // or 'The table contains multiple fields with the same name.: throw new ArgumentException($"{ex.Message}: {featureClassName}", ex); } bool buildStatus = schemaBuilder.Build(); @@ -168,7 +177,7 @@ private void CreateDatasetInDatabase(string featureClassName, List // Add features to the FeatureClass geodatabase.ApplyEdits(() => { - _featureClassUtils.AddNonGISFeaturesToFeatureClass(newFeatureClass, geomList, fields); + _featureClassUtils.AddNonGISFeaturesToFeatureClass(newFeatureClass, listOfGeometryTuples, fieldsAndFunctions); }); } } From 483fe7d77192b851cba0d543d94669f18d39af87 Mon Sep 17 00:00:00 2001 From: Jedd Morgan <45512892+JR-Morgan@users.noreply.github.com> Date: Fri, 21 Jun 2024 13:43:58 +0100 Subject: [PATCH 242/261] [DUI3-293] logging poc bindings and bridge (#3515) * Wip changes * Added top level callback in several places * extracting some non-controversial changes to be merged first for cleaner diff * more * more binding stuff * More binding alighment * formatting * fix merge mistake * removed lies * browser bridge concurrency * More subscriptions * Small tweaks * Resolved some PR comments * last rounds of polish * local to private function * More events that are top level * Interfaced out TopLevelExceptionHandler --- All.sln.DotSettings | 1 + .../Bindings/ArcGISSelectionBinding.cs | 6 +- .../Bindings/ArcGISSendBinding.cs | 46 +++- .../Utils/ArcGisDocumentStore.cs | 34 +-- .../Bindings/AutocadSelectionBinding.cs | 14 +- .../Bindings/AutocadSendBinding.cs | 20 +- .../HostApp/AutocadDocumentModelStore.cs | 11 +- .../Bindings/RevitSendBinding.cs | 11 +- .../Bindings/SelectionBinding.cs | 7 +- .../HostApp/RevitDocumentStore.cs | 15 +- .../Plugin/RevitIdleManager.cs | 22 +- .../Bindings/RhinoSelectionBinding.cs | 38 ++-- .../Bindings/RhinoSendBinding.cs | 66 +++--- .../HostApp/RhinoDocumentStore.cs | 39 ++-- .../DUI3ControlWebView.xaml.cs | 13 +- .../Bindings/IBasicConnectorBinding.cs | 2 +- .../Bridge/BrowserBridge.cs | 202 ++++++++++-------- .../Speckle.Connectors.DUI/Bridge/IBridge.cs | 5 + .../Bridge/TopLevelExceptionHandler.cs | 135 ++++++++++++ .../ContainerRegistration.cs | 2 +- .../ContainerRegistration.cs | 8 +- 21 files changed, 470 insertions(+), 227 deletions(-) create mode 100644 DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/TopLevelExceptionHandler.cs diff --git a/All.sln.DotSettings b/All.sln.DotSettings index a68eee20a7..c5930b608d 100644 --- a/All.sln.DotSettings +++ b/All.sln.DotSettings @@ -625,6 +625,7 @@ QL SQ UI + URI True ExternalToolData|CSharpier|csharpier||csharpier|$FILE$ CamelCase diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISSelectionBinding.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISSelectionBinding.cs index 157bad2797..a9c84e14f5 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISSelectionBinding.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISSelectionBinding.cs @@ -10,16 +10,16 @@ public class ArcGISSelectionBinding : ISelectionBinding public string Name => "selectionBinding"; public IBridge Parent { get; } - public ArcGISSelectionBinding(IBridge parent) + public ArcGISSelectionBinding(IBridge parent, ITopLevelExceptionHandler topLevelHandler) { Parent = parent; // example: https://github.com/Esri/arcgis-pro-sdk-community-samples/blob/master/Map-Authoring/QueryBuilderControl/DefinitionQueryDockPaneViewModel.cs // MapViewEventArgs args = new(MapView.Active); - TOCSelectionChangedEvent.Subscribe(OnSelectionChanged, true); + TOCSelectionChangedEvent.Subscribe(_ => topLevelHandler.CatchUnhandled(OnSelectionChanged), true); } - private void OnSelectionChanged(MapViewEventArgs args) + private void OnSelectionChanged() { SelectionInfo selInfo = GetSelection(); Parent.Send(SelectionBindingEvents.SET_SELECTION, selInfo); diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISSendBinding.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISSendBinding.cs index ef05b43288..4c0215694b 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISSendBinding.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISSendBinding.cs @@ -31,6 +31,7 @@ public sealed class ArcGISSendBinding : ISendBinding private readonly List _sendFilters; private readonly CancellationManager _cancellationManager; private readonly ISendConversionCache _sendConversionCache; + private readonly ITopLevelExceptionHandler _topLevelExceptionHandler; /// /// Used internally to aggregate the changed objects' id. @@ -45,7 +46,8 @@ public ArcGISSendBinding( IEnumerable sendFilters, IUnitOfWorkFactory unitOfWorkFactory, CancellationManager cancellationManager, - ISendConversionCache sendConversionCache + ISendConversionCache sendConversionCache, + ITopLevelExceptionHandler topLevelExceptionHandler ) { _store = store; @@ -53,6 +55,7 @@ ISendConversionCache sendConversionCache _sendFilters = sendFilters.ToList(); _cancellationManager = cancellationManager; _sendConversionCache = sendConversionCache; + _topLevelExceptionHandler = topLevelExceptionHandler; Parent = parent; Commands = new SendBindingUICommands(parent); SubscribeToArcGISEvents(); @@ -60,17 +63,40 @@ ISendConversionCache sendConversionCache private void SubscribeToArcGISEvents() { - LayersRemovedEvent.Subscribe(GetIdsForLayersRemovedEvent, true); - StandaloneTablesRemovedEvent.Subscribe(GetIdsForStandaloneTablesRemovedEvent, true); - MapPropertyChangedEvent.Subscribe(GetIdsForMapPropertyChangedEvent, true); // Map units, CRS etc. - MapMemberPropertiesChangedEvent.Subscribe(GetIdsForMapMemberPropertiesChangedEvent, true); // e.g. Layer name - - ActiveMapViewChangedEvent.Subscribe(SubscribeToMapMembersDataSourceChange, true); - LayersAddedEvent.Subscribe(GetIdsForLayersAddedEvent, true); - StandaloneTablesAddedEvent.Subscribe(GetIdsForStandaloneTablesAddedEvent, true); + LayersRemovedEvent.Subscribe( + a => _topLevelExceptionHandler.CatchUnhandled(() => GetIdsForLayersRemovedEvent(a)), + true + ); + + StandaloneTablesRemovedEvent.Subscribe( + a => _topLevelExceptionHandler.CatchUnhandled(() => GetIdsForStandaloneTablesRemovedEvent(a)), + true + ); + + MapPropertyChangedEvent.Subscribe( + a => _topLevelExceptionHandler.CatchUnhandled(() => GetIdsForMapPropertyChangedEvent(a)), + true + ); // Map units, CRS etc. + + MapMemberPropertiesChangedEvent.Subscribe( + a => _topLevelExceptionHandler.CatchUnhandled(() => GetIdsForMapMemberPropertiesChangedEvent(a)), + true + ); // e.g. Layer name + + ActiveMapViewChangedEvent.Subscribe( + _ => _topLevelExceptionHandler.CatchUnhandled(SubscribeToMapMembersDataSourceChange), + true + ); + + LayersAddedEvent.Subscribe(a => _topLevelExceptionHandler.CatchUnhandled(() => GetIdsForLayersAddedEvent(a)), true); + + StandaloneTablesAddedEvent.Subscribe( + a => _topLevelExceptionHandler.CatchUnhandled(() => GetIdsForStandaloneTablesAddedEvent(a)), + true + ); } - private void SubscribeToMapMembersDataSourceChange(ActiveMapViewChangedEventArgs args) + private void SubscribeToMapMembersDataSourceChange() { var task = QueuedTask.Run(() => { diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Utils/ArcGisDocumentStore.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Utils/ArcGisDocumentStore.cs index d8ca75f959..db0df3550f 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Utils/ArcGisDocumentStore.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Utils/ArcGisDocumentStore.cs @@ -3,6 +3,7 @@ using ArcGIS.Desktop.Framework.Threading.Tasks; using ArcGIS.Desktop.Mapping; using ArcGIS.Desktop.Mapping.Events; +using Speckle.Connectors.DUI.Bridge; using Speckle.Connectors.DUI.Models; using Speckle.Connectors.Utils; using Speckle.Newtonsoft.Json; @@ -11,34 +12,41 @@ namespace Speckle.Connectors.ArcGIS.Utils; public class ArcGISDocumentStore : DocumentModelStore { - public ArcGISDocumentStore(JsonSerializerSettings serializerOption) + public ArcGISDocumentStore( + JsonSerializerSettings serializerOption, + ITopLevelExceptionHandler topLevelExceptionHandler + ) : base(serializerOption, true) { - ActiveMapViewChangedEvent.Subscribe(OnMapViewChanged); - ProjectSavingEvent.Subscribe(OnProjectSaving); - ProjectClosingEvent.Subscribe(OnProjectClosing); + ActiveMapViewChangedEvent.Subscribe(a => topLevelExceptionHandler.CatchUnhandled(() => OnMapViewChanged(a))); + ProjectSavingEvent.Subscribe(_ => + { + topLevelExceptionHandler.CatchUnhandled(OnProjectSaving); + return Task.CompletedTask; + }); + ProjectClosingEvent.Subscribe(_ => + { + topLevelExceptionHandler.CatchUnhandled(OnProjectClosing); + return Task.CompletedTask; + }); } - private Task OnProjectClosing(ProjectClosingEventArgs arg) + private void OnProjectClosing() { if (MapView.Active is null) { - return Task.CompletedTask; + return; } WriteToFile(); - return Task.CompletedTask; } - private Task OnProjectSaving(ProjectEventArgs arg) + private void OnProjectSaving() { - if (MapView.Active is null) + if (MapView.Active is not null) { - return Task.CompletedTask; + WriteToFile(); } - - WriteToFile(); - return Task.CompletedTask; } /// diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadSelectionBinding.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadSelectionBinding.cs index 1da7250ceb..1e13090a9f 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadSelectionBinding.cs +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadSelectionBinding.cs @@ -8,20 +8,24 @@ namespace Speckle.Connectors.Autocad.Bindings; public class AutocadSelectionBinding : ISelectionBinding { private const string SELECTION_EVENT = "setSelection"; - + private readonly ITopLevelExceptionHandler _topLevelExceptionHandler; private readonly HashSet _visitedDocuments = new(); + public string Name => "selectionBinding"; + public IBridge Parent { get; } - public AutocadSelectionBinding(IBridge parent) + public AutocadSelectionBinding(IBridge parent, ITopLevelExceptionHandler topLevelExceptionHandler) { + _topLevelExceptionHandler = topLevelExceptionHandler; Parent = parent; // POC: Use here Context for doc. In converters it's OK but we are still lacking to use context into bindings. // It is with the case of if binding created with already a document // This is valid when user opens acad file directly double clicking TryRegisterDocumentForSelection(Application.DocumentManager.MdiActiveDocument); - Application.DocumentManager.DocumentActivated += (sender, e) => OnDocumentChanged(e.Document); + Application.DocumentManager.DocumentActivated += (_, e) => + _topLevelExceptionHandler.CatchUnhandled(() => OnDocumentChanged(e.Document)); } private void OnDocumentChanged(Document? document) => TryRegisterDocumentForSelection(document); @@ -36,9 +40,7 @@ private void TryRegisterDocumentForSelection(Document? document) if (!_visitedDocuments.Contains(document)) { document.ImpliedSelectionChanged += (_, _) => - { - Parent.RunOnMainThread(OnSelectionChanged); - }; + _topLevelExceptionHandler.CatchUnhandled(() => Parent.RunOnMainThread(OnSelectionChanged)); _visitedDocuments.Add(document); } diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadSendBinding.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadSendBinding.cs index 4d580c6aed..32cc40fbe7 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadSendBinding.cs +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadSendBinding.cs @@ -29,6 +29,7 @@ public sealed class AutocadSendBinding : ISendBinding private readonly IUnitOfWorkFactory _unitOfWorkFactory; private readonly AutocadSettings _autocadSettings; private readonly ISendConversionCache _sendConversionCache; + private readonly ITopLevelExceptionHandler _topLevelExceptionHandler; /// /// Used internally to aggregate the changed objects' id. @@ -43,7 +44,8 @@ public AutocadSendBinding( CancellationManager cancellationManager, AutocadSettings autocadSettings, IUnitOfWorkFactory unitOfWorkFactory, - ISendConversionCache sendConversionCache + ISendConversionCache sendConversionCache, + ITopLevelExceptionHandler topLevelExceptionHandler ) { _store = store; @@ -53,10 +55,13 @@ ISendConversionCache sendConversionCache _cancellationManager = cancellationManager; _sendFilters = sendFilters.ToList(); _sendConversionCache = sendConversionCache; + _topLevelExceptionHandler = topLevelExceptionHandler; Parent = parent; Commands = new SendBindingUICommands(parent); - Application.DocumentManager.DocumentActivated += (sender, args) => SubscribeToObjectChanges(args.Document); + Application.DocumentManager.DocumentActivated += (_, args) => + topLevelExceptionHandler.CatchUnhandled(() => SubscribeToObjectChanges(args.Document)); + if (Application.DocumentManager.CurrentDocument != null) { // catches the case when autocad just opens up with a blank new doc @@ -74,9 +79,14 @@ private void SubscribeToObjectChanges(Document doc) } _docSubsTracker.Add(doc.Name); - doc.Database.ObjectAppended += (_, e) => OnChangeChangedObjectIds(e.DBObject); - doc.Database.ObjectErased += (_, e) => OnChangeChangedObjectIds(e.DBObject); - doc.Database.ObjectModified += (_, e) => OnChangeChangedObjectIds(e.DBObject); + doc.Database.ObjectAppended += (_, e) => OnObjectChanged(e.DBObject); + doc.Database.ObjectErased += (_, e) => OnObjectChanged(e.DBObject); + doc.Database.ObjectModified += (_, e) => OnObjectChanged(e.DBObject); + } + + void OnObjectChanged(DBObject dbObject) + { + _topLevelExceptionHandler.CatchUnhandled(() => OnChangeChangedObjectIds(dbObject)); } private void OnChangeChangedObjectIds(DBObject dBObject) diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/AutocadDocumentModelStore.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/AutocadDocumentModelStore.cs index 17ebfccee0..a01b4a0716 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/AutocadDocumentModelStore.cs +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/AutocadDocumentModelStore.cs @@ -1,3 +1,4 @@ +using Speckle.Connectors.DUI.Bridge; using Speckle.Connectors.DUI.Models; using Speckle.Connectors.Utils; using Speckle.Newtonsoft.Json; @@ -12,7 +13,8 @@ public class AutocadDocumentStore : DocumentModelStore public AutocadDocumentStore( JsonSerializerSettings jsonSerializerSettings, - AutocadDocumentManager autocadDocumentManager + AutocadDocumentManager autocadDocumentManager, + ITopLevelExceptionHandler topLevelExceptionHandler ) : base(jsonSerializerSettings, true) { @@ -29,14 +31,15 @@ AutocadDocumentManager autocadDocumentManager OnDocChangeInternal(Application.DocumentManager.MdiActiveDocument); } - Application.DocumentManager.DocumentActivated += (_, e) => OnDocChangeInternal(e.Document); + Application.DocumentManager.DocumentActivated += (_, e) => + topLevelExceptionHandler.CatchUnhandled(() => OnDocChangeInternal(e.Document)); // since below event triggered as secondary, it breaks the logic in OnDocChangeInternal function, leaving it here for now. // Autodesk.AutoCAD.ApplicationServices.Application.DocumentWindowCollection.DocumentWindowActivated += (_, args) => // OnDocChangeInternal((Document)args.DocumentWindow.Document); } - private void OnDocChangeInternal(Document doc) + private void OnDocChangeInternal(Document? doc) { var currentDocName = doc != null ? doc.Name : _nullDocumentName; if (_previousDocName == currentDocName) @@ -54,7 +57,7 @@ public override void ReadFromFile() Models = new(); // POC: Will be addressed to move it into AutocadContext! - Document doc = Application.DocumentManager.MdiActiveDocument; + Document? doc = Application.DocumentManager.MdiActiveDocument; if (doc == null) { diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/RevitSendBinding.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/RevitSendBinding.cs index ab60430881..8bd3033442 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/RevitSendBinding.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/RevitSendBinding.cs @@ -27,6 +27,7 @@ internal sealed class RevitSendBinding : RevitBaseBinding, ISendBinding private readonly CancellationManager _cancellationManager; private readonly IUnitOfWorkFactory _unitOfWorkFactory; private readonly ISendConversionCache _sendConversionCache; + private readonly ITopLevelExceptionHandler _topLevelExceptionHandler; public RevitSendBinding( IRevitIdleManager idleManager, @@ -36,7 +37,8 @@ public RevitSendBinding( IBridge bridge, IUnitOfWorkFactory unitOfWorkFactory, RevitSettings revitSettings, - ISendConversionCache sendConversionCache + ISendConversionCache sendConversionCache, + ITopLevelExceptionHandler topLevelExceptionHandler ) : base("sendBinding", store, bridge, revitContext) { @@ -45,12 +47,15 @@ ISendConversionCache sendConversionCache _unitOfWorkFactory = unitOfWorkFactory; _revitSettings = revitSettings; _sendConversionCache = sendConversionCache; + _topLevelExceptionHandler = topLevelExceptionHandler; Commands = new SendBindingUICommands(bridge); // TODO expiry events // TODO filters need refresh events - revitContext.UIApplication.NotNull().Application.DocumentChanged += (_, e) => DocChangeHandler(e); - Store.DocumentChanged += (_, _) => OnDocumentChanged(); + revitContext.UIApplication.NotNull().Application.DocumentChanged += (_, e) => + _topLevelExceptionHandler.CatchUnhandled(() => DocChangeHandler(e)); + + Store.DocumentChanged += (_, _) => _topLevelExceptionHandler.CatchUnhandled(OnDocumentChanged); } public List GetSendFilters() diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SelectionBinding.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SelectionBinding.cs index 11b7e8e864..d60fe3ef27 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SelectionBinding.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SelectionBinding.cs @@ -11,20 +11,23 @@ namespace Speckle.Connectors.Revit.Bindings; internal sealed class SelectionBinding : RevitBaseBinding, ISelectionBinding { private readonly IRevitIdleManager _revitIdleManager; + private readonly ITopLevelExceptionHandler _topLevelExceptionHandler; public SelectionBinding( RevitContext revitContext, DocumentModelStore store, IRevitIdleManager idleManager, - IBridge bridge + IBridge bridge, + ITopLevelExceptionHandler topLevelExceptionHandler ) : base("selectionBinding", store, bridge, revitContext) { _revitIdleManager = idleManager; + _topLevelExceptionHandler = topLevelExceptionHandler; // POC: we can inject the solution here // TODO: Need to figure it out equivalent of SelectionChanged for Revit2020 RevitContext.UIApplication.NotNull().SelectionChanged += (_, _) => - _revitIdleManager.SubscribeToIdle(OnSelectionChanged); + topLevelExceptionHandler.CatchUnhandled(() => _revitIdleManager.SubscribeToIdle(OnSelectionChanged)); } private void OnSelectionChanged() diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/RevitDocumentStore.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/RevitDocumentStore.cs index 1278431790..ba9b7d8db3 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/RevitDocumentStore.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/RevitDocumentStore.cs @@ -4,6 +4,7 @@ using Autodesk.Revit.UI; using Autodesk.Revit.UI.Events; using Revit.Async; +using Speckle.Connectors.DUI.Bridge; using Speckle.Connectors.DUI.Models; using Speckle.Connectors.Revit.Plugin; using Speckle.Connectors.RevitShared.Helpers; @@ -29,7 +30,8 @@ public RevitDocumentStore( RevitContext revitContext, JsonSerializerSettings serializerSettings, DocumentModelStorageSchema documentModelStorageSchema, - IdStorageSchema idStorageSchema + IdStorageSchema idStorageSchema, + ITopLevelExceptionHandler topLevelExceptionHandler ) : base(serializerSettings, true) { @@ -40,12 +42,15 @@ IdStorageSchema idStorageSchema UIApplication uiApplication = _revitContext.UIApplication.NotNull(); - uiApplication.ViewActivated += OnViewActivated; + uiApplication.ViewActivated += (s, e) => topLevelExceptionHandler.CatchUnhandled(() => OnViewActivated(s, e)); - uiApplication.Application.DocumentOpening += (_, _) => IsDocumentInit = false; - uiApplication.Application.DocumentOpened += (_, _) => IsDocumentInit = false; + uiApplication.Application.DocumentOpening += (_, _) => + topLevelExceptionHandler.CatchUnhandled(() => IsDocumentInit = false); - Models.CollectionChanged += (_, _) => WriteToFile(); + uiApplication.Application.DocumentOpened += (_, _) => + topLevelExceptionHandler.CatchUnhandled(() => IsDocumentInit = false); + + Models.CollectionChanged += (_, _) => topLevelExceptionHandler.CatchUnhandled(WriteToFile); // There is no event that we can hook here for double-click file open... // It is kind of harmless since we create this object as "SingleInstance". diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitIdleManager.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitIdleManager.cs index 8456ded287..6e3d0c4e5e 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitIdleManager.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitIdleManager.cs @@ -1,6 +1,7 @@ using System.Collections.Concurrent; using Autodesk.Revit.UI; using Autodesk.Revit.UI.Events; +using Speckle.Connectors.DUI.Bridge; using Speckle.Connectors.RevitShared.Helpers; namespace Speckle.Connectors.Revit.Plugin; @@ -9,6 +10,7 @@ namespace Speckle.Connectors.Revit.Plugin; // is probably misnamed, perhaps OnIdleCallbackManager internal sealed class RevitIdleManager : IRevitIdleManager { + private readonly ITopLevelExceptionHandler _topLevelExceptionHandler; private readonly UIApplication _uiApplication; private readonly ConcurrentDictionary _calls = new(); @@ -16,8 +18,9 @@ internal sealed class RevitIdleManager : IRevitIdleManager // POC: still not thread safe private volatile bool _hasSubscribed; - public RevitIdleManager(RevitContext revitContext) + public RevitIdleManager(RevitContext revitContext, ITopLevelExceptionHandler topLevelExceptionHandler) { + _topLevelExceptionHandler = topLevelExceptionHandler; _uiApplication = revitContext.UIApplication!; } @@ -46,15 +49,18 @@ public void SubscribeToIdle(Action action) private void RevitAppOnIdle(object sender, IdlingEventArgs e) { - foreach (KeyValuePair kvp in _calls) + _topLevelExceptionHandler.CatchUnhandled(() => { - kvp.Value(); - } + foreach (KeyValuePair kvp in _calls) + { + kvp.Value.Invoke(); + } - _calls.Clear(); - _uiApplication.Idling -= RevitAppOnIdle; + _calls.Clear(); + _uiApplication.Idling -= RevitAppOnIdle; - // setting last will delay ntering re-subscritption - _hasSubscribed = false; + // setting last will delay ntering re-subscritption + _hasSubscribed = false; + }); } } diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSelectionBinding.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSelectionBinding.cs index 077a4df2fd..ded20ed05f 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSelectionBinding.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSelectionBinding.cs @@ -8,33 +8,37 @@ namespace Speckle.Connectors.Rhino7.Bindings; public class RhinoSelectionBinding : ISelectionBinding { + private readonly RhinoIdleManager _idleManager; + private readonly ITopLevelExceptionHandler _topLevelExceptionHandler; private const string SELECTION_EVENT = "setSelection"; - public string Name { get; } = "selectionBinding"; - public IBridge Parent { get; set; } + public string Name => "selectionBinding"; + public IBridge Parent { get; } - public RhinoSelectionBinding(RhinoIdleManager idleManager, IBridge parent) + public RhinoSelectionBinding( + RhinoIdleManager idleManager, + IBridge parent, + ITopLevelExceptionHandler topLevelExceptionHandler + ) { + _idleManager = idleManager; + _topLevelExceptionHandler = topLevelExceptionHandler; Parent = parent; - RhinoDoc.SelectObjects += (_, _) => - { - idleManager.SubscribeToIdle(OnSelectionChanged); - }; - RhinoDoc.DeselectObjects += (_, _) => - { - idleManager.SubscribeToIdle(OnSelectionChanged); - }; - RhinoDoc.DeselectAllObjects += (_, _) => - { - idleManager.SubscribeToIdle(OnSelectionChanged); - }; + RhinoDoc.SelectObjects += OnSelectionChange; + RhinoDoc.DeselectObjects += OnSelectionChange; + RhinoDoc.DeselectAllObjects += OnSelectionChange; } - private void OnSelectionChanged() + void OnSelectionChange(object o, EventArgs eventArgs) + { + _idleManager.SubscribeToIdle(() => _topLevelExceptionHandler.CatchUnhandled(UpdateSelection)); + } + + private void UpdateSelection() { SelectionInfo selInfo = GetSelection(); - Parent?.Send(SELECTION_EVENT, selInfo); + Parent.Send(SELECTION_EVENT, selInfo); } public SelectionInfo GetSelection() diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSendBinding.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSendBinding.cs index b2c2ab1a20..96ed6aa8a0 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSendBinding.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSendBinding.cs @@ -36,6 +36,7 @@ public sealed class RhinoSendBinding : ISendBinding private HashSet ChangedObjectIds { get; set; } = new(); private readonly ISendConversionCache _sendConversionCache; + private readonly ITopLevelExceptionHandler _topLevelExceptionHandler; public RhinoSendBinding( DocumentModelStore store, @@ -46,7 +47,8 @@ public RhinoSendBinding( IUnitOfWorkFactory unitOfWorkFactory, RhinoSettings rhinoSettings, CancellationManager cancellationManager, - ISendConversionCache sendConversionCache + ISendConversionCache sendConversionCache, + ITopLevelExceptionHandler topLevelExceptionHandler ) { _store = store; @@ -57,6 +59,7 @@ ISendConversionCache sendConversionCache _rhinoSettings = rhinoSettings; _cancellationManager = cancellationManager; _sendConversionCache = sendConversionCache; + _topLevelExceptionHandler = topLevelExceptionHandler; Parent = parent; Commands = new SendBindingUICommands(parent); // POC: Commands are tightly coupled with their bindings, at least for now, saves us injecting a factory. SubscribeToRhinoEvents(); @@ -64,48 +67,45 @@ ISendConversionCache sendConversionCache private void SubscribeToRhinoEvents() { - // POC: It is unclear to me why is the binding keeping track of ChangedObjectIds. Change tracking should be moved to a separate type. - RhinoDoc.LayerTableEvent += (_, _) => - { - Commands.RefreshSendFilters(); - }; - RhinoDoc.AddRhinoObject += (_, e) => - { - // NOTE: This does not work if rhino starts and opens a blank doc; - if (!_store.IsDocumentInit) + _topLevelExceptionHandler.CatchUnhandled(() => { - return; - } + // NOTE: This does not work if rhino starts and opens a blank doc; + if (!_store.IsDocumentInit) + { + return; + } - ChangedObjectIds.Add(e.ObjectId.ToString()); - _idleManager.SubscribeToIdle(RunExpirationChecks); - }; + ChangedObjectIds.Add(e.ObjectId.ToString()); + _idleManager.SubscribeToIdle(RunExpirationChecks); + }); RhinoDoc.DeleteRhinoObject += (_, e) => - { - // NOTE: This does not work if rhino starts and opens a blank doc; - if (!_store.IsDocumentInit) + _topLevelExceptionHandler.CatchUnhandled(() => { - return; - } + // NOTE: This does not work if rhino starts and opens a blank doc; + if (!_store.IsDocumentInit) + { + return; + } - ChangedObjectIds.Add(e.ObjectId.ToString()); - _idleManager.SubscribeToIdle(RunExpirationChecks); - }; + ChangedObjectIds.Add(e.ObjectId.ToString()); + _idleManager.SubscribeToIdle(RunExpirationChecks); + }); RhinoDoc.ReplaceRhinoObject += (_, e) => - { - // NOTE: This does not work if rhino starts and opens a blank doc; - if (!_store.IsDocumentInit) + _topLevelExceptionHandler.CatchUnhandled(() => { - return; - } - - ChangedObjectIds.Add(e.NewRhinoObject.Id.ToString()); - ChangedObjectIds.Add(e.OldRhinoObject.Id.ToString()); - _idleManager.SubscribeToIdle(RunExpirationChecks); - }; + // NOTE: This does not work if rhino starts and opens a blank doc; + if (!_store.IsDocumentInit) + { + return; + } + + ChangedObjectIds.Add(e.NewRhinoObject.Id.ToString()); + ChangedObjectIds.Add(e.OldRhinoObject.Id.ToString()); + _idleManager.SubscribeToIdle(RunExpirationChecks); + }); } public List GetSendFilters() => _sendFilters; diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/RhinoDocumentStore.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/RhinoDocumentStore.cs index 2545b44089..40ac283bce 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/RhinoDocumentStore.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/RhinoDocumentStore.cs @@ -1,4 +1,5 @@ using Rhino; +using Speckle.Connectors.DUI.Bridge; using Speckle.Connectors.DUI.Models; using Speckle.Newtonsoft.Json; @@ -6,29 +7,35 @@ namespace Speckle.Connectors.Rhino7.HostApp; public class RhinoDocumentStore : DocumentModelStore { + private readonly ITopLevelExceptionHandler _topLevelExceptionHandler; private const string SPECKLE_KEY = "Speckle_DUI3"; public override bool IsDocumentInit { get; set; } = true; // Note: because of rhino implementation details regarding expiry checking of sender cards. - public RhinoDocumentStore(JsonSerializerSettings jsonSerializerSettings) + public RhinoDocumentStore( + JsonSerializerSettings jsonSerializerSettings, + ITopLevelExceptionHandler topLevelExceptionHandler + ) : base(jsonSerializerSettings, true) { - RhinoDoc.BeginOpenDocument += (_, _) => IsDocumentInit = false; + _topLevelExceptionHandler = topLevelExceptionHandler; + RhinoDoc.BeginOpenDocument += (_, _) => topLevelExceptionHandler.CatchUnhandled(() => IsDocumentInit = false); RhinoDoc.EndOpenDocument += (_, e) => - { - if (e.Merge) + topLevelExceptionHandler.CatchUnhandled(() => { - return; - } + if (e.Merge) + { + return; + } - if (e.Document == null) - { - return; - } + if (e.Document == null) + { + return; + } - IsDocumentInit = true; - ReadFromFile(); - OnDocumentChanged(); - }; + IsDocumentInit = true; + ReadFromFile(); + OnDocumentChanged(); + }); } public override void WriteToFile() @@ -38,10 +45,10 @@ public override void WriteToFile() return; // Should throw } - RhinoDoc.ActiveDoc?.Strings.Delete(SPECKLE_KEY); + RhinoDoc.ActiveDoc.Strings.Delete(SPECKLE_KEY); string serializedState = Serialize(); - RhinoDoc.ActiveDoc?.Strings.SetString(SPECKLE_KEY, SPECKLE_KEY, serializedState); + RhinoDoc.ActiveDoc.Strings.SetString(SPECKLE_KEY, SPECKLE_KEY, serializedState); } public override void ReadFromFile() diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI.WebView/DUI3ControlWebView.xaml.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI.WebView/DUI3ControlWebView.xaml.cs index 4e9cc6bcc5..c3153a0d5f 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI.WebView/DUI3ControlWebView.xaml.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI.WebView/DUI3ControlWebView.xaml.cs @@ -2,18 +2,23 @@ using System.Windows.Threading; using Microsoft.Web.WebView2.Core; using Speckle.Connectors.DUI.Bindings; +using Speckle.Connectors.DUI.Bridge; namespace Speckle.Connectors.DUI.WebView; public sealed partial class DUI3ControlWebView : UserControl { private readonly IEnumerable> _bindings; + private readonly ITopLevelExceptionHandler _topLevelExceptionHandler; - public DUI3ControlWebView(IEnumerable> bindings) + public DUI3ControlWebView(IEnumerable> bindings, ITopLevelExceptionHandler topLevelExceptionHandler) { _bindings = bindings; + _topLevelExceptionHandler = topLevelExceptionHandler; InitializeComponent(); - Browser.CoreWebView2InitializationCompleted += OnInitialized; + + Browser.CoreWebView2InitializationCompleted += (sender, args) => + _topLevelExceptionHandler.CatchUnhandled(() => OnInitialized(sender, args)); } private void ShowDevToolsMethod() => Browser.CoreWebView2.OpenDevToolsWindow(); @@ -30,9 +35,9 @@ private void ExecuteScriptAsyncMethod(string script) private void OnInitialized(object? sender, CoreWebView2InitializationCompletedEventArgs e) { - if (e.IsSuccess == false) + if (!e.IsSuccess) { - //POC: avoid silently accepting webview failures handle... + throw new InvalidOperationException("Webview Failed to initialize", e.InitializationException); } // We use Lazy here to delay creating the binding until after the Browser is fully initialized. diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/IBasicConnectorBinding.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/IBasicConnectorBinding.cs index 966be49fe2..7b38ee9fbd 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/IBasicConnectorBinding.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/IBasicConnectorBinding.cs @@ -45,7 +45,7 @@ public class BasicConnectorBindingCommands private const string NOTIFY_DOCUMENT_CHANGED_EVENT_NAME = "documentChanged"; private const string SET_MODEL_PROGRESS_UI_COMMAND_NAME = "setModelProgress"; private const string SET_MODEL_ERROR_UI_COMMAND_NAME = "setModelError"; - private const string SET_GLOBAL_NOTIFICATION = "setGlobalNotification"; + internal const string SET_GLOBAL_NOTIFICATION = "setGlobalNotification"; protected IBridge Bridge { get; } diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/BrowserBridge.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/BrowserBridge.cs index 2c27fccc38..aa26374558 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/BrowserBridge.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/BrowserBridge.cs @@ -1,7 +1,7 @@ +using System.Collections.Concurrent; using System.Reflection; using System.Runtime.InteropServices; using Speckle.Newtonsoft.Json; -using Speckle.Core.Logging; using Speckle.Connectors.DUI.Bindings; using System.Threading.Tasks.Dataflow; using System.Diagnostics; @@ -18,7 +18,7 @@ namespace Speckle.Connectors.DUI.Bridge; /// [ClassInterface(ClassInterfaceType.AutoDual)] [ComVisible(true)] -public class BrowserBridge : IBridge +public sealed class BrowserBridge : IBridge { /// /// The name under which we expect the frontend to hoist this bindings class to the global scope. @@ -26,17 +26,19 @@ public class BrowserBridge : IBridge /// private readonly JsonSerializerSettings _serializerOptions; - private readonly Dictionary _resultsStore = new(); + private readonly ConcurrentDictionary _resultsStore = new(); private readonly SynchronizationContext _mainThreadContext; + private readonly ITopLevelExceptionHandler _topLevelExceptionHandler; + + private IReadOnlyDictionary _bindingMethodCache = new Dictionary(); - private Dictionary BindingMethodCache { get; set; } = new(); private ActionBlock? _actionBlock; private Action? _scriptMethod; private IBinding? _binding; private Type? _bindingType; - private readonly ILogger _logger; + private readonly ILogger _logger; /// /// Action that opens up the developer tools of the respective browser we're using. While webview2 allows for "right click, inspect", cefsharp does not - hence the need for this. @@ -77,7 +79,7 @@ public BrowserBridge(JsonSerializerSettings jsonSerializerSettings, ILoggerFacto { _serializerOptions = jsonSerializerSettings; _logger = loggerFactory.CreateLogger(); - + _topLevelExceptionHandler = new TopLevelExceptionHandler(loggerFactory, this); //TODO: Probably we could inject this with a Lazy somewhere // Capture the main thread's SynchronizationContext _mainThreadContext = SynchronizationContext.Current; } @@ -96,38 +98,51 @@ Action showDevToolsAction _scriptMethod = scriptMethod; _bindingType = binding.GetType(); - BindingMethodCache = new Dictionary(); ShowDevToolsAction = showDevToolsAction; // Note: we need to filter out getter and setter methods here because they are not really nicely // supported across browsers, hence the !method.IsSpecialName. + var bindingMethodCache = new Dictionary(); foreach (var m in _bindingType.GetMethods().Where(method => !method.IsSpecialName)) { - BindingMethodCache[m.Name] = m; + bindingMethodCache[m.Name] = m; } + _bindingMethodCache = bindingMethodCache; // Whenever the ui will call run method inside .net, it will post a message to this action block. // This conveniently executes the code outside the UI thread and does not block during long operations (such as sending). - // POC: I wonder if TL exception handler should be living here... _actionBlock = new ActionBlock( - args => ExecuteMethod(args.MethodName, args.RequestId, args.MethodArgs), + OnActionBlock, new ExecutionDataflowBlockOptions { MaxDegreeOfParallelism = 1000, - CancellationToken = new CancellationTokenSource(TimeSpan.FromHours(3)).Token // Not sure we need such a long time. + CancellationToken = new CancellationTokenSource(TimeSpan.FromHours(3)).Token // Not sure we need such a long time. //TODO: This token source is not disposed.... } ); _logger.LogInformation("Bridge bound to front end name {FrontEndName}", binding.Name); } + private async Task OnActionBlock(RunMethodArgs args) + { + Result result = await _topLevelExceptionHandler + .CatchUnhandled(async () => await ExecuteMethod(args.MethodName, args.MethodArgs).ConfigureAwait(false)) + .ConfigureAwait(false); + + string resultJson = result.IsSuccess + ? JsonConvert.SerializeObject(result.Value, _serializerOptions) + : SerializeFormattedException(result.Exception); + + NotifyUIMethodCallResultReady(args.RequestId, resultJson); + } + /// /// Used by the Frontend bridge logic to understand which methods are available. /// /// public string[] GetBindingsMethodNames() { - var bindingNames = BindingMethodCache.Keys.ToArray(); + var bindingNames = _bindingMethodCache.Keys.ToArray(); Debug.WriteLine($"{FrontendBoundName}: " + JsonConvert.SerializeObject(bindingNames, Formatting.Indented)); return bindingNames; } @@ -140,14 +155,26 @@ public string[] GetBindingsMethodNames() /// public void RunMethod(string methodName, string requestId, string args) { - _actionBlock?.Post( - new RunMethodArgs + _topLevelExceptionHandler.CatchUnhandled(Post); + return; + + void Post() + { + bool wasAccepted = _actionBlock + .NotNull() + .Post( + new RunMethodArgs + { + MethodName = methodName, + RequestId = requestId, + MethodArgs = args + } + ); + if (!wasAccepted) { - MethodName = methodName, - RequestId = requestId, - MethodArgs = args + throw new InvalidOperationException($"Action block declined to Post ({methodName} {requestId} {args})"); } - ); + } } /// @@ -170,98 +197,78 @@ public void RunOnMainThread(Action action) /// Used by the action block to invoke the actual method called by the UI. /// /// - /// /// - /// - private void ExecuteMethod(string methodName, string requestId, string args) + /// The was not found or the given were not valid for the method call + /// The invoked method throws an exception + /// The Json + private async Task ExecuteMethod(string methodName, string args) { - // Note: You might be tempted to make this method async Task to prevent the task.Wait() below. - // Do not do that! Cef65 doesn't like waiting for async .NET methods. - // Note: we have this pokemon catch 'em all here because throwing errors in .NET is - // very risky, and we might crash the host application. Behaviour seems also to differ - // between various browser controls (e.g.: cefsharp handles things nicely - basically - // passing back the exception to the browser, but webview throws an access violation - // error that kills Rhino.). - try + if (!_bindingMethodCache.TryGetValue(methodName, out MethodInfo method)) { - if (!BindingMethodCache.TryGetValue(methodName, out MethodInfo method)) - { - throw new SpeckleException( - $"Cannot find method {methodName} in bindings class {_bindingType?.AssemblyQualifiedName}." - ); - } - - var parameters = method.GetParameters(); - var jsonArgsArray = JsonConvert.DeserializeObject(args); - if (parameters.Length != jsonArgsArray?.Length) - { - throw new SpeckleException( - $"Wrong number of arguments when invoking binding function {methodName}, expected {parameters.Length}, but got {jsonArgsArray?.Length}." - ); - } - - var typedArgs = new object[jsonArgsArray.Length]; - - for (int i = 0; i < typedArgs.Length; i++) - { - var ccc = JsonConvert.DeserializeObject(jsonArgsArray[i], parameters[i].ParameterType, _serializerOptions); - if (ccc is null) - { - continue; - } - - typedArgs[i] = ccc; - } - - var resultTyped = method.Invoke(Binding, typedArgs); + throw new ArgumentException( + $"Cannot find method {methodName} in bindings class {_bindingType?.AssemblyQualifiedName}.", + nameof(methodName) + ); + } - string resultJson; + var parameters = method.GetParameters(); + var jsonArgsArray = JsonConvert.DeserializeObject(args); + if (parameters.Length != jsonArgsArray?.Length) + { + throw new ArgumentException( + $"Wrong number of arguments when invoking binding function {methodName}, expected {parameters.Length}, but got {jsonArgsArray?.Length}.", + nameof(args) + ); + } - // Was the method called async? - if (resultTyped is not Task resultTypedTask) - { - // Regular method: no need to await things - resultJson = JsonConvert.SerializeObject(resultTyped, _serializerOptions); - } - else // It's an async call - { - // See note at start of function. Do not asyncify! - resultTypedTask.GetAwaiter().GetResult(); + var typedArgs = new object?[jsonArgsArray.Length]; - // If has a "Result" property return the value otherwise null (Task etc) - PropertyInfo resultProperty = resultTypedTask.GetType().GetProperty("Result"); - object? taskResult = resultProperty?.GetValue(resultTypedTask); - resultJson = JsonConvert.SerializeObject(taskResult, _serializerOptions); - } + for (int i = 0; i < typedArgs.Length; i++) + { + var ccc = JsonConvert.DeserializeObject(jsonArgsArray[i], parameters[i].ParameterType, _serializerOptions); + typedArgs[i] = ccc; + } - NotifyUIMethodCallResultReady(requestId, resultJson); + object? resultTyped; + try + { + resultTyped = method.Invoke(Binding, typedArgs); + } + catch (TargetInvocationException ex) + { + throw new TargetInvocationException($"Unhandled exception while executing {methodName}", ex.InnerException); } - // TOP-LEVEL: Where we report unhandled exceptions as global toast notification in UI! - catch (Exception e) when (!e.IsFatal()) + + // Was the method called async? + if (resultTyped is not Task resultTypedTask) { - ReportUnhandledError(requestId, e); + // Regular method: no need to await things + return resultTyped; } + + // It's an async call + await resultTypedTask.ConfigureAwait(false); + + // If has a "Result" property return the value otherwise null (Task etc) + PropertyInfo? resultProperty = resultTypedTask.GetType().GetProperty(nameof(Task.Result)); + object? taskResult = resultProperty?.GetValue(resultTypedTask); + return taskResult; } /// /// Errors that not handled on bindings. /// - private void ReportUnhandledError(string requestId, Exception e) + private string SerializeFormattedException(Exception e) { - var message = e.Message; - if (e is TargetInvocationException tie) // Exception on SYNC function calls. Message should be passed from inner exception since it is wrapped. - { - message = tie.InnerException?.Message; - } + //TODO: I'm not sure we still require this... the top level handler is already displaying the toast var errorDetails = new { - Message = message, // Topmost message + Message = e.Message, // Topmost message Error = e.ToFormattedString(), // All messages from exceptions - StackTrace = e.ToString() + StackTrace = e.ToString(), }; - var serializedError = JsonConvert.SerializeObject(errorDetails, _serializerOptions); - NotifyUIMethodCallResultReady(requestId, serializedError); + return JsonConvert.SerializeObject(errorDetails, _serializerOptions); } /// @@ -284,8 +291,11 @@ private void NotifyUIMethodCallResultReady(string requestId, string? serializedD /// public string? GetCallResult(string requestId) { - var res = _resultsStore[requestId]; - _resultsStore.Remove(requestId); + bool isFound = _resultsStore.TryRemove(requestId, out string? res); + if (!isFound) + { + throw new ArgumentException($"No result for the given request id was found: {requestId}", nameof(requestId)); + } return res; } @@ -306,6 +316,11 @@ public void OpenUrl(string url) public void Send(string eventName) { + if (_binding is null) + { + throw new InvalidOperationException("Bridge was not Initialized"); + } + var script = $"{FrontendBoundName}.emit('{eventName}')"; _scriptMethod.NotNull().Invoke(script); @@ -314,6 +329,11 @@ public void Send(string eventName) public void Send(string eventName, T data) where T : class { + if (_binding is null) + { + throw new InvalidOperationException("Bridge was not associated with a binding"); + } + string payload = JsonConvert.SerializeObject(data, _serializerOptions); string requestId = $"{Guid.NewGuid()}_{eventName}"; _resultsStore[requestId] = payload; diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/IBridge.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/IBridge.cs index 1bdcd6e364..3b26e58d82 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/IBridge.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/IBridge.cs @@ -36,8 +36,13 @@ public interface IBridge /// Action to run on main thread. public void RunOnMainThread(Action action); + /// + /// Bridge was not associated with a binding public void Send(string eventName); + /// + /// data to store + /// public void Send(string eventName, T data) where T : class; } diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/TopLevelExceptionHandler.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/TopLevelExceptionHandler.cs new file mode 100644 index 0000000000..679303cfe9 --- /dev/null +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/TopLevelExceptionHandler.cs @@ -0,0 +1,135 @@ +using System.Diagnostics.CodeAnalysis; +using Microsoft.Extensions.Logging; +using Speckle.Connectors.DUI.Bindings; +using Speckle.Connectors.Utils; +using Speckle.Core.Logging; +using Speckle.Core.Models.Extensions; +using Speckle.InterfaceGenerator; + +namespace Speckle.Connectors.DUI.Bridge; + +/// +/// Result Pattern struct +/// +/// +public readonly struct Result +{ + //Don't add new members to this struct, it is perfect. + public T? Value { get; } + public Exception? Exception { get; } + + [MemberNotNullWhen(false, nameof(Exception))] + public bool IsSuccess => Exception is null; + + /// + /// Create a successful result + /// + /// + public Result(T result) + { + Value = result; + } + + /// + /// Create a non-sucessful result + /// + /// + /// was null + public Result([NotNull] Exception? result) + { + Exception = result.NotNull(); + } +} + +/// +/// The functions provided by this class are designed to be used in all "top level" scenarios (e.g. Plugin, UI, and Event callbacks) +/// To provide "last ditch effort" handling of unexpected exceptions that have not been handled. +/// 1. Log events to the injected +/// 2. Display a toast notification with exception details +///
+///
+/// +/// exceptions cannot be recovered from. +/// They will be rethrown to allow the host app to run its handlers
+/// Depending on the host app, this may trigger windows event logging, and recovery snapshots before ultimately terminating the process
+/// Attempting to swallow them may lead to data corruption, deadlocking, or things worse than a managed host app crash. +///
+[GenerateAutoInterface] +public sealed class TopLevelExceptionHandler : ITopLevelExceptionHandler +{ + private readonly ILogger _logger; + private readonly IBridge _bridge; + + private const string UNHANDLED_LOGGER_TEMPLATE = "An unhandled Exception occured"; + + public TopLevelExceptionHandler(ILoggerFactory loggerFactory, IBridge bridge) + { + _logger = loggerFactory.CreateLogger(); + _bridge = bridge; + } + + /// + /// Invokes the given function within a / block, + /// and provides exception handling for unexpected exceptions that have not been handled.
+ ///
+ /// The function to invoke and provide error handling for + /// will be rethrown, these should be allowed to bubble up to the host app + /// + public void CatchUnhandled(Action function) + { + CatchUnhandled(() => + { + function.Invoke(); + return (object?)null; + }); + } + + /// + /// return type + /// A result pattern struct (where exceptions have been handled) + public Result CatchUnhandled(Func function) + { + return CatchUnhandled(() => Task.FromResult(function.Invoke())).Result; + } + + /// + public async Task> CatchUnhandled(Func> function) + { + try + { + try + { + return new(await function.Invoke().ConfigureAwait(false)); + } + catch (Exception ex) when (!ex.IsFatal()) + { + _logger.LogError(ex, UNHANDLED_LOGGER_TEMPLATE); + + SetGlobalNotification( + ToastNotificationType.DANGER, + "Unhandled Exception Occured", + ex.ToFormattedString(), + false + ); + return new(ex); + } + } + catch (Exception ex) + { + _logger.LogCritical(ex, UNHANDLED_LOGGER_TEMPLATE); + throw; + } + } + + private void SetGlobalNotification(ToastNotificationType type, string title, string message, bool autoClose) => + _bridge.Send( + BasicConnectorBindingCommands.SET_GLOBAL_NOTIFICATION, //TODO: We could move these constants into a DUI3 constants static class + new + { + type, + title, + description = message, + autoClose + } + ); +} diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/ContainerRegistration.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/ContainerRegistration.cs index 6671c44837..affb3e031b 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/ContainerRegistration.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/ContainerRegistration.cs @@ -18,7 +18,7 @@ public static void AddDUI(this SpeckleContainerBuilder speckleContainerBuilder) speckleContainerBuilder.AddTransient(); speckleContainerBuilder.AddSingleton(); speckleContainerBuilder.AddTransient(); // POC: Each binding should have it's own bridge instance - + speckleContainerBuilder.AddSingleton(); speckleContainerBuilder.AddSingleton(GetJsonSerializerSettings()); } diff --git a/DUI3-DX/Sdk/Speckle.Connectors.Utils/ContainerRegistration.cs b/DUI3-DX/Sdk/Speckle.Connectors.Utils/ContainerRegistration.cs index b444f9ba95..3168ac7709 100644 --- a/DUI3-DX/Sdk/Speckle.Connectors.Utils/ContainerRegistration.cs +++ b/DUI3-DX/Sdk/Speckle.Connectors.Utils/ContainerRegistration.cs @@ -3,6 +3,7 @@ using Speckle.Autofac.DependencyInjection; using Speckle.Connectors.Utils.Cancellation; using Speckle.Connectors.Utils.Operations; +using Speckle.Core.Logging; namespace Speckle.Connectors.Utils; @@ -14,11 +15,8 @@ public static void AddConnectorUtils(this SpeckleContainerBuilder builder) builder.AddSingleton(); builder.AddScoped(); - // POC: will likely need refactoring with our reporting pattern. - var serilogLogger = new LoggerConfiguration().MinimumLevel - .Debug() - .WriteTo.File("log.txt", rollingInterval: RollingInterval.Day) - .CreateLogger(); + //TODO: Logger will likely be removed from Core, we'll plan to figure out the config later... + var serilogLogger = SpeckleLog.Logger; ILoggerFactory loggerFactory = new LoggerFactory().AddSerilog(serilogLogger); builder.AddSingleton(loggerFactory); From 207753c49ee319c45db79231126641b9498bc7de Mon Sep 17 00:00:00 2001 From: Adam Hathcock Date: Tue, 25 Jun 2024 11:10:30 +0100 Subject: [PATCH 243/261] Rhino interfaces for testing (#3523) * add root converter with fallback and tests * proper references * Converters work * fmt * added test! * fmt * One converter to rhino interfaces * more converters done * more converters done! * even more converters * more conversions * more top level converters * all rhino types converted * doing Rhino loading and testing * type moving around * update and use interfaces * using clean up * clean up * Change reflection * update host api and add tests * add no build for tests * revert for circular dependency * to host fixes * update host apis and lock files * fmt * fixes curves! --- Build/Consts.cs | 6 +- Build/Program.cs | 2 +- .../packages.lock.json | 8 +-- .../packages.lock.json | 8 +-- .../packages.lock.json | 17 +++--- .../DependencyInjection/ProxyMapper.cs | 17 ++++++ .../Bindings/RhinoSelectionBinding.cs | 4 +- .../Bindings/RhinoSendBinding.cs | 7 +-- .../DependencyInjection/ProxyMapper.cs | 17 ++++++ .../RhinoConnectorModule.cs | 7 ++- .../DependencyInjection/RhinoPlugin.cs | 12 ++-- .../HostApp/RhinoContext.cs | 8 --- .../HostApp/RhinoIdleManager.cs | 4 +- .../Interfaces/IRhinoPlugin.cs | 7 --- .../Operations/Receive/DisableRedrawScope.cs | 8 +-- .../Receive/RhinoHostObjectBuilder.cs | 51 +++++++++------- .../Plugin/Speckle.Connectors.Rhino7Plugin.cs | 2 +- .../Speckle.Connectors.Rhino7.csproj | 3 +- .../packages.lock.json | 48 ++++++++++++--- .../packages.lock.json | 8 +-- .../packages.lock.json | 8 +-- .../packages.lock.json | 8 +-- .../packages.lock.json | 8 +-- .../RevitConverterModule.cs | 1 - ...rters.Revit2023.DependencyInjection.csproj | 2 +- .../packages.lock.json | 17 +++--- .../Speckle.Converters.Revit2023.Tests.csproj | 2 +- .../packages.lock.json | 11 ++-- .../Speckle.Converters.Revit2023.csproj | 2 +- .../packages.lock.json | 9 ++- .../RhinoConverterModule.cs | 7 ++- .../RhinoRootElementProvider.cs | 9 +++ ...nverters.Rhino7.DependencyInjection.csproj | 2 +- .../packages.lock.json | 24 +++----- .../Speckle.Converters.Rhino7/GlobalUsings.cs | 1 - .../RhinoConversionContextStack.cs | 11 ++-- .../RhinoToSpeckleUnitConverter.cs | 30 ++++----- .../Speckle.Converters.Rhino7.csproj | 5 +- ...ckleToHostGeometryBaseTopLevelConverter.cs | 17 +++--- .../ToHost/Raw/ArcToHostConverter.cs | 32 +++++----- .../ToHost/Raw/BrepToHostConverter.cs | 57 +++++++++-------- .../ToHost/Raw/CircleToHostConverter.cs | 38 +++++++----- .../ToHost/Raw/CurveToHostConverter.cs | 41 +++++++------ .../ToHost/Raw/EllipseToHostConverter.cs | 36 ++++++----- .../Raw/FlatPointListToHostConverter.cs | 21 ++++--- .../ToHost/Raw/IntervalToHostConverter.cs | 14 ++++- .../ToHost/Raw/LineToHostConverter.cs | 21 ++++--- .../ToHost/Raw/MeshToHostConverter.cs | 44 +++++++------ .../ToHost/Raw/NurbsCurveToHostConverter.cs | 25 +++++--- .../ToHost/Raw/PlaneToHostConverter.cs | 18 +++--- .../ToHost/Raw/PointCloudToHostConverter.cs | 17 ++++-- .../ToHost/Raw/PointToHostConverter.cs | 15 ++++- .../ToHost/Raw/PolyCurveToHostConverter.cs | 21 ++++--- .../ToHost/Raw/PolylineToHostConverter.cs | 27 ++++---- .../ToHost/Raw/SpiralToHostConverter.cs | 13 ++-- .../ToHost/Raw/SurfaceToHostConverter.cs | 18 ++++-- .../ToHost/Raw/VectorToHostConverter.cs | 12 +++- .../TopLevel/ArcToHostTopLevelConverter.cs | 13 ++-- .../TopLevel/BrepToHostTopLevelConverter.cs | 13 ++-- .../TopLevel/CircleToHostTopLevelConverter.cs | 13 ++-- .../EllipseToHostTopLevelConverter.cs | 13 ++-- .../FallbackToHostTopLevelConverter.cs | 37 +++++------ .../TopLevel/LineToHostTopLevelConverter.cs | 13 ++-- .../TopLevel/MeshToHostTopLevelConverter.cs | 13 ++-- .../NurbsCurveToHostTopLevelConverter.cs | 13 ++-- .../PointCloudToHostTopLevelConverter.cs | 13 ++-- .../TopLevel/PointToHostTopLevelConverter.cs | 13 ++-- .../PolycurveToHostTopLevelConverter.cs | 14 +++-- .../PolylineToHostTopLevelConverter.cs | 13 ++-- .../Raw/ArcCurveToSpeckleConverter.cs | 28 ++++----- .../ToSpeckle/Raw/ArcToSpeckleConverter.cs | 29 +++++---- .../ToSpeckle/Raw/BoxToSpeckleConverter.cs | 20 +++--- .../ToSpeckle/Raw/BrepToSpeckleConverter.cs | 61 ++++++++++--------- .../ToSpeckle/Raw/CircleToSpeckleConverter.cs | 22 +++---- .../Raw/ControlPointToSpeckleConverter.cs | 15 ++--- .../ToSpeckle/Raw/CurveToSpeckleConverter.cs | 57 +++++++++++------ .../Raw/EllipseToSpeckleConverter.cs | 25 ++++---- .../Raw/IntervalToSpeckleConverter.cs | 5 +- .../ToSpeckle/Raw/LineToSpeckleConverter.cs | 27 ++++---- .../ToSpeckle/Raw/MeshToSpeckleConverter.cs | 28 ++++----- .../ToSpeckle/Raw/NurbsCurveConverter.cs | 33 +++++----- .../Raw/NurbsSurfaceToSpeckleConverter.cs | 32 +++++----- .../ToSpeckle/Raw/PlaneToSpeckleConverter.cs | 18 +++--- .../ToSpeckle/Raw/PointToSpeckleConverter.cs | 15 +++-- .../Raw/PolyCurveToSpeckleConverter.cs | 26 ++++---- .../Raw/PolylineToSpeckleConverter.cs | 39 ++++++------ .../ToSpeckle/Raw/RawPointCloudToSpeckle.cs | 21 ++++--- .../ToSpeckle/Raw/VectorToSpeckleConverter.cs | 12 ++-- .../BrepObjectToSpeckleTopLevelConverter.cs | 12 ++-- .../CurveObjectToSpeckleTopLevelConverter.cs | 13 ++-- ...trusionObjectToSpeckleTopLevelConverter.cs | 12 ++-- .../MeshObjectToSpeckleTopLevelConverter.cs | 13 ++-- ...ntCloudObjectToSpeckleTopLevelConverter.cs | 12 ++-- .../PointObjectToSpeckleTopLevelConverter.cs | 12 ++-- .../RhinoObjectToSpeckleTopLevelConverter.cs | 12 ++-- .../packages.lock.json | 20 +++--- .../ContainerRegistration.cs | 1 + .../packages.lock.json | 8 +-- .../RootToSpeckleConverterTests.cs | 3 +- .../Speckle.Converters.Common.Tests.csproj | 2 +- .../packages.lock.json | 9 ++- .../Speckle.Converters.Common/IProxyMapper.cs | 33 ++++++++++ .../RootConvertManager.cs | 2 +- .../RootToSpeckleConverter.cs | 1 - .../Speckle.Converters.Common.csproj | 3 - .../packages.lock.json | 6 -- 106 files changed, 979 insertions(+), 777 deletions(-) create mode 100644 DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/ProxyMapper.cs create mode 100644 DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/ProxyMapper.cs delete mode 100644 DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/RhinoContext.cs delete mode 100644 DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Interfaces/IRhinoPlugin.cs create mode 100644 DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/RhinoRootElementProvider.cs create mode 100644 DUI3-DX/Sdk/Speckle.Converters.Common/IProxyMapper.cs diff --git a/Build/Consts.cs b/Build/Consts.cs index 48a14139b0..2fa9d8deaa 100644 --- a/Build/Consts.cs +++ b/Build/Consts.cs @@ -5,7 +5,11 @@ namespace Build; public static class Consts { public static readonly string[] Solutions = { "DUI3-DX.slnf" }; - public static readonly string[] TestProjects = { "Speckle.Converters.Revit2023.Tests" }; + public static readonly string[] TestProjects = + { + "Speckle.Converters.Revit2023.Tests", + "Speckle.Converters.Common.Tests" + }; public static readonly InstallerProject[] InstallerManifests = { diff --git a/Build/Program.cs b/Build/Program.cs index a6d5ff9bc1..610115c621 100644 --- a/Build/Program.cs +++ b/Build/Program.cs @@ -127,7 +127,7 @@ IEnumerable GetFiles(string d) foreach (var file in GetFiles($"**/{t}.csproj")) { - Run("dotnet", $"test {file} -c Release --no-restore --verbosity=normal"); + Run("dotnet", $"test {file} -c Release --no-build --no-restore --verbosity=normal"); } } ); diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/packages.lock.json b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/packages.lock.json index 3b14166e57..5306011fc3 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/packages.lock.json +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/packages.lock.json @@ -302,11 +302,6 @@ "resolved": "13.0.2", "contentHash": "g1BejUZwax5PRfL6xHgLEK23sqHWOgOj9hE7RvfRRlN00AGt8GnPYt8HedSK7UB3HiRW8zCA9Pn0iiYxCK24BA==" }, - "Speckle.Revit2023.Interfaces": { - "type": "Transitive", - "resolved": "0.1.1-preview.0.24", - "contentHash": "BSVpOUJc9g6ISrw8GxvtkglTlITpHEDYNOhxv1ZPbckBsI0yO36JiphhQV4q57ERqD9PpCozUJkVhlCaxWeS6A==" - }, "SQLitePCLRaw.bundle_e_sqlite3": { "type": "Transitive", "resolved": "2.1.4", @@ -431,8 +426,7 @@ "type": "Project", "dependencies": { "Speckle.Autofac": "[2.0.999-local, )", - "Speckle.Objects": "[2.0.999-local, )", - "Speckle.Revit2023.Interfaces": "[0.1.1-preview.0.24, )" + "Speckle.Objects": "[2.0.999-local, )" } }, "speckle.converters.common.dependencyinjection": { diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.Autocad2023/packages.lock.json b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.Autocad2023/packages.lock.json index b584dc45f9..ecbfc4fb09 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.Autocad2023/packages.lock.json +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.Autocad2023/packages.lock.json @@ -279,11 +279,6 @@ "resolved": "13.0.2", "contentHash": "g1BejUZwax5PRfL6xHgLEK23sqHWOgOj9hE7RvfRRlN00AGt8GnPYt8HedSK7UB3HiRW8zCA9Pn0iiYxCK24BA==" }, - "Speckle.Revit2023.Interfaces": { - "type": "Transitive", - "resolved": "0.1.1-preview.0.24", - "contentHash": "BSVpOUJc9g6ISrw8GxvtkglTlITpHEDYNOhxv1ZPbckBsI0yO36JiphhQV4q57ERqD9PpCozUJkVhlCaxWeS6A==" - }, "SQLitePCLRaw.bundle_e_sqlite3": { "type": "Transitive", "resolved": "2.1.4", @@ -487,8 +482,7 @@ "type": "Project", "dependencies": { "Speckle.Autofac": "[2.0.999-local, )", - "Speckle.Objects": "[2.0.999-local, )", - "Speckle.Revit2023.Interfaces": "[0.1.1-preview.0.24, )" + "Speckle.Objects": "[2.0.999-local, )" } }, "speckle.converters.common.dependencyinjection": { diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.Revit2023/packages.lock.json b/DUI3-DX/Connectors/Revit/Speckle.Connectors.Revit2023/packages.lock.json index 9039fbd17b..27da03b1ba 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.Revit2023/packages.lock.json +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.Revit2023/packages.lock.json @@ -315,18 +315,18 @@ }, "Speckle.Revit2023.Api": { "type": "Transitive", - "resolved": "0.1.1-preview.0.24", - "contentHash": "hPRXbyvgmealdPPWTxjHbpBRTsyt67DddoIs09M0n319eHh/eONnPC+SgBzJmmB834TtzzayMVk06S1cMT0Iow==", + "resolved": "0.1.1-preview.0.28", + "contentHash": "ejwYS/HI8yy0rJE4vgTr5aj8Fkg/E9JnMGjwyVS2fLtI4f7+FmwAY6inTUT2p/RAoRc2nQw+TerDpUtOhddzag==", "dependencies": { "Mapster": "7.3.0", "Speckle.Revit.API": "2023.0.0", - "Speckle.Revit2023.Interfaces": "0.1.1-preview.0.24" + "Speckle.Revit2023.Interfaces": "0.1.1-preview.0.28" } }, "Speckle.Revit2023.Interfaces": { "type": "Transitive", - "resolved": "0.1.1-preview.0.24", - "contentHash": "BSVpOUJc9g6ISrw8GxvtkglTlITpHEDYNOhxv1ZPbckBsI0yO36JiphhQV4q57ERqD9PpCozUJkVhlCaxWeS6A==" + "resolved": "0.1.1-preview.0.28", + "contentHash": "7szXg/vRvP3Wdrn2ZGriVOfsw+bddlpVorBkCIhSHHs5qVTTG8IAIrI1l9dO0/aullaTMF+Xgxm9x3w1aXPiuA==" }, "SQLitePCLRaw.bundle_e_sqlite3": { "type": "Transitive", @@ -514,8 +514,7 @@ "type": "Project", "dependencies": { "Speckle.Autofac": "[2.0.999-local, )", - "Speckle.Objects": "[2.0.999-local, )", - "Speckle.Revit2023.Interfaces": "[0.1.1-preview.0.24, )" + "Speckle.Objects": "[2.0.999-local, )" } }, "speckle.converters.common.dependencyinjection": { @@ -529,7 +528,7 @@ "type": "Project", "dependencies": { "Speckle.Converters.Common": "[2.0.999-local, )", - "Speckle.Revit2023.Interfaces": "[0.1.1-preview.0.24, )" + "Speckle.Revit2023.Interfaces": "[0.1.1-preview.0.28, )" } }, "speckle.converters.revit2023.dependencyinjection": { @@ -538,7 +537,7 @@ "Speckle.Converters.Common": "[2.0.999-local, )", "Speckle.Converters.Common.DependencyInjection": "[2.0.999-local, )", "Speckle.Converters.Revit2023": "[2.0.999-local, )", - "Speckle.Revit2023.Api": "[0.1.1-preview.0.24, )" + "Speckle.Revit2023.Api": "[0.1.1-preview.0.28, )" } }, "Speckle.Core": { diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/ProxyMapper.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/ProxyMapper.cs new file mode 100644 index 0000000000..e4e997c4e2 --- /dev/null +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/ProxyMapper.cs @@ -0,0 +1,17 @@ +using Speckle.Converters.Common; +using Speckle.ProxyGenerator; + +namespace Speckle.Connectors.Revit.DependencyInjection; + +public class ProxyMapper : IProxyMapper +{ + public Type? GetMappedTypeFromHostType(Type type) => ProxyMap.GetMappedTypeFromHostType(type); + + public Type? GetMappedTypeFromProxyType(Type type) => ProxyMap.GetMappedTypeFromProxyType(type); + + public Type? GetHostTypeFromMappedType(Type type) => ProxyMap.GetHostTypeFromMappedType(type); + + public object CreateProxy(Type type, object toWrap) => ProxyMap.CreateProxy(type, toWrap); + + public T CreateProxy(object toWrap) => ProxyMap.CreateProxy(toWrap); +} diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSelectionBinding.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSelectionBinding.cs index ded20ed05f..dcb7c57fcf 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSelectionBinding.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSelectionBinding.cs @@ -8,7 +8,7 @@ namespace Speckle.Connectors.Rhino7.Bindings; public class RhinoSelectionBinding : ISelectionBinding { - private readonly RhinoIdleManager _idleManager; + private readonly IRhinoIdleManager _idleManager; private readonly ITopLevelExceptionHandler _topLevelExceptionHandler; private const string SELECTION_EVENT = "setSelection"; @@ -16,7 +16,7 @@ public class RhinoSelectionBinding : ISelectionBinding public IBridge Parent { get; } public RhinoSelectionBinding( - RhinoIdleManager idleManager, + IRhinoIdleManager idleManager, IBridge parent, ITopLevelExceptionHandler topLevelExceptionHandler ) diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSendBinding.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSendBinding.cs index 96ed6aa8a0..f0fd3a63d3 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSendBinding.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSendBinding.cs @@ -23,10 +23,9 @@ public sealed class RhinoSendBinding : ISendBinding public IBridge Parent { get; } private readonly DocumentModelStore _store; - private readonly RhinoIdleManager _idleManager; + private readonly IRhinoIdleManager _idleManager; private readonly IUnitOfWorkFactory _unitOfWorkFactory; private readonly List _sendFilters; - private readonly SendOperation _sendOperation; private readonly CancellationManager _cancellationManager; private readonly RhinoSettings _rhinoSettings; @@ -40,10 +39,9 @@ public sealed class RhinoSendBinding : ISendBinding public RhinoSendBinding( DocumentModelStore store, - RhinoIdleManager idleManager, + IRhinoIdleManager idleManager, IBridge parent, IEnumerable sendFilters, - SendOperation sendOperation, IUnitOfWorkFactory unitOfWorkFactory, RhinoSettings rhinoSettings, CancellationManager cancellationManager, @@ -54,7 +52,6 @@ ITopLevelExceptionHandler topLevelExceptionHandler _store = store; _idleManager = idleManager; _unitOfWorkFactory = unitOfWorkFactory; - _sendOperation = sendOperation; _sendFilters = sendFilters.ToList(); _rhinoSettings = rhinoSettings; _cancellationManager = cancellationManager; diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/ProxyMapper.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/ProxyMapper.cs new file mode 100644 index 0000000000..dabeb71d95 --- /dev/null +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/ProxyMapper.cs @@ -0,0 +1,17 @@ +using Speckle.Converters.Common; +using Speckle.ProxyGenerator; + +namespace Speckle.Connectors.Rhino7.DependencyInjection; + +public class ProxyMapper : IProxyMapper +{ + public Type? GetMappedTypeFromHostType(Type type) => ProxyMap.GetMappedTypeFromHostType(type); + + public Type? GetMappedTypeFromProxyType(Type type) => ProxyMap.GetMappedTypeFromProxyType(type); + + public Type? GetHostTypeFromMappedType(Type type) => ProxyMap.GetHostTypeFromMappedType(type); + + public object CreateProxy(Type type, object toWrap) => ProxyMap.CreateProxy(type, toWrap); + + public T CreateProxy(object toWrap) => ProxyMap.CreateProxy(toWrap); +} diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/RhinoConnectorModule.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/RhinoConnectorModule.cs index a227755c66..16cdc3a7de 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/RhinoConnectorModule.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/RhinoConnectorModule.cs @@ -10,7 +10,6 @@ using Speckle.Connectors.Rhino7.Bindings; using Speckle.Connectors.Rhino7.Filters; using Speckle.Connectors.Rhino7.HostApp; -using Speckle.Connectors.Rhino7.Interfaces; using Speckle.Connectors.Rhino7.Operations.Send; using Speckle.Connectors.Rhino7.Plugin; using Speckle.Connectors.Utils.Cancellation; @@ -21,7 +20,9 @@ using Speckle.Connectors.Utils.Builders; using Speckle.Connectors.Utils.Caching; using Speckle.Connectors.Utils.Operations; +using Speckle.Converters.Common; using Speckle.Core.Models.GraphTraversal; +using Speckle.Rhino7.Api; namespace Speckle.Connectors.Rhino7.DependencyInjection; @@ -37,6 +38,7 @@ public void Load(SpeckleContainerBuilder builder) builder.AddConnectorUtils(); builder.AddDUI(); builder.AddDUIView(); + builder.ScanAssemblyOfType(); // POC: Overwriting the SyncToMainThread to SyncToCurrentThread for Rhino! builder.AddSingletonInstance(); @@ -44,7 +46,8 @@ public void Load(SpeckleContainerBuilder builder) // Register other connector specific types builder.AddSingleton(); builder.AddSingleton(); - builder.AddSingleton(); + builder.AddSingleton(); + builder.AddSingleton(); // Register bindings builder.AddSingleton(); diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/RhinoPlugin.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/RhinoPlugin.cs index a295f9f8b6..2262f93f9f 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/RhinoPlugin.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/RhinoPlugin.cs @@ -1,21 +1,17 @@ using Rhino; -using Speckle.Connectors.DUI.WebView; using Speckle.Connectors.Rhino7.HostApp; -using Speckle.Connectors.Rhino7.Interfaces; using Speckle.Connectors.Rhino7.Plugin; +using Speckle.InterfaceGenerator; namespace Speckle.Connectors.Rhino7.DependencyInjection; +[GenerateAutoInterface] public class RhinoPlugin : IRhinoPlugin { - private readonly RhinoIdleManager _idleManager; - private readonly DUI3ControlWebView _panel; - private readonly RhinoSettings _settings; + private readonly IRhinoIdleManager _idleManager; - public RhinoPlugin(DUI3ControlWebView panel, RhinoSettings settings, RhinoIdleManager idleManager) + public RhinoPlugin(IRhinoIdleManager idleManager) { - _panel = panel; - _settings = settings; _idleManager = idleManager; } diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/RhinoContext.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/RhinoContext.cs deleted file mode 100644 index 17b532035a..0000000000 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/RhinoContext.cs +++ /dev/null @@ -1,8 +0,0 @@ -using Rhino; - -namespace Speckle.Connectors.Rhino7.HostApp; - -public class RhinoContext -{ - public RhinoDoc Document { get; } = RhinoDoc.ActiveDoc; -} diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/RhinoIdleManager.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/RhinoIdleManager.cs index 374d979750..5a88ed6c20 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/RhinoIdleManager.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/RhinoIdleManager.cs @@ -1,12 +1,14 @@ using System.Collections.Concurrent; using Rhino; +using Speckle.InterfaceGenerator; namespace Speckle.Connectors.Rhino7.HostApp; /// /// Rhino Idle Manager is a helper util to manage deferred actions. /// -public class RhinoIdleManager +[GenerateAutoInterface] +public class RhinoIdleManager : IRhinoIdleManager { // NOTE: ConcurrentDictionary possibly removing the collection has been modified errors in here private readonly ConcurrentDictionary _sCalls = new(); diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Interfaces/IRhinoPlugin.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Interfaces/IRhinoPlugin.cs deleted file mode 100644 index 487c2968f5..0000000000 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Interfaces/IRhinoPlugin.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Speckle.Connectors.Rhino7.Interfaces; - -public interface IRhinoPlugin -{ - void Initialise(); - void Shutdown(); -} diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Receive/DisableRedrawScope.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Receive/DisableRedrawScope.cs index 1182e5de7a..621bfa45ed 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Receive/DisableRedrawScope.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Receive/DisableRedrawScope.cs @@ -1,16 +1,16 @@ -using Rhino.DocObjects.Tables; +using Speckle.Rhino7.Interfaces; namespace Speckle.Connectors.Rhino7.Operations.Receive; /// -/// Helper class to disable within a scope +/// Helper class to disable within a scope /// public sealed class DisableRedrawScope : IDisposable { - private readonly ViewTable _viewTable; + private readonly IRhinoViewTable _viewTable; private readonly bool _returnToStatus; - public DisableRedrawScope(ViewTable viewTable, bool returnToStatus = true) + public DisableRedrawScope(IRhinoViewTable viewTable, bool returnToStatus = true) { _viewTable = viewTable; _returnToStatus = returnToStatus; diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Receive/RhinoHostObjectBuilder.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Receive/RhinoHostObjectBuilder.cs index 02f653f08a..6c73b9bd10 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Receive/RhinoHostObjectBuilder.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Receive/RhinoHostObjectBuilder.cs @@ -1,31 +1,32 @@ using System.Diagnostics.Contracts; -using Rhino; -using Rhino.DocObjects; -using Rhino.Geometry; using Speckle.Connectors.Utils.Builders; using Speckle.Connectors.Utils.Conversion; using Speckle.Converters.Common; using Speckle.Core.Logging; using Speckle.Core.Models; using Speckle.Core.Models.GraphTraversal; +using Speckle.Rhino7.Interfaces; namespace Speckle.Connectors.Rhino7.Operations.Receive; public class RhinoHostObjectBuilder : IHostObjectBuilder { private readonly IRootToHostConverter _converter; - private readonly IConversionContextStack _contextStack; + private readonly IConversionContextStack _contextStack; private readonly GraphTraversal _traverseFunction; + private readonly IRhinoDocFactory _rhinoDocFactory; public RhinoHostObjectBuilder( IRootToHostConverter converter, - IConversionContextStack contextStack, - GraphTraversal traverseFunction + IConversionContextStack contextStack, + GraphTraversal traverseFunction, + IRhinoDocFactory rhinoDocFactory ) { _converter = converter; _contextStack = contextStack; _traverseFunction = traverseFunction; + _rhinoDocFactory = rhinoDocFactory; } public HostObjectBuilderResult Build( @@ -53,15 +54,19 @@ CancellationToken cancellationToken // POC: Potentially refactor out into an IObjectBaker. private HostObjectBuilderResult BakeObjects(IEnumerable objectsGraph, string baseLayerName) { - RhinoDoc doc = _contextStack.Current.Document; - var rootLayerIndex = _contextStack.Current.Document.Layers.Find(Guid.Empty, baseLayerName, RhinoMath.UnsetIntIndex); + var doc = _contextStack.Current.Document; + var rootLayerIndex = _contextStack.Current.Document.Layers.Find( + Guid.Empty, + baseLayerName, + _rhinoDocFactory.UnsetIntIndex + ); // POC: We could move this out into a separate service for testing and re-use. // Cleans up any previously received objects - if (rootLayerIndex != RhinoMath.UnsetIntIndex) + if (rootLayerIndex != _rhinoDocFactory.UnsetIntIndex) { - Layer documentLayer = doc.Layers[rootLayerIndex]; - Layer[]? childLayers = documentLayer.GetChildren(); + var documentLayer = doc.Layers[rootLayerIndex]; + var childLayers = documentLayer.GetChildren(); if (childLayers != null) { using var layerNoDraw = new DisableRedrawScope(doc.Views); @@ -77,7 +82,7 @@ private HostObjectBuilderResult BakeObjects(IEnumerable object } var cache = new Dictionary(); - rootLayerIndex = doc.Layers.Add(new Layer { Name = baseLayerName }); + rootLayerIndex = doc.Layers.Add(_rhinoDocFactory.CreateLayer(baseLayerName)); cache.Add(baseLayerName, rootLayerIndex); using var noDraw = new DisableRedrawScope(doc.Views); @@ -91,7 +96,7 @@ private HostObjectBuilderResult BakeObjects(IEnumerable object { var path = GetLayerPath(tc); - var fullLayerName = string.Join(Layer.PathSeparator, path); + var fullLayerName = string.Join(_rhinoDocFactory.LayerPathSeparator, path); var layerIndex = cache.TryGetValue(fullLayerName, out int value) ? value : GetAndCreateLayerFromPath(path, baseLayerName, cache); @@ -120,31 +125,31 @@ private IReadOnlyList HandleConversionResult(object conversionResult, Ba List newObjectIds = new(); switch (conversionResult) { - case IEnumerable list: + case IEnumerable list: { - Group group = BakeObjectsAsGroup(originalObject.id, list, layerIndex); + var group = BakeObjectsAsGroup(originalObject.id, list, layerIndex); newObjectIds.Add(group.Id.ToString()); break; } - case GeometryBase newObject: + case IRhinoGeometryBase newObject: { - var newObjectGuid = doc.Objects.Add(newObject, new ObjectAttributes { LayerIndex = layerIndex }); + var newObjectGuid = doc.Objects.Add(newObject, _rhinoDocFactory.CreateAttributes(layerIndex)); newObjectIds.Add(newObjectGuid.ToString()); break; } default: throw new SpeckleConversionException( - $"Unexpected result from conversion: Expected {nameof(GeometryBase)} but instead got {conversionResult.GetType().Name}" + $"Unexpected result from conversion: Expected {nameof(IRhinoGeometryBase)} but instead got {conversionResult.GetType().Name}" ); } return newObjectIds; } - private Group BakeObjectsAsGroup(string groupName, IEnumerable list, int layerIndex) + private IRhinoGroup BakeObjectsAsGroup(string groupName, IEnumerable list, int layerIndex) { var doc = _contextStack.Current.Document; - var objectIds = list.Select(obj => doc.Objects.Add(obj, new ObjectAttributes { LayerIndex = layerIndex })); + var objectIds = list.Select(obj => doc.Objects.Add(obj, _rhinoDocFactory.CreateAttributes(layerIndex))); var groupIndex = _contextStack.Current.Document.Groups.Add(groupName, objectIds); var group = _contextStack.Current.Document.Groups.FindIndex(groupIndex); return group; @@ -154,12 +159,12 @@ private Group BakeObjectsAsGroup(string groupName, IEnumerable lis private int GetAndCreateLayerFromPath(string[] path, string baseLayerName, Dictionary cache) { var currentLayerName = baseLayerName; - RhinoDoc currentDocument = _contextStack.Current.Document; + var currentDocument = _contextStack.Current.Document; var previousLayer = currentDocument.Layers.FindName(currentLayerName); foreach (var layerName in path) { - currentLayerName = baseLayerName + Layer.PathSeparator + layerName; + currentLayerName = baseLayerName + _rhinoDocFactory.LayerPathSeparator + layerName; currentLayerName = currentLayerName.Replace("{", "").Replace("}", ""); // Rhino specific cleanup for gh (see RemoveInvalidRhinoChars) if (cache.TryGetValue(currentLayerName, out int value)) { @@ -168,7 +173,7 @@ private int GetAndCreateLayerFromPath(string[] path, string baseLayerName, Dicti } var cleanNewLayerName = layerName.Replace("{", "").Replace("}", ""); - var newLayer = new Layer { Name = cleanNewLayerName, ParentLayerId = previousLayer.Id }; + var newLayer = _rhinoDocFactory.CreateLayer(cleanNewLayerName, previousLayer.Id); var index = currentDocument.Layers.Add(newLayer); cache.Add(currentLayerName, index); previousLayer = currentDocument.Layers.FindIndex(index); // note we need to get the correct id out, hence why we're double calling this diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Plugin/Speckle.Connectors.Rhino7Plugin.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Plugin/Speckle.Connectors.Rhino7Plugin.cs index 8dff82b2d5..16e7297e5a 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Plugin/Speckle.Connectors.Rhino7Plugin.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Plugin/Speckle.Connectors.Rhino7Plugin.cs @@ -2,8 +2,8 @@ using Rhino.PlugIns; using Speckle.Autofac; using Speckle.Autofac.DependencyInjection; +using Speckle.Connectors.Rhino7.DependencyInjection; using Speckle.Connectors.Rhino7.HostApp; -using Speckle.Connectors.Rhino7.Interfaces; using Speckle.Core.Kits; using Speckle.Core.Logging; using Speckle.Core.Models.Extensions; diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Speckle.Connectors.Rhino7.csproj b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Speckle.Connectors.Rhino7.csproj index cf48f27e61..b64bd8b20b 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Speckle.Connectors.Rhino7.csproj +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Speckle.Connectors.Rhino7.csproj @@ -15,6 +15,8 @@ + + @@ -41,5 +43,4 @@ Resources.Designer.cs - diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/packages.lock.json b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/packages.lock.json index df37836fb8..2b6b868bae 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/packages.lock.json +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/packages.lock.json @@ -29,6 +29,24 @@ "resolved": "0.9.5", "contentHash": "oU/L7pN1R7q8KkbrpQ3WJnHirPHqn+9DEA7asOcUiggV5dzVg1A/VYs7GOSusD24njxXh03tE3a2oTLOjt3cVg==" }, + "Speckle.Rhino7.Api": { + "type": "Direct", + "requested": "[0.1.1-preview.0.28, )", + "resolved": "0.1.1-preview.0.28", + "contentHash": "AE+1lMl+lzwEdNn6kvEWuCy6wRSFAIYP0KXeGI8fECNsCBj023c4IE/wSVn7wIHD+nM2ZHcST/62dmZXNqUt5A==", + "dependencies": { + "Mapster": "7.3.0", + "RhinoCommon": "7.13.21348.13001", + "RhinoWindows": "7.13.21348.13001", + "Speckle.Rhino7.Interfaces": "0.1.1-preview.0.28" + } + }, + "Speckle.Rhino7.Interfaces": { + "type": "Direct", + "requested": "[0.1.1-preview.0.28, )", + "resolved": "0.1.1-preview.0.28", + "contentHash": "TcbfXlRMnQRat1JodgW+YW5FflTYem1GGo9DtKA+6iAuVaYagN5dxsrM5LE6M3pCnEV9rkEQOjFo7sgnnbo4mw==" + }, "System.Resources.Extensions": { "type": "Direct", "requested": "[7.0.0, )", @@ -70,6 +88,21 @@ "resolved": "6.0.0", "contentHash": "yg72rrYDapfsIUrul7aF6wwNnTJBOFvuA9VdDTQpPa8AlAriHbufeXYLBcodKjfUdkCnaiggX1U/nEP08Zb5GA==" }, + "Mapster": { + "type": "Transitive", + "resolved": "7.3.0", + "contentHash": "NrCUX/rJa5PTyo6iW4AL5dZLU9PDNlYnrJOVjgdpo5OQM9EtWH2CMHnC5sSuJWC0d0b0SnmeRrIviEem6WxtuQ==", + "dependencies": { + "Mapster.Core": "1.2.0", + "Microsoft.CSharp": "4.3.0", + "System.Reflection.Emit": "4.3.0" + } + }, + "Mapster.Core": { + "type": "Transitive", + "resolved": "1.2.0", + "contentHash": "TNdqZk2zAuBYfJF88D/3clQTOyOdqr1crU81yZQtlGa+e7FYWhJdK/buBWT+TpM3qQko9UzmzfOT4iq3JCs/ZA==" + }, "Microsoft.Bcl.AsyncInterfaces": { "type": "Transitive", "resolved": "7.0.0", @@ -288,11 +321,6 @@ "resolved": "13.0.2", "contentHash": "g1BejUZwax5PRfL6xHgLEK23sqHWOgOj9hE7RvfRRlN00AGt8GnPYt8HedSK7UB3HiRW8zCA9Pn0iiYxCK24BA==" }, - "Speckle.Revit2023.Interfaces": { - "type": "Transitive", - "resolved": "0.1.1-preview.0.24", - "contentHash": "BSVpOUJc9g6ISrw8GxvtkglTlITpHEDYNOhxv1ZPbckBsI0yO36JiphhQV4q57ERqD9PpCozUJkVhlCaxWeS6A==" - }, "SQLitePCLRaw.bundle_e_sqlite3": { "type": "Transitive", "resolved": "2.1.4", @@ -385,6 +413,11 @@ "System.Threading.Tasks.Extensions": "4.5.4" } }, + "System.Reflection.Emit": { + "type": "Transitive", + "resolved": "4.3.0", + "contentHash": "228FG0jLcIwTVJyz8CLFKueVqQK36ANazUManGaJHkO0icjiIypKW7YLWLIWahyIkdh5M7mV2dJepllLyA1SKg==" + }, "System.Reflection.Metadata": { "type": "Transitive", "resolved": "5.0.0", @@ -481,8 +514,7 @@ "type": "Project", "dependencies": { "Speckle.Autofac": "[2.0.999-local, )", - "Speckle.Objects": "[2.0.999-local, )", - "Speckle.Revit2023.Interfaces": "[0.1.1-preview.0.24, )" + "Speckle.Objects": "[2.0.999-local, )" } }, "speckle.converters.common.dependencyinjection": { @@ -495,7 +527,7 @@ "speckle.converters.rhino7.dependencyinjection": { "type": "Project", "dependencies": { - "RhinoCommon": "[7.13.21348.13001, )" + "Speckle.Rhino7.Interfaces": "[0.1.1-preview.0.28, )" } }, "Speckle.Core": { diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3.DependencyInjection/packages.lock.json b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3.DependencyInjection/packages.lock.json index 308e61b7c6..acad1bb553 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3.DependencyInjection/packages.lock.json +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3.DependencyInjection/packages.lock.json @@ -270,11 +270,6 @@ "resolved": "13.0.2", "contentHash": "g1BejUZwax5PRfL6xHgLEK23sqHWOgOj9hE7RvfRRlN00AGt8GnPYt8HedSK7UB3HiRW8zCA9Pn0iiYxCK24BA==" }, - "Speckle.Revit2023.Interfaces": { - "type": "Transitive", - "resolved": "0.1.1-preview.0.24", - "contentHash": "BSVpOUJc9g6ISrw8GxvtkglTlITpHEDYNOhxv1ZPbckBsI0yO36JiphhQV4q57ERqD9PpCozUJkVhlCaxWeS6A==" - }, "SQLitePCLRaw.bundle_e_sqlite3": { "type": "Transitive", "resolved": "2.1.4", @@ -366,8 +361,7 @@ "type": "Project", "dependencies": { "Speckle.Autofac": "[2.0.999-local, )", - "Speckle.Objects": "[2.0.999-local, )", - "Speckle.Revit2023.Interfaces": "[0.1.1-preview.0.24, )" + "Speckle.Objects": "[2.0.999-local, )" } }, "speckle.converters.common.dependencyinjection": { diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/packages.lock.json b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/packages.lock.json index 25847a4ec6..9c5d3fa603 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/packages.lock.json +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/packages.lock.json @@ -265,11 +265,6 @@ "resolved": "13.0.2", "contentHash": "g1BejUZwax5PRfL6xHgLEK23sqHWOgOj9hE7RvfRRlN00AGt8GnPYt8HedSK7UB3HiRW8zCA9Pn0iiYxCK24BA==" }, - "Speckle.Revit2023.Interfaces": { - "type": "Transitive", - "resolved": "0.1.1-preview.0.24", - "contentHash": "BSVpOUJc9g6ISrw8GxvtkglTlITpHEDYNOhxv1ZPbckBsI0yO36JiphhQV4q57ERqD9PpCozUJkVhlCaxWeS6A==" - }, "SQLitePCLRaw.bundle_e_sqlite3": { "type": "Transitive", "resolved": "2.1.4", @@ -354,8 +349,7 @@ "type": "Project", "dependencies": { "Speckle.Autofac": "[2.0.999-local, )", - "Speckle.Objects": "[2.0.999-local, )", - "Speckle.Revit2023.Interfaces": "[0.1.1-preview.0.24, )" + "Speckle.Objects": "[2.0.999-local, )" } }, "Speckle.Core": { diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2023.DependencyInjection/packages.lock.json b/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2023.DependencyInjection/packages.lock.json index a7f09e4723..57f50cdecb 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2023.DependencyInjection/packages.lock.json +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2023.DependencyInjection/packages.lock.json @@ -213,11 +213,6 @@ "resolved": "13.0.2", "contentHash": "g1BejUZwax5PRfL6xHgLEK23sqHWOgOj9hE7RvfRRlN00AGt8GnPYt8HedSK7UB3HiRW8zCA9Pn0iiYxCK24BA==" }, - "Speckle.Revit2023.Interfaces": { - "type": "Transitive", - "resolved": "0.1.1-preview.0.24", - "contentHash": "BSVpOUJc9g6ISrw8GxvtkglTlITpHEDYNOhxv1ZPbckBsI0yO36JiphhQV4q57ERqD9PpCozUJkVhlCaxWeS6A==" - }, "SQLitePCLRaw.bundle_e_sqlite3": { "type": "Transitive", "resolved": "2.1.4", @@ -374,8 +369,7 @@ "type": "Project", "dependencies": { "Speckle.Autofac": "[2.0.999-local, )", - "Speckle.Objects": "[2.0.999-local, )", - "Speckle.Revit2023.Interfaces": "[0.1.1-preview.0.24, )" + "Speckle.Objects": "[2.0.999-local, )" } }, "speckle.converters.common.dependencyinjection": { diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2023/packages.lock.json b/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2023/packages.lock.json index 66bbf8290c..2ea05d5e3f 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2023/packages.lock.json +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2023/packages.lock.json @@ -205,11 +205,6 @@ "resolved": "13.0.2", "contentHash": "g1BejUZwax5PRfL6xHgLEK23sqHWOgOj9hE7RvfRRlN00AGt8GnPYt8HedSK7UB3HiRW8zCA9Pn0iiYxCK24BA==" }, - "Speckle.Revit2023.Interfaces": { - "type": "Transitive", - "resolved": "0.1.1-preview.0.24", - "contentHash": "BSVpOUJc9g6ISrw8GxvtkglTlITpHEDYNOhxv1ZPbckBsI0yO36JiphhQV4q57ERqD9PpCozUJkVhlCaxWeS6A==" - }, "SQLitePCLRaw.bundle_e_sqlite3": { "type": "Transitive", "resolved": "2.1.4", @@ -359,8 +354,7 @@ "type": "Project", "dependencies": { "Speckle.Autofac": "[2.0.999-local, )", - "Speckle.Objects": "[2.0.999-local, )", - "Speckle.Revit2023.Interfaces": "[0.1.1-preview.0.24, )" + "Speckle.Objects": "[2.0.999-local, )" } }, "Speckle.Core": { diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/RevitConverterModule.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/RevitConverterModule.cs index 1c7eae1e2f..7900f25180 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/RevitConverterModule.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/RevitConverterModule.cs @@ -14,7 +14,6 @@ public class RevitConverterModule : ISpeckleModule public void Load(SpeckleContainerBuilder builder) { builder.AddConverterCommon(); - builder.ScanAssemblyOfType(); // POC: do we need ToSpeckleScalingService as is, do we need to interface it out? builder.AddScoped(); diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/Speckle.Converters.Revit2023.DependencyInjection.csproj b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/Speckle.Converters.Revit2023.DependencyInjection.csproj index ae4703a46f..b9b0735ffe 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/Speckle.Converters.Revit2023.DependencyInjection.csproj +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/Speckle.Converters.Revit2023.DependencyInjection.csproj @@ -6,7 +6,7 @@ - + diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/packages.lock.json b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/packages.lock.json index 48eed8707b..a1b26cfcdc 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/packages.lock.json +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/packages.lock.json @@ -16,13 +16,13 @@ }, "Speckle.Revit2023.Api": { "type": "Direct", - "requested": "[0.1.1-preview.0.24, )", - "resolved": "0.1.1-preview.0.24", - "contentHash": "hPRXbyvgmealdPPWTxjHbpBRTsyt67DddoIs09M0n319eHh/eONnPC+SgBzJmmB834TtzzayMVk06S1cMT0Iow==", + "requested": "[0.1.1-preview.0.28, )", + "resolved": "0.1.1-preview.0.28", + "contentHash": "ejwYS/HI8yy0rJE4vgTr5aj8Fkg/E9JnMGjwyVS2fLtI4f7+FmwAY6inTUT2p/RAoRc2nQw+TerDpUtOhddzag==", "dependencies": { "Mapster": "7.3.0", "Speckle.Revit.API": "2023.0.0", - "Speckle.Revit2023.Interfaces": "0.1.1-preview.0.24" + "Speckle.Revit2023.Interfaces": "0.1.1-preview.0.28" } }, "GraphQL.Client": { @@ -232,8 +232,8 @@ }, "Speckle.Revit2023.Interfaces": { "type": "Transitive", - "resolved": "0.1.1-preview.0.24", - "contentHash": "BSVpOUJc9g6ISrw8GxvtkglTlITpHEDYNOhxv1ZPbckBsI0yO36JiphhQV4q57ERqD9PpCozUJkVhlCaxWeS6A==" + "resolved": "0.1.1-preview.0.28", + "contentHash": "7szXg/vRvP3Wdrn2ZGriVOfsw+bddlpVorBkCIhSHHs5qVTTG8IAIrI1l9dO0/aullaTMF+Xgxm9x3w1aXPiuA==" }, "SQLitePCLRaw.bundle_e_sqlite3": { "type": "Transitive", @@ -389,8 +389,7 @@ "type": "Project", "dependencies": { "Speckle.Autofac": "[2.0.999-local, )", - "Speckle.Objects": "[2.0.999-local, )", - "Speckle.Revit2023.Interfaces": "[0.1.1-preview.0.24, )" + "Speckle.Objects": "[2.0.999-local, )" } }, "speckle.converters.common.dependencyinjection": { @@ -404,7 +403,7 @@ "type": "Project", "dependencies": { "Speckle.Converters.Common": "[2.0.999-local, )", - "Speckle.Revit2023.Interfaces": "[0.1.1-preview.0.24, )" + "Speckle.Revit2023.Interfaces": "[0.1.1-preview.0.28, )" } }, "Speckle.Core": { diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/Speckle.Converters.Revit2023.Tests.csproj b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/Speckle.Converters.Revit2023.Tests.csproj index 296350ca71..4657d9e8ba 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/Speckle.Converters.Revit2023.Tests.csproj +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/Speckle.Converters.Revit2023.Tests.csproj @@ -14,7 +14,7 @@ - + diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/packages.lock.json b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/packages.lock.json index 256510d436..2d40fe5534 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/packages.lock.json +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/packages.lock.json @@ -65,9 +65,9 @@ }, "Speckle.Revit2023.Interfaces": { "type": "Direct", - "requested": "[0.1.1-preview.0.24, )", - "resolved": "0.1.1-preview.0.24", - "contentHash": "BSVpOUJc9g6ISrw8GxvtkglTlITpHEDYNOhxv1ZPbckBsI0yO36JiphhQV4q57ERqD9PpCozUJkVhlCaxWeS6A==" + "requested": "[0.1.1-preview.0.28, )", + "resolved": "0.1.1-preview.0.28", + "contentHash": "7szXg/vRvP3Wdrn2ZGriVOfsw+bddlpVorBkCIhSHHs5qVTTG8IAIrI1l9dO0/aullaTMF+Xgxm9x3w1aXPiuA==" }, "Castle.Core": { "type": "Transitive", @@ -490,8 +490,7 @@ "type": "Project", "dependencies": { "Speckle.Autofac": "[2.0.999-local, )", - "Speckle.Objects": "[2.0.999-local, )", - "Speckle.Revit2023.Interfaces": "[0.1.1-preview.0.24, )" + "Speckle.Objects": "[2.0.999-local, )" } }, "speckle.converters.common.dependencyinjection": { @@ -505,7 +504,7 @@ "type": "Project", "dependencies": { "Speckle.Converters.Common": "[2.0.999-local, )", - "Speckle.Revit2023.Interfaces": "[0.1.1-preview.0.24, )" + "Speckle.Revit2023.Interfaces": "[0.1.1-preview.0.28, )" } }, "Speckle.Core": { diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023/Speckle.Converters.Revit2023.csproj b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023/Speckle.Converters.Revit2023.csproj index 01dc874c3f..26aa7a8647 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023/Speckle.Converters.Revit2023.csproj +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023/Speckle.Converters.Revit2023.csproj @@ -9,7 +9,7 @@ - + diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023/packages.lock.json b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023/packages.lock.json index b021d0f201..7c350fca98 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023/packages.lock.json +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023/packages.lock.json @@ -16,9 +16,9 @@ }, "Speckle.Revit2023.Interfaces": { "type": "Direct", - "requested": "[0.1.1-preview.0.24, )", - "resolved": "0.1.1-preview.0.24", - "contentHash": "BSVpOUJc9g6ISrw8GxvtkglTlITpHEDYNOhxv1ZPbckBsI0yO36JiphhQV4q57ERqD9PpCozUJkVhlCaxWeS6A==" + "requested": "[0.1.1-preview.0.28, )", + "resolved": "0.1.1-preview.0.28", + "contentHash": "7szXg/vRvP3Wdrn2ZGriVOfsw+bddlpVorBkCIhSHHs5qVTTG8IAIrI1l9dO0/aullaTMF+Xgxm9x3w1aXPiuA==" }, "GraphQL.Client": { "type": "Transitive", @@ -354,8 +354,7 @@ "type": "Project", "dependencies": { "Speckle.Autofac": "[2.0.999-local, )", - "Speckle.Objects": "[2.0.999-local, )", - "Speckle.Revit2023.Interfaces": "[0.1.1-preview.0.24, )" + "Speckle.Objects": "[2.0.999-local, )" } }, "Speckle.Core": { diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/RhinoConverterModule.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/RhinoConverterModule.cs index 088b93cc10..6c315439fe 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/RhinoConverterModule.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/RhinoConverterModule.cs @@ -1,7 +1,7 @@ using Speckle.Autofac.DependencyInjection; using Speckle.Converters.Common; -using Rhino; using Speckle.Converters.Common.DependencyInjection; +using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.DependencyInjection; @@ -9,8 +9,9 @@ public class RhinoConverterModule : ISpeckleModule { public void Load(SpeckleContainerBuilder builder) { - builder.AddConverterCommon(); + builder.AddConverterCommon(); // single stack per conversion - builder.AddScoped, RhinoConversionContextStack>(); + builder.AddScoped, RhinoConversionContextStack>(); + builder.AddScoped(); } } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/RhinoRootElementProvider.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/RhinoRootElementProvider.cs new file mode 100644 index 0000000000..58a13d8107 --- /dev/null +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/RhinoRootElementProvider.cs @@ -0,0 +1,9 @@ +using Speckle.Converters.Common; +using Speckle.Rhino7.Interfaces; + +namespace Speckle.Converters.Rhino7.DependencyInjection; + +public class RhinoRootElementProvider : IRootElementProvider +{ + public Type GetRootType() => typeof(IRhinoObject); +} diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/Speckle.Converters.Rhino7.DependencyInjection.csproj b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/Speckle.Converters.Rhino7.DependencyInjection.csproj index d944ee5ed1..052b08bafc 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/Speckle.Converters.Rhino7.DependencyInjection.csproj +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/Speckle.Converters.Rhino7.DependencyInjection.csproj @@ -11,6 +11,6 @@ - + diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/packages.lock.json b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/packages.lock.json index 590b6f9e6c..0b5cd3165f 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/packages.lock.json +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/packages.lock.json @@ -8,18 +8,18 @@ "resolved": "1.14.1", "contentHash": "mOOmFYwad3MIOL14VCjj02LljyF1GNw1wP0YVlxtcPvqdxjGGMNdNJJxHptlry3MOd8b40Flm8RPOM8JOlN2sQ==" }, - "RhinoCommon": { - "type": "Direct", - "requested": "[7.13.21348.13001, )", - "resolved": "7.13.21348.13001", - "contentHash": "JQdaNw61ddBqIe08E9O4N/grwrN1hjDHcYW7tWylwCZyFR7SepoCD4NS+6LN6+oSQhNbhLi9Bf+hQOFYFdRAEA==" - }, "Speckle.InterfaceGenerator": { "type": "Direct", "requested": "[0.9.5, )", "resolved": "0.9.5", "contentHash": "oU/L7pN1R7q8KkbrpQ3WJnHirPHqn+9DEA7asOcUiggV5dzVg1A/VYs7GOSusD24njxXh03tE3a2oTLOjt3cVg==" }, + "Speckle.Rhino7.Interfaces": { + "type": "Direct", + "requested": "[0.1.1-preview.0.28, )", + "resolved": "0.1.1-preview.0.28", + "contentHash": "TcbfXlRMnQRat1JodgW+YW5FflTYem1GGo9DtKA+6iAuVaYagN5dxsrM5LE6M3pCnEV9rkEQOjFo7sgnnbo4mw==" + }, "GraphQL.Client": { "type": "Transitive", "resolved": "6.0.0", @@ -205,11 +205,6 @@ "resolved": "13.0.2", "contentHash": "g1BejUZwax5PRfL6xHgLEK23sqHWOgOj9hE7RvfRRlN00AGt8GnPYt8HedSK7UB3HiRW8zCA9Pn0iiYxCK24BA==" }, - "Speckle.Revit2023.Interfaces": { - "type": "Transitive", - "resolved": "0.1.1-preview.0.24", - "contentHash": "BSVpOUJc9g6ISrw8GxvtkglTlITpHEDYNOhxv1ZPbckBsI0yO36JiphhQV4q57ERqD9PpCozUJkVhlCaxWeS6A==" - }, "SQLitePCLRaw.bundle_e_sqlite3": { "type": "Transitive", "resolved": "2.1.4", @@ -359,8 +354,7 @@ "type": "Project", "dependencies": { "Speckle.Autofac": "[2.0.999-local, )", - "Speckle.Objects": "[2.0.999-local, )", - "Speckle.Revit2023.Interfaces": "[0.1.1-preview.0.24, )" + "Speckle.Objects": "[2.0.999-local, )" } }, "speckle.converters.common.dependencyinjection": { @@ -373,8 +367,8 @@ "speckle.converters.rhino7": { "type": "Project", "dependencies": { - "RhinoCommon": "[7.13.21348.13001, )", - "Speckle.Converters.Common": "[2.0.999-local, )" + "Speckle.Converters.Common": "[2.0.999-local, )", + "Speckle.Rhino7.Interfaces": "[0.1.1-preview.0.28, )" } }, "Speckle.Core": { diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/GlobalUsings.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/GlobalUsings.cs index baa44c188e..c88d8e3105 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/GlobalUsings.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/GlobalUsings.cs @@ -1,3 +1,2 @@ -global using RG = Rhino.Geometry; global using SOG = Objects.Geometry; global using SOP = Objects.Primitive; diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/RhinoConversionContextStack.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/RhinoConversionContextStack.cs index 79ac2f77a4..799f32b350 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/RhinoConversionContextStack.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/RhinoConversionContextStack.cs @@ -1,6 +1,6 @@ using System.Diagnostics.CodeAnalysis; -using Rhino; using Speckle.Converters.Common; +using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7; @@ -10,8 +10,11 @@ namespace Speckle.Converters.Rhino7; "CA1711:Identifiers should not have incorrect suffix", Justification = "Name ends in Stack but it is in fact a Stack, just not inheriting from `System.Collections.Stack`" )] -public class RhinoConversionContextStack : ConversionContextStack +public class RhinoConversionContextStack : ConversionContextStack { - public RhinoConversionContextStack(IHostToSpeckleUnitConverter unitConverter) - : base(RhinoDoc.ActiveDoc, RhinoDoc.ActiveDoc.ModelUnitSystem, unitConverter) { } + public RhinoConversionContextStack( + IRhinoDocFactory rhinoDocFactory, + IHostToSpeckleUnitConverter unitConverter + ) + : base(rhinoDocFactory.ActiveDoc(), rhinoDocFactory.ActiveDoc().ModelUnitSystem, unitConverter) { } } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/RhinoToSpeckleUnitConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/RhinoToSpeckleUnitConverter.cs index 4f4f9c77e4..f7953bc383 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/RhinoToSpeckleUnitConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/RhinoToSpeckleUnitConverter.cs @@ -1,29 +1,29 @@ -using Rhino; -using Speckle.Converters.Common; +using Speckle.Converters.Common; using Speckle.Core.Kits; +using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7; -public class RhinoToSpeckleUnitConverter : IHostToSpeckleUnitConverter +public class RhinoToSpeckleUnitConverter : IHostToSpeckleUnitConverter { - private readonly Dictionary _unitMapping = new(); + private readonly Dictionary _unitMapping = new(); public RhinoToSpeckleUnitConverter() { // POC: CNX-9269 Add unit test to ensure these don't change. - _unitMapping[UnitSystem.None] = Units.Meters; - _unitMapping[UnitSystem.Millimeters] = Units.Millimeters; - _unitMapping[UnitSystem.Centimeters] = Units.Centimeters; - _unitMapping[UnitSystem.Meters] = Units.Meters; - _unitMapping[UnitSystem.Kilometers] = Units.Kilometers; - _unitMapping[UnitSystem.Inches] = Units.Inches; - _unitMapping[UnitSystem.Feet] = Units.Feet; - _unitMapping[UnitSystem.Yards] = Units.Yards; - _unitMapping[UnitSystem.Miles] = Units.Miles; - _unitMapping[UnitSystem.Unset] = Units.Meters; + _unitMapping[RhinoUnitSystem.None] = Units.Meters; + _unitMapping[RhinoUnitSystem.Millimeters] = Units.Millimeters; + _unitMapping[RhinoUnitSystem.Centimeters] = Units.Centimeters; + _unitMapping[RhinoUnitSystem.Meters] = Units.Meters; + _unitMapping[RhinoUnitSystem.Kilometers] = Units.Kilometers; + _unitMapping[RhinoUnitSystem.Inches] = Units.Inches; + _unitMapping[RhinoUnitSystem.Feet] = Units.Feet; + _unitMapping[RhinoUnitSystem.Yards] = Units.Yards; + _unitMapping[RhinoUnitSystem.Miles] = Units.Miles; + _unitMapping[RhinoUnitSystem.Unset] = Units.Meters; } - public string ConvertOrThrow(UnitSystem hostUnit) + public string ConvertOrThrow(RhinoUnitSystem hostUnit) { if (_unitMapping.TryGetValue(hostUnit, out string value)) { diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Speckle.Converters.Rhino7.csproj b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Speckle.Converters.Rhino7.csproj index 249814e554..72c57460cd 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Speckle.Converters.Rhino7.csproj +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Speckle.Converters.Rhino7.csproj @@ -3,12 +3,11 @@ net48 - - + + - diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/SpeckleToHostGeometryBaseTopLevelConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/SpeckleToHostGeometryBaseTopLevelConverter.cs index 75ff2162c2..3d5e09c1a0 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/SpeckleToHostGeometryBaseTopLevelConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/SpeckleToHostGeometryBaseTopLevelConverter.cs @@ -1,25 +1,28 @@ -using Rhino; -using Speckle.Converters.Common; +using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; using Speckle.Core.Kits; using Speckle.Core.Models; +using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7; public abstract class SpeckleToHostGeometryBaseTopLevelConverter : IToHostTopLevelConverter where TIn : Base - where TOut : RG.GeometryBase + where TOut : IRhinoGeometryBase { - protected IConversionContextStack ContextStack { get; private set; } + protected IConversionContextStack ContextStack { get; private set; } private readonly ITypedConverter _geometryBaseConverter; + private readonly IRhinoTransformFactory _transformFactory; protected SpeckleToHostGeometryBaseTopLevelConverter( - IConversionContextStack contextStack, - ITypedConverter geometryBaseConverter + IConversionContextStack contextStack, + ITypedConverter geometryBaseConverter, + IRhinoTransformFactory transformFactory ) { ContextStack = contextStack; _geometryBaseConverter = geometryBaseConverter; + _transformFactory = transformFactory; } public object Convert(Base target) @@ -35,7 +38,7 @@ public object Convert(Base target) if (castedBase["units"] is string units) { var scaleFactor = Units.GetConversionFactor(units, ContextStack.Current.SpeckleUnits); - var scale = RG.Transform.Scale(RG.Point3d.Origin, scaleFactor); + var scale = _transformFactory.Scale(_transformFactory.Origin, scaleFactor); result.Transform(scale); } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/ArcToHostConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/ArcToHostConverter.cs index 0068c38ef2..63d745dec6 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/ArcToHostConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/ArcToHostConverter.cs @@ -1,34 +1,38 @@ using Speckle.Converters.Common.Objects; +using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToHost.Raw; /// /// Converts a SpeckleArcRaw object to a Rhino.Geometry.Arc object or Rhino.Geometry.ArcCurve object. /// -public class ArcToHostConverter : ITypedConverter, ITypedConverter +public class ArcToHostConverter : ITypedConverter, ITypedConverter { - private readonly ITypedConverter _pointConverter; - private readonly ITypedConverter _intervalConverter; + private readonly ITypedConverter _pointConverter; + private readonly ITypedConverter _intervalConverter; + private readonly IRhinoArcFactory _rhinoArcFactory; public ArcToHostConverter( - ITypedConverter pointConverter, - ITypedConverter intervalConverter + ITypedConverter pointConverter, + ITypedConverter intervalConverter, + IRhinoArcFactory rhinoArcFactory ) { _pointConverter = pointConverter; this._intervalConverter = intervalConverter; + _rhinoArcFactory = rhinoArcFactory; } /// - /// Converts a object to a object. + /// Converts a object to a object. /// /// The Speckle Arc object to convert. - /// The converted object. + /// The converted object. /// ⚠️ This conversion does NOT perform scaling. ///
⚠️ This method does not preserve the original curve domain
- public RG.Arc Convert(SOG.Arc target) + public IRhinoArc Convert(SOG.Arc target) { - var rhinoArc = new RG.Arc( + var rhinoArc = _rhinoArcFactory.Create( _pointConverter.Convert(target.startPoint), _pointConverter.Convert(target.midPoint), _pointConverter.Convert(target.endPoint) @@ -39,16 +43,16 @@ public RG.Arc Convert(SOG.Arc target) // POC: CNX-9271 Potential code-smell by directly implementing the interface. We should discuss this further but // since we're using the interfaces instead of the direct type, this may not be an issue. /// - /// Converts a object to a object. + /// Converts a object to a object. /// /// The object to convert. - /// The converted object. + /// The converted object. /// ⚠️ This conversion does NOT perform scaling. - ///
⚠️ Converting to instead of preserves the domain of the curve.
- RG.ArcCurve ITypedConverter.Convert(SOG.Arc target) + ///
⚠️ Converting to instead of preserves the domain of the curve.
+ IRhinoArcCurve ITypedConverter.Convert(SOG.Arc target) { var rhinoArc = Convert(target); - var arcCurve = new RG.ArcCurve(rhinoArc) { Domain = _intervalConverter.Convert(target.domain) }; + var arcCurve = _rhinoArcFactory.Create(rhinoArc, _intervalConverter.Convert(target.domain)); return arcCurve; } } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/BrepToHostConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/BrepToHostConverter.cs index db94e2f7f0..c579d736a1 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/BrepToHostConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/BrepToHostConverter.cs @@ -1,24 +1,26 @@ using Objects; -using Rhino; using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; +using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToHost.Raw; -public class BrepToHostConverter : ITypedConverter +public class BrepToHostConverter : ITypedConverter { - private readonly IConversionContextStack _contextStack; - private readonly ITypedConverter _curveConverter; - private readonly ITypedConverter _surfaceConverter; - private readonly ITypedConverter _pointConverter; - private readonly ITypedConverter _intervalConverter; + private readonly IConversionContextStack _contextStack; + private readonly ITypedConverter _curveConverter; + private readonly ITypedConverter _surfaceConverter; + private readonly ITypedConverter _pointConverter; + private readonly ITypedConverter _intervalConverter; + private readonly IRhinoBrepFactory _rhinoBrepFactory; public BrepToHostConverter( - IConversionContextStack contextStack, - ITypedConverter curveConverter, - ITypedConverter surfaceConverter, - ITypedConverter pointConverter, - ITypedConverter intervalConverter + IConversionContextStack contextStack, + ITypedConverter curveConverter, + ITypedConverter surfaceConverter, + ITypedConverter pointConverter, + ITypedConverter intervalConverter, + IRhinoBrepFactory rhinoBrepFactory ) { _contextStack = contextStack; @@ -26,10 +28,11 @@ public BrepToHostConverter( _surfaceConverter = surfaceConverter; _pointConverter = pointConverter; _intervalConverter = intervalConverter; + _rhinoBrepFactory = rhinoBrepFactory; } /// - /// Converts a Speckle to a Rhino . + /// Converts a Speckle to a Rhino . /// /// /// This method converts a Speckle Brep object to its equivalent Rhino Brep representation. @@ -40,11 +43,11 @@ public BrepToHostConverter( /// The Speckle Brep object to be converted. /// The equivalent Rhino Brep object. /// ⚠️ This conversion does NOT perform scaling. - public RG.Brep Convert(SOG.Brep target) + public IRhinoBrep Convert(SOG.Brep target) { var tolerance = _contextStack.Current.Document.ModelAbsoluteTolerance; - var rhinoBrep = new RG.Brep(); + var rhinoBrep = _rhinoBrepFactory.Create(); // Geometry goes in first, always. Order doesn't matter. target.Curve3D.ForEach(curve => rhinoBrep.AddEdgeCurve(_curveConverter.Convert(curve))); @@ -70,21 +73,21 @@ public RG.Brep Convert(SOG.Brep target) } /// - /// Converts a Speckle to a Rhino and adds it to the provided . + /// Converts a Speckle to a Rhino and adds it to the provided . /// /// /// A consists of individual trims. There are special cases for singular trims and trims with defined edge indices. /// Note that edge cases in Brep structures are not fully covered by this method and should be reviewed for robustness improvement. - /// This operation alters the state of the provided by adding a new loop. + /// This operation alters the state of the provided by adding a new loop. /// - /// The where the new loop will be added. + /// The where the new loop will be added. /// The to be converted and added to . /// The tolerance factor used when adding trims and setting their tolerances. - private void ConvertSpeckleBrepLoop(RG.Brep rhinoBrep, SOG.BrepLoop speckleLoop, double tol) + private void ConvertSpeckleBrepLoop(IRhinoBrep rhinoBrep, SOG.BrepLoop speckleLoop, double tol) { var f = rhinoBrep.Faces[speckleLoop.FaceIndex]; - rhinoBrep.Loops.Add((RG.BrepLoopType)speckleLoop.Type, f); + rhinoBrep.Loops.Add((RhinoBrepLoopType)speckleLoop.Type, f); // POC: This works but it doesn't fully cover all Brep edge cases and could be the cause of some of our failed Rhino->Rhino breps. // We should check Rhino.Inside as they have similar code structure. @@ -92,7 +95,7 @@ private void ConvertSpeckleBrepLoop(RG.Brep rhinoBrep, SOG.BrepLoop speckleLoop, .ToList() .ForEach(trim => { - RG.BrepTrim rhTrim; + IRhinoBrepTrim rhTrim; if (trim.EdgeIndex != -1) { rhTrim = rhinoBrep.Trims.Add( @@ -107,7 +110,7 @@ private void ConvertSpeckleBrepLoop(RG.Brep rhinoBrep, SOG.BrepLoop speckleLoop, rhTrim = rhinoBrep.Trims.AddSingularTrim( rhinoBrep.Vertices[trim.EndIndex], rhinoBrep.Loops[trim.LoopIndex], - (RG.IsoStatus)trim.IsoStatus, + (RhinoIsoStatus)trim.IsoStatus, trim.CurveIndex ); } @@ -116,8 +119,8 @@ private void ConvertSpeckleBrepLoop(RG.Brep rhinoBrep, SOG.BrepLoop speckleLoop, rhTrim = rhinoBrep.Trims.Add(trim.IsReversed, rhinoBrep.Loops[trim.LoopIndex], trim.CurveIndex); } - rhTrim.IsoStatus = (RG.IsoStatus)trim.IsoStatus; - rhTrim.TrimType = (RG.BrepTrimType)trim.TrimType; + rhTrim.IsoStatus = (RhinoIsoStatus)trim.IsoStatus; + rhTrim.TrimType = (RhinoBrepTrimType)trim.TrimType; rhTrim.SetTolerances(tol, tol); }); } @@ -133,7 +136,7 @@ private void ConvertSpeckleBrepLoop(RG.Brep rhinoBrep, SOG.BrepLoop speckleLoop, /// is untrimmed, and hence added directly as a reference to the curve it points to. /// If the edge is trimmed, it is added based on vertices and subdomain using the supplied tolerance /// - private void ConvertSpeckleBrepEdge(RG.Brep rhinoBrep, SOG.BrepEdge speckleEdge, double tolerance) + private void ConvertSpeckleBrepEdge(IRhinoBrep rhinoBrep, SOG.BrepEdge speckleEdge, double tolerance) { if ( speckleEdge.Domain == null @@ -158,11 +161,11 @@ private void ConvertSpeckleBrepEdge(RG.Brep rhinoBrep, SOG.BrepEdge speckleEdge, } /// - /// Converts a into a and adds it to the provided . + /// Converts a into a and adds it to the provided . /// /// The Rhinoceros brep geometry to which the converted face is added. /// The Speckle brep face to be converted and added. - private void ConvertSpeckleBrepFace(RG.Brep rhinoBrep, SOG.BrepFace speckleFace) + private void ConvertSpeckleBrepFace(IRhinoBrep rhinoBrep, SOG.BrepFace speckleFace) { var f = rhinoBrep.Faces.Add(speckleFace.SurfaceIndex); f.OrientationIsReversed = speckleFace.OrientationReversed; diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/CircleToHostConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/CircleToHostConverter.cs index 1431d3fc1a..1fbdfd4a2e 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/CircleToHostConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/CircleToHostConverter.cs @@ -1,46 +1,52 @@ using Speckle.Converters.Common.Objects; +using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToHost.Raw; /// -/// This class is responsible for converting a into and objects. +/// This class is responsible for converting a into and objects. /// Implements the interface, -/// providing implementation for to and conversion. +/// providing implementation for to and conversion. /// -public class CircleToHostConverter : ITypedConverter, ITypedConverter +public class CircleToHostConverter + : ITypedConverter, + ITypedConverter { - private readonly ITypedConverter _planeConverter; - private readonly ITypedConverter _intervalConverter; + private readonly ITypedConverter _planeConverter; + private readonly ITypedConverter _intervalConverter; + private readonly IRhinoCircleFactory _rhinoCircleFactory; /// /// Constructs a new instance of the class. /// /// - /// An implementation of used to convert into . + /// An implementation of used to convert into . /// /// - /// An implementation of used to convert into . + /// An implementation of used to convert into . /// public CircleToHostConverter( - ITypedConverter intervalConverter, - ITypedConverter planeConverter + ITypedConverter intervalConverter, + ITypedConverter planeConverter, + IRhinoCircleFactory rhinoCircleFactory ) { _intervalConverter = intervalConverter; _planeConverter = planeConverter; + _rhinoCircleFactory = rhinoCircleFactory; } /// - /// Converts the given object into a object. + /// Converts the given object into a object. /// /// The object to convert. - /// The resulting object. + /// The resulting object. /// /// Thrown when the radius of the given object is null. /// /// ⚠️ This conversion does NOT perform scaling. - ///
⚠️ This conversion does not preserve the curve domain. If you need it preserved you must request a conversion to conversion instead
- public RG.Circle Convert(SOG.Circle target) + ///
⚠️ This conversion does not preserve the curve domain. If you need it preserved you must request a conversion to conversion instead
+ public IRhinoCircle Convert(SOG.Circle target) { if (target.radius == null) { @@ -50,9 +56,9 @@ public RG.Circle Convert(SOG.Circle target) var plane = _planeConverter.Convert(target.plane); var radius = target.radius.Value; - return new RG.Circle(plane, radius); + return _rhinoCircleFactory.Create(plane, radius); } - RG.ArcCurve ITypedConverter.Convert(SOG.Circle target) => - new(Convert(target)) { Domain = _intervalConverter.Convert(target.domain) }; + IRhinoArcCurve ITypedConverter.Convert(SOG.Circle target) => + _rhinoCircleFactory.Create(Convert(target), _intervalConverter.Convert(target.domain)); } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/CurveToHostConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/CurveToHostConverter.cs index a61425dc2a..d96d413258 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/CurveToHostConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/CurveToHostConverter.cs @@ -1,28 +1,29 @@ using Objects; using Speckle.Converters.Common.Objects; +using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToHost.Raw; -public class CurveToHostConverter : ITypedConverter +public class CurveToHostConverter : ITypedConverter { - private readonly ITypedConverter _lineConverter; - private readonly ITypedConverter _arcConverter; - private readonly ITypedConverter _ellipseConverter; - private readonly ITypedConverter _spiralConverter; - private readonly ITypedConverter _circleConverter; - private readonly ITypedConverter _polylineConverter; - private readonly ITypedConverter _polyCurveConverter; - private readonly ITypedConverter _nurbsCurveConverter; + private readonly ITypedConverter _lineConverter; + private readonly ITypedConverter _arcConverter; + private readonly ITypedConverter _ellipseConverter; + private readonly ITypedConverter _spiralConverter; + private readonly ITypedConverter _circleConverter; + private readonly ITypedConverter _polylineConverter; + private readonly ITypedConverter _polyCurveConverter; + private readonly ITypedConverter _nurbsCurveConverter; public CurveToHostConverter( - ITypedConverter lineConverter, - ITypedConverter arcConverter, - ITypedConverter ellipseConverter, - ITypedConverter spiralConverter, - ITypedConverter circleConverter, - ITypedConverter polylineConverter, - ITypedConverter polyCurveConverter, - ITypedConverter nurbsCurveConverter + ITypedConverter lineConverter, + ITypedConverter arcConverter, + ITypedConverter ellipseConverter, + ITypedConverter spiralConverter, + ITypedConverter circleConverter, + ITypedConverter polylineConverter, + ITypedConverter polyCurveConverter, + ITypedConverter nurbsCurveConverter ) { _lineConverter = lineConverter; @@ -36,13 +37,13 @@ public CurveToHostConverter( } /// - /// Converts a given ICurve object to an RG.Curve object. + /// Converts a given ICurve object to an IRhinoCurve object. /// /// The ICurve object to convert. - /// The converted RG.Curve object. + /// The converted IRhinoCurve object. /// Thrown when the conversion is not supported for the given type of curve. /// ⚠️ This conversion does NOT perform scaling. - public RG.Curve Convert(ICurve target) => + public IRhinoCurve Convert(ICurve target) => target switch { SOG.Line line => _lineConverter.Convert(line), diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/EllipseToHostConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/EllipseToHostConverter.cs index 74f309a61f..c45fa5c3ab 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/EllipseToHostConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/EllipseToHostConverter.cs @@ -1,49 +1,57 @@ using Speckle.Converters.Common.Objects; +using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToHost.Raw; public class EllipseToHostConverter - : ITypedConverter, - ITypedConverter + : ITypedConverter, + ITypedConverter { - private readonly ITypedConverter _planeConverter; - private readonly ITypedConverter _intervalConverter; + private readonly ITypedConverter _planeConverter; + private readonly ITypedConverter _intervalConverter; + private readonly IRhinoEllipseFactory _rhinoEllipseFactory; public EllipseToHostConverter( - ITypedConverter planeConverter, - ITypedConverter intervalConverter + ITypedConverter planeConverter, + ITypedConverter intervalConverter, + IRhinoEllipseFactory rhinoEllipseFactory ) { _planeConverter = planeConverter; _intervalConverter = intervalConverter; + _rhinoEllipseFactory = rhinoEllipseFactory; } /// - /// Converts an instance of to an while preserving geometric properties. + /// Converts an instance of to an while preserving geometric properties. /// /// The instance to be converted. - /// The resulting after conversion. + /// The resulting after conversion. /// Thrown when or properties are null. /// ⚠️ This conversion does NOT perform scaling. - ///
⚠️ This conversion does not preserve the curve domain. If you need it preserved you must request a conversion to conversion instead
- public RG.Ellipse Convert(SOG.Ellipse target) + ///
⚠️ This conversion does not preserve the curve domain. If you need it preserved you must request a conversion to conversion instead
+ public IRhinoEllipse Convert(SOG.Ellipse target) { if (!target.firstRadius.HasValue || !target.secondRadius.HasValue) { throw new InvalidOperationException($"Ellipses cannot have null radii"); } - return new RG.Ellipse(_planeConverter.Convert(target.plane), target.firstRadius.Value, target.secondRadius.Value); + return _rhinoEllipseFactory.Create( + _planeConverter.Convert(target.plane), + target.firstRadius.Value, + target.secondRadius.Value + ); } /// - /// Converts the provided into a representation. + /// Converts the provided into a representation. /// /// The to convert. /// - /// A that represents the provided . + /// A that represents the provided . /// - RG.NurbsCurve ITypedConverter.Convert(SOG.Ellipse target) + IRhinoNurbsCurve ITypedConverter.Convert(SOG.Ellipse target) { var rhinoEllipse = Convert(target); var rhinoNurbsEllipse = rhinoEllipse.ToNurbsCurve(); diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/FlatPointListToHostConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/FlatPointListToHostConverter.cs index f0363a387d..97c2786b44 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/FlatPointListToHostConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/FlatPointListToHostConverter.cs @@ -1,14 +1,21 @@ -using Rhino.Collections; -using Speckle.Converters.Common.Objects; +using Speckle.Converters.Common.Objects; using Speckle.Core.Logging; +using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToHost.Raw; /// /// Converts a flat list of raw double values to a Point3dList. /// -public class FlatPointListToHostConverter : ITypedConverter, Point3dList> +public class FlatPointListToHostConverter : ITypedConverter, IRhinoPoint3dList> { + private readonly IRhinoPointFactory _rhinoPointFactory; + + public FlatPointListToHostConverter(IRhinoPointFactory rhinoPointFactory) + { + _rhinoPointFactory = rhinoPointFactory; + } + /// /// Converts a flat list of raw double values to a Point3dList. /// @@ -19,20 +26,20 @@ public class FlatPointListToHostConverter : ITypedConverter /// Throws when the input list count is not a multiple of 3. - public Point3dList Convert(IReadOnlyList target) + public IRhinoPoint3dList Convert(IReadOnlyList target) { if (target.Count % 3 != 0) { throw new SpeckleException("Array malformed: length%3 != 0."); } - var points = new List(target.Count / 3); + var points = new List(target.Count / 3); for (int i = 2; i < target.Count; i += 3) { - points.Add(new RG.Point3d(target[i - 2], target[i - 1], target[i])); + points.Add(_rhinoPointFactory.Create(target[i - 2], target[i - 1], target[i])); } - return new Point3dList(points); + return _rhinoPointFactory.Create(points); } } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/IntervalToHostConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/IntervalToHostConverter.cs index f201283ebd..ddaa476970 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/IntervalToHostConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/IntervalToHostConverter.cs @@ -1,9 +1,17 @@ using Speckle.Converters.Common.Objects; +using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToHost.Raw; -public class IntervalToHostConverter : ITypedConverter +public class IntervalToHostConverter : ITypedConverter { + private readonly IRhinoIntervalFactory _rhinoIntervalFactory; + + public IntervalToHostConverter(IRhinoIntervalFactory rhinoIntervalFactory) + { + _rhinoIntervalFactory = rhinoIntervalFactory; + } + /// /// Converts a Speckle Interval object to a Rhino.Geometry.Interval object. /// @@ -11,13 +19,13 @@ public class IntervalToHostConverter : ITypedConverterThe converted Rhino.Geometry.Interval object. /// Thrown when the start or end value of the Interval is null. /// ⚠️ This conversion does NOT perform scaling. - public RG.Interval Convert(SOP.Interval target) + public IRhinoInterval Convert(SOP.Interval target) { if (!target.start.HasValue || !target.end.HasValue) // POC: CNX-9272 Interval start and end being nullable makes no sense. { throw new ArgumentException("Interval start/end cannot be null"); } - return new RG.Interval(target.start.Value, target.end.Value); + return _rhinoIntervalFactory.Create(target.start.Value, target.end.Value); } } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/LineToHostConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/LineToHostConverter.cs index c549e96741..a66222299f 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/LineToHostConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/LineToHostConverter.cs @@ -1,14 +1,20 @@ using Speckle.Converters.Common.Objects; +using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToHost.Raw; -public class LineToHostConverter : ITypedConverter, ITypedConverter +public class LineToHostConverter : ITypedConverter, ITypedConverter { - private readonly ITypedConverter _pointConverter; + private readonly ITypedConverter _pointConverter; + private readonly IRhinoLineFactory _rhinoLineFactory; - public LineToHostConverter(ITypedConverter pointConverter) + public LineToHostConverter( + ITypedConverter pointConverter, + IRhinoLineFactory rhinoLineFactory + ) { _pointConverter = pointConverter; + _rhinoLineFactory = rhinoLineFactory; } /// @@ -20,15 +26,16 @@ public LineToHostConverter(ITypedConverter pointConverter /// ///
⚠️ This conversion does not preserve the curve domain. /// If you need it preserved you must request a conversion to - /// conversion instead + /// conversion instead ///
- public RG.Line Convert(SOG.Line target) => - new(_pointConverter.Convert(target.start), _pointConverter.Convert(target.end)); + public IRhinoLine Convert(SOG.Line target) => + _rhinoLineFactory.Create(_pointConverter.Convert(target.start), _pointConverter.Convert(target.end)); /// /// Converts a Speckle Line object to a Rhino LineCurve object. /// /// The Speckle Line object to convert. /// Returns the resulting Rhino LineCurve object. - RG.LineCurve ITypedConverter.Convert(SOG.Line target) => new(Convert(target)); + IRhinoLineCurve ITypedConverter.Convert(SOG.Line target) => + _rhinoLineFactory.Create(Convert(target)); } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/MeshToHostConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/MeshToHostConverter.cs index d3917dafd3..e24adb8ad1 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/MeshToHostConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/MeshToHostConverter.cs @@ -1,17 +1,28 @@ using System.Drawing; using Objects.Utils; -using Rhino.Collections; using Speckle.Converters.Common.Objects; +using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToHost.Raw; -public class MeshToHostConverter : ITypedConverter +public class MeshToHostConverter : ITypedConverter { - private readonly ITypedConverter, Point3dList> _pointListConverter; - - public MeshToHostConverter(ITypedConverter, Point3dList> pointListConverter) + private readonly ITypedConverter, IRhinoPoint3dList> _pointListConverter; + private readonly IRhinoMeshFactory _rhinoMeshFactory; + private readonly IRhinoNgonFactory _rhinoNgonFactory; + private readonly IRhinoPointFactory _rhinoPointFactory; + + public MeshToHostConverter( + ITypedConverter, IRhinoPoint3dList> pointListConverter, + IRhinoMeshFactory rhinoMeshFactory, + IRhinoNgonFactory rhinoNgonFactory, + IRhinoPointFactory rhinoPointFactory + ) { _pointListConverter = pointListConverter; + _rhinoMeshFactory = rhinoMeshFactory; + _rhinoNgonFactory = rhinoNgonFactory; + _rhinoPointFactory = rhinoPointFactory; } /// @@ -20,11 +31,11 @@ public MeshToHostConverter(ITypedConverter, Point3dList> p /// The Speckle mesh object to convert. /// A Rhino mesh object converted from the Speckle mesh. /// ⚠️ This conversion does NOT perform scaling. - public RG.Mesh Convert(SOG.Mesh target) + public IRhinoMesh Convert(SOG.Mesh target) { target.AlignVerticesWithTexCoordsByIndex(); - RG.Mesh m = new(); + IRhinoMesh m = _rhinoMeshFactory.Create(); var vertices = _pointListConverter.Convert(target.vertices); var colors = target.colors.Select(Color.FromArgb).ToArray(); @@ -43,7 +54,7 @@ public RG.Mesh Convert(SOG.Mesh target) // POC: CNX-9274 We should abstract this into the `Mesh` class, or some utility class adjacent to it // All converters need to do this so it's going to be a source of repetition // and it is directly tied to how we serialise the data in the mesh. - private void AssignMeshFaces(SOG.Mesh target, RG.Mesh m) + private void AssignMeshFaces(SOG.Mesh target, IRhinoMesh m) { int i = 0; while (i < target.faces.Count) @@ -59,14 +70,12 @@ private void AssignMeshFaces(SOG.Mesh target, RG.Mesh m) if (n == 3) { // triangle - m.Faces.AddFace(new RG.MeshFace(target.faces[i + 1], target.faces[i + 2], target.faces[i + 3])); + m.Faces.AddFace(target.faces[i + 1], target.faces[i + 2], target.faces[i + 3]); } else if (n == 4) { // quad - m.Faces.AddFace( - new RG.MeshFace(target.faces[i + 1], target.faces[i + 2], target.faces[i + 3], target.faces[i + 4]) - ); + m.Faces.AddFace(target.faces[i + 1], target.faces[i + 2], target.faces[i + 3], target.faces[i + 4]); } else { @@ -76,11 +85,10 @@ private void AssignMeshFaces(SOG.Mesh target, RG.Mesh m) var faceIndices = new List(triangles.Count); for (int t = 0; t < triangles.Count; t += 3) { - var face = new RG.MeshFace(triangles[t], triangles[t + 1], triangles[t + 2]); - faceIndices.Add(m.Faces.AddFace(face)); + faceIndices.Add(m.Faces.AddFace(triangles[t], triangles[t + 1], triangles[t + 2])); } - RG.MeshNgon ngon = RG.MeshNgon.Create(target.faces.GetRange(i + 1, n), faceIndices); + IRhinoMeshNgon ngon = _rhinoNgonFactory.Create(target.faces.GetRange(i + 1, n), faceIndices); m.Ngons.AddNgon(ngon); } @@ -89,13 +97,13 @@ private void AssignMeshFaces(SOG.Mesh target, RG.Mesh m) m.Faces.CullDegenerateFaces(); } - private void AssignTextureCoordinates(SOG.Mesh target, RG.Mesh m) + private void AssignTextureCoordinates(SOG.Mesh target, IRhinoMesh m) { - var textureCoordinates = new RG.Point2f[target.TextureCoordinatesCount]; + var textureCoordinates = new IRhinoPoint2f[target.TextureCoordinatesCount]; for (int ti = 0; ti < target.TextureCoordinatesCount; ti++) { var (u, v) = target.GetTextureCoordinate(ti); - textureCoordinates[ti] = new RG.Point2f(u, v); + textureCoordinates[ti] = _rhinoPointFactory.Create(u, v); } m.TextureCoordinates.SetTextureCoordinates(textureCoordinates); } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/NurbsCurveToHostConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/NurbsCurveToHostConverter.cs index 9f9bf52811..9e2ee516f4 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/NurbsCurveToHostConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/NurbsCurveToHostConverter.cs @@ -1,15 +1,24 @@ using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; +using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToHost.Raw; -public class NurbsCurveToHostConverter : ITypedConverter +public class NurbsCurveToHostConverter : ITypedConverter { - private readonly ITypedConverter _intervalConverter; + private readonly IRhinoPointFactory _rhinoPointFactory; + private readonly IRhinoCurveFactory _rhinoCurveFactory; + private readonly ITypedConverter _intervalConverter; - public NurbsCurveToHostConverter(ITypedConverter intervalConverter) + public NurbsCurveToHostConverter( + ITypedConverter intervalConverter, + IRhinoCurveFactory rhinoCurveFactory, + IRhinoPointFactory rhinoPointFactory + ) { _intervalConverter = intervalConverter; + _rhinoCurveFactory = rhinoCurveFactory; + _rhinoPointFactory = rhinoPointFactory; } /// @@ -19,14 +28,14 @@ public NurbsCurveToHostConverter(ITypedConverter inte /// The converted Rhino NurbsCurve object. /// Thrown when the conversion fails. /// ⚠️ This conversion does NOT perform scaling. - public RG.NurbsCurve Convert(SOG.Curve target) + public IRhinoNurbsCurve Convert(SOG.Curve target) { - RG.NurbsCurve nurbsCurve = new(target.degree, target.points.Count / 3); + IRhinoNurbsCurve nurbsCurve = _rhinoCurveFactory.Create(target.degree, target.points.Count / 3); // Hyper optimised curve control point conversion for (int i = 2, j = 0; i < target.points.Count; i += 3, j++) { - var pt = new RG.Point3d(target.points[i - 2], target.points[i - 1], target.points[i]); // Skip the point converter for performance + var pt = _rhinoPointFactory.Create(target.points[i - 2], target.points[i - 1], target.points[i]); // Skip the point converter for performance nurbsCurve.Points.SetPoint(j, pt, target.weights[j]); } @@ -37,11 +46,11 @@ public RG.NurbsCurve Convert(SOG.Curve target) { if (extraKnots == 2) { - nurbsCurve.Knots[j] = target.knots[j + 1]; + nurbsCurve.Knots.SetKnot(j, target.knots[j + 1]); } else { - nurbsCurve.Knots[j] = target.knots[j]; + nurbsCurve.Knots.SetKnot(j, target.knots[j]); } } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/PlaneToHostConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/PlaneToHostConverter.cs index 49e10ab69e..4b18fac738 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/PlaneToHostConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/PlaneToHostConverter.cs @@ -1,19 +1,23 @@ using Speckle.Converters.Common.Objects; +using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToHost.Raw; -public class PlaneToHostConverter : ITypedConverter +public class PlaneToHostConverter : ITypedConverter { - private readonly ITypedConverter _pointConverter; - private readonly ITypedConverter _vectorConverter; + private readonly ITypedConverter _pointConverter; + private readonly ITypedConverter _vectorConverter; + private readonly IRhinoPlaneFactory _rhinoPlaneFactory; public PlaneToHostConverter( - ITypedConverter pointConverter, - ITypedConverter vectorConverter + ITypedConverter pointConverter, + ITypedConverter vectorConverter, + IRhinoPlaneFactory rhinoPlaneFactory ) { _pointConverter = pointConverter; _vectorConverter = vectorConverter; + _rhinoPlaneFactory = rhinoPlaneFactory; } /// @@ -22,8 +26,8 @@ public PlaneToHostConverter( /// The Speckle Plane object to be converted. /// The converted Rhino Plane object. /// ⚠️ This conversion does NOT perform scaling. - public RG.Plane Convert(SOG.Plane target) => - new( + public IRhinoPlane Convert(SOG.Plane target) => + _rhinoPlaneFactory.Create( _pointConverter.Convert(target.origin), _vectorConverter.Convert(target.xdir), _vectorConverter.Convert(target.ydir) diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/PointCloudToHostConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/PointCloudToHostConverter.cs index a6d749b15c..f4a67b8d8d 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/PointCloudToHostConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/PointCloudToHostConverter.cs @@ -1,16 +1,21 @@ using System.Drawing; -using Rhino.Collections; using Speckle.Converters.Common.Objects; +using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToHost.Raw; -public class PointCloudToHostConverter : ITypedConverter +public class PointCloudToHostConverter : ITypedConverter { - private readonly ITypedConverter, Point3dList> _pointListConverter; + private readonly ITypedConverter, IRhinoPoint3dList> _pointListConverter; + private readonly IRhinoPointCloudFactory _rhinoPointCloudFactory; - public PointCloudToHostConverter(ITypedConverter, Point3dList> pointListConverter) + public PointCloudToHostConverter( + ITypedConverter, IRhinoPoint3dList> pointListConverter, + IRhinoPointCloudFactory rhinoPointCloudFactory + ) { _pointListConverter = pointListConverter; + _rhinoPointCloudFactory = rhinoPointCloudFactory; } /// @@ -19,10 +24,10 @@ public PointCloudToHostConverter(ITypedConverter, Point3dL /// The raw Speckle Pointcloud object to convert. /// The converted Rhino PointCloud object. /// ⚠️ This conversion does NOT perform scaling. - public RG.PointCloud Convert(SOG.Pointcloud target) + public IRhinoPointCloud Convert(SOG.Pointcloud target) { var rhinoPoints = _pointListConverter.Convert(target.points); - var rhinoPointCloud = new RG.PointCloud(rhinoPoints); + var rhinoPointCloud = _rhinoPointCloudFactory.Create(rhinoPoints); if (target.colors.Count == rhinoPoints.Count) { diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/PointToHostConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/PointToHostConverter.cs index 8ce40bcb59..35938f8ad4 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/PointToHostConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/PointToHostConverter.cs @@ -1,16 +1,24 @@ using Speckle.Converters.Common.Objects; +using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToHost.Raw; -public class PointToHostConverter : ITypedConverter, ITypedConverter +public class PointToHostConverter : ITypedConverter, ITypedConverter { + private readonly IRhinoPointFactory _rhinoPointFactory; + + public PointToHostConverter(IRhinoPointFactory rhinoPointFactory) + { + _rhinoPointFactory = rhinoPointFactory; + } + /// /// Converts a Speckle Point object to a Rhino Point3d object. /// /// The Speckle Point object to convert. /// The converted Rhino Point3d object. /// ⚠️ This conversion does NOT perform scaling. - public RG.Point3d Convert(SOG.Point target) => new(target.x, target.y, target.z); + public IRhinoPoint3d Convert(SOG.Point target) => _rhinoPointFactory.Create(target.x, target.y, target.z); /// /// Converts a Speckle Point object to a Rhino Point object. @@ -18,5 +26,6 @@ public class PointToHostConverter : ITypedConverter, ITyp /// The Speckle Point object to convert. /// The converted Rhino Point object. /// ⚠️ This conversion does NOT perform scaling. - RG.Point ITypedConverter.Convert(SOG.Point target) => new(Convert(target)); + IRhinoPoint ITypedConverter.Convert(SOG.Point target) => + _rhinoPointFactory.Create(Convert(target)); } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/PolyCurveToHostConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/PolyCurveToHostConverter.cs index 3f35905090..6a2655ed48 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/PolyCurveToHostConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/PolyCurveToHostConverter.cs @@ -2,18 +2,24 @@ using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; using Speckle.Core.Kits; +using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToHost.Raw; -public class PolyCurveToHostConverter : ITypedConverter +public class PolyCurveToHostConverter : ITypedConverter { - public ITypedConverter? CurveConverter { get; set; } // POC: CNX-9311 Circular dependency injected by the container using property. + public ITypedConverter? CurveConverter { get; set; } // POC: CNX-9311 Circular dependency injected by the container using property. - private readonly ITypedConverter _intervalConverter; + private readonly ITypedConverter _intervalConverter; + private readonly IRhinoCurveFactory _rhinoCurveFactory; - public PolyCurveToHostConverter(ITypedConverter intervalConverter) + public PolyCurveToHostConverter( + ITypedConverter intervalConverter, + IRhinoCurveFactory rhinoCurveFactory + ) { _intervalConverter = intervalConverter; + _rhinoCurveFactory = rhinoCurveFactory; } /// @@ -22,13 +28,14 @@ public PolyCurveToHostConverter(ITypedConverter inter /// The SpecklePolyCurve object to convert. /// The converted Rhino PolyCurve object. /// ⚠️ This conversion does NOT perform scaling. - public RG.PolyCurve Convert(SOG.Polycurve target) + public IRhinoPolyCurve Convert(SOG.Polycurve target) { - RG.PolyCurve result = new(); + IRhinoPolyCurve result = _rhinoCurveFactory.Create(); + var converter = CurveConverter.NotNull(); foreach (var segment in target.segments) { - var childCurve = CurveConverter.NotNull().Convert(segment); + var childCurve = converter.Convert(segment); bool success = result.AppendSegment(childCurve); if (!success) { diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/PolylineToHostConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/PolylineToHostConverter.cs index 5abe48fed5..b803a07943 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/PolylineToHostConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/PolylineToHostConverter.cs @@ -1,22 +1,25 @@ -using Rhino.Collections; -using Speckle.Converters.Common.Objects; +using Speckle.Converters.Common.Objects; +using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToHost.Raw; public class PolylineToHostConverter - : ITypedConverter, - ITypedConverter + : ITypedConverter, + ITypedConverter { - private readonly ITypedConverter, Point3dList> _pointListConverter; - private readonly ITypedConverter _intervalConverter; + private readonly ITypedConverter, IRhinoPoint3dList> _pointListConverter; + private readonly ITypedConverter _intervalConverter; + private readonly IRhinoLineFactory _rhinoLineFactory; public PolylineToHostConverter( - ITypedConverter, Point3dList> pointListConverter, - ITypedConverter intervalConverter + ITypedConverter, IRhinoPoint3dList> pointListConverter, + ITypedConverter intervalConverter, + IRhinoLineFactory rhinoLineFactory ) { _pointListConverter = pointListConverter; _intervalConverter = intervalConverter; + _rhinoLineFactory = rhinoLineFactory; } /// @@ -28,9 +31,9 @@ public PolylineToHostConverter( /// ///
⚠️ This conversion does not preserve the curve domain. /// If you need it preserved you must request a conversion to - /// conversion instead + /// conversion instead ///
- public RG.Polyline Convert(SOG.Polyline target) + public IRhinoPolyline Convert(SOG.Polyline target) { var points = _pointListConverter.Convert(target.value); @@ -39,7 +42,7 @@ public RG.Polyline Convert(SOG.Polyline target) points.Add(points[0]); } - var poly = new RG.Polyline(points); + var poly = _rhinoLineFactory.Create(points); return poly; } @@ -52,7 +55,7 @@ public RG.Polyline Convert(SOG.Polyline target) /// The Speckle polyline object to be converted. /// The converted Rhino Polyline object. /// ⚠️ This conversion does NOT perform scaling. - RG.PolylineCurve ITypedConverter.Convert(SOG.Polyline target) + IRhinoPolylineCurve ITypedConverter.Convert(SOG.Polyline target) { var poly = Convert(target).ToPolylineCurve(); poly.Domain = _intervalConverter.Convert(target.domain); diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpiralToHostConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpiralToHostConverter.cs index cb7f5a8745..c3cc3532ce 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpiralToHostConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpiralToHostConverter.cs @@ -1,15 +1,16 @@ using Speckle.Converters.Common.Objects; +using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToHost.Raw; -public class SpiralToHostConverter : ITypedConverter +public class SpiralToHostConverter : ITypedConverter { - private readonly ITypedConverter _polylineConverter; - private readonly ITypedConverter _intervalConverter; + private readonly ITypedConverter _polylineConverter; + private readonly ITypedConverter _intervalConverter; public SpiralToHostConverter( - ITypedConverter polylineConverter, - ITypedConverter intervalConverter + ITypedConverter polylineConverter, + ITypedConverter intervalConverter ) { _polylineConverter = polylineConverter; @@ -22,7 +23,7 @@ public SpiralToHostConverter( /// The Speckle Spiral object to be converted. /// A Rhino PolylineCurve object. /// ⚠️ This conversion does NOT perform scaling. - public RG.PolylineCurve Convert(SOG.Spiral target) + public IRhinoPolylineCurve Convert(SOG.Spiral target) { var result = _polylineConverter.Convert(target.displayValue); result.Domain = _intervalConverter.Convert(target.domain); diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SurfaceToHostConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SurfaceToHostConverter.cs index 91da44ec59..46689761a8 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SurfaceToHostConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SurfaceToHostConverter.cs @@ -1,21 +1,29 @@ using Speckle.Converters.Common.Objects; +using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToHost.Raw; -public class SurfaceToHostConverter : ITypedConverter +public class SurfaceToHostConverter : ITypedConverter { + private readonly IRhinoSurfaceFactory _rhinoSurfaceFactory; + + public SurfaceToHostConverter(IRhinoSurfaceFactory rhinoSurfaceFactory) + { + _rhinoSurfaceFactory = rhinoSurfaceFactory; + } + /// /// Converts a raw Speckle surface to a Rhino NURBS surface. /// /// The raw Speckle surface to convert. /// The converted Rhino NURBS surface. /// ⚠️ This conversion does NOT perform scaling. - public RG.NurbsSurface Convert(SOG.Surface target) + public IRhinoNurbsSurface Convert(SOG.Surface target) { // Create rhino surface var points = target.GetControlPoints().ToList(); - var result = RG.NurbsSurface.Create( + var result = _rhinoSurfaceFactory.Create( 3, target.rational, target.degreeU + 1, @@ -28,13 +36,13 @@ public RG.NurbsSurface Convert(SOG.Surface target) var correctUKnots = GetCorrectKnots(target.knotsU, target.countU, target.degreeU); for (int i = 0; i < correctUKnots.Count; i++) { - result.KnotsU[i] = correctUKnots[i]; + result.KnotsU.SetKnot(i, correctUKnots[i]); } var correctVKnots = GetCorrectKnots(target.knotsV, target.countV, target.degreeV); for (int i = 0; i < correctVKnots.Count; i++) { - result.KnotsV[i] = correctVKnots[i]; + result.KnotsV.SetKnot(i, correctVKnots[i]); } // Set control points diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/VectorToHostConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/VectorToHostConverter.cs index 77e017f0fd..85ff17692c 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/VectorToHostConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/VectorToHostConverter.cs @@ -1,14 +1,22 @@ using Speckle.Converters.Common.Objects; +using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToHost.Raw; -public class VectorToHostConverter : ITypedConverter +public class VectorToHostConverter : ITypedConverter { + private readonly IRhinoVectorFactory _rhinoVectorFactory; + + public VectorToHostConverter(IRhinoVectorFactory rhinoVectorFactory) + { + _rhinoVectorFactory = rhinoVectorFactory; + } + /// /// Converts a Speckle.Vector object to a Rhino Vector3d object. /// /// The Speckle.Vector to be converted. /// The converted Rhino Vector3d object. /// ⚠️ This conversion does NOT perform scaling. - public RG.Vector3d Convert(SOG.Vector target) => new(target.x, target.y, target.z); + public IRhinoVector3d Convert(SOG.Vector target) => _rhinoVectorFactory.Create(target.x, target.y, target.z); } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/ArcToHostTopLevelConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/ArcToHostTopLevelConverter.cs index 12c4420914..ca8b4938bd 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/ArcToHostTopLevelConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/ArcToHostTopLevelConverter.cs @@ -1,15 +1,16 @@ -using Rhino; -using Speckle.Converters.Common; +using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; +using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToHost.TopLevel; [NameAndRankValue(nameof(SOG.Arc), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class ArcToHostTopLevelConverter : SpeckleToHostGeometryBaseTopLevelConverter +public class ArcToHostTopLevelConverter : SpeckleToHostGeometryBaseTopLevelConverter { public ArcToHostTopLevelConverter( - IConversionContextStack contextStack, - ITypedConverter geometryBaseConverter + IConversionContextStack contextStack, + ITypedConverter geometryBaseConverter, + IRhinoTransformFactory rhinoTransformFactory ) - : base(contextStack, geometryBaseConverter) { } + : base(contextStack, geometryBaseConverter, rhinoTransformFactory) { } } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/BrepToHostTopLevelConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/BrepToHostTopLevelConverter.cs index 6ca70d3ad1..1c8706bd99 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/BrepToHostTopLevelConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/BrepToHostTopLevelConverter.cs @@ -1,15 +1,16 @@ -using Rhino; -using Speckle.Converters.Common; +using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; +using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToHost.TopLevel; [NameAndRankValue(nameof(SOG.Brep), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class BrepToHostTopLevelConverter : SpeckleToHostGeometryBaseTopLevelConverter +public class BrepToHostTopLevelConverter : SpeckleToHostGeometryBaseTopLevelConverter { public BrepToHostTopLevelConverter( - IConversionContextStack contextStack, - ITypedConverter geometryBaseConverter + IConversionContextStack contextStack, + ITypedConverter geometryBaseConverter, + IRhinoTransformFactory rhinoTransformFactory ) - : base(contextStack, geometryBaseConverter) { } + : base(contextStack, geometryBaseConverter, rhinoTransformFactory) { } } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/CircleToHostTopLevelConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/CircleToHostTopLevelConverter.cs index 1493120e57..942854b10b 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/CircleToHostTopLevelConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/CircleToHostTopLevelConverter.cs @@ -1,15 +1,16 @@ -using Rhino; -using Speckle.Converters.Common; +using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; +using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToHost.TopLevel; [NameAndRankValue(nameof(SOG.Circle), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class CircleToHostTopLevelConverter : SpeckleToHostGeometryBaseTopLevelConverter +public class CircleToHostTopLevelConverter : SpeckleToHostGeometryBaseTopLevelConverter { public CircleToHostTopLevelConverter( - IConversionContextStack contextStack, - ITypedConverter geometryBaseConverter + IConversionContextStack contextStack, + ITypedConverter geometryBaseConverter, + IRhinoTransformFactory rhinoTransformFactory ) - : base(contextStack, geometryBaseConverter) { } + : base(contextStack, geometryBaseConverter, rhinoTransformFactory) { } } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/EllipseToHostTopLevelConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/EllipseToHostTopLevelConverter.cs index e6a4b03a41..dbc35c205b 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/EllipseToHostTopLevelConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/EllipseToHostTopLevelConverter.cs @@ -1,15 +1,16 @@ -using Rhino; -using Speckle.Converters.Common; +using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; +using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToHost.TopLevel; [NameAndRankValue(nameof(SOG.Ellipse), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class EllipseToHostTopLevelConverter : SpeckleToHostGeometryBaseTopLevelConverter +public class EllipseToHostTopLevelConverter : SpeckleToHostGeometryBaseTopLevelConverter { public EllipseToHostTopLevelConverter( - IConversionContextStack contextStack, - ITypedConverter geometryBaseConverter + IConversionContextStack contextStack, + ITypedConverter geometryBaseConverter, + IRhinoTransformFactory rhinoTransformFactory ) - : base(contextStack, geometryBaseConverter) { } + : base(contextStack, geometryBaseConverter, rhinoTransformFactory) { } } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/FallbackToHostTopLevelConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/FallbackToHostTopLevelConverter.cs index 811433890c..34c5a989ae 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/FallbackToHostTopLevelConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/FallbackToHostTopLevelConverter.cs @@ -1,42 +1,45 @@ -using Rhino; -using Speckle.Converters.Common; +using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; using Speckle.Core.Kits; using Speckle.Core.Models; +using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToHost.TopLevel; [NameAndRankValue(nameof(DisplayableObject), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] public class FallbackToHostTopLevelConverter : IToHostTopLevelConverter, - ITypedConverter> + ITypedConverter> { - private readonly ITypedConverter _lineConverter; - private readonly ITypedConverter _polylineConverter; - private readonly ITypedConverter _meshConverter; - private readonly IConversionContextStack _contextStack; + private readonly ITypedConverter _lineConverter; + private readonly ITypedConverter _polylineConverter; + private readonly ITypedConverter _meshConverter; + private readonly IConversionContextStack _contextStack; + private readonly IRhinoTransformFactory _rhinoTransformFactory; public FallbackToHostTopLevelConverter( - ITypedConverter lineConverter, - ITypedConverter polylineConverter, - ITypedConverter meshConverter, - IConversionContextStack contextStack + ITypedConverter lineConverter, + ITypedConverter polylineConverter, + ITypedConverter meshConverter, + IConversionContextStack contextStack, + IRhinoTransformFactory rhinoTransformFactory ) { _lineConverter = lineConverter; _polylineConverter = polylineConverter; _meshConverter = meshConverter; _contextStack = contextStack; + _rhinoTransformFactory = rhinoTransformFactory; } public object Convert(Base target) => Convert((DisplayableObject)target); - public List Convert(DisplayableObject target) + public List Convert(DisplayableObject target) { - var result = new List(); + var result = new List(); foreach (var item in target.displayValue) { - RG.GeometryBase x = item switch + IRhinoGeometryBase x = item switch { SOG.Line line => _lineConverter.Convert(line), SOG.Polyline polyline => _polylineConverter.Convert(polyline), @@ -50,7 +53,7 @@ IConversionContextStack contextStack return result; } - private RG.Transform GetUnitsTransform(Base speckleObject) + private IRhinoTransform GetUnitsTransform(Base speckleObject) { /* * POC: CNX-9270 Looking at a simpler, more performant way of doing unit scaling on `ToNative` @@ -60,10 +63,10 @@ private RG.Transform GetUnitsTransform(Base speckleObject) if (speckleObject["units"] is string units) { var scaleFactor = Units.GetConversionFactor(units, _contextStack.Current.SpeckleUnits); - var scale = RG.Transform.Scale(RG.Point3d.Origin, scaleFactor); + var scale = _rhinoTransformFactory.Scale(_rhinoTransformFactory.Origin, scaleFactor); return scale; } - return RG.Transform.Identity; + return _rhinoTransformFactory.Identity; } } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/LineToHostTopLevelConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/LineToHostTopLevelConverter.cs index 5a64a3ebab..8767a91e06 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/LineToHostTopLevelConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/LineToHostTopLevelConverter.cs @@ -1,15 +1,16 @@ -using Rhino; -using Speckle.Converters.Common; +using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; +using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToHost.TopLevel; [NameAndRankValue(nameof(SOG.Line), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class LineToHostTopLevelConverter : SpeckleToHostGeometryBaseTopLevelConverter +public class LineToHostTopLevelConverter : SpeckleToHostGeometryBaseTopLevelConverter { public LineToHostTopLevelConverter( - IConversionContextStack contextStack, - ITypedConverter geometryBaseConverter + IConversionContextStack contextStack, + ITypedConverter geometryBaseConverter, + IRhinoTransformFactory rhinoTransformFactory ) - : base(contextStack, geometryBaseConverter) { } + : base(contextStack, geometryBaseConverter, rhinoTransformFactory) { } } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/MeshToHostTopLevelConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/MeshToHostTopLevelConverter.cs index c7d047df3b..6cdacc4288 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/MeshToHostTopLevelConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/MeshToHostTopLevelConverter.cs @@ -1,15 +1,16 @@ -using Rhino; -using Speckle.Converters.Common; +using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; +using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToHost.TopLevel; [NameAndRankValue(nameof(SOG.Mesh), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class MeshToHostTopLevelConverter : SpeckleToHostGeometryBaseTopLevelConverter +public class MeshToHostTopLevelConverter : SpeckleToHostGeometryBaseTopLevelConverter { public MeshToHostTopLevelConverter( - IConversionContextStack contextStack, - ITypedConverter geometryBaseConverter + IConversionContextStack contextStack, + ITypedConverter geometryBaseConverter, + IRhinoTransformFactory rhinoTransformFactory ) - : base(contextStack, geometryBaseConverter) { } + : base(contextStack, geometryBaseConverter, rhinoTransformFactory) { } } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/NurbsCurveToHostTopLevelConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/NurbsCurveToHostTopLevelConverter.cs index 987b46161f..19201d066a 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/NurbsCurveToHostTopLevelConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/NurbsCurveToHostTopLevelConverter.cs @@ -1,15 +1,16 @@ -using Rhino; -using Speckle.Converters.Common; +using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; +using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToHost.TopLevel; [NameAndRankValue(nameof(SOG.Curve), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class NurbsCurveToHostTopLevelConverter : SpeckleToHostGeometryBaseTopLevelConverter +public class NurbsCurveToHostTopLevelConverter : SpeckleToHostGeometryBaseTopLevelConverter { public NurbsCurveToHostTopLevelConverter( - IConversionContextStack contextStack, - ITypedConverter geometryBaseConverter + IConversionContextStack contextStack, + ITypedConverter geometryBaseConverter, + IRhinoTransformFactory rhinoTransformFactory ) - : base(contextStack, geometryBaseConverter) { } + : base(contextStack, geometryBaseConverter, rhinoTransformFactory) { } } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/PointCloudToHostTopLevelConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/PointCloudToHostTopLevelConverter.cs index 51a2613e90..c4e199b3d4 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/PointCloudToHostTopLevelConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/PointCloudToHostTopLevelConverter.cs @@ -1,16 +1,17 @@ -using Rhino; -using Speckle.Converters.Common; +using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; +using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToHost.TopLevel; [NameAndRankValue(nameof(SOG.Pointcloud), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] public class PointCloudToHostTopLevelConverter - : SpeckleToHostGeometryBaseTopLevelConverter + : SpeckleToHostGeometryBaseTopLevelConverter { public PointCloudToHostTopLevelConverter( - IConversionContextStack contextStack, - ITypedConverter geometryBaseConverter + IConversionContextStack contextStack, + ITypedConverter geometryBaseConverter, + IRhinoTransformFactory rhinoTransformFactory ) - : base(contextStack, geometryBaseConverter) { } + : base(contextStack, geometryBaseConverter, rhinoTransformFactory) { } } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/PointToHostTopLevelConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/PointToHostTopLevelConverter.cs index de10053ce9..6922cf12ad 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/PointToHostTopLevelConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/PointToHostTopLevelConverter.cs @@ -1,15 +1,16 @@ -using Rhino; -using Speckle.Converters.Common; +using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; +using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToHost.TopLevel; [NameAndRankValue(nameof(SOG.Point), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class PointToHostTopLevelConverter : SpeckleToHostGeometryBaseTopLevelConverter +public class PointToHostTopLevelConverter : SpeckleToHostGeometryBaseTopLevelConverter { public PointToHostTopLevelConverter( - IConversionContextStack contextStack, - ITypedConverter geometryBaseConverter + IConversionContextStack contextStack, + ITypedConverter geometryBaseConverter, + IRhinoTransformFactory rhinoTransformFactory ) - : base(contextStack, geometryBaseConverter) { } + : base(contextStack, geometryBaseConverter, rhinoTransformFactory) { } } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/PolycurveToHostTopLevelConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/PolycurveToHostTopLevelConverter.cs index d6f8d2f14b..96511e2856 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/PolycurveToHostTopLevelConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/PolycurveToHostTopLevelConverter.cs @@ -1,15 +1,17 @@ -using Rhino; -using Speckle.Converters.Common; +using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; +using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToHost.TopLevel; [NameAndRankValue(nameof(SOG.Polycurve), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class PolycurveToHostTopLevelConverter : SpeckleToHostGeometryBaseTopLevelConverter +public class PolycurveToHostTopLevelConverter + : SpeckleToHostGeometryBaseTopLevelConverter { public PolycurveToHostTopLevelConverter( - IConversionContextStack contextStack, - ITypedConverter geometryBaseConverter + IConversionContextStack contextStack, + ITypedConverter geometryBaseConverter, + IRhinoTransformFactory rhinoTransformFactory ) - : base(contextStack, geometryBaseConverter) { } + : base(contextStack, geometryBaseConverter, rhinoTransformFactory) { } } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/PolylineToHostTopLevelConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/PolylineToHostTopLevelConverter.cs index 081f217f04..c098b09930 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/PolylineToHostTopLevelConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/PolylineToHostTopLevelConverter.cs @@ -1,16 +1,17 @@ -using Rhino; -using Speckle.Converters.Common; +using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; +using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToHost.TopLevel; [NameAndRankValue(nameof(SOG.Polyline), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] public class PolylineToHostTopLevelConverter - : SpeckleToHostGeometryBaseTopLevelConverter + : SpeckleToHostGeometryBaseTopLevelConverter { public PolylineToHostTopLevelConverter( - IConversionContextStack contextStack, - ITypedConverter geometryBaseConverter + IConversionContextStack contextStack, + ITypedConverter geometryBaseConverter, + IRhinoTransformFactory rhinoTransformFactory ) - : base(contextStack, geometryBaseConverter) { } + : base(contextStack, geometryBaseConverter, rhinoTransformFactory) { } } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/ArcCurveToSpeckleConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/ArcCurveToSpeckleConverter.cs index 8a3eee9cb7..f262520e97 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/ArcCurveToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/ArcCurveToSpeckleConverter.cs @@ -1,23 +1,23 @@ using Objects; -using Rhino; using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; using Speckle.Core.Models; +using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToSpeckle.Raw; -public class ArcCurveToSpeckleConverter : ITypedConverter, ITypedConverter +public class ArcCurveToSpeckleConverter : ITypedConverter, ITypedConverter { - private readonly ITypedConverter _circleConverter; - private readonly ITypedConverter _arcConverter; - private readonly ITypedConverter _intervalConverter; - private readonly IConversionContextStack _contextStack; + private readonly ITypedConverter _circleConverter; + private readonly ITypedConverter _arcConverter; + private readonly ITypedConverter _intervalConverter; + private readonly IConversionContextStack _contextStack; public ArcCurveToSpeckleConverter( - ITypedConverter circleConverter, - ITypedConverter arcConverter, - ITypedConverter intervalConverter, - IConversionContextStack contextStack + ITypedConverter circleConverter, + ITypedConverter arcConverter, + ITypedConverter intervalConverter, + IConversionContextStack contextStack ) { _circleConverter = circleConverter; @@ -27,16 +27,16 @@ IConversionContextStack contextStack } /// - /// Converts an RG.ArcCurve to an ICurve. + /// Converts an IRhinoArcCurve to an ICurve. /// - /// The RG.ArcCurve to convert. + /// The IRhinoArcCurve to convert. /// The converted ICurve. /// /// ⚠️ If the provided ArcCurve is a complete circle, a Speckle Circle will be returned. /// Otherwise, the output will be a Speckle Arc.
/// ✅ This method preserves the domain of the original ArcCurve.
///
- public ICurve Convert(RG.ArcCurve target) + public ICurve Convert(IRhinoArcCurve target) { var tolerance = _contextStack.Current.Document.ModelAbsoluteTolerance; @@ -57,5 +57,5 @@ public ICurve Convert(RG.ArcCurve target) // This also causes us to have to force cast ICurve to Base as a result, which is expected to always succeed but not nice. /// /// The converted ICurve with a cast to object - Base ITypedConverter.Convert(RG.ArcCurve target) => (Base)Convert(target); + Base ITypedConverter.Convert(IRhinoArcCurve target) => (Base)Convert(target); } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/ArcToSpeckleConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/ArcToSpeckleConverter.cs index 82c89c2551..0458715c91 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/ArcToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/ArcToSpeckleConverter.cs @@ -1,27 +1,30 @@ -using Rhino; -using Speckle.Converters.Common; +using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; +using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToSpeckle.Raw; -public class ArcToSpeckleConverter : ITypedConverter +public class ArcToSpeckleConverter : ITypedConverter { - private readonly ITypedConverter _pointConverter; - private readonly ITypedConverter _planeConverter; - private readonly ITypedConverter _boxConverter; - private readonly IConversionContextStack _contextStack; + private readonly ITypedConverter _pointConverter; + private readonly ITypedConverter _planeConverter; + private readonly ITypedConverter _boxConverter; + private readonly IConversionContextStack _contextStack; + private readonly IRhinoBoxFactory _boxFactory; public ArcToSpeckleConverter( - ITypedConverter pointConverter, - ITypedConverter planeConverter, - ITypedConverter boxConverter, - IConversionContextStack contextStack + ITypedConverter pointConverter, + ITypedConverter planeConverter, + ITypedConverter boxConverter, + IConversionContextStack contextStack, + IRhinoBoxFactory boxFactory ) { _pointConverter = pointConverter; _planeConverter = planeConverter; _boxConverter = boxConverter; _contextStack = contextStack; + _boxFactory = boxFactory; } /// @@ -32,7 +35,7 @@ IConversionContextStack contextStack /// /// This method assumes the domain of the arc is (0,1) as Arc types in Rhino do not have domain. You may want to request a conversion from ArcCurve instead. /// - public SOG.Arc Convert(RG.Arc target) => + public SOG.Arc Convert(IRhinoArc target) => new( _planeConverter.Convert(target.Plane), target.Radius, @@ -47,6 +50,6 @@ public SOG.Arc Convert(RG.Arc target) => endPoint = _pointConverter.Convert(target.EndPoint), domain = new SOP.Interval(0, 1), length = target.Length, - bbox = _boxConverter.Convert(new RG.Box(target.BoundingBox())) + bbox = _boxConverter.Convert(_boxFactory.CreateBox(target.BoundingBox())) }; } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/BoxToSpeckleConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/BoxToSpeckleConverter.cs index cebd6e5d70..cae6a5d610 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/BoxToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/BoxToSpeckleConverter.cs @@ -1,19 +1,19 @@ -using Rhino; -using Speckle.Converters.Common; +using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; +using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToSpeckle.Raw; -public class BoxToSpeckleConverter : ITypedConverter +public class BoxToSpeckleConverter : ITypedConverter { - private readonly ITypedConverter _planeConverter; - private readonly ITypedConverter _intervalConverter; - private readonly IConversionContextStack _contextStack; + private readonly ITypedConverter _planeConverter; + private readonly ITypedConverter _intervalConverter; + private readonly IConversionContextStack _contextStack; public BoxToSpeckleConverter( - ITypedConverter planeConverter, - ITypedConverter intervalConverter, - IConversionContextStack contextStack + ITypedConverter planeConverter, + ITypedConverter intervalConverter, + IConversionContextStack contextStack ) { _planeConverter = planeConverter; @@ -26,7 +26,7 @@ IConversionContextStack contextStack /// /// The Rhino Box object to convert. /// The converted Speckle Box object. - public SOG.Box Convert(RG.Box target) => + public SOG.Box Convert(IRhinoBox target) => new( _planeConverter.Convert(target.Plane), _intervalConverter.Convert(target.X), diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/BrepToSpeckleConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/BrepToSpeckleConverter.cs index 236653d4d7..1ae05128f7 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/BrepToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/BrepToSpeckleConverter.cs @@ -1,30 +1,34 @@ using Objects; -using Rhino; using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; using Speckle.Core.Kits; using Speckle.Core.Logging; +using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToSpeckle.Raw; -public class BrepToSpeckleConverter : ITypedConverter +public class BrepToSpeckleConverter : ITypedConverter { - private readonly ITypedConverter _pointConverter; - private readonly ITypedConverter _curveConverter; - private readonly ITypedConverter _surfaceConverter; - private readonly ITypedConverter _meshConverter; - private readonly ITypedConverter _boxConverter; - private readonly ITypedConverter _intervalConverter; - private readonly IConversionContextStack _contextStack; + private readonly ITypedConverter _pointConverter; + private readonly ITypedConverter _curveConverter; + private readonly ITypedConverter _surfaceConverter; + private readonly ITypedConverter _meshConverter; + private readonly ITypedConverter _boxConverter; + private readonly ITypedConverter _intervalConverter; + private readonly IConversionContextStack _contextStack; + private readonly IRhinoBoxFactory _rhinoBoxFactory; + private readonly IRhinoMeshFactory _rhinoMeshFactory; public BrepToSpeckleConverter( - ITypedConverter pointConverter, - ITypedConverter curveConverter, - ITypedConverter surfaceConverter, - ITypedConverter meshConverter, - ITypedConverter boxConverter, - ITypedConverter intervalConverter, - IConversionContextStack contextStack + ITypedConverter pointConverter, + ITypedConverter curveConverter, + ITypedConverter surfaceConverter, + ITypedConverter meshConverter, + ITypedConverter boxConverter, + ITypedConverter intervalConverter, + IConversionContextStack contextStack, + IRhinoBoxFactory rhinoBoxFactory, + IRhinoMeshFactory rhinoMeshFactory ) { _pointConverter = pointConverter; @@ -34,6 +38,8 @@ IConversionContextStack contextStack _boxConverter = boxConverter; _intervalConverter = intervalConverter; _contextStack = contextStack; + _rhinoBoxFactory = rhinoBoxFactory; + _rhinoMeshFactory = rhinoMeshFactory; } /// @@ -41,7 +47,7 @@ IConversionContextStack contextStack /// /// The Brep object to convert. /// The converted Speckle Brep object. - public SOG.Brep Convert(RG.Brep target) + public SOG.Brep Convert(IRhinoBrep target) { var tol = _contextStack.Current.Document.ModelAbsoluteTolerance; target.Repair(tol); @@ -89,7 +95,7 @@ public SOG.Brep Convert(RG.Brep target) Orientation = (SOG.BrepOrientation)target.SolidOrientation, volume = target.IsSolid ? target.GetVolume() : 0, area = target.GetArea(), - bbox = _boxConverter.Convert(new RG.Box(target.GetBoundingBox(false))), + bbox = _boxConverter.Convert(_rhinoBoxFactory.CreateBox(target.GetBoundingBox(false))), units = _contextStack.Current.SpeckleUnits }; @@ -106,7 +112,7 @@ public SOG.Brep Convert(RG.Brep target) return speckleBrep; } - private static List ConvertBrepFaces(RG.Brep brep, SOG.Brep speckleParent) => + private static List ConvertBrepFaces(IRhinoBrep brep, SOG.Brep speckleParent) => brep.Faces .Select( f => @@ -120,7 +126,7 @@ public SOG.Brep Convert(RG.Brep target) ) .ToList(); - private List ConvertBrepEdges(RG.Brep brep, SOG.Brep speckleParent) => + private List ConvertBrepEdges(IRhinoBrep brep, SOG.Brep speckleParent) => brep.Edges .Select( edge => @@ -128,15 +134,15 @@ public SOG.Brep Convert(RG.Brep target) speckleParent, edge.EdgeCurveIndex, edge.TrimIndices(), - edge.StartVertex?.VertexIndex ?? -1, - edge.EndVertex?.VertexIndex ?? -1, + edge.StartVertex.VertexIndex, + edge.EndVertex.VertexIndex, edge.ProxyCurveIsReversed, _intervalConverter.Convert(edge.Domain) ) ) .ToList(); - private List ConvertBrepTrims(RG.Brep brep, SOG.Brep speckleParent) => + private List ConvertBrepTrims(IRhinoBrep brep, SOG.Brep speckleParent) => brep.Trims .Select(trim => { @@ -160,7 +166,7 @@ public SOG.Brep Convert(RG.Brep target) }) .ToList(); - private List ConvertBrepLoops(RG.Brep brep, SOG.Brep speckleParent) => + private List ConvertBrepLoops(IRhinoBrep brep, SOG.Brep speckleParent) => brep.Loops .Select( loop => @@ -173,14 +179,13 @@ public SOG.Brep Convert(RG.Brep target) ) .ToList(); - private RG.Mesh? GetBrepDisplayMesh(RG.Brep brep) + private IRhinoMesh? GetBrepDisplayMesh(IRhinoBrep brep) { - var joinedMesh = new RG.Mesh(); + var joinedMesh = _rhinoMeshFactory.Create(); // get from settings //Settings.TryGetValue("sendMeshSetting", out string meshSetting); - RG.MeshingParameters mySettings = new(0.05, 0.05); // switch (SelectedMeshSettings) // { // case MeshSettings.CurrentDoc: @@ -194,7 +199,7 @@ public SOG.Brep Convert(RG.Brep target) try { - joinedMesh.Append(RG.Mesh.CreateFromBrep(brep, mySettings)); + joinedMesh.Append(_rhinoMeshFactory.CreateFromBrep(brep, 0.05, 0.05)); return joinedMesh; } catch (Exception ex) when (!ex.IsFatal()) diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/CircleToSpeckleConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/CircleToSpeckleConverter.cs index 0e3f91e3bf..64ef397045 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/CircleToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/CircleToSpeckleConverter.cs @@ -1,35 +1,35 @@ -using Rhino; -using Speckle.Converters.Common; +using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; using Speckle.Core.Models; +using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToSpeckle.Raw; -public class CircleToSpeckleConverter : ITypedConverter +public class CircleToSpeckleConverter : ITypedConverter { - private readonly ITypedConverter _planeConverter; - private readonly IConversionContextStack _contextStack; + private readonly ITypedConverter _planeConverter; + private readonly IConversionContextStack _contextStack; public CircleToSpeckleConverter( - ITypedConverter planeConverter, - IConversionContextStack contextStack + ITypedConverter planeConverter, + IConversionContextStack contextStack ) { _planeConverter = planeConverter; _contextStack = contextStack; } - public Base Convert(object target) => Convert((RG.Circle)target); + public Base Convert(object target) => Convert((IRhinoCircle)target); /// - /// Converts a RG.Circle object to a SOG.Circle object. + /// Converts a IRhinoCircle object to a SOG.Circle object. /// - /// The RG.Circle object to convert. + /// The IRhinoCircle object to convert. /// The converted SOG.Circle object. /// /// ⚠️ This conversion assumes the domain of a circle is (0,1) as Rhino Circle types do not have a domain. If you want to preserve the domain use ArcCurve conversion instead. /// - public SOG.Circle Convert(RG.Circle target) => + public SOG.Circle Convert(IRhinoCircle target) => new(_planeConverter.Convert(target.Plane), target.Radius, _contextStack.Current.SpeckleUnits) { domain = new SOP.Interval(0, 1), diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/ControlPointToSpeckleConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/ControlPointToSpeckleConverter.cs index d3747e2faf..0fa733ca87 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/ControlPointToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/ControlPointToSpeckleConverter.cs @@ -1,15 +1,14 @@ -using Rhino; -using Speckle.Converters.Common; +using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; -using Speckle.Core.Models; +using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToSpeckle.Raw; -public class ControlPointToSpeckleConverter : ITypedConverter +public class ControlPointToSpeckleConverter : ITypedConverter { - private readonly IConversionContextStack _contextStack; + private readonly IConversionContextStack _contextStack; - public ControlPointToSpeckleConverter(IConversionContextStack contextStack) + public ControlPointToSpeckleConverter(IConversionContextStack contextStack) { _contextStack = contextStack; } @@ -19,8 +18,6 @@ public ControlPointToSpeckleConverter(IConversionContextStack /// The ControlPoint object to convert. /// The converted Speckle ControlPoint object. - public SOG.ControlPoint Convert(RG.ControlPoint target) => + public SOG.ControlPoint Convert(IRhinoControlPoint target) => new(target.Location.X, target.Location.Y, target.Location.Z, target.Weight, _contextStack.Current.SpeckleUnits); - - public Base Convert(object target) => Convert((RG.ControlPoint)target); } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/CurveToSpeckleConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/CurveToSpeckleConverter.cs index 5c792ebaf8..855a2d43d5 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/CurveToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/CurveToSpeckleConverter.cs @@ -1,24 +1,25 @@ using Objects; using Speckle.Converters.Common.Objects; using Speckle.Core.Models; +using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToSpeckle.Raw; // POC: CNX-9278 This converter decides which specific curve conversion to use. IIndex may be a better choice. -public class CurveToSpeckleConverter : ITypedConverter, ITypedConverter +public class CurveToSpeckleConverter : ITypedConverter, ITypedConverter { - private readonly ITypedConverter _polyCurveConverter; - private readonly ITypedConverter _arcCurveConverter; - private readonly ITypedConverter _polylineConverter; - private readonly ITypedConverter _nurbsCurveConverter; - private readonly ITypedConverter _lineCurveConverter; + private readonly ITypedConverter _polyCurveConverter; + private readonly ITypedConverter _arcCurveConverter; + private readonly ITypedConverter _polylineConverter; + private readonly ITypedConverter _nurbsCurveConverter; + private readonly ITypedConverter _lineCurveConverter; public CurveToSpeckleConverter( - ITypedConverter polyCurveConverter, - ITypedConverter arcCurveConverter, - ITypedConverter polylineConverter, - ITypedConverter nurbsCurveConverter, - ITypedConverter lineCurveConverter + ITypedConverter polyCurveConverter, + ITypedConverter arcCurveConverter, + ITypedConverter polylineConverter, + ITypedConverter nurbsCurveConverter, + ITypedConverter lineCurveConverter ) { _polyCurveConverter = polyCurveConverter; @@ -37,15 +38,31 @@ public CurveToSpeckleConverter( /// This is the main converter when the type of curve you input or output does not matter to the caller.
/// ⚠️ If an unsupported type of Curve is input, it will be converted to NURBS. /// - public ICurve Convert(RG.Curve target) => - target switch + public ICurve Convert(IRhinoCurve target) + { + var polyline = target.ToPolylineCurve(); + if (polyline is not null) + { + return _polylineConverter.Convert(polyline); + } + var arcCurve = target.ToArcCurve(); + if (arcCurve is not null) + { + return _arcCurveConverter.Convert(arcCurve); + } + var polyCurve = target.ToPolyCurve(); + if (polyCurve is not null) { - RG.PolyCurve polyCurve => _polyCurveConverter.Convert(polyCurve), - RG.ArcCurve arcCurve => _arcCurveConverter.Convert(arcCurve), - RG.PolylineCurve polylineCurve => _polylineConverter.Convert(polylineCurve), - RG.LineCurve lineCurve => _lineCurveConverter.Convert(lineCurve), - _ => _nurbsCurveConverter.Convert(target.ToNurbsCurve()) - }; + return _polyCurveConverter.Convert(polyCurve); + } + var lineCurve = target.ToLineCurve(); + if (lineCurve is not null) + { + return _lineCurveConverter.Convert(lineCurve); + } + var nurbsCurve = target.ToNurbsCurve(); + return _nurbsCurveConverter.Convert(nurbsCurve); + } - Base ITypedConverter.Convert(RG.Curve target) => (Base)Convert(target); + Base ITypedConverter.Convert(IRhinoCurve target) => (Base)Convert(target); } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/EllipseToSpeckleConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/EllipseToSpeckleConverter.cs index fc6b52cc8f..0420067ae7 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/EllipseToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/EllipseToSpeckleConverter.cs @@ -1,24 +1,27 @@ -using Rhino; -using Speckle.Converters.Common; +using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; +using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToSpeckle.Raw; -public class EllipseToSpeckleConverter : ITypedConverter +public class EllipseToSpeckleConverter : ITypedConverter { - private readonly ITypedConverter _planeConverter; - private readonly ITypedConverter _boxConverter; - private readonly IConversionContextStack _contextStack; + private readonly ITypedConverter _planeConverter; + private readonly ITypedConverter _boxConverter; + private readonly IConversionContextStack _contextStack; + private readonly IRhinoBoxFactory _rhinoBoxFactory; public EllipseToSpeckleConverter( - ITypedConverter planeConverter, - ITypedConverter boxConverter, - IConversionContextStack contextStack + ITypedConverter planeConverter, + ITypedConverter boxConverter, + IConversionContextStack contextStack, + IRhinoBoxFactory rhinoBoxFactory ) { _planeConverter = planeConverter; _boxConverter = boxConverter; _contextStack = contextStack; + _rhinoBoxFactory = rhinoBoxFactory; } /// @@ -29,7 +32,7 @@ IConversionContextStack contextStack /// /// ⚠️ Rhino ellipses are not curves. The result is a mathematical representation of an ellipse that can be converted into NURBS for display. /// - public SOG.Ellipse Convert(RG.Ellipse target) + public SOG.Ellipse Convert(IRhinoEllipse target) { var nurbsCurve = target.ToNurbsCurve(); return new( @@ -42,7 +45,7 @@ public SOG.Ellipse Convert(RG.Ellipse target) domain = new SOP.Interval(0, 1), length = nurbsCurve.GetLength(), area = Math.PI * target.Radius1 * target.Radius2, - bbox = _boxConverter.Convert(new RG.Box(nurbsCurve.GetBoundingBox(true))) + bbox = _boxConverter.Convert(_rhinoBoxFactory.CreateBox(nurbsCurve.GetBoundingBox(true))) }; } } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/IntervalToSpeckleConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/IntervalToSpeckleConverter.cs index 272fecafdb..8044a90e7d 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/IntervalToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/IntervalToSpeckleConverter.cs @@ -1,13 +1,14 @@ using Speckle.Converters.Common.Objects; +using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToSpeckle.Raw; -public class IntervalToSpeckleConverter : ITypedConverter +public class IntervalToSpeckleConverter : ITypedConverter { /// /// Converts a Rhino Interval object to a Speckle Interval object. /// /// The Rhino Interval object to be converted. /// The converted Speckle Interval object. - public SOP.Interval Convert(RG.Interval target) => new(target.T0, target.T1); + public SOP.Interval Convert(IRhinoInterval target) => new(target.T0, target.T1); } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/LineToSpeckleConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/LineToSpeckleConverter.cs index f40620f78d..dc480c79fd 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/LineToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/LineToSpeckleConverter.cs @@ -1,24 +1,27 @@ -using Rhino; -using Speckle.Converters.Common; +using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; +using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToSpeckle.Raw; -public class LineToSpeckleConverter : ITypedConverter, ITypedConverter +public class LineToSpeckleConverter : ITypedConverter, ITypedConverter { - private readonly ITypedConverter _pointConverter; - private readonly ITypedConverter _boxConverter; - private readonly IConversionContextStack _contextStack; + private readonly ITypedConverter _pointConverter; + private readonly ITypedConverter _boxConverter; + private readonly IConversionContextStack _contextStack; + private readonly IRhinoBoxFactory _rhinoBoxFactory; public LineToSpeckleConverter( - ITypedConverter pointConverter, - ITypedConverter boxConverter, - IConversionContextStack contextStack + ITypedConverter pointConverter, + ITypedConverter boxConverter, + IConversionContextStack contextStack, + IRhinoBoxFactory rhinoBoxFactory ) { _pointConverter = pointConverter; _boxConverter = boxConverter; _contextStack = contextStack; + _rhinoBoxFactory = rhinoBoxFactory; } /// @@ -29,13 +32,13 @@ IConversionContextStack contextStack /// /// ⚠️ This conversion assumes the domain of a line is (0, LENGTH), as Rhino Lines do not have domain. If you want the domain preserved use LineCurve conversions instead. /// - public SOG.Line Convert(RG.Line target) => + public SOG.Line Convert(IRhinoLine target) => new(_pointConverter.Convert(target.From), _pointConverter.Convert(target.To), _contextStack.Current.SpeckleUnits) { length = target.Length, domain = new SOP.Interval(0, target.Length), - bbox = _boxConverter.Convert(new RG.Box(target.BoundingBox)) + bbox = _boxConverter.Convert(_rhinoBoxFactory.CreateBox(target.BoundingBox)) }; - public SOG.Line Convert(RG.LineCurve target) => Convert(target.Line); + public SOG.Line Convert(IRhinoLineCurve target) => Convert(target.Line); } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/MeshToSpeckleConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/MeshToSpeckleConverter.cs index 73aa3f4a8a..cf7dfbc288 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/MeshToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/MeshToSpeckleConverter.cs @@ -1,25 +1,25 @@ -using Rhino; -using Speckle.Converters.Common; +using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; +using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToSpeckle.Raw; -[NameAndRankValue(nameof(RG.Mesh), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class MeshToSpeckleConverter : ITypedConverter +[NameAndRankValue(nameof(IRhinoMesh), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +public class MeshToSpeckleConverter : ITypedConverter { - private readonly ITypedConverter _pointConverter; - private readonly ITypedConverter _boxConverter; - private readonly IConversionContextStack _contextStack; + private readonly ITypedConverter _boxConverter; + private readonly IConversionContextStack _contextStack; + private readonly IRhinoBoxFactory _rhinoBoxFactory; public MeshToSpeckleConverter( - ITypedConverter pointConverter, - ITypedConverter boxConverter, - IConversionContextStack contextStack + ITypedConverter boxConverter, + IConversionContextStack contextStack, + IRhinoBoxFactory rhinoBoxFactory ) { - _pointConverter = pointConverter; _boxConverter = boxConverter; _contextStack = contextStack; + _rhinoBoxFactory = rhinoBoxFactory; } /// @@ -28,7 +28,7 @@ IConversionContextStack contextStack /// The Rhino Mesh to be converted. /// The converted Speckle Mesh. /// Thrown when the Rhino Mesh has 0 vertices or faces. - public SOG.Mesh Convert(RG.Mesh target) + public SOG.Mesh Convert(IRhinoMesh target) { if (target.Vertices.Count == 0 || target.Faces.Count == 0) { @@ -38,7 +38,7 @@ public SOG.Mesh Convert(RG.Mesh target) var vertexCoordinates = target.Vertices.ToPoint3dArray().SelectMany(pt => new[] { pt.X, pt.Y, pt.Z }).ToList(); var faces = new List(); - foreach (RG.MeshNgon polygon in target.GetNgonAndFacesEnumerable()) + foreach (IRhinoMeshNgon polygon in target.GetNgonAndFacesEnumerable()) { var vertIndices = polygon.BoundaryVertexIndexList(); int n = vertIndices.Length; @@ -55,7 +55,7 @@ public SOG.Mesh Convert(RG.Mesh target) var colors = target.VertexColors.Select(cl => cl.ToArgb()).ToList(); var volume = target.IsClosed ? target.Volume() : 0; - var bbox = _boxConverter.Convert(new RG.Box(target.GetBoundingBox(false))); + var bbox = _boxConverter.Convert(_rhinoBoxFactory.CreateBox(target.GetBoundingBox(false))); return new SOG.Mesh(vertexCoordinates, faces, colors, textureCoordinates, _contextStack.Current.SpeckleUnits) { diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/NurbsCurveConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/NurbsCurveConverter.cs index 6cf8dca53d..7c28b72c3d 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/NurbsCurveConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/NurbsCurveConverter.cs @@ -1,27 +1,30 @@ -using Rhino; -using Speckle.Converters.Common; +using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; +using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToSpeckle.Raw; -public class NurbsCurveConverter : ITypedConverter +public class NurbsCurveConverter : ITypedConverter { - private readonly ITypedConverter _polylineConverter; - private readonly ITypedConverter _intervalConverter; - private readonly ITypedConverter _boxConverter; - private readonly IConversionContextStack _contextStack; + private readonly ITypedConverter _polylineConverter; + private readonly ITypedConverter _intervalConverter; + private readonly ITypedConverter _boxConverter; + private readonly IConversionContextStack _contextStack; + private readonly IRhinoBoxFactory _rhinoBoxFactory; public NurbsCurveConverter( - ITypedConverter polylineConverter, - ITypedConverter intervalConverter, - ITypedConverter boxConverter, - IConversionContextStack contextStack + ITypedConverter polylineConverter, + ITypedConverter intervalConverter, + ITypedConverter boxConverter, + IConversionContextStack contextStack, + IRhinoBoxFactory rhinoBoxFactory ) { _polylineConverter = polylineConverter; _intervalConverter = intervalConverter; _boxConverter = boxConverter; _contextStack = contextStack; + _rhinoBoxFactory = rhinoBoxFactory; } /// @@ -34,13 +37,9 @@ IConversionContextStack contextStack /// It adds 1 extra knot at the start and end of the vector by repeating the first and last value. /// This is because Rhino's standard of (controlPoints + degree + 1) wasn't followed on other software. /// - public SOG.Curve Convert(RG.NurbsCurve target) + public SOG.Curve Convert(IRhinoNurbsCurve target) { target.ToPolyline(0, 1, 0, 0, 0, 0.1, 0, 0, true).TryGetPolyline(out var poly); - if (target.IsClosed) - { - poly.Add(poly[0]); - } SOG.Polyline displayValue = _polylineConverter.Convert(poly); @@ -63,7 +62,7 @@ public SOG.Curve Convert(RG.NurbsCurve target) domain = _intervalConverter.Convert(nurbsCurve.Domain), closed = nurbsCurve.IsClosed, length = nurbsCurve.GetLength(), - bbox = _boxConverter.Convert(new RG.Box(nurbsCurve.GetBoundingBox(true))) + bbox = _boxConverter.Convert(_rhinoBoxFactory.CreateBox(nurbsCurve.GetBoundingBox(true))) }; return myCurve; diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/NurbsSurfaceToSpeckleConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/NurbsSurfaceToSpeckleConverter.cs index 0d663ff520..4f4952622a 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/NurbsSurfaceToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/NurbsSurfaceToSpeckleConverter.cs @@ -1,28 +1,30 @@ -using Rhino; -using Rhino.Geometry.Collections; -using Speckle.Converters.Common; +using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; +using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToSpeckle.Raw; -public class NurbsSurfaceToSpeckleConverter : ITypedConverter +public class NurbsSurfaceToSpeckleConverter : ITypedConverter { - private readonly ITypedConverter _boxConverter; - private readonly ITypedConverter _intervalConverter; - private readonly ITypedConverter _controlPointConverter; - private readonly IConversionContextStack _contextStack; + private readonly ITypedConverter _boxConverter; + private readonly ITypedConverter _intervalConverter; + private readonly ITypedConverter _controlPointConverter; + private readonly IConversionContextStack _contextStack; + private readonly IRhinoBoxFactory _rhinoBoxFactory; public NurbsSurfaceToSpeckleConverter( - ITypedConverter boxConverter, - ITypedConverter intervalConverter, - ITypedConverter controlPointConverter, - IConversionContextStack contextStack + ITypedConverter boxConverter, + ITypedConverter intervalConverter, + ITypedConverter controlPointConverter, + IConversionContextStack contextStack, + IRhinoBoxFactory rhinoBoxFactory ) { _boxConverter = boxConverter; _intervalConverter = intervalConverter; _controlPointConverter = controlPointConverter; _contextStack = contextStack; + _rhinoBoxFactory = rhinoBoxFactory; } /// @@ -30,7 +32,7 @@ IConversionContextStack contextStack /// /// The NurbsSurface object to convert. /// A Surface object representing the converted NurbsSurface. - public SOG.Surface Convert(RG.NurbsSurface target) + public SOG.Surface Convert(IRhinoNurbsSurface target) { var result = new SOG.Surface { @@ -44,7 +46,7 @@ public SOG.Surface Convert(RG.NurbsSurface target) knotsU = target.KnotsU.ToList(), knotsV = target.KnotsV.ToList(), units = _contextStack.Current.SpeckleUnits, - bbox = _boxConverter.Convert(new RG.Box(target.GetBoundingBox(true))) + bbox = _boxConverter.Convert(_rhinoBoxFactory.CreateBox(target.GetBoundingBox(true))) }; result.SetControlPoints(ControlPointsToSpeckle(target.Points)); @@ -52,7 +54,7 @@ public SOG.Surface Convert(RG.NurbsSurface target) return result; } - private List> ControlPointsToSpeckle(NurbsSurfacePointList controlPoints) + private List> ControlPointsToSpeckle(IRhinoNurbsSurfacePointList controlPoints) { var points = new List>(); for (var i = 0; i < controlPoints.CountU; i++) diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/PlaneToSpeckleConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/PlaneToSpeckleConverter.cs index 40d15be50c..b2a3264467 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/PlaneToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/PlaneToSpeckleConverter.cs @@ -1,19 +1,19 @@ -using Rhino; using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; +using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToSpeckle.Raw; -public class PlaneToSpeckleConverter : ITypedConverter +public class PlaneToSpeckleConverter : ITypedConverter { - private readonly ITypedConverter _vectorConverter; - private readonly ITypedConverter _pointConverter; - private readonly IConversionContextStack _contextStack; + private readonly ITypedConverter _vectorConverter; + private readonly ITypedConverter _pointConverter; + private readonly IConversionContextStack _contextStack; public PlaneToSpeckleConverter( - ITypedConverter vectorConverter, - ITypedConverter pointConverter, - IConversionContextStack contextStack + ITypedConverter vectorConverter, + ITypedConverter pointConverter, + IConversionContextStack contextStack ) { _vectorConverter = vectorConverter; @@ -26,7 +26,7 @@ IConversionContextStack contextStack /// /// The instance of Rhino Plane to convert. /// The converted instance of Speckle Plane. - public SOG.Plane Convert(RG.Plane target) => + public SOG.Plane Convert(IRhinoPlane target) => new( _pointConverter.Convert(target.Origin), _vectorConverter.Convert(target.ZAxis), diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/PointToSpeckleConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/PointToSpeckleConverter.cs index 2bfdfdae1c..c110af447a 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/PointToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/PointToSpeckleConverter.cs @@ -1,14 +1,16 @@ -using Rhino; using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; +using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToSpeckle.Raw; -public class PointToSpeckleConverter : ITypedConverter, ITypedConverter +public class PointToSpeckleConverter + : ITypedConverter, + ITypedConverter { - private readonly IConversionContextStack _contextStack; + private readonly IConversionContextStack _contextStack; - public PointToSpeckleConverter(IConversionContextStack contextStack) + public PointToSpeckleConverter(IConversionContextStack contextStack) { _contextStack = contextStack; } @@ -18,7 +20,8 @@ public PointToSpeckleConverter(IConversionContextStack con /// /// The Rhino 3D point to convert. /// The converted Speckle point. - public SOG.Point Convert(RG.Point3d target) => new(target.X, target.Y, target.Z, _contextStack.Current.SpeckleUnits); + public SOG.Point Convert(IRhinoPoint3d target) => + new(target.X, target.Y, target.Z, _contextStack.Current.SpeckleUnits); - public SOG.Point Convert(RG.Point target) => Convert(target.Location); + public SOG.Point Convert(IRhinoPoint target) => Convert(target.Location); } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/PolyCurveToSpeckleConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/PolyCurveToSpeckleConverter.cs index 6937d6b007..10cdf491d5 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/PolyCurveToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/PolyCurveToSpeckleConverter.cs @@ -1,26 +1,30 @@ using Objects; -using Rhino; using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; +using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToSpeckle.Raw; -public class PolyCurveToSpeckleConverter : ITypedConverter +public class PolyCurveToSpeckleConverter : ITypedConverter { - public ITypedConverter? CurveConverter { get; set; } // POC: CNX-9279 This created a circular dependency on the constructor, making it a property allows for the container to resolve it correctly - private readonly ITypedConverter _intervalConverter; - private readonly ITypedConverter _boxConverter; - private readonly IConversionContextStack _contextStack; + public ITypedConverter? CurveConverter { get; set; } // POC: CNX-9279 This created a circular dependency on the constructor, making it a property allows for the container to resolve it correctly + + private readonly ITypedConverter _intervalConverter; + private readonly ITypedConverter _boxConverter; + private readonly IConversionContextStack _contextStack; + private readonly IRhinoBoxFactory _rhinoBoxFactory; public PolyCurveToSpeckleConverter( - ITypedConverter intervalConverter, - ITypedConverter boxConverter, - IConversionContextStack contextStack + ITypedConverter intervalConverter, + ITypedConverter boxConverter, + IConversionContextStack contextStack, + IRhinoBoxFactory rhinoBoxFactory ) { _intervalConverter = intervalConverter; _boxConverter = boxConverter; _contextStack = contextStack; + _rhinoBoxFactory = rhinoBoxFactory; } /// @@ -32,14 +36,14 @@ IConversionContextStack contextStack /// This method removes the nesting of the PolyCurve by duplicating the segments at a granular level. /// All PolyLIne, PolyCurve and NURBS curves with G1 discontinuities will be broken down. /// - public SOG.Polycurve Convert(RG.PolyCurve target) + public SOG.Polycurve Convert(IRhinoPolyCurve target) { var myPoly = new SOG.Polycurve { closed = target.IsClosed, domain = _intervalConverter.Convert(target.Domain), length = target.GetLength(), - bbox = _boxConverter.Convert(new RG.Box(target.GetBoundingBox(true))), + bbox = _boxConverter.Convert(_rhinoBoxFactory.CreateBox(target.GetBoundingBox(true))), segments = target.DuplicateSegments().Select(x => CurveConverter.NotNull().Convert(x)).ToList(), units = _contextStack.Current.SpeckleUnits }; diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/PolylineToSpeckleConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/PolylineToSpeckleConverter.cs index 1ee241e7d1..7682ceeb42 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/PolylineToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/PolylineToSpeckleConverter.cs @@ -1,29 +1,32 @@ -using Rhino; -using Speckle.Converters.Common; +using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; +using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToSpeckle.Raw; public class PolylineToSpeckleConverter - : ITypedConverter, - ITypedConverter + : ITypedConverter, + ITypedConverter { - private readonly ITypedConverter _pointConverter; - private readonly ITypedConverter _boxConverter; - private readonly ITypedConverter _intervalConverter; - private readonly IConversionContextStack _contextStack; + private readonly ITypedConverter _pointConverter; + private readonly ITypedConverter _boxConverter; + private readonly ITypedConverter _intervalConverter; + private readonly IConversionContextStack _contextStack; + private readonly IRhinoBoxFactory _rhinoBoxFactory; public PolylineToSpeckleConverter( - ITypedConverter pointConverter, - ITypedConverter boxConverter, - IConversionContextStack contextStack, - ITypedConverter intervalConverter + ITypedConverter pointConverter, + ITypedConverter boxConverter, + IConversionContextStack contextStack, + ITypedConverter intervalConverter, + IRhinoBoxFactory rhinoBoxFactory ) { _pointConverter = pointConverter; _boxConverter = boxConverter; _contextStack = contextStack; _intervalConverter = intervalConverter; + _rhinoBoxFactory = rhinoBoxFactory; } /// @@ -32,12 +35,12 @@ public PolylineToSpeckleConverter( /// The Rhino polyline to be converted. /// The converted Speckle polyline. /// ⚠️ This conversion assumes domain interval is (0,LENGTH) as Rhino Polylines have no domain. If needed, you may want to use PolylineCurve conversion instead. - public SOG.Polyline Convert(RG.Polyline target) + public SOG.Polyline Convert(IRhinoPolyline target) { - var box = _boxConverter.Convert(new RG.Box(target.BoundingBox)); + var box = _boxConverter.Convert(_rhinoBoxFactory.CreateBox(target.BoundingBox)); var points = target.Select(pt => _pointConverter.Convert(pt)).ToList(); - if (target.IsClosed) + if (points[0] == points[^1] && target.IsClosed) { points.RemoveAt(points.Count - 1); } @@ -48,8 +51,8 @@ public SOG.Polyline Convert(RG.Polyline target) ) { bbox = box, - length = target.Length, - domain = new(0, target.Length), + length = target.Count, + domain = new(0, target.Count), closed = target.IsClosed }; } @@ -60,7 +63,7 @@ public SOG.Polyline Convert(RG.Polyline target) /// The Rhino PolylineCurve to be converted. /// The converted Speckle polyline. /// ✅ This conversion respects the domain of the original PolylineCurve - public SOG.Polyline Convert(RG.PolylineCurve target) + public SOG.Polyline Convert(IRhinoPolylineCurve target) { var result = Convert(target.ToPolyline()); result.domain = _intervalConverter.Convert(target.Domain); diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/RawPointCloudToSpeckle.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/RawPointCloudToSpeckle.cs index 5e4a17e6cb..f7d0fdee98 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/RawPointCloudToSpeckle.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/RawPointCloudToSpeckle.cs @@ -1,21 +1,24 @@ -using Rhino; -using Speckle.Converters.Common; +using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; +using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToSpeckle.Raw; -public class RawPointCloudToSpeckle : ITypedConverter +public class RawPointCloudToSpeckle : ITypedConverter { - private readonly IConversionContextStack _contextStack; - private readonly ITypedConverter _boxConverter; + private readonly IConversionContextStack _contextStack; + private readonly ITypedConverter _boxConverter; + private readonly IRhinoBoxFactory _rhinoBoxFactory; public RawPointCloudToSpeckle( - IConversionContextStack contextStack, - ITypedConverter boxConverter + IConversionContextStack contextStack, + ITypedConverter boxConverter, + IRhinoBoxFactory rhinoBoxFactory ) { _contextStack = contextStack; _boxConverter = boxConverter; + _rhinoBoxFactory = rhinoBoxFactory; } /// @@ -23,12 +26,12 @@ public RawPointCloudToSpeckle( /// /// The Rhino PointCloud object to convert. /// The converted Speckle Pointcloud object. - public SOG.Pointcloud Convert(RG.PointCloud target) => + public SOG.Pointcloud Convert(IRhinoPointCloud target) => new() { points = target.GetPoints().SelectMany(pt => new[] { pt.X, pt.Y, pt.Z }).ToList(), colors = target.GetColors().Select(o => o.ToArgb()).ToList(), - bbox = _boxConverter.Convert(new RG.Box(target.GetBoundingBox(true))), + bbox = _boxConverter.Convert(_rhinoBoxFactory.CreateBox(target.GetBoundingBox(true))), units = _contextStack.Current.SpeckleUnits }; } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/VectorToSpeckleConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/VectorToSpeckleConverter.cs index 489eddedc4..fe5de7db27 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/VectorToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/VectorToSpeckleConverter.cs @@ -1,14 +1,14 @@ -using Rhino; -using Speckle.Converters.Common; +using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; +using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToSpeckle.Raw; -public class VectorToSpeckleConverter : ITypedConverter +public class VectorToSpeckleConverter : ITypedConverter { - private readonly IConversionContextStack _contextStack; + private readonly IConversionContextStack _contextStack; - public VectorToSpeckleConverter(IConversionContextStack contextStack) + public VectorToSpeckleConverter(IConversionContextStack contextStack) { _contextStack = contextStack; } @@ -18,6 +18,6 @@ public VectorToSpeckleConverter(IConversionContextStack co /// /// The Rhino Vector3d object to convert. /// The converted Speckle Vector object. - public SOG.Vector Convert(RG.Vector3d target) => + public SOG.Vector Convert(IRhinoVector3d target) => new(target.X, target.Y, target.Z, _contextStack.Current.SpeckleUnits); } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/BrepObjectToSpeckleTopLevelConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/BrepObjectToSpeckleTopLevelConverter.cs index 7520c1bd83..d55b39090c 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/BrepObjectToSpeckleTopLevelConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/BrepObjectToSpeckleTopLevelConverter.cs @@ -1,23 +1,23 @@ -using Rhino.DocObjects; -using Speckle.Converters.Common; +using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; using Speckle.Core.Models; +using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToSpeckle.TopLevel; -[NameAndRankValue(nameof(BrepObject), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +[NameAndRankValue(nameof(IRhinoBrepObject), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] public class BrepObjectToSpeckleTopLevelConverter : IToSpeckleTopLevelConverter { - private readonly ITypedConverter _curveConverter; + private readonly ITypedConverter _curveConverter; - public BrepObjectToSpeckleTopLevelConverter(ITypedConverter curveConverter) + public BrepObjectToSpeckleTopLevelConverter(ITypedConverter curveConverter) { _curveConverter = curveConverter; } public Base Convert(object target) { - var curveObject = (BrepObject)target; + var curveObject = (IRhinoBrepObject)target; //can only be this type var speckleCurve = _curveConverter.Convert(curveObject.BrepGeometry); return speckleCurve; } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/CurveObjectToSpeckleTopLevelConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/CurveObjectToSpeckleTopLevelConverter.cs index a8214a0c97..34fcf6c18e 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/CurveObjectToSpeckleTopLevelConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/CurveObjectToSpeckleTopLevelConverter.cs @@ -1,15 +1,16 @@ -using Rhino.DocObjects; -using Speckle.Converters.Common; +using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; using Speckle.Core.Models; +using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToSpeckle.TopLevel; -[NameAndRankValue(nameof(CurveObject), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class CurveObjectToSpeckleTopLevelConverter : RhinoObjectToSpeckleTopLevelConverter +[NameAndRankValue(nameof(IRhinoCurveObject), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +public class CurveObjectToSpeckleTopLevelConverter + : RhinoObjectToSpeckleTopLevelConverter { - public CurveObjectToSpeckleTopLevelConverter(ITypedConverter conversion) + public CurveObjectToSpeckleTopLevelConverter(ITypedConverter conversion) : base(conversion) { } - protected override RG.Curve GetTypedGeometry(CurveObject input) => input.CurveGeometry; + protected override IRhinoCurve GetTypedGeometry(IRhinoCurveObject input) => input.CurveGeometry; } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/ExtrusionObjectToSpeckleTopLevelConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/ExtrusionObjectToSpeckleTopLevelConverter.cs index 46d2c27586..3c5d93335d 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/ExtrusionObjectToSpeckleTopLevelConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/ExtrusionObjectToSpeckleTopLevelConverter.cs @@ -1,23 +1,23 @@ -using Rhino.DocObjects; -using Speckle.Converters.Common; +using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; using Speckle.Core.Models; +using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToSpeckle.TopLevel; -[NameAndRankValue(nameof(ExtrusionObject), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +[NameAndRankValue(nameof(IRhinoExtrusionObject), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] public class ExtrusionObjectToSpeckleTopLevelConverter : IToSpeckleTopLevelConverter { - private readonly ITypedConverter _curveConverter; + private readonly ITypedConverter _curveConverter; - public ExtrusionObjectToSpeckleTopLevelConverter(ITypedConverter curveConverter) + public ExtrusionObjectToSpeckleTopLevelConverter(ITypedConverter curveConverter) { _curveConverter = curveConverter; } public Base Convert(object target) { - var curveObject = (ExtrusionObject)target; + var curveObject = (IRhinoExtrusionObject)target; //can only be this type var speckleCurve = _curveConverter.Convert(curveObject.ExtrusionGeometry.ToBrep()); return speckleCurve; } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/MeshObjectToSpeckleTopLevelConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/MeshObjectToSpeckleTopLevelConverter.cs index f1c9675a04..025e36fd99 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/MeshObjectToSpeckleTopLevelConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/MeshObjectToSpeckleTopLevelConverter.cs @@ -1,14 +1,15 @@ -using Rhino.DocObjects; -using Speckle.Converters.Common; +using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; +using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToSpeckle.TopLevel; -[NameAndRankValue(nameof(MeshObject), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class MeshObjectToSpeckleTopLevelConverter : RhinoObjectToSpeckleTopLevelConverter +[NameAndRankValue(nameof(IRhinoMeshObject), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +public class MeshObjectToSpeckleTopLevelConverter + : RhinoObjectToSpeckleTopLevelConverter { - public MeshObjectToSpeckleTopLevelConverter(ITypedConverter conversion) + public MeshObjectToSpeckleTopLevelConverter(ITypedConverter conversion) : base(conversion) { } - protected override RG.Mesh GetTypedGeometry(MeshObject input) => input.MeshGeometry; + protected override IRhinoMesh GetTypedGeometry(IRhinoMeshObject input) => input.MeshGeometry; } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/PointCloudObjectToSpeckleTopLevelConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/PointCloudObjectToSpeckleTopLevelConverter.cs index e741e38e49..b25c80d190 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/PointCloudObjectToSpeckleTopLevelConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/PointCloudObjectToSpeckleTopLevelConverter.cs @@ -1,15 +1,15 @@ -using Rhino.DocObjects; -using Speckle.Converters.Common; +using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; +using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToSpeckle.TopLevel; -[NameAndRankValue(nameof(PointCloudObject), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +[NameAndRankValue(nameof(IRhinoPointCloudObject), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] public class PointCloudObjectToSpeckleTopLevelConverter - : RhinoObjectToSpeckleTopLevelConverter + : RhinoObjectToSpeckleTopLevelConverter { - public PointCloudObjectToSpeckleTopLevelConverter(ITypedConverter conversion) + public PointCloudObjectToSpeckleTopLevelConverter(ITypedConverter conversion) : base(conversion) { } - protected override RG.PointCloud GetTypedGeometry(PointCloudObject input) => input.PointCloudGeometry; + protected override IRhinoPointCloud GetTypedGeometry(IRhinoPointCloudObject input) => input.PointCloudGeometry; } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/PointObjectToSpeckleTopLevelConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/PointObjectToSpeckleTopLevelConverter.cs index 7d9c750b64..d127aa0266 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/PointObjectToSpeckleTopLevelConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/PointObjectToSpeckleTopLevelConverter.cs @@ -1,15 +1,15 @@ -using Rhino.DocObjects; -using Speckle.Converters.Common; +using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; +using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToSpeckle.TopLevel; -[NameAndRankValue(nameof(PointObject), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +[NameAndRankValue(nameof(IRhinoPointObject), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] public class PointObjectToSpeckleTopLevelConverter - : RhinoObjectToSpeckleTopLevelConverter + : RhinoObjectToSpeckleTopLevelConverter { - public PointObjectToSpeckleTopLevelConverter(ITypedConverter conversion) + public PointObjectToSpeckleTopLevelConverter(ITypedConverter conversion) : base(conversion) { } - protected override RG.Point GetTypedGeometry(PointObject input) => input.PointGeometry; + protected override IRhinoPoint GetTypedGeometry(IRhinoPointObject input) => input.PointGeometry; } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/RhinoObjectToSpeckleTopLevelConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/RhinoObjectToSpeckleTopLevelConverter.cs index edff24473a..f86d7a09f5 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/RhinoObjectToSpeckleTopLevelConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/RhinoObjectToSpeckleTopLevelConverter.cs @@ -4,15 +4,15 @@ namespace Speckle.Converters.Rhino7.ToSpeckle.TopLevel; public abstract class RhinoObjectToSpeckleTopLevelConverter : IToSpeckleTopLevelConverter - where TTopLevelIn : Rhino.DocObjects.RhinoObject - where TInRaw : RG.GeometryBase + where TTopLevelIn : notnull + where TInRaw : notnull where TOutRaw : Base { - public ITypedConverter Conversion { get; } + private readonly ITypedConverter _conversion; protected RhinoObjectToSpeckleTopLevelConverter(ITypedConverter conversion) { - Conversion = conversion; + _conversion = conversion; } // POC: IIndex would fix this as I would just request the type from `RhinoObject.Geometry` directly. @@ -20,10 +20,10 @@ protected RhinoObjectToSpeckleTopLevelConverter(ITypedConverter public virtual Base Convert(object target) { - var typedTarget = (TTopLevelIn)target; + var typedTarget = (TTopLevelIn)target; //can only be this typee var typedGeometry = GetTypedGeometry(typedTarget); - var result = Conversion.Convert(typedGeometry); + var result = _conversion.Convert(typedGeometry); // POC: Any common operations for all RhinoObjects should be done here, not on the specific implementer // Things like user-dictionaries and other user-defined metadata. diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/packages.lock.json b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/packages.lock.json index 2512d2a6e6..9a85ec5d77 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/packages.lock.json +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/packages.lock.json @@ -8,18 +8,18 @@ "resolved": "1.14.1", "contentHash": "mOOmFYwad3MIOL14VCjj02LljyF1GNw1wP0YVlxtcPvqdxjGGMNdNJJxHptlry3MOd8b40Flm8RPOM8JOlN2sQ==" }, - "RhinoCommon": { - "type": "Direct", - "requested": "[7.13.21348.13001, )", - "resolved": "7.13.21348.13001", - "contentHash": "JQdaNw61ddBqIe08E9O4N/grwrN1hjDHcYW7tWylwCZyFR7SepoCD4NS+6LN6+oSQhNbhLi9Bf+hQOFYFdRAEA==" - }, "Speckle.InterfaceGenerator": { "type": "Direct", "requested": "[0.9.5, )", "resolved": "0.9.5", "contentHash": "oU/L7pN1R7q8KkbrpQ3WJnHirPHqn+9DEA7asOcUiggV5dzVg1A/VYs7GOSusD24njxXh03tE3a2oTLOjt3cVg==" }, + "Speckle.Rhino7.Interfaces": { + "type": "Direct", + "requested": "[0.1.1-preview.0.28, )", + "resolved": "0.1.1-preview.0.28", + "contentHash": "TcbfXlRMnQRat1JodgW+YW5FflTYem1GGo9DtKA+6iAuVaYagN5dxsrM5LE6M3pCnEV9rkEQOjFo7sgnnbo4mw==" + }, "GraphQL.Client": { "type": "Transitive", "resolved": "6.0.0", @@ -205,11 +205,6 @@ "resolved": "13.0.2", "contentHash": "g1BejUZwax5PRfL6xHgLEK23sqHWOgOj9hE7RvfRRlN00AGt8GnPYt8HedSK7UB3HiRW8zCA9Pn0iiYxCK24BA==" }, - "Speckle.Revit2023.Interfaces": { - "type": "Transitive", - "resolved": "0.1.1-preview.0.24", - "contentHash": "BSVpOUJc9g6ISrw8GxvtkglTlITpHEDYNOhxv1ZPbckBsI0yO36JiphhQV4q57ERqD9PpCozUJkVhlCaxWeS6A==" - }, "SQLitePCLRaw.bundle_e_sqlite3": { "type": "Transitive", "resolved": "2.1.4", @@ -359,8 +354,7 @@ "type": "Project", "dependencies": { "Speckle.Autofac": "[2.0.999-local, )", - "Speckle.Objects": "[2.0.999-local, )", - "Speckle.Revit2023.Interfaces": "[0.1.1-preview.0.24, )" + "Speckle.Objects": "[2.0.999-local, )" } }, "Speckle.Core": { diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/ContainerRegistration.cs b/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/ContainerRegistration.cs index 189bbcc6e7..07f974d26a 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/ContainerRegistration.cs +++ b/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/ContainerRegistration.cs @@ -12,6 +12,7 @@ this SpeckleContainerBuilder builder where TRootToSpeckleConverter : class, IRootToSpeckleConverter where THostToSpeckleUnitConverter : class, IHostToSpeckleUnitConverter { + builder.ScanAssemblyOfType(); builder.AddScoped(); builder.AddScoped, THostToSpeckleUnitConverter>(); /* diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/packages.lock.json b/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/packages.lock.json index 326fdefd15..890db720a4 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/packages.lock.json +++ b/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/packages.lock.json @@ -302,11 +302,6 @@ "resolved": "13.0.2", "contentHash": "g1BejUZwax5PRfL6xHgLEK23sqHWOgOj9hE7RvfRRlN00AGt8GnPYt8HedSK7UB3HiRW8zCA9Pn0iiYxCK24BA==" }, - "Speckle.Revit2023.Interfaces": { - "type": "Transitive", - "resolved": "0.1.1-preview.0.24", - "contentHash": "BSVpOUJc9g6ISrw8GxvtkglTlITpHEDYNOhxv1ZPbckBsI0yO36JiphhQV4q57ERqD9PpCozUJkVhlCaxWeS6A==" - }, "SQLitePCLRaw.bundle_e_sqlite3": { "type": "Transitive", "resolved": "2.1.4", @@ -459,8 +454,7 @@ "type": "Project", "dependencies": { "Speckle.Autofac": "[2.0.999-local, )", - "Speckle.Objects": "[2.0.999-local, )", - "Speckle.Revit2023.Interfaces": "[0.1.1-preview.0.24, )" + "Speckle.Objects": "[2.0.999-local, )" } }, "Speckle.Core": { diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common.Tests/RootToSpeckleConverterTests.cs b/DUI3-DX/Sdk/Speckle.Converters.Common.Tests/RootToSpeckleConverterTests.cs index a94bf874e4..ae505bb94b 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common.Tests/RootToSpeckleConverterTests.cs +++ b/DUI3-DX/Sdk/Speckle.Converters.Common.Tests/RootToSpeckleConverterTests.cs @@ -1,8 +1,7 @@ -using FluentAssertions; +using FluentAssertions; using Moq; using NUnit.Framework; using Speckle.Core.Models; -using Speckle.Revit.Interfaces; namespace Speckle.Converters.Common.Tests; diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common.Tests/Speckle.Converters.Common.Tests.csproj b/DUI3-DX/Sdk/Speckle.Converters.Common.Tests/Speckle.Converters.Common.Tests.csproj index e687d74095..f1e4c53353 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common.Tests/Speckle.Converters.Common.Tests.csproj +++ b/DUI3-DX/Sdk/Speckle.Converters.Common.Tests/Speckle.Converters.Common.Tests.csproj @@ -14,7 +14,7 @@ - + diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common.Tests/packages.lock.json b/DUI3-DX/Sdk/Speckle.Converters.Common.Tests/packages.lock.json index c0e6585eb9..202e7670ff 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common.Tests/packages.lock.json +++ b/DUI3-DX/Sdk/Speckle.Converters.Common.Tests/packages.lock.json @@ -65,9 +65,9 @@ }, "Speckle.Revit2023.Interfaces": { "type": "Direct", - "requested": "[0.1.1-preview.0.24, )", - "resolved": "0.1.1-preview.0.24", - "contentHash": "BSVpOUJc9g6ISrw8GxvtkglTlITpHEDYNOhxv1ZPbckBsI0yO36JiphhQV4q57ERqD9PpCozUJkVhlCaxWeS6A==" + "requested": "[0.1.1-preview.0.28, )", + "resolved": "0.1.1-preview.0.28", + "contentHash": "7szXg/vRvP3Wdrn2ZGriVOfsw+bddlpVorBkCIhSHHs5qVTTG8IAIrI1l9dO0/aullaTMF+Xgxm9x3w1aXPiuA==" }, "Castle.Core": { "type": "Transitive", @@ -413,8 +413,7 @@ "type": "Project", "dependencies": { "Speckle.Autofac": "[2.0.999-local, )", - "Speckle.Objects": "[2.0.999-local, )", - "Speckle.Revit2023.Interfaces": "[0.1.1-preview.0.24, )" + "Speckle.Objects": "[2.0.999-local, )" } }, "Speckle.Core": { diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common/IProxyMapper.cs b/DUI3-DX/Sdk/Speckle.Converters.Common/IProxyMapper.cs new file mode 100644 index 0000000000..8b467d9395 --- /dev/null +++ b/DUI3-DX/Sdk/Speckle.Converters.Common/IProxyMapper.cs @@ -0,0 +1,33 @@ +namespace Speckle.Converters.Common; + +public interface IProxyMapper +{ + Type? GetMappedTypeFromHostType(Type type); + Type? GetMappedTypeFromProxyType(Type type); + Type? GetHostTypeFromMappedType(Type type); + + object CreateProxy(Type type, object toWrap); + + T CreateProxy(object toWrap); +} + +public record WrappedType(Type Type, object Target); + +// ghetto default interface implementation :( +public static class ProxyMapExtensions +{ + public static WrappedType? WrapIfExists(this IProxyMapper proxyMap, Type target, object toWrap) + { + var mappedType = proxyMap.GetMappedTypeFromHostType(target); + if (mappedType is not null) + { + return new(mappedType, proxyMap.CreateProxy(mappedType, toWrap)); + } + mappedType = proxyMap.GetMappedTypeFromProxyType(target); + if (mappedType is not null) + { + return new(mappedType, toWrap); + } + return null; + } +} diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common/RootConvertManager.cs b/DUI3-DX/Sdk/Speckle.Converters.Common/RootConvertManager.cs index 4ae930fa1c..6f29a573ad 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common/RootConvertManager.cs +++ b/DUI3-DX/Sdk/Speckle.Converters.Common/RootConvertManager.cs @@ -27,7 +27,7 @@ public Base Convert(Type type, object obj) if (objectConverter == null) { - throw new NotSupportedException($"No conversion found for {type.Name}"); + throw new NotSupportedException($"No conversion found for {type.Name} with actual type of {obj.GetType()}"); } var convertedObject = objectConverter.Convert(obj); diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common/RootToSpeckleConverter.cs b/DUI3-DX/Sdk/Speckle.Converters.Common/RootToSpeckleConverter.cs index fac0af321d..18ccad7495 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common/RootToSpeckleConverter.cs +++ b/DUI3-DX/Sdk/Speckle.Converters.Common/RootToSpeckleConverter.cs @@ -1,6 +1,5 @@ using Speckle.Core.Models; using Speckle.InterfaceGenerator; -using Speckle.Revit.Interfaces; namespace Speckle.Converters.Common; diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common/Speckle.Converters.Common.csproj b/DUI3-DX/Sdk/Speckle.Converters.Common/Speckle.Converters.Common.csproj index 07793ee159..9c80cf3aba 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common/Speckle.Converters.Common.csproj +++ b/DUI3-DX/Sdk/Speckle.Converters.Common/Speckle.Converters.Common.csproj @@ -8,8 +8,5 @@ - - - diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common/packages.lock.json b/DUI3-DX/Sdk/Speckle.Converters.Common/packages.lock.json index c3d43a1f8a..a9095c6e5b 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common/packages.lock.json +++ b/DUI3-DX/Sdk/Speckle.Converters.Common/packages.lock.json @@ -23,12 +23,6 @@ "resolved": "0.9.5", "contentHash": "oU/L7pN1R7q8KkbrpQ3WJnHirPHqn+9DEA7asOcUiggV5dzVg1A/VYs7GOSusD24njxXh03tE3a2oTLOjt3cVg==" }, - "Speckle.Revit2023.Interfaces": { - "type": "Direct", - "requested": "[0.1.1-preview.0.24, )", - "resolved": "0.1.1-preview.0.24", - "contentHash": "BSVpOUJc9g6ISrw8GxvtkglTlITpHEDYNOhxv1ZPbckBsI0yO36JiphhQV4q57ERqD9PpCozUJkVhlCaxWeS6A==" - }, "GraphQL.Client": { "type": "Transitive", "resolved": "6.0.0", From 85c2ff64dcaac0270ad8b89af14d5ede6ca481b9 Mon Sep 17 00:00:00 2001 From: Claire Kuang Date: Tue, 25 Jun 2024 14:04:24 +0100 Subject: [PATCH 244/261] DUI3-325 Add Civil3d 2024 connector (#3531) * adds converter and connector * fixes civil3d connector structure * fixes civil3d connector * removes converter * updates solution files * updates all * fixes civil3d connector merge * adds autocad2024 converter for the civil3d 2024 connector * removes changes to autocad settings * minor refactors * Update Applications.cs * adds shared connector module --- All.sln | 65 ++- Core/Core/Kits/Applications.cs | 6 + DUI3-DX.slnf | 3 + .../Speckle.Connectors.Autocad2023.csproj | 5 +- .../AutocadConnectorModule.cs | 30 +- .../Civil3dConnectorModule.cs | 37 ++ .../SharedConnectorModule.cs | 40 ++ .../HostApp/AutocadLayerManager.cs | 2 +- .../Plugin/AutocadCommand.cs | 9 +- ...Speckle.Connectors.AutocadShared.projitems | 2 + .../Speckle.Connectors.Civil3d2024.csproj | 26 + .../packages.lock.json | 533 ++++++++++++++++++ .../AutocadConverterModule.cs | 19 + ...ers.Autocad2024.DependencyInjection.csproj | 17 + .../packages.lock.json | 411 ++++++++++++++ .../Speckle.Converters.Autocad2024.csproj | 18 + .../packages.lock.json | 389 +++++++++++++ 17 files changed, 1577 insertions(+), 35 deletions(-) create mode 100644 DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/DependencyInjection/Civil3dConnectorModule.cs create mode 100644 DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/DependencyInjection/SharedConnectorModule.cs create mode 100644 DUI3-DX/Connectors/Autocad/Speckle.Connectors.Civil3d2024/Speckle.Connectors.Civil3d2024.csproj create mode 100644 DUI3-DX/Connectors/Autocad/Speckle.Connectors.Civil3d2024/packages.lock.json create mode 100644 DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2024.DependencyInjection/AutocadConverterModule.cs create mode 100644 DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2024.DependencyInjection/Speckle.Converters.Autocad2024.DependencyInjection.csproj create mode 100644 DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2024.DependencyInjection/packages.lock.json create mode 100644 DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2024/Speckle.Converters.Autocad2024.csproj create mode 100644 DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2024/packages.lock.json diff --git a/All.sln b/All.sln index 1365d9e652..9d104a8de5 100644 --- a/All.sln +++ b/All.sln @@ -555,9 +555,15 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConverterCivil2025", "Objec EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{B1324D25-C601-40F2-8AE2-6131F492B911}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Speckle.Converters.Revit2023.Tests", "DUI3-DX\Converters\Revit\Speckle.Converters.Revit2023.Tests\Speckle.Converters.Revit2023.Tests.csproj", "{AEC26A0B-25F3-4544-A9D6-A427BFF79250}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Speckle.Converters.Revit2023.Tests", "DUI3-DX\Converters\Revit\Speckle.Converters.Revit2023.Tests\Speckle.Converters.Revit2023.Tests.csproj", "{AEC26A0B-25F3-4544-A9D6-A427BFF79250}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Speckle.Converters.Common.Tests", "DUI3-DX\Sdk\Speckle.Converters.Common.Tests\Speckle.Converters.Common.Tests.csproj", "{95E23A97-E5EA-4506-A52C-D3DA9012DA02}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Speckle.Converters.Common.Tests", "DUI3-DX\Sdk\Speckle.Converters.Common.Tests\Speckle.Converters.Common.Tests.csproj", "{95E23A97-E5EA-4506-A52C-D3DA9012DA02}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Speckle.Connectors.Civil3d2024", "DUI3-DX\Connectors\Autocad\Speckle.Connectors.Civil3d2024\Speckle.Connectors.Civil3d2024.csproj", "{DDBBA313-69A6-40DE-AB3A-79EE5BF32A7E}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Speckle.Converters.Autocad2024", "DUI3-DX\Converters\Autocad\Speckle.Converters.Autocad2024\Speckle.Converters.Autocad2024.csproj", "{C9C28F31-1367-438C-83B0-049C3B3A3E3B}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Speckle.Converters.Autocad2024.DependencyInjection", "DUI3-DX\Converters\Autocad\Speckle.Converters.Autocad2024.DependencyInjection\Speckle.Converters.Autocad2024.DependencyInjection.csproj", "{06082BAA-98E8-49B1-9D33-252B126A0561}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -2825,6 +2831,54 @@ Global {95E23A97-E5EA-4506-A52C-D3DA9012DA02}.Release|Any CPU.Build.0 = Release|Any CPU {95E23A97-E5EA-4506-A52C-D3DA9012DA02}.Release|x64.ActiveCfg = Release|Any CPU {95E23A97-E5EA-4506-A52C-D3DA9012DA02}.Release|x64.Build.0 = Release|Any CPU + {DDBBA313-69A6-40DE-AB3A-79EE5BF32A7E}.Debug Mac|Any CPU.ActiveCfg = Debug|Any CPU + {DDBBA313-69A6-40DE-AB3A-79EE5BF32A7E}.Debug Mac|Any CPU.Build.0 = Debug|Any CPU + {DDBBA313-69A6-40DE-AB3A-79EE5BF32A7E}.Debug Mac|x64.ActiveCfg = Debug|Any CPU + {DDBBA313-69A6-40DE-AB3A-79EE5BF32A7E}.Debug Mac|x64.Build.0 = Debug|Any CPU + {DDBBA313-69A6-40DE-AB3A-79EE5BF32A7E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {DDBBA313-69A6-40DE-AB3A-79EE5BF32A7E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {DDBBA313-69A6-40DE-AB3A-79EE5BF32A7E}.Debug|x64.ActiveCfg = Debug|Any CPU + {DDBBA313-69A6-40DE-AB3A-79EE5BF32A7E}.Debug|x64.Build.0 = Debug|Any CPU + {DDBBA313-69A6-40DE-AB3A-79EE5BF32A7E}.Release Mac|Any CPU.ActiveCfg = Release|Any CPU + {DDBBA313-69A6-40DE-AB3A-79EE5BF32A7E}.Release Mac|Any CPU.Build.0 = Release|Any CPU + {DDBBA313-69A6-40DE-AB3A-79EE5BF32A7E}.Release Mac|x64.ActiveCfg = Release|Any CPU + {DDBBA313-69A6-40DE-AB3A-79EE5BF32A7E}.Release Mac|x64.Build.0 = Release|Any CPU + {DDBBA313-69A6-40DE-AB3A-79EE5BF32A7E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {DDBBA313-69A6-40DE-AB3A-79EE5BF32A7E}.Release|Any CPU.Build.0 = Release|Any CPU + {DDBBA313-69A6-40DE-AB3A-79EE5BF32A7E}.Release|x64.ActiveCfg = Release|Any CPU + {DDBBA313-69A6-40DE-AB3A-79EE5BF32A7E}.Release|x64.Build.0 = Release|Any CPU + {C9C28F31-1367-438C-83B0-049C3B3A3E3B}.Debug Mac|Any CPU.ActiveCfg = Debug|Any CPU + {C9C28F31-1367-438C-83B0-049C3B3A3E3B}.Debug Mac|Any CPU.Build.0 = Debug|Any CPU + {C9C28F31-1367-438C-83B0-049C3B3A3E3B}.Debug Mac|x64.ActiveCfg = Debug|Any CPU + {C9C28F31-1367-438C-83B0-049C3B3A3E3B}.Debug Mac|x64.Build.0 = Debug|Any CPU + {C9C28F31-1367-438C-83B0-049C3B3A3E3B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C9C28F31-1367-438C-83B0-049C3B3A3E3B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C9C28F31-1367-438C-83B0-049C3B3A3E3B}.Debug|x64.ActiveCfg = Debug|Any CPU + {C9C28F31-1367-438C-83B0-049C3B3A3E3B}.Debug|x64.Build.0 = Debug|Any CPU + {C9C28F31-1367-438C-83B0-049C3B3A3E3B}.Release Mac|Any CPU.ActiveCfg = Release|Any CPU + {C9C28F31-1367-438C-83B0-049C3B3A3E3B}.Release Mac|Any CPU.Build.0 = Release|Any CPU + {C9C28F31-1367-438C-83B0-049C3B3A3E3B}.Release Mac|x64.ActiveCfg = Release|Any CPU + {C9C28F31-1367-438C-83B0-049C3B3A3E3B}.Release Mac|x64.Build.0 = Release|Any CPU + {C9C28F31-1367-438C-83B0-049C3B3A3E3B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C9C28F31-1367-438C-83B0-049C3B3A3E3B}.Release|Any CPU.Build.0 = Release|Any CPU + {C9C28F31-1367-438C-83B0-049C3B3A3E3B}.Release|x64.ActiveCfg = Release|Any CPU + {C9C28F31-1367-438C-83B0-049C3B3A3E3B}.Release|x64.Build.0 = Release|Any CPU + {06082BAA-98E8-49B1-9D33-252B126A0561}.Debug Mac|Any CPU.ActiveCfg = Debug|Any CPU + {06082BAA-98E8-49B1-9D33-252B126A0561}.Debug Mac|Any CPU.Build.0 = Debug|Any CPU + {06082BAA-98E8-49B1-9D33-252B126A0561}.Debug Mac|x64.ActiveCfg = Debug|Any CPU + {06082BAA-98E8-49B1-9D33-252B126A0561}.Debug Mac|x64.Build.0 = Debug|Any CPU + {06082BAA-98E8-49B1-9D33-252B126A0561}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {06082BAA-98E8-49B1-9D33-252B126A0561}.Debug|Any CPU.Build.0 = Debug|Any CPU + {06082BAA-98E8-49B1-9D33-252B126A0561}.Debug|x64.ActiveCfg = Debug|Any CPU + {06082BAA-98E8-49B1-9D33-252B126A0561}.Debug|x64.Build.0 = Debug|Any CPU + {06082BAA-98E8-49B1-9D33-252B126A0561}.Release Mac|Any CPU.ActiveCfg = Release|Any CPU + {06082BAA-98E8-49B1-9D33-252B126A0561}.Release Mac|Any CPU.Build.0 = Release|Any CPU + {06082BAA-98E8-49B1-9D33-252B126A0561}.Release Mac|x64.ActiveCfg = Release|Any CPU + {06082BAA-98E8-49B1-9D33-252B126A0561}.Release Mac|x64.Build.0 = Release|Any CPU + {06082BAA-98E8-49B1-9D33-252B126A0561}.Release|Any CPU.ActiveCfg = Release|Any CPU + {06082BAA-98E8-49B1-9D33-252B126A0561}.Release|Any CPU.Build.0 = Release|Any CPU + {06082BAA-98E8-49B1-9D33-252B126A0561}.Release|x64.ActiveCfg = Release|Any CPU + {06082BAA-98E8-49B1-9D33-252B126A0561}.Release|x64.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -3002,6 +3056,7 @@ Global {2E00592E-558D-492D-88F9-3ECEE4C0C7DA} = {9DB74760-01DE-4AC1-A81B-BC7784351D22} {01F98733-7352-47AD-A594-537D979DE3DE} = {4838C66E-8677-4FBD-9609-25376042E981} {DC570FFF-6FE5-47BD-8BC1-B471A6067786} = {4838C66E-8677-4FBD-9609-25376042E981} + {E1C43415-3200-45F4-8BF9-A4DD7D7F2ED6} = {D92751C8-1039-4005-90B2-913E55E0B8BD} {83EAD6F0-3CB3-456A-AD81-072127D0DE0E} = {D92751C8-1039-4005-90B2-913E55E0B8BD} {26391930-F86F-47E0-A5F6-B89919E38CE1} = {D92751C8-1039-4005-90B2-913E55E0B8BD} {D81C0B87-F0C1-4297-A147-02F001FB7E1E} = {FD4D6594-D81E-456F-8F2E-35B09E04A755} @@ -3035,9 +3090,11 @@ Global {829688CD-CECE-4F6C-A5A0-032BB39CD9E0} = {BE521908-7944-46F3-98BF-B47D34509934} {70DEAA13-6DC8-44A0-B287-9E806A8054F1} = {890F3257-FCC2-4ED8-9180-22B3641B494C} {F06E4C37-4076-4272-9CA6-FB505E02CD31} = {BE521908-7944-46F3-98BF-B47D34509934} - {E1C43415-3200-45F4-8BF9-A4DD7D7F2ED6} = {D92751C8-1039-4005-90B2-913E55E0B8BD} {AEC26A0B-25F3-4544-A9D6-A427BFF79250} = {D92751C8-1039-4005-90B2-913E55E0B8BD} {95E23A97-E5EA-4506-A52C-D3DA9012DA02} = {2E00592E-558D-492D-88F9-3ECEE4C0C7DA} + {DDBBA313-69A6-40DE-AB3A-79EE5BF32A7E} = {743489BF-1941-43D5-8AF9-35C56D0DCC34} + {C9C28F31-1367-438C-83B0-049C3B3A3E3B} = {804E065F-914C-414A-AF84-009312C3CFF6} + {06082BAA-98E8-49B1-9D33-252B126A0561} = {804E065F-914C-414A-AF84-009312C3CFF6} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {1D43D91B-4F01-4A78-8250-CC6F9BD93A14} @@ -3145,6 +3202,7 @@ Global Objects\Converters\ConverterRevit\ConverterRevitShared\ConverterRevitShared.projitems*{c21a6553-b4ec-4ec3-b82a-c7a83cffb809}*SharedItemsImports = 5 ConnectorRevit\RevitSharedResources\RevitSharedResources.projitems*{c2ba8b6b-72bd-4dab-865f-90c66083bdb2}*SharedItemsImports = 5 Objects\Converters\ConverterNavisworks\ConverterNavisworks\ConverterNavisworksShared.projitems*{c3232ef3-2000-44c6-a330-b94531c9cc83}*SharedItemsImports = 13 + DUI3-DX\Converters\Autocad\Speckle.Converters.AutocadShared\Speckle.Converters.AutocadShared.projitems*{c9c28f31-1367-438c-83b0-049c3b3a3e3b}*SharedItemsImports = 5 Objects\Converters\ConverterNavisworks\ConverterNavisworks\ConverterNavisworksShared.projitems*{cafd4eac-75a8-4fc8-94e5-91cadc39f5b3}*SharedItemsImports = 5 Objects\Converters\ConverterRevit\ConverterRevitShared\ConverterRevitShared.projitems*{cc790553-8088-41a9-83cd-b29f7141f408}*SharedItemsImports = 5 Objects\Converters\ConverterNavisworks\ConverterNavisworks\ConverterNavisworksShared.projitems*{cd334556-ba2b-4272-a1eb-628e8152204a}*SharedItemsImports = 5 @@ -3156,6 +3214,7 @@ Global ConnectorRhino\ConnectorRhino\ConnectorRhinoShared\ConnectorRhinoShared.projitems*{d648bb69-b992-4d34-906e-7a547374b86c}*SharedItemsImports = 5 Objects\Converters\ConverterAutocadCivil\ConverterAutocadCivilShared\ConverterAutocadCivilShared.projitems*{d9f443b5-c55b-4ad8-9c70-bc3d2be781be}*SharedItemsImports = 5 DUI3-DX\Connectors\Revit\Speckle.Connectors.RevitShared\Speckle.Connectors.RevitShared.projitems*{dc570fff-6fe5-47bd-8bc1-b471a6067786}*SharedItemsImports = 13 + DUI3-DX\Connectors\Autocad\Speckle.Connectors.AutocadShared\Speckle.Connectors.AutocadShared.projitems*{ddbba313-69a6-40de-ab3a-79ee5bf32a7e}*SharedItemsImports = 5 ConnectorNavisworks\ConnectorNavisworks\ConnectorNavisworks.Shared.projitems*{debc2174-5e31-4b6e-8680-690d75e50e2d}*SharedItemsImports = 5 ConnectorRevit\ConnectorRevit\ConnectorRevit.projitems*{dfdfdbb8-018b-4dcb-a012-54227abf53a7}*SharedItemsImports = 5 DUI3-DX\Converters\Revit\Speckle.Converters.RevitShared\Speckle.Converters.RevitShared.projitems*{e1c43415-3200-45f4-8bf9-a4dd7d7f2ed6}*SharedItemsImports = 13 diff --git a/Core/Core/Kits/Applications.cs b/Core/Core/Kits/Applications.cs index ea3ccb0179..d80b63479e 100644 --- a/Core/Core/Kits/Applications.cs +++ b/Core/Core/Kits/Applications.cs @@ -64,6 +64,7 @@ public static class HostApplications Unity = new("Unity", "unity"), GSA = new("GSA", "gsa"), Civil = new("Civil 3D", "civil3d"), + Civil3D = new("Civil 3D", "civil3d"), AutoCAD = new("AutoCAD", "autocad"), MicroStation = new("MicroStation", "microstation"), OpenRoads = new("OpenRoads", "openroads"), @@ -119,6 +120,11 @@ public static HostApplication GetHostAppFromString(string? appname) return AutoCAD; } + if (appname.Contains("civil3d")) + { + return Civil3D; + } + if (appname.Contains("civil")) { return Civil; diff --git a/DUI3-DX.slnf b/DUI3-DX.slnf index 483d0c9d43..4bfa3426df 100644 --- a/DUI3-DX.slnf +++ b/DUI3-DX.slnf @@ -11,6 +11,7 @@ "DUI3-DX\\Connectors\\ArcGIS\\Speckle.Connectors.ArcGIS3\\Speckle.Connectors.ArcGIS3.csproj", "DUI3-DX\\Connectors\\Autocad\\Speckle.Connectors.Autocad2023\\Speckle.Connectors.Autocad2023.csproj", "DUI3-DX\\Connectors\\Autocad\\Speckle.Connectors.AutocadShared\\Speckle.Connectors.AutocadShared.shproj", + "DUI3-DX\\Connectors\\Autocad\\Speckle.Connectors.Civil3d2024\\Speckle.Connectors.Civil3d2024.csproj", "DUI3-DX\\Connectors\\Revit\\Speckle.Connectors.Revit2023\\Speckle.Connectors.Revit2023.csproj", "DUI3-DX\\Connectors\\Revit\\Speckle.Connectors.RevitShared\\Speckle.Connectors.RevitShared.shproj", "DUI3-DX\\Connectors\\Rhino\\Speckle.Connectors.Rhino7\\Speckle.Connectors.Rhino7.csproj", @@ -18,6 +19,8 @@ "DUI3-DX\\Converters\\ArcGIS\\Speckle.Converters.ArcGIS3\\Speckle.Converters.ArcGIS3.csproj", "DUI3-DX\\Converters\\Autocad\\Speckle.Converters.Autocad2023.DependencyInjection\\Speckle.Converters.Autocad2023.DependencyInjection.csproj", "DUI3-DX\\Converters\\Autocad\\Speckle.Converters.Autocad2023\\Speckle.Converters.Autocad2023.csproj", + "DUI3-DX\\Converters\\Autocad\\Speckle.Converters.Autocad2024.DependencyInjection\\Speckle.Converters.Autocad2024.DependencyInjection.csproj", + "DUI3-DX\\Converters\\Autocad\\Speckle.Converters.Autocad2024\\Speckle.Converters.Autocad2024.csproj", "DUI3-DX\\Converters\\Autocad\\Speckle.Converters.AutocadShared\\Speckle.Converters.AutocadShared.shproj", "DUI3-DX\\Converters\\Revit\\Speckle.Converters.Revit2023.DependencyInjection\\Speckle.Converters.Revit2023.DependencyInjection.csproj", "DUI3-DX\\Converters\\Revit\\Speckle.Converters.Revit2023.Tests\\Speckle.Converters.Revit2023.Tests.csproj", diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.Autocad2023/Speckle.Connectors.Autocad2023.csproj b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.Autocad2023/Speckle.Connectors.Autocad2023.csproj index 4ef5a65342..238ec770f6 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.Autocad2023/Speckle.Connectors.Autocad2023.csproj +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.Autocad2023/Speckle.Connectors.Autocad2023.csproj @@ -1,4 +1,4 @@ - + Speckle.Connectors.Autocad net48 @@ -6,11 +6,12 @@ true Program $(ProgramW6432)\Autodesk\AutoCAD 2023\acad.exe + $(DefineConstants);AUTOCAD2023;AUTOCAD - + diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/DependencyInjection/AutocadConnectorModule.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/DependencyInjection/AutocadConnectorModule.cs index f4a970b1d0..731098b249 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/DependencyInjection/AutocadConnectorModule.cs +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/DependencyInjection/AutocadConnectorModule.cs @@ -1,18 +1,11 @@ -using Speckle.Autofac; +#if AUTOCAD using Speckle.Autofac.DependencyInjection; using Speckle.Connectors.Autocad.Bindings; using Speckle.Connectors.Autocad.Filters; -using Speckle.Connectors.Autocad.HostApp; -using Speckle.Connectors.Autocad.Interfaces; using Speckle.Connectors.Autocad.Operations.Receive; using Speckle.Connectors.Autocad.Operations.Send; -using Speckle.Connectors.Autocad.Plugin; -using Speckle.Connectors.DUI; using Speckle.Connectors.DUI.Bindings; -using Speckle.Connectors.DUI.Models; using Speckle.Connectors.DUI.Models.Card.SendFilter; -using Speckle.Connectors.DUI.WebView; -using Speckle.Connectors.Utils; using Speckle.Connectors.Utils.Builders; using Speckle.Connectors.Utils.Caching; using Speckle.Connectors.Utils.Operations; @@ -24,19 +17,7 @@ public class AutocadConnectorModule : ISpeckleModule { public void Load(SpeckleContainerBuilder builder) { - builder.AddAutofac(); - builder.AddConnectorUtils(); - builder.AddDUI(); - builder.AddDUIView(); - - // Register other connector specific types - builder.AddSingleton(); - builder.AddTransient(); - builder.AddSingleton(new AutocadDocumentManager()); // TODO: Dependent to TransactionContext, can be moved to AutocadContext - builder.AddSingleton(); - builder.AddSingleton(); - builder.AddSingleton(); - builder.AddSingleton(); + SharedConnectorModule.LoadShared(builder); // Operations builder.AddScoped>(); @@ -47,13 +28,7 @@ public void Load(SpeckleContainerBuilder builder) builder.AddScoped, AutocadRootObjectBuilder>(); // Register bindings - - builder.AddSingleton(); builder.AddSingleton("connectorName", "Autocad"); // POC: Easier like this for now, should be cleaned up later - builder.AddSingleton(); - builder.AddSingleton(); - builder.AddSingleton(); - builder.AddSingleton(); builder.AddSingleton(); builder.AddSingleton(); @@ -64,3 +39,4 @@ public void Load(SpeckleContainerBuilder builder) builder.AddSingleton(); } } +#endif diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/DependencyInjection/Civil3dConnectorModule.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/DependencyInjection/Civil3dConnectorModule.cs new file mode 100644 index 0000000000..e6889843c5 --- /dev/null +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/DependencyInjection/Civil3dConnectorModule.cs @@ -0,0 +1,37 @@ +#if CIVIL3D +using Speckle.Autofac.DependencyInjection; +using Speckle.Connectors.Autocad.Bindings; +using Speckle.Connectors.Autocad.Filters; +using Speckle.Connectors.Autocad.Operations.Send; +using Speckle.Connectors.DUI.Bindings; +using Speckle.Connectors.DUI.Models.Card.SendFilter; +using Speckle.Connectors.Utils.Builders; +using Speckle.Connectors.Utils.Caching; +using Speckle.Connectors.Utils.Operations; + +namespace Speckle.Connectors.Autocad.DependencyInjection; + +public class Civil3dConnectorModule : ISpeckleModule +{ + public void Load(SpeckleContainerBuilder builder) + { + SharedConnectorModule.LoadShared(builder); + + // Operations + builder.AddScoped>(); + + // Object Builders + builder.AddScoped, AutocadRootObjectBuilder>(); + + // Register bindings + builder.AddSingleton("connectorName", "Civil3d"); // POC: Easier like this for now, should be cleaned up later + builder.AddSingleton(); + + // register send filters + builder.AddTransient(); + + // register send conversion cache + builder.AddSingleton(); + } +} +#endif diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/DependencyInjection/SharedConnectorModule.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/DependencyInjection/SharedConnectorModule.cs new file mode 100644 index 0000000000..48b71d723e --- /dev/null +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/DependencyInjection/SharedConnectorModule.cs @@ -0,0 +1,40 @@ +using Speckle.Autofac; +using Speckle.Autofac.DependencyInjection; +using Speckle.Connectors.Autocad.Bindings; +using Speckle.Connectors.Autocad.HostApp; +using Speckle.Connectors.Autocad.Interfaces; +using Speckle.Connectors.Autocad.Plugin; +using Speckle.Connectors.DUI; +using Speckle.Connectors.DUI.Bindings; +using Speckle.Connectors.DUI.Models; +using Speckle.Connectors.DUI.WebView; +using Speckle.Connectors.Utils; + +namespace Speckle.Connectors.Autocad.DependencyInjection; + +public static class SharedConnectorModule +{ + public static void LoadShared(SpeckleContainerBuilder builder) + { + builder.AddAutofac(); + builder.AddConnectorUtils(); + builder.AddDUI(); + builder.AddDUIView(); + + // Register other connector specific types + builder.AddSingleton(); + builder.AddTransient(); + builder.AddSingleton(new AutocadDocumentManager()); // TODO: Dependent to TransactionContext, can be moved to AutocadContext + builder.AddSingleton(); + builder.AddSingleton(); + builder.AddSingleton(); + builder.AddSingleton(); + + // Register bindings + builder.AddSingleton(); + builder.AddSingleton(); + builder.AddSingleton(); + builder.AddSingleton(); + builder.AddSingleton(); + } +} diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/AutocadLayerManager.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/AutocadLayerManager.cs index 7fb81ccd82..87b1f00ca7 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/AutocadLayerManager.cs +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/AutocadLayerManager.cs @@ -10,7 +10,7 @@ public class AutocadLayerManager private readonly string _layerFilterName = "Speckle"; // POC: Will be addressed to move it into AutocadContext! - private Document Doc => Autodesk.AutoCAD.ApplicationServices.Core.Application.DocumentManager.MdiActiveDocument; + private Document Doc => Application.DocumentManager.MdiActiveDocument; public AutocadLayerManager(AutocadContext autocadContext) { diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Plugin/AutocadCommand.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Plugin/AutocadCommand.cs index 6727399792..2a08e16bc9 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Plugin/AutocadCommand.cs +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Plugin/AutocadCommand.cs @@ -35,8 +35,13 @@ public void Command() var builder = SpeckleContainerBuilder.CreateInstance(); - var autocadSettings = new AutocadSettings(HostApplications.AutoCAD, HostAppVersion.v2023); - +#if CIVIL3D2024 + AutocadSettings autocadSettings = new (HostApplications.Civil3D, HostAppVersion.v2024); +#elif AUTOCAD2023 + AutocadSettings autocadSettings = new(HostApplications.AutoCAD, HostAppVersion.v2023); +#else + AutocadSettings autocadSettings = new(HostApplications.AutoCAD, HostAppVersion.v2023); +#endif Container = builder .LoadAutofacModules(Assembly.GetExecutingAssembly(), autocadSettings.Modules) .AddSingleton(autocadSettings) diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Speckle.Connectors.AutocadShared.projitems b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Speckle.Connectors.AutocadShared.projitems index d45686060d..dd0f8afa29 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Speckle.Connectors.AutocadShared.projitems +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Speckle.Connectors.AutocadShared.projitems @@ -13,7 +13,9 @@ + + diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.Civil3d2024/Speckle.Connectors.Civil3d2024.csproj b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.Civil3d2024/Speckle.Connectors.Civil3d2024.csproj new file mode 100644 index 0000000000..721a34ab7e --- /dev/null +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.Civil3d2024/Speckle.Connectors.Civil3d2024.csproj @@ -0,0 +1,26 @@ + + + Speckle.Connectors.Civil3d + net48 + x64 + true + Program + $(ProgramW6432)\Autodesk\AutoCAD 2024\acad.exe + $(DefineConstants);CIVIL3D2024;CIVIL3D; + + + + + + + + + + + + + + + + + diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.Civil3d2024/packages.lock.json b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.Civil3d2024/packages.lock.json new file mode 100644 index 0000000000..442462d552 --- /dev/null +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.Civil3d2024/packages.lock.json @@ -0,0 +1,533 @@ +{ + "version": 1, + "dependencies": { + ".NETFramework,Version=v4.8": { + "Microsoft.Extensions.Logging.Abstractions": { + "type": "Direct", + "requested": "[7.0.0, )", + "resolved": "7.0.0", + "contentHash": "kmn78+LPVMOWeITUjIlfxUPDsI0R6G0RkeAMBmQxAJ7vBJn4q2dTva7pWi65ceN5vPGjJ9q/Uae2WKgvfktJAw==", + "dependencies": { + "System.Buffers": "4.5.1", + "System.Memory": "4.5.5" + } + }, + "PolySharp": { + "type": "Direct", + "requested": "[1.14.1, )", + "resolved": "1.14.1", + "contentHash": "mOOmFYwad3MIOL14VCjj02LljyF1GNw1wP0YVlxtcPvqdxjGGMNdNJJxHptlry3MOd8b40Flm8RPOM8JOlN2sQ==" + }, + "Speckle.AutoCAD.API": { + "type": "Direct", + "requested": "[2024.0.0, )", + "resolved": "2024.0.0", + "contentHash": "pZZ5uI+NXhZaQnsqRkgp/rywqBAjDObDJ9XNFGJvemT5k2OthDpHzlK/mKxz8QDCYie7uImQ8dv3uWj2QUFDPw==" + }, + "Speckle.Civil3D.API": { + "type": "Direct", + "requested": "[2024.0.0, )", + "resolved": "2024.0.0", + "contentHash": "9Q7M1k0DotN8w7MkiScQezErRdnZ4dAkxBMcPNhHSWoth/lSaT6UPV1aYEdl90RhehJWG4l3O7U2e3OXvVSFdw==", + "dependencies": { + "Speckle.AutoCAD.API": "2024.0.0" + } + }, + "Speckle.InterfaceGenerator": { + "type": "Direct", + "requested": "[0.9.5, )", + "resolved": "0.9.5", + "contentHash": "oU/L7pN1R7q8KkbrpQ3WJnHirPHqn+9DEA7asOcUiggV5dzVg1A/VYs7GOSusD24njxXh03tE3a2oTLOjt3cVg==" + }, + "Autofac": { + "type": "Transitive", + "resolved": "5.2.0", + "contentHash": "V8dBH0dsv75uDzl7Sw+HkhKDPUw2eXnlMjcSVMH+tLo2s67MpTKGyDj1pDcpR+IF2u4YRs0s3/x7R88YJzIWvg==", + "dependencies": { + "Microsoft.Bcl.AsyncInterfaces": "1.1.0" + } + }, + "GraphQL.Client": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "8yPNBbuVBpTptivyAlak4GZvbwbUcjeQTL4vN1HKHRuOykZ4r7l5fcLS6vpyPyLn0x8FsL31xbOIKyxbmR9rbA==", + "dependencies": { + "GraphQL.Client.Abstractions": "6.0.0", + "GraphQL.Client.Abstractions.Websocket": "6.0.0", + "System.Net.WebSockets.Client.Managed": "1.0.22", + "System.Reactive": "5.0.0" + } + }, + "GraphQL.Client.Abstractions": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "h7uzWFORHZ+CCjwr/ThAyXMr0DPpzEANDa4Uo54wqCQ+j7qUKwqYTgOrb1W40sqbvNaZm9v/X7It31SUw0maHA==", + "dependencies": { + "GraphQL.Primitives": "6.0.0" + } + }, + "GraphQL.Client.Abstractions.Websocket": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "Nr9bPf8gIOvLuXpqEpqr9z9jslYFJOvd0feHth3/kPqeR3uMbjF5pjiwh4jxyMcxHdr8Pb6QiXkV3hsSyt0v7A==", + "dependencies": { + "GraphQL.Client.Abstractions": "6.0.0" + } + }, + "GraphQL.Primitives": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "yg72rrYDapfsIUrul7aF6wwNnTJBOFvuA9VdDTQpPa8AlAriHbufeXYLBcodKjfUdkCnaiggX1U/nEP08Zb5GA==" + }, + "Microsoft.Bcl.AsyncInterfaces": { + "type": "Transitive", + "resolved": "7.0.0", + "contentHash": "3aeMZ1N0lJoSyzqiP03hqemtb1BijhsJADdobn/4nsMJ8V1H+CrpuduUe4hlRdx+ikBQju1VGjMD1GJ3Sk05Eg==", + "dependencies": { + "System.Threading.Tasks.Extensions": "4.5.4" + } + }, + "Microsoft.CSharp": { + "type": "Transitive", + "resolved": "4.7.0", + "contentHash": "pTj+D3uJWyN3My70i2Hqo+OXixq3Os2D1nJ2x92FFo6sk8fYS1m1WLNTs0Dc1uPaViH0YvEEwvzddQ7y4rhXmA==" + }, + "Microsoft.Data.Sqlite": { + "type": "Transitive", + "resolved": "7.0.5", + "contentHash": "KGxbPeWsQMnmQy43DSBxAFtHz3l2JX8EWBSGUCvT3CuZ8KsuzbkqMIJMDOxWtG8eZSoCDI04aiVQjWuuV8HmSw==", + "dependencies": { + "Microsoft.Data.Sqlite.Core": "7.0.5", + "SQLitePCLRaw.bundle_e_sqlite3": "2.1.4" + } + }, + "Microsoft.Data.Sqlite.Core": { + "type": "Transitive", + "resolved": "7.0.5", + "contentHash": "FTerRmQPqHrCrnoUzhBu+E+1DNGwyrAMLqHkAqOOOu5pGfyMOj8qQUBxI/gDtWtG11p49UxSfWmBzRNlwZqfUg==", + "dependencies": { + "SQLitePCLRaw.core": "2.1.4" + } + }, + "Microsoft.Extensions.DependencyInjection": { + "type": "Transitive", + "resolved": "7.0.0", + "contentHash": "elNeOmkeX3eDVG6pYVeV82p29hr+UKDaBhrZyWvWLw/EVZSYEkZlQdkp0V39k/Xehs2Qa0mvoCvkVj3eQxNQ1Q==", + "dependencies": { + "Microsoft.Bcl.AsyncInterfaces": "7.0.0", + "Microsoft.Extensions.DependencyInjection.Abstractions": "7.0.0", + "System.Threading.Tasks.Extensions": "4.5.4" + } + }, + "Microsoft.Extensions.DependencyInjection.Abstractions": { + "type": "Transitive", + "resolved": "7.0.0", + "contentHash": "h3j/QfmFN4S0w4C2A6X7arXij/M/OVw3uQHSOFxnND4DyAzO1F9eMX7Eti7lU/OkSthEE0WzRsfT/Dmx86jzCw==", + "dependencies": { + "Microsoft.Bcl.AsyncInterfaces": "7.0.0", + "System.Threading.Tasks.Extensions": "4.5.4" + } + }, + "Microsoft.Extensions.Logging": { + "type": "Transitive", + "resolved": "7.0.0", + "contentHash": "Nw2muoNrOG5U5qa2ZekXwudUn2BJcD41e65zwmDHb1fQegTX66UokLWZkJRpqSSHXDOWZ5V0iqhbxOEky91atA==", + "dependencies": { + "Microsoft.Bcl.AsyncInterfaces": "7.0.0", + "Microsoft.Extensions.DependencyInjection": "7.0.0", + "Microsoft.Extensions.DependencyInjection.Abstractions": "7.0.0", + "Microsoft.Extensions.Logging.Abstractions": "7.0.0", + "Microsoft.Extensions.Options": "7.0.0", + "System.Diagnostics.DiagnosticSource": "7.0.0", + "System.ValueTuple": "4.5.0" + } + }, + "Microsoft.Extensions.Options": { + "type": "Transitive", + "resolved": "7.0.0", + "contentHash": "lP1yBnTTU42cKpMozuafbvNtQ7QcBjr/CcK3bYOGEMH55Fjt+iecXjT6chR7vbgCMqy3PG3aNQSZgo/EuY/9qQ==", + "dependencies": { + "Microsoft.Extensions.DependencyInjection.Abstractions": "7.0.0", + "Microsoft.Extensions.Primitives": "7.0.0" + } + }, + "Microsoft.Extensions.Primitives": { + "type": "Transitive", + "resolved": "7.0.0", + "contentHash": "um1KU5kxcRp3CNuI8o/GrZtD4AIOXDk+RLsytjZ9QPok3ttLUelLKpilVPuaFT3TFjOhSibUAso0odbOaCDj3Q==", + "dependencies": { + "System.Memory": "4.5.5", + "System.Runtime.CompilerServices.Unsafe": "6.0.0" + } + }, + "Microsoft.Web.WebView2": { + "type": "Transitive", + "resolved": "1.0.1823.32", + "contentHash": "ppRcWBUNggFIqyJp7PfgS4Oe8/7yli/mHcTNDOaqo3ZzJWnv9AOr0WE9ceEP5SPs1M7CQ3QvdGMR7KNz0v09EA==" + }, + "Polly": { + "type": "Transitive", + "resolved": "7.2.3", + "contentHash": "DeCY0OFbNdNxsjntr1gTXHJ5pKUwYzp04Er2LLeN3g6pWhffsGuKVfMBLe1lw7x76HrPkLxKEFxBlpRxS2nDEQ==" + }, + "Polly.Contrib.WaitAndRetry": { + "type": "Transitive", + "resolved": "1.1.1", + "contentHash": "1MUQLiSo4KDkQe6nzQRhIU05lm9jlexX5BVsbuw0SL82ynZ+GzAHQxJVDPVBboxV37Po3SG077aX8DuSy8TkaA==" + }, + "Polly.Extensions.Http": { + "type": "Transitive", + "resolved": "3.0.0", + "contentHash": "drrG+hB3pYFY7w1c3BD+lSGYvH2oIclH8GRSehgfyP5kjnFnHKQuuBhuHLv+PWyFuaTDyk/vfRpnxOzd11+J8g==", + "dependencies": { + "Polly": "7.1.0" + } + }, + "Sentry": { + "type": "Transitive", + "resolved": "3.33.0", + "contentHash": "8vbD2o6IR2wrRrkSiRbnodWGWUOqIlwYtzpjvPNOb5raJdOf+zxMwfS8f6nx9bmrTTfDj7KrCB8C/5OuicAc8A==", + "dependencies": { + "System.Reflection.Metadata": "5.0.0", + "System.Runtime.InteropServices.RuntimeInformation": "4.3.0", + "System.Text.Json": "5.0.2" + } + }, + "Sentry.Serilog": { + "type": "Transitive", + "resolved": "3.33.0", + "contentHash": "V8BU7QGWg2qLYfNPqtuTBhC1opysny5l+Ifp6J6PhOeAxU0FssR7nYfbJVetrnLIoh2rd3DlJ6hHYYQosQYcUQ==", + "dependencies": { + "Sentry": "3.33.0", + "Serilog": "2.7.1" + } + }, + "Serilog": { + "type": "Transitive", + "resolved": "2.12.0", + "contentHash": "xaiJLIdu6rYMKfQMYUZgTy8YK7SMZjB4Yk50C/u//Z4OsvxkUfSPJy4nknfvwAC34yr13q7kcyh4grbwhSxyZg==" + }, + "Serilog.Enrichers.ClientInfo": { + "type": "Transitive", + "resolved": "1.3.0", + "contentHash": "mTc7PM+wC9Hr7LWSwqt5mmnlAr7RJs+eTb3PGPRhwdOackk95MkhUZognuxXEdlW19HAFNmEBTSBY5DfLwM8jQ==", + "dependencies": { + "Serilog": "2.4.0" + } + }, + "Serilog.Exceptions": { + "type": "Transitive", + "resolved": "8.4.0", + "contentHash": "nc/+hUw3lsdo0zCj0KMIybAu7perMx79vu72w0za9Nsi6mWyNkGXxYxakAjWB7nEmYL6zdmhEQRB4oJ2ALUeug==", + "dependencies": { + "Serilog": "2.8.0" + } + }, + "Serilog.Extensions.Logging": { + "type": "Transitive", + "resolved": "7.0.0", + "contentHash": "9faU0zNQqU7I6soVhLUMYaGNpgWv6cKlKb2S5AnS8gXxzW/em5Ladm/6FMrWTnX41cdbdGPOWNAo6adi4WaJ6A==", + "dependencies": { + "Microsoft.Extensions.Logging": "7.0.0", + "Serilog": "2.12.0" + } + }, + "Serilog.Formatting.Compact": { + "type": "Transitive", + "resolved": "1.1.0", + "contentHash": "pNroKVjo+rDqlxNG5PXkRLpfSCuDOBY0ri6jp9PLe505ljqwhwZz8ospy2vWhQlFu5GkIesh3FcDs4n7sWZODA==", + "dependencies": { + "Serilog": "2.8.0" + } + }, + "Serilog.Sinks.Console": { + "type": "Transitive", + "resolved": "4.1.0", + "contentHash": "K6N5q+5fetjnJPvCmkWOpJ/V8IEIoMIB1s86OzBrbxwTyHxdx3pmz4H+8+O/Dc/ftUX12DM1aynx/dDowkwzqg==", + "dependencies": { + "Serilog": "2.10.0" + } + }, + "Serilog.Sinks.File": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "uwV5hdhWPwUH1szhO8PJpFiahqXmzPzJT/sOijH/kFgUx+cyoDTMM8MHD0adw9+Iem6itoibbUXHYslzXsLEAg==", + "dependencies": { + "Serilog": "2.10.0" + } + }, + "Serilog.Sinks.PeriodicBatching": { + "type": "Transitive", + "resolved": "3.1.0", + "contentHash": "NDWR7m3PalVlGEq3rzoktrXikjFMLmpwF0HI4sowo8YDdU+gqPlTHlDQiOGxHfB0sTfjPA9JjA7ctKG9zqjGkw==", + "dependencies": { + "Serilog": "2.0.0" + } + }, + "Serilog.Sinks.Seq": { + "type": "Transitive", + "resolved": "5.2.2", + "contentHash": "1Csmo5ua7NKUe0yXUx+zsRefjAniPWcXFhUXxXG8pwo0iMiw2gjn9SOkgYnnxbgWqmlGv236w0N/dHc2v5XwMg==", + "dependencies": { + "Serilog": "2.12.0", + "Serilog.Formatting.Compact": "1.1.0", + "Serilog.Sinks.File": "5.0.0", + "Serilog.Sinks.PeriodicBatching": "3.1.0" + } + }, + "SerilogTimings": { + "type": "Transitive", + "resolved": "3.0.1", + "contentHash": "Zs28eTgszAMwpIrbBnWHBI50yuxL50p/dmAUWmy75+axdZYK/Sjm5/5m1N/CisR8acJUhTVcjPZrsB1P5iv0Uw==", + "dependencies": { + "Serilog": "2.10.0" + } + }, + "Speckle.Newtonsoft.Json": { + "type": "Transitive", + "resolved": "13.0.2", + "contentHash": "g1BejUZwax5PRfL6xHgLEK23sqHWOgOj9hE7RvfRRlN00AGt8GnPYt8HedSK7UB3HiRW8zCA9Pn0iiYxCK24BA==" + }, + "SQLitePCLRaw.bundle_e_sqlite3": { + "type": "Transitive", + "resolved": "2.1.4", + "contentHash": "EWI1olKDjFEBMJu0+3wuxwziIAdWDVMYLhuZ3Qs84rrz+DHwD00RzWPZCa+bLnHCf3oJwuFZIRsHT5p236QXww==", + "dependencies": { + "SQLitePCLRaw.lib.e_sqlite3": "2.1.4", + "SQLitePCLRaw.provider.dynamic_cdecl": "2.1.4" + } + }, + "SQLitePCLRaw.core": { + "type": "Transitive", + "resolved": "2.1.4", + "contentHash": "inBjvSHo9UDKneGNzfUfDjK08JzlcIhn1+SP5Y3m6cgXpCxXKCJDy6Mka7LpgSV+UZmKSnC8rTwB0SQ0xKu5pA==", + "dependencies": { + "System.Memory": "4.5.3" + } + }, + "SQLitePCLRaw.lib.e_sqlite3": { + "type": "Transitive", + "resolved": "2.1.4", + "contentHash": "2C9Q9eX7CPLveJA0rIhf9RXAvu+7nWZu1A2MdG6SD/NOu26TakGgL1nsbc0JAspGijFOo3HoN79xrx8a368fBg==" + }, + "SQLitePCLRaw.provider.dynamic_cdecl": { + "type": "Transitive", + "resolved": "2.1.4", + "contentHash": "ZsaKKhgYF9B1fvcnOGKl3EycNAwd9CRWX7v0rEfuPWhQQ5Jjpvf2VEHahiLIGHio3hxi3EIKFJw9KvyowWOUAw==", + "dependencies": { + "SQLitePCLRaw.core": "2.1.4" + } + }, + "System.Buffers": { + "type": "Transitive", + "resolved": "4.5.1", + "contentHash": "Rw7ijyl1qqRS0YQD/WycNst8hUUMgrMH4FCn1nNm27M4VxchZ1js3fVjQaANHO5f3sN4isvP4a+Met9Y4YomAg==" + }, + "System.Collections.Immutable": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "FXkLXiK0sVVewcso0imKQoOxjoPAj42R8HtjjbSjVPAzwDfzoyoznWxgA3c38LDbN9SJux1xXoXYAhz98j7r2g==", + "dependencies": { + "System.Memory": "4.5.4" + } + }, + "System.Diagnostics.DiagnosticSource": { + "type": "Transitive", + "resolved": "7.0.0", + "contentHash": "9W0ewWDuAyDqS2PigdTxk6jDKonfgscY/hP8hm7VpxYhNHZHKvZTdRckberlFk3VnCmr3xBUyMBut12Q+T2aOw==", + "dependencies": { + "System.Memory": "4.5.5", + "System.Runtime.CompilerServices.Unsafe": "6.0.0" + } + }, + "System.DoubleNumerics": { + "type": "Transitive", + "resolved": "3.1.3", + "contentHash": "KRKEM/L3KBodjA9VOg3EifFVWUY6EOqaMB05UvPEDm7Zeby/kZW+4kdWUEPzW6xtkwf46p661L9NrbeeQhtLzw==", + "dependencies": { + "NETStandard.Library": "1.6.1" + } + }, + "System.Memory": { + "type": "Transitive", + "resolved": "4.5.5", + "contentHash": "XIWiDvKPXaTveaB7HVganDlOCRoj03l+jrwNvcge/t8vhGYKvqV+dMv6G4SAX2NoNmN0wZfVPTAlFwZcZvVOUw==", + "dependencies": { + "System.Buffers": "4.5.1", + "System.Numerics.Vectors": "4.5.0", + "System.Runtime.CompilerServices.Unsafe": "4.5.3" + } + }, + "System.Net.WebSockets.Client.Managed": { + "type": "Transitive", + "resolved": "1.0.22", + "contentHash": "WqEOxPlXjuZrIjUtXNE9NxEfU/n5E35iV2PtoZdJSUC4tlrqwHnTee+wvMIM4OUaJWmwrymeqcgYrE0IkGAgLA==", + "dependencies": { + "System.Buffers": "4.4.0", + "System.Numerics.Vectors": "4.4.0" + } + }, + "System.Numerics.Vectors": { + "type": "Transitive", + "resolved": "4.5.0", + "contentHash": "QQTlPTl06J/iiDbJCiepZ4H//BVraReU4O4EoRw1U02H5TLUIT7xn3GnDp9AXPSlJUDyFs4uWjWafNX6WrAojQ==" + }, + "System.Reactive": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "erBZjkQHWL9jpasCE/0qKAryzVBJFxGHVBAvgRN1bzM0q2s1S4oYREEEL0Vb+1kA/6BKb5FjUZMp5VXmy+gzkQ==", + "dependencies": { + "System.Threading.Tasks.Extensions": "4.5.4" + } + }, + "System.Reflection.Metadata": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "5NecZgXktdGg34rh1OenY1rFNDCI8xSjFr+Z4OU4cU06AQHUdRnIIEeWENu3Wl4YowbzkymAIMvi3WyK9U53pQ==", + "dependencies": { + "System.Collections.Immutable": "5.0.0" + } + }, + "System.Runtime.CompilerServices.Unsafe": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "/iUeP3tq1S0XdNNoMz5C9twLSrM/TH+qElHkXWaPvuNOt+99G75NrV0OS2EqHx5wMN7popYjpc8oTjC1y16DLg==" + }, + "System.Runtime.InteropServices.RuntimeInformation": { + "type": "Transitive", + "resolved": "4.3.0", + "contentHash": "cbz4YJMqRDR7oLeMRbdYv7mYzc++17lNhScCX0goO2XpGWdvAt60CGN+FHdePUEHCe/Jy9jUlvNAiNdM+7jsOw==" + }, + "System.Text.Encodings.Web": { + "type": "Transitive", + "resolved": "5.0.1", + "contentHash": "KmJ+CJXizDofbq6mpqDoRRLcxgOd2z9X3XoFNULSbvbqVRZkFX3istvr+MUjL6Zw1RT+RNdoI4GYidIINtgvqQ==", + "dependencies": { + "System.Buffers": "4.5.1", + "System.Memory": "4.5.4" + } + }, + "System.Text.Json": { + "type": "Transitive", + "resolved": "5.0.2", + "contentHash": "I47dVIGiV6SfAyppphxqupertT/5oZkYLDCX6vC3HpOI4ZLjyoKAreUoem2ie6G0RbRuFrlqz/PcTQjfb2DOfQ==", + "dependencies": { + "Microsoft.Bcl.AsyncInterfaces": "5.0.0", + "System.Buffers": "4.5.1", + "System.Memory": "4.5.4", + "System.Numerics.Vectors": "4.5.0", + "System.Runtime.CompilerServices.Unsafe": "5.0.0", + "System.Text.Encodings.Web": "5.0.1", + "System.Threading.Tasks.Extensions": "4.5.4", + "System.ValueTuple": "4.5.0" + } + }, + "System.Threading.Tasks.Dataflow": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "+tyDCU3/B1lDdOOAJywHQoFwyXIUghIaP2BxG79uvhfTnO+D9qIgjVlL/JV2NTliYbMHpd6eKDmHp2VHpij7MA==" + }, + "System.Threading.Tasks.Extensions": { + "type": "Transitive", + "resolved": "4.5.4", + "contentHash": "zteT+G8xuGu6mS+mzDzYXbzS7rd3K6Fjb9RiZlYlJPam2/hU7JCBZBVEcywNuR+oZ1ncTvc/cq0faRr3P01OVg==", + "dependencies": { + "System.Runtime.CompilerServices.Unsafe": "4.5.3" + } + }, + "System.ValueTuple": { + "type": "Transitive", + "resolved": "4.5.0", + "contentHash": "okurQJO6NRE/apDIP23ajJ0hpiNmJ+f0BwOlB/cSqTLQlw5upkf+5+96+iG2Jw40G1fCVCyPz/FhIABUjMR+RQ==" + }, + "speckle.autofac": { + "type": "Project", + "dependencies": { + "Microsoft.Extensions.Logging.Abstractions": "[7.0.0, )", + "Speckle.Core": "[2.0.999-local, )" + } + }, + "speckle.connectors.dui": { + "type": "Project", + "dependencies": { + "Microsoft.Extensions.Logging.Abstractions": "[7.0.0, )", + "Speckle.Autofac": "[2.0.999-local, )", + "Speckle.Connectors.Utils": "[2.0.999-local, )", + "Speckle.Core": "[2.0.999-local, )", + "System.Threading.Tasks.Dataflow": "[6.0.0, )" + } + }, + "speckle.connectors.dui.webview": { + "type": "Project", + "dependencies": { + "Microsoft.Web.WebView2": "[1.0.1823.32, )", + "Speckle.Connectors.DUI": "[2.0.999-local, )" + } + }, + "speckle.connectors.utils": { + "type": "Project", + "dependencies": { + "Serilog.Extensions.Logging": "[7.0.0, )", + "Speckle.Autofac": "[2.0.999-local, )", + "Speckle.Core": "[2.0.999-local, )" + } + }, + "speckle.converters.autocad2024": { + "type": "Project", + "dependencies": { + "Speckle.AutoCAD.API": "[2024.0.0, )", + "Speckle.Converters.Common": "[2.0.999-local, )" + } + }, + "speckle.converters.autocad2024.dependencyinjection": { + "type": "Project", + "dependencies": { + "Autofac": "[5.2.0, )", + "Speckle.Converters.Autocad2024": "[2.0.999-local, )", + "Speckle.Converters.Common.DependencyInjection": "[2.0.999-local, )" + } + }, + "speckle.converters.common": { + "type": "Project", + "dependencies": { + "Speckle.Autofac": "[2.0.999-local, )", + "Speckle.Objects": "[2.0.999-local, )" + } + }, + "speckle.converters.common.dependencyinjection": { + "type": "Project", + "dependencies": { + "Speckle.Autofac": "[2.0.999-local, )", + "Speckle.Converters.Common": "[2.0.999-local, )" + } + }, + "Speckle.Core": { + "type": "Project", + "dependencies": { + "GraphQL.Client": "[6.0.0, )", + "Microsoft.CSharp": "[4.7.0, )", + "Microsoft.Data.Sqlite": "[7.0.5, )", + "Polly": "[7.2.3, )", + "Polly.Contrib.WaitAndRetry": "[1.1.1, )", + "Polly.Extensions.Http": "[3.0.0, )", + "Sentry": "[3.33.0, )", + "Sentry.Serilog": "[3.33.0, )", + "Serilog": "[2.12.0, )", + "Serilog.Enrichers.ClientInfo": "[1.3.0, )", + "Serilog.Exceptions": "[8.4.0, )", + "Serilog.Sinks.Console": "[4.1.0, )", + "Serilog.Sinks.Seq": "[5.2.2, )", + "SerilogTimings": "[3.0.1, )", + "Speckle.Newtonsoft.Json": "[13.0.2, )", + "System.DoubleNumerics": "[3.1.3, )" + } + }, + "Speckle.Objects": { + "type": "Project", + "dependencies": { + "Speckle.Core": "[2.0.999-local, )" + } + } + } + } +} \ No newline at end of file diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2024.DependencyInjection/AutocadConverterModule.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2024.DependencyInjection/AutocadConverterModule.cs new file mode 100644 index 0000000000..923bc241d1 --- /dev/null +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2024.DependencyInjection/AutocadConverterModule.cs @@ -0,0 +1,19 @@ +using Autodesk.AutoCAD.ApplicationServices; +using Autodesk.AutoCAD.DatabaseServices; +using Speckle.Autofac.DependencyInjection; +using Speckle.Converters.Autocad; +using Speckle.Converters.Common; +using Speckle.Converters.Common.DependencyInjection; + +namespace Speckle.Converters.Autocad20243.DependencyInjection; + +public class AutocadConverterModule : ISpeckleModule +{ + public void Load(SpeckleContainerBuilder builder) + { + builder.AddConverterCommon(); + + // single stack per conversion + builder.AddScoped, AutocadConversionContextStack>(); + } +} diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2024.DependencyInjection/Speckle.Converters.Autocad2024.DependencyInjection.csproj b/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2024.DependencyInjection/Speckle.Converters.Autocad2024.DependencyInjection.csproj new file mode 100644 index 0000000000..9442c9cfe9 --- /dev/null +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2024.DependencyInjection/Speckle.Converters.Autocad2024.DependencyInjection.csproj @@ -0,0 +1,17 @@ + + + + net48 + x64 + + + + + + + + + + + + diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2024.DependencyInjection/packages.lock.json b/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2024.DependencyInjection/packages.lock.json new file mode 100644 index 0000000000..90415ed373 --- /dev/null +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2024.DependencyInjection/packages.lock.json @@ -0,0 +1,411 @@ +{ + "version": 1, + "dependencies": { + ".NETFramework,Version=v4.8": { + "Autofac": { + "type": "Direct", + "requested": "[5.2.0, )", + "resolved": "5.2.0", + "contentHash": "V8dBH0dsv75uDzl7Sw+HkhKDPUw2eXnlMjcSVMH+tLo2s67MpTKGyDj1pDcpR+IF2u4YRs0s3/x7R88YJzIWvg==", + "dependencies": { + "Microsoft.Bcl.AsyncInterfaces": "1.1.0" + } + }, + "PolySharp": { + "type": "Direct", + "requested": "[1.14.1, )", + "resolved": "1.14.1", + "contentHash": "mOOmFYwad3MIOL14VCjj02LljyF1GNw1wP0YVlxtcPvqdxjGGMNdNJJxHptlry3MOd8b40Flm8RPOM8JOlN2sQ==" + }, + "Speckle.InterfaceGenerator": { + "type": "Direct", + "requested": "[0.9.5, )", + "resolved": "0.9.5", + "contentHash": "oU/L7pN1R7q8KkbrpQ3WJnHirPHqn+9DEA7asOcUiggV5dzVg1A/VYs7GOSusD24njxXh03tE3a2oTLOjt3cVg==" + }, + "GraphQL.Client": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "8yPNBbuVBpTptivyAlak4GZvbwbUcjeQTL4vN1HKHRuOykZ4r7l5fcLS6vpyPyLn0x8FsL31xbOIKyxbmR9rbA==", + "dependencies": { + "GraphQL.Client.Abstractions": "6.0.0", + "GraphQL.Client.Abstractions.Websocket": "6.0.0", + "System.Net.WebSockets.Client.Managed": "1.0.22", + "System.Reactive": "5.0.0" + } + }, + "GraphQL.Client.Abstractions": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "h7uzWFORHZ+CCjwr/ThAyXMr0DPpzEANDa4Uo54wqCQ+j7qUKwqYTgOrb1W40sqbvNaZm9v/X7It31SUw0maHA==", + "dependencies": { + "GraphQL.Primitives": "6.0.0" + } + }, + "GraphQL.Client.Abstractions.Websocket": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "Nr9bPf8gIOvLuXpqEpqr9z9jslYFJOvd0feHth3/kPqeR3uMbjF5pjiwh4jxyMcxHdr8Pb6QiXkV3hsSyt0v7A==", + "dependencies": { + "GraphQL.Client.Abstractions": "6.0.0" + } + }, + "GraphQL.Primitives": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "yg72rrYDapfsIUrul7aF6wwNnTJBOFvuA9VdDTQpPa8AlAriHbufeXYLBcodKjfUdkCnaiggX1U/nEP08Zb5GA==" + }, + "Microsoft.Bcl.AsyncInterfaces": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "W8DPQjkMScOMTtJbPwmPyj9c3zYSFGawDW3jwlBOOsnY+EzZFLgNQ/UMkK35JmkNOVPdCyPr2Tw7Vv9N+KA3ZQ==", + "dependencies": { + "System.Threading.Tasks.Extensions": "4.5.4" + } + }, + "Microsoft.CSharp": { + "type": "Transitive", + "resolved": "4.7.0", + "contentHash": "pTj+D3uJWyN3My70i2Hqo+OXixq3Os2D1nJ2x92FFo6sk8fYS1m1WLNTs0Dc1uPaViH0YvEEwvzddQ7y4rhXmA==" + }, + "Microsoft.Data.Sqlite": { + "type": "Transitive", + "resolved": "7.0.5", + "contentHash": "KGxbPeWsQMnmQy43DSBxAFtHz3l2JX8EWBSGUCvT3CuZ8KsuzbkqMIJMDOxWtG8eZSoCDI04aiVQjWuuV8HmSw==", + "dependencies": { + "Microsoft.Data.Sqlite.Core": "7.0.5", + "SQLitePCLRaw.bundle_e_sqlite3": "2.1.4" + } + }, + "Microsoft.Data.Sqlite.Core": { + "type": "Transitive", + "resolved": "7.0.5", + "contentHash": "FTerRmQPqHrCrnoUzhBu+E+1DNGwyrAMLqHkAqOOOu5pGfyMOj8qQUBxI/gDtWtG11p49UxSfWmBzRNlwZqfUg==", + "dependencies": { + "SQLitePCLRaw.core": "2.1.4" + } + }, + "Microsoft.Extensions.Logging.Abstractions": { + "type": "Transitive", + "resolved": "7.0.0", + "contentHash": "kmn78+LPVMOWeITUjIlfxUPDsI0R6G0RkeAMBmQxAJ7vBJn4q2dTva7pWi65ceN5vPGjJ9q/Uae2WKgvfktJAw==", + "dependencies": { + "System.Buffers": "4.5.1", + "System.Memory": "4.5.5" + } + }, + "Polly": { + "type": "Transitive", + "resolved": "7.2.3", + "contentHash": "DeCY0OFbNdNxsjntr1gTXHJ5pKUwYzp04Er2LLeN3g6pWhffsGuKVfMBLe1lw7x76HrPkLxKEFxBlpRxS2nDEQ==" + }, + "Polly.Contrib.WaitAndRetry": { + "type": "Transitive", + "resolved": "1.1.1", + "contentHash": "1MUQLiSo4KDkQe6nzQRhIU05lm9jlexX5BVsbuw0SL82ynZ+GzAHQxJVDPVBboxV37Po3SG077aX8DuSy8TkaA==" + }, + "Polly.Extensions.Http": { + "type": "Transitive", + "resolved": "3.0.0", + "contentHash": "drrG+hB3pYFY7w1c3BD+lSGYvH2oIclH8GRSehgfyP5kjnFnHKQuuBhuHLv+PWyFuaTDyk/vfRpnxOzd11+J8g==", + "dependencies": { + "Polly": "7.1.0" + } + }, + "Sentry": { + "type": "Transitive", + "resolved": "3.33.0", + "contentHash": "8vbD2o6IR2wrRrkSiRbnodWGWUOqIlwYtzpjvPNOb5raJdOf+zxMwfS8f6nx9bmrTTfDj7KrCB8C/5OuicAc8A==", + "dependencies": { + "System.Reflection.Metadata": "5.0.0", + "System.Runtime.InteropServices.RuntimeInformation": "4.3.0", + "System.Text.Json": "5.0.2" + } + }, + "Sentry.Serilog": { + "type": "Transitive", + "resolved": "3.33.0", + "contentHash": "V8BU7QGWg2qLYfNPqtuTBhC1opysny5l+Ifp6J6PhOeAxU0FssR7nYfbJVetrnLIoh2rd3DlJ6hHYYQosQYcUQ==", + "dependencies": { + "Sentry": "3.33.0", + "Serilog": "2.7.1" + } + }, + "Serilog": { + "type": "Transitive", + "resolved": "2.12.0", + "contentHash": "xaiJLIdu6rYMKfQMYUZgTy8YK7SMZjB4Yk50C/u//Z4OsvxkUfSPJy4nknfvwAC34yr13q7kcyh4grbwhSxyZg==" + }, + "Serilog.Enrichers.ClientInfo": { + "type": "Transitive", + "resolved": "1.3.0", + "contentHash": "mTc7PM+wC9Hr7LWSwqt5mmnlAr7RJs+eTb3PGPRhwdOackk95MkhUZognuxXEdlW19HAFNmEBTSBY5DfLwM8jQ==", + "dependencies": { + "Serilog": "2.4.0" + } + }, + "Serilog.Exceptions": { + "type": "Transitive", + "resolved": "8.4.0", + "contentHash": "nc/+hUw3lsdo0zCj0KMIybAu7perMx79vu72w0za9Nsi6mWyNkGXxYxakAjWB7nEmYL6zdmhEQRB4oJ2ALUeug==", + "dependencies": { + "Serilog": "2.8.0" + } + }, + "Serilog.Formatting.Compact": { + "type": "Transitive", + "resolved": "1.1.0", + "contentHash": "pNroKVjo+rDqlxNG5PXkRLpfSCuDOBY0ri6jp9PLe505ljqwhwZz8ospy2vWhQlFu5GkIesh3FcDs4n7sWZODA==", + "dependencies": { + "Serilog": "2.8.0" + } + }, + "Serilog.Sinks.Console": { + "type": "Transitive", + "resolved": "4.1.0", + "contentHash": "K6N5q+5fetjnJPvCmkWOpJ/V8IEIoMIB1s86OzBrbxwTyHxdx3pmz4H+8+O/Dc/ftUX12DM1aynx/dDowkwzqg==", + "dependencies": { + "Serilog": "2.10.0" + } + }, + "Serilog.Sinks.File": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "uwV5hdhWPwUH1szhO8PJpFiahqXmzPzJT/sOijH/kFgUx+cyoDTMM8MHD0adw9+Iem6itoibbUXHYslzXsLEAg==", + "dependencies": { + "Serilog": "2.10.0" + } + }, + "Serilog.Sinks.PeriodicBatching": { + "type": "Transitive", + "resolved": "3.1.0", + "contentHash": "NDWR7m3PalVlGEq3rzoktrXikjFMLmpwF0HI4sowo8YDdU+gqPlTHlDQiOGxHfB0sTfjPA9JjA7ctKG9zqjGkw==", + "dependencies": { + "Serilog": "2.0.0" + } + }, + "Serilog.Sinks.Seq": { + "type": "Transitive", + "resolved": "5.2.2", + "contentHash": "1Csmo5ua7NKUe0yXUx+zsRefjAniPWcXFhUXxXG8pwo0iMiw2gjn9SOkgYnnxbgWqmlGv236w0N/dHc2v5XwMg==", + "dependencies": { + "Serilog": "2.12.0", + "Serilog.Formatting.Compact": "1.1.0", + "Serilog.Sinks.File": "5.0.0", + "Serilog.Sinks.PeriodicBatching": "3.1.0" + } + }, + "SerilogTimings": { + "type": "Transitive", + "resolved": "3.0.1", + "contentHash": "Zs28eTgszAMwpIrbBnWHBI50yuxL50p/dmAUWmy75+axdZYK/Sjm5/5m1N/CisR8acJUhTVcjPZrsB1P5iv0Uw==", + "dependencies": { + "Serilog": "2.10.0" + } + }, + "Speckle.AutoCAD.API": { + "type": "Transitive", + "resolved": "2024.0.0", + "contentHash": "pZZ5uI+NXhZaQnsqRkgp/rywqBAjDObDJ9XNFGJvemT5k2OthDpHzlK/mKxz8QDCYie7uImQ8dv3uWj2QUFDPw==" + }, + "Speckle.Newtonsoft.Json": { + "type": "Transitive", + "resolved": "13.0.2", + "contentHash": "g1BejUZwax5PRfL6xHgLEK23sqHWOgOj9hE7RvfRRlN00AGt8GnPYt8HedSK7UB3HiRW8zCA9Pn0iiYxCK24BA==" + }, + "SQLitePCLRaw.bundle_e_sqlite3": { + "type": "Transitive", + "resolved": "2.1.4", + "contentHash": "EWI1olKDjFEBMJu0+3wuxwziIAdWDVMYLhuZ3Qs84rrz+DHwD00RzWPZCa+bLnHCf3oJwuFZIRsHT5p236QXww==", + "dependencies": { + "SQLitePCLRaw.lib.e_sqlite3": "2.1.4", + "SQLitePCLRaw.provider.dynamic_cdecl": "2.1.4" + } + }, + "SQLitePCLRaw.core": { + "type": "Transitive", + "resolved": "2.1.4", + "contentHash": "inBjvSHo9UDKneGNzfUfDjK08JzlcIhn1+SP5Y3m6cgXpCxXKCJDy6Mka7LpgSV+UZmKSnC8rTwB0SQ0xKu5pA==", + "dependencies": { + "System.Memory": "4.5.3" + } + }, + "SQLitePCLRaw.lib.e_sqlite3": { + "type": "Transitive", + "resolved": "2.1.4", + "contentHash": "2C9Q9eX7CPLveJA0rIhf9RXAvu+7nWZu1A2MdG6SD/NOu26TakGgL1nsbc0JAspGijFOo3HoN79xrx8a368fBg==" + }, + "SQLitePCLRaw.provider.dynamic_cdecl": { + "type": "Transitive", + "resolved": "2.1.4", + "contentHash": "ZsaKKhgYF9B1fvcnOGKl3EycNAwd9CRWX7v0rEfuPWhQQ5Jjpvf2VEHahiLIGHio3hxi3EIKFJw9KvyowWOUAw==", + "dependencies": { + "SQLitePCLRaw.core": "2.1.4" + } + }, + "System.Buffers": { + "type": "Transitive", + "resolved": "4.5.1", + "contentHash": "Rw7ijyl1qqRS0YQD/WycNst8hUUMgrMH4FCn1nNm27M4VxchZ1js3fVjQaANHO5f3sN4isvP4a+Met9Y4YomAg==" + }, + "System.Collections.Immutable": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "FXkLXiK0sVVewcso0imKQoOxjoPAj42R8HtjjbSjVPAzwDfzoyoznWxgA3c38LDbN9SJux1xXoXYAhz98j7r2g==", + "dependencies": { + "System.Memory": "4.5.4" + } + }, + "System.DoubleNumerics": { + "type": "Transitive", + "resolved": "3.1.3", + "contentHash": "KRKEM/L3KBodjA9VOg3EifFVWUY6EOqaMB05UvPEDm7Zeby/kZW+4kdWUEPzW6xtkwf46p661L9NrbeeQhtLzw==", + "dependencies": { + "NETStandard.Library": "1.6.1" + } + }, + "System.Memory": { + "type": "Transitive", + "resolved": "4.5.5", + "contentHash": "XIWiDvKPXaTveaB7HVganDlOCRoj03l+jrwNvcge/t8vhGYKvqV+dMv6G4SAX2NoNmN0wZfVPTAlFwZcZvVOUw==", + "dependencies": { + "System.Buffers": "4.5.1", + "System.Numerics.Vectors": "4.5.0", + "System.Runtime.CompilerServices.Unsafe": "4.5.3" + } + }, + "System.Net.WebSockets.Client.Managed": { + "type": "Transitive", + "resolved": "1.0.22", + "contentHash": "WqEOxPlXjuZrIjUtXNE9NxEfU/n5E35iV2PtoZdJSUC4tlrqwHnTee+wvMIM4OUaJWmwrymeqcgYrE0IkGAgLA==", + "dependencies": { + "System.Buffers": "4.4.0", + "System.Numerics.Vectors": "4.4.0" + } + }, + "System.Numerics.Vectors": { + "type": "Transitive", + "resolved": "4.5.0", + "contentHash": "QQTlPTl06J/iiDbJCiepZ4H//BVraReU4O4EoRw1U02H5TLUIT7xn3GnDp9AXPSlJUDyFs4uWjWafNX6WrAojQ==" + }, + "System.Reactive": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "erBZjkQHWL9jpasCE/0qKAryzVBJFxGHVBAvgRN1bzM0q2s1S4oYREEEL0Vb+1kA/6BKb5FjUZMp5VXmy+gzkQ==", + "dependencies": { + "System.Threading.Tasks.Extensions": "4.5.4" + } + }, + "System.Reflection.Metadata": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "5NecZgXktdGg34rh1OenY1rFNDCI8xSjFr+Z4OU4cU06AQHUdRnIIEeWENu3Wl4YowbzkymAIMvi3WyK9U53pQ==", + "dependencies": { + "System.Collections.Immutable": "5.0.0" + } + }, + "System.Runtime.CompilerServices.Unsafe": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "ZD9TMpsmYJLrxbbmdvhwt9YEgG5WntEnZ/d1eH8JBX9LBp+Ju8BSBhUGbZMNVHHomWo2KVImJhTDl2hIgw/6MA==" + }, + "System.Runtime.InteropServices.RuntimeInformation": { + "type": "Transitive", + "resolved": "4.3.0", + "contentHash": "cbz4YJMqRDR7oLeMRbdYv7mYzc++17lNhScCX0goO2XpGWdvAt60CGN+FHdePUEHCe/Jy9jUlvNAiNdM+7jsOw==" + }, + "System.Text.Encodings.Web": { + "type": "Transitive", + "resolved": "5.0.1", + "contentHash": "KmJ+CJXizDofbq6mpqDoRRLcxgOd2z9X3XoFNULSbvbqVRZkFX3istvr+MUjL6Zw1RT+RNdoI4GYidIINtgvqQ==", + "dependencies": { + "System.Buffers": "4.5.1", + "System.Memory": "4.5.4" + } + }, + "System.Text.Json": { + "type": "Transitive", + "resolved": "5.0.2", + "contentHash": "I47dVIGiV6SfAyppphxqupertT/5oZkYLDCX6vC3HpOI4ZLjyoKAreUoem2ie6G0RbRuFrlqz/PcTQjfb2DOfQ==", + "dependencies": { + "Microsoft.Bcl.AsyncInterfaces": "5.0.0", + "System.Buffers": "4.5.1", + "System.Memory": "4.5.4", + "System.Numerics.Vectors": "4.5.0", + "System.Runtime.CompilerServices.Unsafe": "5.0.0", + "System.Text.Encodings.Web": "5.0.1", + "System.Threading.Tasks.Extensions": "4.5.4", + "System.ValueTuple": "4.5.0" + } + }, + "System.Threading.Tasks.Extensions": { + "type": "Transitive", + "resolved": "4.5.4", + "contentHash": "zteT+G8xuGu6mS+mzDzYXbzS7rd3K6Fjb9RiZlYlJPam2/hU7JCBZBVEcywNuR+oZ1ncTvc/cq0faRr3P01OVg==", + "dependencies": { + "System.Runtime.CompilerServices.Unsafe": "4.5.3" + } + }, + "System.ValueTuple": { + "type": "Transitive", + "resolved": "4.5.0", + "contentHash": "okurQJO6NRE/apDIP23ajJ0hpiNmJ+f0BwOlB/cSqTLQlw5upkf+5+96+iG2Jw40G1fCVCyPz/FhIABUjMR+RQ==" + }, + "speckle.autofac": { + "type": "Project", + "dependencies": { + "Microsoft.Extensions.Logging.Abstractions": "[7.0.0, )", + "Speckle.Core": "[2.0.999-local, )" + } + }, + "speckle.converters.autocad2024": { + "type": "Project", + "dependencies": { + "Speckle.AutoCAD.API": "[2024.0.0, )", + "Speckle.Converters.Common": "[2.0.999-local, )" + } + }, + "speckle.converters.common": { + "type": "Project", + "dependencies": { + "Speckle.Autofac": "[2.0.999-local, )", + "Speckle.Objects": "[2.0.999-local, )" + } + }, + "speckle.converters.common.dependencyinjection": { + "type": "Project", + "dependencies": { + "Speckle.Autofac": "[2.0.999-local, )", + "Speckle.Converters.Common": "[2.0.999-local, )" + } + }, + "Speckle.Core": { + "type": "Project", + "dependencies": { + "GraphQL.Client": "[6.0.0, )", + "Microsoft.CSharp": "[4.7.0, )", + "Microsoft.Data.Sqlite": "[7.0.5, )", + "Polly": "[7.2.3, )", + "Polly.Contrib.WaitAndRetry": "[1.1.1, )", + "Polly.Extensions.Http": "[3.0.0, )", + "Sentry": "[3.33.0, )", + "Sentry.Serilog": "[3.33.0, )", + "Serilog": "[2.12.0, )", + "Serilog.Enrichers.ClientInfo": "[1.3.0, )", + "Serilog.Exceptions": "[8.4.0, )", + "Serilog.Sinks.Console": "[4.1.0, )", + "Serilog.Sinks.Seq": "[5.2.2, )", + "SerilogTimings": "[3.0.1, )", + "Speckle.Newtonsoft.Json": "[13.0.2, )", + "System.DoubleNumerics": "[3.1.3, )" + } + }, + "Speckle.Objects": { + "type": "Project", + "dependencies": { + "Speckle.Core": "[2.0.999-local, )" + } + } + } + } +} \ No newline at end of file diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2024/Speckle.Converters.Autocad2024.csproj b/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2024/Speckle.Converters.Autocad2024.csproj new file mode 100644 index 0000000000..f23b34ad29 --- /dev/null +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2024/Speckle.Converters.Autocad2024.csproj @@ -0,0 +1,18 @@ + + + + net48 + x64 + + + + + + + + + + + + + diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2024/packages.lock.json b/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2024/packages.lock.json new file mode 100644 index 0000000000..7e24ff76cb --- /dev/null +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2024/packages.lock.json @@ -0,0 +1,389 @@ +{ + "version": 1, + "dependencies": { + ".NETFramework,Version=v4.8": { + "PolySharp": { + "type": "Direct", + "requested": "[1.14.1, )", + "resolved": "1.14.1", + "contentHash": "mOOmFYwad3MIOL14VCjj02LljyF1GNw1wP0YVlxtcPvqdxjGGMNdNJJxHptlry3MOd8b40Flm8RPOM8JOlN2sQ==" + }, + "Speckle.AutoCAD.API": { + "type": "Direct", + "requested": "[2024.0.0, )", + "resolved": "2024.0.0", + "contentHash": "pZZ5uI+NXhZaQnsqRkgp/rywqBAjDObDJ9XNFGJvemT5k2OthDpHzlK/mKxz8QDCYie7uImQ8dv3uWj2QUFDPw==" + }, + "Speckle.InterfaceGenerator": { + "type": "Direct", + "requested": "[0.9.5, )", + "resolved": "0.9.5", + "contentHash": "oU/L7pN1R7q8KkbrpQ3WJnHirPHqn+9DEA7asOcUiggV5dzVg1A/VYs7GOSusD24njxXh03tE3a2oTLOjt3cVg==" + }, + "GraphQL.Client": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "8yPNBbuVBpTptivyAlak4GZvbwbUcjeQTL4vN1HKHRuOykZ4r7l5fcLS6vpyPyLn0x8FsL31xbOIKyxbmR9rbA==", + "dependencies": { + "GraphQL.Client.Abstractions": "6.0.0", + "GraphQL.Client.Abstractions.Websocket": "6.0.0", + "System.Net.WebSockets.Client.Managed": "1.0.22", + "System.Reactive": "5.0.0" + } + }, + "GraphQL.Client.Abstractions": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "h7uzWFORHZ+CCjwr/ThAyXMr0DPpzEANDa4Uo54wqCQ+j7qUKwqYTgOrb1W40sqbvNaZm9v/X7It31SUw0maHA==", + "dependencies": { + "GraphQL.Primitives": "6.0.0" + } + }, + "GraphQL.Client.Abstractions.Websocket": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "Nr9bPf8gIOvLuXpqEpqr9z9jslYFJOvd0feHth3/kPqeR3uMbjF5pjiwh4jxyMcxHdr8Pb6QiXkV3hsSyt0v7A==", + "dependencies": { + "GraphQL.Client.Abstractions": "6.0.0" + } + }, + "GraphQL.Primitives": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "yg72rrYDapfsIUrul7aF6wwNnTJBOFvuA9VdDTQpPa8AlAriHbufeXYLBcodKjfUdkCnaiggX1U/nEP08Zb5GA==" + }, + "Microsoft.Bcl.AsyncInterfaces": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "W8DPQjkMScOMTtJbPwmPyj9c3zYSFGawDW3jwlBOOsnY+EzZFLgNQ/UMkK35JmkNOVPdCyPr2Tw7Vv9N+KA3ZQ==", + "dependencies": { + "System.Threading.Tasks.Extensions": "4.5.4" + } + }, + "Microsoft.CSharp": { + "type": "Transitive", + "resolved": "4.7.0", + "contentHash": "pTj+D3uJWyN3My70i2Hqo+OXixq3Os2D1nJ2x92FFo6sk8fYS1m1WLNTs0Dc1uPaViH0YvEEwvzddQ7y4rhXmA==" + }, + "Microsoft.Data.Sqlite": { + "type": "Transitive", + "resolved": "7.0.5", + "contentHash": "KGxbPeWsQMnmQy43DSBxAFtHz3l2JX8EWBSGUCvT3CuZ8KsuzbkqMIJMDOxWtG8eZSoCDI04aiVQjWuuV8HmSw==", + "dependencies": { + "Microsoft.Data.Sqlite.Core": "7.0.5", + "SQLitePCLRaw.bundle_e_sqlite3": "2.1.4" + } + }, + "Microsoft.Data.Sqlite.Core": { + "type": "Transitive", + "resolved": "7.0.5", + "contentHash": "FTerRmQPqHrCrnoUzhBu+E+1DNGwyrAMLqHkAqOOOu5pGfyMOj8qQUBxI/gDtWtG11p49UxSfWmBzRNlwZqfUg==", + "dependencies": { + "SQLitePCLRaw.core": "2.1.4" + } + }, + "Microsoft.Extensions.Logging.Abstractions": { + "type": "Transitive", + "resolved": "7.0.0", + "contentHash": "kmn78+LPVMOWeITUjIlfxUPDsI0R6G0RkeAMBmQxAJ7vBJn4q2dTva7pWi65ceN5vPGjJ9q/Uae2WKgvfktJAw==", + "dependencies": { + "System.Buffers": "4.5.1", + "System.Memory": "4.5.5" + } + }, + "Polly": { + "type": "Transitive", + "resolved": "7.2.3", + "contentHash": "DeCY0OFbNdNxsjntr1gTXHJ5pKUwYzp04Er2LLeN3g6pWhffsGuKVfMBLe1lw7x76HrPkLxKEFxBlpRxS2nDEQ==" + }, + "Polly.Contrib.WaitAndRetry": { + "type": "Transitive", + "resolved": "1.1.1", + "contentHash": "1MUQLiSo4KDkQe6nzQRhIU05lm9jlexX5BVsbuw0SL82ynZ+GzAHQxJVDPVBboxV37Po3SG077aX8DuSy8TkaA==" + }, + "Polly.Extensions.Http": { + "type": "Transitive", + "resolved": "3.0.0", + "contentHash": "drrG+hB3pYFY7w1c3BD+lSGYvH2oIclH8GRSehgfyP5kjnFnHKQuuBhuHLv+PWyFuaTDyk/vfRpnxOzd11+J8g==", + "dependencies": { + "Polly": "7.1.0" + } + }, + "Sentry": { + "type": "Transitive", + "resolved": "3.33.0", + "contentHash": "8vbD2o6IR2wrRrkSiRbnodWGWUOqIlwYtzpjvPNOb5raJdOf+zxMwfS8f6nx9bmrTTfDj7KrCB8C/5OuicAc8A==", + "dependencies": { + "System.Reflection.Metadata": "5.0.0", + "System.Runtime.InteropServices.RuntimeInformation": "4.3.0", + "System.Text.Json": "5.0.2" + } + }, + "Sentry.Serilog": { + "type": "Transitive", + "resolved": "3.33.0", + "contentHash": "V8BU7QGWg2qLYfNPqtuTBhC1opysny5l+Ifp6J6PhOeAxU0FssR7nYfbJVetrnLIoh2rd3DlJ6hHYYQosQYcUQ==", + "dependencies": { + "Sentry": "3.33.0", + "Serilog": "2.7.1" + } + }, + "Serilog": { + "type": "Transitive", + "resolved": "2.12.0", + "contentHash": "xaiJLIdu6rYMKfQMYUZgTy8YK7SMZjB4Yk50C/u//Z4OsvxkUfSPJy4nknfvwAC34yr13q7kcyh4grbwhSxyZg==" + }, + "Serilog.Enrichers.ClientInfo": { + "type": "Transitive", + "resolved": "1.3.0", + "contentHash": "mTc7PM+wC9Hr7LWSwqt5mmnlAr7RJs+eTb3PGPRhwdOackk95MkhUZognuxXEdlW19HAFNmEBTSBY5DfLwM8jQ==", + "dependencies": { + "Serilog": "2.4.0" + } + }, + "Serilog.Exceptions": { + "type": "Transitive", + "resolved": "8.4.0", + "contentHash": "nc/+hUw3lsdo0zCj0KMIybAu7perMx79vu72w0za9Nsi6mWyNkGXxYxakAjWB7nEmYL6zdmhEQRB4oJ2ALUeug==", + "dependencies": { + "Serilog": "2.8.0" + } + }, + "Serilog.Formatting.Compact": { + "type": "Transitive", + "resolved": "1.1.0", + "contentHash": "pNroKVjo+rDqlxNG5PXkRLpfSCuDOBY0ri6jp9PLe505ljqwhwZz8ospy2vWhQlFu5GkIesh3FcDs4n7sWZODA==", + "dependencies": { + "Serilog": "2.8.0" + } + }, + "Serilog.Sinks.Console": { + "type": "Transitive", + "resolved": "4.1.0", + "contentHash": "K6N5q+5fetjnJPvCmkWOpJ/V8IEIoMIB1s86OzBrbxwTyHxdx3pmz4H+8+O/Dc/ftUX12DM1aynx/dDowkwzqg==", + "dependencies": { + "Serilog": "2.10.0" + } + }, + "Serilog.Sinks.File": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "uwV5hdhWPwUH1szhO8PJpFiahqXmzPzJT/sOijH/kFgUx+cyoDTMM8MHD0adw9+Iem6itoibbUXHYslzXsLEAg==", + "dependencies": { + "Serilog": "2.10.0" + } + }, + "Serilog.Sinks.PeriodicBatching": { + "type": "Transitive", + "resolved": "3.1.0", + "contentHash": "NDWR7m3PalVlGEq3rzoktrXikjFMLmpwF0HI4sowo8YDdU+gqPlTHlDQiOGxHfB0sTfjPA9JjA7ctKG9zqjGkw==", + "dependencies": { + "Serilog": "2.0.0" + } + }, + "Serilog.Sinks.Seq": { + "type": "Transitive", + "resolved": "5.2.2", + "contentHash": "1Csmo5ua7NKUe0yXUx+zsRefjAniPWcXFhUXxXG8pwo0iMiw2gjn9SOkgYnnxbgWqmlGv236w0N/dHc2v5XwMg==", + "dependencies": { + "Serilog": "2.12.0", + "Serilog.Formatting.Compact": "1.1.0", + "Serilog.Sinks.File": "5.0.0", + "Serilog.Sinks.PeriodicBatching": "3.1.0" + } + }, + "SerilogTimings": { + "type": "Transitive", + "resolved": "3.0.1", + "contentHash": "Zs28eTgszAMwpIrbBnWHBI50yuxL50p/dmAUWmy75+axdZYK/Sjm5/5m1N/CisR8acJUhTVcjPZrsB1P5iv0Uw==", + "dependencies": { + "Serilog": "2.10.0" + } + }, + "Speckle.Newtonsoft.Json": { + "type": "Transitive", + "resolved": "13.0.2", + "contentHash": "g1BejUZwax5PRfL6xHgLEK23sqHWOgOj9hE7RvfRRlN00AGt8GnPYt8HedSK7UB3HiRW8zCA9Pn0iiYxCK24BA==" + }, + "SQLitePCLRaw.bundle_e_sqlite3": { + "type": "Transitive", + "resolved": "2.1.4", + "contentHash": "EWI1olKDjFEBMJu0+3wuxwziIAdWDVMYLhuZ3Qs84rrz+DHwD00RzWPZCa+bLnHCf3oJwuFZIRsHT5p236QXww==", + "dependencies": { + "SQLitePCLRaw.lib.e_sqlite3": "2.1.4", + "SQLitePCLRaw.provider.dynamic_cdecl": "2.1.4" + } + }, + "SQLitePCLRaw.core": { + "type": "Transitive", + "resolved": "2.1.4", + "contentHash": "inBjvSHo9UDKneGNzfUfDjK08JzlcIhn1+SP5Y3m6cgXpCxXKCJDy6Mka7LpgSV+UZmKSnC8rTwB0SQ0xKu5pA==", + "dependencies": { + "System.Memory": "4.5.3" + } + }, + "SQLitePCLRaw.lib.e_sqlite3": { + "type": "Transitive", + "resolved": "2.1.4", + "contentHash": "2C9Q9eX7CPLveJA0rIhf9RXAvu+7nWZu1A2MdG6SD/NOu26TakGgL1nsbc0JAspGijFOo3HoN79xrx8a368fBg==" + }, + "SQLitePCLRaw.provider.dynamic_cdecl": { + "type": "Transitive", + "resolved": "2.1.4", + "contentHash": "ZsaKKhgYF9B1fvcnOGKl3EycNAwd9CRWX7v0rEfuPWhQQ5Jjpvf2VEHahiLIGHio3hxi3EIKFJw9KvyowWOUAw==", + "dependencies": { + "SQLitePCLRaw.core": "2.1.4" + } + }, + "System.Buffers": { + "type": "Transitive", + "resolved": "4.5.1", + "contentHash": "Rw7ijyl1qqRS0YQD/WycNst8hUUMgrMH4FCn1nNm27M4VxchZ1js3fVjQaANHO5f3sN4isvP4a+Met9Y4YomAg==" + }, + "System.Collections.Immutable": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "FXkLXiK0sVVewcso0imKQoOxjoPAj42R8HtjjbSjVPAzwDfzoyoznWxgA3c38LDbN9SJux1xXoXYAhz98j7r2g==", + "dependencies": { + "System.Memory": "4.5.4" + } + }, + "System.DoubleNumerics": { + "type": "Transitive", + "resolved": "3.1.3", + "contentHash": "KRKEM/L3KBodjA9VOg3EifFVWUY6EOqaMB05UvPEDm7Zeby/kZW+4kdWUEPzW6xtkwf46p661L9NrbeeQhtLzw==", + "dependencies": { + "NETStandard.Library": "1.6.1" + } + }, + "System.Memory": { + "type": "Transitive", + "resolved": "4.5.5", + "contentHash": "XIWiDvKPXaTveaB7HVganDlOCRoj03l+jrwNvcge/t8vhGYKvqV+dMv6G4SAX2NoNmN0wZfVPTAlFwZcZvVOUw==", + "dependencies": { + "System.Buffers": "4.5.1", + "System.Numerics.Vectors": "4.5.0", + "System.Runtime.CompilerServices.Unsafe": "4.5.3" + } + }, + "System.Net.WebSockets.Client.Managed": { + "type": "Transitive", + "resolved": "1.0.22", + "contentHash": "WqEOxPlXjuZrIjUtXNE9NxEfU/n5E35iV2PtoZdJSUC4tlrqwHnTee+wvMIM4OUaJWmwrymeqcgYrE0IkGAgLA==", + "dependencies": { + "System.Buffers": "4.4.0", + "System.Numerics.Vectors": "4.4.0" + } + }, + "System.Numerics.Vectors": { + "type": "Transitive", + "resolved": "4.5.0", + "contentHash": "QQTlPTl06J/iiDbJCiepZ4H//BVraReU4O4EoRw1U02H5TLUIT7xn3GnDp9AXPSlJUDyFs4uWjWafNX6WrAojQ==" + }, + "System.Reactive": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "erBZjkQHWL9jpasCE/0qKAryzVBJFxGHVBAvgRN1bzM0q2s1S4oYREEEL0Vb+1kA/6BKb5FjUZMp5VXmy+gzkQ==", + "dependencies": { + "System.Threading.Tasks.Extensions": "4.5.4" + } + }, + "System.Reflection.Metadata": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "5NecZgXktdGg34rh1OenY1rFNDCI8xSjFr+Z4OU4cU06AQHUdRnIIEeWENu3Wl4YowbzkymAIMvi3WyK9U53pQ==", + "dependencies": { + "System.Collections.Immutable": "5.0.0" + } + }, + "System.Runtime.CompilerServices.Unsafe": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "ZD9TMpsmYJLrxbbmdvhwt9YEgG5WntEnZ/d1eH8JBX9LBp+Ju8BSBhUGbZMNVHHomWo2KVImJhTDl2hIgw/6MA==" + }, + "System.Runtime.InteropServices.RuntimeInformation": { + "type": "Transitive", + "resolved": "4.3.0", + "contentHash": "cbz4YJMqRDR7oLeMRbdYv7mYzc++17lNhScCX0goO2XpGWdvAt60CGN+FHdePUEHCe/Jy9jUlvNAiNdM+7jsOw==" + }, + "System.Text.Encodings.Web": { + "type": "Transitive", + "resolved": "5.0.1", + "contentHash": "KmJ+CJXizDofbq6mpqDoRRLcxgOd2z9X3XoFNULSbvbqVRZkFX3istvr+MUjL6Zw1RT+RNdoI4GYidIINtgvqQ==", + "dependencies": { + "System.Buffers": "4.5.1", + "System.Memory": "4.5.4" + } + }, + "System.Text.Json": { + "type": "Transitive", + "resolved": "5.0.2", + "contentHash": "I47dVIGiV6SfAyppphxqupertT/5oZkYLDCX6vC3HpOI4ZLjyoKAreUoem2ie6G0RbRuFrlqz/PcTQjfb2DOfQ==", + "dependencies": { + "Microsoft.Bcl.AsyncInterfaces": "5.0.0", + "System.Buffers": "4.5.1", + "System.Memory": "4.5.4", + "System.Numerics.Vectors": "4.5.0", + "System.Runtime.CompilerServices.Unsafe": "5.0.0", + "System.Text.Encodings.Web": "5.0.1", + "System.Threading.Tasks.Extensions": "4.5.4", + "System.ValueTuple": "4.5.0" + } + }, + "System.Threading.Tasks.Extensions": { + "type": "Transitive", + "resolved": "4.5.4", + "contentHash": "zteT+G8xuGu6mS+mzDzYXbzS7rd3K6Fjb9RiZlYlJPam2/hU7JCBZBVEcywNuR+oZ1ncTvc/cq0faRr3P01OVg==", + "dependencies": { + "System.Runtime.CompilerServices.Unsafe": "4.5.3" + } + }, + "System.ValueTuple": { + "type": "Transitive", + "resolved": "4.5.0", + "contentHash": "okurQJO6NRE/apDIP23ajJ0hpiNmJ+f0BwOlB/cSqTLQlw5upkf+5+96+iG2Jw40G1fCVCyPz/FhIABUjMR+RQ==" + }, + "speckle.autofac": { + "type": "Project", + "dependencies": { + "Microsoft.Extensions.Logging.Abstractions": "[7.0.0, )", + "Speckle.Core": "[2.0.999-local, )" + } + }, + "speckle.converters.common": { + "type": "Project", + "dependencies": { + "Speckle.Autofac": "[2.0.999-local, )", + "Speckle.Objects": "[2.0.999-local, )" + } + }, + "Speckle.Core": { + "type": "Project", + "dependencies": { + "GraphQL.Client": "[6.0.0, )", + "Microsoft.CSharp": "[4.7.0, )", + "Microsoft.Data.Sqlite": "[7.0.5, )", + "Polly": "[7.2.3, )", + "Polly.Contrib.WaitAndRetry": "[1.1.1, )", + "Polly.Extensions.Http": "[3.0.0, )", + "Sentry": "[3.33.0, )", + "Sentry.Serilog": "[3.33.0, )", + "Serilog": "[2.12.0, )", + "Serilog.Enrichers.ClientInfo": "[1.3.0, )", + "Serilog.Exceptions": "[8.4.0, )", + "Serilog.Sinks.Console": "[4.1.0, )", + "Serilog.Sinks.Seq": "[5.2.2, )", + "SerilogTimings": "[3.0.1, )", + "Speckle.Newtonsoft.Json": "[13.0.2, )", + "System.DoubleNumerics": "[3.1.3, )" + } + }, + "Speckle.Objects": { + "type": "Project", + "dependencies": { + "Speckle.Core": "[2.0.999-local, )" + } + } + } + } +} \ No newline at end of file From 473711f619d22207dcf0bab3da6f11b960aad7a5 Mon Sep 17 00:00:00 2001 From: KatKatKateryna <89912278+KatKatKateryna@users.noreply.github.com> Date: Thu, 27 Jun 2024 05:59:10 +0800 Subject: [PATCH 245/261] D ui3 299 arc gis not opening saved model cards (#3532) * resurrect DocumentStore subscriptions * read metadata from existing map * don't break DI if Map is still not loaded --- .../Utils/ArcGisDocumentStore.cs | 34 +++++++++++++------ 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Utils/ArcGisDocumentStore.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Utils/ArcGisDocumentStore.cs index db0df3550f..eb420af874 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Utils/ArcGisDocumentStore.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Utils/ArcGisDocumentStore.cs @@ -18,17 +18,31 @@ ITopLevelExceptionHandler topLevelExceptionHandler ) : base(serializerOption, true) { - ActiveMapViewChangedEvent.Subscribe(a => topLevelExceptionHandler.CatchUnhandled(() => OnMapViewChanged(a))); - ProjectSavingEvent.Subscribe(_ => - { - topLevelExceptionHandler.CatchUnhandled(OnProjectSaving); - return Task.CompletedTask; - }); - ProjectClosingEvent.Subscribe(_ => + ActiveMapViewChangedEvent.Subscribe(a => topLevelExceptionHandler.CatchUnhandled(() => OnMapViewChanged(a)), true); + ProjectSavingEvent.Subscribe( + _ => + { + topLevelExceptionHandler.CatchUnhandled(OnProjectSaving); + return Task.CompletedTask; + }, + true + ); + ProjectClosingEvent.Subscribe( + _ => + { + topLevelExceptionHandler.CatchUnhandled(OnProjectClosing); + return Task.CompletedTask; + }, + true + ); + + // in case plugin was loaded into already opened Map, read metadata from the current Map + if (IsDocumentInit == false && MapView.Active != null) { - topLevelExceptionHandler.CatchUnhandled(OnProjectClosing); - return Task.CompletedTask; - }); + IsDocumentInit = true; + ReadFromFile(); + OnDocumentChanged(); + } } private void OnProjectClosing() From fbcb8ffdaa1e06a5093028f0ce07dcd51cde1754 Mon Sep 17 00:00:00 2001 From: Adam Hathcock Date: Thu, 27 Jun 2024 11:57:39 +0100 Subject: [PATCH 246/261] V3 core sdk via nuget (#3533) * initial nuget references * fmt * remove unused revit dependency * Don't use new solution * remove unused file * update core --- .editorconfig | 2 + DUI3-DX.slnf | 9 +- .../packages.lock.json | 67 ++++++------ .../packages.lock.json | 67 ++++++------ .../Speckle.Connectors.Civil3d2024.csproj | 1 - .../packages.lock.json | 78 +++++++------- .../packages.lock.json | 67 ++++++------ .../Plugin/RevitExternalApplication.cs | 1 - .../Plugin/Speckle.Connectors.Rhino7Plugin.cs | 1 - .../packages.lock.json | 67 ++++++------ .../packages.lock.json | 63 +++++------ .../Speckle.Converters.ArcGIS3.csproj | 5 +- .../packages.lock.json | 63 +++++------ .../packages.lock.json | 63 +++++------ .../packages.lock.json | 63 +++++------ .../packages.lock.json | 63 +++++------ .../packages.lock.json | 63 +++++------ .../packages.lock.json | 63 +++++------ .../XyzConversionToPointTests.cs | 2 - .../packages.lock.json | 65 +++++------ .../packages.lock.json | 63 +++++------ .../Helpers/DisplayValueExtractor.cs | 30 +++--- .../Helpers/ParameterObjectAssigner.cs | 11 +- .../packages.lock.json | 63 +++++------ .../packages.lock.json | 63 +++++------ .../packages.lock.json | 102 +++++++++--------- .../Speckle.Connectors.DUI.csproj | 3 +- .../Speckle.Connectors.DUI/packages.lock.json | 50 ++++----- .../SpeckleContainerBuilder.cs | 1 - .../Speckle.Autofac/ExceptionExtensions.cs | 45 ++++++++ .../Speckle.Autofac/Speckle.Autofac.csproj | 4 - .../Speckle.Connectors.Utils.csproj | 3 +- .../packages.lock.json | 48 +++++---- .../packages.lock.json | 63 +++++------ .../packages.lock.json | 63 +++++------ .../Speckle.Converters.Common.csproj | 7 +- .../packages.lock.json | 62 ++++++----- 37 files changed, 822 insertions(+), 732 deletions(-) create mode 100644 DUI3-DX/Sdk/Speckle.Autofac/ExceptionExtensions.cs diff --git a/.editorconfig b/.editorconfig index 36de039b9a..0485923f3a 100644 --- a/.editorconfig +++ b/.editorconfig @@ -242,6 +242,8 @@ dotnet_diagnostic.ca1506.severity = warning # Avoid excessive class coupling dotnet_diagnostic.ca1507.severity = warning # Use nameof in place of string dotnet_diagnostic.ca1508.severity = warning # Avoid dead conditional code dotnet_diagnostic.ca1509.severity = warning # Invalid entry in code metrics configuration file +dotnet_diagnostic.CA2254.severity = none # Template should be a static expression + # Performance rules diff --git a/DUI3-DX.slnf b/DUI3-DX.slnf index 4bfa3426df..fcbcedfb72 100644 --- a/DUI3-DX.slnf +++ b/DUI3-DX.slnf @@ -3,11 +3,6 @@ "path": "All.sln", "projects": [ "Build\\Build.csproj", - "Core\\Core\\Core.csproj", - "Core\\Tests\\Speckle.Core.Tests.Integration\\Speckle.Core.Tests.Integration.csproj", - "Core\\Tests\\Speckle.Core.Tests.Performance\\Speckle.Core.Tests.Performance.csproj", - "Core\\Tests\\Speckle.Core.Tests.Unit\\Speckle.Core.Tests.Unit.csproj", - "Core\\Transports\\DiskTransport\\DiskTransport.csproj", "DUI3-DX\\Connectors\\ArcGIS\\Speckle.Connectors.ArcGIS3\\Speckle.Connectors.ArcGIS3.csproj", "DUI3-DX\\Connectors\\Autocad\\Speckle.Connectors.Autocad2023\\Speckle.Connectors.Autocad2023.csproj", "DUI3-DX\\Connectors\\Autocad\\Speckle.Connectors.AutocadShared\\Speckle.Connectors.AutocadShared.shproj", @@ -34,9 +29,7 @@ "DUI3-DX\\Sdk\\Speckle.Connectors.Utils\\Speckle.Connectors.Utils.csproj", "DUI3-DX\\Sdk\\Speckle.Converters.Common.DependencyInjection\\Speckle.Converters.Common.DependencyInjection.csproj", "DUI3-DX\\Sdk\\Speckle.Converters.Common.Tests\\Speckle.Converters.Common.Tests.csproj", - "DUI3-DX\\Sdk\\Speckle.Converters.Common\\Speckle.Converters.Common.csproj", - "Objects\\Objects\\Objects.csproj", - "Objects\\Tests\\Objects.Tests.Unit\\Objects.Tests.Unit.csproj" + "DUI3-DX\\Sdk\\Speckle.Converters.Common\\Speckle.Converters.Common.csproj" ] } } \ No newline at end of file diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/packages.lock.json b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/packages.lock.json index 5306011fc3..720298148f 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/packages.lock.json +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/packages.lock.json @@ -297,11 +297,42 @@ "Serilog": "2.10.0" } }, + "Speckle.Core": { + "type": "Transitive", + "resolved": "3.0.1-alpha.11", + "contentHash": "Zt2dBJLlfziEACYCHThbhKypSjhoA01rTw9BzNI72c/BDyftXIz70Tetq/8ZMEqQnKqfmRyYADsAdWKxpdV0Hg==", + "dependencies": { + "GraphQL.Client": "6.0.0", + "Microsoft.CSharp": "4.7.0", + "Microsoft.Data.Sqlite": "7.0.5", + "Polly": "7.2.3", + "Polly.Contrib.WaitAndRetry": "1.1.1", + "Polly.Extensions.Http": "3.0.0", + "Sentry": "3.33.0", + "Sentry.Serilog": "3.33.0", + "Serilog": "2.12.0", + "Serilog.Enrichers.ClientInfo": "1.3.0", + "Serilog.Exceptions": "8.4.0", + "Serilog.Sinks.Console": "4.1.0", + "Serilog.Sinks.Seq": "5.2.2", + "SerilogTimings": "3.0.1", + "Speckle.Newtonsoft.Json": "13.0.2", + "System.DoubleNumerics": "3.1.3" + } + }, "Speckle.Newtonsoft.Json": { "type": "Transitive", "resolved": "13.0.2", "contentHash": "g1BejUZwax5PRfL6xHgLEK23sqHWOgOj9hE7RvfRRlN00AGt8GnPYt8HedSK7UB3HiRW8zCA9Pn0iiYxCK24BA==" }, + "Speckle.Objects": { + "type": "Transitive", + "resolved": "3.0.1-alpha.11", + "contentHash": "YR7sei3OQBAi8R/kIu8bEmg5ELDIJK6l5fhOgdnqA9ZvD/fvmRb+09z8lIUTDsgdAdvYU/A/x9VxH9OGPbp9Kw==", + "dependencies": { + "Speckle.Core": "3.0.1-alpha.11" + } + }, "SQLitePCLRaw.bundle_e_sqlite3": { "type": "Transitive", "resolved": "2.1.4", @@ -378,8 +409,7 @@ "speckle.autofac": { "type": "Project", "dependencies": { - "Microsoft.Extensions.Logging.Abstractions": "[7.0.0, )", - "Speckle.Core": "[2.0.999-local, )" + "Microsoft.Extensions.Logging.Abstractions": "[7.0.0, )" } }, "speckle.connectors.dui": { @@ -388,7 +418,7 @@ "Microsoft.Extensions.Logging.Abstractions": "[7.0.0, )", "Speckle.Autofac": "[2.0.999-local, )", "Speckle.Connectors.Utils": "[2.0.999-local, )", - "Speckle.Core": "[2.0.999-local, )", + "Speckle.Core": "[3.0.1-alpha.11, )", "System.Threading.Tasks.Dataflow": "[6.0.0, )" } }, @@ -404,7 +434,7 @@ "dependencies": { "Serilog.Extensions.Logging": "[7.0.0, )", "Speckle.Autofac": "[2.0.999-local, )", - "Speckle.Core": "[2.0.999-local, )" + "Speckle.Core": "[3.0.1-alpha.11, )" } }, "speckle.converters.arcgis3": { @@ -426,7 +456,7 @@ "type": "Project", "dependencies": { "Speckle.Autofac": "[2.0.999-local, )", - "Speckle.Objects": "[2.0.999-local, )" + "Speckle.Objects": "[3.0.1-alpha.11, )" } }, "speckle.converters.common.dependencyinjection": { @@ -435,33 +465,6 @@ "Speckle.Autofac": "[2.0.999-local, )", "Speckle.Converters.Common": "[2.0.999-local, )" } - }, - "Speckle.Core": { - "type": "Project", - "dependencies": { - "GraphQL.Client": "[6.0.0, )", - "Microsoft.CSharp": "[4.7.0, )", - "Microsoft.Data.Sqlite": "[7.0.5, )", - "Polly": "[7.2.3, )", - "Polly.Contrib.WaitAndRetry": "[1.1.1, )", - "Polly.Extensions.Http": "[3.0.0, )", - "Sentry": "[3.33.0, )", - "Sentry.Serilog": "[3.33.0, )", - "Serilog": "[2.12.0, )", - "Serilog.Enrichers.ClientInfo": "[1.3.0, )", - "Serilog.Exceptions": "[8.4.0, )", - "Serilog.Sinks.Console": "[4.1.0, )", - "Serilog.Sinks.Seq": "[5.2.2, )", - "SerilogTimings": "[3.0.1, )", - "Speckle.Newtonsoft.Json": "[13.0.2, )", - "System.DoubleNumerics": "[3.1.3, )" - } - }, - "Speckle.Objects": { - "type": "Project", - "dependencies": { - "Speckle.Core": "[2.0.999-local, )" - } } }, "net6.0-windows7.0/win-x64": { diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.Autocad2023/packages.lock.json b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.Autocad2023/packages.lock.json index ecbfc4fb09..662f264cb2 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.Autocad2023/packages.lock.json +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.Autocad2023/packages.lock.json @@ -274,11 +274,42 @@ "Serilog": "2.10.0" } }, + "Speckle.Core": { + "type": "Transitive", + "resolved": "3.0.1-alpha.11", + "contentHash": "Zt2dBJLlfziEACYCHThbhKypSjhoA01rTw9BzNI72c/BDyftXIz70Tetq/8ZMEqQnKqfmRyYADsAdWKxpdV0Hg==", + "dependencies": { + "GraphQL.Client": "6.0.0", + "Microsoft.CSharp": "4.7.0", + "Microsoft.Data.Sqlite": "7.0.5", + "Polly": "7.2.3", + "Polly.Contrib.WaitAndRetry": "1.1.1", + "Polly.Extensions.Http": "3.0.0", + "Sentry": "3.33.0", + "Sentry.Serilog": "3.33.0", + "Serilog": "2.12.0", + "Serilog.Enrichers.ClientInfo": "1.3.0", + "Serilog.Exceptions": "8.4.0", + "Serilog.Sinks.Console": "4.1.0", + "Serilog.Sinks.Seq": "5.2.2", + "SerilogTimings": "3.0.1", + "Speckle.Newtonsoft.Json": "13.0.2", + "System.DoubleNumerics": "3.1.3" + } + }, "Speckle.Newtonsoft.Json": { "type": "Transitive", "resolved": "13.0.2", "contentHash": "g1BejUZwax5PRfL6xHgLEK23sqHWOgOj9hE7RvfRRlN00AGt8GnPYt8HedSK7UB3HiRW8zCA9Pn0iiYxCK24BA==" }, + "Speckle.Objects": { + "type": "Transitive", + "resolved": "3.0.1-alpha.11", + "contentHash": "YR7sei3OQBAi8R/kIu8bEmg5ELDIJK6l5fhOgdnqA9ZvD/fvmRb+09z8lIUTDsgdAdvYU/A/x9VxH9OGPbp9Kw==", + "dependencies": { + "Speckle.Core": "3.0.1-alpha.11" + } + }, "SQLitePCLRaw.bundle_e_sqlite3": { "type": "Transitive", "resolved": "2.1.4", @@ -434,8 +465,7 @@ "speckle.autofac": { "type": "Project", "dependencies": { - "Microsoft.Extensions.Logging.Abstractions": "[7.0.0, )", - "Speckle.Core": "[2.0.999-local, )" + "Microsoft.Extensions.Logging.Abstractions": "[7.0.0, )" } }, "speckle.connectors.dui": { @@ -444,7 +474,7 @@ "Microsoft.Extensions.Logging.Abstractions": "[7.0.0, )", "Speckle.Autofac": "[2.0.999-local, )", "Speckle.Connectors.Utils": "[2.0.999-local, )", - "Speckle.Core": "[2.0.999-local, )", + "Speckle.Core": "[3.0.1-alpha.11, )", "System.Threading.Tasks.Dataflow": "[6.0.0, )" } }, @@ -460,7 +490,7 @@ "dependencies": { "Serilog.Extensions.Logging": "[7.0.0, )", "Speckle.Autofac": "[2.0.999-local, )", - "Speckle.Core": "[2.0.999-local, )" + "Speckle.Core": "[3.0.1-alpha.11, )" } }, "speckle.converters.autocad2023": { @@ -482,7 +512,7 @@ "type": "Project", "dependencies": { "Speckle.Autofac": "[2.0.999-local, )", - "Speckle.Objects": "[2.0.999-local, )" + "Speckle.Objects": "[3.0.1-alpha.11, )" } }, "speckle.converters.common.dependencyinjection": { @@ -491,33 +521,6 @@ "Speckle.Autofac": "[2.0.999-local, )", "Speckle.Converters.Common": "[2.0.999-local, )" } - }, - "Speckle.Core": { - "type": "Project", - "dependencies": { - "GraphQL.Client": "[6.0.0, )", - "Microsoft.CSharp": "[4.7.0, )", - "Microsoft.Data.Sqlite": "[7.0.5, )", - "Polly": "[7.2.3, )", - "Polly.Contrib.WaitAndRetry": "[1.1.1, )", - "Polly.Extensions.Http": "[3.0.0, )", - "Sentry": "[3.33.0, )", - "Sentry.Serilog": "[3.33.0, )", - "Serilog": "[2.12.0, )", - "Serilog.Enrichers.ClientInfo": "[1.3.0, )", - "Serilog.Exceptions": "[8.4.0, )", - "Serilog.Sinks.Console": "[4.1.0, )", - "Serilog.Sinks.Seq": "[5.2.2, )", - "SerilogTimings": "[3.0.1, )", - "Speckle.Newtonsoft.Json": "[13.0.2, )", - "System.DoubleNumerics": "[3.1.3, )" - } - }, - "Speckle.Objects": { - "type": "Project", - "dependencies": { - "Speckle.Core": "[2.0.999-local, )" - } } } } diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.Civil3d2024/Speckle.Connectors.Civil3d2024.csproj b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.Civil3d2024/Speckle.Connectors.Civil3d2024.csproj index 721a34ab7e..a780058c4e 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.Civil3d2024/Speckle.Connectors.Civil3d2024.csproj +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.Civil3d2024/Speckle.Connectors.Civil3d2024.csproj @@ -19,7 +19,6 @@ - diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.Civil3d2024/packages.lock.json b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.Civil3d2024/packages.lock.json index 442462d552..a56054ea66 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.Civil3d2024/packages.lock.json +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.Civil3d2024/packages.lock.json @@ -18,12 +18,6 @@ "resolved": "1.14.1", "contentHash": "mOOmFYwad3MIOL14VCjj02LljyF1GNw1wP0YVlxtcPvqdxjGGMNdNJJxHptlry3MOd8b40Flm8RPOM8JOlN2sQ==" }, - "Speckle.AutoCAD.API": { - "type": "Direct", - "requested": "[2024.0.0, )", - "resolved": "2024.0.0", - "contentHash": "pZZ5uI+NXhZaQnsqRkgp/rywqBAjDObDJ9XNFGJvemT5k2OthDpHzlK/mKxz8QDCYie7uImQ8dv3uWj2QUFDPw==" - }, "Speckle.Civil3D.API": { "type": "Direct", "requested": "[2024.0.0, )", @@ -283,11 +277,47 @@ "Serilog": "2.10.0" } }, + "Speckle.AutoCAD.API": { + "type": "Transitive", + "resolved": "2024.0.0", + "contentHash": "pZZ5uI+NXhZaQnsqRkgp/rywqBAjDObDJ9XNFGJvemT5k2OthDpHzlK/mKxz8QDCYie7uImQ8dv3uWj2QUFDPw==" + }, + "Speckle.Core": { + "type": "Transitive", + "resolved": "3.0.1-alpha.11", + "contentHash": "Zt2dBJLlfziEACYCHThbhKypSjhoA01rTw9BzNI72c/BDyftXIz70Tetq/8ZMEqQnKqfmRyYADsAdWKxpdV0Hg==", + "dependencies": { + "GraphQL.Client": "6.0.0", + "Microsoft.CSharp": "4.7.0", + "Microsoft.Data.Sqlite": "7.0.5", + "Polly": "7.2.3", + "Polly.Contrib.WaitAndRetry": "1.1.1", + "Polly.Extensions.Http": "3.0.0", + "Sentry": "3.33.0", + "Sentry.Serilog": "3.33.0", + "Serilog": "2.12.0", + "Serilog.Enrichers.ClientInfo": "1.3.0", + "Serilog.Exceptions": "8.4.0", + "Serilog.Sinks.Console": "4.1.0", + "Serilog.Sinks.Seq": "5.2.2", + "SerilogTimings": "3.0.1", + "Speckle.Newtonsoft.Json": "13.0.2", + "System.DoubleNumerics": "3.1.3" + } + }, "Speckle.Newtonsoft.Json": { "type": "Transitive", "resolved": "13.0.2", "contentHash": "g1BejUZwax5PRfL6xHgLEK23sqHWOgOj9hE7RvfRRlN00AGt8GnPYt8HedSK7UB3HiRW8zCA9Pn0iiYxCK24BA==" }, + "Speckle.Objects": { + "type": "Transitive", + "resolved": "3.0.1-alpha.11", + "contentHash": "YR7sei3OQBAi8R/kIu8bEmg5ELDIJK6l5fhOgdnqA9ZvD/fvmRb+09z8lIUTDsgdAdvYU/A/x9VxH9OGPbp9Kw==", + "dependencies": { + "Speckle.Core": "3.0.1-alpha.11" + } + }, "SQLitePCLRaw.bundle_e_sqlite3": { "type": "Transitive", "resolved": "2.1.4", @@ -443,8 +473,7 @@ "speckle.autofac": { "type": "Project", "dependencies": { - "Microsoft.Extensions.Logging.Abstractions": "[7.0.0, )", - "Speckle.Core": "[2.0.999-local, )" + "Microsoft.Extensions.Logging.Abstractions": "[7.0.0, )" } }, "speckle.connectors.dui": { @@ -453,7 +482,7 @@ "Microsoft.Extensions.Logging.Abstractions": "[7.0.0, )", "Speckle.Autofac": "[2.0.999-local, )", "Speckle.Connectors.Utils": "[2.0.999-local, )", - "Speckle.Core": "[2.0.999-local, )", + "Speckle.Core": "[3.0.1-alpha.11, )", "System.Threading.Tasks.Dataflow": "[6.0.0, )" } }, @@ -469,7 +498,7 @@ "dependencies": { "Serilog.Extensions.Logging": "[7.0.0, )", "Speckle.Autofac": "[2.0.999-local, )", - "Speckle.Core": "[2.0.999-local, )" + "Speckle.Core": "[3.0.1-alpha.11, )" } }, "speckle.converters.autocad2024": { @@ -491,7 +520,7 @@ "type": "Project", "dependencies": { "Speckle.Autofac": "[2.0.999-local, )", - "Speckle.Objects": "[2.0.999-local, )" + "Speckle.Objects": "[3.0.1-alpha.11, )" } }, "speckle.converters.common.dependencyinjection": { @@ -500,33 +529,6 @@ "Speckle.Autofac": "[2.0.999-local, )", "Speckle.Converters.Common": "[2.0.999-local, )" } - }, - "Speckle.Core": { - "type": "Project", - "dependencies": { - "GraphQL.Client": "[6.0.0, )", - "Microsoft.CSharp": "[4.7.0, )", - "Microsoft.Data.Sqlite": "[7.0.5, )", - "Polly": "[7.2.3, )", - "Polly.Contrib.WaitAndRetry": "[1.1.1, )", - "Polly.Extensions.Http": "[3.0.0, )", - "Sentry": "[3.33.0, )", - "Sentry.Serilog": "[3.33.0, )", - "Serilog": "[2.12.0, )", - "Serilog.Enrichers.ClientInfo": "[1.3.0, )", - "Serilog.Exceptions": "[8.4.0, )", - "Serilog.Sinks.Console": "[4.1.0, )", - "Serilog.Sinks.Seq": "[5.2.2, )", - "SerilogTimings": "[3.0.1, )", - "Speckle.Newtonsoft.Json": "[13.0.2, )", - "System.DoubleNumerics": "[3.1.3, )" - } - }, - "Speckle.Objects": { - "type": "Project", - "dependencies": { - "Speckle.Core": "[2.0.999-local, )" - } } } } diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.Revit2023/packages.lock.json b/DUI3-DX/Connectors/Revit/Speckle.Connectors.Revit2023/packages.lock.json index 27da03b1ba..90b4c6879e 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.Revit2023/packages.lock.json +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.Revit2023/packages.lock.json @@ -303,11 +303,42 @@ "Serilog": "2.10.0" } }, + "Speckle.Core": { + "type": "Transitive", + "resolved": "3.0.1-alpha.11", + "contentHash": "Zt2dBJLlfziEACYCHThbhKypSjhoA01rTw9BzNI72c/BDyftXIz70Tetq/8ZMEqQnKqfmRyYADsAdWKxpdV0Hg==", + "dependencies": { + "GraphQL.Client": "6.0.0", + "Microsoft.CSharp": "4.7.0", + "Microsoft.Data.Sqlite": "7.0.5", + "Polly": "7.2.3", + "Polly.Contrib.WaitAndRetry": "1.1.1", + "Polly.Extensions.Http": "3.0.0", + "Sentry": "3.33.0", + "Sentry.Serilog": "3.33.0", + "Serilog": "2.12.0", + "Serilog.Enrichers.ClientInfo": "1.3.0", + "Serilog.Exceptions": "8.4.0", + "Serilog.Sinks.Console": "4.1.0", + "Serilog.Sinks.Seq": "5.2.2", + "SerilogTimings": "3.0.1", + "Speckle.Newtonsoft.Json": "13.0.2", + "System.DoubleNumerics": "3.1.3" + } + }, "Speckle.Newtonsoft.Json": { "type": "Transitive", "resolved": "13.0.2", "contentHash": "g1BejUZwax5PRfL6xHgLEK23sqHWOgOj9hE7RvfRRlN00AGt8GnPYt8HedSK7UB3HiRW8zCA9Pn0iiYxCK24BA==" }, + "Speckle.Objects": { + "type": "Transitive", + "resolved": "3.0.1-alpha.11", + "contentHash": "YR7sei3OQBAi8R/kIu8bEmg5ELDIJK6l5fhOgdnqA9ZvD/fvmRb+09z8lIUTDsgdAdvYU/A/x9VxH9OGPbp9Kw==", + "dependencies": { + "Speckle.Core": "3.0.1-alpha.11" + } + }, "Speckle.Revit.API": { "type": "Transitive", "resolved": "2023.0.0", @@ -488,8 +519,7 @@ "speckle.autofac": { "type": "Project", "dependencies": { - "Microsoft.Extensions.Logging.Abstractions": "[7.0.0, )", - "Speckle.Core": "[2.0.999-local, )" + "Microsoft.Extensions.Logging.Abstractions": "[7.0.0, )" } }, "speckle.connectors.dui": { @@ -498,7 +528,7 @@ "Microsoft.Extensions.Logging.Abstractions": "[7.0.0, )", "Speckle.Autofac": "[2.0.999-local, )", "Speckle.Connectors.Utils": "[2.0.999-local, )", - "Speckle.Core": "[2.0.999-local, )", + "Speckle.Core": "[3.0.1-alpha.11, )", "System.Threading.Tasks.Dataflow": "[6.0.0, )" } }, @@ -507,14 +537,14 @@ "dependencies": { "Serilog.Extensions.Logging": "[7.0.0, )", "Speckle.Autofac": "[2.0.999-local, )", - "Speckle.Core": "[2.0.999-local, )" + "Speckle.Core": "[3.0.1-alpha.11, )" } }, "speckle.converters.common": { "type": "Project", "dependencies": { "Speckle.Autofac": "[2.0.999-local, )", - "Speckle.Objects": "[2.0.999-local, )" + "Speckle.Objects": "[3.0.1-alpha.11, )" } }, "speckle.converters.common.dependencyinjection": { @@ -539,33 +569,6 @@ "Speckle.Converters.Revit2023": "[2.0.999-local, )", "Speckle.Revit2023.Api": "[0.1.1-preview.0.28, )" } - }, - "Speckle.Core": { - "type": "Project", - "dependencies": { - "GraphQL.Client": "[6.0.0, )", - "Microsoft.CSharp": "[4.7.0, )", - "Microsoft.Data.Sqlite": "[7.0.5, )", - "Polly": "[7.2.3, )", - "Polly.Contrib.WaitAndRetry": "[1.1.1, )", - "Polly.Extensions.Http": "[3.0.0, )", - "Sentry": "[3.33.0, )", - "Sentry.Serilog": "[3.33.0, )", - "Serilog": "[2.12.0, )", - "Serilog.Enrichers.ClientInfo": "[1.3.0, )", - "Serilog.Exceptions": "[8.4.0, )", - "Serilog.Sinks.Console": "[4.1.0, )", - "Serilog.Sinks.Seq": "[5.2.2, )", - "SerilogTimings": "[3.0.1, )", - "Speckle.Newtonsoft.Json": "[13.0.2, )", - "System.DoubleNumerics": "[3.1.3, )" - } - }, - "Speckle.Objects": { - "type": "Project", - "dependencies": { - "Speckle.Core": "[2.0.999-local, )" - } } } } diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitExternalApplication.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitExternalApplication.cs index 1ce923f7c3..afe71b6f6d 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitExternalApplication.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitExternalApplication.cs @@ -3,7 +3,6 @@ using System.Reflection; using Speckle.Autofac; using Speckle.Connectors.Utils; -using Speckle.Core.Logging; namespace Speckle.Connectors.Revit.Plugin; diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Plugin/Speckle.Connectors.Rhino7Plugin.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Plugin/Speckle.Connectors.Rhino7Plugin.cs index 16e7297e5a..bd1cff5176 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Plugin/Speckle.Connectors.Rhino7Plugin.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Plugin/Speckle.Connectors.Rhino7Plugin.cs @@ -5,7 +5,6 @@ using Speckle.Connectors.Rhino7.DependencyInjection; using Speckle.Connectors.Rhino7.HostApp; using Speckle.Core.Kits; -using Speckle.Core.Logging; using Speckle.Core.Models.Extensions; namespace Speckle.Connectors.Rhino7.Plugin; diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/packages.lock.json b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/packages.lock.json index 2b6b868bae..2423363e91 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/packages.lock.json +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/packages.lock.json @@ -316,11 +316,42 @@ "Serilog": "2.10.0" } }, + "Speckle.Core": { + "type": "Transitive", + "resolved": "3.0.1-alpha.11", + "contentHash": "Zt2dBJLlfziEACYCHThbhKypSjhoA01rTw9BzNI72c/BDyftXIz70Tetq/8ZMEqQnKqfmRyYADsAdWKxpdV0Hg==", + "dependencies": { + "GraphQL.Client": "6.0.0", + "Microsoft.CSharp": "4.7.0", + "Microsoft.Data.Sqlite": "7.0.5", + "Polly": "7.2.3", + "Polly.Contrib.WaitAndRetry": "1.1.1", + "Polly.Extensions.Http": "3.0.0", + "Sentry": "3.33.0", + "Sentry.Serilog": "3.33.0", + "Serilog": "2.12.0", + "Serilog.Enrichers.ClientInfo": "1.3.0", + "Serilog.Exceptions": "8.4.0", + "Serilog.Sinks.Console": "4.1.0", + "Serilog.Sinks.Seq": "5.2.2", + "SerilogTimings": "3.0.1", + "Speckle.Newtonsoft.Json": "13.0.2", + "System.DoubleNumerics": "3.1.3" + } + }, "Speckle.Newtonsoft.Json": { "type": "Transitive", "resolved": "13.0.2", "contentHash": "g1BejUZwax5PRfL6xHgLEK23sqHWOgOj9hE7RvfRRlN00AGt8GnPYt8HedSK7UB3HiRW8zCA9Pn0iiYxCK24BA==" }, + "Speckle.Objects": { + "type": "Transitive", + "resolved": "3.0.1-alpha.11", + "contentHash": "YR7sei3OQBAi8R/kIu8bEmg5ELDIJK6l5fhOgdnqA9ZvD/fvmRb+09z8lIUTDsgdAdvYU/A/x9VxH9OGPbp9Kw==", + "dependencies": { + "Speckle.Core": "3.0.1-alpha.11" + } + }, "SQLitePCLRaw.bundle_e_sqlite3": { "type": "Transitive", "resolved": "2.1.4", @@ -481,8 +512,7 @@ "speckle.autofac": { "type": "Project", "dependencies": { - "Microsoft.Extensions.Logging.Abstractions": "[7.0.0, )", - "Speckle.Core": "[2.0.999-local, )" + "Microsoft.Extensions.Logging.Abstractions": "[7.0.0, )" } }, "speckle.connectors.dui": { @@ -491,7 +521,7 @@ "Microsoft.Extensions.Logging.Abstractions": "[7.0.0, )", "Speckle.Autofac": "[2.0.999-local, )", "Speckle.Connectors.Utils": "[2.0.999-local, )", - "Speckle.Core": "[2.0.999-local, )", + "Speckle.Core": "[3.0.1-alpha.11, )", "System.Threading.Tasks.Dataflow": "[6.0.0, )" } }, @@ -507,14 +537,14 @@ "dependencies": { "Serilog.Extensions.Logging": "[7.0.0, )", "Speckle.Autofac": "[2.0.999-local, )", - "Speckle.Core": "[2.0.999-local, )" + "Speckle.Core": "[3.0.1-alpha.11, )" } }, "speckle.converters.common": { "type": "Project", "dependencies": { "Speckle.Autofac": "[2.0.999-local, )", - "Speckle.Objects": "[2.0.999-local, )" + "Speckle.Objects": "[3.0.1-alpha.11, )" } }, "speckle.converters.common.dependencyinjection": { @@ -529,33 +559,6 @@ "dependencies": { "Speckle.Rhino7.Interfaces": "[0.1.1-preview.0.28, )" } - }, - "Speckle.Core": { - "type": "Project", - "dependencies": { - "GraphQL.Client": "[6.0.0, )", - "Microsoft.CSharp": "[4.7.0, )", - "Microsoft.Data.Sqlite": "[7.0.5, )", - "Polly": "[7.2.3, )", - "Polly.Contrib.WaitAndRetry": "[1.1.1, )", - "Polly.Extensions.Http": "[3.0.0, )", - "Sentry": "[3.33.0, )", - "Sentry.Serilog": "[3.33.0, )", - "Serilog": "[2.12.0, )", - "Serilog.Enrichers.ClientInfo": "[1.3.0, )", - "Serilog.Exceptions": "[8.4.0, )", - "Serilog.Sinks.Console": "[4.1.0, )", - "Serilog.Sinks.Seq": "[5.2.2, )", - "SerilogTimings": "[3.0.1, )", - "Speckle.Newtonsoft.Json": "[13.0.2, )", - "System.DoubleNumerics": "[3.1.3, )" - } - }, - "Speckle.Objects": { - "type": "Project", - "dependencies": { - "Speckle.Core": "[2.0.999-local, )" - } } } } diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3.DependencyInjection/packages.lock.json b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3.DependencyInjection/packages.lock.json index acad1bb553..2e1dba8069 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3.DependencyInjection/packages.lock.json +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3.DependencyInjection/packages.lock.json @@ -265,11 +265,42 @@ "Serilog": "2.10.0" } }, + "Speckle.Core": { + "type": "Transitive", + "resolved": "3.0.1-alpha.11", + "contentHash": "Zt2dBJLlfziEACYCHThbhKypSjhoA01rTw9BzNI72c/BDyftXIz70Tetq/8ZMEqQnKqfmRyYADsAdWKxpdV0Hg==", + "dependencies": { + "GraphQL.Client": "6.0.0", + "Microsoft.CSharp": "4.7.0", + "Microsoft.Data.Sqlite": "7.0.5", + "Polly": "7.2.3", + "Polly.Contrib.WaitAndRetry": "1.1.1", + "Polly.Extensions.Http": "3.0.0", + "Sentry": "3.33.0", + "Sentry.Serilog": "3.33.0", + "Serilog": "2.12.0", + "Serilog.Enrichers.ClientInfo": "1.3.0", + "Serilog.Exceptions": "8.4.0", + "Serilog.Sinks.Console": "4.1.0", + "Serilog.Sinks.Seq": "5.2.2", + "SerilogTimings": "3.0.1", + "Speckle.Newtonsoft.Json": "13.0.2", + "System.DoubleNumerics": "3.1.3" + } + }, "Speckle.Newtonsoft.Json": { "type": "Transitive", "resolved": "13.0.2", "contentHash": "g1BejUZwax5PRfL6xHgLEK23sqHWOgOj9hE7RvfRRlN00AGt8GnPYt8HedSK7UB3HiRW8zCA9Pn0iiYxCK24BA==" }, + "Speckle.Objects": { + "type": "Transitive", + "resolved": "3.0.1-alpha.11", + "contentHash": "YR7sei3OQBAi8R/kIu8bEmg5ELDIJK6l5fhOgdnqA9ZvD/fvmRb+09z8lIUTDsgdAdvYU/A/x9VxH9OGPbp9Kw==", + "dependencies": { + "Speckle.Core": "3.0.1-alpha.11" + } + }, "SQLitePCLRaw.bundle_e_sqlite3": { "type": "Transitive", "resolved": "2.1.4", @@ -346,8 +377,7 @@ "speckle.autofac": { "type": "Project", "dependencies": { - "Microsoft.Extensions.Logging.Abstractions": "[7.0.0, )", - "Speckle.Core": "[2.0.999-local, )" + "Microsoft.Extensions.Logging.Abstractions": "[7.0.0, )" } }, "speckle.converters.arcgis3": { @@ -361,7 +391,7 @@ "type": "Project", "dependencies": { "Speckle.Autofac": "[2.0.999-local, )", - "Speckle.Objects": "[2.0.999-local, )" + "Speckle.Objects": "[3.0.1-alpha.11, )" } }, "speckle.converters.common.dependencyinjection": { @@ -370,33 +400,6 @@ "Speckle.Autofac": "[2.0.999-local, )", "Speckle.Converters.Common": "[2.0.999-local, )" } - }, - "Speckle.Core": { - "type": "Project", - "dependencies": { - "GraphQL.Client": "[6.0.0, )", - "Microsoft.CSharp": "[4.7.0, )", - "Microsoft.Data.Sqlite": "[7.0.5, )", - "Polly": "[7.2.3, )", - "Polly.Contrib.WaitAndRetry": "[1.1.1, )", - "Polly.Extensions.Http": "[3.0.0, )", - "Sentry": "[3.33.0, )", - "Sentry.Serilog": "[3.33.0, )", - "Serilog": "[2.12.0, )", - "Serilog.Enrichers.ClientInfo": "[1.3.0, )", - "Serilog.Exceptions": "[8.4.0, )", - "Serilog.Sinks.Console": "[4.1.0, )", - "Serilog.Sinks.Seq": "[5.2.2, )", - "SerilogTimings": "[3.0.1, )", - "Speckle.Newtonsoft.Json": "[13.0.2, )", - "System.DoubleNumerics": "[3.1.3, )" - } - }, - "Speckle.Objects": { - "type": "Project", - "dependencies": { - "Speckle.Core": "[2.0.999-local, )" - } } } } diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Speckle.Converters.ArcGIS3.csproj b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Speckle.Converters.ArcGIS3.csproj index 3b07dc8f64..f65ef46df7 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Speckle.Converters.ArcGIS3.csproj +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Speckle.Converters.ArcGIS3.csproj @@ -7,8 +7,7 @@ - + @@ -16,4 +15,4 @@ Include="..\..\..\Sdk\Speckle.Converters.Common\Speckle.Converters.Common.csproj"/> - \ No newline at end of file + diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/packages.lock.json b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/packages.lock.json index 9c5d3fa603..b79f0ae450 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/packages.lock.json +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/packages.lock.json @@ -260,11 +260,42 @@ "Serilog": "2.10.0" } }, + "Speckle.Core": { + "type": "Transitive", + "resolved": "3.0.1-alpha.11", + "contentHash": "Zt2dBJLlfziEACYCHThbhKypSjhoA01rTw9BzNI72c/BDyftXIz70Tetq/8ZMEqQnKqfmRyYADsAdWKxpdV0Hg==", + "dependencies": { + "GraphQL.Client": "6.0.0", + "Microsoft.CSharp": "4.7.0", + "Microsoft.Data.Sqlite": "7.0.5", + "Polly": "7.2.3", + "Polly.Contrib.WaitAndRetry": "1.1.1", + "Polly.Extensions.Http": "3.0.0", + "Sentry": "3.33.0", + "Sentry.Serilog": "3.33.0", + "Serilog": "2.12.0", + "Serilog.Enrichers.ClientInfo": "1.3.0", + "Serilog.Exceptions": "8.4.0", + "Serilog.Sinks.Console": "4.1.0", + "Serilog.Sinks.Seq": "5.2.2", + "SerilogTimings": "3.0.1", + "Speckle.Newtonsoft.Json": "13.0.2", + "System.DoubleNumerics": "3.1.3" + } + }, "Speckle.Newtonsoft.Json": { "type": "Transitive", "resolved": "13.0.2", "contentHash": "g1BejUZwax5PRfL6xHgLEK23sqHWOgOj9hE7RvfRRlN00AGt8GnPYt8HedSK7UB3HiRW8zCA9Pn0iiYxCK24BA==" }, + "Speckle.Objects": { + "type": "Transitive", + "resolved": "3.0.1-alpha.11", + "contentHash": "YR7sei3OQBAi8R/kIu8bEmg5ELDIJK6l5fhOgdnqA9ZvD/fvmRb+09z8lIUTDsgdAdvYU/A/x9VxH9OGPbp9Kw==", + "dependencies": { + "Speckle.Core": "3.0.1-alpha.11" + } + }, "SQLitePCLRaw.bundle_e_sqlite3": { "type": "Transitive", "resolved": "2.1.4", @@ -341,42 +372,14 @@ "speckle.autofac": { "type": "Project", "dependencies": { - "Microsoft.Extensions.Logging.Abstractions": "[7.0.0, )", - "Speckle.Core": "[2.0.999-local, )" + "Microsoft.Extensions.Logging.Abstractions": "[7.0.0, )" } }, "speckle.converters.common": { "type": "Project", "dependencies": { "Speckle.Autofac": "[2.0.999-local, )", - "Speckle.Objects": "[2.0.999-local, )" - } - }, - "Speckle.Core": { - "type": "Project", - "dependencies": { - "GraphQL.Client": "[6.0.0, )", - "Microsoft.CSharp": "[4.7.0, )", - "Microsoft.Data.Sqlite": "[7.0.5, )", - "Polly": "[7.2.3, )", - "Polly.Contrib.WaitAndRetry": "[1.1.1, )", - "Polly.Extensions.Http": "[3.0.0, )", - "Sentry": "[3.33.0, )", - "Sentry.Serilog": "[3.33.0, )", - "Serilog": "[2.12.0, )", - "Serilog.Enrichers.ClientInfo": "[1.3.0, )", - "Serilog.Exceptions": "[8.4.0, )", - "Serilog.Sinks.Console": "[4.1.0, )", - "Serilog.Sinks.Seq": "[5.2.2, )", - "SerilogTimings": "[3.0.1, )", - "Speckle.Newtonsoft.Json": "[13.0.2, )", - "System.DoubleNumerics": "[3.1.3, )" - } - }, - "Speckle.Objects": { - "type": "Project", - "dependencies": { - "Speckle.Core": "[2.0.999-local, )" + "Speckle.Objects": "[3.0.1-alpha.11, )" } } } diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2023.DependencyInjection/packages.lock.json b/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2023.DependencyInjection/packages.lock.json index 57f50cdecb..5d933c5ecf 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2023.DependencyInjection/packages.lock.json +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2023.DependencyInjection/packages.lock.json @@ -208,11 +208,42 @@ "resolved": "2023.0.0", "contentHash": "aNfiNw9zRW8pCl8AAQK7afEJuea4bJ4sFNsGVSDrdq1egaonZrwALU01dSyFNCE8tne86eVjlprpOGG6r0+G/A==" }, + "Speckle.Core": { + "type": "Transitive", + "resolved": "3.0.1-alpha.11", + "contentHash": "Zt2dBJLlfziEACYCHThbhKypSjhoA01rTw9BzNI72c/BDyftXIz70Tetq/8ZMEqQnKqfmRyYADsAdWKxpdV0Hg==", + "dependencies": { + "GraphQL.Client": "6.0.0", + "Microsoft.CSharp": "4.7.0", + "Microsoft.Data.Sqlite": "7.0.5", + "Polly": "7.2.3", + "Polly.Contrib.WaitAndRetry": "1.1.1", + "Polly.Extensions.Http": "3.0.0", + "Sentry": "3.33.0", + "Sentry.Serilog": "3.33.0", + "Serilog": "2.12.0", + "Serilog.Enrichers.ClientInfo": "1.3.0", + "Serilog.Exceptions": "8.4.0", + "Serilog.Sinks.Console": "4.1.0", + "Serilog.Sinks.Seq": "5.2.2", + "SerilogTimings": "3.0.1", + "Speckle.Newtonsoft.Json": "13.0.2", + "System.DoubleNumerics": "3.1.3" + } + }, "Speckle.Newtonsoft.Json": { "type": "Transitive", "resolved": "13.0.2", "contentHash": "g1BejUZwax5PRfL6xHgLEK23sqHWOgOj9hE7RvfRRlN00AGt8GnPYt8HedSK7UB3HiRW8zCA9Pn0iiYxCK24BA==" }, + "Speckle.Objects": { + "type": "Transitive", + "resolved": "3.0.1-alpha.11", + "contentHash": "YR7sei3OQBAi8R/kIu8bEmg5ELDIJK6l5fhOgdnqA9ZvD/fvmRb+09z8lIUTDsgdAdvYU/A/x9VxH9OGPbp9Kw==", + "dependencies": { + "Speckle.Core": "3.0.1-alpha.11" + } + }, "SQLitePCLRaw.bundle_e_sqlite3": { "type": "Transitive", "resolved": "2.1.4", @@ -354,8 +385,7 @@ "speckle.autofac": { "type": "Project", "dependencies": { - "Microsoft.Extensions.Logging.Abstractions": "[7.0.0, )", - "Speckle.Core": "[2.0.999-local, )" + "Microsoft.Extensions.Logging.Abstractions": "[7.0.0, )" } }, "speckle.converters.autocad2023": { @@ -369,7 +399,7 @@ "type": "Project", "dependencies": { "Speckle.Autofac": "[2.0.999-local, )", - "Speckle.Objects": "[2.0.999-local, )" + "Speckle.Objects": "[3.0.1-alpha.11, )" } }, "speckle.converters.common.dependencyinjection": { @@ -378,33 +408,6 @@ "Speckle.Autofac": "[2.0.999-local, )", "Speckle.Converters.Common": "[2.0.999-local, )" } - }, - "Speckle.Core": { - "type": "Project", - "dependencies": { - "GraphQL.Client": "[6.0.0, )", - "Microsoft.CSharp": "[4.7.0, )", - "Microsoft.Data.Sqlite": "[7.0.5, )", - "Polly": "[7.2.3, )", - "Polly.Contrib.WaitAndRetry": "[1.1.1, )", - "Polly.Extensions.Http": "[3.0.0, )", - "Sentry": "[3.33.0, )", - "Sentry.Serilog": "[3.33.0, )", - "Serilog": "[2.12.0, )", - "Serilog.Enrichers.ClientInfo": "[1.3.0, )", - "Serilog.Exceptions": "[8.4.0, )", - "Serilog.Sinks.Console": "[4.1.0, )", - "Serilog.Sinks.Seq": "[5.2.2, )", - "SerilogTimings": "[3.0.1, )", - "Speckle.Newtonsoft.Json": "[13.0.2, )", - "System.DoubleNumerics": "[3.1.3, )" - } - }, - "Speckle.Objects": { - "type": "Project", - "dependencies": { - "Speckle.Core": "[2.0.999-local, )" - } } } } diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2023/packages.lock.json b/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2023/packages.lock.json index 2ea05d5e3f..0b3957751a 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2023/packages.lock.json +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2023/packages.lock.json @@ -200,11 +200,42 @@ "Serilog": "2.10.0" } }, + "Speckle.Core": { + "type": "Transitive", + "resolved": "3.0.1-alpha.11", + "contentHash": "Zt2dBJLlfziEACYCHThbhKypSjhoA01rTw9BzNI72c/BDyftXIz70Tetq/8ZMEqQnKqfmRyYADsAdWKxpdV0Hg==", + "dependencies": { + "GraphQL.Client": "6.0.0", + "Microsoft.CSharp": "4.7.0", + "Microsoft.Data.Sqlite": "7.0.5", + "Polly": "7.2.3", + "Polly.Contrib.WaitAndRetry": "1.1.1", + "Polly.Extensions.Http": "3.0.0", + "Sentry": "3.33.0", + "Sentry.Serilog": "3.33.0", + "Serilog": "2.12.0", + "Serilog.Enrichers.ClientInfo": "1.3.0", + "Serilog.Exceptions": "8.4.0", + "Serilog.Sinks.Console": "4.1.0", + "Serilog.Sinks.Seq": "5.2.2", + "SerilogTimings": "3.0.1", + "Speckle.Newtonsoft.Json": "13.0.2", + "System.DoubleNumerics": "3.1.3" + } + }, "Speckle.Newtonsoft.Json": { "type": "Transitive", "resolved": "13.0.2", "contentHash": "g1BejUZwax5PRfL6xHgLEK23sqHWOgOj9hE7RvfRRlN00AGt8GnPYt8HedSK7UB3HiRW8zCA9Pn0iiYxCK24BA==" }, + "Speckle.Objects": { + "type": "Transitive", + "resolved": "3.0.1-alpha.11", + "contentHash": "YR7sei3OQBAi8R/kIu8bEmg5ELDIJK6l5fhOgdnqA9ZvD/fvmRb+09z8lIUTDsgdAdvYU/A/x9VxH9OGPbp9Kw==", + "dependencies": { + "Speckle.Core": "3.0.1-alpha.11" + } + }, "SQLitePCLRaw.bundle_e_sqlite3": { "type": "Transitive", "resolved": "2.1.4", @@ -346,42 +377,14 @@ "speckle.autofac": { "type": "Project", "dependencies": { - "Microsoft.Extensions.Logging.Abstractions": "[7.0.0, )", - "Speckle.Core": "[2.0.999-local, )" + "Microsoft.Extensions.Logging.Abstractions": "[7.0.0, )" } }, "speckle.converters.common": { "type": "Project", "dependencies": { "Speckle.Autofac": "[2.0.999-local, )", - "Speckle.Objects": "[2.0.999-local, )" - } - }, - "Speckle.Core": { - "type": "Project", - "dependencies": { - "GraphQL.Client": "[6.0.0, )", - "Microsoft.CSharp": "[4.7.0, )", - "Microsoft.Data.Sqlite": "[7.0.5, )", - "Polly": "[7.2.3, )", - "Polly.Contrib.WaitAndRetry": "[1.1.1, )", - "Polly.Extensions.Http": "[3.0.0, )", - "Sentry": "[3.33.0, )", - "Sentry.Serilog": "[3.33.0, )", - "Serilog": "[2.12.0, )", - "Serilog.Enrichers.ClientInfo": "[1.3.0, )", - "Serilog.Exceptions": "[8.4.0, )", - "Serilog.Sinks.Console": "[4.1.0, )", - "Serilog.Sinks.Seq": "[5.2.2, )", - "SerilogTimings": "[3.0.1, )", - "Speckle.Newtonsoft.Json": "[13.0.2, )", - "System.DoubleNumerics": "[3.1.3, )" - } - }, - "Speckle.Objects": { - "type": "Project", - "dependencies": { - "Speckle.Core": "[2.0.999-local, )" + "Speckle.Objects": "[3.0.1-alpha.11, )" } } } diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2024.DependencyInjection/packages.lock.json b/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2024.DependencyInjection/packages.lock.json index 90415ed373..6954909ed9 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2024.DependencyInjection/packages.lock.json +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2024.DependencyInjection/packages.lock.json @@ -208,11 +208,42 @@ "resolved": "2024.0.0", "contentHash": "pZZ5uI+NXhZaQnsqRkgp/rywqBAjDObDJ9XNFGJvemT5k2OthDpHzlK/mKxz8QDCYie7uImQ8dv3uWj2QUFDPw==" }, + "Speckle.Core": { + "type": "Transitive", + "resolved": "3.0.1-alpha.11", + "contentHash": "Zt2dBJLlfziEACYCHThbhKypSjhoA01rTw9BzNI72c/BDyftXIz70Tetq/8ZMEqQnKqfmRyYADsAdWKxpdV0Hg==", + "dependencies": { + "GraphQL.Client": "6.0.0", + "Microsoft.CSharp": "4.7.0", + "Microsoft.Data.Sqlite": "7.0.5", + "Polly": "7.2.3", + "Polly.Contrib.WaitAndRetry": "1.1.1", + "Polly.Extensions.Http": "3.0.0", + "Sentry": "3.33.0", + "Sentry.Serilog": "3.33.0", + "Serilog": "2.12.0", + "Serilog.Enrichers.ClientInfo": "1.3.0", + "Serilog.Exceptions": "8.4.0", + "Serilog.Sinks.Console": "4.1.0", + "Serilog.Sinks.Seq": "5.2.2", + "SerilogTimings": "3.0.1", + "Speckle.Newtonsoft.Json": "13.0.2", + "System.DoubleNumerics": "3.1.3" + } + }, "Speckle.Newtonsoft.Json": { "type": "Transitive", "resolved": "13.0.2", "contentHash": "g1BejUZwax5PRfL6xHgLEK23sqHWOgOj9hE7RvfRRlN00AGt8GnPYt8HedSK7UB3HiRW8zCA9Pn0iiYxCK24BA==" }, + "Speckle.Objects": { + "type": "Transitive", + "resolved": "3.0.1-alpha.11", + "contentHash": "YR7sei3OQBAi8R/kIu8bEmg5ELDIJK6l5fhOgdnqA9ZvD/fvmRb+09z8lIUTDsgdAdvYU/A/x9VxH9OGPbp9Kw==", + "dependencies": { + "Speckle.Core": "3.0.1-alpha.11" + } + }, "SQLitePCLRaw.bundle_e_sqlite3": { "type": "Transitive", "resolved": "2.1.4", @@ -354,8 +385,7 @@ "speckle.autofac": { "type": "Project", "dependencies": { - "Microsoft.Extensions.Logging.Abstractions": "[7.0.0, )", - "Speckle.Core": "[2.0.999-local, )" + "Microsoft.Extensions.Logging.Abstractions": "[7.0.0, )" } }, "speckle.converters.autocad2024": { @@ -369,7 +399,7 @@ "type": "Project", "dependencies": { "Speckle.Autofac": "[2.0.999-local, )", - "Speckle.Objects": "[2.0.999-local, )" + "Speckle.Objects": "[3.0.1-alpha.11, )" } }, "speckle.converters.common.dependencyinjection": { @@ -378,33 +408,6 @@ "Speckle.Autofac": "[2.0.999-local, )", "Speckle.Converters.Common": "[2.0.999-local, )" } - }, - "Speckle.Core": { - "type": "Project", - "dependencies": { - "GraphQL.Client": "[6.0.0, )", - "Microsoft.CSharp": "[4.7.0, )", - "Microsoft.Data.Sqlite": "[7.0.5, )", - "Polly": "[7.2.3, )", - "Polly.Contrib.WaitAndRetry": "[1.1.1, )", - "Polly.Extensions.Http": "[3.0.0, )", - "Sentry": "[3.33.0, )", - "Sentry.Serilog": "[3.33.0, )", - "Serilog": "[2.12.0, )", - "Serilog.Enrichers.ClientInfo": "[1.3.0, )", - "Serilog.Exceptions": "[8.4.0, )", - "Serilog.Sinks.Console": "[4.1.0, )", - "Serilog.Sinks.Seq": "[5.2.2, )", - "SerilogTimings": "[3.0.1, )", - "Speckle.Newtonsoft.Json": "[13.0.2, )", - "System.DoubleNumerics": "[3.1.3, )" - } - }, - "Speckle.Objects": { - "type": "Project", - "dependencies": { - "Speckle.Core": "[2.0.999-local, )" - } } } } diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2024/packages.lock.json b/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2024/packages.lock.json index 7e24ff76cb..bd3d39f474 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2024/packages.lock.json +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2024/packages.lock.json @@ -200,11 +200,42 @@ "Serilog": "2.10.0" } }, + "Speckle.Core": { + "type": "Transitive", + "resolved": "3.0.1-alpha.11", + "contentHash": "Zt2dBJLlfziEACYCHThbhKypSjhoA01rTw9BzNI72c/BDyftXIz70Tetq/8ZMEqQnKqfmRyYADsAdWKxpdV0Hg==", + "dependencies": { + "GraphQL.Client": "6.0.0", + "Microsoft.CSharp": "4.7.0", + "Microsoft.Data.Sqlite": "7.0.5", + "Polly": "7.2.3", + "Polly.Contrib.WaitAndRetry": "1.1.1", + "Polly.Extensions.Http": "3.0.0", + "Sentry": "3.33.0", + "Sentry.Serilog": "3.33.0", + "Serilog": "2.12.0", + "Serilog.Enrichers.ClientInfo": "1.3.0", + "Serilog.Exceptions": "8.4.0", + "Serilog.Sinks.Console": "4.1.0", + "Serilog.Sinks.Seq": "5.2.2", + "SerilogTimings": "3.0.1", + "Speckle.Newtonsoft.Json": "13.0.2", + "System.DoubleNumerics": "3.1.3" + } + }, "Speckle.Newtonsoft.Json": { "type": "Transitive", "resolved": "13.0.2", "contentHash": "g1BejUZwax5PRfL6xHgLEK23sqHWOgOj9hE7RvfRRlN00AGt8GnPYt8HedSK7UB3HiRW8zCA9Pn0iiYxCK24BA==" }, + "Speckle.Objects": { + "type": "Transitive", + "resolved": "3.0.1-alpha.11", + "contentHash": "YR7sei3OQBAi8R/kIu8bEmg5ELDIJK6l5fhOgdnqA9ZvD/fvmRb+09z8lIUTDsgdAdvYU/A/x9VxH9OGPbp9Kw==", + "dependencies": { + "Speckle.Core": "3.0.1-alpha.11" + } + }, "SQLitePCLRaw.bundle_e_sqlite3": { "type": "Transitive", "resolved": "2.1.4", @@ -346,42 +377,14 @@ "speckle.autofac": { "type": "Project", "dependencies": { - "Microsoft.Extensions.Logging.Abstractions": "[7.0.0, )", - "Speckle.Core": "[2.0.999-local, )" + "Microsoft.Extensions.Logging.Abstractions": "[7.0.0, )" } }, "speckle.converters.common": { "type": "Project", "dependencies": { "Speckle.Autofac": "[2.0.999-local, )", - "Speckle.Objects": "[2.0.999-local, )" - } - }, - "Speckle.Core": { - "type": "Project", - "dependencies": { - "GraphQL.Client": "[6.0.0, )", - "Microsoft.CSharp": "[4.7.0, )", - "Microsoft.Data.Sqlite": "[7.0.5, )", - "Polly": "[7.2.3, )", - "Polly.Contrib.WaitAndRetry": "[1.1.1, )", - "Polly.Extensions.Http": "[3.0.0, )", - "Sentry": "[3.33.0, )", - "Sentry.Serilog": "[3.33.0, )", - "Serilog": "[2.12.0, )", - "Serilog.Enrichers.ClientInfo": "[1.3.0, )", - "Serilog.Exceptions": "[8.4.0, )", - "Serilog.Sinks.Console": "[4.1.0, )", - "Serilog.Sinks.Seq": "[5.2.2, )", - "SerilogTimings": "[3.0.1, )", - "Speckle.Newtonsoft.Json": "[13.0.2, )", - "System.DoubleNumerics": "[3.1.3, )" - } - }, - "Speckle.Objects": { - "type": "Project", - "dependencies": { - "Speckle.Core": "[2.0.999-local, )" + "Speckle.Objects": "[3.0.1-alpha.11, )" } } } diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/packages.lock.json b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/packages.lock.json index a1b26cfcdc..6bba1c44ba 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/packages.lock.json +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/packages.lock.json @@ -220,11 +220,42 @@ "Serilog": "2.10.0" } }, + "Speckle.Core": { + "type": "Transitive", + "resolved": "3.0.1-alpha.11", + "contentHash": "Zt2dBJLlfziEACYCHThbhKypSjhoA01rTw9BzNI72c/BDyftXIz70Tetq/8ZMEqQnKqfmRyYADsAdWKxpdV0Hg==", + "dependencies": { + "GraphQL.Client": "6.0.0", + "Microsoft.CSharp": "4.7.0", + "Microsoft.Data.Sqlite": "7.0.5", + "Polly": "7.2.3", + "Polly.Contrib.WaitAndRetry": "1.1.1", + "Polly.Extensions.Http": "3.0.0", + "Sentry": "3.33.0", + "Sentry.Serilog": "3.33.0", + "Serilog": "2.12.0", + "Serilog.Enrichers.ClientInfo": "1.3.0", + "Serilog.Exceptions": "8.4.0", + "Serilog.Sinks.Console": "4.1.0", + "Serilog.Sinks.Seq": "5.2.2", + "SerilogTimings": "3.0.1", + "Speckle.Newtonsoft.Json": "13.0.2", + "System.DoubleNumerics": "3.1.3" + } + }, "Speckle.Newtonsoft.Json": { "type": "Transitive", "resolved": "13.0.2", "contentHash": "g1BejUZwax5PRfL6xHgLEK23sqHWOgOj9hE7RvfRRlN00AGt8GnPYt8HedSK7UB3HiRW8zCA9Pn0iiYxCK24BA==" }, + "Speckle.Objects": { + "type": "Transitive", + "resolved": "3.0.1-alpha.11", + "contentHash": "YR7sei3OQBAi8R/kIu8bEmg5ELDIJK6l5fhOgdnqA9ZvD/fvmRb+09z8lIUTDsgdAdvYU/A/x9VxH9OGPbp9Kw==", + "dependencies": { + "Speckle.Core": "3.0.1-alpha.11" + } + }, "Speckle.Revit.API": { "type": "Transitive", "resolved": "2023.0.0", @@ -381,15 +412,14 @@ "speckle.autofac": { "type": "Project", "dependencies": { - "Microsoft.Extensions.Logging.Abstractions": "[7.0.0, )", - "Speckle.Core": "[2.0.999-local, )" + "Microsoft.Extensions.Logging.Abstractions": "[7.0.0, )" } }, "speckle.converters.common": { "type": "Project", "dependencies": { "Speckle.Autofac": "[2.0.999-local, )", - "Speckle.Objects": "[2.0.999-local, )" + "Speckle.Objects": "[3.0.1-alpha.11, )" } }, "speckle.converters.common.dependencyinjection": { @@ -405,33 +435,6 @@ "Speckle.Converters.Common": "[2.0.999-local, )", "Speckle.Revit2023.Interfaces": "[0.1.1-preview.0.28, )" } - }, - "Speckle.Core": { - "type": "Project", - "dependencies": { - "GraphQL.Client": "[6.0.0, )", - "Microsoft.CSharp": "[4.7.0, )", - "Microsoft.Data.Sqlite": "[7.0.5, )", - "Polly": "[7.2.3, )", - "Polly.Contrib.WaitAndRetry": "[1.1.1, )", - "Polly.Extensions.Http": "[3.0.0, )", - "Sentry": "[3.33.0, )", - "Sentry.Serilog": "[3.33.0, )", - "Serilog": "[2.12.0, )", - "Serilog.Enrichers.ClientInfo": "[1.3.0, )", - "Serilog.Exceptions": "[8.4.0, )", - "Serilog.Sinks.Console": "[4.1.0, )", - "Serilog.Sinks.Seq": "[5.2.2, )", - "SerilogTimings": "[3.0.1, )", - "Speckle.Newtonsoft.Json": "[13.0.2, )", - "System.DoubleNumerics": "[3.1.3, )" - } - }, - "Speckle.Objects": { - "type": "Project", - "dependencies": { - "Speckle.Core": "[2.0.999-local, )" - } } } } diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/XyzConversionToPointTests.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/XyzConversionToPointTests.cs index dee5979761..471ca0be47 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/XyzConversionToPointTests.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/XyzConversionToPointTests.cs @@ -1,9 +1,7 @@ using FluentAssertions; using Moq; using NUnit.Framework; -using Objects; using Speckle.Converters.Common; -using Speckle.Converters.Common.Objects; using Speckle.Converters.RevitShared.Services; using Speckle.Converters.RevitShared.ToSpeckle; using Speckle.Revit.Interfaces; diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/packages.lock.json b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/packages.lock.json index 2d40fe5534..818e420a39 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/packages.lock.json +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/packages.lock.json @@ -319,11 +319,42 @@ "Serilog": "2.10.0" } }, + "Speckle.Core": { + "type": "Transitive", + "resolved": "3.0.1-alpha.11", + "contentHash": "Zt2dBJLlfziEACYCHThbhKypSjhoA01rTw9BzNI72c/BDyftXIz70Tetq/8ZMEqQnKqfmRyYADsAdWKxpdV0Hg==", + "dependencies": { + "GraphQL.Client": "6.0.0", + "Microsoft.CSharp": "4.7.0", + "Microsoft.Data.Sqlite": "7.0.5", + "Polly": "7.2.3", + "Polly.Contrib.WaitAndRetry": "1.1.1", + "Polly.Extensions.Http": "3.0.0", + "Sentry": "3.33.0", + "Sentry.Serilog": "3.33.0", + "Serilog": "2.12.0", + "Serilog.Enrichers.ClientInfo": "1.3.0", + "Serilog.Exceptions": "8.4.0", + "Serilog.Sinks.Console": "4.1.0", + "Serilog.Sinks.Seq": "5.2.2", + "SerilogTimings": "3.0.1", + "Speckle.Newtonsoft.Json": "13.0.2", + "System.DoubleNumerics": "3.1.3" + } + }, "Speckle.Newtonsoft.Json": { "type": "Transitive", "resolved": "13.0.2", "contentHash": "g1BejUZwax5PRfL6xHgLEK23sqHWOgOj9hE7RvfRRlN00AGt8GnPYt8HedSK7UB3HiRW8zCA9Pn0iiYxCK24BA==" }, + "Speckle.Objects": { + "type": "Transitive", + "resolved": "3.0.1-alpha.11", + "contentHash": "YR7sei3OQBAi8R/kIu8bEmg5ELDIJK6l5fhOgdnqA9ZvD/fvmRb+09z8lIUTDsgdAdvYU/A/x9VxH9OGPbp9Kw==", + "dependencies": { + "Speckle.Core": "3.0.1-alpha.11" + } + }, "SQLitePCLRaw.bundle_e_sqlite3": { "type": "Transitive", "resolved": "2.1.4", @@ -474,8 +505,7 @@ "speckle.autofac": { "type": "Project", "dependencies": { - "Microsoft.Extensions.Logging.Abstractions": "[7.0.0, )", - "Speckle.Core": "[2.0.999-local, )" + "Microsoft.Extensions.Logging.Abstractions": "[7.0.0, )" } }, "speckle.connectors.utils": { @@ -483,14 +513,14 @@ "dependencies": { "Serilog.Extensions.Logging": "[7.0.0, )", "Speckle.Autofac": "[2.0.999-local, )", - "Speckle.Core": "[2.0.999-local, )" + "Speckle.Core": "[3.0.1-alpha.11, )" } }, "speckle.converters.common": { "type": "Project", "dependencies": { "Speckle.Autofac": "[2.0.999-local, )", - "Speckle.Objects": "[2.0.999-local, )" + "Speckle.Objects": "[3.0.1-alpha.11, )" } }, "speckle.converters.common.dependencyinjection": { @@ -506,33 +536,6 @@ "Speckle.Converters.Common": "[2.0.999-local, )", "Speckle.Revit2023.Interfaces": "[0.1.1-preview.0.28, )" } - }, - "Speckle.Core": { - "type": "Project", - "dependencies": { - "GraphQL.Client": "[6.0.0, )", - "Microsoft.CSharp": "[4.7.0, )", - "Microsoft.Data.Sqlite": "[7.0.5, )", - "Polly": "[7.2.3, )", - "Polly.Contrib.WaitAndRetry": "[1.1.1, )", - "Polly.Extensions.Http": "[3.0.0, )", - "Sentry": "[3.33.0, )", - "Sentry.Serilog": "[3.33.0, )", - "Serilog": "[2.12.0, )", - "Serilog.Enrichers.ClientInfo": "[1.3.0, )", - "Serilog.Exceptions": "[8.4.0, )", - "Serilog.Sinks.Console": "[4.1.0, )", - "Serilog.Sinks.Seq": "[5.2.2, )", - "SerilogTimings": "[3.0.1, )", - "Speckle.Newtonsoft.Json": "[13.0.2, )", - "System.DoubleNumerics": "[3.1.3, )" - } - }, - "Speckle.Objects": { - "type": "Project", - "dependencies": { - "Speckle.Core": "[2.0.999-local, )" - } } } } diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023/packages.lock.json b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023/packages.lock.json index 7c350fca98..d873133c84 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023/packages.lock.json +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023/packages.lock.json @@ -200,11 +200,42 @@ "Serilog": "2.10.0" } }, + "Speckle.Core": { + "type": "Transitive", + "resolved": "3.0.1-alpha.11", + "contentHash": "Zt2dBJLlfziEACYCHThbhKypSjhoA01rTw9BzNI72c/BDyftXIz70Tetq/8ZMEqQnKqfmRyYADsAdWKxpdV0Hg==", + "dependencies": { + "GraphQL.Client": "6.0.0", + "Microsoft.CSharp": "4.7.0", + "Microsoft.Data.Sqlite": "7.0.5", + "Polly": "7.2.3", + "Polly.Contrib.WaitAndRetry": "1.1.1", + "Polly.Extensions.Http": "3.0.0", + "Sentry": "3.33.0", + "Sentry.Serilog": "3.33.0", + "Serilog": "2.12.0", + "Serilog.Enrichers.ClientInfo": "1.3.0", + "Serilog.Exceptions": "8.4.0", + "Serilog.Sinks.Console": "4.1.0", + "Serilog.Sinks.Seq": "5.2.2", + "SerilogTimings": "3.0.1", + "Speckle.Newtonsoft.Json": "13.0.2", + "System.DoubleNumerics": "3.1.3" + } + }, "Speckle.Newtonsoft.Json": { "type": "Transitive", "resolved": "13.0.2", "contentHash": "g1BejUZwax5PRfL6xHgLEK23sqHWOgOj9hE7RvfRRlN00AGt8GnPYt8HedSK7UB3HiRW8zCA9Pn0iiYxCK24BA==" }, + "Speckle.Objects": { + "type": "Transitive", + "resolved": "3.0.1-alpha.11", + "contentHash": "YR7sei3OQBAi8R/kIu8bEmg5ELDIJK6l5fhOgdnqA9ZvD/fvmRb+09z8lIUTDsgdAdvYU/A/x9VxH9OGPbp9Kw==", + "dependencies": { + "Speckle.Core": "3.0.1-alpha.11" + } + }, "SQLitePCLRaw.bundle_e_sqlite3": { "type": "Transitive", "resolved": "2.1.4", @@ -346,42 +377,14 @@ "speckle.autofac": { "type": "Project", "dependencies": { - "Microsoft.Extensions.Logging.Abstractions": "[7.0.0, )", - "Speckle.Core": "[2.0.999-local, )" + "Microsoft.Extensions.Logging.Abstractions": "[7.0.0, )" } }, "speckle.converters.common": { "type": "Project", "dependencies": { "Speckle.Autofac": "[2.0.999-local, )", - "Speckle.Objects": "[2.0.999-local, )" - } - }, - "Speckle.Core": { - "type": "Project", - "dependencies": { - "GraphQL.Client": "[6.0.0, )", - "Microsoft.CSharp": "[4.7.0, )", - "Microsoft.Data.Sqlite": "[7.0.5, )", - "Polly": "[7.2.3, )", - "Polly.Contrib.WaitAndRetry": "[1.1.1, )", - "Polly.Extensions.Http": "[3.0.0, )", - "Sentry": "[3.33.0, )", - "Sentry.Serilog": "[3.33.0, )", - "Serilog": "[2.12.0, )", - "Serilog.Enrichers.ClientInfo": "[1.3.0, )", - "Serilog.Exceptions": "[8.4.0, )", - "Serilog.Sinks.Console": "[4.1.0, )", - "Serilog.Sinks.Seq": "[5.2.2, )", - "SerilogTimings": "[3.0.1, )", - "Speckle.Newtonsoft.Json": "[13.0.2, )", - "System.DoubleNumerics": "[3.1.3, )" - } - }, - "Speckle.Objects": { - "type": "Project", - "dependencies": { - "Speckle.Core": "[2.0.999-local, )" + "Speckle.Objects": "[3.0.1-alpha.11, )" } } } diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/DisplayValueExtractor.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/DisplayValueExtractor.cs index 9dd899678a..d292b5ed2f 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/DisplayValueExtractor.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/DisplayValueExtractor.cs @@ -1,7 +1,7 @@ using System.Diagnostics.CodeAnalysis; +using Microsoft.Extensions.Logging; using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; -using Speckle.Core.Logging; using Speckle.InterfaceGenerator; using Speckle.Revit.Interfaces; @@ -17,16 +17,19 @@ private readonly ITypedConverter< > _meshByMaterialConverter; private readonly IRevitOptionsFactory _revitOptionsFactory; private readonly IRevitSolidUtils _revitSolidUtils; + private readonly ILogger _logger; public DisplayValueExtractor( ITypedConverter>, List> meshByMaterialConverter, IRevitOptionsFactory revitOptionsFactory, - IRevitSolidUtils revitSolidUtils + IRevitSolidUtils revitSolidUtils, + ILogger logger ) { _meshByMaterialConverter = meshByMaterialConverter; _revitOptionsFactory = revitOptionsFactory; _revitSolidUtils = revitSolidUtils; + _logger = logger; } public List GetDisplayValue( @@ -251,7 +254,7 @@ private void SortGeometry( } // POC: should be hoovered up with the new reporting, logging, exception philosophy - private static void LogInstanceMeshRetrievalWarnings( + private void LogInstanceMeshRetrievalWarnings( IRevitElement element, int topLevelSolidsCount, int topLevelMeshesCount, @@ -263,29 +266,20 @@ bool hasSymbolGeom { if (topLevelSolidsCount > 0) { - SpeckleLog.Logger.Warning( - "Element of type {elementType} with uniqueId {uniqueId} has valid symbol geometry and {numSolids} top level solids. See comment on method SortInstanceGeometry for link to RevitAPI docs that leads us to believe this shouldn't happen", - element.GetType(), - element.UniqueId, - topLevelSolidsCount + _logger.LogWarning( + $"Element of type {element.GetType()} with uniqueId {element.UniqueId} has valid symbol geometry and {topLevelSolidsCount} top level solids. See comment on method SortInstanceGeometry for link to RevitAPI docs that leads us to believe this shouldn't happen" ); } if (topLevelMeshesCount > 0) { - SpeckleLog.Logger.Warning( - "Element of type {elementType} with uniqueId {uniqueId} has valid symbol geometry and {numMeshes} top level meshes. See comment on method SortInstanceGeometry for link to RevitAPI docs that leads us to believe this shouldn't happen", - element.GetType(), - element.UniqueId, - topLevelMeshesCount + _logger.LogWarning( + $"Element of type {element.GetType()} with uniqueId {element.UniqueId} has valid symbol geometry and {topLevelMeshesCount} top level meshes. See comment on method SortInstanceGeometry for link to RevitAPI docs that leads us to believe this shouldn't happen" ); } if (topLevelGeomElementCount > 0) { - SpeckleLog.Logger.Warning( - "Element of type {elementType} with uniqueId {uniqueId} has valid symbol geometry and {numGeomElements} top level geometry elements. See comment on method SortInstanceGeometry for link to RevitAPI docs that leads us to believe this shouldn't happen", - element.GetType(), - element.UniqueId, - topLevelGeomElementCount + _logger.LogWarning( + $"Element of type {element.GetType()} with uniqueId {element.UniqueId} has valid symbol geometry and {topLevelGeomElementCount} top level geometry elements. See comment on method SortInstanceGeometry for link to RevitAPI docs that leads us to believe this shouldn't happen" ); } } diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/ParameterObjectAssigner.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/ParameterObjectAssigner.cs index b7b493d064..b6489d3646 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/ParameterObjectAssigner.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/ParameterObjectAssigner.cs @@ -1,6 +1,6 @@ -using Speckle.Converters.Common; +using Microsoft.Extensions.Logging; +using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; -using Speckle.Core.Logging; using Speckle.Core.Models; using Speckle.InterfaceGenerator; using Speckle.Revit.Interfaces; @@ -15,16 +15,19 @@ public sealed class ParameterObjectAssigner : IParameterObjectAssigner private readonly ITypedConverter _paramConverter; private readonly IParameterValueExtractor _parameterValueExtractor; private readonly IRevitElementIdUtils _revitElementIdUtils; + private readonly ILogger _logger; public ParameterObjectAssigner( ITypedConverter paramConverter, IParameterValueExtractor parameterValueExtractor, - IRevitElementIdUtils revitElementIdUtils + IRevitElementIdUtils revitElementIdUtils, + ILogger logger ) { _paramConverter = paramConverter; _parameterValueExtractor = parameterValueExtractor; _revitElementIdUtils = revitElementIdUtils; + _logger = logger; } public void AssignParametersToBase(IRevitElement target, Base @base) @@ -75,7 +78,7 @@ private void AssignSpeckleParamToBaseObject( // maybe hoover these into one exception or into our reporting strategy catch (SpeckleConversionException ex) { - SpeckleLog.Logger.Warning(ex, "Error thrown when trying to set property named {propName}", kv.Key); + _logger.LogWarning(ex, $"Error thrown when trying to set property named {kv.Key}"); } } } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/packages.lock.json b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/packages.lock.json index 0b5cd3165f..c6f96ec282 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/packages.lock.json +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/packages.lock.json @@ -200,11 +200,42 @@ "Serilog": "2.10.0" } }, + "Speckle.Core": { + "type": "Transitive", + "resolved": "3.0.1-alpha.11", + "contentHash": "Zt2dBJLlfziEACYCHThbhKypSjhoA01rTw9BzNI72c/BDyftXIz70Tetq/8ZMEqQnKqfmRyYADsAdWKxpdV0Hg==", + "dependencies": { + "GraphQL.Client": "6.0.0", + "Microsoft.CSharp": "4.7.0", + "Microsoft.Data.Sqlite": "7.0.5", + "Polly": "7.2.3", + "Polly.Contrib.WaitAndRetry": "1.1.1", + "Polly.Extensions.Http": "3.0.0", + "Sentry": "3.33.0", + "Sentry.Serilog": "3.33.0", + "Serilog": "2.12.0", + "Serilog.Enrichers.ClientInfo": "1.3.0", + "Serilog.Exceptions": "8.4.0", + "Serilog.Sinks.Console": "4.1.0", + "Serilog.Sinks.Seq": "5.2.2", + "SerilogTimings": "3.0.1", + "Speckle.Newtonsoft.Json": "13.0.2", + "System.DoubleNumerics": "3.1.3" + } + }, "Speckle.Newtonsoft.Json": { "type": "Transitive", "resolved": "13.0.2", "contentHash": "g1BejUZwax5PRfL6xHgLEK23sqHWOgOj9hE7RvfRRlN00AGt8GnPYt8HedSK7UB3HiRW8zCA9Pn0iiYxCK24BA==" }, + "Speckle.Objects": { + "type": "Transitive", + "resolved": "3.0.1-alpha.11", + "contentHash": "YR7sei3OQBAi8R/kIu8bEmg5ELDIJK6l5fhOgdnqA9ZvD/fvmRb+09z8lIUTDsgdAdvYU/A/x9VxH9OGPbp9Kw==", + "dependencies": { + "Speckle.Core": "3.0.1-alpha.11" + } + }, "SQLitePCLRaw.bundle_e_sqlite3": { "type": "Transitive", "resolved": "2.1.4", @@ -346,15 +377,14 @@ "speckle.autofac": { "type": "Project", "dependencies": { - "Microsoft.Extensions.Logging.Abstractions": "[7.0.0, )", - "Speckle.Core": "[2.0.999-local, )" + "Microsoft.Extensions.Logging.Abstractions": "[7.0.0, )" } }, "speckle.converters.common": { "type": "Project", "dependencies": { "Speckle.Autofac": "[2.0.999-local, )", - "Speckle.Objects": "[2.0.999-local, )" + "Speckle.Objects": "[3.0.1-alpha.11, )" } }, "speckle.converters.common.dependencyinjection": { @@ -370,33 +400,6 @@ "Speckle.Converters.Common": "[2.0.999-local, )", "Speckle.Rhino7.Interfaces": "[0.1.1-preview.0.28, )" } - }, - "Speckle.Core": { - "type": "Project", - "dependencies": { - "GraphQL.Client": "[6.0.0, )", - "Microsoft.CSharp": "[4.7.0, )", - "Microsoft.Data.Sqlite": "[7.0.5, )", - "Polly": "[7.2.3, )", - "Polly.Contrib.WaitAndRetry": "[1.1.1, )", - "Polly.Extensions.Http": "[3.0.0, )", - "Sentry": "[3.33.0, )", - "Sentry.Serilog": "[3.33.0, )", - "Serilog": "[2.12.0, )", - "Serilog.Enrichers.ClientInfo": "[1.3.0, )", - "Serilog.Exceptions": "[8.4.0, )", - "Serilog.Sinks.Console": "[4.1.0, )", - "Serilog.Sinks.Seq": "[5.2.2, )", - "SerilogTimings": "[3.0.1, )", - "Speckle.Newtonsoft.Json": "[13.0.2, )", - "System.DoubleNumerics": "[3.1.3, )" - } - }, - "Speckle.Objects": { - "type": "Project", - "dependencies": { - "Speckle.Core": "[2.0.999-local, )" - } } } } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/packages.lock.json b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/packages.lock.json index 9a85ec5d77..d748c89324 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/packages.lock.json +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/packages.lock.json @@ -200,11 +200,42 @@ "Serilog": "2.10.0" } }, + "Speckle.Core": { + "type": "Transitive", + "resolved": "3.0.1-alpha.11", + "contentHash": "Zt2dBJLlfziEACYCHThbhKypSjhoA01rTw9BzNI72c/BDyftXIz70Tetq/8ZMEqQnKqfmRyYADsAdWKxpdV0Hg==", + "dependencies": { + "GraphQL.Client": "6.0.0", + "Microsoft.CSharp": "4.7.0", + "Microsoft.Data.Sqlite": "7.0.5", + "Polly": "7.2.3", + "Polly.Contrib.WaitAndRetry": "1.1.1", + "Polly.Extensions.Http": "3.0.0", + "Sentry": "3.33.0", + "Sentry.Serilog": "3.33.0", + "Serilog": "2.12.0", + "Serilog.Enrichers.ClientInfo": "1.3.0", + "Serilog.Exceptions": "8.4.0", + "Serilog.Sinks.Console": "4.1.0", + "Serilog.Sinks.Seq": "5.2.2", + "SerilogTimings": "3.0.1", + "Speckle.Newtonsoft.Json": "13.0.2", + "System.DoubleNumerics": "3.1.3" + } + }, "Speckle.Newtonsoft.Json": { "type": "Transitive", "resolved": "13.0.2", "contentHash": "g1BejUZwax5PRfL6xHgLEK23sqHWOgOj9hE7RvfRRlN00AGt8GnPYt8HedSK7UB3HiRW8zCA9Pn0iiYxCK24BA==" }, + "Speckle.Objects": { + "type": "Transitive", + "resolved": "3.0.1-alpha.11", + "contentHash": "YR7sei3OQBAi8R/kIu8bEmg5ELDIJK6l5fhOgdnqA9ZvD/fvmRb+09z8lIUTDsgdAdvYU/A/x9VxH9OGPbp9Kw==", + "dependencies": { + "Speckle.Core": "3.0.1-alpha.11" + } + }, "SQLitePCLRaw.bundle_e_sqlite3": { "type": "Transitive", "resolved": "2.1.4", @@ -346,42 +377,14 @@ "speckle.autofac": { "type": "Project", "dependencies": { - "Microsoft.Extensions.Logging.Abstractions": "[7.0.0, )", - "Speckle.Core": "[2.0.999-local, )" + "Microsoft.Extensions.Logging.Abstractions": "[7.0.0, )" } }, "speckle.converters.common": { "type": "Project", "dependencies": { "Speckle.Autofac": "[2.0.999-local, )", - "Speckle.Objects": "[2.0.999-local, )" - } - }, - "Speckle.Core": { - "type": "Project", - "dependencies": { - "GraphQL.Client": "[6.0.0, )", - "Microsoft.CSharp": "[4.7.0, )", - "Microsoft.Data.Sqlite": "[7.0.5, )", - "Polly": "[7.2.3, )", - "Polly.Contrib.WaitAndRetry": "[1.1.1, )", - "Polly.Extensions.Http": "[3.0.0, )", - "Sentry": "[3.33.0, )", - "Sentry.Serilog": "[3.33.0, )", - "Serilog": "[2.12.0, )", - "Serilog.Enrichers.ClientInfo": "[1.3.0, )", - "Serilog.Exceptions": "[8.4.0, )", - "Serilog.Sinks.Console": "[4.1.0, )", - "Serilog.Sinks.Seq": "[5.2.2, )", - "SerilogTimings": "[3.0.1, )", - "Speckle.Newtonsoft.Json": "[13.0.2, )", - "System.DoubleNumerics": "[3.1.3, )" - } - }, - "Speckle.Objects": { - "type": "Project", - "dependencies": { - "Speckle.Core": "[2.0.999-local, )" + "Speckle.Objects": "[3.0.1-alpha.11, )" } } } diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI.WebView/packages.lock.json b/DUI3-DX/DUI3/Speckle.Connectors.DUI.WebView/packages.lock.json index 2f687deb37..9b1e4b087b 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI.WebView/packages.lock.json +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI.WebView/packages.lock.json @@ -260,6 +260,29 @@ "Serilog": "2.10.0" } }, + "Speckle.Core": { + "type": "Transitive", + "resolved": "3.0.1-alpha.11", + "contentHash": "Zt2dBJLlfziEACYCHThbhKypSjhoA01rTw9BzNI72c/BDyftXIz70Tetq/8ZMEqQnKqfmRyYADsAdWKxpdV0Hg==", + "dependencies": { + "GraphQL.Client": "6.0.0", + "Microsoft.CSharp": "4.7.0", + "Microsoft.Data.Sqlite": "7.0.5", + "Polly": "7.2.3", + "Polly.Contrib.WaitAndRetry": "1.1.1", + "Polly.Extensions.Http": "3.0.0", + "Sentry": "3.33.0", + "Sentry.Serilog": "3.33.0", + "Serilog": "2.12.0", + "Serilog.Enrichers.ClientInfo": "1.3.0", + "Serilog.Exceptions": "8.4.0", + "Serilog.Sinks.Console": "4.1.0", + "Serilog.Sinks.Seq": "5.2.2", + "SerilogTimings": "3.0.1", + "Speckle.Newtonsoft.Json": "13.0.2", + "System.DoubleNumerics": "3.1.3" + } + }, "Speckle.Newtonsoft.Json": { "type": "Transitive", "resolved": "13.0.2", @@ -420,8 +443,7 @@ "speckle.autofac": { "type": "Project", "dependencies": { - "Microsoft.Extensions.Logging.Abstractions": "[7.0.0, )", - "Speckle.Core": "[2.0.999-local, )" + "Microsoft.Extensions.Logging.Abstractions": "[7.0.0, )" } }, "speckle.connectors.dui": { @@ -430,7 +452,7 @@ "Microsoft.Extensions.Logging.Abstractions": "[7.0.0, )", "Speckle.Autofac": "[2.0.999-local, )", "Speckle.Connectors.Utils": "[2.0.999-local, )", - "Speckle.Core": "[2.0.999-local, )", + "Speckle.Core": "[3.0.1-alpha.11, )", "System.Threading.Tasks.Dataflow": "[6.0.0, )" } }, @@ -439,28 +461,7 @@ "dependencies": { "Serilog.Extensions.Logging": "[7.0.0, )", "Speckle.Autofac": "[2.0.999-local, )", - "Speckle.Core": "[2.0.999-local, )" - } - }, - "Speckle.Core": { - "type": "Project", - "dependencies": { - "GraphQL.Client": "[6.0.0, )", - "Microsoft.CSharp": "[4.7.0, )", - "Microsoft.Data.Sqlite": "[7.0.5, )", - "Polly": "[7.2.3, )", - "Polly.Contrib.WaitAndRetry": "[1.1.1, )", - "Polly.Extensions.Http": "[3.0.0, )", - "Sentry": "[3.33.0, )", - "Sentry.Serilog": "[3.33.0, )", - "Serilog": "[2.12.0, )", - "Serilog.Enrichers.ClientInfo": "[1.3.0, )", - "Serilog.Exceptions": "[8.4.0, )", - "Serilog.Sinks.Console": "[4.1.0, )", - "Serilog.Sinks.Seq": "[5.2.2, )", - "SerilogTimings": "[3.0.1, )", - "Speckle.Newtonsoft.Json": "[13.0.2, )", - "System.DoubleNumerics": "[3.1.3, )" + "Speckle.Core": "[3.0.1-alpha.11, )" } } }, @@ -749,6 +750,29 @@ "Serilog": "2.10.0" } }, + "Speckle.Core": { + "type": "Transitive", + "resolved": "3.0.1-alpha.11", + "contentHash": "Zt2dBJLlfziEACYCHThbhKypSjhoA01rTw9BzNI72c/BDyftXIz70Tetq/8ZMEqQnKqfmRyYADsAdWKxpdV0Hg==", + "dependencies": { + "GraphQL.Client": "6.0.0", + "Microsoft.CSharp": "4.7.0", + "Microsoft.Data.Sqlite": "7.0.5", + "Polly": "7.2.3", + "Polly.Contrib.WaitAndRetry": "1.1.1", + "Polly.Extensions.Http": "3.0.0", + "Sentry": "3.33.0", + "Sentry.Serilog": "3.33.0", + "Serilog": "2.12.0", + "Serilog.Enrichers.ClientInfo": "1.3.0", + "Serilog.Exceptions": "8.4.0", + "Serilog.Sinks.Console": "4.1.0", + "Serilog.Sinks.Seq": "5.2.2", + "SerilogTimings": "3.0.1", + "Speckle.Newtonsoft.Json": "13.0.2", + "System.DoubleNumerics": "3.1.3" + } + }, "Speckle.Newtonsoft.Json": { "type": "Transitive", "resolved": "13.0.2", @@ -830,8 +854,7 @@ "speckle.autofac": { "type": "Project", "dependencies": { - "Microsoft.Extensions.Logging.Abstractions": "[7.0.0, )", - "Speckle.Core": "[2.0.999-local, )" + "Microsoft.Extensions.Logging.Abstractions": "[7.0.0, )" } }, "speckle.connectors.dui": { @@ -840,7 +863,7 @@ "Microsoft.Extensions.Logging.Abstractions": "[7.0.0, )", "Speckle.Autofac": "[2.0.999-local, )", "Speckle.Connectors.Utils": "[2.0.999-local, )", - "Speckle.Core": "[2.0.999-local, )", + "Speckle.Core": "[3.0.1-alpha.11, )", "System.Threading.Tasks.Dataflow": "[6.0.0, )" } }, @@ -849,28 +872,7 @@ "dependencies": { "Serilog.Extensions.Logging": "[7.0.0, )", "Speckle.Autofac": "[2.0.999-local, )", - "Speckle.Core": "[2.0.999-local, )" - } - }, - "Speckle.Core": { - "type": "Project", - "dependencies": { - "GraphQL.Client": "[6.0.0, )", - "Microsoft.CSharp": "[4.7.0, )", - "Microsoft.Data.Sqlite": "[7.0.5, )", - "Polly": "[7.2.3, )", - "Polly.Contrib.WaitAndRetry": "[1.1.1, )", - "Polly.Extensions.Http": "[3.0.0, )", - "Sentry": "[3.33.0, )", - "Sentry.Serilog": "[3.33.0, )", - "Serilog": "[2.12.0, )", - "Serilog.Enrichers.ClientInfo": "[1.3.0, )", - "Serilog.Exceptions": "[8.4.0, )", - "Serilog.Sinks.Console": "[4.1.0, )", - "Serilog.Sinks.Seq": "[5.2.2, )", - "SerilogTimings": "[3.0.1, )", - "Speckle.Newtonsoft.Json": "[13.0.2, )", - "System.DoubleNumerics": "[3.1.3, )" + "Speckle.Core": "[3.0.1-alpha.11, )" } } } diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Speckle.Connectors.DUI.csproj b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Speckle.Connectors.DUI.csproj index e0a93209c5..6d4602c693 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Speckle.Connectors.DUI.csproj +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Speckle.Connectors.DUI.csproj @@ -7,12 +7,11 @@ + - - diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/packages.lock.json b/DUI3-DX/DUI3/Speckle.Connectors.DUI/packages.lock.json index 5f57ceb468..8b1d8f5d09 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/packages.lock.json +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/packages.lock.json @@ -27,6 +27,30 @@ "resolved": "1.14.1", "contentHash": "mOOmFYwad3MIOL14VCjj02LljyF1GNw1wP0YVlxtcPvqdxjGGMNdNJJxHptlry3MOd8b40Flm8RPOM8JOlN2sQ==" }, + "Speckle.Core": { + "type": "Direct", + "requested": "[3.0.1-alpha.11, )", + "resolved": "3.0.1-alpha.11", + "contentHash": "Zt2dBJLlfziEACYCHThbhKypSjhoA01rTw9BzNI72c/BDyftXIz70Tetq/8ZMEqQnKqfmRyYADsAdWKxpdV0Hg==", + "dependencies": { + "GraphQL.Client": "6.0.0", + "Microsoft.CSharp": "4.7.0", + "Microsoft.Data.Sqlite": "7.0.5", + "Polly": "7.2.3", + "Polly.Contrib.WaitAndRetry": "1.1.1", + "Polly.Extensions.Http": "3.0.0", + "Sentry": "3.33.0", + "Sentry.Serilog": "3.33.0", + "Serilog": "2.12.0", + "Serilog.Enrichers.ClientInfo": "1.3.0", + "Serilog.Exceptions": "8.4.0", + "Serilog.Sinks.Console": "4.1.0", + "Serilog.Sinks.Seq": "5.2.2", + "SerilogTimings": "3.0.1", + "Speckle.Newtonsoft.Json": "13.0.2", + "System.DoubleNumerics": "3.1.3" + } + }, "Speckle.InterfaceGenerator": { "type": "Direct", "requested": "[0.9.5, )", @@ -495,8 +519,7 @@ "speckle.autofac": { "type": "Project", "dependencies": { - "Microsoft.Extensions.Logging.Abstractions": "[7.0.0, )", - "Speckle.Core": "[2.0.999-local, )" + "Microsoft.Extensions.Logging.Abstractions": "[7.0.0, )" } }, "speckle.connectors.utils": { @@ -504,28 +527,7 @@ "dependencies": { "Serilog.Extensions.Logging": "[7.0.0, )", "Speckle.Autofac": "[2.0.999-local, )", - "Speckle.Core": "[2.0.999-local, )" - } - }, - "Speckle.Core": { - "type": "Project", - "dependencies": { - "GraphQL.Client": "[6.0.0, )", - "Microsoft.CSharp": "[4.7.0, )", - "Microsoft.Data.Sqlite": "[7.0.5, )", - "Polly": "[7.2.3, )", - "Polly.Contrib.WaitAndRetry": "[1.1.1, )", - "Polly.Extensions.Http": "[3.0.0, )", - "Sentry": "[3.33.0, )", - "Sentry.Serilog": "[3.33.0, )", - "Serilog": "[2.12.0, )", - "Serilog.Enrichers.ClientInfo": "[1.3.0, )", - "Serilog.Exceptions": "[8.4.0, )", - "Serilog.Sinks.Console": "[4.1.0, )", - "Serilog.Sinks.Seq": "[5.2.2, )", - "SerilogTimings": "[3.0.1, )", - "Speckle.Newtonsoft.Json": "[13.0.2, )", - "System.DoubleNumerics": "[3.1.3, )" + "Speckle.Core": "[3.0.1-alpha.11, )" } } } diff --git a/DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/SpeckleContainerBuilder.cs b/DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/SpeckleContainerBuilder.cs index ee71d941e6..363e55cc56 100644 --- a/DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/SpeckleContainerBuilder.cs +++ b/DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/SpeckleContainerBuilder.cs @@ -2,7 +2,6 @@ using Autofac; using Microsoft.Extensions.Logging; using Speckle.Autofac.Files; -using Speckle.Core.Logging; using Module = Autofac.Module; namespace Speckle.Autofac.DependencyInjection; diff --git a/DUI3-DX/Sdk/Speckle.Autofac/ExceptionExtensions.cs b/DUI3-DX/Sdk/Speckle.Autofac/ExceptionExtensions.cs new file mode 100644 index 0000000000..626e9751c1 --- /dev/null +++ b/DUI3-DX/Sdk/Speckle.Autofac/ExceptionExtensions.cs @@ -0,0 +1,45 @@ +using System.Diagnostics.Contracts; + +namespace Speckle.Autofac; + +public static class ExceptionExtensions +{ + /// + /// Helper function for catch blocks to avoid catching and handling/wrapping of some critical exception types that are unlikely to be truly handleable + /// + /// + /// We should aim to always catch specific exception types, and have all functions document the types they may throw. + /// However, this is not always achievable. + /// e.g. when dealing with legacy code, some third-party APIs, or in cases where we want to prevent a host app crash. + /// In these cases, we often want to catch all exceptions, and opt out only of the ones that definitely shouldn't be handled + /// + /// + /// + /// try + /// { + /// SomethingSketchy(); + /// } + /// catch (Exception ex) when (!IsFatal(ex)) + /// { + /// throw new SpeckleException("Failed to do something", ex); + /// } + /// + /// + /// + /// for types that are unlikely to ever be recoverable + [Pure] + public static bool IsFatal(this Exception ex) + { + return ex switch + { + OutOfMemoryException + or ThreadAbortException + or InvalidProgramException + or AccessViolationException + or AppDomainUnloadedException + or BadImageFormatException + => true, + _ => false, + }; + } +} diff --git a/DUI3-DX/Sdk/Speckle.Autofac/Speckle.Autofac.csproj b/DUI3-DX/Sdk/Speckle.Autofac/Speckle.Autofac.csproj index c74a1334ca..e1524d1db6 100644 --- a/DUI3-DX/Sdk/Speckle.Autofac/Speckle.Autofac.csproj +++ b/DUI3-DX/Sdk/Speckle.Autofac/Speckle.Autofac.csproj @@ -10,8 +10,4 @@ - - - - diff --git a/DUI3-DX/Sdk/Speckle.Connectors.Utils/Speckle.Connectors.Utils.csproj b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Speckle.Connectors.Utils.csproj index 55e445a089..e2dfaccf8a 100644 --- a/DUI3-DX/Sdk/Speckle.Connectors.Utils/Speckle.Connectors.Utils.csproj +++ b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Speckle.Connectors.Utils.csproj @@ -5,10 +5,9 @@ + - - diff --git a/DUI3-DX/Sdk/Speckle.Connectors.Utils/packages.lock.json b/DUI3-DX/Sdk/Speckle.Connectors.Utils/packages.lock.json index c23420da56..501db4a15e 100644 --- a/DUI3-DX/Sdk/Speckle.Connectors.Utils/packages.lock.json +++ b/DUI3-DX/Sdk/Speckle.Connectors.Utils/packages.lock.json @@ -27,6 +27,30 @@ "Serilog": "2.12.0" } }, + "Speckle.Core": { + "type": "Direct", + "requested": "[3.0.1-alpha.11, )", + "resolved": "3.0.1-alpha.11", + "contentHash": "Zt2dBJLlfziEACYCHThbhKypSjhoA01rTw9BzNI72c/BDyftXIz70Tetq/8ZMEqQnKqfmRyYADsAdWKxpdV0Hg==", + "dependencies": { + "GraphQL.Client": "6.0.0", + "Microsoft.CSharp": "4.7.0", + "Microsoft.Data.Sqlite": "7.0.5", + "Polly": "7.2.3", + "Polly.Contrib.WaitAndRetry": "1.1.1", + "Polly.Extensions.Http": "3.0.0", + "Sentry": "3.33.0", + "Sentry.Serilog": "3.33.0", + "Serilog": "2.12.0", + "Serilog.Enrichers.ClientInfo": "1.3.0", + "Serilog.Exceptions": "8.4.0", + "Serilog.Sinks.Console": "4.1.0", + "Serilog.Sinks.Seq": "5.2.2", + "SerilogTimings": "3.0.1", + "Speckle.Newtonsoft.Json": "13.0.2", + "System.DoubleNumerics": "3.1.3" + } + }, "Speckle.InterfaceGenerator": { "type": "Direct", "requested": "[0.9.5, )", @@ -489,29 +513,7 @@ "speckle.autofac": { "type": "Project", "dependencies": { - "Microsoft.Extensions.Logging.Abstractions": "[7.0.0, )", - "Speckle.Core": "[2.0.999-local, )" - } - }, - "Speckle.Core": { - "type": "Project", - "dependencies": { - "GraphQL.Client": "[6.0.0, )", - "Microsoft.CSharp": "[4.7.0, )", - "Microsoft.Data.Sqlite": "[7.0.5, )", - "Polly": "[7.2.3, )", - "Polly.Contrib.WaitAndRetry": "[1.1.1, )", - "Polly.Extensions.Http": "[3.0.0, )", - "Sentry": "[3.33.0, )", - "Sentry.Serilog": "[3.33.0, )", - "Serilog": "[2.12.0, )", - "Serilog.Enrichers.ClientInfo": "[1.3.0, )", - "Serilog.Exceptions": "[8.4.0, )", - "Serilog.Sinks.Console": "[4.1.0, )", - "Serilog.Sinks.Seq": "[5.2.2, )", - "SerilogTimings": "[3.0.1, )", - "Speckle.Newtonsoft.Json": "[13.0.2, )", - "System.DoubleNumerics": "[3.1.3, )" + "Microsoft.Extensions.Logging.Abstractions": "[7.0.0, )" } } } diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/packages.lock.json b/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/packages.lock.json index 890db720a4..e34336c3a4 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/packages.lock.json +++ b/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/packages.lock.json @@ -297,11 +297,42 @@ "Serilog": "2.10.0" } }, + "Speckle.Core": { + "type": "Transitive", + "resolved": "3.0.1-alpha.11", + "contentHash": "Zt2dBJLlfziEACYCHThbhKypSjhoA01rTw9BzNI72c/BDyftXIz70Tetq/8ZMEqQnKqfmRyYADsAdWKxpdV0Hg==", + "dependencies": { + "GraphQL.Client": "6.0.0", + "Microsoft.CSharp": "4.7.0", + "Microsoft.Data.Sqlite": "7.0.5", + "Polly": "7.2.3", + "Polly.Contrib.WaitAndRetry": "1.1.1", + "Polly.Extensions.Http": "3.0.0", + "Sentry": "3.33.0", + "Sentry.Serilog": "3.33.0", + "Serilog": "2.12.0", + "Serilog.Enrichers.ClientInfo": "1.3.0", + "Serilog.Exceptions": "8.4.0", + "Serilog.Sinks.Console": "4.1.0", + "Serilog.Sinks.Seq": "5.2.2", + "SerilogTimings": "3.0.1", + "Speckle.Newtonsoft.Json": "13.0.2", + "System.DoubleNumerics": "3.1.3" + } + }, "Speckle.Newtonsoft.Json": { "type": "Transitive", "resolved": "13.0.2", "contentHash": "g1BejUZwax5PRfL6xHgLEK23sqHWOgOj9hE7RvfRRlN00AGt8GnPYt8HedSK7UB3HiRW8zCA9Pn0iiYxCK24BA==" }, + "Speckle.Objects": { + "type": "Transitive", + "resolved": "3.0.1-alpha.11", + "contentHash": "YR7sei3OQBAi8R/kIu8bEmg5ELDIJK6l5fhOgdnqA9ZvD/fvmRb+09z8lIUTDsgdAdvYU/A/x9VxH9OGPbp9Kw==", + "dependencies": { + "Speckle.Core": "3.0.1-alpha.11" + } + }, "SQLitePCLRaw.bundle_e_sqlite3": { "type": "Transitive", "resolved": "2.1.4", @@ -446,42 +477,14 @@ "speckle.autofac": { "type": "Project", "dependencies": { - "Microsoft.Extensions.Logging.Abstractions": "[7.0.0, )", - "Speckle.Core": "[2.0.999-local, )" + "Microsoft.Extensions.Logging.Abstractions": "[7.0.0, )" } }, "speckle.converters.common": { "type": "Project", "dependencies": { "Speckle.Autofac": "[2.0.999-local, )", - "Speckle.Objects": "[2.0.999-local, )" - } - }, - "Speckle.Core": { - "type": "Project", - "dependencies": { - "GraphQL.Client": "[6.0.0, )", - "Microsoft.CSharp": "[4.7.0, )", - "Microsoft.Data.Sqlite": "[7.0.5, )", - "Polly": "[7.2.3, )", - "Polly.Contrib.WaitAndRetry": "[1.1.1, )", - "Polly.Extensions.Http": "[3.0.0, )", - "Sentry": "[3.33.0, )", - "Sentry.Serilog": "[3.33.0, )", - "Serilog": "[2.12.0, )", - "Serilog.Enrichers.ClientInfo": "[1.3.0, )", - "Serilog.Exceptions": "[8.4.0, )", - "Serilog.Sinks.Console": "[4.1.0, )", - "Serilog.Sinks.Seq": "[5.2.2, )", - "SerilogTimings": "[3.0.1, )", - "Speckle.Newtonsoft.Json": "[13.0.2, )", - "System.DoubleNumerics": "[3.1.3, )" - } - }, - "Speckle.Objects": { - "type": "Project", - "dependencies": { - "Speckle.Core": "[2.0.999-local, )" + "Speckle.Objects": "[3.0.1-alpha.11, )" } } } diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common.Tests/packages.lock.json b/DUI3-DX/Sdk/Speckle.Converters.Common.Tests/packages.lock.json index 202e7670ff..7bbbb295a6 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common.Tests/packages.lock.json +++ b/DUI3-DX/Sdk/Speckle.Converters.Common.Tests/packages.lock.json @@ -259,11 +259,42 @@ "Serilog": "2.10.0" } }, + "Speckle.Core": { + "type": "Transitive", + "resolved": "3.0.1-alpha.11", + "contentHash": "Zt2dBJLlfziEACYCHThbhKypSjhoA01rTw9BzNI72c/BDyftXIz70Tetq/8ZMEqQnKqfmRyYADsAdWKxpdV0Hg==", + "dependencies": { + "GraphQL.Client": "6.0.0", + "Microsoft.CSharp": "4.7.0", + "Microsoft.Data.Sqlite": "7.0.5", + "Polly": "7.2.3", + "Polly.Contrib.WaitAndRetry": "1.1.1", + "Polly.Extensions.Http": "3.0.0", + "Sentry": "3.33.0", + "Sentry.Serilog": "3.33.0", + "Serilog": "2.12.0", + "Serilog.Enrichers.ClientInfo": "1.3.0", + "Serilog.Exceptions": "8.4.0", + "Serilog.Sinks.Console": "4.1.0", + "Serilog.Sinks.Seq": "5.2.2", + "SerilogTimings": "3.0.1", + "Speckle.Newtonsoft.Json": "13.0.2", + "System.DoubleNumerics": "3.1.3" + } + }, "Speckle.Newtonsoft.Json": { "type": "Transitive", "resolved": "13.0.2", "contentHash": "g1BejUZwax5PRfL6xHgLEK23sqHWOgOj9hE7RvfRRlN00AGt8GnPYt8HedSK7UB3HiRW8zCA9Pn0iiYxCK24BA==" }, + "Speckle.Objects": { + "type": "Transitive", + "resolved": "3.0.1-alpha.11", + "contentHash": "YR7sei3OQBAi8R/kIu8bEmg5ELDIJK6l5fhOgdnqA9ZvD/fvmRb+09z8lIUTDsgdAdvYU/A/x9VxH9OGPbp9Kw==", + "dependencies": { + "Speckle.Core": "3.0.1-alpha.11" + } + }, "SQLitePCLRaw.bundle_e_sqlite3": { "type": "Transitive", "resolved": "2.1.4", @@ -405,42 +436,14 @@ "speckle.autofac": { "type": "Project", "dependencies": { - "Microsoft.Extensions.Logging.Abstractions": "[7.0.0, )", - "Speckle.Core": "[2.0.999-local, )" + "Microsoft.Extensions.Logging.Abstractions": "[7.0.0, )" } }, "speckle.converters.common": { "type": "Project", "dependencies": { "Speckle.Autofac": "[2.0.999-local, )", - "Speckle.Objects": "[2.0.999-local, )" - } - }, - "Speckle.Core": { - "type": "Project", - "dependencies": { - "GraphQL.Client": "[6.0.0, )", - "Microsoft.CSharp": "[4.7.0, )", - "Microsoft.Data.Sqlite": "[7.0.5, )", - "Polly": "[7.2.3, )", - "Polly.Contrib.WaitAndRetry": "[1.1.1, )", - "Polly.Extensions.Http": "[3.0.0, )", - "Sentry": "[3.33.0, )", - "Sentry.Serilog": "[3.33.0, )", - "Serilog": "[2.12.0, )", - "Serilog.Enrichers.ClientInfo": "[1.3.0, )", - "Serilog.Exceptions": "[8.4.0, )", - "Serilog.Sinks.Console": "[4.1.0, )", - "Serilog.Sinks.Seq": "[5.2.2, )", - "SerilogTimings": "[3.0.1, )", - "Speckle.Newtonsoft.Json": "[13.0.2, )", - "System.DoubleNumerics": "[3.1.3, )" - } - }, - "Speckle.Objects": { - "type": "Project", - "dependencies": { - "Speckle.Core": "[2.0.999-local, )" + "Speckle.Objects": "[3.0.1-alpha.11, )" } } } diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common/Speckle.Converters.Common.csproj b/DUI3-DX/Sdk/Speckle.Converters.Common/Speckle.Converters.Common.csproj index 9c80cf3aba..1211ab6937 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common/Speckle.Converters.Common.csproj +++ b/DUI3-DX/Sdk/Speckle.Converters.Common/Speckle.Converters.Common.csproj @@ -3,10 +3,13 @@ netstandard2.0 + - - + + + + diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common/packages.lock.json b/DUI3-DX/Sdk/Speckle.Converters.Common/packages.lock.json index a9095c6e5b..b29c15e4a5 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common/packages.lock.json +++ b/DUI3-DX/Sdk/Speckle.Converters.Common/packages.lock.json @@ -23,6 +23,15 @@ "resolved": "0.9.5", "contentHash": "oU/L7pN1R7q8KkbrpQ3WJnHirPHqn+9DEA7asOcUiggV5dzVg1A/VYs7GOSusD24njxXh03tE3a2oTLOjt3cVg==" }, + "Speckle.Objects": { + "type": "Direct", + "requested": "[3.0.1-alpha.11, )", + "resolved": "3.0.1-alpha.11", + "contentHash": "YR7sei3OQBAi8R/kIu8bEmg5ELDIJK6l5fhOgdnqA9ZvD/fvmRb+09z8lIUTDsgdAdvYU/A/x9VxH9OGPbp9Kw==", + "dependencies": { + "Speckle.Core": "3.0.1-alpha.11" + } + }, "GraphQL.Client": { "type": "Transitive", "resolved": "6.0.0", @@ -288,6 +297,29 @@ "Serilog": "2.10.0" } }, + "Speckle.Core": { + "type": "Transitive", + "resolved": "3.0.1-alpha.11", + "contentHash": "Zt2dBJLlfziEACYCHThbhKypSjhoA01rTw9BzNI72c/BDyftXIz70Tetq/8ZMEqQnKqfmRyYADsAdWKxpdV0Hg==", + "dependencies": { + "GraphQL.Client": "6.0.0", + "Microsoft.CSharp": "4.7.0", + "Microsoft.Data.Sqlite": "7.0.5", + "Polly": "7.2.3", + "Polly.Contrib.WaitAndRetry": "1.1.1", + "Polly.Extensions.Http": "3.0.0", + "Sentry": "3.33.0", + "Sentry.Serilog": "3.33.0", + "Serilog": "2.12.0", + "Serilog.Enrichers.ClientInfo": "1.3.0", + "Serilog.Exceptions": "8.4.0", + "Serilog.Sinks.Console": "4.1.0", + "Serilog.Sinks.Seq": "5.2.2", + "SerilogTimings": "3.0.1", + "Speckle.Newtonsoft.Json": "13.0.2", + "System.DoubleNumerics": "3.1.3" + } + }, "Speckle.Newtonsoft.Json": { "type": "Transitive", "resolved": "13.0.2", @@ -437,35 +469,7 @@ "speckle.autofac": { "type": "Project", "dependencies": { - "Microsoft.Extensions.Logging.Abstractions": "[7.0.0, )", - "Speckle.Core": "[2.0.999-local, )" - } - }, - "Speckle.Core": { - "type": "Project", - "dependencies": { - "GraphQL.Client": "[6.0.0, )", - "Microsoft.CSharp": "[4.7.0, )", - "Microsoft.Data.Sqlite": "[7.0.5, )", - "Polly": "[7.2.3, )", - "Polly.Contrib.WaitAndRetry": "[1.1.1, )", - "Polly.Extensions.Http": "[3.0.0, )", - "Sentry": "[3.33.0, )", - "Sentry.Serilog": "[3.33.0, )", - "Serilog": "[2.12.0, )", - "Serilog.Enrichers.ClientInfo": "[1.3.0, )", - "Serilog.Exceptions": "[8.4.0, )", - "Serilog.Sinks.Console": "[4.1.0, )", - "Serilog.Sinks.Seq": "[5.2.2, )", - "SerilogTimings": "[3.0.1, )", - "Speckle.Newtonsoft.Json": "[13.0.2, )", - "System.DoubleNumerics": "[3.1.3, )" - } - }, - "Speckle.Objects": { - "type": "Project", - "dependencies": { - "Speckle.Core": "[2.0.999-local, )" + "Microsoft.Extensions.Logging.Abstractions": "[7.0.0, )" } } } From 980b75d7fec831c48b89399223bb224461d425dc Mon Sep 17 00:00:00 2001 From: Adam Hathcock Date: Thu, 27 Jun 2024 12:55:23 +0100 Subject: [PATCH 247/261] Manage V3 versions centrally (exception AutoCAD) (#3536) * initial nuget references * fmt * remove unused revit dependency * Don't use new solution * remove unused file * update core * Manage V3 versions centrally (exception AutoCAD) * fixed up multiple autocad versions * fix up lock files --- All.sln | 9 +- DUI3-DX.slnf | 8 +- .../Speckle.Connectors.ArcGIS3.csproj | 7 +- .../packages.lock.json | 143 +++--- .../Autocad/Directory.Packages.props | 6 + .../Speckle.Connectors.Autocad2023.csproj | 7 +- .../packages.lock.json | 109 +++-- .../Speckle.Connectors.Civil3d2024.csproj | 8 +- .../packages.lock.json | 151 ++++--- .../Speckle.Connectors.Revit2023.csproj | 4 +- .../packages.lock.json | 167 ++++--- .../Speckle.Connectors.Rhino7.csproj | 10 +- .../packages.lock.json | 142 +++--- ...verters.ArcGIS3.DependencyInjection.csproj | 2 +- .../packages.lock.json | 108 +++-- .../Speckle.Converters.ArcGIS3.csproj | 2 +- .../packages.lock.json | 97 +++-- .../Autocad/2023/Directory.Packages.props | 6 + .../AutocadConverterModule.cs | 0 ...ers.Autocad2023.DependencyInjection.csproj | 4 +- .../packages.lock.json | 136 ++++-- .../Speckle.Converters.Autocad2023.csproj | 18 + .../packages.lock.json | 121 +++--- .../Autocad/2024/Directory.Packages.props | 6 + .../AutocadConverterModule.cs | 0 ...ers.Autocad2024.DependencyInjection.csproj | 4 +- .../packages.lock.json | 112 +++-- .../Speckle.Converters.Autocad2024.csproj | 18 + .../packages.lock.json | 70 ++- .../Speckle.Converters.Autocad2023.csproj | 18 - .../Speckle.Converters.Autocad2024.csproj | 18 - ...rters.Revit2023.DependencyInjection.csproj | 2 +- .../packages.lock.json | 112 +++-- .../Speckle.Converters.Revit2023.Tests.csproj | 13 +- .../packages.lock.json | 130 +++--- .../Speckle.Converters.Revit2023.csproj | 2 +- .../packages.lock.json | 101 +++-- ...nverters.Rhino7.DependencyInjection.csproj | 2 +- .../packages.lock.json | 101 +++-- .../Speckle.Converters.Rhino7.csproj | 2 +- .../packages.lock.json | 101 +++-- .../Speckle.Connectors.DUI.WebView.csproj | 4 +- .../packages.lock.json | 180 ++++++-- .../Speckle.Connectors.DUI.csproj | 8 +- .../Speckle.Connectors.DUI/packages.lock.json | 41 +- DUI3-DX/Directory.Build.props | 12 +- DUI3-DX/Directory.Packages.props | 30 ++ .../Speckle.Autofac/Speckle.Autofac.csproj | 6 +- .../Sdk/Speckle.Autofac/packages.lock.json | 411 ++---------------- .../Speckle.Connectors.Utils.csproj | 6 +- .../packages.lock.json | 41 +- ...nverters.Common.DependencyInjection.csproj | 2 +- .../packages.lock.json | 105 +++-- .../Speckle.Converters.Common.Tests.csproj | 13 +- .../packages.lock.json | 107 +++-- .../Speckle.Converters.Common.csproj | 2 +- .../packages.lock.json | 88 ++-- 57 files changed, 1735 insertions(+), 1398 deletions(-) create mode 100644 DUI3-DX/Connectors/Autocad/Directory.Packages.props create mode 100644 DUI3-DX/Converters/Autocad/2023/Directory.Packages.props rename DUI3-DX/Converters/Autocad/{ => 2023}/Speckle.Converters.Autocad2023.DependencyInjection/AutocadConverterModule.cs (100%) rename DUI3-DX/Converters/Autocad/{ => 2023}/Speckle.Converters.Autocad2023.DependencyInjection/Speckle.Converters.Autocad2023.DependencyInjection.csproj (63%) rename DUI3-DX/Converters/Autocad/{Speckle.Converters.Autocad2023 => 2023/Speckle.Converters.Autocad2023.DependencyInjection}/packages.lock.json (89%) create mode 100644 DUI3-DX/Converters/Autocad/2023/Speckle.Converters.Autocad2023/Speckle.Converters.Autocad2023.csproj rename DUI3-DX/Converters/Autocad/{Speckle.Converters.Autocad2023.DependencyInjection => 2023/Speckle.Converters.Autocad2023}/packages.lock.json (93%) create mode 100644 DUI3-DX/Converters/Autocad/2024/Directory.Packages.props rename DUI3-DX/Converters/Autocad/{ => 2024}/Speckle.Converters.Autocad2024.DependencyInjection/AutocadConverterModule.cs (100%) rename DUI3-DX/Converters/Autocad/{ => 2024}/Speckle.Converters.Autocad2024.DependencyInjection/Speckle.Converters.Autocad2024.DependencyInjection.csproj (63%) rename DUI3-DX/Converters/Autocad/{ => 2024}/Speckle.Converters.Autocad2024.DependencyInjection/packages.lock.json (93%) create mode 100644 DUI3-DX/Converters/Autocad/2024/Speckle.Converters.Autocad2024/Speckle.Converters.Autocad2024.csproj rename DUI3-DX/Converters/Autocad/{ => 2024}/Speckle.Converters.Autocad2024/packages.lock.json (87%) delete mode 100644 DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2023/Speckle.Converters.Autocad2023.csproj delete mode 100644 DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2024/Speckle.Converters.Autocad2024.csproj create mode 100644 DUI3-DX/Directory.Packages.props diff --git a/All.sln b/All.sln index 9d104a8de5..59406b4cb8 100644 --- a/All.sln +++ b/All.sln @@ -459,6 +459,7 @@ EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "DUI3-DX", "DUI3-DX", "{9DB74760-01DE-4AC1-A81B-BC7784351D22}" ProjectSection(SolutionItems) = preProject DUI3-DX\Directory.Build.props = DUI3-DX\Directory.Build.props + DUI3-DX\Directory.Packages.props = DUI3-DX\Directory.Packages.props EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Revit", "Revit", "{4838C66E-8677-4FBD-9609-25376042E981}" @@ -523,9 +524,9 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Autocad", "Autocad", "{804E EndProject Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Speckle.Converters.AutocadShared", "DUI3-DX\Converters\Autocad\Speckle.Converters.AutocadShared\Speckle.Converters.AutocadShared.shproj", "{9ADD1B7A-6401-4202-8613-F668E2FBC0A4}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Speckle.Converters.Autocad2023", "DUI3-DX\Converters\Autocad\Speckle.Converters.Autocad2023\Speckle.Converters.Autocad2023.csproj", "{631C295A-7CCF-4B42-8686-7034E31469E7}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Speckle.Converters.Autocad2023", "DUI3-DX\Converters\Autocad\2023\Speckle.Converters.Autocad2023\Speckle.Converters.Autocad2023.csproj", "{631C295A-7CCF-4B42-8686-7034E31469E7}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Speckle.Converters.Autocad2023.DependencyInjection", "DUI3-DX\Converters\Autocad\Speckle.Converters.Autocad2023.DependencyInjection\Speckle.Converters.Autocad2023.DependencyInjection.csproj", "{D940853C-003A-482C-BDB0-665367F274A0}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Speckle.Converters.Autocad2023.DependencyInjection", "DUI3-DX\Converters\Autocad\2023\Speckle.Converters.Autocad2023.DependencyInjection\Speckle.Converters.Autocad2023.DependencyInjection.csproj", "{D940853C-003A-482C-BDB0-665367F274A0}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Speckle.Connectors.DUI.WebView", "DUI3-DX\DUI3\Speckle.Connectors.DUI.WebView\Speckle.Connectors.DUI.WebView.csproj", "{7420652C-3046-4F38-BE64-9B9E69D76FA2}" EndProject @@ -561,9 +562,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Speckle.Converters.Common.T EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Speckle.Connectors.Civil3d2024", "DUI3-DX\Connectors\Autocad\Speckle.Connectors.Civil3d2024\Speckle.Connectors.Civil3d2024.csproj", "{DDBBA313-69A6-40DE-AB3A-79EE5BF32A7E}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Speckle.Converters.Autocad2024", "DUI3-DX\Converters\Autocad\Speckle.Converters.Autocad2024\Speckle.Converters.Autocad2024.csproj", "{C9C28F31-1367-438C-83B0-049C3B3A3E3B}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Speckle.Converters.Autocad2024", "DUI3-DX\Converters\Autocad\2024\Speckle.Converters.Autocad2024\Speckle.Converters.Autocad2024.csproj", "{C9C28F31-1367-438C-83B0-049C3B3A3E3B}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Speckle.Converters.Autocad2024.DependencyInjection", "DUI3-DX\Converters\Autocad\Speckle.Converters.Autocad2024.DependencyInjection\Speckle.Converters.Autocad2024.DependencyInjection.csproj", "{06082BAA-98E8-49B1-9D33-252B126A0561}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Speckle.Converters.Autocad2024.DependencyInjection", "DUI3-DX\Converters\Autocad\2024\Speckle.Converters.Autocad2024.DependencyInjection\Speckle.Converters.Autocad2024.DependencyInjection.csproj", "{06082BAA-98E8-49B1-9D33-252B126A0561}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/DUI3-DX.slnf b/DUI3-DX.slnf index fcbcedfb72..157eec292b 100644 --- a/DUI3-DX.slnf +++ b/DUI3-DX.slnf @@ -12,10 +12,10 @@ "DUI3-DX\\Connectors\\Rhino\\Speckle.Connectors.Rhino7\\Speckle.Connectors.Rhino7.csproj", "DUI3-DX\\Converters\\ArcGIS\\Speckle.Converters.ArcGIS3.DependencyInjection\\Speckle.Converters.ArcGIS3.DependencyInjection.csproj", "DUI3-DX\\Converters\\ArcGIS\\Speckle.Converters.ArcGIS3\\Speckle.Converters.ArcGIS3.csproj", - "DUI3-DX\\Converters\\Autocad\\Speckle.Converters.Autocad2023.DependencyInjection\\Speckle.Converters.Autocad2023.DependencyInjection.csproj", - "DUI3-DX\\Converters\\Autocad\\Speckle.Converters.Autocad2023\\Speckle.Converters.Autocad2023.csproj", - "DUI3-DX\\Converters\\Autocad\\Speckle.Converters.Autocad2024.DependencyInjection\\Speckle.Converters.Autocad2024.DependencyInjection.csproj", - "DUI3-DX\\Converters\\Autocad\\Speckle.Converters.Autocad2024\\Speckle.Converters.Autocad2024.csproj", + "DUI3-DX\\Converters\\Autocad\\2023\\Speckle.Converters.Autocad2023.DependencyInjection\\Speckle.Converters.Autocad2023.DependencyInjection.csproj", + "DUI3-DX\\Converters\\Autocad\\2023\\Speckle.Converters.Autocad2023\\Speckle.Converters.Autocad2023.csproj", + "DUI3-DX\\Converters\\Autocad\\2024\\Speckle.Converters.Autocad2024.DependencyInjection\\Speckle.Converters.Autocad2024.DependencyInjection.csproj", + "DUI3-DX\\Converters\\Autocad\\2024\\Speckle.Converters.Autocad2024\\Speckle.Converters.Autocad2024.csproj", "DUI3-DX\\Converters\\Autocad\\Speckle.Converters.AutocadShared\\Speckle.Converters.AutocadShared.shproj", "DUI3-DX\\Converters\\Revit\\Speckle.Converters.Revit2023.DependencyInjection\\Speckle.Converters.Revit2023.DependencyInjection.csproj", "DUI3-DX\\Converters\\Revit\\Speckle.Converters.Revit2023.Tests\\Speckle.Converters.Revit2023.Tests.csproj", diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Speckle.Connectors.ArcGIS3.csproj b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Speckle.Connectors.ArcGIS3.csproj index 0dc50a19aa..3cbc19ac77 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Speckle.Connectors.ArcGIS3.csproj +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Speckle.Connectors.ArcGIS3.csproj @@ -20,9 +20,8 @@ - - + + @@ -35,4 +34,4 @@ - \ No newline at end of file + diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/packages.lock.json b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/packages.lock.json index 720298148f..e890a9f47a 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/packages.lock.json +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/packages.lock.json @@ -1,5 +1,5 @@ { - "version": 1, + "version": 2, "dependencies": { "net6.0-windows7.0": { "Esri.ArcGISPro.Extensions30": { @@ -14,6 +14,16 @@ "resolved": "7.0.0", "contentHash": "kmn78+LPVMOWeITUjIlfxUPDsI0R6G0RkeAMBmQxAJ7vBJn4q2dTva7pWi65ceN5vPGjJ9q/Uae2WKgvfktJAw==" }, + "Microsoft.SourceLink.GitHub": { + "type": "Direct", + "requested": "[8.0.0, )", + "resolved": "8.0.0", + "contentHash": "G5q7OqtwIyGTkeIOAc3u2ZuV/kicQaec5EaRnc0pIeSnh9LUjj+PYQrJYBURvDt7twGl2PKA7nSN0kz1Zw5bnQ==", + "dependencies": { + "Microsoft.Build.Tasks.Git": "8.0.0", + "Microsoft.SourceLink.Common": "8.0.0" + } + }, "PolySharp": { "type": "Direct", "requested": "[1.14.1, )", @@ -26,11 +36,6 @@ "resolved": "0.9.5", "contentHash": "oU/L7pN1R7q8KkbrpQ3WJnHirPHqn+9DEA7asOcUiggV5dzVg1A/VYs7GOSusD24njxXh03tE3a2oTLOjt3cVg==" }, - "Autofac": { - "type": "Transitive", - "resolved": "5.2.0", - "contentHash": "V8dBH0dsv75uDzl7Sw+HkhKDPUw2eXnlMjcSVMH+tLo2s67MpTKGyDj1pDcpR+IF2u4YRs0s3/x7R88YJzIWvg==" - }, "GraphQL.Client": { "type": "Transitive", "resolved": "6.0.0", @@ -100,6 +105,11 @@ "System.Text.Encodings.Web": "4.5.0" } }, + "Microsoft.Build.Tasks.Git": { + "type": "Transitive", + "resolved": "8.0.0", + "contentHash": "bZKfSIKJRXLTuSzLudMFte/8CempWjVamNUR5eHJizsy+iuOuO/k2gnh7W0dHJmYY0tBf+gUErfluCv5mySAOQ==" + }, "Microsoft.CSharp": { "type": "Transitive", "resolved": "4.7.0", @@ -177,10 +187,10 @@ "System.Buffers": "4.5.0" } }, - "Microsoft.Web.WebView2": { + "Microsoft.SourceLink.Common": { "type": "Transitive", - "resolved": "1.0.1823.32", - "contentHash": "ppRcWBUNggFIqyJp7PfgS4Oe8/7yli/mHcTNDOaqo3ZzJWnv9AOr0WE9ceEP5SPs1M7CQ3QvdGMR7KNz0v09EA==" + "resolved": "8.0.0", + "contentHash": "dk9JPxTCIevS75HyEQ0E4OVAFhB2N+V9ShCXf8Q6FkUQZDkgLI12y679Nym1YqsiSysuQskT7Z+6nUf3yab6Vw==" }, "Polly": { "type": "Transitive", @@ -237,15 +247,6 @@ "System.Reflection.TypeExtensions": "4.7.0" } }, - "Serilog.Extensions.Logging": { - "type": "Transitive", - "resolved": "7.0.0", - "contentHash": "9faU0zNQqU7I6soVhLUMYaGNpgWv6cKlKb2S5AnS8gXxzW/em5Ladm/6FMrWTnX41cdbdGPOWNAo6adi4WaJ6A==", - "dependencies": { - "Microsoft.Extensions.Logging": "7.0.0", - "Serilog": "2.12.0" - } - }, "Serilog.Formatting.Compact": { "type": "Transitive", "resolved": "1.1.0", @@ -297,42 +298,11 @@ "Serilog": "2.10.0" } }, - "Speckle.Core": { - "type": "Transitive", - "resolved": "3.0.1-alpha.11", - "contentHash": "Zt2dBJLlfziEACYCHThbhKypSjhoA01rTw9BzNI72c/BDyftXIz70Tetq/8ZMEqQnKqfmRyYADsAdWKxpdV0Hg==", - "dependencies": { - "GraphQL.Client": "6.0.0", - "Microsoft.CSharp": "4.7.0", - "Microsoft.Data.Sqlite": "7.0.5", - "Polly": "7.2.3", - "Polly.Contrib.WaitAndRetry": "1.1.1", - "Polly.Extensions.Http": "3.0.0", - "Sentry": "3.33.0", - "Sentry.Serilog": "3.33.0", - "Serilog": "2.12.0", - "Serilog.Enrichers.ClientInfo": "1.3.0", - "Serilog.Exceptions": "8.4.0", - "Serilog.Sinks.Console": "4.1.0", - "Serilog.Sinks.Seq": "5.2.2", - "SerilogTimings": "3.0.1", - "Speckle.Newtonsoft.Json": "13.0.2", - "System.DoubleNumerics": "3.1.3" - } - }, "Speckle.Newtonsoft.Json": { "type": "Transitive", "resolved": "13.0.2", "contentHash": "g1BejUZwax5PRfL6xHgLEK23sqHWOgOj9hE7RvfRRlN00AGt8GnPYt8HedSK7UB3HiRW8zCA9Pn0iiYxCK24BA==" }, - "Speckle.Objects": { - "type": "Transitive", - "resolved": "3.0.1-alpha.11", - "contentHash": "YR7sei3OQBAi8R/kIu8bEmg5ELDIJK6l5fhOgdnqA9ZvD/fvmRb+09z8lIUTDsgdAdvYU/A/x9VxH9OGPbp9Kw==", - "dependencies": { - "Speckle.Core": "3.0.1-alpha.11" - } - }, "SQLitePCLRaw.bundle_e_sqlite3": { "type": "Transitive", "resolved": "2.1.4", @@ -401,11 +371,6 @@ "resolved": "4.5.0", "contentHash": "Xg4G4Indi4dqP1iuAiMSwpiWS54ZghzR644OtsRCm/m/lBMG8dUBhLVN7hLm8NNrNTR+iGbshCPTwrvxZPlm4g==" }, - "System.Threading.Tasks.Dataflow": { - "type": "Transitive", - "resolved": "6.0.0", - "contentHash": "+tyDCU3/B1lDdOOAJywHQoFwyXIUghIaP2BxG79uvhfTnO+D9qIgjVlL/JV2NTliYbMHpd6eKDmHp2VHpij7MA==" - }, "speckle.autofac": { "type": "Project", "dependencies": { @@ -465,18 +430,80 @@ "Speckle.Autofac": "[2.0.999-local, )", "Speckle.Converters.Common": "[2.0.999-local, )" } - } - }, - "net6.0-windows7.0/win-x64": { + }, + "Autofac": { + "type": "CentralTransitive", + "requested": "[5.2.0, )", + "resolved": "5.2.0", + "contentHash": "V8dBH0dsv75uDzl7Sw+HkhKDPUw2eXnlMjcSVMH+tLo2s67MpTKGyDj1pDcpR+IF2u4YRs0s3/x7R88YJzIWvg==" + }, "Microsoft.Web.WebView2": { - "type": "Transitive", + "type": "CentralTransitive", + "requested": "[1.0.1823.32, )", "resolved": "1.0.1823.32", "contentHash": "ppRcWBUNggFIqyJp7PfgS4Oe8/7yli/mHcTNDOaqo3ZzJWnv9AOr0WE9ceEP5SPs1M7CQ3QvdGMR7KNz0v09EA==" }, + "Serilog.Extensions.Logging": { + "type": "CentralTransitive", + "requested": "[7.0.0, )", + "resolved": "7.0.0", + "contentHash": "9faU0zNQqU7I6soVhLUMYaGNpgWv6cKlKb2S5AnS8gXxzW/em5Ladm/6FMrWTnX41cdbdGPOWNAo6adi4WaJ6A==", + "dependencies": { + "Microsoft.Extensions.Logging": "7.0.0", + "Serilog": "2.12.0" + } + }, + "Speckle.Core": { + "type": "CentralTransitive", + "requested": "[3.0.1-alpha.11, )", + "resolved": "3.0.1-alpha.11", + "contentHash": "Zt2dBJLlfziEACYCHThbhKypSjhoA01rTw9BzNI72c/BDyftXIz70Tetq/8ZMEqQnKqfmRyYADsAdWKxpdV0Hg==", + "dependencies": { + "GraphQL.Client": "6.0.0", + "Microsoft.CSharp": "4.7.0", + "Microsoft.Data.Sqlite": "7.0.5", + "Polly": "7.2.3", + "Polly.Contrib.WaitAndRetry": "1.1.1", + "Polly.Extensions.Http": "3.0.0", + "Sentry": "3.33.0", + "Sentry.Serilog": "3.33.0", + "Serilog": "2.12.0", + "Serilog.Enrichers.ClientInfo": "1.3.0", + "Serilog.Exceptions": "8.4.0", + "Serilog.Sinks.Console": "4.1.0", + "Serilog.Sinks.Seq": "5.2.2", + "SerilogTimings": "3.0.1", + "Speckle.Newtonsoft.Json": "13.0.2", + "System.DoubleNumerics": "3.1.3" + } + }, + "Speckle.Objects": { + "type": "CentralTransitive", + "requested": "[3.0.1-alpha.11, )", + "resolved": "3.0.1-alpha.11", + "contentHash": "YR7sei3OQBAi8R/kIu8bEmg5ELDIJK6l5fhOgdnqA9ZvD/fvmRb+09z8lIUTDsgdAdvYU/A/x9VxH9OGPbp9Kw==", + "dependencies": { + "Speckle.Core": "3.0.1-alpha.11" + } + }, + "System.Threading.Tasks.Dataflow": { + "type": "CentralTransitive", + "requested": "[6.0.0, )", + "resolved": "6.0.0", + "contentHash": "+tyDCU3/B1lDdOOAJywHQoFwyXIUghIaP2BxG79uvhfTnO+D9qIgjVlL/JV2NTliYbMHpd6eKDmHp2VHpij7MA==" + } + }, + "net6.0-windows7.0/win-x64": { "SQLitePCLRaw.lib.e_sqlite3": { "type": "Transitive", "resolved": "2.1.4", "contentHash": "2C9Q9eX7CPLveJA0rIhf9RXAvu+7nWZu1A2MdG6SD/NOu26TakGgL1nsbc0JAspGijFOo3HoN79xrx8a368fBg==" + }, + "Microsoft.Web.WebView2": { + "type": "CentralTransitive", + "requested": "[1.0.1823.32, )", + "resolved": "1.0.1823.32", + "contentHash": "ppRcWBUNggFIqyJp7PfgS4Oe8/7yli/mHcTNDOaqo3ZzJWnv9AOr0WE9ceEP5SPs1M7CQ3QvdGMR7KNz0v09EA==" } } } diff --git a/DUI3-DX/Connectors/Autocad/Directory.Packages.props b/DUI3-DX/Connectors/Autocad/Directory.Packages.props new file mode 100644 index 0000000000..568fea5f0f --- /dev/null +++ b/DUI3-DX/Connectors/Autocad/Directory.Packages.props @@ -0,0 +1,6 @@ + + + + + + diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.Autocad2023/Speckle.Connectors.Autocad2023.csproj b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.Autocad2023/Speckle.Connectors.Autocad2023.csproj index 238ec770f6..b0f4587d7f 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.Autocad2023/Speckle.Connectors.Autocad2023.csproj +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.Autocad2023/Speckle.Connectors.Autocad2023.csproj @@ -10,7 +10,7 @@ - + @@ -18,8 +18,9 @@ - - + + + diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.Autocad2023/packages.lock.json b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.Autocad2023/packages.lock.json index 662f264cb2..df67e2ad73 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.Autocad2023/packages.lock.json +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.Autocad2023/packages.lock.json @@ -1,5 +1,5 @@ { - "version": 1, + "version": 2, "dependencies": { ".NETFramework,Version=v4.8": { "Microsoft.Extensions.Logging.Abstractions": { @@ -12,6 +12,16 @@ "System.Memory": "4.5.5" } }, + "Microsoft.SourceLink.GitHub": { + "type": "Direct", + "requested": "[8.0.0, )", + "resolved": "8.0.0", + "contentHash": "G5q7OqtwIyGTkeIOAc3u2ZuV/kicQaec5EaRnc0pIeSnh9LUjj+PYQrJYBURvDt7twGl2PKA7nSN0kz1Zw5bnQ==", + "dependencies": { + "Microsoft.Build.Tasks.Git": "8.0.0", + "Microsoft.SourceLink.Common": "8.0.0" + } + }, "PolySharp": { "type": "Direct", "requested": "[1.14.1, )", @@ -30,14 +40,6 @@ "resolved": "0.9.5", "contentHash": "oU/L7pN1R7q8KkbrpQ3WJnHirPHqn+9DEA7asOcUiggV5dzVg1A/VYs7GOSusD24njxXh03tE3a2oTLOjt3cVg==" }, - "Autofac": { - "type": "Transitive", - "resolved": "5.2.0", - "contentHash": "V8dBH0dsv75uDzl7Sw+HkhKDPUw2eXnlMjcSVMH+tLo2s67MpTKGyDj1pDcpR+IF2u4YRs0s3/x7R88YJzIWvg==", - "dependencies": { - "Microsoft.Bcl.AsyncInterfaces": "1.1.0" - } - }, "GraphQL.Client": { "type": "Transitive", "resolved": "6.0.0", @@ -78,6 +80,11 @@ "System.Threading.Tasks.Extensions": "4.5.4" } }, + "Microsoft.Build.Tasks.Git": { + "type": "Transitive", + "resolved": "8.0.0", + "contentHash": "bZKfSIKJRXLTuSzLudMFte/8CempWjVamNUR5eHJizsy+iuOuO/k2gnh7W0dHJmYY0tBf+gUErfluCv5mySAOQ==" + }, "Microsoft.CSharp": { "type": "Transitive", "resolved": "4.7.0", @@ -151,10 +158,10 @@ "System.Runtime.CompilerServices.Unsafe": "6.0.0" } }, - "Microsoft.Web.WebView2": { + "Microsoft.SourceLink.Common": { "type": "Transitive", - "resolved": "1.0.1823.32", - "contentHash": "ppRcWBUNggFIqyJp7PfgS4Oe8/7yli/mHcTNDOaqo3ZzJWnv9AOr0WE9ceEP5SPs1M7CQ3QvdGMR7KNz0v09EA==" + "resolved": "8.0.0", + "contentHash": "dk9JPxTCIevS75HyEQ0E4OVAFhB2N+V9ShCXf8Q6FkUQZDkgLI12y679Nym1YqsiSysuQskT7Z+6nUf3yab6Vw==" }, "Polly": { "type": "Transitive", @@ -214,15 +221,6 @@ "Serilog": "2.8.0" } }, - "Serilog.Extensions.Logging": { - "type": "Transitive", - "resolved": "7.0.0", - "contentHash": "9faU0zNQqU7I6soVhLUMYaGNpgWv6cKlKb2S5AnS8gXxzW/em5Ladm/6FMrWTnX41cdbdGPOWNAo6adi4WaJ6A==", - "dependencies": { - "Microsoft.Extensions.Logging": "7.0.0", - "Serilog": "2.12.0" - } - }, "Serilog.Formatting.Compact": { "type": "Transitive", "resolved": "1.1.0", @@ -444,11 +442,6 @@ "System.ValueTuple": "4.5.0" } }, - "System.Threading.Tasks.Dataflow": { - "type": "Transitive", - "resolved": "6.0.0", - "contentHash": "+tyDCU3/B1lDdOOAJywHQoFwyXIUghIaP2BxG79uvhfTnO+D9qIgjVlL/JV2NTliYbMHpd6eKDmHp2VHpij7MA==" - }, "System.Threading.Tasks.Extensions": { "type": "Transitive", "resolved": "4.5.4", @@ -521,6 +514,70 @@ "Speckle.Autofac": "[2.0.999-local, )", "Speckle.Converters.Common": "[2.0.999-local, )" } + }, + "Autofac": { + "type": "CentralTransitive", + "requested": "[5.2.0, )", + "resolved": "5.2.0", + "contentHash": "V8dBH0dsv75uDzl7Sw+HkhKDPUw2eXnlMjcSVMH+tLo2s67MpTKGyDj1pDcpR+IF2u4YRs0s3/x7R88YJzIWvg==", + "dependencies": { + "Microsoft.Bcl.AsyncInterfaces": "1.1.0" + } + }, + "Microsoft.Web.WebView2": { + "type": "CentralTransitive", + "requested": "[1.0.1823.32, )", + "resolved": "1.0.1823.32", + "contentHash": "ppRcWBUNggFIqyJp7PfgS4Oe8/7yli/mHcTNDOaqo3ZzJWnv9AOr0WE9ceEP5SPs1M7CQ3QvdGMR7KNz0v09EA==" + }, + "Serilog.Extensions.Logging": { + "type": "CentralTransitive", + "requested": "[7.0.0, )", + "resolved": "7.0.0", + "contentHash": "9faU0zNQqU7I6soVhLUMYaGNpgWv6cKlKb2S5AnS8gXxzW/em5Ladm/6FMrWTnX41cdbdGPOWNAo6adi4WaJ6A==", + "dependencies": { + "Microsoft.Extensions.Logging": "7.0.0", + "Serilog": "2.12.0" + } + }, + "Speckle.Core": { + "type": "CentralTransitive", + "requested": "[3.0.1-alpha.11, )", + "resolved": "3.0.1-alpha.11", + "contentHash": "Zt2dBJLlfziEACYCHThbhKypSjhoA01rTw9BzNI72c/BDyftXIz70Tetq/8ZMEqQnKqfmRyYADsAdWKxpdV0Hg==", + "dependencies": { + "GraphQL.Client": "6.0.0", + "Microsoft.CSharp": "4.7.0", + "Microsoft.Data.Sqlite": "7.0.5", + "Polly": "7.2.3", + "Polly.Contrib.WaitAndRetry": "1.1.1", + "Polly.Extensions.Http": "3.0.0", + "Sentry": "3.33.0", + "Sentry.Serilog": "3.33.0", + "Serilog": "2.12.0", + "Serilog.Enrichers.ClientInfo": "1.3.0", + "Serilog.Exceptions": "8.4.0", + "Serilog.Sinks.Console": "4.1.0", + "Serilog.Sinks.Seq": "5.2.2", + "SerilogTimings": "3.0.1", + "Speckle.Newtonsoft.Json": "13.0.2", + "System.DoubleNumerics": "3.1.3" + } + }, + "Speckle.Objects": { + "type": "CentralTransitive", + "requested": "[3.0.1-alpha.11, )", + "resolved": "3.0.1-alpha.11", + "contentHash": "YR7sei3OQBAi8R/kIu8bEmg5ELDIJK6l5fhOgdnqA9ZvD/fvmRb+09z8lIUTDsgdAdvYU/A/x9VxH9OGPbp9Kw==", + "dependencies": { + "Speckle.Core": "3.0.1-alpha.11" + } + }, + "System.Threading.Tasks.Dataflow": { + "type": "CentralTransitive", + "requested": "[6.0.0, )", + "resolved": "6.0.0", + "contentHash": "+tyDCU3/B1lDdOOAJywHQoFwyXIUghIaP2BxG79uvhfTnO+D9qIgjVlL/JV2NTliYbMHpd6eKDmHp2VHpij7MA==" } } } diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.Civil3d2024/Speckle.Connectors.Civil3d2024.csproj b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.Civil3d2024/Speckle.Connectors.Civil3d2024.csproj index a780058c4e..b04e1c73e0 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.Civil3d2024/Speckle.Connectors.Civil3d2024.csproj +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.Civil3d2024/Speckle.Connectors.Civil3d2024.csproj @@ -1,4 +1,4 @@ - + Speckle.Connectors.Civil3d net48 @@ -10,7 +10,7 @@ - + @@ -18,8 +18,8 @@ - - + + diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.Civil3d2024/packages.lock.json b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.Civil3d2024/packages.lock.json index a56054ea66..b6c4d13a4c 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.Civil3d2024/packages.lock.json +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.Civil3d2024/packages.lock.json @@ -1,5 +1,5 @@ { - "version": 1, + "version": 2, "dependencies": { ".NETFramework,Version=v4.8": { "Microsoft.Extensions.Logging.Abstractions": { @@ -12,6 +12,16 @@ "System.Memory": "4.5.5" } }, + "Microsoft.SourceLink.GitHub": { + "type": "Direct", + "requested": "[8.0.0, )", + "resolved": "8.0.0", + "contentHash": "G5q7OqtwIyGTkeIOAc3u2ZuV/kicQaec5EaRnc0pIeSnh9LUjj+PYQrJYBURvDt7twGl2PKA7nSN0kz1Zw5bnQ==", + "dependencies": { + "Microsoft.Build.Tasks.Git": "8.0.0", + "Microsoft.SourceLink.Common": "8.0.0" + } + }, "PolySharp": { "type": "Direct", "requested": "[1.14.1, )", @@ -33,14 +43,6 @@ "resolved": "0.9.5", "contentHash": "oU/L7pN1R7q8KkbrpQ3WJnHirPHqn+9DEA7asOcUiggV5dzVg1A/VYs7GOSusD24njxXh03tE3a2oTLOjt3cVg==" }, - "Autofac": { - "type": "Transitive", - "resolved": "5.2.0", - "contentHash": "V8dBH0dsv75uDzl7Sw+HkhKDPUw2eXnlMjcSVMH+tLo2s67MpTKGyDj1pDcpR+IF2u4YRs0s3/x7R88YJzIWvg==", - "dependencies": { - "Microsoft.Bcl.AsyncInterfaces": "1.1.0" - } - }, "GraphQL.Client": { "type": "Transitive", "resolved": "6.0.0", @@ -81,6 +83,11 @@ "System.Threading.Tasks.Extensions": "4.5.4" } }, + "Microsoft.Build.Tasks.Git": { + "type": "Transitive", + "resolved": "8.0.0", + "contentHash": "bZKfSIKJRXLTuSzLudMFte/8CempWjVamNUR5eHJizsy+iuOuO/k2gnh7W0dHJmYY0tBf+gUErfluCv5mySAOQ==" + }, "Microsoft.CSharp": { "type": "Transitive", "resolved": "4.7.0", @@ -154,10 +161,10 @@ "System.Runtime.CompilerServices.Unsafe": "6.0.0" } }, - "Microsoft.Web.WebView2": { + "Microsoft.SourceLink.Common": { "type": "Transitive", - "resolved": "1.0.1823.32", - "contentHash": "ppRcWBUNggFIqyJp7PfgS4Oe8/7yli/mHcTNDOaqo3ZzJWnv9AOr0WE9ceEP5SPs1M7CQ3QvdGMR7KNz0v09EA==" + "resolved": "8.0.0", + "contentHash": "dk9JPxTCIevS75HyEQ0E4OVAFhB2N+V9ShCXf8Q6FkUQZDkgLI12y679Nym1YqsiSysuQskT7Z+6nUf3yab6Vw==" }, "Polly": { "type": "Transitive", @@ -217,15 +224,6 @@ "Serilog": "2.8.0" } }, - "Serilog.Extensions.Logging": { - "type": "Transitive", - "resolved": "7.0.0", - "contentHash": "9faU0zNQqU7I6soVhLUMYaGNpgWv6cKlKb2S5AnS8gXxzW/em5Ladm/6FMrWTnX41cdbdGPOWNAo6adi4WaJ6A==", - "dependencies": { - "Microsoft.Extensions.Logging": "7.0.0", - "Serilog": "2.12.0" - } - }, "Serilog.Formatting.Compact": { "type": "Transitive", "resolved": "1.1.0", @@ -277,47 +275,11 @@ "Serilog": "2.10.0" } }, - "Speckle.AutoCAD.API": { - "type": "Transitive", - "resolved": "2024.0.0", - "contentHash": "pZZ5uI+NXhZaQnsqRkgp/rywqBAjDObDJ9XNFGJvemT5k2OthDpHzlK/mKxz8QDCYie7uImQ8dv3uWj2QUFDPw==" - }, - "Speckle.Core": { - "type": "Transitive", - "resolved": "3.0.1-alpha.11", - "contentHash": "Zt2dBJLlfziEACYCHThbhKypSjhoA01rTw9BzNI72c/BDyftXIz70Tetq/8ZMEqQnKqfmRyYADsAdWKxpdV0Hg==", - "dependencies": { - "GraphQL.Client": "6.0.0", - "Microsoft.CSharp": "4.7.0", - "Microsoft.Data.Sqlite": "7.0.5", - "Polly": "7.2.3", - "Polly.Contrib.WaitAndRetry": "1.1.1", - "Polly.Extensions.Http": "3.0.0", - "Sentry": "3.33.0", - "Sentry.Serilog": "3.33.0", - "Serilog": "2.12.0", - "Serilog.Enrichers.ClientInfo": "1.3.0", - "Serilog.Exceptions": "8.4.0", - "Serilog.Sinks.Console": "4.1.0", - "Serilog.Sinks.Seq": "5.2.2", - "SerilogTimings": "3.0.1", - "Speckle.Newtonsoft.Json": "13.0.2", - "System.DoubleNumerics": "3.1.3" - } - }, "Speckle.Newtonsoft.Json": { "type": "Transitive", "resolved": "13.0.2", "contentHash": "g1BejUZwax5PRfL6xHgLEK23sqHWOgOj9hE7RvfRRlN00AGt8GnPYt8HedSK7UB3HiRW8zCA9Pn0iiYxCK24BA==" }, - "Speckle.Objects": { - "type": "Transitive", - "resolved": "3.0.1-alpha.11", - "contentHash": "YR7sei3OQBAi8R/kIu8bEmg5ELDIJK6l5fhOgdnqA9ZvD/fvmRb+09z8lIUTDsgdAdvYU/A/x9VxH9OGPbp9Kw==", - "dependencies": { - "Speckle.Core": "3.0.1-alpha.11" - } - }, "SQLitePCLRaw.bundle_e_sqlite3": { "type": "Transitive", "resolved": "2.1.4", @@ -452,11 +414,6 @@ "System.ValueTuple": "4.5.0" } }, - "System.Threading.Tasks.Dataflow": { - "type": "Transitive", - "resolved": "6.0.0", - "contentHash": "+tyDCU3/B1lDdOOAJywHQoFwyXIUghIaP2BxG79uvhfTnO+D9qIgjVlL/JV2NTliYbMHpd6eKDmHp2VHpij7MA==" - }, "System.Threading.Tasks.Extensions": { "type": "Transitive", "resolved": "4.5.4", @@ -529,6 +486,76 @@ "Speckle.Autofac": "[2.0.999-local, )", "Speckle.Converters.Common": "[2.0.999-local, )" } + }, + "Autofac": { + "type": "CentralTransitive", + "requested": "[5.2.0, )", + "resolved": "5.2.0", + "contentHash": "V8dBH0dsv75uDzl7Sw+HkhKDPUw2eXnlMjcSVMH+tLo2s67MpTKGyDj1pDcpR+IF2u4YRs0s3/x7R88YJzIWvg==", + "dependencies": { + "Microsoft.Bcl.AsyncInterfaces": "1.1.0" + } + }, + "Microsoft.Web.WebView2": { + "type": "CentralTransitive", + "requested": "[1.0.1823.32, )", + "resolved": "1.0.1823.32", + "contentHash": "ppRcWBUNggFIqyJp7PfgS4Oe8/7yli/mHcTNDOaqo3ZzJWnv9AOr0WE9ceEP5SPs1M7CQ3QvdGMR7KNz0v09EA==" + }, + "Serilog.Extensions.Logging": { + "type": "CentralTransitive", + "requested": "[7.0.0, )", + "resolved": "7.0.0", + "contentHash": "9faU0zNQqU7I6soVhLUMYaGNpgWv6cKlKb2S5AnS8gXxzW/em5Ladm/6FMrWTnX41cdbdGPOWNAo6adi4WaJ6A==", + "dependencies": { + "Microsoft.Extensions.Logging": "7.0.0", + "Serilog": "2.12.0" + } + }, + "Speckle.AutoCAD.API": { + "type": "CentralTransitive", + "requested": "[2023.0.0, )", + "resolved": "2024.0.0", + "contentHash": "pZZ5uI+NXhZaQnsqRkgp/rywqBAjDObDJ9XNFGJvemT5k2OthDpHzlK/mKxz8QDCYie7uImQ8dv3uWj2QUFDPw==" + }, + "Speckle.Core": { + "type": "CentralTransitive", + "requested": "[3.0.1-alpha.11, )", + "resolved": "3.0.1-alpha.11", + "contentHash": "Zt2dBJLlfziEACYCHThbhKypSjhoA01rTw9BzNI72c/BDyftXIz70Tetq/8ZMEqQnKqfmRyYADsAdWKxpdV0Hg==", + "dependencies": { + "GraphQL.Client": "6.0.0", + "Microsoft.CSharp": "4.7.0", + "Microsoft.Data.Sqlite": "7.0.5", + "Polly": "7.2.3", + "Polly.Contrib.WaitAndRetry": "1.1.1", + "Polly.Extensions.Http": "3.0.0", + "Sentry": "3.33.0", + "Sentry.Serilog": "3.33.0", + "Serilog": "2.12.0", + "Serilog.Enrichers.ClientInfo": "1.3.0", + "Serilog.Exceptions": "8.4.0", + "Serilog.Sinks.Console": "4.1.0", + "Serilog.Sinks.Seq": "5.2.2", + "SerilogTimings": "3.0.1", + "Speckle.Newtonsoft.Json": "13.0.2", + "System.DoubleNumerics": "3.1.3" + } + }, + "Speckle.Objects": { + "type": "CentralTransitive", + "requested": "[3.0.1-alpha.11, )", + "resolved": "3.0.1-alpha.11", + "contentHash": "YR7sei3OQBAi8R/kIu8bEmg5ELDIJK6l5fhOgdnqA9ZvD/fvmRb+09z8lIUTDsgdAdvYU/A/x9VxH9OGPbp9Kw==", + "dependencies": { + "Speckle.Core": "3.0.1-alpha.11" + } + }, + "System.Threading.Tasks.Dataflow": { + "type": "CentralTransitive", + "requested": "[6.0.0, )", + "resolved": "6.0.0", + "contentHash": "+tyDCU3/B1lDdOOAJywHQoFwyXIUghIaP2BxG79uvhfTnO+D9qIgjVlL/JV2NTliYbMHpd6eKDmHp2VHpij7MA==" } } } diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.Revit2023/Speckle.Connectors.Revit2023.csproj b/DUI3-DX/Connectors/Revit/Speckle.Connectors.Revit2023/Speckle.Connectors.Revit2023.csproj index 893a9a4c12..1ce038c81e 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.Revit2023/Speckle.Connectors.Revit2023.csproj +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.Revit2023/Speckle.Connectors.Revit2023.csproj @@ -30,8 +30,8 @@ - - + + diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.Revit2023/packages.lock.json b/DUI3-DX/Connectors/Revit/Speckle.Connectors.Revit2023/packages.lock.json index 90b4c6879e..99af7ef77d 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.Revit2023/packages.lock.json +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.Revit2023/packages.lock.json @@ -1,5 +1,5 @@ { - "version": 1, + "version": 2, "dependencies": { ".NETFramework,Version=v4.8": { "CefSharp.Wpf": { @@ -11,6 +11,16 @@ "CefSharp.Common": "[92.0.260]" } }, + "Microsoft.SourceLink.GitHub": { + "type": "Direct", + "requested": "[8.0.0, )", + "resolved": "8.0.0", + "contentHash": "G5q7OqtwIyGTkeIOAc3u2ZuV/kicQaec5EaRnc0pIeSnh9LUjj+PYQrJYBURvDt7twGl2PKA7nSN0kz1Zw5bnQ==", + "dependencies": { + "Microsoft.Build.Tasks.Git": "8.0.0", + "Microsoft.SourceLink.Common": "8.0.0" + } + }, "PolySharp": { "type": "Direct", "requested": "[1.14.1, )", @@ -103,6 +113,11 @@ "System.Threading.Tasks.Extensions": "4.5.4" } }, + "Microsoft.Build.Tasks.Git": { + "type": "Transitive", + "resolved": "8.0.0", + "contentHash": "bZKfSIKJRXLTuSzLudMFte/8CempWjVamNUR5eHJizsy+iuOuO/k2gnh7W0dHJmYY0tBf+gUErfluCv5mySAOQ==" + }, "Microsoft.CSharp": { "type": "Transitive", "resolved": "4.7.0", @@ -158,15 +173,6 @@ "System.ValueTuple": "4.5.0" } }, - "Microsoft.Extensions.Logging.Abstractions": { - "type": "Transitive", - "resolved": "7.0.0", - "contentHash": "kmn78+LPVMOWeITUjIlfxUPDsI0R6G0RkeAMBmQxAJ7vBJn4q2dTva7pWi65ceN5vPGjJ9q/Uae2WKgvfktJAw==", - "dependencies": { - "System.Buffers": "4.5.1", - "System.Memory": "4.5.5" - } - }, "Microsoft.Extensions.Options": { "type": "Transitive", "resolved": "7.0.0", @@ -185,6 +191,11 @@ "System.Runtime.CompilerServices.Unsafe": "6.0.0" } }, + "Microsoft.SourceLink.Common": { + "type": "Transitive", + "resolved": "8.0.0", + "contentHash": "dk9JPxTCIevS75HyEQ0E4OVAFhB2N+V9ShCXf8Q6FkUQZDkgLI12y679Nym1YqsiSysuQskT7Z+6nUf3yab6Vw==" + }, "Polly": { "type": "Transitive", "resolved": "7.2.3", @@ -243,15 +254,6 @@ "Serilog": "2.8.0" } }, - "Serilog.Extensions.Logging": { - "type": "Transitive", - "resolved": "7.0.0", - "contentHash": "9faU0zNQqU7I6soVhLUMYaGNpgWv6cKlKb2S5AnS8gXxzW/em5Ladm/6FMrWTnX41cdbdGPOWNAo6adi4WaJ6A==", - "dependencies": { - "Microsoft.Extensions.Logging": "7.0.0", - "Serilog": "2.12.0" - } - }, "Serilog.Formatting.Compact": { "type": "Transitive", "resolved": "1.1.0", @@ -303,62 +305,16 @@ "Serilog": "2.10.0" } }, - "Speckle.Core": { - "type": "Transitive", - "resolved": "3.0.1-alpha.11", - "contentHash": "Zt2dBJLlfziEACYCHThbhKypSjhoA01rTw9BzNI72c/BDyftXIz70Tetq/8ZMEqQnKqfmRyYADsAdWKxpdV0Hg==", - "dependencies": { - "GraphQL.Client": "6.0.0", - "Microsoft.CSharp": "4.7.0", - "Microsoft.Data.Sqlite": "7.0.5", - "Polly": "7.2.3", - "Polly.Contrib.WaitAndRetry": "1.1.1", - "Polly.Extensions.Http": "3.0.0", - "Sentry": "3.33.0", - "Sentry.Serilog": "3.33.0", - "Serilog": "2.12.0", - "Serilog.Enrichers.ClientInfo": "1.3.0", - "Serilog.Exceptions": "8.4.0", - "Serilog.Sinks.Console": "4.1.0", - "Serilog.Sinks.Seq": "5.2.2", - "SerilogTimings": "3.0.1", - "Speckle.Newtonsoft.Json": "13.0.2", - "System.DoubleNumerics": "3.1.3" - } - }, "Speckle.Newtonsoft.Json": { "type": "Transitive", "resolved": "13.0.2", "contentHash": "g1BejUZwax5PRfL6xHgLEK23sqHWOgOj9hE7RvfRRlN00AGt8GnPYt8HedSK7UB3HiRW8zCA9Pn0iiYxCK24BA==" }, - "Speckle.Objects": { - "type": "Transitive", - "resolved": "3.0.1-alpha.11", - "contentHash": "YR7sei3OQBAi8R/kIu8bEmg5ELDIJK6l5fhOgdnqA9ZvD/fvmRb+09z8lIUTDsgdAdvYU/A/x9VxH9OGPbp9Kw==", - "dependencies": { - "Speckle.Core": "3.0.1-alpha.11" - } - }, "Speckle.Revit.API": { "type": "Transitive", "resolved": "2023.0.0", "contentHash": "tq40eD7psgTbV+epNouYyqfo6+hEi7FmXZqcxEOsAV7zfYyWhL6Rt3vmojkWGNuerGbH6oRI6KIIxrnlCNb8Hw==" }, - "Speckle.Revit2023.Api": { - "type": "Transitive", - "resolved": "0.1.1-preview.0.28", - "contentHash": "ejwYS/HI8yy0rJE4vgTr5aj8Fkg/E9JnMGjwyVS2fLtI4f7+FmwAY6inTUT2p/RAoRc2nQw+TerDpUtOhddzag==", - "dependencies": { - "Mapster": "7.3.0", - "Speckle.Revit.API": "2023.0.0", - "Speckle.Revit2023.Interfaces": "0.1.1-preview.0.28" - } - }, - "Speckle.Revit2023.Interfaces": { - "type": "Transitive", - "resolved": "0.1.1-preview.0.28", - "contentHash": "7szXg/vRvP3Wdrn2ZGriVOfsw+bddlpVorBkCIhSHHs5qVTTG8IAIrI1l9dO0/aullaTMF+Xgxm9x3w1aXPiuA==" - }, "SQLitePCLRaw.bundle_e_sqlite3": { "type": "Transitive", "resolved": "2.1.4", @@ -498,11 +454,6 @@ "System.ValueTuple": "4.5.0" } }, - "System.Threading.Tasks.Dataflow": { - "type": "Transitive", - "resolved": "6.0.0", - "contentHash": "+tyDCU3/B1lDdOOAJywHQoFwyXIUghIaP2BxG79uvhfTnO+D9qIgjVlL/JV2NTliYbMHpd6eKDmHp2VHpij7MA==" - }, "System.Threading.Tasks.Extensions": { "type": "Transitive", "resolved": "4.5.4", @@ -569,6 +520,82 @@ "Speckle.Converters.Revit2023": "[2.0.999-local, )", "Speckle.Revit2023.Api": "[0.1.1-preview.0.28, )" } + }, + "Microsoft.Extensions.Logging.Abstractions": { + "type": "CentralTransitive", + "requested": "[7.0.0, )", + "resolved": "7.0.0", + "contentHash": "kmn78+LPVMOWeITUjIlfxUPDsI0R6G0RkeAMBmQxAJ7vBJn4q2dTva7pWi65ceN5vPGjJ9q/Uae2WKgvfktJAw==", + "dependencies": { + "System.Buffers": "4.5.1", + "System.Memory": "4.5.5" + } + }, + "Serilog.Extensions.Logging": { + "type": "CentralTransitive", + "requested": "[7.0.0, )", + "resolved": "7.0.0", + "contentHash": "9faU0zNQqU7I6soVhLUMYaGNpgWv6cKlKb2S5AnS8gXxzW/em5Ladm/6FMrWTnX41cdbdGPOWNAo6adi4WaJ6A==", + "dependencies": { + "Microsoft.Extensions.Logging": "7.0.0", + "Serilog": "2.12.0" + } + }, + "Speckle.Core": { + "type": "CentralTransitive", + "requested": "[3.0.1-alpha.11, )", + "resolved": "3.0.1-alpha.11", + "contentHash": "Zt2dBJLlfziEACYCHThbhKypSjhoA01rTw9BzNI72c/BDyftXIz70Tetq/8ZMEqQnKqfmRyYADsAdWKxpdV0Hg==", + "dependencies": { + "GraphQL.Client": "6.0.0", + "Microsoft.CSharp": "4.7.0", + "Microsoft.Data.Sqlite": "7.0.5", + "Polly": "7.2.3", + "Polly.Contrib.WaitAndRetry": "1.1.1", + "Polly.Extensions.Http": "3.0.0", + "Sentry": "3.33.0", + "Sentry.Serilog": "3.33.0", + "Serilog": "2.12.0", + "Serilog.Enrichers.ClientInfo": "1.3.0", + "Serilog.Exceptions": "8.4.0", + "Serilog.Sinks.Console": "4.1.0", + "Serilog.Sinks.Seq": "5.2.2", + "SerilogTimings": "3.0.1", + "Speckle.Newtonsoft.Json": "13.0.2", + "System.DoubleNumerics": "3.1.3" + } + }, + "Speckle.Objects": { + "type": "CentralTransitive", + "requested": "[3.0.1-alpha.11, )", + "resolved": "3.0.1-alpha.11", + "contentHash": "YR7sei3OQBAi8R/kIu8bEmg5ELDIJK6l5fhOgdnqA9ZvD/fvmRb+09z8lIUTDsgdAdvYU/A/x9VxH9OGPbp9Kw==", + "dependencies": { + "Speckle.Core": "3.0.1-alpha.11" + } + }, + "Speckle.Revit2023.Api": { + "type": "CentralTransitive", + "requested": "[0.1.1-preview.0.28, )", + "resolved": "0.1.1-preview.0.28", + "contentHash": "ejwYS/HI8yy0rJE4vgTr5aj8Fkg/E9JnMGjwyVS2fLtI4f7+FmwAY6inTUT2p/RAoRc2nQw+TerDpUtOhddzag==", + "dependencies": { + "Mapster": "7.3.0", + "Speckle.Revit.API": "2023.0.0", + "Speckle.Revit2023.Interfaces": "0.1.1-preview.0.28" + } + }, + "Speckle.Revit2023.Interfaces": { + "type": "CentralTransitive", + "requested": "[0.1.1-preview.0.28, )", + "resolved": "0.1.1-preview.0.28", + "contentHash": "7szXg/vRvP3Wdrn2ZGriVOfsw+bddlpVorBkCIhSHHs5qVTTG8IAIrI1l9dO0/aullaTMF+Xgxm9x3w1aXPiuA==" + }, + "System.Threading.Tasks.Dataflow": { + "type": "CentralTransitive", + "requested": "[6.0.0, )", + "resolved": "6.0.0", + "contentHash": "+tyDCU3/B1lDdOOAJywHQoFwyXIUghIaP2BxG79uvhfTnO+D9qIgjVlL/JV2NTliYbMHpd6eKDmHp2VHpij7MA==" } } } diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Speckle.Connectors.Rhino7.csproj b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Speckle.Connectors.Rhino7.csproj index b64bd8b20b..e114f0d218 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Speckle.Connectors.Rhino7.csproj +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Speckle.Connectors.Rhino7.csproj @@ -13,11 +13,11 @@ - - - - - + + + + + diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/packages.lock.json b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/packages.lock.json index 2423363e91..c8f0acc3ee 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/packages.lock.json +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/packages.lock.json @@ -1,7 +1,17 @@ { - "version": 1, + "version": 2, "dependencies": { ".NETFramework,Version=v4.8": { + "Microsoft.SourceLink.GitHub": { + "type": "Direct", + "requested": "[8.0.0, )", + "resolved": "8.0.0", + "contentHash": "G5q7OqtwIyGTkeIOAc3u2ZuV/kicQaec5EaRnc0pIeSnh9LUjj+PYQrJYBURvDt7twGl2PKA7nSN0kz1Zw5bnQ==", + "dependencies": { + "Microsoft.Build.Tasks.Git": "8.0.0", + "Microsoft.SourceLink.Common": "8.0.0" + } + }, "PolySharp": { "type": "Direct", "requested": "[1.14.1, )", @@ -111,6 +121,11 @@ "System.Threading.Tasks.Extensions": "4.5.4" } }, + "Microsoft.Build.Tasks.Git": { + "type": "Transitive", + "resolved": "8.0.0", + "contentHash": "bZKfSIKJRXLTuSzLudMFte/8CempWjVamNUR5eHJizsy+iuOuO/k2gnh7W0dHJmYY0tBf+gUErfluCv5mySAOQ==" + }, "Microsoft.CSharp": { "type": "Transitive", "resolved": "4.7.0", @@ -166,15 +181,6 @@ "System.ValueTuple": "4.5.0" } }, - "Microsoft.Extensions.Logging.Abstractions": { - "type": "Transitive", - "resolved": "7.0.0", - "contentHash": "kmn78+LPVMOWeITUjIlfxUPDsI0R6G0RkeAMBmQxAJ7vBJn4q2dTva7pWi65ceN5vPGjJ9q/Uae2WKgvfktJAw==", - "dependencies": { - "System.Buffers": "4.5.1", - "System.Memory": "4.5.5" - } - }, "Microsoft.Extensions.Options": { "type": "Transitive", "resolved": "7.0.0", @@ -193,10 +199,10 @@ "System.Runtime.CompilerServices.Unsafe": "6.0.0" } }, - "Microsoft.Web.WebView2": { + "Microsoft.SourceLink.Common": { "type": "Transitive", - "resolved": "1.0.1823.32", - "contentHash": "ppRcWBUNggFIqyJp7PfgS4Oe8/7yli/mHcTNDOaqo3ZzJWnv9AOr0WE9ceEP5SPs1M7CQ3QvdGMR7KNz0v09EA==" + "resolved": "8.0.0", + "contentHash": "dk9JPxTCIevS75HyEQ0E4OVAFhB2N+V9ShCXf8Q6FkUQZDkgLI12y679Nym1YqsiSysuQskT7Z+6nUf3yab6Vw==" }, "Polly": { "type": "Transitive", @@ -256,15 +262,6 @@ "Serilog": "2.8.0" } }, - "Serilog.Extensions.Logging": { - "type": "Transitive", - "resolved": "7.0.0", - "contentHash": "9faU0zNQqU7I6soVhLUMYaGNpgWv6cKlKb2S5AnS8gXxzW/em5Ladm/6FMrWTnX41cdbdGPOWNAo6adi4WaJ6A==", - "dependencies": { - "Microsoft.Extensions.Logging": "7.0.0", - "Serilog": "2.12.0" - } - }, "Serilog.Formatting.Compact": { "type": "Transitive", "resolved": "1.1.0", @@ -316,42 +313,11 @@ "Serilog": "2.10.0" } }, - "Speckle.Core": { - "type": "Transitive", - "resolved": "3.0.1-alpha.11", - "contentHash": "Zt2dBJLlfziEACYCHThbhKypSjhoA01rTw9BzNI72c/BDyftXIz70Tetq/8ZMEqQnKqfmRyYADsAdWKxpdV0Hg==", - "dependencies": { - "GraphQL.Client": "6.0.0", - "Microsoft.CSharp": "4.7.0", - "Microsoft.Data.Sqlite": "7.0.5", - "Polly": "7.2.3", - "Polly.Contrib.WaitAndRetry": "1.1.1", - "Polly.Extensions.Http": "3.0.0", - "Sentry": "3.33.0", - "Sentry.Serilog": "3.33.0", - "Serilog": "2.12.0", - "Serilog.Enrichers.ClientInfo": "1.3.0", - "Serilog.Exceptions": "8.4.0", - "Serilog.Sinks.Console": "4.1.0", - "Serilog.Sinks.Seq": "5.2.2", - "SerilogTimings": "3.0.1", - "Speckle.Newtonsoft.Json": "13.0.2", - "System.DoubleNumerics": "3.1.3" - } - }, "Speckle.Newtonsoft.Json": { "type": "Transitive", "resolved": "13.0.2", "contentHash": "g1BejUZwax5PRfL6xHgLEK23sqHWOgOj9hE7RvfRRlN00AGt8GnPYt8HedSK7UB3HiRW8zCA9Pn0iiYxCK24BA==" }, - "Speckle.Objects": { - "type": "Transitive", - "resolved": "3.0.1-alpha.11", - "contentHash": "YR7sei3OQBAi8R/kIu8bEmg5ELDIJK6l5fhOgdnqA9ZvD/fvmRb+09z8lIUTDsgdAdvYU/A/x9VxH9OGPbp9Kw==", - "dependencies": { - "Speckle.Core": "3.0.1-alpha.11" - } - }, "SQLitePCLRaw.bundle_e_sqlite3": { "type": "Transitive", "resolved": "2.1.4", @@ -491,11 +457,6 @@ "System.ValueTuple": "4.5.0" } }, - "System.Threading.Tasks.Dataflow": { - "type": "Transitive", - "resolved": "6.0.0", - "contentHash": "+tyDCU3/B1lDdOOAJywHQoFwyXIUghIaP2BxG79uvhfTnO+D9qIgjVlL/JV2NTliYbMHpd6eKDmHp2VHpij7MA==" - }, "System.Threading.Tasks.Extensions": { "type": "Transitive", "resolved": "4.5.4", @@ -559,6 +520,71 @@ "dependencies": { "Speckle.Rhino7.Interfaces": "[0.1.1-preview.0.28, )" } + }, + "Microsoft.Extensions.Logging.Abstractions": { + "type": "CentralTransitive", + "requested": "[7.0.0, )", + "resolved": "7.0.0", + "contentHash": "kmn78+LPVMOWeITUjIlfxUPDsI0R6G0RkeAMBmQxAJ7vBJn4q2dTva7pWi65ceN5vPGjJ9q/Uae2WKgvfktJAw==", + "dependencies": { + "System.Buffers": "4.5.1", + "System.Memory": "4.5.5" + } + }, + "Microsoft.Web.WebView2": { + "type": "CentralTransitive", + "requested": "[1.0.1823.32, )", + "resolved": "1.0.1823.32", + "contentHash": "ppRcWBUNggFIqyJp7PfgS4Oe8/7yli/mHcTNDOaqo3ZzJWnv9AOr0WE9ceEP5SPs1M7CQ3QvdGMR7KNz0v09EA==" + }, + "Serilog.Extensions.Logging": { + "type": "CentralTransitive", + "requested": "[7.0.0, )", + "resolved": "7.0.0", + "contentHash": "9faU0zNQqU7I6soVhLUMYaGNpgWv6cKlKb2S5AnS8gXxzW/em5Ladm/6FMrWTnX41cdbdGPOWNAo6adi4WaJ6A==", + "dependencies": { + "Microsoft.Extensions.Logging": "7.0.0", + "Serilog": "2.12.0" + } + }, + "Speckle.Core": { + "type": "CentralTransitive", + "requested": "[3.0.1-alpha.11, )", + "resolved": "3.0.1-alpha.11", + "contentHash": "Zt2dBJLlfziEACYCHThbhKypSjhoA01rTw9BzNI72c/BDyftXIz70Tetq/8ZMEqQnKqfmRyYADsAdWKxpdV0Hg==", + "dependencies": { + "GraphQL.Client": "6.0.0", + "Microsoft.CSharp": "4.7.0", + "Microsoft.Data.Sqlite": "7.0.5", + "Polly": "7.2.3", + "Polly.Contrib.WaitAndRetry": "1.1.1", + "Polly.Extensions.Http": "3.0.0", + "Sentry": "3.33.0", + "Sentry.Serilog": "3.33.0", + "Serilog": "2.12.0", + "Serilog.Enrichers.ClientInfo": "1.3.0", + "Serilog.Exceptions": "8.4.0", + "Serilog.Sinks.Console": "4.1.0", + "Serilog.Sinks.Seq": "5.2.2", + "SerilogTimings": "3.0.1", + "Speckle.Newtonsoft.Json": "13.0.2", + "System.DoubleNumerics": "3.1.3" + } + }, + "Speckle.Objects": { + "type": "CentralTransitive", + "requested": "[3.0.1-alpha.11, )", + "resolved": "3.0.1-alpha.11", + "contentHash": "YR7sei3OQBAi8R/kIu8bEmg5ELDIJK6l5fhOgdnqA9ZvD/fvmRb+09z8lIUTDsgdAdvYU/A/x9VxH9OGPbp9Kw==", + "dependencies": { + "Speckle.Core": "3.0.1-alpha.11" + } + }, + "System.Threading.Tasks.Dataflow": { + "type": "CentralTransitive", + "requested": "[6.0.0, )", + "resolved": "6.0.0", + "contentHash": "+tyDCU3/B1lDdOOAJywHQoFwyXIUghIaP2BxG79uvhfTnO+D9qIgjVlL/JV2NTliYbMHpd6eKDmHp2VHpij7MA==" } } } diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3.DependencyInjection/Speckle.Converters.ArcGIS3.DependencyInjection.csproj b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3.DependencyInjection/Speckle.Converters.ArcGIS3.DependencyInjection.csproj index 2cb23d51d9..3c4c103894 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3.DependencyInjection/Speckle.Converters.ArcGIS3.DependencyInjection.csproj +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3.DependencyInjection/Speckle.Converters.ArcGIS3.DependencyInjection.csproj @@ -11,7 +11,7 @@ - + diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3.DependencyInjection/packages.lock.json b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3.DependencyInjection/packages.lock.json index 2e1dba8069..383e499052 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3.DependencyInjection/packages.lock.json +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3.DependencyInjection/packages.lock.json @@ -1,5 +1,5 @@ { - "version": 1, + "version": 2, "dependencies": { "net6.0-windows7.0": { "Autofac": { @@ -8,6 +8,16 @@ "resolved": "5.2.0", "contentHash": "V8dBH0dsv75uDzl7Sw+HkhKDPUw2eXnlMjcSVMH+tLo2s67MpTKGyDj1pDcpR+IF2u4YRs0s3/x7R88YJzIWvg==" }, + "Microsoft.SourceLink.GitHub": { + "type": "Direct", + "requested": "[8.0.0, )", + "resolved": "8.0.0", + "contentHash": "G5q7OqtwIyGTkeIOAc3u2ZuV/kicQaec5EaRnc0pIeSnh9LUjj+PYQrJYBURvDt7twGl2PKA7nSN0kz1Zw5bnQ==", + "dependencies": { + "Microsoft.Build.Tasks.Git": "8.0.0", + "Microsoft.SourceLink.Common": "8.0.0" + } + }, "PolySharp": { "type": "Direct", "requested": "[1.14.1, )", @@ -20,11 +30,6 @@ "resolved": "0.9.5", "contentHash": "oU/L7pN1R7q8KkbrpQ3WJnHirPHqn+9DEA7asOcUiggV5dzVg1A/VYs7GOSusD24njxXh03tE3a2oTLOjt3cVg==" }, - "Esri.ArcGISPro.Extensions30": { - "type": "Transitive", - "resolved": "3.2.0.49743", - "contentHash": "fmnYm+mD14Cz0Uqh1ij37SfLJerkyFHK5581y5tXT/l3H2ZvUmVuuxjYquXzyzj9p7IexQzMW4xCpxe+mD922g==" - }, "GraphQL.Client": { "type": "Transitive", "resolved": "6.0.0", @@ -94,6 +99,11 @@ "System.Text.Encodings.Web": "4.5.0" } }, + "Microsoft.Build.Tasks.Git": { + "type": "Transitive", + "resolved": "8.0.0", + "contentHash": "bZKfSIKJRXLTuSzLudMFte/8CempWjVamNUR5eHJizsy+iuOuO/k2gnh7W0dHJmYY0tBf+gUErfluCv5mySAOQ==" + }, "Microsoft.CSharp": { "type": "Transitive", "resolved": "4.7.0", @@ -121,11 +131,6 @@ "resolved": "2.2.0", "contentHash": "f9hstgjVmr6rmrfGSpfsVOl2irKAgr1QjrSi3FgnS7kulxband50f2brRLwySAQTADPZeTdow0mpSMcoAdadCw==" }, - "Microsoft.Extensions.Logging.Abstractions": { - "type": "Transitive", - "resolved": "7.0.0", - "contentHash": "kmn78+LPVMOWeITUjIlfxUPDsI0R6G0RkeAMBmQxAJ7vBJn4q2dTva7pWi65ceN5vPGjJ9q/Uae2WKgvfktJAw==" - }, "Microsoft.Extensions.ObjectPool": { "type": "Transitive", "resolved": "2.2.0", @@ -159,6 +164,11 @@ "System.Buffers": "4.5.0" } }, + "Microsoft.SourceLink.Common": { + "type": "Transitive", + "resolved": "8.0.0", + "contentHash": "dk9JPxTCIevS75HyEQ0E4OVAFhB2N+V9ShCXf8Q6FkUQZDkgLI12y679Nym1YqsiSysuQskT7Z+6nUf3yab6Vw==" + }, "Polly": { "type": "Transitive", "resolved": "7.2.3", @@ -265,42 +275,11 @@ "Serilog": "2.10.0" } }, - "Speckle.Core": { - "type": "Transitive", - "resolved": "3.0.1-alpha.11", - "contentHash": "Zt2dBJLlfziEACYCHThbhKypSjhoA01rTw9BzNI72c/BDyftXIz70Tetq/8ZMEqQnKqfmRyYADsAdWKxpdV0Hg==", - "dependencies": { - "GraphQL.Client": "6.0.0", - "Microsoft.CSharp": "4.7.0", - "Microsoft.Data.Sqlite": "7.0.5", - "Polly": "7.2.3", - "Polly.Contrib.WaitAndRetry": "1.1.1", - "Polly.Extensions.Http": "3.0.0", - "Sentry": "3.33.0", - "Sentry.Serilog": "3.33.0", - "Serilog": "2.12.0", - "Serilog.Enrichers.ClientInfo": "1.3.0", - "Serilog.Exceptions": "8.4.0", - "Serilog.Sinks.Console": "4.1.0", - "Serilog.Sinks.Seq": "5.2.2", - "SerilogTimings": "3.0.1", - "Speckle.Newtonsoft.Json": "13.0.2", - "System.DoubleNumerics": "3.1.3" - } - }, "Speckle.Newtonsoft.Json": { "type": "Transitive", "resolved": "13.0.2", "contentHash": "g1BejUZwax5PRfL6xHgLEK23sqHWOgOj9hE7RvfRRlN00AGt8GnPYt8HedSK7UB3HiRW8zCA9Pn0iiYxCK24BA==" }, - "Speckle.Objects": { - "type": "Transitive", - "resolved": "3.0.1-alpha.11", - "contentHash": "YR7sei3OQBAi8R/kIu8bEmg5ELDIJK6l5fhOgdnqA9ZvD/fvmRb+09z8lIUTDsgdAdvYU/A/x9VxH9OGPbp9Kw==", - "dependencies": { - "Speckle.Core": "3.0.1-alpha.11" - } - }, "SQLitePCLRaw.bundle_e_sqlite3": { "type": "Transitive", "resolved": "2.1.4", @@ -400,6 +379,51 @@ "Speckle.Autofac": "[2.0.999-local, )", "Speckle.Converters.Common": "[2.0.999-local, )" } + }, + "Esri.ArcGISPro.Extensions30": { + "type": "CentralTransitive", + "requested": "[3.2.0.49743, )", + "resolved": "3.2.0.49743", + "contentHash": "fmnYm+mD14Cz0Uqh1ij37SfLJerkyFHK5581y5tXT/l3H2ZvUmVuuxjYquXzyzj9p7IexQzMW4xCpxe+mD922g==" + }, + "Microsoft.Extensions.Logging.Abstractions": { + "type": "CentralTransitive", + "requested": "[7.0.0, )", + "resolved": "7.0.0", + "contentHash": "kmn78+LPVMOWeITUjIlfxUPDsI0R6G0RkeAMBmQxAJ7vBJn4q2dTva7pWi65ceN5vPGjJ9q/Uae2WKgvfktJAw==" + }, + "Speckle.Core": { + "type": "CentralTransitive", + "requested": "[3.0.1-alpha.11, )", + "resolved": "3.0.1-alpha.11", + "contentHash": "Zt2dBJLlfziEACYCHThbhKypSjhoA01rTw9BzNI72c/BDyftXIz70Tetq/8ZMEqQnKqfmRyYADsAdWKxpdV0Hg==", + "dependencies": { + "GraphQL.Client": "6.0.0", + "Microsoft.CSharp": "4.7.0", + "Microsoft.Data.Sqlite": "7.0.5", + "Polly": "7.2.3", + "Polly.Contrib.WaitAndRetry": "1.1.1", + "Polly.Extensions.Http": "3.0.0", + "Sentry": "3.33.0", + "Sentry.Serilog": "3.33.0", + "Serilog": "2.12.0", + "Serilog.Enrichers.ClientInfo": "1.3.0", + "Serilog.Exceptions": "8.4.0", + "Serilog.Sinks.Console": "4.1.0", + "Serilog.Sinks.Seq": "5.2.2", + "SerilogTimings": "3.0.1", + "Speckle.Newtonsoft.Json": "13.0.2", + "System.DoubleNumerics": "3.1.3" + } + }, + "Speckle.Objects": { + "type": "CentralTransitive", + "requested": "[3.0.1-alpha.11, )", + "resolved": "3.0.1-alpha.11", + "contentHash": "YR7sei3OQBAi8R/kIu8bEmg5ELDIJK6l5fhOgdnqA9ZvD/fvmRb+09z8lIUTDsgdAdvYU/A/x9VxH9OGPbp9Kw==", + "dependencies": { + "Speckle.Core": "3.0.1-alpha.11" + } } } } diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Speckle.Converters.ArcGIS3.csproj b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Speckle.Converters.ArcGIS3.csproj index f65ef46df7..9d4668fbe4 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Speckle.Converters.ArcGIS3.csproj +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Speckle.Converters.ArcGIS3.csproj @@ -7,7 +7,7 @@ - + diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/packages.lock.json b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/packages.lock.json index b79f0ae450..18027e4d25 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/packages.lock.json +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/packages.lock.json @@ -1,5 +1,5 @@ { - "version": 1, + "version": 2, "dependencies": { "net6.0-windows7.0": { "Esri.ArcGISPro.Extensions30": { @@ -8,6 +8,16 @@ "resolved": "3.2.0.49743", "contentHash": "fmnYm+mD14Cz0Uqh1ij37SfLJerkyFHK5581y5tXT/l3H2ZvUmVuuxjYquXzyzj9p7IexQzMW4xCpxe+mD922g==" }, + "Microsoft.SourceLink.GitHub": { + "type": "Direct", + "requested": "[8.0.0, )", + "resolved": "8.0.0", + "contentHash": "G5q7OqtwIyGTkeIOAc3u2ZuV/kicQaec5EaRnc0pIeSnh9LUjj+PYQrJYBURvDt7twGl2PKA7nSN0kz1Zw5bnQ==", + "dependencies": { + "Microsoft.Build.Tasks.Git": "8.0.0", + "Microsoft.SourceLink.Common": "8.0.0" + } + }, "PolySharp": { "type": "Direct", "requested": "[1.14.1, )", @@ -89,6 +99,11 @@ "System.Text.Encodings.Web": "4.5.0" } }, + "Microsoft.Build.Tasks.Git": { + "type": "Transitive", + "resolved": "8.0.0", + "contentHash": "bZKfSIKJRXLTuSzLudMFte/8CempWjVamNUR5eHJizsy+iuOuO/k2gnh7W0dHJmYY0tBf+gUErfluCv5mySAOQ==" + }, "Microsoft.CSharp": { "type": "Transitive", "resolved": "4.7.0", @@ -116,11 +131,6 @@ "resolved": "2.2.0", "contentHash": "f9hstgjVmr6rmrfGSpfsVOl2irKAgr1QjrSi3FgnS7kulxband50f2brRLwySAQTADPZeTdow0mpSMcoAdadCw==" }, - "Microsoft.Extensions.Logging.Abstractions": { - "type": "Transitive", - "resolved": "7.0.0", - "contentHash": "kmn78+LPVMOWeITUjIlfxUPDsI0R6G0RkeAMBmQxAJ7vBJn4q2dTva7pWi65ceN5vPGjJ9q/Uae2WKgvfktJAw==" - }, "Microsoft.Extensions.ObjectPool": { "type": "Transitive", "resolved": "2.2.0", @@ -154,6 +164,11 @@ "System.Buffers": "4.5.0" } }, + "Microsoft.SourceLink.Common": { + "type": "Transitive", + "resolved": "8.0.0", + "contentHash": "dk9JPxTCIevS75HyEQ0E4OVAFhB2N+V9ShCXf8Q6FkUQZDkgLI12y679Nym1YqsiSysuQskT7Z+6nUf3yab6Vw==" + }, "Polly": { "type": "Transitive", "resolved": "7.2.3", @@ -260,42 +275,11 @@ "Serilog": "2.10.0" } }, - "Speckle.Core": { - "type": "Transitive", - "resolved": "3.0.1-alpha.11", - "contentHash": "Zt2dBJLlfziEACYCHThbhKypSjhoA01rTw9BzNI72c/BDyftXIz70Tetq/8ZMEqQnKqfmRyYADsAdWKxpdV0Hg==", - "dependencies": { - "GraphQL.Client": "6.0.0", - "Microsoft.CSharp": "4.7.0", - "Microsoft.Data.Sqlite": "7.0.5", - "Polly": "7.2.3", - "Polly.Contrib.WaitAndRetry": "1.1.1", - "Polly.Extensions.Http": "3.0.0", - "Sentry": "3.33.0", - "Sentry.Serilog": "3.33.0", - "Serilog": "2.12.0", - "Serilog.Enrichers.ClientInfo": "1.3.0", - "Serilog.Exceptions": "8.4.0", - "Serilog.Sinks.Console": "4.1.0", - "Serilog.Sinks.Seq": "5.2.2", - "SerilogTimings": "3.0.1", - "Speckle.Newtonsoft.Json": "13.0.2", - "System.DoubleNumerics": "3.1.3" - } - }, "Speckle.Newtonsoft.Json": { "type": "Transitive", "resolved": "13.0.2", "contentHash": "g1BejUZwax5PRfL6xHgLEK23sqHWOgOj9hE7RvfRRlN00AGt8GnPYt8HedSK7UB3HiRW8zCA9Pn0iiYxCK24BA==" }, - "Speckle.Objects": { - "type": "Transitive", - "resolved": "3.0.1-alpha.11", - "contentHash": "YR7sei3OQBAi8R/kIu8bEmg5ELDIJK6l5fhOgdnqA9ZvD/fvmRb+09z8lIUTDsgdAdvYU/A/x9VxH9OGPbp9Kw==", - "dependencies": { - "Speckle.Core": "3.0.1-alpha.11" - } - }, "SQLitePCLRaw.bundle_e_sqlite3": { "type": "Transitive", "resolved": "2.1.4", @@ -381,6 +365,45 @@ "Speckle.Autofac": "[2.0.999-local, )", "Speckle.Objects": "[3.0.1-alpha.11, )" } + }, + "Microsoft.Extensions.Logging.Abstractions": { + "type": "CentralTransitive", + "requested": "[7.0.0, )", + "resolved": "7.0.0", + "contentHash": "kmn78+LPVMOWeITUjIlfxUPDsI0R6G0RkeAMBmQxAJ7vBJn4q2dTva7pWi65ceN5vPGjJ9q/Uae2WKgvfktJAw==" + }, + "Speckle.Core": { + "type": "CentralTransitive", + "requested": "[3.0.1-alpha.11, )", + "resolved": "3.0.1-alpha.11", + "contentHash": "Zt2dBJLlfziEACYCHThbhKypSjhoA01rTw9BzNI72c/BDyftXIz70Tetq/8ZMEqQnKqfmRyYADsAdWKxpdV0Hg==", + "dependencies": { + "GraphQL.Client": "6.0.0", + "Microsoft.CSharp": "4.7.0", + "Microsoft.Data.Sqlite": "7.0.5", + "Polly": "7.2.3", + "Polly.Contrib.WaitAndRetry": "1.1.1", + "Polly.Extensions.Http": "3.0.0", + "Sentry": "3.33.0", + "Sentry.Serilog": "3.33.0", + "Serilog": "2.12.0", + "Serilog.Enrichers.ClientInfo": "1.3.0", + "Serilog.Exceptions": "8.4.0", + "Serilog.Sinks.Console": "4.1.0", + "Serilog.Sinks.Seq": "5.2.2", + "SerilogTimings": "3.0.1", + "Speckle.Newtonsoft.Json": "13.0.2", + "System.DoubleNumerics": "3.1.3" + } + }, + "Speckle.Objects": { + "type": "CentralTransitive", + "requested": "[3.0.1-alpha.11, )", + "resolved": "3.0.1-alpha.11", + "contentHash": "YR7sei3OQBAi8R/kIu8bEmg5ELDIJK6l5fhOgdnqA9ZvD/fvmRb+09z8lIUTDsgdAdvYU/A/x9VxH9OGPbp9Kw==", + "dependencies": { + "Speckle.Core": "3.0.1-alpha.11" + } } } } diff --git a/DUI3-DX/Converters/Autocad/2023/Directory.Packages.props b/DUI3-DX/Converters/Autocad/2023/Directory.Packages.props new file mode 100644 index 0000000000..568fea5f0f --- /dev/null +++ b/DUI3-DX/Converters/Autocad/2023/Directory.Packages.props @@ -0,0 +1,6 @@ + + + + + + diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2023.DependencyInjection/AutocadConverterModule.cs b/DUI3-DX/Converters/Autocad/2023/Speckle.Converters.Autocad2023.DependencyInjection/AutocadConverterModule.cs similarity index 100% rename from DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2023.DependencyInjection/AutocadConverterModule.cs rename to DUI3-DX/Converters/Autocad/2023/Speckle.Converters.Autocad2023.DependencyInjection/AutocadConverterModule.cs diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2023.DependencyInjection/Speckle.Converters.Autocad2023.DependencyInjection.csproj b/DUI3-DX/Converters/Autocad/2023/Speckle.Converters.Autocad2023.DependencyInjection/Speckle.Converters.Autocad2023.DependencyInjection.csproj similarity index 63% rename from DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2023.DependencyInjection/Speckle.Converters.Autocad2023.DependencyInjection.csproj rename to DUI3-DX/Converters/Autocad/2023/Speckle.Converters.Autocad2023.DependencyInjection/Speckle.Converters.Autocad2023.DependencyInjection.csproj index c115e62f88..303e2f808a 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2023.DependencyInjection/Speckle.Converters.Autocad2023.DependencyInjection.csproj +++ b/DUI3-DX/Converters/Autocad/2023/Speckle.Converters.Autocad2023.DependencyInjection/Speckle.Converters.Autocad2023.DependencyInjection.csproj @@ -6,12 +6,12 @@ - + - + diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2023/packages.lock.json b/DUI3-DX/Converters/Autocad/2023/Speckle.Converters.Autocad2023.DependencyInjection/packages.lock.json similarity index 89% rename from DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2023/packages.lock.json rename to DUI3-DX/Converters/Autocad/2023/Speckle.Converters.Autocad2023.DependencyInjection/packages.lock.json index 0b3957751a..e9931ee09e 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2023/packages.lock.json +++ b/DUI3-DX/Converters/Autocad/2023/Speckle.Converters.Autocad2023.DependencyInjection/packages.lock.json @@ -1,19 +1,32 @@ { - "version": 1, + "version": 2, "dependencies": { ".NETFramework,Version=v4.8": { + "Autofac": { + "type": "Direct", + "requested": "[5.2.0, )", + "resolved": "5.2.0", + "contentHash": "V8dBH0dsv75uDzl7Sw+HkhKDPUw2eXnlMjcSVMH+tLo2s67MpTKGyDj1pDcpR+IF2u4YRs0s3/x7R88YJzIWvg==", + "dependencies": { + "Microsoft.Bcl.AsyncInterfaces": "1.1.0" + } + }, + "Microsoft.SourceLink.GitHub": { + "type": "Direct", + "requested": "[8.0.0, )", + "resolved": "8.0.0", + "contentHash": "G5q7OqtwIyGTkeIOAc3u2ZuV/kicQaec5EaRnc0pIeSnh9LUjj+PYQrJYBURvDt7twGl2PKA7nSN0kz1Zw5bnQ==", + "dependencies": { + "Microsoft.Build.Tasks.Git": "8.0.0", + "Microsoft.SourceLink.Common": "8.0.0" + } + }, "PolySharp": { "type": "Direct", "requested": "[1.14.1, )", "resolved": "1.14.1", "contentHash": "mOOmFYwad3MIOL14VCjj02LljyF1GNw1wP0YVlxtcPvqdxjGGMNdNJJxHptlry3MOd8b40Flm8RPOM8JOlN2sQ==" }, - "Speckle.AutoCAD.API": { - "type": "Direct", - "requested": "[2023.0.0, )", - "resolved": "2023.0.0", - "contentHash": "aNfiNw9zRW8pCl8AAQK7afEJuea4bJ4sFNsGVSDrdq1egaonZrwALU01dSyFNCE8tne86eVjlprpOGG6r0+G/A==" - }, "Speckle.InterfaceGenerator": { "type": "Direct", "requested": "[0.9.5, )", @@ -60,6 +73,11 @@ "System.Threading.Tasks.Extensions": "4.5.4" } }, + "Microsoft.Build.Tasks.Git": { + "type": "Transitive", + "resolved": "8.0.0", + "contentHash": "bZKfSIKJRXLTuSzLudMFte/8CempWjVamNUR5eHJizsy+iuOuO/k2gnh7W0dHJmYY0tBf+gUErfluCv5mySAOQ==" + }, "Microsoft.CSharp": { "type": "Transitive", "resolved": "4.7.0", @@ -82,14 +100,10 @@ "SQLitePCLRaw.core": "2.1.4" } }, - "Microsoft.Extensions.Logging.Abstractions": { + "Microsoft.SourceLink.Common": { "type": "Transitive", - "resolved": "7.0.0", - "contentHash": "kmn78+LPVMOWeITUjIlfxUPDsI0R6G0RkeAMBmQxAJ7vBJn4q2dTva7pWi65ceN5vPGjJ9q/Uae2WKgvfktJAw==", - "dependencies": { - "System.Buffers": "4.5.1", - "System.Memory": "4.5.5" - } + "resolved": "8.0.0", + "contentHash": "dk9JPxTCIevS75HyEQ0E4OVAFhB2N+V9ShCXf8Q6FkUQZDkgLI12y679Nym1YqsiSysuQskT7Z+6nUf3yab6Vw==" }, "Polly": { "type": "Transitive", @@ -200,42 +214,11 @@ "Serilog": "2.10.0" } }, - "Speckle.Core": { - "type": "Transitive", - "resolved": "3.0.1-alpha.11", - "contentHash": "Zt2dBJLlfziEACYCHThbhKypSjhoA01rTw9BzNI72c/BDyftXIz70Tetq/8ZMEqQnKqfmRyYADsAdWKxpdV0Hg==", - "dependencies": { - "GraphQL.Client": "6.0.0", - "Microsoft.CSharp": "4.7.0", - "Microsoft.Data.Sqlite": "7.0.5", - "Polly": "7.2.3", - "Polly.Contrib.WaitAndRetry": "1.1.1", - "Polly.Extensions.Http": "3.0.0", - "Sentry": "3.33.0", - "Sentry.Serilog": "3.33.0", - "Serilog": "2.12.0", - "Serilog.Enrichers.ClientInfo": "1.3.0", - "Serilog.Exceptions": "8.4.0", - "Serilog.Sinks.Console": "4.1.0", - "Serilog.Sinks.Seq": "5.2.2", - "SerilogTimings": "3.0.1", - "Speckle.Newtonsoft.Json": "13.0.2", - "System.DoubleNumerics": "3.1.3" - } - }, "Speckle.Newtonsoft.Json": { "type": "Transitive", "resolved": "13.0.2", "contentHash": "g1BejUZwax5PRfL6xHgLEK23sqHWOgOj9hE7RvfRRlN00AGt8GnPYt8HedSK7UB3HiRW8zCA9Pn0iiYxCK24BA==" }, - "Speckle.Objects": { - "type": "Transitive", - "resolved": "3.0.1-alpha.11", - "contentHash": "YR7sei3OQBAi8R/kIu8bEmg5ELDIJK6l5fhOgdnqA9ZvD/fvmRb+09z8lIUTDsgdAdvYU/A/x9VxH9OGPbp9Kw==", - "dependencies": { - "Speckle.Core": "3.0.1-alpha.11" - } - }, "SQLitePCLRaw.bundle_e_sqlite3": { "type": "Transitive", "resolved": "2.1.4", @@ -380,12 +363,75 @@ "Microsoft.Extensions.Logging.Abstractions": "[7.0.0, )" } }, + "speckle.converters.autocad2023": { + "type": "Project", + "dependencies": { + "Speckle.AutoCAD.API": "[2023.0.0, )", + "Speckle.Converters.Common": "[2.0.999-local, )" + } + }, "speckle.converters.common": { "type": "Project", "dependencies": { "Speckle.Autofac": "[2.0.999-local, )", "Speckle.Objects": "[3.0.1-alpha.11, )" } + }, + "speckle.converters.common.dependencyinjection": { + "type": "Project", + "dependencies": { + "Speckle.Autofac": "[2.0.999-local, )", + "Speckle.Converters.Common": "[2.0.999-local, )" + } + }, + "Microsoft.Extensions.Logging.Abstractions": { + "type": "CentralTransitive", + "requested": "[7.0.0, )", + "resolved": "7.0.0", + "contentHash": "kmn78+LPVMOWeITUjIlfxUPDsI0R6G0RkeAMBmQxAJ7vBJn4q2dTva7pWi65ceN5vPGjJ9q/Uae2WKgvfktJAw==", + "dependencies": { + "System.Buffers": "4.5.1", + "System.Memory": "4.5.5" + } + }, + "Speckle.AutoCAD.API": { + "type": "CentralTransitive", + "requested": "[2023.0.0, )", + "resolved": "2023.0.0", + "contentHash": "aNfiNw9zRW8pCl8AAQK7afEJuea4bJ4sFNsGVSDrdq1egaonZrwALU01dSyFNCE8tne86eVjlprpOGG6r0+G/A==" + }, + "Speckle.Core": { + "type": "CentralTransitive", + "requested": "[3.0.1-alpha.11, )", + "resolved": "3.0.1-alpha.11", + "contentHash": "Zt2dBJLlfziEACYCHThbhKypSjhoA01rTw9BzNI72c/BDyftXIz70Tetq/8ZMEqQnKqfmRyYADsAdWKxpdV0Hg==", + "dependencies": { + "GraphQL.Client": "6.0.0", + "Microsoft.CSharp": "4.7.0", + "Microsoft.Data.Sqlite": "7.0.5", + "Polly": "7.2.3", + "Polly.Contrib.WaitAndRetry": "1.1.1", + "Polly.Extensions.Http": "3.0.0", + "Sentry": "3.33.0", + "Sentry.Serilog": "3.33.0", + "Serilog": "2.12.0", + "Serilog.Enrichers.ClientInfo": "1.3.0", + "Serilog.Exceptions": "8.4.0", + "Serilog.Sinks.Console": "4.1.0", + "Serilog.Sinks.Seq": "5.2.2", + "SerilogTimings": "3.0.1", + "Speckle.Newtonsoft.Json": "13.0.2", + "System.DoubleNumerics": "3.1.3" + } + }, + "Speckle.Objects": { + "type": "CentralTransitive", + "requested": "[3.0.1-alpha.11, )", + "resolved": "3.0.1-alpha.11", + "contentHash": "YR7sei3OQBAi8R/kIu8bEmg5ELDIJK6l5fhOgdnqA9ZvD/fvmRb+09z8lIUTDsgdAdvYU/A/x9VxH9OGPbp9Kw==", + "dependencies": { + "Speckle.Core": "3.0.1-alpha.11" + } } } } diff --git a/DUI3-DX/Converters/Autocad/2023/Speckle.Converters.Autocad2023/Speckle.Converters.Autocad2023.csproj b/DUI3-DX/Converters/Autocad/2023/Speckle.Converters.Autocad2023/Speckle.Converters.Autocad2023.csproj new file mode 100644 index 0000000000..753a408e8e --- /dev/null +++ b/DUI3-DX/Converters/Autocad/2023/Speckle.Converters.Autocad2023/Speckle.Converters.Autocad2023.csproj @@ -0,0 +1,18 @@ + + + + net48 + x64 + + + + + + + + + + + + + diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2023.DependencyInjection/packages.lock.json b/DUI3-DX/Converters/Autocad/2023/Speckle.Converters.Autocad2023/packages.lock.json similarity index 93% rename from DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2023.DependencyInjection/packages.lock.json rename to DUI3-DX/Converters/Autocad/2023/Speckle.Converters.Autocad2023/packages.lock.json index 5d933c5ecf..b114e8a7c5 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2023.DependencyInjection/packages.lock.json +++ b/DUI3-DX/Converters/Autocad/2023/Speckle.Converters.Autocad2023/packages.lock.json @@ -1,14 +1,15 @@ { - "version": 1, + "version": 2, "dependencies": { ".NETFramework,Version=v4.8": { - "Autofac": { + "Microsoft.SourceLink.GitHub": { "type": "Direct", - "requested": "[5.2.0, )", - "resolved": "5.2.0", - "contentHash": "V8dBH0dsv75uDzl7Sw+HkhKDPUw2eXnlMjcSVMH+tLo2s67MpTKGyDj1pDcpR+IF2u4YRs0s3/x7R88YJzIWvg==", + "requested": "[8.0.0, )", + "resolved": "8.0.0", + "contentHash": "G5q7OqtwIyGTkeIOAc3u2ZuV/kicQaec5EaRnc0pIeSnh9LUjj+PYQrJYBURvDt7twGl2PKA7nSN0kz1Zw5bnQ==", "dependencies": { - "Microsoft.Bcl.AsyncInterfaces": "1.1.0" + "Microsoft.Build.Tasks.Git": "8.0.0", + "Microsoft.SourceLink.Common": "8.0.0" } }, "PolySharp": { @@ -17,6 +18,12 @@ "resolved": "1.14.1", "contentHash": "mOOmFYwad3MIOL14VCjj02LljyF1GNw1wP0YVlxtcPvqdxjGGMNdNJJxHptlry3MOd8b40Flm8RPOM8JOlN2sQ==" }, + "Speckle.AutoCAD.API": { + "type": "Direct", + "requested": "[2023.0.0, )", + "resolved": "2023.0.0", + "contentHash": "aNfiNw9zRW8pCl8AAQK7afEJuea4bJ4sFNsGVSDrdq1egaonZrwALU01dSyFNCE8tne86eVjlprpOGG6r0+G/A==" + }, "Speckle.InterfaceGenerator": { "type": "Direct", "requested": "[0.9.5, )", @@ -63,6 +70,11 @@ "System.Threading.Tasks.Extensions": "4.5.4" } }, + "Microsoft.Build.Tasks.Git": { + "type": "Transitive", + "resolved": "8.0.0", + "contentHash": "bZKfSIKJRXLTuSzLudMFte/8CempWjVamNUR5eHJizsy+iuOuO/k2gnh7W0dHJmYY0tBf+gUErfluCv5mySAOQ==" + }, "Microsoft.CSharp": { "type": "Transitive", "resolved": "4.7.0", @@ -85,14 +97,10 @@ "SQLitePCLRaw.core": "2.1.4" } }, - "Microsoft.Extensions.Logging.Abstractions": { + "Microsoft.SourceLink.Common": { "type": "Transitive", - "resolved": "7.0.0", - "contentHash": "kmn78+LPVMOWeITUjIlfxUPDsI0R6G0RkeAMBmQxAJ7vBJn4q2dTva7pWi65ceN5vPGjJ9q/Uae2WKgvfktJAw==", - "dependencies": { - "System.Buffers": "4.5.1", - "System.Memory": "4.5.5" - } + "resolved": "8.0.0", + "contentHash": "dk9JPxTCIevS75HyEQ0E4OVAFhB2N+V9ShCXf8Q6FkUQZDkgLI12y679Nym1YqsiSysuQskT7Z+6nUf3yab6Vw==" }, "Polly": { "type": "Transitive", @@ -203,47 +211,11 @@ "Serilog": "2.10.0" } }, - "Speckle.AutoCAD.API": { - "type": "Transitive", - "resolved": "2023.0.0", - "contentHash": "aNfiNw9zRW8pCl8AAQK7afEJuea4bJ4sFNsGVSDrdq1egaonZrwALU01dSyFNCE8tne86eVjlprpOGG6r0+G/A==" - }, - "Speckle.Core": { - "type": "Transitive", - "resolved": "3.0.1-alpha.11", - "contentHash": "Zt2dBJLlfziEACYCHThbhKypSjhoA01rTw9BzNI72c/BDyftXIz70Tetq/8ZMEqQnKqfmRyYADsAdWKxpdV0Hg==", - "dependencies": { - "GraphQL.Client": "6.0.0", - "Microsoft.CSharp": "4.7.0", - "Microsoft.Data.Sqlite": "7.0.5", - "Polly": "7.2.3", - "Polly.Contrib.WaitAndRetry": "1.1.1", - "Polly.Extensions.Http": "3.0.0", - "Sentry": "3.33.0", - "Sentry.Serilog": "3.33.0", - "Serilog": "2.12.0", - "Serilog.Enrichers.ClientInfo": "1.3.0", - "Serilog.Exceptions": "8.4.0", - "Serilog.Sinks.Console": "4.1.0", - "Serilog.Sinks.Seq": "5.2.2", - "SerilogTimings": "3.0.1", - "Speckle.Newtonsoft.Json": "13.0.2", - "System.DoubleNumerics": "3.1.3" - } - }, "Speckle.Newtonsoft.Json": { "type": "Transitive", "resolved": "13.0.2", "contentHash": "g1BejUZwax5PRfL6xHgLEK23sqHWOgOj9hE7RvfRRlN00AGt8GnPYt8HedSK7UB3HiRW8zCA9Pn0iiYxCK24BA==" }, - "Speckle.Objects": { - "type": "Transitive", - "resolved": "3.0.1-alpha.11", - "contentHash": "YR7sei3OQBAi8R/kIu8bEmg5ELDIJK6l5fhOgdnqA9ZvD/fvmRb+09z8lIUTDsgdAdvYU/A/x9VxH9OGPbp9Kw==", - "dependencies": { - "Speckle.Core": "3.0.1-alpha.11" - } - }, "SQLitePCLRaw.bundle_e_sqlite3": { "type": "Transitive", "resolved": "2.1.4", @@ -388,13 +360,6 @@ "Microsoft.Extensions.Logging.Abstractions": "[7.0.0, )" } }, - "speckle.converters.autocad2023": { - "type": "Project", - "dependencies": { - "Speckle.AutoCAD.API": "[2023.0.0, )", - "Speckle.Converters.Common": "[2.0.999-local, )" - } - }, "speckle.converters.common": { "type": "Project", "dependencies": { @@ -402,11 +367,47 @@ "Speckle.Objects": "[3.0.1-alpha.11, )" } }, - "speckle.converters.common.dependencyinjection": { - "type": "Project", + "Microsoft.Extensions.Logging.Abstractions": { + "type": "CentralTransitive", + "requested": "[7.0.0, )", + "resolved": "7.0.0", + "contentHash": "kmn78+LPVMOWeITUjIlfxUPDsI0R6G0RkeAMBmQxAJ7vBJn4q2dTva7pWi65ceN5vPGjJ9q/Uae2WKgvfktJAw==", "dependencies": { - "Speckle.Autofac": "[2.0.999-local, )", - "Speckle.Converters.Common": "[2.0.999-local, )" + "System.Buffers": "4.5.1", + "System.Memory": "4.5.5" + } + }, + "Speckle.Core": { + "type": "CentralTransitive", + "requested": "[3.0.1-alpha.11, )", + "resolved": "3.0.1-alpha.11", + "contentHash": "Zt2dBJLlfziEACYCHThbhKypSjhoA01rTw9BzNI72c/BDyftXIz70Tetq/8ZMEqQnKqfmRyYADsAdWKxpdV0Hg==", + "dependencies": { + "GraphQL.Client": "6.0.0", + "Microsoft.CSharp": "4.7.0", + "Microsoft.Data.Sqlite": "7.0.5", + "Polly": "7.2.3", + "Polly.Contrib.WaitAndRetry": "1.1.1", + "Polly.Extensions.Http": "3.0.0", + "Sentry": "3.33.0", + "Sentry.Serilog": "3.33.0", + "Serilog": "2.12.0", + "Serilog.Enrichers.ClientInfo": "1.3.0", + "Serilog.Exceptions": "8.4.0", + "Serilog.Sinks.Console": "4.1.0", + "Serilog.Sinks.Seq": "5.2.2", + "SerilogTimings": "3.0.1", + "Speckle.Newtonsoft.Json": "13.0.2", + "System.DoubleNumerics": "3.1.3" + } + }, + "Speckle.Objects": { + "type": "CentralTransitive", + "requested": "[3.0.1-alpha.11, )", + "resolved": "3.0.1-alpha.11", + "contentHash": "YR7sei3OQBAi8R/kIu8bEmg5ELDIJK6l5fhOgdnqA9ZvD/fvmRb+09z8lIUTDsgdAdvYU/A/x9VxH9OGPbp9Kw==", + "dependencies": { + "Speckle.Core": "3.0.1-alpha.11" } } } diff --git a/DUI3-DX/Converters/Autocad/2024/Directory.Packages.props b/DUI3-DX/Converters/Autocad/2024/Directory.Packages.props new file mode 100644 index 0000000000..27e149ab85 --- /dev/null +++ b/DUI3-DX/Converters/Autocad/2024/Directory.Packages.props @@ -0,0 +1,6 @@ + + + + + + diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2024.DependencyInjection/AutocadConverterModule.cs b/DUI3-DX/Converters/Autocad/2024/Speckle.Converters.Autocad2024.DependencyInjection/AutocadConverterModule.cs similarity index 100% rename from DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2024.DependencyInjection/AutocadConverterModule.cs rename to DUI3-DX/Converters/Autocad/2024/Speckle.Converters.Autocad2024.DependencyInjection/AutocadConverterModule.cs diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2024.DependencyInjection/Speckle.Converters.Autocad2024.DependencyInjection.csproj b/DUI3-DX/Converters/Autocad/2024/Speckle.Converters.Autocad2024.DependencyInjection/Speckle.Converters.Autocad2024.DependencyInjection.csproj similarity index 63% rename from DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2024.DependencyInjection/Speckle.Converters.Autocad2024.DependencyInjection.csproj rename to DUI3-DX/Converters/Autocad/2024/Speckle.Converters.Autocad2024.DependencyInjection/Speckle.Converters.Autocad2024.DependencyInjection.csproj index 9442c9cfe9..05de443d1e 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2024.DependencyInjection/Speckle.Converters.Autocad2024.DependencyInjection.csproj +++ b/DUI3-DX/Converters/Autocad/2024/Speckle.Converters.Autocad2024.DependencyInjection/Speckle.Converters.Autocad2024.DependencyInjection.csproj @@ -6,12 +6,12 @@ - + - + diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2024.DependencyInjection/packages.lock.json b/DUI3-DX/Converters/Autocad/2024/Speckle.Converters.Autocad2024.DependencyInjection/packages.lock.json similarity index 93% rename from DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2024.DependencyInjection/packages.lock.json rename to DUI3-DX/Converters/Autocad/2024/Speckle.Converters.Autocad2024.DependencyInjection/packages.lock.json index 6954909ed9..8eee516ff1 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2024.DependencyInjection/packages.lock.json +++ b/DUI3-DX/Converters/Autocad/2024/Speckle.Converters.Autocad2024.DependencyInjection/packages.lock.json @@ -1,5 +1,5 @@ { - "version": 1, + "version": 2, "dependencies": { ".NETFramework,Version=v4.8": { "Autofac": { @@ -11,6 +11,16 @@ "Microsoft.Bcl.AsyncInterfaces": "1.1.0" } }, + "Microsoft.SourceLink.GitHub": { + "type": "Direct", + "requested": "[8.0.0, )", + "resolved": "8.0.0", + "contentHash": "G5q7OqtwIyGTkeIOAc3u2ZuV/kicQaec5EaRnc0pIeSnh9LUjj+PYQrJYBURvDt7twGl2PKA7nSN0kz1Zw5bnQ==", + "dependencies": { + "Microsoft.Build.Tasks.Git": "8.0.0", + "Microsoft.SourceLink.Common": "8.0.0" + } + }, "PolySharp": { "type": "Direct", "requested": "[1.14.1, )", @@ -63,6 +73,11 @@ "System.Threading.Tasks.Extensions": "4.5.4" } }, + "Microsoft.Build.Tasks.Git": { + "type": "Transitive", + "resolved": "8.0.0", + "contentHash": "bZKfSIKJRXLTuSzLudMFte/8CempWjVamNUR5eHJizsy+iuOuO/k2gnh7W0dHJmYY0tBf+gUErfluCv5mySAOQ==" + }, "Microsoft.CSharp": { "type": "Transitive", "resolved": "4.7.0", @@ -85,14 +100,10 @@ "SQLitePCLRaw.core": "2.1.4" } }, - "Microsoft.Extensions.Logging.Abstractions": { + "Microsoft.SourceLink.Common": { "type": "Transitive", - "resolved": "7.0.0", - "contentHash": "kmn78+LPVMOWeITUjIlfxUPDsI0R6G0RkeAMBmQxAJ7vBJn4q2dTva7pWi65ceN5vPGjJ9q/Uae2WKgvfktJAw==", - "dependencies": { - "System.Buffers": "4.5.1", - "System.Memory": "4.5.5" - } + "resolved": "8.0.0", + "contentHash": "dk9JPxTCIevS75HyEQ0E4OVAFhB2N+V9ShCXf8Q6FkUQZDkgLI12y679Nym1YqsiSysuQskT7Z+6nUf3yab6Vw==" }, "Polly": { "type": "Transitive", @@ -203,47 +214,11 @@ "Serilog": "2.10.0" } }, - "Speckle.AutoCAD.API": { - "type": "Transitive", - "resolved": "2024.0.0", - "contentHash": "pZZ5uI+NXhZaQnsqRkgp/rywqBAjDObDJ9XNFGJvemT5k2OthDpHzlK/mKxz8QDCYie7uImQ8dv3uWj2QUFDPw==" - }, - "Speckle.Core": { - "type": "Transitive", - "resolved": "3.0.1-alpha.11", - "contentHash": "Zt2dBJLlfziEACYCHThbhKypSjhoA01rTw9BzNI72c/BDyftXIz70Tetq/8ZMEqQnKqfmRyYADsAdWKxpdV0Hg==", - "dependencies": { - "GraphQL.Client": "6.0.0", - "Microsoft.CSharp": "4.7.0", - "Microsoft.Data.Sqlite": "7.0.5", - "Polly": "7.2.3", - "Polly.Contrib.WaitAndRetry": "1.1.1", - "Polly.Extensions.Http": "3.0.0", - "Sentry": "3.33.0", - "Sentry.Serilog": "3.33.0", - "Serilog": "2.12.0", - "Serilog.Enrichers.ClientInfo": "1.3.0", - "Serilog.Exceptions": "8.4.0", - "Serilog.Sinks.Console": "4.1.0", - "Serilog.Sinks.Seq": "5.2.2", - "SerilogTimings": "3.0.1", - "Speckle.Newtonsoft.Json": "13.0.2", - "System.DoubleNumerics": "3.1.3" - } - }, "Speckle.Newtonsoft.Json": { "type": "Transitive", "resolved": "13.0.2", "contentHash": "g1BejUZwax5PRfL6xHgLEK23sqHWOgOj9hE7RvfRRlN00AGt8GnPYt8HedSK7UB3HiRW8zCA9Pn0iiYxCK24BA==" }, - "Speckle.Objects": { - "type": "Transitive", - "resolved": "3.0.1-alpha.11", - "contentHash": "YR7sei3OQBAi8R/kIu8bEmg5ELDIJK6l5fhOgdnqA9ZvD/fvmRb+09z8lIUTDsgdAdvYU/A/x9VxH9OGPbp9Kw==", - "dependencies": { - "Speckle.Core": "3.0.1-alpha.11" - } - }, "SQLitePCLRaw.bundle_e_sqlite3": { "type": "Transitive", "resolved": "2.1.4", @@ -408,6 +383,55 @@ "Speckle.Autofac": "[2.0.999-local, )", "Speckle.Converters.Common": "[2.0.999-local, )" } + }, + "Microsoft.Extensions.Logging.Abstractions": { + "type": "CentralTransitive", + "requested": "[7.0.0, )", + "resolved": "7.0.0", + "contentHash": "kmn78+LPVMOWeITUjIlfxUPDsI0R6G0RkeAMBmQxAJ7vBJn4q2dTva7pWi65ceN5vPGjJ9q/Uae2WKgvfktJAw==", + "dependencies": { + "System.Buffers": "4.5.1", + "System.Memory": "4.5.5" + } + }, + "Speckle.AutoCAD.API": { + "type": "CentralTransitive", + "requested": "[2024.0.0, )", + "resolved": "2024.0.0", + "contentHash": "pZZ5uI+NXhZaQnsqRkgp/rywqBAjDObDJ9XNFGJvemT5k2OthDpHzlK/mKxz8QDCYie7uImQ8dv3uWj2QUFDPw==" + }, + "Speckle.Core": { + "type": "CentralTransitive", + "requested": "[3.0.1-alpha.11, )", + "resolved": "3.0.1-alpha.11", + "contentHash": "Zt2dBJLlfziEACYCHThbhKypSjhoA01rTw9BzNI72c/BDyftXIz70Tetq/8ZMEqQnKqfmRyYADsAdWKxpdV0Hg==", + "dependencies": { + "GraphQL.Client": "6.0.0", + "Microsoft.CSharp": "4.7.0", + "Microsoft.Data.Sqlite": "7.0.5", + "Polly": "7.2.3", + "Polly.Contrib.WaitAndRetry": "1.1.1", + "Polly.Extensions.Http": "3.0.0", + "Sentry": "3.33.0", + "Sentry.Serilog": "3.33.0", + "Serilog": "2.12.0", + "Serilog.Enrichers.ClientInfo": "1.3.0", + "Serilog.Exceptions": "8.4.0", + "Serilog.Sinks.Console": "4.1.0", + "Serilog.Sinks.Seq": "5.2.2", + "SerilogTimings": "3.0.1", + "Speckle.Newtonsoft.Json": "13.0.2", + "System.DoubleNumerics": "3.1.3" + } + }, + "Speckle.Objects": { + "type": "CentralTransitive", + "requested": "[3.0.1-alpha.11, )", + "resolved": "3.0.1-alpha.11", + "contentHash": "YR7sei3OQBAi8R/kIu8bEmg5ELDIJK6l5fhOgdnqA9ZvD/fvmRb+09z8lIUTDsgdAdvYU/A/x9VxH9OGPbp9Kw==", + "dependencies": { + "Speckle.Core": "3.0.1-alpha.11" + } } } } diff --git a/DUI3-DX/Converters/Autocad/2024/Speckle.Converters.Autocad2024/Speckle.Converters.Autocad2024.csproj b/DUI3-DX/Converters/Autocad/2024/Speckle.Converters.Autocad2024/Speckle.Converters.Autocad2024.csproj new file mode 100644 index 0000000000..8aad1ab7d5 --- /dev/null +++ b/DUI3-DX/Converters/Autocad/2024/Speckle.Converters.Autocad2024/Speckle.Converters.Autocad2024.csproj @@ -0,0 +1,18 @@ + + + + net48 + x64 + + + + + + + + + + + + + diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2024/packages.lock.json b/DUI3-DX/Converters/Autocad/2024/Speckle.Converters.Autocad2024/packages.lock.json similarity index 87% rename from DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2024/packages.lock.json rename to DUI3-DX/Converters/Autocad/2024/Speckle.Converters.Autocad2024/packages.lock.json index bd3d39f474..66a0d5e333 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2024/packages.lock.json +++ b/DUI3-DX/Converters/Autocad/2024/Speckle.Converters.Autocad2024/packages.lock.json @@ -1,7 +1,17 @@ { - "version": 1, + "version": 2, "dependencies": { ".NETFramework,Version=v4.8": { + "Microsoft.SourceLink.GitHub": { + "type": "Direct", + "requested": "[8.0.0, )", + "resolved": "8.0.0", + "contentHash": "G5q7OqtwIyGTkeIOAc3u2ZuV/kicQaec5EaRnc0pIeSnh9LUjj+PYQrJYBURvDt7twGl2PKA7nSN0kz1Zw5bnQ==", + "dependencies": { + "Microsoft.Build.Tasks.Git": "8.0.0", + "Microsoft.SourceLink.Common": "8.0.0" + } + }, "PolySharp": { "type": "Direct", "requested": "[1.14.1, )", @@ -60,6 +70,11 @@ "System.Threading.Tasks.Extensions": "4.5.4" } }, + "Microsoft.Build.Tasks.Git": { + "type": "Transitive", + "resolved": "8.0.0", + "contentHash": "bZKfSIKJRXLTuSzLudMFte/8CempWjVamNUR5eHJizsy+iuOuO/k2gnh7W0dHJmYY0tBf+gUErfluCv5mySAOQ==" + }, "Microsoft.CSharp": { "type": "Transitive", "resolved": "4.7.0", @@ -82,14 +97,10 @@ "SQLitePCLRaw.core": "2.1.4" } }, - "Microsoft.Extensions.Logging.Abstractions": { + "Microsoft.SourceLink.Common": { "type": "Transitive", - "resolved": "7.0.0", - "contentHash": "kmn78+LPVMOWeITUjIlfxUPDsI0R6G0RkeAMBmQxAJ7vBJn4q2dTva7pWi65ceN5vPGjJ9q/Uae2WKgvfktJAw==", - "dependencies": { - "System.Buffers": "4.5.1", - "System.Memory": "4.5.5" - } + "resolved": "8.0.0", + "contentHash": "dk9JPxTCIevS75HyEQ0E4OVAFhB2N+V9ShCXf8Q6FkUQZDkgLI12y679Nym1YqsiSysuQskT7Z+6nUf3yab6Vw==" }, "Polly": { "type": "Transitive", @@ -386,6 +397,49 @@ "Speckle.Autofac": "[2.0.999-local, )", "Speckle.Objects": "[3.0.1-alpha.11, )" } + }, + "Microsoft.Extensions.Logging.Abstractions": { + "type": "CentralTransitive", + "requested": "[7.0.0, )", + "resolved": "7.0.0", + "contentHash": "kmn78+LPVMOWeITUjIlfxUPDsI0R6G0RkeAMBmQxAJ7vBJn4q2dTva7pWi65ceN5vPGjJ9q/Uae2WKgvfktJAw==", + "dependencies": { + "System.Buffers": "4.5.1", + "System.Memory": "4.5.5" + } + }, + "Speckle.Core": { + "type": "CentralTransitive", + "requested": "[3.0.1-alpha.11, )", + "resolved": "3.0.1-alpha.11", + "contentHash": "Zt2dBJLlfziEACYCHThbhKypSjhoA01rTw9BzNI72c/BDyftXIz70Tetq/8ZMEqQnKqfmRyYADsAdWKxpdV0Hg==", + "dependencies": { + "GraphQL.Client": "6.0.0", + "Microsoft.CSharp": "4.7.0", + "Microsoft.Data.Sqlite": "7.0.5", + "Polly": "7.2.3", + "Polly.Contrib.WaitAndRetry": "1.1.1", + "Polly.Extensions.Http": "3.0.0", + "Sentry": "3.33.0", + "Sentry.Serilog": "3.33.0", + "Serilog": "2.12.0", + "Serilog.Enrichers.ClientInfo": "1.3.0", + "Serilog.Exceptions": "8.4.0", + "Serilog.Sinks.Console": "4.1.0", + "Serilog.Sinks.Seq": "5.2.2", + "SerilogTimings": "3.0.1", + "Speckle.Newtonsoft.Json": "13.0.2", + "System.DoubleNumerics": "3.1.3" + } + }, + "Speckle.Objects": { + "type": "CentralTransitive", + "requested": "[3.0.1-alpha.11, )", + "resolved": "3.0.1-alpha.11", + "contentHash": "YR7sei3OQBAi8R/kIu8bEmg5ELDIJK6l5fhOgdnqA9ZvD/fvmRb+09z8lIUTDsgdAdvYU/A/x9VxH9OGPbp9Kw==", + "dependencies": { + "Speckle.Core": "3.0.1-alpha.11" + } } } } diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2023/Speckle.Converters.Autocad2023.csproj b/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2023/Speckle.Converters.Autocad2023.csproj deleted file mode 100644 index 60d55503f4..0000000000 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2023/Speckle.Converters.Autocad2023.csproj +++ /dev/null @@ -1,18 +0,0 @@ - - - - net48 - x64 - - - - - - - - - - - - - diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2024/Speckle.Converters.Autocad2024.csproj b/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2024/Speckle.Converters.Autocad2024.csproj deleted file mode 100644 index f23b34ad29..0000000000 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2024/Speckle.Converters.Autocad2024.csproj +++ /dev/null @@ -1,18 +0,0 @@ - - - - net48 - x64 - - - - - - - - - - - - - diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/Speckle.Converters.Revit2023.DependencyInjection.csproj b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/Speckle.Converters.Revit2023.DependencyInjection.csproj index b9b0735ffe..a4ecb27491 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/Speckle.Converters.Revit2023.DependencyInjection.csproj +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/Speckle.Converters.Revit2023.DependencyInjection.csproj @@ -6,7 +6,7 @@ - + diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/packages.lock.json b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/packages.lock.json index 6bba1c44ba..928fe09a85 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/packages.lock.json +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/packages.lock.json @@ -1,7 +1,17 @@ { - "version": 1, + "version": 2, "dependencies": { ".NETFramework,Version=v4.8": { + "Microsoft.SourceLink.GitHub": { + "type": "Direct", + "requested": "[8.0.0, )", + "resolved": "8.0.0", + "contentHash": "G5q7OqtwIyGTkeIOAc3u2ZuV/kicQaec5EaRnc0pIeSnh9LUjj+PYQrJYBURvDt7twGl2PKA7nSN0kz1Zw5bnQ==", + "dependencies": { + "Microsoft.Build.Tasks.Git": "8.0.0", + "Microsoft.SourceLink.Common": "8.0.0" + } + }, "PolySharp": { "type": "Direct", "requested": "[1.14.1, )", @@ -80,6 +90,11 @@ "System.Threading.Tasks.Extensions": "4.5.4" } }, + "Microsoft.Build.Tasks.Git": { + "type": "Transitive", + "resolved": "8.0.0", + "contentHash": "bZKfSIKJRXLTuSzLudMFte/8CempWjVamNUR5eHJizsy+iuOuO/k2gnh7W0dHJmYY0tBf+gUErfluCv5mySAOQ==" + }, "Microsoft.CSharp": { "type": "Transitive", "resolved": "4.7.0", @@ -102,14 +117,10 @@ "SQLitePCLRaw.core": "2.1.4" } }, - "Microsoft.Extensions.Logging.Abstractions": { + "Microsoft.SourceLink.Common": { "type": "Transitive", - "resolved": "7.0.0", - "contentHash": "kmn78+LPVMOWeITUjIlfxUPDsI0R6G0RkeAMBmQxAJ7vBJn4q2dTva7pWi65ceN5vPGjJ9q/Uae2WKgvfktJAw==", - "dependencies": { - "System.Buffers": "4.5.1", - "System.Memory": "4.5.5" - } + "resolved": "8.0.0", + "contentHash": "dk9JPxTCIevS75HyEQ0E4OVAFhB2N+V9ShCXf8Q6FkUQZDkgLI12y679Nym1YqsiSysuQskT7Z+6nUf3yab6Vw==" }, "Polly": { "type": "Transitive", @@ -220,52 +231,16 @@ "Serilog": "2.10.0" } }, - "Speckle.Core": { - "type": "Transitive", - "resolved": "3.0.1-alpha.11", - "contentHash": "Zt2dBJLlfziEACYCHThbhKypSjhoA01rTw9BzNI72c/BDyftXIz70Tetq/8ZMEqQnKqfmRyYADsAdWKxpdV0Hg==", - "dependencies": { - "GraphQL.Client": "6.0.0", - "Microsoft.CSharp": "4.7.0", - "Microsoft.Data.Sqlite": "7.0.5", - "Polly": "7.2.3", - "Polly.Contrib.WaitAndRetry": "1.1.1", - "Polly.Extensions.Http": "3.0.0", - "Sentry": "3.33.0", - "Sentry.Serilog": "3.33.0", - "Serilog": "2.12.0", - "Serilog.Enrichers.ClientInfo": "1.3.0", - "Serilog.Exceptions": "8.4.0", - "Serilog.Sinks.Console": "4.1.0", - "Serilog.Sinks.Seq": "5.2.2", - "SerilogTimings": "3.0.1", - "Speckle.Newtonsoft.Json": "13.0.2", - "System.DoubleNumerics": "3.1.3" - } - }, "Speckle.Newtonsoft.Json": { "type": "Transitive", "resolved": "13.0.2", "contentHash": "g1BejUZwax5PRfL6xHgLEK23sqHWOgOj9hE7RvfRRlN00AGt8GnPYt8HedSK7UB3HiRW8zCA9Pn0iiYxCK24BA==" }, - "Speckle.Objects": { - "type": "Transitive", - "resolved": "3.0.1-alpha.11", - "contentHash": "YR7sei3OQBAi8R/kIu8bEmg5ELDIJK6l5fhOgdnqA9ZvD/fvmRb+09z8lIUTDsgdAdvYU/A/x9VxH9OGPbp9Kw==", - "dependencies": { - "Speckle.Core": "3.0.1-alpha.11" - } - }, "Speckle.Revit.API": { "type": "Transitive", "resolved": "2023.0.0", "contentHash": "tq40eD7psgTbV+epNouYyqfo6+hEi7FmXZqcxEOsAV7zfYyWhL6Rt3vmojkWGNuerGbH6oRI6KIIxrnlCNb8Hw==" }, - "Speckle.Revit2023.Interfaces": { - "type": "Transitive", - "resolved": "0.1.1-preview.0.28", - "contentHash": "7szXg/vRvP3Wdrn2ZGriVOfsw+bddlpVorBkCIhSHHs5qVTTG8IAIrI1l9dO0/aullaTMF+Xgxm9x3w1aXPiuA==" - }, "SQLitePCLRaw.bundle_e_sqlite3": { "type": "Transitive", "resolved": "2.1.4", @@ -435,6 +410,55 @@ "Speckle.Converters.Common": "[2.0.999-local, )", "Speckle.Revit2023.Interfaces": "[0.1.1-preview.0.28, )" } + }, + "Microsoft.Extensions.Logging.Abstractions": { + "type": "CentralTransitive", + "requested": "[7.0.0, )", + "resolved": "7.0.0", + "contentHash": "kmn78+LPVMOWeITUjIlfxUPDsI0R6G0RkeAMBmQxAJ7vBJn4q2dTva7pWi65ceN5vPGjJ9q/Uae2WKgvfktJAw==", + "dependencies": { + "System.Buffers": "4.5.1", + "System.Memory": "4.5.5" + } + }, + "Speckle.Core": { + "type": "CentralTransitive", + "requested": "[3.0.1-alpha.11, )", + "resolved": "3.0.1-alpha.11", + "contentHash": "Zt2dBJLlfziEACYCHThbhKypSjhoA01rTw9BzNI72c/BDyftXIz70Tetq/8ZMEqQnKqfmRyYADsAdWKxpdV0Hg==", + "dependencies": { + "GraphQL.Client": "6.0.0", + "Microsoft.CSharp": "4.7.0", + "Microsoft.Data.Sqlite": "7.0.5", + "Polly": "7.2.3", + "Polly.Contrib.WaitAndRetry": "1.1.1", + "Polly.Extensions.Http": "3.0.0", + "Sentry": "3.33.0", + "Sentry.Serilog": "3.33.0", + "Serilog": "2.12.0", + "Serilog.Enrichers.ClientInfo": "1.3.0", + "Serilog.Exceptions": "8.4.0", + "Serilog.Sinks.Console": "4.1.0", + "Serilog.Sinks.Seq": "5.2.2", + "SerilogTimings": "3.0.1", + "Speckle.Newtonsoft.Json": "13.0.2", + "System.DoubleNumerics": "3.1.3" + } + }, + "Speckle.Objects": { + "type": "CentralTransitive", + "requested": "[3.0.1-alpha.11, )", + "resolved": "3.0.1-alpha.11", + "contentHash": "YR7sei3OQBAi8R/kIu8bEmg5ELDIJK6l5fhOgdnqA9ZvD/fvmRb+09z8lIUTDsgdAdvYU/A/x9VxH9OGPbp9Kw==", + "dependencies": { + "Speckle.Core": "3.0.1-alpha.11" + } + }, + "Speckle.Revit2023.Interfaces": { + "type": "CentralTransitive", + "requested": "[0.1.1-preview.0.28, )", + "resolved": "0.1.1-preview.0.28", + "contentHash": "7szXg/vRvP3Wdrn2ZGriVOfsw+bddlpVorBkCIhSHHs5qVTTG8IAIrI1l9dO0/aullaTMF+Xgxm9x3w1aXPiuA==" } } } diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/Speckle.Converters.Revit2023.Tests.csproj b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/Speckle.Converters.Revit2023.Tests.csproj index 4657d9e8ba..2839be1e72 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/Speckle.Converters.Revit2023.Tests.csproj +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/Speckle.Converters.Revit2023.Tests.csproj @@ -8,13 +8,12 @@ - - - - - - - + + + + + + diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/packages.lock.json b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/packages.lock.json index 818e420a39..2c05f6ade3 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/packages.lock.json +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/packages.lock.json @@ -1,13 +1,7 @@ { - "version": 1, + "version": 2, "dependencies": { ".NETFramework,Version=v4.8": { - "coverlet.collector": { - "type": "Direct", - "requested": "[6.0.2, )", - "resolved": "6.0.2", - "contentHash": "bJShQ6uWRTQ100ZeyiMqcFlhP7WJ+bCuabUs885dJiBEzMsJMSFr7BOyeCw4rgvQokteGi5rKQTlkhfQPUXg2A==" - }, "FluentAssertions": { "type": "Direct", "requested": "[6.12.0, )", @@ -26,6 +20,16 @@ "Microsoft.CodeCoverage": "17.10.0" } }, + "Microsoft.SourceLink.GitHub": { + "type": "Direct", + "requested": "[8.0.0, )", + "resolved": "8.0.0", + "contentHash": "G5q7OqtwIyGTkeIOAc3u2ZuV/kicQaec5EaRnc0pIeSnh9LUjj+PYQrJYBURvDt7twGl2PKA7nSN0kz1Zw5bnQ==", + "dependencies": { + "Microsoft.Build.Tasks.Git": "8.0.0", + "Microsoft.SourceLink.Common": "8.0.0" + } + }, "Moq": { "type": "Direct", "requested": "[4.20.70, )", @@ -114,6 +118,11 @@ "System.Threading.Tasks.Extensions": "4.5.4" } }, + "Microsoft.Build.Tasks.Git": { + "type": "Transitive", + "resolved": "8.0.0", + "contentHash": "bZKfSIKJRXLTuSzLudMFte/8CempWjVamNUR5eHJizsy+iuOuO/k2gnh7W0dHJmYY0tBf+gUErfluCv5mySAOQ==" + }, "Microsoft.CodeCoverage": { "type": "Transitive", "resolved": "17.10.0", @@ -174,15 +183,6 @@ "System.ValueTuple": "4.5.0" } }, - "Microsoft.Extensions.Logging.Abstractions": { - "type": "Transitive", - "resolved": "7.0.0", - "contentHash": "kmn78+LPVMOWeITUjIlfxUPDsI0R6G0RkeAMBmQxAJ7vBJn4q2dTva7pWi65ceN5vPGjJ9q/Uae2WKgvfktJAw==", - "dependencies": { - "System.Buffers": "4.5.1", - "System.Memory": "4.5.5" - } - }, "Microsoft.Extensions.Options": { "type": "Transitive", "resolved": "7.0.0", @@ -201,6 +201,11 @@ "System.Runtime.CompilerServices.Unsafe": "6.0.0" } }, + "Microsoft.SourceLink.Common": { + "type": "Transitive", + "resolved": "8.0.0", + "contentHash": "dk9JPxTCIevS75HyEQ0E4OVAFhB2N+V9ShCXf8Q6FkUQZDkgLI12y679Nym1YqsiSysuQskT7Z+6nUf3yab6Vw==" + }, "Polly": { "type": "Transitive", "resolved": "7.2.3", @@ -259,15 +264,6 @@ "Serilog": "2.8.0" } }, - "Serilog.Extensions.Logging": { - "type": "Transitive", - "resolved": "7.0.0", - "contentHash": "9faU0zNQqU7I6soVhLUMYaGNpgWv6cKlKb2S5AnS8gXxzW/em5Ladm/6FMrWTnX41cdbdGPOWNAo6adi4WaJ6A==", - "dependencies": { - "Microsoft.Extensions.Logging": "7.0.0", - "Serilog": "2.12.0" - } - }, "Serilog.Formatting.Compact": { "type": "Transitive", "resolved": "1.1.0", @@ -319,42 +315,11 @@ "Serilog": "2.10.0" } }, - "Speckle.Core": { - "type": "Transitive", - "resolved": "3.0.1-alpha.11", - "contentHash": "Zt2dBJLlfziEACYCHThbhKypSjhoA01rTw9BzNI72c/BDyftXIz70Tetq/8ZMEqQnKqfmRyYADsAdWKxpdV0Hg==", - "dependencies": { - "GraphQL.Client": "6.0.0", - "Microsoft.CSharp": "4.7.0", - "Microsoft.Data.Sqlite": "7.0.5", - "Polly": "7.2.3", - "Polly.Contrib.WaitAndRetry": "1.1.1", - "Polly.Extensions.Http": "3.0.0", - "Sentry": "3.33.0", - "Sentry.Serilog": "3.33.0", - "Serilog": "2.12.0", - "Serilog.Enrichers.ClientInfo": "1.3.0", - "Serilog.Exceptions": "8.4.0", - "Serilog.Sinks.Console": "4.1.0", - "Serilog.Sinks.Seq": "5.2.2", - "SerilogTimings": "3.0.1", - "Speckle.Newtonsoft.Json": "13.0.2", - "System.DoubleNumerics": "3.1.3" - } - }, "Speckle.Newtonsoft.Json": { "type": "Transitive", "resolved": "13.0.2", "contentHash": "g1BejUZwax5PRfL6xHgLEK23sqHWOgOj9hE7RvfRRlN00AGt8GnPYt8HedSK7UB3HiRW8zCA9Pn0iiYxCK24BA==" }, - "Speckle.Objects": { - "type": "Transitive", - "resolved": "3.0.1-alpha.11", - "contentHash": "YR7sei3OQBAi8R/kIu8bEmg5ELDIJK6l5fhOgdnqA9ZvD/fvmRb+09z8lIUTDsgdAdvYU/A/x9VxH9OGPbp9Kw==", - "dependencies": { - "Speckle.Core": "3.0.1-alpha.11" - } - }, "SQLitePCLRaw.bundle_e_sqlite3": { "type": "Transitive", "resolved": "2.1.4", @@ -536,6 +501,59 @@ "Speckle.Converters.Common": "[2.0.999-local, )", "Speckle.Revit2023.Interfaces": "[0.1.1-preview.0.28, )" } + }, + "Microsoft.Extensions.Logging.Abstractions": { + "type": "CentralTransitive", + "requested": "[7.0.0, )", + "resolved": "7.0.0", + "contentHash": "kmn78+LPVMOWeITUjIlfxUPDsI0R6G0RkeAMBmQxAJ7vBJn4q2dTva7pWi65ceN5vPGjJ9q/Uae2WKgvfktJAw==", + "dependencies": { + "System.Buffers": "4.5.1", + "System.Memory": "4.5.5" + } + }, + "Serilog.Extensions.Logging": { + "type": "CentralTransitive", + "requested": "[7.0.0, )", + "resolved": "7.0.0", + "contentHash": "9faU0zNQqU7I6soVhLUMYaGNpgWv6cKlKb2S5AnS8gXxzW/em5Ladm/6FMrWTnX41cdbdGPOWNAo6adi4WaJ6A==", + "dependencies": { + "Microsoft.Extensions.Logging": "7.0.0", + "Serilog": "2.12.0" + } + }, + "Speckle.Core": { + "type": "CentralTransitive", + "requested": "[3.0.1-alpha.11, )", + "resolved": "3.0.1-alpha.11", + "contentHash": "Zt2dBJLlfziEACYCHThbhKypSjhoA01rTw9BzNI72c/BDyftXIz70Tetq/8ZMEqQnKqfmRyYADsAdWKxpdV0Hg==", + "dependencies": { + "GraphQL.Client": "6.0.0", + "Microsoft.CSharp": "4.7.0", + "Microsoft.Data.Sqlite": "7.0.5", + "Polly": "7.2.3", + "Polly.Contrib.WaitAndRetry": "1.1.1", + "Polly.Extensions.Http": "3.0.0", + "Sentry": "3.33.0", + "Sentry.Serilog": "3.33.0", + "Serilog": "2.12.0", + "Serilog.Enrichers.ClientInfo": "1.3.0", + "Serilog.Exceptions": "8.4.0", + "Serilog.Sinks.Console": "4.1.0", + "Serilog.Sinks.Seq": "5.2.2", + "SerilogTimings": "3.0.1", + "Speckle.Newtonsoft.Json": "13.0.2", + "System.DoubleNumerics": "3.1.3" + } + }, + "Speckle.Objects": { + "type": "CentralTransitive", + "requested": "[3.0.1-alpha.11, )", + "resolved": "3.0.1-alpha.11", + "contentHash": "YR7sei3OQBAi8R/kIu8bEmg5ELDIJK6l5fhOgdnqA9ZvD/fvmRb+09z8lIUTDsgdAdvYU/A/x9VxH9OGPbp9Kw==", + "dependencies": { + "Speckle.Core": "3.0.1-alpha.11" + } } } } diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023/Speckle.Converters.Revit2023.csproj b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023/Speckle.Converters.Revit2023.csproj index 26aa7a8647..e3c04fcf68 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023/Speckle.Converters.Revit2023.csproj +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023/Speckle.Converters.Revit2023.csproj @@ -9,7 +9,7 @@ - + diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023/packages.lock.json b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023/packages.lock.json index d873133c84..220a146664 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023/packages.lock.json +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023/packages.lock.json @@ -1,7 +1,17 @@ { - "version": 1, + "version": 2, "dependencies": { ".NETFramework,Version=v4.8": { + "Microsoft.SourceLink.GitHub": { + "type": "Direct", + "requested": "[8.0.0, )", + "resolved": "8.0.0", + "contentHash": "G5q7OqtwIyGTkeIOAc3u2ZuV/kicQaec5EaRnc0pIeSnh9LUjj+PYQrJYBURvDt7twGl2PKA7nSN0kz1Zw5bnQ==", + "dependencies": { + "Microsoft.Build.Tasks.Git": "8.0.0", + "Microsoft.SourceLink.Common": "8.0.0" + } + }, "PolySharp": { "type": "Direct", "requested": "[1.14.1, )", @@ -60,6 +70,11 @@ "System.Threading.Tasks.Extensions": "4.5.4" } }, + "Microsoft.Build.Tasks.Git": { + "type": "Transitive", + "resolved": "8.0.0", + "contentHash": "bZKfSIKJRXLTuSzLudMFte/8CempWjVamNUR5eHJizsy+iuOuO/k2gnh7W0dHJmYY0tBf+gUErfluCv5mySAOQ==" + }, "Microsoft.CSharp": { "type": "Transitive", "resolved": "4.7.0", @@ -82,14 +97,10 @@ "SQLitePCLRaw.core": "2.1.4" } }, - "Microsoft.Extensions.Logging.Abstractions": { + "Microsoft.SourceLink.Common": { "type": "Transitive", - "resolved": "7.0.0", - "contentHash": "kmn78+LPVMOWeITUjIlfxUPDsI0R6G0RkeAMBmQxAJ7vBJn4q2dTva7pWi65ceN5vPGjJ9q/Uae2WKgvfktJAw==", - "dependencies": { - "System.Buffers": "4.5.1", - "System.Memory": "4.5.5" - } + "resolved": "8.0.0", + "contentHash": "dk9JPxTCIevS75HyEQ0E4OVAFhB2N+V9ShCXf8Q6FkUQZDkgLI12y679Nym1YqsiSysuQskT7Z+6nUf3yab6Vw==" }, "Polly": { "type": "Transitive", @@ -200,42 +211,11 @@ "Serilog": "2.10.0" } }, - "Speckle.Core": { - "type": "Transitive", - "resolved": "3.0.1-alpha.11", - "contentHash": "Zt2dBJLlfziEACYCHThbhKypSjhoA01rTw9BzNI72c/BDyftXIz70Tetq/8ZMEqQnKqfmRyYADsAdWKxpdV0Hg==", - "dependencies": { - "GraphQL.Client": "6.0.0", - "Microsoft.CSharp": "4.7.0", - "Microsoft.Data.Sqlite": "7.0.5", - "Polly": "7.2.3", - "Polly.Contrib.WaitAndRetry": "1.1.1", - "Polly.Extensions.Http": "3.0.0", - "Sentry": "3.33.0", - "Sentry.Serilog": "3.33.0", - "Serilog": "2.12.0", - "Serilog.Enrichers.ClientInfo": "1.3.0", - "Serilog.Exceptions": "8.4.0", - "Serilog.Sinks.Console": "4.1.0", - "Serilog.Sinks.Seq": "5.2.2", - "SerilogTimings": "3.0.1", - "Speckle.Newtonsoft.Json": "13.0.2", - "System.DoubleNumerics": "3.1.3" - } - }, "Speckle.Newtonsoft.Json": { "type": "Transitive", "resolved": "13.0.2", "contentHash": "g1BejUZwax5PRfL6xHgLEK23sqHWOgOj9hE7RvfRRlN00AGt8GnPYt8HedSK7UB3HiRW8zCA9Pn0iiYxCK24BA==" }, - "Speckle.Objects": { - "type": "Transitive", - "resolved": "3.0.1-alpha.11", - "contentHash": "YR7sei3OQBAi8R/kIu8bEmg5ELDIJK6l5fhOgdnqA9ZvD/fvmRb+09z8lIUTDsgdAdvYU/A/x9VxH9OGPbp9Kw==", - "dependencies": { - "Speckle.Core": "3.0.1-alpha.11" - } - }, "SQLitePCLRaw.bundle_e_sqlite3": { "type": "Transitive", "resolved": "2.1.4", @@ -386,6 +366,49 @@ "Speckle.Autofac": "[2.0.999-local, )", "Speckle.Objects": "[3.0.1-alpha.11, )" } + }, + "Microsoft.Extensions.Logging.Abstractions": { + "type": "CentralTransitive", + "requested": "[7.0.0, )", + "resolved": "7.0.0", + "contentHash": "kmn78+LPVMOWeITUjIlfxUPDsI0R6G0RkeAMBmQxAJ7vBJn4q2dTva7pWi65ceN5vPGjJ9q/Uae2WKgvfktJAw==", + "dependencies": { + "System.Buffers": "4.5.1", + "System.Memory": "4.5.5" + } + }, + "Speckle.Core": { + "type": "CentralTransitive", + "requested": "[3.0.1-alpha.11, )", + "resolved": "3.0.1-alpha.11", + "contentHash": "Zt2dBJLlfziEACYCHThbhKypSjhoA01rTw9BzNI72c/BDyftXIz70Tetq/8ZMEqQnKqfmRyYADsAdWKxpdV0Hg==", + "dependencies": { + "GraphQL.Client": "6.0.0", + "Microsoft.CSharp": "4.7.0", + "Microsoft.Data.Sqlite": "7.0.5", + "Polly": "7.2.3", + "Polly.Contrib.WaitAndRetry": "1.1.1", + "Polly.Extensions.Http": "3.0.0", + "Sentry": "3.33.0", + "Sentry.Serilog": "3.33.0", + "Serilog": "2.12.0", + "Serilog.Enrichers.ClientInfo": "1.3.0", + "Serilog.Exceptions": "8.4.0", + "Serilog.Sinks.Console": "4.1.0", + "Serilog.Sinks.Seq": "5.2.2", + "SerilogTimings": "3.0.1", + "Speckle.Newtonsoft.Json": "13.0.2", + "System.DoubleNumerics": "3.1.3" + } + }, + "Speckle.Objects": { + "type": "CentralTransitive", + "requested": "[3.0.1-alpha.11, )", + "resolved": "3.0.1-alpha.11", + "contentHash": "YR7sei3OQBAi8R/kIu8bEmg5ELDIJK6l5fhOgdnqA9ZvD/fvmRb+09z8lIUTDsgdAdvYU/A/x9VxH9OGPbp9Kw==", + "dependencies": { + "Speckle.Core": "3.0.1-alpha.11" + } } } } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/Speckle.Converters.Rhino7.DependencyInjection.csproj b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/Speckle.Converters.Rhino7.DependencyInjection.csproj index 052b08bafc..a9a52748e3 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/Speckle.Converters.Rhino7.DependencyInjection.csproj +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/Speckle.Converters.Rhino7.DependencyInjection.csproj @@ -11,6 +11,6 @@ - + diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/packages.lock.json b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/packages.lock.json index c6f96ec282..7e98fae831 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/packages.lock.json +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/packages.lock.json @@ -1,7 +1,17 @@ { - "version": 1, + "version": 2, "dependencies": { ".NETFramework,Version=v4.8": { + "Microsoft.SourceLink.GitHub": { + "type": "Direct", + "requested": "[8.0.0, )", + "resolved": "8.0.0", + "contentHash": "G5q7OqtwIyGTkeIOAc3u2ZuV/kicQaec5EaRnc0pIeSnh9LUjj+PYQrJYBURvDt7twGl2PKA7nSN0kz1Zw5bnQ==", + "dependencies": { + "Microsoft.Build.Tasks.Git": "8.0.0", + "Microsoft.SourceLink.Common": "8.0.0" + } + }, "PolySharp": { "type": "Direct", "requested": "[1.14.1, )", @@ -60,6 +70,11 @@ "System.Threading.Tasks.Extensions": "4.5.4" } }, + "Microsoft.Build.Tasks.Git": { + "type": "Transitive", + "resolved": "8.0.0", + "contentHash": "bZKfSIKJRXLTuSzLudMFte/8CempWjVamNUR5eHJizsy+iuOuO/k2gnh7W0dHJmYY0tBf+gUErfluCv5mySAOQ==" + }, "Microsoft.CSharp": { "type": "Transitive", "resolved": "4.7.0", @@ -82,14 +97,10 @@ "SQLitePCLRaw.core": "2.1.4" } }, - "Microsoft.Extensions.Logging.Abstractions": { + "Microsoft.SourceLink.Common": { "type": "Transitive", - "resolved": "7.0.0", - "contentHash": "kmn78+LPVMOWeITUjIlfxUPDsI0R6G0RkeAMBmQxAJ7vBJn4q2dTva7pWi65ceN5vPGjJ9q/Uae2WKgvfktJAw==", - "dependencies": { - "System.Buffers": "4.5.1", - "System.Memory": "4.5.5" - } + "resolved": "8.0.0", + "contentHash": "dk9JPxTCIevS75HyEQ0E4OVAFhB2N+V9ShCXf8Q6FkUQZDkgLI12y679Nym1YqsiSysuQskT7Z+6nUf3yab6Vw==" }, "Polly": { "type": "Transitive", @@ -200,42 +211,11 @@ "Serilog": "2.10.0" } }, - "Speckle.Core": { - "type": "Transitive", - "resolved": "3.0.1-alpha.11", - "contentHash": "Zt2dBJLlfziEACYCHThbhKypSjhoA01rTw9BzNI72c/BDyftXIz70Tetq/8ZMEqQnKqfmRyYADsAdWKxpdV0Hg==", - "dependencies": { - "GraphQL.Client": "6.0.0", - "Microsoft.CSharp": "4.7.0", - "Microsoft.Data.Sqlite": "7.0.5", - "Polly": "7.2.3", - "Polly.Contrib.WaitAndRetry": "1.1.1", - "Polly.Extensions.Http": "3.0.0", - "Sentry": "3.33.0", - "Sentry.Serilog": "3.33.0", - "Serilog": "2.12.0", - "Serilog.Enrichers.ClientInfo": "1.3.0", - "Serilog.Exceptions": "8.4.0", - "Serilog.Sinks.Console": "4.1.0", - "Serilog.Sinks.Seq": "5.2.2", - "SerilogTimings": "3.0.1", - "Speckle.Newtonsoft.Json": "13.0.2", - "System.DoubleNumerics": "3.1.3" - } - }, "Speckle.Newtonsoft.Json": { "type": "Transitive", "resolved": "13.0.2", "contentHash": "g1BejUZwax5PRfL6xHgLEK23sqHWOgOj9hE7RvfRRlN00AGt8GnPYt8HedSK7UB3HiRW8zCA9Pn0iiYxCK24BA==" }, - "Speckle.Objects": { - "type": "Transitive", - "resolved": "3.0.1-alpha.11", - "contentHash": "YR7sei3OQBAi8R/kIu8bEmg5ELDIJK6l5fhOgdnqA9ZvD/fvmRb+09z8lIUTDsgdAdvYU/A/x9VxH9OGPbp9Kw==", - "dependencies": { - "Speckle.Core": "3.0.1-alpha.11" - } - }, "SQLitePCLRaw.bundle_e_sqlite3": { "type": "Transitive", "resolved": "2.1.4", @@ -400,6 +380,49 @@ "Speckle.Converters.Common": "[2.0.999-local, )", "Speckle.Rhino7.Interfaces": "[0.1.1-preview.0.28, )" } + }, + "Microsoft.Extensions.Logging.Abstractions": { + "type": "CentralTransitive", + "requested": "[7.0.0, )", + "resolved": "7.0.0", + "contentHash": "kmn78+LPVMOWeITUjIlfxUPDsI0R6G0RkeAMBmQxAJ7vBJn4q2dTva7pWi65ceN5vPGjJ9q/Uae2WKgvfktJAw==", + "dependencies": { + "System.Buffers": "4.5.1", + "System.Memory": "4.5.5" + } + }, + "Speckle.Core": { + "type": "CentralTransitive", + "requested": "[3.0.1-alpha.11, )", + "resolved": "3.0.1-alpha.11", + "contentHash": "Zt2dBJLlfziEACYCHThbhKypSjhoA01rTw9BzNI72c/BDyftXIz70Tetq/8ZMEqQnKqfmRyYADsAdWKxpdV0Hg==", + "dependencies": { + "GraphQL.Client": "6.0.0", + "Microsoft.CSharp": "4.7.0", + "Microsoft.Data.Sqlite": "7.0.5", + "Polly": "7.2.3", + "Polly.Contrib.WaitAndRetry": "1.1.1", + "Polly.Extensions.Http": "3.0.0", + "Sentry": "3.33.0", + "Sentry.Serilog": "3.33.0", + "Serilog": "2.12.0", + "Serilog.Enrichers.ClientInfo": "1.3.0", + "Serilog.Exceptions": "8.4.0", + "Serilog.Sinks.Console": "4.1.0", + "Serilog.Sinks.Seq": "5.2.2", + "SerilogTimings": "3.0.1", + "Speckle.Newtonsoft.Json": "13.0.2", + "System.DoubleNumerics": "3.1.3" + } + }, + "Speckle.Objects": { + "type": "CentralTransitive", + "requested": "[3.0.1-alpha.11, )", + "resolved": "3.0.1-alpha.11", + "contentHash": "YR7sei3OQBAi8R/kIu8bEmg5ELDIJK6l5fhOgdnqA9ZvD/fvmRb+09z8lIUTDsgdAdvYU/A/x9VxH9OGPbp9Kw==", + "dependencies": { + "Speckle.Core": "3.0.1-alpha.11" + } } } } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Speckle.Converters.Rhino7.csproj b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Speckle.Converters.Rhino7.csproj index 72c57460cd..206a1eecf0 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Speckle.Converters.Rhino7.csproj +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Speckle.Converters.Rhino7.csproj @@ -4,7 +4,7 @@ net48 - + diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/packages.lock.json b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/packages.lock.json index d748c89324..e88d9d0998 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/packages.lock.json +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/packages.lock.json @@ -1,7 +1,17 @@ { - "version": 1, + "version": 2, "dependencies": { ".NETFramework,Version=v4.8": { + "Microsoft.SourceLink.GitHub": { + "type": "Direct", + "requested": "[8.0.0, )", + "resolved": "8.0.0", + "contentHash": "G5q7OqtwIyGTkeIOAc3u2ZuV/kicQaec5EaRnc0pIeSnh9LUjj+PYQrJYBURvDt7twGl2PKA7nSN0kz1Zw5bnQ==", + "dependencies": { + "Microsoft.Build.Tasks.Git": "8.0.0", + "Microsoft.SourceLink.Common": "8.0.0" + } + }, "PolySharp": { "type": "Direct", "requested": "[1.14.1, )", @@ -60,6 +70,11 @@ "System.Threading.Tasks.Extensions": "4.5.4" } }, + "Microsoft.Build.Tasks.Git": { + "type": "Transitive", + "resolved": "8.0.0", + "contentHash": "bZKfSIKJRXLTuSzLudMFte/8CempWjVamNUR5eHJizsy+iuOuO/k2gnh7W0dHJmYY0tBf+gUErfluCv5mySAOQ==" + }, "Microsoft.CSharp": { "type": "Transitive", "resolved": "4.7.0", @@ -82,14 +97,10 @@ "SQLitePCLRaw.core": "2.1.4" } }, - "Microsoft.Extensions.Logging.Abstractions": { + "Microsoft.SourceLink.Common": { "type": "Transitive", - "resolved": "7.0.0", - "contentHash": "kmn78+LPVMOWeITUjIlfxUPDsI0R6G0RkeAMBmQxAJ7vBJn4q2dTva7pWi65ceN5vPGjJ9q/Uae2WKgvfktJAw==", - "dependencies": { - "System.Buffers": "4.5.1", - "System.Memory": "4.5.5" - } + "resolved": "8.0.0", + "contentHash": "dk9JPxTCIevS75HyEQ0E4OVAFhB2N+V9ShCXf8Q6FkUQZDkgLI12y679Nym1YqsiSysuQskT7Z+6nUf3yab6Vw==" }, "Polly": { "type": "Transitive", @@ -200,42 +211,11 @@ "Serilog": "2.10.0" } }, - "Speckle.Core": { - "type": "Transitive", - "resolved": "3.0.1-alpha.11", - "contentHash": "Zt2dBJLlfziEACYCHThbhKypSjhoA01rTw9BzNI72c/BDyftXIz70Tetq/8ZMEqQnKqfmRyYADsAdWKxpdV0Hg==", - "dependencies": { - "GraphQL.Client": "6.0.0", - "Microsoft.CSharp": "4.7.0", - "Microsoft.Data.Sqlite": "7.0.5", - "Polly": "7.2.3", - "Polly.Contrib.WaitAndRetry": "1.1.1", - "Polly.Extensions.Http": "3.0.0", - "Sentry": "3.33.0", - "Sentry.Serilog": "3.33.0", - "Serilog": "2.12.0", - "Serilog.Enrichers.ClientInfo": "1.3.0", - "Serilog.Exceptions": "8.4.0", - "Serilog.Sinks.Console": "4.1.0", - "Serilog.Sinks.Seq": "5.2.2", - "SerilogTimings": "3.0.1", - "Speckle.Newtonsoft.Json": "13.0.2", - "System.DoubleNumerics": "3.1.3" - } - }, "Speckle.Newtonsoft.Json": { "type": "Transitive", "resolved": "13.0.2", "contentHash": "g1BejUZwax5PRfL6xHgLEK23sqHWOgOj9hE7RvfRRlN00AGt8GnPYt8HedSK7UB3HiRW8zCA9Pn0iiYxCK24BA==" }, - "Speckle.Objects": { - "type": "Transitive", - "resolved": "3.0.1-alpha.11", - "contentHash": "YR7sei3OQBAi8R/kIu8bEmg5ELDIJK6l5fhOgdnqA9ZvD/fvmRb+09z8lIUTDsgdAdvYU/A/x9VxH9OGPbp9Kw==", - "dependencies": { - "Speckle.Core": "3.0.1-alpha.11" - } - }, "SQLitePCLRaw.bundle_e_sqlite3": { "type": "Transitive", "resolved": "2.1.4", @@ -386,6 +366,49 @@ "Speckle.Autofac": "[2.0.999-local, )", "Speckle.Objects": "[3.0.1-alpha.11, )" } + }, + "Microsoft.Extensions.Logging.Abstractions": { + "type": "CentralTransitive", + "requested": "[7.0.0, )", + "resolved": "7.0.0", + "contentHash": "kmn78+LPVMOWeITUjIlfxUPDsI0R6G0RkeAMBmQxAJ7vBJn4q2dTva7pWi65ceN5vPGjJ9q/Uae2WKgvfktJAw==", + "dependencies": { + "System.Buffers": "4.5.1", + "System.Memory": "4.5.5" + } + }, + "Speckle.Core": { + "type": "CentralTransitive", + "requested": "[3.0.1-alpha.11, )", + "resolved": "3.0.1-alpha.11", + "contentHash": "Zt2dBJLlfziEACYCHThbhKypSjhoA01rTw9BzNI72c/BDyftXIz70Tetq/8ZMEqQnKqfmRyYADsAdWKxpdV0Hg==", + "dependencies": { + "GraphQL.Client": "6.0.0", + "Microsoft.CSharp": "4.7.0", + "Microsoft.Data.Sqlite": "7.0.5", + "Polly": "7.2.3", + "Polly.Contrib.WaitAndRetry": "1.1.1", + "Polly.Extensions.Http": "3.0.0", + "Sentry": "3.33.0", + "Sentry.Serilog": "3.33.0", + "Serilog": "2.12.0", + "Serilog.Enrichers.ClientInfo": "1.3.0", + "Serilog.Exceptions": "8.4.0", + "Serilog.Sinks.Console": "4.1.0", + "Serilog.Sinks.Seq": "5.2.2", + "SerilogTimings": "3.0.1", + "Speckle.Newtonsoft.Json": "13.0.2", + "System.DoubleNumerics": "3.1.3" + } + }, + "Speckle.Objects": { + "type": "CentralTransitive", + "requested": "[3.0.1-alpha.11, )", + "resolved": "3.0.1-alpha.11", + "contentHash": "YR7sei3OQBAi8R/kIu8bEmg5ELDIJK6l5fhOgdnqA9ZvD/fvmRb+09z8lIUTDsgdAdvYU/A/x9VxH9OGPbp9Kw==", + "dependencies": { + "Speckle.Core": "3.0.1-alpha.11" + } } } } diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI.WebView/Speckle.Connectors.DUI.WebView.csproj b/DUI3-DX/DUI3/Speckle.Connectors.DUI.WebView/Speckle.Connectors.DUI.WebView.csproj index ed1204c751..4f80899e94 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI.WebView/Speckle.Connectors.DUI.WebView.csproj +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI.WebView/Speckle.Connectors.DUI.WebView.csproj @@ -7,10 +7,10 @@ - + - \ No newline at end of file + diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI.WebView/packages.lock.json b/DUI3-DX/DUI3/Speckle.Connectors.DUI.WebView/packages.lock.json index 9b1e4b087b..2586c0cd45 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI.WebView/packages.lock.json +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI.WebView/packages.lock.json @@ -1,7 +1,17 @@ { - "version": 1, + "version": 2, "dependencies": { ".NETFramework,Version=v4.8": { + "Microsoft.SourceLink.GitHub": { + "type": "Direct", + "requested": "[8.0.0, )", + "resolved": "8.0.0", + "contentHash": "G5q7OqtwIyGTkeIOAc3u2ZuV/kicQaec5EaRnc0pIeSnh9LUjj+PYQrJYBURvDt7twGl2PKA7nSN0kz1Zw5bnQ==", + "dependencies": { + "Microsoft.Build.Tasks.Git": "8.0.0", + "Microsoft.SourceLink.Common": "8.0.0" + } + }, "Microsoft.Web.WebView2": { "type": "Direct", "requested": "[1.0.1823.32, )", @@ -60,6 +70,11 @@ "System.Threading.Tasks.Extensions": "4.5.4" } }, + "Microsoft.Build.Tasks.Git": { + "type": "Transitive", + "resolved": "8.0.0", + "contentHash": "bZKfSIKJRXLTuSzLudMFte/8CempWjVamNUR5eHJizsy+iuOuO/k2gnh7W0dHJmYY0tBf+gUErfluCv5mySAOQ==" + }, "Microsoft.CSharp": { "type": "Transitive", "resolved": "4.7.0", @@ -115,15 +130,6 @@ "System.ValueTuple": "4.5.0" } }, - "Microsoft.Extensions.Logging.Abstractions": { - "type": "Transitive", - "resolved": "7.0.0", - "contentHash": "kmn78+LPVMOWeITUjIlfxUPDsI0R6G0RkeAMBmQxAJ7vBJn4q2dTva7pWi65ceN5vPGjJ9q/Uae2WKgvfktJAw==", - "dependencies": { - "System.Buffers": "4.5.1", - "System.Memory": "4.5.5" - } - }, "Microsoft.Extensions.Options": { "type": "Transitive", "resolved": "7.0.0", @@ -142,6 +148,11 @@ "System.Runtime.CompilerServices.Unsafe": "6.0.0" } }, + "Microsoft.SourceLink.Common": { + "type": "Transitive", + "resolved": "8.0.0", + "contentHash": "dk9JPxTCIevS75HyEQ0E4OVAFhB2N+V9ShCXf8Q6FkUQZDkgLI12y679Nym1YqsiSysuQskT7Z+6nUf3yab6Vw==" + }, "Polly": { "type": "Transitive", "resolved": "7.2.3", @@ -200,15 +211,6 @@ "Serilog": "2.8.0" } }, - "Serilog.Extensions.Logging": { - "type": "Transitive", - "resolved": "7.0.0", - "contentHash": "9faU0zNQqU7I6soVhLUMYaGNpgWv6cKlKb2S5AnS8gXxzW/em5Ladm/6FMrWTnX41cdbdGPOWNAo6adi4WaJ6A==", - "dependencies": { - "Microsoft.Extensions.Logging": "7.0.0", - "Serilog": "2.12.0" - } - }, "Serilog.Formatting.Compact": { "type": "Transitive", "resolved": "1.1.0", @@ -422,11 +424,6 @@ "System.ValueTuple": "4.5.0" } }, - "System.Threading.Tasks.Dataflow": { - "type": "Transitive", - "resolved": "6.0.0", - "contentHash": "+tyDCU3/B1lDdOOAJywHQoFwyXIUghIaP2BxG79uvhfTnO+D9qIgjVlL/JV2NTliYbMHpd6eKDmHp2VHpij7MA==" - }, "System.Threading.Tasks.Extensions": { "type": "Transitive", "resolved": "4.5.4", @@ -463,9 +460,69 @@ "Speckle.Autofac": "[2.0.999-local, )", "Speckle.Core": "[3.0.1-alpha.11, )" } + }, + "Microsoft.Extensions.Logging.Abstractions": { + "type": "CentralTransitive", + "requested": "[7.0.0, )", + "resolved": "7.0.0", + "contentHash": "kmn78+LPVMOWeITUjIlfxUPDsI0R6G0RkeAMBmQxAJ7vBJn4q2dTva7pWi65ceN5vPGjJ9q/Uae2WKgvfktJAw==", + "dependencies": { + "System.Buffers": "4.5.1", + "System.Memory": "4.5.5" + } + }, + "Serilog.Extensions.Logging": { + "type": "CentralTransitive", + "requested": "[7.0.0, )", + "resolved": "7.0.0", + "contentHash": "9faU0zNQqU7I6soVhLUMYaGNpgWv6cKlKb2S5AnS8gXxzW/em5Ladm/6FMrWTnX41cdbdGPOWNAo6adi4WaJ6A==", + "dependencies": { + "Microsoft.Extensions.Logging": "7.0.0", + "Serilog": "2.12.0" + } + }, + "Speckle.Core": { + "type": "CentralTransitive", + "requested": "[3.0.1-alpha.11, )", + "resolved": "3.0.1-alpha.11", + "contentHash": "Zt2dBJLlfziEACYCHThbhKypSjhoA01rTw9BzNI72c/BDyftXIz70Tetq/8ZMEqQnKqfmRyYADsAdWKxpdV0Hg==", + "dependencies": { + "GraphQL.Client": "6.0.0", + "Microsoft.CSharp": "4.7.0", + "Microsoft.Data.Sqlite": "7.0.5", + "Polly": "7.2.3", + "Polly.Contrib.WaitAndRetry": "1.1.1", + "Polly.Extensions.Http": "3.0.0", + "Sentry": "3.33.0", + "Sentry.Serilog": "3.33.0", + "Serilog": "2.12.0", + "Serilog.Enrichers.ClientInfo": "1.3.0", + "Serilog.Exceptions": "8.4.0", + "Serilog.Sinks.Console": "4.1.0", + "Serilog.Sinks.Seq": "5.2.2", + "SerilogTimings": "3.0.1", + "Speckle.Newtonsoft.Json": "13.0.2", + "System.DoubleNumerics": "3.1.3" + } + }, + "System.Threading.Tasks.Dataflow": { + "type": "CentralTransitive", + "requested": "[6.0.0, )", + "resolved": "6.0.0", + "contentHash": "+tyDCU3/B1lDdOOAJywHQoFwyXIUghIaP2BxG79uvhfTnO+D9qIgjVlL/JV2NTliYbMHpd6eKDmHp2VHpij7MA==" } }, "net6.0-windows7.0": { + "Microsoft.SourceLink.GitHub": { + "type": "Direct", + "requested": "[8.0.0, )", + "resolved": "8.0.0", + "contentHash": "G5q7OqtwIyGTkeIOAc3u2ZuV/kicQaec5EaRnc0pIeSnh9LUjj+PYQrJYBURvDt7twGl2PKA7nSN0kz1Zw5bnQ==", + "dependencies": { + "Microsoft.Build.Tasks.Git": "8.0.0", + "Microsoft.SourceLink.Common": "8.0.0" + } + }, "Microsoft.Web.WebView2": { "type": "Direct", "requested": "[1.0.1823.32, )", @@ -553,6 +610,11 @@ "System.Text.Encodings.Web": "4.5.0" } }, + "Microsoft.Build.Tasks.Git": { + "type": "Transitive", + "resolved": "8.0.0", + "contentHash": "bZKfSIKJRXLTuSzLudMFte/8CempWjVamNUR5eHJizsy+iuOuO/k2gnh7W0dHJmYY0tBf+gUErfluCv5mySAOQ==" + }, "Microsoft.CSharp": { "type": "Transitive", "resolved": "4.7.0", @@ -599,11 +661,6 @@ "Microsoft.Extensions.Options": "7.0.0" } }, - "Microsoft.Extensions.Logging.Abstractions": { - "type": "Transitive", - "resolved": "7.0.0", - "contentHash": "kmn78+LPVMOWeITUjIlfxUPDsI0R6G0RkeAMBmQxAJ7vBJn4q2dTva7pWi65ceN5vPGjJ9q/Uae2WKgvfktJAw==" - }, "Microsoft.Extensions.ObjectPool": { "type": "Transitive", "resolved": "2.2.0", @@ -635,6 +692,11 @@ "System.Buffers": "4.5.0" } }, + "Microsoft.SourceLink.Common": { + "type": "Transitive", + "resolved": "8.0.0", + "contentHash": "dk9JPxTCIevS75HyEQ0E4OVAFhB2N+V9ShCXf8Q6FkUQZDkgLI12y679Nym1YqsiSysuQskT7Z+6nUf3yab6Vw==" + }, "Polly": { "type": "Transitive", "resolved": "7.2.3", @@ -690,15 +752,6 @@ "System.Reflection.TypeExtensions": "4.7.0" } }, - "Serilog.Extensions.Logging": { - "type": "Transitive", - "resolved": "7.0.0", - "contentHash": "9faU0zNQqU7I6soVhLUMYaGNpgWv6cKlKb2S5AnS8gXxzW/em5Ladm/6FMrWTnX41cdbdGPOWNAo6adi4WaJ6A==", - "dependencies": { - "Microsoft.Extensions.Logging": "7.0.0", - "Serilog": "2.12.0" - } - }, "Serilog.Formatting.Compact": { "type": "Transitive", "resolved": "1.1.0", @@ -846,11 +899,6 @@ "resolved": "4.5.0", "contentHash": "Xg4G4Indi4dqP1iuAiMSwpiWS54ZghzR644OtsRCm/m/lBMG8dUBhLVN7hLm8NNrNTR+iGbshCPTwrvxZPlm4g==" }, - "System.Threading.Tasks.Dataflow": { - "type": "Transitive", - "resolved": "6.0.0", - "contentHash": "+tyDCU3/B1lDdOOAJywHQoFwyXIUghIaP2BxG79uvhfTnO+D9qIgjVlL/JV2NTliYbMHpd6eKDmHp2VHpij7MA==" - }, "speckle.autofac": { "type": "Project", "dependencies": { @@ -874,6 +922,52 @@ "Speckle.Autofac": "[2.0.999-local, )", "Speckle.Core": "[3.0.1-alpha.11, )" } + }, + "Microsoft.Extensions.Logging.Abstractions": { + "type": "CentralTransitive", + "requested": "[7.0.0, )", + "resolved": "7.0.0", + "contentHash": "kmn78+LPVMOWeITUjIlfxUPDsI0R6G0RkeAMBmQxAJ7vBJn4q2dTva7pWi65ceN5vPGjJ9q/Uae2WKgvfktJAw==" + }, + "Serilog.Extensions.Logging": { + "type": "CentralTransitive", + "requested": "[7.0.0, )", + "resolved": "7.0.0", + "contentHash": "9faU0zNQqU7I6soVhLUMYaGNpgWv6cKlKb2S5AnS8gXxzW/em5Ladm/6FMrWTnX41cdbdGPOWNAo6adi4WaJ6A==", + "dependencies": { + "Microsoft.Extensions.Logging": "7.0.0", + "Serilog": "2.12.0" + } + }, + "Speckle.Core": { + "type": "CentralTransitive", + "requested": "[3.0.1-alpha.11, )", + "resolved": "3.0.1-alpha.11", + "contentHash": "Zt2dBJLlfziEACYCHThbhKypSjhoA01rTw9BzNI72c/BDyftXIz70Tetq/8ZMEqQnKqfmRyYADsAdWKxpdV0Hg==", + "dependencies": { + "GraphQL.Client": "6.0.0", + "Microsoft.CSharp": "4.7.0", + "Microsoft.Data.Sqlite": "7.0.5", + "Polly": "7.2.3", + "Polly.Contrib.WaitAndRetry": "1.1.1", + "Polly.Extensions.Http": "3.0.0", + "Sentry": "3.33.0", + "Sentry.Serilog": "3.33.0", + "Serilog": "2.12.0", + "Serilog.Enrichers.ClientInfo": "1.3.0", + "Serilog.Exceptions": "8.4.0", + "Serilog.Sinks.Console": "4.1.0", + "Serilog.Sinks.Seq": "5.2.2", + "SerilogTimings": "3.0.1", + "Speckle.Newtonsoft.Json": "13.0.2", + "System.DoubleNumerics": "3.1.3" + } + }, + "System.Threading.Tasks.Dataflow": { + "type": "CentralTransitive", + "requested": "[6.0.0, )", + "resolved": "6.0.0", + "contentHash": "+tyDCU3/B1lDdOOAJywHQoFwyXIUghIaP2BxG79uvhfTnO+D9qIgjVlL/JV2NTliYbMHpd6eKDmHp2VHpij7MA==" } } } diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Speckle.Connectors.DUI.csproj b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Speckle.Connectors.DUI.csproj index 6d4602c693..421db57bc1 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Speckle.Connectors.DUI.csproj +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Speckle.Connectors.DUI.csproj @@ -1,13 +1,13 @@ - + netstandard2.0 - - - + + + diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/packages.lock.json b/DUI3-DX/DUI3/Speckle.Connectors.DUI/packages.lock.json index 8b1d8f5d09..d1e30f591b 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/packages.lock.json +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/packages.lock.json @@ -1,5 +1,5 @@ { - "version": 1, + "version": 2, "dependencies": { ".NETStandard,Version=v2.0": { "Microsoft.Extensions.Logging.Abstractions": { @@ -12,6 +12,16 @@ "System.Memory": "4.5.5" } }, + "Microsoft.SourceLink.GitHub": { + "type": "Direct", + "requested": "[8.0.0, )", + "resolved": "8.0.0", + "contentHash": "G5q7OqtwIyGTkeIOAc3u2ZuV/kicQaec5EaRnc0pIeSnh9LUjj+PYQrJYBURvDt7twGl2PKA7nSN0kz1Zw5bnQ==", + "dependencies": { + "Microsoft.Build.Tasks.Git": "8.0.0", + "Microsoft.SourceLink.Common": "8.0.0" + } + }, "NETStandard.Library": { "type": "Direct", "requested": "[2.0.3, )", @@ -140,6 +150,11 @@ "System.Threading.Tasks.Extensions": "4.5.4" } }, + "Microsoft.Build.Tasks.Git": { + "type": "Transitive", + "resolved": "8.0.0", + "contentHash": "bZKfSIKJRXLTuSzLudMFte/8CempWjVamNUR5eHJizsy+iuOuO/k2gnh7W0dHJmYY0tBf+gUErfluCv5mySAOQ==" + }, "Microsoft.CSharp": { "type": "Transitive", "resolved": "4.7.0", @@ -237,6 +252,11 @@ "resolved": "1.1.0", "contentHash": "aOZA3BWfz9RXjpzt0sRJJMjAscAUm3Hoa4UWAfceV9UTYxgwZ1lZt5nO2myFf+/jetYQo4uTP7zS8sJY67BBxg==" }, + "Microsoft.SourceLink.Common": { + "type": "Transitive", + "resolved": "8.0.0", + "contentHash": "dk9JPxTCIevS75HyEQ0E4OVAFhB2N+V9ShCXf8Q6FkUQZDkgLI12y679Nym1YqsiSysuQskT7Z+6nUf3yab6Vw==" + }, "Polly": { "type": "Transitive", "resolved": "7.2.3", @@ -296,15 +316,6 @@ "System.Reflection.TypeExtensions": "4.7.0" } }, - "Serilog.Extensions.Logging": { - "type": "Transitive", - "resolved": "7.0.0", - "contentHash": "9faU0zNQqU7I6soVhLUMYaGNpgWv6cKlKb2S5AnS8gXxzW/em5Ladm/6FMrWTnX41cdbdGPOWNAo6adi4WaJ6A==", - "dependencies": { - "Microsoft.Extensions.Logging": "7.0.0", - "Serilog": "2.12.0" - } - }, "Serilog.Formatting.Compact": { "type": "Transitive", "resolved": "1.1.0", @@ -529,6 +540,16 @@ "Speckle.Autofac": "[2.0.999-local, )", "Speckle.Core": "[3.0.1-alpha.11, )" } + }, + "Serilog.Extensions.Logging": { + "type": "CentralTransitive", + "requested": "[7.0.0, )", + "resolved": "7.0.0", + "contentHash": "9faU0zNQqU7I6soVhLUMYaGNpgWv6cKlKb2S5AnS8gXxzW/em5Ladm/6FMrWTnX41cdbdGPOWNAo6adi4WaJ6A==", + "dependencies": { + "Microsoft.Extensions.Logging": "7.0.0", + "Serilog": "2.12.0" + } } } } diff --git a/DUI3-DX/Directory.Build.props b/DUI3-DX/Directory.Build.props index ecc6709aba..7093d49171 100644 --- a/DUI3-DX/Directory.Build.props +++ b/DUI3-DX/Directory.Build.props @@ -7,10 +7,12 @@ true false true + true + true + + + true + true + $(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb - - - - - diff --git a/DUI3-DX/Directory.Packages.props b/DUI3-DX/Directory.Packages.props new file mode 100644 index 0000000000..5e7ea97006 --- /dev/null +++ b/DUI3-DX/Directory.Packages.props @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/DUI3-DX/Sdk/Speckle.Autofac/Speckle.Autofac.csproj b/DUI3-DX/Sdk/Speckle.Autofac/Speckle.Autofac.csproj index e1524d1db6..c87411e8e9 100644 --- a/DUI3-DX/Sdk/Speckle.Autofac/Speckle.Autofac.csproj +++ b/DUI3-DX/Sdk/Speckle.Autofac/Speckle.Autofac.csproj @@ -1,4 +1,4 @@ - + true @@ -6,8 +6,8 @@ - - + + diff --git a/DUI3-DX/Sdk/Speckle.Autofac/packages.lock.json b/DUI3-DX/Sdk/Speckle.Autofac/packages.lock.json index c4cbeb83cb..bea3fab0df 100644 --- a/DUI3-DX/Sdk/Speckle.Autofac/packages.lock.json +++ b/DUI3-DX/Sdk/Speckle.Autofac/packages.lock.json @@ -1,5 +1,5 @@ { - "version": 1, + "version": 2, "dependencies": { ".NETStandard,Version=v2.0": { "Autofac": { @@ -21,6 +21,16 @@ "System.Memory": "4.5.5" } }, + "Microsoft.SourceLink.GitHub": { + "type": "Direct", + "requested": "[8.0.0, )", + "resolved": "8.0.0", + "contentHash": "G5q7OqtwIyGTkeIOAc3u2ZuV/kicQaec5EaRnc0pIeSnh9LUjj+PYQrJYBURvDt7twGl2PKA7nSN0kz1Zw5bnQ==", + "dependencies": { + "Microsoft.Build.Tasks.Git": "8.0.0", + "Microsoft.SourceLink.Common": "8.0.0" + } + }, "NETStandard.Library": { "type": "Direct", "requested": "[2.0.3, )", @@ -42,318 +52,34 @@ "resolved": "0.9.5", "contentHash": "oU/L7pN1R7q8KkbrpQ3WJnHirPHqn+9DEA7asOcUiggV5dzVg1A/VYs7GOSusD24njxXh03tE3a2oTLOjt3cVg==" }, - "GraphQL.Client": { - "type": "Transitive", - "resolved": "6.0.0", - "contentHash": "8yPNBbuVBpTptivyAlak4GZvbwbUcjeQTL4vN1HKHRuOykZ4r7l5fcLS6vpyPyLn0x8FsL31xbOIKyxbmR9rbA==", - "dependencies": { - "GraphQL.Client.Abstractions": "6.0.0", - "GraphQL.Client.Abstractions.Websocket": "6.0.0", - "System.Reactive": "5.0.0" - } - }, - "GraphQL.Client.Abstractions": { - "type": "Transitive", - "resolved": "6.0.0", - "contentHash": "h7uzWFORHZ+CCjwr/ThAyXMr0DPpzEANDa4Uo54wqCQ+j7qUKwqYTgOrb1W40sqbvNaZm9v/X7It31SUw0maHA==", - "dependencies": { - "GraphQL.Primitives": "6.0.0" - } - }, - "GraphQL.Client.Abstractions.Websocket": { - "type": "Transitive", - "resolved": "6.0.0", - "contentHash": "Nr9bPf8gIOvLuXpqEpqr9z9jslYFJOvd0feHth3/kPqeR3uMbjF5pjiwh4jxyMcxHdr8Pb6QiXkV3hsSyt0v7A==", - "dependencies": { - "GraphQL.Client.Abstractions": "6.0.0" - } - }, - "GraphQL.Primitives": { - "type": "Transitive", - "resolved": "6.0.0", - "contentHash": "yg72rrYDapfsIUrul7aF6wwNnTJBOFvuA9VdDTQpPa8AlAriHbufeXYLBcodKjfUdkCnaiggX1U/nEP08Zb5GA==" - }, - "Microsoft.AspNetCore.Http": { - "type": "Transitive", - "resolved": "2.1.1", - "contentHash": "pPDcCW8spnyibK3krpxrOpaFHf5fjV6k1Hsl6gfh77N/8gRYlLU7MOQDUnjpEwdlHmtxwJKQJNxZqVQOmJGRUw==", - "dependencies": { - "Microsoft.AspNetCore.Http.Abstractions": "2.1.1", - "Microsoft.AspNetCore.WebUtilities": "2.1.1", - "Microsoft.Extensions.ObjectPool": "2.1.1", - "Microsoft.Extensions.Options": "2.1.1", - "Microsoft.Net.Http.Headers": "2.1.1" - } - }, - "Microsoft.AspNetCore.Http.Abstractions": { - "type": "Transitive", - "resolved": "2.1.1", - "contentHash": "kQUEVOU4loc8CPSb2WoHFTESqwIa8Ik7ysCBfTwzHAd0moWovc9JQLmhDIHlYLjHbyexqZAlkq/FPRUZqokebw==", - "dependencies": { - "Microsoft.AspNetCore.Http.Features": "2.1.1", - "System.Text.Encodings.Web": "4.5.0" - } - }, - "Microsoft.AspNetCore.Http.Features": { - "type": "Transitive", - "resolved": "2.1.1", - "contentHash": "VklZ7hWgSvHBcDtwYYkdMdI/adlf7ebxTZ9kdzAhX+gUs5jSHE9mZlTamdgf9miSsxc1QjNazHXTDJdVPZKKTw==", - "dependencies": { - "Microsoft.Extensions.Primitives": "2.1.1" - } - }, - "Microsoft.AspNetCore.WebUtilities": { - "type": "Transitive", - "resolved": "2.1.1", - "contentHash": "PGKIZt4+412Z/XPoSjvYu/QIbTxcAQuEFNoA1Pw8a9mgmO0ZhNBmfaNyhgXFf7Rq62kP0tT/2WXpxdcQhkFUPA==", - "dependencies": { - "Microsoft.Net.Http.Headers": "2.1.1", - "System.Text.Encodings.Web": "4.5.0" - } - }, "Microsoft.Bcl.AsyncInterfaces": { "type": "Transitive", - "resolved": "5.0.0", - "contentHash": "W8DPQjkMScOMTtJbPwmPyj9c3zYSFGawDW3jwlBOOsnY+EzZFLgNQ/UMkK35JmkNOVPdCyPr2Tw7Vv9N+KA3ZQ==", - "dependencies": { - "System.Threading.Tasks.Extensions": "4.5.4" - } - }, - "Microsoft.CSharp": { - "type": "Transitive", - "resolved": "4.7.0", - "contentHash": "pTj+D3uJWyN3My70i2Hqo+OXixq3Os2D1nJ2x92FFo6sk8fYS1m1WLNTs0Dc1uPaViH0YvEEwvzddQ7y4rhXmA==" - }, - "Microsoft.Data.Sqlite": { - "type": "Transitive", - "resolved": "7.0.5", - "contentHash": "KGxbPeWsQMnmQy43DSBxAFtHz3l2JX8EWBSGUCvT3CuZ8KsuzbkqMIJMDOxWtG8eZSoCDI04aiVQjWuuV8HmSw==", - "dependencies": { - "Microsoft.Data.Sqlite.Core": "7.0.5", - "SQLitePCLRaw.bundle_e_sqlite3": "2.1.4" - } - }, - "Microsoft.Data.Sqlite.Core": { - "type": "Transitive", - "resolved": "7.0.5", - "contentHash": "FTerRmQPqHrCrnoUzhBu+E+1DNGwyrAMLqHkAqOOOu5pGfyMOj8qQUBxI/gDtWtG11p49UxSfWmBzRNlwZqfUg==", - "dependencies": { - "SQLitePCLRaw.core": "2.1.4" - } - }, - "Microsoft.Extensions.DependencyInjection.Abstractions": { - "type": "Transitive", - "resolved": "2.1.1", - "contentHash": "MgYpU5cwZohUMKKg3sbPhvGG+eAZ/59E9UwPwlrUkyXU+PGzqwZg9yyQNjhxuAWmoNoFReoemeCku50prYSGzA==" - }, - "Microsoft.Extensions.ObjectPool": { - "type": "Transitive", - "resolved": "2.1.1", - "contentHash": "SErON45qh4ogDp6lr6UvVmFYW0FERihW+IQ+2JyFv1PUyWktcJytFaWH5zarufJvZwhci7Rf1IyGXr9pVEadTw==" - }, - "Microsoft.Extensions.Options": { - "type": "Transitive", - "resolved": "2.1.1", - "contentHash": "V7lXCU78lAbzaulCGFKojcCyG8RTJicEbiBkPJjFqiqXwndEBBIehdXRMWEVU3UtzQ1yDvphiWUL9th6/4gJ7w==", - "dependencies": { - "Microsoft.Extensions.DependencyInjection.Abstractions": "2.1.1", - "Microsoft.Extensions.Primitives": "2.1.1" - } - }, - "Microsoft.Extensions.Primitives": { - "type": "Transitive", - "resolved": "2.1.1", - "contentHash": "scJ1GZNIxMmjpENh0UZ8XCQ6vzr/LzeF9WvEA51Ix2OQGAs9WPgPu8ABVUdvpKPLuor/t05gm6menJK3PwqOXg==", + "resolved": "1.1.0", + "contentHash": "1Am6l4Vpn3/K32daEqZI+FFr96OlZkgwK2LcT3pZ2zWubR5zTPW3/FkO1Rat9kb7oQOa4rxgl9LJHc5tspCWfg==", "dependencies": { - "System.Memory": "4.5.1", - "System.Runtime.CompilerServices.Unsafe": "4.5.1" + "System.Threading.Tasks.Extensions": "4.5.2" } }, - "Microsoft.Net.Http.Headers": { + "Microsoft.Build.Tasks.Git": { "type": "Transitive", - "resolved": "2.1.1", - "contentHash": "lPNIphl8b2EuhOE9dMH6EZDmu7pS882O+HMi5BJNsigxHaWlBrYxZHFZgE18cyaPp6SSZcTkKkuzfjV/RRQKlA==", - "dependencies": { - "Microsoft.Extensions.Primitives": "2.1.1", - "System.Buffers": "4.5.0" - } + "resolved": "8.0.0", + "contentHash": "bZKfSIKJRXLTuSzLudMFte/8CempWjVamNUR5eHJizsy+iuOuO/k2gnh7W0dHJmYY0tBf+gUErfluCv5mySAOQ==" }, "Microsoft.NETCore.Platforms": { "type": "Transitive", "resolved": "1.1.0", "contentHash": "kz0PEW2lhqygehI/d6XsPCQzD7ff7gUJaVGPVETX611eadGsA3A877GdSlU0LRVMCTH/+P3o2iDTak+S08V2+A==" }, - "Microsoft.NETCore.Targets": { - "type": "Transitive", - "resolved": "1.1.0", - "contentHash": "aOZA3BWfz9RXjpzt0sRJJMjAscAUm3Hoa4UWAfceV9UTYxgwZ1lZt5nO2myFf+/jetYQo4uTP7zS8sJY67BBxg==" - }, - "Polly": { - "type": "Transitive", - "resolved": "7.2.3", - "contentHash": "DeCY0OFbNdNxsjntr1gTXHJ5pKUwYzp04Er2LLeN3g6pWhffsGuKVfMBLe1lw7x76HrPkLxKEFxBlpRxS2nDEQ==" - }, - "Polly.Contrib.WaitAndRetry": { - "type": "Transitive", - "resolved": "1.1.1", - "contentHash": "1MUQLiSo4KDkQe6nzQRhIU05lm9jlexX5BVsbuw0SL82ynZ+GzAHQxJVDPVBboxV37Po3SG077aX8DuSy8TkaA==" - }, - "Polly.Extensions.Http": { + "Microsoft.SourceLink.Common": { "type": "Transitive", - "resolved": "3.0.0", - "contentHash": "drrG+hB3pYFY7w1c3BD+lSGYvH2oIclH8GRSehgfyP5kjnFnHKQuuBhuHLv+PWyFuaTDyk/vfRpnxOzd11+J8g==", - "dependencies": { - "Polly": "7.1.0" - } - }, - "Sentry": { - "type": "Transitive", - "resolved": "3.33.0", - "contentHash": "8vbD2o6IR2wrRrkSiRbnodWGWUOqIlwYtzpjvPNOb5raJdOf+zxMwfS8f6nx9bmrTTfDj7KrCB8C/5OuicAc8A==", - "dependencies": { - "System.Reflection.Metadata": "5.0.0", - "System.Text.Json": "5.0.2" - } - }, - "Sentry.Serilog": { - "type": "Transitive", - "resolved": "3.33.0", - "contentHash": "V8BU7QGWg2qLYfNPqtuTBhC1opysny5l+Ifp6J6PhOeAxU0FssR7nYfbJVetrnLIoh2rd3DlJ6hHYYQosQYcUQ==", - "dependencies": { - "Sentry": "3.33.0", - "Serilog": "2.7.1" - } - }, - "Serilog": { - "type": "Transitive", - "resolved": "2.12.0", - "contentHash": "xaiJLIdu6rYMKfQMYUZgTy8YK7SMZjB4Yk50C/u//Z4OsvxkUfSPJy4nknfvwAC34yr13q7kcyh4grbwhSxyZg==" - }, - "Serilog.Enrichers.ClientInfo": { - "type": "Transitive", - "resolved": "1.3.0", - "contentHash": "mTc7PM+wC9Hr7LWSwqt5mmnlAr7RJs+eTb3PGPRhwdOackk95MkhUZognuxXEdlW19HAFNmEBTSBY5DfLwM8jQ==", - "dependencies": { - "Microsoft.AspNetCore.Http": "2.1.1", - "Serilog": "2.7.1" - } - }, - "Serilog.Exceptions": { - "type": "Transitive", - "resolved": "8.4.0", - "contentHash": "nc/+hUw3lsdo0zCj0KMIybAu7perMx79vu72w0za9Nsi6mWyNkGXxYxakAjWB7nEmYL6zdmhEQRB4oJ2ALUeug==", - "dependencies": { - "Serilog": "2.8.0", - "System.Reflection.TypeExtensions": "4.7.0" - } - }, - "Serilog.Formatting.Compact": { - "type": "Transitive", - "resolved": "1.1.0", - "contentHash": "pNroKVjo+rDqlxNG5PXkRLpfSCuDOBY0ri6jp9PLe505ljqwhwZz8ospy2vWhQlFu5GkIesh3FcDs4n7sWZODA==", - "dependencies": { - "Serilog": "2.8.0" - } - }, - "Serilog.Sinks.Console": { - "type": "Transitive", - "resolved": "4.1.0", - "contentHash": "K6N5q+5fetjnJPvCmkWOpJ/V8IEIoMIB1s86OzBrbxwTyHxdx3pmz4H+8+O/Dc/ftUX12DM1aynx/dDowkwzqg==", - "dependencies": { - "Serilog": "2.10.0" - } - }, - "Serilog.Sinks.File": { - "type": "Transitive", - "resolved": "5.0.0", - "contentHash": "uwV5hdhWPwUH1szhO8PJpFiahqXmzPzJT/sOijH/kFgUx+cyoDTMM8MHD0adw9+Iem6itoibbUXHYslzXsLEAg==", - "dependencies": { - "Serilog": "2.10.0" - } - }, - "Serilog.Sinks.PeriodicBatching": { - "type": "Transitive", - "resolved": "3.1.0", - "contentHash": "NDWR7m3PalVlGEq3rzoktrXikjFMLmpwF0HI4sowo8YDdU+gqPlTHlDQiOGxHfB0sTfjPA9JjA7ctKG9zqjGkw==", - "dependencies": { - "Serilog": "2.0.0" - } - }, - "Serilog.Sinks.Seq": { - "type": "Transitive", - "resolved": "5.2.2", - "contentHash": "1Csmo5ua7NKUe0yXUx+zsRefjAniPWcXFhUXxXG8pwo0iMiw2gjn9SOkgYnnxbgWqmlGv236w0N/dHc2v5XwMg==", - "dependencies": { - "Serilog": "2.12.0", - "Serilog.Formatting.Compact": "1.1.0", - "Serilog.Sinks.File": "5.0.0", - "Serilog.Sinks.PeriodicBatching": "3.1.0" - } - }, - "SerilogTimings": { - "type": "Transitive", - "resolved": "3.0.1", - "contentHash": "Zs28eTgszAMwpIrbBnWHBI50yuxL50p/dmAUWmy75+axdZYK/Sjm5/5m1N/CisR8acJUhTVcjPZrsB1P5iv0Uw==", - "dependencies": { - "Serilog": "2.10.0" - } - }, - "Speckle.Newtonsoft.Json": { - "type": "Transitive", - "resolved": "13.0.2", - "contentHash": "g1BejUZwax5PRfL6xHgLEK23sqHWOgOj9hE7RvfRRlN00AGt8GnPYt8HedSK7UB3HiRW8zCA9Pn0iiYxCK24BA==" - }, - "SQLitePCLRaw.bundle_e_sqlite3": { - "type": "Transitive", - "resolved": "2.1.4", - "contentHash": "EWI1olKDjFEBMJu0+3wuxwziIAdWDVMYLhuZ3Qs84rrz+DHwD00RzWPZCa+bLnHCf3oJwuFZIRsHT5p236QXww==", - "dependencies": { - "SQLitePCLRaw.lib.e_sqlite3": "2.1.4", - "SQLitePCLRaw.provider.e_sqlite3": "2.1.4" - } - }, - "SQLitePCLRaw.core": { - "type": "Transitive", - "resolved": "2.1.4", - "contentHash": "inBjvSHo9UDKneGNzfUfDjK08JzlcIhn1+SP5Y3m6cgXpCxXKCJDy6Mka7LpgSV+UZmKSnC8rTwB0SQ0xKu5pA==", - "dependencies": { - "System.Memory": "4.5.3" - } - }, - "SQLitePCLRaw.lib.e_sqlite3": { - "type": "Transitive", - "resolved": "2.1.4", - "contentHash": "2C9Q9eX7CPLveJA0rIhf9RXAvu+7nWZu1A2MdG6SD/NOu26TakGgL1nsbc0JAspGijFOo3HoN79xrx8a368fBg==" - }, - "SQLitePCLRaw.provider.e_sqlite3": { - "type": "Transitive", - "resolved": "2.1.4", - "contentHash": "CSlb5dUp1FMIkez9Iv5EXzpeq7rHryVNqwJMWnpq87j9zWZexaEMdisDktMsnnrzKM6ahNrsTkjqNodTBPBxtQ==", - "dependencies": { - "SQLitePCLRaw.core": "2.1.4" - } + "resolved": "8.0.0", + "contentHash": "dk9JPxTCIevS75HyEQ0E4OVAFhB2N+V9ShCXf8Q6FkUQZDkgLI12y679Nym1YqsiSysuQskT7Z+6nUf3yab6Vw==" }, "System.Buffers": { "type": "Transitive", "resolved": "4.5.1", "contentHash": "Rw7ijyl1qqRS0YQD/WycNst8hUUMgrMH4FCn1nNm27M4VxchZ1js3fVjQaANHO5f3sN4isvP4a+Met9Y4YomAg==" }, - "System.Collections.Immutable": { - "type": "Transitive", - "resolved": "5.0.0", - "contentHash": "FXkLXiK0sVVewcso0imKQoOxjoPAj42R8HtjjbSjVPAzwDfzoyoznWxgA3c38LDbN9SJux1xXoXYAhz98j7r2g==", - "dependencies": { - "System.Memory": "4.5.4" - } - }, - "System.DoubleNumerics": { - "type": "Transitive", - "resolved": "3.1.3", - "contentHash": "KRKEM/L3KBodjA9VOg3EifFVWUY6EOqaMB05UvPEDm7Zeby/kZW+4kdWUEPzW6xtkwf46p661L9NrbeeQhtLzw==", - "dependencies": { - "NETStandard.Library": "1.6.1" - } - }, "System.Memory": { "type": "Transitive", "resolved": "4.5.5", @@ -366,103 +92,20 @@ }, "System.Numerics.Vectors": { "type": "Transitive", - "resolved": "4.5.0", - "contentHash": "QQTlPTl06J/iiDbJCiepZ4H//BVraReU4O4EoRw1U02H5TLUIT7xn3GnDp9AXPSlJUDyFs4uWjWafNX6WrAojQ==" - }, - "System.Reactive": { - "type": "Transitive", - "resolved": "5.0.0", - "contentHash": "erBZjkQHWL9jpasCE/0qKAryzVBJFxGHVBAvgRN1bzM0q2s1S4oYREEEL0Vb+1kA/6BKb5FjUZMp5VXmy+gzkQ==", - "dependencies": { - "System.Runtime.InteropServices.WindowsRuntime": "4.3.0", - "System.Threading.Tasks.Extensions": "4.5.4" - } - }, - "System.Reflection.Metadata": { - "type": "Transitive", - "resolved": "5.0.0", - "contentHash": "5NecZgXktdGg34rh1OenY1rFNDCI8xSjFr+Z4OU4cU06AQHUdRnIIEeWENu3Wl4YowbzkymAIMvi3WyK9U53pQ==", - "dependencies": { - "System.Collections.Immutable": "5.0.0" - } - }, - "System.Reflection.TypeExtensions": { - "type": "Transitive", - "resolved": "4.7.0", - "contentHash": "VybpaOQQhqE6siHppMktjfGBw1GCwvCqiufqmP8F1nj7fTUNtW35LOEt3UZTEsECfo+ELAl/9o9nJx3U91i7vA==" - }, - "System.Runtime": { - "type": "Transitive", - "resolved": "4.3.0", - "contentHash": "JufQi0vPQ0xGnAczR13AUFglDyVYt4Kqnz1AZaiKZ5+GICq0/1MH/mO/eAJHt/mHW1zjKBJd7kV26SrxddAhiw==", - "dependencies": { - "Microsoft.NETCore.Platforms": "1.1.0", - "Microsoft.NETCore.Targets": "1.1.0" - } + "resolved": "4.4.0", + "contentHash": "UiLzLW+Lw6HLed1Hcg+8jSRttrbuXv7DANVj0DkL9g6EnnzbL75EB7EWsw5uRbhxd/4YdG8li5XizGWepmG3PQ==" }, "System.Runtime.CompilerServices.Unsafe": { "type": "Transitive", - "resolved": "5.0.0", - "contentHash": "ZD9TMpsmYJLrxbbmdvhwt9YEgG5WntEnZ/d1eH8JBX9LBp+Ju8BSBhUGbZMNVHHomWo2KVImJhTDl2hIgw/6MA==" - }, - "System.Runtime.InteropServices.WindowsRuntime": { - "type": "Transitive", - "resolved": "4.3.0", - "contentHash": "J4GUi3xZQLUBasNwZnjrffN8i5wpHrBtZoLG+OhRyGo/+YunMRWWtwoMDlUAIdmX0uRfpHIBDSV6zyr3yf00TA==", - "dependencies": { - "System.Runtime": "4.3.0" - } - }, - "System.Text.Encodings.Web": { - "type": "Transitive", - "resolved": "5.0.1", - "contentHash": "KmJ+CJXizDofbq6mpqDoRRLcxgOd2z9X3XoFNULSbvbqVRZkFX3istvr+MUjL6Zw1RT+RNdoI4GYidIINtgvqQ==", - "dependencies": { - "System.Buffers": "4.5.1", - "System.Memory": "4.5.4" - } - }, - "System.Text.Json": { - "type": "Transitive", - "resolved": "5.0.2", - "contentHash": "I47dVIGiV6SfAyppphxqupertT/5oZkYLDCX6vC3HpOI4ZLjyoKAreUoem2ie6G0RbRuFrlqz/PcTQjfb2DOfQ==", - "dependencies": { - "Microsoft.Bcl.AsyncInterfaces": "5.0.0", - "System.Buffers": "4.5.1", - "System.Memory": "4.5.4", - "System.Numerics.Vectors": "4.5.0", - "System.Runtime.CompilerServices.Unsafe": "5.0.0", - "System.Text.Encodings.Web": "5.0.1", - "System.Threading.Tasks.Extensions": "4.5.4" - } + "resolved": "4.5.3", + "contentHash": "3TIsJhD1EiiT0w2CcDMN/iSSwnNnsrnbzeVHSKkaEgV85txMprmuO+Yq2AdSbeVGcg28pdNDTPK87tJhX7VFHw==" }, "System.Threading.Tasks.Extensions": { "type": "Transitive", - "resolved": "4.5.4", - "contentHash": "zteT+G8xuGu6mS+mzDzYXbzS7rd3K6Fjb9RiZlYlJPam2/hU7JCBZBVEcywNuR+oZ1ncTvc/cq0faRr3P01OVg==", - "dependencies": { - "System.Runtime.CompilerServices.Unsafe": "4.5.3" - } - }, - "Speckle.Core": { - "type": "Project", + "resolved": "4.5.2", + "contentHash": "BG/TNxDFv0svAzx8OiMXDlsHfGw623BZ8tCXw4YLhDFDvDhNUEV58jKYMGRnkbJNm7c3JNNJDiN7JBMzxRBR2w==", "dependencies": { - "GraphQL.Client": "[6.0.0, )", - "Microsoft.CSharp": "[4.7.0, )", - "Microsoft.Data.Sqlite": "[7.0.5, )", - "Polly": "[7.2.3, )", - "Polly.Contrib.WaitAndRetry": "[1.1.1, )", - "Polly.Extensions.Http": "[3.0.0, )", - "Sentry": "[3.33.0, )", - "Sentry.Serilog": "[3.33.0, )", - "Serilog": "[2.12.0, )", - "Serilog.Enrichers.ClientInfo": "[1.3.0, )", - "Serilog.Exceptions": "[8.4.0, )", - "Serilog.Sinks.Console": "[4.1.0, )", - "Serilog.Sinks.Seq": "[5.2.2, )", - "SerilogTimings": "[3.0.1, )", - "Speckle.Newtonsoft.Json": "[13.0.2, )", - "System.DoubleNumerics": "[3.1.3, )" + "System.Runtime.CompilerServices.Unsafe": "4.5.2" } } } diff --git a/DUI3-DX/Sdk/Speckle.Connectors.Utils/Speckle.Connectors.Utils.csproj b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Speckle.Connectors.Utils.csproj index e2dfaccf8a..d379d2aace 100644 --- a/DUI3-DX/Sdk/Speckle.Connectors.Utils/Speckle.Connectors.Utils.csproj +++ b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Speckle.Connectors.Utils.csproj @@ -1,11 +1,11 @@ - + netstandard2.0 - - + + diff --git a/DUI3-DX/Sdk/Speckle.Connectors.Utils/packages.lock.json b/DUI3-DX/Sdk/Speckle.Connectors.Utils/packages.lock.json index 501db4a15e..077e72b92b 100644 --- a/DUI3-DX/Sdk/Speckle.Connectors.Utils/packages.lock.json +++ b/DUI3-DX/Sdk/Speckle.Connectors.Utils/packages.lock.json @@ -1,7 +1,17 @@ { - "version": 1, + "version": 2, "dependencies": { ".NETStandard,Version=v2.0": { + "Microsoft.SourceLink.GitHub": { + "type": "Direct", + "requested": "[8.0.0, )", + "resolved": "8.0.0", + "contentHash": "G5q7OqtwIyGTkeIOAc3u2ZuV/kicQaec5EaRnc0pIeSnh9LUjj+PYQrJYBURvDt7twGl2PKA7nSN0kz1Zw5bnQ==", + "dependencies": { + "Microsoft.Build.Tasks.Git": "8.0.0", + "Microsoft.SourceLink.Common": "8.0.0" + } + }, "NETStandard.Library": { "type": "Direct", "requested": "[2.0.3, )", @@ -134,6 +144,11 @@ "System.Threading.Tasks.Extensions": "4.5.4" } }, + "Microsoft.Build.Tasks.Git": { + "type": "Transitive", + "resolved": "8.0.0", + "contentHash": "bZKfSIKJRXLTuSzLudMFte/8CempWjVamNUR5eHJizsy+iuOuO/k2gnh7W0dHJmYY0tBf+gUErfluCv5mySAOQ==" + }, "Microsoft.CSharp": { "type": "Transitive", "resolved": "4.7.0", @@ -188,15 +203,6 @@ "System.Diagnostics.DiagnosticSource": "7.0.0" } }, - "Microsoft.Extensions.Logging.Abstractions": { - "type": "Transitive", - "resolved": "7.0.0", - "contentHash": "kmn78+LPVMOWeITUjIlfxUPDsI0R6G0RkeAMBmQxAJ7vBJn4q2dTva7pWi65ceN5vPGjJ9q/Uae2WKgvfktJAw==", - "dependencies": { - "System.Buffers": "4.5.1", - "System.Memory": "4.5.5" - } - }, "Microsoft.Extensions.ObjectPool": { "type": "Transitive", "resolved": "2.1.1", @@ -240,6 +246,11 @@ "resolved": "1.1.0", "contentHash": "aOZA3BWfz9RXjpzt0sRJJMjAscAUm3Hoa4UWAfceV9UTYxgwZ1lZt5nO2myFf+/jetYQo4uTP7zS8sJY67BBxg==" }, + "Microsoft.SourceLink.Common": { + "type": "Transitive", + "resolved": "8.0.0", + "contentHash": "dk9JPxTCIevS75HyEQ0E4OVAFhB2N+V9ShCXf8Q6FkUQZDkgLI12y679Nym1YqsiSysuQskT7Z+6nUf3yab6Vw==" + }, "Polly": { "type": "Transitive", "resolved": "7.2.3", @@ -515,6 +526,16 @@ "dependencies": { "Microsoft.Extensions.Logging.Abstractions": "[7.0.0, )" } + }, + "Microsoft.Extensions.Logging.Abstractions": { + "type": "CentralTransitive", + "requested": "[7.0.0, )", + "resolved": "7.0.0", + "contentHash": "kmn78+LPVMOWeITUjIlfxUPDsI0R6G0RkeAMBmQxAJ7vBJn4q2dTva7pWi65ceN5vPGjJ9q/Uae2WKgvfktJAw==", + "dependencies": { + "System.Buffers": "4.5.1", + "System.Memory": "4.5.5" + } } } } diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/Speckle.Converters.Common.DependencyInjection.csproj b/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/Speckle.Converters.Common.DependencyInjection.csproj index 7675aeeae6..b7e5a37e54 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/Speckle.Converters.Common.DependencyInjection.csproj +++ b/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/Speckle.Converters.Common.DependencyInjection.csproj @@ -5,7 +5,7 @@ - + diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/packages.lock.json b/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/packages.lock.json index e34336c3a4..19523196d8 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/packages.lock.json +++ b/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/packages.lock.json @@ -1,5 +1,5 @@ { - "version": 1, + "version": 2, "dependencies": { ".NETStandard,Version=v2.0": { "Autofac": { @@ -11,6 +11,16 @@ "Microsoft.Bcl.AsyncInterfaces": "1.1.0" } }, + "Microsoft.SourceLink.GitHub": { + "type": "Direct", + "requested": "[8.0.0, )", + "resolved": "8.0.0", + "contentHash": "G5q7OqtwIyGTkeIOAc3u2ZuV/kicQaec5EaRnc0pIeSnh9LUjj+PYQrJYBURvDt7twGl2PKA7nSN0kz1Zw5bnQ==", + "dependencies": { + "Microsoft.Build.Tasks.Git": "8.0.0", + "Microsoft.SourceLink.Common": "8.0.0" + } + }, "NETStandard.Library": { "type": "Direct", "requested": "[2.0.3, )", @@ -109,6 +119,11 @@ "System.Threading.Tasks.Extensions": "4.5.4" } }, + "Microsoft.Build.Tasks.Git": { + "type": "Transitive", + "resolved": "8.0.0", + "contentHash": "bZKfSIKJRXLTuSzLudMFte/8CempWjVamNUR5eHJizsy+iuOuO/k2gnh7W0dHJmYY0tBf+gUErfluCv5mySAOQ==" + }, "Microsoft.CSharp": { "type": "Transitive", "resolved": "4.7.0", @@ -136,15 +151,6 @@ "resolved": "2.1.1", "contentHash": "MgYpU5cwZohUMKKg3sbPhvGG+eAZ/59E9UwPwlrUkyXU+PGzqwZg9yyQNjhxuAWmoNoFReoemeCku50prYSGzA==" }, - "Microsoft.Extensions.Logging.Abstractions": { - "type": "Transitive", - "resolved": "7.0.0", - "contentHash": "kmn78+LPVMOWeITUjIlfxUPDsI0R6G0RkeAMBmQxAJ7vBJn4q2dTva7pWi65ceN5vPGjJ9q/Uae2WKgvfktJAw==", - "dependencies": { - "System.Buffers": "4.5.1", - "System.Memory": "4.5.5" - } - }, "Microsoft.Extensions.ObjectPool": { "type": "Transitive", "resolved": "2.1.1", @@ -187,6 +193,11 @@ "resolved": "1.1.0", "contentHash": "aOZA3BWfz9RXjpzt0sRJJMjAscAUm3Hoa4UWAfceV9UTYxgwZ1lZt5nO2myFf+/jetYQo4uTP7zS8sJY67BBxg==" }, + "Microsoft.SourceLink.Common": { + "type": "Transitive", + "resolved": "8.0.0", + "contentHash": "dk9JPxTCIevS75HyEQ0E4OVAFhB2N+V9ShCXf8Q6FkUQZDkgLI12y679Nym1YqsiSysuQskT7Z+6nUf3yab6Vw==" + }, "Polly": { "type": "Transitive", "resolved": "7.2.3", @@ -297,42 +308,11 @@ "Serilog": "2.10.0" } }, - "Speckle.Core": { - "type": "Transitive", - "resolved": "3.0.1-alpha.11", - "contentHash": "Zt2dBJLlfziEACYCHThbhKypSjhoA01rTw9BzNI72c/BDyftXIz70Tetq/8ZMEqQnKqfmRyYADsAdWKxpdV0Hg==", - "dependencies": { - "GraphQL.Client": "6.0.0", - "Microsoft.CSharp": "4.7.0", - "Microsoft.Data.Sqlite": "7.0.5", - "Polly": "7.2.3", - "Polly.Contrib.WaitAndRetry": "1.1.1", - "Polly.Extensions.Http": "3.0.0", - "Sentry": "3.33.0", - "Sentry.Serilog": "3.33.0", - "Serilog": "2.12.0", - "Serilog.Enrichers.ClientInfo": "1.3.0", - "Serilog.Exceptions": "8.4.0", - "Serilog.Sinks.Console": "4.1.0", - "Serilog.Sinks.Seq": "5.2.2", - "SerilogTimings": "3.0.1", - "Speckle.Newtonsoft.Json": "13.0.2", - "System.DoubleNumerics": "3.1.3" - } - }, "Speckle.Newtonsoft.Json": { "type": "Transitive", "resolved": "13.0.2", "contentHash": "g1BejUZwax5PRfL6xHgLEK23sqHWOgOj9hE7RvfRRlN00AGt8GnPYt8HedSK7UB3HiRW8zCA9Pn0iiYxCK24BA==" }, - "Speckle.Objects": { - "type": "Transitive", - "resolved": "3.0.1-alpha.11", - "contentHash": "YR7sei3OQBAi8R/kIu8bEmg5ELDIJK6l5fhOgdnqA9ZvD/fvmRb+09z8lIUTDsgdAdvYU/A/x9VxH9OGPbp9Kw==", - "dependencies": { - "Speckle.Core": "3.0.1-alpha.11" - } - }, "SQLitePCLRaw.bundle_e_sqlite3": { "type": "Transitive", "resolved": "2.1.4", @@ -486,6 +466,49 @@ "Speckle.Autofac": "[2.0.999-local, )", "Speckle.Objects": "[3.0.1-alpha.11, )" } + }, + "Microsoft.Extensions.Logging.Abstractions": { + "type": "CentralTransitive", + "requested": "[7.0.0, )", + "resolved": "7.0.0", + "contentHash": "kmn78+LPVMOWeITUjIlfxUPDsI0R6G0RkeAMBmQxAJ7vBJn4q2dTva7pWi65ceN5vPGjJ9q/Uae2WKgvfktJAw==", + "dependencies": { + "System.Buffers": "4.5.1", + "System.Memory": "4.5.5" + } + }, + "Speckle.Core": { + "type": "CentralTransitive", + "requested": "[3.0.1-alpha.11, )", + "resolved": "3.0.1-alpha.11", + "contentHash": "Zt2dBJLlfziEACYCHThbhKypSjhoA01rTw9BzNI72c/BDyftXIz70Tetq/8ZMEqQnKqfmRyYADsAdWKxpdV0Hg==", + "dependencies": { + "GraphQL.Client": "6.0.0", + "Microsoft.CSharp": "4.7.0", + "Microsoft.Data.Sqlite": "7.0.5", + "Polly": "7.2.3", + "Polly.Contrib.WaitAndRetry": "1.1.1", + "Polly.Extensions.Http": "3.0.0", + "Sentry": "3.33.0", + "Sentry.Serilog": "3.33.0", + "Serilog": "2.12.0", + "Serilog.Enrichers.ClientInfo": "1.3.0", + "Serilog.Exceptions": "8.4.0", + "Serilog.Sinks.Console": "4.1.0", + "Serilog.Sinks.Seq": "5.2.2", + "SerilogTimings": "3.0.1", + "Speckle.Newtonsoft.Json": "13.0.2", + "System.DoubleNumerics": "3.1.3" + } + }, + "Speckle.Objects": { + "type": "CentralTransitive", + "requested": "[3.0.1-alpha.11, )", + "resolved": "3.0.1-alpha.11", + "contentHash": "YR7sei3OQBAi8R/kIu8bEmg5ELDIJK6l5fhOgdnqA9ZvD/fvmRb+09z8lIUTDsgdAdvYU/A/x9VxH9OGPbp9Kw==", + "dependencies": { + "Speckle.Core": "3.0.1-alpha.11" + } } } } diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common.Tests/Speckle.Converters.Common.Tests.csproj b/DUI3-DX/Sdk/Speckle.Converters.Common.Tests/Speckle.Converters.Common.Tests.csproj index f1e4c53353..e5baa8e603 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common.Tests/Speckle.Converters.Common.Tests.csproj +++ b/DUI3-DX/Sdk/Speckle.Converters.Common.Tests/Speckle.Converters.Common.Tests.csproj @@ -8,13 +8,12 @@ - - - - - - - + + + + + + diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common.Tests/packages.lock.json b/DUI3-DX/Sdk/Speckle.Converters.Common.Tests/packages.lock.json index 7bbbb295a6..25241e1d85 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common.Tests/packages.lock.json +++ b/DUI3-DX/Sdk/Speckle.Converters.Common.Tests/packages.lock.json @@ -1,13 +1,7 @@ { - "version": 1, + "version": 2, "dependencies": { ".NETFramework,Version=v4.8": { - "coverlet.collector": { - "type": "Direct", - "requested": "[6.0.2, )", - "resolved": "6.0.2", - "contentHash": "bJShQ6uWRTQ100ZeyiMqcFlhP7WJ+bCuabUs885dJiBEzMsJMSFr7BOyeCw4rgvQokteGi5rKQTlkhfQPUXg2A==" - }, "FluentAssertions": { "type": "Direct", "requested": "[6.12.0, )", @@ -26,6 +20,16 @@ "Microsoft.CodeCoverage": "17.10.0" } }, + "Microsoft.SourceLink.GitHub": { + "type": "Direct", + "requested": "[8.0.0, )", + "resolved": "8.0.0", + "contentHash": "G5q7OqtwIyGTkeIOAc3u2ZuV/kicQaec5EaRnc0pIeSnh9LUjj+PYQrJYBURvDt7twGl2PKA7nSN0kz1Zw5bnQ==", + "dependencies": { + "Microsoft.Build.Tasks.Git": "8.0.0", + "Microsoft.SourceLink.Common": "8.0.0" + } + }, "Moq": { "type": "Direct", "requested": "[4.20.70, )", @@ -114,6 +118,11 @@ "System.Threading.Tasks.Extensions": "4.5.4" } }, + "Microsoft.Build.Tasks.Git": { + "type": "Transitive", + "resolved": "8.0.0", + "contentHash": "bZKfSIKJRXLTuSzLudMFte/8CempWjVamNUR5eHJizsy+iuOuO/k2gnh7W0dHJmYY0tBf+gUErfluCv5mySAOQ==" + }, "Microsoft.CodeCoverage": { "type": "Transitive", "resolved": "17.10.0", @@ -141,14 +150,10 @@ "SQLitePCLRaw.core": "2.1.4" } }, - "Microsoft.Extensions.Logging.Abstractions": { + "Microsoft.SourceLink.Common": { "type": "Transitive", - "resolved": "7.0.0", - "contentHash": "kmn78+LPVMOWeITUjIlfxUPDsI0R6G0RkeAMBmQxAJ7vBJn4q2dTva7pWi65ceN5vPGjJ9q/Uae2WKgvfktJAw==", - "dependencies": { - "System.Buffers": "4.5.1", - "System.Memory": "4.5.5" - } + "resolved": "8.0.0", + "contentHash": "dk9JPxTCIevS75HyEQ0E4OVAFhB2N+V9ShCXf8Q6FkUQZDkgLI12y679Nym1YqsiSysuQskT7Z+6nUf3yab6Vw==" }, "Polly": { "type": "Transitive", @@ -259,42 +264,11 @@ "Serilog": "2.10.0" } }, - "Speckle.Core": { - "type": "Transitive", - "resolved": "3.0.1-alpha.11", - "contentHash": "Zt2dBJLlfziEACYCHThbhKypSjhoA01rTw9BzNI72c/BDyftXIz70Tetq/8ZMEqQnKqfmRyYADsAdWKxpdV0Hg==", - "dependencies": { - "GraphQL.Client": "6.0.0", - "Microsoft.CSharp": "4.7.0", - "Microsoft.Data.Sqlite": "7.0.5", - "Polly": "7.2.3", - "Polly.Contrib.WaitAndRetry": "1.1.1", - "Polly.Extensions.Http": "3.0.0", - "Sentry": "3.33.0", - "Sentry.Serilog": "3.33.0", - "Serilog": "2.12.0", - "Serilog.Enrichers.ClientInfo": "1.3.0", - "Serilog.Exceptions": "8.4.0", - "Serilog.Sinks.Console": "4.1.0", - "Serilog.Sinks.Seq": "5.2.2", - "SerilogTimings": "3.0.1", - "Speckle.Newtonsoft.Json": "13.0.2", - "System.DoubleNumerics": "3.1.3" - } - }, "Speckle.Newtonsoft.Json": { "type": "Transitive", "resolved": "13.0.2", "contentHash": "g1BejUZwax5PRfL6xHgLEK23sqHWOgOj9hE7RvfRRlN00AGt8GnPYt8HedSK7UB3HiRW8zCA9Pn0iiYxCK24BA==" }, - "Speckle.Objects": { - "type": "Transitive", - "resolved": "3.0.1-alpha.11", - "contentHash": "YR7sei3OQBAi8R/kIu8bEmg5ELDIJK6l5fhOgdnqA9ZvD/fvmRb+09z8lIUTDsgdAdvYU/A/x9VxH9OGPbp9Kw==", - "dependencies": { - "Speckle.Core": "3.0.1-alpha.11" - } - }, "SQLitePCLRaw.bundle_e_sqlite3": { "type": "Transitive", "resolved": "2.1.4", @@ -445,6 +419,49 @@ "Speckle.Autofac": "[2.0.999-local, )", "Speckle.Objects": "[3.0.1-alpha.11, )" } + }, + "Microsoft.Extensions.Logging.Abstractions": { + "type": "CentralTransitive", + "requested": "[7.0.0, )", + "resolved": "7.0.0", + "contentHash": "kmn78+LPVMOWeITUjIlfxUPDsI0R6G0RkeAMBmQxAJ7vBJn4q2dTva7pWi65ceN5vPGjJ9q/Uae2WKgvfktJAw==", + "dependencies": { + "System.Buffers": "4.5.1", + "System.Memory": "4.5.5" + } + }, + "Speckle.Core": { + "type": "CentralTransitive", + "requested": "[3.0.1-alpha.11, )", + "resolved": "3.0.1-alpha.11", + "contentHash": "Zt2dBJLlfziEACYCHThbhKypSjhoA01rTw9BzNI72c/BDyftXIz70Tetq/8ZMEqQnKqfmRyYADsAdWKxpdV0Hg==", + "dependencies": { + "GraphQL.Client": "6.0.0", + "Microsoft.CSharp": "4.7.0", + "Microsoft.Data.Sqlite": "7.0.5", + "Polly": "7.2.3", + "Polly.Contrib.WaitAndRetry": "1.1.1", + "Polly.Extensions.Http": "3.0.0", + "Sentry": "3.33.0", + "Sentry.Serilog": "3.33.0", + "Serilog": "2.12.0", + "Serilog.Enrichers.ClientInfo": "1.3.0", + "Serilog.Exceptions": "8.4.0", + "Serilog.Sinks.Console": "4.1.0", + "Serilog.Sinks.Seq": "5.2.2", + "SerilogTimings": "3.0.1", + "Speckle.Newtonsoft.Json": "13.0.2", + "System.DoubleNumerics": "3.1.3" + } + }, + "Speckle.Objects": { + "type": "CentralTransitive", + "requested": "[3.0.1-alpha.11, )", + "resolved": "3.0.1-alpha.11", + "contentHash": "YR7sei3OQBAi8R/kIu8bEmg5ELDIJK6l5fhOgdnqA9ZvD/fvmRb+09z8lIUTDsgdAdvYU/A/x9VxH9OGPbp9Kw==", + "dependencies": { + "Speckle.Core": "3.0.1-alpha.11" + } } } } diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common/Speckle.Converters.Common.csproj b/DUI3-DX/Sdk/Speckle.Converters.Common/Speckle.Converters.Common.csproj index 1211ab6937..4bbe1058c7 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common/Speckle.Converters.Common.csproj +++ b/DUI3-DX/Sdk/Speckle.Converters.Common/Speckle.Converters.Common.csproj @@ -5,7 +5,7 @@ - + diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common/packages.lock.json b/DUI3-DX/Sdk/Speckle.Converters.Common/packages.lock.json index b29c15e4a5..0bd34a6305 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common/packages.lock.json +++ b/DUI3-DX/Sdk/Speckle.Converters.Common/packages.lock.json @@ -1,7 +1,17 @@ { - "version": 1, + "version": 2, "dependencies": { ".NETStandard,Version=v2.0": { + "Microsoft.SourceLink.GitHub": { + "type": "Direct", + "requested": "[8.0.0, )", + "resolved": "8.0.0", + "contentHash": "G5q7OqtwIyGTkeIOAc3u2ZuV/kicQaec5EaRnc0pIeSnh9LUjj+PYQrJYBURvDt7twGl2PKA7nSN0kz1Zw5bnQ==", + "dependencies": { + "Microsoft.Build.Tasks.Git": "8.0.0", + "Microsoft.SourceLink.Common": "8.0.0" + } + }, "NETStandard.Library": { "type": "Direct", "requested": "[2.0.3, )", @@ -109,6 +119,11 @@ "System.Threading.Tasks.Extensions": "4.5.4" } }, + "Microsoft.Build.Tasks.Git": { + "type": "Transitive", + "resolved": "8.0.0", + "contentHash": "bZKfSIKJRXLTuSzLudMFte/8CempWjVamNUR5eHJizsy+iuOuO/k2gnh7W0dHJmYY0tBf+gUErfluCv5mySAOQ==" + }, "Microsoft.CSharp": { "type": "Transitive", "resolved": "4.7.0", @@ -136,15 +151,6 @@ "resolved": "2.1.1", "contentHash": "MgYpU5cwZohUMKKg3sbPhvGG+eAZ/59E9UwPwlrUkyXU+PGzqwZg9yyQNjhxuAWmoNoFReoemeCku50prYSGzA==" }, - "Microsoft.Extensions.Logging.Abstractions": { - "type": "Transitive", - "resolved": "7.0.0", - "contentHash": "kmn78+LPVMOWeITUjIlfxUPDsI0R6G0RkeAMBmQxAJ7vBJn4q2dTva7pWi65ceN5vPGjJ9q/Uae2WKgvfktJAw==", - "dependencies": { - "System.Buffers": "4.5.1", - "System.Memory": "4.5.5" - } - }, "Microsoft.Extensions.ObjectPool": { "type": "Transitive", "resolved": "2.1.1", @@ -187,6 +193,11 @@ "resolved": "1.1.0", "contentHash": "aOZA3BWfz9RXjpzt0sRJJMjAscAUm3Hoa4UWAfceV9UTYxgwZ1lZt5nO2myFf+/jetYQo4uTP7zS8sJY67BBxg==" }, + "Microsoft.SourceLink.Common": { + "type": "Transitive", + "resolved": "8.0.0", + "contentHash": "dk9JPxTCIevS75HyEQ0E4OVAFhB2N+V9ShCXf8Q6FkUQZDkgLI12y679Nym1YqsiSysuQskT7Z+6nUf3yab6Vw==" + }, "Polly": { "type": "Transitive", "resolved": "7.2.3", @@ -297,29 +308,6 @@ "Serilog": "2.10.0" } }, - "Speckle.Core": { - "type": "Transitive", - "resolved": "3.0.1-alpha.11", - "contentHash": "Zt2dBJLlfziEACYCHThbhKypSjhoA01rTw9BzNI72c/BDyftXIz70Tetq/8ZMEqQnKqfmRyYADsAdWKxpdV0Hg==", - "dependencies": { - "GraphQL.Client": "6.0.0", - "Microsoft.CSharp": "4.7.0", - "Microsoft.Data.Sqlite": "7.0.5", - "Polly": "7.2.3", - "Polly.Contrib.WaitAndRetry": "1.1.1", - "Polly.Extensions.Http": "3.0.0", - "Sentry": "3.33.0", - "Sentry.Serilog": "3.33.0", - "Serilog": "2.12.0", - "Serilog.Enrichers.ClientInfo": "1.3.0", - "Serilog.Exceptions": "8.4.0", - "Serilog.Sinks.Console": "4.1.0", - "Serilog.Sinks.Seq": "5.2.2", - "SerilogTimings": "3.0.1", - "Speckle.Newtonsoft.Json": "13.0.2", - "System.DoubleNumerics": "3.1.3" - } - }, "Speckle.Newtonsoft.Json": { "type": "Transitive", "resolved": "13.0.2", @@ -471,6 +459,40 @@ "dependencies": { "Microsoft.Extensions.Logging.Abstractions": "[7.0.0, )" } + }, + "Microsoft.Extensions.Logging.Abstractions": { + "type": "CentralTransitive", + "requested": "[7.0.0, )", + "resolved": "7.0.0", + "contentHash": "kmn78+LPVMOWeITUjIlfxUPDsI0R6G0RkeAMBmQxAJ7vBJn4q2dTva7pWi65ceN5vPGjJ9q/Uae2WKgvfktJAw==", + "dependencies": { + "System.Buffers": "4.5.1", + "System.Memory": "4.5.5" + } + }, + "Speckle.Core": { + "type": "CentralTransitive", + "requested": "[3.0.1-alpha.11, )", + "resolved": "3.0.1-alpha.11", + "contentHash": "Zt2dBJLlfziEACYCHThbhKypSjhoA01rTw9BzNI72c/BDyftXIz70Tetq/8ZMEqQnKqfmRyYADsAdWKxpdV0Hg==", + "dependencies": { + "GraphQL.Client": "6.0.0", + "Microsoft.CSharp": "4.7.0", + "Microsoft.Data.Sqlite": "7.0.5", + "Polly": "7.2.3", + "Polly.Contrib.WaitAndRetry": "1.1.1", + "Polly.Extensions.Http": "3.0.0", + "Sentry": "3.33.0", + "Sentry.Serilog": "3.33.0", + "Serilog": "2.12.0", + "Serilog.Enrichers.ClientInfo": "1.3.0", + "Serilog.Exceptions": "8.4.0", + "Serilog.Sinks.Console": "4.1.0", + "Serilog.Sinks.Seq": "5.2.2", + "SerilogTimings": "3.0.1", + "Speckle.Newtonsoft.Json": "13.0.2", + "System.DoubleNumerics": "3.1.3" + } } } } From cd39d867065b53c111ff02adbe66642780cc863f Mon Sep 17 00:00:00 2001 From: Adam Hathcock Date: Thu, 27 Jun 2024 16:28:09 +0100 Subject: [PATCH 248/261] Rollback interfaces (#3540) * initial nuget references * fmt * remove unused revit dependency * Don't use new solution * remove unused file * update core * Manage V3 versions centrally (exception AutoCAD) * fixed up multiple autocad versions * Removal of Revit interfaces * Remove Rhino interfaces * fix up project dependencies * some changes from reviewing * Merge remote-tracking branch 'origin/dui3/alpha' into rollback-interfaces * merge fixes and fmt * more review changes * more fixes * recheck lock files * fix caching * logger IOC fixes * fix IOC and fmt * try stuff for columns? * use less nullables and revit root properly --- All.sln | 19 - Build/Consts.cs | 6 +- DUI3-DX.slnf | 2 - .../packages.lock.json | 31 - .../packages.lock.json | 49 +- .../Bindings/BasicConnectorBindingRevit.cs | 2 +- .../Bindings/RevitBaseBinding.cs | 2 +- .../Bindings/RevitSendBinding.cs | 2 +- .../Bindings/SelectionBinding.cs | 2 +- .../DependencyInjection/ProxyMapper.cs | 17 - .../RevitConnectorModule.cs | 10 +- .../Helpers/RevitConversionContextStack.cs | 38 -- .../HostApp/RevitDocumentStore.cs | 2 +- .../Operations/Send/RevitRootObjectBuilder.cs | 11 +- .../Plugin/RevitExternalApplication.cs | 3 +- .../Plugin/RevitIdleManager.cs | 2 +- .../Plugin/RevitPlugin.cs | 5 +- .../Speckle.Connectors.RevitShared.projitems | 23 +- .../DependencyInjection/ProxyMapper.cs | 17 - .../RhinoConnectorModule.cs | 4 - .../HostApp/RhinoContext.cs | 8 + .../Operations/Receive/DisableRedrawScope.cs | 8 +- .../Receive/RhinoHostObjectBuilder.cs | 51 +- .../Speckle.Connectors.Rhino7.csproj | 3 +- .../packages.lock.json | 45 +- .../ArcGISConverterModule.cs | 2 +- .../packages.lock.json | 31 - .../RevitConverterModule.cs | 22 +- ...rters.Revit2023.DependencyInjection.csproj | 3 - .../packages.lock.json | 46 +- .../LocationConversionToSpeckleTests.cs | 85 --- .../Speckle.Converters.Revit2023.Tests.csproj | 27 - .../packages.lock.json | 560 ------------------ .../RevitVersionConversionHelper.cs | 19 + .../Speckle.Converters.Revit2023.csproj | 3 +- .../packages.lock.json | 8 +- .../Extensions/CategoryExtensions.cs | 8 +- .../Extensions/DefinitionExtensions.cs | 8 +- .../Extensions/ElementExtensions.cs | 23 +- .../Extensions/ForgeTypeIdExtensions.cs | 14 +- .../Extensions/ParameterExtensions.cs | 13 +- .../GlobalUsings.cs | 4 +- .../Helpers/DisplayValueExtractor.cs | 200 +++---- .../Helpers/IRevitConversionContextStack.cs | 13 + .../Helpers/ISlopeArrowExtractor.cs | 10 + .../Helpers/ParameterObjectAssigner.cs | 35 +- .../Helpers/ParameterObjectBuilder.cs | 50 ++ .../Helpers/ParameterValueExtractor.cs | 161 +++-- .../Helpers/RevitCategories.cs | 150 +++++ .../Helpers/RevitCategoryInfo.cs | 65 ++ .../Helpers/RevitContext.cs | 4 +- .../Helpers/RevitConversionContextStack.cs | 28 + .../Helpers/SendSelection.cs | 17 + .../Helpers/SlopeArrowExtractor.cs | 55 +- .../Helpers/ToSpeckleConvertedObjectsCache.cs | 25 + .../IReferencePointConverter.cs | 6 + .../IRevitVersionConversionHelper.cs | 6 + .../Raw/BeamConversionToSpeckle.cs | 36 +- .../Raw/BoundarySegmentConversionToSpeckle.cs | 13 +- .../Raw/BraceToSpeckleConverter.cs | 15 +- .../Raw/ColumnConversionToSpeckle.cs | 80 ++- .../Raw/Geometry/ArcToSpeckleConverter.cs | 42 +- .../BoundingBoxXYZToSpeckleConverter.cs | 26 +- .../Raw/Geometry/CircleToSpeckleConverter.cs | 24 +- ...urveArrArrayToSpecklePolycurveConverter.cs | 27 +- .../Geometry/CurveArrayConversionToSpeckle.cs | 30 +- .../Raw/Geometry/CurveConversionToSpeckle.cs | 67 +-- .../Raw/Geometry/EllipseToSpeckleConverter.cs | 32 +- .../HermiteSplineToSpeckleConverter.cs | 18 +- .../Raw/Geometry/LineConversionToSpeckle.cs | 21 +- .../MeshByMaterialDictionaryToSpeckle.cs | 41 +- .../Raw/Geometry/MeshConversionToSpeckle.cs | 37 +- .../Geometry/NurbsSplineToSpeckleConverter.cs | 27 +- .../Raw/Geometry/PlaneToSpeckleConverter.cs | 19 +- .../Geometry/PointCloudToSpeckleConverter.cs | 41 +- .../Raw/Geometry/PointConversionToSpeckle.cs | 11 +- .../Geometry/PolylineToSpeckleConverter.cs | 15 +- .../Raw/Geometry/SolidConversionToSpeckle.cs | 40 +- .../Raw/Geometry/VectorToSpeckleConverter.cs | 13 +- .../Raw/Geometry/XyzConversionToPoint.cs | 16 +- .../Raw/LevelConversionToSpeckle.cs | 13 +- .../Raw/LocationConversionToSpeckle.cs | 37 +- .../Raw/MaterialConversionToSpeckle.cs | 7 +- .../ModelCurveArrArrayConverterToSpeckle.cs | 30 - .../ModelCurveArrArrayToSpeckleConverter.cs | 28 + .../Raw/ModelCurveArrayToSpeckleConverter.cs | 30 +- .../Raw/ParameterConversionToSpeckle.cs | 27 +- .../Raw/RevitVersionConversionHelper.cs | 23 - .../{Services => }/ReferencePointConverter.cs | 75 +-- .../RevitConstants.cs | 6 - .../RevitConversionSettings.cs | 19 + .../RevitRootToHostConverter.cs | 50 ++ .../Services/RevitToSpeckleUnitConverter.cs | 27 +- .../Services/ScalingServiceToSpeckle.cs | 25 +- .../Speckle.Converters.RevitShared.projitems | 68 ++- .../BaseTopLevelConverterToSpeckle.cs | 2 +- .../CeilingTopLevelConverterToSpeckle.cs | 35 +- .../DirectShapeTopLevelConverterToSpeckle.cs | 22 +- .../ElementTopLevelConverterToSpeckle.cs | 20 +- ...ExtrusionRoofToSpeckleTopLevelConverter.cs | 57 +- ...amilyInstanceTopLevelConverterToSpeckle.cs | 32 +- .../FloorTopLevelConverterToSpeckle.cs | 48 +- ...FootPrintRoofToSpeckleTopLevelConverter.cs | 57 +- .../HostedElementConversionToSpeckle.cs | 20 +- .../ModelCurveToSpeckleTopLevelConverter.cs | 19 +- ...fBaseToSpeckleTopLevelTopLevelConverter.cs | 31 +- .../RoomTopLevelConverterToSpeckle.cs | 39 +- .../TopographyTopLevelConverterToSpeckle.cs | 17 +- .../WallTopLevelConverterToSpeckle.cs | 82 +-- .../RhinoConverterModule.cs | 7 +- .../RhinoRootElementProvider.cs | 9 - ...nverters.Rhino7.DependencyInjection.csproj | 2 +- .../packages.lock.json | 21 +- .../Speckle.Converters.Rhino7/GlobalUsings.cs | 1 + .../RhinoConversionContextStack.cs | 11 +- .../RhinoToSpeckleUnitConverter.cs | 30 +- .../Speckle.Converters.Rhino7.csproj | 5 +- ...ckleToHostGeometryBaseTopLevelConverter.cs | 17 +- .../ToHost/Raw/ArcToHostConverter.cs | 32 +- .../ToHost/Raw/BrepToHostConverter.cs | 57 +- .../ToHost/Raw/CircleToHostConverter.cs | 38 +- .../ToHost/Raw/CurveToHostConverter.cs | 41 +- .../ToHost/Raw/EllipseToHostConverter.cs | 36 +- .../Raw/FlatPointListToHostConverter.cs | 21 +- .../ToHost/Raw/IntervalToHostConverter.cs | 14 +- .../ToHost/Raw/LineToHostConverter.cs | 21 +- .../ToHost/Raw/MeshToHostConverter.cs | 44 +- .../ToHost/Raw/NurbsCurveToHostConverter.cs | 25 +- .../ToHost/Raw/PlaneToHostConverter.cs | 18 +- .../ToHost/Raw/PointCloudToHostConverter.cs | 17 +- .../ToHost/Raw/PointToHostConverter.cs | 15 +- .../ToHost/Raw/PolyCurveToHostConverter.cs | 21 +- .../ToHost/Raw/PolylineToHostConverter.cs | 27 +- .../ToHost/Raw/SpiralToHostConverter.cs | 13 +- .../ToHost/Raw/SurfaceToHostConverter.cs | 18 +- .../ToHost/Raw/VectorToHostConverter.cs | 12 +- .../TopLevel/ArcToHostTopLevelConverter.cs | 13 +- .../TopLevel/BrepToHostTopLevelConverter.cs | 13 +- .../TopLevel/CircleToHostTopLevelConverter.cs | 13 +- .../EllipseToHostTopLevelConverter.cs | 13 +- .../FallbackToHostTopLevelConverter.cs | 37 +- .../TopLevel/LineToHostTopLevelConverter.cs | 13 +- .../TopLevel/MeshToHostTopLevelConverter.cs | 13 +- .../NurbsCurveToHostTopLevelConverter.cs | 13 +- .../PointCloudToHostTopLevelConverter.cs | 13 +- .../TopLevel/PointToHostTopLevelConverter.cs | 13 +- .../PolycurveToHostTopLevelConverter.cs | 14 +- .../PolylineToHostTopLevelConverter.cs | 13 +- .../Raw/ArcCurveToSpeckleConverter.cs | 28 +- .../ToSpeckle/Raw/ArcToSpeckleConverter.cs | 29 +- .../ToSpeckle/Raw/BoxToSpeckleConverter.cs | 20 +- .../ToSpeckle/Raw/BrepToSpeckleConverter.cs | 59 +- .../ToSpeckle/Raw/CircleToSpeckleConverter.cs | 22 +- .../Raw/ControlPointToSpeckleConverter.cs | 15 +- .../ToSpeckle/Raw/CurveToSpeckleConverter.cs | 57 +- .../Raw/EllipseToSpeckleConverter.cs | 25 +- .../Raw/IntervalToSpeckleConverter.cs | 5 +- .../ToSpeckle/Raw/LineToSpeckleConverter.cs | 27 +- .../ToSpeckle/Raw/MeshToSpeckleConverter.cs | 28 +- .../ToSpeckle/Raw/NurbsCurveConverter.cs | 33 +- .../Raw/NurbsSurfaceToSpeckleConverter.cs | 32 +- .../ToSpeckle/Raw/PlaneToSpeckleConverter.cs | 18 +- .../ToSpeckle/Raw/PointToSpeckleConverter.cs | 15 +- .../Raw/PolyCurveToSpeckleConverter.cs | 26 +- .../Raw/PolylineToSpeckleConverter.cs | 39 +- .../ToSpeckle/Raw/RawPointCloudToSpeckle.cs | 21 +- .../ToSpeckle/Raw/VectorToSpeckleConverter.cs | 12 +- .../BrepObjectToSpeckleTopLevelConverter.cs | 12 +- .../CurveObjectToSpeckleTopLevelConverter.cs | 13 +- ...trusionObjectToSpeckleTopLevelConverter.cs | 12 +- .../MeshObjectToSpeckleTopLevelConverter.cs | 13 +- ...ntCloudObjectToSpeckleTopLevelConverter.cs | 12 +- .../PointObjectToSpeckleTopLevelConverter.cs | 12 +- .../RhinoObjectToSpeckleTopLevelConverter.cs | 12 +- .../packages.lock.json | 12 +- .../packages.lock.json | 46 -- DUI3-DX/Directory.Packages.props | 11 +- .../ContainerRegistration.cs | 6 +- .../Speckle.Connectors.Utils.csproj | 1 + .../packages.lock.json | 9 + .../ContainerRegistration.cs | 3 +- .../NamedTypeInjector.cs | 22 +- .../RawConversionRegisterer.cs | 23 +- .../FakeType.cs | 109 ---- .../RootToSpeckleConverterTests.cs | 66 --- .../Speckle.Converters.Common.Tests.csproj | 24 - .../packages.lock.json | 468 --------------- .../ContextWrapper.cs | 2 +- .../ConversionContext.cs | 8 +- .../ConversionContextStack.cs | 9 +- .../Speckle.Converters.Common/IProxyMapper.cs | 33 -- .../LegacyRootToSpeckleConverter.cs | 37 -- .../RootConvertManager.cs | 2 +- .../RootToSpeckleConverter.cs | 45 +- 194 files changed, 2196 insertions(+), 3791 deletions(-) delete mode 100644 DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/ProxyMapper.cs delete mode 100644 DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Helpers/RevitConversionContextStack.cs delete mode 100644 DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/ProxyMapper.cs create mode 100644 DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/RhinoContext.cs delete mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/LocationConversionToSpeckleTests.cs delete mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/Speckle.Converters.Revit2023.Tests.csproj delete mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/packages.lock.json create mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023/RevitVersionConversionHelper.cs create mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/IRevitConversionContextStack.cs create mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/ISlopeArrowExtractor.cs create mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/ParameterObjectBuilder.cs create mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/RevitCategories.cs create mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/RevitCategoryInfo.cs rename DUI3-DX/{Connectors/Revit/Speckle.Connectors.RevitShared => Converters/Revit/Speckle.Converters.RevitShared}/Helpers/RevitContext.cs (80%) create mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/RevitConversionContextStack.cs create mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/SendSelection.cs create mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/ToSpeckleConvertedObjectsCache.cs create mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/IReferencePointConverter.cs create mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/IRevitVersionConversionHelper.cs delete mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ModelCurveArrArrayConverterToSpeckle.cs create mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ModelCurveArrArrayToSpeckleConverter.cs delete mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/RevitVersionConversionHelper.cs rename DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/{Services => }/ReferencePointConverter.cs (51%) delete mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/RevitConstants.cs create mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/RevitConversionSettings.cs create mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/RevitRootToHostConverter.cs delete mode 100644 DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/RhinoRootElementProvider.cs delete mode 100644 DUI3-DX/Sdk/Speckle.Converters.Common.Tests/FakeType.cs delete mode 100644 DUI3-DX/Sdk/Speckle.Converters.Common.Tests/RootToSpeckleConverterTests.cs delete mode 100644 DUI3-DX/Sdk/Speckle.Converters.Common.Tests/Speckle.Converters.Common.Tests.csproj delete mode 100644 DUI3-DX/Sdk/Speckle.Converters.Common.Tests/packages.lock.json delete mode 100644 DUI3-DX/Sdk/Speckle.Converters.Common/IProxyMapper.cs delete mode 100644 DUI3-DX/Sdk/Speckle.Converters.Common/LegacyRootToSpeckleConverter.cs diff --git a/All.sln b/All.sln index 59406b4cb8..da15c240b4 100644 --- a/All.sln +++ b/All.sln @@ -558,8 +558,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{B1324D25 EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Speckle.Converters.Revit2023.Tests", "DUI3-DX\Converters\Revit\Speckle.Converters.Revit2023.Tests\Speckle.Converters.Revit2023.Tests.csproj", "{AEC26A0B-25F3-4544-A9D6-A427BFF79250}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Speckle.Converters.Common.Tests", "DUI3-DX\Sdk\Speckle.Converters.Common.Tests\Speckle.Converters.Common.Tests.csproj", "{95E23A97-E5EA-4506-A52C-D3DA9012DA02}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Speckle.Connectors.Civil3d2024", "DUI3-DX\Connectors\Autocad\Speckle.Connectors.Civil3d2024\Speckle.Connectors.Civil3d2024.csproj", "{DDBBA313-69A6-40DE-AB3A-79EE5BF32A7E}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Speckle.Converters.Autocad2024", "DUI3-DX\Converters\Autocad\2024\Speckle.Converters.Autocad2024\Speckle.Converters.Autocad2024.csproj", "{C9C28F31-1367-438C-83B0-049C3B3A3E3B}" @@ -2816,22 +2814,6 @@ Global {AEC26A0B-25F3-4544-A9D6-A427BFF79250}.Release|Any CPU.Build.0 = Release|Any CPU {AEC26A0B-25F3-4544-A9D6-A427BFF79250}.Release|x64.ActiveCfg = Release|Any CPU {AEC26A0B-25F3-4544-A9D6-A427BFF79250}.Release|x64.Build.0 = Release|Any CPU - {95E23A97-E5EA-4506-A52C-D3DA9012DA02}.Debug Mac|Any CPU.ActiveCfg = Debug|Any CPU - {95E23A97-E5EA-4506-A52C-D3DA9012DA02}.Debug Mac|Any CPU.Build.0 = Debug|Any CPU - {95E23A97-E5EA-4506-A52C-D3DA9012DA02}.Debug Mac|x64.ActiveCfg = Debug|Any CPU - {95E23A97-E5EA-4506-A52C-D3DA9012DA02}.Debug Mac|x64.Build.0 = Debug|Any CPU - {95E23A97-E5EA-4506-A52C-D3DA9012DA02}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {95E23A97-E5EA-4506-A52C-D3DA9012DA02}.Debug|Any CPU.Build.0 = Debug|Any CPU - {95E23A97-E5EA-4506-A52C-D3DA9012DA02}.Debug|x64.ActiveCfg = Debug|Any CPU - {95E23A97-E5EA-4506-A52C-D3DA9012DA02}.Debug|x64.Build.0 = Debug|Any CPU - {95E23A97-E5EA-4506-A52C-D3DA9012DA02}.Release Mac|Any CPU.ActiveCfg = Debug|Any CPU - {95E23A97-E5EA-4506-A52C-D3DA9012DA02}.Release Mac|Any CPU.Build.0 = Debug|Any CPU - {95E23A97-E5EA-4506-A52C-D3DA9012DA02}.Release Mac|x64.ActiveCfg = Debug|Any CPU - {95E23A97-E5EA-4506-A52C-D3DA9012DA02}.Release Mac|x64.Build.0 = Debug|Any CPU - {95E23A97-E5EA-4506-A52C-D3DA9012DA02}.Release|Any CPU.ActiveCfg = Release|Any CPU - {95E23A97-E5EA-4506-A52C-D3DA9012DA02}.Release|Any CPU.Build.0 = Release|Any CPU - {95E23A97-E5EA-4506-A52C-D3DA9012DA02}.Release|x64.ActiveCfg = Release|Any CPU - {95E23A97-E5EA-4506-A52C-D3DA9012DA02}.Release|x64.Build.0 = Release|Any CPU {DDBBA313-69A6-40DE-AB3A-79EE5BF32A7E}.Debug Mac|Any CPU.ActiveCfg = Debug|Any CPU {DDBBA313-69A6-40DE-AB3A-79EE5BF32A7E}.Debug Mac|Any CPU.Build.0 = Debug|Any CPU {DDBBA313-69A6-40DE-AB3A-79EE5BF32A7E}.Debug Mac|x64.ActiveCfg = Debug|Any CPU @@ -3092,7 +3074,6 @@ Global {70DEAA13-6DC8-44A0-B287-9E806A8054F1} = {890F3257-FCC2-4ED8-9180-22B3641B494C} {F06E4C37-4076-4272-9CA6-FB505E02CD31} = {BE521908-7944-46F3-98BF-B47D34509934} {AEC26A0B-25F3-4544-A9D6-A427BFF79250} = {D92751C8-1039-4005-90B2-913E55E0B8BD} - {95E23A97-E5EA-4506-A52C-D3DA9012DA02} = {2E00592E-558D-492D-88F9-3ECEE4C0C7DA} {DDBBA313-69A6-40DE-AB3A-79EE5BF32A7E} = {743489BF-1941-43D5-8AF9-35C56D0DCC34} {C9C28F31-1367-438C-83B0-049C3B3A3E3B} = {804E065F-914C-414A-AF84-009312C3CFF6} {06082BAA-98E8-49B1-9D33-252B126A0561} = {804E065F-914C-414A-AF84-009312C3CFF6} diff --git a/Build/Consts.cs b/Build/Consts.cs index 2fa9d8deaa..5d3f91de54 100644 --- a/Build/Consts.cs +++ b/Build/Consts.cs @@ -5,11 +5,7 @@ namespace Build; public static class Consts { public static readonly string[] Solutions = { "DUI3-DX.slnf" }; - public static readonly string[] TestProjects = - { - "Speckle.Converters.Revit2023.Tests", - "Speckle.Converters.Common.Tests" - }; + public static readonly string[] TestProjects = System.Array.Empty(); public static readonly InstallerProject[] InstallerManifests = { diff --git a/DUI3-DX.slnf b/DUI3-DX.slnf index 157eec292b..4f4a6e3edb 100644 --- a/DUI3-DX.slnf +++ b/DUI3-DX.slnf @@ -18,7 +18,6 @@ "DUI3-DX\\Converters\\Autocad\\2024\\Speckle.Converters.Autocad2024\\Speckle.Converters.Autocad2024.csproj", "DUI3-DX\\Converters\\Autocad\\Speckle.Converters.AutocadShared\\Speckle.Converters.AutocadShared.shproj", "DUI3-DX\\Converters\\Revit\\Speckle.Converters.Revit2023.DependencyInjection\\Speckle.Converters.Revit2023.DependencyInjection.csproj", - "DUI3-DX\\Converters\\Revit\\Speckle.Converters.Revit2023.Tests\\Speckle.Converters.Revit2023.Tests.csproj", "DUI3-DX\\Converters\\Revit\\Speckle.Converters.Revit2023\\Speckle.Converters.Revit2023.csproj", "DUI3-DX\\Converters\\Revit\\Speckle.Converters.RevitShared\\Speckle.Converters.RevitShared.shproj", "DUI3-DX\\Converters\\Rhino\\Speckle.Converters.Rhino7.DependencyInjection\\Speckle.Converters.Rhino7.DependencyInjection.csproj", @@ -28,7 +27,6 @@ "DUI3-DX\\Sdk\\Speckle.Autofac\\Speckle.Autofac.csproj", "DUI3-DX\\Sdk\\Speckle.Connectors.Utils\\Speckle.Connectors.Utils.csproj", "DUI3-DX\\Sdk\\Speckle.Converters.Common.DependencyInjection\\Speckle.Converters.Common.DependencyInjection.csproj", - "DUI3-DX\\Sdk\\Speckle.Converters.Common.Tests\\Speckle.Converters.Common.Tests.csproj", "DUI3-DX\\Sdk\\Speckle.Converters.Common\\Speckle.Converters.Common.csproj" ] } diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.Autocad2023/packages.lock.json b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.Autocad2023/packages.lock.json index df67e2ad73..68bcf35809 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.Autocad2023/packages.lock.json +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.Autocad2023/packages.lock.json @@ -272,42 +272,11 @@ "Serilog": "2.10.0" } }, - "Speckle.Core": { - "type": "Transitive", - "resolved": "3.0.1-alpha.11", - "contentHash": "Zt2dBJLlfziEACYCHThbhKypSjhoA01rTw9BzNI72c/BDyftXIz70Tetq/8ZMEqQnKqfmRyYADsAdWKxpdV0Hg==", - "dependencies": { - "GraphQL.Client": "6.0.0", - "Microsoft.CSharp": "4.7.0", - "Microsoft.Data.Sqlite": "7.0.5", - "Polly": "7.2.3", - "Polly.Contrib.WaitAndRetry": "1.1.1", - "Polly.Extensions.Http": "3.0.0", - "Sentry": "3.33.0", - "Sentry.Serilog": "3.33.0", - "Serilog": "2.12.0", - "Serilog.Enrichers.ClientInfo": "1.3.0", - "Serilog.Exceptions": "8.4.0", - "Serilog.Sinks.Console": "4.1.0", - "Serilog.Sinks.Seq": "5.2.2", - "SerilogTimings": "3.0.1", - "Speckle.Newtonsoft.Json": "13.0.2", - "System.DoubleNumerics": "3.1.3" - } - }, "Speckle.Newtonsoft.Json": { "type": "Transitive", "resolved": "13.0.2", "contentHash": "g1BejUZwax5PRfL6xHgLEK23sqHWOgOj9hE7RvfRRlN00AGt8GnPYt8HedSK7UB3HiRW8zCA9Pn0iiYxCK24BA==" }, - "Speckle.Objects": { - "type": "Transitive", - "resolved": "3.0.1-alpha.11", - "contentHash": "YR7sei3OQBAi8R/kIu8bEmg5ELDIJK6l5fhOgdnqA9ZvD/fvmRb+09z8lIUTDsgdAdvYU/A/x9VxH9OGPbp9Kw==", - "dependencies": { - "Speckle.Core": "3.0.1-alpha.11" - } - }, "SQLitePCLRaw.bundle_e_sqlite3": { "type": "Transitive", "resolved": "2.1.4", diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.Revit2023/packages.lock.json b/DUI3-DX/Connectors/Revit/Speckle.Connectors.Revit2023/packages.lock.json index 99af7ef77d..0a002c7391 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.Revit2023/packages.lock.json +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.Revit2023/packages.lock.json @@ -90,21 +90,6 @@ "resolved": "6.0.0", "contentHash": "yg72rrYDapfsIUrul7aF6wwNnTJBOFvuA9VdDTQpPa8AlAriHbufeXYLBcodKjfUdkCnaiggX1U/nEP08Zb5GA==" }, - "Mapster": { - "type": "Transitive", - "resolved": "7.3.0", - "contentHash": "NrCUX/rJa5PTyo6iW4AL5dZLU9PDNlYnrJOVjgdpo5OQM9EtWH2CMHnC5sSuJWC0d0b0SnmeRrIviEem6WxtuQ==", - "dependencies": { - "Mapster.Core": "1.2.0", - "Microsoft.CSharp": "4.3.0", - "System.Reflection.Emit": "4.3.0" - } - }, - "Mapster.Core": { - "type": "Transitive", - "resolved": "1.2.0", - "contentHash": "TNdqZk2zAuBYfJF88D/3clQTOyOdqr1crU81yZQtlGa+e7FYWhJdK/buBWT+TpM3qQko9UzmzfOT4iq3JCs/ZA==" - }, "Microsoft.Bcl.AsyncInterfaces": { "type": "Transitive", "resolved": "7.0.0", @@ -310,11 +295,6 @@ "resolved": "13.0.2", "contentHash": "g1BejUZwax5PRfL6xHgLEK23sqHWOgOj9hE7RvfRRlN00AGt8GnPYt8HedSK7UB3HiRW8zCA9Pn0iiYxCK24BA==" }, - "Speckle.Revit.API": { - "type": "Transitive", - "resolved": "2023.0.0", - "contentHash": "tq40eD7psgTbV+epNouYyqfo6+hEi7FmXZqcxEOsAV7zfYyWhL6Rt3vmojkWGNuerGbH6oRI6KIIxrnlCNb8Hw==" - }, "SQLitePCLRaw.bundle_e_sqlite3": { "type": "Transitive", "resolved": "2.1.4", @@ -407,11 +387,6 @@ "System.Threading.Tasks.Extensions": "4.5.4" } }, - "System.Reflection.Emit": { - "type": "Transitive", - "resolved": "4.3.0", - "contentHash": "228FG0jLcIwTVJyz8CLFKueVqQK36ANazUManGaJHkO0icjiIypKW7YLWLIWahyIkdh5M7mV2dJepllLyA1SKg==" - }, "System.Reflection.Metadata": { "type": "Transitive", "resolved": "5.0.0", @@ -509,7 +484,7 @@ "type": "Project", "dependencies": { "Speckle.Converters.Common": "[2.0.999-local, )", - "Speckle.Revit2023.Interfaces": "[0.1.1-preview.0.28, )" + "Speckle.Revit.API": "[2023.0.0, )" } }, "speckle.converters.revit2023.dependencyinjection": { @@ -517,8 +492,7 @@ "dependencies": { "Speckle.Converters.Common": "[2.0.999-local, )", "Speckle.Converters.Common.DependencyInjection": "[2.0.999-local, )", - "Speckle.Converters.Revit2023": "[2.0.999-local, )", - "Speckle.Revit2023.Api": "[0.1.1-preview.0.28, )" + "Speckle.Converters.Revit2023": "[2.0.999-local, )" } }, "Microsoft.Extensions.Logging.Abstractions": { @@ -574,22 +548,11 @@ "Speckle.Core": "3.0.1-alpha.11" } }, - "Speckle.Revit2023.Api": { - "type": "CentralTransitive", - "requested": "[0.1.1-preview.0.28, )", - "resolved": "0.1.1-preview.0.28", - "contentHash": "ejwYS/HI8yy0rJE4vgTr5aj8Fkg/E9JnMGjwyVS2fLtI4f7+FmwAY6inTUT2p/RAoRc2nQw+TerDpUtOhddzag==", - "dependencies": { - "Mapster": "7.3.0", - "Speckle.Revit.API": "2023.0.0", - "Speckle.Revit2023.Interfaces": "0.1.1-preview.0.28" - } - }, - "Speckle.Revit2023.Interfaces": { + "Speckle.Revit.API": { "type": "CentralTransitive", - "requested": "[0.1.1-preview.0.28, )", - "resolved": "0.1.1-preview.0.28", - "contentHash": "7szXg/vRvP3Wdrn2ZGriVOfsw+bddlpVorBkCIhSHHs5qVTTG8IAIrI1l9dO0/aullaTMF+Xgxm9x3w1aXPiuA==" + "requested": "[2023.0.0, )", + "resolved": "2023.0.0", + "contentHash": "tq40eD7psgTbV+epNouYyqfo6+hEi7FmXZqcxEOsAV7zfYyWhL6Rt3vmojkWGNuerGbH6oRI6KIIxrnlCNb8Hw==" }, "System.Threading.Tasks.Dataflow": { "type": "CentralTransitive", diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/BasicConnectorBindingRevit.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/BasicConnectorBindingRevit.cs index ff27f05fb4..3aa6be233f 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/BasicConnectorBindingRevit.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/BasicConnectorBindingRevit.cs @@ -6,8 +6,8 @@ using Speckle.Connectors.DUI.Models; using Speckle.Connectors.DUI.Models.Card; using Speckle.Connectors.Revit.Plugin; -using Speckle.Connectors.RevitShared.Helpers; using Speckle.Connectors.Utils; +using Speckle.Converters.RevitShared.Helpers; using Speckle.Core.Logging; namespace Speckle.Connectors.DUI.Bindings; diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/RevitBaseBinding.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/RevitBaseBinding.cs index 566cc9c41a..9774517d94 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/RevitBaseBinding.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/RevitBaseBinding.cs @@ -1,7 +1,7 @@ using Speckle.Connectors.DUI.Bindings; using Speckle.Connectors.DUI.Bridge; using Speckle.Connectors.DUI.Models; -using Speckle.Connectors.RevitShared.Helpers; +using Speckle.Converters.RevitShared.Helpers; namespace Speckle.Connectors.Revit.Bindings; diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/RevitSendBinding.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/RevitSendBinding.cs index 8bd3033442..99e6492b79 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/RevitSendBinding.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/RevitSendBinding.cs @@ -3,12 +3,12 @@ using Speckle.Connectors.DUI.Bridge; using Speckle.Connectors.Revit.Plugin; using Speckle.Connectors.Utils; +using Speckle.Converters.RevitShared.Helpers; using Speckle.Connectors.DUI.Models.Card; using Speckle.Connectors.DUI.Bindings; using Speckle.Autofac.DependencyInjection; using Speckle.Connectors.DUI.Exceptions; using Speckle.Connectors.DUI.Models; -using Speckle.Connectors.RevitShared.Helpers; using Speckle.Connectors.Utils.Caching; using Speckle.Connectors.Utils.Cancellation; using Speckle.Connectors.Utils.Operations; diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SelectionBinding.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SelectionBinding.cs index d60fe3ef27..c74a0606bd 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SelectionBinding.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/SelectionBinding.cs @@ -2,8 +2,8 @@ using Speckle.Connectors.DUI.Bridge; using Speckle.Connectors.DUI.Models; using Speckle.Connectors.Revit.Plugin; -using Speckle.Connectors.RevitShared.Helpers; using Speckle.Converters.Common; +using Speckle.Converters.RevitShared.Helpers; namespace Speckle.Connectors.Revit.Bindings; diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/ProxyMapper.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/ProxyMapper.cs deleted file mode 100644 index e4e997c4e2..0000000000 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/ProxyMapper.cs +++ /dev/null @@ -1,17 +0,0 @@ -using Speckle.Converters.Common; -using Speckle.ProxyGenerator; - -namespace Speckle.Connectors.Revit.DependencyInjection; - -public class ProxyMapper : IProxyMapper -{ - public Type? GetMappedTypeFromHostType(Type type) => ProxyMap.GetMappedTypeFromHostType(type); - - public Type? GetMappedTypeFromProxyType(Type type) => ProxyMap.GetMappedTypeFromProxyType(type); - - public Type? GetHostTypeFromMappedType(Type type) => ProxyMap.GetHostTypeFromMappedType(type); - - public object CreateProxy(Type type, object toWrap) => ProxyMap.CreateProxy(type, toWrap); - - public T CreateProxy(object toWrap) => ProxyMap.CreateProxy(toWrap); -} diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/RevitConnectorModule.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/RevitConnectorModule.cs index 879bf05041..ec1bcb5566 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/RevitConnectorModule.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/RevitConnectorModule.cs @@ -10,14 +10,10 @@ using Speckle.Connectors.Revit.HostApp; using Speckle.Connectors.Revit.Operations.Send; using Speckle.Connectors.Revit.Plugin; -using Speckle.Connectors.RevitShared.Helpers; using Speckle.Connectors.Utils; using Speckle.Connectors.Utils.Builders; using Speckle.Connectors.Utils.Caching; using Speckle.Connectors.Utils.Operations; -using Speckle.Converters.Common; -using Speckle.Revit.Api; -using Speckle.Revit.Interfaces; namespace Speckle.Connectors.Revit.DependencyInjection; @@ -29,11 +25,7 @@ public void Load(SpeckleContainerBuilder builder) builder.AddAutofac(); builder.AddConnectorUtils(); builder.AddDUI(); - builder.AddSingleton(new RevitContext()); - - // POC: the concrete type can come out if we remove all the reference to it - builder.AddScoped, RevitConversionContextStack>(); - builder.ScanAssemblyOfType(); + //builder.AddDUIView(); builder.AddSingletonInstance(); diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Helpers/RevitConversionContextStack.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Helpers/RevitConversionContextStack.cs deleted file mode 100644 index d5461e7f60..0000000000 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Helpers/RevitConversionContextStack.cs +++ /dev/null @@ -1,38 +0,0 @@ -using Autodesk.Revit.DB; -using Speckle.Converters.Common; -using Speckle.Revit.Api; -using Speckle.Revit.Interfaces; - -namespace Speckle.Connectors.RevitShared.Helpers; - -[System.Diagnostics.CodeAnalysis.SuppressMessage( - "Naming", - "CA1711:Identifiers should not have incorrect suffix", - Justification = "See base class justification" -)] -// POC: so this should *probably* be Document and NOT UI.UIDocument, the former is Conversion centric -// and the latter is more for connector -public class RevitConversionContextStack - : ConversionContextStack, - IConversionContextStack -{ - public RevitConversionContextStack(RevitContext context, IHostToSpeckleUnitConverter unitConverter) - : base( - // POC: we probably should not get here without a valid document - // so should this perpetuate or do we assume this is valid? - // relting on the context.UIApplication?.ActiveUIDocument is not right - // this should be some IActiveDocument I suspect? - new DocumentProxy( - context.UIApplication?.ActiveUIDocument?.Document - ?? throw new SpeckleConversionException("Active UI document could not be determined") - ), - new ForgeTypeIdProxy( - context.UIApplication.ActiveUIDocument.Document.GetUnits().GetFormatOptions(SpecTypeId.Length).GetUnitTypeId() - ), - unitConverter - ) { } - - ContextWrapper IConversionContextStack.Push( - string speckleUnit - ) => throw new NotImplementedException(); -} diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/RevitDocumentStore.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/RevitDocumentStore.cs index ba9b7d8db3..42acdc95ca 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/RevitDocumentStore.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/RevitDocumentStore.cs @@ -7,8 +7,8 @@ using Speckle.Connectors.DUI.Bridge; using Speckle.Connectors.DUI.Models; using Speckle.Connectors.Revit.Plugin; -using Speckle.Connectors.RevitShared.Helpers; using Speckle.Connectors.Utils; +using Speckle.Converters.RevitShared.Helpers; using Speckle.Core.Logging; using Speckle.Newtonsoft.Json; diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RevitRootObjectBuilder.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RevitRootObjectBuilder.cs index 417478e952..df84c9218e 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RevitRootObjectBuilder.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RevitRootObjectBuilder.cs @@ -3,13 +3,12 @@ using Speckle.Core.Models; using Autodesk.Revit.DB; using Speckle.Connectors.DUI.Exceptions; +using Speckle.Converters.RevitShared.Helpers; using Speckle.Connectors.Utils.Builders; using Speckle.Connectors.Utils.Caching; using Speckle.Connectors.Utils.Conversion; using Speckle.Connectors.Utils.Operations; using Speckle.Core.Logging; -using Speckle.Revit.Api; -using Speckle.Revit.Interfaces; namespace Speckle.Connectors.Revit.Operations.Send; @@ -17,14 +16,14 @@ public class RevitRootObjectBuilder : IRootObjectBuilder { // POC: SendSelection and RevitConversionContextStack should be interfaces, former needs interfaces private readonly IRootToSpeckleConverter _converter; - private readonly IConversionContextStack _contextStack; + private readonly IRevitConversionContextStack _contextStack; private readonly Dictionary _collectionCache; private readonly Collection _rootObject; private readonly ISendConversionCache _sendConversionCache; public RevitRootObjectBuilder( IRootToSpeckleConverter converter, - IConversionContextStack contextStack, + IRevitConversionContextStack contextStack, ISendConversionCache sendConversionCache ) { @@ -46,7 +45,7 @@ public RootObjectBuilderResult Build( CancellationToken ct = default ) { - var doc = ((DocumentProxy)_contextStack.Current.Document)._Instance; + var doc = _contextStack.Current.Document; if (doc.IsFamilyDocument) { @@ -57,7 +56,7 @@ public RootObjectBuilderResult Build( foreach (var id in objects) { - var el = doc.GetElement(id); + var el = _contextStack.Current.Document.GetElement(id); if (el != null) { revitElements.Add(el); diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitExternalApplication.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitExternalApplication.cs index afe71b6f6d..6de43da0c7 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitExternalApplication.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitExternalApplication.cs @@ -1,5 +1,6 @@ using Autodesk.Revit.UI; using Speckle.Autofac.DependencyInjection; +using System.IO; using System.Reflection; using Speckle.Autofac; using Speckle.Connectors.Utils; @@ -31,7 +32,7 @@ public RevitExternalApplication() "2023", "Speckle New UI", "Revit", - new[] { System.IO.Path.GetDirectoryName(typeof(RevitExternalApplication).Assembly.Location) }, + new[] { Path.GetDirectoryName(typeof(RevitExternalApplication).Assembly.Location) }, "Revit Connector", "2023" //POC: app version? ); diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitIdleManager.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitIdleManager.cs index 6e3d0c4e5e..1b46efa267 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitIdleManager.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitIdleManager.cs @@ -2,7 +2,7 @@ using Autodesk.Revit.UI; using Autodesk.Revit.UI.Events; using Speckle.Connectors.DUI.Bridge; -using Speckle.Connectors.RevitShared.Helpers; +using Speckle.Converters.RevitShared.Helpers; namespace Speckle.Connectors.Revit.Plugin; diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitPlugin.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitPlugin.cs index a46046dd45..13d3500b2f 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitPlugin.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitPlugin.cs @@ -5,11 +5,12 @@ using Speckle.Connectors.DUI.Bridge; using Speckle.Connectors.DUI.Bindings; using System.Diagnostics; +using Speckle.Converters.RevitShared.Helpers; using Speckle.Core.Logging; using System.Reflection; using System.Windows.Media.Imaging; using System.Windows.Media; -using Speckle.Connectors.RevitShared.Helpers; +using System.IO; namespace Speckle.Connectors.Revit.Plugin; @@ -181,7 +182,7 @@ private void RegisterDockablePane() { try { - var assembly = Assembly.LoadFrom(System.IO.Path.Combine(path)); + var assembly = Assembly.LoadFrom(Path.Combine(path)); var icon = assembly.GetManifestResourceStream(sourceName); PngBitmapDecoder decoder = new(icon, BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.Default); ImageSource source = decoder.Frames[0]; diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Speckle.Connectors.RevitShared.projitems b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Speckle.Connectors.RevitShared.projitems index a479f3189b..8a671aefc9 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Speckle.Connectors.RevitShared.projitems +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Speckle.Connectors.RevitShared.projitems @@ -16,7 +16,28 @@ - + + + + + + + + + + + + + + CefSharpPanel.xaml + + + + + + + + diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/ProxyMapper.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/ProxyMapper.cs deleted file mode 100644 index dabeb71d95..0000000000 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/ProxyMapper.cs +++ /dev/null @@ -1,17 +0,0 @@ -using Speckle.Converters.Common; -using Speckle.ProxyGenerator; - -namespace Speckle.Connectors.Rhino7.DependencyInjection; - -public class ProxyMapper : IProxyMapper -{ - public Type? GetMappedTypeFromHostType(Type type) => ProxyMap.GetMappedTypeFromHostType(type); - - public Type? GetMappedTypeFromProxyType(Type type) => ProxyMap.GetMappedTypeFromProxyType(type); - - public Type? GetHostTypeFromMappedType(Type type) => ProxyMap.GetHostTypeFromMappedType(type); - - public object CreateProxy(Type type, object toWrap) => ProxyMap.CreateProxy(type, toWrap); - - public T CreateProxy(object toWrap) => ProxyMap.CreateProxy(toWrap); -} diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/RhinoConnectorModule.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/RhinoConnectorModule.cs index 16cdc3a7de..7be48aa2b6 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/RhinoConnectorModule.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/RhinoConnectorModule.cs @@ -20,9 +20,7 @@ using Speckle.Connectors.Utils.Builders; using Speckle.Connectors.Utils.Caching; using Speckle.Connectors.Utils.Operations; -using Speckle.Converters.Common; using Speckle.Core.Models.GraphTraversal; -using Speckle.Rhino7.Api; namespace Speckle.Connectors.Rhino7.DependencyInjection; @@ -38,7 +36,6 @@ public void Load(SpeckleContainerBuilder builder) builder.AddConnectorUtils(); builder.AddDUI(); builder.AddDUIView(); - builder.ScanAssemblyOfType(); // POC: Overwriting the SyncToMainThread to SyncToCurrentThread for Rhino! builder.AddSingletonInstance(); @@ -47,7 +44,6 @@ public void Load(SpeckleContainerBuilder builder) builder.AddSingleton(); builder.AddSingleton(); builder.AddSingleton(); - builder.AddSingleton(); // Register bindings builder.AddSingleton(); diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/RhinoContext.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/RhinoContext.cs new file mode 100644 index 0000000000..17b532035a --- /dev/null +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/RhinoContext.cs @@ -0,0 +1,8 @@ +using Rhino; + +namespace Speckle.Connectors.Rhino7.HostApp; + +public class RhinoContext +{ + public RhinoDoc Document { get; } = RhinoDoc.ActiveDoc; +} diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Receive/DisableRedrawScope.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Receive/DisableRedrawScope.cs index 621bfa45ed..1182e5de7a 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Receive/DisableRedrawScope.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Receive/DisableRedrawScope.cs @@ -1,16 +1,16 @@ -using Speckle.Rhino7.Interfaces; +using Rhino.DocObjects.Tables; namespace Speckle.Connectors.Rhino7.Operations.Receive; /// -/// Helper class to disable within a scope +/// Helper class to disable within a scope /// public sealed class DisableRedrawScope : IDisposable { - private readonly IRhinoViewTable _viewTable; + private readonly ViewTable _viewTable; private readonly bool _returnToStatus; - public DisableRedrawScope(IRhinoViewTable viewTable, bool returnToStatus = true) + public DisableRedrawScope(ViewTable viewTable, bool returnToStatus = true) { _viewTable = viewTable; _returnToStatus = returnToStatus; diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Receive/RhinoHostObjectBuilder.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Receive/RhinoHostObjectBuilder.cs index 6c73b9bd10..02f653f08a 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Receive/RhinoHostObjectBuilder.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Receive/RhinoHostObjectBuilder.cs @@ -1,32 +1,31 @@ using System.Diagnostics.Contracts; +using Rhino; +using Rhino.DocObjects; +using Rhino.Geometry; using Speckle.Connectors.Utils.Builders; using Speckle.Connectors.Utils.Conversion; using Speckle.Converters.Common; using Speckle.Core.Logging; using Speckle.Core.Models; using Speckle.Core.Models.GraphTraversal; -using Speckle.Rhino7.Interfaces; namespace Speckle.Connectors.Rhino7.Operations.Receive; public class RhinoHostObjectBuilder : IHostObjectBuilder { private readonly IRootToHostConverter _converter; - private readonly IConversionContextStack _contextStack; + private readonly IConversionContextStack _contextStack; private readonly GraphTraversal _traverseFunction; - private readonly IRhinoDocFactory _rhinoDocFactory; public RhinoHostObjectBuilder( IRootToHostConverter converter, - IConversionContextStack contextStack, - GraphTraversal traverseFunction, - IRhinoDocFactory rhinoDocFactory + IConversionContextStack contextStack, + GraphTraversal traverseFunction ) { _converter = converter; _contextStack = contextStack; _traverseFunction = traverseFunction; - _rhinoDocFactory = rhinoDocFactory; } public HostObjectBuilderResult Build( @@ -54,19 +53,15 @@ CancellationToken cancellationToken // POC: Potentially refactor out into an IObjectBaker. private HostObjectBuilderResult BakeObjects(IEnumerable objectsGraph, string baseLayerName) { - var doc = _contextStack.Current.Document; - var rootLayerIndex = _contextStack.Current.Document.Layers.Find( - Guid.Empty, - baseLayerName, - _rhinoDocFactory.UnsetIntIndex - ); + RhinoDoc doc = _contextStack.Current.Document; + var rootLayerIndex = _contextStack.Current.Document.Layers.Find(Guid.Empty, baseLayerName, RhinoMath.UnsetIntIndex); // POC: We could move this out into a separate service for testing and re-use. // Cleans up any previously received objects - if (rootLayerIndex != _rhinoDocFactory.UnsetIntIndex) + if (rootLayerIndex != RhinoMath.UnsetIntIndex) { - var documentLayer = doc.Layers[rootLayerIndex]; - var childLayers = documentLayer.GetChildren(); + Layer documentLayer = doc.Layers[rootLayerIndex]; + Layer[]? childLayers = documentLayer.GetChildren(); if (childLayers != null) { using var layerNoDraw = new DisableRedrawScope(doc.Views); @@ -82,7 +77,7 @@ private HostObjectBuilderResult BakeObjects(IEnumerable object } var cache = new Dictionary(); - rootLayerIndex = doc.Layers.Add(_rhinoDocFactory.CreateLayer(baseLayerName)); + rootLayerIndex = doc.Layers.Add(new Layer { Name = baseLayerName }); cache.Add(baseLayerName, rootLayerIndex); using var noDraw = new DisableRedrawScope(doc.Views); @@ -96,7 +91,7 @@ private HostObjectBuilderResult BakeObjects(IEnumerable object { var path = GetLayerPath(tc); - var fullLayerName = string.Join(_rhinoDocFactory.LayerPathSeparator, path); + var fullLayerName = string.Join(Layer.PathSeparator, path); var layerIndex = cache.TryGetValue(fullLayerName, out int value) ? value : GetAndCreateLayerFromPath(path, baseLayerName, cache); @@ -125,31 +120,31 @@ private IReadOnlyList HandleConversionResult(object conversionResult, Ba List newObjectIds = new(); switch (conversionResult) { - case IEnumerable list: + case IEnumerable list: { - var group = BakeObjectsAsGroup(originalObject.id, list, layerIndex); + Group group = BakeObjectsAsGroup(originalObject.id, list, layerIndex); newObjectIds.Add(group.Id.ToString()); break; } - case IRhinoGeometryBase newObject: + case GeometryBase newObject: { - var newObjectGuid = doc.Objects.Add(newObject, _rhinoDocFactory.CreateAttributes(layerIndex)); + var newObjectGuid = doc.Objects.Add(newObject, new ObjectAttributes { LayerIndex = layerIndex }); newObjectIds.Add(newObjectGuid.ToString()); break; } default: throw new SpeckleConversionException( - $"Unexpected result from conversion: Expected {nameof(IRhinoGeometryBase)} but instead got {conversionResult.GetType().Name}" + $"Unexpected result from conversion: Expected {nameof(GeometryBase)} but instead got {conversionResult.GetType().Name}" ); } return newObjectIds; } - private IRhinoGroup BakeObjectsAsGroup(string groupName, IEnumerable list, int layerIndex) + private Group BakeObjectsAsGroup(string groupName, IEnumerable list, int layerIndex) { var doc = _contextStack.Current.Document; - var objectIds = list.Select(obj => doc.Objects.Add(obj, _rhinoDocFactory.CreateAttributes(layerIndex))); + var objectIds = list.Select(obj => doc.Objects.Add(obj, new ObjectAttributes { LayerIndex = layerIndex })); var groupIndex = _contextStack.Current.Document.Groups.Add(groupName, objectIds); var group = _contextStack.Current.Document.Groups.FindIndex(groupIndex); return group; @@ -159,12 +154,12 @@ private IRhinoGroup BakeObjectsAsGroup(string groupName, IEnumerable cache) { var currentLayerName = baseLayerName; - var currentDocument = _contextStack.Current.Document; + RhinoDoc currentDocument = _contextStack.Current.Document; var previousLayer = currentDocument.Layers.FindName(currentLayerName); foreach (var layerName in path) { - currentLayerName = baseLayerName + _rhinoDocFactory.LayerPathSeparator + layerName; + currentLayerName = baseLayerName + Layer.PathSeparator + layerName; currentLayerName = currentLayerName.Replace("{", "").Replace("}", ""); // Rhino specific cleanup for gh (see RemoveInvalidRhinoChars) if (cache.TryGetValue(currentLayerName, out int value)) { @@ -173,7 +168,7 @@ private int GetAndCreateLayerFromPath(string[] path, string baseLayerName, Dicti } var cleanNewLayerName = layerName.Replace("{", "").Replace("}", ""); - var newLayer = _rhinoDocFactory.CreateLayer(cleanNewLayerName, previousLayer.Id); + var newLayer = new Layer { Name = cleanNewLayerName, ParentLayerId = previousLayer.Id }; var index = currentDocument.Layers.Add(newLayer); cache.Add(currentLayerName, index); previousLayer = currentDocument.Layers.FindIndex(index); // note we need to get the correct id out, hence why we're double calling this diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Speckle.Connectors.Rhino7.csproj b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Speckle.Connectors.Rhino7.csproj index e114f0d218..dbea907d5c 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Speckle.Connectors.Rhino7.csproj +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Speckle.Connectors.Rhino7.csproj @@ -15,8 +15,6 @@ - - @@ -43,4 +41,5 @@ Resources.Designer.cs + diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/packages.lock.json b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/packages.lock.json index c8f0acc3ee..42b0399f3e 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/packages.lock.json +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/packages.lock.json @@ -39,24 +39,6 @@ "resolved": "0.9.5", "contentHash": "oU/L7pN1R7q8KkbrpQ3WJnHirPHqn+9DEA7asOcUiggV5dzVg1A/VYs7GOSusD24njxXh03tE3a2oTLOjt3cVg==" }, - "Speckle.Rhino7.Api": { - "type": "Direct", - "requested": "[0.1.1-preview.0.28, )", - "resolved": "0.1.1-preview.0.28", - "contentHash": "AE+1lMl+lzwEdNn6kvEWuCy6wRSFAIYP0KXeGI8fECNsCBj023c4IE/wSVn7wIHD+nM2ZHcST/62dmZXNqUt5A==", - "dependencies": { - "Mapster": "7.3.0", - "RhinoCommon": "7.13.21348.13001", - "RhinoWindows": "7.13.21348.13001", - "Speckle.Rhino7.Interfaces": "0.1.1-preview.0.28" - } - }, - "Speckle.Rhino7.Interfaces": { - "type": "Direct", - "requested": "[0.1.1-preview.0.28, )", - "resolved": "0.1.1-preview.0.28", - "contentHash": "TcbfXlRMnQRat1JodgW+YW5FflTYem1GGo9DtKA+6iAuVaYagN5dxsrM5LE6M3pCnEV9rkEQOjFo7sgnnbo4mw==" - }, "System.Resources.Extensions": { "type": "Direct", "requested": "[7.0.0, )", @@ -98,21 +80,6 @@ "resolved": "6.0.0", "contentHash": "yg72rrYDapfsIUrul7aF6wwNnTJBOFvuA9VdDTQpPa8AlAriHbufeXYLBcodKjfUdkCnaiggX1U/nEP08Zb5GA==" }, - "Mapster": { - "type": "Transitive", - "resolved": "7.3.0", - "contentHash": "NrCUX/rJa5PTyo6iW4AL5dZLU9PDNlYnrJOVjgdpo5OQM9EtWH2CMHnC5sSuJWC0d0b0SnmeRrIviEem6WxtuQ==", - "dependencies": { - "Mapster.Core": "1.2.0", - "Microsoft.CSharp": "4.3.0", - "System.Reflection.Emit": "4.3.0" - } - }, - "Mapster.Core": { - "type": "Transitive", - "resolved": "1.2.0", - "contentHash": "TNdqZk2zAuBYfJF88D/3clQTOyOdqr1crU81yZQtlGa+e7FYWhJdK/buBWT+TpM3qQko9UzmzfOT4iq3JCs/ZA==" - }, "Microsoft.Bcl.AsyncInterfaces": { "type": "Transitive", "resolved": "7.0.0", @@ -318,6 +285,11 @@ "resolved": "13.0.2", "contentHash": "g1BejUZwax5PRfL6xHgLEK23sqHWOgOj9hE7RvfRRlN00AGt8GnPYt8HedSK7UB3HiRW8zCA9Pn0iiYxCK24BA==" }, + "Speckle.Revit2023.Interfaces": { + "type": "Transitive", + "resolved": "0.1.1-preview.0.24", + "contentHash": "BSVpOUJc9g6ISrw8GxvtkglTlITpHEDYNOhxv1ZPbckBsI0yO36JiphhQV4q57ERqD9PpCozUJkVhlCaxWeS6A==" + }, "SQLitePCLRaw.bundle_e_sqlite3": { "type": "Transitive", "resolved": "2.1.4", @@ -410,11 +382,6 @@ "System.Threading.Tasks.Extensions": "4.5.4" } }, - "System.Reflection.Emit": { - "type": "Transitive", - "resolved": "4.3.0", - "contentHash": "228FG0jLcIwTVJyz8CLFKueVqQK36ANazUManGaJHkO0icjiIypKW7YLWLIWahyIkdh5M7mV2dJepllLyA1SKg==" - }, "System.Reflection.Metadata": { "type": "Transitive", "resolved": "5.0.0", @@ -518,7 +485,7 @@ "speckle.converters.rhino7.dependencyinjection": { "type": "Project", "dependencies": { - "Speckle.Rhino7.Interfaces": "[0.1.1-preview.0.28, )" + "RhinoCommon": "[7.13.21348.13001, )" } }, "Microsoft.Extensions.Logging.Abstractions": { diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3.DependencyInjection/ArcGISConverterModule.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3.DependencyInjection/ArcGISConverterModule.cs index 88d26d8166..30a739310b 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3.DependencyInjection/ArcGISConverterModule.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3.DependencyInjection/ArcGISConverterModule.cs @@ -11,7 +11,7 @@ public class ArcGISConverterModule : ISpeckleModule public void Load(SpeckleContainerBuilder builder) { //don't need a host specific RootToSpeckleConverter - builder.AddConverterCommon(); + builder.AddConverterCommon(); // most things should be InstancePerLifetimeScope so we get one per operation builder.AddScoped(); builder.AddScoped(); diff --git a/DUI3-DX/Converters/Autocad/2024/Speckle.Converters.Autocad2024/packages.lock.json b/DUI3-DX/Converters/Autocad/2024/Speckle.Converters.Autocad2024/packages.lock.json index 66a0d5e333..5ef4059ca1 100644 --- a/DUI3-DX/Converters/Autocad/2024/Speckle.Converters.Autocad2024/packages.lock.json +++ b/DUI3-DX/Converters/Autocad/2024/Speckle.Converters.Autocad2024/packages.lock.json @@ -211,42 +211,11 @@ "Serilog": "2.10.0" } }, - "Speckle.Core": { - "type": "Transitive", - "resolved": "3.0.1-alpha.11", - "contentHash": "Zt2dBJLlfziEACYCHThbhKypSjhoA01rTw9BzNI72c/BDyftXIz70Tetq/8ZMEqQnKqfmRyYADsAdWKxpdV0Hg==", - "dependencies": { - "GraphQL.Client": "6.0.0", - "Microsoft.CSharp": "4.7.0", - "Microsoft.Data.Sqlite": "7.0.5", - "Polly": "7.2.3", - "Polly.Contrib.WaitAndRetry": "1.1.1", - "Polly.Extensions.Http": "3.0.0", - "Sentry": "3.33.0", - "Sentry.Serilog": "3.33.0", - "Serilog": "2.12.0", - "Serilog.Enrichers.ClientInfo": "1.3.0", - "Serilog.Exceptions": "8.4.0", - "Serilog.Sinks.Console": "4.1.0", - "Serilog.Sinks.Seq": "5.2.2", - "SerilogTimings": "3.0.1", - "Speckle.Newtonsoft.Json": "13.0.2", - "System.DoubleNumerics": "3.1.3" - } - }, "Speckle.Newtonsoft.Json": { "type": "Transitive", "resolved": "13.0.2", "contentHash": "g1BejUZwax5PRfL6xHgLEK23sqHWOgOj9hE7RvfRRlN00AGt8GnPYt8HedSK7UB3HiRW8zCA9Pn0iiYxCK24BA==" }, - "Speckle.Objects": { - "type": "Transitive", - "resolved": "3.0.1-alpha.11", - "contentHash": "YR7sei3OQBAi8R/kIu8bEmg5ELDIJK6l5fhOgdnqA9ZvD/fvmRb+09z8lIUTDsgdAdvYU/A/x9VxH9OGPbp9Kw==", - "dependencies": { - "Speckle.Core": "3.0.1-alpha.11" - } - }, "SQLitePCLRaw.bundle_e_sqlite3": { "type": "Transitive", "resolved": "2.1.4", diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/RevitConverterModule.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/RevitConverterModule.cs index 7900f25180..60c5050217 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/RevitConverterModule.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/RevitConverterModule.cs @@ -1,11 +1,10 @@ +using Autodesk.Revit.DB; using Speckle.Autofac.DependencyInjection; -using Speckle.Converters.Common; using Speckle.Converters.Common.DependencyInjection; using Speckle.Converters.RevitShared; using Speckle.Converters.RevitShared.Helpers; using Speckle.Converters.RevitShared.Services; using Speckle.Converters.RevitShared.ToSpeckle; -using Speckle.Revit.Interfaces; namespace Speckle.Converters.Revit2023.DependencyInjection; @@ -13,21 +12,24 @@ public class RevitConverterModule : ISpeckleModule { public void Load(SpeckleContainerBuilder builder) { - builder.AddConverterCommon(); + builder.AddConverterCommon(); + builder.AddSingleton(new RevitContext()); // POC: do we need ToSpeckleScalingService as is, do we need to interface it out? - builder.AddScoped(); + builder.AddScoped(); + + // POC: the concrete type can come out if we remove all the reference to it + builder.AddScoped(); builder.AddScoped(); - builder.AddScoped(); + builder.AddScoped(); builder.AddScoped(); - builder.AddScoped(); - builder.AddScoped(); - builder.AddScoped(); - builder.AddScoped(); + builder.AddScoped(); + builder.AddScoped(); + builder.AddScoped(); + builder.AddScoped(); builder.AddScoped(); - builder.AddScoped(); } } diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/Speckle.Converters.Revit2023.DependencyInjection.csproj b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/Speckle.Converters.Revit2023.DependencyInjection.csproj index a4ecb27491..704fef95ed 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/Speckle.Converters.Revit2023.DependencyInjection.csproj +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/Speckle.Converters.Revit2023.DependencyInjection.csproj @@ -5,9 +5,6 @@ x64 - - - diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/packages.lock.json b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/packages.lock.json index 928fe09a85..a1186a3a61 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/packages.lock.json +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/packages.lock.json @@ -24,17 +24,6 @@ "resolved": "0.9.5", "contentHash": "oU/L7pN1R7q8KkbrpQ3WJnHirPHqn+9DEA7asOcUiggV5dzVg1A/VYs7GOSusD24njxXh03tE3a2oTLOjt3cVg==" }, - "Speckle.Revit2023.Api": { - "type": "Direct", - "requested": "[0.1.1-preview.0.28, )", - "resolved": "0.1.1-preview.0.28", - "contentHash": "ejwYS/HI8yy0rJE4vgTr5aj8Fkg/E9JnMGjwyVS2fLtI4f7+FmwAY6inTUT2p/RAoRc2nQw+TerDpUtOhddzag==", - "dependencies": { - "Mapster": "7.3.0", - "Speckle.Revit.API": "2023.0.0", - "Speckle.Revit2023.Interfaces": "0.1.1-preview.0.28" - } - }, "GraphQL.Client": { "type": "Transitive", "resolved": "6.0.0", @@ -67,21 +56,6 @@ "resolved": "6.0.0", "contentHash": "yg72rrYDapfsIUrul7aF6wwNnTJBOFvuA9VdDTQpPa8AlAriHbufeXYLBcodKjfUdkCnaiggX1U/nEP08Zb5GA==" }, - "Mapster": { - "type": "Transitive", - "resolved": "7.3.0", - "contentHash": "NrCUX/rJa5PTyo6iW4AL5dZLU9PDNlYnrJOVjgdpo5OQM9EtWH2CMHnC5sSuJWC0d0b0SnmeRrIviEem6WxtuQ==", - "dependencies": { - "Mapster.Core": "1.2.0", - "Microsoft.CSharp": "4.3.0", - "System.Reflection.Emit": "4.3.0" - } - }, - "Mapster.Core": { - "type": "Transitive", - "resolved": "1.2.0", - "contentHash": "TNdqZk2zAuBYfJF88D/3clQTOyOdqr1crU81yZQtlGa+e7FYWhJdK/buBWT+TpM3qQko9UzmzfOT4iq3JCs/ZA==" - }, "Microsoft.Bcl.AsyncInterfaces": { "type": "Transitive", "resolved": "5.0.0", @@ -236,11 +210,6 @@ "resolved": "13.0.2", "contentHash": "g1BejUZwax5PRfL6xHgLEK23sqHWOgOj9hE7RvfRRlN00AGt8GnPYt8HedSK7UB3HiRW8zCA9Pn0iiYxCK24BA==" }, - "Speckle.Revit.API": { - "type": "Transitive", - "resolved": "2023.0.0", - "contentHash": "tq40eD7psgTbV+epNouYyqfo6+hEi7FmXZqcxEOsAV7zfYyWhL6Rt3vmojkWGNuerGbH6oRI6KIIxrnlCNb8Hw==" - }, "SQLitePCLRaw.bundle_e_sqlite3": { "type": "Transitive", "resolved": "2.1.4", @@ -324,11 +293,6 @@ "System.Threading.Tasks.Extensions": "4.5.4" } }, - "System.Reflection.Emit": { - "type": "Transitive", - "resolved": "4.3.0", - "contentHash": "228FG0jLcIwTVJyz8CLFKueVqQK36ANazUManGaJHkO0icjiIypKW7YLWLIWahyIkdh5M7mV2dJepllLyA1SKg==" - }, "System.Reflection.Metadata": { "type": "Transitive", "resolved": "5.0.0", @@ -408,7 +372,7 @@ "type": "Project", "dependencies": { "Speckle.Converters.Common": "[2.0.999-local, )", - "Speckle.Revit2023.Interfaces": "[0.1.1-preview.0.28, )" + "Speckle.Revit.API": "[2023.0.0, )" } }, "Microsoft.Extensions.Logging.Abstractions": { @@ -454,11 +418,11 @@ "Speckle.Core": "3.0.1-alpha.11" } }, - "Speckle.Revit2023.Interfaces": { + "Speckle.Revit.API": { "type": "CentralTransitive", - "requested": "[0.1.1-preview.0.28, )", - "resolved": "0.1.1-preview.0.28", - "contentHash": "7szXg/vRvP3Wdrn2ZGriVOfsw+bddlpVorBkCIhSHHs5qVTTG8IAIrI1l9dO0/aullaTMF+Xgxm9x3w1aXPiuA==" + "requested": "[2023.0.0, )", + "resolved": "2023.0.0", + "contentHash": "tq40eD7psgTbV+epNouYyqfo6+hEi7FmXZqcxEOsAV7zfYyWhL6Rt3vmojkWGNuerGbH6oRI6KIIxrnlCNb8Hw==" } } } diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/LocationConversionToSpeckleTests.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/LocationConversionToSpeckleTests.cs deleted file mode 100644 index 6fb5ba34d3..0000000000 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/LocationConversionToSpeckleTests.cs +++ /dev/null @@ -1,85 +0,0 @@ -using FluentAssertions; -using Moq; -using NUnit.Framework; -using Objects; -using Speckle.Converters.Common; -using Speckle.Converters.Common.Objects; -using Speckle.Converters.RevitShared; -using Speckle.Converters.RevitShared.Services; -using Speckle.Revit.Interfaces; - -namespace Speckle.Converters.Revit2023.Tests; - -public class ModelCurveArrayToSpeckleConverterTests -{ - private readonly MockRepository _repository = new(MockBehavior.Strict); - - private readonly Mock> _revitConversionContextStack; - private readonly Mock _scalingServiceToSpeckle; - private readonly Mock> _curveConverter; - - public ModelCurveArrayToSpeckleConverterTests() - { - _revitConversionContextStack = _repository.Create>(); - _scalingServiceToSpeckle = _repository.Create(); - _curveConverter = _repository.Create>(); - } - - [TearDown] - public void Verify() => _repository.VerifyAll(); - - [Test] - public void Convert_Empty() - { - var sut = new ModelCurveArrayToSpeckleConverter( - _revitConversionContextStack.Object, - _scalingServiceToSpeckle.Object, - _curveConverter.Object - ); - Assert.Throws(() => sut.Convert(new List())); - } - - [Test] - public void Convert() - { - var endpoint1 = _repository.Create(); - var geometry1 = _repository.Create(); - var curve1 = _repository.Create(); - curve1.Setup(x => x.GeometryCurve).Returns(geometry1.Object); - geometry1.Setup(x => x.Length).Returns(2); - geometry1.Setup(x => x.GetEndPoint(0)).Returns(endpoint1.Object); - - var endpoint2 = _repository.Create(); - var geometry2 = _repository.Create(); - var curve2 = _repository.Create(); - curve2.Setup(x => x.GeometryCurve).Returns(geometry2.Object); - geometry2.Setup(x => x.Length).Returns(3); - geometry2.Setup(x => x.GetEndPoint(1)).Returns(endpoint2.Object); - - var context = _repository.Create>(); - _revitConversionContextStack.Setup(x => x.Current).Returns(context.Object); - - var units = "units"; - context.Setup(x => x.SpeckleUnits).Returns(units); - - var scaleLength = 2.2; - _scalingServiceToSpeckle.Setup(x => x.ScaleLength(2 + 3)).Returns(scaleLength); - - endpoint1.Setup(x => x.DistanceTo(endpoint2.Object)).Returns(4.4); - - _curveConverter.Setup(x => x.Convert(geometry1.Object)).Returns(_repository.Create().Object); - _curveConverter.Setup(x => x.Convert(geometry2.Object)).Returns(_repository.Create().Object); - - var sut = new ModelCurveArrayToSpeckleConverter( - _revitConversionContextStack.Object, - _scalingServiceToSpeckle.Object, - _curveConverter.Object - ); - var polycurve = sut.Convert(new List() { curve1.Object, curve2.Object }); - - polycurve.units.Should().Be(units); - polycurve.closed.Should().BeFalse(); - polycurve.length.Should().Be(scaleLength); - polycurve.segments.Count.Should().Be(2); - } -} diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/Speckle.Converters.Revit2023.Tests.csproj b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/Speckle.Converters.Revit2023.Tests.csproj deleted file mode 100644 index 2839be1e72..0000000000 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/Speckle.Converters.Revit2023.Tests.csproj +++ /dev/null @@ -1,27 +0,0 @@ - - - - net48 - x64 - false - true - - - - - - - - - - - - - - - - - - - - diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/packages.lock.json b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/packages.lock.json deleted file mode 100644 index 2c05f6ade3..0000000000 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/packages.lock.json +++ /dev/null @@ -1,560 +0,0 @@ -{ - "version": 2, - "dependencies": { - ".NETFramework,Version=v4.8": { - "FluentAssertions": { - "type": "Direct", - "requested": "[6.12.0, )", - "resolved": "6.12.0", - "contentHash": "ZXhHT2YwP9lajrwSKbLlFqsmCCvFJMoRSK9t7sImfnCyd0OB3MhgxdoMcVqxbq1iyxD6mD2fiackWmBb7ayiXQ==", - "dependencies": { - "System.Threading.Tasks.Extensions": "4.5.0" - } - }, - "Microsoft.NET.Test.Sdk": { - "type": "Direct", - "requested": "[17.10.0, )", - "resolved": "17.10.0", - "contentHash": "0/2HeACkaHEYU3wc83YlcD2Fi4LMtECJjqrtvw0lPi9DCEa35zSPt1j4fuvM8NagjDqJuh1Ja35WcRtn1Um6/A==", - "dependencies": { - "Microsoft.CodeCoverage": "17.10.0" - } - }, - "Microsoft.SourceLink.GitHub": { - "type": "Direct", - "requested": "[8.0.0, )", - "resolved": "8.0.0", - "contentHash": "G5q7OqtwIyGTkeIOAc3u2ZuV/kicQaec5EaRnc0pIeSnh9LUjj+PYQrJYBURvDt7twGl2PKA7nSN0kz1Zw5bnQ==", - "dependencies": { - "Microsoft.Build.Tasks.Git": "8.0.0", - "Microsoft.SourceLink.Common": "8.0.0" - } - }, - "Moq": { - "type": "Direct", - "requested": "[4.20.70, )", - "resolved": "4.20.70", - "contentHash": "4rNnAwdpXJBuxqrOCzCyICXHSImOTRktCgCWXWykuF1qwoIsVvEnR7PjbMk/eLOxWvhmj5Kwt+kDV3RGUYcNwg==", - "dependencies": { - "Castle.Core": "5.1.1", - "System.Threading.Tasks.Extensions": "4.5.4" - } - }, - "NUnit": { - "type": "Direct", - "requested": "[4.1.0, )", - "resolved": "4.1.0", - "contentHash": "MT/DpAhjtiytzhTgTqIhBuWx4y26PKfDepYUHUM+5uv4TsryHC2jwFo5e6NhWkApCm/G6kZ80dRjdJFuAxq3rg==", - "dependencies": { - "System.Threading.Tasks.Extensions": "4.5.4" - } - }, - "NUnit.Analyzers": { - "type": "Direct", - "requested": "[4.2.0, )", - "resolved": "4.2.0", - "contentHash": "4fJojPkzdoa4nB2+p6U+fITvPnVvwWSnsmiJ/Dl30xqiL3oxNbYvfeSLVd91hOmEjoUqSwN3Z7j1aFedjqWbUA==" - }, - "PolySharp": { - "type": "Direct", - "requested": "[1.14.1, )", - "resolved": "1.14.1", - "contentHash": "mOOmFYwad3MIOL14VCjj02LljyF1GNw1wP0YVlxtcPvqdxjGGMNdNJJxHptlry3MOd8b40Flm8RPOM8JOlN2sQ==" - }, - "Speckle.InterfaceGenerator": { - "type": "Direct", - "requested": "[0.9.5, )", - "resolved": "0.9.5", - "contentHash": "oU/L7pN1R7q8KkbrpQ3WJnHirPHqn+9DEA7asOcUiggV5dzVg1A/VYs7GOSusD24njxXh03tE3a2oTLOjt3cVg==" - }, - "Speckle.Revit2023.Interfaces": { - "type": "Direct", - "requested": "[0.1.1-preview.0.28, )", - "resolved": "0.1.1-preview.0.28", - "contentHash": "7szXg/vRvP3Wdrn2ZGriVOfsw+bddlpVorBkCIhSHHs5qVTTG8IAIrI1l9dO0/aullaTMF+Xgxm9x3w1aXPiuA==" - }, - "Castle.Core": { - "type": "Transitive", - "resolved": "5.1.1", - "contentHash": "rpYtIczkzGpf+EkZgDr9CClTdemhsrwA/W5hMoPjLkRFnXzH44zDLoovXeKtmxb1ykXK9aJVODSpiJml8CTw2g==" - }, - "GraphQL.Client": { - "type": "Transitive", - "resolved": "6.0.0", - "contentHash": "8yPNBbuVBpTptivyAlak4GZvbwbUcjeQTL4vN1HKHRuOykZ4r7l5fcLS6vpyPyLn0x8FsL31xbOIKyxbmR9rbA==", - "dependencies": { - "GraphQL.Client.Abstractions": "6.0.0", - "GraphQL.Client.Abstractions.Websocket": "6.0.0", - "System.Net.WebSockets.Client.Managed": "1.0.22", - "System.Reactive": "5.0.0" - } - }, - "GraphQL.Client.Abstractions": { - "type": "Transitive", - "resolved": "6.0.0", - "contentHash": "h7uzWFORHZ+CCjwr/ThAyXMr0DPpzEANDa4Uo54wqCQ+j7qUKwqYTgOrb1W40sqbvNaZm9v/X7It31SUw0maHA==", - "dependencies": { - "GraphQL.Primitives": "6.0.0" - } - }, - "GraphQL.Client.Abstractions.Websocket": { - "type": "Transitive", - "resolved": "6.0.0", - "contentHash": "Nr9bPf8gIOvLuXpqEpqr9z9jslYFJOvd0feHth3/kPqeR3uMbjF5pjiwh4jxyMcxHdr8Pb6QiXkV3hsSyt0v7A==", - "dependencies": { - "GraphQL.Client.Abstractions": "6.0.0" - } - }, - "GraphQL.Primitives": { - "type": "Transitive", - "resolved": "6.0.0", - "contentHash": "yg72rrYDapfsIUrul7aF6wwNnTJBOFvuA9VdDTQpPa8AlAriHbufeXYLBcodKjfUdkCnaiggX1U/nEP08Zb5GA==" - }, - "Microsoft.Bcl.AsyncInterfaces": { - "type": "Transitive", - "resolved": "7.0.0", - "contentHash": "3aeMZ1N0lJoSyzqiP03hqemtb1BijhsJADdobn/4nsMJ8V1H+CrpuduUe4hlRdx+ikBQju1VGjMD1GJ3Sk05Eg==", - "dependencies": { - "System.Threading.Tasks.Extensions": "4.5.4" - } - }, - "Microsoft.Build.Tasks.Git": { - "type": "Transitive", - "resolved": "8.0.0", - "contentHash": "bZKfSIKJRXLTuSzLudMFte/8CempWjVamNUR5eHJizsy+iuOuO/k2gnh7W0dHJmYY0tBf+gUErfluCv5mySAOQ==" - }, - "Microsoft.CodeCoverage": { - "type": "Transitive", - "resolved": "17.10.0", - "contentHash": "yC7oSlnR54XO5kOuHlVOKtxomNNN1BWXX8lK1G2jaPXT9sUok7kCOoA4Pgs0qyFaCtMrNsprztYMeoEGqCm4uA==" - }, - "Microsoft.CSharp": { - "type": "Transitive", - "resolved": "4.7.0", - "contentHash": "pTj+D3uJWyN3My70i2Hqo+OXixq3Os2D1nJ2x92FFo6sk8fYS1m1WLNTs0Dc1uPaViH0YvEEwvzddQ7y4rhXmA==" - }, - "Microsoft.Data.Sqlite": { - "type": "Transitive", - "resolved": "7.0.5", - "contentHash": "KGxbPeWsQMnmQy43DSBxAFtHz3l2JX8EWBSGUCvT3CuZ8KsuzbkqMIJMDOxWtG8eZSoCDI04aiVQjWuuV8HmSw==", - "dependencies": { - "Microsoft.Data.Sqlite.Core": "7.0.5", - "SQLitePCLRaw.bundle_e_sqlite3": "2.1.4" - } - }, - "Microsoft.Data.Sqlite.Core": { - "type": "Transitive", - "resolved": "7.0.5", - "contentHash": "FTerRmQPqHrCrnoUzhBu+E+1DNGwyrAMLqHkAqOOOu5pGfyMOj8qQUBxI/gDtWtG11p49UxSfWmBzRNlwZqfUg==", - "dependencies": { - "SQLitePCLRaw.core": "2.1.4" - } - }, - "Microsoft.Extensions.DependencyInjection": { - "type": "Transitive", - "resolved": "7.0.0", - "contentHash": "elNeOmkeX3eDVG6pYVeV82p29hr+UKDaBhrZyWvWLw/EVZSYEkZlQdkp0V39k/Xehs2Qa0mvoCvkVj3eQxNQ1Q==", - "dependencies": { - "Microsoft.Bcl.AsyncInterfaces": "7.0.0", - "Microsoft.Extensions.DependencyInjection.Abstractions": "7.0.0", - "System.Threading.Tasks.Extensions": "4.5.4" - } - }, - "Microsoft.Extensions.DependencyInjection.Abstractions": { - "type": "Transitive", - "resolved": "7.0.0", - "contentHash": "h3j/QfmFN4S0w4C2A6X7arXij/M/OVw3uQHSOFxnND4DyAzO1F9eMX7Eti7lU/OkSthEE0WzRsfT/Dmx86jzCw==", - "dependencies": { - "Microsoft.Bcl.AsyncInterfaces": "7.0.0", - "System.Threading.Tasks.Extensions": "4.5.4" - } - }, - "Microsoft.Extensions.Logging": { - "type": "Transitive", - "resolved": "7.0.0", - "contentHash": "Nw2muoNrOG5U5qa2ZekXwudUn2BJcD41e65zwmDHb1fQegTX66UokLWZkJRpqSSHXDOWZ5V0iqhbxOEky91atA==", - "dependencies": { - "Microsoft.Bcl.AsyncInterfaces": "7.0.0", - "Microsoft.Extensions.DependencyInjection": "7.0.0", - "Microsoft.Extensions.DependencyInjection.Abstractions": "7.0.0", - "Microsoft.Extensions.Logging.Abstractions": "7.0.0", - "Microsoft.Extensions.Options": "7.0.0", - "System.Diagnostics.DiagnosticSource": "7.0.0", - "System.ValueTuple": "4.5.0" - } - }, - "Microsoft.Extensions.Options": { - "type": "Transitive", - "resolved": "7.0.0", - "contentHash": "lP1yBnTTU42cKpMozuafbvNtQ7QcBjr/CcK3bYOGEMH55Fjt+iecXjT6chR7vbgCMqy3PG3aNQSZgo/EuY/9qQ==", - "dependencies": { - "Microsoft.Extensions.DependencyInjection.Abstractions": "7.0.0", - "Microsoft.Extensions.Primitives": "7.0.0" - } - }, - "Microsoft.Extensions.Primitives": { - "type": "Transitive", - "resolved": "7.0.0", - "contentHash": "um1KU5kxcRp3CNuI8o/GrZtD4AIOXDk+RLsytjZ9QPok3ttLUelLKpilVPuaFT3TFjOhSibUAso0odbOaCDj3Q==", - "dependencies": { - "System.Memory": "4.5.5", - "System.Runtime.CompilerServices.Unsafe": "6.0.0" - } - }, - "Microsoft.SourceLink.Common": { - "type": "Transitive", - "resolved": "8.0.0", - "contentHash": "dk9JPxTCIevS75HyEQ0E4OVAFhB2N+V9ShCXf8Q6FkUQZDkgLI12y679Nym1YqsiSysuQskT7Z+6nUf3yab6Vw==" - }, - "Polly": { - "type": "Transitive", - "resolved": "7.2.3", - "contentHash": "DeCY0OFbNdNxsjntr1gTXHJ5pKUwYzp04Er2LLeN3g6pWhffsGuKVfMBLe1lw7x76HrPkLxKEFxBlpRxS2nDEQ==" - }, - "Polly.Contrib.WaitAndRetry": { - "type": "Transitive", - "resolved": "1.1.1", - "contentHash": "1MUQLiSo4KDkQe6nzQRhIU05lm9jlexX5BVsbuw0SL82ynZ+GzAHQxJVDPVBboxV37Po3SG077aX8DuSy8TkaA==" - }, - "Polly.Extensions.Http": { - "type": "Transitive", - "resolved": "3.0.0", - "contentHash": "drrG+hB3pYFY7w1c3BD+lSGYvH2oIclH8GRSehgfyP5kjnFnHKQuuBhuHLv+PWyFuaTDyk/vfRpnxOzd11+J8g==", - "dependencies": { - "Polly": "7.1.0" - } - }, - "Sentry": { - "type": "Transitive", - "resolved": "3.33.0", - "contentHash": "8vbD2o6IR2wrRrkSiRbnodWGWUOqIlwYtzpjvPNOb5raJdOf+zxMwfS8f6nx9bmrTTfDj7KrCB8C/5OuicAc8A==", - "dependencies": { - "System.Reflection.Metadata": "5.0.0", - "System.Runtime.InteropServices.RuntimeInformation": "4.3.0", - "System.Text.Json": "5.0.2" - } - }, - "Sentry.Serilog": { - "type": "Transitive", - "resolved": "3.33.0", - "contentHash": "V8BU7QGWg2qLYfNPqtuTBhC1opysny5l+Ifp6J6PhOeAxU0FssR7nYfbJVetrnLIoh2rd3DlJ6hHYYQosQYcUQ==", - "dependencies": { - "Sentry": "3.33.0", - "Serilog": "2.7.1" - } - }, - "Serilog": { - "type": "Transitive", - "resolved": "2.12.0", - "contentHash": "xaiJLIdu6rYMKfQMYUZgTy8YK7SMZjB4Yk50C/u//Z4OsvxkUfSPJy4nknfvwAC34yr13q7kcyh4grbwhSxyZg==" - }, - "Serilog.Enrichers.ClientInfo": { - "type": "Transitive", - "resolved": "1.3.0", - "contentHash": "mTc7PM+wC9Hr7LWSwqt5mmnlAr7RJs+eTb3PGPRhwdOackk95MkhUZognuxXEdlW19HAFNmEBTSBY5DfLwM8jQ==", - "dependencies": { - "Serilog": "2.4.0" - } - }, - "Serilog.Exceptions": { - "type": "Transitive", - "resolved": "8.4.0", - "contentHash": "nc/+hUw3lsdo0zCj0KMIybAu7perMx79vu72w0za9Nsi6mWyNkGXxYxakAjWB7nEmYL6zdmhEQRB4oJ2ALUeug==", - "dependencies": { - "Serilog": "2.8.0" - } - }, - "Serilog.Formatting.Compact": { - "type": "Transitive", - "resolved": "1.1.0", - "contentHash": "pNroKVjo+rDqlxNG5PXkRLpfSCuDOBY0ri6jp9PLe505ljqwhwZz8ospy2vWhQlFu5GkIesh3FcDs4n7sWZODA==", - "dependencies": { - "Serilog": "2.8.0" - } - }, - "Serilog.Sinks.Console": { - "type": "Transitive", - "resolved": "4.1.0", - "contentHash": "K6N5q+5fetjnJPvCmkWOpJ/V8IEIoMIB1s86OzBrbxwTyHxdx3pmz4H+8+O/Dc/ftUX12DM1aynx/dDowkwzqg==", - "dependencies": { - "Serilog": "2.10.0" - } - }, - "Serilog.Sinks.File": { - "type": "Transitive", - "resolved": "5.0.0", - "contentHash": "uwV5hdhWPwUH1szhO8PJpFiahqXmzPzJT/sOijH/kFgUx+cyoDTMM8MHD0adw9+Iem6itoibbUXHYslzXsLEAg==", - "dependencies": { - "Serilog": "2.10.0" - } - }, - "Serilog.Sinks.PeriodicBatching": { - "type": "Transitive", - "resolved": "3.1.0", - "contentHash": "NDWR7m3PalVlGEq3rzoktrXikjFMLmpwF0HI4sowo8YDdU+gqPlTHlDQiOGxHfB0sTfjPA9JjA7ctKG9zqjGkw==", - "dependencies": { - "Serilog": "2.0.0" - } - }, - "Serilog.Sinks.Seq": { - "type": "Transitive", - "resolved": "5.2.2", - "contentHash": "1Csmo5ua7NKUe0yXUx+zsRefjAniPWcXFhUXxXG8pwo0iMiw2gjn9SOkgYnnxbgWqmlGv236w0N/dHc2v5XwMg==", - "dependencies": { - "Serilog": "2.12.0", - "Serilog.Formatting.Compact": "1.1.0", - "Serilog.Sinks.File": "5.0.0", - "Serilog.Sinks.PeriodicBatching": "3.1.0" - } - }, - "SerilogTimings": { - "type": "Transitive", - "resolved": "3.0.1", - "contentHash": "Zs28eTgszAMwpIrbBnWHBI50yuxL50p/dmAUWmy75+axdZYK/Sjm5/5m1N/CisR8acJUhTVcjPZrsB1P5iv0Uw==", - "dependencies": { - "Serilog": "2.10.0" - } - }, - "Speckle.Newtonsoft.Json": { - "type": "Transitive", - "resolved": "13.0.2", - "contentHash": "g1BejUZwax5PRfL6xHgLEK23sqHWOgOj9hE7RvfRRlN00AGt8GnPYt8HedSK7UB3HiRW8zCA9Pn0iiYxCK24BA==" - }, - "SQLitePCLRaw.bundle_e_sqlite3": { - "type": "Transitive", - "resolved": "2.1.4", - "contentHash": "EWI1olKDjFEBMJu0+3wuxwziIAdWDVMYLhuZ3Qs84rrz+DHwD00RzWPZCa+bLnHCf3oJwuFZIRsHT5p236QXww==", - "dependencies": { - "SQLitePCLRaw.lib.e_sqlite3": "2.1.4", - "SQLitePCLRaw.provider.dynamic_cdecl": "2.1.4" - } - }, - "SQLitePCLRaw.core": { - "type": "Transitive", - "resolved": "2.1.4", - "contentHash": "inBjvSHo9UDKneGNzfUfDjK08JzlcIhn1+SP5Y3m6cgXpCxXKCJDy6Mka7LpgSV+UZmKSnC8rTwB0SQ0xKu5pA==", - "dependencies": { - "System.Memory": "4.5.3" - } - }, - "SQLitePCLRaw.lib.e_sqlite3": { - "type": "Transitive", - "resolved": "2.1.4", - "contentHash": "2C9Q9eX7CPLveJA0rIhf9RXAvu+7nWZu1A2MdG6SD/NOu26TakGgL1nsbc0JAspGijFOo3HoN79xrx8a368fBg==" - }, - "SQLitePCLRaw.provider.dynamic_cdecl": { - "type": "Transitive", - "resolved": "2.1.4", - "contentHash": "ZsaKKhgYF9B1fvcnOGKl3EycNAwd9CRWX7v0rEfuPWhQQ5Jjpvf2VEHahiLIGHio3hxi3EIKFJw9KvyowWOUAw==", - "dependencies": { - "SQLitePCLRaw.core": "2.1.4" - } - }, - "System.Buffers": { - "type": "Transitive", - "resolved": "4.5.1", - "contentHash": "Rw7ijyl1qqRS0YQD/WycNst8hUUMgrMH4FCn1nNm27M4VxchZ1js3fVjQaANHO5f3sN4isvP4a+Met9Y4YomAg==" - }, - "System.Collections.Immutable": { - "type": "Transitive", - "resolved": "5.0.0", - "contentHash": "FXkLXiK0sVVewcso0imKQoOxjoPAj42R8HtjjbSjVPAzwDfzoyoznWxgA3c38LDbN9SJux1xXoXYAhz98j7r2g==", - "dependencies": { - "System.Memory": "4.5.4" - } - }, - "System.Diagnostics.DiagnosticSource": { - "type": "Transitive", - "resolved": "7.0.0", - "contentHash": "9W0ewWDuAyDqS2PigdTxk6jDKonfgscY/hP8hm7VpxYhNHZHKvZTdRckberlFk3VnCmr3xBUyMBut12Q+T2aOw==", - "dependencies": { - "System.Memory": "4.5.5", - "System.Runtime.CompilerServices.Unsafe": "6.0.0" - } - }, - "System.DoubleNumerics": { - "type": "Transitive", - "resolved": "3.1.3", - "contentHash": "KRKEM/L3KBodjA9VOg3EifFVWUY6EOqaMB05UvPEDm7Zeby/kZW+4kdWUEPzW6xtkwf46p661L9NrbeeQhtLzw==", - "dependencies": { - "NETStandard.Library": "1.6.1" - } - }, - "System.Memory": { - "type": "Transitive", - "resolved": "4.5.5", - "contentHash": "XIWiDvKPXaTveaB7HVganDlOCRoj03l+jrwNvcge/t8vhGYKvqV+dMv6G4SAX2NoNmN0wZfVPTAlFwZcZvVOUw==", - "dependencies": { - "System.Buffers": "4.5.1", - "System.Numerics.Vectors": "4.5.0", - "System.Runtime.CompilerServices.Unsafe": "4.5.3" - } - }, - "System.Net.WebSockets.Client.Managed": { - "type": "Transitive", - "resolved": "1.0.22", - "contentHash": "WqEOxPlXjuZrIjUtXNE9NxEfU/n5E35iV2PtoZdJSUC4tlrqwHnTee+wvMIM4OUaJWmwrymeqcgYrE0IkGAgLA==", - "dependencies": { - "System.Buffers": "4.4.0", - "System.Numerics.Vectors": "4.4.0" - } - }, - "System.Numerics.Vectors": { - "type": "Transitive", - "resolved": "4.5.0", - "contentHash": "QQTlPTl06J/iiDbJCiepZ4H//BVraReU4O4EoRw1U02H5TLUIT7xn3GnDp9AXPSlJUDyFs4uWjWafNX6WrAojQ==" - }, - "System.Reactive": { - "type": "Transitive", - "resolved": "5.0.0", - "contentHash": "erBZjkQHWL9jpasCE/0qKAryzVBJFxGHVBAvgRN1bzM0q2s1S4oYREEEL0Vb+1kA/6BKb5FjUZMp5VXmy+gzkQ==", - "dependencies": { - "System.Threading.Tasks.Extensions": "4.5.4" - } - }, - "System.Reflection.Metadata": { - "type": "Transitive", - "resolved": "5.0.0", - "contentHash": "5NecZgXktdGg34rh1OenY1rFNDCI8xSjFr+Z4OU4cU06AQHUdRnIIEeWENu3Wl4YowbzkymAIMvi3WyK9U53pQ==", - "dependencies": { - "System.Collections.Immutable": "5.0.0" - } - }, - "System.Runtime.CompilerServices.Unsafe": { - "type": "Transitive", - "resolved": "6.0.0", - "contentHash": "/iUeP3tq1S0XdNNoMz5C9twLSrM/TH+qElHkXWaPvuNOt+99G75NrV0OS2EqHx5wMN7popYjpc8oTjC1y16DLg==" - }, - "System.Runtime.InteropServices.RuntimeInformation": { - "type": "Transitive", - "resolved": "4.3.0", - "contentHash": "cbz4YJMqRDR7oLeMRbdYv7mYzc++17lNhScCX0goO2XpGWdvAt60CGN+FHdePUEHCe/Jy9jUlvNAiNdM+7jsOw==" - }, - "System.Text.Encodings.Web": { - "type": "Transitive", - "resolved": "5.0.1", - "contentHash": "KmJ+CJXizDofbq6mpqDoRRLcxgOd2z9X3XoFNULSbvbqVRZkFX3istvr+MUjL6Zw1RT+RNdoI4GYidIINtgvqQ==", - "dependencies": { - "System.Buffers": "4.5.1", - "System.Memory": "4.5.4" - } - }, - "System.Text.Json": { - "type": "Transitive", - "resolved": "5.0.2", - "contentHash": "I47dVIGiV6SfAyppphxqupertT/5oZkYLDCX6vC3HpOI4ZLjyoKAreUoem2ie6G0RbRuFrlqz/PcTQjfb2DOfQ==", - "dependencies": { - "Microsoft.Bcl.AsyncInterfaces": "5.0.0", - "System.Buffers": "4.5.1", - "System.Memory": "4.5.4", - "System.Numerics.Vectors": "4.5.0", - "System.Runtime.CompilerServices.Unsafe": "5.0.0", - "System.Text.Encodings.Web": "5.0.1", - "System.Threading.Tasks.Extensions": "4.5.4", - "System.ValueTuple": "4.5.0" - } - }, - "System.Threading.Tasks.Extensions": { - "type": "Transitive", - "resolved": "4.5.4", - "contentHash": "zteT+G8xuGu6mS+mzDzYXbzS7rd3K6Fjb9RiZlYlJPam2/hU7JCBZBVEcywNuR+oZ1ncTvc/cq0faRr3P01OVg==", - "dependencies": { - "System.Runtime.CompilerServices.Unsafe": "4.5.3" - } - }, - "System.ValueTuple": { - "type": "Transitive", - "resolved": "4.5.0", - "contentHash": "okurQJO6NRE/apDIP23ajJ0hpiNmJ+f0BwOlB/cSqTLQlw5upkf+5+96+iG2Jw40G1fCVCyPz/FhIABUjMR+RQ==" - }, - "speckle.autofac": { - "type": "Project", - "dependencies": { - "Microsoft.Extensions.Logging.Abstractions": "[7.0.0, )" - } - }, - "speckle.connectors.utils": { - "type": "Project", - "dependencies": { - "Serilog.Extensions.Logging": "[7.0.0, )", - "Speckle.Autofac": "[2.0.999-local, )", - "Speckle.Core": "[3.0.1-alpha.11, )" - } - }, - "speckle.converters.common": { - "type": "Project", - "dependencies": { - "Speckle.Autofac": "[2.0.999-local, )", - "Speckle.Objects": "[3.0.1-alpha.11, )" - } - }, - "speckle.converters.common.dependencyinjection": { - "type": "Project", - "dependencies": { - "Speckle.Autofac": "[2.0.999-local, )", - "Speckle.Converters.Common": "[2.0.999-local, )" - } - }, - "speckle.converters.revit2023": { - "type": "Project", - "dependencies": { - "Speckle.Converters.Common": "[2.0.999-local, )", - "Speckle.Revit2023.Interfaces": "[0.1.1-preview.0.28, )" - } - }, - "Microsoft.Extensions.Logging.Abstractions": { - "type": "CentralTransitive", - "requested": "[7.0.0, )", - "resolved": "7.0.0", - "contentHash": "kmn78+LPVMOWeITUjIlfxUPDsI0R6G0RkeAMBmQxAJ7vBJn4q2dTva7pWi65ceN5vPGjJ9q/Uae2WKgvfktJAw==", - "dependencies": { - "System.Buffers": "4.5.1", - "System.Memory": "4.5.5" - } - }, - "Serilog.Extensions.Logging": { - "type": "CentralTransitive", - "requested": "[7.0.0, )", - "resolved": "7.0.0", - "contentHash": "9faU0zNQqU7I6soVhLUMYaGNpgWv6cKlKb2S5AnS8gXxzW/em5Ladm/6FMrWTnX41cdbdGPOWNAo6adi4WaJ6A==", - "dependencies": { - "Microsoft.Extensions.Logging": "7.0.0", - "Serilog": "2.12.0" - } - }, - "Speckle.Core": { - "type": "CentralTransitive", - "requested": "[3.0.1-alpha.11, )", - "resolved": "3.0.1-alpha.11", - "contentHash": "Zt2dBJLlfziEACYCHThbhKypSjhoA01rTw9BzNI72c/BDyftXIz70Tetq/8ZMEqQnKqfmRyYADsAdWKxpdV0Hg==", - "dependencies": { - "GraphQL.Client": "6.0.0", - "Microsoft.CSharp": "4.7.0", - "Microsoft.Data.Sqlite": "7.0.5", - "Polly": "7.2.3", - "Polly.Contrib.WaitAndRetry": "1.1.1", - "Polly.Extensions.Http": "3.0.0", - "Sentry": "3.33.0", - "Sentry.Serilog": "3.33.0", - "Serilog": "2.12.0", - "Serilog.Enrichers.ClientInfo": "1.3.0", - "Serilog.Exceptions": "8.4.0", - "Serilog.Sinks.Console": "4.1.0", - "Serilog.Sinks.Seq": "5.2.2", - "SerilogTimings": "3.0.1", - "Speckle.Newtonsoft.Json": "13.0.2", - "System.DoubleNumerics": "3.1.3" - } - }, - "Speckle.Objects": { - "type": "CentralTransitive", - "requested": "[3.0.1-alpha.11, )", - "resolved": "3.0.1-alpha.11", - "contentHash": "YR7sei3OQBAi8R/kIu8bEmg5ELDIJK6l5fhOgdnqA9ZvD/fvmRb+09z8lIUTDsgdAdvYU/A/x9VxH9OGPbp9Kw==", - "dependencies": { - "Speckle.Core": "3.0.1-alpha.11" - } - } - } - } -} \ No newline at end of file diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023/RevitVersionConversionHelper.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023/RevitVersionConversionHelper.cs new file mode 100644 index 0000000000..515c2e057f --- /dev/null +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023/RevitVersionConversionHelper.cs @@ -0,0 +1,19 @@ +using Speckle.Converters.RevitShared; + +namespace Speckle.Converters.Revit2023; + +public class RevitVersionConversionHelper : IRevitVersionConversionHelper +{ + public bool IsCurveClosed(DB.NurbSpline nurbsSpline) + { + try + { + return nurbsSpline.IsClosed; + } + catch (Autodesk.Revit.Exceptions.ApplicationException) + { + // POC: is this actually a good assumption? + return true; + } + } +} diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023/Speckle.Converters.Revit2023.csproj b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023/Speckle.Converters.Revit2023.csproj index e3c04fcf68..985086abd5 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023/Speckle.Converters.Revit2023.csproj +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023/Speckle.Converters.Revit2023.csproj @@ -3,13 +3,12 @@ net48 x64 - false - + diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023/packages.lock.json b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023/packages.lock.json index 220a146664..0fbae10307 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023/packages.lock.json +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023/packages.lock.json @@ -24,11 +24,11 @@ "resolved": "0.9.5", "contentHash": "oU/L7pN1R7q8KkbrpQ3WJnHirPHqn+9DEA7asOcUiggV5dzVg1A/VYs7GOSusD24njxXh03tE3a2oTLOjt3cVg==" }, - "Speckle.Revit2023.Interfaces": { + "Speckle.Revit.API": { "type": "Direct", - "requested": "[0.1.1-preview.0.28, )", - "resolved": "0.1.1-preview.0.28", - "contentHash": "7szXg/vRvP3Wdrn2ZGriVOfsw+bddlpVorBkCIhSHHs5qVTTG8IAIrI1l9dO0/aullaTMF+Xgxm9x3w1aXPiuA==" + "requested": "[2023.0.0, )", + "resolved": "2023.0.0", + "contentHash": "tq40eD7psgTbV+epNouYyqfo6+hEi7FmXZqcxEOsAV7zfYyWhL6Rt3vmojkWGNuerGbH6oRI6KIIxrnlCNb8Hw==" }, "GraphQL.Client": { "type": "Transitive", diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Extensions/CategoryExtensions.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Extensions/CategoryExtensions.cs index c0acca23c8..9083375a2e 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Extensions/CategoryExtensions.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Extensions/CategoryExtensions.cs @@ -1,10 +1,10 @@ -using Speckle.Revit.Interfaces; +using Autodesk.Revit.DB; namespace Speckle.Converters.RevitShared.Extensions; public static class CategoryExtensions { - public static SOBR.RevitCategory GetSchemaBuilderCategoryFromBuiltIn(this RevitBuiltInCategory builtInCategory) + public static SOBR.RevitCategory GetSchemaBuilderCategoryFromBuiltIn(this DB.BuiltInCategory builtInCategory) { // Clean up built-in name "OST_Walls" to be just "WALLS" var cleanName = builtInCategory @@ -23,9 +23,9 @@ public static SOBR.RevitCategory GetSchemaBuilderCategoryFromBuiltIn(this RevitB return cat; } - public static RevitBuiltInCategory GetBuiltInCategory(this IRevitCategory category) + public static BuiltInCategory GetBuiltInCategory(this Category category) { - return (RevitBuiltInCategory)category.Id.IntegerValue; + return (BuiltInCategory)category.Id.IntegerValue; } public static string GetBuiltInFromSchemaBuilderCategory(this SOBR.RevitCategory c) diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Extensions/DefinitionExtensions.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Extensions/DefinitionExtensions.cs index 1b3a22beda..77aff9d11b 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Extensions/DefinitionExtensions.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Extensions/DefinitionExtensions.cs @@ -1,12 +1,16 @@ -using Speckle.Revit.Interfaces; +using Autodesk.Revit.DB; namespace Speckle.Converters.RevitShared.Extensions; public static class DefinitionExtensions { // POC: can we just interface these specialisations out and thereby avoid this kind of BS :D - public static string GetUnitTypeString(this IRevitDefinition definition) + public static string GetUnitTypeString(this Definition definition) { +#if REVIT2020 || REVIT2021 + return definition.UnitType.ToString(); +#else return definition.GetDataType().TypeId; +#endif } } diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Extensions/ElementExtensions.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Extensions/ElementExtensions.cs index e8553e34cb..468a98fd0f 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Extensions/ElementExtensions.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Extensions/ElementExtensions.cs @@ -1,31 +1,30 @@ -using Speckle.Revit.Interfaces; +using Autodesk.Revit.DB; namespace Speckle.Converters.RevitShared.Extensions; public static class ElementExtensions { // POC: should this be an injected service? - public static IList GetHostedElementIds(this IRevitElement host, IRevitFilterFactory filterFactory) + public static IList GetHostedElementIds(this Element host) { - IList ids; - var hostObject = host.ToHostObject(); - if (hostObject is not null) + IList ids; + if (host is HostObject hostObject) { ids = hostObject.FindInserts(true, false, false, false); } else { - var typeFilter = filterFactory.CreateElementIsElementTypeFilter(true); - var categoryFilter = filterFactory.CreateElementMulticategoryFilter( - new List() + var typeFilter = new ElementIsElementTypeFilter(true); + var categoryFilter = new ElementMulticategoryFilter( + new List() { - RevitBuiltInCategory.OST_CLines, - RevitBuiltInCategory.OST_SketchLines, - RevitBuiltInCategory.OST_WeakDims + BuiltInCategory.OST_CLines, + BuiltInCategory.OST_SketchLines, + BuiltInCategory.OST_WeakDims }, true ); - ids = host.GetDependentElements(filterFactory.CreateLogicalAndFilter(typeFilter, categoryFilter)); + ids = host.GetDependentElements(new LogicalAndFilter(typeFilter, categoryFilter)); } // dont include host elementId diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Extensions/ForgeTypeIdExtensions.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Extensions/ForgeTypeIdExtensions.cs index 1c9d03b5a1..790e92a07a 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Extensions/ForgeTypeIdExtensions.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Extensions/ForgeTypeIdExtensions.cs @@ -1,25 +1,25 @@ -using Speckle.Revit.Interfaces; +using Autodesk.Revit.DB; namespace Speckle.Converters.RevitShared.Extensions; public static class ForgeTypeIdExtensions { - public static string? GetSymbol(this IRevitForgeTypeId forgeTypeId, IRevitFormatOptionsUtils formatOptionsUtils) + public static string? GetSymbol(this ForgeTypeId forgeTypeId) { - if (!formatOptionsUtils.CanHaveSymbol(forgeTypeId)) + if (!FormatOptions.CanHaveSymbol(forgeTypeId)) { return null; } - var validSymbols = formatOptionsUtils.GetValidSymbols(forgeTypeId); + var validSymbols = FormatOptions.GetValidSymbols(forgeTypeId); var typeId = validSymbols.Where(x => !x.Empty()); - foreach (var symbolId in typeId) + foreach (DB.ForgeTypeId symbolId in typeId) { - return formatOptionsUtils.GetLabelForSymbol(symbolId); + return LabelUtils.GetLabelForSymbol(symbolId); } return null; } - public static string ToUniqueString(this IRevitForgeTypeId forgeTypeId) + public static string ToUniqueString(this ForgeTypeId forgeTypeId) { return forgeTypeId.TypeId; } diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Extensions/ParameterExtensions.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Extensions/ParameterExtensions.cs index 704eb40484..c8ac6f92e8 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Extensions/ParameterExtensions.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Extensions/ParameterExtensions.cs @@ -1,5 +1,4 @@ -using Speckle.Converters.Common; -using Speckle.Revit.Interfaces; +using Autodesk.Revit.DB; namespace Speckle.Converters.RevitShared.Extensions; @@ -11,7 +10,7 @@ public static class ParameterExtensions /// /// /// - public static string GetInternalName(this IRevitParameter rp) + public static string GetInternalName(this DB.Parameter rp) { if (rp.IsShared) { @@ -19,8 +18,8 @@ public static string GetInternalName(this IRevitParameter rp) } else { - var def = rp.Definition.ToInternal().NotNull(); - if (def.BuiltInParameter == RevitBuiltInParameter.INVALID) + var def = (InternalDefinition)rp.Definition; + if (def.BuiltInParameter == BuiltInParameter.INVALID) { return def.Name; } @@ -29,9 +28,9 @@ public static string GetInternalName(this IRevitParameter rp) } } - public static RevitBuiltInParameter? GetBuiltInParameter(this IRevitParameter rp) + public static BuiltInParameter? GetBuiltInParameter(this Parameter rp) { - var def = rp.Definition.ToInternal(); + var def = rp.Definition as InternalDefinition; return def?.BuiltInParameter; } } diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/GlobalUsings.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/GlobalUsings.cs index a4a6c2cf0d..5a7a8f20bd 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/GlobalUsings.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/GlobalUsings.cs @@ -1,3 +1,5 @@ -global using SOG = Objects.Geometry; +global using DB = Autodesk.Revit.DB; +global using DBA = Autodesk.Revit.DB.Architecture; +global using SOG = Objects.Geometry; global using SOBR = Objects.BuiltElements.Revit; global using SOBE = Objects.BuiltElements; diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/DisplayValueExtractor.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/DisplayValueExtractor.cs index d292b5ed2f..7980fa5b02 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/DisplayValueExtractor.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/DisplayValueExtractor.cs @@ -1,53 +1,38 @@ -using System.Diagnostics.CodeAnalysis; using Microsoft.Extensions.Logging; -using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; -using Speckle.InterfaceGenerator; -using Speckle.Revit.Interfaces; namespace Speckle.Converters.RevitShared.Helpers; // POC: needs breaking down https://spockle.atlassian.net/browse/CNX-9354 -[GenerateAutoInterface] -public sealed class DisplayValueExtractor : IDisplayValueExtractor +public sealed class DisplayValueExtractor { - private readonly ITypedConverter< - Dictionary>, - List - > _meshByMaterialConverter; - private readonly IRevitOptionsFactory _revitOptionsFactory; - private readonly IRevitSolidUtils _revitSolidUtils; + private readonly ITypedConverter>, List> _meshByMaterialConverter; private readonly ILogger _logger; public DisplayValueExtractor( - ITypedConverter>, List> meshByMaterialConverter, - IRevitOptionsFactory revitOptionsFactory, - IRevitSolidUtils revitSolidUtils, + ITypedConverter>, List> meshByMaterialConverter, ILogger logger ) { _meshByMaterialConverter = meshByMaterialConverter; - _revitOptionsFactory = revitOptionsFactory; - _revitSolidUtils = revitSolidUtils; _logger = logger; } public List GetDisplayValue( - IRevitElement element, - IRevitOptions? options = null, + DB.Element element, + DB.Options? options = null, // POC: should this be part of the context? - IRevitTransform? transform = null + DB.Transform? transform = null ) { var displayMeshes = new List(); // test if the element is a group first - var g = element.ToGroup(); - if (g is not null) + if (element is DB.Group g) { foreach (var id in g.GetMemberIds()) { - var groupMeshes = GetDisplayValue(element.Document.GetElement(id).NotNull(), options); + var groupMeshes = GetDisplayValue(element.Document.GetElement(id), options); displayMeshes.AddRange(groupMeshes); } return displayMeshes; @@ -60,18 +45,18 @@ ILogger logger return _meshByMaterialConverter.Convert(meshesByMaterial); } - private static Dictionary> GetMeshesByMaterial( - List meshes, - List solids + private static Dictionary> GetMeshesByMaterial( + List meshes, + List solids ) { - var meshesByMaterial = new Dictionary>(); + var meshesByMaterial = new Dictionary>(); foreach (var mesh in meshes) { var materialId = mesh.MaterialElementId; - if (!meshesByMaterial.TryGetValue(materialId, out List? value)) + if (!meshesByMaterial.TryGetValue(materialId, out List? value)) { - value = new List(); + value = new List(); meshesByMaterial[materialId] = value; } @@ -80,12 +65,12 @@ List solids foreach (var solid in solids) { - foreach (IRevitFace face in solid.Faces) + foreach (DB.Face face in solid.Faces) { var materialId = face.MaterialElementId; - if (!meshesByMaterial.TryGetValue(materialId, out List? value)) + if (!meshesByMaterial.TryGetValue(materialId, out List? value)) { - value = new List(); + value = new List(); meshesByMaterial[materialId] = value; } @@ -96,30 +81,29 @@ List solids return meshesByMaterial; } - [SuppressMessage("Design", "CA1031:Do not catch general exception types")] - private (List, List) GetSolidsAndMeshesFromElement( - IRevitElement element, - IRevitOptions? options, - IRevitTransform? transform = null + private (List, List) GetSolidsAndMeshesFromElement( + DB.Element element, + DB.Options? options, + DB.Transform? transform = null ) { //options = ViewSpecificOptions ?? options ?? new Options() { DetailLevel = DetailLevelSetting }; - options ??= _revitOptionsFactory.Create(RevitViewDetailLevel.Fine); + options ??= new DB.Options { DetailLevel = DB.ViewDetailLevel.Fine }; - IRevitGeometryElement? geom; + DB.GeometryElement geom; try { - geom = element.GetGeometry(options); + geom = element.get_Geometry(options); } // POC: should we be trying to continue? - catch (Exception) + catch (Autodesk.Revit.Exceptions.ArgumentException) { options.ComputeReferences = false; - geom = element.GetGeometry(options); + geom = element.get_Geometry(options); } - var solids = new List(); - var meshes = new List(); + var solids = new List(); + var meshes = new List(); if (geom != null) { @@ -147,11 +131,11 @@ List solids /// /// private void SortGeometry( - IRevitElement element, - List solids, - List meshes, - IRevitGeometryElement geom, - IRevitTransform? inverseTransform = null + DB.Element element, + List solids, + List meshes, + DB.GeometryElement geom, + DB.Transform? inverseTransform = null ) { var topLevelSolidsCount = 0; @@ -160,36 +144,32 @@ private void SortGeometry( var topLevelGeomInstanceCount = 0; bool hasSymbolGeometry = false; - foreach (IRevitGeometryObject geomObj in geom) + foreach (DB.GeometryObject geomObj in geom) { // POC: switch could possibly become factory and IIndex<,> pattern and move conversions to // separate IComeConversionInterfaces - var solid = geomObj.ToSolid(); - if (solid is not null) + switch (geomObj) { - // skip invalid solid - if ( - solid.Faces.Count == 0 - || Math.Abs(solid.SurfaceArea) == 0 - || IsSkippableGraphicStyle(solid.GraphicsStyleId, element.Document) - ) - { - continue; - } + case DB.Solid solid: + // skip invalid solid + if ( + solid.Faces.Size == 0 + || Math.Abs(solid.SurfaceArea) == 0 + || IsSkippableGraphicStyle(solid.GraphicsStyleId, element.Document) + ) + { + continue; + } - if (inverseTransform != null) - { - topLevelSolidsCount++; - solid = _revitSolidUtils.CreateTransformed(solid, inverseTransform); - } + if (inverseTransform != null) + { + topLevelSolidsCount++; + solid = DB.SolidUtils.CreateTransformed(solid, inverseTransform); + } - solids.Add(solid); - } - else - { - var mesh = geomObj.ToMesh(); - if (mesh is not null) - { + solids.Add(solid); + break; + case DB.Mesh mesh: if (IsSkippableGraphicStyle(mesh.GraphicsStyleId, element.Document)) { continue; @@ -198,46 +178,35 @@ private void SortGeometry( if (inverseTransform != null) { topLevelMeshesCount++; - mesh = mesh.GetTransformed(inverseTransform); + mesh = mesh.get_Transformed(inverseTransform); } meshes.Add(mesh); - } - else - { - var instance = geomObj.ToGeometryInstance(); - if (instance is not null) + break; + case DB.GeometryInstance instance: + // element transforms should not be carried down into nested geometryInstances. + // Nested geomInstances should have their geom retreived with GetInstanceGeom, not GetSymbolGeom + if (inverseTransform != null) { - // element transforms should not be carried down into nested geometryInstances. - // Nested geomInstances should have their geom retreived with GetInstanceGeom, not GetSymbolGeom - if (inverseTransform != null) - { - topLevelGeomInstanceCount++; - SortGeometry(element, solids, meshes, instance.GetSymbolGeometry()); - if (meshes.Count > 0 || solids.Count > 0) - { - hasSymbolGeometry = true; - } - } - else + topLevelGeomInstanceCount++; + SortGeometry(element, solids, meshes, instance.GetSymbolGeometry()); + if (meshes.Count > 0 || solids.Count > 0) { - SortGeometry(element, solids, meshes, instance.GetInstanceGeometry()); + hasSymbolGeometry = true; } } else { - var geometryElement = geomObj.ToGeometryElement(); - if (geometryElement is not null) - { - if (inverseTransform != null) - { - topLevelGeomElementCount++; - } - - SortGeometry(element, solids, meshes, geometryElement); - } + SortGeometry(element, solids, meshes, instance.GetInstanceGeometry()); } - } + break; + case DB.GeometryElement geometryElement: + if (inverseTransform != null) + { + topLevelGeomElementCount++; + } + SortGeometry(element, solids, meshes, geometryElement); + break; } } @@ -255,7 +224,7 @@ private void SortGeometry( // POC: should be hoovered up with the new reporting, logging, exception philosophy private void LogInstanceMeshRetrievalWarnings( - IRevitElement element, + DB.Element element, int topLevelSolidsCount, int topLevelMeshesCount, int topLevelGeomElementCount, @@ -288,24 +257,27 @@ bool hasSymbolGeom /// /// We're caching a dictionary of graphic styles and their ids as it can be a costly operation doing Document.GetElement(solid.GraphicsStyleId) for every solid /// - private readonly Dictionary _graphicStyleCache = new(); + private readonly Dictionary _graphicStyleCache = new(); /// /// Exclude light source cones and potentially other geometries by their graphic style /// - private bool IsSkippableGraphicStyle(IRevitElementId id, IRevitDocument doc) + /// + /// + /// + private bool IsSkippableGraphicStyle(DB.ElementId id, DB.Document doc) { - var graphicStyle = doc.GetElement(id)?.ToGraphicsStyle(); - if (graphicStyle is null) - { - return false; - } - if (!_graphicStyleCache.ContainsKey(id.IntegerValue)) + var key = id.ToString(); + if (_graphicStyleCache.TryGetValue(key, out var graphicStyle)) { - _graphicStyleCache.Add(id.IntegerValue, graphicStyle); + graphicStyle = (DB.GraphicsStyle)doc.GetElement(id); + _graphicStyleCache.Add(key, graphicStyle); } - if (graphicStyle.GraphicsStyleCategory.Id.IntegerValue == (int)RevitBuiltInCategory.OST_LightingFixtureSource) + if ( + graphicStyle != null + && graphicStyle.GraphicsStyleCategory.Id.IntegerValue == (int)DB.BuiltInCategory.OST_LightingFixtureSource + ) { return true; } diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/IRevitConversionContextStack.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/IRevitConversionContextStack.cs new file mode 100644 index 0000000000..1cf5d4b80c --- /dev/null +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/IRevitConversionContextStack.cs @@ -0,0 +1,13 @@ +using Autodesk.Revit.DB; +using Speckle.Converters.Common; + +namespace Speckle.Converters.RevitShared.Helpers; + +[System.Diagnostics.CodeAnalysis.SuppressMessage( + "Naming", + "CA1711:Identifiers should not have incorrect suffix", + Justification = "See base class justification" +)] +// POC: so this should *probably* be Document and NOT UI.UIDocument, the former is Conversion centric +// and the latter is more for connector +public interface IRevitConversionContextStack : IConversionContextStack { } diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/ISlopeArrowExtractor.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/ISlopeArrowExtractor.cs new file mode 100644 index 0000000000..750f4d1073 --- /dev/null +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/ISlopeArrowExtractor.cs @@ -0,0 +1,10 @@ +namespace Speckle.Converters.RevitShared.Helpers; + +public interface ISlopeArrowExtractor +{ + DB.ModelLine? GetSlopeArrow(DB.Element element); + SOG.Point GetSlopeArrowHead(DB.ModelLine slopeArrow); + SOG.Point GetSlopeArrowTail(DB.ModelLine slopeArrow); + double GetSlopeArrowTailOffset(DB.ModelLine slopeArrow); + double GetSlopeArrowHeadOffset(DB.ModelLine slopeArrow, double tailOffset, out double slope); +} diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/ParameterObjectAssigner.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/ParameterObjectAssigner.cs index b6489d3646..86735165b1 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/ParameterObjectAssigner.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/ParameterObjectAssigner.cs @@ -1,49 +1,44 @@ -using Microsoft.Extensions.Logging; +using Autodesk.Revit.DB; +using Microsoft.Extensions.Logging; using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; using Speckle.Core.Models; -using Speckle.InterfaceGenerator; -using Speckle.Revit.Interfaces; namespace Speckle.Converters.RevitShared.Helpers; // POC: rationalise whether this and ParameterObjectBuilder are sufficiently different?? // did it go away? -[GenerateAutoInterface] -public sealed class ParameterObjectAssigner : IParameterObjectAssigner +public sealed class ParameterObjectAssigner { - private readonly ITypedConverter _paramConverter; - private readonly IParameterValueExtractor _parameterValueExtractor; - private readonly IRevitElementIdUtils _revitElementIdUtils; + private readonly ITypedConverter _paramConverter; + private readonly ParameterValueExtractor _parameterValueExtractor; private readonly ILogger _logger; public ParameterObjectAssigner( - ITypedConverter paramConverter, - IParameterValueExtractor parameterValueExtractor, - IRevitElementIdUtils revitElementIdUtils, + ITypedConverter paramConverter, + ParameterValueExtractor parameterValueExtractor, ILogger logger ) { _paramConverter = paramConverter; _parameterValueExtractor = parameterValueExtractor; - _revitElementIdUtils = revitElementIdUtils; _logger = logger; } - public void AssignParametersToBase(IRevitElement target, Base @base) + public void AssignParametersToBase(Element target, Base @base) { - var instanceParameters = _parameterValueExtractor.GetAllRemainingParams(target); - IRevitElementId elementId = target.GetTypeId(); + Dictionary instanceParameters = _parameterValueExtractor.GetAllRemainingParams(target); + ElementId elementId = target.GetTypeId(); Base paramBase = new(); AssignSpeckleParamToBaseObject(instanceParameters, paramBase); // POC: Some elements can have an invalid element type ID, I don't think we want to continue here. - if (elementId.IntegerValue != _revitElementIdUtils.InvalidElementId.IntegerValue && target is not SOBE.Level) //ignore type props of levels..! + if (elementId != ElementId.InvalidElementId && target is not Level) //ignore type props of levels..! { - var elementType = target.Document.GetElement(elementId).NotNull(); + var elementType = target.Document.GetElement(elementId); // I don't think we should be adding the type parameters to the object like this - var typeParameters = _parameterValueExtractor.GetAllRemainingParams(elementType); + Dictionary typeParameters = _parameterValueExtractor.GetAllRemainingParams(elementType); AssignSpeckleParamToBaseObject(typeParameters, paramBase, true); } @@ -54,7 +49,7 @@ public void AssignParametersToBase(IRevitElement target, Base @base) } private void AssignSpeckleParamToBaseObject( - IEnumerable> parameters, + IEnumerable> parameters, Base paramBase, bool isTypeParameter = false ) @@ -64,7 +59,7 @@ private void AssignSpeckleParamToBaseObject( { try { - var speckleParam = _paramConverter.Convert(kv.Value); + SOBR.Parameter speckleParam = _paramConverter.Convert(kv.Value); speckleParam.isTypeParameter = isTypeParameter; paramBase[kv.Key] = speckleParam; } diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/ParameterObjectBuilder.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/ParameterObjectBuilder.cs new file mode 100644 index 0000000000..71cf930224 --- /dev/null +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/ParameterObjectBuilder.cs @@ -0,0 +1,50 @@ +using System.Collections.Generic; +using System.Linq; +using Autodesk.Revit.DB; +using Speckle.Converters.Common.Objects; +using Speckle.Core.Logging; +using Speckle.Core.Models; + +namespace Speckle.Converters.RevitShared.Helpers; + +public sealed class ParameterObjectAssigner +{ + private readonly IRawConversion _paramConverter; + private readonly ParameterValueExtractor _parameterValueExtractor; + + public ParameterObjectAssigner( + IRawConversion paramConverter, + ParameterValueExtractor parameterValueExtractor + ) + { + _paramConverter = paramConverter; + _parameterValueExtractor = parameterValueExtractor; + } + + public void AssignParametersToBase(Element target, Base @base) + { + Dictionary allParams = _parameterValueExtractor.GetAllRemainingParams(target); + Base paramBase = new(); + //sort by key + foreach (var kv in allParams.OrderBy(x => x.Key)) + { + try + { + paramBase[kv.Key] = _paramConverter.RawConvert(kv.Value); + } + catch (InvalidPropNameException) + { + //ignore + } + catch (SpeckleException ex) + { + SpeckleLog.Logger.Warning(ex, "Error thrown when trying to set property named {propName}", kv.Key); + } + } + + if (paramBase.GetMembers(DynamicBaseMemberType.Dynamic).Count > 0) + { + @base["parameters"] = paramBase; + } + } +} diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/ParameterValueExtractor.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/ParameterValueExtractor.cs index 2f5a71a853..cdc8e69243 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/ParameterValueExtractor.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/ParameterValueExtractor.cs @@ -1,8 +1,7 @@ -using System.Diagnostics.CodeAnalysis; +using Autodesk.Revit.DB; using Speckle.Converters.Common; using Speckle.Converters.RevitShared.Extensions; using Speckle.Converters.RevitShared.Services; -using Speckle.Revit.Interfaces; namespace Speckle.Converters.RevitShared.Helpers; @@ -10,18 +9,17 @@ namespace Speckle.Converters.RevitShared.Helpers; // really if we have to edit a switch statement... // maybe also better as an extension method, but maybe is fine? // POC: there are a lot of public methods here. Maybe consider consolodating - -public class ParameterValueExtractor : IParameterValueExtractor +public class ParameterValueExtractor { - private readonly IScalingServiceToSpeckle _scalingService; - private readonly Dictionary> _uniqueIdToUsedParameterSetMap = new(); + private readonly ScalingServiceToSpeckle _scalingService; + private readonly Dictionary> _uniqueIdToUsedParameterSetMap = new(); - public ParameterValueExtractor(IScalingServiceToSpeckle scalingService) + public ParameterValueExtractor(ScalingServiceToSpeckle scalingService) { _scalingService = scalingService; } - public object? GetValue(IRevitParameter parameter) + public object? GetValue(Parameter parameter) { if (!parameter.HasValue) { @@ -30,36 +28,32 @@ public ParameterValueExtractor(IScalingServiceToSpeckle scalingService) return parameter.StorageType switch { - RevitStorageType.Double => GetValueAsDouble(parameter), - RevitStorageType.Integer => GetValueAsInt(parameter), - RevitStorageType.String => GetValueAsString(parameter), - RevitStorageType.ElementId => GetValueAsElementId(parameter)?.ToString(), - RevitStorageType.None + StorageType.Double => GetValueAsDouble(parameter), + StorageType.Integer => GetValueAsInt(parameter), + StorageType.String => GetValueAsString(parameter), + StorageType.ElementId => GetValueAsElementId(parameter)?.ToString(), + StorageType.None or _ => throw new SpeckleConversionException($"Unsupported parameter storage type {parameter.StorageType}") }; } - public double GetValueAsDouble(IRevitElement element, RevitBuiltInParameter builtInParameter) + public double GetValueAsDouble(Element element, BuiltInParameter builtInParameter) { if (!TryGetValueAsDouble(element, builtInParameter, out double? value)) { throw new SpeckleConversionException($"Failed to get {builtInParameter} as double."); } - return value.Value; // If TryGet returns true, we succeeded in obtaining the value, and it will not be null. + return value!.Value; // If TryGet returns true, we succeeded in obtaining the value, and it will not be null. } - public bool TryGetValueAsDouble( - IRevitElement element, - RevitBuiltInParameter builtInParameter, - [NotNullWhen(true)] out double? value - ) + public bool TryGetValueAsDouble(Element element, BuiltInParameter builtInParameter, out double? value) { var number = GetValueGeneric( element, builtInParameter, - RevitStorageType.Double, + StorageType.Double, (parameter) => _scalingService.Scale(parameter.AsDouble(), parameter.GetUnitTypeId()) ); if (number.HasValue) @@ -72,81 +66,69 @@ public bool TryGetValueAsDouble( return false; } - private double? GetValueAsDouble(IRevitParameter parameter) + private double? GetValueAsDouble(Parameter parameter) { return GetValueGeneric( parameter, - RevitStorageType.Double, + StorageType.Double, (parameter) => _scalingService.Scale(parameter.AsDouble(), parameter.GetUnitTypeId()) ); } - public int GetValueAsInt(IRevitElement element, RevitBuiltInParameter builtInParameter) + public int GetValueAsInt(Element element, BuiltInParameter builtInParameter) { - return GetValueGeneric( - element, - builtInParameter, - RevitStorageType.Integer, - (parameter) => parameter.AsInteger() - ) + return GetValueGeneric(element, builtInParameter, StorageType.Integer, (parameter) => parameter.AsInteger()) ?? throw new SpeckleConversionException( $"Expected int but got null for property {builtInParameter} on element of type {element.GetType()}" ); } - private int? GetValueAsInt(IRevitParameter parameter) + private int? GetValueAsInt(Parameter parameter) { - return GetValueGeneric(parameter, RevitStorageType.Integer, (parameter) => parameter.AsInteger()); + return GetValueGeneric(parameter, StorageType.Integer, (parameter) => parameter.AsInteger()); } - public bool? GetValueAsBool(IRevitElement element, RevitBuiltInParameter builtInParameter) + public bool? GetValueAsBool(Element element, BuiltInParameter builtInParameter) { var intVal = GetValueGeneric( element, builtInParameter, - RevitStorageType.Integer, + StorageType.Integer, (parameter) => parameter.AsInteger() ); return intVal.HasValue ? Convert.ToBoolean(intVal.Value) : null; } - public string? GetValueAsString(IRevitElement element, RevitBuiltInParameter builtInParameter) + public string? GetValueAsString(Element element, BuiltInParameter builtInParameter) { - return GetValueGeneric(element, builtInParameter, RevitStorageType.String, (parameter) => parameter.AsString()); + return GetValueGeneric(element, builtInParameter, StorageType.String, (parameter) => parameter.AsString()); } - private string? GetValueAsString(IRevitParameter parameter) + private string? GetValueAsString(Parameter parameter) { - return GetValueGeneric(parameter, RevitStorageType.String, (parameter) => parameter.AsString()); + return GetValueGeneric(parameter, StorageType.String, (parameter) => parameter.AsString()); } - public IRevitElementId GetValueAsElementId(IRevitElement element, RevitBuiltInParameter builtInParameter) + public ElementId GetValueAsElementId(Element element, BuiltInParameter builtInParameter) { if (TryGetValueAsElementId(element, builtInParameter, out var elementId)) { - return elementId; + return elementId!; } throw new SpeckleConversionException( $"Failed to get {builtInParameter} on element of type {element.GetType()} as ElementId" ); } - public bool TryGetValueAsElementId( - IRevitElement element, - RevitBuiltInParameter builtInParameter, - [NotNullWhen(true)] out IRevitElementId? elementId - ) + public bool TryGetValueAsElementId(Element element, BuiltInParameter builtInParameter, out ElementId? elementId) { - var generic = GetValueGeneric( - element, - builtInParameter, - RevitStorageType.ElementId, - (parameter) => parameter.AsElementId() - ); - if (generic is not null) + if ( + GetValueGeneric(element, builtInParameter, StorageType.ElementId, (parameter) => parameter.AsElementId()) + is ElementId elementIdNotNull + ) { - elementId = generic; + elementId = elementIdNotNull; return true; } @@ -154,66 +136,62 @@ public bool TryGetValueAsElementId( return false; } - public IRevitElementId? GetValueAsElementId(IRevitParameter parameter) + public ElementId? GetValueAsElementId(Parameter parameter) { - return GetValueGeneric(parameter, RevitStorageType.ElementId, (p) => p.AsElementId()); + return GetValueGeneric(parameter, StorageType.ElementId, (parameter) => parameter.AsElementId()); } - public IRevitLevel GetValueAsRevitLevel(IRevitElement element, RevitBuiltInParameter builtInParameter) + public bool TryGetValueAsDocumentObject(Element element, BuiltInParameter builtInParameter, out T? value) { if (!TryGetValueAsElementId(element, builtInParameter, out var elementId)) { - throw new SpeckleConversionException(); + value = default; + return false; } - var paramElement = element.Document.GetElement(elementId); - return (paramElement?.ToLevel()).NotNull(); + Element paramElement = element.Document.GetElement(elementId); + if (paramElement is not T typedElement) + { + value = default; + return false; + } + + value = typedElement; + return true; } - public bool TryGetValueAsRevitLevel( - IRevitElement element, - RevitBuiltInParameter builtInParameter, - [NotNullWhen(true)] out IRevitLevel? revitLevel - ) + public T GetValueAsDocumentObject(Element element, BuiltInParameter builtInParameter) + where T : class { - if (!TryGetValueAsElementId(element, builtInParameter, out var elementId)) + if (!TryGetValueAsDocumentObject(element, builtInParameter, out var value)) { - revitLevel = null; - return false; + throw new SpeckleConversionException($"Failed to get {builtInParameter} as an element of type {typeof(T)}"); } - var paramElement = element.Document.GetElement(elementId); - revitLevel = paramElement?.ToLevel(); - return revitLevel is not null; + return value!; // If TryGet returns true, we succeeded in obtaining the value, and it will not be null. } private TResult? GetValueGeneric( - IRevitElement element, - RevitBuiltInParameter builtInParameter, - RevitStorageType expectedStorageType, - Func getParamValue + Element element, + BuiltInParameter builtInParameter, + StorageType expectedStorageType, + Func getParamValue ) { - if ( - !_uniqueIdToUsedParameterSetMap.TryGetValue(element.UniqueId, out HashSet usedParameters) - ) + if (!_uniqueIdToUsedParameterSetMap.TryGetValue(element.UniqueId, out HashSet usedParameters)) { usedParameters = new(); _uniqueIdToUsedParameterSetMap[element.UniqueId] = usedParameters; } usedParameters.Add(builtInParameter); - var parameter = element.GetParameter(builtInParameter); - if (parameter is null) - { - return default; - } + var parameter = element.get_Parameter(builtInParameter); return GetValueGeneric(parameter, expectedStorageType, getParamValue); } private TResult? GetValueGeneric( - IRevitParameter parameter, - RevitStorageType expectedStorageType, - Func getParamValue + Parameter parameter, + StorageType expectedStorageType, + Func getParamValue ) { if (parameter == null || !parameter.HasValue) @@ -231,20 +209,20 @@ Func getParamValue return getParamValue(parameter); } - public Dictionary GetAllRemainingParams(IRevitElement revitElement) + public Dictionary GetAllRemainingParams(DB.Element revitElement) { - var allParams = new Dictionary(); + var allParams = new Dictionary(); AddElementParamsToDict(revitElement, allParams); return allParams; } - private void AddElementParamsToDict(IRevitElement element, Dictionary paramDict) + private void AddElementParamsToDict(DB.Element element, Dictionary paramDict) { - _uniqueIdToUsedParameterSetMap.TryGetValue(element.UniqueId, out HashSet? usedParameters); + _uniqueIdToUsedParameterSetMap.TryGetValue(element.UniqueId, out HashSet? usedParameters); using var parameters = element.Parameters; - foreach (IRevitParameter param in parameters) + foreach (DB.Parameter param in parameters) { var internalName = param.GetInternalName(); if (paramDict.ContainsKey(internalName)) @@ -252,8 +230,7 @@ private void AddElementParamsToDict(IRevitElement element, Dictionary +/// Contains predefined categories of revit objects as well as the types that make up the elements +/// in that category +/// +/// +// POC: is quite a messy looking thing, need some review +// might be legit or maybe a bette/cleaner pattern rather than the dictionary of pain, but maybe not +// some whitespace between each at the least! +public static class RevitCategories +{ + public static Dictionary All { get; } + + static RevitCategories() + { + All = new(StringComparer.OrdinalIgnoreCase) + { + { nameof(CableTray), CableTray }, + { nameof(Ceiling), Ceiling }, + { nameof(Column), Column }, + { nameof(Conduit), Conduit }, + { nameof(Door), Door }, + { nameof(Duct), Duct }, + { nameof(FamilyInstance), FamilyInstance }, + { nameof(Floor), Floor }, + { nameof(Furniture), Furniture }, + { nameof(Pipe), Pipe }, + { nameof(PlumbingFixture), PlumbingFixture }, + { nameof(Roof), Roof }, + { nameof(Railing), Railing }, + { nameof(StructuralFraming), StructuralFraming }, + { nameof(Wall), Wall }, + { nameof(Window), Window }, + { nameof(Wire), Wire }, + { nameof(Undefined), Undefined }, + }; + } + + public static RevitCategoryInfo CableTray { get; } = + new( + nameof(CableTray), + typeof(DB.Electrical.CableTray), + typeof(DB.Electrical.CableTrayType), + new List() + ); + public static RevitCategoryInfo Ceiling { get; } = + new(nameof(Ceiling), typeof(DB.Ceiling), typeof(CeilingType), new List()); + public static RevitCategoryInfo Column { get; } = + new( + nameof(Column), + typeof(FamilyInstance), + typeof(FamilySymbol), + new List { BuiltInCategory.OST_Columns, BuiltInCategory.OST_StructuralColumns } + ); + public static RevitCategoryInfo Conduit { get; } = + new(nameof(Conduit), typeof(DB.Electrical.Conduit), typeof(DB.Electrical.ConduitType), new List()); + public static RevitCategoryInfo Door { get; } = + new( + nameof(Door), + typeof(DB.FamilyInstance), + typeof(DB.FamilySymbol), + new List { BuiltInCategory.OST_Doors } + ); + public static RevitCategoryInfo Duct { get; } = + new( + nameof(Duct), + typeof(DB.Mechanical.Duct), + typeof(DB.MEPCurveType), + new List { BuiltInCategory.OST_DuctCurves, BuiltInCategory.OST_FlexDuctCurves } + ); + public static RevitCategoryInfo FamilyInstance { get; } = + new(nameof(FamilyInstance), typeof(DB.FamilyInstance), typeof(DB.FamilySymbol), new List()); + public static RevitCategoryInfo Floor { get; } = + new( + nameof(Floor), + typeof(DB.Floor), + typeof(DB.FloorType), + new List { BuiltInCategory.OST_Floors } + ); + public static RevitCategoryInfo Furniture { get; } = + new( + nameof(Furniture), + typeof(DB.FamilyInstance), + typeof(DB.FamilySymbol), + new List { BuiltInCategory.OST_Furniture } + ); + + //public static RevitCategoryInfo Material { get; } = new( + // nameof(Material), + // typeof(DB.Material), + // null, + // new List + // { + // BuiltInCategory.OST_Materials, + // BuiltInCategory.OST_PipeMaterials, + // BuiltInCategory.OST_WireMaterials + // }); + public static RevitCategoryInfo Pipe { get; } = + new( + nameof(Pipe), + typeof(DB.Plumbing.Pipe), + typeof(DB.MEPCurveType), + new List { BuiltInCategory.OST_PipeCurves, BuiltInCategory.OST_FlexPipeCurves } + ); + public static RevitCategoryInfo PlumbingFixture { get; } = + new( + nameof(PlumbingFixture), + typeof(DB.FamilyInstance), + typeof(DB.FamilySymbol), + new List { BuiltInCategory.OST_PlumbingFixtures } + ); + public static RevitCategoryInfo Roof { get; } = + new( + nameof(Roof), + typeof(DB.RoofBase), + typeof(DB.RoofType), + new List { BuiltInCategory.OST_Roofs, } + ); + public static RevitCategoryInfo Railing { get; } = + new( + nameof(Railing), + typeof(DB.Architecture.Railing), + typeof(DB.Architecture.RailingType), + new List() + ); + public static RevitCategoryInfo StructuralFraming { get; } = + new( + nameof(StructuralFraming), + typeof(DB.FamilyInstance), + typeof(DB.FamilySymbol), + new List { BuiltInCategory.OST_StructuralFraming }, + new List { "beam", "brace", "framing" } + ); + public static RevitCategoryInfo Wall { get; } = + new(nameof(Wall), typeof(DB.Wall), typeof(DB.WallType), new List { BuiltInCategory.OST_Walls }); + public static RevitCategoryInfo Window { get; } = + new( + nameof(Window), + typeof(DB.FamilyInstance), + typeof(DB.FamilySymbol), + new List { BuiltInCategory.OST_Windows } + ); + public static RevitCategoryInfo Wire { get; } = + new(nameof(Wire), typeof(DB.Electrical.Wire), typeof(DB.Electrical.WireType), new List()); + public static RevitCategoryInfo Undefined { get; } = + new(nameof(Undefined), typeof(RevitCategoryInfo), typeof(RevitCategoryInfo), new List()); +} diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/RevitCategoryInfo.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/RevitCategoryInfo.cs new file mode 100644 index 0000000000..f883f7c9e8 --- /dev/null +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/RevitCategoryInfo.cs @@ -0,0 +1,65 @@ +using System.Diagnostics.CodeAnalysis; +using Autodesk.Revit.DB; + +namespace Speckle.Converters.RevitShared.Helpers; + +// review, maybe it doesn't need injecting, or maybe we inject a factory? +public class RevitCategoryInfo +{ + public RevitCategoryInfo( + string name, + Type instanceType, + Type familyType, + List categories, + List? categoryAliases = null + ) + { + CategoryName = name; + ElementInstanceType = instanceType; + ElementTypeType = familyType; + BuiltInCategories = categories; + CategoryAliases = categoryAliases ?? new List(); + } + + public string CategoryName { get; } + public Type ElementInstanceType { get; } + public Type ElementTypeType { get; } + public ICollection BuiltInCategories { get; } + public List CategoryAliases { get; } + + public bool ContainsRevitCategory(Category category) + { + return BuiltInCategories.Select(x => (int)x).Contains(category.Id.IntegerValue); + } + + public List GetElementTypes(Document document) + { + return GetElementTypes(document); + } + + [SuppressMessage("Reliability", "CA2000:Dispose objects before losing scope")] + public List GetElementTypes(Document document) + where T : ElementType + { + // POC: why is this disabled? surely a using statement is golden here? + var collector = new FilteredElementCollector(document); + + if (BuiltInCategories.Count > 0) + { + using var filter = new ElementMulticategoryFilter(BuiltInCategories); + collector = collector.WherePasses(filter); + } + if (ElementTypeType != null) + { + collector = collector.OfClass(ElementTypeType); + } + var elementTypes = collector.WhereElementIsElementType().Cast().ToList(); + collector.Dispose(); + return elementTypes; + } + + public string GetCategorySpecificTypeName(string typeName) + { + return CategoryName + "_" + typeName; + } +} diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Helpers/RevitContext.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/RevitContext.cs similarity index 80% rename from DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Helpers/RevitContext.cs rename to DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/RevitContext.cs index 3148acc5dc..59c3892a75 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Helpers/RevitContext.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/RevitContext.cs @@ -1,6 +1,6 @@ -using Autodesk.Revit.UI; +using Autodesk.Revit.UI; -namespace Speckle.Connectors.RevitShared.Helpers; +namespace Speckle.Converters.RevitShared.Helpers; public class RevitContext { diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/RevitConversionContextStack.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/RevitConversionContextStack.cs new file mode 100644 index 0000000000..ce43a88901 --- /dev/null +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/RevitConversionContextStack.cs @@ -0,0 +1,28 @@ +using Autodesk.Revit.DB; +using Speckle.Converters.Common; + +namespace Speckle.Converters.RevitShared.Helpers; + +[System.Diagnostics.CodeAnalysis.SuppressMessage( + "Naming", + "CA1711:Identifiers should not have incorrect suffix", + Justification = "See base class justification" +)] +// POC: so this should *probably* be Document and NOT UI.UIDocument, the former is Conversion centric +// and the latter is more for connector +public class RevitConversionContextStack : ConversionContextStack, IRevitConversionContextStack +{ + public const double TOLERANCE = 0.0164042; // 5mm in ft + + public RevitConversionContextStack(RevitContext context, IHostToSpeckleUnitConverter unitConverter) + : base( + // POC: we probably should not get here without a valid document + // so should this perpetuate or do we assume this is valid? + // relting on the context.UIApplication?.ActiveUIDocument is not right + // this should be some IActiveDocument I suspect? + context.UIApplication?.ActiveUIDocument?.Document + ?? throw new SpeckleConversionException("Active UI document could not be determined"), + context.UIApplication.ActiveUIDocument.Document.GetUnits().GetFormatOptions(SpecTypeId.Length).GetUnitTypeId(), + unitConverter + ) { } +} diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/SendSelection.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/SendSelection.cs new file mode 100644 index 0000000000..c6b4590a6d --- /dev/null +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/SendSelection.cs @@ -0,0 +1,17 @@ +namespace Speckle.Converters.RevitShared.Helpers; + +// POC: why do we need this send selection? +// why does conversion need to know about selection in this way? +public class SendSelection +{ + private readonly HashSet _selectedItemIds; + + public SendSelection(IEnumerable selectedItemIds) + { + _selectedItemIds = new HashSet(selectedItemIds); + } + + public bool Contains(string elementId) => _selectedItemIds.Contains(elementId); + + public IReadOnlyCollection SelectedItems => _selectedItemIds.ToList().AsReadOnly(); +} diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/SlopeArrowExtractor.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/SlopeArrowExtractor.cs index 1ae02630be..9db6d14583 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/SlopeArrowExtractor.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/SlopeArrowExtractor.cs @@ -1,51 +1,43 @@ -using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; -using Speckle.InterfaceGenerator; -using Speckle.Revit.Interfaces; namespace Speckle.Converters.RevitShared.Helpers; -[GenerateAutoInterface] public class SlopeArrowExtractor : ISlopeArrowExtractor { - private readonly ITypedConverter _pointConverter; - private readonly IParameterValueExtractor _parameterValueExtractor; - private readonly IRevitFilterFactory _revitFilterFactory; + private readonly ITypedConverter _pointConverter; + private readonly ParameterValueExtractor _parameterValueExtractor; public SlopeArrowExtractor( - ITypedConverter pointConverter, - IParameterValueExtractor parameterValueExtractor, - IRevitFilterFactory revitFilterFactory + ITypedConverter pointConverter, + ParameterValueExtractor parameterValueExtractor ) { _pointConverter = pointConverter; _parameterValueExtractor = parameterValueExtractor; - _revitFilterFactory = revitFilterFactory; } - public IRevitModelLine? GetSlopeArrow(IRevitElement element) + public DB.ModelLine? GetSlopeArrow(DB.Element element) { - IList? elementIds = null; - if (element is IRevitFloor floor) + IList? elementIds = null; + if (element is DB.Floor floor) { - elementIds = (floor.Document.GetElement(floor.SketchId).NotNull().ToSketch().NotNull()).GetAllElements(); + elementIds = ((DB.Sketch)floor.Document.GetElement(floor.SketchId)).GetAllElements(); } if (elementIds == null) { - using var modelLineFilter = _revitFilterFactory.CreateElementCategoryFilter(RevitBuiltInCategory.OST_SketchLines); + using var modelLineFilter = new DB.ElementCategoryFilter(DB.BuiltInCategory.OST_SketchLines); elementIds = element.GetDependentElements(modelLineFilter); } foreach (var elementId in elementIds) { - var line = element.Document.GetElement(elementId)?.ToModelLine(); - if (line is null) + if (element.Document.GetElement(elementId) is not DB.ModelLine line) { continue; } - var offsetAtTailParameter = line.GetParameter(RevitBuiltInParameter.SLOPE_START_HEIGHT); + var offsetAtTailParameter = line.get_Parameter(DB.BuiltInParameter.SLOPE_START_HEIGHT); if (offsetAtTailParameter != null) { return line; @@ -54,29 +46,26 @@ IRevitFilterFactory revitFilterFactory return null; } - public SOG.Point GetSlopeArrowHead(IRevitModelLine slopeArrow) + public SOG.Point GetSlopeArrowHead(DB.ModelLine slopeArrow) { - return _pointConverter.Convert((slopeArrow.GetLocationAsLocationCurve().NotNull()).Curve.GetEndPoint(1)); + return _pointConverter.Convert(((DB.LocationCurve)slopeArrow.Location).Curve.GetEndPoint(1)); } - public SOG.Point GetSlopeArrowTail(IRevitModelLine slopeArrow) + public SOG.Point GetSlopeArrowTail(DB.ModelLine slopeArrow) { - return _pointConverter.Convert((slopeArrow.GetLocationAsLocationCurve().NotNull()).Curve.GetEndPoint(0)); + return _pointConverter.Convert(((DB.LocationCurve)slopeArrow.Location).Curve.GetEndPoint(0)); } - public double GetSlopeArrowTailOffset(IRevitModelLine slopeArrow) + public double GetSlopeArrowTailOffset(DB.ModelLine slopeArrow) { - return _parameterValueExtractor.GetValueAsDouble(slopeArrow, RevitBuiltInParameter.SLOPE_START_HEIGHT); + return _parameterValueExtractor.GetValueAsDouble(slopeArrow, DB.BuiltInParameter.SLOPE_START_HEIGHT); } - public double GetSlopeArrowHeadOffset(IRevitModelLine slopeArrow, double tailOffset, out double slope) + public double GetSlopeArrowHeadOffset(DB.ModelLine slopeArrow, double tailOffset, out double slope) { - var specifyOffset = _parameterValueExtractor.GetValueAsInt( - slopeArrow, - RevitBuiltInParameter.SPECIFY_SLOPE_OR_OFFSET - ); + var specifyOffset = _parameterValueExtractor.GetValueAsInt(slopeArrow, DB.BuiltInParameter.SPECIFY_SLOPE_OR_OFFSET); - var lineLength = _parameterValueExtractor.GetValueAsDouble(slopeArrow, RevitBuiltInParameter.CURVE_ELEM_LENGTH); + var lineLength = _parameterValueExtractor.GetValueAsDouble(slopeArrow, DB.BuiltInParameter.CURVE_ELEM_LENGTH); slope = 0; double headOffset = 0; @@ -84,12 +73,12 @@ public double GetSlopeArrowHeadOffset(IRevitModelLine slopeArrow, double tailOff if (specifyOffset == 1) { // in this scenario, slope is returned as a percentage. Divide by 100 to get the unitless form - slope = _parameterValueExtractor.GetValueAsDouble(slopeArrow, RevitBuiltInParameter.ROOF_SLOPE) / 100d; + slope = _parameterValueExtractor.GetValueAsDouble(slopeArrow, DB.BuiltInParameter.ROOF_SLOPE) / 100d; headOffset = tailOffset + lineLength * Math.Sin(Math.Atan(slope)); } else if (specifyOffset == 0) // 0 corrospondes to the "height at tail" option { - headOffset = _parameterValueExtractor.GetValueAsDouble(slopeArrow, RevitBuiltInParameter.SLOPE_END_HEIGHT); + headOffset = _parameterValueExtractor.GetValueAsDouble(slopeArrow, DB.BuiltInParameter.SLOPE_END_HEIGHT); slope = (headOffset - tailOffset) / lineLength; } diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/ToSpeckleConvertedObjectsCache.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/ToSpeckleConvertedObjectsCache.cs new file mode 100644 index 0000000000..c4c91d9fb8 --- /dev/null +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/ToSpeckleConvertedObjectsCache.cs @@ -0,0 +1,25 @@ +using Speckle.Core.Models; + +namespace Speckle.Converters.RevitShared.Helpers; + +// POC: review the cache? should this be a common class? +// Does caching work this way everywhere, i.e, string key and base value? +public sealed class ToSpeckleConvertedObjectsCache +{ + private readonly Dictionary _uniqueIdToConvertedBaseDict = new(); + + public void AddConvertedBase(string revitUniqueId, Base b) + { + _uniqueIdToConvertedBaseDict.Add(revitUniqueId, b); + } + + public bool ContainsBaseConvertedFromId(string revitUniqueId) + { + return _uniqueIdToConvertedBaseDict.ContainsKey(revitUniqueId); + } + + public bool TryGetConvertedBase(string revitUniqueId, out Base? value) + { + return _uniqueIdToConvertedBaseDict.TryGetValue(revitUniqueId, out value); + } +} diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/IReferencePointConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/IReferencePointConverter.cs new file mode 100644 index 0000000000..f526412336 --- /dev/null +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/IReferencePointConverter.cs @@ -0,0 +1,6 @@ +namespace Speckle.Converters.RevitShared; + +public interface IReferencePointConverter +{ + DB.XYZ ConvertToExternalCoordindates(DB.XYZ inbound, bool isPoint); +} diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/IRevitVersionConversionHelper.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/IRevitVersionConversionHelper.cs new file mode 100644 index 0000000000..18a593cbbd --- /dev/null +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/IRevitVersionConversionHelper.cs @@ -0,0 +1,6 @@ +namespace Speckle.Converters.RevitShared; + +public interface IRevitVersionConversionHelper +{ + bool IsCurveClosed(DB.NurbSpline nurbsSpline); +} diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/BeamConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/BeamConversionToSpeckle.cs index 59f790664f..d6ee746e43 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/BeamConversionToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/BeamConversionToSpeckle.cs @@ -3,28 +3,27 @@ using Speckle.Converters.Common.Objects; using Speckle.Converters.RevitShared.Helpers; using Speckle.Core.Models; -using Speckle.Revit.Interfaces; -namespace Speckle.Converters.RevitShared; +namespace Speckle.Converters.RevitShared.ToSpeckle; // POC: There is no validation on this converter to prevent conversion from "not a Revit Beam" to a Speckle Beam. // This will definitely explode if we tried. Goes back to the `CanConvert` functionality conversation. // As-is, what we are saying is that it can take "any Family Instance" and turn it into a Speckle.RevitBeam, which is far from correct. // CNX-9312 -public class BeamConversionToSpeckle : ITypedConverter +public class BeamConversionToSpeckle : ITypedConverter { - private readonly ITypedConverter _locationConverter; - private readonly ITypedConverter _levelConverter; - private readonly IParameterValueExtractor _parameterValueExtractor; - private readonly IDisplayValueExtractor _displayValueExtractor; - private readonly IParameterObjectAssigner _parameterObjectAssigner; + private readonly ITypedConverter _locationConverter; + private readonly ITypedConverter _levelConverter; + private readonly ParameterValueExtractor _parameterValueExtractor; + private readonly DisplayValueExtractor _displayValueExtractor; + private readonly ParameterObjectAssigner _parameterObjectAssigner; public BeamConversionToSpeckle( - ITypedConverter locationConverter, - ITypedConverter levelConverter, - IParameterValueExtractor parameterValueExtractor, - IDisplayValueExtractor displayValueExtractor, - IParameterObjectAssigner parameterObjectAssigner + ITypedConverter locationConverter, + ITypedConverter levelConverter, + ParameterValueExtractor parameterValueExtractor, + DisplayValueExtractor displayValueExtractor, + ParameterObjectAssigner parameterObjectAssigner ) { _locationConverter = locationConverter; @@ -34,7 +33,7 @@ IParameterObjectAssigner parameterObjectAssigner _parameterObjectAssigner = parameterObjectAssigner; } - public SOBR.RevitBeam Convert(IRevitFamilyInstance target) + public SOBR.RevitBeam Convert(DB.FamilyInstance target) { var baseGeometry = _locationConverter.Convert(target.Location); if (baseGeometry is not ICurve baseCurve) @@ -43,20 +42,19 @@ public SOBR.RevitBeam Convert(IRevitFamilyInstance target) $"Beam location conversion did not yield an ICurve, instead it yielded an object of type {baseGeometry.GetType()}" ); } - - var symbol = target.Document.GetElement(target.GetTypeId()).NotNull().ToFamilySymbol().NotNull(); + var symbol = (DB.FamilySymbol)target.Document.GetElement(target.GetTypeId()); SOBR.RevitBeam speckleBeam = new() { family = symbol.FamilyName, - type = target.Document.GetElement(target.GetTypeId()).NotNull().Name, + type = target.Document.GetElement(target.GetTypeId()).Name, baseLine = baseCurve }; - var level = _parameterValueExtractor.GetValueAsRevitLevel( + var level = _parameterValueExtractor.GetValueAsDocumentObject( target, - RevitBuiltInParameter.INSTANCE_REFERENCE_LEVEL_PARAM + DB.BuiltInParameter.INSTANCE_REFERENCE_LEVEL_PARAM ); speckleBeam.level = _levelConverter.Convert(level); diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/BoundarySegmentConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/BoundarySegmentConversionToSpeckle.cs index 793e03735e..8f02d4c345 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/BoundarySegmentConversionToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/BoundarySegmentConversionToSpeckle.cs @@ -1,19 +1,18 @@ using Objects; using Speckle.Converters.Common.Objects; -using Speckle.Revit.Interfaces; -namespace Speckle.Converters.RevitShared; +namespace Speckle.Converters.RevitShared.ToSpeckle; -public class BoundarySegmentConversionToSpeckle : ITypedConverter, SOG.Polycurve> +public class BoundarySegmentConversionToSpeckle : ITypedConverter, SOG.Polycurve> { - private readonly ITypedConverter _curveConverter; + private readonly ITypedConverter _curveConverter; - public BoundarySegmentConversionToSpeckle(ITypedConverter curveConverter) + public BoundarySegmentConversionToSpeckle(ITypedConverter curveConverter) { _curveConverter = curveConverter; } - public SOG.Polycurve Convert(IList target) + public SOG.Polycurve Convert(IList target) { if (target.Count == 0) { @@ -23,7 +22,7 @@ public SOG.Polycurve Convert(IList target) var poly = new SOG.Polycurve(); foreach (var segment in target) { - IRevitCurve revitCurve = segment.GetCurve(); + DB.Curve revitCurve = segment.GetCurve(); var curve = _curveConverter.Convert(revitCurve); // POC: We used to attach the `elementID` of every curve in a PolyCurve as a dynamic property. diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/BraceToSpeckleConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/BraceToSpeckleConverter.cs index bcee398c73..ccae249fe5 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/BraceToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/BraceToSpeckleConverter.cs @@ -1,25 +1,24 @@ -using Speckle.Converters.Common.Objects; +using Speckle.Converters.Common.Objects; using Speckle.Core.Models; -using Speckle.Revit.Interfaces; -namespace Speckle.Converters.RevitShared; +namespace Speckle.Converters.RevitShared.ToSpeckle; // POC: There is no validation on this converter to prevent conversion from "not a Revit Beam" to a Speckle Beam. // This will definitely explode if we tried. Goes back to the `CanConvert` functionality conversation. // As-is, what we are saying is that it can take "any Family Instance" and turn it into a Speckle.RevitBeam, which is far from correct. // CNX-9312 -public class BraceToSpeckleConverter : ITypedConverter +public class BraceToSpeckleConverter : ITypedConverter { - private readonly ITypedConverter _beamConverter; + private readonly ITypedConverter _beamConverter; - public BraceToSpeckleConverter(ITypedConverter beamConverter) + public BraceToSpeckleConverter(ITypedConverter beamConverter) { _beamConverter = beamConverter; } - public SOBR.RevitBrace Convert(IRevitFamilyInstance target) + public SOBR.RevitBrace Convert(DB.FamilyInstance target) { - // POC: we might want some easy one-liner here to FamilyMatchesOrThrow(target, IRevitStructure.StructuralType.Brace) or similar + // POC: we might want some easy one-liner here to FamilyMatchesOrThrow(target, DB.Structure.StructuralType.Brace) or similar // and added in each Convert // POC: this and the beam lost the notes we were returning, though this seems against even the original pattern diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ColumnConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ColumnConversionToSpeckle.cs index afcf6f27eb..1786febd39 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ColumnConversionToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ColumnConversionToSpeckle.cs @@ -1,30 +1,31 @@ -using Objects; +using Autodesk.Revit.DB; +using Objects; +using Objects.BuiltElements.Revit; using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; using Speckle.Converters.RevitShared.Helpers; using Speckle.Core.Models; -using Speckle.Revit.Interfaces; -namespace Speckle.Converters.RevitShared; +namespace Speckle.Converters.RevitShared.ToSpeckle; // POC: There is no validation on this converter to prevent conversion from "not a Revit Beam" to a Speckle Beam. // This will definitely explode if we tried. Goes back to the `CanConvert` functionality conversation. -public class ColumnConversionToSpeckle : ITypedConverter +public class ColumnConversionToSpeckle : ITypedConverter { - private readonly ITypedConverter _locationConverter; - private readonly ITypedConverter _levelConverter; - private readonly IParameterValueExtractor _parameterValueExtractor; - private readonly IDisplayValueExtractor _displayValueExtractor; - private readonly IConversionContextStack _contextStack; - private readonly IParameterObjectAssigner _parameterObjectAssigner; + private readonly ITypedConverter _locationConverter; + private readonly ITypedConverter _levelConverter; + private readonly ParameterValueExtractor _parameterValueExtractor; + private readonly DisplayValueExtractor _displayValueExtractor; + private readonly IRevitConversionContextStack _contextStack; + private readonly ParameterObjectAssigner _parameterObjectAssigner; public ColumnConversionToSpeckle( - ITypedConverter locationConverter, - ITypedConverter levelConverter, - IParameterValueExtractor parameterValueExtractor, - IDisplayValueExtractor displayValueExtractor, - IConversionContextStack contextStack, - IParameterObjectAssigner parameterObjectAssigner + ITypedConverter locationConverter, + ITypedConverter levelConverter, + ParameterValueExtractor parameterValueExtractor, + DisplayValueExtractor displayValueExtractor, + IRevitConversionContextStack contextStack, + ParameterObjectAssigner parameterObjectAssigner ) { _locationConverter = locationConverter; @@ -35,71 +36,67 @@ IParameterObjectAssigner parameterObjectAssigner _parameterObjectAssigner = parameterObjectAssigner; } - public SOBR.RevitColumn Convert(IRevitFamilyInstance target) + public RevitColumn Convert(DB.FamilyInstance target) { - var symbol = target.Document.GetElement(target.GetTypeId()).NotNull().ToFamilySymbol().NotNull(); + FamilySymbol symbol = (FamilySymbol)target.Document.GetElement(target.GetTypeId()); - SOBR.RevitColumn speckleColumn = - new() { family = symbol.FamilyName, type = target.Document.GetElement(target.GetTypeId()).NotNull().Name }; + RevitColumn speckleColumn = + new() { family = symbol.FamilyName, type = target.Document.GetElement(target.GetTypeId()).Name }; - //should these all be try? if ( - _parameterValueExtractor.TryGetValueAsRevitLevel( + _parameterValueExtractor.TryGetValueAsDocumentObject( target, - RevitBuiltInParameter.FAMILY_BASE_LEVEL_PARAM, + BuiltInParameter.FAMILY_BASE_LEVEL_PARAM, out var level ) ) { - speckleColumn.level = _levelConverter.Convert(level); + speckleColumn.level = _levelConverter.Convert(level.NotNull()); } - //should these all be try? if ( - _parameterValueExtractor.TryGetValueAsRevitLevel( + _parameterValueExtractor.TryGetValueAsDocumentObject( target, - RevitBuiltInParameter.FAMILY_TOP_LEVEL_PARAM, + BuiltInParameter.FAMILY_TOP_LEVEL_PARAM, out var topLevel ) ) { - speckleColumn.topLevel = _levelConverter.Convert(topLevel); + speckleColumn.topLevel = _levelConverter.Convert(topLevel.NotNull()); } - //should these all be try? if ( _parameterValueExtractor.TryGetValueAsDouble( target, - RevitBuiltInParameter.FAMILY_BASE_LEVEL_OFFSET_PARAM, + BuiltInParameter.FAMILY_BASE_LEVEL_OFFSET_PARAM, out var baseOffset ) ) { - speckleColumn.baseOffset = baseOffset.Value; + speckleColumn.baseOffset = baseOffset.NotNull(); } - //should these all be try? if ( _parameterValueExtractor.TryGetValueAsDouble( target, - RevitBuiltInParameter.FAMILY_TOP_LEVEL_OFFSET_PARAM, + BuiltInParameter.FAMILY_TOP_LEVEL_OFFSET_PARAM, out var topOffset ) ) { - speckleColumn.topOffset = topOffset.Value; + speckleColumn.topOffset = topOffset.NotNull(); } + speckleColumn.facingFlipped = target.FacingFlipped; speckleColumn.handFlipped = target.HandFlipped; speckleColumn.isSlanted = target.IsSlantedColumn; - var locationPoint = target.GetLocationAsLocationPoint(); - if (locationPoint is not null) + if (target.Location is LocationPoint locationPoint) { speckleColumn.rotation = locationPoint.Rotation; } speckleColumn.baseLine = - GetBaseCurve(target, speckleColumn.topLevel?.elevation, speckleColumn.topOffset) + GetBaseCurve(target, speckleColumn.topLevel?.elevation ?? -1, speckleColumn.topOffset) ?? throw new SpeckleConversionException("Unable to find a valid baseCurve for column"); speckleColumn.displayValue = _displayValueExtractor.GetDisplayValue(target); @@ -109,7 +106,7 @@ out var topOffset return speckleColumn; } - private ICurve? GetBaseCurve(IRevitFamilyInstance target, double? topLevelElevation, double topLevelOffset) + private ICurve? GetBaseCurve(DB.FamilyInstance target, double topLevelElevation, double topLevelOffset) { Base baseGeometry = _locationConverter.Convert(target.Location); ICurve? baseCurve = baseGeometry as ICurve; @@ -132,12 +129,7 @@ out var topOffset return new SOG.Line( basePoint, - new SOG.Point( - basePoint.x, - basePoint.y, - topLevelElevation ?? 0 + topLevelOffset, - _contextStack.Current.SpeckleUnits - ), + new SOG.Point(basePoint.x, basePoint.y, topLevelElevation + topLevelOffset, _contextStack.Current.SpeckleUnits), _contextStack.Current.SpeckleUnits ); } diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/ArcToSpeckleConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/ArcToSpeckleConverter.cs index a5830c9c45..d6774a710b 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/ArcToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/ArcToSpeckleConverter.cs @@ -1,46 +1,42 @@ -using Objects.Primitive; -using Speckle.Converters.Common; +using Objects.Primitive; using Speckle.Converters.Common.Objects; +using Speckle.Converters.RevitShared.Helpers; using Speckle.Converters.RevitShared.Services; -using Speckle.Revit.Interfaces; namespace Speckle.Converters.RevitShared.ToSpeckle; -public class ArcToSpeckleConverter : ITypedConverter +public class ArcToSpeckleConverter : ITypedConverter { - private readonly IConversionContextStack _contextStack; - private readonly ITypedConverter _xyzToPointConverter; - private readonly ITypedConverter _planeConverter; - private readonly IScalingServiceToSpeckle _scalingService; - private readonly IRevitPlaneUtils _revitPlaneUtils; + private readonly IRevitConversionContextStack _contextStack; + private readonly ITypedConverter _xyzToPointConverter; + private readonly ITypedConverter _planeConverter; + private readonly ScalingServiceToSpeckle _scalingService; public ArcToSpeckleConverter( - IConversionContextStack contextStack, - ITypedConverter xyzToPointConverter, - ITypedConverter planeConverter, - IScalingServiceToSpeckle scalingService, - IRevitPlaneUtils revitPlaneUtils + IRevitConversionContextStack contextStack, + ITypedConverter xyzToPointConverter, + ITypedConverter planeConverter, + ScalingServiceToSpeckle scalingService ) { _contextStack = contextStack; _xyzToPointConverter = xyzToPointConverter; _planeConverter = planeConverter; _scalingService = scalingService; - _revitPlaneUtils = revitPlaneUtils; } - public SOG.Arc Convert(IRevitArc target) + public SOG.Arc Convert(DB.Arc target) { // see https://forums.autodesk.com/t5/revit-api-forum/how-to-retrieve-startangle-and-endangle-of-arc-object/td-p/7637128 - var arcPlane = _revitPlaneUtils.CreateByOriginAndBasis(target.Center, target.XDirection, target.YDirection); - IRevitXYZ center = target.Center; + var arcPlane = DB.Plane.CreateByOriginAndBasis(target.Center, target.XDirection, target.YDirection); + DB.XYZ center = target.Center; - IRevitXYZ dir0 = (target.GetEndPoint(0).Subtract(center)).Normalize(); - IRevitXYZ dir1 = (target.GetEndPoint(1).Subtract(center)).Normalize(); + DB.XYZ dir0 = (target.GetEndPoint(0) - center).Normalize(); + DB.XYZ dir1 = (target.GetEndPoint(1) - center).Normalize(); - IRevitXYZ start = target.Evaluate(0, true); - IRevitXYZ end = target.Evaluate(1, true); - IRevitXYZ mid = target.Evaluate(0.5, true); + DB.XYZ start = target.Evaluate(0, true); + DB.XYZ end = target.Evaluate(1, true); + DB.XYZ mid = target.Evaluate(0.5, true); double startAngle = target.XDirection.AngleOnPlaneTo(dir0, target.Normal); double endAngle = target.XDirection.AngleOnPlaneTo(dir1, target.Normal); diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/BoundingBoxXYZToSpeckleConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/BoundingBoxXYZToSpeckleConverter.cs index f91deee0cc..a891579ad5 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/BoundingBoxXYZToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/BoundingBoxXYZToSpeckleConverter.cs @@ -1,31 +1,27 @@ -using Objects.Primitive; -using Speckle.Converters.Common; +using Objects.Primitive; using Speckle.Converters.Common.Objects; -using Speckle.Revit.Interfaces; +using Speckle.Converters.RevitShared.Helpers; namespace Speckle.Converters.RevitShared.ToSpeckle; -public class BoundingBoxXYZToSpeckleConverter : ITypedConverter +public class BoundingBoxXYZToSpeckleConverter : ITypedConverter { - private readonly IConversionContextStack _contextStack; - private readonly ITypedConverter _xyzToPointConverter; - private readonly ITypedConverter _planeConverter; - private readonly IRevitPlaneUtils _revitPlaneUtils; + private readonly IRevitConversionContextStack _contextStack; + private readonly ITypedConverter _xyzToPointConverter; + private readonly ITypedConverter _planeConverter; public BoundingBoxXYZToSpeckleConverter( - IConversionContextStack contextStack, - ITypedConverter xyzToPointConverter, - ITypedConverter planeConverter, - IRevitPlaneUtils revitPlaneUtils + IRevitConversionContextStack contextStack, + ITypedConverter xyzToPointConverter, + ITypedConverter planeConverter ) { _contextStack = contextStack; _xyzToPointConverter = xyzToPointConverter; _planeConverter = planeConverter; - _revitPlaneUtils = revitPlaneUtils; } - public SOG.Box Convert(IRevitBoundingBoxXYZ target) + public SOG.Box Convert(DB.BoundingBoxXYZ target) { // convert min and max pts to speckle first var min = _xyzToPointConverter.Convert(target.Min); @@ -33,7 +29,7 @@ public SOG.Box Convert(IRevitBoundingBoxXYZ target) // get the base plane of the bounding box from the transform var transform = target.Transform; - var plane = _revitPlaneUtils.CreateByOriginAndBasis( + var plane = DB.Plane.CreateByOriginAndBasis( transform.Origin, transform.BasisX.Normalize(), transform.BasisY.Normalize() diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/CircleToSpeckleConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/CircleToSpeckleConverter.cs index 580c223c6b..7abdc08cfc 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/CircleToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/CircleToSpeckleConverter.cs @@ -1,36 +1,32 @@ -using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; +using Speckle.Converters.RevitShared.Helpers; using Speckle.Converters.RevitShared.Services; -using Speckle.Revit.Interfaces; namespace Speckle.Converters.RevitShared.ToSpeckle; -public class CircleToSpeckleConverter : ITypedConverter +public class CircleToSpeckleConverter : ITypedConverter { - private readonly IConversionContextStack _contextStack; - private readonly ITypedConverter _planeConverter; - private readonly IScalingServiceToSpeckle _scalingService; - private readonly IRevitPlaneUtils _revitPlaneUtils; + private readonly IRevitConversionContextStack _contextStack; + private readonly ITypedConverter _planeConverter; + private readonly ScalingServiceToSpeckle _scalingService; public CircleToSpeckleConverter( - IConversionContextStack contextStack, - ITypedConverter planeConverter, - IScalingServiceToSpeckle scalingService, - IRevitPlaneUtils revitPlaneUtils + IRevitConversionContextStack contextStack, + ITypedConverter planeConverter, + ScalingServiceToSpeckle scalingService ) { _contextStack = contextStack; _planeConverter = planeConverter; _scalingService = scalingService; - _revitPlaneUtils = revitPlaneUtils; } - public SOG.Circle Convert(IRevitArc target) + public SOG.Circle Convert(DB.Arc target) { // POC: should we check for arc of 360 and throw? Original CircleToSpeckle did not do this. // see https://forums.autodesk.com/t5/revit-api-forum/how-to-retrieve-startangle-and-endangle-of-arc-object/td-p/7637128 - var arcPlane = _revitPlaneUtils.CreateByNormalAndOrigin(target.Normal, target.Center); + var arcPlane = DB.Plane.CreateByNormalAndOrigin(target.Normal, target.Center); var c = new SOG.Circle() { plane = _planeConverter.Convert(arcPlane), diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/CurveArrArrayToSpecklePolycurveConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/CurveArrArrayToSpecklePolycurveConverter.cs index d393d310c6..4644bc1435 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/CurveArrArrayToSpecklePolycurveConverter.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/CurveArrArrayToSpecklePolycurveConverter.cs @@ -1,25 +1,34 @@ -using Speckle.Converters.Common.Objects; -using Speckle.Revit.Interfaces; +using Autodesk.Revit.DB; +using Objects.Geometry; +using Speckle.Converters.Common.Objects; -namespace Speckle.Converters.RevitShared.ToSpeckle; +namespace Speckle.Converters.RevitShared.Raw; -public sealed class CurveArrArrayToSpecklePolycurveConverter : ITypedConverter> +internal sealed class CurveArrArrayToSpecklePolycurveConverter : ITypedConverter> { - private readonly ITypedConverter _curveArrayConverter; + private readonly ITypedConverter _curveArrayConverter; - public CurveArrArrayToSpecklePolycurveConverter(ITypedConverter curveArrayConverter) + public CurveArrArrayToSpecklePolycurveConverter(ITypedConverter curveArrayConverter) { _curveArrayConverter = curveArrayConverter; } - public List Convert(IRevitCurveArrArray target) + public List Convert(CurveArrArray target) { - List polycurves = new(target.Count); - foreach (var curveArray in target) + List polycurves = new(); + foreach (var curveArray in GetCurveArrays(target)) { polycurves.Add(_curveArrayConverter.Convert(curveArray)); } return polycurves; } + + private IEnumerable GetCurveArrays(DB.CurveArrArray curveArrArray) + { + for (var i = 0; i < curveArrArray.Size; i++) + { + yield return curveArrArray.get_Item(i); + } + } } diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/CurveArrayConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/CurveArrayConversionToSpeckle.cs index afa6ad4830..8ec80fe9f7 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/CurveArrayConversionToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/CurveArrayConversionToSpeckle.cs @@ -1,21 +1,22 @@ -using Objects; -using Speckle.Converters.Common; +using Autodesk.Revit.DB; +using Objects; +using Objects.Geometry; using Speckle.Converters.Common.Objects; +using Speckle.Converters.RevitShared.Helpers; using Speckle.Converters.RevitShared.Services; -using Speckle.Revit.Interfaces; namespace Speckle.Converters.RevitShared.ToSpeckle; -public sealed class CurveArrayConversionToSpeckle : ITypedConverter +public sealed class CurveArrayConversionToSpeckle : ITypedConverter { - private readonly IConversionContextStack _contextStack; - private readonly IScalingServiceToSpeckle _scalingService; - private readonly ITypedConverter _curveConverter; + private readonly IRevitConversionContextStack _contextStack; + private readonly ScalingServiceToSpeckle _scalingService; + private readonly ITypedConverter _curveConverter; public CurveArrayConversionToSpeckle( - IConversionContextStack contextStack, - IScalingServiceToSpeckle scalingService, - ITypedConverter curveConverter + IRevitConversionContextStack contextStack, + ScalingServiceToSpeckle scalingService, + ITypedConverter curveConverter ) { _contextStack = contextStack; @@ -23,14 +24,15 @@ ITypedConverter curveConverter _curveConverter = curveConverter; } - public SOG.Polycurve Convert(IRevitCurveArray target) + public Polycurve Convert(CurveArray target) { - List curves = target.Cast().ToList(); + List curves = target.Cast().ToList(); - return new SOG.Polycurve() + return new Polycurve() { units = _contextStack.Current.SpeckleUnits, - closed = curves.First().GetEndPoint(0).DistanceTo(curves.Last().GetEndPoint(1)) < RevitConstants.TOLERANCE, + closed = + curves.First().GetEndPoint(0).DistanceTo(curves.Last().GetEndPoint(1)) < RevitConversionContextStack.TOLERANCE, length = _scalingService.ScaleLength(curves.Sum(x => x.Length)), segments = curves.Select(x => _curveConverter.Convert(x)).ToList() }; diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/CurveConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/CurveConversionToSpeckle.cs index e165964a28..0b034a779c 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/CurveConversionToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/CurveConversionToSpeckle.cs @@ -1,26 +1,25 @@ -using Objects; -using Speckle.Converters.Common; +using Objects; using Speckle.Converters.Common.Objects; -using Speckle.Revit.Interfaces; +using Speckle.Converters.Common; namespace Speckle.Converters.RevitShared.ToSpeckle; -public class CurveConversionToSpeckle : ITypedConverter +public class CurveConversionToSpeckle : ITypedConverter { - private readonly ITypedConverter _lineConverter; - private readonly ITypedConverter _arcConverter; - private readonly ITypedConverter _circleConverter; - private readonly ITypedConverter _ellipseConverter; - private readonly ITypedConverter _nurbsConverter; - private readonly ITypedConverter _hermiteConverter; // POC: should this be ICurve? + private readonly ITypedConverter _lineConverter; + private readonly ITypedConverter _arcConverter; + private readonly ITypedConverter _circleConverter; + private readonly ITypedConverter _ellipseConverter; + private readonly ITypedConverter _nurbsConverter; + private readonly ITypedConverter _hermiteConverter; // POC: should this be ICurve? public CurveConversionToSpeckle( - ITypedConverter lineConverter, - ITypedConverter arcConverter, - ITypedConverter circleConverter, - ITypedConverter ellipseConverter, - ITypedConverter nurbsConverter, - ITypedConverter hermiteConverter + ITypedConverter lineConverter, + ITypedConverter arcConverter, + ITypedConverter circleConverter, + ITypedConverter ellipseConverter, + ITypedConverter nurbsConverter, + ITypedConverter hermiteConverter ) { _lineConverter = lineConverter; @@ -31,34 +30,18 @@ public CurveConversionToSpeckle( _hermiteConverter = hermiteConverter; } - public ICurve Convert(IRevitCurve target) + public ICurve Convert(DB.Curve target) { - var line = target.ToLine(); - if (line is not null) - { - return _lineConverter.Convert(line); - } - var arc = target.ToArc(); - if (arc is not null) - { - return arc.IsClosed ? _circleConverter.Convert(arc) : _arcConverter.Convert(arc); - } - var ellipse = target.ToEllipse(); - if (ellipse is not null) - { - return _ellipseConverter.Convert(ellipse); - } - var nurbs = target.ToNurbSpline(); - if (nurbs is not null) - { - return _nurbsConverter.Convert(nurbs); - } - var hermite = target.ToHermiteSpline(); - if (hermite is not null) + return target switch { - return _hermiteConverter.Convert(hermite); - } + DB.Line line => _lineConverter.Convert(line), + // POC: are maybe arc.IsCyclic ? + DB.Arc arc => arc.IsClosed ? _circleConverter.Convert(arc) : _arcConverter.Convert(arc), + DB.Ellipse ellipse => _ellipseConverter.Convert(ellipse), + DB.NurbSpline nurbs => _nurbsConverter.Convert(nurbs), + DB.HermiteSpline hermite => _hermiteConverter.Convert(hermite), - throw new SpeckleConversionException($"Unsupported curve type {target.GetType()}"); + _ => throw new SpeckleConversionException($"Unsupported curve type {target.GetType()}") + }; } } diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/EllipseToSpeckleConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/EllipseToSpeckleConverter.cs index 7f920e5954..96ca62f8f1 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/EllipseToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/EllipseToSpeckleConverter.cs @@ -1,40 +1,30 @@ -using Objects.Primitive; -using Speckle.Converters.Common; +using Objects.Primitive; using Speckle.Converters.Common.Objects; +using Speckle.Converters.RevitShared.Helpers; using Speckle.Converters.RevitShared.Services; -using Speckle.Revit.Interfaces; namespace Speckle.Converters.RevitShared.ToSpeckle; -public class EllipseToSpeckleConverter : ITypedConverter +public class EllipseToSpeckleConverter : ITypedConverter { - private readonly IConversionContextStack _contextStack; - private readonly ITypedConverter _planeConverter; - private readonly IScalingServiceToSpeckle _scalingService; - private readonly IRevitPlaneUtils _revitPlaneUtils; + private readonly IRevitConversionContextStack _contextStack; + private readonly ITypedConverter _planeConverter; + private readonly ScalingServiceToSpeckle _scalingService; public EllipseToSpeckleConverter( - IConversionContextStack contextStack, - ITypedConverter planeConverter, - IScalingServiceToSpeckle scalingService, - IRevitPlaneUtils revitPlaneUtils + IRevitConversionContextStack contextStack, + ITypedConverter planeConverter, + ScalingServiceToSpeckle scalingService ) { _contextStack = contextStack; _planeConverter = planeConverter; _scalingService = scalingService; - _revitPlaneUtils = revitPlaneUtils; } - public SOG.Ellipse Convert(IRevitEllipse target) + public SOG.Ellipse Convert(DB.Ellipse target) { - using ( - IRevitPlane basePlane = _revitPlaneUtils.CreateByOriginAndBasis( - target.Center, - target.XDirection, - target.YDirection - ) - ) + using (DB.Plane basePlane = DB.Plane.CreateByOriginAndBasis(target.Center, target.XDirection, target.YDirection)) { var trim = target.IsBound ? new Interval(target.GetEndParameter(0), target.GetEndParameter(1)) : null; diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/HermiteSplineToSpeckleConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/HermiteSplineToSpeckleConverter.cs index 1c364da849..5aa2a07ed2 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/HermiteSplineToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/HermiteSplineToSpeckleConverter.cs @@ -1,25 +1,19 @@ -using Speckle.Converters.Common.Objects; -using Speckle.Revit.Interfaces; +using Speckle.Converters.Common.Objects; namespace Speckle.Converters.RevitShared.ToSpeckle; -public class HermiteSplineToSpeckleConverter : ITypedConverter +public class HerminteSplitToSpeckleConverter : ITypedConverter { - private readonly ITypedConverter _splineConverter; - private readonly IRevitNurbSplineUtils _revitNurbSplineUtils; + private readonly ITypedConverter _splineConverter; - public HermiteSplineToSpeckleConverter( - ITypedConverter splineConverter, - IRevitNurbSplineUtils revitNurbSplineUtils - ) + public HerminteSplitToSpeckleConverter(ITypedConverter splineConverter) { _splineConverter = splineConverter; - _revitNurbSplineUtils = revitNurbSplineUtils; } - public SOG.Curve Convert(IRevitHermiteSpline target) + public SOG.Curve Convert(DB.HermiteSpline target) { - var nurbs = _revitNurbSplineUtils.Create(target); + var nurbs = DB.NurbSpline.Create(target); return _splineConverter.Convert(nurbs); } } diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/LineConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/LineConversionToSpeckle.cs index ceddef39b0..2405cf0b22 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/LineConversionToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/LineConversionToSpeckle.cs @@ -1,21 +1,20 @@ -using Objects.Primitive; -using Speckle.Converters.Common; +using Objects.Primitive; using Speckle.Converters.Common.Objects; +using Speckle.Converters.RevitShared.Helpers; using Speckle.Converters.RevitShared.Services; -using Speckle.Revit.Interfaces; namespace Speckle.Converters.RevitShared.ToSpeckle; -public class LineConversionToSpeckle : ITypedConverter +public class LineConversionToSpeckle : ITypedConverter { - private readonly IConversionContextStack _contextStack; - private readonly ITypedConverter _xyzToPointConverter; - private readonly IScalingServiceToSpeckle _scalingService; + private readonly IRevitConversionContextStack _contextStack; + private readonly ITypedConverter _xyzToPointConverter; + private readonly ScalingServiceToSpeckle _scalingService; public LineConversionToSpeckle( - IConversionContextStack contextStack, - ITypedConverter xyzToPointConverter, - IScalingServiceToSpeckle scalingService + IRevitConversionContextStack contextStack, + ITypedConverter xyzToPointConverter, + ScalingServiceToSpeckle scalingService ) { _contextStack = contextStack; @@ -23,7 +22,7 @@ IScalingServiceToSpeckle scalingService _scalingService = scalingService; } - public SOG.Line Convert(IRevitLine target) => + public SOG.Line Convert(DB.Line target) => new() { units = _contextStack.Current.SpeckleUnits, diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/MeshByMaterialDictionaryToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/MeshByMaterialDictionaryToSpeckle.cs index 22d806277a..29b0bd9f98 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/MeshByMaterialDictionaryToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/MeshByMaterialDictionaryToSpeckle.cs @@ -1,21 +1,20 @@ using Objects.Other; -using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; -using Speckle.Revit.Interfaces; +using Speckle.Converters.RevitShared.Helpers; namespace Speckle.Converters.RevitShared.ToSpeckle; public class MeshByMaterialDictionaryToSpeckle - : ITypedConverter>, List> + : ITypedConverter>, List> { - private readonly IConversionContextStack _contextStack; - private readonly ITypedConverter _xyzToPointConverter; - private readonly ITypedConverter _materialConverter; + private readonly IRevitConversionContextStack _contextStack; + private readonly ITypedConverter _xyzToPointConverter; + private readonly ITypedConverter _materialConverter; public MeshByMaterialDictionaryToSpeckle( - ITypedConverter materialConverter, - IConversionContextStack contextStack, - ITypedConverter xyzToPointConverter + ITypedConverter materialConverter, + IRevitConversionContextStack contextStack, + ITypedConverter xyzToPointConverter ) { _materialConverter = materialConverter; @@ -26,24 +25,24 @@ public MeshByMaterialDictionaryToSpeckle( /// /// Converts a dictionary of Revit meshes, where key is MaterialId, into a list of Speckle meshes. /// - /// A dictionary with IRevitElementId keys and List of IRevitMesh values. + /// A dictionary with DB.ElementId keys and List of DB.Mesh values. /// /// Returns a list of objects where each mesh represents one unique material in the input dictionary. /// /// /// Be aware that this method internally creates a new instance of for each unique material in the input dictionary. /// These meshes are created with an initial capacity based on the size of the vertex and face arrays to avoid unnecessary resizing. - /// Also note that, for each unique material, the method tries to retrieve the related IRevitMaterial from the current document and convert it. If the conversion is successful, + /// Also note that, for each unique material, the method tries to retrieve the related DB.Material from the current document and convert it. If the conversion is successful, /// the material is added to the corresponding Speckle mesh. If the conversion fails, the operation simply continues without the material. /// - public List Convert(Dictionary> target) + public List Convert(Dictionary> target) { var result = new List(target.Keys.Count); foreach (var meshData in target) { - IRevitElementId materialId = meshData.Key; - List meshes = meshData.Value; + DB.ElementId materialId = meshData.Key; + List meshes = meshData.Value; // We compute the final size of the arrays to prevent unnecessary resizing. (int verticesSize, int facesSize) = GetVertexAndFaceListSize(meshes); @@ -56,7 +55,7 @@ public MeshByMaterialDictionaryToSpeckle( ); var doc = _contextStack.Current.Document; - if (doc.GetElement(materialId) is IRevitMaterial material) + if (doc.GetElement(materialId) is DB.Material material) { speckleMesh["renderMaterial"] = _materialConverter.Convert(material); } @@ -73,7 +72,7 @@ public MeshByMaterialDictionaryToSpeckle( return result; } - private void AppendToSpeckleMesh(IRevitMesh mesh, SOG.Mesh speckleMesh) + private void AppendToSpeckleMesh(DB.Mesh mesh, SOG.Mesh speckleMesh) { int faceIndexOffset = speckleMesh.vertices.Count / 3; @@ -87,16 +86,16 @@ private void AppendToSpeckleMesh(IRevitMesh mesh, SOG.Mesh speckleMesh) for (int i = 0; i < mesh.NumTriangles; i++) { - var triangle = mesh.GetTriangle(i); + var triangle = mesh.get_Triangle(i); speckleMesh.faces.Add(3); // TRIANGLE flag - speckleMesh.faces.Add((int)triangle.GetIndex(0) + faceIndexOffset); - speckleMesh.faces.Add((int)triangle.GetIndex(1) + faceIndexOffset); - speckleMesh.faces.Add((int)triangle.GetIndex(2) + faceIndexOffset); + speckleMesh.faces.Add((int)triangle.get_Index(0) + faceIndexOffset); + speckleMesh.faces.Add((int)triangle.get_Index(1) + faceIndexOffset); + speckleMesh.faces.Add((int)triangle.get_Index(2) + faceIndexOffset); } } - private static (int vertexCount, int) GetVertexAndFaceListSize(List meshes) + private static (int vertexCount, int) GetVertexAndFaceListSize(List meshes) { int numberOfVertices = 0; int numberOfFaces = 0; diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/MeshConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/MeshConversionToSpeckle.cs index 093d553cf2..2f6c494ba0 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/MeshConversionToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/MeshConversionToSpeckle.cs @@ -1,20 +1,19 @@ using Objects.Other; -using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; -using Speckle.Revit.Interfaces; +using Speckle.Converters.RevitShared.Helpers; namespace Speckle.Converters.RevitShared.ToSpeckle; -public class MeshConversionToSpeckle : ITypedConverter +public class MeshConversionToSpeckle : ITypedConverter { - private readonly ITypedConverter _xyzToPointConverter; - private readonly ITypedConverter _materialConverter; - private readonly IConversionContextStack _contextStack; + private readonly ITypedConverter _xyzToPointConverter; + private readonly ITypedConverter _materialConverter; + private readonly IRevitConversionContextStack _contextStack; public MeshConversionToSpeckle( - IConversionContextStack contextStack, - ITypedConverter xyzToPointConverter, - ITypedConverter materialConverter + IRevitConversionContextStack contextStack, + ITypedConverter xyzToPointConverter, + ITypedConverter materialConverter ) { _contextStack = contextStack; @@ -22,17 +21,15 @@ ITypedConverter materialConverter _materialConverter = materialConverter; } - public SOG.Mesh Convert(IRevitMesh target) + public SOG.Mesh Convert(DB.Mesh target) { var doc = _contextStack.Current.Document; List vertices = GetSpeckleMeshVertexData(target); List faces = GetSpeckleMeshFaceData(target); - var element = doc.GetElement(target.MaterialElementId); - var revitMaterial = element?.ToMaterial(); RenderMaterial? speckleMaterial = null; - if (revitMaterial is not null) + if (doc.GetElement(target.MaterialElementId) is DB.Material revitMaterial) { speckleMaterial = _materialConverter.Convert(revitMaterial); } @@ -43,7 +40,7 @@ public SOG.Mesh Convert(IRevitMesh target) }; } - private List GetSpeckleMeshVertexData(IRevitMesh target) + private List GetSpeckleMeshVertexData(DB.Mesh target) { var vertices = new List(target.Vertices.Count * 3); @@ -55,12 +52,12 @@ private List GetSpeckleMeshVertexData(IRevitMesh target) return vertices; } - private List GetSpeckleMeshFaceData(IRevitMesh target) + private List GetSpeckleMeshFaceData(DB.Mesh target) { var faces = new List(target.NumTriangles * 4); for (int i = 0; i < target.NumTriangles; i++) { - var triangle = target.GetTriangle(i); + var triangle = target.get_Triangle(i); faces.AddRange(GetMeshTriangleData(triangle)); } @@ -76,12 +73,12 @@ private List GetSpeckleMeshFaceData(IRevitMesh target) /// Output format is a 4 item list with format [3, v1, v2, v3]; where the first item is the triangle flag (for speckle) /// and the 3 following numbers are the indices of each vertex in the vertex list. /// - private IReadOnlyList GetMeshTriangleData(IRevitMeshTriangle triangle) => + private IReadOnlyList GetMeshTriangleData(DB.MeshTriangle triangle) => new[] { 3, // The TRIANGLE flag in speckle - (int)triangle.GetIndex(0), - (int)triangle.GetIndex(1), - (int)triangle.GetIndex(2) + (int)triangle.get_Index(0), + (int)triangle.get_Index(1), + (int)triangle.get_Index(2) }; } diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/NurbsSplineToSpeckleConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/NurbsSplineToSpeckleConverter.cs index c646f9e6b4..7229f639e3 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/NurbsSplineToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/NurbsSplineToSpeckleConverter.cs @@ -1,23 +1,22 @@ -using Objects.Primitive; -using Speckle.Converters.Common; +using Objects.Primitive; using Speckle.Converters.Common.Objects; +using Speckle.Converters.RevitShared.Helpers; using Speckle.Converters.RevitShared.Services; -using Speckle.Revit.Interfaces; namespace Speckle.Converters.RevitShared.ToSpeckle; -public class NurbsSplineToSpeckleConverter : ITypedConverter +public class NurbsSplineToSpeckleConverter : ITypedConverter { private readonly IRevitVersionConversionHelper _conversionHelper; - private readonly IConversionContextStack _contextStack; - private readonly ITypedConverter _xyzToPointConverter; - private readonly IScalingServiceToSpeckle _scalingService; + private readonly IRevitConversionContextStack _contextStack; + private readonly ITypedConverter _xyzToPointConverter; + private readonly ScalingServiceToSpeckle _scalingService; public NurbsSplineToSpeckleConverter( IRevitVersionConversionHelper conversionHelper, - IConversionContextStack contextStack, - ITypedConverter xyzToPointConverter, - IScalingServiceToSpeckle scalingService + IRevitConversionContextStack contextStack, + ITypedConverter xyzToPointConverter, + ScalingServiceToSpeckle scalingService ) { _conversionHelper = conversionHelper; @@ -26,7 +25,7 @@ IScalingServiceToSpeckle scalingService _scalingService = scalingService; } - public SOG.Curve Convert(IRevitNurbSpline target) + public SOG.Curve Convert(DB.NurbSpline target) { var units = _contextStack.Current.SpeckleUnits; @@ -41,12 +40,12 @@ public SOG.Curve Convert(IRevitNurbSpline target) return new SOG.Curve() { - weights = target.Weights.ToList(), + weights = target.Weights.Cast().ToList(), points = points, - knots = target.Knots.ToList(), + knots = target.Knots.Cast().ToList(), degree = target.Degree, //speckleCurve.periodic = revitCurve.Period; // POC: already commented out, remove? - rational = target.IsRational, + rational = target.isRational, closed = _conversionHelper.IsCurveClosed(target), units = units, domain = new Interval(target.GetEndParameter(0), target.GetEndParameter(1)), diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/PlaneToSpeckleConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/PlaneToSpeckleConverter.cs index 56f098ceda..27cef7bab6 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/PlaneToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/PlaneToSpeckleConverter.cs @@ -1,19 +1,18 @@ -using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; -using Speckle.Revit.Interfaces; +using Speckle.Converters.RevitShared.Helpers; namespace Speckle.Converters.RevitShared.ToSpeckle; -public class PlaneToSpeckleConverter : ITypedConverter +public class PlaneToSpeckleConverter : ITypedConverter { - private readonly IConversionContextStack _contextStack; - private readonly ITypedConverter _xyzToPointConverter; - private readonly ITypedConverter _xyzToVectorConverter; + private readonly IRevitConversionContextStack _contextStack; + private readonly ITypedConverter _xyzToPointConverter; + private readonly ITypedConverter _xyzToVectorConverter; public PlaneToSpeckleConverter( - IConversionContextStack contextStack, - ITypedConverter xyzToPointConverter, - ITypedConverter xyzToVectorConverter + IRevitConversionContextStack contextStack, + ITypedConverter xyzToPointConverter, + ITypedConverter xyzToVectorConverter ) { _contextStack = contextStack; @@ -21,7 +20,7 @@ public PlaneToSpeckleConverter( _xyzToVectorConverter = xyzToVectorConverter; } - public SOG.Plane Convert(IRevitPlane target) + public SOG.Plane Convert(DB.Plane target) { var origin = _xyzToPointConverter.Convert(target.Origin); var normal = _xyzToVectorConverter.Convert(target.Normal); diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/PointCloudToSpeckleConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/PointCloudToSpeckleConverter.cs index c552e7dbdf..ab86301cd2 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/PointCloudToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/PointCloudToSpeckleConverter.cs @@ -1,52 +1,39 @@ -using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; -using Speckle.Revit.Interfaces; +using Speckle.Converters.RevitShared.Helpers; namespace Speckle.Converters.RevitShared.ToSpeckle; -public class PointCloudToSpeckleConverter : ITypedConverter +public class PointCloudToSpeckleConverter : ITypedConverter { - private readonly IConversionContextStack _contextStack; - private readonly ITypedConverter _xyzToPointConverter; - private readonly ITypedConverter _boundingBoxConverter; - private readonly IRevitPlaneUtils _revitPlaneUtils; - private readonly IRevitXYZUtils _revitxyzUtils; - private readonly IRevitFilterFactory _revitFilterFactory; + private readonly IRevitConversionContextStack _contextStack; + private readonly ITypedConverter _xyzToPointConverter; + private readonly ITypedConverter _boundingBoxConverter; public PointCloudToSpeckleConverter( - IConversionContextStack contextStack, - ITypedConverter xyzToPointConverter, - ITypedConverter boundingBoxConverter, - IRevitPlaneUtils revitPlaneUtils, - IRevitXYZUtils revitxyzUtils, - IRevitFilterFactory revitFilterFactory + IRevitConversionContextStack contextStack, + ITypedConverter xyzToPointConverter, + ITypedConverter boundingBoxConverter ) { _contextStack = contextStack; _xyzToPointConverter = xyzToPointConverter; _boundingBoxConverter = boundingBoxConverter; - _revitPlaneUtils = revitPlaneUtils; - _revitxyzUtils = revitxyzUtils; - _revitFilterFactory = revitFilterFactory; } - public SOG.Pointcloud Convert(IRevitPointCloudInstance target) + public SOG.Pointcloud Convert(DB.PointCloudInstance target) { - var boundingBox = target.GetBoundingBox(); - using IRevitTransform transform = target.GetTransform(); + var boundingBox = target.get_BoundingBox(null); + using DB.Transform transform = target.GetTransform(); { - var minPlane = _revitPlaneUtils.CreateByNormalAndOrigin( - _revitxyzUtils.BasisZ, - transform.OfPoint(boundingBox.NotNull().Min) - ); - var filter = _revitFilterFactory.CreateMultiPlaneFilter(minPlane); + var minPlane = DB.Plane.CreateByNormalAndOrigin(DB.XYZ.BasisZ, transform.OfPoint(boundingBox.Min)); + var filter = DB.PointClouds.PointCloudFilterFactory.CreateMultiPlaneFilter(new List() { minPlane }); var points = target.GetPoints(filter, 0.0001, 999999); // max limit is 1 mil but 1000000 throws error // POC: complaining about nullability var specklePointCloud = new SOG.Pointcloud { points = points - .Select(o => _xyzToPointConverter.Convert(transform.OfPoint(o.ToXYZ()))) + .Select(o => _xyzToPointConverter.Convert(transform.OfPoint(o))) .SelectMany(o => new List() { o.x, o.y, o.z }) .ToList(), colors = points.Select(o => o.Color).ToList(), diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/PointConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/PointConversionToSpeckle.cs index 4da12eafca..8f6ca703db 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/PointConversionToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/PointConversionToSpeckle.cs @@ -1,16 +1,15 @@ -using Speckle.Converters.Common.Objects; -using Speckle.Revit.Interfaces; +using Speckle.Converters.Common.Objects; namespace Speckle.Converters.RevitShared.ToSpeckle; -public class PointConversionToSpeckle : ITypedConverter +public class PointConversionToSpeckle : ITypedConverter { - private readonly ITypedConverter _xyzToPointConverter; + private readonly ITypedConverter _xyzToPointConverter; - public PointConversionToSpeckle(ITypedConverter xyzToPointConverter) + public PointConversionToSpeckle(ITypedConverter xyzToPointConverter) { _xyzToPointConverter = xyzToPointConverter; } - public SOG.Point Convert(IRevitPoint target) => _xyzToPointConverter.Convert(target.Coord); + public SOG.Point Convert(DB.Point target) => _xyzToPointConverter.Convert(target.Coord); } diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/PolylineToSpeckleConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/PolylineToSpeckleConverter.cs index e64b28309b..5efb22e278 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/PolylineToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/PolylineToSpeckleConverter.cs @@ -1,24 +1,23 @@ -using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; -using Speckle.Revit.Interfaces; +using Speckle.Converters.RevitShared.Helpers; namespace Speckle.Converters.RevitShared.ToSpeckle; -public class PolylineToSpeckleConverter : ITypedConverter +public class PolylineToSpeckleConverter : ITypedConverter { - private readonly IConversionContextStack _contextStack; - private readonly ITypedConverter _xyzToPointConverter; + private readonly IRevitConversionContextStack _contextStack; + private readonly ITypedConverter _xyzToPointConverter; public PolylineToSpeckleConverter( - IConversionContextStack contextStack, - ITypedConverter xyzToPointConverter + IRevitConversionContextStack contextStack, + ITypedConverter xyzToPointConverter ) { _contextStack = contextStack; _xyzToPointConverter = xyzToPointConverter; } - public SOG.Polyline Convert(IRevitPolyLine target) + public SOG.Polyline Convert(DB.PolyLine target) { var coords = target.GetCoordinates().SelectMany(coord => _xyzToPointConverter.Convert(coord).ToList()).ToList(); return new SOG.Polyline(coords, _contextStack.Current.SpeckleUnits); diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/SolidConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/SolidConversionToSpeckle.cs index 039c706869..e848d3a843 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/SolidConversionToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/SolidConversionToSpeckle.cs @@ -1,53 +1,53 @@ -using Speckle.Converters.Common.Objects; -using Speckle.Revit.Interfaces; +using Speckle.Converters.Common.Objects; +using Speckle.Converters.RevitShared.Helpers; namespace Speckle.Converters.RevitShared.ToSpeckle; /// /// Solid conversion is a one->many. For each material used in the solid, a mesh will be returned to reduce the amount of instances created. /// -public class SolidConversionToSpeckle : ITypedConverter> +public class SolidConversionToSpeckle : IRawConversion> { - private readonly ITypedConverter< - Dictionary>, - List - > _meshByMaterialConverter; + private readonly RevitConversionContextStack _contextStack; + private readonly IRawConversion>, List> _meshByMaterialConverter; public SolidConversionToSpeckle( - ITypedConverter>, List> meshByMaterialConverter + RevitConversionContextStack contextStack, + IRawConversion>, List> meshByMaterialConverter ) { + _contextStack = contextStack; _meshByMaterialConverter = meshByMaterialConverter; } /// - /// Converts the input object into a list of . + /// Converts the input object into a list of . /// - /// The input object to be converted. + /// The input object to be converted. /// - /// A list of objects that represent the input object. Each mesh in the list corresponds to a different material in the original solid. + /// A list of objects that represent the input object. Each mesh in the list corresponds to a different material in the original solid. /// /// /// This conversion process first triangulates the input solid by material, and then converts the result to raw meshes individually. /// Be aware that this operation might be computationally intensive for complex solids, due to the need for triangulation. /// - public List Convert(IRevitSolid target) + public List RawConvert(DB.Solid target) { var meshesByMaterial = GetTriangulatedMeshesFromSolidByMaterial(target); - return _meshByMaterialConverter.Convert(meshesByMaterial); + return _meshByMaterialConverter.RawConvert(meshesByMaterial); } - private Dictionary> GetTriangulatedMeshesFromSolidByMaterial(IRevitSolid solid) + private Dictionary> GetTriangulatedMeshesFromSolidByMaterial(DB.Solid solid) { - var result = new Dictionary>(); - foreach (IRevitFace face in solid.Faces) + var result = new Dictionary>(); + foreach (DB.Face face in solid.Faces) { - if (!result.TryGetValue(face.MaterialElementId, out var mat)) + if (!result.ContainsKey(face.MaterialElementId)) { - mat = new List(); - result[face.MaterialElementId] = mat; + result[face.MaterialElementId] = new List(); } - mat.Add(face.Triangulate()); + + result[face.MaterialElementId].Add(face.Triangulate()); } return result; diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/VectorToSpeckleConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/VectorToSpeckleConverter.cs index ad04f5d8db..e97cf962f4 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/VectorToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/VectorToSpeckleConverter.cs @@ -1,28 +1,27 @@ -using Speckle.Converters.Common.Objects; +using Speckle.Converters.Common.Objects; using Speckle.Converters.RevitShared.Services; -using Speckle.Revit.Interfaces; namespace Speckle.Converters.RevitShared.ToSpeckle; -public class VectorToSpeckleConverter : ITypedConverter +public class VectorToSpeckleConverter : ITypedConverter { private readonly IReferencePointConverter _referencePointConverter; - private readonly IScalingServiceToSpeckle _scalingService; + private readonly ScalingServiceToSpeckle _scalingService; public VectorToSpeckleConverter( IReferencePointConverter referencePointConverter, - IScalingServiceToSpeckle scalingService + ScalingServiceToSpeckle scalingService ) { _referencePointConverter = referencePointConverter; _scalingService = scalingService; } - public SOG.Vector Convert(IRevitXYZ target) + public SOG.Vector Convert(DB.XYZ target) { // POC: originally had a concept of not transforming, but this was // optional arg defaulting to false - removing the argument appeared to break nothing - var extPt = _referencePointConverter.ConvertToExternalCoordindates(target, false); + DB.XYZ extPt = _referencePointConverter.ConvertToExternalCoordindates(target, false); var pointToSpeckle = new SOG.Vector( _scalingService.ScaleLength(extPt.X), _scalingService.ScaleLength(extPt.Y), diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/XyzConversionToPoint.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/XyzConversionToPoint.cs index 4f5996e1e5..bf250d06c3 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/XyzConversionToPoint.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/XyzConversionToPoint.cs @@ -1,26 +1,24 @@ -using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; +using Speckle.Converters.RevitShared.Helpers; using Speckle.Converters.RevitShared.Services; -using Speckle.Revit.Interfaces; -#pragma warning disable IDE0130 namespace Speckle.Converters.RevitShared.ToSpeckle; -public class XyzConversionToPoint : ITypedConverter +public class XyzConversionToPoint : ITypedConverter { - private readonly IScalingServiceToSpeckle _toSpeckleScalingService; - private readonly IConversionContextStack _contextStack; + private readonly ScalingServiceToSpeckle _toSpeckleScalingService; + private readonly IRevitConversionContextStack _contextStack; public XyzConversionToPoint( - IScalingServiceToSpeckle toSpeckleScalingService, - IConversionContextStack contextStack + ScalingServiceToSpeckle toSpeckleScalingService, + IRevitConversionContextStack contextStack ) { _toSpeckleScalingService = toSpeckleScalingService; _contextStack = contextStack; } - public SOG.Point Convert(IRevitXYZ target) + public SOG.Point Convert(DB.XYZ target) { var pointToSpeckle = new SOG.Point( _toSpeckleScalingService.ScaleLength(target.X), diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/LevelConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/LevelConversionToSpeckle.cs index bea059ceaa..33e1d7fea2 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/LevelConversionToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/LevelConversionToSpeckle.cs @@ -1,19 +1,18 @@ -using Speckle.Converters.Common.Objects; +using Speckle.Converters.Common.Objects; using Speckle.Converters.RevitShared.Services; -using Speckle.Revit.Interfaces; -namespace Speckle.Converters.RevitShared; +namespace Speckle.Converters.RevitShared.ToSpeckle; -public class LevelConversionToSpeckle : ITypedConverter +public class LevelConversionToSpeckle : ITypedConverter { - private readonly IScalingServiceToSpeckle _scalingService; + private readonly ScalingServiceToSpeckle _scalingService; - public LevelConversionToSpeckle(IScalingServiceToSpeckle scalingService) + public LevelConversionToSpeckle(ScalingServiceToSpeckle scalingService) { _scalingService = scalingService; } - public SOBR.RevitLevel Convert(IRevitLevel target) + public SOBR.RevitLevel Convert(DB.Level target) { SOBR.RevitLevel level = new() diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/LocationConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/LocationConversionToSpeckle.cs index ac47cb38cf..29d3378103 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/LocationConversionToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/LocationConversionToSpeckle.cs @@ -1,43 +1,34 @@ -using Objects; -using Speckle.Converters.Common; +using Objects; using Speckle.Converters.Common.Objects; +using Speckle.Converters.Common; using Speckle.Core.Models; -using Speckle.Revit.Interfaces; -#pragma warning disable IDE0130 -namespace Speckle.Converters.RevitShared; +namespace Speckle.Converters.RevitShared.ToSpeckle; -#pragma warning restore IDE0130 - -public class LocationConversionToSpeckle : ITypedConverter +public class LocationConversionToSpeckle : ITypedConverter { - private readonly ITypedConverter _curveConverter; - private readonly ITypedConverter _xyzConverter; + private readonly ITypedConverter _curveConverter; + private readonly ITypedConverter _xyzConverter; // POC: review IRawConversion which always returns a Base, this is ToSpeckle, so... this breaks // the meaning of IRawConversion, it could be IToSpeckleRawConversion // also a factory type public LocationConversionToSpeckle( - ITypedConverter curveConverter, - ITypedConverter xyzConverter + ITypedConverter curveConverter, + ITypedConverter xyzConverter ) { _curveConverter = curveConverter; _xyzConverter = xyzConverter; } - public Base Convert(IRevitLocation target) + public Base Convert(DB.Location target) { - var curve = target.ToLocationCurve(); - if (curve is not null) - { - return (_curveConverter.Convert(curve.Curve) as Base).NotNull(); // POC: ICurve and Base are not related but we know they must be, had to soft cast and then !. - } - var point = target.ToLocationPoint(); - if (point is not null) + return target switch { - return _xyzConverter.Convert(point.Point); - } - throw new SpeckleConversionException($"Unexpected location type {target.GetType()}"); + DB.LocationCurve curve => (_curveConverter.Convert(curve.Curve) as Base)!, // POC: ICurve and Base are not related but we know they must be, had to soft cast and then !. + DB.LocationPoint point => _xyzConverter.Convert(point.Point), + _ => throw new SpeckleConversionException($"Unexpected location type {target.GetType()}") + }; } } diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/MaterialConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/MaterialConversionToSpeckle.cs index 50062f88fd..f7f48974f7 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/MaterialConversionToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/MaterialConversionToSpeckle.cs @@ -1,12 +1,11 @@ using Objects.Other; using Speckle.Converters.Common.Objects; -using Speckle.Revit.Interfaces; -namespace Speckle.Converters.RevitShared; +namespace Speckle.Converters.RevitShared.ToSpeckle; -public class MaterialConversionToSpeckle : ITypedConverter +public class MaterialConversionToSpeckle : ITypedConverter { - public RenderMaterial Convert(IRevitMaterial target) => + public RenderMaterial Convert(DB.Material target) => // POC: not sure we should be pulling in System.Drawing - // maybe this isn't a problem as it's part of the netstandard Fwk // ideally we'd have serialiser of our own colour class, i.e. to serialise to an uint diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ModelCurveArrArrayConverterToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ModelCurveArrArrayConverterToSpeckle.cs deleted file mode 100644 index 111e12a42b..0000000000 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ModelCurveArrArrayConverterToSpeckle.cs +++ /dev/null @@ -1,30 +0,0 @@ -using Objects.Geometry; -using Speckle.Converters.Common.Objects; -using Speckle.Revit.Interfaces; -#pragma warning disable IDE0130 -namespace Speckle.Converters.RevitShared; - -internal sealed class ModelCurveArrArrayConverterToSpeckle : ITypedConverter -{ - private readonly ITypedConverter _modelCurveArrayConverter; - - public ModelCurveArrArrayConverterToSpeckle( - ITypedConverter modelCurveArrayConverter - ) - { - _modelCurveArrayConverter = modelCurveArrayConverter; - } - - public Objects.Geometry.Polycurve[] Convert(IRevitModelCurveArrArray target) - { - var polycurves = new Objects.Geometry.Polycurve[target.Count]; - var revitArrays = target.ToArray(); - - for (int i = 0; i < polycurves.Length; i++) - { - polycurves[i] = _modelCurveArrayConverter.Convert(revitArrays[i]); - } - - return polycurves; - } -} diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ModelCurveArrArrayToSpeckleConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ModelCurveArrArrayToSpeckleConverter.cs new file mode 100644 index 0000000000..d294360b2d --- /dev/null +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ModelCurveArrArrayToSpeckleConverter.cs @@ -0,0 +1,28 @@ +using Autodesk.Revit.DB; +using Objects.Geometry; +using Speckle.Converters.Common.Objects; + +namespace Speckle.Converters.RevitShared.Raw; + +internal sealed class ModelCurveArrArrayConverterToSpeckle : ITypedConverter +{ + private readonly ITypedConverter _modelCurveArrayConverter; + + public ModelCurveArrArrayConverterToSpeckle(ITypedConverter modelCurveArrayConverter) + { + _modelCurveArrayConverter = modelCurveArrayConverter; + } + + public SOG.Polycurve[] Convert(ModelCurveArrArray target) + { + var polycurves = new Polycurve[target.Size]; + var revitArrays = target.Cast().ToArray(); + + for (int i = 0; i < polycurves.Length; i++) + { + polycurves[i] = _modelCurveArrayConverter.Convert(revitArrays[i]); + } + + return polycurves; + } +} diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ModelCurveArrayToSpeckleConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ModelCurveArrayToSpeckleConverter.cs index ce1690ee5d..5bfd4d11bb 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ModelCurveArrayToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ModelCurveArrayToSpeckleConverter.cs @@ -1,21 +1,21 @@ -using Objects; +using Objects; using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; +using Speckle.Converters.RevitShared.Helpers; using Speckle.Converters.RevitShared.Services; -using Speckle.Revit.Interfaces; -#pragma warning disable IDE0130 -namespace Speckle.Converters.RevitShared; -public sealed class ModelCurveArrayToSpeckleConverter : ITypedConverter +namespace Speckle.Converters.RevitShared.Raw; + +internal sealed class ModelCurveArrayToSpeckleConverter : ITypedConverter { - private readonly IConversionContextStack _contextStack; - private readonly IScalingServiceToSpeckle _scalingService; - private readonly ITypedConverter _curveConverter; + private readonly IRevitConversionContextStack _contextStack; + private readonly ScalingServiceToSpeckle _scalingService; + private readonly ITypedConverter _curveConverter; public ModelCurveArrayToSpeckleConverter( - IConversionContextStack contextStack, - IScalingServiceToSpeckle scalingService, - ITypedConverter curveConverter + IRevitConversionContextStack contextStack, + ScalingServiceToSpeckle scalingService, + ITypedConverter curveConverter ) { _contextStack = contextStack; @@ -23,12 +23,10 @@ ITypedConverter curveConverter _curveConverter = curveConverter; } - public SOG.Polycurve Convert(IRevitModelCurveArray target) => Convert((IReadOnlyList)target); - - public SOG.Polycurve Convert(IReadOnlyList target) + public SOG.Polycurve Convert(DB.ModelCurveArray target) { SOG.Polycurve polycurve = new(); - var curves = target.Select(mc => mc.GeometryCurve).ToArray(); + var curves = target.Cast().Select(mc => mc.GeometryCurve).ToArray(); if (curves.Length == 0) { @@ -38,7 +36,7 @@ public SOG.Polycurve Convert(IReadOnlyList target) var start = curves[0].GetEndPoint(0); var end = curves[^1].GetEndPoint(1); polycurve.units = _contextStack.Current.SpeckleUnits; - polycurve.closed = start.DistanceTo(end) < RevitConstants.TOLERANCE; + polycurve.closed = start.DistanceTo(end) < RevitConversionContextStack.TOLERANCE; polycurve.length = _scalingService.ScaleLength(curves.Sum(x => x.Length)); polycurve.segments.AddRange(curves.Select(x => _curveConverter.Convert(x))); diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ParameterConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ParameterConversionToSpeckle.cs index ae2a9ec5c5..a0b1f01da5 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ParameterConversionToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ParameterConversionToSpeckle.cs @@ -1,35 +1,30 @@ -using Speckle.Converters.Common.Objects; +using Autodesk.Revit.DB; +using Speckle.Converters.Common.Objects; using Speckle.Converters.RevitShared.Extensions; using Speckle.Converters.RevitShared.Helpers; -using Speckle.Revit.Interfaces; -namespace Speckle.Converters.RevitShared; +namespace Speckle.Converters.RevitShared.ToSpeckle; -public class ParameterConversionToSpeckle : ITypedConverter +public class ParameterConversionToSpeckle : ITypedConverter { - private readonly IParameterValueExtractor _valueExtractor; - private readonly IRevitFormatOptionsUtils _revitFormatOptionsUtils; + private readonly ParameterValueExtractor _valueExtractor; - public ParameterConversionToSpeckle( - IParameterValueExtractor valueExtractor, - IRevitFormatOptionsUtils revitFormatOptionsUtils - ) + public ParameterConversionToSpeckle(ParameterValueExtractor valueExtractor) { _valueExtractor = valueExtractor; - _revitFormatOptionsUtils = revitFormatOptionsUtils; } - public SOBR.Parameter Convert(IRevitParameter target) + public SOBR.Parameter Convert(Parameter target) { string internalName = target.GetInternalName(); - IRevitForgeTypeId? unitTypeId = null; - if (target.StorageType is RevitStorageType.Double) + ForgeTypeId? unitTypeId = null; + if (target.StorageType is StorageType.Double) { // according to the api documentation, this method will throw if the storage type is not a VALUE type // however, I've found that it will still throw if StorageType == StorageType.Integer unitTypeId = target.GetUnitTypeId(); } - IRevitDefinition definition = target.Definition; + Definition definition = target.Definition; return new SOBR.Parameter() { @@ -38,7 +33,7 @@ public SOBR.Parameter Convert(IRevitParameter target) isShared = target.IsShared, isReadOnly = target.IsReadOnly, name = definition.Name, - units = unitTypeId?.GetSymbol(_revitFormatOptionsUtils) ?? "None", + units = unitTypeId?.GetSymbol() ?? "None", value = _valueExtractor.GetValue(target) }; } diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/RevitVersionConversionHelper.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/RevitVersionConversionHelper.cs deleted file mode 100644 index 7ebcaf9d95..0000000000 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/RevitVersionConversionHelper.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System.Diagnostics.CodeAnalysis; -using Speckle.InterfaceGenerator; -using Speckle.Revit.Interfaces; - -namespace Speckle.Converters.RevitShared; - -[GenerateAutoInterface] -public class RevitVersionConversionHelper : IRevitVersionConversionHelper -{ - [SuppressMessage("Design", "CA1031:Do not catch general exception types")] - public bool IsCurveClosed(IRevitNurbSpline nurbsSpline) - { - try - { - return nurbsSpline.IsClosed; - } - catch (Exception) - { - // POC: is this actually a good assumption? - return true; - } - } -} diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Services/ReferencePointConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ReferencePointConverter.cs similarity index 51% rename from DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Services/ReferencePointConverter.cs rename to DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ReferencePointConverter.cs index 4eef722c25..4704184be6 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Services/ReferencePointConverter.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ReferencePointConverter.cs @@ -1,25 +1,12 @@ using System.Diagnostics.CodeAnalysis; -using Speckle.Converters.Common; -using Speckle.InterfaceGenerator; -using Speckle.Revit.Interfaces; +using Speckle.Converters.RevitShared.Helpers; namespace Speckle.Converters.RevitShared; -[GenerateAutoInterface] -public class RevitConversionSettings : IRevitConversionSettings -{ - private Dictionary Settings { get; } = new(); - - public bool TryGetSettingString(string key, out string value) => Settings.TryGetValue(key, out value); - - public string this[string key] - { - get => Settings[key]; - set => Settings[key] = value; - } -} - -[GenerateAutoInterface] +// POC: this could perhaps becomes some RevitDocumentService but also... +// This reference point feature needs review. We could do with knowing whether this feature is widely used. +// there's also some bogus disposal happening +// https://spockle.atlassian.net/browse/CNX-9357 public class ReferencePointConverter : IReferencePointConverter { // POC: probably not the best place for this @@ -27,33 +14,21 @@ public class ReferencePointConverter : IReferencePointConverter private const string REFPOINT_PROJECT_BASE = "Project Base"; private const string REFPOINT_SURVEY = "Survey"; - private readonly IRevitConversionSettings _revitSettings; - private readonly IConversionContextStack _contextStack; - private readonly IRevitTransformUtils _transformUtils; - private readonly IRevitFilterFactory _revitFilterFactory; - private readonly IRevitXYZUtils _revitXyzUtils; - - private readonly Dictionary _docTransforms = new(); - - public ReferencePointConverter( - IConversionContextStack contextStack, - IRevitConversionSettings revitSettings, - IRevitFilterFactory revitFilterFactory, - IRevitTransformUtils transformUtils, - IRevitXYZUtils revitXyzUtils - ) + private readonly RevitConversionSettings _revitSettings; + private readonly IRevitConversionContextStack _contextStack; + + private readonly Dictionary _docTransforms = new(); + + public ReferencePointConverter(IRevitConversionContextStack contextStack, RevitConversionSettings revitSettings) { _contextStack = contextStack; _revitSettings = revitSettings; - _revitFilterFactory = revitFilterFactory; - _transformUtils = transformUtils; - _revitXyzUtils = revitXyzUtils; } // POC: the original allowed for the document to be passed in // if required, we would probably need to push the stack with a new document if the // doc can change during the lifeycycle of the conversions. This may need some looking into - public IRevitXYZ ConvertToExternalCoordindates(IRevitXYZ inbound, bool isPoint) + public DB.XYZ ConvertToExternalCoordindates(DB.XYZ inbound, bool isPoint) { var rpt = GetDocReferencePointTransform(_contextStack.Current.Document); return isPoint ? rpt.OfPoint(inbound) : rpt.OfVector(inbound); @@ -61,13 +36,13 @@ public IRevitXYZ ConvertToExternalCoordindates(IRevitXYZ inbound, bool isPoint) // POC: this might be better in some RevitDocumentService // we could probably return that instance instead of the Doc from the context, maybe... - public IRevitTransform GetDocReferencePointTransform(IRevitDocument doc) + public DB.Transform GetDocReferencePointTransform(DB.Document doc) { //linked files are always saved to disc and will have a path name //if the current doc is unsaved it will not, but then it'll be the only one :) var id = doc.PathName; - if (!_docTransforms.TryGetValue(id, out IRevitTransform? transform)) + if (!_docTransforms.TryGetValue(id, out DB.Transform? transform)) { // get from settings var referencePointSetting = _revitSettings.TryGetSettingString("reference-point", out string value) @@ -81,25 +56,25 @@ public IRevitTransform GetDocReferencePointTransform(IRevitDocument doc) } [SuppressMessage("Reliability", "CA2000:Dispose objects before losing scope")] - public IRevitTransform GetReferencePointTransform(string referencePointSetting) + public DB.Transform GetReferencePointTransform(string referencePointSetting) { // first get the main doc base points and reference setting transform - var referencePointTransform = _transformUtils.Identity; + var referencePointTransform = DB.Transform.Identity; // POC: bogus disposal below - var points = _revitFilterFactory - .CreateFilteredElementCollector(_contextStack.Current.Document) - .OfClass() + var points = new DB.FilteredElementCollector(_contextStack.Current.Document) + .OfClass(typeof(DB.BasePoint)) + .Cast() .ToList(); - var projectPoint = NotNullExtensions.NotNull(points.FirstOrDefault(o => o.IsShared == false), "No projectPoint"); - var surveyPoint = NotNullExtensions.NotNull(points.FirstOrDefault(o => o.IsShared), "No surveyPoint"); + var projectPoint = points.FirstOrDefault(o => o.IsShared == false); + var surveyPoint = points.FirstOrDefault(o => o.IsShared); // POC: it's not clear what support is needed for this switch (referencePointSetting) { case REFPOINT_PROJECT_BASE: // note that the project base (ui) rotation is registered on the survey pt, not on the base point - referencePointTransform = _transformUtils.CreateTranslation(projectPoint.Position); + referencePointTransform = DB.Transform.CreateTranslation(projectPoint.Position); break; case REFPOINT_SURVEY: @@ -107,12 +82,12 @@ public IRevitTransform GetReferencePointTransform(string referencePointSetting) // retrieve the survey point rotation from the project point // POC: should a null angle resolve to 0? - var angle = projectPoint.GetParameter(RevitBuiltInParameter.BASEPOINT_ANGLETON_PARAM)?.AsDouble() ?? 0; + var angle = projectPoint.get_Parameter(DB.BuiltInParameter.BASEPOINT_ANGLETON_PARAM)?.AsDouble() ?? 0; // POC: following disposed incorrectly or early or maybe a false negative? - referencePointTransform = _transformUtils + referencePointTransform = DB.Transform .CreateTranslation(surveyPoint.Position) - .Multiply(_transformUtils.CreateRotation(_revitXyzUtils.BasisZ, angle)); + .Multiply(DB.Transform.CreateRotation(DB.XYZ.BasisZ, angle)); break; diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/RevitConstants.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/RevitConstants.cs deleted file mode 100644 index 79a6ef167a..0000000000 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/RevitConstants.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace Speckle.Converters.RevitShared; - -public static class RevitConstants -{ - public const double TOLERANCE = 0.0164042; // 5mm in ft -} diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/RevitConversionSettings.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/RevitConversionSettings.cs new file mode 100644 index 0000000000..3fb4466120 --- /dev/null +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/RevitConversionSettings.cs @@ -0,0 +1,19 @@ +namespace Speckle.Converters.RevitShared; + +// POC: probably NOT the right place, probably needs passing in with the send/rcv operation +// not clear how this should get configured or if we should have it, the shape probably needs to change +// this was dragged in because it (or something like it) is required for reference point conversion. +// have made it a strongly typed thing encapsulating a dictionary so as not to rely on injecting a weak type. +// relates to https://spockle.atlassian.net/browse/CNX-9357 +public class RevitConversionSettings +{ + private Dictionary Settings { get; } = new Dictionary(); + + public bool TryGetSettingString(string key, out string value) => Settings.TryGetValue(key, out value); + + public string this[string key] + { + get => Settings[key]; + set => Settings[key] = value; + } +} diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/RevitRootToHostConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/RevitRootToHostConverter.cs new file mode 100644 index 0000000000..78790ee19e --- /dev/null +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/RevitRootToHostConverter.cs @@ -0,0 +1,50 @@ +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; +using Speckle.Core.Models; +using Speckle.Converters.RevitShared.Helpers; + +namespace Speckle.Converters.RevitShared; + +// POC: maybe possible to restrict the access so this cannot be created directly? +public class RevitRootToHostConverter : IRootToSpeckleConverter +{ + private readonly IConverterResolver _toSpeckle; + private readonly ParameterValueExtractor _parameterValueExtractor; + + public RevitRootToHostConverter( + IConverterResolver toSpeckle, + ParameterValueExtractor parameterValueExtractor + ) + { + _toSpeckle = toSpeckle; + _parameterValueExtractor = parameterValueExtractor; + } + + // POC: our assumption here is target is valid for conversion + // if it cannot be converted then we should throw + public Base Convert(object target) + { + var objectConverter = _toSpeckle.GetConversionForType(target.GetType()); + + if (objectConverter == null) + { + throw new SpeckleConversionException($"No conversion found for {target.GetType().Name}"); + } + + Base result = + objectConverter.Convert(target) + ?? throw new SpeckleConversionException($"Conversion of object with type {target.GetType()} returned null"); + + // POC : where should logic common to most objects go? + // shouldn't target ALWAYS be DB.Element? + if (target is DB.Element element) + { + // POC: is this the right place? + result.applicationId = element.UniqueId; + + _parameterValueExtractor.RemoveUniqueId(element.UniqueId); + } + + return result; + } +} diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Services/RevitToSpeckleUnitConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Services/RevitToSpeckleUnitConverter.cs index e6de0840fa..e1d7a7a62b 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Services/RevitToSpeckleUnitConverter.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Services/RevitToSpeckleUnitConverter.cs @@ -1,30 +1,29 @@ using Speckle.Converters.Common; using Speckle.Core.Kits; using Speckle.Core.Logging; -using Speckle.Revit.Interfaces; namespace Speckle.Converters.RevitShared.Services; -public sealed class RevitToSpeckleUnitConverter : IHostToSpeckleUnitConverter +public sealed class RevitToSpeckleUnitConverter : IHostToSpeckleUnitConverter { - private readonly Dictionary _unitMapping = new(); + private readonly Dictionary _unitMapping = new(); - public RevitToSpeckleUnitConverter(IRevitUnitUtils revitUnitUtils) + public RevitToSpeckleUnitConverter() { - _unitMapping[revitUnitUtils.Millimeters.TypeId] = Units.Millimeters; - _unitMapping[revitUnitUtils.Centimeters.TypeId] = Units.Centimeters; - _unitMapping[revitUnitUtils.Meters.TypeId] = Units.Meters; - _unitMapping[revitUnitUtils.MetersCentimeters.TypeId] = Units.Meters; - _unitMapping[revitUnitUtils.Inches.TypeId] = Units.Inches; - _unitMapping[revitUnitUtils.FractionalInches.TypeId] = Units.Inches; - _unitMapping[revitUnitUtils.Feet.TypeId] = Units.Feet; - _unitMapping[revitUnitUtils.FeetFractionalInches.TypeId] = Units.Feet; + _unitMapping[DB.UnitTypeId.Millimeters] = Units.Millimeters; + _unitMapping[DB.UnitTypeId.Centimeters] = Units.Centimeters; + _unitMapping[DB.UnitTypeId.Meters] = Units.Meters; + _unitMapping[DB.UnitTypeId.MetersCentimeters] = Units.Meters; + _unitMapping[DB.UnitTypeId.Inches] = Units.Inches; + _unitMapping[DB.UnitTypeId.FractionalInches] = Units.Inches; + _unitMapping[DB.UnitTypeId.Feet] = Units.Feet; + _unitMapping[DB.UnitTypeId.FeetFractionalInches] = Units.Feet; } // POC: maybe just convert, it's not a Try method - public string ConvertOrThrow(IRevitForgeTypeId hostUnit) + public string ConvertOrThrow(DB.ForgeTypeId hostUnit) { - if (_unitMapping.TryGetValue(hostUnit.TypeId, out string value)) + if (_unitMapping.TryGetValue(hostUnit, out string value)) { return value; } diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Services/ScalingServiceToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Services/ScalingServiceToSpeckle.cs index 57ba7be5f2..a0c2779048 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Services/ScalingServiceToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Services/ScalingServiceToSpeckle.cs @@ -1,27 +1,20 @@ -using Speckle.Converters.Common; -using Speckle.InterfaceGenerator; -using Speckle.Revit.Interfaces; +using Autodesk.Revit.DB; +using Speckle.Converters.RevitShared.Helpers; namespace Speckle.Converters.RevitShared.Services; // POC: feels like this is a context thing and we should be calculating this occasionally? // needs some thought as to how it could be be done, could leave as is for now -[GenerateAutoInterface] -public sealed class ScalingServiceToSpeckle : IScalingServiceToSpeckle +public sealed class ScalingServiceToSpeckle { private readonly double _defaultLengthConversionFactor; - private readonly IRevitUnitUtils _revitUnitUtils; // POC: this seems like the reverse relationship - public ScalingServiceToSpeckle( - IConversionContextStack contextStack, - IRevitUnitUtils revitUnitUtils - ) + public ScalingServiceToSpeckle(IRevitConversionContextStack contextStack) { - _revitUnitUtils = revitUnitUtils; // POC: this is accurate for the current context stack - var documentUnits = contextStack.Current.Document.GetUnits(); - var formatOptions = documentUnits.GetFormatOptions(_revitUnitUtils.Length); + Units documentUnits = contextStack.Current.Document.GetUnits(); + FormatOptions formatOptions = documentUnits.GetFormatOptions(SpecTypeId.Length); var lengthUnitsTypeId = formatOptions.GetUnitTypeId(); _defaultLengthConversionFactor = ScaleStatic(1, lengthUnitsTypeId); } @@ -33,14 +26,14 @@ IRevitUnitUtils revitUnitUtils public double ScaleLength(double length) => length * _defaultLengthConversionFactor; // POC: not sure about this??? - public double Scale(double value, IRevitForgeTypeId forgeTypeId) + public double Scale(double value, ForgeTypeId forgeTypeId) { return ScaleStatic(value, forgeTypeId); } // POC: not sure why this is needed??? - private double ScaleStatic(double value, IRevitForgeTypeId forgeTypeId) + private static double ScaleStatic(double value, ForgeTypeId forgeTypeId) { - return _revitUnitUtils.ConvertFromInternalUnits(value, forgeTypeId); + return UnitUtils.ConvertFromInternalUnits(value, forgeTypeId); } } diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Speckle.Converters.RevitShared.projitems b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Speckle.Converters.RevitShared.projitems index 575c0093e6..5e5d29480e 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Speckle.Converters.RevitShared.projitems +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Speckle.Converters.RevitShared.projitems @@ -9,6 +9,72 @@ Speckle.Converters.RevitShared - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/BaseTopLevelConverterToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/BaseTopLevelConverterToSpeckle.cs index 0a246e3b2f..f7a94c8d1f 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/BaseTopLevelConverterToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/BaseTopLevelConverterToSpeckle.cs @@ -1,4 +1,4 @@ -using Speckle.Converters.Common; +using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; using Speckle.Core.Models; diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/CeilingTopLevelConverterToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/CeilingTopLevelConverterToSpeckle.cs index 3dd7ed8cb6..c3de2636aa 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/CeilingTopLevelConverterToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/CeilingTopLevelConverterToSpeckle.cs @@ -1,31 +1,30 @@ +using Autodesk.Revit.DB; using Objects; using Objects.BuiltElements.Revit; using Objects.Geometry; using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; using Speckle.Converters.RevitShared.Helpers; -using Speckle.Revit.Interfaces; namespace Speckle.Converters.RevitShared.ToSpeckle; -[NameAndRankValue(nameof(IRevitCeiling), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -internal sealed class CeilingTopLevelConverterToSpeckle - : BaseTopLevelConverterToSpeckle +[NameAndRankValue(nameof(DB.Ceiling), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +internal sealed class CeilingTopLevelConverterToSpeckle : BaseTopLevelConverterToSpeckle { - private readonly ITypedConverter> _curveArrArrayConverter; - private readonly ITypedConverter _levelConverter; - private readonly IParameterValueExtractor _parameterValueExtractor; - private readonly IParameterObjectAssigner _parameterObjectAssigner; - private readonly IDisplayValueExtractor _displayValueExtractor; + private readonly ITypedConverter> _curveArrArrayConverter; + private readonly ITypedConverter _levelConverter; + private readonly ParameterValueExtractor _parameterValueExtractor; + private readonly ParameterObjectAssigner _parameterObjectAssigner; + private readonly DisplayValueExtractor _displayValueExtractor; //private readonly HostedElementConversionToSpeckle _hostedElementConverter; public CeilingTopLevelConverterToSpeckle( - ITypedConverter> curveArrArrayConverter, - ITypedConverter levelConverter, - IParameterValueExtractor parameterValueExtractor, - IParameterObjectAssigner parameterObjectAssigner, - IDisplayValueExtractor displayValueExtractor + ITypedConverter> curveArrArrayConverter, + ITypedConverter levelConverter, + ParameterValueExtractor parameterValueExtractor, + ParameterObjectAssigner parameterObjectAssigner, + DisplayValueExtractor displayValueExtractor ) { _curveArrArrayConverter = curveArrArrayConverter; @@ -35,14 +34,14 @@ IDisplayValueExtractor displayValueExtractor _displayValueExtractor = displayValueExtractor; } - public override RevitCeiling Convert(IRevitCeiling target) + public override RevitCeiling Convert(DB.Ceiling target) { - var sketch = target.Document.GetElement(target.SketchId).NotNull().ToSketch().NotNull(); + var sketch = (Sketch)target.Document.GetElement(target.SketchId); List profiles = _curveArrArrayConverter.Convert(sketch.Profile); var speckleCeiling = new RevitCeiling(); - var elementType = target.Document.GetElement(target.GetTypeId()).NotNull().ToType().NotNull(); + var elementType = (ElementType)target.Document.GetElement(target.GetTypeId()); speckleCeiling.type = elementType.Name; speckleCeiling.family = elementType.FamilyName; @@ -59,7 +58,7 @@ public override RevitCeiling Convert(IRevitCeiling target) // POC: our existing receive operation is checking the "slopeDirection" prop, // but it is never being set. We should be setting it - var level = _parameterValueExtractor.GetValueAsRevitLevel(target, RevitBuiltInParameter.LEVEL_PARAM); + var level = _parameterValueExtractor.GetValueAsDocumentObject(target, DB.BuiltInParameter.LEVEL_PARAM); speckleCeiling.level = _levelConverter.Convert(level); _parameterObjectAssigner.AssignParametersToBase(target, speckleCeiling); diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/DirectShapeTopLevelConverterToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/DirectShapeTopLevelConverterToSpeckle.cs index 1f87f63696..c9c9ca5e14 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/DirectShapeTopLevelConverterToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/DirectShapeTopLevelConverterToSpeckle.cs @@ -1,22 +1,22 @@ using Speckle.Converters.Common; using Speckle.Converters.RevitShared.Extensions; using Speckle.Converters.RevitShared.Helpers; +using Speckle.Converters.RevitShared.ToSpeckle; using Speckle.Core.Models; -using Speckle.Revit.Interfaces; -namespace Speckle.Converters.RevitShared.ToSpeckle; +namespace Speckle.Converters.Revit2023.ToSpeckle; -[NameAndRankValue(nameof(IRevitDirectShape), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class DirectShapeTopLevelConverterToSpeckle : BaseTopLevelConverterToSpeckle +[NameAndRankValue(nameof(DB.DirectShape), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +public class DirectShapeTopLevelConverterToSpeckle : BaseTopLevelConverterToSpeckle { - private readonly IConversionContextStack _contextStack; - private readonly IParameterObjectAssigner _parameterObjectAssigner; - private readonly IDisplayValueExtractor _displayValueExtractor; + private readonly IRevitConversionContextStack _contextStack; + private readonly ParameterObjectAssigner _parameterObjectAssigner; + private readonly DisplayValueExtractor _displayValueExtractor; public DirectShapeTopLevelConverterToSpeckle( - IParameterObjectAssigner parameterObjectAssigner, - IConversionContextStack contextStack, - IDisplayValueExtractor displayValueExtractor + ParameterObjectAssigner parameterObjectAssigner, + IRevitConversionContextStack contextStack, + DisplayValueExtractor displayValueExtractor ) { _parameterObjectAssigner = parameterObjectAssigner; @@ -24,7 +24,7 @@ IDisplayValueExtractor displayValueExtractor _displayValueExtractor = displayValueExtractor; } - public override SOBR.DirectShape Convert(IRevitDirectShape target) + public override SOBR.DirectShape Convert(DB.DirectShape target) { var category = target.Category.GetBuiltInCategory().GetSchemaBuilderCategoryFromBuiltIn(); diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/ElementTopLevelConverterToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/ElementTopLevelConverterToSpeckle.cs index cbd1cd9e06..c3b96c9001 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/ElementTopLevelConverterToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/ElementTopLevelConverterToSpeckle.cs @@ -1,27 +1,25 @@ -using Speckle.Converters.Common; +using Speckle.Converters.Common; +using Objects.BuiltElements.Revit; using Speckle.Converters.RevitShared.Helpers; -using Speckle.Revit.Interfaces; namespace Speckle.Converters.RevitShared.ToSpeckle; // POC: not currently used? clearly some missing pieces -[NameAndRankValue(nameof(IRevitElement), 0)] -public class ElementTopLevelConverterToSpeckle : BaseTopLevelConverterToSpeckle +[NameAndRankValue(nameof(DB.Element), 0)] +public class ElementTopLevelConverterToSpeckle : BaseTopLevelConverterToSpeckle { - private readonly IDisplayValueExtractor _displayValueExtractor; + private readonly DisplayValueExtractor _displayValueExtractor; - public ElementTopLevelConverterToSpeckle(IDisplayValueExtractor displayValueExtractor) + public ElementTopLevelConverterToSpeckle(DisplayValueExtractor displayValueExtractor) { _displayValueExtractor = displayValueExtractor; } - public override SOBR.RevitElement Convert(IRevitElement target) + public override RevitElement Convert(DB.Element target) { - SOBR.RevitElement speckleElement = new(); + RevitElement speckleElement = new(); - var element = target.Document.GetElement(target.GetTypeId()); - var symbol = element?.ToFamilySymbol(); - if (symbol is not null) + if (target.Document.GetElement(target.GetTypeId()) is DB.FamilySymbol symbol) { speckleElement.family = symbol.FamilyName; speckleElement.type = symbol.Name; diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/ExtrusionRoofToSpeckleTopLevelConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/ExtrusionRoofToSpeckleTopLevelConverter.cs index 8dfeb7907a..d46c93794f 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/ExtrusionRoofToSpeckleTopLevelConverter.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/ExtrusionRoofToSpeckleTopLevelConverter.cs @@ -1,34 +1,32 @@ using Objects.BuiltElements.Revit.RevitRoof; -using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; -using Speckle.Converters.RevitShared.Extensions; +using Speckle.Converters.Common; using Speckle.Converters.RevitShared.Helpers; -using Speckle.Revit.Interfaces; + +using Speckle.Converters.RevitShared.Extensions; namespace Speckle.Converters.RevitShared.ToSpeckle; -[NameAndRankValue(nameof(IRevitExtrusionRoof), 0)] +[NameAndRankValue(nameof(DB.ExtrusionRoof), 0)] public class ExtrusionRoofToSpeckleTopLevelConverter - : BaseTopLevelConverterToSpeckle + : BaseTopLevelConverterToSpeckle { - private readonly ITypedConverter _levelConverter; - private readonly ITypedConverter _modelCurveArrayConverter; - private readonly ITypedConverter _pointConverter; - private readonly IParameterValueExtractor _parameterValueExtractor; - private readonly IDisplayValueExtractor _displayValueExtractor; - private readonly IHostedElementConversionToSpeckle _hostedElementConverter; - private readonly IParameterObjectAssigner _parameterObjectAssigner; - private readonly IRevitFilterFactory _revitFilterFactory; + private readonly ITypedConverter _levelConverter; + private readonly ITypedConverter _modelCurveArrayConverter; + private readonly ITypedConverter _pointConverter; + private readonly ParameterValueExtractor _parameterValueExtractor; + private readonly DisplayValueExtractor _displayValueExtractor; + private readonly HostedElementConversionToSpeckle _hostedElementConverter; + private readonly ParameterObjectAssigner _parameterObjectAssigner; public ExtrusionRoofToSpeckleTopLevelConverter( - ITypedConverter levelConverter, - ITypedConverter modelCurveArrayConverter, - ITypedConverter pointConverter, - IParameterValueExtractor parameterValueExtractor, - IDisplayValueExtractor displayValueExtractor, - IHostedElementConversionToSpeckle hostedElementConverter, - IParameterObjectAssigner parameterObjectAssigner, - IRevitFilterFactory revitFilterFactory + ITypedConverter levelConverter, + ITypedConverter modelCurveArrayConverter, + ITypedConverter pointConverter, + ParameterValueExtractor parameterValueExtractor, + DisplayValueExtractor displayValueExtractor, + HostedElementConversionToSpeckle hostedElementConverter, + ParameterObjectAssigner parameterObjectAssigner ) { _levelConverter = levelConverter; @@ -38,36 +36,35 @@ IRevitFilterFactory revitFilterFactory _displayValueExtractor = displayValueExtractor; _hostedElementConverter = hostedElementConverter; _parameterObjectAssigner = parameterObjectAssigner; - _revitFilterFactory = revitFilterFactory; } - public override RevitExtrusionRoof Convert(IRevitExtrusionRoof target) + public override RevitExtrusionRoof Convert(DB.ExtrusionRoof target) { var speckleExtrusionRoof = new RevitExtrusionRoof { - start = _parameterValueExtractor.GetValueAsDouble(target, RevitBuiltInParameter.EXTRUSION_START_PARAM), - end = _parameterValueExtractor.GetValueAsDouble(target, RevitBuiltInParameter.EXTRUSION_END_PARAM) + start = _parameterValueExtractor.GetValueAsDouble(target, DB.BuiltInParameter.EXTRUSION_START_PARAM), + end = _parameterValueExtractor.GetValueAsDouble(target, DB.BuiltInParameter.EXTRUSION_END_PARAM) }; - var plane = target.GetProfile()[0].SketchPlane.GetPlane(); + var plane = target.GetProfile().get_Item(0).SketchPlane.GetPlane(); speckleExtrusionRoof.referenceLine = new SOG.Line( _pointConverter.Convert(plane.Origin.Add(plane.XVec.Normalize().Negate())), _pointConverter.Convert(plane.Origin) ); - var level = _parameterValueExtractor.GetValueAsRevitLevel( + var level = _parameterValueExtractor.GetValueAsDocumentObject( target, - RevitBuiltInParameter.ROOF_CONSTRAINT_LEVEL_PARAM + DB.BuiltInParameter.ROOF_CONSTRAINT_LEVEL_PARAM ); speckleExtrusionRoof.level = _levelConverter.Convert(level); speckleExtrusionRoof.outline = _modelCurveArrayConverter.Convert(target.GetProfile()); - var elementType = target.Document.GetElement(target.GetTypeId()).NotNull().ToType().NotNull(); + var elementType = (DB.ElementType)target.Document.GetElement(target.GetTypeId()); speckleExtrusionRoof.type = elementType.Name; speckleExtrusionRoof.family = elementType.FamilyName; _parameterObjectAssigner.AssignParametersToBase(target, speckleExtrusionRoof); speckleExtrusionRoof.displayValue = _displayValueExtractor.GetDisplayValue(target); speckleExtrusionRoof.elements = _hostedElementConverter - .ConvertHostedElements(target.GetHostedElementIds(_revitFilterFactory)) + .ConvertHostedElements(target.GetHostedElementIds()) .ToList(); return speckleExtrusionRoof; diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/FamilyInstanceTopLevelConverterToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/FamilyInstanceTopLevelConverterToSpeckle.cs index b408d104cc..446dcd4383 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/FamilyInstanceTopLevelConverterToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/FamilyInstanceTopLevelConverterToSpeckle.cs @@ -1,26 +1,24 @@ -using Speckle.Converters.Common; +using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; using Speckle.Core.Models; -using Speckle.Revit.Interfaces; namespace Speckle.Converters.RevitShared.ToSpeckle; // POC: bin for now? This is also a parent child relationship and may need a pattern for this // so we don't end up with some god FamilyInstanceTopLevelConverterToSpeckle converter -[NameAndRankValue(nameof(IRevitFamilyInstance), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public sealed class FamilyInstanceTopLevelConverterToSpeckle - : BaseTopLevelConverterToSpeckle +[NameAndRankValue(nameof(DB.FamilyInstance), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +public sealed class FamilyInstanceTopLevelConverterToSpeckle : BaseTopLevelConverterToSpeckle { - private readonly ITypedConverter _elementConverter; - private readonly ITypedConverter _beamConversion; - private readonly ITypedConverter _columnConversion; - private readonly ITypedConverter _braceConversion; + private readonly ITypedConverter _elementConverter; + private readonly ITypedConverter _beamConversion; + private readonly ITypedConverter _columnConversion; + private readonly ITypedConverter _braceConversion; public FamilyInstanceTopLevelConverterToSpeckle( - ITypedConverter elementConverter, - ITypedConverter beamConversion, - ITypedConverter columnConversion, - ITypedConverter braceConversion + ITypedConverter elementConverter, + ITypedConverter beamConversion, + ITypedConverter columnConversion, + ITypedConverter braceConversion ) { _elementConverter = elementConverter; @@ -29,13 +27,13 @@ public FamilyInstanceTopLevelConverterToSpeckle( _braceConversion = braceConversion; } - public override Base Convert(IRevitFamilyInstance target) + public override Base Convert(DB.FamilyInstance target) { return target.StructuralType switch { - RevitStructuralType.Beam => _beamConversion.Convert(target), - RevitStructuralType.Column => _columnConversion.Convert(target), - RevitStructuralType.Brace => _braceConversion.Convert(target), + DB.Structure.StructuralType.Beam => _beamConversion.Convert(target), + DB.Structure.StructuralType.Column => _columnConversion.Convert(target), + DB.Structure.StructuralType.Brace => _braceConversion.Convert(target), // POC: return generic element conversion or throw? // diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/FloorTopLevelConverterToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/FloorTopLevelConverterToSpeckle.cs index eb292cae5b..13d0d3086f 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/FloorTopLevelConverterToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/FloorTopLevelConverterToSpeckle.cs @@ -1,33 +1,32 @@ using Objects; -using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; using Speckle.Converters.RevitShared.Helpers; +using Speckle.Converters.RevitShared.ToSpeckle; using Speckle.Core.Models; -using Speckle.Revit.Interfaces; -namespace Speckle.Converters.RevitShared.ToSpeckle; +namespace Speckle.Converters.Common; // POC: reminder - writing classes and creating interfaces is a bit like organising your space // if you have a structure for organising things, your interfaces, then finding your stuff, your classes & methods, becomes easy // having a lack of interfaces or large interfaces is a bit like lacking structure, when all of your stuff, your classes & methods // clould be anywhere or all in once place - rooting through box 274 for something you need, when said box has a miriad different // and unrelated items, is no fun. Plus when you need that item, you end up bringing out the whole box/ -[NameAndRankValue(nameof(IRevitFloor), 0)] -public class FloorTopLevelConverterToSpeckle : BaseTopLevelConverterToSpeckle +[NameAndRankValue(nameof(DB.Floor), 0)] +public class FloorTopLevelConverterToSpeckle : BaseTopLevelConverterToSpeckle { - private readonly ITypedConverter> _curveArrArrayConverter; - private readonly ITypedConverter _levelConverter; - private readonly IParameterValueExtractor _parameterValueExtractor; - private readonly IParameterObjectAssigner _parameterObjectAssigner; - private readonly IDisplayValueExtractor _displayValueExtractor; + private readonly ITypedConverter> _curveArrArrayConverter; + private readonly ITypedConverter _levelConverter; + private readonly ParameterValueExtractor _parameterValueExtractor; + private readonly ParameterObjectAssigner _parameterObjectAssigner; + private readonly DisplayValueExtractor _displayValueExtractor; private readonly ISlopeArrowExtractor _slopeArrowExtractor; public FloorTopLevelConverterToSpeckle( - ITypedConverter> curveArrArrayConverter, - ITypedConverter levelConverter, - IParameterValueExtractor parameterValueExtractor, - IParameterObjectAssigner parameterObjectAssigner, - IDisplayValueExtractor displayValueExtractor, + ITypedConverter> curveArrArrayConverter, + ITypedConverter levelConverter, + ParameterValueExtractor parameterValueExtractor, + ParameterObjectAssigner parameterObjectAssigner, + DisplayValueExtractor displayValueExtractor, ISlopeArrowExtractor slopeArrowExtractor ) { @@ -39,14 +38,14 @@ ISlopeArrowExtractor slopeArrowExtractor _slopeArrowExtractor = slopeArrowExtractor; } - public override SOBR.RevitFloor Convert(IRevitFloor target) + public override SOBR.RevitFloor Convert(DB.Floor target) { SOBR.RevitFloor speckleFloor = new(); - var sketch = target.Document.GetElement(target.SketchId).NotNull().ToSketch().NotNull(); + var sketch = (DB.Sketch)target.Document.GetElement(target.SketchId); List profiles = _curveArrArrayConverter.Convert(sketch.Profile); - IRevitElementType type = target.Document.GetElement(target.GetTypeId()).NotNull().ToType().NotNull(); + DB.ElementType type = (DB.ElementType)target.Document.GetElement(target.GetTypeId()); speckleFloor.family = type.FamilyName; speckleFloor.type = type.Name; @@ -62,13 +61,13 @@ public override SOBR.RevitFloor Convert(IRevitFloor target) speckleFloor.voids = profiles.Skip(1).ToList(); } - var level = _parameterValueExtractor.GetValueAsRevitLevel(target, RevitBuiltInParameter.LEVEL_PARAM); - speckleFloor.level = _levelConverter.Convert(level.NotNull()); + var level = _parameterValueExtractor.GetValueAsDocumentObject(target, DB.BuiltInParameter.LEVEL_PARAM); + speckleFloor.level = _levelConverter.Convert(level); speckleFloor.structural = - _parameterValueExtractor.GetValueAsBool(target, RevitBuiltInParameter.FLOOR_PARAM_IS_STRUCTURAL) ?? false; + _parameterValueExtractor.GetValueAsBool(target, DB.BuiltInParameter.FLOOR_PARAM_IS_STRUCTURAL) ?? false; double? slopeParam = null; - if (_parameterValueExtractor.TryGetValueAsDouble(target, RevitBuiltInParameter.ROOF_SLOPE, out var slope)) + if (_parameterValueExtractor.TryGetValueAsDouble(target, DB.BuiltInParameter.ROOF_SLOPE, out var slope)) { // Divide by 100 to convert from percentage to unitless ratio (rise over run) slopeParam = slope / 100d; @@ -84,10 +83,9 @@ public override SOBR.RevitFloor Convert(IRevitFloor target) return speckleFloor; } - private void TryAssignSlopeFromSlopeArrow(IRevitFloor target, SOBR.RevitFloor speckleFloor, double? slopeParam) + private void TryAssignSlopeFromSlopeArrow(DB.Floor target, SOBR.RevitFloor speckleFloor, double? slopeParam) { - var slopeArrow = _slopeArrowExtractor.GetSlopeArrow(target); - if (slopeArrow is null) + if (_slopeArrowExtractor.GetSlopeArrow(target) is not DB.ModelLine slopeArrow) { return; } diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/FootPrintRoofToSpeckleTopLevelConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/FootPrintRoofToSpeckleTopLevelConverter.cs index 78600db3ff..1c8e74bb04 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/FootPrintRoofToSpeckleTopLevelConverter.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/FootPrintRoofToSpeckleTopLevelConverter.cs @@ -1,33 +1,33 @@ -using Objects; +using Autodesk.Revit.DB; +using Objects; +using Objects.BuiltElements.Revit; using Objects.BuiltElements.Revit.RevitRoof; +using Objects.Geometry; using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; using Speckle.Converters.RevitShared.Extensions; using Speckle.Converters.RevitShared.Helpers; -using Speckle.Revit.Interfaces; namespace Speckle.Converters.RevitShared.ToSpeckle; -[NameAndRankValue(nameof(IRevitFootPrintRoof), 0)] +[NameAndRankValue(nameof(DB.FootPrintRoof), 0)] public class FootPrintRoofToSpeckleTopLevelConverter - : BaseTopLevelConverterToSpeckle + : BaseTopLevelConverterToSpeckle { - private readonly ITypedConverter _levelConverter; - private readonly ITypedConverter _modelCurveArrArrayConverter; - private readonly IParameterValueExtractor _parameterValueExtractor; - private readonly IDisplayValueExtractor _displayValueExtractor; - private readonly IHostedElementConversionToSpeckle _hostedElementConverter; - private readonly IParameterObjectAssigner _parameterObjectAssigner; - private readonly IRevitFilterFactory _revitFilterFactory; + private readonly ITypedConverter _levelConverter; + private readonly ITypedConverter _modelCurveArrArrayConverter; + private readonly ParameterValueExtractor _parameterValueExtractor; + private readonly DisplayValueExtractor _displayValueExtractor; + private readonly HostedElementConversionToSpeckle _hostedElementConverter; + private readonly ParameterObjectAssigner _parameterObjectAssigner; public FootPrintRoofToSpeckleTopLevelConverter( - ITypedConverter levelConverter, - ITypedConverter modelCurveArrArrayConverter, - IParameterValueExtractor parameterValueExtractor, - IDisplayValueExtractor displayValueExtractor, - IHostedElementConversionToSpeckle hostedElementConverter, - IParameterObjectAssigner parameterObjectAssigner, - IRevitFilterFactory revitFilterFactory + ITypedConverter levelConverter, + ITypedConverter modelCurveArrArrayConverter, + ParameterValueExtractor parameterValueExtractor, + DisplayValueExtractor displayValueExtractor, + HostedElementConversionToSpeckle hostedElementConverter, + ParameterObjectAssigner parameterObjectAssigner ) { _levelConverter = levelConverter; @@ -36,20 +36,25 @@ IRevitFilterFactory revitFilterFactory _displayValueExtractor = displayValueExtractor; _hostedElementConverter = hostedElementConverter; _parameterObjectAssigner = parameterObjectAssigner; - _revitFilterFactory = revitFilterFactory; } - public override RevitFootprintRoof Convert(IRevitFootPrintRoof target) + public override RevitFootprintRoof Convert(FootPrintRoof target) { - var baseLevel = _parameterValueExtractor.GetValueAsRevitLevel(target, RevitBuiltInParameter.ROOF_BASE_LEVEL_PARAM); + var baseLevel = _parameterValueExtractor.GetValueAsDocumentObject( + target, + DB.BuiltInParameter.ROOF_BASE_LEVEL_PARAM + ); // We don't currently validate the success of this TryGet, it is assumed some Roofs don't have a top-level. - IRevitLevel? topLevel; - _parameterValueExtractor.TryGetValueAsRevitLevel(target, RevitBuiltInParameter.ROOF_UPTO_LEVEL_PARAM, out topLevel); + _parameterValueExtractor.TryGetValueAsDocumentObject( + target, + DB.BuiltInParameter.ROOF_UPTO_LEVEL_PARAM, + out var topLevel + ); //POC: CNX-9403 can be null if the sides have different slopes. //We currently don't validate the success or failure of this TryGet as it's not necessary, but will be once we start the above ticket. - _parameterValueExtractor.TryGetValueAsDouble(target, RevitBuiltInParameter.ROOF_SLOPE, out var slope); + _parameterValueExtractor.TryGetValueAsDouble(target, DB.BuiltInParameter.ROOF_SLOPE, out var slope); RevitFootprintRoof speckleFootprintRoof = new() @@ -67,7 +72,7 @@ public override RevitFootprintRoof Convert(IRevitFootPrintRoof target) speckleFootprintRoof.outline = profiles.FirstOrDefault(); speckleFootprintRoof.voids = profiles.Skip(1).ToList(); - var elementType = target.Document.GetElement(target.GetTypeId()).NotNull().ToType().NotNull(); + var elementType = (ElementType)target.Document.GetElement(target.GetTypeId()); speckleFootprintRoof.type = elementType.Name; speckleFootprintRoof.family = elementType.FamilyName; @@ -76,7 +81,7 @@ public override RevitFootprintRoof Convert(IRevitFootPrintRoof target) _parameterObjectAssigner.AssignParametersToBase(target, speckleFootprintRoof); speckleFootprintRoof.displayValue = _displayValueExtractor.GetDisplayValue(target); speckleFootprintRoof.elements = _hostedElementConverter - .ConvertHostedElements(target.GetHostedElementIds(_revitFilterFactory)) + .ConvertHostedElements(target.GetHostedElementIds()) .ToList(); return speckleFootprintRoof; diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/HostedElementConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/HostedElementConversionToSpeckle.cs index b927329b7e..f9643119e0 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/HostedElementConversionToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/HostedElementConversionToSpeckle.cs @@ -1,7 +1,7 @@ -using Speckle.Converters.Common; +using Autodesk.Revit.DB; +using Speckle.Converters.Common; +using Speckle.Converters.RevitShared.Helpers; using Speckle.Core.Models; -using Speckle.InterfaceGenerator; -using Speckle.Revit.Interfaces; namespace Speckle.Converters.RevitShared.ToSpeckle; @@ -9,26 +9,22 @@ namespace Speckle.Converters.RevitShared.ToSpeckle; // opportunity to rethink or confirm hosted element handling? Should this be a connector responsibiliy? // No interfacing out however... // CNX-9414 Re-evaluate hosted element conversions -[GenerateAutoInterface] -public class HostedElementConversionToSpeckle : IHostedElementConversionToSpeckle +public class HostedElementConversionToSpeckle { private readonly IRootToSpeckleConverter _converter; - private readonly IConversionContextStack _contextStack; + private readonly IRevitConversionContextStack _contextStack; - public HostedElementConversionToSpeckle( - IRootToSpeckleConverter converter, - IConversionContextStack contextStack - ) + public HostedElementConversionToSpeckle(IRootToSpeckleConverter converter, IRevitConversionContextStack contextStack) { _converter = converter; _contextStack = contextStack; } - public IEnumerable ConvertHostedElements(IEnumerable hostedElementIds) + public IEnumerable ConvertHostedElements(IEnumerable hostedElementIds) { foreach (var elemId in hostedElementIds) { - IRevitElement element = _contextStack.Current.Document.GetElement(elemId).NotNull(); + Element element = _contextStack.Current.Document.GetElement(elemId); Base @base; try diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/ModelCurveToSpeckleTopLevelConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/ModelCurveToSpeckleTopLevelConverter.cs index f305468ece..240cbe4713 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/ModelCurveToSpeckleTopLevelConverter.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/ModelCurveToSpeckleTopLevelConverter.cs @@ -1,29 +1,28 @@ -using Objects; +using Objects; using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; -using Speckle.Revit.Interfaces; +using Speckle.Converters.RevitShared.Helpers; namespace Speckle.Converters.RevitShared.ToSpeckle; // POC: ModelCurve looks a bit bogus and we may wish to revise what that is and how it inherits // see https://spockle.atlassian.net/browse/CNX-9381 -[NameAndRankValue(nameof(IRevitModelCurve), 0)] -public class ModelCurveToSpeckleTopLevelConverter - : BaseTopLevelConverterToSpeckle +[NameAndRankValue(nameof(DB.ModelCurve), 0)] +public class ModelCurveToSpeckleTopLevelConverter : BaseTopLevelConverterToSpeckle { - private readonly ITypedConverter _curveConverter; - private readonly IConversionContextStack _conversionContext; + private readonly ITypedConverter _curveConverter; + private readonly IRevitConversionContextStack _conversionContext; public ModelCurveToSpeckleTopLevelConverter( - ITypedConverter curveConverter, - IConversionContextStack conversionContext + ITypedConverter curveConverter, + IRevitConversionContextStack conversionContext ) { _curveConverter = curveConverter; _conversionContext = conversionContext; } - public override SOBR.Curve.ModelCurve Convert(IRevitModelCurve target) + public override SOBR.Curve.ModelCurve Convert(DB.ModelCurve target) { var modelCurve = new SOBR.Curve.ModelCurve() { diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/RoofBaseToSpeckleTopLevelTopLevelConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/RoofBaseToSpeckleTopLevelTopLevelConverter.cs index 805671c0a7..77f9ce831c 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/RoofBaseToSpeckleTopLevelTopLevelConverter.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/RoofBaseToSpeckleTopLevelTopLevelConverter.cs @@ -1,45 +1,40 @@ -using Objects.BuiltElements.Revit.RevitRoof; +using Autodesk.Revit.DB; +using Objects.BuiltElements.Revit.RevitRoof; using Speckle.Converters.Common; using Speckle.Converters.RevitShared.Extensions; using Speckle.Converters.RevitShared.Helpers; -using Speckle.Revit.Interfaces; namespace Speckle.Converters.RevitShared.ToSpeckle; -[NameAndRankValue(nameof(IRevitRoofBase), 0)] +[NameAndRankValue(nameof(DB.RoofBase), 0)] internal sealed class RoofBaseToSpeckleTopLevelTopLevelConverter - : BaseTopLevelConverterToSpeckle + : BaseTopLevelConverterToSpeckle { - private readonly IDisplayValueExtractor _displayValueExtractor; - private readonly IHostedElementConversionToSpeckle _hostedElementConverter; - private readonly IParameterObjectAssigner _parameterObjectAssigner; - private readonly IRevitFilterFactory _revitFilterFactory; + private readonly DisplayValueExtractor _displayValueExtractor; + private readonly HostedElementConversionToSpeckle _hostedElementConverter; + private readonly ParameterObjectAssigner _parameterObjectAssigner; public RoofBaseToSpeckleTopLevelTopLevelConverter( - IDisplayValueExtractor displayValueExtractor, - IHostedElementConversionToSpeckle hostedElementConverter, - IParameterObjectAssigner parameterObjectAssigner, - IRevitFilterFactory revitFilterFactory + DisplayValueExtractor displayValueExtractor, + HostedElementConversionToSpeckle hostedElementConverter, + ParameterObjectAssigner parameterObjectAssigner ) { _displayValueExtractor = displayValueExtractor; _hostedElementConverter = hostedElementConverter; _parameterObjectAssigner = parameterObjectAssigner; - _revitFilterFactory = revitFilterFactory; } - public override RevitRoof Convert(IRevitRoofBase target) + public override RevitRoof Convert(RoofBase target) { RevitRoof revitRoof = new(); - var elementType = target.Document.GetElement(target.GetTypeId()).NotNull().ToType().NotNull(); + var elementType = (ElementType)target.Document.GetElement(target.GetTypeId()); revitRoof.type = elementType.Name; revitRoof.family = elementType.FamilyName; _parameterObjectAssigner.AssignParametersToBase(target, revitRoof); revitRoof.displayValue = _displayValueExtractor.GetDisplayValue(target); - revitRoof.elements = _hostedElementConverter - .ConvertHostedElements(target.GetHostedElementIds(_revitFilterFactory)) - .ToList(); + revitRoof.elements = _hostedElementConverter.ConvertHostedElements(target.GetHostedElementIds()).ToList(); return revitRoof; } diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/RoomTopLevelConverterToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/RoomTopLevelConverterToSpeckle.cs index 6baaa3d6aa..6e4e1f91cb 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/RoomTopLevelConverterToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/RoomTopLevelConverterToSpeckle.cs @@ -3,27 +3,26 @@ using Speckle.Converters.Common.Objects; using Speckle.Converters.RevitShared.Helpers; using Speckle.Core.Models; -using Speckle.Revit.Interfaces; namespace Speckle.Converters.RevitShared.ToSpeckle; -[NameAndRankValue(nameof(IRevitRoom), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class RoomTopLevelConverterToSpeckle : BaseTopLevelConverterToSpeckle +[NameAndRankValue(nameof(DBA.Room), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +public class RoomTopLevelConverterToSpeckle : BaseTopLevelConverterToSpeckle { - private readonly IDisplayValueExtractor _displayValueExtractor; - private readonly IParameterObjectAssigner _parameterObjectAssigner; - private readonly ITypedConverter _levelConverter; - private readonly IParameterValueExtractor _parameterValueExtractor; - private readonly ITypedConverter _locationConverter; - private readonly ITypedConverter, SOG.Polycurve> _boundarySegmentConverter; + private readonly DisplayValueExtractor _displayValueExtractor; + private readonly ParameterObjectAssigner _parameterObjectAssigner; + private readonly ITypedConverter _levelConverter; + private readonly ParameterValueExtractor _parameterValueExtractor; + private readonly ITypedConverter _locationConverter; + private readonly ITypedConverter, SOG.Polycurve> _boundarySegmentConverter; public RoomTopLevelConverterToSpeckle( - IDisplayValueExtractor displayValueExtractor, - IParameterObjectAssigner parameterObjectAssigner, - ITypedConverter levelConverter, - IParameterValueExtractor parameterValueExtractor, - ITypedConverter locationConverter, - ITypedConverter, SOG.Polycurve> boundarySegmentConverter + DisplayValueExtractor displayValueExtractor, + ParameterObjectAssigner parameterObjectAssigner, + ITypedConverter levelConverter, + ParameterValueExtractor parameterValueExtractor, + ITypedConverter locationConverter, + ITypedConverter, SOG.Polycurve> boundarySegmentConverter ) { _displayValueExtractor = displayValueExtractor; @@ -34,19 +33,19 @@ public RoomTopLevelConverterToSpeckle( _boundarySegmentConverter = boundarySegmentConverter; } - public override SOBE.Room Convert(IRevitRoom target) + public override SOBE.Room Convert(DBA.Room target) { var number = target.Number; - var name = _parameterValueExtractor.GetValueAsString(target, RevitBuiltInParameter.ROOM_NAME); - var area = _parameterValueExtractor.GetValueAsDouble(target, RevitBuiltInParameter.ROOM_AREA); + var name = _parameterValueExtractor.GetValueAsString(target, DB.BuiltInParameter.ROOM_NAME); + var area = _parameterValueExtractor.GetValueAsDouble(target, DB.BuiltInParameter.ROOM_AREA); var displayValue = _displayValueExtractor.GetDisplayValue(target); var basePoint = (SOG.Point)_locationConverter.Convert(target.Location); var level = _levelConverter.Convert(target.Level); var profiles = target - .GetBoundarySegments() - .Select(c => (ICurve)_boundarySegmentConverter.Convert(c.ToList())) + .GetBoundarySegments(new DB.SpatialElementBoundaryOptions()) + .Select(c => (ICurve)_boundarySegmentConverter.Convert(c)) .ToList(); var outline = profiles.First(); diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/TopographyTopLevelConverterToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/TopographyTopLevelConverterToSpeckle.cs index ce34b66376..eea4ea51c9 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/TopographyTopLevelConverterToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/TopographyTopLevelConverterToSpeckle.cs @@ -1,28 +1,27 @@ -using Speckle.Converters.Common; +using Speckle.Converters.Common; using Speckle.Converters.RevitShared.Helpers; -using Speckle.Revit.Interfaces; namespace Speckle.Converters.RevitShared.ToSpeckle; // POC: needs review feels, BIG, feels like it could be broken down.. // i.e. GetParams(), GetGeom()? feels like it's doing too much -[NameAndRankValue(nameof(IRevitTopographySurface), 0)] +[NameAndRankValue(nameof(DBA.TopographySurface), 0)] public class TopographyTopLevelConverterToSpeckle - : BaseTopLevelConverterToSpeckle + : BaseTopLevelConverterToSpeckle { - private readonly IDisplayValueExtractor _displayValueExtractor; - private readonly IParameterObjectAssigner _parameterObjectAssigner; + private readonly DisplayValueExtractor _displayValueExtractor; + private readonly ParameterObjectAssigner _parameterObjectAssigner; public TopographyTopLevelConverterToSpeckle( - IDisplayValueExtractor displayValueExtractor, - IParameterObjectAssigner parameterObjectAssigner + DisplayValueExtractor displayValueExtractor, + ParameterObjectAssigner parameterObjectAssigner ) { _displayValueExtractor = displayValueExtractor; _parameterObjectAssigner = parameterObjectAssigner; } - public override SOBR.RevitTopography Convert(IRevitTopographySurface target) + public override SOBR.RevitTopography Convert(DBA.TopographySurface target) { var speckleTopo = new SOBR.RevitTopography { diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/WallTopLevelConverterToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/WallTopLevelConverterToSpeckle.cs index e9a0dbafc1..8e0cce3ba9 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/WallTopLevelConverterToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/WallTopLevelConverterToSpeckle.cs @@ -6,35 +6,32 @@ using Speckle.Core.Models.Extensions; using Speckle.Converters.RevitShared.Extensions; using Objects.BuiltElements.Revit; -using Speckle.Revit.Interfaces; namespace Speckle.Converters.RevitShared.ToSpeckle; // POC: needs review feels, BIG, feels like it could be broken down.. // i.e. GetParams(), GetGeom()? feels like it's doing too much -[NameAndRankValue(nameof(IRevitWall), 0)] -public class WallTopLevelConverterToSpeckle : BaseTopLevelConverterToSpeckle +[NameAndRankValue(nameof(DB.Wall), 0)] +public class WallTopLevelConverterToSpeckle : BaseTopLevelConverterToSpeckle { - private readonly ITypedConverter _curveConverter; - private readonly ITypedConverter _levelConverter; - private readonly ITypedConverter> _curveArrArrayConverter; - private readonly IParameterValueExtractor _parameterValueExtractor; - private readonly IConversionContextStack _contextStack; - private readonly IDisplayValueExtractor _displayValueExtractor; - private readonly IParameterObjectAssigner _parameterObjectAssigner; + private readonly ITypedConverter _curveConverter; + private readonly ITypedConverter _levelConverter; + private readonly ITypedConverter> _curveArrArrayConverter; + private readonly ParameterValueExtractor _parameterValueExtractor; + private readonly IRevitConversionContextStack _contextStack; + private readonly DisplayValueExtractor _displayValueExtractor; + private readonly ParameterObjectAssigner _parameterObjectAssigner; private readonly IRootToSpeckleConverter _converter; - private readonly IRevitFilterFactory _revitFilterFactory; public WallTopLevelConverterToSpeckle( - ITypedConverter curveConverter, - ITypedConverter levelConverter, - ITypedConverter> curveArrArrayConverter, - IConversionContextStack contextStack, - IParameterValueExtractor parameterValueExtractor, - IDisplayValueExtractor displayValueExtractor, - IParameterObjectAssigner parameterObjectAssigner, - IRootToSpeckleConverter converter, - IRevitFilterFactory revitFilterFactory + ITypedConverter curveConverter, + ITypedConverter levelConverter, + ITypedConverter> curveArrArrayConverter, + IRevitConversionContextStack contextStack, + ParameterValueExtractor parameterValueExtractor, + DisplayValueExtractor displayValueExtractor, + ParameterObjectAssigner parameterObjectAssigner, + IRootToSpeckleConverter converter ) { _curveConverter = curveConverter; @@ -45,10 +42,9 @@ IRevitFilterFactory revitFilterFactory _displayValueExtractor = displayValueExtractor; _parameterObjectAssigner = parameterObjectAssigner; _converter = converter; - _revitFilterFactory = revitFilterFactory; } - public override SOBR.RevitWall Convert(IRevitWall target) + public override SOBR.RevitWall Convert(DB.Wall target) { SOBR.RevitWall speckleWall = new() { family = target.WallType.FamilyName.ToString(), type = target.WallType.Name }; @@ -61,10 +57,9 @@ public override SOBR.RevitWall Convert(IRevitWall target) return speckleWall; } - private void AssignSpecificParameters(IRevitWall target, RevitWall speckleWall) + private void AssignSpecificParameters(DB.Wall target, RevitWall speckleWall) { - var locationCurve = target.GetLocationAsLocationCurve(); - if (locationCurve is null) + if (target.Location is not DB.LocationCurve locationCurve) { throw new SpeckleConversionException( "Incorrect assumption was made that all Revit Wall location properties would be of type \"LocationCurve\"" @@ -73,41 +68,46 @@ private void AssignSpecificParameters(IRevitWall target, RevitWall speckleWall) speckleWall.baseLine = _curveConverter.Convert(locationCurve.Curve); - var level = _parameterValueExtractor.GetValueAsRevitLevel(target, RevitBuiltInParameter.WALL_BASE_CONSTRAINT); + var level = _parameterValueExtractor.GetValueAsDocumentObject( + target, + DB.BuiltInParameter.WALL_BASE_CONSTRAINT + ); speckleWall.level = _levelConverter.Convert(level); - var topLevel = _parameterValueExtractor.GetValueAsRevitLevel(target, RevitBuiltInParameter.WALL_BASE_CONSTRAINT); + var topLevel = _parameterValueExtractor.GetValueAsDocumentObject( + target, + DB.BuiltInParameter.WALL_BASE_CONSTRAINT + ); speckleWall.topLevel = _levelConverter.Convert(topLevel); // POC : what to do if these parameters are unset (instead of assigning default) _ = _parameterValueExtractor.TryGetValueAsDouble( target, - RevitBuiltInParameter.WALL_USER_HEIGHT_PARAM, + DB.BuiltInParameter.WALL_USER_HEIGHT_PARAM, out double? height ); speckleWall.height = height ?? 0; _ = _parameterValueExtractor.TryGetValueAsDouble( target, - RevitBuiltInParameter.WALL_BASE_OFFSET, + DB.BuiltInParameter.WALL_BASE_OFFSET, out double? baseOffset ); speckleWall.baseOffset = baseOffset ?? 0; _ = _parameterValueExtractor.TryGetValueAsDouble( target, - RevitBuiltInParameter.WALL_TOP_OFFSET, + DB.BuiltInParameter.WALL_TOP_OFFSET, out double? topOffset ); speckleWall.topOffset = topOffset ?? 0; speckleWall.structural = - _parameterValueExtractor.GetValueAsBool(target, RevitBuiltInParameter.WALL_STRUCTURAL_SIGNIFICANT) ?? false; + _parameterValueExtractor.GetValueAsBool(target, DB.BuiltInParameter.WALL_STRUCTURAL_SIGNIFICANT) ?? false; speckleWall.flipped = target.Flipped; } - private List GetChildElements(IRevitWall target) + private List GetChildElements(DB.Wall target) { List wallChildren = new(); - var grid = target.CurtainGrid; - if (grid is not null) + if (target.CurtainGrid is DB.CurtainGrid grid) { wallChildren.AddRange(ConvertElements(grid.GetMullionIds())); wallChildren.AddRange(ConvertElements(grid.GetPanelIds())); @@ -116,19 +116,19 @@ private List GetChildElements(IRevitWall target) { wallChildren.AddRange(ConvertElements(target.GetStackedWallMemberIds())); } - wallChildren.AddRange(ConvertElements(target.GetHostedElementIds(_revitFilterFactory))); + wallChildren.AddRange(ConvertElements(target.GetHostedElementIds())); return wallChildren; } - private IEnumerable ConvertElements(IEnumerable elementIds) + private IEnumerable ConvertElements(IEnumerable elementIds) { - foreach (IRevitElementId elementId in elementIds) + foreach (DB.ElementId elementId in elementIds) { - yield return _converter.Convert(_contextStack.Current.Document.GetElement(elementId).NotNull()); + yield return _converter.Convert(_contextStack.Current.Document.GetElement(elementId)); } } - private void AssignDisplayValue(IRevitWall target, RevitWall speckleWall) + private void AssignDisplayValue(DB.Wall target, RevitWall speckleWall) { if (target.CurtainGrid is null) { @@ -159,9 +159,9 @@ private void AssignHostedElements(SOBR.RevitWall speckleWall, List hostedO } } - private void AssignVoids(IRevitWall target, SOBR.RevitWall speckleWall) + private void AssignVoids(DB.Wall target, SOBR.RevitWall speckleWall) { - IRevitCurveArrArray? profile = target.Document.GetElement(target.SketchId)?.ToSketch()?.Profile; + DB.CurveArrArray? profile = ((DB.Sketch)target.Document.GetElement(target.SketchId))?.Profile; if (profile is null) { return; diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/RhinoConverterModule.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/RhinoConverterModule.cs index 6c315439fe..9117848c90 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/RhinoConverterModule.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/RhinoConverterModule.cs @@ -1,7 +1,7 @@ using Speckle.Autofac.DependencyInjection; using Speckle.Converters.Common; +using Rhino; using Speckle.Converters.Common.DependencyInjection; -using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.DependencyInjection; @@ -9,9 +9,8 @@ public class RhinoConverterModule : ISpeckleModule { public void Load(SpeckleContainerBuilder builder) { - builder.AddConverterCommon(); + builder.AddConverterCommon(); // single stack per conversion - builder.AddScoped, RhinoConversionContextStack>(); - builder.AddScoped(); + builder.AddScoped, RhinoConversionContextStack>(); } } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/RhinoRootElementProvider.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/RhinoRootElementProvider.cs deleted file mode 100644 index 58a13d8107..0000000000 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/RhinoRootElementProvider.cs +++ /dev/null @@ -1,9 +0,0 @@ -using Speckle.Converters.Common; -using Speckle.Rhino7.Interfaces; - -namespace Speckle.Converters.Rhino7.DependencyInjection; - -public class RhinoRootElementProvider : IRootElementProvider -{ - public Type GetRootType() => typeof(IRhinoObject); -} diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/Speckle.Converters.Rhino7.DependencyInjection.csproj b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/Speckle.Converters.Rhino7.DependencyInjection.csproj index a9a52748e3..78870eeb41 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/Speckle.Converters.Rhino7.DependencyInjection.csproj +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/Speckle.Converters.Rhino7.DependencyInjection.csproj @@ -11,6 +11,6 @@ - + diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/packages.lock.json b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/packages.lock.json index 7e98fae831..a897641f42 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/packages.lock.json +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/packages.lock.json @@ -18,18 +18,18 @@ "resolved": "1.14.1", "contentHash": "mOOmFYwad3MIOL14VCjj02LljyF1GNw1wP0YVlxtcPvqdxjGGMNdNJJxHptlry3MOd8b40Flm8RPOM8JOlN2sQ==" }, + "RhinoCommon": { + "type": "Direct", + "requested": "[7.13.21348.13001, )", + "resolved": "7.13.21348.13001", + "contentHash": "JQdaNw61ddBqIe08E9O4N/grwrN1hjDHcYW7tWylwCZyFR7SepoCD4NS+6LN6+oSQhNbhLi9Bf+hQOFYFdRAEA==" + }, "Speckle.InterfaceGenerator": { "type": "Direct", "requested": "[0.9.5, )", "resolved": "0.9.5", "contentHash": "oU/L7pN1R7q8KkbrpQ3WJnHirPHqn+9DEA7asOcUiggV5dzVg1A/VYs7GOSusD24njxXh03tE3a2oTLOjt3cVg==" }, - "Speckle.Rhino7.Interfaces": { - "type": "Direct", - "requested": "[0.1.1-preview.0.28, )", - "resolved": "0.1.1-preview.0.28", - "contentHash": "TcbfXlRMnQRat1JodgW+YW5FflTYem1GGo9DtKA+6iAuVaYagN5dxsrM5LE6M3pCnEV9rkEQOjFo7sgnnbo4mw==" - }, "GraphQL.Client": { "type": "Transitive", "resolved": "6.0.0", @@ -216,6 +216,11 @@ "resolved": "13.0.2", "contentHash": "g1BejUZwax5PRfL6xHgLEK23sqHWOgOj9hE7RvfRRlN00AGt8GnPYt8HedSK7UB3HiRW8zCA9Pn0iiYxCK24BA==" }, + "Speckle.Revit2023.Interfaces": { + "type": "Transitive", + "resolved": "0.1.1-preview.0.24", + "contentHash": "BSVpOUJc9g6ISrw8GxvtkglTlITpHEDYNOhxv1ZPbckBsI0yO36JiphhQV4q57ERqD9PpCozUJkVhlCaxWeS6A==" + }, "SQLitePCLRaw.bundle_e_sqlite3": { "type": "Transitive", "resolved": "2.1.4", @@ -377,8 +382,8 @@ "speckle.converters.rhino7": { "type": "Project", "dependencies": { - "Speckle.Converters.Common": "[2.0.999-local, )", - "Speckle.Rhino7.Interfaces": "[0.1.1-preview.0.28, )" + "RhinoCommon": "[7.13.21348.13001, )", + "Speckle.Converters.Common": "[2.0.999-local, )" } }, "Microsoft.Extensions.Logging.Abstractions": { diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/GlobalUsings.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/GlobalUsings.cs index c88d8e3105..baa44c188e 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/GlobalUsings.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/GlobalUsings.cs @@ -1,2 +1,3 @@ +global using RG = Rhino.Geometry; global using SOG = Objects.Geometry; global using SOP = Objects.Primitive; diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/RhinoConversionContextStack.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/RhinoConversionContextStack.cs index 799f32b350..79ac2f77a4 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/RhinoConversionContextStack.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/RhinoConversionContextStack.cs @@ -1,6 +1,6 @@ using System.Diagnostics.CodeAnalysis; +using Rhino; using Speckle.Converters.Common; -using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7; @@ -10,11 +10,8 @@ namespace Speckle.Converters.Rhino7; "CA1711:Identifiers should not have incorrect suffix", Justification = "Name ends in Stack but it is in fact a Stack, just not inheriting from `System.Collections.Stack`" )] -public class RhinoConversionContextStack : ConversionContextStack +public class RhinoConversionContextStack : ConversionContextStack { - public RhinoConversionContextStack( - IRhinoDocFactory rhinoDocFactory, - IHostToSpeckleUnitConverter unitConverter - ) - : base(rhinoDocFactory.ActiveDoc(), rhinoDocFactory.ActiveDoc().ModelUnitSystem, unitConverter) { } + public RhinoConversionContextStack(IHostToSpeckleUnitConverter unitConverter) + : base(RhinoDoc.ActiveDoc, RhinoDoc.ActiveDoc.ModelUnitSystem, unitConverter) { } } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/RhinoToSpeckleUnitConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/RhinoToSpeckleUnitConverter.cs index f7953bc383..4f4f9c77e4 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/RhinoToSpeckleUnitConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/RhinoToSpeckleUnitConverter.cs @@ -1,29 +1,29 @@ -using Speckle.Converters.Common; +using Rhino; +using Speckle.Converters.Common; using Speckle.Core.Kits; -using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7; -public class RhinoToSpeckleUnitConverter : IHostToSpeckleUnitConverter +public class RhinoToSpeckleUnitConverter : IHostToSpeckleUnitConverter { - private readonly Dictionary _unitMapping = new(); + private readonly Dictionary _unitMapping = new(); public RhinoToSpeckleUnitConverter() { // POC: CNX-9269 Add unit test to ensure these don't change. - _unitMapping[RhinoUnitSystem.None] = Units.Meters; - _unitMapping[RhinoUnitSystem.Millimeters] = Units.Millimeters; - _unitMapping[RhinoUnitSystem.Centimeters] = Units.Centimeters; - _unitMapping[RhinoUnitSystem.Meters] = Units.Meters; - _unitMapping[RhinoUnitSystem.Kilometers] = Units.Kilometers; - _unitMapping[RhinoUnitSystem.Inches] = Units.Inches; - _unitMapping[RhinoUnitSystem.Feet] = Units.Feet; - _unitMapping[RhinoUnitSystem.Yards] = Units.Yards; - _unitMapping[RhinoUnitSystem.Miles] = Units.Miles; - _unitMapping[RhinoUnitSystem.Unset] = Units.Meters; + _unitMapping[UnitSystem.None] = Units.Meters; + _unitMapping[UnitSystem.Millimeters] = Units.Millimeters; + _unitMapping[UnitSystem.Centimeters] = Units.Centimeters; + _unitMapping[UnitSystem.Meters] = Units.Meters; + _unitMapping[UnitSystem.Kilometers] = Units.Kilometers; + _unitMapping[UnitSystem.Inches] = Units.Inches; + _unitMapping[UnitSystem.Feet] = Units.Feet; + _unitMapping[UnitSystem.Yards] = Units.Yards; + _unitMapping[UnitSystem.Miles] = Units.Miles; + _unitMapping[UnitSystem.Unset] = Units.Meters; } - public string ConvertOrThrow(RhinoUnitSystem hostUnit) + public string ConvertOrThrow(UnitSystem hostUnit) { if (_unitMapping.TryGetValue(hostUnit, out string value)) { diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Speckle.Converters.Rhino7.csproj b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Speckle.Converters.Rhino7.csproj index 206a1eecf0..bf1bdbd6de 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Speckle.Converters.Rhino7.csproj +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Speckle.Converters.Rhino7.csproj @@ -3,11 +3,12 @@ net48 + - + - + diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/SpeckleToHostGeometryBaseTopLevelConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/SpeckleToHostGeometryBaseTopLevelConverter.cs index 3d5e09c1a0..75ff2162c2 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/SpeckleToHostGeometryBaseTopLevelConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/SpeckleToHostGeometryBaseTopLevelConverter.cs @@ -1,28 +1,25 @@ -using Speckle.Converters.Common; +using Rhino; +using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; using Speckle.Core.Kits; using Speckle.Core.Models; -using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7; public abstract class SpeckleToHostGeometryBaseTopLevelConverter : IToHostTopLevelConverter where TIn : Base - where TOut : IRhinoGeometryBase + where TOut : RG.GeometryBase { - protected IConversionContextStack ContextStack { get; private set; } + protected IConversionContextStack ContextStack { get; private set; } private readonly ITypedConverter _geometryBaseConverter; - private readonly IRhinoTransformFactory _transformFactory; protected SpeckleToHostGeometryBaseTopLevelConverter( - IConversionContextStack contextStack, - ITypedConverter geometryBaseConverter, - IRhinoTransformFactory transformFactory + IConversionContextStack contextStack, + ITypedConverter geometryBaseConverter ) { ContextStack = contextStack; _geometryBaseConverter = geometryBaseConverter; - _transformFactory = transformFactory; } public object Convert(Base target) @@ -38,7 +35,7 @@ public object Convert(Base target) if (castedBase["units"] is string units) { var scaleFactor = Units.GetConversionFactor(units, ContextStack.Current.SpeckleUnits); - var scale = _transformFactory.Scale(_transformFactory.Origin, scaleFactor); + var scale = RG.Transform.Scale(RG.Point3d.Origin, scaleFactor); result.Transform(scale); } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/ArcToHostConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/ArcToHostConverter.cs index 63d745dec6..0068c38ef2 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/ArcToHostConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/ArcToHostConverter.cs @@ -1,38 +1,34 @@ using Speckle.Converters.Common.Objects; -using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToHost.Raw; /// /// Converts a SpeckleArcRaw object to a Rhino.Geometry.Arc object or Rhino.Geometry.ArcCurve object. /// -public class ArcToHostConverter : ITypedConverter, ITypedConverter +public class ArcToHostConverter : ITypedConverter, ITypedConverter { - private readonly ITypedConverter _pointConverter; - private readonly ITypedConverter _intervalConverter; - private readonly IRhinoArcFactory _rhinoArcFactory; + private readonly ITypedConverter _pointConverter; + private readonly ITypedConverter _intervalConverter; public ArcToHostConverter( - ITypedConverter pointConverter, - ITypedConverter intervalConverter, - IRhinoArcFactory rhinoArcFactory + ITypedConverter pointConverter, + ITypedConverter intervalConverter ) { _pointConverter = pointConverter; this._intervalConverter = intervalConverter; - _rhinoArcFactory = rhinoArcFactory; } /// - /// Converts a object to a object. + /// Converts a object to a object. /// /// The Speckle Arc object to convert. - /// The converted object. + /// The converted object. /// ⚠️ This conversion does NOT perform scaling. ///
⚠️ This method does not preserve the original curve domain
- public IRhinoArc Convert(SOG.Arc target) + public RG.Arc Convert(SOG.Arc target) { - var rhinoArc = _rhinoArcFactory.Create( + var rhinoArc = new RG.Arc( _pointConverter.Convert(target.startPoint), _pointConverter.Convert(target.midPoint), _pointConverter.Convert(target.endPoint) @@ -43,16 +39,16 @@ public IRhinoArc Convert(SOG.Arc target) // POC: CNX-9271 Potential code-smell by directly implementing the interface. We should discuss this further but // since we're using the interfaces instead of the direct type, this may not be an issue. /// - /// Converts a object to a object. + /// Converts a object to a object. /// /// The object to convert. - /// The converted object. + /// The converted object. /// ⚠️ This conversion does NOT perform scaling. - ///
⚠️ Converting to instead of preserves the domain of the curve.
- IRhinoArcCurve ITypedConverter.Convert(SOG.Arc target) + ///
⚠️ Converting to instead of preserves the domain of the curve.
+ RG.ArcCurve ITypedConverter.Convert(SOG.Arc target) { var rhinoArc = Convert(target); - var arcCurve = _rhinoArcFactory.Create(rhinoArc, _intervalConverter.Convert(target.domain)); + var arcCurve = new RG.ArcCurve(rhinoArc) { Domain = _intervalConverter.Convert(target.domain) }; return arcCurve; } } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/BrepToHostConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/BrepToHostConverter.cs index c579d736a1..db94e2f7f0 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/BrepToHostConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/BrepToHostConverter.cs @@ -1,26 +1,24 @@ using Objects; +using Rhino; using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; -using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToHost.Raw; -public class BrepToHostConverter : ITypedConverter +public class BrepToHostConverter : ITypedConverter { - private readonly IConversionContextStack _contextStack; - private readonly ITypedConverter _curveConverter; - private readonly ITypedConverter _surfaceConverter; - private readonly ITypedConverter _pointConverter; - private readonly ITypedConverter _intervalConverter; - private readonly IRhinoBrepFactory _rhinoBrepFactory; + private readonly IConversionContextStack _contextStack; + private readonly ITypedConverter _curveConverter; + private readonly ITypedConverter _surfaceConverter; + private readonly ITypedConverter _pointConverter; + private readonly ITypedConverter _intervalConverter; public BrepToHostConverter( - IConversionContextStack contextStack, - ITypedConverter curveConverter, - ITypedConverter surfaceConverter, - ITypedConverter pointConverter, - ITypedConverter intervalConverter, - IRhinoBrepFactory rhinoBrepFactory + IConversionContextStack contextStack, + ITypedConverter curveConverter, + ITypedConverter surfaceConverter, + ITypedConverter pointConverter, + ITypedConverter intervalConverter ) { _contextStack = contextStack; @@ -28,11 +26,10 @@ IRhinoBrepFactory rhinoBrepFactory _surfaceConverter = surfaceConverter; _pointConverter = pointConverter; _intervalConverter = intervalConverter; - _rhinoBrepFactory = rhinoBrepFactory; } /// - /// Converts a Speckle to a Rhino . + /// Converts a Speckle to a Rhino . /// /// /// This method converts a Speckle Brep object to its equivalent Rhino Brep representation. @@ -43,11 +40,11 @@ IRhinoBrepFactory rhinoBrepFactory /// The Speckle Brep object to be converted. /// The equivalent Rhino Brep object. /// ⚠️ This conversion does NOT perform scaling. - public IRhinoBrep Convert(SOG.Brep target) + public RG.Brep Convert(SOG.Brep target) { var tolerance = _contextStack.Current.Document.ModelAbsoluteTolerance; - var rhinoBrep = _rhinoBrepFactory.Create(); + var rhinoBrep = new RG.Brep(); // Geometry goes in first, always. Order doesn't matter. target.Curve3D.ForEach(curve => rhinoBrep.AddEdgeCurve(_curveConverter.Convert(curve))); @@ -73,21 +70,21 @@ public IRhinoBrep Convert(SOG.Brep target) } /// - /// Converts a Speckle to a Rhino and adds it to the provided . + /// Converts a Speckle to a Rhino and adds it to the provided . /// /// /// A consists of individual trims. There are special cases for singular trims and trims with defined edge indices. /// Note that edge cases in Brep structures are not fully covered by this method and should be reviewed for robustness improvement. - /// This operation alters the state of the provided by adding a new loop. + /// This operation alters the state of the provided by adding a new loop. /// - /// The where the new loop will be added. + /// The where the new loop will be added. /// The to be converted and added to . /// The tolerance factor used when adding trims and setting their tolerances. - private void ConvertSpeckleBrepLoop(IRhinoBrep rhinoBrep, SOG.BrepLoop speckleLoop, double tol) + private void ConvertSpeckleBrepLoop(RG.Brep rhinoBrep, SOG.BrepLoop speckleLoop, double tol) { var f = rhinoBrep.Faces[speckleLoop.FaceIndex]; - rhinoBrep.Loops.Add((RhinoBrepLoopType)speckleLoop.Type, f); + rhinoBrep.Loops.Add((RG.BrepLoopType)speckleLoop.Type, f); // POC: This works but it doesn't fully cover all Brep edge cases and could be the cause of some of our failed Rhino->Rhino breps. // We should check Rhino.Inside as they have similar code structure. @@ -95,7 +92,7 @@ private void ConvertSpeckleBrepLoop(IRhinoBrep rhinoBrep, SOG.BrepLoop speckleLo .ToList() .ForEach(trim => { - IRhinoBrepTrim rhTrim; + RG.BrepTrim rhTrim; if (trim.EdgeIndex != -1) { rhTrim = rhinoBrep.Trims.Add( @@ -110,7 +107,7 @@ private void ConvertSpeckleBrepLoop(IRhinoBrep rhinoBrep, SOG.BrepLoop speckleLo rhTrim = rhinoBrep.Trims.AddSingularTrim( rhinoBrep.Vertices[trim.EndIndex], rhinoBrep.Loops[trim.LoopIndex], - (RhinoIsoStatus)trim.IsoStatus, + (RG.IsoStatus)trim.IsoStatus, trim.CurveIndex ); } @@ -119,8 +116,8 @@ private void ConvertSpeckleBrepLoop(IRhinoBrep rhinoBrep, SOG.BrepLoop speckleLo rhTrim = rhinoBrep.Trims.Add(trim.IsReversed, rhinoBrep.Loops[trim.LoopIndex], trim.CurveIndex); } - rhTrim.IsoStatus = (RhinoIsoStatus)trim.IsoStatus; - rhTrim.TrimType = (RhinoBrepTrimType)trim.TrimType; + rhTrim.IsoStatus = (RG.IsoStatus)trim.IsoStatus; + rhTrim.TrimType = (RG.BrepTrimType)trim.TrimType; rhTrim.SetTolerances(tol, tol); }); } @@ -136,7 +133,7 @@ private void ConvertSpeckleBrepLoop(IRhinoBrep rhinoBrep, SOG.BrepLoop speckleLo /// is untrimmed, and hence added directly as a reference to the curve it points to. /// If the edge is trimmed, it is added based on vertices and subdomain using the supplied tolerance /// - private void ConvertSpeckleBrepEdge(IRhinoBrep rhinoBrep, SOG.BrepEdge speckleEdge, double tolerance) + private void ConvertSpeckleBrepEdge(RG.Brep rhinoBrep, SOG.BrepEdge speckleEdge, double tolerance) { if ( speckleEdge.Domain == null @@ -161,11 +158,11 @@ private void ConvertSpeckleBrepEdge(IRhinoBrep rhinoBrep, SOG.BrepEdge speckleEd } /// - /// Converts a into a and adds it to the provided . + /// Converts a into a and adds it to the provided . /// /// The Rhinoceros brep geometry to which the converted face is added. /// The Speckle brep face to be converted and added. - private void ConvertSpeckleBrepFace(IRhinoBrep rhinoBrep, SOG.BrepFace speckleFace) + private void ConvertSpeckleBrepFace(RG.Brep rhinoBrep, SOG.BrepFace speckleFace) { var f = rhinoBrep.Faces.Add(speckleFace.SurfaceIndex); f.OrientationIsReversed = speckleFace.OrientationReversed; diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/CircleToHostConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/CircleToHostConverter.cs index 1fbdfd4a2e..1431d3fc1a 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/CircleToHostConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/CircleToHostConverter.cs @@ -1,52 +1,46 @@ using Speckle.Converters.Common.Objects; -using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToHost.Raw; /// -/// This class is responsible for converting a into and objects. +/// This class is responsible for converting a into and objects. /// Implements the interface, -/// providing implementation for to and conversion. +/// providing implementation for to and conversion. /// -public class CircleToHostConverter - : ITypedConverter, - ITypedConverter +public class CircleToHostConverter : ITypedConverter, ITypedConverter { - private readonly ITypedConverter _planeConverter; - private readonly ITypedConverter _intervalConverter; - private readonly IRhinoCircleFactory _rhinoCircleFactory; + private readonly ITypedConverter _planeConverter; + private readonly ITypedConverter _intervalConverter; /// /// Constructs a new instance of the class. /// /// - /// An implementation of used to convert into . + /// An implementation of used to convert into . /// /// - /// An implementation of used to convert into . + /// An implementation of used to convert into . /// public CircleToHostConverter( - ITypedConverter intervalConverter, - ITypedConverter planeConverter, - IRhinoCircleFactory rhinoCircleFactory + ITypedConverter intervalConverter, + ITypedConverter planeConverter ) { _intervalConverter = intervalConverter; _planeConverter = planeConverter; - _rhinoCircleFactory = rhinoCircleFactory; } /// - /// Converts the given object into a object. + /// Converts the given object into a object. /// /// The object to convert. - /// The resulting object. + /// The resulting object. /// /// Thrown when the radius of the given object is null. /// /// ⚠️ This conversion does NOT perform scaling. - ///
⚠️ This conversion does not preserve the curve domain. If you need it preserved you must request a conversion to conversion instead
- public IRhinoCircle Convert(SOG.Circle target) + ///
⚠️ This conversion does not preserve the curve domain. If you need it preserved you must request a conversion to conversion instead
+ public RG.Circle Convert(SOG.Circle target) { if (target.radius == null) { @@ -56,9 +50,9 @@ public IRhinoCircle Convert(SOG.Circle target) var plane = _planeConverter.Convert(target.plane); var radius = target.radius.Value; - return _rhinoCircleFactory.Create(plane, radius); + return new RG.Circle(plane, radius); } - IRhinoArcCurve ITypedConverter.Convert(SOG.Circle target) => - _rhinoCircleFactory.Create(Convert(target), _intervalConverter.Convert(target.domain)); + RG.ArcCurve ITypedConverter.Convert(SOG.Circle target) => + new(Convert(target)) { Domain = _intervalConverter.Convert(target.domain) }; } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/CurveToHostConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/CurveToHostConverter.cs index d96d413258..a61425dc2a 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/CurveToHostConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/CurveToHostConverter.cs @@ -1,29 +1,28 @@ using Objects; using Speckle.Converters.Common.Objects; -using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToHost.Raw; -public class CurveToHostConverter : ITypedConverter +public class CurveToHostConverter : ITypedConverter { - private readonly ITypedConverter _lineConverter; - private readonly ITypedConverter _arcConverter; - private readonly ITypedConverter _ellipseConverter; - private readonly ITypedConverter _spiralConverter; - private readonly ITypedConverter _circleConverter; - private readonly ITypedConverter _polylineConverter; - private readonly ITypedConverter _polyCurveConverter; - private readonly ITypedConverter _nurbsCurveConverter; + private readonly ITypedConverter _lineConverter; + private readonly ITypedConverter _arcConverter; + private readonly ITypedConverter _ellipseConverter; + private readonly ITypedConverter _spiralConverter; + private readonly ITypedConverter _circleConverter; + private readonly ITypedConverter _polylineConverter; + private readonly ITypedConverter _polyCurveConverter; + private readonly ITypedConverter _nurbsCurveConverter; public CurveToHostConverter( - ITypedConverter lineConverter, - ITypedConverter arcConverter, - ITypedConverter ellipseConverter, - ITypedConverter spiralConverter, - ITypedConverter circleConverter, - ITypedConverter polylineConverter, - ITypedConverter polyCurveConverter, - ITypedConverter nurbsCurveConverter + ITypedConverter lineConverter, + ITypedConverter arcConverter, + ITypedConverter ellipseConverter, + ITypedConverter spiralConverter, + ITypedConverter circleConverter, + ITypedConverter polylineConverter, + ITypedConverter polyCurveConverter, + ITypedConverter nurbsCurveConverter ) { _lineConverter = lineConverter; @@ -37,13 +36,13 @@ public CurveToHostConverter( } /// - /// Converts a given ICurve object to an IRhinoCurve object. + /// Converts a given ICurve object to an RG.Curve object. /// /// The ICurve object to convert. - /// The converted IRhinoCurve object. + /// The converted RG.Curve object. /// Thrown when the conversion is not supported for the given type of curve. /// ⚠️ This conversion does NOT perform scaling. - public IRhinoCurve Convert(ICurve target) => + public RG.Curve Convert(ICurve target) => target switch { SOG.Line line => _lineConverter.Convert(line), diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/EllipseToHostConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/EllipseToHostConverter.cs index c45fa5c3ab..74f309a61f 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/EllipseToHostConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/EllipseToHostConverter.cs @@ -1,57 +1,49 @@ using Speckle.Converters.Common.Objects; -using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToHost.Raw; public class EllipseToHostConverter - : ITypedConverter, - ITypedConverter + : ITypedConverter, + ITypedConverter { - private readonly ITypedConverter _planeConverter; - private readonly ITypedConverter _intervalConverter; - private readonly IRhinoEllipseFactory _rhinoEllipseFactory; + private readonly ITypedConverter _planeConverter; + private readonly ITypedConverter _intervalConverter; public EllipseToHostConverter( - ITypedConverter planeConverter, - ITypedConverter intervalConverter, - IRhinoEllipseFactory rhinoEllipseFactory + ITypedConverter planeConverter, + ITypedConverter intervalConverter ) { _planeConverter = planeConverter; _intervalConverter = intervalConverter; - _rhinoEllipseFactory = rhinoEllipseFactory; } /// - /// Converts an instance of to an while preserving geometric properties. + /// Converts an instance of to an while preserving geometric properties. /// /// The instance to be converted. - /// The resulting after conversion. + /// The resulting after conversion. /// Thrown when or properties are null. /// ⚠️ This conversion does NOT perform scaling. - ///
⚠️ This conversion does not preserve the curve domain. If you need it preserved you must request a conversion to conversion instead
- public IRhinoEllipse Convert(SOG.Ellipse target) + ///
⚠️ This conversion does not preserve the curve domain. If you need it preserved you must request a conversion to conversion instead
+ public RG.Ellipse Convert(SOG.Ellipse target) { if (!target.firstRadius.HasValue || !target.secondRadius.HasValue) { throw new InvalidOperationException($"Ellipses cannot have null radii"); } - return _rhinoEllipseFactory.Create( - _planeConverter.Convert(target.plane), - target.firstRadius.Value, - target.secondRadius.Value - ); + return new RG.Ellipse(_planeConverter.Convert(target.plane), target.firstRadius.Value, target.secondRadius.Value); } /// - /// Converts the provided into a representation. + /// Converts the provided into a representation. /// /// The to convert. /// - /// A that represents the provided . + /// A that represents the provided . /// - IRhinoNurbsCurve ITypedConverter.Convert(SOG.Ellipse target) + RG.NurbsCurve ITypedConverter.Convert(SOG.Ellipse target) { var rhinoEllipse = Convert(target); var rhinoNurbsEllipse = rhinoEllipse.ToNurbsCurve(); diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/FlatPointListToHostConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/FlatPointListToHostConverter.cs index 97c2786b44..f0363a387d 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/FlatPointListToHostConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/FlatPointListToHostConverter.cs @@ -1,21 +1,14 @@ -using Speckle.Converters.Common.Objects; +using Rhino.Collections; +using Speckle.Converters.Common.Objects; using Speckle.Core.Logging; -using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToHost.Raw; /// /// Converts a flat list of raw double values to a Point3dList. /// -public class FlatPointListToHostConverter : ITypedConverter, IRhinoPoint3dList> +public class FlatPointListToHostConverter : ITypedConverter, Point3dList> { - private readonly IRhinoPointFactory _rhinoPointFactory; - - public FlatPointListToHostConverter(IRhinoPointFactory rhinoPointFactory) - { - _rhinoPointFactory = rhinoPointFactory; - } - /// /// Converts a flat list of raw double values to a Point3dList. /// @@ -26,20 +19,20 @@ public FlatPointListToHostConverter(IRhinoPointFactory rhinoPointFactory) /// with the numbers being coordinates of each point in the format {x1, y1, z1, x2, y2, z2, ..., xN, yN, zN} /// /// Throws when the input list count is not a multiple of 3. - public IRhinoPoint3dList Convert(IReadOnlyList target) + public Point3dList Convert(IReadOnlyList target) { if (target.Count % 3 != 0) { throw new SpeckleException("Array malformed: length%3 != 0."); } - var points = new List(target.Count / 3); + var points = new List(target.Count / 3); for (int i = 2; i < target.Count; i += 3) { - points.Add(_rhinoPointFactory.Create(target[i - 2], target[i - 1], target[i])); + points.Add(new RG.Point3d(target[i - 2], target[i - 1], target[i])); } - return _rhinoPointFactory.Create(points); + return new Point3dList(points); } } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/IntervalToHostConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/IntervalToHostConverter.cs index ddaa476970..f201283ebd 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/IntervalToHostConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/IntervalToHostConverter.cs @@ -1,17 +1,9 @@ using Speckle.Converters.Common.Objects; -using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToHost.Raw; -public class IntervalToHostConverter : ITypedConverter +public class IntervalToHostConverter : ITypedConverter { - private readonly IRhinoIntervalFactory _rhinoIntervalFactory; - - public IntervalToHostConverter(IRhinoIntervalFactory rhinoIntervalFactory) - { - _rhinoIntervalFactory = rhinoIntervalFactory; - } - /// /// Converts a Speckle Interval object to a Rhino.Geometry.Interval object. /// @@ -19,13 +11,13 @@ public IntervalToHostConverter(IRhinoIntervalFactory rhinoIntervalFactory) /// The converted Rhino.Geometry.Interval object. /// Thrown when the start or end value of the Interval is null. /// ⚠️ This conversion does NOT perform scaling. - public IRhinoInterval Convert(SOP.Interval target) + public RG.Interval Convert(SOP.Interval target) { if (!target.start.HasValue || !target.end.HasValue) // POC: CNX-9272 Interval start and end being nullable makes no sense. { throw new ArgumentException("Interval start/end cannot be null"); } - return _rhinoIntervalFactory.Create(target.start.Value, target.end.Value); + return new RG.Interval(target.start.Value, target.end.Value); } } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/LineToHostConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/LineToHostConverter.cs index a66222299f..c549e96741 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/LineToHostConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/LineToHostConverter.cs @@ -1,20 +1,14 @@ using Speckle.Converters.Common.Objects; -using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToHost.Raw; -public class LineToHostConverter : ITypedConverter, ITypedConverter +public class LineToHostConverter : ITypedConverter, ITypedConverter { - private readonly ITypedConverter _pointConverter; - private readonly IRhinoLineFactory _rhinoLineFactory; + private readonly ITypedConverter _pointConverter; - public LineToHostConverter( - ITypedConverter pointConverter, - IRhinoLineFactory rhinoLineFactory - ) + public LineToHostConverter(ITypedConverter pointConverter) { _pointConverter = pointConverter; - _rhinoLineFactory = rhinoLineFactory; } /// @@ -26,16 +20,15 @@ IRhinoLineFactory rhinoLineFactory /// ///
⚠️ This conversion does not preserve the curve domain. /// If you need it preserved you must request a conversion to - /// conversion instead + /// conversion instead ///
- public IRhinoLine Convert(SOG.Line target) => - _rhinoLineFactory.Create(_pointConverter.Convert(target.start), _pointConverter.Convert(target.end)); + public RG.Line Convert(SOG.Line target) => + new(_pointConverter.Convert(target.start), _pointConverter.Convert(target.end)); /// /// Converts a Speckle Line object to a Rhino LineCurve object. /// /// The Speckle Line object to convert. /// Returns the resulting Rhino LineCurve object. - IRhinoLineCurve ITypedConverter.Convert(SOG.Line target) => - _rhinoLineFactory.Create(Convert(target)); + RG.LineCurve ITypedConverter.Convert(SOG.Line target) => new(Convert(target)); } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/MeshToHostConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/MeshToHostConverter.cs index e24adb8ad1..d3917dafd3 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/MeshToHostConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/MeshToHostConverter.cs @@ -1,28 +1,17 @@ using System.Drawing; using Objects.Utils; +using Rhino.Collections; using Speckle.Converters.Common.Objects; -using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToHost.Raw; -public class MeshToHostConverter : ITypedConverter +public class MeshToHostConverter : ITypedConverter { - private readonly ITypedConverter, IRhinoPoint3dList> _pointListConverter; - private readonly IRhinoMeshFactory _rhinoMeshFactory; - private readonly IRhinoNgonFactory _rhinoNgonFactory; - private readonly IRhinoPointFactory _rhinoPointFactory; - - public MeshToHostConverter( - ITypedConverter, IRhinoPoint3dList> pointListConverter, - IRhinoMeshFactory rhinoMeshFactory, - IRhinoNgonFactory rhinoNgonFactory, - IRhinoPointFactory rhinoPointFactory - ) + private readonly ITypedConverter, Point3dList> _pointListConverter; + + public MeshToHostConverter(ITypedConverter, Point3dList> pointListConverter) { _pointListConverter = pointListConverter; - _rhinoMeshFactory = rhinoMeshFactory; - _rhinoNgonFactory = rhinoNgonFactory; - _rhinoPointFactory = rhinoPointFactory; } /// @@ -31,11 +20,11 @@ IRhinoPointFactory rhinoPointFactory /// The Speckle mesh object to convert. /// A Rhino mesh object converted from the Speckle mesh. /// ⚠️ This conversion does NOT perform scaling. - public IRhinoMesh Convert(SOG.Mesh target) + public RG.Mesh Convert(SOG.Mesh target) { target.AlignVerticesWithTexCoordsByIndex(); - IRhinoMesh m = _rhinoMeshFactory.Create(); + RG.Mesh m = new(); var vertices = _pointListConverter.Convert(target.vertices); var colors = target.colors.Select(Color.FromArgb).ToArray(); @@ -54,7 +43,7 @@ public IRhinoMesh Convert(SOG.Mesh target) // POC: CNX-9274 We should abstract this into the `Mesh` class, or some utility class adjacent to it // All converters need to do this so it's going to be a source of repetition // and it is directly tied to how we serialise the data in the mesh. - private void AssignMeshFaces(SOG.Mesh target, IRhinoMesh m) + private void AssignMeshFaces(SOG.Mesh target, RG.Mesh m) { int i = 0; while (i < target.faces.Count) @@ -70,12 +59,14 @@ private void AssignMeshFaces(SOG.Mesh target, IRhinoMesh m) if (n == 3) { // triangle - m.Faces.AddFace(target.faces[i + 1], target.faces[i + 2], target.faces[i + 3]); + m.Faces.AddFace(new RG.MeshFace(target.faces[i + 1], target.faces[i + 2], target.faces[i + 3])); } else if (n == 4) { // quad - m.Faces.AddFace(target.faces[i + 1], target.faces[i + 2], target.faces[i + 3], target.faces[i + 4]); + m.Faces.AddFace( + new RG.MeshFace(target.faces[i + 1], target.faces[i + 2], target.faces[i + 3], target.faces[i + 4]) + ); } else { @@ -85,10 +76,11 @@ private void AssignMeshFaces(SOG.Mesh target, IRhinoMesh m) var faceIndices = new List(triangles.Count); for (int t = 0; t < triangles.Count; t += 3) { - faceIndices.Add(m.Faces.AddFace(triangles[t], triangles[t + 1], triangles[t + 2])); + var face = new RG.MeshFace(triangles[t], triangles[t + 1], triangles[t + 2]); + faceIndices.Add(m.Faces.AddFace(face)); } - IRhinoMeshNgon ngon = _rhinoNgonFactory.Create(target.faces.GetRange(i + 1, n), faceIndices); + RG.MeshNgon ngon = RG.MeshNgon.Create(target.faces.GetRange(i + 1, n), faceIndices); m.Ngons.AddNgon(ngon); } @@ -97,13 +89,13 @@ private void AssignMeshFaces(SOG.Mesh target, IRhinoMesh m) m.Faces.CullDegenerateFaces(); } - private void AssignTextureCoordinates(SOG.Mesh target, IRhinoMesh m) + private void AssignTextureCoordinates(SOG.Mesh target, RG.Mesh m) { - var textureCoordinates = new IRhinoPoint2f[target.TextureCoordinatesCount]; + var textureCoordinates = new RG.Point2f[target.TextureCoordinatesCount]; for (int ti = 0; ti < target.TextureCoordinatesCount; ti++) { var (u, v) = target.GetTextureCoordinate(ti); - textureCoordinates[ti] = _rhinoPointFactory.Create(u, v); + textureCoordinates[ti] = new RG.Point2f(u, v); } m.TextureCoordinates.SetTextureCoordinates(textureCoordinates); } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/NurbsCurveToHostConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/NurbsCurveToHostConverter.cs index 9e2ee516f4..9f9bf52811 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/NurbsCurveToHostConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/NurbsCurveToHostConverter.cs @@ -1,24 +1,15 @@ using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; -using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToHost.Raw; -public class NurbsCurveToHostConverter : ITypedConverter +public class NurbsCurveToHostConverter : ITypedConverter { - private readonly IRhinoPointFactory _rhinoPointFactory; - private readonly IRhinoCurveFactory _rhinoCurveFactory; - private readonly ITypedConverter _intervalConverter; + private readonly ITypedConverter _intervalConverter; - public NurbsCurveToHostConverter( - ITypedConverter intervalConverter, - IRhinoCurveFactory rhinoCurveFactory, - IRhinoPointFactory rhinoPointFactory - ) + public NurbsCurveToHostConverter(ITypedConverter intervalConverter) { _intervalConverter = intervalConverter; - _rhinoCurveFactory = rhinoCurveFactory; - _rhinoPointFactory = rhinoPointFactory; } /// @@ -28,14 +19,14 @@ IRhinoPointFactory rhinoPointFactory /// The converted Rhino NurbsCurve object. /// Thrown when the conversion fails. /// ⚠️ This conversion does NOT perform scaling. - public IRhinoNurbsCurve Convert(SOG.Curve target) + public RG.NurbsCurve Convert(SOG.Curve target) { - IRhinoNurbsCurve nurbsCurve = _rhinoCurveFactory.Create(target.degree, target.points.Count / 3); + RG.NurbsCurve nurbsCurve = new(target.degree, target.points.Count / 3); // Hyper optimised curve control point conversion for (int i = 2, j = 0; i < target.points.Count; i += 3, j++) { - var pt = _rhinoPointFactory.Create(target.points[i - 2], target.points[i - 1], target.points[i]); // Skip the point converter for performance + var pt = new RG.Point3d(target.points[i - 2], target.points[i - 1], target.points[i]); // Skip the point converter for performance nurbsCurve.Points.SetPoint(j, pt, target.weights[j]); } @@ -46,11 +37,11 @@ public IRhinoNurbsCurve Convert(SOG.Curve target) { if (extraKnots == 2) { - nurbsCurve.Knots.SetKnot(j, target.knots[j + 1]); + nurbsCurve.Knots[j] = target.knots[j + 1]; } else { - nurbsCurve.Knots.SetKnot(j, target.knots[j]); + nurbsCurve.Knots[j] = target.knots[j]; } } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/PlaneToHostConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/PlaneToHostConverter.cs index 4b18fac738..49e10ab69e 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/PlaneToHostConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/PlaneToHostConverter.cs @@ -1,23 +1,19 @@ using Speckle.Converters.Common.Objects; -using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToHost.Raw; -public class PlaneToHostConverter : ITypedConverter +public class PlaneToHostConverter : ITypedConverter { - private readonly ITypedConverter _pointConverter; - private readonly ITypedConverter _vectorConverter; - private readonly IRhinoPlaneFactory _rhinoPlaneFactory; + private readonly ITypedConverter _pointConverter; + private readonly ITypedConverter _vectorConverter; public PlaneToHostConverter( - ITypedConverter pointConverter, - ITypedConverter vectorConverter, - IRhinoPlaneFactory rhinoPlaneFactory + ITypedConverter pointConverter, + ITypedConverter vectorConverter ) { _pointConverter = pointConverter; _vectorConverter = vectorConverter; - _rhinoPlaneFactory = rhinoPlaneFactory; } /// @@ -26,8 +22,8 @@ IRhinoPlaneFactory rhinoPlaneFactory /// The Speckle Plane object to be converted. /// The converted Rhino Plane object. /// ⚠️ This conversion does NOT perform scaling. - public IRhinoPlane Convert(SOG.Plane target) => - _rhinoPlaneFactory.Create( + public RG.Plane Convert(SOG.Plane target) => + new( _pointConverter.Convert(target.origin), _vectorConverter.Convert(target.xdir), _vectorConverter.Convert(target.ydir) diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/PointCloudToHostConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/PointCloudToHostConverter.cs index f4a67b8d8d..a6d749b15c 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/PointCloudToHostConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/PointCloudToHostConverter.cs @@ -1,21 +1,16 @@ using System.Drawing; +using Rhino.Collections; using Speckle.Converters.Common.Objects; -using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToHost.Raw; -public class PointCloudToHostConverter : ITypedConverter +public class PointCloudToHostConverter : ITypedConverter { - private readonly ITypedConverter, IRhinoPoint3dList> _pointListConverter; - private readonly IRhinoPointCloudFactory _rhinoPointCloudFactory; + private readonly ITypedConverter, Point3dList> _pointListConverter; - public PointCloudToHostConverter( - ITypedConverter, IRhinoPoint3dList> pointListConverter, - IRhinoPointCloudFactory rhinoPointCloudFactory - ) + public PointCloudToHostConverter(ITypedConverter, Point3dList> pointListConverter) { _pointListConverter = pointListConverter; - _rhinoPointCloudFactory = rhinoPointCloudFactory; } /// @@ -24,10 +19,10 @@ IRhinoPointCloudFactory rhinoPointCloudFactory /// The raw Speckle Pointcloud object to convert. /// The converted Rhino PointCloud object. /// ⚠️ This conversion does NOT perform scaling. - public IRhinoPointCloud Convert(SOG.Pointcloud target) + public RG.PointCloud Convert(SOG.Pointcloud target) { var rhinoPoints = _pointListConverter.Convert(target.points); - var rhinoPointCloud = _rhinoPointCloudFactory.Create(rhinoPoints); + var rhinoPointCloud = new RG.PointCloud(rhinoPoints); if (target.colors.Count == rhinoPoints.Count) { diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/PointToHostConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/PointToHostConverter.cs index 35938f8ad4..8ce40bcb59 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/PointToHostConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/PointToHostConverter.cs @@ -1,24 +1,16 @@ using Speckle.Converters.Common.Objects; -using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToHost.Raw; -public class PointToHostConverter : ITypedConverter, ITypedConverter +public class PointToHostConverter : ITypedConverter, ITypedConverter { - private readonly IRhinoPointFactory _rhinoPointFactory; - - public PointToHostConverter(IRhinoPointFactory rhinoPointFactory) - { - _rhinoPointFactory = rhinoPointFactory; - } - /// /// Converts a Speckle Point object to a Rhino Point3d object. /// /// The Speckle Point object to convert. /// The converted Rhino Point3d object. /// ⚠️ This conversion does NOT perform scaling. - public IRhinoPoint3d Convert(SOG.Point target) => _rhinoPointFactory.Create(target.x, target.y, target.z); + public RG.Point3d Convert(SOG.Point target) => new(target.x, target.y, target.z); /// /// Converts a Speckle Point object to a Rhino Point object. @@ -26,6 +18,5 @@ public PointToHostConverter(IRhinoPointFactory rhinoPointFactory) /// The Speckle Point object to convert. /// The converted Rhino Point object. /// ⚠️ This conversion does NOT perform scaling. - IRhinoPoint ITypedConverter.Convert(SOG.Point target) => - _rhinoPointFactory.Create(Convert(target)); + RG.Point ITypedConverter.Convert(SOG.Point target) => new(Convert(target)); } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/PolyCurveToHostConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/PolyCurveToHostConverter.cs index 6a2655ed48..3f35905090 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/PolyCurveToHostConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/PolyCurveToHostConverter.cs @@ -2,24 +2,18 @@ using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; using Speckle.Core.Kits; -using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToHost.Raw; -public class PolyCurveToHostConverter : ITypedConverter +public class PolyCurveToHostConverter : ITypedConverter { - public ITypedConverter? CurveConverter { get; set; } // POC: CNX-9311 Circular dependency injected by the container using property. + public ITypedConverter? CurveConverter { get; set; } // POC: CNX-9311 Circular dependency injected by the container using property. - private readonly ITypedConverter _intervalConverter; - private readonly IRhinoCurveFactory _rhinoCurveFactory; + private readonly ITypedConverter _intervalConverter; - public PolyCurveToHostConverter( - ITypedConverter intervalConverter, - IRhinoCurveFactory rhinoCurveFactory - ) + public PolyCurveToHostConverter(ITypedConverter intervalConverter) { _intervalConverter = intervalConverter; - _rhinoCurveFactory = rhinoCurveFactory; } /// @@ -28,14 +22,13 @@ IRhinoCurveFactory rhinoCurveFactory /// The SpecklePolyCurve object to convert. /// The converted Rhino PolyCurve object. /// ⚠️ This conversion does NOT perform scaling. - public IRhinoPolyCurve Convert(SOG.Polycurve target) + public RG.PolyCurve Convert(SOG.Polycurve target) { - IRhinoPolyCurve result = _rhinoCurveFactory.Create(); - var converter = CurveConverter.NotNull(); + RG.PolyCurve result = new(); foreach (var segment in target.segments) { - var childCurve = converter.Convert(segment); + var childCurve = CurveConverter.NotNull().Convert(segment); bool success = result.AppendSegment(childCurve); if (!success) { diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/PolylineToHostConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/PolylineToHostConverter.cs index b803a07943..5abe48fed5 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/PolylineToHostConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/PolylineToHostConverter.cs @@ -1,25 +1,22 @@ -using Speckle.Converters.Common.Objects; -using Speckle.Rhino7.Interfaces; +using Rhino.Collections; +using Speckle.Converters.Common.Objects; namespace Speckle.Converters.Rhino7.ToHost.Raw; public class PolylineToHostConverter - : ITypedConverter, - ITypedConverter + : ITypedConverter, + ITypedConverter { - private readonly ITypedConverter, IRhinoPoint3dList> _pointListConverter; - private readonly ITypedConverter _intervalConverter; - private readonly IRhinoLineFactory _rhinoLineFactory; + private readonly ITypedConverter, Point3dList> _pointListConverter; + private readonly ITypedConverter _intervalConverter; public PolylineToHostConverter( - ITypedConverter, IRhinoPoint3dList> pointListConverter, - ITypedConverter intervalConverter, - IRhinoLineFactory rhinoLineFactory + ITypedConverter, Point3dList> pointListConverter, + ITypedConverter intervalConverter ) { _pointListConverter = pointListConverter; _intervalConverter = intervalConverter; - _rhinoLineFactory = rhinoLineFactory; } /// @@ -31,9 +28,9 @@ IRhinoLineFactory rhinoLineFactory /// ///
⚠️ This conversion does not preserve the curve domain. /// If you need it preserved you must request a conversion to - /// conversion instead + /// conversion instead ///
- public IRhinoPolyline Convert(SOG.Polyline target) + public RG.Polyline Convert(SOG.Polyline target) { var points = _pointListConverter.Convert(target.value); @@ -42,7 +39,7 @@ public IRhinoPolyline Convert(SOG.Polyline target) points.Add(points[0]); } - var poly = _rhinoLineFactory.Create(points); + var poly = new RG.Polyline(points); return poly; } @@ -55,7 +52,7 @@ public IRhinoPolyline Convert(SOG.Polyline target) /// The Speckle polyline object to be converted. /// The converted Rhino Polyline object. /// ⚠️ This conversion does NOT perform scaling. - IRhinoPolylineCurve ITypedConverter.Convert(SOG.Polyline target) + RG.PolylineCurve ITypedConverter.Convert(SOG.Polyline target) { var poly = Convert(target).ToPolylineCurve(); poly.Domain = _intervalConverter.Convert(target.domain); diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpiralToHostConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpiralToHostConverter.cs index c3cc3532ce..cb7f5a8745 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpiralToHostConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpiralToHostConverter.cs @@ -1,16 +1,15 @@ using Speckle.Converters.Common.Objects; -using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToHost.Raw; -public class SpiralToHostConverter : ITypedConverter +public class SpiralToHostConverter : ITypedConverter { - private readonly ITypedConverter _polylineConverter; - private readonly ITypedConverter _intervalConverter; + private readonly ITypedConverter _polylineConverter; + private readonly ITypedConverter _intervalConverter; public SpiralToHostConverter( - ITypedConverter polylineConverter, - ITypedConverter intervalConverter + ITypedConverter polylineConverter, + ITypedConverter intervalConverter ) { _polylineConverter = polylineConverter; @@ -23,7 +22,7 @@ public SpiralToHostConverter( /// The Speckle Spiral object to be converted. /// A Rhino PolylineCurve object. /// ⚠️ This conversion does NOT perform scaling. - public IRhinoPolylineCurve Convert(SOG.Spiral target) + public RG.PolylineCurve Convert(SOG.Spiral target) { var result = _polylineConverter.Convert(target.displayValue); result.Domain = _intervalConverter.Convert(target.domain); diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SurfaceToHostConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SurfaceToHostConverter.cs index 46689761a8..91da44ec59 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SurfaceToHostConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SurfaceToHostConverter.cs @@ -1,29 +1,21 @@ using Speckle.Converters.Common.Objects; -using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToHost.Raw; -public class SurfaceToHostConverter : ITypedConverter +public class SurfaceToHostConverter : ITypedConverter { - private readonly IRhinoSurfaceFactory _rhinoSurfaceFactory; - - public SurfaceToHostConverter(IRhinoSurfaceFactory rhinoSurfaceFactory) - { - _rhinoSurfaceFactory = rhinoSurfaceFactory; - } - /// /// Converts a raw Speckle surface to a Rhino NURBS surface. /// /// The raw Speckle surface to convert. /// The converted Rhino NURBS surface. /// ⚠️ This conversion does NOT perform scaling. - public IRhinoNurbsSurface Convert(SOG.Surface target) + public RG.NurbsSurface Convert(SOG.Surface target) { // Create rhino surface var points = target.GetControlPoints().ToList(); - var result = _rhinoSurfaceFactory.Create( + var result = RG.NurbsSurface.Create( 3, target.rational, target.degreeU + 1, @@ -36,13 +28,13 @@ public IRhinoNurbsSurface Convert(SOG.Surface target) var correctUKnots = GetCorrectKnots(target.knotsU, target.countU, target.degreeU); for (int i = 0; i < correctUKnots.Count; i++) { - result.KnotsU.SetKnot(i, correctUKnots[i]); + result.KnotsU[i] = correctUKnots[i]; } var correctVKnots = GetCorrectKnots(target.knotsV, target.countV, target.degreeV); for (int i = 0; i < correctVKnots.Count; i++) { - result.KnotsV.SetKnot(i, correctVKnots[i]); + result.KnotsV[i] = correctVKnots[i]; } // Set control points diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/VectorToHostConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/VectorToHostConverter.cs index 85ff17692c..77e017f0fd 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/VectorToHostConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/VectorToHostConverter.cs @@ -1,22 +1,14 @@ using Speckle.Converters.Common.Objects; -using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToHost.Raw; -public class VectorToHostConverter : ITypedConverter +public class VectorToHostConverter : ITypedConverter { - private readonly IRhinoVectorFactory _rhinoVectorFactory; - - public VectorToHostConverter(IRhinoVectorFactory rhinoVectorFactory) - { - _rhinoVectorFactory = rhinoVectorFactory; - } - /// /// Converts a Speckle.Vector object to a Rhino Vector3d object. /// /// The Speckle.Vector to be converted. /// The converted Rhino Vector3d object. /// ⚠️ This conversion does NOT perform scaling. - public IRhinoVector3d Convert(SOG.Vector target) => _rhinoVectorFactory.Create(target.x, target.y, target.z); + public RG.Vector3d Convert(SOG.Vector target) => new(target.x, target.y, target.z); } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/ArcToHostTopLevelConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/ArcToHostTopLevelConverter.cs index ca8b4938bd..12c4420914 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/ArcToHostTopLevelConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/ArcToHostTopLevelConverter.cs @@ -1,16 +1,15 @@ -using Speckle.Converters.Common; +using Rhino; +using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; -using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToHost.TopLevel; [NameAndRankValue(nameof(SOG.Arc), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class ArcToHostTopLevelConverter : SpeckleToHostGeometryBaseTopLevelConverter +public class ArcToHostTopLevelConverter : SpeckleToHostGeometryBaseTopLevelConverter { public ArcToHostTopLevelConverter( - IConversionContextStack contextStack, - ITypedConverter geometryBaseConverter, - IRhinoTransformFactory rhinoTransformFactory + IConversionContextStack contextStack, + ITypedConverter geometryBaseConverter ) - : base(contextStack, geometryBaseConverter, rhinoTransformFactory) { } + : base(contextStack, geometryBaseConverter) { } } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/BrepToHostTopLevelConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/BrepToHostTopLevelConverter.cs index 1c8706bd99..6ca70d3ad1 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/BrepToHostTopLevelConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/BrepToHostTopLevelConverter.cs @@ -1,16 +1,15 @@ -using Speckle.Converters.Common; +using Rhino; +using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; -using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToHost.TopLevel; [NameAndRankValue(nameof(SOG.Brep), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class BrepToHostTopLevelConverter : SpeckleToHostGeometryBaseTopLevelConverter +public class BrepToHostTopLevelConverter : SpeckleToHostGeometryBaseTopLevelConverter { public BrepToHostTopLevelConverter( - IConversionContextStack contextStack, - ITypedConverter geometryBaseConverter, - IRhinoTransformFactory rhinoTransformFactory + IConversionContextStack contextStack, + ITypedConverter geometryBaseConverter ) - : base(contextStack, geometryBaseConverter, rhinoTransformFactory) { } + : base(contextStack, geometryBaseConverter) { } } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/CircleToHostTopLevelConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/CircleToHostTopLevelConverter.cs index 942854b10b..1493120e57 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/CircleToHostTopLevelConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/CircleToHostTopLevelConverter.cs @@ -1,16 +1,15 @@ -using Speckle.Converters.Common; +using Rhino; +using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; -using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToHost.TopLevel; [NameAndRankValue(nameof(SOG.Circle), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class CircleToHostTopLevelConverter : SpeckleToHostGeometryBaseTopLevelConverter +public class CircleToHostTopLevelConverter : SpeckleToHostGeometryBaseTopLevelConverter { public CircleToHostTopLevelConverter( - IConversionContextStack contextStack, - ITypedConverter geometryBaseConverter, - IRhinoTransformFactory rhinoTransformFactory + IConversionContextStack contextStack, + ITypedConverter geometryBaseConverter ) - : base(contextStack, geometryBaseConverter, rhinoTransformFactory) { } + : base(contextStack, geometryBaseConverter) { } } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/EllipseToHostTopLevelConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/EllipseToHostTopLevelConverter.cs index dbc35c205b..e6a4b03a41 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/EllipseToHostTopLevelConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/EllipseToHostTopLevelConverter.cs @@ -1,16 +1,15 @@ -using Speckle.Converters.Common; +using Rhino; +using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; -using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToHost.TopLevel; [NameAndRankValue(nameof(SOG.Ellipse), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class EllipseToHostTopLevelConverter : SpeckleToHostGeometryBaseTopLevelConverter +public class EllipseToHostTopLevelConverter : SpeckleToHostGeometryBaseTopLevelConverter { public EllipseToHostTopLevelConverter( - IConversionContextStack contextStack, - ITypedConverter geometryBaseConverter, - IRhinoTransformFactory rhinoTransformFactory + IConversionContextStack contextStack, + ITypedConverter geometryBaseConverter ) - : base(contextStack, geometryBaseConverter, rhinoTransformFactory) { } + : base(contextStack, geometryBaseConverter) { } } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/FallbackToHostTopLevelConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/FallbackToHostTopLevelConverter.cs index 34c5a989ae..811433890c 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/FallbackToHostTopLevelConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/FallbackToHostTopLevelConverter.cs @@ -1,45 +1,42 @@ -using Speckle.Converters.Common; +using Rhino; +using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; using Speckle.Core.Kits; using Speckle.Core.Models; -using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToHost.TopLevel; [NameAndRankValue(nameof(DisplayableObject), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] public class FallbackToHostTopLevelConverter : IToHostTopLevelConverter, - ITypedConverter> + ITypedConverter> { - private readonly ITypedConverter _lineConverter; - private readonly ITypedConverter _polylineConverter; - private readonly ITypedConverter _meshConverter; - private readonly IConversionContextStack _contextStack; - private readonly IRhinoTransformFactory _rhinoTransformFactory; + private readonly ITypedConverter _lineConverter; + private readonly ITypedConverter _polylineConverter; + private readonly ITypedConverter _meshConverter; + private readonly IConversionContextStack _contextStack; public FallbackToHostTopLevelConverter( - ITypedConverter lineConverter, - ITypedConverter polylineConverter, - ITypedConverter meshConverter, - IConversionContextStack contextStack, - IRhinoTransformFactory rhinoTransformFactory + ITypedConverter lineConverter, + ITypedConverter polylineConverter, + ITypedConverter meshConverter, + IConversionContextStack contextStack ) { _lineConverter = lineConverter; _polylineConverter = polylineConverter; _meshConverter = meshConverter; _contextStack = contextStack; - _rhinoTransformFactory = rhinoTransformFactory; } public object Convert(Base target) => Convert((DisplayableObject)target); - public List Convert(DisplayableObject target) + public List Convert(DisplayableObject target) { - var result = new List(); + var result = new List(); foreach (var item in target.displayValue) { - IRhinoGeometryBase x = item switch + RG.GeometryBase x = item switch { SOG.Line line => _lineConverter.Convert(line), SOG.Polyline polyline => _polylineConverter.Convert(polyline), @@ -53,7 +50,7 @@ public List Convert(DisplayableObject target) return result; } - private IRhinoTransform GetUnitsTransform(Base speckleObject) + private RG.Transform GetUnitsTransform(Base speckleObject) { /* * POC: CNX-9270 Looking at a simpler, more performant way of doing unit scaling on `ToNative` @@ -63,10 +60,10 @@ private IRhinoTransform GetUnitsTransform(Base speckleObject) if (speckleObject["units"] is string units) { var scaleFactor = Units.GetConversionFactor(units, _contextStack.Current.SpeckleUnits); - var scale = _rhinoTransformFactory.Scale(_rhinoTransformFactory.Origin, scaleFactor); + var scale = RG.Transform.Scale(RG.Point3d.Origin, scaleFactor); return scale; } - return _rhinoTransformFactory.Identity; + return RG.Transform.Identity; } } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/LineToHostTopLevelConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/LineToHostTopLevelConverter.cs index 8767a91e06..5a64a3ebab 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/LineToHostTopLevelConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/LineToHostTopLevelConverter.cs @@ -1,16 +1,15 @@ -using Speckle.Converters.Common; +using Rhino; +using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; -using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToHost.TopLevel; [NameAndRankValue(nameof(SOG.Line), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class LineToHostTopLevelConverter : SpeckleToHostGeometryBaseTopLevelConverter +public class LineToHostTopLevelConverter : SpeckleToHostGeometryBaseTopLevelConverter { public LineToHostTopLevelConverter( - IConversionContextStack contextStack, - ITypedConverter geometryBaseConverter, - IRhinoTransformFactory rhinoTransformFactory + IConversionContextStack contextStack, + ITypedConverter geometryBaseConverter ) - : base(contextStack, geometryBaseConverter, rhinoTransformFactory) { } + : base(contextStack, geometryBaseConverter) { } } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/MeshToHostTopLevelConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/MeshToHostTopLevelConverter.cs index 6cdacc4288..c7d047df3b 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/MeshToHostTopLevelConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/MeshToHostTopLevelConverter.cs @@ -1,16 +1,15 @@ -using Speckle.Converters.Common; +using Rhino; +using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; -using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToHost.TopLevel; [NameAndRankValue(nameof(SOG.Mesh), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class MeshToHostTopLevelConverter : SpeckleToHostGeometryBaseTopLevelConverter +public class MeshToHostTopLevelConverter : SpeckleToHostGeometryBaseTopLevelConverter { public MeshToHostTopLevelConverter( - IConversionContextStack contextStack, - ITypedConverter geometryBaseConverter, - IRhinoTransformFactory rhinoTransformFactory + IConversionContextStack contextStack, + ITypedConverter geometryBaseConverter ) - : base(contextStack, geometryBaseConverter, rhinoTransformFactory) { } + : base(contextStack, geometryBaseConverter) { } } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/NurbsCurveToHostTopLevelConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/NurbsCurveToHostTopLevelConverter.cs index 19201d066a..987b46161f 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/NurbsCurveToHostTopLevelConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/NurbsCurveToHostTopLevelConverter.cs @@ -1,16 +1,15 @@ -using Speckle.Converters.Common; +using Rhino; +using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; -using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToHost.TopLevel; [NameAndRankValue(nameof(SOG.Curve), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class NurbsCurveToHostTopLevelConverter : SpeckleToHostGeometryBaseTopLevelConverter +public class NurbsCurveToHostTopLevelConverter : SpeckleToHostGeometryBaseTopLevelConverter { public NurbsCurveToHostTopLevelConverter( - IConversionContextStack contextStack, - ITypedConverter geometryBaseConverter, - IRhinoTransformFactory rhinoTransformFactory + IConversionContextStack contextStack, + ITypedConverter geometryBaseConverter ) - : base(contextStack, geometryBaseConverter, rhinoTransformFactory) { } + : base(contextStack, geometryBaseConverter) { } } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/PointCloudToHostTopLevelConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/PointCloudToHostTopLevelConverter.cs index c4e199b3d4..51a2613e90 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/PointCloudToHostTopLevelConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/PointCloudToHostTopLevelConverter.cs @@ -1,17 +1,16 @@ -using Speckle.Converters.Common; +using Rhino; +using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; -using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToHost.TopLevel; [NameAndRankValue(nameof(SOG.Pointcloud), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] public class PointCloudToHostTopLevelConverter - : SpeckleToHostGeometryBaseTopLevelConverter + : SpeckleToHostGeometryBaseTopLevelConverter { public PointCloudToHostTopLevelConverter( - IConversionContextStack contextStack, - ITypedConverter geometryBaseConverter, - IRhinoTransformFactory rhinoTransformFactory + IConversionContextStack contextStack, + ITypedConverter geometryBaseConverter ) - : base(contextStack, geometryBaseConverter, rhinoTransformFactory) { } + : base(contextStack, geometryBaseConverter) { } } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/PointToHostTopLevelConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/PointToHostTopLevelConverter.cs index 6922cf12ad..de10053ce9 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/PointToHostTopLevelConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/PointToHostTopLevelConverter.cs @@ -1,16 +1,15 @@ -using Speckle.Converters.Common; +using Rhino; +using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; -using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToHost.TopLevel; [NameAndRankValue(nameof(SOG.Point), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class PointToHostTopLevelConverter : SpeckleToHostGeometryBaseTopLevelConverter +public class PointToHostTopLevelConverter : SpeckleToHostGeometryBaseTopLevelConverter { public PointToHostTopLevelConverter( - IConversionContextStack contextStack, - ITypedConverter geometryBaseConverter, - IRhinoTransformFactory rhinoTransformFactory + IConversionContextStack contextStack, + ITypedConverter geometryBaseConverter ) - : base(contextStack, geometryBaseConverter, rhinoTransformFactory) { } + : base(contextStack, geometryBaseConverter) { } } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/PolycurveToHostTopLevelConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/PolycurveToHostTopLevelConverter.cs index 96511e2856..d6f8d2f14b 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/PolycurveToHostTopLevelConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/PolycurveToHostTopLevelConverter.cs @@ -1,17 +1,15 @@ -using Speckle.Converters.Common; +using Rhino; +using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; -using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToHost.TopLevel; [NameAndRankValue(nameof(SOG.Polycurve), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class PolycurveToHostTopLevelConverter - : SpeckleToHostGeometryBaseTopLevelConverter +public class PolycurveToHostTopLevelConverter : SpeckleToHostGeometryBaseTopLevelConverter { public PolycurveToHostTopLevelConverter( - IConversionContextStack contextStack, - ITypedConverter geometryBaseConverter, - IRhinoTransformFactory rhinoTransformFactory + IConversionContextStack contextStack, + ITypedConverter geometryBaseConverter ) - : base(contextStack, geometryBaseConverter, rhinoTransformFactory) { } + : base(contextStack, geometryBaseConverter) { } } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/PolylineToHostTopLevelConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/PolylineToHostTopLevelConverter.cs index c098b09930..081f217f04 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/PolylineToHostTopLevelConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/PolylineToHostTopLevelConverter.cs @@ -1,17 +1,16 @@ -using Speckle.Converters.Common; +using Rhino; +using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; -using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToHost.TopLevel; [NameAndRankValue(nameof(SOG.Polyline), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] public class PolylineToHostTopLevelConverter - : SpeckleToHostGeometryBaseTopLevelConverter + : SpeckleToHostGeometryBaseTopLevelConverter { public PolylineToHostTopLevelConverter( - IConversionContextStack contextStack, - ITypedConverter geometryBaseConverter, - IRhinoTransformFactory rhinoTransformFactory + IConversionContextStack contextStack, + ITypedConverter geometryBaseConverter ) - : base(contextStack, geometryBaseConverter, rhinoTransformFactory) { } + : base(contextStack, geometryBaseConverter) { } } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/ArcCurveToSpeckleConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/ArcCurveToSpeckleConverter.cs index f262520e97..8a3eee9cb7 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/ArcCurveToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/ArcCurveToSpeckleConverter.cs @@ -1,23 +1,23 @@ using Objects; +using Rhino; using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; using Speckle.Core.Models; -using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToSpeckle.Raw; -public class ArcCurveToSpeckleConverter : ITypedConverter, ITypedConverter +public class ArcCurveToSpeckleConverter : ITypedConverter, ITypedConverter { - private readonly ITypedConverter _circleConverter; - private readonly ITypedConverter _arcConverter; - private readonly ITypedConverter _intervalConverter; - private readonly IConversionContextStack _contextStack; + private readonly ITypedConverter _circleConverter; + private readonly ITypedConverter _arcConverter; + private readonly ITypedConverter _intervalConverter; + private readonly IConversionContextStack _contextStack; public ArcCurveToSpeckleConverter( - ITypedConverter circleConverter, - ITypedConverter arcConverter, - ITypedConverter intervalConverter, - IConversionContextStack contextStack + ITypedConverter circleConverter, + ITypedConverter arcConverter, + ITypedConverter intervalConverter, + IConversionContextStack contextStack ) { _circleConverter = circleConverter; @@ -27,16 +27,16 @@ IConversionContextStack contextStack } /// - /// Converts an IRhinoArcCurve to an ICurve. + /// Converts an RG.ArcCurve to an ICurve. /// - /// The IRhinoArcCurve to convert. + /// The RG.ArcCurve to convert. /// The converted ICurve. /// /// ⚠️ If the provided ArcCurve is a complete circle, a Speckle Circle will be returned. /// Otherwise, the output will be a Speckle Arc.
/// ✅ This method preserves the domain of the original ArcCurve.
///
- public ICurve Convert(IRhinoArcCurve target) + public ICurve Convert(RG.ArcCurve target) { var tolerance = _contextStack.Current.Document.ModelAbsoluteTolerance; @@ -57,5 +57,5 @@ public ICurve Convert(IRhinoArcCurve target) // This also causes us to have to force cast ICurve to Base as a result, which is expected to always succeed but not nice. /// /// The converted ICurve with a cast to object - Base ITypedConverter.Convert(IRhinoArcCurve target) => (Base)Convert(target); + Base ITypedConverter.Convert(RG.ArcCurve target) => (Base)Convert(target); } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/ArcToSpeckleConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/ArcToSpeckleConverter.cs index 0458715c91..82c89c2551 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/ArcToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/ArcToSpeckleConverter.cs @@ -1,30 +1,27 @@ -using Speckle.Converters.Common; +using Rhino; +using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; -using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToSpeckle.Raw; -public class ArcToSpeckleConverter : ITypedConverter +public class ArcToSpeckleConverter : ITypedConverter { - private readonly ITypedConverter _pointConverter; - private readonly ITypedConverter _planeConverter; - private readonly ITypedConverter _boxConverter; - private readonly IConversionContextStack _contextStack; - private readonly IRhinoBoxFactory _boxFactory; + private readonly ITypedConverter _pointConverter; + private readonly ITypedConverter _planeConverter; + private readonly ITypedConverter _boxConverter; + private readonly IConversionContextStack _contextStack; public ArcToSpeckleConverter( - ITypedConverter pointConverter, - ITypedConverter planeConverter, - ITypedConverter boxConverter, - IConversionContextStack contextStack, - IRhinoBoxFactory boxFactory + ITypedConverter pointConverter, + ITypedConverter planeConverter, + ITypedConverter boxConverter, + IConversionContextStack contextStack ) { _pointConverter = pointConverter; _planeConverter = planeConverter; _boxConverter = boxConverter; _contextStack = contextStack; - _boxFactory = boxFactory; } /// @@ -35,7 +32,7 @@ IRhinoBoxFactory boxFactory /// /// This method assumes the domain of the arc is (0,1) as Arc types in Rhino do not have domain. You may want to request a conversion from ArcCurve instead. /// - public SOG.Arc Convert(IRhinoArc target) => + public SOG.Arc Convert(RG.Arc target) => new( _planeConverter.Convert(target.Plane), target.Radius, @@ -50,6 +47,6 @@ public SOG.Arc Convert(IRhinoArc target) => endPoint = _pointConverter.Convert(target.EndPoint), domain = new SOP.Interval(0, 1), length = target.Length, - bbox = _boxConverter.Convert(_boxFactory.CreateBox(target.BoundingBox())) + bbox = _boxConverter.Convert(new RG.Box(target.BoundingBox())) }; } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/BoxToSpeckleConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/BoxToSpeckleConverter.cs index cae6a5d610..cebd6e5d70 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/BoxToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/BoxToSpeckleConverter.cs @@ -1,19 +1,19 @@ -using Speckle.Converters.Common; +using Rhino; +using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; -using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToSpeckle.Raw; -public class BoxToSpeckleConverter : ITypedConverter +public class BoxToSpeckleConverter : ITypedConverter { - private readonly ITypedConverter _planeConverter; - private readonly ITypedConverter _intervalConverter; - private readonly IConversionContextStack _contextStack; + private readonly ITypedConverter _planeConverter; + private readonly ITypedConverter _intervalConverter; + private readonly IConversionContextStack _contextStack; public BoxToSpeckleConverter( - ITypedConverter planeConverter, - ITypedConverter intervalConverter, - IConversionContextStack contextStack + ITypedConverter planeConverter, + ITypedConverter intervalConverter, + IConversionContextStack contextStack ) { _planeConverter = planeConverter; @@ -26,7 +26,7 @@ IConversionContextStack contextStack /// /// The Rhino Box object to convert. /// The converted Speckle Box object. - public SOG.Box Convert(IRhinoBox target) => + public SOG.Box Convert(RG.Box target) => new( _planeConverter.Convert(target.Plane), _intervalConverter.Convert(target.X), diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/BrepToSpeckleConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/BrepToSpeckleConverter.cs index 1ae05128f7..e74bb2f374 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/BrepToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/BrepToSpeckleConverter.cs @@ -1,34 +1,30 @@ using Objects; +using Rhino; using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; using Speckle.Core.Kits; using Speckle.Core.Logging; -using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToSpeckle.Raw; -public class BrepToSpeckleConverter : ITypedConverter +public class BrepToSpeckleConverter : ITypedConverter { - private readonly ITypedConverter _pointConverter; - private readonly ITypedConverter _curveConverter; - private readonly ITypedConverter _surfaceConverter; - private readonly ITypedConverter _meshConverter; - private readonly ITypedConverter _boxConverter; - private readonly ITypedConverter _intervalConverter; - private readonly IConversionContextStack _contextStack; - private readonly IRhinoBoxFactory _rhinoBoxFactory; - private readonly IRhinoMeshFactory _rhinoMeshFactory; + private readonly ITypedConverter _pointConverter; + private readonly ITypedConverter _curveConverter; + private readonly ITypedConverter _surfaceConverter; + private readonly ITypedConverter _meshConverter; + private readonly ITypedConverter _boxConverter; + private readonly ITypedConverter _intervalConverter; + private readonly IConversionContextStack _contextStack; public BrepToSpeckleConverter( - ITypedConverter pointConverter, - ITypedConverter curveConverter, - ITypedConverter surfaceConverter, - ITypedConverter meshConverter, - ITypedConverter boxConverter, - ITypedConverter intervalConverter, - IConversionContextStack contextStack, - IRhinoBoxFactory rhinoBoxFactory, - IRhinoMeshFactory rhinoMeshFactory + ITypedConverter pointConverter, + ITypedConverter curveConverter, + ITypedConverter surfaceConverter, + ITypedConverter meshConverter, + ITypedConverter boxConverter, + ITypedConverter intervalConverter, + IConversionContextStack contextStack ) { _pointConverter = pointConverter; @@ -38,8 +34,6 @@ IRhinoMeshFactory rhinoMeshFactory _boxConverter = boxConverter; _intervalConverter = intervalConverter; _contextStack = contextStack; - _rhinoBoxFactory = rhinoBoxFactory; - _rhinoMeshFactory = rhinoMeshFactory; } /// @@ -47,7 +41,7 @@ IRhinoMeshFactory rhinoMeshFactory /// /// The Brep object to convert. /// The converted Speckle Brep object. - public SOG.Brep Convert(IRhinoBrep target) + public SOG.Brep Convert(RG.Brep target) { var tol = _contextStack.Current.Document.ModelAbsoluteTolerance; target.Repair(tol); @@ -95,7 +89,7 @@ public SOG.Brep Convert(IRhinoBrep target) Orientation = (SOG.BrepOrientation)target.SolidOrientation, volume = target.IsSolid ? target.GetVolume() : 0, area = target.GetArea(), - bbox = _boxConverter.Convert(_rhinoBoxFactory.CreateBox(target.GetBoundingBox(false))), + bbox = _boxConverter.Convert(new RG.Box(target.GetBoundingBox(false))), units = _contextStack.Current.SpeckleUnits }; @@ -112,7 +106,7 @@ public SOG.Brep Convert(IRhinoBrep target) return speckleBrep; } - private static List ConvertBrepFaces(IRhinoBrep brep, SOG.Brep speckleParent) => + private static List ConvertBrepFaces(RG.Brep brep, SOG.Brep speckleParent) => brep.Faces .Select( f => @@ -126,7 +120,7 @@ public SOG.Brep Convert(IRhinoBrep target) ) .ToList(); - private List ConvertBrepEdges(IRhinoBrep brep, SOG.Brep speckleParent) => + private List ConvertBrepEdges(RG.Brep brep, SOG.Brep speckleParent) => brep.Edges .Select( edge => @@ -142,13 +136,13 @@ public SOG.Brep Convert(IRhinoBrep target) ) .ToList(); - private List ConvertBrepTrims(IRhinoBrep brep, SOG.Brep speckleParent) => + private List ConvertBrepTrims(RG.Brep brep, SOG.Brep speckleParent) => brep.Trims .Select(trim => { var t = new SOG.BrepTrim( speckleParent, - trim.Edge?.EdgeIndex ?? -1, + trim.Edge.EdgeIndex, trim.Face.FaceIndex, trim.Loop.LoopIndex, trim.TrimCurveIndex, @@ -166,7 +160,7 @@ public SOG.Brep Convert(IRhinoBrep target) }) .ToList(); - private List ConvertBrepLoops(IRhinoBrep brep, SOG.Brep speckleParent) => + private List ConvertBrepLoops(RG.Brep brep, SOG.Brep speckleParent) => brep.Loops .Select( loop => @@ -179,13 +173,14 @@ public SOG.Brep Convert(IRhinoBrep target) ) .ToList(); - private IRhinoMesh? GetBrepDisplayMesh(IRhinoBrep brep) + private RG.Mesh? GetBrepDisplayMesh(RG.Brep brep) { - var joinedMesh = _rhinoMeshFactory.Create(); + var joinedMesh = new RG.Mesh(); // get from settings //Settings.TryGetValue("sendMeshSetting", out string meshSetting); + RG.MeshingParameters mySettings = new(0.05, 0.05); // switch (SelectedMeshSettings) // { // case MeshSettings.CurrentDoc: @@ -199,7 +194,7 @@ public SOG.Brep Convert(IRhinoBrep target) try { - joinedMesh.Append(_rhinoMeshFactory.CreateFromBrep(brep, 0.05, 0.05)); + joinedMesh.Append(RG.Mesh.CreateFromBrep(brep, mySettings)); return joinedMesh; } catch (Exception ex) when (!ex.IsFatal()) diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/CircleToSpeckleConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/CircleToSpeckleConverter.cs index 64ef397045..0e3f91e3bf 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/CircleToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/CircleToSpeckleConverter.cs @@ -1,35 +1,35 @@ -using Speckle.Converters.Common; +using Rhino; +using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; using Speckle.Core.Models; -using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToSpeckle.Raw; -public class CircleToSpeckleConverter : ITypedConverter +public class CircleToSpeckleConverter : ITypedConverter { - private readonly ITypedConverter _planeConverter; - private readonly IConversionContextStack _contextStack; + private readonly ITypedConverter _planeConverter; + private readonly IConversionContextStack _contextStack; public CircleToSpeckleConverter( - ITypedConverter planeConverter, - IConversionContextStack contextStack + ITypedConverter planeConverter, + IConversionContextStack contextStack ) { _planeConverter = planeConverter; _contextStack = contextStack; } - public Base Convert(object target) => Convert((IRhinoCircle)target); + public Base Convert(object target) => Convert((RG.Circle)target); /// - /// Converts a IRhinoCircle object to a SOG.Circle object. + /// Converts a RG.Circle object to a SOG.Circle object. /// - /// The IRhinoCircle object to convert. + /// The RG.Circle object to convert. /// The converted SOG.Circle object. /// /// ⚠️ This conversion assumes the domain of a circle is (0,1) as Rhino Circle types do not have a domain. If you want to preserve the domain use ArcCurve conversion instead. /// - public SOG.Circle Convert(IRhinoCircle target) => + public SOG.Circle Convert(RG.Circle target) => new(_planeConverter.Convert(target.Plane), target.Radius, _contextStack.Current.SpeckleUnits) { domain = new SOP.Interval(0, 1), diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/ControlPointToSpeckleConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/ControlPointToSpeckleConverter.cs index 0fa733ca87..d3747e2faf 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/ControlPointToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/ControlPointToSpeckleConverter.cs @@ -1,14 +1,15 @@ -using Speckle.Converters.Common; +using Rhino; +using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; -using Speckle.Rhino7.Interfaces; +using Speckle.Core.Models; namespace Speckle.Converters.Rhino7.ToSpeckle.Raw; -public class ControlPointToSpeckleConverter : ITypedConverter +public class ControlPointToSpeckleConverter : ITypedConverter { - private readonly IConversionContextStack _contextStack; + private readonly IConversionContextStack _contextStack; - public ControlPointToSpeckleConverter(IConversionContextStack contextStack) + public ControlPointToSpeckleConverter(IConversionContextStack contextStack) { _contextStack = contextStack; } @@ -18,6 +19,8 @@ public ControlPointToSpeckleConverter(IConversionContextStack /// The ControlPoint object to convert. /// The converted Speckle ControlPoint object. - public SOG.ControlPoint Convert(IRhinoControlPoint target) => + public SOG.ControlPoint Convert(RG.ControlPoint target) => new(target.Location.X, target.Location.Y, target.Location.Z, target.Weight, _contextStack.Current.SpeckleUnits); + + public Base Convert(object target) => Convert((RG.ControlPoint)target); } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/CurveToSpeckleConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/CurveToSpeckleConverter.cs index 855a2d43d5..5c792ebaf8 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/CurveToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/CurveToSpeckleConverter.cs @@ -1,25 +1,24 @@ using Objects; using Speckle.Converters.Common.Objects; using Speckle.Core.Models; -using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToSpeckle.Raw; // POC: CNX-9278 This converter decides which specific curve conversion to use. IIndex may be a better choice. -public class CurveToSpeckleConverter : ITypedConverter, ITypedConverter +public class CurveToSpeckleConverter : ITypedConverter, ITypedConverter { - private readonly ITypedConverter _polyCurveConverter; - private readonly ITypedConverter _arcCurveConverter; - private readonly ITypedConverter _polylineConverter; - private readonly ITypedConverter _nurbsCurveConverter; - private readonly ITypedConverter _lineCurveConverter; + private readonly ITypedConverter _polyCurveConverter; + private readonly ITypedConverter _arcCurveConverter; + private readonly ITypedConverter _polylineConverter; + private readonly ITypedConverter _nurbsCurveConverter; + private readonly ITypedConverter _lineCurveConverter; public CurveToSpeckleConverter( - ITypedConverter polyCurveConverter, - ITypedConverter arcCurveConverter, - ITypedConverter polylineConverter, - ITypedConverter nurbsCurveConverter, - ITypedConverter lineCurveConverter + ITypedConverter polyCurveConverter, + ITypedConverter arcCurveConverter, + ITypedConverter polylineConverter, + ITypedConverter nurbsCurveConverter, + ITypedConverter lineCurveConverter ) { _polyCurveConverter = polyCurveConverter; @@ -38,31 +37,15 @@ public CurveToSpeckleConverter( /// This is the main converter when the type of curve you input or output does not matter to the caller.
/// ⚠️ If an unsupported type of Curve is input, it will be converted to NURBS. /// - public ICurve Convert(IRhinoCurve target) - { - var polyline = target.ToPolylineCurve(); - if (polyline is not null) - { - return _polylineConverter.Convert(polyline); - } - var arcCurve = target.ToArcCurve(); - if (arcCurve is not null) - { - return _arcCurveConverter.Convert(arcCurve); - } - var polyCurve = target.ToPolyCurve(); - if (polyCurve is not null) + public ICurve Convert(RG.Curve target) => + target switch { - return _polyCurveConverter.Convert(polyCurve); - } - var lineCurve = target.ToLineCurve(); - if (lineCurve is not null) - { - return _lineCurveConverter.Convert(lineCurve); - } - var nurbsCurve = target.ToNurbsCurve(); - return _nurbsCurveConverter.Convert(nurbsCurve); - } + RG.PolyCurve polyCurve => _polyCurveConverter.Convert(polyCurve), + RG.ArcCurve arcCurve => _arcCurveConverter.Convert(arcCurve), + RG.PolylineCurve polylineCurve => _polylineConverter.Convert(polylineCurve), + RG.LineCurve lineCurve => _lineCurveConverter.Convert(lineCurve), + _ => _nurbsCurveConverter.Convert(target.ToNurbsCurve()) + }; - Base ITypedConverter.Convert(IRhinoCurve target) => (Base)Convert(target); + Base ITypedConverter.Convert(RG.Curve target) => (Base)Convert(target); } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/EllipseToSpeckleConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/EllipseToSpeckleConverter.cs index 0420067ae7..fc6b52cc8f 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/EllipseToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/EllipseToSpeckleConverter.cs @@ -1,27 +1,24 @@ -using Speckle.Converters.Common; +using Rhino; +using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; -using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToSpeckle.Raw; -public class EllipseToSpeckleConverter : ITypedConverter +public class EllipseToSpeckleConverter : ITypedConverter { - private readonly ITypedConverter _planeConverter; - private readonly ITypedConverter _boxConverter; - private readonly IConversionContextStack _contextStack; - private readonly IRhinoBoxFactory _rhinoBoxFactory; + private readonly ITypedConverter _planeConverter; + private readonly ITypedConverter _boxConverter; + private readonly IConversionContextStack _contextStack; public EllipseToSpeckleConverter( - ITypedConverter planeConverter, - ITypedConverter boxConverter, - IConversionContextStack contextStack, - IRhinoBoxFactory rhinoBoxFactory + ITypedConverter planeConverter, + ITypedConverter boxConverter, + IConversionContextStack contextStack ) { _planeConverter = planeConverter; _boxConverter = boxConverter; _contextStack = contextStack; - _rhinoBoxFactory = rhinoBoxFactory; } /// @@ -32,7 +29,7 @@ IRhinoBoxFactory rhinoBoxFactory /// /// ⚠️ Rhino ellipses are not curves. The result is a mathematical representation of an ellipse that can be converted into NURBS for display. /// - public SOG.Ellipse Convert(IRhinoEllipse target) + public SOG.Ellipse Convert(RG.Ellipse target) { var nurbsCurve = target.ToNurbsCurve(); return new( @@ -45,7 +42,7 @@ public SOG.Ellipse Convert(IRhinoEllipse target) domain = new SOP.Interval(0, 1), length = nurbsCurve.GetLength(), area = Math.PI * target.Radius1 * target.Radius2, - bbox = _boxConverter.Convert(_rhinoBoxFactory.CreateBox(nurbsCurve.GetBoundingBox(true))) + bbox = _boxConverter.Convert(new RG.Box(nurbsCurve.GetBoundingBox(true))) }; } } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/IntervalToSpeckleConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/IntervalToSpeckleConverter.cs index 8044a90e7d..272fecafdb 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/IntervalToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/IntervalToSpeckleConverter.cs @@ -1,14 +1,13 @@ using Speckle.Converters.Common.Objects; -using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToSpeckle.Raw; -public class IntervalToSpeckleConverter : ITypedConverter +public class IntervalToSpeckleConverter : ITypedConverter { /// /// Converts a Rhino Interval object to a Speckle Interval object. /// /// The Rhino Interval object to be converted. /// The converted Speckle Interval object. - public SOP.Interval Convert(IRhinoInterval target) => new(target.T0, target.T1); + public SOP.Interval Convert(RG.Interval target) => new(target.T0, target.T1); } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/LineToSpeckleConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/LineToSpeckleConverter.cs index dc480c79fd..f40620f78d 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/LineToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/LineToSpeckleConverter.cs @@ -1,27 +1,24 @@ -using Speckle.Converters.Common; +using Rhino; +using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; -using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToSpeckle.Raw; -public class LineToSpeckleConverter : ITypedConverter, ITypedConverter +public class LineToSpeckleConverter : ITypedConverter, ITypedConverter { - private readonly ITypedConverter _pointConverter; - private readonly ITypedConverter _boxConverter; - private readonly IConversionContextStack _contextStack; - private readonly IRhinoBoxFactory _rhinoBoxFactory; + private readonly ITypedConverter _pointConverter; + private readonly ITypedConverter _boxConverter; + private readonly IConversionContextStack _contextStack; public LineToSpeckleConverter( - ITypedConverter pointConverter, - ITypedConverter boxConverter, - IConversionContextStack contextStack, - IRhinoBoxFactory rhinoBoxFactory + ITypedConverter pointConverter, + ITypedConverter boxConverter, + IConversionContextStack contextStack ) { _pointConverter = pointConverter; _boxConverter = boxConverter; _contextStack = contextStack; - _rhinoBoxFactory = rhinoBoxFactory; } /// @@ -32,13 +29,13 @@ IRhinoBoxFactory rhinoBoxFactory /// /// ⚠️ This conversion assumes the domain of a line is (0, LENGTH), as Rhino Lines do not have domain. If you want the domain preserved use LineCurve conversions instead. /// - public SOG.Line Convert(IRhinoLine target) => + public SOG.Line Convert(RG.Line target) => new(_pointConverter.Convert(target.From), _pointConverter.Convert(target.To), _contextStack.Current.SpeckleUnits) { length = target.Length, domain = new SOP.Interval(0, target.Length), - bbox = _boxConverter.Convert(_rhinoBoxFactory.CreateBox(target.BoundingBox)) + bbox = _boxConverter.Convert(new RG.Box(target.BoundingBox)) }; - public SOG.Line Convert(IRhinoLineCurve target) => Convert(target.Line); + public SOG.Line Convert(RG.LineCurve target) => Convert(target.Line); } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/MeshToSpeckleConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/MeshToSpeckleConverter.cs index cf7dfbc288..73aa3f4a8a 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/MeshToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/MeshToSpeckleConverter.cs @@ -1,25 +1,25 @@ -using Speckle.Converters.Common; +using Rhino; +using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; -using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToSpeckle.Raw; -[NameAndRankValue(nameof(IRhinoMesh), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class MeshToSpeckleConverter : ITypedConverter +[NameAndRankValue(nameof(RG.Mesh), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +public class MeshToSpeckleConverter : ITypedConverter { - private readonly ITypedConverter _boxConverter; - private readonly IConversionContextStack _contextStack; - private readonly IRhinoBoxFactory _rhinoBoxFactory; + private readonly ITypedConverter _pointConverter; + private readonly ITypedConverter _boxConverter; + private readonly IConversionContextStack _contextStack; public MeshToSpeckleConverter( - ITypedConverter boxConverter, - IConversionContextStack contextStack, - IRhinoBoxFactory rhinoBoxFactory + ITypedConverter pointConverter, + ITypedConverter boxConverter, + IConversionContextStack contextStack ) { + _pointConverter = pointConverter; _boxConverter = boxConverter; _contextStack = contextStack; - _rhinoBoxFactory = rhinoBoxFactory; } /// @@ -28,7 +28,7 @@ IRhinoBoxFactory rhinoBoxFactory /// The Rhino Mesh to be converted. /// The converted Speckle Mesh. /// Thrown when the Rhino Mesh has 0 vertices or faces. - public SOG.Mesh Convert(IRhinoMesh target) + public SOG.Mesh Convert(RG.Mesh target) { if (target.Vertices.Count == 0 || target.Faces.Count == 0) { @@ -38,7 +38,7 @@ public SOG.Mesh Convert(IRhinoMesh target) var vertexCoordinates = target.Vertices.ToPoint3dArray().SelectMany(pt => new[] { pt.X, pt.Y, pt.Z }).ToList(); var faces = new List(); - foreach (IRhinoMeshNgon polygon in target.GetNgonAndFacesEnumerable()) + foreach (RG.MeshNgon polygon in target.GetNgonAndFacesEnumerable()) { var vertIndices = polygon.BoundaryVertexIndexList(); int n = vertIndices.Length; @@ -55,7 +55,7 @@ public SOG.Mesh Convert(IRhinoMesh target) var colors = target.VertexColors.Select(cl => cl.ToArgb()).ToList(); var volume = target.IsClosed ? target.Volume() : 0; - var bbox = _boxConverter.Convert(_rhinoBoxFactory.CreateBox(target.GetBoundingBox(false))); + var bbox = _boxConverter.Convert(new RG.Box(target.GetBoundingBox(false))); return new SOG.Mesh(vertexCoordinates, faces, colors, textureCoordinates, _contextStack.Current.SpeckleUnits) { diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/NurbsCurveConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/NurbsCurveConverter.cs index 7c28b72c3d..6cf8dca53d 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/NurbsCurveConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/NurbsCurveConverter.cs @@ -1,30 +1,27 @@ -using Speckle.Converters.Common; +using Rhino; +using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; -using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToSpeckle.Raw; -public class NurbsCurveConverter : ITypedConverter +public class NurbsCurveConverter : ITypedConverter { - private readonly ITypedConverter _polylineConverter; - private readonly ITypedConverter _intervalConverter; - private readonly ITypedConverter _boxConverter; - private readonly IConversionContextStack _contextStack; - private readonly IRhinoBoxFactory _rhinoBoxFactory; + private readonly ITypedConverter _polylineConverter; + private readonly ITypedConverter _intervalConverter; + private readonly ITypedConverter _boxConverter; + private readonly IConversionContextStack _contextStack; public NurbsCurveConverter( - ITypedConverter polylineConverter, - ITypedConverter intervalConverter, - ITypedConverter boxConverter, - IConversionContextStack contextStack, - IRhinoBoxFactory rhinoBoxFactory + ITypedConverter polylineConverter, + ITypedConverter intervalConverter, + ITypedConverter boxConverter, + IConversionContextStack contextStack ) { _polylineConverter = polylineConverter; _intervalConverter = intervalConverter; _boxConverter = boxConverter; _contextStack = contextStack; - _rhinoBoxFactory = rhinoBoxFactory; } /// @@ -37,9 +34,13 @@ IRhinoBoxFactory rhinoBoxFactory /// It adds 1 extra knot at the start and end of the vector by repeating the first and last value. /// This is because Rhino's standard of (controlPoints + degree + 1) wasn't followed on other software. /// - public SOG.Curve Convert(IRhinoNurbsCurve target) + public SOG.Curve Convert(RG.NurbsCurve target) { target.ToPolyline(0, 1, 0, 0, 0, 0.1, 0, 0, true).TryGetPolyline(out var poly); + if (target.IsClosed) + { + poly.Add(poly[0]); + } SOG.Polyline displayValue = _polylineConverter.Convert(poly); @@ -62,7 +63,7 @@ public SOG.Curve Convert(IRhinoNurbsCurve target) domain = _intervalConverter.Convert(nurbsCurve.Domain), closed = nurbsCurve.IsClosed, length = nurbsCurve.GetLength(), - bbox = _boxConverter.Convert(_rhinoBoxFactory.CreateBox(nurbsCurve.GetBoundingBox(true))) + bbox = _boxConverter.Convert(new RG.Box(nurbsCurve.GetBoundingBox(true))) }; return myCurve; diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/NurbsSurfaceToSpeckleConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/NurbsSurfaceToSpeckleConverter.cs index 4f4952622a..0d663ff520 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/NurbsSurfaceToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/NurbsSurfaceToSpeckleConverter.cs @@ -1,30 +1,28 @@ -using Speckle.Converters.Common; +using Rhino; +using Rhino.Geometry.Collections; +using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; -using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToSpeckle.Raw; -public class NurbsSurfaceToSpeckleConverter : ITypedConverter +public class NurbsSurfaceToSpeckleConverter : ITypedConverter { - private readonly ITypedConverter _boxConverter; - private readonly ITypedConverter _intervalConverter; - private readonly ITypedConverter _controlPointConverter; - private readonly IConversionContextStack _contextStack; - private readonly IRhinoBoxFactory _rhinoBoxFactory; + private readonly ITypedConverter _boxConverter; + private readonly ITypedConverter _intervalConverter; + private readonly ITypedConverter _controlPointConverter; + private readonly IConversionContextStack _contextStack; public NurbsSurfaceToSpeckleConverter( - ITypedConverter boxConverter, - ITypedConverter intervalConverter, - ITypedConverter controlPointConverter, - IConversionContextStack contextStack, - IRhinoBoxFactory rhinoBoxFactory + ITypedConverter boxConverter, + ITypedConverter intervalConverter, + ITypedConverter controlPointConverter, + IConversionContextStack contextStack ) { _boxConverter = boxConverter; _intervalConverter = intervalConverter; _controlPointConverter = controlPointConverter; _contextStack = contextStack; - _rhinoBoxFactory = rhinoBoxFactory; } /// @@ -32,7 +30,7 @@ IRhinoBoxFactory rhinoBoxFactory /// /// The NurbsSurface object to convert. /// A Surface object representing the converted NurbsSurface. - public SOG.Surface Convert(IRhinoNurbsSurface target) + public SOG.Surface Convert(RG.NurbsSurface target) { var result = new SOG.Surface { @@ -46,7 +44,7 @@ public SOG.Surface Convert(IRhinoNurbsSurface target) knotsU = target.KnotsU.ToList(), knotsV = target.KnotsV.ToList(), units = _contextStack.Current.SpeckleUnits, - bbox = _boxConverter.Convert(_rhinoBoxFactory.CreateBox(target.GetBoundingBox(true))) + bbox = _boxConverter.Convert(new RG.Box(target.GetBoundingBox(true))) }; result.SetControlPoints(ControlPointsToSpeckle(target.Points)); @@ -54,7 +52,7 @@ public SOG.Surface Convert(IRhinoNurbsSurface target) return result; } - private List> ControlPointsToSpeckle(IRhinoNurbsSurfacePointList controlPoints) + private List> ControlPointsToSpeckle(NurbsSurfacePointList controlPoints) { var points = new List>(); for (var i = 0; i < controlPoints.CountU; i++) diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/PlaneToSpeckleConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/PlaneToSpeckleConverter.cs index b2a3264467..40d15be50c 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/PlaneToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/PlaneToSpeckleConverter.cs @@ -1,19 +1,19 @@ +using Rhino; using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; -using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToSpeckle.Raw; -public class PlaneToSpeckleConverter : ITypedConverter +public class PlaneToSpeckleConverter : ITypedConverter { - private readonly ITypedConverter _vectorConverter; - private readonly ITypedConverter _pointConverter; - private readonly IConversionContextStack _contextStack; + private readonly ITypedConverter _vectorConverter; + private readonly ITypedConverter _pointConverter; + private readonly IConversionContextStack _contextStack; public PlaneToSpeckleConverter( - ITypedConverter vectorConverter, - ITypedConverter pointConverter, - IConversionContextStack contextStack + ITypedConverter vectorConverter, + ITypedConverter pointConverter, + IConversionContextStack contextStack ) { _vectorConverter = vectorConverter; @@ -26,7 +26,7 @@ IConversionContextStack contextStack /// /// The instance of Rhino Plane to convert. /// The converted instance of Speckle Plane. - public SOG.Plane Convert(IRhinoPlane target) => + public SOG.Plane Convert(RG.Plane target) => new( _pointConverter.Convert(target.Origin), _vectorConverter.Convert(target.ZAxis), diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/PointToSpeckleConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/PointToSpeckleConverter.cs index c110af447a..2bfdfdae1c 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/PointToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/PointToSpeckleConverter.cs @@ -1,16 +1,14 @@ +using Rhino; using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; -using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToSpeckle.Raw; -public class PointToSpeckleConverter - : ITypedConverter, - ITypedConverter +public class PointToSpeckleConverter : ITypedConverter, ITypedConverter { - private readonly IConversionContextStack _contextStack; + private readonly IConversionContextStack _contextStack; - public PointToSpeckleConverter(IConversionContextStack contextStack) + public PointToSpeckleConverter(IConversionContextStack contextStack) { _contextStack = contextStack; } @@ -20,8 +18,7 @@ public PointToSpeckleConverter(IConversionContextStack /// The Rhino 3D point to convert. /// The converted Speckle point. - public SOG.Point Convert(IRhinoPoint3d target) => - new(target.X, target.Y, target.Z, _contextStack.Current.SpeckleUnits); + public SOG.Point Convert(RG.Point3d target) => new(target.X, target.Y, target.Z, _contextStack.Current.SpeckleUnits); - public SOG.Point Convert(IRhinoPoint target) => Convert(target.Location); + public SOG.Point Convert(RG.Point target) => Convert(target.Location); } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/PolyCurveToSpeckleConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/PolyCurveToSpeckleConverter.cs index 10cdf491d5..6937d6b007 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/PolyCurveToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/PolyCurveToSpeckleConverter.cs @@ -1,30 +1,26 @@ using Objects; +using Rhino; using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; -using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToSpeckle.Raw; -public class PolyCurveToSpeckleConverter : ITypedConverter +public class PolyCurveToSpeckleConverter : ITypedConverter { - public ITypedConverter? CurveConverter { get; set; } // POC: CNX-9279 This created a circular dependency on the constructor, making it a property allows for the container to resolve it correctly - - private readonly ITypedConverter _intervalConverter; - private readonly ITypedConverter _boxConverter; - private readonly IConversionContextStack _contextStack; - private readonly IRhinoBoxFactory _rhinoBoxFactory; + public ITypedConverter? CurveConverter { get; set; } // POC: CNX-9279 This created a circular dependency on the constructor, making it a property allows for the container to resolve it correctly + private readonly ITypedConverter _intervalConverter; + private readonly ITypedConverter _boxConverter; + private readonly IConversionContextStack _contextStack; public PolyCurveToSpeckleConverter( - ITypedConverter intervalConverter, - ITypedConverter boxConverter, - IConversionContextStack contextStack, - IRhinoBoxFactory rhinoBoxFactory + ITypedConverter intervalConverter, + ITypedConverter boxConverter, + IConversionContextStack contextStack ) { _intervalConverter = intervalConverter; _boxConverter = boxConverter; _contextStack = contextStack; - _rhinoBoxFactory = rhinoBoxFactory; } /// @@ -36,14 +32,14 @@ IRhinoBoxFactory rhinoBoxFactory /// This method removes the nesting of the PolyCurve by duplicating the segments at a granular level. /// All PolyLIne, PolyCurve and NURBS curves with G1 discontinuities will be broken down. /// - public SOG.Polycurve Convert(IRhinoPolyCurve target) + public SOG.Polycurve Convert(RG.PolyCurve target) { var myPoly = new SOG.Polycurve { closed = target.IsClosed, domain = _intervalConverter.Convert(target.Domain), length = target.GetLength(), - bbox = _boxConverter.Convert(_rhinoBoxFactory.CreateBox(target.GetBoundingBox(true))), + bbox = _boxConverter.Convert(new RG.Box(target.GetBoundingBox(true))), segments = target.DuplicateSegments().Select(x => CurveConverter.NotNull().Convert(x)).ToList(), units = _contextStack.Current.SpeckleUnits }; diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/PolylineToSpeckleConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/PolylineToSpeckleConverter.cs index 7682ceeb42..1ee241e7d1 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/PolylineToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/PolylineToSpeckleConverter.cs @@ -1,32 +1,29 @@ -using Speckle.Converters.Common; +using Rhino; +using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; -using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToSpeckle.Raw; public class PolylineToSpeckleConverter - : ITypedConverter, - ITypedConverter + : ITypedConverter, + ITypedConverter { - private readonly ITypedConverter _pointConverter; - private readonly ITypedConverter _boxConverter; - private readonly ITypedConverter _intervalConverter; - private readonly IConversionContextStack _contextStack; - private readonly IRhinoBoxFactory _rhinoBoxFactory; + private readonly ITypedConverter _pointConverter; + private readonly ITypedConverter _boxConverter; + private readonly ITypedConverter _intervalConverter; + private readonly IConversionContextStack _contextStack; public PolylineToSpeckleConverter( - ITypedConverter pointConverter, - ITypedConverter boxConverter, - IConversionContextStack contextStack, - ITypedConverter intervalConverter, - IRhinoBoxFactory rhinoBoxFactory + ITypedConverter pointConverter, + ITypedConverter boxConverter, + IConversionContextStack contextStack, + ITypedConverter intervalConverter ) { _pointConverter = pointConverter; _boxConverter = boxConverter; _contextStack = contextStack; _intervalConverter = intervalConverter; - _rhinoBoxFactory = rhinoBoxFactory; } /// @@ -35,12 +32,12 @@ IRhinoBoxFactory rhinoBoxFactory /// The Rhino polyline to be converted. /// The converted Speckle polyline. /// ⚠️ This conversion assumes domain interval is (0,LENGTH) as Rhino Polylines have no domain. If needed, you may want to use PolylineCurve conversion instead. - public SOG.Polyline Convert(IRhinoPolyline target) + public SOG.Polyline Convert(RG.Polyline target) { - var box = _boxConverter.Convert(_rhinoBoxFactory.CreateBox(target.BoundingBox)); + var box = _boxConverter.Convert(new RG.Box(target.BoundingBox)); var points = target.Select(pt => _pointConverter.Convert(pt)).ToList(); - if (points[0] == points[^1] && target.IsClosed) + if (target.IsClosed) { points.RemoveAt(points.Count - 1); } @@ -51,8 +48,8 @@ public SOG.Polyline Convert(IRhinoPolyline target) ) { bbox = box, - length = target.Count, - domain = new(0, target.Count), + length = target.Length, + domain = new(0, target.Length), closed = target.IsClosed }; } @@ -63,7 +60,7 @@ public SOG.Polyline Convert(IRhinoPolyline target) /// The Rhino PolylineCurve to be converted. /// The converted Speckle polyline. /// ✅ This conversion respects the domain of the original PolylineCurve - public SOG.Polyline Convert(IRhinoPolylineCurve target) + public SOG.Polyline Convert(RG.PolylineCurve target) { var result = Convert(target.ToPolyline()); result.domain = _intervalConverter.Convert(target.Domain); diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/RawPointCloudToSpeckle.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/RawPointCloudToSpeckle.cs index f7d0fdee98..5e4a17e6cb 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/RawPointCloudToSpeckle.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/RawPointCloudToSpeckle.cs @@ -1,24 +1,21 @@ -using Speckle.Converters.Common; +using Rhino; +using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; -using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToSpeckle.Raw; -public class RawPointCloudToSpeckle : ITypedConverter +public class RawPointCloudToSpeckle : ITypedConverter { - private readonly IConversionContextStack _contextStack; - private readonly ITypedConverter _boxConverter; - private readonly IRhinoBoxFactory _rhinoBoxFactory; + private readonly IConversionContextStack _contextStack; + private readonly ITypedConverter _boxConverter; public RawPointCloudToSpeckle( - IConversionContextStack contextStack, - ITypedConverter boxConverter, - IRhinoBoxFactory rhinoBoxFactory + IConversionContextStack contextStack, + ITypedConverter boxConverter ) { _contextStack = contextStack; _boxConverter = boxConverter; - _rhinoBoxFactory = rhinoBoxFactory; } /// @@ -26,12 +23,12 @@ IRhinoBoxFactory rhinoBoxFactory /// /// The Rhino PointCloud object to convert. /// The converted Speckle Pointcloud object. - public SOG.Pointcloud Convert(IRhinoPointCloud target) => + public SOG.Pointcloud Convert(RG.PointCloud target) => new() { points = target.GetPoints().SelectMany(pt => new[] { pt.X, pt.Y, pt.Z }).ToList(), colors = target.GetColors().Select(o => o.ToArgb()).ToList(), - bbox = _boxConverter.Convert(_rhinoBoxFactory.CreateBox(target.GetBoundingBox(true))), + bbox = _boxConverter.Convert(new RG.Box(target.GetBoundingBox(true))), units = _contextStack.Current.SpeckleUnits }; } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/VectorToSpeckleConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/VectorToSpeckleConverter.cs index fe5de7db27..489eddedc4 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/VectorToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/VectorToSpeckleConverter.cs @@ -1,14 +1,14 @@ -using Speckle.Converters.Common; +using Rhino; +using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; -using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToSpeckle.Raw; -public class VectorToSpeckleConverter : ITypedConverter +public class VectorToSpeckleConverter : ITypedConverter { - private readonly IConversionContextStack _contextStack; + private readonly IConversionContextStack _contextStack; - public VectorToSpeckleConverter(IConversionContextStack contextStack) + public VectorToSpeckleConverter(IConversionContextStack contextStack) { _contextStack = contextStack; } @@ -18,6 +18,6 @@ public VectorToSpeckleConverter(IConversionContextStack /// The Rhino Vector3d object to convert. /// The converted Speckle Vector object. - public SOG.Vector Convert(IRhinoVector3d target) => + public SOG.Vector Convert(RG.Vector3d target) => new(target.X, target.Y, target.Z, _contextStack.Current.SpeckleUnits); } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/BrepObjectToSpeckleTopLevelConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/BrepObjectToSpeckleTopLevelConverter.cs index d55b39090c..7520c1bd83 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/BrepObjectToSpeckleTopLevelConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/BrepObjectToSpeckleTopLevelConverter.cs @@ -1,23 +1,23 @@ -using Speckle.Converters.Common; +using Rhino.DocObjects; +using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; using Speckle.Core.Models; -using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToSpeckle.TopLevel; -[NameAndRankValue(nameof(IRhinoBrepObject), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +[NameAndRankValue(nameof(BrepObject), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] public class BrepObjectToSpeckleTopLevelConverter : IToSpeckleTopLevelConverter { - private readonly ITypedConverter _curveConverter; + private readonly ITypedConverter _curveConverter; - public BrepObjectToSpeckleTopLevelConverter(ITypedConverter curveConverter) + public BrepObjectToSpeckleTopLevelConverter(ITypedConverter curveConverter) { _curveConverter = curveConverter; } public Base Convert(object target) { - var curveObject = (IRhinoBrepObject)target; //can only be this type + var curveObject = (BrepObject)target; var speckleCurve = _curveConverter.Convert(curveObject.BrepGeometry); return speckleCurve; } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/CurveObjectToSpeckleTopLevelConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/CurveObjectToSpeckleTopLevelConverter.cs index 34fcf6c18e..a8214a0c97 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/CurveObjectToSpeckleTopLevelConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/CurveObjectToSpeckleTopLevelConverter.cs @@ -1,16 +1,15 @@ -using Speckle.Converters.Common; +using Rhino.DocObjects; +using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; using Speckle.Core.Models; -using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToSpeckle.TopLevel; -[NameAndRankValue(nameof(IRhinoCurveObject), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class CurveObjectToSpeckleTopLevelConverter - : RhinoObjectToSpeckleTopLevelConverter +[NameAndRankValue(nameof(CurveObject), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +public class CurveObjectToSpeckleTopLevelConverter : RhinoObjectToSpeckleTopLevelConverter { - public CurveObjectToSpeckleTopLevelConverter(ITypedConverter conversion) + public CurveObjectToSpeckleTopLevelConverter(ITypedConverter conversion) : base(conversion) { } - protected override IRhinoCurve GetTypedGeometry(IRhinoCurveObject input) => input.CurveGeometry; + protected override RG.Curve GetTypedGeometry(CurveObject input) => input.CurveGeometry; } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/ExtrusionObjectToSpeckleTopLevelConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/ExtrusionObjectToSpeckleTopLevelConverter.cs index 3c5d93335d..46d2c27586 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/ExtrusionObjectToSpeckleTopLevelConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/ExtrusionObjectToSpeckleTopLevelConverter.cs @@ -1,23 +1,23 @@ -using Speckle.Converters.Common; +using Rhino.DocObjects; +using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; using Speckle.Core.Models; -using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToSpeckle.TopLevel; -[NameAndRankValue(nameof(IRhinoExtrusionObject), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +[NameAndRankValue(nameof(ExtrusionObject), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] public class ExtrusionObjectToSpeckleTopLevelConverter : IToSpeckleTopLevelConverter { - private readonly ITypedConverter _curveConverter; + private readonly ITypedConverter _curveConverter; - public ExtrusionObjectToSpeckleTopLevelConverter(ITypedConverter curveConverter) + public ExtrusionObjectToSpeckleTopLevelConverter(ITypedConverter curveConverter) { _curveConverter = curveConverter; } public Base Convert(object target) { - var curveObject = (IRhinoExtrusionObject)target; //can only be this type + var curveObject = (ExtrusionObject)target; var speckleCurve = _curveConverter.Convert(curveObject.ExtrusionGeometry.ToBrep()); return speckleCurve; } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/MeshObjectToSpeckleTopLevelConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/MeshObjectToSpeckleTopLevelConverter.cs index 025e36fd99..f1c9675a04 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/MeshObjectToSpeckleTopLevelConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/MeshObjectToSpeckleTopLevelConverter.cs @@ -1,15 +1,14 @@ -using Speckle.Converters.Common; +using Rhino.DocObjects; +using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; -using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToSpeckle.TopLevel; -[NameAndRankValue(nameof(IRhinoMeshObject), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class MeshObjectToSpeckleTopLevelConverter - : RhinoObjectToSpeckleTopLevelConverter +[NameAndRankValue(nameof(MeshObject), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +public class MeshObjectToSpeckleTopLevelConverter : RhinoObjectToSpeckleTopLevelConverter { - public MeshObjectToSpeckleTopLevelConverter(ITypedConverter conversion) + public MeshObjectToSpeckleTopLevelConverter(ITypedConverter conversion) : base(conversion) { } - protected override IRhinoMesh GetTypedGeometry(IRhinoMeshObject input) => input.MeshGeometry; + protected override RG.Mesh GetTypedGeometry(MeshObject input) => input.MeshGeometry; } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/PointCloudObjectToSpeckleTopLevelConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/PointCloudObjectToSpeckleTopLevelConverter.cs index b25c80d190..e741e38e49 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/PointCloudObjectToSpeckleTopLevelConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/PointCloudObjectToSpeckleTopLevelConverter.cs @@ -1,15 +1,15 @@ -using Speckle.Converters.Common; +using Rhino.DocObjects; +using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; -using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToSpeckle.TopLevel; -[NameAndRankValue(nameof(IRhinoPointCloudObject), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +[NameAndRankValue(nameof(PointCloudObject), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] public class PointCloudObjectToSpeckleTopLevelConverter - : RhinoObjectToSpeckleTopLevelConverter + : RhinoObjectToSpeckleTopLevelConverter { - public PointCloudObjectToSpeckleTopLevelConverter(ITypedConverter conversion) + public PointCloudObjectToSpeckleTopLevelConverter(ITypedConverter conversion) : base(conversion) { } - protected override IRhinoPointCloud GetTypedGeometry(IRhinoPointCloudObject input) => input.PointCloudGeometry; + protected override RG.PointCloud GetTypedGeometry(PointCloudObject input) => input.PointCloudGeometry; } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/PointObjectToSpeckleTopLevelConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/PointObjectToSpeckleTopLevelConverter.cs index d127aa0266..7d9c750b64 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/PointObjectToSpeckleTopLevelConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/PointObjectToSpeckleTopLevelConverter.cs @@ -1,15 +1,15 @@ -using Speckle.Converters.Common; +using Rhino.DocObjects; +using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; -using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToSpeckle.TopLevel; -[NameAndRankValue(nameof(IRhinoPointObject), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +[NameAndRankValue(nameof(PointObject), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] public class PointObjectToSpeckleTopLevelConverter - : RhinoObjectToSpeckleTopLevelConverter + : RhinoObjectToSpeckleTopLevelConverter { - public PointObjectToSpeckleTopLevelConverter(ITypedConverter conversion) + public PointObjectToSpeckleTopLevelConverter(ITypedConverter conversion) : base(conversion) { } - protected override IRhinoPoint GetTypedGeometry(IRhinoPointObject input) => input.PointGeometry; + protected override RG.Point GetTypedGeometry(PointObject input) => input.PointGeometry; } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/RhinoObjectToSpeckleTopLevelConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/RhinoObjectToSpeckleTopLevelConverter.cs index f86d7a09f5..edff24473a 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/RhinoObjectToSpeckleTopLevelConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/RhinoObjectToSpeckleTopLevelConverter.cs @@ -4,15 +4,15 @@ namespace Speckle.Converters.Rhino7.ToSpeckle.TopLevel; public abstract class RhinoObjectToSpeckleTopLevelConverter : IToSpeckleTopLevelConverter - where TTopLevelIn : notnull - where TInRaw : notnull + where TTopLevelIn : Rhino.DocObjects.RhinoObject + where TInRaw : RG.GeometryBase where TOutRaw : Base { - private readonly ITypedConverter _conversion; + public ITypedConverter Conversion { get; } protected RhinoObjectToSpeckleTopLevelConverter(ITypedConverter conversion) { - _conversion = conversion; + Conversion = conversion; } // POC: IIndex would fix this as I would just request the type from `RhinoObject.Geometry` directly. @@ -20,10 +20,10 @@ protected RhinoObjectToSpeckleTopLevelConverter(ITypedConverter public virtual Base Convert(object target) { - var typedTarget = (TTopLevelIn)target; //can only be this typee + var typedTarget = (TTopLevelIn)target; var typedGeometry = GetTypedGeometry(typedTarget); - var result = _conversion.Convert(typedGeometry); + var result = Conversion.Convert(typedGeometry); // POC: Any common operations for all RhinoObjects should be done here, not on the specific implementer // Things like user-dictionaries and other user-defined metadata. diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/packages.lock.json b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/packages.lock.json index e88d9d0998..57b03cf40e 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/packages.lock.json +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/packages.lock.json @@ -18,18 +18,18 @@ "resolved": "1.14.1", "contentHash": "mOOmFYwad3MIOL14VCjj02LljyF1GNw1wP0YVlxtcPvqdxjGGMNdNJJxHptlry3MOd8b40Flm8RPOM8JOlN2sQ==" }, + "RhinoCommon": { + "type": "Direct", + "requested": "[7.13.21348.13001, )", + "resolved": "7.13.21348.13001", + "contentHash": "JQdaNw61ddBqIe08E9O4N/grwrN1hjDHcYW7tWylwCZyFR7SepoCD4NS+6LN6+oSQhNbhLi9Bf+hQOFYFdRAEA==" + }, "Speckle.InterfaceGenerator": { "type": "Direct", "requested": "[0.9.5, )", "resolved": "0.9.5", "contentHash": "oU/L7pN1R7q8KkbrpQ3WJnHirPHqn+9DEA7asOcUiggV5dzVg1A/VYs7GOSusD24njxXh03tE3a2oTLOjt3cVg==" }, - "Speckle.Rhino7.Interfaces": { - "type": "Direct", - "requested": "[0.1.1-preview.0.28, )", - "resolved": "0.1.1-preview.0.28", - "contentHash": "TcbfXlRMnQRat1JodgW+YW5FflTYem1GGo9DtKA+6iAuVaYagN5dxsrM5LE6M3pCnEV9rkEQOjFo7sgnnbo4mw==" - }, "GraphQL.Client": { "type": "Transitive", "resolved": "6.0.0", diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI.WebView/packages.lock.json b/DUI3-DX/DUI3/Speckle.Connectors.DUI.WebView/packages.lock.json index 2586c0cd45..9529e2c9c7 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI.WebView/packages.lock.json +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI.WebView/packages.lock.json @@ -262,29 +262,6 @@ "Serilog": "2.10.0" } }, - "Speckle.Core": { - "type": "Transitive", - "resolved": "3.0.1-alpha.11", - "contentHash": "Zt2dBJLlfziEACYCHThbhKypSjhoA01rTw9BzNI72c/BDyftXIz70Tetq/8ZMEqQnKqfmRyYADsAdWKxpdV0Hg==", - "dependencies": { - "GraphQL.Client": "6.0.0", - "Microsoft.CSharp": "4.7.0", - "Microsoft.Data.Sqlite": "7.0.5", - "Polly": "7.2.3", - "Polly.Contrib.WaitAndRetry": "1.1.1", - "Polly.Extensions.Http": "3.0.0", - "Sentry": "3.33.0", - "Sentry.Serilog": "3.33.0", - "Serilog": "2.12.0", - "Serilog.Enrichers.ClientInfo": "1.3.0", - "Serilog.Exceptions": "8.4.0", - "Serilog.Sinks.Console": "4.1.0", - "Serilog.Sinks.Seq": "5.2.2", - "SerilogTimings": "3.0.1", - "Speckle.Newtonsoft.Json": "13.0.2", - "System.DoubleNumerics": "3.1.3" - } - }, "Speckle.Newtonsoft.Json": { "type": "Transitive", "resolved": "13.0.2", @@ -803,29 +780,6 @@ "Serilog": "2.10.0" } }, - "Speckle.Core": { - "type": "Transitive", - "resolved": "3.0.1-alpha.11", - "contentHash": "Zt2dBJLlfziEACYCHThbhKypSjhoA01rTw9BzNI72c/BDyftXIz70Tetq/8ZMEqQnKqfmRyYADsAdWKxpdV0Hg==", - "dependencies": { - "GraphQL.Client": "6.0.0", - "Microsoft.CSharp": "4.7.0", - "Microsoft.Data.Sqlite": "7.0.5", - "Polly": "7.2.3", - "Polly.Contrib.WaitAndRetry": "1.1.1", - "Polly.Extensions.Http": "3.0.0", - "Sentry": "3.33.0", - "Sentry.Serilog": "3.33.0", - "Serilog": "2.12.0", - "Serilog.Enrichers.ClientInfo": "1.3.0", - "Serilog.Exceptions": "8.4.0", - "Serilog.Sinks.Console": "4.1.0", - "Serilog.Sinks.Seq": "5.2.2", - "SerilogTimings": "3.0.1", - "Speckle.Newtonsoft.Json": "13.0.2", - "System.DoubleNumerics": "3.1.3" - } - }, "Speckle.Newtonsoft.Json": { "type": "Transitive", "resolved": "13.0.2", diff --git a/DUI3-DX/Directory.Packages.props b/DUI3-DX/Directory.Packages.props index 5e7ea97006..ece50df9a0 100644 --- a/DUI3-DX/Directory.Packages.props +++ b/DUI3-DX/Directory.Packages.props @@ -3,25 +3,22 @@ - - - - - - - + + + + diff --git a/DUI3-DX/Sdk/Speckle.Connectors.Utils/ContainerRegistration.cs b/DUI3-DX/Sdk/Speckle.Connectors.Utils/ContainerRegistration.cs index 3168ac7709..93a7c326dd 100644 --- a/DUI3-DX/Sdk/Speckle.Connectors.Utils/ContainerRegistration.cs +++ b/DUI3-DX/Sdk/Speckle.Connectors.Utils/ContainerRegistration.cs @@ -1,4 +1,5 @@ -using Microsoft.Extensions.Logging; +using Autofac; +using Microsoft.Extensions.Logging; using Serilog; using Speckle.Autofac.DependencyInjection; using Speckle.Connectors.Utils.Cancellation; @@ -19,6 +20,9 @@ public static void AddConnectorUtils(this SpeckleContainerBuilder builder) var serilogLogger = SpeckleLog.Logger; ILoggerFactory loggerFactory = new LoggerFactory().AddSerilog(serilogLogger); + builder.ContainerBuilder.Register(_ => loggerFactory).As().SingleInstance().AutoActivate(); + + builder.ContainerBuilder.RegisterGeneric(typeof(Logger<>)).As(typeof(ILogger<>)).SingleInstance(); builder.AddSingleton(loggerFactory); } } diff --git a/DUI3-DX/Sdk/Speckle.Connectors.Utils/Speckle.Connectors.Utils.csproj b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Speckle.Connectors.Utils.csproj index d379d2aace..125a1a6f7a 100644 --- a/DUI3-DX/Sdk/Speckle.Connectors.Utils/Speckle.Connectors.Utils.csproj +++ b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Speckle.Connectors.Utils.csproj @@ -6,6 +6,7 @@ + diff --git a/DUI3-DX/Sdk/Speckle.Connectors.Utils/packages.lock.json b/DUI3-DX/Sdk/Speckle.Connectors.Utils/packages.lock.json index 077e72b92b..2b72b82db0 100644 --- a/DUI3-DX/Sdk/Speckle.Connectors.Utils/packages.lock.json +++ b/DUI3-DX/Sdk/Speckle.Connectors.Utils/packages.lock.json @@ -2,6 +2,15 @@ "version": 2, "dependencies": { ".NETStandard,Version=v2.0": { + "Autofac": { + "type": "Direct", + "requested": "[5.2.0, )", + "resolved": "5.2.0", + "contentHash": "V8dBH0dsv75uDzl7Sw+HkhKDPUw2eXnlMjcSVMH+tLo2s67MpTKGyDj1pDcpR+IF2u4YRs0s3/x7R88YJzIWvg==", + "dependencies": { + "Microsoft.Bcl.AsyncInterfaces": "1.1.0" + } + }, "Microsoft.SourceLink.GitHub": { "type": "Direct", "requested": "[8.0.0, )", diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/ContainerRegistration.cs b/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/ContainerRegistration.cs index 07f974d26a..6a5fb37913 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/ContainerRegistration.cs +++ b/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/ContainerRegistration.cs @@ -12,7 +12,6 @@ this SpeckleContainerBuilder builder where TRootToSpeckleConverter : class, IRootToSpeckleConverter where THostToSpeckleUnitConverter : class, IHostToSpeckleUnitConverter { - builder.ScanAssemblyOfType(); builder.AddScoped(); builder.AddScoped, THostToSpeckleUnitConverter>(); /* @@ -30,7 +29,7 @@ This will require consolidating across other connectors. builder.AddScoped(); - builder.RegisterConverters(); + builder.RegisterRawConversions(); builder.InjectNamedTypes(); builder.InjectNamedTypes(); } diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/NamedTypeInjector.cs b/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/NamedTypeInjector.cs index 1c701cc642..c4a0800ce7 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/NamedTypeInjector.cs +++ b/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/NamedTypeInjector.cs @@ -7,8 +7,6 @@ namespace Speckle.Converters.Common.DependencyInjection; public static class ConversionTypesInjector { - private record NamedType(string Name, int Rank, Type Type); - public static void InjectNamedTypes(this SpeckleContainerBuilder containerBuilder) where T : notnull { @@ -21,33 +19,33 @@ public static void InjectNamedTypes(this SpeckleContainerBuilder containerBui { var nameAndRank = x.GetCustomAttribute(); - return new NamedType(Name: nameAndRank.Name, Rank: nameAndRank.Rank, Type: x); + return (name: nameAndRank.Name, rank: nameAndRank.Rank, type: x); }) .ToList(); // we'll register the types accordingly - var names = byName.Select(x => x.Name).Distinct(); + var names = byName.Select(x => x.name).Distinct(); foreach (string name in names) { - var namedTypes = byName.Where(x => x.Name == name).OrderByDescending(y => y.Rank).ToList(); + var namedTypes = byName.Where(x => x.name == name).OrderByDescending(y => y.rank).ToList(); // first type found var first = namedTypes[0]; // POC: may need to be instance per lifecycle scope - containerBuilder.ContainerBuilder.RegisterType(first.Type).Keyed(first.Name).InstancePerLifetimeScope(); + containerBuilder.ContainerBuilder.RegisterType(first.type).Keyed(first.name).InstancePerLifetimeScope(); // POC: not sure yet if... // * This should be an array of types // * Whether the scope should be modified or modifiable // * Whether this is in the write project... hmmm // POC: IsAssignableFrom() - var secondaryType = first.Type.GetInterface(typeof(ITypedConverter<,>).Name); + var secondaryType = first.type.GetInterface(typeof(ITypedConverter<,>).Name); // POC: should we explode if no found? if (secondaryType != null) { containerBuilder.ContainerBuilder - .RegisterType(first.Type) + .RegisterType(first.type) .As(secondaryType) .PropertiesAutowired(PropertyWiringOptions.AllowCircularDependencies) .InstancePerLifetimeScope(); @@ -59,8 +57,8 @@ public static void InjectNamedTypes(this SpeckleContainerBuilder containerBui { // POC: is this the right scope? containerBuilder.ContainerBuilder - .RegisterType(other.Type) - .Keyed($"{other.Name}|{other.Rank}") + .RegisterType(other.type) + .Keyed($"{other.name}|{other.rank}") .InstancePerLifetimeScope(); // POC: not sure yet if... @@ -69,11 +67,11 @@ public static void InjectNamedTypes(this SpeckleContainerBuilder containerBui // * Whether this is in the write project... hmmm // POC: IsAssignableFrom() // NOT very DRY - secondaryType = first.Type.GetInterface(typeof(ITypedConverter<,>).Name); + secondaryType = first.type.GetInterface(typeof(ITypedConverter<,>).Name); // POC: should we explode if no found? if (secondaryType != null) { - containerBuilder.ContainerBuilder.RegisterType(first.Type).As(secondaryType).InstancePerLifetimeScope(); + containerBuilder.ContainerBuilder.RegisterType(first.type).As(secondaryType).InstancePerLifetimeScope(); } } } diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/RawConversionRegisterer.cs b/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/RawConversionRegisterer.cs index 7b8743151e..73745af1f7 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/RawConversionRegisterer.cs +++ b/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/RawConversionRegisterer.cs @@ -6,29 +6,22 @@ namespace Speckle.Converters.Common.DependencyInjection; // POC: review and see if it can be made more generic, related to the // NameAndRankAttribute work that needs doing -public static class ConverterRegistration +public static class RawConversionRegisterer { - public static void RegisterConverters(this SpeckleContainerBuilder containerBuilder) + public static void RegisterRawConversions(this SpeckleContainerBuilder containerBuilder) { // POC: hard-coding speckle... :/ foreach (Type speckleType in containerBuilder.SpeckleTypes) { - foreach (var conversionInterface in RegisterConversionsForType(speckleType)) - { - containerBuilder.ContainerBuilder - .RegisterType(speckleType) - .As(conversionInterface) - .PropertiesAutowired(PropertyWiringOptions.AllowCircularDependencies) - .InstancePerLifetimeScope(); - } + RegisterRawConversionsForType(containerBuilder.ContainerBuilder, speckleType); } } - private static IEnumerable RegisterConversionsForType(Type type) + private static void RegisterRawConversionsForType(ContainerBuilder containerBuilder, Type type) { if (!type.IsClass || type.IsAbstract) { - yield break; + return; } var rawConversionInterfaces = type.GetInterfaces() @@ -36,7 +29,11 @@ private static IEnumerable RegisterConversionsForType(Type type) foreach (var conversionInterface in rawConversionInterfaces) { - yield return conversionInterface.NotNull(); + containerBuilder + .RegisterType(type) + .As(conversionInterface) + .PropertiesAutowired(PropertyWiringOptions.AllowCircularDependencies) + .InstancePerLifetimeScope(); } } } diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common.Tests/FakeType.cs b/DUI3-DX/Sdk/Speckle.Converters.Common.Tests/FakeType.cs deleted file mode 100644 index 517313bd4b..0000000000 --- a/DUI3-DX/Sdk/Speckle.Converters.Common.Tests/FakeType.cs +++ /dev/null @@ -1,109 +0,0 @@ -using System.Diagnostics.CodeAnalysis; -using System.Globalization; -using System.Reflection; - -namespace Speckle.Converters.Common.Tests; - -public class FakeType : Type -{ - public FakeType(string name) - { - Name = name; - } - - public override object[] GetCustomAttributes(bool inherit) => throw new NotImplementedException(); - - public override bool IsDefined(Type attributeType, bool inherit) => throw new NotImplementedException(); - - public override ConstructorInfo[] GetConstructors(BindingFlags bindingAttr) => throw new NotImplementedException(); - - public override Type GetInterface(string name, bool ignoreCase) => throw new NotImplementedException(); - - public override Type[] GetInterfaces() => throw new NotImplementedException(); - - public override EventInfo GetEvent(string name, BindingFlags bindingAttr) => throw new NotImplementedException(); - - public override EventInfo[] GetEvents(BindingFlags bindingAttr) => throw new NotImplementedException(); - - public override Type[] GetNestedTypes(BindingFlags bindingAttr) => throw new NotImplementedException(); - - public override Type GetNestedType(string name, BindingFlags bindingAttr) => throw new NotImplementedException(); - - public override Type GetElementType() => throw new NotImplementedException(); - - protected override bool HasElementTypeImpl() => throw new NotImplementedException(); - - protected override PropertyInfo GetPropertyImpl( - string name, - BindingFlags bindingAttr, - Binder binder, - Type returnType, - Type[] types, - ParameterModifier[] modifiers - ) => throw new NotImplementedException(); - - public override PropertyInfo[] GetProperties(BindingFlags bindingAttr) => throw new NotImplementedException(); - - protected override MethodInfo GetMethodImpl( - string name, - BindingFlags bindingAttr, - Binder binder, - CallingConventions callConvention, - Type[] types, - ParameterModifier[] modifiers - ) => throw new NotImplementedException(); - - public override MethodInfo[] GetMethods(BindingFlags bindingAttr) => throw new NotImplementedException(); - - public override FieldInfo GetField(string name, BindingFlags bindingAttr) => throw new NotImplementedException(); - - public override FieldInfo[] GetFields(BindingFlags bindingAttr) => throw new NotImplementedException(); - - public override MemberInfo[] GetMembers(BindingFlags bindingAttr) => throw new NotImplementedException(); - - protected override TypeAttributes GetAttributeFlagsImpl() => throw new NotImplementedException(); - - protected override bool IsArrayImpl() => throw new NotImplementedException(); - - protected override bool IsByRefImpl() => throw new NotImplementedException(); - - protected override bool IsPointerImpl() => throw new NotImplementedException(); - - protected override bool IsPrimitiveImpl() => throw new NotImplementedException(); - - protected override bool IsCOMObjectImpl() => throw new NotImplementedException(); - - public override object InvokeMember( - string name, - BindingFlags invokeAttr, - Binder binder, - object target, - object[] args, - ParameterModifier[] modifiers, - CultureInfo culture, - string[] namedParameters - ) => throw new NotImplementedException(); - - public override Type UnderlyingSystemType { get; } - - protected override ConstructorInfo GetConstructorImpl( - BindingFlags bindingAttr, - Binder binder, - CallingConventions callConvention, - Type[] types, - ParameterModifier[] modifiers - ) => throw new NotImplementedException(); - - public override string Name { get; } - - [SuppressMessage("Naming", "CA1720:Identifier contains type name")] - public override Guid GUID { get; } = Guid.Empty; - public override Module Module { get; } - public override Assembly Assembly { get; } - public override string FullName { get; } - public override string Namespace { get; } - public override string AssemblyQualifiedName { get; } - public override Type BaseType { get; } - - public override object[] GetCustomAttributes(Type attributeType, bool inherit) => throw new NotImplementedException(); -} diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common.Tests/RootToSpeckleConverterTests.cs b/DUI3-DX/Sdk/Speckle.Converters.Common.Tests/RootToSpeckleConverterTests.cs deleted file mode 100644 index ae505bb94b..0000000000 --- a/DUI3-DX/Sdk/Speckle.Converters.Common.Tests/RootToSpeckleConverterTests.cs +++ /dev/null @@ -1,66 +0,0 @@ -using FluentAssertions; -using Moq; -using NUnit.Framework; -using Speckle.Core.Models; - -namespace Speckle.Converters.Common.Tests; - -public class RootToSpeckleConverterTests -{ - private readonly MockRepository _repository = new(MockBehavior.Strict); - - private readonly Mock _rootConvertManager; - private readonly Mock _proxyMapper; - private readonly Mock _rootElementProvider; - - public RootToSpeckleConverterTests() - { - _rootConvertManager = _repository.Create(); - _proxyMapper = _repository.Create(); - _rootElementProvider = _repository.Create(); - } - - [TearDown] - public void Verify() => _repository.VerifyAll(); - - [Test] - public void Convert_BaseType() - { - try - { - Type baseType = new FakeType("baseType"); - Type hostType = new FakeType("hostType"); - - object target = new(); - Type targetType = new FakeType("targetType"); - - object wrappedTarget = new(); - Base converted = new(); - - _rootConvertManager.Setup(x => x.GetTargetType(target)).Returns(targetType); - _rootElementProvider.Setup(x => x.GetRootType()).Returns(baseType); - _proxyMapper.Setup(x => x.GetHostTypeFromMappedType(baseType)).Returns(hostType); - - _proxyMapper.Setup(x => x.GetMappedTypeFromHostType(targetType)).Returns((Type?)null); - _proxyMapper.Setup(x => x.GetMappedTypeFromProxyType(targetType)).Returns((Type?)null); - - _rootConvertManager.Setup(x => x.IsSubClass(baseType, targetType)).Returns(true); - _proxyMapper.Setup(x => x.CreateProxy(baseType, target)).Returns(wrappedTarget); - _rootConvertManager.Setup(x => x.Convert(baseType, wrappedTarget)).Returns(converted); - - var rootToSpeckleConverter = new RootToSpeckleConverter( - _proxyMapper.Object, - _rootConvertManager.Object, - _rootElementProvider.Object - ); - var testConverted = rootToSpeckleConverter.Convert(target); - - testConverted.Should().BeSameAs(converted); - } - catch (Exception e) - { - Console.WriteLine(e); - throw; - } - } -} diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common.Tests/Speckle.Converters.Common.Tests.csproj b/DUI3-DX/Sdk/Speckle.Converters.Common.Tests/Speckle.Converters.Common.Tests.csproj deleted file mode 100644 index e5baa8e603..0000000000 --- a/DUI3-DX/Sdk/Speckle.Converters.Common.Tests/Speckle.Converters.Common.Tests.csproj +++ /dev/null @@ -1,24 +0,0 @@ - - - - net48 - x64 - false - true - - - - - - - - - - - - - - - - - diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common.Tests/packages.lock.json b/DUI3-DX/Sdk/Speckle.Converters.Common.Tests/packages.lock.json deleted file mode 100644 index 25241e1d85..0000000000 --- a/DUI3-DX/Sdk/Speckle.Converters.Common.Tests/packages.lock.json +++ /dev/null @@ -1,468 +0,0 @@ -{ - "version": 2, - "dependencies": { - ".NETFramework,Version=v4.8": { - "FluentAssertions": { - "type": "Direct", - "requested": "[6.12.0, )", - "resolved": "6.12.0", - "contentHash": "ZXhHT2YwP9lajrwSKbLlFqsmCCvFJMoRSK9t7sImfnCyd0OB3MhgxdoMcVqxbq1iyxD6mD2fiackWmBb7ayiXQ==", - "dependencies": { - "System.Threading.Tasks.Extensions": "4.5.0" - } - }, - "Microsoft.NET.Test.Sdk": { - "type": "Direct", - "requested": "[17.10.0, )", - "resolved": "17.10.0", - "contentHash": "0/2HeACkaHEYU3wc83YlcD2Fi4LMtECJjqrtvw0lPi9DCEa35zSPt1j4fuvM8NagjDqJuh1Ja35WcRtn1Um6/A==", - "dependencies": { - "Microsoft.CodeCoverage": "17.10.0" - } - }, - "Microsoft.SourceLink.GitHub": { - "type": "Direct", - "requested": "[8.0.0, )", - "resolved": "8.0.0", - "contentHash": "G5q7OqtwIyGTkeIOAc3u2ZuV/kicQaec5EaRnc0pIeSnh9LUjj+PYQrJYBURvDt7twGl2PKA7nSN0kz1Zw5bnQ==", - "dependencies": { - "Microsoft.Build.Tasks.Git": "8.0.0", - "Microsoft.SourceLink.Common": "8.0.0" - } - }, - "Moq": { - "type": "Direct", - "requested": "[4.20.70, )", - "resolved": "4.20.70", - "contentHash": "4rNnAwdpXJBuxqrOCzCyICXHSImOTRktCgCWXWykuF1qwoIsVvEnR7PjbMk/eLOxWvhmj5Kwt+kDV3RGUYcNwg==", - "dependencies": { - "Castle.Core": "5.1.1", - "System.Threading.Tasks.Extensions": "4.5.4" - } - }, - "NUnit": { - "type": "Direct", - "requested": "[4.1.0, )", - "resolved": "4.1.0", - "contentHash": "MT/DpAhjtiytzhTgTqIhBuWx4y26PKfDepYUHUM+5uv4TsryHC2jwFo5e6NhWkApCm/G6kZ80dRjdJFuAxq3rg==", - "dependencies": { - "System.Threading.Tasks.Extensions": "4.5.4" - } - }, - "NUnit.Analyzers": { - "type": "Direct", - "requested": "[4.2.0, )", - "resolved": "4.2.0", - "contentHash": "4fJojPkzdoa4nB2+p6U+fITvPnVvwWSnsmiJ/Dl30xqiL3oxNbYvfeSLVd91hOmEjoUqSwN3Z7j1aFedjqWbUA==" - }, - "PolySharp": { - "type": "Direct", - "requested": "[1.14.1, )", - "resolved": "1.14.1", - "contentHash": "mOOmFYwad3MIOL14VCjj02LljyF1GNw1wP0YVlxtcPvqdxjGGMNdNJJxHptlry3MOd8b40Flm8RPOM8JOlN2sQ==" - }, - "Speckle.InterfaceGenerator": { - "type": "Direct", - "requested": "[0.9.5, )", - "resolved": "0.9.5", - "contentHash": "oU/L7pN1R7q8KkbrpQ3WJnHirPHqn+9DEA7asOcUiggV5dzVg1A/VYs7GOSusD24njxXh03tE3a2oTLOjt3cVg==" - }, - "Speckle.Revit2023.Interfaces": { - "type": "Direct", - "requested": "[0.1.1-preview.0.28, )", - "resolved": "0.1.1-preview.0.28", - "contentHash": "7szXg/vRvP3Wdrn2ZGriVOfsw+bddlpVorBkCIhSHHs5qVTTG8IAIrI1l9dO0/aullaTMF+Xgxm9x3w1aXPiuA==" - }, - "Castle.Core": { - "type": "Transitive", - "resolved": "5.1.1", - "contentHash": "rpYtIczkzGpf+EkZgDr9CClTdemhsrwA/W5hMoPjLkRFnXzH44zDLoovXeKtmxb1ykXK9aJVODSpiJml8CTw2g==" - }, - "GraphQL.Client": { - "type": "Transitive", - "resolved": "6.0.0", - "contentHash": "8yPNBbuVBpTptivyAlak4GZvbwbUcjeQTL4vN1HKHRuOykZ4r7l5fcLS6vpyPyLn0x8FsL31xbOIKyxbmR9rbA==", - "dependencies": { - "GraphQL.Client.Abstractions": "6.0.0", - "GraphQL.Client.Abstractions.Websocket": "6.0.0", - "System.Net.WebSockets.Client.Managed": "1.0.22", - "System.Reactive": "5.0.0" - } - }, - "GraphQL.Client.Abstractions": { - "type": "Transitive", - "resolved": "6.0.0", - "contentHash": "h7uzWFORHZ+CCjwr/ThAyXMr0DPpzEANDa4Uo54wqCQ+j7qUKwqYTgOrb1W40sqbvNaZm9v/X7It31SUw0maHA==", - "dependencies": { - "GraphQL.Primitives": "6.0.0" - } - }, - "GraphQL.Client.Abstractions.Websocket": { - "type": "Transitive", - "resolved": "6.0.0", - "contentHash": "Nr9bPf8gIOvLuXpqEpqr9z9jslYFJOvd0feHth3/kPqeR3uMbjF5pjiwh4jxyMcxHdr8Pb6QiXkV3hsSyt0v7A==", - "dependencies": { - "GraphQL.Client.Abstractions": "6.0.0" - } - }, - "GraphQL.Primitives": { - "type": "Transitive", - "resolved": "6.0.0", - "contentHash": "yg72rrYDapfsIUrul7aF6wwNnTJBOFvuA9VdDTQpPa8AlAriHbufeXYLBcodKjfUdkCnaiggX1U/nEP08Zb5GA==" - }, - "Microsoft.Bcl.AsyncInterfaces": { - "type": "Transitive", - "resolved": "5.0.0", - "contentHash": "W8DPQjkMScOMTtJbPwmPyj9c3zYSFGawDW3jwlBOOsnY+EzZFLgNQ/UMkK35JmkNOVPdCyPr2Tw7Vv9N+KA3ZQ==", - "dependencies": { - "System.Threading.Tasks.Extensions": "4.5.4" - } - }, - "Microsoft.Build.Tasks.Git": { - "type": "Transitive", - "resolved": "8.0.0", - "contentHash": "bZKfSIKJRXLTuSzLudMFte/8CempWjVamNUR5eHJizsy+iuOuO/k2gnh7W0dHJmYY0tBf+gUErfluCv5mySAOQ==" - }, - "Microsoft.CodeCoverage": { - "type": "Transitive", - "resolved": "17.10.0", - "contentHash": "yC7oSlnR54XO5kOuHlVOKtxomNNN1BWXX8lK1G2jaPXT9sUok7kCOoA4Pgs0qyFaCtMrNsprztYMeoEGqCm4uA==" - }, - "Microsoft.CSharp": { - "type": "Transitive", - "resolved": "4.7.0", - "contentHash": "pTj+D3uJWyN3My70i2Hqo+OXixq3Os2D1nJ2x92FFo6sk8fYS1m1WLNTs0Dc1uPaViH0YvEEwvzddQ7y4rhXmA==" - }, - "Microsoft.Data.Sqlite": { - "type": "Transitive", - "resolved": "7.0.5", - "contentHash": "KGxbPeWsQMnmQy43DSBxAFtHz3l2JX8EWBSGUCvT3CuZ8KsuzbkqMIJMDOxWtG8eZSoCDI04aiVQjWuuV8HmSw==", - "dependencies": { - "Microsoft.Data.Sqlite.Core": "7.0.5", - "SQLitePCLRaw.bundle_e_sqlite3": "2.1.4" - } - }, - "Microsoft.Data.Sqlite.Core": { - "type": "Transitive", - "resolved": "7.0.5", - "contentHash": "FTerRmQPqHrCrnoUzhBu+E+1DNGwyrAMLqHkAqOOOu5pGfyMOj8qQUBxI/gDtWtG11p49UxSfWmBzRNlwZqfUg==", - "dependencies": { - "SQLitePCLRaw.core": "2.1.4" - } - }, - "Microsoft.SourceLink.Common": { - "type": "Transitive", - "resolved": "8.0.0", - "contentHash": "dk9JPxTCIevS75HyEQ0E4OVAFhB2N+V9ShCXf8Q6FkUQZDkgLI12y679Nym1YqsiSysuQskT7Z+6nUf3yab6Vw==" - }, - "Polly": { - "type": "Transitive", - "resolved": "7.2.3", - "contentHash": "DeCY0OFbNdNxsjntr1gTXHJ5pKUwYzp04Er2LLeN3g6pWhffsGuKVfMBLe1lw7x76HrPkLxKEFxBlpRxS2nDEQ==" - }, - "Polly.Contrib.WaitAndRetry": { - "type": "Transitive", - "resolved": "1.1.1", - "contentHash": "1MUQLiSo4KDkQe6nzQRhIU05lm9jlexX5BVsbuw0SL82ynZ+GzAHQxJVDPVBboxV37Po3SG077aX8DuSy8TkaA==" - }, - "Polly.Extensions.Http": { - "type": "Transitive", - "resolved": "3.0.0", - "contentHash": "drrG+hB3pYFY7w1c3BD+lSGYvH2oIclH8GRSehgfyP5kjnFnHKQuuBhuHLv+PWyFuaTDyk/vfRpnxOzd11+J8g==", - "dependencies": { - "Polly": "7.1.0" - } - }, - "Sentry": { - "type": "Transitive", - "resolved": "3.33.0", - "contentHash": "8vbD2o6IR2wrRrkSiRbnodWGWUOqIlwYtzpjvPNOb5raJdOf+zxMwfS8f6nx9bmrTTfDj7KrCB8C/5OuicAc8A==", - "dependencies": { - "System.Reflection.Metadata": "5.0.0", - "System.Runtime.InteropServices.RuntimeInformation": "4.3.0", - "System.Text.Json": "5.0.2" - } - }, - "Sentry.Serilog": { - "type": "Transitive", - "resolved": "3.33.0", - "contentHash": "V8BU7QGWg2qLYfNPqtuTBhC1opysny5l+Ifp6J6PhOeAxU0FssR7nYfbJVetrnLIoh2rd3DlJ6hHYYQosQYcUQ==", - "dependencies": { - "Sentry": "3.33.0", - "Serilog": "2.7.1" - } - }, - "Serilog": { - "type": "Transitive", - "resolved": "2.12.0", - "contentHash": "xaiJLIdu6rYMKfQMYUZgTy8YK7SMZjB4Yk50C/u//Z4OsvxkUfSPJy4nknfvwAC34yr13q7kcyh4grbwhSxyZg==" - }, - "Serilog.Enrichers.ClientInfo": { - "type": "Transitive", - "resolved": "1.3.0", - "contentHash": "mTc7PM+wC9Hr7LWSwqt5mmnlAr7RJs+eTb3PGPRhwdOackk95MkhUZognuxXEdlW19HAFNmEBTSBY5DfLwM8jQ==", - "dependencies": { - "Serilog": "2.4.0" - } - }, - "Serilog.Exceptions": { - "type": "Transitive", - "resolved": "8.4.0", - "contentHash": "nc/+hUw3lsdo0zCj0KMIybAu7perMx79vu72w0za9Nsi6mWyNkGXxYxakAjWB7nEmYL6zdmhEQRB4oJ2ALUeug==", - "dependencies": { - "Serilog": "2.8.0" - } - }, - "Serilog.Formatting.Compact": { - "type": "Transitive", - "resolved": "1.1.0", - "contentHash": "pNroKVjo+rDqlxNG5PXkRLpfSCuDOBY0ri6jp9PLe505ljqwhwZz8ospy2vWhQlFu5GkIesh3FcDs4n7sWZODA==", - "dependencies": { - "Serilog": "2.8.0" - } - }, - "Serilog.Sinks.Console": { - "type": "Transitive", - "resolved": "4.1.0", - "contentHash": "K6N5q+5fetjnJPvCmkWOpJ/V8IEIoMIB1s86OzBrbxwTyHxdx3pmz4H+8+O/Dc/ftUX12DM1aynx/dDowkwzqg==", - "dependencies": { - "Serilog": "2.10.0" - } - }, - "Serilog.Sinks.File": { - "type": "Transitive", - "resolved": "5.0.0", - "contentHash": "uwV5hdhWPwUH1szhO8PJpFiahqXmzPzJT/sOijH/kFgUx+cyoDTMM8MHD0adw9+Iem6itoibbUXHYslzXsLEAg==", - "dependencies": { - "Serilog": "2.10.0" - } - }, - "Serilog.Sinks.PeriodicBatching": { - "type": "Transitive", - "resolved": "3.1.0", - "contentHash": "NDWR7m3PalVlGEq3rzoktrXikjFMLmpwF0HI4sowo8YDdU+gqPlTHlDQiOGxHfB0sTfjPA9JjA7ctKG9zqjGkw==", - "dependencies": { - "Serilog": "2.0.0" - } - }, - "Serilog.Sinks.Seq": { - "type": "Transitive", - "resolved": "5.2.2", - "contentHash": "1Csmo5ua7NKUe0yXUx+zsRefjAniPWcXFhUXxXG8pwo0iMiw2gjn9SOkgYnnxbgWqmlGv236w0N/dHc2v5XwMg==", - "dependencies": { - "Serilog": "2.12.0", - "Serilog.Formatting.Compact": "1.1.0", - "Serilog.Sinks.File": "5.0.0", - "Serilog.Sinks.PeriodicBatching": "3.1.0" - } - }, - "SerilogTimings": { - "type": "Transitive", - "resolved": "3.0.1", - "contentHash": "Zs28eTgszAMwpIrbBnWHBI50yuxL50p/dmAUWmy75+axdZYK/Sjm5/5m1N/CisR8acJUhTVcjPZrsB1P5iv0Uw==", - "dependencies": { - "Serilog": "2.10.0" - } - }, - "Speckle.Newtonsoft.Json": { - "type": "Transitive", - "resolved": "13.0.2", - "contentHash": "g1BejUZwax5PRfL6xHgLEK23sqHWOgOj9hE7RvfRRlN00AGt8GnPYt8HedSK7UB3HiRW8zCA9Pn0iiYxCK24BA==" - }, - "SQLitePCLRaw.bundle_e_sqlite3": { - "type": "Transitive", - "resolved": "2.1.4", - "contentHash": "EWI1olKDjFEBMJu0+3wuxwziIAdWDVMYLhuZ3Qs84rrz+DHwD00RzWPZCa+bLnHCf3oJwuFZIRsHT5p236QXww==", - "dependencies": { - "SQLitePCLRaw.lib.e_sqlite3": "2.1.4", - "SQLitePCLRaw.provider.dynamic_cdecl": "2.1.4" - } - }, - "SQLitePCLRaw.core": { - "type": "Transitive", - "resolved": "2.1.4", - "contentHash": "inBjvSHo9UDKneGNzfUfDjK08JzlcIhn1+SP5Y3m6cgXpCxXKCJDy6Mka7LpgSV+UZmKSnC8rTwB0SQ0xKu5pA==", - "dependencies": { - "System.Memory": "4.5.3" - } - }, - "SQLitePCLRaw.lib.e_sqlite3": { - "type": "Transitive", - "resolved": "2.1.4", - "contentHash": "2C9Q9eX7CPLveJA0rIhf9RXAvu+7nWZu1A2MdG6SD/NOu26TakGgL1nsbc0JAspGijFOo3HoN79xrx8a368fBg==" - }, - "SQLitePCLRaw.provider.dynamic_cdecl": { - "type": "Transitive", - "resolved": "2.1.4", - "contentHash": "ZsaKKhgYF9B1fvcnOGKl3EycNAwd9CRWX7v0rEfuPWhQQ5Jjpvf2VEHahiLIGHio3hxi3EIKFJw9KvyowWOUAw==", - "dependencies": { - "SQLitePCLRaw.core": "2.1.4" - } - }, - "System.Buffers": { - "type": "Transitive", - "resolved": "4.5.1", - "contentHash": "Rw7ijyl1qqRS0YQD/WycNst8hUUMgrMH4FCn1nNm27M4VxchZ1js3fVjQaANHO5f3sN4isvP4a+Met9Y4YomAg==" - }, - "System.Collections.Immutable": { - "type": "Transitive", - "resolved": "5.0.0", - "contentHash": "FXkLXiK0sVVewcso0imKQoOxjoPAj42R8HtjjbSjVPAzwDfzoyoznWxgA3c38LDbN9SJux1xXoXYAhz98j7r2g==", - "dependencies": { - "System.Memory": "4.5.4" - } - }, - "System.DoubleNumerics": { - "type": "Transitive", - "resolved": "3.1.3", - "contentHash": "KRKEM/L3KBodjA9VOg3EifFVWUY6EOqaMB05UvPEDm7Zeby/kZW+4kdWUEPzW6xtkwf46p661L9NrbeeQhtLzw==", - "dependencies": { - "NETStandard.Library": "1.6.1" - } - }, - "System.Memory": { - "type": "Transitive", - "resolved": "4.5.5", - "contentHash": "XIWiDvKPXaTveaB7HVganDlOCRoj03l+jrwNvcge/t8vhGYKvqV+dMv6G4SAX2NoNmN0wZfVPTAlFwZcZvVOUw==", - "dependencies": { - "System.Buffers": "4.5.1", - "System.Numerics.Vectors": "4.5.0", - "System.Runtime.CompilerServices.Unsafe": "4.5.3" - } - }, - "System.Net.WebSockets.Client.Managed": { - "type": "Transitive", - "resolved": "1.0.22", - "contentHash": "WqEOxPlXjuZrIjUtXNE9NxEfU/n5E35iV2PtoZdJSUC4tlrqwHnTee+wvMIM4OUaJWmwrymeqcgYrE0IkGAgLA==", - "dependencies": { - "System.Buffers": "4.4.0", - "System.Numerics.Vectors": "4.4.0" - } - }, - "System.Numerics.Vectors": { - "type": "Transitive", - "resolved": "4.5.0", - "contentHash": "QQTlPTl06J/iiDbJCiepZ4H//BVraReU4O4EoRw1U02H5TLUIT7xn3GnDp9AXPSlJUDyFs4uWjWafNX6WrAojQ==" - }, - "System.Reactive": { - "type": "Transitive", - "resolved": "5.0.0", - "contentHash": "erBZjkQHWL9jpasCE/0qKAryzVBJFxGHVBAvgRN1bzM0q2s1S4oYREEEL0Vb+1kA/6BKb5FjUZMp5VXmy+gzkQ==", - "dependencies": { - "System.Threading.Tasks.Extensions": "4.5.4" - } - }, - "System.Reflection.Metadata": { - "type": "Transitive", - "resolved": "5.0.0", - "contentHash": "5NecZgXktdGg34rh1OenY1rFNDCI8xSjFr+Z4OU4cU06AQHUdRnIIEeWENu3Wl4YowbzkymAIMvi3WyK9U53pQ==", - "dependencies": { - "System.Collections.Immutable": "5.0.0" - } - }, - "System.Runtime.CompilerServices.Unsafe": { - "type": "Transitive", - "resolved": "5.0.0", - "contentHash": "ZD9TMpsmYJLrxbbmdvhwt9YEgG5WntEnZ/d1eH8JBX9LBp+Ju8BSBhUGbZMNVHHomWo2KVImJhTDl2hIgw/6MA==" - }, - "System.Runtime.InteropServices.RuntimeInformation": { - "type": "Transitive", - "resolved": "4.3.0", - "contentHash": "cbz4YJMqRDR7oLeMRbdYv7mYzc++17lNhScCX0goO2XpGWdvAt60CGN+FHdePUEHCe/Jy9jUlvNAiNdM+7jsOw==" - }, - "System.Text.Encodings.Web": { - "type": "Transitive", - "resolved": "5.0.1", - "contentHash": "KmJ+CJXizDofbq6mpqDoRRLcxgOd2z9X3XoFNULSbvbqVRZkFX3istvr+MUjL6Zw1RT+RNdoI4GYidIINtgvqQ==", - "dependencies": { - "System.Buffers": "4.5.1", - "System.Memory": "4.5.4" - } - }, - "System.Text.Json": { - "type": "Transitive", - "resolved": "5.0.2", - "contentHash": "I47dVIGiV6SfAyppphxqupertT/5oZkYLDCX6vC3HpOI4ZLjyoKAreUoem2ie6G0RbRuFrlqz/PcTQjfb2DOfQ==", - "dependencies": { - "Microsoft.Bcl.AsyncInterfaces": "5.0.0", - "System.Buffers": "4.5.1", - "System.Memory": "4.5.4", - "System.Numerics.Vectors": "4.5.0", - "System.Runtime.CompilerServices.Unsafe": "5.0.0", - "System.Text.Encodings.Web": "5.0.1", - "System.Threading.Tasks.Extensions": "4.5.4", - "System.ValueTuple": "4.5.0" - } - }, - "System.Threading.Tasks.Extensions": { - "type": "Transitive", - "resolved": "4.5.4", - "contentHash": "zteT+G8xuGu6mS+mzDzYXbzS7rd3K6Fjb9RiZlYlJPam2/hU7JCBZBVEcywNuR+oZ1ncTvc/cq0faRr3P01OVg==", - "dependencies": { - "System.Runtime.CompilerServices.Unsafe": "4.5.3" - } - }, - "System.ValueTuple": { - "type": "Transitive", - "resolved": "4.5.0", - "contentHash": "okurQJO6NRE/apDIP23ajJ0hpiNmJ+f0BwOlB/cSqTLQlw5upkf+5+96+iG2Jw40G1fCVCyPz/FhIABUjMR+RQ==" - }, - "speckle.autofac": { - "type": "Project", - "dependencies": { - "Microsoft.Extensions.Logging.Abstractions": "[7.0.0, )" - } - }, - "speckle.converters.common": { - "type": "Project", - "dependencies": { - "Speckle.Autofac": "[2.0.999-local, )", - "Speckle.Objects": "[3.0.1-alpha.11, )" - } - }, - "Microsoft.Extensions.Logging.Abstractions": { - "type": "CentralTransitive", - "requested": "[7.0.0, )", - "resolved": "7.0.0", - "contentHash": "kmn78+LPVMOWeITUjIlfxUPDsI0R6G0RkeAMBmQxAJ7vBJn4q2dTva7pWi65ceN5vPGjJ9q/Uae2WKgvfktJAw==", - "dependencies": { - "System.Buffers": "4.5.1", - "System.Memory": "4.5.5" - } - }, - "Speckle.Core": { - "type": "CentralTransitive", - "requested": "[3.0.1-alpha.11, )", - "resolved": "3.0.1-alpha.11", - "contentHash": "Zt2dBJLlfziEACYCHThbhKypSjhoA01rTw9BzNI72c/BDyftXIz70Tetq/8ZMEqQnKqfmRyYADsAdWKxpdV0Hg==", - "dependencies": { - "GraphQL.Client": "6.0.0", - "Microsoft.CSharp": "4.7.0", - "Microsoft.Data.Sqlite": "7.0.5", - "Polly": "7.2.3", - "Polly.Contrib.WaitAndRetry": "1.1.1", - "Polly.Extensions.Http": "3.0.0", - "Sentry": "3.33.0", - "Sentry.Serilog": "3.33.0", - "Serilog": "2.12.0", - "Serilog.Enrichers.ClientInfo": "1.3.0", - "Serilog.Exceptions": "8.4.0", - "Serilog.Sinks.Console": "4.1.0", - "Serilog.Sinks.Seq": "5.2.2", - "SerilogTimings": "3.0.1", - "Speckle.Newtonsoft.Json": "13.0.2", - "System.DoubleNumerics": "3.1.3" - } - }, - "Speckle.Objects": { - "type": "CentralTransitive", - "requested": "[3.0.1-alpha.11, )", - "resolved": "3.0.1-alpha.11", - "contentHash": "YR7sei3OQBAi8R/kIu8bEmg5ELDIJK6l5fhOgdnqA9ZvD/fvmRb+09z8lIUTDsgdAdvYU/A/x9VxH9OGPbp9Kw==", - "dependencies": { - "Speckle.Core": "3.0.1-alpha.11" - } - } - } - } -} \ No newline at end of file diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common/ContextWrapper.cs b/DUI3-DX/Sdk/Speckle.Converters.Common/ContextWrapper.cs index 97d77a3389..02088f06bb 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common/ContextWrapper.cs +++ b/DUI3-DX/Sdk/Speckle.Converters.Common/ContextWrapper.cs @@ -5,7 +5,7 @@ public class ContextWrapper : IDisposable { private IConversionContextStack? _stack; - public IConversionContext? Context { get; private set; } + public ConversionContext? Context { get; private set; } public ContextWrapper(IConversionContextStack stack) { diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common/ConversionContext.cs b/DUI3-DX/Sdk/Speckle.Converters.Common/ConversionContext.cs index c4423c1cc2..723877d0b9 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common/ConversionContext.cs +++ b/DUI3-DX/Sdk/Speckle.Converters.Common/ConversionContext.cs @@ -1,9 +1,7 @@ -using Speckle.InterfaceGenerator; +namespace Speckle.Converters.Common; -namespace Speckle.Converters.Common; - -[GenerateAutoInterface] -public class ConversionContext : IConversionContext +// POC: record? +public class ConversionContext where TDocument : class { public ConversionContext(TDocument doc, string speckleUnits) diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common/ConversionContextStack.cs b/DUI3-DX/Sdk/Speckle.Converters.Common/ConversionContextStack.cs index 4575c4da49..918a29d3c1 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common/ConversionContextStack.cs +++ b/DUI3-DX/Sdk/Speckle.Converters.Common/ConversionContextStack.cs @@ -28,9 +28,9 @@ IHostToSpeckleUnitConverter unitConverter _stack.Push(new ConversionContext(_document, _unitConverter.ConvertOrThrow(hostUnit))); } - private readonly Stack> _stack = new(); + private readonly Stack> _stack = new(); - public IConversionContext Current => _stack.Peek(); + public ConversionContext Current => _stack.Peek(); public ContextWrapper Push(string speckleUnit) { @@ -39,7 +39,10 @@ public ContextWrapper Push(string speckleUnit) return new ContextWrapper(this); } - public ContextWrapper Push(THostUnit hostUnit) => Push(_unitConverter.ConvertOrThrow(hostUnit)); + public ContextWrapper Push(THostUnit hostUnit) + { + return Push(_unitConverter.ConvertOrThrow(hostUnit)); + } public void Pop() => _stack.Pop(); } diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common/IProxyMapper.cs b/DUI3-DX/Sdk/Speckle.Converters.Common/IProxyMapper.cs deleted file mode 100644 index 8b467d9395..0000000000 --- a/DUI3-DX/Sdk/Speckle.Converters.Common/IProxyMapper.cs +++ /dev/null @@ -1,33 +0,0 @@ -namespace Speckle.Converters.Common; - -public interface IProxyMapper -{ - Type? GetMappedTypeFromHostType(Type type); - Type? GetMappedTypeFromProxyType(Type type); - Type? GetHostTypeFromMappedType(Type type); - - object CreateProxy(Type type, object toWrap); - - T CreateProxy(object toWrap); -} - -public record WrappedType(Type Type, object Target); - -// ghetto default interface implementation :( -public static class ProxyMapExtensions -{ - public static WrappedType? WrapIfExists(this IProxyMapper proxyMap, Type target, object toWrap) - { - var mappedType = proxyMap.GetMappedTypeFromHostType(target); - if (mappedType is not null) - { - return new(mappedType, proxyMap.CreateProxy(mappedType, toWrap)); - } - mappedType = proxyMap.GetMappedTypeFromProxyType(target); - if (mappedType is not null) - { - return new(mappedType, toWrap); - } - return null; - } -} diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common/LegacyRootToSpeckleConverter.cs b/DUI3-DX/Sdk/Speckle.Converters.Common/LegacyRootToSpeckleConverter.cs deleted file mode 100644 index 34cd5576a2..0000000000 --- a/DUI3-DX/Sdk/Speckle.Converters.Common/LegacyRootToSpeckleConverter.cs +++ /dev/null @@ -1,37 +0,0 @@ -using Speckle.Autofac.DependencyInjection; -using Speckle.Converters.Common.Objects; -using Speckle.Core.Models; - -namespace Speckle.Converters.Common; - -public class LegacyRootToSpeckleConverter : IRootToSpeckleConverter -{ - private readonly IFactory _toSpeckle; - - public LegacyRootToSpeckleConverter(IFactory toSpeckle) - { - _toSpeckle = toSpeckle; - } - - public Base Convert(object target) - { - Type type = target.GetType(); - try - { - var objectConverter = _toSpeckle.ResolveInstance(type.Name); //poc: would be nice to have supertypes resolve - - if (objectConverter == null) - { - throw new NotSupportedException($"No conversion found for {type.Name}"); - } - var convertedObject = objectConverter.Convert(target); - - return convertedObject; - } - catch (SpeckleConversionException e) - { - Console.WriteLine(e); - throw; // Just rethrowing for now, Logs may be needed here. - } - } -} diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common/RootConvertManager.cs b/DUI3-DX/Sdk/Speckle.Converters.Common/RootConvertManager.cs index 6f29a573ad..4ae930fa1c 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common/RootConvertManager.cs +++ b/DUI3-DX/Sdk/Speckle.Converters.Common/RootConvertManager.cs @@ -27,7 +27,7 @@ public Base Convert(Type type, object obj) if (objectConverter == null) { - throw new NotSupportedException($"No conversion found for {type.Name} with actual type of {obj.GetType()}"); + throw new NotSupportedException($"No conversion found for {type.Name}"); } var convertedObject = objectConverter.Convert(obj); diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common/RootToSpeckleConverter.cs b/DUI3-DX/Sdk/Speckle.Converters.Common/RootToSpeckleConverter.cs index 18ccad7495..d1807e231f 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common/RootToSpeckleConverter.cs +++ b/DUI3-DX/Sdk/Speckle.Converters.Common/RootToSpeckleConverter.cs @@ -1,3 +1,5 @@ +using Speckle.Autofac.DependencyInjection; +using Speckle.Converters.Common.Objects; using Speckle.Core.Models; using Speckle.InterfaceGenerator; @@ -6,41 +8,32 @@ namespace Speckle.Converters.Common; [GenerateAutoInterface] public class RootToSpeckleConverter : IRootToSpeckleConverter { - private readonly IRootConvertManager _rootConvertManager; - private readonly IProxyMapper _proxyMapper; - private readonly IRootElementProvider _rootElementProvider; + private readonly IFactory _toSpeckle; - private readonly Type _revitElementType; - - public RootToSpeckleConverter( - IProxyMapper proxyMapper, - IRootConvertManager rootConvertManager, - IRootElementProvider rootElementProvider - ) + public RootToSpeckleConverter(IFactory toSpeckle) { - _proxyMapper = proxyMapper; - _rootConvertManager = rootConvertManager; - _rootElementProvider = rootElementProvider; - _revitElementType = _proxyMapper.GetHostTypeFromMappedType(_rootElementProvider.GetRootType()).NotNull(); + _toSpeckle = toSpeckle; } public Base Convert(object target) { - Type revitType = _rootConvertManager.GetTargetType(target); - var wrapper = _proxyMapper.WrapIfExists(revitType, target); - if (wrapper == null) + Type type = target.GetType(); + try { - //try to fallback to element type - if (_rootConvertManager.IsSubClass(_revitElementType, revitType)) + var objectConverter = _toSpeckle.ResolveInstance(type.Name); //poc: would be nice to have supertypes resolve + + if (objectConverter == null) { - return _rootConvertManager.Convert( - _rootElementProvider.GetRootType(), - _proxyMapper.CreateProxy(_rootElementProvider.GetRootType(), target) - ); + throw new NotSupportedException($"No conversion found for {type.Name}"); } - throw new NotSupportedException($"No wrapper found for Revit type: {revitType.Name}"); + var convertedObject = objectConverter.Convert(target); + + return convertedObject; + } + catch (SpeckleConversionException e) + { + Console.WriteLine(e); + throw; // Just rethrowing for now, Logs may be needed here. } - var (wrappedType, wrappedObject) = wrapper; - return _rootConvertManager.Convert(wrappedType, wrappedObject); } } From e11bace2658383ebf6a8f5fb54833d6808e564e7 Mon Sep 17 00:00:00 2001 From: Adam Hathcock Date: Thu, 27 Jun 2024 17:40:05 +0100 Subject: [PATCH 249/261] Fix all.sln (#3541) --- All.sln | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/All.sln b/All.sln index da15c240b4..3fffc2325d 100644 --- a/All.sln +++ b/All.sln @@ -556,8 +556,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConverterCivil2025", "Objec EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{B1324D25-C601-40F2-8AE2-6131F492B911}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Speckle.Converters.Revit2023.Tests", "DUI3-DX\Converters\Revit\Speckle.Converters.Revit2023.Tests\Speckle.Converters.Revit2023.Tests.csproj", "{AEC26A0B-25F3-4544-A9D6-A427BFF79250}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Speckle.Connectors.Civil3d2024", "DUI3-DX\Connectors\Autocad\Speckle.Connectors.Civil3d2024\Speckle.Connectors.Civil3d2024.csproj", "{DDBBA313-69A6-40DE-AB3A-79EE5BF32A7E}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Speckle.Converters.Autocad2024", "DUI3-DX\Converters\Autocad\2024\Speckle.Converters.Autocad2024\Speckle.Converters.Autocad2024.csproj", "{C9C28F31-1367-438C-83B0-049C3B3A3E3B}" @@ -2798,22 +2796,6 @@ Global {F06E4C37-4076-4272-9CA6-FB505E02CD31}.Release|Any CPU.Build.0 = Release|Any CPU {F06E4C37-4076-4272-9CA6-FB505E02CD31}.Release|x64.ActiveCfg = Release|Any CPU {F06E4C37-4076-4272-9CA6-FB505E02CD31}.Release|x64.Build.0 = Release|Any CPU - {AEC26A0B-25F3-4544-A9D6-A427BFF79250}.Debug Mac|Any CPU.ActiveCfg = Debug|Any CPU - {AEC26A0B-25F3-4544-A9D6-A427BFF79250}.Debug Mac|Any CPU.Build.0 = Debug|Any CPU - {AEC26A0B-25F3-4544-A9D6-A427BFF79250}.Debug Mac|x64.ActiveCfg = Debug|Any CPU - {AEC26A0B-25F3-4544-A9D6-A427BFF79250}.Debug Mac|x64.Build.0 = Debug|Any CPU - {AEC26A0B-25F3-4544-A9D6-A427BFF79250}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {AEC26A0B-25F3-4544-A9D6-A427BFF79250}.Debug|Any CPU.Build.0 = Debug|Any CPU - {AEC26A0B-25F3-4544-A9D6-A427BFF79250}.Debug|x64.ActiveCfg = Debug|Any CPU - {AEC26A0B-25F3-4544-A9D6-A427BFF79250}.Debug|x64.Build.0 = Debug|Any CPU - {AEC26A0B-25F3-4544-A9D6-A427BFF79250}.Release Mac|Any CPU.ActiveCfg = Debug|Any CPU - {AEC26A0B-25F3-4544-A9D6-A427BFF79250}.Release Mac|Any CPU.Build.0 = Debug|Any CPU - {AEC26A0B-25F3-4544-A9D6-A427BFF79250}.Release Mac|x64.ActiveCfg = Debug|Any CPU - {AEC26A0B-25F3-4544-A9D6-A427BFF79250}.Release Mac|x64.Build.0 = Debug|Any CPU - {AEC26A0B-25F3-4544-A9D6-A427BFF79250}.Release|Any CPU.ActiveCfg = Release|Any CPU - {AEC26A0B-25F3-4544-A9D6-A427BFF79250}.Release|Any CPU.Build.0 = Release|Any CPU - {AEC26A0B-25F3-4544-A9D6-A427BFF79250}.Release|x64.ActiveCfg = Release|Any CPU - {AEC26A0B-25F3-4544-A9D6-A427BFF79250}.Release|x64.Build.0 = Release|Any CPU {DDBBA313-69A6-40DE-AB3A-79EE5BF32A7E}.Debug Mac|Any CPU.ActiveCfg = Debug|Any CPU {DDBBA313-69A6-40DE-AB3A-79EE5BF32A7E}.Debug Mac|Any CPU.Build.0 = Debug|Any CPU {DDBBA313-69A6-40DE-AB3A-79EE5BF32A7E}.Debug Mac|x64.ActiveCfg = Debug|Any CPU @@ -3073,7 +3055,6 @@ Global {829688CD-CECE-4F6C-A5A0-032BB39CD9E0} = {BE521908-7944-46F3-98BF-B47D34509934} {70DEAA13-6DC8-44A0-B287-9E806A8054F1} = {890F3257-FCC2-4ED8-9180-22B3641B494C} {F06E4C37-4076-4272-9CA6-FB505E02CD31} = {BE521908-7944-46F3-98BF-B47D34509934} - {AEC26A0B-25F3-4544-A9D6-A427BFF79250} = {D92751C8-1039-4005-90B2-913E55E0B8BD} {DDBBA313-69A6-40DE-AB3A-79EE5BF32A7E} = {743489BF-1941-43D5-8AF9-35C56D0DCC34} {C9C28F31-1367-438C-83B0-049C3B3A3E3B} = {804E065F-914C-414A-AF84-009312C3CFF6} {06082BAA-98E8-49B1-9D33-252B126A0561} = {804E065F-914C-414A-AF84-009312C3CFF6} From 0568a29d8e30857d9095446542b3cea7bed1d279 Mon Sep 17 00:00:00 2001 From: Dimitrie Stefanescu Date: Thu, 27 Jun 2024 21:10:04 +0100 Subject: [PATCH 250/261] Blocks POC (Rhino, Acad) (#3519) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat(dui3): adds instance def and instance proxy classes to core * feat(dui3): rhino blocks send wip * feat(dui3): wip (works!) rhino blocks send & receive * some cleanup * wip fixes * wip cleanup * wip scaffolds acad * wip acad send instances and co * wip acad - getting close to wrapping up send * wip - units * feat(dui3): blocks poc wip: adds rhino layer manager, moves instance baking to instance manager, etc. * feat(dui3): blocks poc WIP - acad receive * wip acad instance receives * acad blocks - receive ok * feat(dui3): acad receive blocks ✅ more testing still needed! * feat(dui3): blocks poc minor refactors * feat(dui3): acad blocks proper cleanup * feat(dui3): blocks poc ready(ish) rhino & acad * chore(dui3): reverts accidental change * feat(dui3): adds comments/docs * chore(dui3): comments * fix(dui3): throws ex upwards * fix(dui3): blocks correctly handled in acad * update core reference and fix to not use interfaces * remove extra files --------- Co-authored-by: Adam Hathcock --- .../Models/Instances/IInstanceComponent.cs | 12 + .../Instances/InstanceDefinitionProxy.cs | 16 + Core/Core/Models/Instances/InstanceProxy.cs | 26 ++ .../packages.lock.json | 20 +- .../packages.lock.json | 20 +- .../Bindings/AutocadBasicConnectorBinding.cs | 47 ++- .../AutocadConnectorModule.cs | 27 ++ .../HostApp/AutocadInstanceObjectManager.cs | 368 ++++++++++++++++++ .../HostApp/AutocadLayerManager.cs | 83 +++- .../HostApp/Extensions/AcadUnitsExtension.cs | 39 ++ .../Receive/AutocadHostObjectBuilder.cs | 114 ++++-- .../Send/AutocadRootObjectBuilder.cs | 28 +- ...Speckle.Connectors.AutocadShared.projitems | 2 + .../packages.lock.json | 20 +- .../packages.lock.json | 20 +- .../Bindings/RhinoSendBinding.cs | 15 + .../RhinoConnectorModule.cs | 3 + .../Extensions/RhinoUnitsExtension.cs | 37 ++ .../HostApp/RhinoInstanceObjectsManager.cs | 254 ++++++++++++ .../HostApp/RhinoLayerManager.cs | 122 ++++++ .../Receive/RhinoHostObjectBuilder.cs | 186 +++++---- .../Operations/Send/RhinoRootObjectBuilder.cs | 99 ++--- .../packages.lock.json | 25 +- .../packages.lock.json | 16 +- .../packages.lock.json | 16 +- .../packages.lock.json | 16 +- .../packages.lock.json | 16 +- .../packages.lock.json | 16 +- .../packages.lock.json | 16 +- .../packages.lock.json | 16 +- .../XyzConversionToPointTests.cs | 59 --- .../packages.lock.json | 16 +- .../packages.lock.json | 21 +- .../packages.lock.json | 16 +- .../packages.lock.json | 20 +- .../Speckle.Connectors.DUI/packages.lock.json | 8 +- DUI3-DX/Directory.Packages.props | 4 +- .../Instances/IInstanceObjectsManager.cs | 53 +++ .../packages.lock.json | 6 +- .../packages.lock.json | 16 +- .../packages.lock.json | 14 +- 41 files changed, 1488 insertions(+), 440 deletions(-) create mode 100644 Core/Core/Models/Instances/IInstanceComponent.cs create mode 100644 Core/Core/Models/Instances/InstanceDefinitionProxy.cs create mode 100644 Core/Core/Models/Instances/InstanceProxy.cs create mode 100644 DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/AutocadInstanceObjectManager.cs create mode 100644 DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/Extensions/AcadUnitsExtension.cs create mode 100644 DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Extensions/RhinoUnitsExtension.cs create mode 100644 DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/RhinoInstanceObjectsManager.cs create mode 100644 DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/RhinoLayerManager.cs delete mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/XyzConversionToPointTests.cs create mode 100644 DUI3-DX/Sdk/Speckle.Connectors.Utils/Instances/IInstanceObjectsManager.cs diff --git a/Core/Core/Models/Instances/IInstanceComponent.cs b/Core/Core/Models/Instances/IInstanceComponent.cs new file mode 100644 index 0000000000..9a6478607d --- /dev/null +++ b/Core/Core/Models/Instances/IInstanceComponent.cs @@ -0,0 +1,12 @@ +namespace Speckle.Core.Models.Instances; + +/// +/// Abstracts over and for sorting and grouping in receive operations. +/// +public interface IInstanceComponent +{ + /// + /// The maximum "depth" at which this or was found. On receive, as instances can be composed of other instances, we need to start from the deepest instance elements first when reconstructing them, starting with definitions first. + /// + public int MaxDepth { get; set; } +} diff --git a/Core/Core/Models/Instances/InstanceDefinitionProxy.cs b/Core/Core/Models/Instances/InstanceDefinitionProxy.cs new file mode 100644 index 0000000000..0fde842faa --- /dev/null +++ b/Core/Core/Models/Instances/InstanceDefinitionProxy.cs @@ -0,0 +1,16 @@ +using System.Collections.Generic; + +namespace Speckle.Core.Models.Instances; + +/// +/// A proxy class for an instance definition. +/// +public class InstanceDefinitionProxy : Base, IInstanceComponent +{ + /// + /// The original ids of the objects that are part of this definition, as present in the source host app. On receive, they will be mapped to corresponding newly created definition ids. + /// + public List Objects { get; set; } // source app application ids for the objects + + public int MaxDepth { get; set; } +} diff --git a/Core/Core/Models/Instances/InstanceProxy.cs b/Core/Core/Models/Instances/InstanceProxy.cs new file mode 100644 index 0000000000..5fa18496e9 --- /dev/null +++ b/Core/Core/Models/Instances/InstanceProxy.cs @@ -0,0 +1,26 @@ +using System.DoubleNumerics; + +namespace Speckle.Core.Models.Instances; + +/// +/// A proxy class for an instance (e.g, a rhino block, or an autocad block reference). +/// +public class InstanceProxy : Base, IInstanceComponent +{ + /// + /// The definition id as present in the original host app. On receive, it will be mapped to the newly created definition id. + /// + public string DefinitionId { get; set; } + + /// + /// The transform of the instance reference. + /// + public Matrix4x4 Transform { get; set; } + + /// + /// The units of the host application file. + /// + public string Units { get; set; } = Kits.Units.Meters; + + public int MaxDepth { get; set; } +} diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/packages.lock.json b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/packages.lock.json index e890a9f47a..b975016a9b 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/packages.lock.json +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/packages.lock.json @@ -383,7 +383,7 @@ "Microsoft.Extensions.Logging.Abstractions": "[7.0.0, )", "Speckle.Autofac": "[2.0.999-local, )", "Speckle.Connectors.Utils": "[2.0.999-local, )", - "Speckle.Core": "[3.0.1-alpha.11, )", + "Speckle.Core": "[3.0.1-alpha.14, )", "System.Threading.Tasks.Dataflow": "[6.0.0, )" } }, @@ -399,7 +399,7 @@ "dependencies": { "Serilog.Extensions.Logging": "[7.0.0, )", "Speckle.Autofac": "[2.0.999-local, )", - "Speckle.Core": "[3.0.1-alpha.11, )" + "Speckle.Core": "[3.0.1-alpha.14, )" } }, "speckle.converters.arcgis3": { @@ -421,7 +421,7 @@ "type": "Project", "dependencies": { "Speckle.Autofac": "[2.0.999-local, )", - "Speckle.Objects": "[3.0.1-alpha.11, )" + "Speckle.Objects": "[3.0.1-alpha.14, )" } }, "speckle.converters.common.dependencyinjection": { @@ -455,9 +455,9 @@ }, "Speckle.Core": { "type": "CentralTransitive", - "requested": "[3.0.1-alpha.11, )", - "resolved": "3.0.1-alpha.11", - "contentHash": "Zt2dBJLlfziEACYCHThbhKypSjhoA01rTw9BzNI72c/BDyftXIz70Tetq/8ZMEqQnKqfmRyYADsAdWKxpdV0Hg==", + "requested": "[3.0.1-alpha.14, )", + "resolved": "3.0.1-alpha.14", + "contentHash": "RzQPVIGFFkKvG56YLr8ACtiwdWJE6IJ9vCQ4qHa0PIsUEpfzAIAi59jnzqtByOFC0FiFrFPow9bkfzylaZorAA==", "dependencies": { "GraphQL.Client": "6.0.0", "Microsoft.CSharp": "4.7.0", @@ -479,11 +479,11 @@ }, "Speckle.Objects": { "type": "CentralTransitive", - "requested": "[3.0.1-alpha.11, )", - "resolved": "3.0.1-alpha.11", - "contentHash": "YR7sei3OQBAi8R/kIu8bEmg5ELDIJK6l5fhOgdnqA9ZvD/fvmRb+09z8lIUTDsgdAdvYU/A/x9VxH9OGPbp9Kw==", + "requested": "[3.0.1-alpha.14, )", + "resolved": "3.0.1-alpha.14", + "contentHash": "z38LGryMvh7iU1uBW+4uo5DwsB3CwRgLt2uFexWFx3mPSid+A0l5XcJzOgLwgFhNl6B42Ryz4ezBsddTp1Uc/g==", "dependencies": { - "Speckle.Core": "3.0.1-alpha.11" + "Speckle.Core": "3.0.1-alpha.14" } }, "System.Threading.Tasks.Dataflow": { diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.Autocad2023/packages.lock.json b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.Autocad2023/packages.lock.json index 68bcf35809..0fff9ad56a 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.Autocad2023/packages.lock.json +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.Autocad2023/packages.lock.json @@ -436,7 +436,7 @@ "Microsoft.Extensions.Logging.Abstractions": "[7.0.0, )", "Speckle.Autofac": "[2.0.999-local, )", "Speckle.Connectors.Utils": "[2.0.999-local, )", - "Speckle.Core": "[3.0.1-alpha.11, )", + "Speckle.Core": "[3.0.1-alpha.14, )", "System.Threading.Tasks.Dataflow": "[6.0.0, )" } }, @@ -452,7 +452,7 @@ "dependencies": { "Serilog.Extensions.Logging": "[7.0.0, )", "Speckle.Autofac": "[2.0.999-local, )", - "Speckle.Core": "[3.0.1-alpha.11, )" + "Speckle.Core": "[3.0.1-alpha.14, )" } }, "speckle.converters.autocad2023": { @@ -474,7 +474,7 @@ "type": "Project", "dependencies": { "Speckle.Autofac": "[2.0.999-local, )", - "Speckle.Objects": "[3.0.1-alpha.11, )" + "Speckle.Objects": "[3.0.1-alpha.14, )" } }, "speckle.converters.common.dependencyinjection": { @@ -511,9 +511,9 @@ }, "Speckle.Core": { "type": "CentralTransitive", - "requested": "[3.0.1-alpha.11, )", - "resolved": "3.0.1-alpha.11", - "contentHash": "Zt2dBJLlfziEACYCHThbhKypSjhoA01rTw9BzNI72c/BDyftXIz70Tetq/8ZMEqQnKqfmRyYADsAdWKxpdV0Hg==", + "requested": "[3.0.1-alpha.14, )", + "resolved": "3.0.1-alpha.14", + "contentHash": "RzQPVIGFFkKvG56YLr8ACtiwdWJE6IJ9vCQ4qHa0PIsUEpfzAIAi59jnzqtByOFC0FiFrFPow9bkfzylaZorAA==", "dependencies": { "GraphQL.Client": "6.0.0", "Microsoft.CSharp": "4.7.0", @@ -535,11 +535,11 @@ }, "Speckle.Objects": { "type": "CentralTransitive", - "requested": "[3.0.1-alpha.11, )", - "resolved": "3.0.1-alpha.11", - "contentHash": "YR7sei3OQBAi8R/kIu8bEmg5ELDIJK6l5fhOgdnqA9ZvD/fvmRb+09z8lIUTDsgdAdvYU/A/x9VxH9OGPbp9Kw==", + "requested": "[3.0.1-alpha.14, )", + "resolved": "3.0.1-alpha.14", + "contentHash": "z38LGryMvh7iU1uBW+4uo5DwsB3CwRgLt2uFexWFx3mPSid+A0l5XcJzOgLwgFhNl6B42Ryz4ezBsddTp1Uc/g==", "dependencies": { - "Speckle.Core": "3.0.1-alpha.11" + "Speckle.Core": "3.0.1-alpha.14" } }, "System.Threading.Tasks.Dataflow": { diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadBasicConnectorBinding.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadBasicConnectorBinding.cs index a87ea7f70d..a30179a2cb 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadBasicConnectorBinding.cs +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadBasicConnectorBinding.cs @@ -8,6 +8,7 @@ using Speckle.Core.Credentials; using Speckle.Connectors.Autocad.HostApp.Extensions; using Speckle.Connectors.Utils; +using Speckle.Core.Logging; namespace Speckle.Connectors.Autocad.Bindings; @@ -108,34 +109,50 @@ public void HighlightModel(string modelCardId) return; } - HighlightObjectsOnView(objectIds); + HighlightObjectsOnView(objectIds, modelCardId); } - private void HighlightObjectsOnView(ObjectId[] objectIds) + private void HighlightObjectsOnView(ObjectId[] objectIds, string? modelCardId = null) { var doc = Application.DocumentManager.MdiActiveDocument; Parent.RunOnMainThread(() => { - doc.Editor.SetImpliedSelection(Array.Empty()); // Deselects - doc.Editor.SetImpliedSelection(objectIds); // Selects - doc.Editor.UpdateScreen(); + try + { + doc.Editor.SetImpliedSelection(Array.Empty()); // Deselects + doc.Editor.SetImpliedSelection(objectIds); // Selects + doc.Editor.UpdateScreen(); + + Extents3d selectedExtents = new(); - Extents3d selectedExtents = new(); + var tr = doc.TransactionManager.StartTransaction(); + foreach (ObjectId objectId in objectIds) + { + var entity = (Entity)tr.GetObject(objectId, OpenMode.ForRead); + if (entity != null) + { + selectedExtents.AddExtents(entity.GeometricExtents); + } + } - var tr = doc.TransactionManager.StartTransaction(); - foreach (ObjectId objectId in objectIds) + doc.Editor.Zoom(selectedExtents); + tr.Commit(); + Autodesk.AutoCAD.Internal.Utils.FlushGraphics(); + } + catch (Exception ex) when (!ex.IsFatal()) { - var entity = (Entity)tr.GetObject(objectId, OpenMode.ForRead); - if (entity != null) + if (modelCardId != null) + { + Commands.SetModelError(modelCardId, new OperationCanceledException("Failed to highlight objects.")); + } + else { - selectedExtents.AddExtents(entity.GeometricExtents); + // This will happen, in some cases, where we highlight individual objects. Should be caught by the top level handler and not + // crash the host app. + throw; } } - - doc.Editor.Zoom(selectedExtents); - tr.Commit(); - Autodesk.AutoCAD.Internal.Utils.FlushGraphics(); }); } } diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/DependencyInjection/AutocadConnectorModule.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/DependencyInjection/AutocadConnectorModule.cs index 731098b249..52da8c7d75 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/DependencyInjection/AutocadConnectorModule.cs +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/DependencyInjection/AutocadConnectorModule.cs @@ -1,13 +1,23 @@ #if AUTOCAD +using Autodesk.AutoCAD.DatabaseServices; +using Speckle.Autofac; using Speckle.Autofac.DependencyInjection; using Speckle.Connectors.Autocad.Bindings; using Speckle.Connectors.Autocad.Filters; +using Speckle.Connectors.Autocad.HostApp; +using Speckle.Connectors.Autocad.Interfaces; using Speckle.Connectors.Autocad.Operations.Receive; using Speckle.Connectors.Autocad.Operations.Send; +using Speckle.Connectors.Autocad.Plugin; +using Speckle.Connectors.DUI; using Speckle.Connectors.DUI.Bindings; +using Speckle.Connectors.DUI.Models; using Speckle.Connectors.DUI.Models.Card.SendFilter; +using Speckle.Connectors.DUI.WebView; +using Speckle.Connectors.Utils; using Speckle.Connectors.Utils.Builders; using Speckle.Connectors.Utils.Caching; +using Speckle.Connectors.Utils.Instances; using Speckle.Connectors.Utils.Operations; using Speckle.Core.Models.GraphTraversal; @@ -17,8 +27,24 @@ public class AutocadConnectorModule : ISpeckleModule { public void Load(SpeckleContainerBuilder builder) { + builder.AddAutofac(); + builder.AddConnectorUtils(); + builder.AddDUI(); + builder.AddDUIView(); + + // Register other connector specific types + builder.AddSingleton(); + builder.AddTransient(); + builder.AddSingleton(new AutocadDocumentManager()); // TODO: Dependent to TransactionContext, can be moved to AutocadContext + builder.AddSingleton(); + builder.AddSingleton(); + builder.AddSingleton(); + SharedConnectorModule.LoadShared(builder); + + builder.AddScoped(); + // Operations builder.AddScoped>(); builder.AddSingleton(DefaultTraversal.CreateTraversalFunc()); @@ -37,6 +63,7 @@ public void Load(SpeckleContainerBuilder builder) // register send conversion cache builder.AddSingleton(); + builder.AddScoped>, AutocadInstanceObjectManager>(); } } #endif diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/AutocadInstanceObjectManager.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/AutocadInstanceObjectManager.cs new file mode 100644 index 0000000000..11067f52ba --- /dev/null +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/AutocadInstanceObjectManager.cs @@ -0,0 +1,368 @@ +using System.DoubleNumerics; +using Autodesk.AutoCAD.DatabaseServices; +using Autodesk.AutoCAD.Geometry; +using Speckle.Connectors.Autocad.HostApp.Extensions; +using Speckle.Connectors.Autocad.Operations.Send; +using Speckle.Connectors.Utils.Conversion; +using Speckle.Connectors.Utils.Instances; +using Speckle.Core.Kits; +using Speckle.Core.Logging; +using Speckle.Core.Models; +using Speckle.Core.Models.Instances; + +namespace Speckle.Connectors.Autocad.HostApp; + +/// +/// +/// Expects to be a scoped dependency per send or receive operation. +/// +public class AutocadInstanceObjectManager : IInstanceObjectsManager> +{ + private readonly AutocadLayerManager _autocadLayerManager; + private Dictionary InstanceProxies { get; set; } = new(); + private Dictionary> InstanceProxiesByDefinitionId { get; set; } = new(); + private Dictionary DefinitionProxies { get; set; } = new(); + private Dictionary FlatAtomicObjects { get; set; } = new(); + + public AutocadInstanceObjectManager(AutocadLayerManager autocadLayerManager) + { + _autocadLayerManager = autocadLayerManager; + } + + public UnpackResult UnpackSelection(IEnumerable objects) + { + using var transaction = Application.DocumentManager.CurrentDocument.Database.TransactionManager.StartTransaction(); + + foreach (var obj in objects) + { + if (obj.Root is BlockReference blockReference && !blockReference.IsDynamicBlock) + { + UnpackInstance(blockReference, 0, transaction); + } + + FlatAtomicObjects[obj.ApplicationId] = obj; + } + return new(FlatAtomicObjects.Values.ToList(), InstanceProxies, DefinitionProxies.Values.ToList()); + } + + private void UnpackInstance(BlockReference instance, int depth, Transaction transaction) + { + var instanceIdString = instance.Handle.Value.ToString(); + var definitionId = instance.BlockTableRecord; + + InstanceProxies[instanceIdString] = new InstanceProxy() + { + applicationId = instanceIdString, + DefinitionId = definitionId.ToString(), + MaxDepth = depth, + Transform = GetMatrix(instance.BlockTransform.ToArray()), + Units = Application.DocumentManager.CurrentDocument.Database.Insunits.ToSpeckleString() + }; + + // For each block instance that has the same definition, we need to keep track of the "maximum depth" at which is found. + // This will enable on receive to create them in the correct order (descending by max depth, interleaved definitions and instances). + // We need to interleave the creation of definitions and instances, as some definitions may depend on instances. + if ( + !InstanceProxiesByDefinitionId.TryGetValue( + definitionId.ToString(), + out List instanceProxiesWithSameDefinition + ) + ) + { + instanceProxiesWithSameDefinition = new List(); + InstanceProxiesByDefinitionId[definitionId.ToString()] = instanceProxiesWithSameDefinition; + } + + // We ensure that all previous instance proxies that have the same definition are at this max depth. I kind of have a feeling this can be done more elegantly, but YOLO + foreach (var instanceProxy in instanceProxiesWithSameDefinition) + { + instanceProxy.MaxDepth = depth; + } + + instanceProxiesWithSameDefinition.Add(InstanceProxies[instanceIdString]); + + if (DefinitionProxies.TryGetValue(definitionId.ToString(), out InstanceDefinitionProxy value)) + { + value.MaxDepth = depth; + return; // exit fast - we've parsed this one so no need to go further + } + + var definition = (BlockTableRecord)transaction.GetObject(definitionId, OpenMode.ForRead); + // definition.Origin + var definitionProxy = new InstanceDefinitionProxy() + { + applicationId = definitionId.ToString(), + Objects = new(), + MaxDepth = depth, + ["name"] = definition.Name, + ["comments"] = definition.Comments, + ["units"] = definition.Units // ? not sure needed? + }; + + // Go through each definition object + foreach (ObjectId id in definition) + { + var obj = transaction.GetObject(id, OpenMode.ForRead); + var handleIdString = obj.Handle.Value.ToString(); + definitionProxy.Objects.Add(handleIdString); + + if (obj is BlockReference blockReference && !blockReference.IsDynamicBlock) + { + UnpackInstance(blockReference, depth + 1, transaction); + } + FlatAtomicObjects[handleIdString] = new(obj, handleIdString); + } + + DefinitionProxies[definitionId.ToString()] = definitionProxy; + } + + public BakeResult BakeInstances( + List<(string[] layerPath, IInstanceComponent obj)> instanceComponents, + Dictionary> applicationIdMap, + string baseLayerName, + Action? onOperationProgressed + ) + { + var sortedInstanceComponents = instanceComponents + .OrderByDescending(x => x.obj.MaxDepth) // Sort by max depth, so we start baking from the deepest element first + .ThenBy(x => x.obj is InstanceDefinitionProxy ? 0 : 1) // Ensure we bake the deepest definition first, then any instances that depend on it + .ToList(); + + var definitionIdAndApplicationIdMap = new Dictionary(); + + using var transaction = Application.DocumentManager.CurrentDocument.Database.TransactionManager.StartTransaction(); + var conversionResults = new List(); + var createdObjectIds = new List(); + var consumedObjectIds = new List(); + var count = 0; + + foreach (var (path, instanceOrDefinition) in sortedInstanceComponents) + { + try + { + onOperationProgressed?.Invoke("Converting blocks", (double)++count / sortedInstanceComponents.Count); + if (instanceOrDefinition is InstanceDefinitionProxy { applicationId: not null } definitionProxy) + { + // TODO: create definition (block table record) + var constituentEntities = definitionProxy.Objects + .Select(id => applicationIdMap.TryGetValue(id, out List value) ? value : null) + .Where(x => x is not null) + .SelectMany(ent => ent) + .ToList(); + + var record = new BlockTableRecord(); + var objectIds = new ObjectIdCollection(); + record.Name = baseLayerName; + if (definitionProxy["name"] is string name) + { + record.Name += name; + } + else + { + record.Name += definitionProxy.applicationId; + } + + foreach (var entity in constituentEntities) + { + // record.AppendEntity(entity); + objectIds.Add(entity.ObjectId); + } + + using var blockTable = (BlockTable) + transaction.GetObject(Application.DocumentManager.CurrentDocument.Database.BlockTableId, OpenMode.ForWrite); + var id = blockTable.Add(record); + record.AssumeOwnershipOf(objectIds); + + definitionIdAndApplicationIdMap[definitionProxy.applicationId] = id; + transaction.AddNewlyCreatedDBObject(record, true); + var consumedEntitiesHandleValues = constituentEntities.Select(ent => ent.Handle.Value.ToString()).ToArray(); + consumedObjectIds.AddRange(consumedEntitiesHandleValues); + createdObjectIds.RemoveAll(newId => consumedEntitiesHandleValues.Contains(newId)); + } + else if ( + instanceOrDefinition is InstanceProxy instanceProxy + && definitionIdAndApplicationIdMap.TryGetValue(instanceProxy.DefinitionId, out ObjectId definitionId) + ) + { + var matrix3d = GetMatrix3d(instanceProxy.Transform, instanceProxy.Units); + var insertionPoint = Point3d.Origin.TransformBy(matrix3d); + + var modelSpaceBlockTableRecord = Application.DocumentManager.CurrentDocument.Database.GetModelSpace( + OpenMode.ForWrite + ); + _autocadLayerManager.CreateLayerForReceive(path[0]); + var blockRef = new BlockReference(insertionPoint, definitionId) + { + BlockTransform = matrix3d, + Layer = path[0], + }; + + modelSpaceBlockTableRecord.AppendEntity(blockRef); + + if (instanceProxy.applicationId != null) + { + applicationIdMap[instanceProxy.applicationId] = new List { blockRef }; + } + + transaction.AddNewlyCreatedDBObject(blockRef, true); + conversionResults.Add( + new(Status.SUCCESS, instanceProxy, blockRef.Handle.Value.ToString(), "Instance (Block)") + ); + createdObjectIds.Add(blockRef.Handle.Value.ToString()); + } + } + catch (Exception ex) when (!ex.IsFatal()) + { + conversionResults.Add(new(Status.ERROR, instanceOrDefinition as Base ?? new Base(), null, null, ex)); + } + } + transaction.Commit(); + return new(createdObjectIds, consumedObjectIds, conversionResults); + } + + /// + /// Cleans up any previously created instances. + /// POC: This function will not be able to delete block definitions if the user creates a new one composed out of received definitions. + /// + /// + public void PurgeInstances(string namePrefix) + { + using var transaction = Application.DocumentManager.CurrentDocument.Database.TransactionManager.StartTransaction(); + var instanceDefinitionsToDelete = new Dictionary(); + + // Helper function that recurses through a given block table record's constituent objects and purges inner instances as required. + void TraverseAndClean(BlockTableRecord btr) + { + foreach (var objectId in btr) + { + var obj = transaction.GetObject(objectId, OpenMode.ForRead) as BlockReference; + if (obj == null) + { + continue; + } + var definition = (BlockTableRecord)transaction.GetObject(obj.BlockTableRecord, OpenMode.ForRead); + if (obj.IsErased) + { + TraverseAndClean(definition); + continue; + } + + obj.UpgradeOpen(); + obj.Erase(); + TraverseAndClean(definition); + instanceDefinitionsToDelete[obj.BlockTableRecord.ToString()] = definition; + } + } + + using var blockTable = (BlockTable) + transaction.GetObject(Application.DocumentManager.CurrentDocument.Database.BlockTableId, OpenMode.ForRead); + + // deep clean definitions + foreach (var btrId in blockTable) + { + var btr = (BlockTableRecord)transaction.GetObject(btrId, OpenMode.ForRead); + if (btr.Name.Contains(namePrefix)) // POC: this is tightly coupled with a naming convention for definitions in the instance object manager + { + TraverseAndClean(btr); + instanceDefinitionsToDelete[btr.Name] = btr; + } + } + + foreach (var def in instanceDefinitionsToDelete.Values) + { + def.UpgradeOpen(); + def.Erase(); + } + + transaction.Commit(); + } + + private Matrix4x4 GetMatrix(double[] t) + { + return new Matrix4x4( + t[0], + t[1], + t[2], + t[3], + t[4], + t[5], + t[6], + t[7], + t[8], + t[9], + t[10], + t[11], + t[12], + t[13], + t[14], + t[15] + ); + } + + private Matrix3d GetMatrix3d(Matrix4x4 matrix, string units) + { + var sf = Units.GetConversionFactor( + units, + Application.DocumentManager.CurrentDocument.Database.Insunits.ToSpeckleString() + ); + + var scaledTransform = new[] + { + matrix.M11, + matrix.M12, + matrix.M13, + matrix.M14 * sf, + matrix.M21, + matrix.M22, + matrix.M23, + matrix.M24 * sf, + matrix.M31, + matrix.M32, + matrix.M33, + matrix.M34 * sf, + matrix.M41, + matrix.M42, + matrix.M43, + matrix.M44 + }; + + var m3d = new Matrix3d(scaledTransform); + if (!m3d.IsScaledOrtho()) + { + m3d = new Matrix3d(MakePerpendicular(m3d)); + } + + return m3d; + } + + // https://forums.autodesk.com/t5/net/set-blocktransform-values/m-p/6452121#M49479 + private static double[] MakePerpendicular(Matrix3d matrix) + { + // Get the basis vectors of the matrix + Vector3d right = new(matrix[0, 0], matrix[1, 0], matrix[2, 0]); + Vector3d up = new(matrix[0, 1], matrix[1, 1], matrix[2, 1]); + + Vector3d newForward = right.CrossProduct(up).GetNormal(); + Vector3d newUp = newForward.CrossProduct(right).GetNormal(); + + return new[] + { + right.X, + newUp.X, + newForward.X, + matrix[0, 3], + right.Y, + newUp.Y, + newForward.Y, + matrix[1, 3], + right.Z, + newUp.Z, + newForward.Z, + matrix[2, 3], + 0.0, + 0.0, + 0.0, + matrix[3, 3], + }; + } +} diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/AutocadLayerManager.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/AutocadLayerManager.cs index 87b1f00ca7..d172bea860 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/AutocadLayerManager.cs +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/AutocadLayerManager.cs @@ -1,9 +1,14 @@ using Autodesk.AutoCAD.DatabaseServices; using Autodesk.AutoCAD.EditorInput; using Autodesk.AutoCAD.LayerManager; +using Speckle.Core.Models; +using Speckle.Core.Models.GraphTraversal; namespace Speckle.Connectors.Autocad.HostApp; +/// +/// Expects to be a scoped dependency for a given operation and helps with layer creation and cleanup. +/// public class AutocadLayerManager { private readonly AutocadContext _autocadContext; @@ -11,38 +16,30 @@ public class AutocadLayerManager // POC: Will be addressed to move it into AutocadContext! private Document Doc => Application.DocumentManager.MdiActiveDocument; + private readonly HashSet _uniqueLayerNames = new(); public AutocadLayerManager(AutocadContext autocadContext) { _autocadContext = autocadContext; } - /// - /// Constructs layer name with prefix and valid characters. - /// - /// Prefix to add layer name. - /// list of entries to concat with hyphen. - /// Full layer name with provided prefix and path. - public string LayerFullName(string baseLayerPrefix, string path) - { - var layerFullName = baseLayerPrefix + string.Join("-", path); - return _autocadContext.RemoveInvalidChars(layerFullName); - } - /// /// Will create a layer with the provided name, or, if it finds an existing one, will "purge" all objects from it. /// This ensures we're creating the new objects we've just received rather than overlaying them. /// /// Name to search layer for purge and create. - public void CreateLayerOrPurge(string layerName) + public void CreateLayerForReceive(string layerName) { - // POC: Will be addressed to move it into AutocadContext! - Document doc = Application.DocumentManager.MdiActiveDocument; - doc.LockDocument(); - using Transaction transaction = doc.TransactionManager.StartTransaction(); + if (!_uniqueLayerNames.Add(layerName)) + { + return; + } + + Doc.LockDocument(); + using Transaction transaction = Doc.TransactionManager.StartTransaction(); LayerTable? layerTable = - transaction.TransactionManager.GetObject(doc.Database.LayerTableId, OpenMode.ForRead) as LayerTable; + transaction.TransactionManager.GetObject(Doc.Database.LayerTableId, OpenMode.ForRead) as LayerTable; LayerTableRecord layerTableRecord = new() { Name = layerName }; bool hasLayer = layerTable != null && layerTable.Has(layerName); @@ -50,7 +47,7 @@ public void CreateLayerOrPurge(string layerName) { TypedValue[] tvs = { new((int)DxfCode.LayerName, layerName) }; SelectionFilter selectionFilter = new(tvs); - SelectionSet selectionResult = doc.Editor.SelectAll(selectionFilter).Value; + SelectionSet selectionResult = Doc.Editor.SelectAll(selectionFilter).Value; if (selectionResult == null) { return; @@ -69,7 +66,38 @@ public void CreateLayerOrPurge(string layerName) transaction.Commit(); } - // POC: Consider to extract somehow in factory or service! + public void DeleteAllLayersByPrefix(string prefix) + { + Doc.LockDocument(); + using Transaction transaction = Doc.TransactionManager.StartTransaction(); + + var layerTable = (LayerTable)transaction.TransactionManager.GetObject(Doc.Database.LayerTableId, OpenMode.ForRead); + foreach (var layerId in layerTable) + { + var layer = (LayerTableRecord)transaction.GetObject(layerId, OpenMode.ForRead); + var layerName = layer.Name; + if (layer.Name.Contains(prefix)) + { + // Delete objects from this layer + TypedValue[] tvs = { new((int)DxfCode.LayerName, layerName) }; + SelectionFilter selectionFilter = new(tvs); + SelectionSet selectionResult = Doc.Editor.SelectAll(selectionFilter).Value; + if (selectionResult == null) + { + return; + } + foreach (SelectedObject selectedObject in selectionResult) + { + transaction.GetObject(selectedObject.ObjectId, OpenMode.ForWrite).Erase(); + } + // Delete layer + layer.UpgradeOpen(); + layer.Erase(); + } + } + transaction.Commit(); + } + /// /// Creates a layer filter for the just received model, grouped under a top level filter "Speckle". Note: manual close and open of the layer properties panel required (it's an acad thing). /// This comes in handy to quickly access the layers created for this specific model. @@ -114,4 +142,19 @@ public void CreateLayerFilter(string projectName, string modelName) groupFilter.NestedFilters.Add(layerFilter); Doc.Database.LayerFilters = layerFilterTree; } + + /// + /// Gets a valid layer name for a given context. + /// + /// + /// + /// + public string GetLayerPath(TraversalContext context, string baseLayerPrefix) + { + string[] collectionBasedPath = context.GetAscendantOfType().Select(c => c.name).Reverse().ToArray(); + string[] path = collectionBasedPath.Length != 0 ? collectionBasedPath : context.GetPropertyPath().ToArray(); + + var name = baseLayerPrefix + string.Join("-", path); + return _autocadContext.RemoveInvalidChars(name); + } } diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/Extensions/AcadUnitsExtension.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/Extensions/AcadUnitsExtension.cs new file mode 100644 index 0000000000..f4ee8e3a66 --- /dev/null +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/Extensions/AcadUnitsExtension.cs @@ -0,0 +1,39 @@ +using Autodesk.AutoCAD.DatabaseServices; +using Speckle.Core.Kits; +using Speckle.Core.Logging; + +namespace Speckle.Connectors.Autocad.HostApp.Extensions; + +public static class AcadUnitsExtension +{ + public static string ToSpeckleString(this UnitsValue units) + { + switch (units) + { + case UnitsValue.Millimeters: + return Units.Millimeters; + case UnitsValue.Centimeters: + return Units.Centimeters; + case UnitsValue.Meters: + return Units.Meters; + case UnitsValue.Kilometers: + return Units.Kilometers; + case UnitsValue.Inches: + case UnitsValue.USSurveyInch: + return Units.Inches; + case UnitsValue.Feet: + case UnitsValue.USSurveyFeet: + return Units.Feet; + case UnitsValue.Yards: + case UnitsValue.USSurveyYard: + return Units.Yards; + case UnitsValue.Miles: + case UnitsValue.USSurveyMile: + return Units.Miles; + case UnitsValue.Undefined: + return Units.None; + default: + throw new SpeckleException($"The Unit System \"{units}\" is unsupported."); + } + } +} diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Operations/Receive/AutocadHostObjectBuilder.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Operations/Receive/AutocadHostObjectBuilder.cs index e5b720aad7..3e2e44c0fe 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Operations/Receive/AutocadHostObjectBuilder.cs +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Operations/Receive/AutocadHostObjectBuilder.cs @@ -1,30 +1,41 @@ using Autodesk.AutoCAD.DatabaseServices; using Speckle.Connectors.Autocad.HostApp; using Speckle.Connectors.Autocad.HostApp.Extensions; +using Speckle.Connectors.Autocad.Operations.Send; using Speckle.Core.Models; using Speckle.Connectors.Utils.Builders; using Speckle.Connectors.Utils.Conversion; +using Speckle.Connectors.Utils.Instances; using Speckle.Converters.Common; using Speckle.Core.Logging; using Speckle.Core.Models.GraphTraversal; +using Speckle.Core.Models.Instances; namespace Speckle.Connectors.Autocad.Operations.Receive; +/// +/// Expects to be a scoped dependency per receive operation. +/// public class AutocadHostObjectBuilder : IHostObjectBuilder { private readonly AutocadLayerManager _autocadLayerManager; private readonly IRootToHostConverter _converter; private readonly GraphTraversal _traversalFunction; + // private readonly HashSet _uniqueLayerNames = new(); + private readonly IInstanceObjectsManager> _instanceObjectsManager; + public AutocadHostObjectBuilder( IRootToHostConverter converter, GraphTraversal traversalFunction, - AutocadLayerManager autocadLayerManager + AutocadLayerManager autocadLayerManager, + IInstanceObjectsManager> instanceObjectsManager ) { _converter = converter; _traversalFunction = traversalFunction; _autocadLayerManager = autocadLayerManager; + _instanceObjectsManager = instanceObjectsManager; } public HostObjectBuilderResult Build( @@ -43,20 +54,68 @@ CancellationToken cancellationToken //TODO: make the layerManager handle \/ ? string baseLayerPrefix = $"SPK-{projectName}-{modelName}-"; - HashSet uniqueLayerNames = new(); + + PreReceiveDeepClean(baseLayerPrefix); List results = new(); List bakedObjectIds = new(); - foreach (var tc in _traversalFunction.TraverseWithProgress(rootObject, onOperationProgressed, cancellationToken)) + + // return new(bakedObjectIds, results); + + var objectGraph = _traversalFunction.Traverse(rootObject).Where(obj => obj.Current is not Collection); + + // POC: these are not captured by traversal, so we need to re-add them here + var instanceDefinitionProxies = (rootObject["instanceDefinitionProxies"] as List) + ?.Cast() + .ToList(); + + var instanceComponents = new List<(string[] path, IInstanceComponent obj)>(); + // POC: these are not captured by traversal, so we need to re-add them here + if (instanceDefinitionProxies != null && instanceDefinitionProxies.Count > 0) + { + var transformed = instanceDefinitionProxies.Select(proxy => (Array.Empty(), proxy as IInstanceComponent)); + instanceComponents.AddRange(transformed); + } + + var atomicObjects = new List<(string layerName, Base obj)>(); + + foreach (TraversalContext tc in objectGraph) + { + var layerName = _autocadLayerManager.GetLayerPath(tc, baseLayerPrefix); + if (tc.Current is IInstanceComponent instanceComponent) + { + instanceComponents.Add((new string[] { layerName }, instanceComponent)); + } + else + { + atomicObjects.Add((layerName, tc.Current)); + } + } + + // Stage 1: Convert atomic objects + Dictionary> applicationIdMap = new(); + var count = 0; + foreach (var (layerName, atomicObject) in atomicObjects) { + onOperationProgressed?.Invoke("Converting objects", (double)++count / atomicObjects.Count); try { - var convertedObjects = ConvertObject(tc, baseLayerPrefix, uniqueLayerNames).ToList(); + var convertedObjects = ConvertObject(atomicObject, layerName).ToList(); + + if (atomicObject.applicationId != null) + { + applicationIdMap[atomicObject.applicationId] = convertedObjects; + } results.AddRange( convertedObjects.Select( e => - new ReceiveConversionResult(Status.SUCCESS, tc.Current, e.Handle.Value.ToString(), e.GetType().ToString()) + new ReceiveConversionResult( + Status.SUCCESS, + atomicObject, + e.Handle.Value.ToString(), + e.GetType().ToString() + ) ) ); @@ -64,32 +123,44 @@ CancellationToken cancellationToken } catch (Exception ex) when (!ex.IsFatal()) { - results.Add(new(Status.ERROR, tc.Current, null, null, ex)); + results.Add(new(Status.ERROR, atomicObject, null, null, ex)); } } + // Stage 2: Convert instances + var (createdInstanceIds, consumedObjectIds, instanceConversionResults) = _instanceObjectsManager.BakeInstances( + instanceComponents, + applicationIdMap, + baseLayerPrefix, + onOperationProgressed + ); + + bakedObjectIds.RemoveAll(id => consumedObjectIds.Contains(id)); + bakedObjectIds.AddRange(createdInstanceIds); + results.RemoveAll(result => result.ResultId != null && consumedObjectIds.Contains(result.ResultId)); + results.AddRange(instanceConversionResults); + return new(bakedObjectIds, results); } - private IEnumerable ConvertObject(TraversalContext tc, string baseLayerPrefix, ISet uniqueLayerNames) + private void PreReceiveDeepClean(string baseLayerPrefix) + { + _autocadLayerManager.DeleteAllLayersByPrefix(baseLayerPrefix); + _instanceObjectsManager.PurgeInstances(baseLayerPrefix); + } + + private IEnumerable ConvertObject(Base obj, string layerName) { using TransactionContext transactionContext = TransactionContext.StartTransaction( Application.DocumentManager.MdiActiveDocument ); - string layerFullName = GetLayerPath(tc, baseLayerPrefix); + _autocadLayerManager.CreateLayerForReceive(layerName); - if (uniqueLayerNames.Add(layerFullName)) - { - _autocadLayerManager.CreateLayerOrPurge(layerFullName); - } - - //POC: this transaction used to be called in the converter, We've moved it here to unify converter implementation - //POC: Is this transaction 100% needed? we are already inside a transaction? object converted; using (var tr = Application.DocumentManager.CurrentDocument.Database.TransactionManager.StartTransaction()) { - converted = _converter.Convert(tc.Current); + converted = _converter.Convert(obj); tr.Commit(); } @@ -103,17 +174,8 @@ private IEnumerable ConvertObject(TraversalContext tc, string baseLayerP continue; } - conversionResult.AppendToDb(layerFullName); - + conversionResult.AppendToDb(layerName); yield return conversionResult; } } - - private string GetLayerPath(TraversalContext context, string baseLayerPrefix) - { - string[] collectionBasedPath = context.GetAscendantOfType().Select(c => c.name).ToArray(); - string[] path = collectionBasedPath.Length != 0 ? collectionBasedPath : context.GetPropertyPath().ToArray(); - - return _autocadLayerManager.LayerFullName(baseLayerPrefix, string.Join("-", path)); //TODO: reverse path? - } } diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Operations/Send/AutocadRootObjectBuilder.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Operations/Send/AutocadRootObjectBuilder.cs index 3073a07b25..5c09948f3b 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Operations/Send/AutocadRootObjectBuilder.cs +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Operations/Send/AutocadRootObjectBuilder.cs @@ -3,10 +3,12 @@ using Speckle.Connectors.Utils.Builders; using Speckle.Connectors.Utils.Caching; using Speckle.Connectors.Utils.Conversion; +using Speckle.Connectors.Utils.Instances; using Speckle.Connectors.Utils.Operations; using Speckle.Converters.Common; using Speckle.Core.Logging; using Speckle.Core.Models; +using Speckle.Core.Models.Instances; namespace Speckle.Connectors.Autocad.Operations.Send; @@ -15,11 +17,17 @@ public class AutocadRootObjectBuilder : IRootObjectBuilder private readonly IRootToSpeckleConverter _converter; private readonly string[] _documentPathSeparator = { "\\" }; private readonly ISendConversionCache _sendConversionCache; + private readonly IInstanceObjectsManager> _instanceObjectsManager; - public AutocadRootObjectBuilder(IRootToSpeckleConverter converter, ISendConversionCache sendConversionCache) + public AutocadRootObjectBuilder( + IRootToSpeckleConverter converter, + ISendConversionCache sendConversionCache, + IInstanceObjectsManager> instanceObjectManager + ) { _converter = converter; _sendConversionCache = sendConversionCache; + _instanceObjectsManager = instanceObjectManager; } public RootObjectBuilderResult Build( @@ -43,16 +51,24 @@ public RootObjectBuilderResult Build( Dictionary collectionCache = new(); int count = 0; - List results = new(objects.Count); + var (atomicObjects, instanceProxies, instanceDefinitionProxies) = _instanceObjectsManager.UnpackSelection(objects); + // POC: until we formalise a bit more the root object + modelWithLayers["instanceDefinitionProxies"] = instanceDefinitionProxies; + + List results = new(); var cacheHitCount = 0; - foreach (var (dbObject, applicationId) in objects) + + foreach (var (dbObject, applicationId) in atomicObjects) { ct.ThrowIfCancellationRequested(); - try { Base converted; - if (_sendConversionCache.TryGetValue(sendInfo.ProjectId, applicationId, out ObjectReference value)) + if (dbObject is BlockReference && instanceProxies.TryGetValue(applicationId, out InstanceProxy instanceProxy)) + { + converted = instanceProxy; + } + else if (_sendConversionCache.TryGetValue(sendInfo.ProjectId, applicationId, out ObjectReference value)) { converted = value; cacheHitCount++; @@ -84,7 +100,7 @@ public RootObjectBuilderResult Build( // POC: add logging } - onOperationProgressed?.Invoke("Converting", (double)++count / objects.Count); + onOperationProgressed?.Invoke("Converting", (double)++count / atomicObjects.Count); } // POC: Log would be nice, or can be removed. diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Speckle.Connectors.AutocadShared.projitems b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Speckle.Connectors.AutocadShared.projitems index dd0f8afa29..b95639804d 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Speckle.Connectors.AutocadShared.projitems +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Speckle.Connectors.AutocadShared.projitems @@ -17,12 +17,14 @@ + + diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.Civil3d2024/packages.lock.json b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.Civil3d2024/packages.lock.json index b6c4d13a4c..71a6fee082 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.Civil3d2024/packages.lock.json +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.Civil3d2024/packages.lock.json @@ -439,7 +439,7 @@ "Microsoft.Extensions.Logging.Abstractions": "[7.0.0, )", "Speckle.Autofac": "[2.0.999-local, )", "Speckle.Connectors.Utils": "[2.0.999-local, )", - "Speckle.Core": "[3.0.1-alpha.11, )", + "Speckle.Core": "[3.0.1-alpha.14, )", "System.Threading.Tasks.Dataflow": "[6.0.0, )" } }, @@ -455,7 +455,7 @@ "dependencies": { "Serilog.Extensions.Logging": "[7.0.0, )", "Speckle.Autofac": "[2.0.999-local, )", - "Speckle.Core": "[3.0.1-alpha.11, )" + "Speckle.Core": "[3.0.1-alpha.14, )" } }, "speckle.converters.autocad2024": { @@ -477,7 +477,7 @@ "type": "Project", "dependencies": { "Speckle.Autofac": "[2.0.999-local, )", - "Speckle.Objects": "[3.0.1-alpha.11, )" + "Speckle.Objects": "[3.0.1-alpha.14, )" } }, "speckle.converters.common.dependencyinjection": { @@ -520,9 +520,9 @@ }, "Speckle.Core": { "type": "CentralTransitive", - "requested": "[3.0.1-alpha.11, )", - "resolved": "3.0.1-alpha.11", - "contentHash": "Zt2dBJLlfziEACYCHThbhKypSjhoA01rTw9BzNI72c/BDyftXIz70Tetq/8ZMEqQnKqfmRyYADsAdWKxpdV0Hg==", + "requested": "[3.0.1-alpha.14, )", + "resolved": "3.0.1-alpha.14", + "contentHash": "RzQPVIGFFkKvG56YLr8ACtiwdWJE6IJ9vCQ4qHa0PIsUEpfzAIAi59jnzqtByOFC0FiFrFPow9bkfzylaZorAA==", "dependencies": { "GraphQL.Client": "6.0.0", "Microsoft.CSharp": "4.7.0", @@ -544,11 +544,11 @@ }, "Speckle.Objects": { "type": "CentralTransitive", - "requested": "[3.0.1-alpha.11, )", - "resolved": "3.0.1-alpha.11", - "contentHash": "YR7sei3OQBAi8R/kIu8bEmg5ELDIJK6l5fhOgdnqA9ZvD/fvmRb+09z8lIUTDsgdAdvYU/A/x9VxH9OGPbp9Kw==", + "requested": "[3.0.1-alpha.14, )", + "resolved": "3.0.1-alpha.14", + "contentHash": "z38LGryMvh7iU1uBW+4uo5DwsB3CwRgLt2uFexWFx3mPSid+A0l5XcJzOgLwgFhNl6B42Ryz4ezBsddTp1Uc/g==", "dependencies": { - "Speckle.Core": "3.0.1-alpha.11" + "Speckle.Core": "3.0.1-alpha.14" } }, "System.Threading.Tasks.Dataflow": { diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.Revit2023/packages.lock.json b/DUI3-DX/Connectors/Revit/Speckle.Connectors.Revit2023/packages.lock.json index 0a002c7391..503e92ef50 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.Revit2023/packages.lock.json +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.Revit2023/packages.lock.json @@ -454,7 +454,7 @@ "Microsoft.Extensions.Logging.Abstractions": "[7.0.0, )", "Speckle.Autofac": "[2.0.999-local, )", "Speckle.Connectors.Utils": "[2.0.999-local, )", - "Speckle.Core": "[3.0.1-alpha.11, )", + "Speckle.Core": "[3.0.1-alpha.14, )", "System.Threading.Tasks.Dataflow": "[6.0.0, )" } }, @@ -463,14 +463,14 @@ "dependencies": { "Serilog.Extensions.Logging": "[7.0.0, )", "Speckle.Autofac": "[2.0.999-local, )", - "Speckle.Core": "[3.0.1-alpha.11, )" + "Speckle.Core": "[3.0.1-alpha.14, )" } }, "speckle.converters.common": { "type": "Project", "dependencies": { "Speckle.Autofac": "[2.0.999-local, )", - "Speckle.Objects": "[3.0.1-alpha.11, )" + "Speckle.Objects": "[3.0.1-alpha.14, )" } }, "speckle.converters.common.dependencyinjection": { @@ -517,9 +517,9 @@ }, "Speckle.Core": { "type": "CentralTransitive", - "requested": "[3.0.1-alpha.11, )", - "resolved": "3.0.1-alpha.11", - "contentHash": "Zt2dBJLlfziEACYCHThbhKypSjhoA01rTw9BzNI72c/BDyftXIz70Tetq/8ZMEqQnKqfmRyYADsAdWKxpdV0Hg==", + "requested": "[3.0.1-alpha.14, )", + "resolved": "3.0.1-alpha.14", + "contentHash": "RzQPVIGFFkKvG56YLr8ACtiwdWJE6IJ9vCQ4qHa0PIsUEpfzAIAi59jnzqtByOFC0FiFrFPow9bkfzylaZorAA==", "dependencies": { "GraphQL.Client": "6.0.0", "Microsoft.CSharp": "4.7.0", @@ -541,11 +541,11 @@ }, "Speckle.Objects": { "type": "CentralTransitive", - "requested": "[3.0.1-alpha.11, )", - "resolved": "3.0.1-alpha.11", - "contentHash": "YR7sei3OQBAi8R/kIu8bEmg5ELDIJK6l5fhOgdnqA9ZvD/fvmRb+09z8lIUTDsgdAdvYU/A/x9VxH9OGPbp9Kw==", + "requested": "[3.0.1-alpha.14, )", + "resolved": "3.0.1-alpha.14", + "contentHash": "z38LGryMvh7iU1uBW+4uo5DwsB3CwRgLt2uFexWFx3mPSid+A0l5XcJzOgLwgFhNl6B42Ryz4ezBsddTp1Uc/g==", "dependencies": { - "Speckle.Core": "3.0.1-alpha.11" + "Speckle.Core": "3.0.1-alpha.14" } }, "Speckle.Revit.API": { diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSendBinding.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSendBinding.cs index f0fd3a63d3..7e4e6be8a3 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSendBinding.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSendBinding.cs @@ -1,4 +1,5 @@ using Rhino; +using Rhino.Commands; using Speckle.Connectors.DUI.Bindings; using Speckle.Connectors.DUI.Bridge; using Speckle.Connectors.DUI.Models; @@ -64,6 +65,20 @@ ITopLevelExceptionHandler topLevelExceptionHandler private void SubscribeToRhinoEvents() { + RhinoDoc.LayerTableEvent += (_, _) => + { + Commands.RefreshSendFilters(); + }; + + Command.BeginCommand += (_, e) => + { + if (e.CommandEnglishName == "BlockEdit") + { + var selectedObject = RhinoDoc.ActiveDoc.Objects.GetSelectedObjects(false, false).First(); + ChangedObjectIds.Add(selectedObject.Id.ToString()); + } + }; + RhinoDoc.AddRhinoObject += (_, e) => _topLevelExceptionHandler.CatchUnhandled(() => { diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/RhinoConnectorModule.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/RhinoConnectorModule.cs index 7be48aa2b6..a21fee9903 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/RhinoConnectorModule.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/RhinoConnectorModule.cs @@ -19,6 +19,7 @@ using Speckle.Connectors.Utils; using Speckle.Connectors.Utils.Builders; using Speckle.Connectors.Utils.Caching; +using Speckle.Connectors.Utils.Instances; using Speckle.Connectors.Utils.Operations; using Speckle.Core.Models.GraphTraversal; @@ -70,5 +71,7 @@ public void Load(SpeckleContainerBuilder builder) builder.AddSingleton(DefaultTraversal.CreateTraversalFunc()); builder.AddScoped, RhinoRootObjectBuilder>(); + builder.AddScoped>, RhinoInstanceObjectsManager>(); + builder.AddScoped(); } } diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Extensions/RhinoUnitsExtension.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Extensions/RhinoUnitsExtension.cs new file mode 100644 index 0000000000..2d431afadc --- /dev/null +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Extensions/RhinoUnitsExtension.cs @@ -0,0 +1,37 @@ +using Rhino; +using Speckle.Core.Kits; +using Speckle.Core.Logging; + +namespace Speckle.Connectors.Rhino7.Extensions; + +public static class RhinoUnitsExtension +{ + public static string ToSpeckleString(this UnitSystem unitSystem) + { + switch (unitSystem) + { + case UnitSystem.None: + return Units.Meters; + case UnitSystem.Millimeters: + return Units.Millimeters; + case UnitSystem.Centimeters: + return Units.Centimeters; + case UnitSystem.Meters: + return Units.Meters; + case UnitSystem.Kilometers: + return Units.Kilometers; + case UnitSystem.Inches: + return Units.Inches; + case UnitSystem.Feet: + return Units.Feet; + case UnitSystem.Yards: + return Units.Yards; + case UnitSystem.Miles: + return Units.Miles; + case UnitSystem.Unset: + return Units.Meters; + default: + throw new SpeckleException($"The Unit System \"{unitSystem}\" is unsupported."); + } + } +} diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/RhinoInstanceObjectsManager.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/RhinoInstanceObjectsManager.cs new file mode 100644 index 0000000000..e79073bddf --- /dev/null +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/RhinoInstanceObjectsManager.cs @@ -0,0 +1,254 @@ +using System.DoubleNumerics; +using Rhino; +using Rhino.DocObjects; +using Rhino.Geometry; +using Speckle.Connectors.Rhino7.Extensions; +using Speckle.Connectors.Utils.Conversion; +using Speckle.Connectors.Utils.Instances; +using Speckle.Core.Kits; +using Speckle.Core.Logging; +using Speckle.Core.Models; +using Speckle.Core.Models.Instances; + +namespace Speckle.Connectors.Rhino7.HostApp; + +/// +/// +/// Expects to be a scoped dependency per send or receive operation. +/// +public class RhinoInstanceObjectsManager : IInstanceObjectsManager> +{ + private readonly Dictionary _instanceProxies = new(); + private readonly Dictionary> _instanceProxiesByDefinitionId = new(); + private readonly Dictionary _definitionProxies = new(); + private readonly Dictionary _flatAtomicObjects = new(); + private readonly RhinoLayerManager _layerManager; + + public RhinoInstanceObjectsManager(RhinoLayerManager layerManager) + { + _layerManager = layerManager; + } + + public UnpackResult UnpackSelection(IEnumerable objects) + { + foreach (var obj in objects) + { + if (obj is InstanceObject instanceObject) + { + UnpackInstance(instanceObject); + } + _flatAtomicObjects[obj.Id.ToString()] = obj; + } + return new(_flatAtomicObjects.Values.ToList(), _instanceProxies, _definitionProxies.Values.ToList()); + } + + private void UnpackInstance(InstanceObject instance, int depth = 0) + { + var instanceId = instance.Id.ToString(); + var instanceDefinitionId = instance.InstanceDefinition.Id.ToString(); + var currentDoc = RhinoDoc.ActiveDoc; // POC: too much right now to interface around + + _instanceProxies[instanceId] = new InstanceProxy() + { + applicationId = instanceId, + DefinitionId = instance.InstanceDefinition.Id.ToString(), + Transform = XFormToMatrix(instance.InstanceXform), + MaxDepth = depth, + Units = currentDoc.ModelUnitSystem.ToSpeckleString() + }; + + // For each block instance that has the same definition, we need to keep track of the "maximum depth" at which is found. + // This will enable on receive to create them in the correct order (descending by max depth, interleaved definitions and instances). + // We need to interleave the creation of definitions and instances, as some definitions may depend on instances. + if ( + !_instanceProxiesByDefinitionId.TryGetValue( + instanceDefinitionId, + out List instanceProxiesWithSameDefinition + ) + ) + { + instanceProxiesWithSameDefinition = new List(); + _instanceProxiesByDefinitionId[instanceDefinitionId] = instanceProxiesWithSameDefinition; + } + + // We ensure that all previous instance proxies that have the same definition are at this max depth. I kind of have a feeling this can be done more elegantly, but YOLO + foreach (var instanceProxy in instanceProxiesWithSameDefinition) + { + instanceProxy.MaxDepth = depth; + } + + instanceProxiesWithSameDefinition.Add(_instanceProxies[instanceId]); + + if (_definitionProxies.TryGetValue(instanceDefinitionId, out InstanceDefinitionProxy value)) + { + value.MaxDepth = depth; + return; + } + + var definition = new InstanceDefinitionProxy + { + applicationId = instanceDefinitionId, + Objects = new List(), + MaxDepth = depth, + ["name"] = instance.InstanceDefinition.Name, + ["description"] = instance.InstanceDefinition.Description + }; + + _definitionProxies[instance.InstanceDefinition.Id.ToString()] = definition; + + foreach (var obj in instance.InstanceDefinition.GetObjects()) + { + definition.Objects.Add(obj.Id.ToString()); + if (obj is InstanceObject localInstance) + { + UnpackInstance(localInstance, depth + 1); + } + _flatAtomicObjects[obj.Id.ToString()] = obj; + } + } + + /// + /// Bakes in the host app doc instances. Assumes constituent atomic objects already present in the host app. + /// + /// Instance definitions and instances that need creating. + /// A dict mapping { original application id -> [resulting application ids post conversion] } + /// + public BakeResult BakeInstances( + List<(string[] layerPath, IInstanceComponent obj)> instanceComponents, + Dictionary> applicationIdMap, + string baseLayerName, + Action? onOperationProgressed + ) + { + // var doc = _contextStack.Current.Document; + var doc = RhinoDoc.ActiveDoc; // POC: too much right now to interface around + + var sortedInstanceComponents = instanceComponents + .OrderByDescending(x => x.obj.MaxDepth) // Sort by max depth, so we start baking from the deepest element first + .ThenBy(x => x.obj is InstanceDefinitionProxy ? 0 : 1) // Ensure we bake the deepest definition first, then any instances that depend on it + .ToList(); + var definitionIdAndApplicationIdMap = new Dictionary(); + + var count = 0; + var conversionResults = new List(); + var createdObjectIds = new List(); + var consumedObjectIds = new List(); + foreach (var (path, instanceOrDefinition) in sortedInstanceComponents) + { + onOperationProgressed?.Invoke("Converting blocks", (double)++count / sortedInstanceComponents.Count); + try + { + if (instanceOrDefinition is InstanceDefinitionProxy definitionProxy) + { + var currentApplicationObjectsIds = definitionProxy.Objects + .Select(x => applicationIdMap.TryGetValue(x, out List value) ? value : null) + .Where(x => x is not null) + .SelectMany(id => id) + .ToList(); + + var definitionGeometryList = new List(); + var attributes = new List(); + + foreach (var id in currentApplicationObjectsIds) + { + var docObject = doc.Objects.FindId(new Guid(id)); + definitionGeometryList.Add(docObject.Geometry); + attributes.Add(docObject.Attributes); + } + + // POC: Currently we're relying on the definition name for identification if it's coming from speckle and from which model; could we do something else? + var defName = $"{baseLayerName} ({definitionProxy.applicationId})"; + var defIndex = doc.InstanceDefinitions.Add( + defName, + "No description", // POC: perhaps bring it along from source? We'd need to look at ACAD first + Point3d.Origin, + definitionGeometryList, + attributes + ); + + // POC: check on defIndex -1, means we haven't created anything - this is most likely an recoverable error at this stage + if (defIndex == -1) + { + throw new ConversionException("Failed to create an instance defintion object."); + } + + if (definitionProxy.applicationId != null) + { + definitionIdAndApplicationIdMap[definitionProxy.applicationId] = defIndex; + } + + // Rhino deletes original objects on block creation - we should do the same. + doc.Objects.Delete(currentApplicationObjectsIds.Select(stringId => new Guid(stringId)), false); + consumedObjectIds.AddRange(currentApplicationObjectsIds); + createdObjectIds.RemoveAll(id => consumedObjectIds.Contains(id)); // in case we've consumed some existing instances + } + + if ( + instanceOrDefinition is InstanceProxy instanceProxy + && definitionIdAndApplicationIdMap.TryGetValue(instanceProxy.DefinitionId, out int index) + ) + { + var transform = MatrixToTransform(instanceProxy.Transform, instanceProxy.Units); + var layerIndex = _layerManager.GetAndCreateLayerFromPath(path, baseLayerName); + var id = doc.Objects.AddInstanceObject(index, transform, new ObjectAttributes() { LayerIndex = layerIndex }); + if (instanceProxy.applicationId != null) + { + applicationIdMap[instanceProxy.applicationId] = new List() { id.ToString() }; + } + + createdObjectIds.Add(id.ToString()); + conversionResults.Add(new(Status.SUCCESS, instanceProxy, id.ToString(), "Instance (Block)")); + } + } + catch (Exception ex) when (!ex.IsFatal()) + { + conversionResults.Add(new(Status.ERROR, instanceOrDefinition as Base ?? new Base(), null, null, ex)); + } + } + + return new(createdObjectIds, consumedObjectIds, conversionResults); + } + + public void PurgeInstances(string namePrefix) + { + var currentDoc = RhinoDoc.ActiveDoc; // POC: too much right now to interface around + foreach (var definition in currentDoc.InstanceDefinitions) + { + if (!definition.IsDeleted && definition.Name.Contains(namePrefix)) + { + currentDoc.InstanceDefinitions.Delete(definition.Index, true, false); + } + } + } + + private Matrix4x4 XFormToMatrix(Transform t) => + new(t.M00, t.M01, t.M02, t.M03, t.M10, t.M11, t.M12, t.M13, t.M20, t.M21, t.M22, t.M23, t.M30, t.M31, t.M32, t.M33); + + private Transform MatrixToTransform(Matrix4x4 matrix, string units) + { + var currentDoc = RhinoDoc.ActiveDoc; // POC: too much right now to interface around + var conversionFactor = Units.GetConversionFactor(units, currentDoc.ModelUnitSystem.ToSpeckleString()); + + var t = Transform.Identity; + t.M00 = matrix.M11; + t.M01 = matrix.M12; + t.M02 = matrix.M13; + t.M03 = matrix.M14 * conversionFactor; + + t.M10 = matrix.M21; + t.M11 = matrix.M22; + t.M12 = matrix.M23; + t.M13 = matrix.M24 * conversionFactor; + + t.M20 = matrix.M31; + t.M21 = matrix.M32; + t.M22 = matrix.M33; + t.M23 = matrix.M34 * conversionFactor; + + t.M30 = matrix.M41; + t.M31 = matrix.M42; + t.M32 = matrix.M43; + t.M33 = matrix.M44; + return t; + } +} diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/RhinoLayerManager.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/RhinoLayerManager.cs new file mode 100644 index 0000000000..55323bf099 --- /dev/null +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/RhinoLayerManager.cs @@ -0,0 +1,122 @@ +using System.Diagnostics.Contracts; +using Rhino; +using Rhino.DocObjects; +using Speckle.Core.Models; +using Speckle.Core.Models.GraphTraversal; + +namespace Speckle.Connectors.Rhino7.HostApp; + +/// +/// Utility class managing layer creation and/or extraction from rhino. Expects to be a scoped dependency per send or receive operation. +/// +public class RhinoLayerManager +{ + private readonly Dictionary _hostLayerCache = new(); + private readonly Dictionary _layerCollectionCache = new(); + + /// + /// Creates the base layer and adds it to the cache. + /// + /// + public void CreateBaseLayer(string baseLayerName) + { + var index = RhinoDoc.ActiveDoc.Layers.Add(new Layer { Name = baseLayerName }); // POC: too much effort right now to wrap around the interfaced layers and doc + // var index = _contextStack.Current.Document.Layers.Add(new Layer { Name = baseLayerName }); + _hostLayerCache.Add(baseLayerName, index); + } + + /// + /// For receive: Use this method to construct layers in the host app when receiving.. + /// + /// + /// + /// + public int GetAndCreateLayerFromPath(string[] path, string baseLayerName) + { + var fullLayerName = string.Join(Layer.PathSeparator, path); + if (_hostLayerCache.TryGetValue(fullLayerName, out int existingLayerIndex)) + { + return existingLayerIndex; + } + + var currentLayerName = baseLayerName; + var currentDocument = RhinoDoc.ActiveDoc; // POC: too much effort right now to wrap around the interfaced layers + + var previousLayer = currentDocument.Layers.FindName(currentLayerName); + foreach (var layerName in path) + { + currentLayerName = baseLayerName + Layer.PathSeparator + layerName; + currentLayerName = currentLayerName.Replace("{", "").Replace("}", ""); // Rhino specific cleanup for gh (see RemoveInvalidRhinoChars) + if (_hostLayerCache.TryGetValue(currentLayerName, out int value)) + { + previousLayer = currentDocument.Layers.FindIndex(value); + continue; + } + + var cleanNewLayerName = layerName.Replace("{", "").Replace("}", ""); + var newLayer = new Layer { Name = cleanNewLayerName, ParentLayerId = previousLayer.Id }; + var index = currentDocument.Layers.Add(newLayer); + _hostLayerCache.Add(currentLayerName, index); + previousLayer = currentDocument.Layers.FindIndex(index); // note we need to get the correct id out, hence why we're double calling this + } + return previousLayer.Index; + } + + /// + /// For send: Use this method to construct the root commit object while converting objects. + /// Returns the host collection corresponding to the provided layer. If it's the first time that it is being asked for, it will be created and stored in the root object collection. + /// + /// The layer you want the equivalent collection for. + /// The root object that will be sent to Speckle, and will host all collections. + /// + public Collection GetHostObjectCollection(Layer layer, Collection rootObjectCollection) + { + if (_layerCollectionCache.TryGetValue(layer.Index, out Collection value)) + { + return value; + } + + var names = layer.FullPath.Split(new[] { Layer.PathSeparator }, StringSplitOptions.None); + var path = names[0]; + var index = 0; + var previousCollection = rootObjectCollection; + foreach (var layerName in names) + { + var existingLayerIndex = RhinoDoc.ActiveDoc.Layers.FindByFullPath(path, -1); + Collection? childCollection = null; + if (_layerCollectionCache.TryGetValue(existingLayerIndex, out Collection? collection)) + { + childCollection = collection; + } + else + { + childCollection = new Collection(layerName, "layer") + { + applicationId = RhinoDoc.ActiveDoc.Layers[existingLayerIndex].Id.ToString() + }; + previousCollection.elements.Add(childCollection); + _layerCollectionCache[existingLayerIndex] = childCollection; + } + + previousCollection = childCollection; + + if (index < names.Length - 1) + { + path += Layer.PathSeparator + names[index + 1]; + } + index++; + } + + _layerCollectionCache[layer.Index] = previousCollection; + return previousCollection; + } + + [Pure] + public string[] GetLayerPath(TraversalContext context) + { + string[] collectionBasedPath = context.GetAscendantOfType().Select(c => c.name).ToArray(); + string[] reverseOrderPath = + collectionBasedPath.Length != 0 ? collectionBasedPath : context.GetPropertyPath().ToArray(); + return reverseOrderPath.Reverse().ToArray(); + } +} diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Receive/RhinoHostObjectBuilder.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Receive/RhinoHostObjectBuilder.cs index 02f653f08a..1967f3a2bf 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Receive/RhinoHostObjectBuilder.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Receive/RhinoHostObjectBuilder.cs @@ -1,31 +1,43 @@ -using System.Diagnostics.Contracts; using Rhino; using Rhino.DocObjects; using Rhino.Geometry; +using Speckle.Connectors.Rhino7.HostApp; using Speckle.Connectors.Utils.Builders; using Speckle.Connectors.Utils.Conversion; +using Speckle.Connectors.Utils.Instances; using Speckle.Converters.Common; using Speckle.Core.Logging; using Speckle.Core.Models; using Speckle.Core.Models.GraphTraversal; +using Speckle.Core.Models.Instances; namespace Speckle.Connectors.Rhino7.Operations.Receive; +/// +/// Expects to be a scoped dependency per receive operation. +/// public class RhinoHostObjectBuilder : IHostObjectBuilder { private readonly IRootToHostConverter _converter; private readonly IConversionContextStack _contextStack; private readonly GraphTraversal _traverseFunction; + private readonly IInstanceObjectsManager> _instanceObjectsManager; + private readonly RhinoLayerManager _layerManager; + public RhinoHostObjectBuilder( IRootToHostConverter converter, IConversionContextStack contextStack, - GraphTraversal traverseFunction + GraphTraversal traverseFunction, + RhinoLayerManager layerManager, + IInstanceObjectsManager> instanceObjectsManager ) { _converter = converter; _contextStack = contextStack; _traverseFunction = traverseFunction; + _layerManager = layerManager; + _instanceObjectsManager = instanceObjectsManager; } public HostObjectBuilderResult Build( @@ -43,77 +55,136 @@ CancellationToken cancellationToken .TraverseWithProgress(rootObject, onOperationProgressed, cancellationToken) .Where(obj => obj.Current is not Collection); - var conversionResults = BakeObjects(objectsToConvert, baseLayerName); + var instanceDefinitionProxies = (rootObject["instanceDefinitionProxies"] as List) + ?.Cast() + .ToList(); + + var conversionResults = BakeObjects( + objectsToConvert, + instanceDefinitionProxies, + baseLayerName, + onOperationProgressed + ); _contextStack.Current.Document.Views.Redraw(); return conversionResults; } - // POC: Potentially refactor out into an IObjectBaker. - private HostObjectBuilderResult BakeObjects(IEnumerable objectsGraph, string baseLayerName) + private HostObjectBuilderResult BakeObjects( + IEnumerable objectsGraph, + List? instanceDefinitionProxies, + string baseLayerName, + Action? onOperationProgressed + ) { RhinoDoc doc = _contextStack.Current.Document; var rootLayerIndex = _contextStack.Current.Document.Layers.Find(Guid.Empty, baseLayerName, RhinoMath.UnsetIntIndex); - // POC: We could move this out into a separate service for testing and re-use. - // Cleans up any previously received objects - if (rootLayerIndex != RhinoMath.UnsetIntIndex) - { - Layer documentLayer = doc.Layers[rootLayerIndex]; - Layer[]? childLayers = documentLayer.GetChildren(); - if (childLayers != null) - { - using var layerNoDraw = new DisableRedrawScope(doc.Views); - foreach (var layer in childLayers) - { - var purgeSuccess = doc.Layers.Purge(layer.Index, true); - if (!purgeSuccess) - { - Console.WriteLine($"Failed to purge layer: {layer}"); - } - } - } - } - - var cache = new Dictionary(); - rootLayerIndex = doc.Layers.Add(new Layer { Name = baseLayerName }); - cache.Add(baseLayerName, rootLayerIndex); + PreReceiveDeepClean(baseLayerName, rootLayerIndex); + _layerManager.CreateBaseLayer(baseLayerName); using var noDraw = new DisableRedrawScope(doc.Views); var conversionResults = new List(); var bakedObjectIds = new List(); - foreach (TraversalContext tc in objectsGraph) + var instanceComponents = new List<(string[] layerPath, IInstanceComponent obj)>(); + + // POC: these are not captured by traversal, so we need to re-add them here + if (instanceDefinitionProxies != null && instanceDefinitionProxies.Count > 0) { - try - { - var path = GetLayerPath(tc); + var transformed = instanceDefinitionProxies.Select(proxy => (Array.Empty(), proxy as IInstanceComponent)); + instanceComponents.AddRange(transformed); + } - var fullLayerName = string.Join(Layer.PathSeparator, path); - var layerIndex = cache.TryGetValue(fullLayerName, out int value) - ? value - : GetAndCreateLayerFromPath(path, baseLayerName, cache); + var atomicObjects = new List<(string[] layerPath, Base obj)>(); - var result = _converter.Convert(tc.Current); + // Split up the instances from the non-instances + foreach (TraversalContext tc in objectsGraph) + { + var path = _layerManager.GetLayerPath(tc); + if (tc.Current is IInstanceComponent instanceComponent) + { + instanceComponents.Add((path, instanceComponent)); + } + else + { + atomicObjects.Add((path, tc.Current)); + } + } - var conversionIds = HandleConversionResult(result, tc.Current, layerIndex); + // Stage 1: Convert atomic objects + // Note: this can become encapsulated later in an "atomic object baker" of sorts, if needed. + var applicationIdMap = new Dictionary>(); // used in converting blocks in stage 2. keeps track of original app id => resulting new app ids post baking + var count = 0; + foreach (var (path, obj) in atomicObjects) + { + onOperationProgressed?.Invoke("Converting objects", (double)++count / atomicObjects.Count); + try + { + var layerIndex = _layerManager.GetAndCreateLayerFromPath(path, baseLayerName); + var result = _converter.Convert(obj); + var conversionIds = HandleConversionResult(result, obj, layerIndex).ToList(); foreach (var r in conversionIds) { - conversionResults.Add(new(Status.SUCCESS, tc.Current, r, result.GetType().ToString())); + conversionResults.Add(new(Status.SUCCESS, obj, r, result.GetType().ToString())); bakedObjectIds.Add(r); } + + if (obj.applicationId != null) + { + applicationIdMap[obj.applicationId] = conversionIds; + } } catch (Exception ex) when (!ex.IsFatal()) { - conversionResults.Add(new(Status.ERROR, tc.Current, null, null, ex)); + conversionResults.Add(new(Status.ERROR, obj, null, null, ex)); } } + // Stage 2: Convert instances + var (createdInstanceIds, consumedObjectIds, instanceConversionResults) = _instanceObjectsManager.BakeInstances( + instanceComponents, + applicationIdMap, + baseLayerName, + onOperationProgressed + ); + + bakedObjectIds.RemoveAll(id => consumedObjectIds.Contains(id)); // remove all objects that have been "consumed" + bakedObjectIds.AddRange(createdInstanceIds); // add instance ids + conversionResults.RemoveAll(result => result.ResultId != null && consumedObjectIds.Contains(result.ResultId)); // remove all conversion results for atomic objects that have been consumed (POC: not that cool, but prevents problems on object highlighting) + conversionResults.AddRange(instanceConversionResults); // add instance conversion results to our list + + // Stage 3: Return return new(bakedObjectIds, conversionResults); } + private void PreReceiveDeepClean(string baseLayerName, int rootLayerIndex) + { + _instanceObjectsManager.PurgeInstances(baseLayerName); + + var doc = _contextStack.Current.Document; + // Cleans up any previously received objects + if (rootLayerIndex != RhinoMath.UnsetIntIndex) + { + var documentLayer = doc.Layers[rootLayerIndex]; + var childLayers = documentLayer.GetChildren(); + if (childLayers != null) + { + using var layerNoDraw = new DisableRedrawScope(doc.Views); + foreach (var layer in childLayers) + { + var purgeSuccess = doc.Layers.Purge(layer.Index, true); + if (!purgeSuccess) + { + Console.WriteLine($"Failed to purge layer: {layer}"); + } + } + } + } + } + private IReadOnlyList HandleConversionResult(object conversionResult, Base originalObject, int layerIndex) { var doc = _contextStack.Current.Document; @@ -149,39 +220,4 @@ private Group BakeObjectsAsGroup(string groupName, IEnumerable lis var group = _contextStack.Current.Document.Groups.FindIndex(groupIndex); return group; } - - // POC: This is the original DUI3 function, this will grow over time as we add more conversions that are missing, so it should be refactored out into an ILayerManager or some sort of service. - private int GetAndCreateLayerFromPath(string[] path, string baseLayerName, Dictionary cache) - { - var currentLayerName = baseLayerName; - RhinoDoc currentDocument = _contextStack.Current.Document; - - var previousLayer = currentDocument.Layers.FindName(currentLayerName); - foreach (var layerName in path) - { - currentLayerName = baseLayerName + Layer.PathSeparator + layerName; - currentLayerName = currentLayerName.Replace("{", "").Replace("}", ""); // Rhino specific cleanup for gh (see RemoveInvalidRhinoChars) - if (cache.TryGetValue(currentLayerName, out int value)) - { - previousLayer = currentDocument.Layers.FindIndex(value); - continue; - } - - var cleanNewLayerName = layerName.Replace("{", "").Replace("}", ""); - var newLayer = new Layer { Name = cleanNewLayerName, ParentLayerId = previousLayer.Id }; - var index = currentDocument.Layers.Add(newLayer); - cache.Add(currentLayerName, index); - previousLayer = currentDocument.Layers.FindIndex(index); // note we need to get the correct id out, hence why we're double calling this - } - return previousLayer.Index; - } - - [Pure] - private static string[] GetLayerPath(TraversalContext context) - { - string[] collectionBasedPath = context.GetAscendantOfType().Select(c => c.name).ToArray(); - string[] reverseOrderPath = - collectionBasedPath.Length != 0 ? collectionBasedPath : context.GetPropertyPath().ToArray(); - return reverseOrderPath.Reverse().ToArray(); - } } diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Send/RhinoRootObjectBuilder.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Send/RhinoRootObjectBuilder.cs index 2d5996c97a..03d01c8568 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Send/RhinoRootObjectBuilder.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Send/RhinoRootObjectBuilder.cs @@ -1,13 +1,15 @@ using System.Diagnostics; -using Rhino.DocObjects; using Rhino; +using Rhino.DocObjects; using Speckle.Core.Models; using Speckle.Autofac.DependencyInjection; using Speckle.Converters.Common; using Speckle.Connectors.DUI.Models.Card.SendFilter; +using Speckle.Connectors.Rhino7.HostApp; using Speckle.Connectors.Utils.Builders; using Speckle.Connectors.Utils.Caching; using Speckle.Connectors.Utils.Conversion; +using Speckle.Connectors.Utils.Instances; using Speckle.Connectors.Utils.Operations; using Speckle.Core.Logging; @@ -20,11 +22,23 @@ public class RhinoRootObjectBuilder : IRootObjectBuilder { private readonly IUnitOfWorkFactory _unitOfWorkFactory; private readonly ISendConversionCache _sendConversionCache; - - public RhinoRootObjectBuilder(IUnitOfWorkFactory unitOfWorkFactory, ISendConversionCache sendConversionCache) + private readonly IInstanceObjectsManager> _instanceObjectsManager; + private readonly IConversionContextStack _contextStack; + private readonly RhinoLayerManager _layerManager; + + public RhinoRootObjectBuilder( + IUnitOfWorkFactory unitOfWorkFactory, + ISendConversionCache sendConversionCache, + IConversionContextStack contextStack, + RhinoLayerManager layerManager, + IInstanceObjectsManager> instanceObjectsManager + ) { _unitOfWorkFactory = unitOfWorkFactory; _sendConversionCache = sendConversionCache; + _contextStack = contextStack; + _layerManager = layerManager; + _instanceObjectsManager = instanceObjectsManager; } public RootObjectBuilderResult Build( @@ -46,22 +60,28 @@ private RootObjectBuilderResult ConvertObjects( using var uow = _unitOfWorkFactory.Resolve(); var converter = uow.Service; - var rootObjectCollection = new Collection { name = RhinoDoc.ActiveDoc.Name ?? "Unnamed document" }; + var rootObjectCollection = new Collection { name = _contextStack.Current.Document.Name ?? "Unnamed document" }; int count = 0; Dictionary layerCollectionCache = new(); + var (atomicObjects, instanceProxies, instanceDefinitionProxies) = _instanceObjectsManager.UnpackSelection( + rhinoObjects + ); + + // POC: we should formalise this, sooner or later - or somehow fix it a bit more + rootObjectCollection["instanceDefinitionProxies"] = instanceDefinitionProxies; // this won't work re traversal on receive + // POC: Handle blocks. List results = new(rhinoObjects.Count); var cacheHitCount = 0; - foreach (RhinoObject rhinoObject in rhinoObjects) + foreach (RhinoObject rhinoObject in atomicObjects) { cancellationToken.ThrowIfCancellationRequested(); + // RhinoDoc.ActiveDoc.Layers + var layer = _contextStack.Current.Document.Layers[rhinoObject.Attributes.LayerIndex]; - // POC: This uses the ActiveDoc but it is bad practice to do so. A context object should be injected that would contain the Doc. - var layer = RhinoDoc.ActiveDoc.Layers[rhinoObject.Attributes.LayerIndex]; - - var collectionHost = GetHostObjectCollection(layerCollectionCache, layer, rootObjectCollection); + var collectionHost = _layerManager.GetHostObjectCollection(layer, rootObjectCollection); var applicationId = rhinoObject.Id.ToString(); try @@ -70,8 +90,11 @@ private RootObjectBuilderResult ConvertObjects( // What we actually do here is check if the object has been previously converted AND has not changed. // If that's the case, we insert in the host collection just its object reference which has been saved from the prior conversion. Base converted; - - if (_sendConversionCache.TryGetValue(sendInfo.ProjectId, applicationId, out ObjectReference value)) + if (rhinoObject is InstanceObject) + { + converted = instanceProxies[applicationId]; + } + else if (_sendConversionCache.TryGetValue(sendInfo.ProjectId, applicationId, out ObjectReference value)) { converted = value; cacheHitCount++; @@ -106,58 +129,4 @@ private RootObjectBuilderResult ConvertObjects( // 5. profit return new(rootObjectCollection, results); } - - /// - /// Returns the host collection based on the provided layer. If it's not found, it will be created and hosted within the the rootObjectCollection. - /// - /// - /// - /// - /// - private Collection GetHostObjectCollection( - Dictionary layerCollectionCache, - Layer layer, - Collection rootObjectCollection - ) - { - // POC: This entire implementation should be broken down and potentially injected in. - if (layerCollectionCache.TryGetValue(layer.Index, out Collection value)) - { - return value; - } - - var names = layer.FullPath.Split(new[] { Layer.PathSeparator }, StringSplitOptions.None); - var path = names[0]; - var index = 0; - var previousCollection = rootObjectCollection; - foreach (var layerName in names) - { - var existingLayerIndex = RhinoDoc.ActiveDoc.Layers.FindByFullPath(path, -1); - Collection? childCollection = null; - if (layerCollectionCache.TryGetValue(existingLayerIndex, out Collection? collection)) - { - childCollection = collection; - } - else - { - childCollection = new Collection(layerName, "layer") - { - applicationId = RhinoDoc.ActiveDoc.Layers[existingLayerIndex].Id.ToString() - }; - previousCollection.elements.Add(childCollection); - layerCollectionCache[existingLayerIndex] = childCollection; - } - - previousCollection = childCollection; - - if (index < names.Length - 1) - { - path += Layer.PathSeparator + names[index + 1]; - } - index++; - } - - layerCollectionCache[layer.Index] = previousCollection; - return previousCollection; - } } diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/packages.lock.json b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/packages.lock.json index 42b0399f3e..53de68cb60 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/packages.lock.json +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/packages.lock.json @@ -285,11 +285,6 @@ "resolved": "13.0.2", "contentHash": "g1BejUZwax5PRfL6xHgLEK23sqHWOgOj9hE7RvfRRlN00AGt8GnPYt8HedSK7UB3HiRW8zCA9Pn0iiYxCK24BA==" }, - "Speckle.Revit2023.Interfaces": { - "type": "Transitive", - "resolved": "0.1.1-preview.0.24", - "contentHash": "BSVpOUJc9g6ISrw8GxvtkglTlITpHEDYNOhxv1ZPbckBsI0yO36JiphhQV4q57ERqD9PpCozUJkVhlCaxWeS6A==" - }, "SQLitePCLRaw.bundle_e_sqlite3": { "type": "Transitive", "resolved": "2.1.4", @@ -449,7 +444,7 @@ "Microsoft.Extensions.Logging.Abstractions": "[7.0.0, )", "Speckle.Autofac": "[2.0.999-local, )", "Speckle.Connectors.Utils": "[2.0.999-local, )", - "Speckle.Core": "[3.0.1-alpha.11, )", + "Speckle.Core": "[3.0.1-alpha.14, )", "System.Threading.Tasks.Dataflow": "[6.0.0, )" } }, @@ -465,14 +460,14 @@ "dependencies": { "Serilog.Extensions.Logging": "[7.0.0, )", "Speckle.Autofac": "[2.0.999-local, )", - "Speckle.Core": "[3.0.1-alpha.11, )" + "Speckle.Core": "[3.0.1-alpha.14, )" } }, "speckle.converters.common": { "type": "Project", "dependencies": { "Speckle.Autofac": "[2.0.999-local, )", - "Speckle.Objects": "[3.0.1-alpha.11, )" + "Speckle.Objects": "[3.0.1-alpha.14, )" } }, "speckle.converters.common.dependencyinjection": { @@ -516,9 +511,9 @@ }, "Speckle.Core": { "type": "CentralTransitive", - "requested": "[3.0.1-alpha.11, )", - "resolved": "3.0.1-alpha.11", - "contentHash": "Zt2dBJLlfziEACYCHThbhKypSjhoA01rTw9BzNI72c/BDyftXIz70Tetq/8ZMEqQnKqfmRyYADsAdWKxpdV0Hg==", + "requested": "[3.0.1-alpha.14, )", + "resolved": "3.0.1-alpha.14", + "contentHash": "RzQPVIGFFkKvG56YLr8ACtiwdWJE6IJ9vCQ4qHa0PIsUEpfzAIAi59jnzqtByOFC0FiFrFPow9bkfzylaZorAA==", "dependencies": { "GraphQL.Client": "6.0.0", "Microsoft.CSharp": "4.7.0", @@ -540,11 +535,11 @@ }, "Speckle.Objects": { "type": "CentralTransitive", - "requested": "[3.0.1-alpha.11, )", - "resolved": "3.0.1-alpha.11", - "contentHash": "YR7sei3OQBAi8R/kIu8bEmg5ELDIJK6l5fhOgdnqA9ZvD/fvmRb+09z8lIUTDsgdAdvYU/A/x9VxH9OGPbp9Kw==", + "requested": "[3.0.1-alpha.14, )", + "resolved": "3.0.1-alpha.14", + "contentHash": "z38LGryMvh7iU1uBW+4uo5DwsB3CwRgLt2uFexWFx3mPSid+A0l5XcJzOgLwgFhNl6B42Ryz4ezBsddTp1Uc/g==", "dependencies": { - "Speckle.Core": "3.0.1-alpha.11" + "Speckle.Core": "3.0.1-alpha.14" } }, "System.Threading.Tasks.Dataflow": { diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3.DependencyInjection/packages.lock.json b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3.DependencyInjection/packages.lock.json index 383e499052..9f83e4c13d 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3.DependencyInjection/packages.lock.json +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3.DependencyInjection/packages.lock.json @@ -370,7 +370,7 @@ "type": "Project", "dependencies": { "Speckle.Autofac": "[2.0.999-local, )", - "Speckle.Objects": "[3.0.1-alpha.11, )" + "Speckle.Objects": "[3.0.1-alpha.14, )" } }, "speckle.converters.common.dependencyinjection": { @@ -394,9 +394,9 @@ }, "Speckle.Core": { "type": "CentralTransitive", - "requested": "[3.0.1-alpha.11, )", - "resolved": "3.0.1-alpha.11", - "contentHash": "Zt2dBJLlfziEACYCHThbhKypSjhoA01rTw9BzNI72c/BDyftXIz70Tetq/8ZMEqQnKqfmRyYADsAdWKxpdV0Hg==", + "requested": "[3.0.1-alpha.14, )", + "resolved": "3.0.1-alpha.14", + "contentHash": "RzQPVIGFFkKvG56YLr8ACtiwdWJE6IJ9vCQ4qHa0PIsUEpfzAIAi59jnzqtByOFC0FiFrFPow9bkfzylaZorAA==", "dependencies": { "GraphQL.Client": "6.0.0", "Microsoft.CSharp": "4.7.0", @@ -418,11 +418,11 @@ }, "Speckle.Objects": { "type": "CentralTransitive", - "requested": "[3.0.1-alpha.11, )", - "resolved": "3.0.1-alpha.11", - "contentHash": "YR7sei3OQBAi8R/kIu8bEmg5ELDIJK6l5fhOgdnqA9ZvD/fvmRb+09z8lIUTDsgdAdvYU/A/x9VxH9OGPbp9Kw==", + "requested": "[3.0.1-alpha.14, )", + "resolved": "3.0.1-alpha.14", + "contentHash": "z38LGryMvh7iU1uBW+4uo5DwsB3CwRgLt2uFexWFx3mPSid+A0l5XcJzOgLwgFhNl6B42Ryz4ezBsddTp1Uc/g==", "dependencies": { - "Speckle.Core": "3.0.1-alpha.11" + "Speckle.Core": "3.0.1-alpha.14" } } } diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/packages.lock.json b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/packages.lock.json index 18027e4d25..b77f27c0be 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/packages.lock.json +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/packages.lock.json @@ -363,7 +363,7 @@ "type": "Project", "dependencies": { "Speckle.Autofac": "[2.0.999-local, )", - "Speckle.Objects": "[3.0.1-alpha.11, )" + "Speckle.Objects": "[3.0.1-alpha.14, )" } }, "Microsoft.Extensions.Logging.Abstractions": { @@ -374,9 +374,9 @@ }, "Speckle.Core": { "type": "CentralTransitive", - "requested": "[3.0.1-alpha.11, )", - "resolved": "3.0.1-alpha.11", - "contentHash": "Zt2dBJLlfziEACYCHThbhKypSjhoA01rTw9BzNI72c/BDyftXIz70Tetq/8ZMEqQnKqfmRyYADsAdWKxpdV0Hg==", + "requested": "[3.0.1-alpha.14, )", + "resolved": "3.0.1-alpha.14", + "contentHash": "RzQPVIGFFkKvG56YLr8ACtiwdWJE6IJ9vCQ4qHa0PIsUEpfzAIAi59jnzqtByOFC0FiFrFPow9bkfzylaZorAA==", "dependencies": { "GraphQL.Client": "6.0.0", "Microsoft.CSharp": "4.7.0", @@ -398,11 +398,11 @@ }, "Speckle.Objects": { "type": "CentralTransitive", - "requested": "[3.0.1-alpha.11, )", - "resolved": "3.0.1-alpha.11", - "contentHash": "YR7sei3OQBAi8R/kIu8bEmg5ELDIJK6l5fhOgdnqA9ZvD/fvmRb+09z8lIUTDsgdAdvYU/A/x9VxH9OGPbp9Kw==", + "requested": "[3.0.1-alpha.14, )", + "resolved": "3.0.1-alpha.14", + "contentHash": "z38LGryMvh7iU1uBW+4uo5DwsB3CwRgLt2uFexWFx3mPSid+A0l5XcJzOgLwgFhNl6B42Ryz4ezBsddTp1Uc/g==", "dependencies": { - "Speckle.Core": "3.0.1-alpha.11" + "Speckle.Core": "3.0.1-alpha.14" } } } diff --git a/DUI3-DX/Converters/Autocad/2023/Speckle.Converters.Autocad2023.DependencyInjection/packages.lock.json b/DUI3-DX/Converters/Autocad/2023/Speckle.Converters.Autocad2023.DependencyInjection/packages.lock.json index e9931ee09e..e51635ea86 100644 --- a/DUI3-DX/Converters/Autocad/2023/Speckle.Converters.Autocad2023.DependencyInjection/packages.lock.json +++ b/DUI3-DX/Converters/Autocad/2023/Speckle.Converters.Autocad2023.DependencyInjection/packages.lock.json @@ -374,7 +374,7 @@ "type": "Project", "dependencies": { "Speckle.Autofac": "[2.0.999-local, )", - "Speckle.Objects": "[3.0.1-alpha.11, )" + "Speckle.Objects": "[3.0.1-alpha.14, )" } }, "speckle.converters.common.dependencyinjection": { @@ -402,9 +402,9 @@ }, "Speckle.Core": { "type": "CentralTransitive", - "requested": "[3.0.1-alpha.11, )", - "resolved": "3.0.1-alpha.11", - "contentHash": "Zt2dBJLlfziEACYCHThbhKypSjhoA01rTw9BzNI72c/BDyftXIz70Tetq/8ZMEqQnKqfmRyYADsAdWKxpdV0Hg==", + "requested": "[3.0.1-alpha.14, )", + "resolved": "3.0.1-alpha.14", + "contentHash": "RzQPVIGFFkKvG56YLr8ACtiwdWJE6IJ9vCQ4qHa0PIsUEpfzAIAi59jnzqtByOFC0FiFrFPow9bkfzylaZorAA==", "dependencies": { "GraphQL.Client": "6.0.0", "Microsoft.CSharp": "4.7.0", @@ -426,11 +426,11 @@ }, "Speckle.Objects": { "type": "CentralTransitive", - "requested": "[3.0.1-alpha.11, )", - "resolved": "3.0.1-alpha.11", - "contentHash": "YR7sei3OQBAi8R/kIu8bEmg5ELDIJK6l5fhOgdnqA9ZvD/fvmRb+09z8lIUTDsgdAdvYU/A/x9VxH9OGPbp9Kw==", + "requested": "[3.0.1-alpha.14, )", + "resolved": "3.0.1-alpha.14", + "contentHash": "z38LGryMvh7iU1uBW+4uo5DwsB3CwRgLt2uFexWFx3mPSid+A0l5XcJzOgLwgFhNl6B42Ryz4ezBsddTp1Uc/g==", "dependencies": { - "Speckle.Core": "3.0.1-alpha.11" + "Speckle.Core": "3.0.1-alpha.14" } } } diff --git a/DUI3-DX/Converters/Autocad/2023/Speckle.Converters.Autocad2023/packages.lock.json b/DUI3-DX/Converters/Autocad/2023/Speckle.Converters.Autocad2023/packages.lock.json index b114e8a7c5..3c281f9dcf 100644 --- a/DUI3-DX/Converters/Autocad/2023/Speckle.Converters.Autocad2023/packages.lock.json +++ b/DUI3-DX/Converters/Autocad/2023/Speckle.Converters.Autocad2023/packages.lock.json @@ -364,7 +364,7 @@ "type": "Project", "dependencies": { "Speckle.Autofac": "[2.0.999-local, )", - "Speckle.Objects": "[3.0.1-alpha.11, )" + "Speckle.Objects": "[3.0.1-alpha.14, )" } }, "Microsoft.Extensions.Logging.Abstractions": { @@ -379,9 +379,9 @@ }, "Speckle.Core": { "type": "CentralTransitive", - "requested": "[3.0.1-alpha.11, )", - "resolved": "3.0.1-alpha.11", - "contentHash": "Zt2dBJLlfziEACYCHThbhKypSjhoA01rTw9BzNI72c/BDyftXIz70Tetq/8ZMEqQnKqfmRyYADsAdWKxpdV0Hg==", + "requested": "[3.0.1-alpha.14, )", + "resolved": "3.0.1-alpha.14", + "contentHash": "RzQPVIGFFkKvG56YLr8ACtiwdWJE6IJ9vCQ4qHa0PIsUEpfzAIAi59jnzqtByOFC0FiFrFPow9bkfzylaZorAA==", "dependencies": { "GraphQL.Client": "6.0.0", "Microsoft.CSharp": "4.7.0", @@ -403,11 +403,11 @@ }, "Speckle.Objects": { "type": "CentralTransitive", - "requested": "[3.0.1-alpha.11, )", - "resolved": "3.0.1-alpha.11", - "contentHash": "YR7sei3OQBAi8R/kIu8bEmg5ELDIJK6l5fhOgdnqA9ZvD/fvmRb+09z8lIUTDsgdAdvYU/A/x9VxH9OGPbp9Kw==", + "requested": "[3.0.1-alpha.14, )", + "resolved": "3.0.1-alpha.14", + "contentHash": "z38LGryMvh7iU1uBW+4uo5DwsB3CwRgLt2uFexWFx3mPSid+A0l5XcJzOgLwgFhNl6B42Ryz4ezBsddTp1Uc/g==", "dependencies": { - "Speckle.Core": "3.0.1-alpha.11" + "Speckle.Core": "3.0.1-alpha.14" } } } diff --git a/DUI3-DX/Converters/Autocad/2024/Speckle.Converters.Autocad2024.DependencyInjection/packages.lock.json b/DUI3-DX/Converters/Autocad/2024/Speckle.Converters.Autocad2024.DependencyInjection/packages.lock.json index 8eee516ff1..fe9923d926 100644 --- a/DUI3-DX/Converters/Autocad/2024/Speckle.Converters.Autocad2024.DependencyInjection/packages.lock.json +++ b/DUI3-DX/Converters/Autocad/2024/Speckle.Converters.Autocad2024.DependencyInjection/packages.lock.json @@ -374,7 +374,7 @@ "type": "Project", "dependencies": { "Speckle.Autofac": "[2.0.999-local, )", - "Speckle.Objects": "[3.0.1-alpha.11, )" + "Speckle.Objects": "[3.0.1-alpha.14, )" } }, "speckle.converters.common.dependencyinjection": { @@ -402,9 +402,9 @@ }, "Speckle.Core": { "type": "CentralTransitive", - "requested": "[3.0.1-alpha.11, )", - "resolved": "3.0.1-alpha.11", - "contentHash": "Zt2dBJLlfziEACYCHThbhKypSjhoA01rTw9BzNI72c/BDyftXIz70Tetq/8ZMEqQnKqfmRyYADsAdWKxpdV0Hg==", + "requested": "[3.0.1-alpha.14, )", + "resolved": "3.0.1-alpha.14", + "contentHash": "RzQPVIGFFkKvG56YLr8ACtiwdWJE6IJ9vCQ4qHa0PIsUEpfzAIAi59jnzqtByOFC0FiFrFPow9bkfzylaZorAA==", "dependencies": { "GraphQL.Client": "6.0.0", "Microsoft.CSharp": "4.7.0", @@ -426,11 +426,11 @@ }, "Speckle.Objects": { "type": "CentralTransitive", - "requested": "[3.0.1-alpha.11, )", - "resolved": "3.0.1-alpha.11", - "contentHash": "YR7sei3OQBAi8R/kIu8bEmg5ELDIJK6l5fhOgdnqA9ZvD/fvmRb+09z8lIUTDsgdAdvYU/A/x9VxH9OGPbp9Kw==", + "requested": "[3.0.1-alpha.14, )", + "resolved": "3.0.1-alpha.14", + "contentHash": "z38LGryMvh7iU1uBW+4uo5DwsB3CwRgLt2uFexWFx3mPSid+A0l5XcJzOgLwgFhNl6B42Ryz4ezBsddTp1Uc/g==", "dependencies": { - "Speckle.Core": "3.0.1-alpha.11" + "Speckle.Core": "3.0.1-alpha.14" } } } diff --git a/DUI3-DX/Converters/Autocad/2024/Speckle.Converters.Autocad2024/packages.lock.json b/DUI3-DX/Converters/Autocad/2024/Speckle.Converters.Autocad2024/packages.lock.json index 5ef4059ca1..0a1d936cee 100644 --- a/DUI3-DX/Converters/Autocad/2024/Speckle.Converters.Autocad2024/packages.lock.json +++ b/DUI3-DX/Converters/Autocad/2024/Speckle.Converters.Autocad2024/packages.lock.json @@ -364,7 +364,7 @@ "type": "Project", "dependencies": { "Speckle.Autofac": "[2.0.999-local, )", - "Speckle.Objects": "[3.0.1-alpha.11, )" + "Speckle.Objects": "[3.0.1-alpha.14, )" } }, "Microsoft.Extensions.Logging.Abstractions": { @@ -379,9 +379,9 @@ }, "Speckle.Core": { "type": "CentralTransitive", - "requested": "[3.0.1-alpha.11, )", - "resolved": "3.0.1-alpha.11", - "contentHash": "Zt2dBJLlfziEACYCHThbhKypSjhoA01rTw9BzNI72c/BDyftXIz70Tetq/8ZMEqQnKqfmRyYADsAdWKxpdV0Hg==", + "requested": "[3.0.1-alpha.14, )", + "resolved": "3.0.1-alpha.14", + "contentHash": "RzQPVIGFFkKvG56YLr8ACtiwdWJE6IJ9vCQ4qHa0PIsUEpfzAIAi59jnzqtByOFC0FiFrFPow9bkfzylaZorAA==", "dependencies": { "GraphQL.Client": "6.0.0", "Microsoft.CSharp": "4.7.0", @@ -403,11 +403,11 @@ }, "Speckle.Objects": { "type": "CentralTransitive", - "requested": "[3.0.1-alpha.11, )", - "resolved": "3.0.1-alpha.11", - "contentHash": "YR7sei3OQBAi8R/kIu8bEmg5ELDIJK6l5fhOgdnqA9ZvD/fvmRb+09z8lIUTDsgdAdvYU/A/x9VxH9OGPbp9Kw==", + "requested": "[3.0.1-alpha.14, )", + "resolved": "3.0.1-alpha.14", + "contentHash": "z38LGryMvh7iU1uBW+4uo5DwsB3CwRgLt2uFexWFx3mPSid+A0l5XcJzOgLwgFhNl6B42Ryz4ezBsddTp1Uc/g==", "dependencies": { - "Speckle.Core": "3.0.1-alpha.11" + "Speckle.Core": "3.0.1-alpha.14" } } } diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/packages.lock.json b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/packages.lock.json index a1186a3a61..254754bd42 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/packages.lock.json +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/packages.lock.json @@ -358,7 +358,7 @@ "type": "Project", "dependencies": { "Speckle.Autofac": "[2.0.999-local, )", - "Speckle.Objects": "[3.0.1-alpha.11, )" + "Speckle.Objects": "[3.0.1-alpha.14, )" } }, "speckle.converters.common.dependencyinjection": { @@ -387,9 +387,9 @@ }, "Speckle.Core": { "type": "CentralTransitive", - "requested": "[3.0.1-alpha.11, )", - "resolved": "3.0.1-alpha.11", - "contentHash": "Zt2dBJLlfziEACYCHThbhKypSjhoA01rTw9BzNI72c/BDyftXIz70Tetq/8ZMEqQnKqfmRyYADsAdWKxpdV0Hg==", + "requested": "[3.0.1-alpha.14, )", + "resolved": "3.0.1-alpha.14", + "contentHash": "RzQPVIGFFkKvG56YLr8ACtiwdWJE6IJ9vCQ4qHa0PIsUEpfzAIAi59jnzqtByOFC0FiFrFPow9bkfzylaZorAA==", "dependencies": { "GraphQL.Client": "6.0.0", "Microsoft.CSharp": "4.7.0", @@ -411,11 +411,11 @@ }, "Speckle.Objects": { "type": "CentralTransitive", - "requested": "[3.0.1-alpha.11, )", - "resolved": "3.0.1-alpha.11", - "contentHash": "YR7sei3OQBAi8R/kIu8bEmg5ELDIJK6l5fhOgdnqA9ZvD/fvmRb+09z8lIUTDsgdAdvYU/A/x9VxH9OGPbp9Kw==", + "requested": "[3.0.1-alpha.14, )", + "resolved": "3.0.1-alpha.14", + "contentHash": "z38LGryMvh7iU1uBW+4uo5DwsB3CwRgLt2uFexWFx3mPSid+A0l5XcJzOgLwgFhNl6B42Ryz4ezBsddTp1Uc/g==", "dependencies": { - "Speckle.Core": "3.0.1-alpha.11" + "Speckle.Core": "3.0.1-alpha.14" } }, "Speckle.Revit.API": { diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/XyzConversionToPointTests.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/XyzConversionToPointTests.cs deleted file mode 100644 index 471ca0be47..0000000000 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/XyzConversionToPointTests.cs +++ /dev/null @@ -1,59 +0,0 @@ -using FluentAssertions; -using Moq; -using NUnit.Framework; -using Speckle.Converters.Common; -using Speckle.Converters.RevitShared.Services; -using Speckle.Converters.RevitShared.ToSpeckle; -using Speckle.Revit.Interfaces; - -namespace Speckle.Converters.Revit2023.Tests; - -public class XyzConversionToPointTests -{ - private readonly MockRepository _repository = new(MockBehavior.Strict); - - private readonly Mock> _revitConversionContextStack; - private readonly Mock _scalingServiceToSpeckle; - - public XyzConversionToPointTests() - { - _revitConversionContextStack = _repository.Create>(); - _scalingServiceToSpeckle = _repository.Create(); - } - - [TearDown] - public void Verify() => _repository.VerifyAll(); - - [Test] - public void Convert_Point() - { - var x = 3.1; - var y = 3.2; - var z = 3.3; - var xScaled = 4.1; - var yScaled = 4.2; - var zScaled = 4.3; - var xyz = _repository.Create(); - xyz.Setup(x => x.X).Returns(x); - xyz.Setup(x => x.Y).Returns(y); - xyz.Setup(x => x.Z).Returns(z); - - var units = "units"; - var conversionContext = _repository.Create>(); - conversionContext.Setup(x => x.SpeckleUnits).Returns(units); - - _scalingServiceToSpeckle.Setup(a => a.ScaleLength(x)).Returns(xScaled); - _scalingServiceToSpeckle.Setup(a => a.ScaleLength(y)).Returns(yScaled); - _scalingServiceToSpeckle.Setup(a => a.ScaleLength(z)).Returns(zScaled); - - _revitConversionContextStack.Setup(x => x.Current).Returns(conversionContext.Object); - - var converter = new XyzConversionToPoint(_scalingServiceToSpeckle.Object, _revitConversionContextStack.Object); - var point = converter.Convert(xyz.Object); - - point.x.Should().Be(xScaled); - point.y.Should().Be(yScaled); - point.z.Should().Be(zScaled); - point.units.Should().Be(units); - } -} diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023/packages.lock.json b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023/packages.lock.json index 0fbae10307..742efddba5 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023/packages.lock.json +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023/packages.lock.json @@ -364,7 +364,7 @@ "type": "Project", "dependencies": { "Speckle.Autofac": "[2.0.999-local, )", - "Speckle.Objects": "[3.0.1-alpha.11, )" + "Speckle.Objects": "[3.0.1-alpha.14, )" } }, "Microsoft.Extensions.Logging.Abstractions": { @@ -379,9 +379,9 @@ }, "Speckle.Core": { "type": "CentralTransitive", - "requested": "[3.0.1-alpha.11, )", - "resolved": "3.0.1-alpha.11", - "contentHash": "Zt2dBJLlfziEACYCHThbhKypSjhoA01rTw9BzNI72c/BDyftXIz70Tetq/8ZMEqQnKqfmRyYADsAdWKxpdV0Hg==", + "requested": "[3.0.1-alpha.14, )", + "resolved": "3.0.1-alpha.14", + "contentHash": "RzQPVIGFFkKvG56YLr8ACtiwdWJE6IJ9vCQ4qHa0PIsUEpfzAIAi59jnzqtByOFC0FiFrFPow9bkfzylaZorAA==", "dependencies": { "GraphQL.Client": "6.0.0", "Microsoft.CSharp": "4.7.0", @@ -403,11 +403,11 @@ }, "Speckle.Objects": { "type": "CentralTransitive", - "requested": "[3.0.1-alpha.11, )", - "resolved": "3.0.1-alpha.11", - "contentHash": "YR7sei3OQBAi8R/kIu8bEmg5ELDIJK6l5fhOgdnqA9ZvD/fvmRb+09z8lIUTDsgdAdvYU/A/x9VxH9OGPbp9Kw==", + "requested": "[3.0.1-alpha.14, )", + "resolved": "3.0.1-alpha.14", + "contentHash": "z38LGryMvh7iU1uBW+4uo5DwsB3CwRgLt2uFexWFx3mPSid+A0l5XcJzOgLwgFhNl6B42Ryz4ezBsddTp1Uc/g==", "dependencies": { - "Speckle.Core": "3.0.1-alpha.11" + "Speckle.Core": "3.0.1-alpha.14" } } } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/packages.lock.json b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/packages.lock.json index a897641f42..8094f14468 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/packages.lock.json +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/packages.lock.json @@ -216,11 +216,6 @@ "resolved": "13.0.2", "contentHash": "g1BejUZwax5PRfL6xHgLEK23sqHWOgOj9hE7RvfRRlN00AGt8GnPYt8HedSK7UB3HiRW8zCA9Pn0iiYxCK24BA==" }, - "Speckle.Revit2023.Interfaces": { - "type": "Transitive", - "resolved": "0.1.1-preview.0.24", - "contentHash": "BSVpOUJc9g6ISrw8GxvtkglTlITpHEDYNOhxv1ZPbckBsI0yO36JiphhQV4q57ERqD9PpCozUJkVhlCaxWeS6A==" - }, "SQLitePCLRaw.bundle_e_sqlite3": { "type": "Transitive", "resolved": "2.1.4", @@ -369,7 +364,7 @@ "type": "Project", "dependencies": { "Speckle.Autofac": "[2.0.999-local, )", - "Speckle.Objects": "[3.0.1-alpha.11, )" + "Speckle.Objects": "[3.0.1-alpha.14, )" } }, "speckle.converters.common.dependencyinjection": { @@ -398,9 +393,9 @@ }, "Speckle.Core": { "type": "CentralTransitive", - "requested": "[3.0.1-alpha.11, )", - "resolved": "3.0.1-alpha.11", - "contentHash": "Zt2dBJLlfziEACYCHThbhKypSjhoA01rTw9BzNI72c/BDyftXIz70Tetq/8ZMEqQnKqfmRyYADsAdWKxpdV0Hg==", + "requested": "[3.0.1-alpha.14, )", + "resolved": "3.0.1-alpha.14", + "contentHash": "RzQPVIGFFkKvG56YLr8ACtiwdWJE6IJ9vCQ4qHa0PIsUEpfzAIAi59jnzqtByOFC0FiFrFPow9bkfzylaZorAA==", "dependencies": { "GraphQL.Client": "6.0.0", "Microsoft.CSharp": "4.7.0", @@ -422,11 +417,11 @@ }, "Speckle.Objects": { "type": "CentralTransitive", - "requested": "[3.0.1-alpha.11, )", - "resolved": "3.0.1-alpha.11", - "contentHash": "YR7sei3OQBAi8R/kIu8bEmg5ELDIJK6l5fhOgdnqA9ZvD/fvmRb+09z8lIUTDsgdAdvYU/A/x9VxH9OGPbp9Kw==", + "requested": "[3.0.1-alpha.14, )", + "resolved": "3.0.1-alpha.14", + "contentHash": "z38LGryMvh7iU1uBW+4uo5DwsB3CwRgLt2uFexWFx3mPSid+A0l5XcJzOgLwgFhNl6B42Ryz4ezBsddTp1Uc/g==", "dependencies": { - "Speckle.Core": "3.0.1-alpha.11" + "Speckle.Core": "3.0.1-alpha.14" } } } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/packages.lock.json b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/packages.lock.json index 57b03cf40e..98fcfe0158 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/packages.lock.json +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/packages.lock.json @@ -364,7 +364,7 @@ "type": "Project", "dependencies": { "Speckle.Autofac": "[2.0.999-local, )", - "Speckle.Objects": "[3.0.1-alpha.11, )" + "Speckle.Objects": "[3.0.1-alpha.14, )" } }, "Microsoft.Extensions.Logging.Abstractions": { @@ -379,9 +379,9 @@ }, "Speckle.Core": { "type": "CentralTransitive", - "requested": "[3.0.1-alpha.11, )", - "resolved": "3.0.1-alpha.11", - "contentHash": "Zt2dBJLlfziEACYCHThbhKypSjhoA01rTw9BzNI72c/BDyftXIz70Tetq/8ZMEqQnKqfmRyYADsAdWKxpdV0Hg==", + "requested": "[3.0.1-alpha.14, )", + "resolved": "3.0.1-alpha.14", + "contentHash": "RzQPVIGFFkKvG56YLr8ACtiwdWJE6IJ9vCQ4qHa0PIsUEpfzAIAi59jnzqtByOFC0FiFrFPow9bkfzylaZorAA==", "dependencies": { "GraphQL.Client": "6.0.0", "Microsoft.CSharp": "4.7.0", @@ -403,11 +403,11 @@ }, "Speckle.Objects": { "type": "CentralTransitive", - "requested": "[3.0.1-alpha.11, )", - "resolved": "3.0.1-alpha.11", - "contentHash": "YR7sei3OQBAi8R/kIu8bEmg5ELDIJK6l5fhOgdnqA9ZvD/fvmRb+09z8lIUTDsgdAdvYU/A/x9VxH9OGPbp9Kw==", + "requested": "[3.0.1-alpha.14, )", + "resolved": "3.0.1-alpha.14", + "contentHash": "z38LGryMvh7iU1uBW+4uo5DwsB3CwRgLt2uFexWFx3mPSid+A0l5XcJzOgLwgFhNl6B42Ryz4ezBsddTp1Uc/g==", "dependencies": { - "Speckle.Core": "3.0.1-alpha.11" + "Speckle.Core": "3.0.1-alpha.14" } } } diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI.WebView/packages.lock.json b/DUI3-DX/DUI3/Speckle.Connectors.DUI.WebView/packages.lock.json index 9529e2c9c7..ff084cdbee 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI.WebView/packages.lock.json +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI.WebView/packages.lock.json @@ -426,7 +426,7 @@ "Microsoft.Extensions.Logging.Abstractions": "[7.0.0, )", "Speckle.Autofac": "[2.0.999-local, )", "Speckle.Connectors.Utils": "[2.0.999-local, )", - "Speckle.Core": "[3.0.1-alpha.11, )", + "Speckle.Core": "[3.0.1-alpha.14, )", "System.Threading.Tasks.Dataflow": "[6.0.0, )" } }, @@ -435,7 +435,7 @@ "dependencies": { "Serilog.Extensions.Logging": "[7.0.0, )", "Speckle.Autofac": "[2.0.999-local, )", - "Speckle.Core": "[3.0.1-alpha.11, )" + "Speckle.Core": "[3.0.1-alpha.14, )" } }, "Microsoft.Extensions.Logging.Abstractions": { @@ -460,9 +460,9 @@ }, "Speckle.Core": { "type": "CentralTransitive", - "requested": "[3.0.1-alpha.11, )", - "resolved": "3.0.1-alpha.11", - "contentHash": "Zt2dBJLlfziEACYCHThbhKypSjhoA01rTw9BzNI72c/BDyftXIz70Tetq/8ZMEqQnKqfmRyYADsAdWKxpdV0Hg==", + "requested": "[3.0.1-alpha.14, )", + "resolved": "3.0.1-alpha.14", + "contentHash": "RzQPVIGFFkKvG56YLr8ACtiwdWJE6IJ9vCQ4qHa0PIsUEpfzAIAi59jnzqtByOFC0FiFrFPow9bkfzylaZorAA==", "dependencies": { "GraphQL.Client": "6.0.0", "Microsoft.CSharp": "4.7.0", @@ -865,7 +865,7 @@ "Microsoft.Extensions.Logging.Abstractions": "[7.0.0, )", "Speckle.Autofac": "[2.0.999-local, )", "Speckle.Connectors.Utils": "[2.0.999-local, )", - "Speckle.Core": "[3.0.1-alpha.11, )", + "Speckle.Core": "[3.0.1-alpha.14, )", "System.Threading.Tasks.Dataflow": "[6.0.0, )" } }, @@ -874,7 +874,7 @@ "dependencies": { "Serilog.Extensions.Logging": "[7.0.0, )", "Speckle.Autofac": "[2.0.999-local, )", - "Speckle.Core": "[3.0.1-alpha.11, )" + "Speckle.Core": "[3.0.1-alpha.14, )" } }, "Microsoft.Extensions.Logging.Abstractions": { @@ -895,9 +895,9 @@ }, "Speckle.Core": { "type": "CentralTransitive", - "requested": "[3.0.1-alpha.11, )", - "resolved": "3.0.1-alpha.11", - "contentHash": "Zt2dBJLlfziEACYCHThbhKypSjhoA01rTw9BzNI72c/BDyftXIz70Tetq/8ZMEqQnKqfmRyYADsAdWKxpdV0Hg==", + "requested": "[3.0.1-alpha.14, )", + "resolved": "3.0.1-alpha.14", + "contentHash": "RzQPVIGFFkKvG56YLr8ACtiwdWJE6IJ9vCQ4qHa0PIsUEpfzAIAi59jnzqtByOFC0FiFrFPow9bkfzylaZorAA==", "dependencies": { "GraphQL.Client": "6.0.0", "Microsoft.CSharp": "4.7.0", diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/packages.lock.json b/DUI3-DX/DUI3/Speckle.Connectors.DUI/packages.lock.json index d1e30f591b..9f44602e71 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/packages.lock.json +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/packages.lock.json @@ -39,9 +39,9 @@ }, "Speckle.Core": { "type": "Direct", - "requested": "[3.0.1-alpha.11, )", - "resolved": "3.0.1-alpha.11", - "contentHash": "Zt2dBJLlfziEACYCHThbhKypSjhoA01rTw9BzNI72c/BDyftXIz70Tetq/8ZMEqQnKqfmRyYADsAdWKxpdV0Hg==", + "requested": "[3.0.1-alpha.14, )", + "resolved": "3.0.1-alpha.14", + "contentHash": "RzQPVIGFFkKvG56YLr8ACtiwdWJE6IJ9vCQ4qHa0PIsUEpfzAIAi59jnzqtByOFC0FiFrFPow9bkfzylaZorAA==", "dependencies": { "GraphQL.Client": "6.0.0", "Microsoft.CSharp": "4.7.0", @@ -538,7 +538,7 @@ "dependencies": { "Serilog.Extensions.Logging": "[7.0.0, )", "Speckle.Autofac": "[2.0.999-local, )", - "Speckle.Core": "[3.0.1-alpha.11, )" + "Speckle.Core": "[3.0.1-alpha.14, )" } }, "Serilog.Extensions.Logging": { diff --git a/DUI3-DX/Directory.Packages.props b/DUI3-DX/Directory.Packages.props index ece50df9a0..f8e92452ff 100644 --- a/DUI3-DX/Directory.Packages.props +++ b/DUI3-DX/Directory.Packages.props @@ -16,8 +16,8 @@ - - + + diff --git a/DUI3-DX/Sdk/Speckle.Connectors.Utils/Instances/IInstanceObjectsManager.cs b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Instances/IInstanceObjectsManager.cs new file mode 100644 index 0000000000..532e42ed0e --- /dev/null +++ b/DUI3-DX/Sdk/Speckle.Connectors.Utils/Instances/IInstanceObjectsManager.cs @@ -0,0 +1,53 @@ +using Speckle.Connectors.Utils.Conversion; +using Speckle.Core.Models.Instances; + +namespace Speckle.Connectors.Utils.Instances; + +/// +/// A utility class that helps manage host application blocks in send/receive operations. This expects to be a scoped dependendency per send/receive operation. +/// POC: could be split into two - instance unpacker and instance baker. +/// +/// Host application object type, e.g. RhinoObject +/// The type of the applicationIdMap values. +public interface IInstanceObjectsManager +{ + /// + /// Given a list of host application objects, it will unpack them into atomic objects, instance proxies and instance proxy definitions. + /// + /// Raw selection from the host application. + UnpackResult UnpackSelection(IEnumerable objects); + + /// + /// Will bake a set of instance components (instances and instance definitions) in the host app. + /// + /// + /// + /// + /// + /// + BakeResult BakeInstances( + List<(string[] layerPath, IInstanceComponent obj)> instanceComponents, + Dictionary applicationIdMap, + string baseLayerName, + Action? onOperationProgressed + ); + + /// + /// Cleans up previously baked instances and associated definitions containing the `namePrefix` in their name. + /// Note: this is based on the convention that all defintions have their name set to a model based prefix. + /// + /// The name prefix to search and delete by. + void PurgeInstances(string namePrefix); +} + +public record UnpackResult( + List AtomicObjects, + Dictionary InstanceProxies, + List InstanceDefinitionProxies +); + +public record BakeResult( + List CreatedInstanceIds, + List ConsumedObjectIds, + List InstanceConversionResults +); diff --git a/DUI3-DX/Sdk/Speckle.Connectors.Utils/packages.lock.json b/DUI3-DX/Sdk/Speckle.Connectors.Utils/packages.lock.json index 2b72b82db0..990763d412 100644 --- a/DUI3-DX/Sdk/Speckle.Connectors.Utils/packages.lock.json +++ b/DUI3-DX/Sdk/Speckle.Connectors.Utils/packages.lock.json @@ -48,9 +48,9 @@ }, "Speckle.Core": { "type": "Direct", - "requested": "[3.0.1-alpha.11, )", - "resolved": "3.0.1-alpha.11", - "contentHash": "Zt2dBJLlfziEACYCHThbhKypSjhoA01rTw9BzNI72c/BDyftXIz70Tetq/8ZMEqQnKqfmRyYADsAdWKxpdV0Hg==", + "requested": "[3.0.1-alpha.14, )", + "resolved": "3.0.1-alpha.14", + "contentHash": "RzQPVIGFFkKvG56YLr8ACtiwdWJE6IJ9vCQ4qHa0PIsUEpfzAIAi59jnzqtByOFC0FiFrFPow9bkfzylaZorAA==", "dependencies": { "GraphQL.Client": "6.0.0", "Microsoft.CSharp": "4.7.0", diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/packages.lock.json b/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/packages.lock.json index 19523196d8..cb39bea478 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/packages.lock.json +++ b/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/packages.lock.json @@ -464,7 +464,7 @@ "type": "Project", "dependencies": { "Speckle.Autofac": "[2.0.999-local, )", - "Speckle.Objects": "[3.0.1-alpha.11, )" + "Speckle.Objects": "[3.0.1-alpha.14, )" } }, "Microsoft.Extensions.Logging.Abstractions": { @@ -479,9 +479,9 @@ }, "Speckle.Core": { "type": "CentralTransitive", - "requested": "[3.0.1-alpha.11, )", - "resolved": "3.0.1-alpha.11", - "contentHash": "Zt2dBJLlfziEACYCHThbhKypSjhoA01rTw9BzNI72c/BDyftXIz70Tetq/8ZMEqQnKqfmRyYADsAdWKxpdV0Hg==", + "requested": "[3.0.1-alpha.14, )", + "resolved": "3.0.1-alpha.14", + "contentHash": "RzQPVIGFFkKvG56YLr8ACtiwdWJE6IJ9vCQ4qHa0PIsUEpfzAIAi59jnzqtByOFC0FiFrFPow9bkfzylaZorAA==", "dependencies": { "GraphQL.Client": "6.0.0", "Microsoft.CSharp": "4.7.0", @@ -503,11 +503,11 @@ }, "Speckle.Objects": { "type": "CentralTransitive", - "requested": "[3.0.1-alpha.11, )", - "resolved": "3.0.1-alpha.11", - "contentHash": "YR7sei3OQBAi8R/kIu8bEmg5ELDIJK6l5fhOgdnqA9ZvD/fvmRb+09z8lIUTDsgdAdvYU/A/x9VxH9OGPbp9Kw==", + "requested": "[3.0.1-alpha.14, )", + "resolved": "3.0.1-alpha.14", + "contentHash": "z38LGryMvh7iU1uBW+4uo5DwsB3CwRgLt2uFexWFx3mPSid+A0l5XcJzOgLwgFhNl6B42Ryz4ezBsddTp1Uc/g==", "dependencies": { - "Speckle.Core": "3.0.1-alpha.11" + "Speckle.Core": "3.0.1-alpha.14" } } } diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common/packages.lock.json b/DUI3-DX/Sdk/Speckle.Converters.Common/packages.lock.json index 0bd34a6305..23035de679 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common/packages.lock.json +++ b/DUI3-DX/Sdk/Speckle.Converters.Common/packages.lock.json @@ -35,11 +35,11 @@ }, "Speckle.Objects": { "type": "Direct", - "requested": "[3.0.1-alpha.11, )", - "resolved": "3.0.1-alpha.11", - "contentHash": "YR7sei3OQBAi8R/kIu8bEmg5ELDIJK6l5fhOgdnqA9ZvD/fvmRb+09z8lIUTDsgdAdvYU/A/x9VxH9OGPbp9Kw==", + "requested": "[3.0.1-alpha.14, )", + "resolved": "3.0.1-alpha.14", + "contentHash": "z38LGryMvh7iU1uBW+4uo5DwsB3CwRgLt2uFexWFx3mPSid+A0l5XcJzOgLwgFhNl6B42Ryz4ezBsddTp1Uc/g==", "dependencies": { - "Speckle.Core": "3.0.1-alpha.11" + "Speckle.Core": "3.0.1-alpha.14" } }, "GraphQL.Client": { @@ -472,9 +472,9 @@ }, "Speckle.Core": { "type": "CentralTransitive", - "requested": "[3.0.1-alpha.11, )", - "resolved": "3.0.1-alpha.11", - "contentHash": "Zt2dBJLlfziEACYCHThbhKypSjhoA01rTw9BzNI72c/BDyftXIz70Tetq/8ZMEqQnKqfmRyYADsAdWKxpdV0Hg==", + "requested": "[3.0.1-alpha.14, )", + "resolved": "3.0.1-alpha.14", + "contentHash": "RzQPVIGFFkKvG56YLr8ACtiwdWJE6IJ9vCQ4qHa0PIsUEpfzAIAi59jnzqtByOFC0FiFrFPow9bkfzylaZorAA==", "dependencies": { "GraphQL.Client": "6.0.0", "Microsoft.CSharp": "4.7.0", From cbe19c76d4c27a752ece17b56f788f03c9df9486 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?O=C4=9Fuzhan=20Koral?= <45078678+oguzhankoral@users.noreply.github.com> Date: Fri, 28 Jun 2024 18:00:44 +0300 Subject: [PATCH 251/261] DUI3-448 both model card types need 2 clicks to actually cancel 1 to stop operation and 1 to refresh progress bar (#3538) * Do not send any progress update if cancelled * Use cts instead ct --------- Co-authored-by: KatKatKateryna --- .../Bindings/ArcGISReceiveBinding.cs | 8 ++------ .../Bindings/ArcGISSendBinding.cs | 8 ++------ .../Bindings/AutocadReceiveBinding.cs | 8 ++------ .../Bindings/AutocadSendBinding.cs | 8 ++------ .../Bindings/RevitSendBinding.cs | 8 ++------ .../Bindings/RhinoReceiveBinding.cs | 8 ++------ .../Bindings/RhinoSendBinding.cs | 8 ++------ .../Bindings/IBasicConnectorBinding.cs | 12 ++++++++++-- 8 files changed, 24 insertions(+), 44 deletions(-) diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISReceiveBinding.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISReceiveBinding.cs index fcccc93f25..489e7296bd 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISReceiveBinding.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISReceiveBinding.cs @@ -58,7 +58,8 @@ public async Task Receive(string modelCardId) modelCard.ModelName.NotNull(), modelCard.SelectedVersionId.NotNull(), cts.Token, - (status, progress) => OnSendOperationProgress(modelCardId, status, progress) + (status, progress) => + Commands.SetModelProgress(modelCardId, new ModelCardProgress(modelCardId, status, progress), cts) ) .ConfigureAwait(false); @@ -77,10 +78,5 @@ public async Task Receive(string modelCardId) } } - private void OnSendOperationProgress(string modelCardId, string status, double? progress) - { - Commands.SetModelProgress(modelCardId, new ModelCardProgress(modelCardId, status, progress)); - } - public void CancelReceive(string modelCardId) => _cancellationManager.CancelOperation(modelCardId); } diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISSendBinding.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISSendBinding.cs index 4c0215694b..9ef113e74d 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISSendBinding.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/ArcGISSendBinding.cs @@ -350,7 +350,8 @@ public async Task Send(string modelCardId) .Execute( mapMembers, sendInfo, - (status, progress) => OnSendOperationProgress(modelCardId, status, progress), + (status, progress) => + Commands.SetModelProgress(modelCardId, new ModelCardProgress(modelCardId, status, progress), cts), cts.Token ) .ConfigureAwait(false); @@ -407,9 +408,4 @@ private void RunExpirationChecks(bool idsDeleted) Commands.SetModelsExpired(expiredSenderIds); ChangedObjectIds = new HashSet(); } - - private void OnSendOperationProgress(string modelCardId, string status, double? progress) - { - Commands.SetModelProgress(modelCardId, new ModelCardProgress(modelCardId, status, progress)); - } } diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadReceiveBinding.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadReceiveBinding.cs index 2faf89f7ad..b1973d331d 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadReceiveBinding.cs +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadReceiveBinding.cs @@ -65,7 +65,8 @@ public async Task Receive(string modelCardId) modelCard.ModelName.NotNull(), modelCard.SelectedVersionId.NotNull(), cts.Token, - onOperationProgressed: (status, progress) => OnSendOperationProgress(modelCardId, status, progress) + (status, progress) => + Commands.SetModelProgress(modelCardId, new ModelCardProgress(modelCardId, status, progress), cts) ) .ConfigureAwait(false); @@ -83,9 +84,4 @@ public async Task Receive(string modelCardId) Application.DocumentManager.DocumentActivationEnabled = true; } } - - private void OnSendOperationProgress(string modelCardId, string status, double? progress) - { - Commands.SetModelProgress(modelCardId, new ModelCardProgress(modelCardId, status, progress)); - } } diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadSendBinding.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadSendBinding.cs index 32cc40fbe7..820fb90097 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadSendBinding.cs +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadSendBinding.cs @@ -167,7 +167,8 @@ private async Task SendInternal(string modelCardId) .Execute( autocadObjects, sendInfo, - (status, progress) => OnSendOperationProgress(modelCardId, status, progress), + (status, progress) => + Commands.SetModelProgress(modelCardId, new ModelCardProgress(modelCardId, status, progress), cts), cts.Token ) .ConfigureAwait(false); @@ -191,10 +192,5 @@ private async Task SendInternal(string modelCardId) } } - private void OnSendOperationProgress(string modelCardId, string status, double? progress) - { - Commands.SetModelProgress(modelCardId, new ModelCardProgress(modelCardId, status, progress)); - } - public void CancelSend(string modelCardId) => _cancellationManager.CancelOperation(modelCardId); } diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/RevitSendBinding.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/RevitSendBinding.cs index 99e6492b79..ee437aeea2 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/RevitSendBinding.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/RevitSendBinding.cs @@ -112,7 +112,8 @@ public async Task Send(string modelCardId) .Execute( revitObjects, sendInfo, - (status, progress) => OnSendOperationProgress(modelCardId, status, progress), + (status, progress) => + Commands.SetModelProgress(modelCardId, new ModelCardProgress(modelCardId, status, progress), cts), cts.Token ) .ConfigureAwait(false); @@ -130,11 +131,6 @@ public async Task Send(string modelCardId) } } - private void OnSendOperationProgress(string modelCardId, string status, double? progress) - { - Commands.SetModelProgress(modelCardId, new ModelCardProgress(modelCardId, status, progress)); - } - /// /// Keeps track of the changed element ids as well as checks if any of them need to trigger /// a filter refresh (e.g., views being added). diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoReceiveBinding.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoReceiveBinding.cs index 951ff40f6f..6c78f254df 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoReceiveBinding.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoReceiveBinding.cs @@ -60,7 +60,8 @@ public async Task Receive(string modelCardId) modelCard.ModelName.NotNull(), modelCard.SelectedVersionId.NotNull(), cts.Token, - (status, progress) => OnSendOperationProgress(modelCardId, status, progress) + (status, progress) => + Commands.SetModelProgress(modelCardId, new ModelCardProgress(modelCardId, status, progress), cts) ) .ConfigureAwait(false); @@ -79,10 +80,5 @@ public async Task Receive(string modelCardId) } } - private void OnSendOperationProgress(string modelCardId, string status, double? progress) - { - Commands.SetModelProgress(modelCardId, new ModelCardProgress(modelCardId, status, progress)); - } - public void CancelSend(string modelCardId) => _cancellationManager.CancelOperation(modelCardId); } diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSendBinding.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSendBinding.cs index 7e4e6be8a3..9005692407 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSendBinding.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSendBinding.cs @@ -174,7 +174,8 @@ public async Task Send(string modelCardId) .Execute( rhinoObjects, sendInfo, - (status, progress) => OnSendOperationProgress(modelCardId, status, progress), + (status, progress) => + Commands.SetModelProgress(modelCardId, new ModelCardProgress(modelCardId, status, progress), cts), cts.Token ) .ConfigureAwait(false); @@ -193,11 +194,6 @@ public async Task Send(string modelCardId) } } - private void OnSendOperationProgress(string modelCardId, string status, double? progress) - { - Commands.SetModelProgress(modelCardId, new ModelCardProgress(modelCardId, status, progress)); - } - public void CancelSend(string modelCardId) => _cancellationManager.CancelOperation(modelCardId); /// diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/IBasicConnectorBinding.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/IBasicConnectorBinding.cs index 7b38ee9fbd..c88da91a81 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/IBasicConnectorBinding.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/IBasicConnectorBinding.cs @@ -75,8 +75,16 @@ public void SetGlobalNotification(ToastNotificationType type, string title, stri } ); - public void SetModelProgress(string modelCardId, ModelCardProgress progress) => - Bridge.Send(SET_MODEL_PROGRESS_UI_COMMAND_NAME, new { modelCardId, progress }); + public void SetModelProgress(string modelCardId, ModelCardProgress progress, CancellationTokenSource cts) + { + // NOTE: To prevent potential race condition + // After cancelling operation some parts could still send last progress update which was set progress on UI + // after it forced to be undefined. This is the safest way to prevent any case like this. + if (!cts.IsCancellationRequested) + { + Bridge.Send(SET_MODEL_PROGRESS_UI_COMMAND_NAME, new { modelCardId, progress }); + } + } public void SetModelError(string modelCardId, Exception error) => Bridge.Send(SET_MODEL_ERROR_UI_COMMAND_NAME, new { modelCardId, error = error.Message }); From 7d10c7fc89414290a7d5e36780d024f5b7ec1d82 Mon Sep 17 00:00:00 2001 From: KatKatKateryna <89912278+KatKatKateryna@users.noreply.github.com> Date: Mon, 1 Jul 2024 18:44:48 +0800 Subject: [PATCH 252/261] DUI3-305 agis implement highlight for individual features e.g. from receive report (#3529) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * introduce ObjectID constructor * adapt BasicBindings highlight to use ObjectId struct * select individual features * update missing tracker Items * query features by ID for selection * separate struct for MapMembers * add comments * formatting * formatting --------- Co-authored-by: Oğuzhan Koral <45078678+oguzhankoral@users.noreply.github.com> --- .../Bindings/BasicConnectorBinding.cs | 64 ++++++++++++------- .../Operations/Receive/HostObjectBuilder.cs | 62 ++++++++++++++---- .../Utils/MapMemberFeature.cs | 16 +++++ .../Utils/ObjectID.cs | 38 +++++++++++ 4 files changed, 143 insertions(+), 37 deletions(-) create mode 100644 DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Utils/MapMemberFeature.cs create mode 100644 DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Utils/ObjectID.cs diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/BasicConnectorBinding.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/BasicConnectorBinding.cs index 649691a526..961ceb1576 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/BasicConnectorBinding.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Bindings/BasicConnectorBinding.cs @@ -1,7 +1,9 @@ using System.Reflection; +using ArcGIS.Core.Data; using ArcGIS.Desktop.Framework.Threading.Tasks; using ArcGIS.Desktop.Mapping; using Speckle.Connectors.ArcGIS.HostApp; +using Speckle.Connectors.ArcGIS.Utils; using Speckle.Connectors.DUI.Bindings; using Speckle.Connectors.DUI.Bridge; using Speckle.Connectors.DUI.Models; @@ -58,7 +60,8 @@ public BasicConnectorBinding(DocumentModelStore store, ArcGISSettings settings, public void RemoveModel(ModelCard model) => _store.RemoveModel(model); - public void HighlightObjects(List objectIds) => HighlightObjectsOnView(objectIds); + public void HighlightObjects(List objectIds) => + HighlightObjectsOnView(objectIds.Select(x => new ObjectID(x)).ToList()); public void HighlightModel(string modelCardId) { @@ -69,16 +72,16 @@ public void HighlightModel(string modelCardId) return; } - var objectIds = new List(); + var objectIds = new List(); if (model is SenderModelCard senderModelCard) { - objectIds = senderModelCard.SendFilter.NotNull().GetObjectIds(); + objectIds = senderModelCard.SendFilter.NotNull().GetObjectIds().Select(x => new ObjectID(x)).ToList(); } if (model is ReceiverModelCard receiverModelCard) { - objectIds = receiverModelCard.BakedObjectIds.NotNull(); + objectIds = receiverModelCard.BakedObjectIds.NotNull().Select(x => new ObjectID(x)).ToList(); } if (objectIds is null) @@ -88,42 +91,42 @@ public void HighlightModel(string modelCardId) HighlightObjectsOnView(objectIds); } - private async void HighlightObjectsOnView(List objectIds) + private async void HighlightObjectsOnView(List objectIds) { MapView mapView = MapView.Active; await QueuedTask .Run(() => { - List mapMembers = GetMapMembers(objectIds, mapView); + List mapMembersFeatures = GetMapMembers(objectIds, mapView); ClearSelectionInTOC(); ClearSelection(); - SelectMapMembersInTOC(mapMembers); - SelectMapMembers(mapMembers); + SelectMapMembersInTOC(mapMembersFeatures); + SelectMapMembersAndFeatures(mapMembersFeatures); mapView.ZoomToSelected(); }) .ConfigureAwait(false); } - private List GetMapMembers(List objectIds, MapView mapView) + private List GetMapMembers(List objectIds, MapView mapView) { - List mapMembers = new(); + // find the layer on the map (from the objectID) and add the featureID is available + List mapMembersFeatures = new(); - foreach (string objectId in objectIds) + foreach (ObjectID objectId in objectIds) { - MapMember mapMember = mapView.Map.FindLayer(objectId); + MapMember mapMember = mapView.Map.FindLayer(objectId.MappedLayerURI, true); if (mapMember is null) { - mapMember = mapView.Map.FindStandaloneTable(objectId); + mapMember = mapView.Map.FindStandaloneTable(objectId.MappedLayerURI); } - if (mapMember is null) + if (mapMember is not null) { - continue; + MapMemberFeature mapMembersFeat = new(mapMember, objectId.FeatureId); + mapMembersFeatures.Add(mapMembersFeat); } - mapMembers.Add(mapMember); } - - return mapMembers; + return mapMembersFeatures; } private void ClearSelection() @@ -143,24 +146,39 @@ private void ClearSelectionInTOC() MapView.Active.ClearTOCSelection(); } - private void SelectMapMembers(List mapMembers) + private void SelectMapMembersAndFeatures(List mapMembersFeatures) { - foreach (var member in mapMembers) + foreach (MapMemberFeature mapMemberFeat in mapMembersFeatures) { + MapMember member = mapMemberFeat.MapMember; if (member is FeatureLayer layer) { - layer.Select(); + if (mapMemberFeat.FeatureId == null) + { + // select full layer if featureID not specified + layer.Select(); + } + else + { + // query features by ID + var objectIDfield = layer.GetFeatureClass().GetDefinition().GetObjectIDField(); + + // FeatureID range starts from 0, but auto-assigned IDs in the layer start from 1 + QueryFilter anotherQueryFilter = new() { WhereClause = $"{objectIDfield} = {mapMemberFeat.FeatureId + 1}" }; + using (Selection onlyOneSelection = layer.Select(anotherQueryFilter, SelectionCombinationMethod.New)) { } + } } } } - private void SelectMapMembersInTOC(List mapMembers) + private void SelectMapMembersInTOC(List mapMembersFeatures) { List layers = new(); List tables = new(); - foreach (MapMember member in mapMembers) + foreach (MapMemberFeature mapMemberFeat in mapMembersFeatures) { + MapMember member = mapMemberFeat.MapMember; if (member is Layer layer) { if (member is not GroupLayer) // group layer selection clears other layers selection diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Receive/HostObjectBuilder.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Receive/HostObjectBuilder.cs index 3e22f2d85d..953a6b2abb 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Receive/HostObjectBuilder.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Receive/HostObjectBuilder.cs @@ -11,6 +11,7 @@ using Speckle.Core.Models.GraphTraversal; using Speckle.Converters.ArcGIS3; using RasterLayer = Objects.GIS.RasterLayer; +using Speckle.Connectors.ArcGIS.Utils; namespace Speckle.Connectors.ArcGIS.Operations.Receive; @@ -116,21 +117,33 @@ CancellationToken cancellationToken else if (trackerItem.DatasetId == null) { results.Add( - new(Status.ERROR, trackerItem.Base, null, null, new ArgumentException("Unknown error: Dataset not created")) + new( + Status.ERROR, + trackerItem.Base, + null, + null, + new ArgumentException($"Unknown error: Dataset not created for {trackerItem.Base.speckle_type}") + ) ); } else if (bakedMapMembers.TryGetValue(trackerItem.DatasetId, out MapMember? value)) { + // add layer and layer URI to tracker + trackerItem.AddConvertedMapMember(value); + trackerItem.AddLayerURI(value.URI); + conversionTracker[item.Key] = trackerItem; // not necessary atm, but needed if we use conversionTracker further // only add a report item AddResultsFromTracker(trackerItem, results); } else { - // add layer and layer URI to tracker + // add layer to Map MapMember mapMember = AddDatasetsToMap(trackerItem, createdLayerGroups); + + // add layer and layer URI to tracker trackerItem.AddConvertedMapMember(mapMember); trackerItem.AddLayerURI(mapMember.URI); - conversionTracker[item.Key] = trackerItem; + conversionTracker[item.Key] = trackerItem; // not necessary atm, but needed if we use conversionTracker further // add layer URI to bakedIds bakedObjectIds.Add(trackerItem.MappedLayerURI == null ? "" : trackerItem.MappedLayerURI); @@ -151,24 +164,45 @@ CancellationToken cancellationToken private void AddResultsFromTracker(ObjectConversionTracker trackerItem, List results) { - // prioritize individual hostAppGeometry type, if available: - if (trackerItem.HostAppGeom != null) - { - results.Add( - new(Status.SUCCESS, trackerItem.Base, trackerItem.MappedLayerURI, trackerItem.HostAppGeom.GetType().ToString()) - ); - } - else + if (trackerItem.MappedLayerURI == null) // should not happen { results.Add( new( - Status.SUCCESS, + Status.ERROR, trackerItem.Base, - trackerItem.MappedLayerURI, - trackerItem.HostAppMapMember?.GetType().ToString() + null, + null, + new ArgumentException($"Created Layer URI not found for {trackerItem.Base.speckle_type}") ) ); } + else + { + // encode layer ID and ID of its feature in 1 object represented as string + ObjectID objectId = new(trackerItem.MappedLayerURI, trackerItem.DatasetRow); + if (trackerItem.HostAppGeom != null) // individual hostAppGeometry + { + results.Add( + new( + Status.SUCCESS, + trackerItem.Base, + objectId.ObjectIdToString(), + trackerItem.HostAppGeom.GetType().ToString() + ) + ); + } + else // hostApp Layers + { + results.Add( + new( + Status.SUCCESS, + trackerItem.Base, + objectId.ObjectIdToString(), + trackerItem.HostAppMapMember?.GetType().ToString() + ) + ); + } + } } private MapMember AddDatasetsToMap( diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Utils/MapMemberFeature.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Utils/MapMemberFeature.cs new file mode 100644 index 0000000000..026e5165dc --- /dev/null +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Utils/MapMemberFeature.cs @@ -0,0 +1,16 @@ +using ArcGIS.Desktop.Mapping; + +namespace Speckle.Connectors.ArcGIS.Utils; + +// bind together a layer object on the map, and auto-assigned ID if the specific feature +public readonly struct MapMemberFeature +{ + public int? FeatureId { get; } // unique feature id (start from 0) of a feature in the layer + public MapMember MapMember { get; } // layer object on the Map + + public MapMemberFeature(MapMember mapMember, int? featureId) + { + MapMember = mapMember; + FeatureId = featureId; + } +} diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Utils/ObjectID.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Utils/ObjectID.cs new file mode 100644 index 0000000000..8374181c5b --- /dev/null +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Utils/ObjectID.cs @@ -0,0 +1,38 @@ +namespace Speckle.Connectors.ArcGIS.Utils; + +// this struct is needed to be able to parse single-string value into IDs of both a layer, and it's individual feature +public struct ObjectID +{ + private const string FEATURE_ID_SEPARATOR = "__speckleFeatureId__"; + public string MappedLayerURI { get; } // unique ID of the layer on the map + public int? FeatureId { get; } // unique feature id (start from 0) of a feature in the layer + + public ObjectID(string encodedId) + { + List stringParts = encodedId.Split(FEATURE_ID_SEPARATOR).ToList(); + MappedLayerURI = stringParts[0]; + FeatureId = null; + if (stringParts.Count > 1) + { + FeatureId = Convert.ToInt32(stringParts[1]); + } + } + + public ObjectID(string layerId, int? featureId) + { + MappedLayerURI = layerId; + FeatureId = featureId; + } + + public readonly string ObjectIdToString() + { + if (FeatureId == null) + { + return $"{MappedLayerURI}"; + } + else + { + return $"{MappedLayerURI}{FEATURE_ID_SEPARATOR}{FeatureId}"; + } + } +} From 763037ccc230449a0a815c8b73ee7d0fbb2d43b4 Mon Sep 17 00:00:00 2001 From: Adam Hathcock Date: Mon, 1 Jul 2024 12:48:31 +0100 Subject: [PATCH 253/261] Host app non-central managed (#3543) * Add Autocad versions like file system * remove override * Move all host apps to not be centrally managed * Use VersionOverride --- All.sln | 4 ++-- DUI3-DX/Connectors/Autocad/Directory.Packages.props | 6 ------ .../Speckle.Connectors.Autocad2023.csproj | 3 +-- .../Speckle.Connectors.Rhino7.csproj | 4 ++-- DUI3-DX/Converters/Autocad/2023/Directory.Packages.props | 6 ------ .../Speckle.Converters.Autocad2023.csproj | 2 +- DUI3-DX/Converters/Autocad/2024/Directory.Packages.props | 6 ------ .../packages.lock.json | 2 +- .../Speckle.Converters.Autocad2024.csproj | 2 +- .../Speckle.Converters.Revit2023.csproj | 2 +- .../Speckle.Converters.Rhino7.DependencyInjection.csproj | 2 +- .../Speckle.Converters.Rhino7.csproj | 2 +- DUI3-DX/Directory.Packages.props | 5 +++-- 13 files changed, 14 insertions(+), 32 deletions(-) delete mode 100644 DUI3-DX/Connectors/Autocad/Directory.Packages.props delete mode 100644 DUI3-DX/Converters/Autocad/2023/Directory.Packages.props delete mode 100644 DUI3-DX/Converters/Autocad/2024/Directory.Packages.props diff --git a/All.sln b/All.sln index 3fffc2325d..5e80640bb0 100644 --- a/All.sln +++ b/All.sln @@ -3044,8 +3044,6 @@ Global {11F7D41B-AFCA-4D29-BC08-285A14BF3A3B} = {2E00592E-558D-492D-88F9-3ECEE4C0C7DA} {804E065F-914C-414A-AF84-009312C3CFF6} = {1FE3C60E-7865-40A5-9794-55ECB64F6489} {9ADD1B7A-6401-4202-8613-F668E2FBC0A4} = {804E065F-914C-414A-AF84-009312C3CFF6} - {631C295A-7CCF-4B42-8686-7034E31469E7} = {804E065F-914C-414A-AF84-009312C3CFF6} - {D940853C-003A-482C-BDB0-665367F274A0} = {804E065F-914C-414A-AF84-009312C3CFF6} {7420652C-3046-4F38-BE64-9B9E69D76FA2} = {FD4D6594-D81E-456F-8F2E-35B09E04A755} {3973D572-5E24-476F-B058-8022D826B793} = {326ECEE0-D009-4A65-B24C-00FA343D8B99} {7B02BACC-D9B6-4FFE-A450-7ECB5F71F209} = {C73C19B5-72A3-4C63-8D56-0A7E7DB46CA5} @@ -3056,6 +3054,8 @@ Global {70DEAA13-6DC8-44A0-B287-9E806A8054F1} = {890F3257-FCC2-4ED8-9180-22B3641B494C} {F06E4C37-4076-4272-9CA6-FB505E02CD31} = {BE521908-7944-46F3-98BF-B47D34509934} {DDBBA313-69A6-40DE-AB3A-79EE5BF32A7E} = {743489BF-1941-43D5-8AF9-35C56D0DCC34} + {631C295A-7CCF-4B42-8686-7034E31469E7} = {804E065F-914C-414A-AF84-009312C3CFF6} + {D940853C-003A-482C-BDB0-665367F274A0} = {804E065F-914C-414A-AF84-009312C3CFF6} {C9C28F31-1367-438C-83B0-049C3B3A3E3B} = {804E065F-914C-414A-AF84-009312C3CFF6} {06082BAA-98E8-49B1-9D33-252B126A0561} = {804E065F-914C-414A-AF84-009312C3CFF6} EndGlobalSection diff --git a/DUI3-DX/Connectors/Autocad/Directory.Packages.props b/DUI3-DX/Connectors/Autocad/Directory.Packages.props deleted file mode 100644 index 568fea5f0f..0000000000 --- a/DUI3-DX/Connectors/Autocad/Directory.Packages.props +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.Autocad2023/Speckle.Connectors.Autocad2023.csproj b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.Autocad2023/Speckle.Connectors.Autocad2023.csproj index b0f4587d7f..e3913f6c11 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.Autocad2023/Speckle.Connectors.Autocad2023.csproj +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.Autocad2023/Speckle.Connectors.Autocad2023.csproj @@ -19,8 +19,7 @@ - - + diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Speckle.Connectors.Rhino7.csproj b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Speckle.Connectors.Rhino7.csproj index dbea907d5c..ef4a884995 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Speckle.Connectors.Rhino7.csproj +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Speckle.Connectors.Rhino7.csproj @@ -13,8 +13,8 @@ - - + + diff --git a/DUI3-DX/Converters/Autocad/2023/Directory.Packages.props b/DUI3-DX/Converters/Autocad/2023/Directory.Packages.props deleted file mode 100644 index 568fea5f0f..0000000000 --- a/DUI3-DX/Converters/Autocad/2023/Directory.Packages.props +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/DUI3-DX/Converters/Autocad/2023/Speckle.Converters.Autocad2023/Speckle.Converters.Autocad2023.csproj b/DUI3-DX/Converters/Autocad/2023/Speckle.Converters.Autocad2023/Speckle.Converters.Autocad2023.csproj index 753a408e8e..2fc9b23da0 100644 --- a/DUI3-DX/Converters/Autocad/2023/Speckle.Converters.Autocad2023/Speckle.Converters.Autocad2023.csproj +++ b/DUI3-DX/Converters/Autocad/2023/Speckle.Converters.Autocad2023/Speckle.Converters.Autocad2023.csproj @@ -6,7 +6,7 @@ - + diff --git a/DUI3-DX/Converters/Autocad/2024/Directory.Packages.props b/DUI3-DX/Converters/Autocad/2024/Directory.Packages.props deleted file mode 100644 index 27e149ab85..0000000000 --- a/DUI3-DX/Converters/Autocad/2024/Directory.Packages.props +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/DUI3-DX/Converters/Autocad/2024/Speckle.Converters.Autocad2024.DependencyInjection/packages.lock.json b/DUI3-DX/Converters/Autocad/2024/Speckle.Converters.Autocad2024.DependencyInjection/packages.lock.json index fe9923d926..bb0e3cfe08 100644 --- a/DUI3-DX/Converters/Autocad/2024/Speckle.Converters.Autocad2024.DependencyInjection/packages.lock.json +++ b/DUI3-DX/Converters/Autocad/2024/Speckle.Converters.Autocad2024.DependencyInjection/packages.lock.json @@ -396,7 +396,7 @@ }, "Speckle.AutoCAD.API": { "type": "CentralTransitive", - "requested": "[2024.0.0, )", + "requested": "[2023.0.0, )", "resolved": "2024.0.0", "contentHash": "pZZ5uI+NXhZaQnsqRkgp/rywqBAjDObDJ9XNFGJvemT5k2OthDpHzlK/mKxz8QDCYie7uImQ8dv3uWj2QUFDPw==" }, diff --git a/DUI3-DX/Converters/Autocad/2024/Speckle.Converters.Autocad2024/Speckle.Converters.Autocad2024.csproj b/DUI3-DX/Converters/Autocad/2024/Speckle.Converters.Autocad2024/Speckle.Converters.Autocad2024.csproj index 8aad1ab7d5..05f9613b37 100644 --- a/DUI3-DX/Converters/Autocad/2024/Speckle.Converters.Autocad2024/Speckle.Converters.Autocad2024.csproj +++ b/DUI3-DX/Converters/Autocad/2024/Speckle.Converters.Autocad2024/Speckle.Converters.Autocad2024.csproj @@ -6,7 +6,7 @@ - + diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023/Speckle.Converters.Revit2023.csproj b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023/Speckle.Converters.Revit2023.csproj index 985086abd5..4b7de6a4df 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023/Speckle.Converters.Revit2023.csproj +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023/Speckle.Converters.Revit2023.csproj @@ -8,7 +8,7 @@ - + diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/Speckle.Converters.Rhino7.DependencyInjection.csproj b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/Speckle.Converters.Rhino7.DependencyInjection.csproj index 78870eeb41..f92549ccd3 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/Speckle.Converters.Rhino7.DependencyInjection.csproj +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/Speckle.Converters.Rhino7.DependencyInjection.csproj @@ -11,6 +11,6 @@ - + diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Speckle.Converters.Rhino7.csproj b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Speckle.Converters.Rhino7.csproj index bf1bdbd6de..19094744c9 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Speckle.Converters.Rhino7.csproj +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Speckle.Converters.Rhino7.csproj @@ -5,7 +5,7 @@ - + diff --git a/DUI3-DX/Directory.Packages.props b/DUI3-DX/Directory.Packages.props index f8e92452ff..217c4a191b 100644 --- a/DUI3-DX/Directory.Packages.props +++ b/DUI3-DX/Directory.Packages.props @@ -14,11 +14,12 @@ - - + + + From b6141ff584832b4a82c7acc9e5263d914454c57a Mon Sep 17 00:00:00 2001 From: KatKatKateryna <89912278+KatKatKateryna@users.noreply.github.com> Date: Tue, 2 Jul 2024 00:32:35 +0800 Subject: [PATCH 254/261] 2-liner-exception-messages-fix (#3535) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Update FeatureClassUtils.cs * show CRS name * exception message --------- Co-authored-by: Oğuzhan Koral <45078678+oguzhankoral@users.noreply.github.com> --- .../Geometry/PointToSpeckleConverter.cs | 2 +- .../Speckle.Converters.ArcGIS3/Utils/FeatureClassUtils.cs | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/PointToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/PointToSpeckleConverter.cs index 198af4e5ee..9b0859318b 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/PointToSpeckleConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/PointToSpeckleConverter.cs @@ -23,7 +23,7 @@ is not MapPoint reprojectedPt ) { throw new SpeckleConversionException( - $"Conversion to Spatial Reference {_contextStack.Current.Document.Map.SpatialReference} failed" + $"Conversion to Spatial Reference {_contextStack.Current.Document.Map.SpatialReference.Name} failed" ); } return new(reprojectedPt.X, reprojectedPt.Y, reprojectedPt.Z, _contextStack.Current.SpeckleUnits); diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/FeatureClassUtils.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/FeatureClassUtils.cs index c80b8473f1..6e3a587b45 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/FeatureClassUtils.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/FeatureClassUtils.cs @@ -122,7 +122,11 @@ public ACG.GeometryType GetLayerGeometryType(VectorLayer target) GISLayerGeometryType.POLYLINE => ACG.GeometryType.Polyline, GISLayerGeometryType.MULTIPATCH => ACG.GeometryType.Multipatch, GISLayerGeometryType.POLYGON3D => ACG.GeometryType.Multipatch, - _ => throw new ArgumentOutOfRangeException(nameof(target)), + _ + => throw new ArgumentOutOfRangeException( + nameof(target), + $"Geometry type '{originalGeomType}' is not recognized." + ), }; } } From a71d37d765f09617fdfc6784271f908ba4c9747f Mon Sep 17 00:00:00 2001 From: KatKatKateryna <89912278+KatKatKateryna@users.noreply.github.com> Date: Tue, 2 Jul 2024 01:39:59 +0800 Subject: [PATCH 255/261] Dui3 124 receiving curves arcs ellipses nurbs curves (#3521) * arcs received (tested with Rhino and AutoCAD commits) * add SpatialRef to every new host geometry * don't receive non-flat arcs, circles, ellipses * more specific exceptions * namespaces and densification for arc-polygon edges * added ICurve converter (not used yet); added check for sequential Polycurve * precision points --- .../PointFeatureToSpeckleConverter.cs | 35 ------- .../ArcToHostConverter.cs | 54 ---------- .../EllipseToHostConverter.cs | 53 ---------- .../PolycurveToHostConverter.cs | 46 --------- .../SegmentCollectionToSpeckleConverter.cs | 65 ------------ .../ToHost/Raw/CurveToHostConverter.cs | 52 ++++++++++ .../Raw}/FeatureClassToHostConverter.cs | 2 +- .../Raw}/GeometryToHostConverter.cs | 2 +- .../Raw}/MeshListToHostConverter.cs | 11 ++- .../Raw}/MultipatchListToHostConverter.cs | 2 +- .../Raw}/PointListToHostConverter.cs | 2 +- .../Raw}/PointSingleToHostConverter.cs | 5 +- .../Raw}/PointcloudLayerToHostConverter.cs | 2 +- .../Raw}/Polygon3dListToHostConverter.cs | 4 +- .../Raw}/PolygonListToHostConverter.cs | 4 +- .../Raw}/PolylineListToHostConverter.cs | 4 +- .../Raw}/TableToHostConverter.cs | 6 +- .../ToHost/TopLevel/ArcToHostConverter.cs | 47 +++++++++ .../TopLevel}/CircleToHostConverter.cs | 19 +++- .../ToHost/TopLevel/EllipseToHostConverter.cs | 70 +++++++++++++ .../TopLevel}/FallbackToHostConverter.cs | 2 +- .../TopLevel}/LineToHostConverter.cs | 15 ++- .../TopLevel}/MeshToHostConverter.cs | 2 +- .../TopLevel}/PointToHostConverter.cs | 2 +- .../TopLevel/PolycurveToHostConverter.cs | 60 ++++++++++++ .../TopLevel}/PolylineToHostConverter.cs | 15 ++- .../TopLevel}/RasterLayerToHostConverter.cs | 2 +- .../TopLevel}/VectorLayerToHostConverter.cs | 2 +- .../Raw}/EnvelopBoxToSpeckleConverter.cs | 6 +- .../Raw}/GeometryToSpeckleBase.cs | 2 +- .../Raw}/GisFeatureToSpeckleConverter.cs | 9 +- .../Raw}/GisRasterToSpeckleConverter.cs | 8 +- .../MultipatchFeatureToSpeckleConverter.cs | 6 +- .../MultipointFeatureToSpeckleConverter.cs | 2 +- .../Raw}/PointToSpeckleConverter.cs | 4 +- .../Raw}/PolygonFeatureToSpeckleConverter.cs | 4 +- .../Raw}/PolylineFeatureToSpeckleConverter.cs | 6 +- .../SegmentCollectionToSpeckleConverter.cs | 98 +++++++++++++++++++ .../PointcloudLayerToSpeckleConverter.cs | 13 ++- .../RasterLayerToSpeckleConverter.cs | 10 +- .../TopLevel}/TableToSpeckleConverter.cs | 10 +- .../VectorLayerToSpeckleConverter.cs | 14 +-- .../{Geometry => Utils}/GeometryExtension.cs | 2 +- 43 files changed, 442 insertions(+), 337 deletions(-) delete mode 100644 DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/PointFeatureToSpeckleConverter.cs delete mode 100644 DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/ArcToHostConverter.cs delete mode 100644 DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/EllipseToHostConverter.cs delete mode 100644 DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/PolycurveToHostConverter.cs delete mode 100644 DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/SegmentCollectionToSpeckleConverter.cs create mode 100644 DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/Raw/CurveToHostConverter.cs rename DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/{Layers => ToHost/Raw}/FeatureClassToHostConverter.cs (99%) rename DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/{Features => ToHost/Raw}/GeometryToHostConverter.cs (98%) rename DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/{Geometry/GisFeatureGeometriesToHost => ToHost/Raw}/MeshListToHostConverter.cs (72%) rename DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/{Geometry/GisFeatureGeometriesToHost => ToHost/Raw}/MultipatchListToHostConverter.cs (93%) rename DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/{Geometry/GisFeatureGeometriesToHost => ToHost/Raw}/PointListToHostConverter.cs (91%) rename DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/{Geometry => ToHost/Raw}/PointSingleToHostConverter.cs (84%) rename DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/{Layers => ToHost/Raw}/PointcloudLayerToHostConverter.cs (90%) rename DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/{Geometry/GisFeatureGeometriesToHost => ToHost/Raw}/Polygon3dListToHostConverter.cs (95%) rename DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/{Geometry/GisFeatureGeometriesToHost => ToHost/Raw}/PolygonListToHostConverter.cs (94%) rename DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/{Geometry/GisFeatureGeometriesToHost => ToHost/Raw}/PolylineListToHostConverter.cs (92%) rename DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/{Layers => ToHost/Raw}/TableToHostConverter.cs (98%) create mode 100644 DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/TopLevel/ArcToHostConverter.cs rename DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/{Geometry/ISpeckleObjectToHost => ToHost/TopLevel}/CircleToHostConverter.cs (72%) create mode 100644 DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/TopLevel/EllipseToHostConverter.cs rename DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/{Geometry => ToHost/TopLevel}/FallbackToHostConverter.cs (96%) rename DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/{Geometry/ISpeckleObjectToHost => ToHost/TopLevel}/LineToHostConverter.cs (58%) rename DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/{Geometry/ISpeckleObjectToHost => ToHost/TopLevel}/MeshToHostConverter.cs (91%) rename DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/{Geometry/ISpeckleObjectToHost => ToHost/TopLevel}/PointToHostConverter.cs (89%) create mode 100644 DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/TopLevel/PolycurveToHostConverter.cs rename DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/{Geometry/ISpeckleObjectToHost => ToHost/TopLevel}/PolylineToHostConverter.cs (61%) rename DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/{Layers => ToHost/TopLevel}/RasterLayerToHostConverter.cs (90%) rename DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/{Layers => ToHost/TopLevel}/VectorLayerToHostConverter.cs (97%) rename DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/{Geometry => ToSpeckle/Raw}/EnvelopBoxToSpeckleConverter.cs (96%) rename DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/{Features => ToSpeckle/Raw}/GeometryToSpeckleBase.cs (97%) rename DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/{Features => ToSpeckle/Raw}/GisFeatureToSpeckleConverter.cs (97%) rename DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/{Features => ToSpeckle/Raw}/GisRasterToSpeckleConverter.cs (99%) rename DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/{Features => ToSpeckle/Raw}/MultipatchFeatureToSpeckleConverter.cs (98%) rename DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/{Features => ToSpeckle/Raw}/MultipointFeatureToSpeckleConverter.cs (92%) rename DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/{Geometry => ToSpeckle/Raw}/PointToSpeckleConverter.cs (95%) rename DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/{Features => ToSpeckle/Raw}/PolygonFeatureToSpeckleConverter.cs (96%) rename DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/{Features => ToSpeckle/Raw}/PolylineFeatureToSpeckleConverter.cs (91%) create mode 100644 DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToSpeckle/Raw/SegmentCollectionToSpeckleConverter.cs rename DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/{Layers => ToSpeckle/TopLevel}/PointcloudLayerToSpeckleConverter.cs (97%) rename DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/{Layers => ToSpeckle/TopLevel}/RasterLayerToSpeckleConverter.cs (97%) rename DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/{Layers => ToSpeckle/TopLevel}/TableToSpeckleConverter.cs (97%) rename DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/{Layers => ToSpeckle/TopLevel}/VectorLayerToSpeckleConverter.cs (98%) rename DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/{Geometry => Utils}/GeometryExtension.cs (99%) diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/PointFeatureToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/PointFeatureToSpeckleConverter.cs deleted file mode 100644 index 7b53a664de..0000000000 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/PointFeatureToSpeckleConverter.cs +++ /dev/null @@ -1,35 +0,0 @@ -using Speckle.Converters.Common.Objects; -using Speckle.Core.Models; -using Speckle.Converters.Common; - -namespace Speckle.Converters.ArcGIS3.Features; - -[NameAndRankValue(nameof(ACG.MapPoint), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class PointFeatureToSpeckleConverter : IToSpeckleTopLevelConverter, ITypedConverter -{ - private readonly IConversionContextStack _contextStack; - - public PointFeatureToSpeckleConverter(IConversionContextStack contextStack) - { - _contextStack = contextStack; - } - - public Base Convert(object target) => Convert((ACG.MapPoint)target); - - public Base Convert(ACG.MapPoint target) - { - if ( - ACG.GeometryEngine.Instance.Project(target, _contextStack.Current.Document.Map.SpatialReference) - is not ACG.MapPoint reprojectedPt - ) - { - throw new SpeckleConversionException( - $"Conversion to Spatial Reference {_contextStack.Current.Document.Map.SpatialReference} failed" - ); - } - List geometry = - new() { new SOG.Point(reprojectedPt.X, reprojectedPt.Y, reprojectedPt.Z, _contextStack.Current.SpeckleUnits) }; - - return geometry[0]; - } -} diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/ArcToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/ArcToHostConverter.cs deleted file mode 100644 index ec46307cfc..0000000000 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/ArcToHostConverter.cs +++ /dev/null @@ -1,54 +0,0 @@ -using Speckle.Converters.Common; -using Speckle.Converters.Common.Objects; -using Speckle.Core.Models; - -namespace Speckle.Converters.ArcGIS3.Geometry.ISpeckleObjectToHost; - -//TODO: Ellipses don't convert correctly, see Autocad test stream -//[NameAndRankValue(nameof(SOG.Arc), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class CurveToHostConverter : IToHostTopLevelConverter, ITypedConverter -{ - private readonly ITypedConverter _pointConverter; - - public CurveToHostConverter(ITypedConverter pointConverter) - { - _pointConverter = pointConverter; - } - - public object Convert(Base target) => Convert((SOG.Arc)target); - - public ACG.Polyline Convert(SOG.Arc target) - { - // Determine the number of vertices to create along the arc - int numVertices = Math.Max((int)target.length, 50); // Determine based on desired segment length or other criteria - List pointsOriginal = new(); - - // get correct direction - double? angleStart = target.startAngle; - double? fullAngle = target.endAngle - target.startAngle; - double? radius = target.radius; - - if (angleStart == null || fullAngle == null || radius == null) - { - throw new SpeckleConversionException("Conversion failed: Arc doesn't have start & end angle or radius"); - } - - // Calculate the vertices along the arc - for (int i = 0; i <= numVertices; i++) - { - // Calculate the point along the arc - double angle = (double)angleStart + (double)fullAngle * (i / (double)numVertices); - SOG.Point pointOnArc = - new( - target.plane.origin.x + (double)radius * Math.Cos(angle), - target.plane.origin.y + (double)radius * Math.Sin(angle), - target.plane.origin.z - ); - - pointsOriginal.Add(pointOnArc); - } - - var points = pointsOriginal.Select(x => _pointConverter.Convert(x)); - return new ACG.PolylineBuilderEx(points, ACG.AttributeFlags.HasZ).ToGeometry(); - } -} diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/EllipseToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/EllipseToHostConverter.cs deleted file mode 100644 index 94ee04b951..0000000000 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/EllipseToHostConverter.cs +++ /dev/null @@ -1,53 +0,0 @@ -using Speckle.Converters.Common; -using Speckle.Converters.Common.Objects; -using Speckle.Core.Models; - -namespace Speckle.Converters.ArcGIS3.Geometry.ISpeckleObjectToHost; - -//TODO: Ellipses don't convert correctly, see Autocad test stream -// [NameAndRankValue(nameof(SOG.Ellipse), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class EllipseToHostConverter : IToHostTopLevelConverter, ITypedConverter -{ - private readonly ITypedConverter _pointConverter; - - public EllipseToHostConverter(ITypedConverter pointConverter) - { - _pointConverter = pointConverter; - } - - public object Convert(Base target) => Convert((SOG.Ellipse)target); - - public ACG.Polyline Convert(SOG.Ellipse target) - { - // Determine the number of vertices to create along the Ellipse - int numVertices = Math.Max((int)target.length, 100); // Determine based on desired segment length or other criteria - List pointsOriginal = new(); - - if (target.firstRadius == null || target.secondRadius == null) - { - throw new SpeckleConversionException("Conversion failed: Ellipse doesn't have 1st and 2nd radius"); - } - - // Calculate the vertices along the arc - for (int i = 0; i <= numVertices; i++) - { - // Calculate the point along the arc - double angle = 2 * Math.PI * (i / (double)numVertices); - SOG.Point pointOnEllipse = - new( - target.plane.origin.x + (double)target.secondRadius * Math.Cos(angle), - target.plane.origin.y + (double)target.firstRadius * Math.Sin(angle), - target.plane.origin.z - ); - - pointsOriginal.Add(pointOnEllipse); - } - if (pointsOriginal[0] != pointsOriginal[^1]) - { - pointsOriginal.Add(pointsOriginal[0]); - } - - var points = pointsOriginal.Select(x => _pointConverter.Convert(x)); - return new ACG.PolylineBuilderEx(points, ACG.AttributeFlags.HasZ).ToGeometry(); - } -} diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/PolycurveToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/PolycurveToHostConverter.cs deleted file mode 100644 index 35adddb385..0000000000 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/PolycurveToHostConverter.cs +++ /dev/null @@ -1,46 +0,0 @@ -using Speckle.Converters.Common; -using Speckle.Converters.Common.Objects; -using Speckle.Core.Models; - -namespace Speckle.Converters.ArcGIS3.Geometry.ISpeckleObjectToHost; - -[NameAndRankValue(nameof(SOG.Polycurve), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class PolycurveToHostConverter : IToHostTopLevelConverter, ITypedConverter -{ - private readonly ITypedConverter _pointConverter; - private readonly IRootToHostConverter _converter; - - public PolycurveToHostConverter( - ITypedConverter pointConverter, - IRootToHostConverter converter - ) - { - _pointConverter = pointConverter; - _converter = converter; - } - - public object Convert(Base target) => Convert((SOG.Polycurve)target); - - public ACG.Polyline Convert(SOG.Polycurve target) - { - List points = new(); - foreach (var segment in target.segments) - { - if (segment is SOG.Arc) - { - throw new NotImplementedException("Polycurves with arc segments are not supported"); - } - ACG.Polyline converted = (ACG.Polyline)_converter.Convert((Base)segment); - List newPts = converted.Points.ToList(); - - // reverse new segment if needed - if (points.Count > 0 && newPts.Count > 0 && points[^1] != newPts[0] && points[^1] == newPts[^1]) - { - newPts.Reverse(); - } - points.AddRange(newPts); - } - - return new ACG.PolylineBuilderEx(points, ACG.AttributeFlags.HasZ).ToGeometry(); - } -} diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/SegmentCollectionToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/SegmentCollectionToSpeckleConverter.cs deleted file mode 100644 index 2d3c93fce8..0000000000 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/SegmentCollectionToSpeckleConverter.cs +++ /dev/null @@ -1,65 +0,0 @@ -using Speckle.Converters.Common; -using Speckle.Converters.Common.Objects; - -namespace Speckle.Converters.ArcGIS3.Geometry; - -public class SegmentCollectionToSpeckleConverter : ITypedConverter -{ - private readonly IConversionContextStack _contextStack; - private readonly ITypedConverter _pointConverter; - - public SegmentCollectionToSpeckleConverter( - IConversionContextStack contextStack, - ITypedConverter pointConverter - ) - { - _contextStack = contextStack; - _pointConverter = pointConverter; - } - - public SOG.Polyline Convert(ACG.ReadOnlySegmentCollection target) - { - // https://pro.arcgis.com/en/pro-app/latest/sdk/api-reference/topic8480.html - double len = 0; - - List points = new(); - foreach (var segment in target) - { - len += segment.Length; - - // specific conversion per segment type - switch (segment.SegmentType) - { - case ACG.SegmentType.Line: - points = AddPtsToPolylinePts( - points, - new List() - { - _pointConverter.Convert(segment.StartPoint), - _pointConverter.Convert(segment.EndPoint) - } - ); - break; - default: - throw new SpeckleConversionException($"Segment of type '{segment.SegmentType}' cannot be converted"); - } - } - SOG.Polyline polyline = - new(points.SelectMany(pt => new[] { pt.x, pt.y, pt.z }).ToList(), _contextStack.Current.SpeckleUnits) { }; - - return polyline; - } - - private List AddPtsToPolylinePts(List points, List newSegmentPts) - { - if (points.Count == 0 || points[^1] != newSegmentPts[0]) - { - points.AddRange(newSegmentPts); - } - else - { - points.AddRange(newSegmentPts.GetRange(1, newSegmentPts.Count - 1)); - } - return points; - } -} diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/Raw/CurveToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/Raw/CurveToHostConverter.cs new file mode 100644 index 0000000000..57bd7b3c83 --- /dev/null +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/Raw/CurveToHostConverter.cs @@ -0,0 +1,52 @@ +using Objects; +using Speckle.Converters.Common.Objects; + +namespace Speckle.Converters.ArcGIS3.ToHost.Raw; + +public class CurveToHostConverter : ITypedConverter +{ + private readonly ITypedConverter _lineConverter; + private readonly ITypedConverter _arcConverter; + private readonly ITypedConverter _ellipseConverter; + private readonly ITypedConverter _circleConverter; + private readonly ITypedConverter _polylineConverter; + private readonly ITypedConverter _polyCurveConverter; + + public CurveToHostConverter( + ITypedConverter lineConverter, + ITypedConverter arcConverter, + ITypedConverter ellipseConverter, + ITypedConverter circleConverter, + ITypedConverter polylineConverter, + ITypedConverter polyCurveConverter + ) + { + _lineConverter = lineConverter; + _arcConverter = arcConverter; + _ellipseConverter = ellipseConverter; + _circleConverter = circleConverter; + _polylineConverter = polylineConverter; + _polyCurveConverter = polyCurveConverter; + } + + /// + /// Converts a given ICurve object to an ACG.Polyline object. + /// + /// The ICurve object to convert. + /// The converted RG.Curve object. + /// Thrown when the conversion is not supported for the given type of curve. + /// ⚠️ This conversion does NOT perform scaling. + public ACG.Polyline Convert(ICurve target) => + target switch + { + SOG.Line line => _lineConverter.Convert(line), + SOG.Arc arc => _arcConverter.Convert(arc), + SOG.Circle circle => _circleConverter.Convert(circle), + SOG.Ellipse ellipse => _ellipseConverter.Convert(ellipse), + SOG.Spiral spiral => _polylineConverter.Convert(spiral.displayValue), + SOG.Polyline polyline => _polylineConverter.Convert(polyline), + SOG.Curve curve => _polylineConverter.Convert(curve.displayValue), + SOG.Polycurve polyCurve => _polyCurveConverter.Convert(polyCurve), + _ => throw new NotSupportedException($"Unable to convert curves of type {target.GetType().Name}") + }; +} diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/FeatureClassToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/Raw/FeatureClassToHostConverter.cs similarity index 99% rename from DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/FeatureClassToHostConverter.cs rename to DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/Raw/FeatureClassToHostConverter.cs index 0a084ffee8..d491ca2a1e 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/FeatureClassToHostConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/Raw/FeatureClassToHostConverter.cs @@ -8,7 +8,7 @@ using Speckle.Core.Models; using FieldDescription = ArcGIS.Core.Data.DDL.FieldDescription; -namespace Speckle.Converters.ArcGIS3.Layers; +namespace Speckle.Converters.ArcGIS3.ToHost.Raw; public class FeatureClassToHostConverter : ITypedConverter { diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GeometryToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/Raw/GeometryToHostConverter.cs similarity index 98% rename from DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GeometryToHostConverter.cs rename to DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/Raw/GeometryToHostConverter.cs index 2ee8dc31d2..9ec0f3d279 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GeometryToHostConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/Raw/GeometryToHostConverter.cs @@ -2,7 +2,7 @@ using Speckle.Converters.Common.Objects; using Speckle.Core.Models; -namespace Speckle.Converters.ArcGIS3.Features; +namespace Speckle.Converters.ArcGIS3.ToHost.Raw; public class GeometryToHostConverter : ITypedConverter, ACG.Geometry> { diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/MeshListToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/Raw/MeshListToHostConverter.cs similarity index 72% rename from DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/MeshListToHostConverter.cs rename to DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/Raw/MeshListToHostConverter.cs index 7730f54308..941f6ac70f 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/MeshListToHostConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/Raw/MeshListToHostConverter.cs @@ -2,15 +2,20 @@ using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; -namespace Speckle.Converters.ArcGIS3.Geometry.GisFeatureGeometriesToHost; +namespace Speckle.Converters.ArcGIS3.ToHost.Raw; public class MeshListToHostConverter : ITypedConverter, ACG.Multipatch> { private readonly ITypedConverter _pointConverter; + private readonly IConversionContextStack _contextStack; - public MeshListToHostConverter(ITypedConverter pointConverter) + public MeshListToHostConverter( + ITypedConverter pointConverter, + IConversionContextStack contextStack + ) { _pointConverter = pointConverter; + _contextStack = contextStack; } public ACG.Multipatch Convert(List target) @@ -19,7 +24,7 @@ public ACG.Multipatch Convert(List target) { throw new SpeckleConversionException("Feature contains no geometries"); } - ACG.MultipatchBuilderEx multipatchPart = new(); + ACG.MultipatchBuilderEx multipatchPart = new(_contextStack.Current.Document.Map.SpatialReference); foreach (SOG.Mesh part in target) { part.TriangulateMesh(); diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/MultipatchListToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/Raw/MultipatchListToHostConverter.cs similarity index 93% rename from DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/MultipatchListToHostConverter.cs rename to DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/Raw/MultipatchListToHostConverter.cs index e2a4d6028e..44c961e9bc 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/MultipatchListToHostConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/Raw/MultipatchListToHostConverter.cs @@ -1,7 +1,7 @@ using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; -namespace Speckle.Converters.ArcGIS3.Geometry.GisFeatureGeometriesToHost; +namespace Speckle.Converters.ArcGIS3.ToHost.Raw; public class MultipatchListToHostConverter : ITypedConverter, ACG.Multipatch> { diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/PointListToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/Raw/PointListToHostConverter.cs similarity index 91% rename from DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/PointListToHostConverter.cs rename to DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/Raw/PointListToHostConverter.cs index ac1d3e5467..e1204f36c5 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/PointListToHostConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/Raw/PointListToHostConverter.cs @@ -1,7 +1,7 @@ using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; -namespace Speckle.Converters.ArcGIS3.Geometry.GisFeatureGeometriesToHost; +namespace Speckle.Converters.ArcGIS3.ToHost.Raw; public class PointListToHostConverter : ITypedConverter, ACG.Multipoint> { diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/PointSingleToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/Raw/PointSingleToHostConverter.cs similarity index 84% rename from DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/PointSingleToHostConverter.cs rename to DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/Raw/PointSingleToHostConverter.cs index e30ec589e5..75bb57b476 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/PointSingleToHostConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/Raw/PointSingleToHostConverter.cs @@ -3,7 +3,7 @@ using Speckle.Core.Kits; using Speckle.Core.Models; -namespace Speckle.Converters.ArcGIS3.Geometry; +namespace Speckle.Converters.ArcGIS3.ToHost.Raw; public class PointToHostConverter : ITypedConverter { @@ -22,7 +22,8 @@ public ACG.MapPoint Convert(SOG.Point target) return new ACG.MapPointBuilderEx( target.x * scaleFactor, target.y * scaleFactor, - target.z * scaleFactor + target.z * scaleFactor, + _contextStack.Current.Document.Map.SpatialReference ).ToGeometry(); } } diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/PointcloudLayerToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/Raw/PointcloudLayerToHostConverter.cs similarity index 90% rename from DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/PointcloudLayerToHostConverter.cs rename to DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/Raw/PointcloudLayerToHostConverter.cs index 2011596618..fa04b92fa0 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/PointcloudLayerToHostConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/Raw/PointcloudLayerToHostConverter.cs @@ -3,7 +3,7 @@ using Speckle.Converters.Common.Objects; using Speckle.Core.Models; -namespace Speckle.Converters.ArcGIS3.Layers; +namespace Speckle.Converters.ArcGIS3.ToHost.Raw; public class PointcloudLayerToHostConverter : ITypedConverter { diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/Polygon3dListToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/Raw/Polygon3dListToHostConverter.cs similarity index 95% rename from DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/Polygon3dListToHostConverter.cs rename to DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/Raw/Polygon3dListToHostConverter.cs index 72f6951056..5d68c5be91 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/Polygon3dListToHostConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/Raw/Polygon3dListToHostConverter.cs @@ -1,7 +1,7 @@ -using Speckle.Converters.Common.Objects; using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; -namespace Speckle.Converters.ArcGIS3.Geometry.GisFeatureGeometriesToHost; +namespace Speckle.Converters.ArcGIS3.ToHost.Raw; public class Polygon3dListToHostConverter : ITypedConverter, ACG.Multipatch> { diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/PolygonListToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/Raw/PolygonListToHostConverter.cs similarity index 94% rename from DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/PolygonListToHostConverter.cs rename to DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/Raw/PolygonListToHostConverter.cs index b6aa76cb1c..6acc30b826 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/PolygonListToHostConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/Raw/PolygonListToHostConverter.cs @@ -1,7 +1,7 @@ -using Speckle.Converters.Common.Objects; using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; -namespace Speckle.Converters.ArcGIS3.Geometry.GisFeatureGeometriesToHost; +namespace Speckle.Converters.ArcGIS3.ToHost.Raw; public class PolygonListToHostConverter : ITypedConverter, ACG.Polygon> { diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/PolylineListToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/Raw/PolylineListToHostConverter.cs similarity index 92% rename from DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/PolylineListToHostConverter.cs rename to DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/Raw/PolylineListToHostConverter.cs index 97983c42bf..d512a23d94 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/PolylineListToHostConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/Raw/PolylineListToHostConverter.cs @@ -1,7 +1,7 @@ -using Speckle.Converters.Common.Objects; using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; -namespace Speckle.Converters.ArcGIS3.Geometry.GisFeatureGeometriesToHost; +namespace Speckle.Converters.ArcGIS3.ToHost.Raw; public class PolylineListToHostConverter : ITypedConverter, ACG.Polyline> { diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/TableToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/Raw/TableToHostConverter.cs similarity index 98% rename from DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/TableToHostConverter.cs rename to DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/Raw/TableToHostConverter.cs index 374f09c23d..8af12954d6 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/TableToHostConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/Raw/TableToHostConverter.cs @@ -1,13 +1,13 @@ +using ArcGIS.Core.Data; using ArcGIS.Core.Data.DDL; using ArcGIS.Core.Data.Exceptions; -using ArcGIS.Core.Data; using Objects.GIS; using Speckle.Converters.ArcGIS3.Utils; +using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; using FieldDescription = ArcGIS.Core.Data.DDL.FieldDescription; -using Speckle.Converters.Common; -namespace Speckle.Converters.ArcGIS3.Layers; +namespace Speckle.Converters.ArcGIS3.ToHost.Raw; public class TableLayerToHostConverter : ITypedConverter { diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/TopLevel/ArcToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/TopLevel/ArcToHostConverter.cs new file mode 100644 index 0000000000..f334713612 --- /dev/null +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/TopLevel/ArcToHostConverter.cs @@ -0,0 +1,47 @@ +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; +using Speckle.Core.Models; + +namespace Speckle.Converters.ArcGIS3.ToHost.TopLevel; + +[NameAndRankValue(nameof(SOG.Arc), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +public class ArcToHostConverter : IToHostTopLevelConverter, ITypedConverter +{ + private readonly ITypedConverter _pointConverter; + private readonly IConversionContextStack _contextStack; + + public ArcToHostConverter( + ITypedConverter pointConverter, + IConversionContextStack contextStack + ) + { + _pointConverter = pointConverter; + _contextStack = contextStack; + } + + public object Convert(Base target) => Convert((SOG.Arc)target); + + public ACG.Polyline Convert(SOG.Arc target) + { + if (target.startPoint.z != target.midPoint.z || target.startPoint.z != target.endPoint.z) + { + throw new ArgumentException("Only Arc in XY plane are supported"); + } + ACG.MapPoint fromPt = _pointConverter.Convert(target.startPoint); + ACG.MapPoint toPt = _pointConverter.Convert(target.endPoint); + ACG.MapPoint midPt = _pointConverter.Convert(target.midPoint); + + ACG.EllipticArcSegment segment = ACG.EllipticArcBuilderEx.CreateCircularArc( + fromPt, + toPt, + new ACG.Coordinate2D(midPt), + _contextStack.Current.Document.Map.SpatialReference + ); + + return new ACG.PolylineBuilderEx( + segment, + ACG.AttributeFlags.HasZ, + _contextStack.Current.Document.Map.SpatialReference + ).ToGeometry(); + } +} diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/CircleToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/TopLevel/CircleToHostConverter.cs similarity index 72% rename from DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/CircleToHostConverter.cs rename to DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/TopLevel/CircleToHostConverter.cs index d4ffe06c35..089ac64b1b 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/CircleToHostConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/TopLevel/CircleToHostConverter.cs @@ -3,7 +3,7 @@ using Speckle.Core.Kits; using Speckle.Core.Models; -namespace Speckle.Converters.ArcGIS3.Geometry.ISpeckleObjectToHost; +namespace Speckle.Converters.ArcGIS3.ToHost.TopLevel; [NameAndRankValue(nameof(SOG.Circle), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] public class CircleToHostConverter : IToHostTopLevelConverter, ITypedConverter @@ -28,6 +28,12 @@ public ACG.Polyline Convert(SOG.Circle target) { throw new SpeckleConversionException("Conversion failed: Circle doesn't have a radius"); } + if ( + target.plane.normal.x != 0 || target.plane.normal.y != 0 || target.plane.xdir.z != 0 || target.plane.ydir.z != 0 + ) + { + throw new ArgumentException("Only Circles in XY plane are supported"); + } // create a native ArcGIS circle segment ACG.MapPoint centerPt = _pointConverter.Convert(target.plane.origin); @@ -36,11 +42,14 @@ public ACG.Polyline Convert(SOG.Circle target) ACG.EllipticArcSegment circleSegment = ACG.EllipticArcBuilderEx.CreateCircle( new ACG.Coordinate2D(centerPt.X, centerPt.Y), (double)target.radius * scaleFactor, - ACG.ArcOrientation.ArcClockwise + ACG.ArcOrientation.ArcClockwise, + _contextStack.Current.Document.Map.SpatialReference ); - var circlePolyline = new ACG.PolylineBuilderEx(circleSegment, ACG.AttributeFlags.HasZ).ToGeometry(); - - return circlePolyline; + return new ACG.PolylineBuilderEx( + circleSegment, + ACG.AttributeFlags.HasZ, + _contextStack.Current.Document.Map.SpatialReference + ).ToGeometry(); } } diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/TopLevel/EllipseToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/TopLevel/EllipseToHostConverter.cs new file mode 100644 index 0000000000..d839109fb2 --- /dev/null +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/TopLevel/EllipseToHostConverter.cs @@ -0,0 +1,70 @@ +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; +using Speckle.Core.Kits; +using Speckle.Core.Models; + +namespace Speckle.Converters.ArcGIS3.ToHost.TopLevel; + +[NameAndRankValue(nameof(SOG.Ellipse), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +public class EllipseToHostConverter : IToHostTopLevelConverter, ITypedConverter +{ + private readonly ITypedConverter _pointConverter; + private readonly IConversionContextStack _contextStack; + + public EllipseToHostConverter( + ITypedConverter pointConverter, + IConversionContextStack contextStack + ) + { + _pointConverter = pointConverter; + _contextStack = contextStack; + } + + public object Convert(Base target) => Convert((SOG.Ellipse)target); + + public ACG.Polyline Convert(SOG.Ellipse target) + { + // dummy check + if (target.firstRadius == null || target.secondRadius == null) + { + throw new ArgumentException("Ellipse is missing the first or second radius"); + } + if ( + target.plane.normal.x != 0 || target.plane.normal.y != 0 || target.plane.xdir.z != 0 || target.plane.ydir.z != 0 + ) + { + throw new ArgumentException("Only Ellipses in XY plane are supported"); + } + + ACG.MapPoint centerPt = _pointConverter.Convert(target.plane.origin); + double scaleFactor = Units.GetConversionFactor(target.units, _contextStack.Current.SpeckleUnits); + + // set default values + double angle = Math.Atan2(target.plane.xdir.y, target.plane.xdir.x); + double majorAxisRadius = (double)target.firstRadius; + double minorAxisRatio = (double)target.secondRadius / majorAxisRadius; + + // adjust if needed + if (minorAxisRatio > 1) + { + majorAxisRadius = (double)target.secondRadius; + minorAxisRatio = 1 / minorAxisRatio; + angle += Math.PI / 2; + } + + ACG.EllipticArcSegment segment = ACG.EllipticArcBuilderEx.CreateEllipse( + new ACG.Coordinate2D(centerPt), + angle, + majorAxisRadius * scaleFactor, + minorAxisRatio, + ACG.ArcOrientation.ArcCounterClockwise, + _contextStack.Current.Document.Map.SpatialReference + ); + + return new ACG.PolylineBuilderEx( + segment, + ACG.AttributeFlags.HasZ, + _contextStack.Current.Document.Map.SpatialReference + ).ToGeometry(); + } +} diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/FallbackToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/TopLevel/FallbackToHostConverter.cs similarity index 96% rename from DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/FallbackToHostConverter.cs rename to DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/TopLevel/FallbackToHostConverter.cs index ec9f1eef77..0f777c297c 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/FallbackToHostConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/TopLevel/FallbackToHostConverter.cs @@ -2,7 +2,7 @@ using Speckle.Converters.Common.Objects; using Speckle.Core.Models; -namespace Speckle.Converters.ArcGIS3.Geometry; +namespace Speckle.Converters.ArcGIS3.ToHost.TopLevel; [NameAndRankValue(nameof(DisplayableObject), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] public class FallbackToHostConverter : IToHostTopLevelConverter, ITypedConverter diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/LineToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/TopLevel/LineToHostConverter.cs similarity index 58% rename from DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/LineToHostConverter.cs rename to DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/TopLevel/LineToHostConverter.cs index 60a1447d7b..ab562f2395 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/LineToHostConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/TopLevel/LineToHostConverter.cs @@ -2,16 +2,21 @@ using Speckle.Converters.Common.Objects; using Speckle.Core.Models; -namespace Speckle.Converters.ArcGIS3.Geometry.ISpeckleObjectToHost; +namespace Speckle.Converters.ArcGIS3.ToHost.TopLevel; [NameAndRankValue(nameof(SOG.Line), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] public class LineSingleToHostConverter : IToHostTopLevelConverter, ITypedConverter { private readonly ITypedConverter _pointConverter; + private readonly IConversionContextStack _contextStack; - public LineSingleToHostConverter(ITypedConverter pointConverter) + public LineSingleToHostConverter( + ITypedConverter pointConverter, + IConversionContextStack contextStack + ) { _pointConverter = pointConverter; + _contextStack = contextStack; } public object Convert(Base target) => Convert((SOG.Line)target); @@ -20,6 +25,10 @@ public ACG.Polyline Convert(SOG.Line target) { List originalPoints = new() { target.start, target.end }; IEnumerable points = originalPoints.Select(x => _pointConverter.Convert(x)); - return new ACG.PolylineBuilderEx(points, ACG.AttributeFlags.HasZ).ToGeometry(); + return new ACG.PolylineBuilderEx( + points, + ACG.AttributeFlags.HasZ, + _contextStack.Current.Document.Map.SpatialReference + ).ToGeometry(); } } diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/MeshToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/TopLevel/MeshToHostConverter.cs similarity index 91% rename from DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/MeshToHostConverter.cs rename to DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/TopLevel/MeshToHostConverter.cs index 8de4c957e4..d9f60803f5 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/MeshToHostConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/TopLevel/MeshToHostConverter.cs @@ -2,7 +2,7 @@ using Speckle.Converters.Common.Objects; using Speckle.Core.Models; -namespace Speckle.Converters.ArcGIS3.Geometry.ISpeckleObjectToHost; +namespace Speckle.Converters.ArcGIS3.ToHost.TopLevel; [NameAndRankValue(nameof(SOG.Mesh), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] public class MeshToHostConverter : IToHostTopLevelConverter, ITypedConverter diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/PointToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/TopLevel/PointToHostConverter.cs similarity index 89% rename from DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/PointToHostConverter.cs rename to DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/TopLevel/PointToHostConverter.cs index abf671574a..4fe87d57ac 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/PointToHostConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/TopLevel/PointToHostConverter.cs @@ -2,7 +2,7 @@ using Speckle.Converters.Common.Objects; using Speckle.Core.Models; -namespace Speckle.Converters.ArcGIS3.Geometry.ISpeckleObjectToHost; +namespace Speckle.Converters.ArcGIS3.ToHost.TopLevel; [NameAndRankValue(nameof(SOG.Point), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] public class PointToHostConverter : IToHostTopLevelConverter diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/TopLevel/PolycurveToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/TopLevel/PolycurveToHostConverter.cs new file mode 100644 index 0000000000..ba57e347f6 --- /dev/null +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/TopLevel/PolycurveToHostConverter.cs @@ -0,0 +1,60 @@ +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; +using Speckle.Core.Models; + +namespace Speckle.Converters.ArcGIS3.ToHost.TopLevel; + +[NameAndRankValue(nameof(SOG.Polycurve), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +public class PolycurveToHostConverter : IToHostTopLevelConverter, ITypedConverter +{ + private readonly ITypedConverter _pointConverter; + private readonly IRootToHostConverter _converter; + private readonly IConversionContextStack _contextStack; + + public PolycurveToHostConverter( + ITypedConverter pointConverter, + IRootToHostConverter converter, + IConversionContextStack contextStack + ) + { + _pointConverter = pointConverter; + _converter = converter; + _contextStack = contextStack; + } + + public object Convert(Base target) => Convert((SOG.Polycurve)target); + + public ACG.Polyline Convert(SOG.Polycurve target) + { + ACG.MapPoint? lastConvertedPt = null; + List segments = new(); + + foreach (var segment in target.segments) + { + ACG.Polyline converted = (ACG.Polyline)_converter.Convert((Base)segment); //CurveConverter.NotNull().Convert(segment); + List segmentPts = converted.Points.ToList(); + + if ( + lastConvertedPt != null + && segmentPts.Count > 0 + && ( + Math.Round(lastConvertedPt.X, 6) != Math.Round(segmentPts[0].X, 6) + || Math.Round(lastConvertedPt.Y, 6) != Math.Round(segmentPts[0].Y, 6) + || Math.Round(lastConvertedPt.Z, 6) != Math.Round(segmentPts[0].Z, 6) + ) + ) + { + throw new SpeckleConversionException("Polycurve segments are not in a correct sequence/orientation"); + } + + lastConvertedPt = segmentPts[^1]; + segments.Add(converted); + } + + return new ACG.PolylineBuilderEx( + segments, + ACG.AttributeFlags.HasZ, + _contextStack.Current.Document.Map.SpatialReference + ).ToGeometry(); + } +} diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/PolylineToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/TopLevel/PolylineToHostConverter.cs similarity index 61% rename from DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/PolylineToHostConverter.cs rename to DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/TopLevel/PolylineToHostConverter.cs index 6615607b98..d32e32d022 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/PolylineToHostConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/TopLevel/PolylineToHostConverter.cs @@ -2,16 +2,21 @@ using Speckle.Converters.Common.Objects; using Speckle.Core.Models; -namespace Speckle.Converters.ArcGIS3.Geometry.ISpeckleObjectToHost; +namespace Speckle.Converters.ArcGIS3.ToHost.TopLevel; [NameAndRankValue(nameof(SOG.Polyline), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] public class PolylineToHostConverter : IToHostTopLevelConverter, ITypedConverter { private readonly ITypedConverter _pointConverter; + private readonly IConversionContextStack _contextStack; - public PolylineToHostConverter(ITypedConverter pointConverter) + public PolylineToHostConverter( + ITypedConverter pointConverter, + IConversionContextStack contextStack + ) { _pointConverter = pointConverter; + _contextStack = contextStack; } public object Convert(Base target) => Convert((SOG.Polyline)target); @@ -24,6 +29,10 @@ public ACG.Polyline Convert(SOG.Polyline target) { points.Add(points[0]); } - return new ACG.PolylineBuilderEx(points, ACG.AttributeFlags.HasZ).ToGeometry(); + return new ACG.PolylineBuilderEx( + points, + ACG.AttributeFlags.HasZ, + _contextStack.Current.Document.Map.SpatialReference + ).ToGeometry(); } } diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/RasterLayerToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/TopLevel/RasterLayerToHostConverter.cs similarity index 90% rename from DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/RasterLayerToHostConverter.cs rename to DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/TopLevel/RasterLayerToHostConverter.cs index f97cbc5dd8..6ffb334009 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/RasterLayerToHostConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/TopLevel/RasterLayerToHostConverter.cs @@ -3,7 +3,7 @@ using Speckle.Converters.Common.Objects; using Speckle.Core.Models; -namespace Speckle.Converters.ArcGIS3.Layers; +namespace Speckle.Converters.ArcGIS3.ToHost.TopLevel; [NameAndRankValue(nameof(RasterLayer), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] public class RasterLayerToHostConverter : IToHostTopLevelConverter, ITypedConverter diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/VectorLayerToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/TopLevel/VectorLayerToHostConverter.cs similarity index 97% rename from DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/VectorLayerToHostConverter.cs rename to DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/TopLevel/VectorLayerToHostConverter.cs index d4438f7339..5c7dd8c9eb 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/VectorLayerToHostConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/TopLevel/VectorLayerToHostConverter.cs @@ -6,7 +6,7 @@ using Speckle.Converters.Common.Objects; using Speckle.Core.Models; -namespace Speckle.Converters.ArcGIS3.Layers; +namespace Speckle.Converters.ArcGIS3.ToHost.TopLevel; [NameAndRankValue(nameof(VectorLayer), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] public class VectorLayerToHostConverter : IToHostTopLevelConverter, ITypedConverter diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/EnvelopBoxToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToSpeckle/Raw/EnvelopBoxToSpeckleConverter.cs similarity index 96% rename from DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/EnvelopBoxToSpeckleConverter.cs rename to DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToSpeckle/Raw/EnvelopBoxToSpeckleConverter.cs index 15dad97faf..0296c5d328 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/EnvelopBoxToSpeckleConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToSpeckle/Raw/EnvelopBoxToSpeckleConverter.cs @@ -1,9 +1,9 @@ using ArcGIS.Core.Geometry; -using Speckle.Converters.Common.Objects; -using Speckle.Converters.Common; using Objects.Primitive; +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; -namespace Speckle.Converters.ArcGIS3.Geometry; +namespace Speckle.Converters.ArcGIS3.ToSpeckle.Raw; public class EnvelopToSpeckleConverter : ITypedConverter { diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GeometryToSpeckleBase.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToSpeckle/Raw/GeometryToSpeckleBase.cs similarity index 97% rename from DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GeometryToSpeckleBase.cs rename to DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToSpeckle/Raw/GeometryToSpeckleBase.cs index db4c5cab66..951432f74c 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GeometryToSpeckleBase.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToSpeckle/Raw/GeometryToSpeckleBase.cs @@ -2,7 +2,7 @@ using Speckle.Converters.Common.Objects; using Speckle.Core.Models; -namespace Speckle.Converters.ArcGIS3.Features; +namespace Speckle.Converters.ArcGIS3.ToSpeckle.Raw; public class GeometryToSpeckleBaseList : ITypedConverter> { diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GisFeatureToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToSpeckle/Raw/GisFeatureToSpeckleConverter.cs similarity index 97% rename from DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GisFeatureToSpeckleConverter.cs rename to DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToSpeckle/Raw/GisFeatureToSpeckleConverter.cs index a3c9d41e40..aa82bf5a2c 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GisFeatureToSpeckleConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToSpeckle/Raw/GisFeatureToSpeckleConverter.cs @@ -1,11 +1,10 @@ -using Speckle.Converters.Common.Objects; -using Speckle.Core.Models; using ArcGIS.Core.Data; -using Speckle.Converters.ArcGIS3.Geometry; -using Speckle.Converters.Common; using Speckle.Converters.ArcGIS3.Utils; +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; +using Speckle.Core.Models; -namespace Speckle.Converters.ArcGIS3.Features; +namespace Speckle.Converters.ArcGIS3.ToSpeckle.Raw; public class GisFeatureToSpeckleConverter : ITypedConverter { diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GisRasterToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToSpeckle/Raw/GisRasterToSpeckleConverter.cs similarity index 99% rename from DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GisRasterToSpeckleConverter.cs rename to DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToSpeckle/Raw/GisRasterToSpeckleConverter.cs index af3e268b8b..7d67bfd67c 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GisRasterToSpeckleConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToSpeckle/Raw/GisRasterToSpeckleConverter.cs @@ -1,10 +1,10 @@ -using Speckle.Converters.Common.Objects; -using Speckle.Core.Models; -using Objects.GIS; using ArcGIS.Core.Data.Raster; +using Objects.GIS; using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; +using Speckle.Core.Models; -namespace Speckle.Converters.ArcGIS3.Features; +namespace Speckle.Converters.ArcGIS3.ToSpeckle.Raw; public class GisRasterToSpeckleConverter : ITypedConverter { diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/MultipatchFeatureToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToSpeckle/Raw/MultipatchFeatureToSpeckleConverter.cs similarity index 98% rename from DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/MultipatchFeatureToSpeckleConverter.cs rename to DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToSpeckle/Raw/MultipatchFeatureToSpeckleConverter.cs index 2e15ae765b..7b60ee416f 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/MultipatchFeatureToSpeckleConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToSpeckle/Raw/MultipatchFeatureToSpeckleConverter.cs @@ -1,9 +1,9 @@ -using Speckle.Converters.Common.Objects; +using Speckle.Converters.ArcGIS3.Utils; using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; using Speckle.Core.Models; -using Speckle.Converters.ArcGIS3.Geometry; -namespace Speckle.Converters.ArcGIS3.Features; +namespace Speckle.Converters.ArcGIS3.ToSpeckle.Raw; public class MultipatchFeatureToSpeckleConverter : ITypedConverter> { diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/MultipointFeatureToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToSpeckle/Raw/MultipointFeatureToSpeckleConverter.cs similarity index 92% rename from DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/MultipointFeatureToSpeckleConverter.cs rename to DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToSpeckle/Raw/MultipointFeatureToSpeckleConverter.cs index c7e1669038..c6d6299ffb 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/MultipointFeatureToSpeckleConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToSpeckle/Raw/MultipointFeatureToSpeckleConverter.cs @@ -1,6 +1,6 @@ using Speckle.Converters.Common.Objects; -namespace Speckle.Converters.ArcGIS3.Features; +namespace Speckle.Converters.ArcGIS3.ToSpeckle.Raw; public class MultipointFeatureToSpeckleConverter : ITypedConverter> { diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/PointToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToSpeckle/Raw/PointToSpeckleConverter.cs similarity index 95% rename from DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/PointToSpeckleConverter.cs rename to DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToSpeckle/Raw/PointToSpeckleConverter.cs index 9b0859318b..46ffb8f937 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/PointToSpeckleConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToSpeckle/Raw/PointToSpeckleConverter.cs @@ -1,8 +1,8 @@ using ArcGIS.Core.Geometry; -using Speckle.Converters.Common.Objects; using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; -namespace Speckle.Converters.ArcGIS3.Geometry; +namespace Speckle.Converters.ArcGIS3.ToSpeckle.Raw; public class PointToSpeckleConverter : ITypedConverter { diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/PolygonFeatureToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToSpeckle/Raw/PolygonFeatureToSpeckleConverter.cs similarity index 96% rename from DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/PolygonFeatureToSpeckleConverter.cs rename to DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToSpeckle/Raw/PolygonFeatureToSpeckleConverter.cs index 3bbf377d3b..23034aa454 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/PolygonFeatureToSpeckleConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToSpeckle/Raw/PolygonFeatureToSpeckleConverter.cs @@ -1,8 +1,8 @@ -using Speckle.Converters.Common.Objects; using Objects.GIS; using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; -namespace Speckle.Converters.ArcGIS3.Features; +namespace Speckle.Converters.ArcGIS3.ToSpeckle.Raw; public class PolygonFeatureToSpeckleConverter : ITypedConverter> { diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/PolylineFeatureToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToSpeckle/Raw/PolylineFeatureToSpeckleConverter.cs similarity index 91% rename from DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/PolylineFeatureToSpeckleConverter.cs rename to DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToSpeckle/Raw/PolylineFeatureToSpeckleConverter.cs index 92bc6ff70e..a8cc1a99d3 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/PolylineFeatureToSpeckleConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToSpeckle/Raw/PolylineFeatureToSpeckleConverter.cs @@ -1,7 +1,7 @@ using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; -namespace Speckle.Converters.ArcGIS3.Features; +namespace Speckle.Converters.ArcGIS3.ToSpeckle.Raw; public class PolyineFeatureToSpeckleConverter : ITypedConverter> { @@ -23,7 +23,7 @@ public PolyineFeatureToSpeckleConverter( List polylineList = new(); ACG.Polyline polylineToConvert = target; - // segmentize the polylines with curves using precision value of the Map's Spatial Reference + // densify the polylines with curves using precision value of the Map's Spatial Reference if (target.HasCurves is true) { double tolerance = _contextStack.Current.Document.Map.SpatialReference.XYTolerance; @@ -32,11 +32,11 @@ public PolyineFeatureToSpeckleConverter( target, tolerance * conversionFactorToMeter ); - polylineToConvert = (ACG.Polyline)densifiedPolyline; if (densifiedPolyline == null) { throw new ArgumentException("Polyline densification failed"); } + polylineToConvert = (ACG.Polyline)densifiedPolyline; } foreach (var segmentCollection in polylineToConvert.Parts) diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToSpeckle/Raw/SegmentCollectionToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToSpeckle/Raw/SegmentCollectionToSpeckleConverter.cs new file mode 100644 index 0000000000..f0b71ef47c --- /dev/null +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToSpeckle/Raw/SegmentCollectionToSpeckleConverter.cs @@ -0,0 +1,98 @@ +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; + +namespace Speckle.Converters.ArcGIS3.ToSpeckle.Raw; + +public class SegmentCollectionToSpeckleConverter : ITypedConverter +{ + private readonly IConversionContextStack _contextStack; + private readonly ITypedConverter _pointConverter; + + public SegmentCollectionToSpeckleConverter( + IConversionContextStack contextStack, + ITypedConverter pointConverter + ) + { + _contextStack = contextStack; + _pointConverter = pointConverter; + } + + public SOG.Polyline Convert(ACG.ReadOnlySegmentCollection target) + { + // https://pro.arcgis.com/en/pro-app/latest/sdk/api-reference/topic8480.html + double len = 0; + + List points = new(); + foreach (var segment in target) + { + len += segment.Length; + + if (segment.SegmentType != ACG.SegmentType.Line) + { + // densify the segments with curves using precision value of the Map's Spatial Reference + ACG.Polyline polylineFromSegment = new ACG.PolylineBuilderEx( + segment, + ACG.AttributeFlags.HasZ, + _contextStack.Current.Document.Map.SpatialReference + ).ToGeometry(); + + double tolerance = _contextStack.Current.Document.Map.SpatialReference.XYTolerance; + double conversionFactorToMeter = _contextStack.Current.Document.Map.SpatialReference.Unit.ConversionFactor; + var densifiedPolyline = ACG.GeometryEngine.Instance.DensifyByDeviation( + polylineFromSegment, + tolerance * conversionFactorToMeter + ); + if (densifiedPolyline == null) + { + throw new ArgumentException("Segment densification failed"); + } + + ACG.Polyline polylineToConvert = (ACG.Polyline)densifiedPolyline; + // add points from each segment of the densified original segment + ACG.ReadOnlyPartCollection subParts = polylineToConvert.Parts; + foreach (ACG.ReadOnlySegmentCollection subSegments in subParts) + { + foreach (ACG.Segment? subSegment in subSegments) + { + points = AddPtsToPolylinePts( + points, + new List() + { + _pointConverter.Convert(subSegment.StartPoint), + _pointConverter.Convert(subSegment.EndPoint) + } + ); + } + } + } + else + { + points = AddPtsToPolylinePts( + points, + new List() + { + _pointConverter.Convert(segment.StartPoint), + _pointConverter.Convert(segment.EndPoint) + } + ); + } + } + SOG.Polyline polyline = + new(points.SelectMany(pt => new[] { pt.x, pt.y, pt.z }).ToList(), _contextStack.Current.SpeckleUnits) { }; + + return polyline; + } + + private List AddPtsToPolylinePts(List points, List newSegmentPts) + { + if (points.Count == 0 || points[^1] != newSegmentPts[0]) + { + points.AddRange(newSegmentPts); + } + else + { + points.AddRange(newSegmentPts.GetRange(1, newSegmentPts.Count - 1)); + } + return points; + } +} diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/PointcloudLayerToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToSpeckle/TopLevel/PointcloudLayerToSpeckleConverter.cs similarity index 97% rename from DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/PointcloudLayerToSpeckleConverter.cs rename to DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToSpeckle/TopLevel/PointcloudLayerToSpeckleConverter.cs index 6c1590aaa3..2ad672dea9 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/PointcloudLayerToSpeckleConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToSpeckle/TopLevel/PointcloudLayerToSpeckleConverter.cs @@ -1,13 +1,12 @@ -using Speckle.Converters.Common.Objects; -using Speckle.Converters.Common; -using ArcGIS.Desktop.Mapping; -using ArcGIS.Core.Data.Analyst3D; using ArcGIS.Core.CIM; -using Speckle.Converters.ArcGIS3.Geometry; -using Speckle.Core.Models; +using ArcGIS.Core.Data.Analyst3D; +using ArcGIS.Desktop.Mapping; using Speckle.Converters.ArcGIS3.Utils; +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; +using Speckle.Core.Models; -namespace Speckle.Converters.ArcGIS3.Layers; +namespace Speckle.Converters.ArcGIS3.ToSpeckle.TopLevel; [NameAndRankValue(nameof(LasDatasetLayer), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] public class PointCloudToSpeckleConverter diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/RasterLayerToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToSpeckle/TopLevel/RasterLayerToSpeckleConverter.cs similarity index 97% rename from DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/RasterLayerToSpeckleConverter.cs rename to DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToSpeckle/TopLevel/RasterLayerToSpeckleConverter.cs index 3afee5b6c3..22a93c52a9 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/RasterLayerToSpeckleConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToSpeckle/TopLevel/RasterLayerToSpeckleConverter.cs @@ -1,12 +1,12 @@ -using Speckle.Converters.Common.Objects; -using Speckle.Core.Models; +using ArcGIS.Core.Data.Raster; +using ArcGIS.Core.Geometry; using Objects.GIS; using Speckle.Converters.Common; -using ArcGIS.Core.Geometry; +using Speckle.Converters.Common.Objects; +using Speckle.Core.Models; using RasterLayer = ArcGIS.Desktop.Mapping.RasterLayer; -using ArcGIS.Core.Data.Raster; -namespace Speckle.Converters.ArcGIS3.Layers; +namespace Speckle.Converters.ArcGIS3.ToSpeckle.TopLevel; [NameAndRankValue(nameof(RasterLayer), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] public class RasterLayerToSpeckleConverter : IToSpeckleTopLevelConverter, ITypedConverter diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/TableToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToSpeckle/TopLevel/TableToSpeckleConverter.cs similarity index 97% rename from DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/TableToSpeckleConverter.cs rename to DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToSpeckle/TopLevel/TableToSpeckleConverter.cs index 110f752fc9..7649211f18 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/TableToSpeckleConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToSpeckle/TopLevel/TableToSpeckleConverter.cs @@ -1,11 +1,11 @@ -using Speckle.Converters.Common.Objects; -using Speckle.Core.Models; +using ArcGIS.Core.Data; +using ArcGIS.Desktop.Mapping; using Objects.GIS; using Speckle.Converters.Common; -using ArcGIS.Desktop.Mapping; -using ArcGIS.Core.Data; +using Speckle.Converters.Common.Objects; +using Speckle.Core.Models; -namespace Speckle.Converters.ArcGIS3.Layers; +namespace Speckle.Converters.ArcGIS3.ToSpeckle.TopLevel; [NameAndRankValue(nameof(StandaloneTable), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] public class StandaloneTableToSpeckleConverter diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/VectorLayerToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToSpeckle/TopLevel/VectorLayerToSpeckleConverter.cs similarity index 98% rename from DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/VectorLayerToSpeckleConverter.cs rename to DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToSpeckle/TopLevel/VectorLayerToSpeckleConverter.cs index 5712ecc8ee..8d2a36e33f 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/VectorLayerToSpeckleConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToSpeckle/TopLevel/VectorLayerToSpeckleConverter.cs @@ -1,14 +1,14 @@ -using Speckle.Converters.Common.Objects; -using Speckle.Core.Models; -using Objects.GIS; -using Speckle.Converters.Common; -using ArcGIS.Desktop.Mapping; +using ArcGIS.Core.CIM; using ArcGIS.Core.Data; using ArcGIS.Core.Geometry; +using ArcGIS.Desktop.Mapping; +using Objects.GIS; using Speckle.Converters.ArcGIS3.Utils; -using ArcGIS.Core.CIM; +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; +using Speckle.Core.Models; -namespace Speckle.Converters.ArcGIS3.Layers; +namespace Speckle.Converters.ArcGIS3.ToSpeckle.TopLevel; [NameAndRankValue(nameof(FeatureLayer), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] public class VectorLayerToSpeckleConverter : IToSpeckleTopLevelConverter, ITypedConverter diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GeometryExtension.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/GeometryExtension.cs similarity index 99% rename from DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GeometryExtension.cs rename to DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/GeometryExtension.cs index cd0e8bfbd0..1bc46399f2 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GeometryExtension.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/GeometryExtension.cs @@ -1,7 +1,7 @@ using ArcGIS.Core.CIM; using Speckle.Converters.Common; -namespace Speckle.Converters.ArcGIS3.Geometry; +namespace Speckle.Converters.ArcGIS3.Utils; public static class GeometryUtils { From 56496ee236e913c90475644141279df473f088a0 Mon Sep 17 00:00:00 2001 From: connorivy <43247197+connorivy@users.noreply.github.com> Date: Tue, 2 Jul 2024 14:33:06 -0500 Subject: [PATCH 256/261] DUI3-71 receive bindings and receive geometry (#3544) * Auto stash before checking out "origin/dui3/alpha" * Fix Rhino lock * fix build errors * address pr comments * address pr comments * add jira ticket comments * proper transaction disposal --------- Co-authored-by: Connor Ivy Co-authored-by: Adam Hathcock --- .../Speckle.Connectors.Revit2023.csproj | 2 +- .../Bindings/RevitReceiveBinding.cs | 82 +++++++++++ .../RevitConnectorModule.cs | 16 ++- .../Operations/Receive/ITransactionManager.cs | 13 ++ .../Receive/RevitContextAccessor.cs | 9 ++ .../Receive/RevitHostObjectBuilder.cs | 85 ++++++++++++ .../Operations/Receive/TransactionManager.cs | 124 +++++++++++++++++ .../Speckle.Connectors.RevitShared.projitems | 7 +- .../RevitConverterModule.cs | 3 +- .../IReferencePointConverter.cs | 6 +- .../ReferencePointConverter.cs | 16 ++- ...rter.cs => RevitRootToSpeckleConverter.cs} | 4 +- .../Services/ScalingServiceToHost.cs | 32 +++++ .../Speckle.Converters.RevitShared.projitems | 99 ++++++++------ .../ToHost/Raw/Geometry/ArcConverterToHost.cs | 59 ++++++++ .../Raw/Geometry/CircleConverterToHost.cs | 28 ++++ .../Raw/Geometry/CurveConverterToHost.cs | 47 +++++++ .../Raw/Geometry/EllipseConverterToHost.cs | 40 ++++++ .../Raw/Geometry/ICurveConverterToHost.cs | 129 ++++++++++++++++++ .../Raw/Geometry/LineConverterToHost.cs | 16 +++ .../Raw/Geometry/PlaneConverterToHost.cs | 27 ++++ .../Raw/Geometry/PointConverterToHost.cs | 27 ++++ .../Raw/Geometry/PolylineConverterToHost.cs | 88 ++++++++++++ .../Raw/Geometry/VectorConverterToHost.cs | 28 ++++ .../TopLevel/BaseTopLevelConverterToHost.cs | 17 +++ .../ModelCurveToSpeckleTopLevelConverter.cs | 107 +++++++++++++++ .../Raw/BeamConversionToSpeckle.cs | 0 .../Raw/BoundarySegmentConversionToSpeckle.cs | 0 .../Raw/BraceToSpeckleConverter.cs | 0 .../Raw/ColumnConversionToSpeckle.cs | 0 .../Raw/Geometry/ArcToSpeckleConverter.cs | 0 .../BoundingBoxXYZToSpeckleConverter.cs | 0 .../Raw/Geometry/CircleToSpeckleConverter.cs | 0 ...urveArrArrayToSpecklePolycurveConverter.cs | 0 .../Geometry/CurveArrayConversionToSpeckle.cs | 0 .../Raw/Geometry/CurveConversionToSpeckle.cs | 0 .../Raw/Geometry/EllipseToSpeckleConverter.cs | 0 .../HermiteSplineToSpeckleConverter.cs | 0 .../Raw/Geometry/LineConversionToSpeckle.cs | 0 .../MeshByMaterialDictionaryToSpeckle.cs | 0 .../Raw/Geometry/MeshConversionToSpeckle.cs | 0 .../Geometry/NurbsSplineToSpeckleConverter.cs | 0 .../Raw/Geometry/PlaneToSpeckleConverter.cs | 0 .../Geometry/PointCloudToSpeckleConverter.cs | 0 .../Raw/Geometry/PointConversionToSpeckle.cs | 0 .../Geometry/PolylineToSpeckleConverter.cs | 0 .../Raw/Geometry/SolidConversionToSpeckle.cs | 0 .../Raw/Geometry/VectorToSpeckleConverter.cs | 0 .../Raw/Geometry/XyzConversionToPoint.cs | 0 .../Raw/LevelConversionToSpeckle.cs | 0 .../Raw/LocationConversionToSpeckle.cs | 0 .../Raw/MaterialConversionToSpeckle.cs | 0 .../ModelCurveArrArrayToSpeckleConverter.cs | 0 .../Raw/ModelCurveArrayToSpeckleConverter.cs | 0 .../Raw/ParameterConversionToSpeckle.cs | 0 .../BaseTopLevelConverterToSpeckle.cs | 0 .../CeilingTopLevelConverterToSpeckle.cs | 0 .../DirectShapeTopLevelConverterToSpeckle.cs | 0 .../ElementTopLevelConverterToSpeckle.cs | 0 ...ExtrusionRoofToSpeckleTopLevelConverter.cs | 0 ...amilyInstanceTopLevelConverterToSpeckle.cs | 0 .../FloorTopLevelConverterToSpeckle.cs | 0 ...FootPrintRoofToSpeckleTopLevelConverter.cs | 0 .../HostedElementConversionToSpeckle.cs | 0 .../ModelCurveToSpeckleTopLevelConverter.cs | 0 ...fBaseToSpeckleTopLevelTopLevelConverter.cs | 0 .../RoomTopLevelConverterToSpeckle.cs | 0 .../TopographyTopLevelConverterToSpeckle.cs | 0 .../WallTopLevelConverterToSpeckle.cs | 0 69 files changed, 1053 insertions(+), 58 deletions(-) create mode 100644 DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/RevitReceiveBinding.cs create mode 100644 DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Receive/ITransactionManager.cs create mode 100644 DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Receive/RevitContextAccessor.cs create mode 100644 DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Receive/RevitHostObjectBuilder.cs create mode 100644 DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Receive/TransactionManager.cs rename DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/{RevitRootToHostConverter.cs => RevitRootToSpeckleConverter.cs} (93%) create mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Services/ScalingServiceToHost.cs create mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToHost/Raw/Geometry/ArcConverterToHost.cs create mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToHost/Raw/Geometry/CircleConverterToHost.cs create mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToHost/Raw/Geometry/CurveConverterToHost.cs create mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToHost/Raw/Geometry/EllipseConverterToHost.cs create mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToHost/Raw/Geometry/ICurveConverterToHost.cs create mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToHost/Raw/Geometry/LineConverterToHost.cs create mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToHost/Raw/Geometry/PlaneConverterToHost.cs create mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToHost/Raw/Geometry/PointConverterToHost.cs create mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToHost/Raw/Geometry/PolylineConverterToHost.cs create mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToHost/Raw/Geometry/VectorConverterToHost.cs create mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToHost/TopLevel/BaseTopLevelConverterToHost.cs create mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToHost/TopLevel/ModelCurveToSpeckleTopLevelConverter.cs rename DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/{ => ToSpeckle}/Raw/BeamConversionToSpeckle.cs (100%) rename DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/{ => ToSpeckle}/Raw/BoundarySegmentConversionToSpeckle.cs (100%) rename DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/{ => ToSpeckle}/Raw/BraceToSpeckleConverter.cs (100%) rename DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/{ => ToSpeckle}/Raw/ColumnConversionToSpeckle.cs (100%) rename DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/{ => ToSpeckle}/Raw/Geometry/ArcToSpeckleConverter.cs (100%) rename DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/{ => ToSpeckle}/Raw/Geometry/BoundingBoxXYZToSpeckleConverter.cs (100%) rename DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/{ => ToSpeckle}/Raw/Geometry/CircleToSpeckleConverter.cs (100%) rename DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/{ => ToSpeckle}/Raw/Geometry/CurveArrArrayToSpecklePolycurveConverter.cs (100%) rename DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/{ => ToSpeckle}/Raw/Geometry/CurveArrayConversionToSpeckle.cs (100%) rename DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/{ => ToSpeckle}/Raw/Geometry/CurveConversionToSpeckle.cs (100%) rename DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/{ => ToSpeckle}/Raw/Geometry/EllipseToSpeckleConverter.cs (100%) rename DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/{ => ToSpeckle}/Raw/Geometry/HermiteSplineToSpeckleConverter.cs (100%) rename DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/{ => ToSpeckle}/Raw/Geometry/LineConversionToSpeckle.cs (100%) rename DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/{ => ToSpeckle}/Raw/Geometry/MeshByMaterialDictionaryToSpeckle.cs (100%) rename DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/{ => ToSpeckle}/Raw/Geometry/MeshConversionToSpeckle.cs (100%) rename DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/{ => ToSpeckle}/Raw/Geometry/NurbsSplineToSpeckleConverter.cs (100%) rename DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/{ => ToSpeckle}/Raw/Geometry/PlaneToSpeckleConverter.cs (100%) rename DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/{ => ToSpeckle}/Raw/Geometry/PointCloudToSpeckleConverter.cs (100%) rename DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/{ => ToSpeckle}/Raw/Geometry/PointConversionToSpeckle.cs (100%) rename DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/{ => ToSpeckle}/Raw/Geometry/PolylineToSpeckleConverter.cs (100%) rename DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/{ => ToSpeckle}/Raw/Geometry/SolidConversionToSpeckle.cs (100%) rename DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/{ => ToSpeckle}/Raw/Geometry/VectorToSpeckleConverter.cs (100%) rename DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/{ => ToSpeckle}/Raw/Geometry/XyzConversionToPoint.cs (100%) rename DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/{ => ToSpeckle}/Raw/LevelConversionToSpeckle.cs (100%) rename DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/{ => ToSpeckle}/Raw/LocationConversionToSpeckle.cs (100%) rename DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/{ => ToSpeckle}/Raw/MaterialConversionToSpeckle.cs (100%) rename DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/{ => ToSpeckle}/Raw/ModelCurveArrArrayToSpeckleConverter.cs (100%) rename DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/{ => ToSpeckle}/Raw/ModelCurveArrayToSpeckleConverter.cs (100%) rename DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/{ => ToSpeckle}/Raw/ParameterConversionToSpeckle.cs (100%) rename DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/{ => TopLevel}/BaseTopLevelConverterToSpeckle.cs (100%) rename DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/{ => TopLevel}/CeilingTopLevelConverterToSpeckle.cs (100%) rename DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/{ => TopLevel}/DirectShapeTopLevelConverterToSpeckle.cs (100%) rename DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/{ => TopLevel}/ElementTopLevelConverterToSpeckle.cs (100%) rename DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/{ => TopLevel}/ExtrusionRoofToSpeckleTopLevelConverter.cs (100%) rename DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/{ => TopLevel}/FamilyInstanceTopLevelConverterToSpeckle.cs (100%) rename DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/{ => TopLevel}/FloorTopLevelConverterToSpeckle.cs (100%) rename DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/{ => TopLevel}/FootPrintRoofToSpeckleTopLevelConverter.cs (100%) rename DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/{ => TopLevel}/HostedElementConversionToSpeckle.cs (100%) rename DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/{ => TopLevel}/ModelCurveToSpeckleTopLevelConverter.cs (100%) rename DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/{ => TopLevel}/RoofBaseToSpeckleTopLevelTopLevelConverter.cs (100%) rename DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/{ => TopLevel}/RoomTopLevelConverterToSpeckle.cs (100%) rename DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/{ => TopLevel}/TopographyTopLevelConverterToSpeckle.cs (100%) rename DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/{ => TopLevel}/WallTopLevelConverterToSpeckle.cs (100%) diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.Revit2023/Speckle.Connectors.Revit2023.csproj b/DUI3-DX/Connectors/Revit/Speckle.Connectors.Revit2023/Speckle.Connectors.Revit2023.csproj index 1ce038c81e..3cf6edeb8c 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.Revit2023/Speckle.Connectors.Revit2023.csproj +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.Revit2023/Speckle.Connectors.Revit2023.csproj @@ -30,7 +30,7 @@ - + diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/RevitReceiveBinding.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/RevitReceiveBinding.cs new file mode 100644 index 0000000000..77119f01a0 --- /dev/null +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/RevitReceiveBinding.cs @@ -0,0 +1,82 @@ +using Speckle.Connectors.DUI.Bindings; +using Speckle.Connectors.DUI.Bridge; +using Speckle.Connectors.DUI.Models.Card; +using Speckle.Connectors.DUI.Models; +using Speckle.Connectors.Utils.Builders; +using Speckle.Connectors.Utils.Cancellation; +using Speckle.Connectors.Utils.Operations; +using Speckle.Autofac.DependencyInjection; +using Speckle.Connectors.Utils; + +namespace Speckle.Connectors.Revit.Bindings; + +internal class RevitReceiveBinding : IReceiveBinding +{ + public string Name => "receiveBinding"; + public IBridge Parent { get; } + + private readonly CancellationManager _cancellationManager; + private readonly DocumentModelStore _store; + private readonly IUnitOfWorkFactory _unitOfWorkFactory; + public ReceiveBindingUICommands Commands { get; } + + public RevitReceiveBinding( + DocumentModelStore store, + CancellationManager cancellationManager, + IBridge parent, + IUnitOfWorkFactory unitOfWorkFactory + ) + { + Parent = parent; + _store = store; + _unitOfWorkFactory = unitOfWorkFactory; + _cancellationManager = cancellationManager; + Commands = new ReceiveBindingUICommands(parent); + } + + public void CancelReceive(string modelCardId) => _cancellationManager.CancelOperation(modelCardId); + + public async Task Receive(string modelCardId) + { + using var unitOfWork = _unitOfWorkFactory.Resolve(); + try + { + // Get receiver card + if (_store.GetModelById(modelCardId) is not ReceiverModelCard modelCard) + { + // Handle as GLOBAL ERROR at BrowserBridge + throw new InvalidOperationException("No download model card was found."); + } + + // Init cancellation token source -> Manager also cancel it if exist before + CancellationTokenSource cts = _cancellationManager.InitCancellationTokenSource(modelCardId); + + // Receive host objects + HostObjectBuilderResult conversionResults = await unitOfWork.Service + .Execute( + modelCard.AccountId.NotNull(), // POC: I hear -you are saying why we're passing them separately. Not sure pass the DUI3-> Connectors.DUI project dependency to the SDK-> Connector.Utils + modelCard.ProjectId.NotNull(), + modelCard.ProjectName.NotNull(), + modelCard.ModelName.NotNull(), + modelCard.SelectedVersionId.NotNull(), + cts.Token, + (status, progress) => + Commands.SetModelProgress(modelCardId, new ModelCardProgress(modelCardId, status, progress), cts) + ) + .ConfigureAwait(false); + + modelCard.BakedObjectIds = conversionResults.BakedObjectIds.ToList(); + Commands.SetModelReceiveResult( + modelCardId, + conversionResults.BakedObjectIds, + conversionResults.ConversionResults + ); + } + // Catch here specific exceptions if they related to model card. + catch (OperationCanceledException) + { + // SWALLOW -> UI handles it immediately, so we do not need to handle anything + return; + } + } +} diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/RevitConnectorModule.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/RevitConnectorModule.cs index ec1bcb5566..7ec943cde0 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/RevitConnectorModule.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/RevitConnectorModule.cs @@ -4,16 +4,17 @@ using Speckle.Autofac.DependencyInjection; using Speckle.Connectors.DUI; using Speckle.Connectors.DUI.Bindings; -using Speckle.Connectors.DUI.Bridge; using Speckle.Connectors.DUI.Models; using Speckle.Connectors.Revit.Bindings; using Speckle.Connectors.Revit.HostApp; +using Speckle.Connectors.Revit.Operations.Receive; using Speckle.Connectors.Revit.Operations.Send; using Speckle.Connectors.Revit.Plugin; using Speckle.Connectors.Utils; using Speckle.Connectors.Utils.Builders; using Speckle.Connectors.Utils.Caching; using Speckle.Connectors.Utils.Operations; +using Speckle.Core.Models.GraphTraversal; namespace Speckle.Connectors.Revit.DependencyInjection; @@ -27,7 +28,7 @@ public void Load(SpeckleContainerBuilder builder) builder.AddDUI(); //builder.AddDUIView(); - builder.AddSingletonInstance(); + builder.AddSingletonInstance(); // POC: different versons for different versions of CEF builder.AddSingleton(BindingOptions.DefaultBinder); @@ -49,20 +50,23 @@ public void Load(SpeckleContainerBuilder builder) // and where the UoW should be // register UI bindings builder.AddSingleton(); - builder.AddSingleton("connectorName", "ArcGIS"); // POC: Easier like this for now, should be cleaned up later + builder.AddSingleton("connectorName", "Revit"); // POC: Easier like this for now, should be cleaned up later builder.AddSingleton(); builder.AddSingleton(); builder.AddSingleton(); builder.AddSingleton(); builder.AddSingleton(); - //no receive? + builder.AddSingleton(); builder.AddSingleton(); // send operation and dependencies builder.AddScoped>(); builder.AddScoped, RevitRootObjectBuilder>(); - - // register send conversion cache builder.AddSingleton(); + + // receive operation and dependencies + builder.AddScoped(); + builder.AddScoped(); + builder.AddSingleton(DefaultTraversal.CreateTraversalFunc()); } } diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Receive/ITransactionManager.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Receive/ITransactionManager.cs new file mode 100644 index 0000000000..d698dfac0f --- /dev/null +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Receive/ITransactionManager.cs @@ -0,0 +1,13 @@ +using Autodesk.Revit.DB; + +namespace Speckle.Connectors.Revit.Operations.Receive; + +public interface ITransactionManager : IDisposable +{ + TransactionStatus CommitSubtransaction(); + TransactionStatus CommitTransaction(); + void RollbackSubTransaction(); + void RollbackTransaction(); + void StartSubtransaction(); + void StartTransaction(); +} diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Receive/RevitContextAccessor.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Receive/RevitContextAccessor.cs new file mode 100644 index 0000000000..d90ce9076b --- /dev/null +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Receive/RevitContextAccessor.cs @@ -0,0 +1,9 @@ +using Revit.Async; +using Speckle.Connectors.Utils.Operations; + +namespace Speckle.Connectors.Revit.Operations.Receive; + +internal class RevitContextAccessor : ISyncToThread +{ + public Task RunOnThread(Func func) => RevitTask.RunAsync(func); +} diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Receive/RevitHostObjectBuilder.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Receive/RevitHostObjectBuilder.cs new file mode 100644 index 0000000000..245284543d --- /dev/null +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Receive/RevitHostObjectBuilder.cs @@ -0,0 +1,85 @@ +using Speckle.Connectors.Utils.Builders; +using Speckle.Connectors.Utils.Conversion; +using Speckle.Converters.Common; +using Speckle.Core.Logging; +using Speckle.Core.Models.GraphTraversal; +using Speckle.Core.Models; +using Speckle.Converters.RevitShared.Helpers; +using Autodesk.Revit.DB; + +namespace Speckle.Connectors.Revit.Operations.Receive; + +/// +/// Potentially consolidate all application specific IHostObjectBuilders +/// https://spockle.atlassian.net/browse/DUI3-465 +/// +internal class RevitHostObjectBuilder : IHostObjectBuilder, IDisposable +{ + private readonly IRootToHostConverter _converter; + private readonly IRevitConversionContextStack _contextStack; + private readonly GraphTraversal _traverseFunction; + private readonly ITransactionManager _transactionManager; + + public RevitHostObjectBuilder( + IRootToHostConverter converter, + IRevitConversionContextStack contextStack, + GraphTraversal traverseFunction, + ITransactionManager transactionManager + ) + { + _converter = converter; + _contextStack = contextStack; + _traverseFunction = traverseFunction; + _transactionManager = transactionManager; + } + + public HostObjectBuilderResult Build( + Base rootObject, + string projectName, + string modelName, + Action? onOperationProgressed, + CancellationToken cancellationToken + ) + { + var objectsToConvert = _traverseFunction + .TraverseWithProgress(rootObject, onOperationProgressed, cancellationToken) + .Where(obj => obj.Current is not Collection); + + using TransactionGroup transactionGroup = new(_contextStack.Current.Document, $"Received data from {projectName}"); + transactionGroup.Start(); + _transactionManager.StartTransaction(); + + var conversionResults = BakeObjects(objectsToConvert); + + _transactionManager.CommitTransaction(); + transactionGroup.Assimilate(); + + return conversionResults; + } + + // POC: Potentially refactor out into an IObjectBaker. + private HostObjectBuilderResult BakeObjects(IEnumerable objectsGraph) + { + var conversionResults = new List(); + var bakedObjectIds = new List(); + + foreach (TraversalContext tc in objectsGraph) + { + try + { + var result = _converter.Convert(tc.Current); + } + catch (Exception ex) when (!ex.IsFatal()) + { + conversionResults.Add(new(Status.ERROR, tc.Current, null, null, ex)); + } + } + + return new(bakedObjectIds, conversionResults); + } + + public void Dispose() + { + _transactionManager?.Dispose(); + } +} diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Receive/TransactionManager.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Receive/TransactionManager.cs new file mode 100644 index 0000000000..aa2ec3153a --- /dev/null +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Receive/TransactionManager.cs @@ -0,0 +1,124 @@ +using Autodesk.Revit.DB; +using Speckle.Converters.RevitShared.Helpers; + +namespace Speckle.Connectors.Revit.Operations.Receive; + +/// +/// Is responsible for all functionality regarding subtransactions, transactions, and transaction groups. +/// This includes starting, pausing, committing, and rolling back transactions +/// +public sealed class TransactionManager : ITransactionManager +{ + private readonly IRevitConversionContextStack _contextStack; + private Document Document => _contextStack.Current.Document; + + public TransactionManager(IRevitConversionContextStack contextStack) + { + _contextStack = contextStack; + } + + // poc : these are being disposed. I'm not sure why I need to supress this warning +#pragma warning disable CA2213 // Disposable fields should be disposed + private Transaction? _transaction; + private SubTransaction? _subTransaction; +#pragma warning restore CA2213 // Disposable fields should be disposed + + public void StartTransaction() + { + if (_transaction == null || !_transaction.IsValidObject || _transaction.GetStatus() != TransactionStatus.Started) + { + _transaction = new Transaction(Document, "Speckle Transaction"); + var failOpts = _transaction.GetFailureHandlingOptions(); + // POC: make sure to implement and add the failure preprocessor + // https://spockle.atlassian.net/browse/DUI3-461 + //failOpts.SetFailuresPreprocessor(_errorPreprocessingService); + failOpts.SetClearAfterRollback(true); + _transaction.SetFailureHandlingOptions(failOpts); + _transaction.Start(); + } + } + + public TransactionStatus CommitTransaction() + { + if ( + _subTransaction != null + && _subTransaction.IsValidObject + && _subTransaction.GetStatus() == TransactionStatus.Started + ) + { + var status = _subTransaction.Commit(); + if (status != TransactionStatus.Committed) + { + // POC: handle failed commit + //HandleFailedCommit(status); + } + } + if (_transaction != null && _transaction.IsValidObject && _transaction.GetStatus() == TransactionStatus.Started) + { + var status = _transaction.Commit(); + if (status != TransactionStatus.Committed) + { + // POC: handle failed commit + //HandleFailedCommit(status); + } + return status; + } + return TransactionStatus.Uninitialized; + } + + public void RollbackTransaction() + { + RollbackSubTransaction(); + if (_transaction != null && _transaction.IsValidObject && _transaction.GetStatus() == TransactionStatus.Started) + { + _transaction.RollBack(); + } + } + + public void StartSubtransaction() + { + StartTransaction(); + if ( + _subTransaction == null + || !_subTransaction.IsValidObject + || _subTransaction.GetStatus() != TransactionStatus.Started + ) + { + _subTransaction = new SubTransaction(Document); + _subTransaction.Start(); + } + } + + public TransactionStatus CommitSubtransaction() + { + if (_subTransaction != null && _subTransaction.IsValidObject) + { + var status = _subTransaction.Commit(); + if (status != TransactionStatus.Committed) + { + // POC: handle failed commit + //HandleFailedCommit(status); + } + return status; + } + return TransactionStatus.Uninitialized; + } + + public void RollbackSubTransaction() + { + if ( + _subTransaction != null + && _subTransaction.IsValidObject + && _subTransaction.GetStatus() == TransactionStatus.Started + ) + { + _subTransaction.RollBack(); + } + } + + public void Dispose() + { + _subTransaction?.Dispose(); + _transaction?.Dispose(); + } +} diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Speckle.Connectors.RevitShared.projitems b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Speckle.Connectors.RevitShared.projitems index 8a671aefc9..1abd960016 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Speckle.Connectors.RevitShared.projitems +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Speckle.Connectors.RevitShared.projitems @@ -1,4 +1,4 @@ - + $(MSBuildAllProjects);$(MSBuildThisFileFullPath) @@ -19,6 +19,7 @@ + @@ -27,6 +28,10 @@ + + + + CefSharpPanel.xaml diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/RevitConverterModule.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/RevitConverterModule.cs index 60c5050217..f5211019ae 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/RevitConverterModule.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/RevitConverterModule.cs @@ -12,11 +12,12 @@ public class RevitConverterModule : ISpeckleModule { public void Load(SpeckleContainerBuilder builder) { - builder.AddConverterCommon(); + builder.AddConverterCommon(); builder.AddSingleton(new RevitContext()); // POC: do we need ToSpeckleScalingService as is, do we need to interface it out? builder.AddScoped(); + builder.AddScoped(); // POC: the concrete type can come out if we remove all the reference to it builder.AddScoped(); diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/IReferencePointConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/IReferencePointConverter.cs index f526412336..601ab31128 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/IReferencePointConverter.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/IReferencePointConverter.cs @@ -1,6 +1,8 @@ -namespace Speckle.Converters.RevitShared; +namespace Speckle.Converters.RevitShared; public interface IReferencePointConverter { - DB.XYZ ConvertToExternalCoordindates(DB.XYZ inbound, bool isPoint); + DB.XYZ ConvertToExternalCoordindates(DB.XYZ p, bool isPoint); + + DB.XYZ ToInternalCoordinates(DB.XYZ p, bool isPoint); } diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ReferencePointConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ReferencePointConverter.cs index 4704184be6..1cf1394bb0 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ReferencePointConverter.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ReferencePointConverter.cs @@ -1,4 +1,5 @@ using System.Diagnostics.CodeAnalysis; +using Autodesk.Revit.DB; using Speckle.Converters.RevitShared.Helpers; namespace Speckle.Converters.RevitShared; @@ -28,10 +29,21 @@ public ReferencePointConverter(IRevitConversionContextStack contextStack, RevitC // POC: the original allowed for the document to be passed in // if required, we would probably need to push the stack with a new document if the // doc can change during the lifeycycle of the conversions. This may need some looking into - public DB.XYZ ConvertToExternalCoordindates(DB.XYZ inbound, bool isPoint) + public DB.XYZ ConvertToExternalCoordindates(DB.XYZ p, bool isPoint) { var rpt = GetDocReferencePointTransform(_contextStack.Current.Document); - return isPoint ? rpt.OfPoint(inbound) : rpt.OfVector(inbound); + return (isPoint) ? rpt.Inverse.OfPoint(p) : rpt.Inverse.OfVector(p); + } + + /// + /// For importing in Revit, moves and rotates a point according to this document BasePoint + /// + /// + /// + public XYZ ToInternalCoordinates(XYZ p, bool isPoint) + { + var rpt = GetDocReferencePointTransform(_contextStack.Current.Document); + return (isPoint) ? rpt.OfPoint(p) : rpt.OfVector(p); } // POC: this might be better in some RevitDocumentService diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/RevitRootToHostConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/RevitRootToSpeckleConverter.cs similarity index 93% rename from DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/RevitRootToHostConverter.cs rename to DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/RevitRootToSpeckleConverter.cs index 78790ee19e..28336c4eb3 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/RevitRootToHostConverter.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/RevitRootToSpeckleConverter.cs @@ -6,12 +6,12 @@ namespace Speckle.Converters.RevitShared; // POC: maybe possible to restrict the access so this cannot be created directly? -public class RevitRootToHostConverter : IRootToSpeckleConverter +public class RevitRootToSpeckleConverter : IRootToSpeckleConverter { private readonly IConverterResolver _toSpeckle; private readonly ParameterValueExtractor _parameterValueExtractor; - public RevitRootToHostConverter( + public RevitRootToSpeckleConverter( IConverterResolver toSpeckle, ParameterValueExtractor parameterValueExtractor ) diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Services/ScalingServiceToHost.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Services/ScalingServiceToHost.cs new file mode 100644 index 0000000000..bf6e956279 --- /dev/null +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Services/ScalingServiceToHost.cs @@ -0,0 +1,32 @@ +using Autodesk.Revit.DB; +using Speckle.Converters.Common; + +namespace Speckle.Converters.RevitShared.Services; + +public sealed class ScalingServiceToHost +{ + public double ScaleToNative(double value, string units) + { + if (string.IsNullOrEmpty(units)) + { + return value; + } + + return UnitUtils.ConvertToInternalUnits(value, UnitsToNative(units)); + } + + public ForgeTypeId UnitsToNative(string units) + { + var u = Core.Kits.Units.GetUnitsFromString(units); + + return u switch + { + Core.Kits.Units.Millimeters => UnitTypeId.Millimeters, + Core.Kits.Units.Centimeters => UnitTypeId.Centimeters, + Core.Kits.Units.Meters => UnitTypeId.Meters, + Core.Kits.Units.Inches => UnitTypeId.Inches, + Core.Kits.Units.Feet => UnitTypeId.Feet, + _ => throw new SpeckleConversionException($"The Unit System \"{units}\" is unsupported."), + }; + } +} diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Speckle.Converters.RevitShared.projitems b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Speckle.Converters.RevitShared.projitems index 5e5d29480e..dce4c4898e 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Speckle.Converters.RevitShared.projitems +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Speckle.Converters.RevitShared.projitems @@ -21,47 +21,64 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -69,12 +86,8 @@ - - - - - + \ No newline at end of file diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToHost/Raw/Geometry/ArcConverterToHost.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToHost/Raw/Geometry/ArcConverterToHost.cs new file mode 100644 index 0000000000..6e9167c7eb --- /dev/null +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToHost/Raw/Geometry/ArcConverterToHost.cs @@ -0,0 +1,59 @@ +using Speckle.Converters.Common.Objects; +using Speckle.Converters.RevitShared.Services; +using Speckle.Core.Common; + +namespace Speckle.Converters.RevitShared.ToHost.Raw.Geometry; + +public class ArcConverterToHost : ITypedConverter +{ + private readonly ScalingServiceToHost _scalingService; + private readonly ITypedConverter _pointToXyzConverter; + private readonly ITypedConverter _planeConverter; + + public ArcConverterToHost( + ITypedConverter pointToXyzConverter, + ScalingServiceToHost scalingService, + ITypedConverter planeConverter + ) + { + _pointToXyzConverter = pointToXyzConverter; + _scalingService = scalingService; + _planeConverter = planeConverter; + } + + public DB.Arc Convert(SOG.Arc target) + { + double startAngle; + double endAngle; + + if (target.startAngle > target.endAngle) + { + startAngle = (double)target.endAngle; + endAngle = (double)target.startAngle; + } + else + { + startAngle = (double)target.startAngle.NotNull(); + endAngle = (double)target.endAngle.NotNull(); + } + + var plane = _planeConverter.Convert(target.plane); + + if (SOG.Point.Distance(target.startPoint, target.endPoint) < 1E-6) + { + // Endpoints coincide, it's a circle. + return DB.Arc.Create( + plane, + _scalingService.ScaleToNative(target.radius ?? 0, target.units), + startAngle, + endAngle + ); + } + + return DB.Arc.Create( + _pointToXyzConverter.Convert(target.startPoint), + _pointToXyzConverter.Convert(target.endPoint), + _pointToXyzConverter.Convert(target.midPoint) + ); + } +} diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToHost/Raw/Geometry/CircleConverterToHost.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToHost/Raw/Geometry/CircleConverterToHost.cs new file mode 100644 index 0000000000..55ba5f1974 --- /dev/null +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToHost/Raw/Geometry/CircleConverterToHost.cs @@ -0,0 +1,28 @@ +using Speckle.Converters.Common.Objects; +using Speckle.Converters.RevitShared.Services; +using Speckle.Core.Common; + +namespace Speckle.Converters.RevitShared.ToHost.Raw.Geometry; + +public class CircleConverterToHost : ITypedConverter +{ + private readonly ScalingServiceToHost _scalingService; + private readonly ITypedConverter _planeConverter; + + public CircleConverterToHost(ScalingServiceToHost scalingService, ITypedConverter planeConverter) + { + _scalingService = scalingService; + _planeConverter = planeConverter; + } + + public DB.Arc Convert(SOG.Circle target) + { + var plane = _planeConverter.Convert(target.plane); + return DB.Arc.Create( + plane, + _scalingService.ScaleToNative((double)target.radius.NotNull(), target.units), + 0, + 2 * Math.PI + ); + } +} diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToHost/Raw/Geometry/CurveConverterToHost.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToHost/Raw/Geometry/CurveConverterToHost.cs new file mode 100644 index 0000000000..5f1f40f603 --- /dev/null +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToHost/Raw/Geometry/CurveConverterToHost.cs @@ -0,0 +1,47 @@ +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; + +namespace Speckle.Converters.RevitShared.ToSpeckle; + +public class CurveConverterToHost : ITypedConverter +{ + private readonly ITypedConverter _pointConverter; + + public CurveConverterToHost(ITypedConverter pointConverter) + { + _pointConverter = pointConverter; + } + + public DB.Curve Convert(SOG.Curve target) + { + var pts = new List(); + for (int i = 0; i < target.points.Count; i += 3) + { + //use PointToNative for conversion as that takes into account the Project Base Point + var point = new SOG.Point(target.points[i], target.points[i + 1], target.points[i + 2], target.units); + pts.Add(_pointConverter.Convert(point)); + } + + if (target.knots != null && target.weights != null && target.knots.Count > 0 && target.weights.Count > 0) + { + var weights = target.weights.GetRange(0, pts.Count); + var speckleKnots = new List(target.knots); + if (speckleKnots.Count != pts.Count + target.degree + 1) + { + // Curve has rhino knots, repeat first and last. + speckleKnots.Insert(0, speckleKnots[0]); + speckleKnots.Add(speckleKnots[^1]); + } + + //var knots = speckleKnots.GetRange(0, pts.Count + speckleCurve.degree + 1); + var curve = DB.NurbSpline.CreateCurve(target.degree, speckleKnots, pts, weights); + return curve; + } + else + { + var weights = target.weights.NotNull().GetRange(0, pts.Count); + var curve = DB.NurbSpline.CreateCurve(pts, weights); + return curve; + } + } +} diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToHost/Raw/Geometry/EllipseConverterToHost.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToHost/Raw/Geometry/EllipseConverterToHost.cs new file mode 100644 index 0000000000..f2c86ef7c8 --- /dev/null +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToHost/Raw/Geometry/EllipseConverterToHost.cs @@ -0,0 +1,40 @@ +using Speckle.Converters.Common.Objects; +using Speckle.Converters.RevitShared.Services; +using Speckle.Core.Common; + +namespace Speckle.Converters.RevitShared.ToHost.Raw.Geometry; + +public class EllipseConverterToHost : ITypedConverter +{ + private readonly ScalingServiceToHost _scalingService; + private readonly ITypedConverter _pointToXyzConverter; + private readonly ITypedConverter _planeConverter; + + public EllipseConverterToHost( + ITypedConverter pointToXyzConverter, + ScalingServiceToHost scalingService, + ITypedConverter planeConverter + ) + { + _pointToXyzConverter = pointToXyzConverter; + _scalingService = scalingService; + _planeConverter = planeConverter; + } + + public DB.Curve Convert(SOG.Ellipse target) + { + using DB.Plane basePlane = _planeConverter.Convert(target.plane); + + var e = DB.Ellipse.CreateCurve( + _pointToXyzConverter.Convert(target.plane.origin), + _scalingService.ScaleToNative((double)target.firstRadius.NotNull(), target.units), + _scalingService.ScaleToNative((double)target.secondRadius.NotNull(), target.units), + basePlane.XVec.Normalize(), + basePlane.YVec.Normalize(), + 0, + 2 * Math.PI + ); + e.MakeBound(target.trimDomain?.start ?? 0, target.trimDomain?.end ?? 2 * Math.PI); + return e; + } +} diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToHost/Raw/Geometry/ICurveConverterToHost.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToHost/Raw/Geometry/ICurveConverterToHost.cs new file mode 100644 index 0000000000..2b3eedcb15 --- /dev/null +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToHost/Raw/Geometry/ICurveConverterToHost.cs @@ -0,0 +1,129 @@ +using Objects; +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; + +namespace Speckle.Converters.RevitShared.ToSpeckle; + +public class ICurveConverterToHost : ITypedConverter +{ + private readonly ITypedConverter _pointConverter; + private readonly ITypedConverter _vectorConverter; + private readonly ITypedConverter _arcConverter; + private readonly ITypedConverter _lineConverter; + private readonly ITypedConverter _circleConverter; + private readonly ITypedConverter _ellipseConverter; + private readonly ITypedConverter _polylineConverter; + private readonly ITypedConverter _curveConverter; + + public ICurveConverterToHost( + ITypedConverter pointConverter, + ITypedConverter vectorConverter, + ITypedConverter arcConverter, + ITypedConverter lineConverter, + ITypedConverter circleConverter, + ITypedConverter ellipseConverter, + ITypedConverter polylineConverter, + ITypedConverter curveConverter + ) + { + _pointConverter = pointConverter; + _vectorConverter = vectorConverter; + _arcConverter = arcConverter; + _lineConverter = lineConverter; + _circleConverter = circleConverter; + _ellipseConverter = ellipseConverter; + _polylineConverter = polylineConverter; + _curveConverter = curveConverter; + } + + public DB.CurveArray Convert(ICurve target) + { + DB.CurveArray curveArray = new(); + switch (target) + { + case SOG.Line line: + curveArray.Append(_lineConverter.Convert(line)); + return curveArray; + + case SOG.Arc arc: + curveArray.Append(_arcConverter.Convert(arc)); + return curveArray; + + case SOG.Circle circle: + curveArray.Append(_circleConverter.Convert(circle)); + return curveArray; + + case SOG.Ellipse ellipse: + curveArray.Append(_ellipseConverter.Convert(ellipse)); + return curveArray; + + case SOG.Spiral spiral: + return _polylineConverter.Convert(spiral.displayValue); + + case SOG.Curve nurbs: + var n = _curveConverter.Convert(nurbs); + + // poc : in original converter, we were passing a bool into this method 'splitIfClosed'. + // https://spockle.atlassian.net/browse/DUI3-462 + // I'm not entirely sure why we need to split curves, but there are several occurances + // of the method being called and overriding the bool to be true. + + //if (IsCurveClosed(n) && splitIfClosed) + //{ + // var split = SplitCurveInTwoHalves(n); + // curveArray.Append(split.Item1); + // curveArray.Append(split.Item2); + //} + //else + //{ + // curveArray.Append(n); + //} + curveArray.Append(n); + return curveArray; + + case SOG.Polyline poly: + return _polylineConverter.Convert(poly); + + case SOG.Polycurve plc: + foreach (var seg in plc.segments) + { + // Enumerate all curves in the array to ensure polylines get fully converted. + using var subCurves = Convert(seg); + var crvEnumerator = subCurves.GetEnumerator(); + while (crvEnumerator.MoveNext() && crvEnumerator.Current != null) + { + curveArray.Append(crvEnumerator.Current as DB.Curve); + } + } + return curveArray; + default: + throw new SpeckleConversionException($"The provided geometry of type {target.GetType()} is not a supported"); + } + } + + public bool IsCurveClosed(DB.Curve nativeCurve, double tol = 1E-6) + { + var endPoint = nativeCurve.GetEndPoint(0); + var source = nativeCurve.GetEndPoint(1); + var distanceTo = endPoint.DistanceTo(source); + return distanceTo < tol; + } + + public (DB.Curve, DB.Curve) SplitCurveInTwoHalves(DB.Curve nativeCurve) + { + using var curveArray = new DB.CurveArray(); + // Revit does not like single curve loop edges, so we split them in two. + var start = nativeCurve.GetEndParameter(0); + var end = nativeCurve.GetEndParameter(1); + var mid = start + ((end - start) / 2); + + var a = nativeCurve.Clone(); + a.MakeBound(start, mid); + curveArray.Append(a); + var b = nativeCurve.Clone(); + b.MakeBound(mid, end); + curveArray.Append(b); + + return (a, b); + } +} diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToHost/Raw/Geometry/LineConverterToHost.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToHost/Raw/Geometry/LineConverterToHost.cs new file mode 100644 index 0000000000..de8237e3ce --- /dev/null +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToHost/Raw/Geometry/LineConverterToHost.cs @@ -0,0 +1,16 @@ +using Speckle.Converters.Common.Objects; + +namespace Speckle.Converters.RevitShared.ToSpeckle; + +public class LineConverterToHost : ITypedConverter +{ + private readonly ITypedConverter _pointToXyzConverter; + + public LineConverterToHost(ITypedConverter pointToXyzConverter) + { + _pointToXyzConverter = pointToXyzConverter; + } + + public DB.Line Convert(SOG.Line target) => + DB.Line.CreateBound(_pointToXyzConverter.Convert(target.start), _pointToXyzConverter.Convert(target.end)); +} diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToHost/Raw/Geometry/PlaneConverterToHost.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToHost/Raw/Geometry/PlaneConverterToHost.cs new file mode 100644 index 0000000000..c789aba066 --- /dev/null +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToHost/Raw/Geometry/PlaneConverterToHost.cs @@ -0,0 +1,27 @@ +using Autodesk.Revit.DB; +using Objects.Geometry; +using Speckle.Converters.Common.Objects; + +namespace Speckle.Converters.RevitShared.ToSpeckle; + +public class PlaneConverterToHost : ITypedConverter +{ + private readonly ITypedConverter _pointConverter; + private readonly ITypedConverter _vectorConverter; + + public PlaneConverterToHost( + ITypedConverter pointConverter, + ITypedConverter vectorConverter + ) + { + _pointConverter = pointConverter; + _vectorConverter = vectorConverter; + } + + public DB.Plane Convert(SOG.Plane target) => + DB.Plane.CreateByOriginAndBasis( + _pointConverter.Convert(target.origin), + _vectorConverter.Convert(target.xdir).Normalize(), + _vectorConverter.Convert(target.ydir).Normalize() + ); +} diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToHost/Raw/Geometry/PointConverterToHost.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToHost/Raw/Geometry/PointConverterToHost.cs new file mode 100644 index 0000000000..66b8b5488b --- /dev/null +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToHost/Raw/Geometry/PointConverterToHost.cs @@ -0,0 +1,27 @@ +using Autodesk.Revit.DB; +using Speckle.Converters.Common.Objects; +using Speckle.Converters.RevitShared.Services; + +namespace Speckle.Converters.RevitShared.ToSpeckle; + +public class PointConverterToHost : ITypedConverter +{ + private readonly ScalingServiceToHost _scalingService; + private readonly IReferencePointConverter _referencePointConverter; + + public PointConverterToHost(ScalingServiceToHost scalingService, IReferencePointConverter referencePointConverter) + { + _scalingService = scalingService; + _referencePointConverter = referencePointConverter; + } + + public XYZ Convert(SOG.Point target) + { + var revitPoint = new XYZ( + _scalingService.ScaleToNative(target.x, target.units), + _scalingService.ScaleToNative(target.y, target.units), + _scalingService.ScaleToNative(target.z, target.units) + ); + return _referencePointConverter.ToInternalCoordinates(revitPoint, true); + } +} diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToHost/Raw/Geometry/PolylineConverterToHost.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToHost/Raw/Geometry/PolylineConverterToHost.cs new file mode 100644 index 0000000000..544df8254f --- /dev/null +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToHost/Raw/Geometry/PolylineConverterToHost.cs @@ -0,0 +1,88 @@ +using Autodesk.Revit.DB; +using Objects.Geometry; +using Speckle.Converters.Common.Objects; +using Speckle.Converters.RevitShared.Helpers; +using Speckle.Converters.RevitShared.Services; + +namespace Speckle.Converters.RevitShared.ToSpeckle; + +public class PolylineConverterToHost : ITypedConverter +{ + private readonly ITypedConverter _lineConverter; + private readonly ScalingServiceToHost _scalingService; + private readonly IRevitConversionContextStack _contextStack; + + public PolylineConverterToHost( + ITypedConverter lineConverter, + ScalingServiceToHost scalingService, + IRevitConversionContextStack contextStack + ) + { + _lineConverter = lineConverter; + _scalingService = scalingService; + _contextStack = contextStack; + } + + public CurveArray Convert(Polyline target) + { + var curveArray = new CurveArray(); + if (target.value.Count == 6) + { + // 6 coordinate values (two sets of 3), so polyline is actually a single line + curveArray.Append(_lineConverter.Convert(new SOG.Line(target.value, target.units))); + } + else + { + var pts = target.GetPoints(); + var lastPt = pts[0]; + for (var i = 1; i < pts.Count; i++) + { + var success = TryAppendLineSafely(curveArray, new SOG.Line(lastPt, pts[i], target.units)); + if (success) + { + lastPt = pts[i]; + } + } + + if (target.closed) + { + TryAppendLineSafely(curveArray, new SOG.Line(pts[^1], pts[0], target.units)); + } + } + return curveArray; + } + + /// + /// Checks if a Speckle is too sort to be created in Revit. + /// + /// + /// The length of the line will be computed on the spot to ensure it is accurate. + /// + /// The to be tested. + /// true if the line is too short, false otherwise. + public bool IsLineTooShort(SOG.Line line) + { + var scaleToNative = _scalingService.ScaleToNative(SOG.Point.Distance(line.start, line.end), line.units); + return scaleToNative < _contextStack.Current.Document.Application.ShortCurveTolerance; + } + + /// + /// Attempts to append a Speckle onto a Revit . + /// This method ensures the line is long enough to be supported. + /// It will also convert the line to Revit before appending it to the . + /// + /// The revit to add the line to. + /// The to be added. + /// True if the line was added, false otherwise. + public bool TryAppendLineSafely(CurveArray curveArray, SOG.Line line) + { + if (IsLineTooShort(line)) + { + // poc : logging "Some lines in the CurveArray where ignored due to being smaller than the allowed curve length." + return false; + } + + curveArray.Append(_lineConverter.Convert(line)); + return true; + } +} diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToHost/Raw/Geometry/VectorConverterToHost.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToHost/Raw/Geometry/VectorConverterToHost.cs new file mode 100644 index 0000000000..04f589d2cf --- /dev/null +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToHost/Raw/Geometry/VectorConverterToHost.cs @@ -0,0 +1,28 @@ +using Autodesk.Revit.DB; +using Objects.Geometry; +using Speckle.Converters.Common.Objects; +using Speckle.Converters.RevitShared.Services; + +namespace Speckle.Converters.RevitShared.ToSpeckle; + +public class VectorConverterToHost : ITypedConverter +{ + private readonly ScalingServiceToHost _scalingService; + private readonly IReferencePointConverter _referencePointConverter; + + public VectorConverterToHost(ScalingServiceToHost scalingService, IReferencePointConverter referencePointConverter) + { + _scalingService = scalingService; + _referencePointConverter = referencePointConverter; + } + + public XYZ Convert(Vector target) + { + var revitVector = new XYZ( + _scalingService.ScaleToNative(target.x, target.units), + _scalingService.ScaleToNative(target.y, target.units), + _scalingService.ScaleToNative(target.z, target.units) + ); + return _referencePointConverter.ToInternalCoordinates(revitVector, false); + } +} diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToHost/TopLevel/BaseTopLevelConverterToHost.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToHost/TopLevel/BaseTopLevelConverterToHost.cs new file mode 100644 index 0000000000..4ea35a7980 --- /dev/null +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToHost/TopLevel/BaseTopLevelConverterToHost.cs @@ -0,0 +1,17 @@ +using Speckle.Converters.Common.Objects; +using Speckle.Core.Models; + +namespace Speckle.Converters.RevitShared.ToSpeckle; + +public abstract class BaseTopLevelConverterToHost : IToHostTopLevelConverter + where TSpeckle : Base + where THost : notnull +{ + public abstract THost Convert(TSpeckle target); + + public object Convert(Base target) + { + var result = Convert((TSpeckle)target); + return result; + } +} diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToHost/TopLevel/ModelCurveToSpeckleTopLevelConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToHost/TopLevel/ModelCurveToSpeckleTopLevelConverter.cs new file mode 100644 index 0000000000..e037bafd9e --- /dev/null +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToHost/TopLevel/ModelCurveToSpeckleTopLevelConverter.cs @@ -0,0 +1,107 @@ +using Objects; +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; +using Speckle.Converters.RevitShared.Helpers; +using System.Collections; + +namespace Speckle.Converters.RevitShared.ToSpeckle; + +[NameAndRankValue(nameof(SOBR.Curve.ModelCurve), 0)] +public class ModelCurveToHostTopLevelConverter : BaseTopLevelConverterToHost +{ + private readonly ITypedConverter _curveConverter; + private readonly IRevitConversionContextStack _contextStack; + + public ModelCurveToHostTopLevelConverter( + ITypedConverter curveConverter, + IRevitConversionContextStack conversionContext + ) + { + _curveConverter = curveConverter; + _contextStack = conversionContext; + } + + public override DB.ModelCurve[] Convert(SOBR.Curve.ModelCurve target) => + ModelCurvesFromEnumerator(_curveConverter.Convert(target.baseCurve).GetEnumerator(), target.baseCurve).ToArray(); + + private IEnumerable ModelCurvesFromEnumerator(IEnumerator curveEnum, ICurve speckleLine) + { + while (curveEnum.MoveNext() && curveEnum.Current != null) + { + var curve = (DB.Curve)curveEnum.Current; + // Curves must be bound in order to be valid model curves + if (!curve.IsBound) + { + curve.MakeBound(speckleLine.domain.start ?? 0, speckleLine.domain.end ?? Math.PI * 2); + } + + if (_contextStack.Current.Document.IsFamilyDocument) + { + yield return _contextStack.Current.Document.FamilyCreate.NewModelCurve( + curve, + NewSketchPlaneFromCurve(curve, _contextStack.Current.Document) + ); + } + else + { + yield return _contextStack.Current.Document.Create.NewModelCurve( + curve, + NewSketchPlaneFromCurve(curve, _contextStack.Current.Document) + ); + } + } + } + + /// + /// Credits: Grevit + /// Creates a new Sketch Plane from a Curve + /// https://github.com/grevit-dev/Grevit/blob/3c7a5cc198e00dfa4cc1e892edba7c7afd1a3f84/Grevit.Revit/Utilities.cs#L402 + /// + /// Curve to get plane from + /// Plane of the curve + private DB.SketchPlane NewSketchPlaneFromCurve(DB.Curve curve, DB.Document doc) + { + DB.XYZ startPoint = curve.GetEndPoint(0); + DB.XYZ endPoint = curve.GetEndPoint(1); + + // If Start end Endpoint are the same check further points. + int i = 2; + while (startPoint == endPoint && endPoint != null) + { + endPoint = curve.GetEndPoint(i); + i++; + } + + // Plane to return + DB.Plane plane; + + // If Z Values are equal the Plane is XY + if (startPoint.Z == endPoint.NotNull().Z) + { + plane = DB.Plane.CreateByNormalAndOrigin(DB.XYZ.BasisZ, startPoint); + } + // If X Values are equal the Plane is YZ + else if (startPoint.X == endPoint.X) + { + plane = DB.Plane.CreateByNormalAndOrigin(DB.XYZ.BasisX, startPoint); + } + // If Y Values are equal the Plane is XZ + else if (startPoint.Y == endPoint.Y) + { + plane = DB.Plane.CreateByNormalAndOrigin(DB.XYZ.BasisY, startPoint); + } + // Otherwise the Planes Normal Vector is not X,Y or Z. + // We draw lines from the Origin to each Point and use the Plane this one spans up. + else + { + using DB.CurveArray curves = new(); + curves.Append(curve); + curves.Append(DB.Line.CreateBound(new DB.XYZ(0, 0, 0), startPoint)); + curves.Append(DB.Line.CreateBound(endPoint, new DB.XYZ(0, 0, 0))); + + plane = DB.Plane.CreateByThreePoints(startPoint, new DB.XYZ(0, 0, 0), endPoint); + } + + return DB.SketchPlane.Create(doc, plane); + } +} diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/BeamConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/Raw/BeamConversionToSpeckle.cs similarity index 100% rename from DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/BeamConversionToSpeckle.cs rename to DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/Raw/BeamConversionToSpeckle.cs diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/BoundarySegmentConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/Raw/BoundarySegmentConversionToSpeckle.cs similarity index 100% rename from DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/BoundarySegmentConversionToSpeckle.cs rename to DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/Raw/BoundarySegmentConversionToSpeckle.cs diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/BraceToSpeckleConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/Raw/BraceToSpeckleConverter.cs similarity index 100% rename from DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/BraceToSpeckleConverter.cs rename to DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/Raw/BraceToSpeckleConverter.cs diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ColumnConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/Raw/ColumnConversionToSpeckle.cs similarity index 100% rename from DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ColumnConversionToSpeckle.cs rename to DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/Raw/ColumnConversionToSpeckle.cs diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/ArcToSpeckleConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/Raw/Geometry/ArcToSpeckleConverter.cs similarity index 100% rename from DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/ArcToSpeckleConverter.cs rename to DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/Raw/Geometry/ArcToSpeckleConverter.cs diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/BoundingBoxXYZToSpeckleConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/Raw/Geometry/BoundingBoxXYZToSpeckleConverter.cs similarity index 100% rename from DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/BoundingBoxXYZToSpeckleConverter.cs rename to DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/Raw/Geometry/BoundingBoxXYZToSpeckleConverter.cs diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/CircleToSpeckleConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/Raw/Geometry/CircleToSpeckleConverter.cs similarity index 100% rename from DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/CircleToSpeckleConverter.cs rename to DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/Raw/Geometry/CircleToSpeckleConverter.cs diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/CurveArrArrayToSpecklePolycurveConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/Raw/Geometry/CurveArrArrayToSpecklePolycurveConverter.cs similarity index 100% rename from DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/CurveArrArrayToSpecklePolycurveConverter.cs rename to DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/Raw/Geometry/CurveArrArrayToSpecklePolycurveConverter.cs diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/CurveArrayConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/Raw/Geometry/CurveArrayConversionToSpeckle.cs similarity index 100% rename from DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/CurveArrayConversionToSpeckle.cs rename to DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/Raw/Geometry/CurveArrayConversionToSpeckle.cs diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/CurveConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/Raw/Geometry/CurveConversionToSpeckle.cs similarity index 100% rename from DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/CurveConversionToSpeckle.cs rename to DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/Raw/Geometry/CurveConversionToSpeckle.cs diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/EllipseToSpeckleConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/Raw/Geometry/EllipseToSpeckleConverter.cs similarity index 100% rename from DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/EllipseToSpeckleConverter.cs rename to DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/Raw/Geometry/EllipseToSpeckleConverter.cs diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/HermiteSplineToSpeckleConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/Raw/Geometry/HermiteSplineToSpeckleConverter.cs similarity index 100% rename from DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/HermiteSplineToSpeckleConverter.cs rename to DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/Raw/Geometry/HermiteSplineToSpeckleConverter.cs diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/LineConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/Raw/Geometry/LineConversionToSpeckle.cs similarity index 100% rename from DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/LineConversionToSpeckle.cs rename to DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/Raw/Geometry/LineConversionToSpeckle.cs diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/MeshByMaterialDictionaryToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/Raw/Geometry/MeshByMaterialDictionaryToSpeckle.cs similarity index 100% rename from DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/MeshByMaterialDictionaryToSpeckle.cs rename to DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/Raw/Geometry/MeshByMaterialDictionaryToSpeckle.cs diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/MeshConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/Raw/Geometry/MeshConversionToSpeckle.cs similarity index 100% rename from DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/MeshConversionToSpeckle.cs rename to DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/Raw/Geometry/MeshConversionToSpeckle.cs diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/NurbsSplineToSpeckleConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/Raw/Geometry/NurbsSplineToSpeckleConverter.cs similarity index 100% rename from DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/NurbsSplineToSpeckleConverter.cs rename to DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/Raw/Geometry/NurbsSplineToSpeckleConverter.cs diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/PlaneToSpeckleConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/Raw/Geometry/PlaneToSpeckleConverter.cs similarity index 100% rename from DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/PlaneToSpeckleConverter.cs rename to DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/Raw/Geometry/PlaneToSpeckleConverter.cs diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/PointCloudToSpeckleConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/Raw/Geometry/PointCloudToSpeckleConverter.cs similarity index 100% rename from DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/PointCloudToSpeckleConverter.cs rename to DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/Raw/Geometry/PointCloudToSpeckleConverter.cs diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/PointConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/Raw/Geometry/PointConversionToSpeckle.cs similarity index 100% rename from DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/PointConversionToSpeckle.cs rename to DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/Raw/Geometry/PointConversionToSpeckle.cs diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/PolylineToSpeckleConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/Raw/Geometry/PolylineToSpeckleConverter.cs similarity index 100% rename from DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/PolylineToSpeckleConverter.cs rename to DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/Raw/Geometry/PolylineToSpeckleConverter.cs diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/SolidConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/Raw/Geometry/SolidConversionToSpeckle.cs similarity index 100% rename from DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/SolidConversionToSpeckle.cs rename to DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/Raw/Geometry/SolidConversionToSpeckle.cs diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/VectorToSpeckleConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/Raw/Geometry/VectorToSpeckleConverter.cs similarity index 100% rename from DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/VectorToSpeckleConverter.cs rename to DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/Raw/Geometry/VectorToSpeckleConverter.cs diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/XyzConversionToPoint.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/Raw/Geometry/XyzConversionToPoint.cs similarity index 100% rename from DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/XyzConversionToPoint.cs rename to DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/Raw/Geometry/XyzConversionToPoint.cs diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/LevelConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/Raw/LevelConversionToSpeckle.cs similarity index 100% rename from DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/LevelConversionToSpeckle.cs rename to DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/Raw/LevelConversionToSpeckle.cs diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/LocationConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/Raw/LocationConversionToSpeckle.cs similarity index 100% rename from DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/LocationConversionToSpeckle.cs rename to DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/Raw/LocationConversionToSpeckle.cs diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/MaterialConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/Raw/MaterialConversionToSpeckle.cs similarity index 100% rename from DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/MaterialConversionToSpeckle.cs rename to DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/Raw/MaterialConversionToSpeckle.cs diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ModelCurveArrArrayToSpeckleConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/Raw/ModelCurveArrArrayToSpeckleConverter.cs similarity index 100% rename from DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ModelCurveArrArrayToSpeckleConverter.cs rename to DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/Raw/ModelCurveArrArrayToSpeckleConverter.cs diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ModelCurveArrayToSpeckleConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/Raw/ModelCurveArrayToSpeckleConverter.cs similarity index 100% rename from DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ModelCurveArrayToSpeckleConverter.cs rename to DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/Raw/ModelCurveArrayToSpeckleConverter.cs diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ParameterConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/Raw/ParameterConversionToSpeckle.cs similarity index 100% rename from DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ParameterConversionToSpeckle.cs rename to DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/Raw/ParameterConversionToSpeckle.cs diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/BaseTopLevelConverterToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/TopLevel/BaseTopLevelConverterToSpeckle.cs similarity index 100% rename from DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/BaseTopLevelConverterToSpeckle.cs rename to DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/TopLevel/BaseTopLevelConverterToSpeckle.cs diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/CeilingTopLevelConverterToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/TopLevel/CeilingTopLevelConverterToSpeckle.cs similarity index 100% rename from DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/CeilingTopLevelConverterToSpeckle.cs rename to DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/TopLevel/CeilingTopLevelConverterToSpeckle.cs diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/DirectShapeTopLevelConverterToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/TopLevel/DirectShapeTopLevelConverterToSpeckle.cs similarity index 100% rename from DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/DirectShapeTopLevelConverterToSpeckle.cs rename to DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/TopLevel/DirectShapeTopLevelConverterToSpeckle.cs diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/ElementTopLevelConverterToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/TopLevel/ElementTopLevelConverterToSpeckle.cs similarity index 100% rename from DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/ElementTopLevelConverterToSpeckle.cs rename to DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/TopLevel/ElementTopLevelConverterToSpeckle.cs diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/ExtrusionRoofToSpeckleTopLevelConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/TopLevel/ExtrusionRoofToSpeckleTopLevelConverter.cs similarity index 100% rename from DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/ExtrusionRoofToSpeckleTopLevelConverter.cs rename to DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/TopLevel/ExtrusionRoofToSpeckleTopLevelConverter.cs diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/FamilyInstanceTopLevelConverterToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/TopLevel/FamilyInstanceTopLevelConverterToSpeckle.cs similarity index 100% rename from DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/FamilyInstanceTopLevelConverterToSpeckle.cs rename to DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/TopLevel/FamilyInstanceTopLevelConverterToSpeckle.cs diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/FloorTopLevelConverterToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/TopLevel/FloorTopLevelConverterToSpeckle.cs similarity index 100% rename from DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/FloorTopLevelConverterToSpeckle.cs rename to DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/TopLevel/FloorTopLevelConverterToSpeckle.cs diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/FootPrintRoofToSpeckleTopLevelConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/TopLevel/FootPrintRoofToSpeckleTopLevelConverter.cs similarity index 100% rename from DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/FootPrintRoofToSpeckleTopLevelConverter.cs rename to DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/TopLevel/FootPrintRoofToSpeckleTopLevelConverter.cs diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/HostedElementConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/TopLevel/HostedElementConversionToSpeckle.cs similarity index 100% rename from DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/HostedElementConversionToSpeckle.cs rename to DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/TopLevel/HostedElementConversionToSpeckle.cs diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/ModelCurveToSpeckleTopLevelConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/TopLevel/ModelCurveToSpeckleTopLevelConverter.cs similarity index 100% rename from DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/ModelCurveToSpeckleTopLevelConverter.cs rename to DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/TopLevel/ModelCurveToSpeckleTopLevelConverter.cs diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/RoofBaseToSpeckleTopLevelTopLevelConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/TopLevel/RoofBaseToSpeckleTopLevelTopLevelConverter.cs similarity index 100% rename from DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/RoofBaseToSpeckleTopLevelTopLevelConverter.cs rename to DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/TopLevel/RoofBaseToSpeckleTopLevelTopLevelConverter.cs diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/RoomTopLevelConverterToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/TopLevel/RoomTopLevelConverterToSpeckle.cs similarity index 100% rename from DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/RoomTopLevelConverterToSpeckle.cs rename to DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/TopLevel/RoomTopLevelConverterToSpeckle.cs diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/TopographyTopLevelConverterToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/TopLevel/TopographyTopLevelConverterToSpeckle.cs similarity index 100% rename from DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/TopographyTopLevelConverterToSpeckle.cs rename to DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/TopLevel/TopographyTopLevelConverterToSpeckle.cs diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/WallTopLevelConverterToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/TopLevel/WallTopLevelConverterToSpeckle.cs similarity index 100% rename from DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/WallTopLevelConverterToSpeckle.cs rename to DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/TopLevel/WallTopLevelConverterToSpeckle.cs From a2954b1bf34a3f2e6f5cee60932f74efb6767fbe Mon Sep 17 00:00:00 2001 From: Claire Kuang Date: Wed, 3 Jul 2024 11:56:54 +0100 Subject: [PATCH 257/261] DUI3-464: Separates root and raw converter registration (#3555) * separates root and raw converter container registration and updates for all converters * Update ContainerRegistration.cs --- .../ArcGISConverterModule.cs | 7 ++++++- .../AutocadConverterModule.cs | 8 +++++--- .../AutocadConverterModule.cs | 6 ++++-- .../RevitConverterModule.cs | 7 ++++++- .../RhinoConverterModule.cs | 7 +++++-- .../ContainerRegistration.cs | 18 +++++++++++------- 6 files changed, 37 insertions(+), 16 deletions(-) diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3.DependencyInjection/ArcGISConverterModule.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3.DependencyInjection/ArcGISConverterModule.cs index 30a739310b..c9ea4f55a7 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3.DependencyInjection/ArcGISConverterModule.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3.DependencyInjection/ArcGISConverterModule.cs @@ -10,8 +10,13 @@ public class ArcGISConverterModule : ISpeckleModule { public void Load(SpeckleContainerBuilder builder) { + // add single root converter //don't need a host specific RootToSpeckleConverter - builder.AddConverterCommon(); + builder.AddRootCommon(); + + // add application converters + builder.AddApplicationConverters(); + // most things should be InstancePerLifetimeScope so we get one per operation builder.AddScoped(); builder.AddScoped(); diff --git a/DUI3-DX/Converters/Autocad/2023/Speckle.Converters.Autocad2023.DependencyInjection/AutocadConverterModule.cs b/DUI3-DX/Converters/Autocad/2023/Speckle.Converters.Autocad2023.DependencyInjection/AutocadConverterModule.cs index 375d2c8170..f37ac6541f 100644 --- a/DUI3-DX/Converters/Autocad/2023/Speckle.Converters.Autocad2023.DependencyInjection/AutocadConverterModule.cs +++ b/DUI3-DX/Converters/Autocad/2023/Speckle.Converters.Autocad2023.DependencyInjection/AutocadConverterModule.cs @@ -1,4 +1,4 @@ -using Autodesk.AutoCAD.ApplicationServices; +using Autodesk.AutoCAD.ApplicationServices; using Autodesk.AutoCAD.DatabaseServices; using Speckle.Autofac.DependencyInjection; using Speckle.Converters.Autocad; @@ -11,9 +11,11 @@ public class AutocadConverterModule : ISpeckleModule { public void Load(SpeckleContainerBuilder builder) { - builder.AddConverterCommon(); + // add single root converter + builder.AddRootCommon(); - // single stack per conversion + // add application converters and context stack + builder.AddApplicationConverters(); builder.AddScoped, AutocadConversionContextStack>(); } } diff --git a/DUI3-DX/Converters/Autocad/2024/Speckle.Converters.Autocad2024.DependencyInjection/AutocadConverterModule.cs b/DUI3-DX/Converters/Autocad/2024/Speckle.Converters.Autocad2024.DependencyInjection/AutocadConverterModule.cs index 923bc241d1..66c4b57aff 100644 --- a/DUI3-DX/Converters/Autocad/2024/Speckle.Converters.Autocad2024.DependencyInjection/AutocadConverterModule.cs +++ b/DUI3-DX/Converters/Autocad/2024/Speckle.Converters.Autocad2024.DependencyInjection/AutocadConverterModule.cs @@ -11,9 +11,11 @@ public class AutocadConverterModule : ISpeckleModule { public void Load(SpeckleContainerBuilder builder) { - builder.AddConverterCommon(); + // add single root converter + builder.AddRootCommon(); - // single stack per conversion + // add application converters and context stack + builder.AddApplicationConverters(); builder.AddScoped, AutocadConversionContextStack>(); } } diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/RevitConverterModule.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/RevitConverterModule.cs index f5211019ae..54203e1e03 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/RevitConverterModule.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/RevitConverterModule.cs @@ -12,7 +12,12 @@ public class RevitConverterModule : ISpeckleModule { public void Load(SpeckleContainerBuilder builder) { - builder.AddConverterCommon(); + // Register single root + builder.AddRootCommon(); + + // register all application converters + builder.AddApplicationConverters(); + builder.AddSingleton(new RevitContext()); // POC: do we need ToSpeckleScalingService as is, do we need to interface it out? diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/RhinoConverterModule.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/RhinoConverterModule.cs index 9117848c90..6cfca7fa5e 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/RhinoConverterModule.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/RhinoConverterModule.cs @@ -9,8 +9,11 @@ public class RhinoConverterModule : ISpeckleModule { public void Load(SpeckleContainerBuilder builder) { - builder.AddConverterCommon(); - // single stack per conversion + // Register single root + builder.AddRootCommon(); + + // register all application converters and context stacks + builder.AddApplicationConverters(); builder.AddScoped, RhinoConversionContextStack>(); } } diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/ContainerRegistration.cs b/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/ContainerRegistration.cs index 6a5fb37913..84ab8defe1 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/ContainerRegistration.cs +++ b/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/ContainerRegistration.cs @@ -1,4 +1,4 @@ -using Speckle.Autofac.DependencyInjection; +using Speckle.Autofac.DependencyInjection; using Speckle.Converters.Common.DependencyInjection.ToHost; using Speckle.Converters.Common.Objects; @@ -6,14 +6,10 @@ namespace Speckle.Converters.Common.DependencyInjection; public static class ContainerRegistration { - public static void AddConverterCommon( - this SpeckleContainerBuilder builder - ) + public static void AddRootCommon(this SpeckleContainerBuilder builder) where TRootToSpeckleConverter : class, IRootToSpeckleConverter - where THostToSpeckleUnitConverter : class, IHostToSpeckleUnitConverter { builder.AddScoped(); - builder.AddScoped, THostToSpeckleUnitConverter>(); /* POC: CNX-9267 Moved the Injection of converters into the converter module. Not sure if this is 100% right, as this doesn't just register the conversions within this converter, but any conversions found in any Speckle.*.dll file. This will require consolidating across other connectors. @@ -29,8 +25,16 @@ This will require consolidating across other connectors. builder.AddScoped(); - builder.RegisterRawConversions(); builder.InjectNamedTypes(); builder.InjectNamedTypes(); } + + public static void AddApplicationConverters( + this SpeckleContainerBuilder builder + ) + where THostToSpeckleUnitConverter : class, IHostToSpeckleUnitConverter + { + builder.AddScoped, THostToSpeckleUnitConverter>(); + builder.RegisterRawConversions(); + } } From 7451d8e4ee35e6d2b52c15680267d5adb6d8fba4 Mon Sep 17 00:00:00 2001 From: connorivy <43247197+connorivy@users.noreply.github.com> Date: Wed, 3 Jul 2024 09:37:10 -0500 Subject: [PATCH 258/261] Dui3 178 gridlines (#3554) add gridline conversion Co-authored-by: Connor Ivy --- .../Speckle.Converters.RevitShared.projitems | 1 + .../GridlineToHostTopLevelConverter.cs | 56 +++++++++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToHost/TopLevel/GridlineToHostTopLevelConverter.cs diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Speckle.Converters.RevitShared.projitems b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Speckle.Converters.RevitShared.projitems index dce4c4898e..2db6172222 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Speckle.Converters.RevitShared.projitems +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Speckle.Converters.RevitShared.projitems @@ -36,6 +36,7 @@ + diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToHost/TopLevel/GridlineToHostTopLevelConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToHost/TopLevel/GridlineToHostTopLevelConverter.cs new file mode 100644 index 0000000000..24080b9516 --- /dev/null +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToHost/TopLevel/GridlineToHostTopLevelConverter.cs @@ -0,0 +1,56 @@ +using Objects; +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; +using Speckle.Converters.RevitShared.Helpers; +using Speckle.Converters.RevitShared.ToSpeckle; + +namespace Speckle.Converters.RevitShared.ToHost.TopLevel; + +[NameAndRankValue(nameof(SOBE.GridLine), 0)] +internal class GridlineToHostTopLevelConverter : BaseTopLevelConverterToHost +{ + private readonly ITypedConverter _curveConverter; + private readonly IRevitConversionContextStack _contextStack; + + public GridlineToHostTopLevelConverter( + ITypedConverter curveConverter, + IRevitConversionContextStack contextStack + ) + { + _curveConverter = curveConverter; + _contextStack = contextStack; + } + + public override DB.Grid Convert(SOBE.GridLine target) + { + DB.Curve curve = _curveConverter.Convert(target.baseLine).get_Item(0); + + using DB.Grid revitGrid = curve switch + { + DB.Arc arc => DB.Grid.Create(_contextStack.Current.Document, arc), + DB.Line line => DB.Grid.Create(_contextStack.Current.Document, line), + _ => throw new SpeckleConversionException($"Grid line curve is of type {curve.GetType()} which is not supported") + }; + + if (!string.IsNullOrEmpty(target.label) && !GridNameIsTaken(target.label)) + { + revitGrid.Name = target.label; + } + + return revitGrid; + } + + private bool GridNameIsTaken(string gridName) + { + using var collector = new DB.FilteredElementCollector(_contextStack.Current.Document); + + IEnumerable gridNames = collector + .WhereElementIsNotElementType() + .OfClass(typeof(DB.Grid)) + .ToElements() + .Cast() + .Select(grid => grid.Name); + + return gridNames.Contains(gridName); + } +} From 5fddfd92a3d443a6360232ef4770821be5a3c695 Mon Sep 17 00:00:00 2001 From: connorivy <43247197+connorivy@users.noreply.github.com> Date: Wed, 3 Jul 2024 10:33:49 -0500 Subject: [PATCH 259/261] Dui3 177 receive levels in Revit (#3553) * Auto stash before checking out "origin/dui3/alpha" * Fix Rhino lock * address pr comments * add level receive (and top level send) * fix merge * fix rebase operation --------- Co-authored-by: Connor Ivy Co-authored-by: Adam Hathcock --- .../RevitConverterModule.cs | 2 + .../RevitRootToHostConverter.cs | 28 +++++++ .../Speckle.Converters.RevitShared.projitems | 4 +- .../TopLevel/LevelToHostTopLevelConverter.cs | 77 +++++++++++++++++++ .../LevelTopLevelConverterToSpeckle.cs} | 7 +- 5 files changed, 114 insertions(+), 4 deletions(-) create mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/RevitRootToHostConverter.cs create mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToHost/TopLevel/LevelToHostTopLevelConverter.cs rename DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/{Raw/LevelConversionToSpeckle.cs => TopLevel/LevelTopLevelConverterToSpeckle.cs} (68%) diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/RevitConverterModule.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/RevitConverterModule.cs index 54203e1e03..e82fe0100a 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/RevitConverterModule.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/RevitConverterModule.cs @@ -1,5 +1,6 @@ using Autodesk.Revit.DB; using Speckle.Autofac.DependencyInjection; +using Speckle.Converters.Common; using Speckle.Converters.Common.DependencyInjection; using Speckle.Converters.RevitShared; using Speckle.Converters.RevitShared.Helpers; @@ -18,6 +19,7 @@ public void Load(SpeckleContainerBuilder builder) // register all application converters builder.AddApplicationConverters(); + builder.AddScoped(); builder.AddSingleton(new RevitContext()); // POC: do we need ToSpeckleScalingService as is, do we need to interface it out? diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/RevitRootToHostConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/RevitRootToHostConverter.cs new file mode 100644 index 0000000000..f6284b930f --- /dev/null +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/RevitRootToHostConverter.cs @@ -0,0 +1,28 @@ +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; +using Speckle.Core.Models; + +namespace Speckle.Converters.RevitShared; + +public class RevitRootToHostConverter : IRootToHostConverter +{ + private readonly IConverterResolver _converterResolver; + + public RevitRootToHostConverter(IConverterResolver converterResolver) + { + _converterResolver = converterResolver; + } + + public object Convert(Base target) + { + var objectConverter = _converterResolver.GetConversionForType(target.GetType()); + + if (objectConverter == null) + { + throw new SpeckleConversionException($"No conversion found for {target.GetType().Name}"); + } + + return objectConverter.Convert(target) + ?? throw new SpeckleConversionException($"Conversion of object with type {target.GetType()} returned null"); + } +} diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Speckle.Converters.RevitShared.projitems b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Speckle.Converters.RevitShared.projitems index 2db6172222..e33ba9046a 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Speckle.Converters.RevitShared.projitems +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Speckle.Converters.RevitShared.projitems @@ -23,6 +23,7 @@ + @@ -36,6 +37,7 @@ + @@ -60,7 +62,7 @@ - + diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToHost/TopLevel/LevelToHostTopLevelConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToHost/TopLevel/LevelToHostTopLevelConverter.cs new file mode 100644 index 0000000000..69f72e4f18 --- /dev/null +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToHost/TopLevel/LevelToHostTopLevelConverter.cs @@ -0,0 +1,77 @@ +using Speckle.Converters.Common; +using Speckle.Converters.RevitShared.Helpers; +using Speckle.Converters.RevitShared.ToSpeckle; +using Speckle.Converters.RevitShared.Services; + +namespace Speckle.Converters.RevitShared.ToHost.ToLevel; + +[NameAndRankValue(nameof(SOBE.Level), 0)] +public class LevelToHostTopLevelConverter : BaseTopLevelConverterToHost +{ + private readonly IRevitConversionContextStack _contextStack; + private readonly ScalingServiceToHost _scalingService; + + public LevelToHostTopLevelConverter(IRevitConversionContextStack contextStack, ScalingServiceToHost scalingService) + { + _contextStack = contextStack; + _scalingService = scalingService; + } + + public override DB.Level Convert(SOBE.Level target) + { + using var documentLevelCollector = new DB.FilteredElementCollector(_contextStack.Current.Document); + var docLevels = documentLevelCollector.OfClass(typeof(DB.Level)).ToElements().Cast(); + + // POC : I'm not really understanding the linked use case for this. Do we want to bring this over? + + //bool elevationMatch = true; + ////level by name component + //if (target is RevitLevel speckleRevitLevel && speckleRevitLevel.referenceOnly) + //{ + // //see: https://speckle.community/t/revit-connector-levels-and-spaces/2824/5 + // elevationMatch = false; + // if (GetExistingLevelByName(docLevels, target.name) is DB.Level existingLevelWithSameName) + // { + // return existingLevelWithSameName; + // } + //} + + DB.Level revitLevel; + var targetElevation = _scalingService.ScaleToNative(target.elevation, target.units); + + if (GetExistingLevelByElevation(docLevels, targetElevation) is DB.Level existingLevel) + { + revitLevel = existingLevel; + } + else + { + revitLevel = DB.Level.Create(_contextStack.Current.Document, targetElevation); + revitLevel.Name = target.name; + + if (target is SOBR.RevitLevel rl && rl.createView) + { + using var viewPlan = CreateViewPlan(target.name, revitLevel.Id); + } + } + + return revitLevel; + } + + private static DB.Level GetExistingLevelByElevation(IEnumerable docLevels, double elevation) + { + return docLevels.FirstOrDefault(l => Math.Abs(l.Elevation - elevation) < RevitConversionContextStack.TOLERANCE); + } + + private DB.ViewPlan CreateViewPlan(string name, DB.ElementId levelId) + { + using var collector = new DB.FilteredElementCollector(_contextStack.Current.Document); + var vt = collector + .OfClass(typeof(DB.ViewFamilyType)) + .First(el => ((DB.ViewFamilyType)el).ViewFamily == DB.ViewFamily.FloorPlan); + + var view = DB.ViewPlan.Create(_contextStack.Current.Document, vt.Id, levelId); + view.Name = name; + + return view; + } +} diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/Raw/LevelConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/TopLevel/LevelTopLevelConverterToSpeckle.cs similarity index 68% rename from DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/Raw/LevelConversionToSpeckle.cs rename to DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/TopLevel/LevelTopLevelConverterToSpeckle.cs index 33e1d7fea2..2916415bb3 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/Raw/LevelConversionToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/TopLevel/LevelTopLevelConverterToSpeckle.cs @@ -1,9 +1,10 @@ -using Speckle.Converters.Common.Objects; +using Speckle.Converters.Common; using Speckle.Converters.RevitShared.Services; namespace Speckle.Converters.RevitShared.ToSpeckle; -public class LevelConversionToSpeckle : ITypedConverter +[NameAndRankValue(nameof(DB.Level), 0)] +public class LevelConversionToSpeckle : BaseTopLevelConverterToSpeckle { private readonly ScalingServiceToSpeckle _scalingService; @@ -12,7 +13,7 @@ public LevelConversionToSpeckle(ScalingServiceToSpeckle scalingService) _scalingService = scalingService; } - public SOBR.RevitLevel Convert(DB.Level target) + public override SOBR.RevitLevel Convert(DB.Level target) { SOBR.RevitLevel level = new() From 4561d18cef84376c89ba0a20e6ac562cf7203300 Mon Sep 17 00:00:00 2001 From: Claire Kuang Date: Thu, 4 Jul 2024 11:55:52 +0100 Subject: [PATCH 260/261] DUI3-326: Add civil3d 2024 converter (#3548) * adds converter project with pipe conversion * updates with TODO comment to resolve multiple converter registration * Update Speckle.Connectors.Civil3d2024.csproj * changes container registration * fixed bugs with raw conversion registration * adds missing autocad converters * fixes merge issue with package version and autocad proj structure * more project reference fixing :/ * restore locks * csprojs now reference correctly * fixes send registration for civil - was broken by blocks pr --------- Co-authored-by: Adam Hathcock --- All.sln | 199 +++++--- DUI3-DX.slnf | 11 +- .../Speckle.Connectors.Autocad2023.csproj | 4 +- .../AutocadConnectorModule.cs | 54 +-- .../Civil3dConnectorModule.cs | 26 +- .../SharedConnectorModule.cs | 40 -- .../DependencyInjection/SharedRegistration.cs | 82 ++++ ...Speckle.Connectors.AutocadShared.projitems | 2 +- .../Speckle.Connectors.Civil3d2024.csproj | 5 +- .../packages.lock.json | 19 +- .../AutocadConverterModule.cs | 0 ...ers.Autocad2023.DependencyInjection.csproj | 8 +- .../packages.lock.json | 2 +- .../Speckle.Converters.Autocad2023.csproj | 4 +- .../packages.lock.json | 0 .../AutocadConverterModule.cs | 2 +- ...ers.Autocad2024.DependencyInjection.csproj | 2 +- .../packages.lock.json | 2 +- .../Speckle.Converters.Autocad2024.csproj | 4 +- .../packages.lock.json | 0 .../GlobalUsings.cs | 1 + ...Speckle.Converters.AutocadShared.projitems | 10 +- .../Geometry/ArcToSpeckleConverter.cs | 49 +- .../Geometry/CircleToSpeckleConverter.cs | 24 +- .../Geometry/EllipseToSpeckleConverter.cs | 34 +- .../Geometry/LineToSpeckleConverter.cs | 28 +- .../Geometry/Polyline2dToSpeckleConverter.cs | 8 +- .../Geometry/Polyline3dToSpeckleConverter.cs | 8 +- .../Geometry/Solid3dToSpeckleConverter.cs | 23 + .../Geometry/SplineToSpeckleConverter.cs | 146 +----- ... => CircularArc3dToSpeckleRawConverter.cs} | 0 .../Raw/DBArcToSpeckleRawConverter.cs | 58 +++ .../Raw/DBCircleToSpeckleRawConverter.cs | 35 ++ .../Raw/DBCurveToSpeckleRawConverter.cs | 67 +++ .../Raw/DBEllipseToSpeckleRawConverter.cs | 45 ++ .../Raw/DBLineToSpeckleRawConverter.cs | 37 ++ .../Raw/DBSolid3dToSpeckleRawConverter.cs | 84 ++++ .../Raw/DBSplineToSpeckleRawConverter.cs | 155 ++++++ .../Raw/PlaneToSpeckleRawConverter.cs | 2 +- .../Civil3dConverterModule.cs | 24 + ...ers.Civil3d2024.DependencyInjection.csproj | 17 + .../packages.lock.json | 448 ++++++++++++++++++ .../Speckle.Converters.Civil3d2024.csproj | 21 + .../packages.lock.json | 424 +++++++++++++++++ .../Civil3dConversionContextStack.cs | 38 ++ .../Civil3dRootToHostConverter.cs | 59 +++ .../Civil3dToSpeckleUnitConverter.cs | 39 ++ .../GlobalUsings.cs | 3 + ...Speckle.Converters.Civil3dShared.projitems | 19 + .../Speckle.Converters.Civil3dShared.shproj | 13 + .../BuiltElements/PipeToSpeckleConverter.cs | 60 +++ .../Raw/PropertySetToSpeckleRawConverter.cs | 55 +++ DUI3-DX/Directory.Packages.props | 20 +- 53 files changed, 2025 insertions(+), 495 deletions(-) delete mode 100644 DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/DependencyInjection/SharedConnectorModule.cs create mode 100644 DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/DependencyInjection/SharedRegistration.cs rename DUI3-DX/Converters/Autocad/{2023 => }/Speckle.Converters.Autocad2023.DependencyInjection/AutocadConverterModule.cs (100%) rename DUI3-DX/Converters/Autocad/{2023 => }/Speckle.Converters.Autocad2023.DependencyInjection/Speckle.Converters.Autocad2023.DependencyInjection.csproj (72%) rename DUI3-DX/Converters/Autocad/{2023 => }/Speckle.Converters.Autocad2023.DependencyInjection/packages.lock.json (99%) rename DUI3-DX/Converters/Autocad/{2023 => }/Speckle.Converters.Autocad2023/Speckle.Converters.Autocad2023.csproj (57%) rename DUI3-DX/Converters/Autocad/{2023 => }/Speckle.Converters.Autocad2023/packages.lock.json (100%) rename DUI3-DX/Converters/Autocad/{2024 => }/Speckle.Converters.Autocad2024.DependencyInjection/AutocadConverterModule.cs (91%) rename DUI3-DX/Converters/Autocad/{2024 => }/Speckle.Converters.Autocad2024.DependencyInjection/Speckle.Converters.Autocad2024.DependencyInjection.csproj (73%) rename DUI3-DX/Converters/Autocad/{2024 => }/Speckle.Converters.Autocad2024.DependencyInjection/packages.lock.json (99%) rename DUI3-DX/Converters/Autocad/{2024 => }/Speckle.Converters.Autocad2024/Speckle.Converters.Autocad2024.csproj (57%) rename DUI3-DX/Converters/Autocad/{2024 => }/Speckle.Converters.Autocad2024/packages.lock.json (100%) create mode 100644 DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/Solid3dToSpeckleConverter.cs rename DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Raw/{CircularArc3dToSpeckleConverter.cs => CircularArc3dToSpeckleRawConverter.cs} (100%) create mode 100644 DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Raw/DBArcToSpeckleRawConverter.cs create mode 100644 DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Raw/DBCircleToSpeckleRawConverter.cs create mode 100644 DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Raw/DBCurveToSpeckleRawConverter.cs create mode 100644 DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Raw/DBEllipseToSpeckleRawConverter.cs create mode 100644 DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Raw/DBLineToSpeckleRawConverter.cs create mode 100644 DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Raw/DBSolid3dToSpeckleRawConverter.cs create mode 100644 DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Raw/DBSplineToSpeckleRawConverter.cs create mode 100644 DUI3-DX/Converters/Civil3d/Speckle.Converters.Civil3d2024.DependencyInjection/Civil3dConverterModule.cs create mode 100644 DUI3-DX/Converters/Civil3d/Speckle.Converters.Civil3d2024.DependencyInjection/Speckle.Converters.Civil3d2024.DependencyInjection.csproj create mode 100644 DUI3-DX/Converters/Civil3d/Speckle.Converters.Civil3d2024.DependencyInjection/packages.lock.json create mode 100644 DUI3-DX/Converters/Civil3d/Speckle.Converters.Civil3d2024/Speckle.Converters.Civil3d2024.csproj create mode 100644 DUI3-DX/Converters/Civil3d/Speckle.Converters.Civil3d2024/packages.lock.json create mode 100644 DUI3-DX/Converters/Civil3d/Speckle.Converters.Civil3dShared/Civil3dConversionContextStack.cs create mode 100644 DUI3-DX/Converters/Civil3d/Speckle.Converters.Civil3dShared/Civil3dRootToHostConverter.cs create mode 100644 DUI3-DX/Converters/Civil3d/Speckle.Converters.Civil3dShared/Civil3dToSpeckleUnitConverter.cs create mode 100644 DUI3-DX/Converters/Civil3d/Speckle.Converters.Civil3dShared/GlobalUsings.cs create mode 100644 DUI3-DX/Converters/Civil3d/Speckle.Converters.Civil3dShared/Speckle.Converters.Civil3dShared.projitems create mode 100644 DUI3-DX/Converters/Civil3d/Speckle.Converters.Civil3dShared/Speckle.Converters.Civil3dShared.shproj create mode 100644 DUI3-DX/Converters/Civil3d/Speckle.Converters.Civil3dShared/ToSpeckle/BuiltElements/PipeToSpeckleConverter.cs create mode 100644 DUI3-DX/Converters/Civil3d/Speckle.Converters.Civil3dShared/ToSpeckle/Raw/PropertySetToSpeckleRawConverter.cs diff --git a/All.sln b/All.sln index 5e80640bb0..4cca95fc50 100644 --- a/All.sln +++ b/All.sln @@ -524,10 +524,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Autocad", "Autocad", "{804E EndProject Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Speckle.Converters.AutocadShared", "DUI3-DX\Converters\Autocad\Speckle.Converters.AutocadShared\Speckle.Converters.AutocadShared.shproj", "{9ADD1B7A-6401-4202-8613-F668E2FBC0A4}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Speckle.Converters.Autocad2023", "DUI3-DX\Converters\Autocad\2023\Speckle.Converters.Autocad2023\Speckle.Converters.Autocad2023.csproj", "{631C295A-7CCF-4B42-8686-7034E31469E7}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Speckle.Converters.Autocad2023.DependencyInjection", "DUI3-DX\Converters\Autocad\2023\Speckle.Converters.Autocad2023.DependencyInjection\Speckle.Converters.Autocad2023.DependencyInjection.csproj", "{D940853C-003A-482C-BDB0-665367F274A0}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Speckle.Connectors.DUI.WebView", "DUI3-DX\DUI3\Speckle.Connectors.DUI.WebView\Speckle.Connectors.DUI.WebView.csproj", "{7420652C-3046-4F38-BE64-9B9E69D76FA2}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Build", "Build", "{326ECEE0-D009-4A65-B24C-00FA343D8B99}" @@ -558,9 +554,21 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{B1324D25 EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Speckle.Connectors.Civil3d2024", "DUI3-DX\Connectors\Autocad\Speckle.Connectors.Civil3d2024\Speckle.Connectors.Civil3d2024.csproj", "{DDBBA313-69A6-40DE-AB3A-79EE5BF32A7E}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Speckle.Converters.Autocad2024", "DUI3-DX\Converters\Autocad\2024\Speckle.Converters.Autocad2024\Speckle.Converters.Autocad2024.csproj", "{C9C28F31-1367-438C-83B0-049C3B3A3E3B}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Civil3d", "Civil3d", "{34A6BB15-A030-4C5B-94B2-1A1DFE49334A}" +EndProject +Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Speckle.Converters.Civil3dShared", "DUI3-DX\Converters\Civil3d\Speckle.Converters.Civil3dShared\Speckle.Converters.Civil3dShared.shproj", "{35175682-DA83-4C0A-A49D-B191F5885D8E}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Speckle.Converters.Civil3d2024", "DUI3-DX\Converters\Civil3d\Speckle.Converters.Civil3d2024\Speckle.Converters.Civil3d2024.csproj", "{E7FA6A25-A224-4207-846B-75CE8236228D}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Speckle.Converters.Civil3d2024.DependencyInjection", "DUI3-DX\Converters\Civil3d\Speckle.Converters.Civil3d2024.DependencyInjection\Speckle.Converters.Civil3d2024.DependencyInjection.csproj", "{9BCE88BA-1E01-44EE-BF9D-2CB906E63E34}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Speckle.Converters.Autocad2024.DependencyInjection", "DUI3-DX\Converters\Autocad\Speckle.Converters.Autocad2024.DependencyInjection\Speckle.Converters.Autocad2024.DependencyInjection.csproj", "{2C587020-5F9F-40E1-8AF8-772FE3FC256A}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Speckle.Converters.Autocad2023", "DUI3-DX\Converters\Autocad\Speckle.Converters.Autocad2023\Speckle.Converters.Autocad2023.csproj", "{C9F084AF-FB70-4F5F-ACEB-DB6818BBECAF}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Speckle.Converters.Autocad2023.DependencyInjection", "DUI3-DX\Converters\Autocad\Speckle.Converters.Autocad2023.DependencyInjection\Speckle.Converters.Autocad2023.DependencyInjection.csproj", "{4E83BA93-4EC4-4A6E-AD27-8CD9A409FD23}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Speckle.Converters.Autocad2024.DependencyInjection", "DUI3-DX\Converters\Autocad\2024\Speckle.Converters.Autocad2024.DependencyInjection\Speckle.Converters.Autocad2024.DependencyInjection.csproj", "{06082BAA-98E8-49B1-9D33-252B126A0561}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Speckle.Converters.Autocad2024", "DUI3-DX\Converters\Autocad\Speckle.Converters.Autocad2024\Speckle.Converters.Autocad2024.csproj", "{A6BAA749-0DBE-49A9-9A9D-FCA0F06EE096}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -2620,38 +2628,6 @@ Global {11F7D41B-AFCA-4D29-BC08-285A14BF3A3B}.Release|Any CPU.Build.0 = Release|Any CPU {11F7D41B-AFCA-4D29-BC08-285A14BF3A3B}.Release|x64.ActiveCfg = Release|Any CPU {11F7D41B-AFCA-4D29-BC08-285A14BF3A3B}.Release|x64.Build.0 = Release|Any CPU - {631C295A-7CCF-4B42-8686-7034E31469E7}.Debug Mac|Any CPU.ActiveCfg = Debug|Any CPU - {631C295A-7CCF-4B42-8686-7034E31469E7}.Debug Mac|Any CPU.Build.0 = Debug|Any CPU - {631C295A-7CCF-4B42-8686-7034E31469E7}.Debug Mac|x64.ActiveCfg = Debug|Any CPU - {631C295A-7CCF-4B42-8686-7034E31469E7}.Debug Mac|x64.Build.0 = Debug|Any CPU - {631C295A-7CCF-4B42-8686-7034E31469E7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {631C295A-7CCF-4B42-8686-7034E31469E7}.Debug|Any CPU.Build.0 = Debug|Any CPU - {631C295A-7CCF-4B42-8686-7034E31469E7}.Debug|x64.ActiveCfg = Debug|Any CPU - {631C295A-7CCF-4B42-8686-7034E31469E7}.Debug|x64.Build.0 = Debug|Any CPU - {631C295A-7CCF-4B42-8686-7034E31469E7}.Release Mac|Any CPU.ActiveCfg = Release|Any CPU - {631C295A-7CCF-4B42-8686-7034E31469E7}.Release Mac|Any CPU.Build.0 = Release|Any CPU - {631C295A-7CCF-4B42-8686-7034E31469E7}.Release Mac|x64.ActiveCfg = Release|Any CPU - {631C295A-7CCF-4B42-8686-7034E31469E7}.Release Mac|x64.Build.0 = Release|Any CPU - {631C295A-7CCF-4B42-8686-7034E31469E7}.Release|Any CPU.ActiveCfg = Release|Any CPU - {631C295A-7CCF-4B42-8686-7034E31469E7}.Release|Any CPU.Build.0 = Release|Any CPU - {631C295A-7CCF-4B42-8686-7034E31469E7}.Release|x64.ActiveCfg = Release|Any CPU - {631C295A-7CCF-4B42-8686-7034E31469E7}.Release|x64.Build.0 = Release|Any CPU - {D940853C-003A-482C-BDB0-665367F274A0}.Debug Mac|Any CPU.ActiveCfg = Debug|Any CPU - {D940853C-003A-482C-BDB0-665367F274A0}.Debug Mac|Any CPU.Build.0 = Debug|Any CPU - {D940853C-003A-482C-BDB0-665367F274A0}.Debug Mac|x64.ActiveCfg = Debug|Any CPU - {D940853C-003A-482C-BDB0-665367F274A0}.Debug Mac|x64.Build.0 = Debug|Any CPU - {D940853C-003A-482C-BDB0-665367F274A0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {D940853C-003A-482C-BDB0-665367F274A0}.Debug|Any CPU.Build.0 = Debug|Any CPU - {D940853C-003A-482C-BDB0-665367F274A0}.Debug|x64.ActiveCfg = Debug|Any CPU - {D940853C-003A-482C-BDB0-665367F274A0}.Debug|x64.Build.0 = Debug|Any CPU - {D940853C-003A-482C-BDB0-665367F274A0}.Release Mac|Any CPU.ActiveCfg = Debug|Any CPU - {D940853C-003A-482C-BDB0-665367F274A0}.Release Mac|Any CPU.Build.0 = Debug|Any CPU - {D940853C-003A-482C-BDB0-665367F274A0}.Release Mac|x64.ActiveCfg = Debug|Any CPU - {D940853C-003A-482C-BDB0-665367F274A0}.Release Mac|x64.Build.0 = Debug|Any CPU - {D940853C-003A-482C-BDB0-665367F274A0}.Release|Any CPU.ActiveCfg = Release|Any CPU - {D940853C-003A-482C-BDB0-665367F274A0}.Release|Any CPU.Build.0 = Release|Any CPU - {D940853C-003A-482C-BDB0-665367F274A0}.Release|x64.ActiveCfg = Release|Any CPU - {D940853C-003A-482C-BDB0-665367F274A0}.Release|x64.Build.0 = Release|Any CPU {7420652C-3046-4F38-BE64-9B9E69D76FA2}.Debug Mac|Any CPU.ActiveCfg = Debug|Any CPU {7420652C-3046-4F38-BE64-9B9E69D76FA2}.Debug Mac|Any CPU.Build.0 = Debug|Any CPU {7420652C-3046-4F38-BE64-9B9E69D76FA2}.Debug Mac|x64.ActiveCfg = Debug|Any CPU @@ -2812,38 +2788,102 @@ Global {DDBBA313-69A6-40DE-AB3A-79EE5BF32A7E}.Release|Any CPU.Build.0 = Release|Any CPU {DDBBA313-69A6-40DE-AB3A-79EE5BF32A7E}.Release|x64.ActiveCfg = Release|Any CPU {DDBBA313-69A6-40DE-AB3A-79EE5BF32A7E}.Release|x64.Build.0 = Release|Any CPU - {C9C28F31-1367-438C-83B0-049C3B3A3E3B}.Debug Mac|Any CPU.ActiveCfg = Debug|Any CPU - {C9C28F31-1367-438C-83B0-049C3B3A3E3B}.Debug Mac|Any CPU.Build.0 = Debug|Any CPU - {C9C28F31-1367-438C-83B0-049C3B3A3E3B}.Debug Mac|x64.ActiveCfg = Debug|Any CPU - {C9C28F31-1367-438C-83B0-049C3B3A3E3B}.Debug Mac|x64.Build.0 = Debug|Any CPU - {C9C28F31-1367-438C-83B0-049C3B3A3E3B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {C9C28F31-1367-438C-83B0-049C3B3A3E3B}.Debug|Any CPU.Build.0 = Debug|Any CPU - {C9C28F31-1367-438C-83B0-049C3B3A3E3B}.Debug|x64.ActiveCfg = Debug|Any CPU - {C9C28F31-1367-438C-83B0-049C3B3A3E3B}.Debug|x64.Build.0 = Debug|Any CPU - {C9C28F31-1367-438C-83B0-049C3B3A3E3B}.Release Mac|Any CPU.ActiveCfg = Release|Any CPU - {C9C28F31-1367-438C-83B0-049C3B3A3E3B}.Release Mac|Any CPU.Build.0 = Release|Any CPU - {C9C28F31-1367-438C-83B0-049C3B3A3E3B}.Release Mac|x64.ActiveCfg = Release|Any CPU - {C9C28F31-1367-438C-83B0-049C3B3A3E3B}.Release Mac|x64.Build.0 = Release|Any CPU - {C9C28F31-1367-438C-83B0-049C3B3A3E3B}.Release|Any CPU.ActiveCfg = Release|Any CPU - {C9C28F31-1367-438C-83B0-049C3B3A3E3B}.Release|Any CPU.Build.0 = Release|Any CPU - {C9C28F31-1367-438C-83B0-049C3B3A3E3B}.Release|x64.ActiveCfg = Release|Any CPU - {C9C28F31-1367-438C-83B0-049C3B3A3E3B}.Release|x64.Build.0 = Release|Any CPU - {06082BAA-98E8-49B1-9D33-252B126A0561}.Debug Mac|Any CPU.ActiveCfg = Debug|Any CPU - {06082BAA-98E8-49B1-9D33-252B126A0561}.Debug Mac|Any CPU.Build.0 = Debug|Any CPU - {06082BAA-98E8-49B1-9D33-252B126A0561}.Debug Mac|x64.ActiveCfg = Debug|Any CPU - {06082BAA-98E8-49B1-9D33-252B126A0561}.Debug Mac|x64.Build.0 = Debug|Any CPU - {06082BAA-98E8-49B1-9D33-252B126A0561}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {06082BAA-98E8-49B1-9D33-252B126A0561}.Debug|Any CPU.Build.0 = Debug|Any CPU - {06082BAA-98E8-49B1-9D33-252B126A0561}.Debug|x64.ActiveCfg = Debug|Any CPU - {06082BAA-98E8-49B1-9D33-252B126A0561}.Debug|x64.Build.0 = Debug|Any CPU - {06082BAA-98E8-49B1-9D33-252B126A0561}.Release Mac|Any CPU.ActiveCfg = Release|Any CPU - {06082BAA-98E8-49B1-9D33-252B126A0561}.Release Mac|Any CPU.Build.0 = Release|Any CPU - {06082BAA-98E8-49B1-9D33-252B126A0561}.Release Mac|x64.ActiveCfg = Release|Any CPU - {06082BAA-98E8-49B1-9D33-252B126A0561}.Release Mac|x64.Build.0 = Release|Any CPU - {06082BAA-98E8-49B1-9D33-252B126A0561}.Release|Any CPU.ActiveCfg = Release|Any CPU - {06082BAA-98E8-49B1-9D33-252B126A0561}.Release|Any CPU.Build.0 = Release|Any CPU - {06082BAA-98E8-49B1-9D33-252B126A0561}.Release|x64.ActiveCfg = Release|Any CPU - {06082BAA-98E8-49B1-9D33-252B126A0561}.Release|x64.Build.0 = Release|Any CPU + {E7FA6A25-A224-4207-846B-75CE8236228D}.Debug Mac|Any CPU.ActiveCfg = Debug|Any CPU + {E7FA6A25-A224-4207-846B-75CE8236228D}.Debug Mac|Any CPU.Build.0 = Debug|Any CPU + {E7FA6A25-A224-4207-846B-75CE8236228D}.Debug Mac|x64.ActiveCfg = Debug|Any CPU + {E7FA6A25-A224-4207-846B-75CE8236228D}.Debug Mac|x64.Build.0 = Debug|Any CPU + {E7FA6A25-A224-4207-846B-75CE8236228D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E7FA6A25-A224-4207-846B-75CE8236228D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E7FA6A25-A224-4207-846B-75CE8236228D}.Debug|x64.ActiveCfg = Debug|Any CPU + {E7FA6A25-A224-4207-846B-75CE8236228D}.Debug|x64.Build.0 = Debug|Any CPU + {E7FA6A25-A224-4207-846B-75CE8236228D}.Release Mac|Any CPU.ActiveCfg = Release|Any CPU + {E7FA6A25-A224-4207-846B-75CE8236228D}.Release Mac|Any CPU.Build.0 = Release|Any CPU + {E7FA6A25-A224-4207-846B-75CE8236228D}.Release Mac|x64.ActiveCfg = Release|Any CPU + {E7FA6A25-A224-4207-846B-75CE8236228D}.Release Mac|x64.Build.0 = Release|Any CPU + {E7FA6A25-A224-4207-846B-75CE8236228D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E7FA6A25-A224-4207-846B-75CE8236228D}.Release|Any CPU.Build.0 = Release|Any CPU + {E7FA6A25-A224-4207-846B-75CE8236228D}.Release|x64.ActiveCfg = Release|Any CPU + {E7FA6A25-A224-4207-846B-75CE8236228D}.Release|x64.Build.0 = Release|Any CPU + {9BCE88BA-1E01-44EE-BF9D-2CB906E63E34}.Debug Mac|Any CPU.ActiveCfg = Debug|Any CPU + {9BCE88BA-1E01-44EE-BF9D-2CB906E63E34}.Debug Mac|Any CPU.Build.0 = Debug|Any CPU + {9BCE88BA-1E01-44EE-BF9D-2CB906E63E34}.Debug Mac|x64.ActiveCfg = Debug|Any CPU + {9BCE88BA-1E01-44EE-BF9D-2CB906E63E34}.Debug Mac|x64.Build.0 = Debug|Any CPU + {9BCE88BA-1E01-44EE-BF9D-2CB906E63E34}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9BCE88BA-1E01-44EE-BF9D-2CB906E63E34}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9BCE88BA-1E01-44EE-BF9D-2CB906E63E34}.Debug|x64.ActiveCfg = Debug|Any CPU + {9BCE88BA-1E01-44EE-BF9D-2CB906E63E34}.Debug|x64.Build.0 = Debug|Any CPU + {9BCE88BA-1E01-44EE-BF9D-2CB906E63E34}.Release Mac|Any CPU.ActiveCfg = Release|Any CPU + {9BCE88BA-1E01-44EE-BF9D-2CB906E63E34}.Release Mac|Any CPU.Build.0 = Release|Any CPU + {9BCE88BA-1E01-44EE-BF9D-2CB906E63E34}.Release Mac|x64.ActiveCfg = Release|Any CPU + {9BCE88BA-1E01-44EE-BF9D-2CB906E63E34}.Release Mac|x64.Build.0 = Release|Any CPU + {9BCE88BA-1E01-44EE-BF9D-2CB906E63E34}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9BCE88BA-1E01-44EE-BF9D-2CB906E63E34}.Release|Any CPU.Build.0 = Release|Any CPU + {9BCE88BA-1E01-44EE-BF9D-2CB906E63E34}.Release|x64.ActiveCfg = Release|Any CPU + {9BCE88BA-1E01-44EE-BF9D-2CB906E63E34}.Release|x64.Build.0 = Release|Any CPU + {2C587020-5F9F-40E1-8AF8-772FE3FC256A}.Debug Mac|Any CPU.ActiveCfg = Debug|Any CPU + {2C587020-5F9F-40E1-8AF8-772FE3FC256A}.Debug Mac|Any CPU.Build.0 = Debug|Any CPU + {2C587020-5F9F-40E1-8AF8-772FE3FC256A}.Debug Mac|x64.ActiveCfg = Debug|Any CPU + {2C587020-5F9F-40E1-8AF8-772FE3FC256A}.Debug Mac|x64.Build.0 = Debug|Any CPU + {2C587020-5F9F-40E1-8AF8-772FE3FC256A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2C587020-5F9F-40E1-8AF8-772FE3FC256A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2C587020-5F9F-40E1-8AF8-772FE3FC256A}.Debug|x64.ActiveCfg = Debug|Any CPU + {2C587020-5F9F-40E1-8AF8-772FE3FC256A}.Debug|x64.Build.0 = Debug|Any CPU + {2C587020-5F9F-40E1-8AF8-772FE3FC256A}.Release Mac|Any CPU.ActiveCfg = Release|Any CPU + {2C587020-5F9F-40E1-8AF8-772FE3FC256A}.Release Mac|Any CPU.Build.0 = Release|Any CPU + {2C587020-5F9F-40E1-8AF8-772FE3FC256A}.Release Mac|x64.ActiveCfg = Release|Any CPU + {2C587020-5F9F-40E1-8AF8-772FE3FC256A}.Release Mac|x64.Build.0 = Release|Any CPU + {2C587020-5F9F-40E1-8AF8-772FE3FC256A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2C587020-5F9F-40E1-8AF8-772FE3FC256A}.Release|Any CPU.Build.0 = Release|Any CPU + {2C587020-5F9F-40E1-8AF8-772FE3FC256A}.Release|x64.ActiveCfg = Release|Any CPU + {2C587020-5F9F-40E1-8AF8-772FE3FC256A}.Release|x64.Build.0 = Release|Any CPU + {C9F084AF-FB70-4F5F-ACEB-DB6818BBECAF}.Debug Mac|Any CPU.ActiveCfg = Debug|Any CPU + {C9F084AF-FB70-4F5F-ACEB-DB6818BBECAF}.Debug Mac|Any CPU.Build.0 = Debug|Any CPU + {C9F084AF-FB70-4F5F-ACEB-DB6818BBECAF}.Debug Mac|x64.ActiveCfg = Debug|Any CPU + {C9F084AF-FB70-4F5F-ACEB-DB6818BBECAF}.Debug Mac|x64.Build.0 = Debug|Any CPU + {C9F084AF-FB70-4F5F-ACEB-DB6818BBECAF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C9F084AF-FB70-4F5F-ACEB-DB6818BBECAF}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C9F084AF-FB70-4F5F-ACEB-DB6818BBECAF}.Debug|x64.ActiveCfg = Debug|Any CPU + {C9F084AF-FB70-4F5F-ACEB-DB6818BBECAF}.Debug|x64.Build.0 = Debug|Any CPU + {C9F084AF-FB70-4F5F-ACEB-DB6818BBECAF}.Release Mac|Any CPU.ActiveCfg = Release|Any CPU + {C9F084AF-FB70-4F5F-ACEB-DB6818BBECAF}.Release Mac|Any CPU.Build.0 = Release|Any CPU + {C9F084AF-FB70-4F5F-ACEB-DB6818BBECAF}.Release Mac|x64.ActiveCfg = Release|Any CPU + {C9F084AF-FB70-4F5F-ACEB-DB6818BBECAF}.Release Mac|x64.Build.0 = Release|Any CPU + {C9F084AF-FB70-4F5F-ACEB-DB6818BBECAF}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C9F084AF-FB70-4F5F-ACEB-DB6818BBECAF}.Release|Any CPU.Build.0 = Release|Any CPU + {C9F084AF-FB70-4F5F-ACEB-DB6818BBECAF}.Release|x64.ActiveCfg = Release|Any CPU + {C9F084AF-FB70-4F5F-ACEB-DB6818BBECAF}.Release|x64.Build.0 = Release|Any CPU + {4E83BA93-4EC4-4A6E-AD27-8CD9A409FD23}.Debug Mac|Any CPU.ActiveCfg = Debug|Any CPU + {4E83BA93-4EC4-4A6E-AD27-8CD9A409FD23}.Debug Mac|Any CPU.Build.0 = Debug|Any CPU + {4E83BA93-4EC4-4A6E-AD27-8CD9A409FD23}.Debug Mac|x64.ActiveCfg = Debug|Any CPU + {4E83BA93-4EC4-4A6E-AD27-8CD9A409FD23}.Debug Mac|x64.Build.0 = Debug|Any CPU + {4E83BA93-4EC4-4A6E-AD27-8CD9A409FD23}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4E83BA93-4EC4-4A6E-AD27-8CD9A409FD23}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4E83BA93-4EC4-4A6E-AD27-8CD9A409FD23}.Debug|x64.ActiveCfg = Debug|Any CPU + {4E83BA93-4EC4-4A6E-AD27-8CD9A409FD23}.Debug|x64.Build.0 = Debug|Any CPU + {4E83BA93-4EC4-4A6E-AD27-8CD9A409FD23}.Release Mac|Any CPU.ActiveCfg = Release|Any CPU + {4E83BA93-4EC4-4A6E-AD27-8CD9A409FD23}.Release Mac|Any CPU.Build.0 = Release|Any CPU + {4E83BA93-4EC4-4A6E-AD27-8CD9A409FD23}.Release Mac|x64.ActiveCfg = Release|Any CPU + {4E83BA93-4EC4-4A6E-AD27-8CD9A409FD23}.Release Mac|x64.Build.0 = Release|Any CPU + {4E83BA93-4EC4-4A6E-AD27-8CD9A409FD23}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4E83BA93-4EC4-4A6E-AD27-8CD9A409FD23}.Release|Any CPU.Build.0 = Release|Any CPU + {4E83BA93-4EC4-4A6E-AD27-8CD9A409FD23}.Release|x64.ActiveCfg = Release|Any CPU + {4E83BA93-4EC4-4A6E-AD27-8CD9A409FD23}.Release|x64.Build.0 = Release|Any CPU + {A6BAA749-0DBE-49A9-9A9D-FCA0F06EE096}.Debug Mac|Any CPU.ActiveCfg = Debug|Any CPU + {A6BAA749-0DBE-49A9-9A9D-FCA0F06EE096}.Debug Mac|Any CPU.Build.0 = Debug|Any CPU + {A6BAA749-0DBE-49A9-9A9D-FCA0F06EE096}.Debug Mac|x64.ActiveCfg = Debug|Any CPU + {A6BAA749-0DBE-49A9-9A9D-FCA0F06EE096}.Debug Mac|x64.Build.0 = Debug|Any CPU + {A6BAA749-0DBE-49A9-9A9D-FCA0F06EE096}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A6BAA749-0DBE-49A9-9A9D-FCA0F06EE096}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A6BAA749-0DBE-49A9-9A9D-FCA0F06EE096}.Debug|x64.ActiveCfg = Debug|Any CPU + {A6BAA749-0DBE-49A9-9A9D-FCA0F06EE096}.Debug|x64.Build.0 = Debug|Any CPU + {A6BAA749-0DBE-49A9-9A9D-FCA0F06EE096}.Release Mac|Any CPU.ActiveCfg = Release|Any CPU + {A6BAA749-0DBE-49A9-9A9D-FCA0F06EE096}.Release Mac|Any CPU.Build.0 = Release|Any CPU + {A6BAA749-0DBE-49A9-9A9D-FCA0F06EE096}.Release Mac|x64.ActiveCfg = Release|Any CPU + {A6BAA749-0DBE-49A9-9A9D-FCA0F06EE096}.Release Mac|x64.Build.0 = Release|Any CPU + {A6BAA749-0DBE-49A9-9A9D-FCA0F06EE096}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A6BAA749-0DBE-49A9-9A9D-FCA0F06EE096}.Release|Any CPU.Build.0 = Release|Any CPU + {A6BAA749-0DBE-49A9-9A9D-FCA0F06EE096}.Release|x64.ActiveCfg = Release|Any CPU + {A6BAA749-0DBE-49A9-9A9D-FCA0F06EE096}.Release|x64.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -3054,10 +3094,14 @@ Global {70DEAA13-6DC8-44A0-B287-9E806A8054F1} = {890F3257-FCC2-4ED8-9180-22B3641B494C} {F06E4C37-4076-4272-9CA6-FB505E02CD31} = {BE521908-7944-46F3-98BF-B47D34509934} {DDBBA313-69A6-40DE-AB3A-79EE5BF32A7E} = {743489BF-1941-43D5-8AF9-35C56D0DCC34} - {631C295A-7CCF-4B42-8686-7034E31469E7} = {804E065F-914C-414A-AF84-009312C3CFF6} - {D940853C-003A-482C-BDB0-665367F274A0} = {804E065F-914C-414A-AF84-009312C3CFF6} - {C9C28F31-1367-438C-83B0-049C3B3A3E3B} = {804E065F-914C-414A-AF84-009312C3CFF6} - {06082BAA-98E8-49B1-9D33-252B126A0561} = {804E065F-914C-414A-AF84-009312C3CFF6} + {34A6BB15-A030-4C5B-94B2-1A1DFE49334A} = {1FE3C60E-7865-40A5-9794-55ECB64F6489} + {35175682-DA83-4C0A-A49D-B191F5885D8E} = {34A6BB15-A030-4C5B-94B2-1A1DFE49334A} + {E7FA6A25-A224-4207-846B-75CE8236228D} = {34A6BB15-A030-4C5B-94B2-1A1DFE49334A} + {9BCE88BA-1E01-44EE-BF9D-2CB906E63E34} = {34A6BB15-A030-4C5B-94B2-1A1DFE49334A} + {2C587020-5F9F-40E1-8AF8-772FE3FC256A} = {804E065F-914C-414A-AF84-009312C3CFF6} + {C9F084AF-FB70-4F5F-ACEB-DB6818BBECAF} = {804E065F-914C-414A-AF84-009312C3CFF6} + {4E83BA93-4EC4-4A6E-AD27-8CD9A409FD23} = {804E065F-914C-414A-AF84-009312C3CFF6} + {A6BAA749-0DBE-49A9-9A9D-FCA0F06EE096} = {804E065F-914C-414A-AF84-009312C3CFF6} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {1D43D91B-4F01-4A78-8250-CC6F9BD93A14} @@ -3084,6 +3128,7 @@ Global ConnectorTeklaStructures\ConnectorTeklaStructuresShared\ConnectorTeklaStructuresShared.projitems*{28e2ea7f-ffd1-4e13-9165-0243b5ac82f5}*SharedItemsImports = 13 Objects\Converters\ConverterAutocadCivil\ConverterAutocadCivilShared\ConverterAutocadCivilShared.projitems*{2d0f9f8a-2e89-4780-978a-cd92d6d7b843}*SharedItemsImports = 13 Objects\Converters\ConverterRevit\ConverterRevitShared\ConverterRevitShared.projitems*{2dcd648d-dca5-4d2a-8b14-ad2cb85d24b0}*SharedItemsImports = 13 + DUI3-DX\Converters\Civil3d\Speckle.Converters.Civil3dShared\Speckle.Converters.Civil3dShared.projitems*{35175682-da83-4c0a-a49d-b191f5885d8e}*SharedItemsImports = 13 ConnectorBentley\ConnectorBentleyShared\ConnectorBentleyShared.projitems*{372d9f0f-ede9-4050-bf8c-758911c5c2e0}*SharedItemsImports = 13 ConnectorTeklaStructures\ConnectorTeklaStructuresShared\ConnectorTeklaStructuresShared.projitems*{3af1ef30-0906-4926-a02c-4e3ad666352a}*SharedItemsImports = 5 ConnectorAutocadCivil\ConnectorAutocadCivil\ConnectorAutocadCivilShared.projitems*{3b9189b9-e485-448a-8793-9b9587a36791}*SharedItemsImports = 5 @@ -3112,7 +3157,6 @@ Global ConnectorRevit\ConnectorRevit\ConnectorRevit.projitems*{5fd0d810-03e9-4fd2-93e4-b1b51e5d82c5}*SharedItemsImports = 13 ConnectorCSI\ConnectorCSIShared\ConnectorCSIShared.projitems*{61374cd0-e774-4dcd-bfab-6356b0931283}*SharedItemsImports = 13 ConnectorRevit\RevitSharedResources\RevitSharedResources.projitems*{61c1304b-ed48-456b-ab90-a89066187952}*SharedItemsImports = 5 - DUI3-DX\Converters\Autocad\Speckle.Converters.AutocadShared\Speckle.Converters.AutocadShared.projitems*{631c295a-7ccf-4b42-8686-7034e31469e7}*SharedItemsImports = 5 ConnectorAutocadCivil\ConnectorAutocadCivil\ConnectorAutocadCivilShared.projitems*{658de496-5177-4cd5-a949-fe59e47109b6}*SharedItemsImports = 5 ConnectorTeklaStructures\ConnectorTeklaStructuresShared\ConnectorTeklaStructuresShared.projitems*{67157264-aaa5-46a8-a38b-16254b49b892}*SharedItemsImports = 5 Objects\Converters\ConverterDynamo\ConverterDynamoShared\ConverterDynamoShared.projitems*{67a463d3-e98b-4b16-b069-d7bbb05386a1}*SharedItemsImports = 5 @@ -3147,6 +3191,7 @@ Global ConnectorBentley\ConnectorBentleyShared\ConnectorBentleyShared.projitems*{a3a0ee09-6055-4009-ab8e-13fbc1a403a9}*SharedItemsImports = 5 ConnectorNavisworks\ConnectorNavisworks\ConnectorNavisworks.Shared.projitems*{a517a609-cab1-4b33-b83c-1b13b34e4560}*SharedItemsImports = 13 ConnectorRhino\ConnectorRhino\ConnectorRhinoShared\ConnectorRhinoShared.projitems*{a64acbf9-db82-4839-af99-57ed2e7989f4}*SharedItemsImports = 5 + DUI3-DX\Converters\Autocad\Speckle.Converters.AutocadShared\Speckle.Converters.AutocadShared.projitems*{a6baa749-0dbe-49a9-9a9d-fca0f06ee096}*SharedItemsImports = 5 Objects\Converters\ConverterRhinoGh\ConverterRhinoGhShared\ConverterRhinoGhShared.projitems*{a8607330-1b23-43cc-8b9b-25818d9c1d64}*SharedItemsImports = 5 Objects\Converters\ConverterDynamo\ConverterDynamoShared\ConverterDynamoShared.projitems*{aaa05c3d-856d-4f22-971e-5e3f066d0eae}*SharedItemsImports = 5 Objects\Converters\ConverterRevit\ConverterRevitShared\ConverterRevitShared.projitems*{aaa05c3d-856d-4f22-971e-5e3f066d0eae}*SharedItemsImports = 5 @@ -3165,7 +3210,7 @@ Global Objects\Converters\ConverterRevit\ConverterRevitShared\ConverterRevitShared.projitems*{c21a6553-b4ec-4ec3-b82a-c7a83cffb809}*SharedItemsImports = 5 ConnectorRevit\RevitSharedResources\RevitSharedResources.projitems*{c2ba8b6b-72bd-4dab-865f-90c66083bdb2}*SharedItemsImports = 5 Objects\Converters\ConverterNavisworks\ConverterNavisworks\ConverterNavisworksShared.projitems*{c3232ef3-2000-44c6-a330-b94531c9cc83}*SharedItemsImports = 13 - DUI3-DX\Converters\Autocad\Speckle.Converters.AutocadShared\Speckle.Converters.AutocadShared.projitems*{c9c28f31-1367-438c-83b0-049c3b3a3e3b}*SharedItemsImports = 5 + DUI3-DX\Converters\Autocad\Speckle.Converters.AutocadShared\Speckle.Converters.AutocadShared.projitems*{c9f084af-fb70-4f5f-aceb-db6818bbecaf}*SharedItemsImports = 5 Objects\Converters\ConverterNavisworks\ConverterNavisworks\ConverterNavisworksShared.projitems*{cafd4eac-75a8-4fc8-94e5-91cadc39f5b3}*SharedItemsImports = 5 Objects\Converters\ConverterRevit\ConverterRevitShared\ConverterRevitShared.projitems*{cc790553-8088-41a9-83cd-b29f7141f408}*SharedItemsImports = 5 Objects\Converters\ConverterNavisworks\ConverterNavisworks\ConverterNavisworksShared.projitems*{cd334556-ba2b-4272-a1eb-628e8152204a}*SharedItemsImports = 5 @@ -3181,6 +3226,8 @@ Global ConnectorNavisworks\ConnectorNavisworks\ConnectorNavisworks.Shared.projitems*{debc2174-5e31-4b6e-8680-690d75e50e2d}*SharedItemsImports = 5 ConnectorRevit\ConnectorRevit\ConnectorRevit.projitems*{dfdfdbb8-018b-4dcb-a012-54227abf53a7}*SharedItemsImports = 5 DUI3-DX\Converters\Revit\Speckle.Converters.RevitShared\Speckle.Converters.RevitShared.projitems*{e1c43415-3200-45f4-8bf9-a4dd7d7f2ed6}*SharedItemsImports = 13 + DUI3-DX\Converters\Autocad\Speckle.Converters.AutocadShared\Speckle.Converters.AutocadShared.projitems*{e7fa6a25-a224-4207-846b-75ce8236228d}*SharedItemsImports = 5 + DUI3-DX\Converters\Civil3d\Speckle.Converters.Civil3dShared\Speckle.Converters.Civil3dShared.projitems*{e7fa6a25-a224-4207-846b-75ce8236228d}*SharedItemsImports = 5 ConnectorRevit\RevitSharedResources\RevitSharedResources.projitems*{ea34ac83-5825-4473-a572-d5127fd33b1b}*SharedItemsImports = 5 Objects\Converters\ConverterRhinoGh\ConverterRhinoGhShared\ConverterRhinoGhShared.projitems*{ea81f83c-1485-49c8-ab05-9df2798d70ec}*SharedItemsImports = 5 Objects\Converters\ConverterTeklaStructures\ConverterTeklaStructuresShared\ConverterTeklaStructuresShared.projitems*{eb52e451-9ed8-460e-9ee4-6717bfb12eab}*SharedItemsImports = 5 diff --git a/DUI3-DX.slnf b/DUI3-DX.slnf index 4f4a6e3edb..ae770c7ef8 100644 --- a/DUI3-DX.slnf +++ b/DUI3-DX.slnf @@ -12,11 +12,14 @@ "DUI3-DX\\Connectors\\Rhino\\Speckle.Connectors.Rhino7\\Speckle.Connectors.Rhino7.csproj", "DUI3-DX\\Converters\\ArcGIS\\Speckle.Converters.ArcGIS3.DependencyInjection\\Speckle.Converters.ArcGIS3.DependencyInjection.csproj", "DUI3-DX\\Converters\\ArcGIS\\Speckle.Converters.ArcGIS3\\Speckle.Converters.ArcGIS3.csproj", - "DUI3-DX\\Converters\\Autocad\\2023\\Speckle.Converters.Autocad2023.DependencyInjection\\Speckle.Converters.Autocad2023.DependencyInjection.csproj", - "DUI3-DX\\Converters\\Autocad\\2023\\Speckle.Converters.Autocad2023\\Speckle.Converters.Autocad2023.csproj", - "DUI3-DX\\Converters\\Autocad\\2024\\Speckle.Converters.Autocad2024.DependencyInjection\\Speckle.Converters.Autocad2024.DependencyInjection.csproj", - "DUI3-DX\\Converters\\Autocad\\2024\\Speckle.Converters.Autocad2024\\Speckle.Converters.Autocad2024.csproj", + "DUI3-DX\\Converters\\Autocad\\Speckle.Converters.Autocad2023.DependencyInjection\\Speckle.Converters.Autocad2023.DependencyInjection.csproj", + "DUI3-DX\\Converters\\Autocad\\Speckle.Converters.Autocad2023\\Speckle.Converters.Autocad2023.csproj", + "DUI3-DX\\Converters\\Autocad\\Speckle.Converters.Autocad2024.DependencyInjection\\Speckle.Converters.Autocad2024.DependencyInjection.csproj", + "DUI3-DX\\Converters\\Autocad\\Speckle.Converters.Autocad2024\\Speckle.Converters.Autocad2024.csproj", "DUI3-DX\\Converters\\Autocad\\Speckle.Converters.AutocadShared\\Speckle.Converters.AutocadShared.shproj", + "DUI3-DX\\Converters\\Civil3d\\Speckle.Converters.Civil3d2024.DependencyInjection\\Speckle.Converters.Civil3d2024.DependencyInjection.csproj", + "DUI3-DX\\Converters\\Civil3d\\Speckle.Converters.Civil3d2024\\Speckle.Converters.Civil3d2024.csproj", + "DUI3-DX\\Converters\\Civil3d\\Speckle.Converters.Civil3dShared\\Speckle.Converters.Civil3dShared.shproj", "DUI3-DX\\Converters\\Revit\\Speckle.Converters.Revit2023.DependencyInjection\\Speckle.Converters.Revit2023.DependencyInjection.csproj", "DUI3-DX\\Converters\\Revit\\Speckle.Converters.Revit2023\\Speckle.Converters.Revit2023.csproj", "DUI3-DX\\Converters\\Revit\\Speckle.Converters.RevitShared\\Speckle.Converters.RevitShared.shproj", diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.Autocad2023/Speckle.Connectors.Autocad2023.csproj b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.Autocad2023/Speckle.Connectors.Autocad2023.csproj index e3913f6c11..88e6b47cdf 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.Autocad2023/Speckle.Connectors.Autocad2023.csproj +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.Autocad2023/Speckle.Connectors.Autocad2023.csproj @@ -10,7 +10,7 @@ - + @@ -19,7 +19,7 @@ - + diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/DependencyInjection/AutocadConnectorModule.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/DependencyInjection/AutocadConnectorModule.cs index 52da8c7d75..777a2ed66c 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/DependencyInjection/AutocadConnectorModule.cs +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/DependencyInjection/AutocadConnectorModule.cs @@ -1,25 +1,6 @@ #if AUTOCAD -using Autodesk.AutoCAD.DatabaseServices; -using Speckle.Autofac; using Speckle.Autofac.DependencyInjection; -using Speckle.Connectors.Autocad.Bindings; -using Speckle.Connectors.Autocad.Filters; -using Speckle.Connectors.Autocad.HostApp; -using Speckle.Connectors.Autocad.Interfaces; -using Speckle.Connectors.Autocad.Operations.Receive; -using Speckle.Connectors.Autocad.Operations.Send; -using Speckle.Connectors.Autocad.Plugin; -using Speckle.Connectors.DUI; using Speckle.Connectors.DUI.Bindings; -using Speckle.Connectors.DUI.Models; -using Speckle.Connectors.DUI.Models.Card.SendFilter; -using Speckle.Connectors.DUI.WebView; -using Speckle.Connectors.Utils; -using Speckle.Connectors.Utils.Builders; -using Speckle.Connectors.Utils.Caching; -using Speckle.Connectors.Utils.Instances; -using Speckle.Connectors.Utils.Operations; -using Speckle.Core.Models.GraphTraversal; namespace Speckle.Connectors.Autocad.DependencyInjection; @@ -27,43 +8,14 @@ public class AutocadConnectorModule : ISpeckleModule { public void Load(SpeckleContainerBuilder builder) { - builder.AddAutofac(); - builder.AddConnectorUtils(); - builder.AddDUI(); - builder.AddDUIView(); - - // Register other connector specific types - builder.AddSingleton(); - builder.AddTransient(); - builder.AddSingleton(new AutocadDocumentManager()); // TODO: Dependent to TransactionContext, can be moved to AutocadContext - builder.AddSingleton(); - builder.AddSingleton(); - builder.AddSingleton(); - - SharedConnectorModule.LoadShared(builder); - - - builder.AddScoped(); + SharedRegistration.Load(builder); // Operations - builder.AddScoped>(); - builder.AddSingleton(DefaultTraversal.CreateTraversalFunc()); - - // Object Builders - builder.AddScoped(); - builder.AddScoped, AutocadRootObjectBuilder>(); + SharedRegistration.LoadSend(builder); + SharedRegistration.LoadReceive(builder); // Register bindings builder.AddSingleton("connectorName", "Autocad"); // POC: Easier like this for now, should be cleaned up later - builder.AddSingleton(); - builder.AddSingleton(); - - // register send filters - builder.AddTransient(); - - // register send conversion cache - builder.AddSingleton(); - builder.AddScoped>, AutocadInstanceObjectManager>(); } } #endif diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/DependencyInjection/Civil3dConnectorModule.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/DependencyInjection/Civil3dConnectorModule.cs index e6889843c5..0b06869c6e 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/DependencyInjection/Civil3dConnectorModule.cs +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/DependencyInjection/Civil3dConnectorModule.cs @@ -1,13 +1,7 @@ #if CIVIL3D + using Speckle.Autofac.DependencyInjection; -using Speckle.Connectors.Autocad.Bindings; -using Speckle.Connectors.Autocad.Filters; -using Speckle.Connectors.Autocad.Operations.Send; using Speckle.Connectors.DUI.Bindings; -using Speckle.Connectors.DUI.Models.Card.SendFilter; -using Speckle.Connectors.Utils.Builders; -using Speckle.Connectors.Utils.Caching; -using Speckle.Connectors.Utils.Operations; namespace Speckle.Connectors.Autocad.DependencyInjection; @@ -15,23 +9,11 @@ public class Civil3dConnectorModule : ISpeckleModule { public void Load(SpeckleContainerBuilder builder) { - SharedConnectorModule.LoadShared(builder); - - // Operations - builder.AddScoped>(); - - // Object Builders - builder.AddScoped, AutocadRootObjectBuilder>(); - + SharedRegistration.Load(builder); + SharedRegistration.LoadSend(builder); + // Register bindings builder.AddSingleton("connectorName", "Civil3d"); // POC: Easier like this for now, should be cleaned up later - builder.AddSingleton(); - - // register send filters - builder.AddTransient(); - - // register send conversion cache - builder.AddSingleton(); } } #endif diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/DependencyInjection/SharedConnectorModule.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/DependencyInjection/SharedConnectorModule.cs deleted file mode 100644 index 48b71d723e..0000000000 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/DependencyInjection/SharedConnectorModule.cs +++ /dev/null @@ -1,40 +0,0 @@ -using Speckle.Autofac; -using Speckle.Autofac.DependencyInjection; -using Speckle.Connectors.Autocad.Bindings; -using Speckle.Connectors.Autocad.HostApp; -using Speckle.Connectors.Autocad.Interfaces; -using Speckle.Connectors.Autocad.Plugin; -using Speckle.Connectors.DUI; -using Speckle.Connectors.DUI.Bindings; -using Speckle.Connectors.DUI.Models; -using Speckle.Connectors.DUI.WebView; -using Speckle.Connectors.Utils; - -namespace Speckle.Connectors.Autocad.DependencyInjection; - -public static class SharedConnectorModule -{ - public static void LoadShared(SpeckleContainerBuilder builder) - { - builder.AddAutofac(); - builder.AddConnectorUtils(); - builder.AddDUI(); - builder.AddDUIView(); - - // Register other connector specific types - builder.AddSingleton(); - builder.AddTransient(); - builder.AddSingleton(new AutocadDocumentManager()); // TODO: Dependent to TransactionContext, can be moved to AutocadContext - builder.AddSingleton(); - builder.AddSingleton(); - builder.AddSingleton(); - builder.AddSingleton(); - - // Register bindings - builder.AddSingleton(); - builder.AddSingleton(); - builder.AddSingleton(); - builder.AddSingleton(); - builder.AddSingleton(); - } -} diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/DependencyInjection/SharedRegistration.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/DependencyInjection/SharedRegistration.cs new file mode 100644 index 0000000000..b9b5856054 --- /dev/null +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/DependencyInjection/SharedRegistration.cs @@ -0,0 +1,82 @@ +using Autodesk.AutoCAD.DatabaseServices; +using Speckle.Autofac; +using Speckle.Autofac.DependencyInjection; +using Speckle.Connectors.Autocad.Bindings; +using Speckle.Connectors.Autocad.HostApp; +using Speckle.Connectors.Autocad.Interfaces; +using Speckle.Connectors.Autocad.Plugin; +using Speckle.Connectors.DUI; +using Speckle.Connectors.DUI.Bindings; +using Speckle.Connectors.DUI.Models; +using Speckle.Connectors.DUI.WebView; +using Speckle.Connectors.Utils; +using Speckle.Connectors.Autocad.Filters; +using Speckle.Connectors.Autocad.Operations.Send; +using Speckle.Connectors.DUI.Models.Card.SendFilter; +using Speckle.Connectors.Utils.Builders; +using Speckle.Connectors.Utils.Caching; +using Speckle.Connectors.Utils.Operations; +using Speckle.Connectors.Utils.Instances; +using Speckle.Connectors.Autocad.Operations.Receive; + +using Speckle.Core.Models.GraphTraversal; + +namespace Speckle.Connectors.Autocad.DependencyInjection; + +public static class SharedRegistration +{ + public static void Load(SpeckleContainerBuilder builder) + { + builder.AddAutofac(); + builder.AddConnectorUtils(); + builder.AddDUI(); + builder.AddDUIView(); + + // Register other connector specific types + builder.AddSingleton(); + builder.AddTransient(); + builder.AddSingleton(new AutocadDocumentManager()); // TODO: Dependent to TransactionContext, can be moved to AutocadContext + builder.AddSingleton(); + builder.AddSingleton(); + builder.AddScoped(); + builder.AddSingleton(); + + // Register bindings + builder.AddSingleton(); + builder.AddSingleton(); + builder.AddSingleton(); + builder.AddSingleton(); + builder.AddSingleton(); + } + + public static void LoadSend(SpeckleContainerBuilder builder) + { + // Operations + builder.AddScoped>(); + + // Object Builders + builder.AddScoped, AutocadRootObjectBuilder>(); + + // Register bindings + builder.AddSingleton(); + + // register send filters + builder.AddTransient(); + + // register send conversion cache + builder.AddSingleton(); + builder.AddScoped>, AutocadInstanceObjectManager>(); + } + + public static void LoadReceive(SpeckleContainerBuilder builder) + { + // traversal + builder.AddSingleton(DefaultTraversal.CreateTraversalFunc()); + + // Object Builders + builder.AddScoped(); + + // Register bindings + builder.AddSingleton(); + } +} diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Speckle.Connectors.AutocadShared.projitems b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Speckle.Connectors.AutocadShared.projitems index b95639804d..8fb44c372f 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Speckle.Connectors.AutocadShared.projitems +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Speckle.Connectors.AutocadShared.projitems @@ -13,7 +13,7 @@ - + diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.Civil3d2024/Speckle.Connectors.Civil3d2024.csproj b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.Civil3d2024/Speckle.Connectors.Civil3d2024.csproj index b04e1c73e0..8e9190f710 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.Civil3d2024/Speckle.Connectors.Civil3d2024.csproj +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.Civil3d2024/Speckle.Connectors.Civil3d2024.csproj @@ -1,4 +1,4 @@ - + Speckle.Connectors.Civil3d net48 @@ -10,7 +10,7 @@ - + @@ -19,6 +19,7 @@ + diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.Civil3d2024/packages.lock.json b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.Civil3d2024/packages.lock.json index 71a6fee082..aff9c51d13 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.Civil3d2024/packages.lock.json +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.Civil3d2024/packages.lock.json @@ -28,6 +28,12 @@ "resolved": "1.14.1", "contentHash": "mOOmFYwad3MIOL14VCjj02LljyF1GNw1wP0YVlxtcPvqdxjGGMNdNJJxHptlry3MOd8b40Flm8RPOM8JOlN2sQ==" }, + "Speckle.AutoCAD.API": { + "type": "Direct", + "requested": "[2024.0.0, )", + "resolved": "2024.0.0", + "contentHash": "pZZ5uI+NXhZaQnsqRkgp/rywqBAjDObDJ9XNFGJvemT5k2OthDpHzlK/mKxz8QDCYie7uImQ8dv3uWj2QUFDPw==" + }, "Speckle.Civil3D.API": { "type": "Direct", "requested": "[2024.0.0, )", @@ -458,18 +464,19 @@ "Speckle.Core": "[3.0.1-alpha.14, )" } }, - "speckle.converters.autocad2024": { + "speckle.converters.civil3d2024": { "type": "Project", "dependencies": { "Speckle.AutoCAD.API": "[2024.0.0, )", + "Speckle.Civil3D.API": "[2024.0.0, )", "Speckle.Converters.Common": "[2.0.999-local, )" } }, - "speckle.converters.autocad2024.dependencyinjection": { + "speckle.converters.civil3d2024.dependencyinjection": { "type": "Project", "dependencies": { "Autofac": "[5.2.0, )", - "Speckle.Converters.Autocad2024": "[2.0.999-local, )", + "Speckle.Converters.Civil3d2024": "[2.0.999-local, )", "Speckle.Converters.Common.DependencyInjection": "[2.0.999-local, )" } }, @@ -512,12 +519,6 @@ "Serilog": "2.12.0" } }, - "Speckle.AutoCAD.API": { - "type": "CentralTransitive", - "requested": "[2023.0.0, )", - "resolved": "2024.0.0", - "contentHash": "pZZ5uI+NXhZaQnsqRkgp/rywqBAjDObDJ9XNFGJvemT5k2OthDpHzlK/mKxz8QDCYie7uImQ8dv3uWj2QUFDPw==" - }, "Speckle.Core": { "type": "CentralTransitive", "requested": "[3.0.1-alpha.14, )", diff --git a/DUI3-DX/Converters/Autocad/2023/Speckle.Converters.Autocad2023.DependencyInjection/AutocadConverterModule.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2023.DependencyInjection/AutocadConverterModule.cs similarity index 100% rename from DUI3-DX/Converters/Autocad/2023/Speckle.Converters.Autocad2023.DependencyInjection/AutocadConverterModule.cs rename to DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2023.DependencyInjection/AutocadConverterModule.cs diff --git a/DUI3-DX/Converters/Autocad/2023/Speckle.Converters.Autocad2023.DependencyInjection/Speckle.Converters.Autocad2023.DependencyInjection.csproj b/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2023.DependencyInjection/Speckle.Converters.Autocad2023.DependencyInjection.csproj similarity index 72% rename from DUI3-DX/Converters/Autocad/2023/Speckle.Converters.Autocad2023.DependencyInjection/Speckle.Converters.Autocad2023.DependencyInjection.csproj rename to DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2023.DependencyInjection/Speckle.Converters.Autocad2023.DependencyInjection.csproj index 303e2f808a..aa5a5af310 100644 --- a/DUI3-DX/Converters/Autocad/2023/Speckle.Converters.Autocad2023.DependencyInjection/Speckle.Converters.Autocad2023.DependencyInjection.csproj +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2023.DependencyInjection/Speckle.Converters.Autocad2023.DependencyInjection.csproj @@ -4,14 +4,14 @@ net48 x64 - + - - + - + + diff --git a/DUI3-DX/Converters/Autocad/2023/Speckle.Converters.Autocad2023.DependencyInjection/packages.lock.json b/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2023.DependencyInjection/packages.lock.json similarity index 99% rename from DUI3-DX/Converters/Autocad/2023/Speckle.Converters.Autocad2023.DependencyInjection/packages.lock.json rename to DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2023.DependencyInjection/packages.lock.json index e51635ea86..99b4b1fb8c 100644 --- a/DUI3-DX/Converters/Autocad/2023/Speckle.Converters.Autocad2023.DependencyInjection/packages.lock.json +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2023.DependencyInjection/packages.lock.json @@ -396,7 +396,7 @@ }, "Speckle.AutoCAD.API": { "type": "CentralTransitive", - "requested": "[2023.0.0, )", + "requested": "[2024.0.0, )", "resolved": "2023.0.0", "contentHash": "aNfiNw9zRW8pCl8AAQK7afEJuea4bJ4sFNsGVSDrdq1egaonZrwALU01dSyFNCE8tne86eVjlprpOGG6r0+G/A==" }, diff --git a/DUI3-DX/Converters/Autocad/2023/Speckle.Converters.Autocad2023/Speckle.Converters.Autocad2023.csproj b/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2023/Speckle.Converters.Autocad2023.csproj similarity index 57% rename from DUI3-DX/Converters/Autocad/2023/Speckle.Converters.Autocad2023/Speckle.Converters.Autocad2023.csproj rename to DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2023/Speckle.Converters.Autocad2023.csproj index 2fc9b23da0..06ab0541d9 100644 --- a/DUI3-DX/Converters/Autocad/2023/Speckle.Converters.Autocad2023/Speckle.Converters.Autocad2023.csproj +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2023/Speckle.Converters.Autocad2023.csproj @@ -10,9 +10,9 @@ - + - + diff --git a/DUI3-DX/Converters/Autocad/2023/Speckle.Converters.Autocad2023/packages.lock.json b/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2023/packages.lock.json similarity index 100% rename from DUI3-DX/Converters/Autocad/2023/Speckle.Converters.Autocad2023/packages.lock.json rename to DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2023/packages.lock.json diff --git a/DUI3-DX/Converters/Autocad/2024/Speckle.Converters.Autocad2024.DependencyInjection/AutocadConverterModule.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2024.DependencyInjection/AutocadConverterModule.cs similarity index 91% rename from DUI3-DX/Converters/Autocad/2024/Speckle.Converters.Autocad2024.DependencyInjection/AutocadConverterModule.cs rename to DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2024.DependencyInjection/AutocadConverterModule.cs index 66c4b57aff..6d9b3a767a 100644 --- a/DUI3-DX/Converters/Autocad/2024/Speckle.Converters.Autocad2024.DependencyInjection/AutocadConverterModule.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2024.DependencyInjection/AutocadConverterModule.cs @@ -5,7 +5,7 @@ using Speckle.Converters.Common; using Speckle.Converters.Common.DependencyInjection; -namespace Speckle.Converters.Autocad20243.DependencyInjection; +namespace Speckle.Converters.Autocad2024.DependencyInjection; public class AutocadConverterModule : ISpeckleModule { diff --git a/DUI3-DX/Converters/Autocad/2024/Speckle.Converters.Autocad2024.DependencyInjection/Speckle.Converters.Autocad2024.DependencyInjection.csproj b/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2024.DependencyInjection/Speckle.Converters.Autocad2024.DependencyInjection.csproj similarity index 73% rename from DUI3-DX/Converters/Autocad/2024/Speckle.Converters.Autocad2024.DependencyInjection/Speckle.Converters.Autocad2024.DependencyInjection.csproj rename to DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2024.DependencyInjection/Speckle.Converters.Autocad2024.DependencyInjection.csproj index 05de443d1e..79c93f345c 100644 --- a/DUI3-DX/Converters/Autocad/2024/Speckle.Converters.Autocad2024.DependencyInjection/Speckle.Converters.Autocad2024.DependencyInjection.csproj +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2024.DependencyInjection/Speckle.Converters.Autocad2024.DependencyInjection.csproj @@ -6,7 +6,7 @@ - + diff --git a/DUI3-DX/Converters/Autocad/2024/Speckle.Converters.Autocad2024.DependencyInjection/packages.lock.json b/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2024.DependencyInjection/packages.lock.json similarity index 99% rename from DUI3-DX/Converters/Autocad/2024/Speckle.Converters.Autocad2024.DependencyInjection/packages.lock.json rename to DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2024.DependencyInjection/packages.lock.json index bb0e3cfe08..fe9923d926 100644 --- a/DUI3-DX/Converters/Autocad/2024/Speckle.Converters.Autocad2024.DependencyInjection/packages.lock.json +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2024.DependencyInjection/packages.lock.json @@ -396,7 +396,7 @@ }, "Speckle.AutoCAD.API": { "type": "CentralTransitive", - "requested": "[2023.0.0, )", + "requested": "[2024.0.0, )", "resolved": "2024.0.0", "contentHash": "pZZ5uI+NXhZaQnsqRkgp/rywqBAjDObDJ9XNFGJvemT5k2OthDpHzlK/mKxz8QDCYie7uImQ8dv3uWj2QUFDPw==" }, diff --git a/DUI3-DX/Converters/Autocad/2024/Speckle.Converters.Autocad2024/Speckle.Converters.Autocad2024.csproj b/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2024/Speckle.Converters.Autocad2024.csproj similarity index 57% rename from DUI3-DX/Converters/Autocad/2024/Speckle.Converters.Autocad2024/Speckle.Converters.Autocad2024.csproj rename to DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2024/Speckle.Converters.Autocad2024.csproj index 05f9613b37..da1163a6ad 100644 --- a/DUI3-DX/Converters/Autocad/2024/Speckle.Converters.Autocad2024/Speckle.Converters.Autocad2024.csproj +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2024/Speckle.Converters.Autocad2024.csproj @@ -10,9 +10,9 @@ - + - + diff --git a/DUI3-DX/Converters/Autocad/2024/Speckle.Converters.Autocad2024/packages.lock.json b/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2024/packages.lock.json similarity index 100% rename from DUI3-DX/Converters/Autocad/2024/Speckle.Converters.Autocad2024/packages.lock.json rename to DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2024/packages.lock.json diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/GlobalUsings.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/GlobalUsings.cs index 9c48f198aa..7922a59807 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/GlobalUsings.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/GlobalUsings.cs @@ -1,5 +1,6 @@ global using ADB = Autodesk.AutoCAD.DatabaseServices; global using AG = Autodesk.AutoCAD.Geometry; +global using ABR = Autodesk.AutoCAD.BoundaryRepresentation; global using SOG = Objects.Geometry; global using SOP = Objects.Primitive; global using Document = Autodesk.AutoCAD.ApplicationServices.Document; diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/Speckle.Converters.AutocadShared.projitems b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/Speckle.Converters.AutocadShared.projitems index 3644c81cc1..8fb784a3af 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/Speckle.Converters.AutocadShared.projitems +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/Speckle.Converters.AutocadShared.projitems @@ -38,6 +38,13 @@ + + + + + + + @@ -49,11 +56,12 @@ - + + \ No newline at end of file diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/ArcToSpeckleConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/ArcToSpeckleConverter.cs index 36d7b796f6..c437aa04e0 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/ArcToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/ArcToSpeckleConverter.cs @@ -5,55 +5,16 @@ namespace Speckle.Converters.Autocad.ToSpeckle.Geometry; [NameAndRankValue(nameof(ADB.Arc), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class DBArcToSpeckleConverter : IToSpeckleTopLevelConverter, ITypedConverter +public class DBArcToSpeckleConverter : IToSpeckleTopLevelConverter { - private readonly ITypedConverter _pointConverter; - private readonly ITypedConverter _planeConverter; - private readonly ITypedConverter _boxConverter; - private readonly IConversionContextStack _contextStack; + private readonly ITypedConverter _arcConverter; - public DBArcToSpeckleConverter( - ITypedConverter pointConverter, - ITypedConverter planeConverter, - ITypedConverter boxConverter, - IConversionContextStack contextStack - ) + public DBArcToSpeckleConverter(ITypedConverter arcConverter) { - _pointConverter = pointConverter; - _planeConverter = planeConverter; - _boxConverter = boxConverter; - _contextStack = contextStack; + _arcConverter = arcConverter; } public Base Convert(object target) => Convert((ADB.Arc)target); - public SOG.Arc Convert(ADB.Arc target) - { - SOG.Plane plane = _planeConverter.Convert(target.GetPlane()); - SOG.Point start = _pointConverter.Convert(target.StartPoint); - SOG.Point end = _pointConverter.Convert(target.EndPoint); - SOG.Point mid = _pointConverter.Convert(target.GetPointAtDist(target.Length / 2.0)); - SOP.Interval domain = new(target.StartParam, target.EndParam); - SOG.Box bbox = _boxConverter.Convert(target.GeometricExtents); - - SOG.Arc arc = - new( - plane, - target.Radius, - target.StartAngle, - target.EndAngle, - target.TotalAngle, - _contextStack.Current.SpeckleUnits - ) - { - startPoint = start, - endPoint = end, - midPoint = mid, - domain = domain, - length = target.Length, - bbox = bbox - }; - - return arc; - } + public SOG.Arc Convert(ADB.Arc target) => _arcConverter.Convert(target); } diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/CircleToSpeckleConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/CircleToSpeckleConverter.cs index 18b45a8daf..16b1a2bd26 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/CircleToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/CircleToSpeckleConverter.cs @@ -7,30 +7,14 @@ namespace Speckle.Converters.Autocad.ToSpeckle.Geometry; [NameAndRankValue(nameof(ADB.Circle), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] public class DBCircleToSpeckleConverter : IToSpeckleTopLevelConverter { - private readonly ITypedConverter _planeConverter; - private readonly ITypedConverter _boxConverter; - private readonly IConversionContextStack _contextStack; + private readonly ITypedConverter _circleConverter; - public DBCircleToSpeckleConverter( - ITypedConverter planeConverter, - ITypedConverter boxConverter, - IConversionContextStack contextStack - ) + public DBCircleToSpeckleConverter(ITypedConverter circleConverter) { - _planeConverter = planeConverter; - _boxConverter = boxConverter; - _contextStack = contextStack; + _circleConverter = circleConverter; } public Base Convert(object target) => RawConvert((ADB.Circle)target); - public SOG.Circle RawConvert(ADB.Circle target) - { - SOG.Plane plane = _planeConverter.Convert(target.GetPlane()); - SOG.Box bbox = _boxConverter.Convert(target.GeometricExtents); - SOG.Circle circle = - new(plane, target.Radius, _contextStack.Current.SpeckleUnits) { length = target.Circumference, bbox = bbox }; - - return circle; - } + public SOG.Circle RawConvert(ADB.Circle target) => _circleConverter.Convert(target); } diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/EllipseToSpeckleConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/EllipseToSpeckleConverter.cs index 524e1a1d8c..53d3d7e5b7 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/EllipseToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/EllipseToSpeckleConverter.cs @@ -7,40 +7,14 @@ namespace Speckle.Converters.Autocad.ToSpeckle.Geometry; [NameAndRankValue(nameof(ADB.Ellipse), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] public class DBEllipseToSpeckleConverter : IToSpeckleTopLevelConverter { - private readonly ITypedConverter _planeConverter; - private readonly ITypedConverter _boxConverter; - private readonly IConversionContextStack _contextStack; + private readonly ITypedConverter _ellipseConverter; - public DBEllipseToSpeckleConverter( - ITypedConverter planeConverter, - ITypedConverter boxConverter, - IConversionContextStack contextStack - ) + public DBEllipseToSpeckleConverter(ITypedConverter ellipseConverter) { - _planeConverter = planeConverter; - _boxConverter = boxConverter; - _contextStack = contextStack; + _ellipseConverter = ellipseConverter; } public Base Convert(object target) => RawConvert((ADB.Ellipse)target); - public SOG.Ellipse RawConvert(ADB.Ellipse target) - { - SOG.Plane plane = _planeConverter.Convert(new AG.Plane(target.Center, target.MajorAxis, target.MinorAxis)); - SOG.Box bbox = _boxConverter.Convert(target.GeometricExtents); - - // the start and end param corresponds to start and end angle in radians - SOP.Interval trim = new(target.StartAngle, target.EndAngle); - - SOG.Ellipse ellipse = - new(plane, target.MajorRadius, target.MinorRadius, _contextStack.Current.SpeckleUnits) - { - domain = new(0, Math.PI * 2), - trimDomain = trim, - length = target.GetDistanceAtParameter(target.EndParam), - bbox = bbox - }; - - return ellipse; - } + public SOG.Ellipse RawConvert(ADB.Ellipse target) => _ellipseConverter.Convert(target); } diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/LineToSpeckleConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/LineToSpeckleConverter.cs index 22787e2290..710a607f9e 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/LineToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/LineToSpeckleConverter.cs @@ -5,34 +5,16 @@ namespace Speckle.Converters.Autocad.ToSpeckle.Geometry; [NameAndRankValue(nameof(ADB.Line), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class LineToSpeckleConverter : IToSpeckleTopLevelConverter, ITypedConverter +public class LineToSpeckleConverter : IToSpeckleTopLevelConverter { - private readonly ITypedConverter _pointConverter; - private readonly ITypedConverter _boxConverter; - private readonly IConversionContextStack _contextStack; + private readonly ITypedConverter _lineConverter; - public LineToSpeckleConverter( - ITypedConverter pointConverter, - ITypedConverter boxConverter, - IConversionContextStack contextStack - ) + public LineToSpeckleConverter(ITypedConverter lineConverter) { - _pointConverter = pointConverter; - _boxConverter = boxConverter; - _contextStack = contextStack; + _lineConverter = lineConverter; } public Base Convert(object target) => Convert((ADB.Line)target); - public SOG.Line Convert(ADB.Line target) => - new( - _pointConverter.Convert(target.StartPoint), - _pointConverter.Convert(target.EndPoint), - _contextStack.Current.SpeckleUnits - ) - { - length = target.Length, - domain = new SOP.Interval(0, target.Length), - bbox = _boxConverter.Convert(target.GeometricExtents) - }; + public SOG.Line Convert(ADB.Line target) => _lineConverter.Convert(target); } diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/Polyline2dToSpeckleConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/Polyline2dToSpeckleConverter.cs index 330d832cba..e0b053c12c 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/Polyline2dToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/Polyline2dToSpeckleConverter.cs @@ -15,7 +15,9 @@ namespace Speckle.Converters.Autocad.Geometry; /// The IToSpeckleTopLevelConverter inheritance should only expect database-resident objects. IRawConversion inheritance can expect non database-resident objects, when generated from other converters. /// [NameAndRankValue(nameof(ADB.Polyline2d), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class Polyline2dToSpeckleConverter : IToSpeckleTopLevelConverter +public class Polyline2dToSpeckleConverter + : IToSpeckleTopLevelConverter, + ITypedConverter { private readonly ITypedConverter _arcConverter; private readonly ITypedConverter _lineConverter; @@ -44,9 +46,9 @@ public Polyline2dToSpeckleConverter( _contextStack = contextStack; } - public Base Convert(object target) => RawConvert((ADB.Polyline2d)target); + public Base Convert(object target) => Convert((ADB.Polyline2d)target); - public SOG.Autocad.AutocadPolycurve RawConvert(ADB.Polyline2d target) + public SOG.Autocad.AutocadPolycurve Convert(ADB.Polyline2d target) { // get the poly type var polyType = SOG.Autocad.AutocadPolyType.Unknown; diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/Polyline3dToSpeckleConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/Polyline3dToSpeckleConverter.cs index fdef5bd478..87b90ad1e9 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/Polyline3dToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/Polyline3dToSpeckleConverter.cs @@ -14,7 +14,9 @@ namespace Speckle.Converters.Autocad.Geometry; /// The IToSpeckleTopLevelConverter inheritance should only expect database-resident Polyline2d objects. IRawConversion inheritance can expect non database-resident objects, when generated from other converters. /// [NameAndRankValue(nameof(ADB.Polyline3d), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class Polyline3dToSpeckleConverter : IToSpeckleTopLevelConverter +public class Polyline3dToSpeckleConverter + : IToSpeckleTopLevelConverter, + ITypedConverter { private readonly ITypedConverter _pointConverter; private readonly ITypedConverter _splineConverter; @@ -34,9 +36,9 @@ public Polyline3dToSpeckleConverter( _contextStack = contextStack; } - public Base Convert(object target) => RawConvert((ADB.Polyline3d)target); + public Base Convert(object target) => Convert((ADB.Polyline3d)target); - public SOG.Autocad.AutocadPolycurve RawConvert(ADB.Polyline3d target) + public SOG.Autocad.AutocadPolycurve Convert(ADB.Polyline3d target) { // get the poly type var polyType = SOG.Autocad.AutocadPolyType.Unknown; diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/Solid3dToSpeckleConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/Solid3dToSpeckleConverter.cs new file mode 100644 index 0000000000..841dc1120b --- /dev/null +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/Solid3dToSpeckleConverter.cs @@ -0,0 +1,23 @@ +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; +using Speckle.Core.Models; + +namespace Speckle.Converters.Autocad.Geometry; + +[NameAndRankValue(nameof(ADB.Solid3d), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +public class Solid3dToSpeckleConverter : IToSpeckleTopLevelConverter +{ + private readonly ITypedConverter _solidConverter; + + public Solid3dToSpeckleConverter(ITypedConverter solidConverter) + { + _solidConverter = solidConverter; + } + + public Base Convert(object target) => RawConvert((ADB.Solid3d)target); + + public SOG.Mesh RawConvert(ADB.Solid3d target) + { + return _solidConverter.Convert(target); + } +} diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/SplineToSpeckleConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/SplineToSpeckleConverter.cs index 059f92f033..d182376cd7 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/SplineToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/SplineToSpeckleConverter.cs @@ -1,5 +1,3 @@ -using Autodesk.AutoCAD.Geometry; -using Speckle.Converters.Autocad.Extensions; using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; using Speckle.Core.Models; @@ -7,150 +5,16 @@ namespace Speckle.Converters.Autocad.ToSpeckle.Geometry; [NameAndRankValue(nameof(ADB.Spline), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class SplineToSpeckleConverter : IToSpeckleTopLevelConverter, ITypedConverter +public class SplineToSpeckleConverter : IToSpeckleTopLevelConverter { - private readonly ITypedConverter _intervalConverter; - private readonly ITypedConverter _boxConverter; - private readonly IConversionContextStack _contextStack; + private readonly ITypedConverter _splineConverter; - public SplineToSpeckleConverter( - ITypedConverter intervalConverter, - ITypedConverter boxConverter, - IConversionContextStack contextStack - ) + public SplineToSpeckleConverter(ITypedConverter splineConverter) { - _intervalConverter = intervalConverter; - _boxConverter = boxConverter; - _contextStack = contextStack; + _splineConverter = splineConverter; } public Base Convert(object target) => Convert((ADB.Spline)target); - public SOG.Curve Convert(ADB.Spline target) - { - // get nurbs and geo data - ADB.NurbsData data = target.NurbsData; - - // POC: HACK: check for incorrectly closed periodic curves (this seems like acad bug, has resulted from receiving rhino curves) - bool periodicClosed = false; - double length = 0; - SOP.Interval domain = new(); - if (target.GetGeCurve() is NurbCurve3d nurbs) - { - length = nurbs.GetLength(nurbs.StartParameter, nurbs.EndParameter, 0.001); - domain = _intervalConverter.Convert(nurbs.GetInterval()); - if (nurbs.Knots.Count < nurbs.NumberOfControlPoints + nurbs.Degree + 1 && target.IsPeriodic) - { - periodicClosed = true; - } - } - - // get points - List points = new(); - foreach (Point3d point in data.GetControlPoints().OfType()) - { - points.Add(point); - } - - // NOTE: for closed periodic splines, autocad does not track last #degree points. - // Add the first #degree control points to the list if so. - if (periodicClosed) - { - points.AddRange(points.GetRange(0, target.Degree)); - } - - // get knots - // NOTE: for closed periodic splines, autocad has #control points + 1 knots. - // Add #degree extra knots to beginning and end with #degree - 1 multiplicity for first and last - var knots = data.GetKnots().OfType().ToList(); - if (periodicClosed) - { - double interval = knots[1] - knots[0]; //knot interval - - for (int i = 0; i < data.Degree; i++) - { - if (i < 2) - { - knots.Insert(knots.Count, knots[^1] + interval); - knots.Insert(0, knots[0] - interval); - } - else - { - knots.Insert(knots.Count, knots[^1]); - knots.Insert(0, knots[0]); - } - } - } - - // get weights - // NOTE: autocad assigns unweighted points a value of -1, and will return an empty list in the spline's nurbsdata if no points are weighted - // NOTE: for closed periodic splines, autocad does not track last #degree points. Add the first #degree weights to the list if so. - List weights = new(); - for (int i = 0; i < target.NumControlPoints; i++) - { - double weight = target.WeightAt(i); - weights.Add(weight <= 0 ? 1 : weight); - } - - if (periodicClosed) - { - weights.AddRange(weights.GetRange(0, target.Degree)); - } - - // set nurbs curve info - var curve = new SOG.Curve - { - points = points.SelectMany(o => o.ToArray()).ToList(), - knots = knots, - weights = weights, - degree = target.Degree, - periodic = target.IsPeriodic, - rational = target.IsRational, - closed = periodicClosed || target.Closed, - length = length, - domain = domain, - bbox = _boxConverter.Convert(target.GeometricExtents), - units = _contextStack.Current.SpeckleUnits - }; - - // POC: get display value if this is a database-resident spline - // POC: if this is called by another converter that has created a spline, assumes the display value is set by that converter - if (target.Database is not null) - { - curve.displayValue = GetDisplayValue(target); - } - - return curve; - } - - // POC: we might have DisplayValue converter/mapper? - private SOG.Polyline GetDisplayValue(ADB.Spline spline) - { - ADB.Curve polySpline = spline.ToPolylineWithPrecision(10, false, false); - List verticesList = new(); - switch (polySpline) - { - case ADB.Polyline2d o: - verticesList = o.GetSubEntities( - ADB.OpenMode.ForRead, - _contextStack.Current.Document.TransactionManager.TopTransaction - ) - .Where(e => e.VertexType != ADB.Vertex2dType.SplineControlVertex) // POC: not validated yet! - .SelectMany(o => o.Position.ToArray()) - .ToList(); - - break; - case ADB.Polyline3d o: - verticesList = o.GetSubEntities( - ADB.OpenMode.ForRead, - _contextStack.Current.Document.TransactionManager.TopTransaction - ) - .Where(e => e.VertexType != ADB.Vertex3dType.ControlVertex) - .SelectMany(o => o.Position.ToArray()) - .ToList(); - break; - } - - return verticesList.ConvertToSpecklePolyline(_contextStack.Current.SpeckleUnits); - } + public SOG.Curve Convert(ADB.Spline target) => _splineConverter.Convert(target); } diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Raw/CircularArc3dToSpeckleConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Raw/CircularArc3dToSpeckleRawConverter.cs similarity index 100% rename from DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Raw/CircularArc3dToSpeckleConverter.cs rename to DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Raw/CircularArc3dToSpeckleRawConverter.cs diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Raw/DBArcToSpeckleRawConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Raw/DBArcToSpeckleRawConverter.cs new file mode 100644 index 0000000000..8b45be3de3 --- /dev/null +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Raw/DBArcToSpeckleRawConverter.cs @@ -0,0 +1,58 @@ +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; +using Speckle.Core.Models; + +namespace Speckle.Converters.Autocad.ToSpeckle.Raw; + +public class DBArcToSpeckleRawConverter : ITypedConverter +{ + private readonly ITypedConverter _pointConverter; + private readonly ITypedConverter _planeConverter; + private readonly ITypedConverter _boxConverter; + private readonly IConversionContextStack _contextStack; + + public DBArcToSpeckleRawConverter( + ITypedConverter pointConverter, + ITypedConverter planeConverter, + ITypedConverter boxConverter, + IConversionContextStack contextStack + ) + { + _pointConverter = pointConverter; + _planeConverter = planeConverter; + _boxConverter = boxConverter; + _contextStack = contextStack; + } + + public Base Convert(object target) => Convert((ADB.Arc)target); + + public SOG.Arc Convert(ADB.Arc target) + { + SOG.Plane plane = _planeConverter.Convert(target.GetPlane()); + SOG.Point start = _pointConverter.Convert(target.StartPoint); + SOG.Point end = _pointConverter.Convert(target.EndPoint); + SOG.Point mid = _pointConverter.Convert(target.GetPointAtDist(target.Length / 2.0)); + SOP.Interval domain = new(target.StartParam, target.EndParam); + SOG.Box bbox = _boxConverter.Convert(target.GeometricExtents); + + SOG.Arc arc = + new( + plane, + target.Radius, + target.StartAngle, + target.EndAngle, + target.TotalAngle, + _contextStack.Current.SpeckleUnits + ) + { + startPoint = start, + endPoint = end, + midPoint = mid, + domain = domain, + length = target.Length, + bbox = bbox + }; + + return arc; + } +} diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Raw/DBCircleToSpeckleRawConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Raw/DBCircleToSpeckleRawConverter.cs new file mode 100644 index 0000000000..06f4cf6877 --- /dev/null +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Raw/DBCircleToSpeckleRawConverter.cs @@ -0,0 +1,35 @@ +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; +using Speckle.Core.Models; + +namespace Speckle.Converters.Autocad.ToSpeckle.Raw; + +public class DBCircleToSpeckleRawConverter : ITypedConverter +{ + private readonly ITypedConverter _planeConverter; + private readonly ITypedConverter _boxConverter; + private readonly IConversionContextStack _contextStack; + + public DBCircleToSpeckleRawConverter( + ITypedConverter planeConverter, + ITypedConverter boxConverter, + IConversionContextStack contextStack + ) + { + _planeConverter = planeConverter; + _boxConverter = boxConverter; + _contextStack = contextStack; + } + + public Base Convert(object target) => Convert((ADB.Circle)target); + + public SOG.Circle Convert(ADB.Circle target) + { + SOG.Plane plane = _planeConverter.Convert(target.GetPlane()); + SOG.Box bbox = _boxConverter.Convert(target.GeometricExtents); + SOG.Circle circle = + new(plane, target.Radius, _contextStack.Current.SpeckleUnits) { length = target.Circumference, bbox = bbox }; + + return circle; + } +} diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Raw/DBCurveToSpeckleRawConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Raw/DBCurveToSpeckleRawConverter.cs new file mode 100644 index 0000000000..ef392923be --- /dev/null +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Raw/DBCurveToSpeckleRawConverter.cs @@ -0,0 +1,67 @@ +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; +using Speckle.Core.Models; + +namespace Speckle.Converters.Autocad.ToSpeckle.Raw; + +public class DBCurveToSpeckleRawConverter : ITypedConverter, ITypedConverter +{ + private readonly ITypedConverter _lineConverter; + + private readonly ITypedConverter _polylineConverter; + private readonly ITypedConverter _polyline2dConverter; + private readonly ITypedConverter _polyline3dConverter; + private readonly ITypedConverter _arcConverter; + private readonly ITypedConverter _circleConverter; + private readonly ITypedConverter _ellipseConverter; + private readonly ITypedConverter _splineConverter; + private readonly IConversionContextStack _contextStack; + + public DBCurveToSpeckleRawConverter( + ITypedConverter lineConverter, + ITypedConverter polylineConverter, + ITypedConverter polyline2dConverter, + ITypedConverter polyline3dConverter, + ITypedConverter arcConverter, + ITypedConverter circleConverter, + ITypedConverter ellipseConverter, + ITypedConverter splineConverter, + IConversionContextStack contextStack + ) + { + _lineConverter = lineConverter; + _polylineConverter = polylineConverter; + _polyline2dConverter = polyline2dConverter; + _polyline3dConverter = polyline3dConverter; + _arcConverter = arcConverter; + _circleConverter = circleConverter; + _ellipseConverter = ellipseConverter; + _splineConverter = splineConverter; + _contextStack = contextStack; + } + + /// + /// Converts an Autocad curve to a Speckle ICurve. + /// + /// The Autocad curve to convert. + /// The Speckle curve. + /// + /// This is the main converter when the type of curve you input or output does not matter to the caller.
+ /// ⚠️ If an unsupported type of Curve is input, it will be converted as Spline. + ///
+ public Objects.ICurve Convert(ADB.Curve target) => + target switch + { + ADB.Line line => _lineConverter.Convert(line), + //ADB.Polyline polyline => _polylineConverter.Convert(polyline), + //ADB.Polyline2d polyline2d => _polyline2dConverter.Convert(polyline2d), + //ADB.Polyline3d polyline3d => _polyline3dConverter.Convert(polyline3d), + ADB.Arc arc => _arcConverter.Convert(arc), + ADB.Circle circle => _circleConverter.Convert(circle), + ADB.Ellipse ellipse => _ellipseConverter.Convert(ellipse), + ADB.Spline spline => _splineConverter.Convert(spline), + _ => _splineConverter.Convert(target.Spline) + }; + + Base ITypedConverter.Convert(ADB.Curve target) => (Base)Convert(target); +} diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Raw/DBEllipseToSpeckleRawConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Raw/DBEllipseToSpeckleRawConverter.cs new file mode 100644 index 0000000000..c763bb0e66 --- /dev/null +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Raw/DBEllipseToSpeckleRawConverter.cs @@ -0,0 +1,45 @@ +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; +using Speckle.Core.Models; + +namespace Speckle.Converters.Autocad.ToSpeckle.Raw; + +public class DBEllipseToSpeckleRawConverter : ITypedConverter +{ + private readonly ITypedConverter _planeConverter; + private readonly ITypedConverter _boxConverter; + private readonly IConversionContextStack _contextStack; + + public DBEllipseToSpeckleRawConverter( + ITypedConverter planeConverter, + ITypedConverter boxConverter, + IConversionContextStack contextStack + ) + { + _planeConverter = planeConverter; + _boxConverter = boxConverter; + _contextStack = contextStack; + } + + public Base Convert(object target) => Convert((ADB.Ellipse)target); + + public SOG.Ellipse Convert(ADB.Ellipse target) + { + SOG.Plane plane = _planeConverter.Convert(new AG.Plane(target.Center, target.MajorAxis, target.MinorAxis)); + SOG.Box bbox = _boxConverter.Convert(target.GeometricExtents); + + // the start and end param corresponds to start and end angle in radians + SOP.Interval trim = new(target.StartAngle, target.EndAngle); + + SOG.Ellipse ellipse = + new(plane, target.MajorRadius, target.MinorRadius, _contextStack.Current.SpeckleUnits) + { + domain = new(0, Math.PI * 2), + trimDomain = trim, + length = target.GetDistanceAtParameter(target.EndParam), + bbox = bbox + }; + + return ellipse; + } +} diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Raw/DBLineToSpeckleRawConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Raw/DBLineToSpeckleRawConverter.cs new file mode 100644 index 0000000000..b4a083c8e3 --- /dev/null +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Raw/DBLineToSpeckleRawConverter.cs @@ -0,0 +1,37 @@ +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; +using Speckle.Core.Models; + +namespace Speckle.Converters.Autocad.ToSpeckle.Raw; + +public class DBLineToSpeckleRawConverter : ITypedConverter +{ + private readonly ITypedConverter _pointConverter; + private readonly ITypedConverter _boxConverter; + private readonly IConversionContextStack _contextStack; + + public DBLineToSpeckleRawConverter( + ITypedConverter pointConverter, + ITypedConverter boxConverter, + IConversionContextStack contextStack + ) + { + _pointConverter = pointConverter; + _boxConverter = boxConverter; + _contextStack = contextStack; + } + + public Base Convert(object target) => Convert((ADB.Line)target); + + public SOG.Line Convert(ADB.Line target) => + new( + _pointConverter.Convert(target.StartPoint), + _pointConverter.Convert(target.EndPoint), + _contextStack.Current.SpeckleUnits + ) + { + length = target.Length, + domain = new SOP.Interval(0, target.Length), + bbox = _boxConverter.Convert(target.GeometricExtents) + }; +} diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Raw/DBSolid3dToSpeckleRawConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Raw/DBSolid3dToSpeckleRawConverter.cs new file mode 100644 index 0000000000..45c2d531a4 --- /dev/null +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Raw/DBSolid3dToSpeckleRawConverter.cs @@ -0,0 +1,84 @@ +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; +using Speckle.Core.Models; + +namespace Speckle.Converters.Autocad.ToSpeckle.Raw; + +public class Solid3dToSpeckleRawConverter : ITypedConverter +{ + private readonly ITypedConverter _pointConverter; + private readonly ITypedConverter _boxConverter; + private readonly IConversionContextStack _contextStack; + + public Solid3dToSpeckleRawConverter( + ITypedConverter pointConverter, + ITypedConverter boxConverter, + IConversionContextStack contextStack + ) + { + _pointConverter = pointConverter; + _boxConverter = boxConverter; + _contextStack = contextStack; + } + + public Base Convert(object target) => Convert((ADB.Solid3d)target); + + public SOG.Mesh Convert(ADB.Solid3d target) + { + using ABR.Brep brep = new(target); + if (brep.IsNull) + { + throw new SpeckleConversionException("Could not retrieve brep from the solid3d."); + } + + var vertices = new List(); + var faces = new List(); + + // create mesh from solid with mesh filter + using ABR.Mesh2dControl control = new(); + control.MaxSubdivisions = 10000; // POC: these settings may need adjusting + using ABR.Mesh2dFilter filter = new(); + filter.Insert(brep, control); + using ABR.Mesh2d m = new(filter); + foreach (ABR.Element2d e in m.Element2ds) + { + // get vertices + List faceIndices = new(); + foreach (ABR.Node n in e.Nodes) + { + faceIndices.Add(vertices.Count); + vertices.Add(n.Point); + n.Dispose(); + } + + // get faces + List faceList = new() { e.Nodes.Count() }; + for (int i = 0; i < e.Nodes.Count(); i++) + { + faceList.Add(faceIndices[i]); + } + + faces.AddRange(faceList); + + e.Dispose(); + } + + // mesh props + var convertedVertices = vertices.SelectMany(o => _pointConverter.Convert(o).ToList()).ToList(); + double volume = target.MassProperties.Volume; + double area = target.Area; + SOG.Box bbox = _boxConverter.Convert(target.GeometricExtents); + + // create speckle mesh + SOG.Mesh mesh = + new(convertedVertices, faces) + { + units = _contextStack.Current.SpeckleUnits, + bbox = bbox, + area = area, + volume = volume + }; + + return mesh; + } +} diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Raw/DBSplineToSpeckleRawConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Raw/DBSplineToSpeckleRawConverter.cs new file mode 100644 index 0000000000..d46b9de0a7 --- /dev/null +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Raw/DBSplineToSpeckleRawConverter.cs @@ -0,0 +1,155 @@ +using Autodesk.AutoCAD.Geometry; +using Speckle.Converters.Autocad.Extensions; +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; +using Speckle.Core.Models; + +namespace Speckle.Converters.Autocad.ToSpeckle.Raw; + +public class DBSplineToSpeckleRawConverter : ITypedConverter +{ + private readonly ITypedConverter _intervalConverter; + private readonly ITypedConverter _boxConverter; + private readonly IConversionContextStack _contextStack; + + public DBSplineToSpeckleRawConverter( + ITypedConverter intervalConverter, + ITypedConverter boxConverter, + IConversionContextStack contextStack + ) + { + _intervalConverter = intervalConverter; + _boxConverter = boxConverter; + _contextStack = contextStack; + } + + public Base Convert(object target) => Convert((ADB.Spline)target); + + public SOG.Curve Convert(ADB.Spline target) + { + // get nurbs and geo data + ADB.NurbsData data = target.NurbsData; + + // POC: HACK: check for incorrectly closed periodic curves (this seems like acad bug, has resulted from receiving rhino curves) + bool periodicClosed = false; + double length = 0; + SOP.Interval domain = new(); + if (target.GetGeCurve() is NurbCurve3d nurbs) + { + length = nurbs.GetLength(nurbs.StartParameter, nurbs.EndParameter, 0.001); + domain = _intervalConverter.Convert(nurbs.GetInterval()); + if (nurbs.Knots.Count < nurbs.NumberOfControlPoints + nurbs.Degree + 1 && target.IsPeriodic) + { + periodicClosed = true; + } + } + + // get points + List points = new(); + foreach (Point3d point in data.GetControlPoints().OfType()) + { + points.Add(point); + } + + // NOTE: for closed periodic splines, autocad does not track last #degree points. + // Add the first #degree control points to the list if so. + if (periodicClosed) + { + points.AddRange(points.GetRange(0, target.Degree)); + } + + // get knots + // NOTE: for closed periodic splines, autocad has #control points + 1 knots. + // Add #degree extra knots to beginning and end with #degree - 1 multiplicity for first and last + var knots = data.GetKnots().OfType().ToList(); + if (periodicClosed) + { + double interval = knots[1] - knots[0]; //knot interval + + for (int i = 0; i < data.Degree; i++) + { + if (i < 2) + { + knots.Insert(knots.Count, knots[^1] + interval); + knots.Insert(0, knots[0] - interval); + } + else + { + knots.Insert(knots.Count, knots[^1]); + knots.Insert(0, knots[0]); + } + } + } + + // get weights + // NOTE: autocad assigns unweighted points a value of -1, and will return an empty list in the spline's nurbsdata if no points are weighted + // NOTE: for closed periodic splines, autocad does not track last #degree points. Add the first #degree weights to the list if so. + List weights = new(); + for (int i = 0; i < target.NumControlPoints; i++) + { + double weight = target.WeightAt(i); + weights.Add(weight <= 0 ? 1 : weight); + } + + if (periodicClosed) + { + weights.AddRange(weights.GetRange(0, target.Degree)); + } + + // set nurbs curve info + var curve = new SOG.Curve + { + points = points.SelectMany(o => o.ToArray()).ToList(), + knots = knots, + weights = weights, + degree = target.Degree, + periodic = target.IsPeriodic, + rational = target.IsRational, + closed = periodicClosed || target.Closed, + length = length, + domain = domain, + bbox = _boxConverter.Convert(target.GeometricExtents), + units = _contextStack.Current.SpeckleUnits + }; + + // POC: get display value if this is a database-resident spline + // POC: if this is called by another converter that has created a spline, assumes the display value is set by that converter + if (target.Database is not null) + { + curve.displayValue = GetDisplayValue(target); + } + + return curve; + } + + // POC: we might have DisplayValue converter/mapper? + private SOG.Polyline GetDisplayValue(ADB.Spline spline) + { + ADB.Curve polySpline = spline.ToPolylineWithPrecision(10, false, false); + List verticesList = new(); + switch (polySpline) + { + case ADB.Polyline2d o: + verticesList = o.GetSubEntities( + ADB.OpenMode.ForRead, + _contextStack.Current.Document.TransactionManager.TopTransaction + ) + .Where(e => e.VertexType != ADB.Vertex2dType.SplineControlVertex) // POC: not validated yet! + .SelectMany(o => o.Position.ToArray()) + .ToList(); + + break; + case ADB.Polyline3d o: + verticesList = o.GetSubEntities( + ADB.OpenMode.ForRead, + _contextStack.Current.Document.TransactionManager.TopTransaction + ) + .Where(e => e.VertexType != ADB.Vertex3dType.ControlVertex) + .SelectMany(o => o.Position.ToArray()) + .ToList(); + break; + } + + return verticesList.ConvertToSpecklePolyline(_contextStack.Current.SpeckleUnits); + } +} diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Raw/PlaneToSpeckleRawConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Raw/PlaneToSpeckleRawConverter.cs index 4c5bc6f1ce..5e712b033b 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Raw/PlaneToSpeckleRawConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Raw/PlaneToSpeckleRawConverter.cs @@ -4,7 +4,7 @@ namespace Speckle.Converters.Autocad.ToSpeckle.Raw; -public class PlaneToSpeckleRawConverter : IToSpeckleTopLevelConverter, ITypedConverter +public class PlaneToSpeckleRawConverter : ITypedConverter { private readonly ITypedConverter _vectorConverter; private readonly ITypedConverter _pointConverter; diff --git a/DUI3-DX/Converters/Civil3d/Speckle.Converters.Civil3d2024.DependencyInjection/Civil3dConverterModule.cs b/DUI3-DX/Converters/Civil3d/Speckle.Converters.Civil3d2024.DependencyInjection/Civil3dConverterModule.cs new file mode 100644 index 0000000000..193648613b --- /dev/null +++ b/DUI3-DX/Converters/Civil3d/Speckle.Converters.Civil3d2024.DependencyInjection/Civil3dConverterModule.cs @@ -0,0 +1,24 @@ +using Autodesk.AutoCAD.ApplicationServices; +using Speckle.Autofac.DependencyInjection; +using Speckle.Converters.Civil3d; +using Speckle.Converters.Common; +using Speckle.Converters.Common.DependencyInjection; +using Autodesk.AutoCAD.DatabaseServices; +using Speckle.Converters.Autocad; + +namespace Speckle.Converters.Civil3d2024.DependencyInjection; + +public class Civil3dConverterModule : ISpeckleModule +{ + public void Load(SpeckleContainerBuilder builder) + { + // Register single root + builder.AddRootCommon(); + + // register all application converters + builder.AddApplicationConverters(); + builder.AddApplicationConverters(); + builder.AddScoped, Civil3dConversionContextStack>(); + builder.AddScoped, AutocadConversionContextStack>(); + } +} diff --git a/DUI3-DX/Converters/Civil3d/Speckle.Converters.Civil3d2024.DependencyInjection/Speckle.Converters.Civil3d2024.DependencyInjection.csproj b/DUI3-DX/Converters/Civil3d/Speckle.Converters.Civil3d2024.DependencyInjection/Speckle.Converters.Civil3d2024.DependencyInjection.csproj new file mode 100644 index 0000000000..9cbf64f01c --- /dev/null +++ b/DUI3-DX/Converters/Civil3d/Speckle.Converters.Civil3d2024.DependencyInjection/Speckle.Converters.Civil3d2024.DependencyInjection.csproj @@ -0,0 +1,17 @@ + + + + net48 + x64 + + + + + + + + + + + + diff --git a/DUI3-DX/Converters/Civil3d/Speckle.Converters.Civil3d2024.DependencyInjection/packages.lock.json b/DUI3-DX/Converters/Civil3d/Speckle.Converters.Civil3d2024.DependencyInjection/packages.lock.json new file mode 100644 index 0000000000..90e69d514d --- /dev/null +++ b/DUI3-DX/Converters/Civil3d/Speckle.Converters.Civil3d2024.DependencyInjection/packages.lock.json @@ -0,0 +1,448 @@ +{ + "version": 2, + "dependencies": { + ".NETFramework,Version=v4.8": { + "Autofac": { + "type": "Direct", + "requested": "[5.2.0, )", + "resolved": "5.2.0", + "contentHash": "V8dBH0dsv75uDzl7Sw+HkhKDPUw2eXnlMjcSVMH+tLo2s67MpTKGyDj1pDcpR+IF2u4YRs0s3/x7R88YJzIWvg==", + "dependencies": { + "Microsoft.Bcl.AsyncInterfaces": "1.1.0" + } + }, + "Microsoft.SourceLink.GitHub": { + "type": "Direct", + "requested": "[8.0.0, )", + "resolved": "8.0.0", + "contentHash": "G5q7OqtwIyGTkeIOAc3u2ZuV/kicQaec5EaRnc0pIeSnh9LUjj+PYQrJYBURvDt7twGl2PKA7nSN0kz1Zw5bnQ==", + "dependencies": { + "Microsoft.Build.Tasks.Git": "8.0.0", + "Microsoft.SourceLink.Common": "8.0.0" + } + }, + "PolySharp": { + "type": "Direct", + "requested": "[1.14.1, )", + "resolved": "1.14.1", + "contentHash": "mOOmFYwad3MIOL14VCjj02LljyF1GNw1wP0YVlxtcPvqdxjGGMNdNJJxHptlry3MOd8b40Flm8RPOM8JOlN2sQ==" + }, + "Speckle.InterfaceGenerator": { + "type": "Direct", + "requested": "[0.9.5, )", + "resolved": "0.9.5", + "contentHash": "oU/L7pN1R7q8KkbrpQ3WJnHirPHqn+9DEA7asOcUiggV5dzVg1A/VYs7GOSusD24njxXh03tE3a2oTLOjt3cVg==" + }, + "GraphQL.Client": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "8yPNBbuVBpTptivyAlak4GZvbwbUcjeQTL4vN1HKHRuOykZ4r7l5fcLS6vpyPyLn0x8FsL31xbOIKyxbmR9rbA==", + "dependencies": { + "GraphQL.Client.Abstractions": "6.0.0", + "GraphQL.Client.Abstractions.Websocket": "6.0.0", + "System.Net.WebSockets.Client.Managed": "1.0.22", + "System.Reactive": "5.0.0" + } + }, + "GraphQL.Client.Abstractions": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "h7uzWFORHZ+CCjwr/ThAyXMr0DPpzEANDa4Uo54wqCQ+j7qUKwqYTgOrb1W40sqbvNaZm9v/X7It31SUw0maHA==", + "dependencies": { + "GraphQL.Primitives": "6.0.0" + } + }, + "GraphQL.Client.Abstractions.Websocket": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "Nr9bPf8gIOvLuXpqEpqr9z9jslYFJOvd0feHth3/kPqeR3uMbjF5pjiwh4jxyMcxHdr8Pb6QiXkV3hsSyt0v7A==", + "dependencies": { + "GraphQL.Client.Abstractions": "6.0.0" + } + }, + "GraphQL.Primitives": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "yg72rrYDapfsIUrul7aF6wwNnTJBOFvuA9VdDTQpPa8AlAriHbufeXYLBcodKjfUdkCnaiggX1U/nEP08Zb5GA==" + }, + "Microsoft.Bcl.AsyncInterfaces": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "W8DPQjkMScOMTtJbPwmPyj9c3zYSFGawDW3jwlBOOsnY+EzZFLgNQ/UMkK35JmkNOVPdCyPr2Tw7Vv9N+KA3ZQ==", + "dependencies": { + "System.Threading.Tasks.Extensions": "4.5.4" + } + }, + "Microsoft.Build.Tasks.Git": { + "type": "Transitive", + "resolved": "8.0.0", + "contentHash": "bZKfSIKJRXLTuSzLudMFte/8CempWjVamNUR5eHJizsy+iuOuO/k2gnh7W0dHJmYY0tBf+gUErfluCv5mySAOQ==" + }, + "Microsoft.CSharp": { + "type": "Transitive", + "resolved": "4.7.0", + "contentHash": "pTj+D3uJWyN3My70i2Hqo+OXixq3Os2D1nJ2x92FFo6sk8fYS1m1WLNTs0Dc1uPaViH0YvEEwvzddQ7y4rhXmA==" + }, + "Microsoft.Data.Sqlite": { + "type": "Transitive", + "resolved": "7.0.5", + "contentHash": "KGxbPeWsQMnmQy43DSBxAFtHz3l2JX8EWBSGUCvT3CuZ8KsuzbkqMIJMDOxWtG8eZSoCDI04aiVQjWuuV8HmSw==", + "dependencies": { + "Microsoft.Data.Sqlite.Core": "7.0.5", + "SQLitePCLRaw.bundle_e_sqlite3": "2.1.4" + } + }, + "Microsoft.Data.Sqlite.Core": { + "type": "Transitive", + "resolved": "7.0.5", + "contentHash": "FTerRmQPqHrCrnoUzhBu+E+1DNGwyrAMLqHkAqOOOu5pGfyMOj8qQUBxI/gDtWtG11p49UxSfWmBzRNlwZqfUg==", + "dependencies": { + "SQLitePCLRaw.core": "2.1.4" + } + }, + "Microsoft.SourceLink.Common": { + "type": "Transitive", + "resolved": "8.0.0", + "contentHash": "dk9JPxTCIevS75HyEQ0E4OVAFhB2N+V9ShCXf8Q6FkUQZDkgLI12y679Nym1YqsiSysuQskT7Z+6nUf3yab6Vw==" + }, + "Polly": { + "type": "Transitive", + "resolved": "7.2.3", + "contentHash": "DeCY0OFbNdNxsjntr1gTXHJ5pKUwYzp04Er2LLeN3g6pWhffsGuKVfMBLe1lw7x76HrPkLxKEFxBlpRxS2nDEQ==" + }, + "Polly.Contrib.WaitAndRetry": { + "type": "Transitive", + "resolved": "1.1.1", + "contentHash": "1MUQLiSo4KDkQe6nzQRhIU05lm9jlexX5BVsbuw0SL82ynZ+GzAHQxJVDPVBboxV37Po3SG077aX8DuSy8TkaA==" + }, + "Polly.Extensions.Http": { + "type": "Transitive", + "resolved": "3.0.0", + "contentHash": "drrG+hB3pYFY7w1c3BD+lSGYvH2oIclH8GRSehgfyP5kjnFnHKQuuBhuHLv+PWyFuaTDyk/vfRpnxOzd11+J8g==", + "dependencies": { + "Polly": "7.1.0" + } + }, + "Sentry": { + "type": "Transitive", + "resolved": "3.33.0", + "contentHash": "8vbD2o6IR2wrRrkSiRbnodWGWUOqIlwYtzpjvPNOb5raJdOf+zxMwfS8f6nx9bmrTTfDj7KrCB8C/5OuicAc8A==", + "dependencies": { + "System.Reflection.Metadata": "5.0.0", + "System.Runtime.InteropServices.RuntimeInformation": "4.3.0", + "System.Text.Json": "5.0.2" + } + }, + "Sentry.Serilog": { + "type": "Transitive", + "resolved": "3.33.0", + "contentHash": "V8BU7QGWg2qLYfNPqtuTBhC1opysny5l+Ifp6J6PhOeAxU0FssR7nYfbJVetrnLIoh2rd3DlJ6hHYYQosQYcUQ==", + "dependencies": { + "Sentry": "3.33.0", + "Serilog": "2.7.1" + } + }, + "Serilog": { + "type": "Transitive", + "resolved": "2.12.0", + "contentHash": "xaiJLIdu6rYMKfQMYUZgTy8YK7SMZjB4Yk50C/u//Z4OsvxkUfSPJy4nknfvwAC34yr13q7kcyh4grbwhSxyZg==" + }, + "Serilog.Enrichers.ClientInfo": { + "type": "Transitive", + "resolved": "1.3.0", + "contentHash": "mTc7PM+wC9Hr7LWSwqt5mmnlAr7RJs+eTb3PGPRhwdOackk95MkhUZognuxXEdlW19HAFNmEBTSBY5DfLwM8jQ==", + "dependencies": { + "Serilog": "2.4.0" + } + }, + "Serilog.Exceptions": { + "type": "Transitive", + "resolved": "8.4.0", + "contentHash": "nc/+hUw3lsdo0zCj0KMIybAu7perMx79vu72w0za9Nsi6mWyNkGXxYxakAjWB7nEmYL6zdmhEQRB4oJ2ALUeug==", + "dependencies": { + "Serilog": "2.8.0" + } + }, + "Serilog.Formatting.Compact": { + "type": "Transitive", + "resolved": "1.1.0", + "contentHash": "pNroKVjo+rDqlxNG5PXkRLpfSCuDOBY0ri6jp9PLe505ljqwhwZz8ospy2vWhQlFu5GkIesh3FcDs4n7sWZODA==", + "dependencies": { + "Serilog": "2.8.0" + } + }, + "Serilog.Sinks.Console": { + "type": "Transitive", + "resolved": "4.1.0", + "contentHash": "K6N5q+5fetjnJPvCmkWOpJ/V8IEIoMIB1s86OzBrbxwTyHxdx3pmz4H+8+O/Dc/ftUX12DM1aynx/dDowkwzqg==", + "dependencies": { + "Serilog": "2.10.0" + } + }, + "Serilog.Sinks.File": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "uwV5hdhWPwUH1szhO8PJpFiahqXmzPzJT/sOijH/kFgUx+cyoDTMM8MHD0adw9+Iem6itoibbUXHYslzXsLEAg==", + "dependencies": { + "Serilog": "2.10.0" + } + }, + "Serilog.Sinks.PeriodicBatching": { + "type": "Transitive", + "resolved": "3.1.0", + "contentHash": "NDWR7m3PalVlGEq3rzoktrXikjFMLmpwF0HI4sowo8YDdU+gqPlTHlDQiOGxHfB0sTfjPA9JjA7ctKG9zqjGkw==", + "dependencies": { + "Serilog": "2.0.0" + } + }, + "Serilog.Sinks.Seq": { + "type": "Transitive", + "resolved": "5.2.2", + "contentHash": "1Csmo5ua7NKUe0yXUx+zsRefjAniPWcXFhUXxXG8pwo0iMiw2gjn9SOkgYnnxbgWqmlGv236w0N/dHc2v5XwMg==", + "dependencies": { + "Serilog": "2.12.0", + "Serilog.Formatting.Compact": "1.1.0", + "Serilog.Sinks.File": "5.0.0", + "Serilog.Sinks.PeriodicBatching": "3.1.0" + } + }, + "SerilogTimings": { + "type": "Transitive", + "resolved": "3.0.1", + "contentHash": "Zs28eTgszAMwpIrbBnWHBI50yuxL50p/dmAUWmy75+axdZYK/Sjm5/5m1N/CisR8acJUhTVcjPZrsB1P5iv0Uw==", + "dependencies": { + "Serilog": "2.10.0" + } + }, + "Speckle.Newtonsoft.Json": { + "type": "Transitive", + "resolved": "13.0.2", + "contentHash": "g1BejUZwax5PRfL6xHgLEK23sqHWOgOj9hE7RvfRRlN00AGt8GnPYt8HedSK7UB3HiRW8zCA9Pn0iiYxCK24BA==" + }, + "SQLitePCLRaw.bundle_e_sqlite3": { + "type": "Transitive", + "resolved": "2.1.4", + "contentHash": "EWI1olKDjFEBMJu0+3wuxwziIAdWDVMYLhuZ3Qs84rrz+DHwD00RzWPZCa+bLnHCf3oJwuFZIRsHT5p236QXww==", + "dependencies": { + "SQLitePCLRaw.lib.e_sqlite3": "2.1.4", + "SQLitePCLRaw.provider.dynamic_cdecl": "2.1.4" + } + }, + "SQLitePCLRaw.core": { + "type": "Transitive", + "resolved": "2.1.4", + "contentHash": "inBjvSHo9UDKneGNzfUfDjK08JzlcIhn1+SP5Y3m6cgXpCxXKCJDy6Mka7LpgSV+UZmKSnC8rTwB0SQ0xKu5pA==", + "dependencies": { + "System.Memory": "4.5.3" + } + }, + "SQLitePCLRaw.lib.e_sqlite3": { + "type": "Transitive", + "resolved": "2.1.4", + "contentHash": "2C9Q9eX7CPLveJA0rIhf9RXAvu+7nWZu1A2MdG6SD/NOu26TakGgL1nsbc0JAspGijFOo3HoN79xrx8a368fBg==" + }, + "SQLitePCLRaw.provider.dynamic_cdecl": { + "type": "Transitive", + "resolved": "2.1.4", + "contentHash": "ZsaKKhgYF9B1fvcnOGKl3EycNAwd9CRWX7v0rEfuPWhQQ5Jjpvf2VEHahiLIGHio3hxi3EIKFJw9KvyowWOUAw==", + "dependencies": { + "SQLitePCLRaw.core": "2.1.4" + } + }, + "System.Buffers": { + "type": "Transitive", + "resolved": "4.5.1", + "contentHash": "Rw7ijyl1qqRS0YQD/WycNst8hUUMgrMH4FCn1nNm27M4VxchZ1js3fVjQaANHO5f3sN4isvP4a+Met9Y4YomAg==" + }, + "System.Collections.Immutable": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "FXkLXiK0sVVewcso0imKQoOxjoPAj42R8HtjjbSjVPAzwDfzoyoznWxgA3c38LDbN9SJux1xXoXYAhz98j7r2g==", + "dependencies": { + "System.Memory": "4.5.4" + } + }, + "System.DoubleNumerics": { + "type": "Transitive", + "resolved": "3.1.3", + "contentHash": "KRKEM/L3KBodjA9VOg3EifFVWUY6EOqaMB05UvPEDm7Zeby/kZW+4kdWUEPzW6xtkwf46p661L9NrbeeQhtLzw==", + "dependencies": { + "NETStandard.Library": "1.6.1" + } + }, + "System.Memory": { + "type": "Transitive", + "resolved": "4.5.5", + "contentHash": "XIWiDvKPXaTveaB7HVganDlOCRoj03l+jrwNvcge/t8vhGYKvqV+dMv6G4SAX2NoNmN0wZfVPTAlFwZcZvVOUw==", + "dependencies": { + "System.Buffers": "4.5.1", + "System.Numerics.Vectors": "4.5.0", + "System.Runtime.CompilerServices.Unsafe": "4.5.3" + } + }, + "System.Net.WebSockets.Client.Managed": { + "type": "Transitive", + "resolved": "1.0.22", + "contentHash": "WqEOxPlXjuZrIjUtXNE9NxEfU/n5E35iV2PtoZdJSUC4tlrqwHnTee+wvMIM4OUaJWmwrymeqcgYrE0IkGAgLA==", + "dependencies": { + "System.Buffers": "4.4.0", + "System.Numerics.Vectors": "4.4.0" + } + }, + "System.Numerics.Vectors": { + "type": "Transitive", + "resolved": "4.5.0", + "contentHash": "QQTlPTl06J/iiDbJCiepZ4H//BVraReU4O4EoRw1U02H5TLUIT7xn3GnDp9AXPSlJUDyFs4uWjWafNX6WrAojQ==" + }, + "System.Reactive": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "erBZjkQHWL9jpasCE/0qKAryzVBJFxGHVBAvgRN1bzM0q2s1S4oYREEEL0Vb+1kA/6BKb5FjUZMp5VXmy+gzkQ==", + "dependencies": { + "System.Threading.Tasks.Extensions": "4.5.4" + } + }, + "System.Reflection.Metadata": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "5NecZgXktdGg34rh1OenY1rFNDCI8xSjFr+Z4OU4cU06AQHUdRnIIEeWENu3Wl4YowbzkymAIMvi3WyK9U53pQ==", + "dependencies": { + "System.Collections.Immutable": "5.0.0" + } + }, + "System.Runtime.CompilerServices.Unsafe": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "ZD9TMpsmYJLrxbbmdvhwt9YEgG5WntEnZ/d1eH8JBX9LBp+Ju8BSBhUGbZMNVHHomWo2KVImJhTDl2hIgw/6MA==" + }, + "System.Runtime.InteropServices.RuntimeInformation": { + "type": "Transitive", + "resolved": "4.3.0", + "contentHash": "cbz4YJMqRDR7oLeMRbdYv7mYzc++17lNhScCX0goO2XpGWdvAt60CGN+FHdePUEHCe/Jy9jUlvNAiNdM+7jsOw==" + }, + "System.Text.Encodings.Web": { + "type": "Transitive", + "resolved": "5.0.1", + "contentHash": "KmJ+CJXizDofbq6mpqDoRRLcxgOd2z9X3XoFNULSbvbqVRZkFX3istvr+MUjL6Zw1RT+RNdoI4GYidIINtgvqQ==", + "dependencies": { + "System.Buffers": "4.5.1", + "System.Memory": "4.5.4" + } + }, + "System.Text.Json": { + "type": "Transitive", + "resolved": "5.0.2", + "contentHash": "I47dVIGiV6SfAyppphxqupertT/5oZkYLDCX6vC3HpOI4ZLjyoKAreUoem2ie6G0RbRuFrlqz/PcTQjfb2DOfQ==", + "dependencies": { + "Microsoft.Bcl.AsyncInterfaces": "5.0.0", + "System.Buffers": "4.5.1", + "System.Memory": "4.5.4", + "System.Numerics.Vectors": "4.5.0", + "System.Runtime.CompilerServices.Unsafe": "5.0.0", + "System.Text.Encodings.Web": "5.0.1", + "System.Threading.Tasks.Extensions": "4.5.4", + "System.ValueTuple": "4.5.0" + } + }, + "System.Threading.Tasks.Extensions": { + "type": "Transitive", + "resolved": "4.5.4", + "contentHash": "zteT+G8xuGu6mS+mzDzYXbzS7rd3K6Fjb9RiZlYlJPam2/hU7JCBZBVEcywNuR+oZ1ncTvc/cq0faRr3P01OVg==", + "dependencies": { + "System.Runtime.CompilerServices.Unsafe": "4.5.3" + } + }, + "System.ValueTuple": { + "type": "Transitive", + "resolved": "4.5.0", + "contentHash": "okurQJO6NRE/apDIP23ajJ0hpiNmJ+f0BwOlB/cSqTLQlw5upkf+5+96+iG2Jw40G1fCVCyPz/FhIABUjMR+RQ==" + }, + "speckle.autofac": { + "type": "Project", + "dependencies": { + "Microsoft.Extensions.Logging.Abstractions": "[7.0.0, )" + } + }, + "speckle.converters.civil3d2024": { + "type": "Project", + "dependencies": { + "Speckle.AutoCAD.API": "[2024.0.0, )", + "Speckle.Civil3D.API": "[2024.0.0, )", + "Speckle.Converters.Common": "[2.0.999-local, )" + } + }, + "speckle.converters.common": { + "type": "Project", + "dependencies": { + "Speckle.Autofac": "[2.0.999-local, )", + "Speckle.Objects": "[3.0.1-alpha.14, )" + } + }, + "speckle.converters.common.dependencyinjection": { + "type": "Project", + "dependencies": { + "Speckle.Autofac": "[2.0.999-local, )", + "Speckle.Converters.Common": "[2.0.999-local, )" + } + }, + "Microsoft.Extensions.Logging.Abstractions": { + "type": "CentralTransitive", + "requested": "[7.0.0, )", + "resolved": "7.0.0", + "contentHash": "kmn78+LPVMOWeITUjIlfxUPDsI0R6G0RkeAMBmQxAJ7vBJn4q2dTva7pWi65ceN5vPGjJ9q/Uae2WKgvfktJAw==", + "dependencies": { + "System.Buffers": "4.5.1", + "System.Memory": "4.5.5" + } + }, + "Speckle.AutoCAD.API": { + "type": "CentralTransitive", + "requested": "[2024.0.0, )", + "resolved": "2024.0.0", + "contentHash": "pZZ5uI+NXhZaQnsqRkgp/rywqBAjDObDJ9XNFGJvemT5k2OthDpHzlK/mKxz8QDCYie7uImQ8dv3uWj2QUFDPw==" + }, + "Speckle.Civil3D.API": { + "type": "CentralTransitive", + "requested": "[2024.0.0, )", + "resolved": "2024.0.0", + "contentHash": "9Q7M1k0DotN8w7MkiScQezErRdnZ4dAkxBMcPNhHSWoth/lSaT6UPV1aYEdl90RhehJWG4l3O7U2e3OXvVSFdw==", + "dependencies": { + "Speckle.AutoCAD.API": "2024.0.0" + } + }, + "Speckle.Core": { + "type": "CentralTransitive", + "requested": "[3.0.1-alpha.14, )", + "resolved": "3.0.1-alpha.14", + "contentHash": "RzQPVIGFFkKvG56YLr8ACtiwdWJE6IJ9vCQ4qHa0PIsUEpfzAIAi59jnzqtByOFC0FiFrFPow9bkfzylaZorAA==", + "dependencies": { + "GraphQL.Client": "6.0.0", + "Microsoft.CSharp": "4.7.0", + "Microsoft.Data.Sqlite": "7.0.5", + "Polly": "7.2.3", + "Polly.Contrib.WaitAndRetry": "1.1.1", + "Polly.Extensions.Http": "3.0.0", + "Sentry": "3.33.0", + "Sentry.Serilog": "3.33.0", + "Serilog": "2.12.0", + "Serilog.Enrichers.ClientInfo": "1.3.0", + "Serilog.Exceptions": "8.4.0", + "Serilog.Sinks.Console": "4.1.0", + "Serilog.Sinks.Seq": "5.2.2", + "SerilogTimings": "3.0.1", + "Speckle.Newtonsoft.Json": "13.0.2", + "System.DoubleNumerics": "3.1.3" + } + }, + "Speckle.Objects": { + "type": "CentralTransitive", + "requested": "[3.0.1-alpha.14, )", + "resolved": "3.0.1-alpha.14", + "contentHash": "z38LGryMvh7iU1uBW+4uo5DwsB3CwRgLt2uFexWFx3mPSid+A0l5XcJzOgLwgFhNl6B42Ryz4ezBsddTp1Uc/g==", + "dependencies": { + "Speckle.Core": "3.0.1-alpha.14" + } + } + } + } +} \ No newline at end of file diff --git a/DUI3-DX/Converters/Civil3d/Speckle.Converters.Civil3d2024/Speckle.Converters.Civil3d2024.csproj b/DUI3-DX/Converters/Civil3d/Speckle.Converters.Civil3d2024/Speckle.Converters.Civil3d2024.csproj new file mode 100644 index 0000000000..5cd6f9707b --- /dev/null +++ b/DUI3-DX/Converters/Civil3d/Speckle.Converters.Civil3d2024/Speckle.Converters.Civil3d2024.csproj @@ -0,0 +1,21 @@ + + + + net48 + x64 + + + + + + + + + + + + + + + + diff --git a/DUI3-DX/Converters/Civil3d/Speckle.Converters.Civil3d2024/packages.lock.json b/DUI3-DX/Converters/Civil3d/Speckle.Converters.Civil3d2024/packages.lock.json new file mode 100644 index 0000000000..853f08eb85 --- /dev/null +++ b/DUI3-DX/Converters/Civil3d/Speckle.Converters.Civil3d2024/packages.lock.json @@ -0,0 +1,424 @@ +{ + "version": 2, + "dependencies": { + ".NETFramework,Version=v4.8": { + "Microsoft.SourceLink.GitHub": { + "type": "Direct", + "requested": "[8.0.0, )", + "resolved": "8.0.0", + "contentHash": "G5q7OqtwIyGTkeIOAc3u2ZuV/kicQaec5EaRnc0pIeSnh9LUjj+PYQrJYBURvDt7twGl2PKA7nSN0kz1Zw5bnQ==", + "dependencies": { + "Microsoft.Build.Tasks.Git": "8.0.0", + "Microsoft.SourceLink.Common": "8.0.0" + } + }, + "PolySharp": { + "type": "Direct", + "requested": "[1.14.1, )", + "resolved": "1.14.1", + "contentHash": "mOOmFYwad3MIOL14VCjj02LljyF1GNw1wP0YVlxtcPvqdxjGGMNdNJJxHptlry3MOd8b40Flm8RPOM8JOlN2sQ==" + }, + "Speckle.AutoCAD.API": { + "type": "Direct", + "requested": "[2024.0.0, )", + "resolved": "2024.0.0", + "contentHash": "pZZ5uI+NXhZaQnsqRkgp/rywqBAjDObDJ9XNFGJvemT5k2OthDpHzlK/mKxz8QDCYie7uImQ8dv3uWj2QUFDPw==" + }, + "Speckle.Civil3D.API": { + "type": "Direct", + "requested": "[2024.0.0, )", + "resolved": "2024.0.0", + "contentHash": "9Q7M1k0DotN8w7MkiScQezErRdnZ4dAkxBMcPNhHSWoth/lSaT6UPV1aYEdl90RhehJWG4l3O7U2e3OXvVSFdw==", + "dependencies": { + "Speckle.AutoCAD.API": "2024.0.0" + } + }, + "Speckle.InterfaceGenerator": { + "type": "Direct", + "requested": "[0.9.5, )", + "resolved": "0.9.5", + "contentHash": "oU/L7pN1R7q8KkbrpQ3WJnHirPHqn+9DEA7asOcUiggV5dzVg1A/VYs7GOSusD24njxXh03tE3a2oTLOjt3cVg==" + }, + "GraphQL.Client": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "8yPNBbuVBpTptivyAlak4GZvbwbUcjeQTL4vN1HKHRuOykZ4r7l5fcLS6vpyPyLn0x8FsL31xbOIKyxbmR9rbA==", + "dependencies": { + "GraphQL.Client.Abstractions": "6.0.0", + "GraphQL.Client.Abstractions.Websocket": "6.0.0", + "System.Net.WebSockets.Client.Managed": "1.0.22", + "System.Reactive": "5.0.0" + } + }, + "GraphQL.Client.Abstractions": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "h7uzWFORHZ+CCjwr/ThAyXMr0DPpzEANDa4Uo54wqCQ+j7qUKwqYTgOrb1W40sqbvNaZm9v/X7It31SUw0maHA==", + "dependencies": { + "GraphQL.Primitives": "6.0.0" + } + }, + "GraphQL.Client.Abstractions.Websocket": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "Nr9bPf8gIOvLuXpqEpqr9z9jslYFJOvd0feHth3/kPqeR3uMbjF5pjiwh4jxyMcxHdr8Pb6QiXkV3hsSyt0v7A==", + "dependencies": { + "GraphQL.Client.Abstractions": "6.0.0" + } + }, + "GraphQL.Primitives": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "yg72rrYDapfsIUrul7aF6wwNnTJBOFvuA9VdDTQpPa8AlAriHbufeXYLBcodKjfUdkCnaiggX1U/nEP08Zb5GA==" + }, + "Microsoft.Bcl.AsyncInterfaces": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "W8DPQjkMScOMTtJbPwmPyj9c3zYSFGawDW3jwlBOOsnY+EzZFLgNQ/UMkK35JmkNOVPdCyPr2Tw7Vv9N+KA3ZQ==", + "dependencies": { + "System.Threading.Tasks.Extensions": "4.5.4" + } + }, + "Microsoft.Build.Tasks.Git": { + "type": "Transitive", + "resolved": "8.0.0", + "contentHash": "bZKfSIKJRXLTuSzLudMFte/8CempWjVamNUR5eHJizsy+iuOuO/k2gnh7W0dHJmYY0tBf+gUErfluCv5mySAOQ==" + }, + "Microsoft.CSharp": { + "type": "Transitive", + "resolved": "4.7.0", + "contentHash": "pTj+D3uJWyN3My70i2Hqo+OXixq3Os2D1nJ2x92FFo6sk8fYS1m1WLNTs0Dc1uPaViH0YvEEwvzddQ7y4rhXmA==" + }, + "Microsoft.Data.Sqlite": { + "type": "Transitive", + "resolved": "7.0.5", + "contentHash": "KGxbPeWsQMnmQy43DSBxAFtHz3l2JX8EWBSGUCvT3CuZ8KsuzbkqMIJMDOxWtG8eZSoCDI04aiVQjWuuV8HmSw==", + "dependencies": { + "Microsoft.Data.Sqlite.Core": "7.0.5", + "SQLitePCLRaw.bundle_e_sqlite3": "2.1.4" + } + }, + "Microsoft.Data.Sqlite.Core": { + "type": "Transitive", + "resolved": "7.0.5", + "contentHash": "FTerRmQPqHrCrnoUzhBu+E+1DNGwyrAMLqHkAqOOOu5pGfyMOj8qQUBxI/gDtWtG11p49UxSfWmBzRNlwZqfUg==", + "dependencies": { + "SQLitePCLRaw.core": "2.1.4" + } + }, + "Microsoft.SourceLink.Common": { + "type": "Transitive", + "resolved": "8.0.0", + "contentHash": "dk9JPxTCIevS75HyEQ0E4OVAFhB2N+V9ShCXf8Q6FkUQZDkgLI12y679Nym1YqsiSysuQskT7Z+6nUf3yab6Vw==" + }, + "Polly": { + "type": "Transitive", + "resolved": "7.2.3", + "contentHash": "DeCY0OFbNdNxsjntr1gTXHJ5pKUwYzp04Er2LLeN3g6pWhffsGuKVfMBLe1lw7x76HrPkLxKEFxBlpRxS2nDEQ==" + }, + "Polly.Contrib.WaitAndRetry": { + "type": "Transitive", + "resolved": "1.1.1", + "contentHash": "1MUQLiSo4KDkQe6nzQRhIU05lm9jlexX5BVsbuw0SL82ynZ+GzAHQxJVDPVBboxV37Po3SG077aX8DuSy8TkaA==" + }, + "Polly.Extensions.Http": { + "type": "Transitive", + "resolved": "3.0.0", + "contentHash": "drrG+hB3pYFY7w1c3BD+lSGYvH2oIclH8GRSehgfyP5kjnFnHKQuuBhuHLv+PWyFuaTDyk/vfRpnxOzd11+J8g==", + "dependencies": { + "Polly": "7.1.0" + } + }, + "Sentry": { + "type": "Transitive", + "resolved": "3.33.0", + "contentHash": "8vbD2o6IR2wrRrkSiRbnodWGWUOqIlwYtzpjvPNOb5raJdOf+zxMwfS8f6nx9bmrTTfDj7KrCB8C/5OuicAc8A==", + "dependencies": { + "System.Reflection.Metadata": "5.0.0", + "System.Runtime.InteropServices.RuntimeInformation": "4.3.0", + "System.Text.Json": "5.0.2" + } + }, + "Sentry.Serilog": { + "type": "Transitive", + "resolved": "3.33.0", + "contentHash": "V8BU7QGWg2qLYfNPqtuTBhC1opysny5l+Ifp6J6PhOeAxU0FssR7nYfbJVetrnLIoh2rd3DlJ6hHYYQosQYcUQ==", + "dependencies": { + "Sentry": "3.33.0", + "Serilog": "2.7.1" + } + }, + "Serilog": { + "type": "Transitive", + "resolved": "2.12.0", + "contentHash": "xaiJLIdu6rYMKfQMYUZgTy8YK7SMZjB4Yk50C/u//Z4OsvxkUfSPJy4nknfvwAC34yr13q7kcyh4grbwhSxyZg==" + }, + "Serilog.Enrichers.ClientInfo": { + "type": "Transitive", + "resolved": "1.3.0", + "contentHash": "mTc7PM+wC9Hr7LWSwqt5mmnlAr7RJs+eTb3PGPRhwdOackk95MkhUZognuxXEdlW19HAFNmEBTSBY5DfLwM8jQ==", + "dependencies": { + "Serilog": "2.4.0" + } + }, + "Serilog.Exceptions": { + "type": "Transitive", + "resolved": "8.4.0", + "contentHash": "nc/+hUw3lsdo0zCj0KMIybAu7perMx79vu72w0za9Nsi6mWyNkGXxYxakAjWB7nEmYL6zdmhEQRB4oJ2ALUeug==", + "dependencies": { + "Serilog": "2.8.0" + } + }, + "Serilog.Formatting.Compact": { + "type": "Transitive", + "resolved": "1.1.0", + "contentHash": "pNroKVjo+rDqlxNG5PXkRLpfSCuDOBY0ri6jp9PLe505ljqwhwZz8ospy2vWhQlFu5GkIesh3FcDs4n7sWZODA==", + "dependencies": { + "Serilog": "2.8.0" + } + }, + "Serilog.Sinks.Console": { + "type": "Transitive", + "resolved": "4.1.0", + "contentHash": "K6N5q+5fetjnJPvCmkWOpJ/V8IEIoMIB1s86OzBrbxwTyHxdx3pmz4H+8+O/Dc/ftUX12DM1aynx/dDowkwzqg==", + "dependencies": { + "Serilog": "2.10.0" + } + }, + "Serilog.Sinks.File": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "uwV5hdhWPwUH1szhO8PJpFiahqXmzPzJT/sOijH/kFgUx+cyoDTMM8MHD0adw9+Iem6itoibbUXHYslzXsLEAg==", + "dependencies": { + "Serilog": "2.10.0" + } + }, + "Serilog.Sinks.PeriodicBatching": { + "type": "Transitive", + "resolved": "3.1.0", + "contentHash": "NDWR7m3PalVlGEq3rzoktrXikjFMLmpwF0HI4sowo8YDdU+gqPlTHlDQiOGxHfB0sTfjPA9JjA7ctKG9zqjGkw==", + "dependencies": { + "Serilog": "2.0.0" + } + }, + "Serilog.Sinks.Seq": { + "type": "Transitive", + "resolved": "5.2.2", + "contentHash": "1Csmo5ua7NKUe0yXUx+zsRefjAniPWcXFhUXxXG8pwo0iMiw2gjn9SOkgYnnxbgWqmlGv236w0N/dHc2v5XwMg==", + "dependencies": { + "Serilog": "2.12.0", + "Serilog.Formatting.Compact": "1.1.0", + "Serilog.Sinks.File": "5.0.0", + "Serilog.Sinks.PeriodicBatching": "3.1.0" + } + }, + "SerilogTimings": { + "type": "Transitive", + "resolved": "3.0.1", + "contentHash": "Zs28eTgszAMwpIrbBnWHBI50yuxL50p/dmAUWmy75+axdZYK/Sjm5/5m1N/CisR8acJUhTVcjPZrsB1P5iv0Uw==", + "dependencies": { + "Serilog": "2.10.0" + } + }, + "Speckle.Newtonsoft.Json": { + "type": "Transitive", + "resolved": "13.0.2", + "contentHash": "g1BejUZwax5PRfL6xHgLEK23sqHWOgOj9hE7RvfRRlN00AGt8GnPYt8HedSK7UB3HiRW8zCA9Pn0iiYxCK24BA==" + }, + "SQLitePCLRaw.bundle_e_sqlite3": { + "type": "Transitive", + "resolved": "2.1.4", + "contentHash": "EWI1olKDjFEBMJu0+3wuxwziIAdWDVMYLhuZ3Qs84rrz+DHwD00RzWPZCa+bLnHCf3oJwuFZIRsHT5p236QXww==", + "dependencies": { + "SQLitePCLRaw.lib.e_sqlite3": "2.1.4", + "SQLitePCLRaw.provider.dynamic_cdecl": "2.1.4" + } + }, + "SQLitePCLRaw.core": { + "type": "Transitive", + "resolved": "2.1.4", + "contentHash": "inBjvSHo9UDKneGNzfUfDjK08JzlcIhn1+SP5Y3m6cgXpCxXKCJDy6Mka7LpgSV+UZmKSnC8rTwB0SQ0xKu5pA==", + "dependencies": { + "System.Memory": "4.5.3" + } + }, + "SQLitePCLRaw.lib.e_sqlite3": { + "type": "Transitive", + "resolved": "2.1.4", + "contentHash": "2C9Q9eX7CPLveJA0rIhf9RXAvu+7nWZu1A2MdG6SD/NOu26TakGgL1nsbc0JAspGijFOo3HoN79xrx8a368fBg==" + }, + "SQLitePCLRaw.provider.dynamic_cdecl": { + "type": "Transitive", + "resolved": "2.1.4", + "contentHash": "ZsaKKhgYF9B1fvcnOGKl3EycNAwd9CRWX7v0rEfuPWhQQ5Jjpvf2VEHahiLIGHio3hxi3EIKFJw9KvyowWOUAw==", + "dependencies": { + "SQLitePCLRaw.core": "2.1.4" + } + }, + "System.Buffers": { + "type": "Transitive", + "resolved": "4.5.1", + "contentHash": "Rw7ijyl1qqRS0YQD/WycNst8hUUMgrMH4FCn1nNm27M4VxchZ1js3fVjQaANHO5f3sN4isvP4a+Met9Y4YomAg==" + }, + "System.Collections.Immutable": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "FXkLXiK0sVVewcso0imKQoOxjoPAj42R8HtjjbSjVPAzwDfzoyoznWxgA3c38LDbN9SJux1xXoXYAhz98j7r2g==", + "dependencies": { + "System.Memory": "4.5.4" + } + }, + "System.DoubleNumerics": { + "type": "Transitive", + "resolved": "3.1.3", + "contentHash": "KRKEM/L3KBodjA9VOg3EifFVWUY6EOqaMB05UvPEDm7Zeby/kZW+4kdWUEPzW6xtkwf46p661L9NrbeeQhtLzw==", + "dependencies": { + "NETStandard.Library": "1.6.1" + } + }, + "System.Memory": { + "type": "Transitive", + "resolved": "4.5.5", + "contentHash": "XIWiDvKPXaTveaB7HVganDlOCRoj03l+jrwNvcge/t8vhGYKvqV+dMv6G4SAX2NoNmN0wZfVPTAlFwZcZvVOUw==", + "dependencies": { + "System.Buffers": "4.5.1", + "System.Numerics.Vectors": "4.5.0", + "System.Runtime.CompilerServices.Unsafe": "4.5.3" + } + }, + "System.Net.WebSockets.Client.Managed": { + "type": "Transitive", + "resolved": "1.0.22", + "contentHash": "WqEOxPlXjuZrIjUtXNE9NxEfU/n5E35iV2PtoZdJSUC4tlrqwHnTee+wvMIM4OUaJWmwrymeqcgYrE0IkGAgLA==", + "dependencies": { + "System.Buffers": "4.4.0", + "System.Numerics.Vectors": "4.4.0" + } + }, + "System.Numerics.Vectors": { + "type": "Transitive", + "resolved": "4.5.0", + "contentHash": "QQTlPTl06J/iiDbJCiepZ4H//BVraReU4O4EoRw1U02H5TLUIT7xn3GnDp9AXPSlJUDyFs4uWjWafNX6WrAojQ==" + }, + "System.Reactive": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "erBZjkQHWL9jpasCE/0qKAryzVBJFxGHVBAvgRN1bzM0q2s1S4oYREEEL0Vb+1kA/6BKb5FjUZMp5VXmy+gzkQ==", + "dependencies": { + "System.Threading.Tasks.Extensions": "4.5.4" + } + }, + "System.Reflection.Metadata": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "5NecZgXktdGg34rh1OenY1rFNDCI8xSjFr+Z4OU4cU06AQHUdRnIIEeWENu3Wl4YowbzkymAIMvi3WyK9U53pQ==", + "dependencies": { + "System.Collections.Immutable": "5.0.0" + } + }, + "System.Runtime.CompilerServices.Unsafe": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "ZD9TMpsmYJLrxbbmdvhwt9YEgG5WntEnZ/d1eH8JBX9LBp+Ju8BSBhUGbZMNVHHomWo2KVImJhTDl2hIgw/6MA==" + }, + "System.Runtime.InteropServices.RuntimeInformation": { + "type": "Transitive", + "resolved": "4.3.0", + "contentHash": "cbz4YJMqRDR7oLeMRbdYv7mYzc++17lNhScCX0goO2XpGWdvAt60CGN+FHdePUEHCe/Jy9jUlvNAiNdM+7jsOw==" + }, + "System.Text.Encodings.Web": { + "type": "Transitive", + "resolved": "5.0.1", + "contentHash": "KmJ+CJXizDofbq6mpqDoRRLcxgOd2z9X3XoFNULSbvbqVRZkFX3istvr+MUjL6Zw1RT+RNdoI4GYidIINtgvqQ==", + "dependencies": { + "System.Buffers": "4.5.1", + "System.Memory": "4.5.4" + } + }, + "System.Text.Json": { + "type": "Transitive", + "resolved": "5.0.2", + "contentHash": "I47dVIGiV6SfAyppphxqupertT/5oZkYLDCX6vC3HpOI4ZLjyoKAreUoem2ie6G0RbRuFrlqz/PcTQjfb2DOfQ==", + "dependencies": { + "Microsoft.Bcl.AsyncInterfaces": "5.0.0", + "System.Buffers": "4.5.1", + "System.Memory": "4.5.4", + "System.Numerics.Vectors": "4.5.0", + "System.Runtime.CompilerServices.Unsafe": "5.0.0", + "System.Text.Encodings.Web": "5.0.1", + "System.Threading.Tasks.Extensions": "4.5.4", + "System.ValueTuple": "4.5.0" + } + }, + "System.Threading.Tasks.Extensions": { + "type": "Transitive", + "resolved": "4.5.4", + "contentHash": "zteT+G8xuGu6mS+mzDzYXbzS7rd3K6Fjb9RiZlYlJPam2/hU7JCBZBVEcywNuR+oZ1ncTvc/cq0faRr3P01OVg==", + "dependencies": { + "System.Runtime.CompilerServices.Unsafe": "4.5.3" + } + }, + "System.ValueTuple": { + "type": "Transitive", + "resolved": "4.5.0", + "contentHash": "okurQJO6NRE/apDIP23ajJ0hpiNmJ+f0BwOlB/cSqTLQlw5upkf+5+96+iG2Jw40G1fCVCyPz/FhIABUjMR+RQ==" + }, + "speckle.autofac": { + "type": "Project", + "dependencies": { + "Microsoft.Extensions.Logging.Abstractions": "[7.0.0, )" + } + }, + "speckle.converters.common": { + "type": "Project", + "dependencies": { + "Speckle.Autofac": "[2.0.999-local, )", + "Speckle.Objects": "[3.0.1-alpha.14, )" + } + }, + "Microsoft.Extensions.Logging.Abstractions": { + "type": "CentralTransitive", + "requested": "[7.0.0, )", + "resolved": "7.0.0", + "contentHash": "kmn78+LPVMOWeITUjIlfxUPDsI0R6G0RkeAMBmQxAJ7vBJn4q2dTva7pWi65ceN5vPGjJ9q/Uae2WKgvfktJAw==", + "dependencies": { + "System.Buffers": "4.5.1", + "System.Memory": "4.5.5" + } + }, + "Speckle.Core": { + "type": "CentralTransitive", + "requested": "[3.0.1-alpha.14, )", + "resolved": "3.0.1-alpha.14", + "contentHash": "RzQPVIGFFkKvG56YLr8ACtiwdWJE6IJ9vCQ4qHa0PIsUEpfzAIAi59jnzqtByOFC0FiFrFPow9bkfzylaZorAA==", + "dependencies": { + "GraphQL.Client": "6.0.0", + "Microsoft.CSharp": "4.7.0", + "Microsoft.Data.Sqlite": "7.0.5", + "Polly": "7.2.3", + "Polly.Contrib.WaitAndRetry": "1.1.1", + "Polly.Extensions.Http": "3.0.0", + "Sentry": "3.33.0", + "Sentry.Serilog": "3.33.0", + "Serilog": "2.12.0", + "Serilog.Enrichers.ClientInfo": "1.3.0", + "Serilog.Exceptions": "8.4.0", + "Serilog.Sinks.Console": "4.1.0", + "Serilog.Sinks.Seq": "5.2.2", + "SerilogTimings": "3.0.1", + "Speckle.Newtonsoft.Json": "13.0.2", + "System.DoubleNumerics": "3.1.3" + } + }, + "Speckle.Objects": { + "type": "CentralTransitive", + "requested": "[3.0.1-alpha.14, )", + "resolved": "3.0.1-alpha.14", + "contentHash": "z38LGryMvh7iU1uBW+4uo5DwsB3CwRgLt2uFexWFx3mPSid+A0l5XcJzOgLwgFhNl6B42Ryz4ezBsddTp1Uc/g==", + "dependencies": { + "Speckle.Core": "3.0.1-alpha.14" + } + } + } + } +} \ No newline at end of file diff --git a/DUI3-DX/Converters/Civil3d/Speckle.Converters.Civil3dShared/Civil3dConversionContextStack.cs b/DUI3-DX/Converters/Civil3d/Speckle.Converters.Civil3dShared/Civil3dConversionContextStack.cs new file mode 100644 index 0000000000..0d803db250 --- /dev/null +++ b/DUI3-DX/Converters/Civil3d/Speckle.Converters.Civil3dShared/Civil3dConversionContextStack.cs @@ -0,0 +1,38 @@ +using System.Diagnostics.CodeAnalysis; +using Speckle.Converters.Common; + +namespace Speckle.Converters.Civil3d; + +// POC: Suppressed naming warning for now, but we should evaluate if we should follow this or disable it. +[SuppressMessage( + "Naming", + "CA1711:Identifiers should not have incorrect suffix", + Justification = "Name ends in Stack but it is in fact a Stack, just not inheriting from `System.Collections.Stack`" +)] +public class Civil3dConversionContextStack : ConversionContextStack +{ + public Civil3dConversionContextStack(IHostToSpeckleUnitConverter unitConverter) + : base( + Application.DocumentManager.CurrentDocument, + GetDocBuiltInUnit(Application.DocumentManager.CurrentDocument), + unitConverter + ) { } + + private static AAEC.BuiltInUnit GetDocBuiltInUnit(Document doc) + { + AAEC.BuiltInUnit unit = AAEC.BuiltInUnit.Dimensionless; + + using (ADB.Transaction tr = doc.Database.TransactionManager.StartTransaction()) + { + ADB.ObjectId id = AAEC.ApplicationServices.DrawingSetupVariables.GetInstance(doc.Database, false); + if (tr.GetObject(id, ADB.OpenMode.ForRead) is AAEC.ApplicationServices.DrawingSetupVariables setupVariables) + { + unit = setupVariables.LinearUnit; + } + + tr.Commit(); + } + + return unit; + } +} diff --git a/DUI3-DX/Converters/Civil3d/Speckle.Converters.Civil3dShared/Civil3dRootToHostConverter.cs b/DUI3-DX/Converters/Civil3d/Speckle.Converters.Civil3dShared/Civil3dRootToHostConverter.cs new file mode 100644 index 0000000000..265cd3a796 --- /dev/null +++ b/DUI3-DX/Converters/Civil3d/Speckle.Converters.Civil3dShared/Civil3dRootToHostConverter.cs @@ -0,0 +1,59 @@ +using Autodesk.AutoCAD.DatabaseServices; +using Speckle.Autofac.DependencyInjection; +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; +using Speckle.Core.Models; + +namespace Speckle.Converters.Civil3d; + +public class Civil3dRootToHostConverter : IRootToSpeckleConverter +{ + private readonly IFactory _toSpeckle; + private readonly IConversionContextStack _contextStack; + + public Civil3dRootToHostConverter( + IFactory toSpeckle, + IConversionContextStack contextStack + ) + { + _toSpeckle = toSpeckle; + _contextStack = contextStack; + } + + public Base Convert(object target) + { + if (target is not DBObject dbObject) + { + throw new NotSupportedException( + $"Conversion of {target.GetType().Name} to Speckle is not supported. Only objects that inherit from DBObject are." + ); + } + + Type type = dbObject.GetType(); + + try + { + using (var l = _contextStack.Current.Document.LockDocument()) + { + using (var tr = _contextStack.Current.Document.Database.TransactionManager.StartTransaction()) + { + var objectConverter = _toSpeckle.ResolveInstance(type.Name); + + if (objectConverter == null) + { + throw new NotSupportedException($"No conversion found for {target.GetType().Name}"); + } + + var convertedObject = objectConverter.Convert(dbObject); + tr.Commit(); + return convertedObject; + } + } + } + catch (SpeckleConversionException e) + { + Console.WriteLine(e); + throw; // Just rethrowing for now, Logs may be needed here. + } + } +} diff --git a/DUI3-DX/Converters/Civil3d/Speckle.Converters.Civil3dShared/Civil3dToSpeckleUnitConverter.cs b/DUI3-DX/Converters/Civil3d/Speckle.Converters.Civil3dShared/Civil3dToSpeckleUnitConverter.cs new file mode 100644 index 0000000000..0c61621a4c --- /dev/null +++ b/DUI3-DX/Converters/Civil3d/Speckle.Converters.Civil3dShared/Civil3dToSpeckleUnitConverter.cs @@ -0,0 +1,39 @@ +using Speckle.Converters.Common; +using Speckle.Core.Kits; +using Speckle.Core.Logging; // POC: boy do I think this is the wrong place for SpeckleException! + +namespace Speckle.Converters.Civil3d; + +public class Civil3dToSpeckleUnitConverter : IHostToSpeckleUnitConverter +{ + private static readonly IReadOnlyDictionary s_unitsMapping = Create(); + + private static IReadOnlyDictionary Create() + { + var dict = new Dictionary(); + + // POC: we should have a unit test to confirm these are as expected and don't change + dict[AAEC.BuiltInUnit.Kilometer] = Units.Kilometers; + dict[AAEC.BuiltInUnit.Meter] = Units.Meters; + dict[AAEC.BuiltInUnit.Centimeter] = Units.Centimeters; + dict[AAEC.BuiltInUnit.Millimeter] = Units.Millimeters; + dict[AAEC.BuiltInUnit.Mile] = Units.Miles; + dict[AAEC.BuiltInUnit.Yards] = Units.Yards; + dict[AAEC.BuiltInUnit.Foot] = Units.Feet; + dict[AAEC.BuiltInUnit.SurveyFoot] = Units.USFeet; + dict[AAEC.BuiltInUnit.Inch] = Units.Inches; + dict[AAEC.BuiltInUnit.Dimensionless] = Units.None; + return dict; + } + + public string ConvertOrThrow(AAEC.BuiltInUnit hostUnit) + { + if (s_unitsMapping.TryGetValue(hostUnit, out string value)) + { + return value; + } + + // POC: probably would prefer something more specific + throw new SpeckleException($"The Unit System \"{hostUnit}\" is unsupported."); + } +} diff --git a/DUI3-DX/Converters/Civil3d/Speckle.Converters.Civil3dShared/GlobalUsings.cs b/DUI3-DX/Converters/Civil3d/Speckle.Converters.Civil3dShared/GlobalUsings.cs new file mode 100644 index 0000000000..c4134c866e --- /dev/null +++ b/DUI3-DX/Converters/Civil3d/Speckle.Converters.Civil3dShared/GlobalUsings.cs @@ -0,0 +1,3 @@ +global using AAEC = Autodesk.Aec; +global using CDB = Autodesk.Civil.DatabaseServices; +global using SOBE = Objects.BuiltElements; diff --git a/DUI3-DX/Converters/Civil3d/Speckle.Converters.Civil3dShared/Speckle.Converters.Civil3dShared.projitems b/DUI3-DX/Converters/Civil3d/Speckle.Converters.Civil3dShared/Speckle.Converters.Civil3dShared.projitems new file mode 100644 index 0000000000..1dc6ebd3b8 --- /dev/null +++ b/DUI3-DX/Converters/Civil3d/Speckle.Converters.Civil3dShared/Speckle.Converters.Civil3dShared.projitems @@ -0,0 +1,19 @@ + + + + $(MSBuildAllProjects);$(MSBuildThisFileFullPath) + true + 35175682-da83-4c0a-a49d-b191f5885d8e + + + Speckle.Converters.Civil3dShared + + + + + + + + + + \ No newline at end of file diff --git a/DUI3-DX/Converters/Civil3d/Speckle.Converters.Civil3dShared/Speckle.Converters.Civil3dShared.shproj b/DUI3-DX/Converters/Civil3d/Speckle.Converters.Civil3dShared/Speckle.Converters.Civil3dShared.shproj new file mode 100644 index 0000000000..ab81b391e7 --- /dev/null +++ b/DUI3-DX/Converters/Civil3d/Speckle.Converters.Civil3dShared/Speckle.Converters.Civil3dShared.shproj @@ -0,0 +1,13 @@ + + + + 35175682-da83-4c0a-a49d-b191f5885d8e + 14.0 + + + + + + + + diff --git a/DUI3-DX/Converters/Civil3d/Speckle.Converters.Civil3dShared/ToSpeckle/BuiltElements/PipeToSpeckleConverter.cs b/DUI3-DX/Converters/Civil3d/Speckle.Converters.Civil3dShared/ToSpeckle/BuiltElements/PipeToSpeckleConverter.cs new file mode 100644 index 0000000000..f061a890bd --- /dev/null +++ b/DUI3-DX/Converters/Civil3d/Speckle.Converters.Civil3dShared/ToSpeckle/BuiltElements/PipeToSpeckleConverter.cs @@ -0,0 +1,60 @@ +using Objects; +using Objects.Other; +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; +using Speckle.Core.Models; +using AECPropDB = Autodesk.Aec.PropertyData.DatabaseServices; + +namespace Speckle.Converters.Civil3d.ToSpeckle.BuiltElements; + +[NameAndRankValue(nameof(CDB.Pipe), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +public class PipeToSpeckleConverter : IToSpeckleTopLevelConverter +{ + private readonly ITypedConverter _pointConverter; + private readonly ITypedConverter _curveConverter; + private readonly ITypedConverter _boxConverter; + private readonly ITypedConverter _solidConverter; + private readonly ITypedConverter> _propertySetConverter; + private readonly IConversionContextStack _contextStack; + + public PipeToSpeckleConverter( + ITypedConverter pointConverter, + ITypedConverter curveConverter, + ITypedConverter boxConverter, + ITypedConverter solidConverter, + ITypedConverter> propertySetConverter, + IConversionContextStack contextStack + ) + { + _pointConverter = pointConverter; + _curveConverter = curveConverter; + _boxConverter = boxConverter; + _solidConverter = solidConverter; + _propertySetConverter = propertySetConverter; + _contextStack = contextStack; + } + + public Base Convert(object target) => Convert((CDB.Pipe)target); + + public SOBE.Pipe Convert(CDB.Pipe target) + { + ICurve curve = _curveConverter.Convert(target.BaseCurve); + SOG.Mesh pipeMesh = _solidConverter.Convert(target.Solid3dBody); + + SOBE.Pipe specklePipe = + new() + { + baseCurve = curve, + diameter = target.InnerDiameterOrWidth, + length = target.Length3DToInsideEdge, + displayValue = new List { pipeMesh }, + units = _contextStack.Current.SpeckleUnits + }; + + // POC: not setting property sets yet, need to determine connector parameter interoperability + // POC: not setting part data yet, same reason as above + // POC: not setting additional pipe properties, probably should scope a CivilPipe class + + return specklePipe; + } +} diff --git a/DUI3-DX/Converters/Civil3d/Speckle.Converters.Civil3dShared/ToSpeckle/Raw/PropertySetToSpeckleRawConverter.cs b/DUI3-DX/Converters/Civil3d/Speckle.Converters.Civil3dShared/ToSpeckle/Raw/PropertySetToSpeckleRawConverter.cs new file mode 100644 index 0000000000..d3576871cc --- /dev/null +++ b/DUI3-DX/Converters/Civil3d/Speckle.Converters.Civil3dShared/ToSpeckle/Raw/PropertySetToSpeckleRawConverter.cs @@ -0,0 +1,55 @@ +using Objects.Other; +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; +using AECPropDB = Autodesk.Aec.PropertyData.DatabaseServices; + +namespace Speckle.Converters.Civil3d.ToSpeckle.Raw; + +public class PropertySetToSpeckleRawConverter : ITypedConverter> +{ + private readonly ITypedConverter _vectorConverter; + private readonly ITypedConverter _pointConverter; + private readonly IConversionContextStack _contextStack; + + public PropertySetToSpeckleRawConverter( + ITypedConverter vectorConverter, + ITypedConverter pointConverter, + IConversionContextStack contextStack + ) + { + _vectorConverter = vectorConverter; + _pointConverter = pointConverter; + _contextStack = contextStack; + } + + public List Convert(object target) => Convert((AECPropDB.PropertySet)target); + + public List Convert(AECPropDB.PropertySet target) + { + List properties = new(); + + ADB.Transaction tr = _contextStack.Current.Document.TransactionManager.TopTransaction; + AECPropDB.PropertySetDefinition setDef = (AECPropDB.PropertySetDefinition) + tr.GetObject(target.PropertySetDefinition, ADB.OpenMode.ForRead); + + // get property definitions + var propDefs = new Dictionary(); + foreach (AECPropDB.PropertyDefinition def in setDef.Definitions) + { + propDefs.Add(def.Id, def); + } + + foreach (AECPropDB.PropertySetData data in target.PropertySetData) + { + string fieldName = propDefs.TryGetValue(data.Id, out AECPropDB.PropertyDefinition value) + ? value.Name + : data.FieldBucketId; + + object fieldData = data.GetData(); + DataField field = new(fieldName, fieldData.GetType().Name, data.UnitType.PluralName(false), fieldData); + properties.Add(field); + } + + return properties; + } +} diff --git a/DUI3-DX/Directory.Packages.props b/DUI3-DX/Directory.Packages.props index 217c4a191b..06de90bb1c 100644 --- a/DUI3-DX/Directory.Packages.props +++ b/DUI3-DX/Directory.Packages.props @@ -4,25 +4,25 @@ - + - + - + - - + + - + - - - + + + - + \ No newline at end of file From 4e57b47381bc4391f844d30bf2266eeb57dcdd8e Mon Sep 17 00:00:00 2001 From: Adam Hathcock Date: Fri, 5 Jul 2024 15:46:38 +0100 Subject: [PATCH 261/261] Disable the installer trigger for alpha branch (#3561) --- .github/workflows/main.yml | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 032f35808a..b83fa759fc 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -11,20 +11,20 @@ jobs: build: uses: ./.github/workflows/ci.yml - deploy-installers: - runs-on: ubuntu-latest - needs: build - steps: - - name: 🔫 Trigger Build Installers - uses: ALEEF02/workflow-dispatch@v3.0.0 - with: - workflow: Build Installers - repo: specklesystems/connector-installers - token: ${{ secrets.CONNECTORS_GH_TOKEN }} - inputs: '{ "run_id": "${{ github.run_id }}", "version": "${{ needs.build.outputs.version }}" }' - ref: main - wait-for-completion: true - wait-for-completion-interval: 10s - wait-for-completion-timeout: 10m - display-workflow-run-url: true - display-workflow-run-url-interval: 10s + # deploy-installers: + # runs-on: ubuntu-latest + # needs: build + # steps: + # - name: 🔫 Trigger Build Installers + # uses: ALEEF02/workflow-dispatch@v3.0.0 + # with: + # workflow: Build Installers + # repo: specklesystems/connector-installers + # token: ${{ secrets.CONNECTORS_GH_TOKEN }} + # inputs: '{ "run_id": "${{ github.run_id }}", "version": "${{ needs.build.outputs.version }}" }' + # ref: main + # wait-for-completion: true + # wait-for-completion-interval: 10s + # wait-for-completion-timeout: 10m + # display-workflow-run-url: true + # display-workflow-run-url-interval: 10s