diff --git a/src/IPA.Bcfier.Revit/Models/ViewContinuationInstructions.cs b/src/IPA.Bcfier.Revit/Models/ViewContinuationInstructions.cs index b0170eb..9406a36 100644 --- a/src/IPA.Bcfier.Revit/Models/ViewContinuationInstructions.cs +++ b/src/IPA.Bcfier.Revit/Models/ViewContinuationInstructions.cs @@ -1,10 +1,11 @@ using Autodesk.Revit.DB; +using Autodesk.Revit.UI; namespace IPA.Bcfier.Revit.Models { public class ViewContinuationInstructions { - public Action? ViewContinuation { get; set; } + public Action? ViewContinuation { get; set; } public ElementId? ViewId { get; set; } diff --git a/src/IPA.Bcfier.Revit/RevitTaskQueueHandler.cs b/src/IPA.Bcfier.Revit/RevitTaskQueueHandler.cs index 1c78d61..8483e4a 100644 --- a/src/IPA.Bcfier.Revit/RevitTaskQueueHandler.cs +++ b/src/IPA.Bcfier.Revit/RevitTaskQueueHandler.cs @@ -80,7 +80,7 @@ private void HandlAfterViewCreationCallbackQueueItems(UIDocument uiDocument) var item = AfterViewCreationCallbackQueue.Dequeue(); if (item?.ViewId == uiDocument.ActiveView.Id) { - item.ViewContinuation?.Invoke(); + item.ViewContinuation?.Invoke(uiDocument); Task.Run(async () => { if (item != null && item.Callback != null) diff --git a/src/IPA.Bcfier.Revit/Services/RevitViewpointDisplayService.cs b/src/IPA.Bcfier.Revit/Services/RevitViewpointDisplayService.cs index 70ce62e..026ce9d 100644 --- a/src/IPA.Bcfier.Revit/Services/RevitViewpointDisplayService.cs +++ b/src/IPA.Bcfier.Revit/Services/RevitViewpointDisplayService.cs @@ -139,7 +139,7 @@ public RevitViewpointDisplayService(UIDocument uiDocument) return null; } - Action viewContinuation = () => + Action viewContinuation = (uiDocument) => { if (bcfViewpoint.ViewpointComponents == null) { @@ -156,25 +156,25 @@ public RevitViewpointDisplayService(UIDocument uiDocument) _uiDocument.GetOpenUIViews().First().ZoomAndCenterRectangle(m_xyzTl, m_xyzBr); } - var baseViewTemplate = new FilteredElementCollector(doc) + var baseViewTemplate = new FilteredElementCollector(uiDocument.Document) .OfClass(typeof(View)) .Cast() .Where(view => view.IsTemplate && view.Name.Contains("3D") && view.Name.Contains("IPA BCF")) .FirstOrDefault(); if (baseViewTemplate != null) { - doc.ActiveView.ApplyViewTemplateParameters(baseViewTemplate); + uiDocument.Document.ActiveView.ApplyViewTemplateParameters(baseViewTemplate); } var elementsToSelect = new List(); var elementsToHide = new List(); var elementsToShow = new List(); - var visibleElems = new FilteredElementCollector(doc, doc.ActiveView.Id) + var visibleElems = new FilteredElementCollector(uiDocument.Document, uiDocument.Document.ActiveView.Id) .WhereElementIsNotElementType() .WhereElementIsViewIndependent() .ToElementIds() - .Where(e => doc.GetElement(e).CanBeHidden(doc.ActiveView)); //might affect performance, but it's necessary + .Where(e => uiDocument.Document.GetElement(e).CanBeHidden(uiDocument.Document.ActiveView)); //might affect performance, but it's necessary bool canSetVisibility = (bcfViewpoint.ViewpointComponents.Visibility != null && bcfViewpoint.ViewpointComponents.Visibility.DefaultVisibility && @@ -213,29 +213,29 @@ public RevitViewpointDisplayService(UIDocument uiDocument) } } - using (var trans = new Transaction(_uiDocument.Document)) + using (var trans = new Transaction(uiDocument.Document)) { if (trans.Start("Apply BCF visibility and selection and section box") == TransactionStatus.Started) { if (elementsToHide.Any()) - doc.ActiveView.HideElementsTemporary(elementsToHide); + uiDocument.Document.ActiveView.HideElementsTemporary(elementsToHide); //there are no items to hide, therefore hide everything and just show the visible ones else if (elementsToShow.Any()) - doc.ActiveView.IsolateElementsTemporary(elementsToShow); + uiDocument.Document.ActiveView.IsolateElementsTemporary(elementsToShow); if (elementsToSelect.Any()) - _uiDocument.Selection.SetElementIds(elementsToSelect); + uiDocument.Selection.SetElementIds(elementsToSelect); - if (_uiDocument.ActiveView is View3D view3d) + if (uiDocument.ActiveView is View3D view3d) { - ApplyClippingPlanes(_uiDocument, view3d, bcfViewpoint); + ApplyClippingPlanes(uiDocument, view3d, bcfViewpoint); } } trans.Commit(); } - _uiDocument.RefreshActiveView(); + uiDocument.RefreshActiveView(); }; return new ViewContinuationInstructions