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 01/12] 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 02/12] 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 03/12] 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 04/12] 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 05/12] 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 06/12] 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 07/12] 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 08/12] 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 09/12] 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 10/12] 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 11/12] 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 17819afcc700680bc8135c2932cb9077ebdd93ed Mon Sep 17 00:00:00 2001 From: Alan Rynne Date: Wed, 8 May 2024 22:20:26 +0200 Subject: [PATCH 12/12] 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 @@ - + - +