From e9d6a3069deb8ed3e1a8d627b7d5ca5027708726 Mon Sep 17 00:00:00 2001 From: connorivy <43247197+connorivy@users.noreply.github.com> Date: Tue, 30 Aug 2022 12:53:06 -0400 Subject: [PATCH] fix: better build optimization and bug fix (#1560) * switched to avalonia dispatcher * add missing import * fix: updating objects breaks when the og object doesn't import correctly * change the way that the UI "refreshes" Co-authored-by: Connor Ivy --- .../ConnectorBindingsRevit2.Receive.cs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/ConnectorRevit/ConnectorRevit/UI/ConnectorBindingsRevit2/ConnectorBindingsRevit2.Receive.cs b/ConnectorRevit/ConnectorRevit/UI/ConnectorBindingsRevit2/ConnectorBindingsRevit2.Receive.cs index 74f7723c26..d2123b5f50 100644 --- a/ConnectorRevit/ConnectorRevit/UI/ConnectorBindingsRevit2/ConnectorBindingsRevit2.Receive.cs +++ b/ConnectorRevit/ConnectorRevit/UI/ConnectorBindingsRevit2/ConnectorBindingsRevit2.Receive.cs @@ -3,8 +3,10 @@ using System.Collections.Concurrent; using System.Collections.Generic; using System.Linq; +using System.Threading; using System.Threading.Tasks; using Autodesk.Revit.DB; +using Avalonia.Threading; using ConnectorRevit.Revit; using DesktopUI2.Models; using DesktopUI2.Models.Settings; @@ -167,7 +169,7 @@ private void DeleteObjects(List previouslyReceiveObjects, Lis { foreach (var obj in previouslyReceiveObjects) { - if (newPlaceholderObjects.Any(x => x.applicationId == obj.applicationId)) + if (obj.CreatedIds.Count == 0 || newPlaceholderObjects.Any(x => x.applicationId == obj.applicationId)) continue; var element = CurrentDoc.Document.GetElement(obj.CreatedIds.FirstOrDefault()); @@ -198,10 +200,11 @@ private List ConvertReceivedObjects(ISpeckleConverter convert try { conversionProgressDict["Conversion"]++; - System.Windows.Threading.Dispatcher.CurrentDispatcher.Invoke(() => - { - progress.Update(conversionProgressDict); - }, System.Windows.Threading.DispatcherPriority.Background); + progress.Update(conversionProgressDict); + + var s = new CancellationTokenSource(); + DispatcherTimer.RunOnce(() => s.Cancel(), TimeSpan.FromMilliseconds(10)); + Dispatcher.UIThread.MainLoop(s.Token); //skip element if is from a linked file and setting is off if (!receiveLinkedModels && @base["isRevitLinkedModel"] != null && bool.Parse(@base["isRevitLinkedModel"].ToString())) @@ -216,11 +219,8 @@ private List ConvertReceivedObjects(ISpeckleConverter convert var view = CurrentDoc.ActiveGraphicalView ?? CurrentDoc.Document.ActiveView; var uiView = CurrentDoc.GetOpenUIViews().FirstOrDefault(uv => uv.ViewId.Equals(view.Id)); - //So as not to bother the user by changing the zoom - var zc = uiView.GetZoomCorners().ToList(); - // "refresh" the active view - uiView.ZoomAndCenterRectangle(zc.ElementAt(0), zc.ElementAt(1)); + uiView.Zoom(1); switch (convRes) {