Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable Grasshopper while deleting elements. #1245

Merged
merged 1 commit into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/RhinoInside.Revit.GH/Parameters/Element.cs
Original file line number Diff line number Diff line change
Expand Up @@ -450,8 +450,9 @@ void Menu_DeleteElements(object sender, EventArgs e)
{
bool enableSolutions = Guest.DocumentChangedEvent.EnableSolutions;
Guest.DocumentChangedEvent.EnableSolutions = false;
var enabledCanvas = Grasshopper.Instances.ActiveCanvas.Enabled;
Grasshopper.Instances.ActiveCanvas.Enabled = false;
var editor = Grasshopper.Instances.DocumentEditor;
var modifiersEnabled = Grasshopper.Instances.ActiveCanvas.ModifiersEnabled;
if (modifiersEnabled) editor.DisableUI();

try
{
Expand All @@ -478,7 +479,7 @@ void Menu_DeleteElements(object sender, EventArgs e)
}
finally
{
Grasshopper.Instances.ActiveCanvas.Enabled = enabledCanvas;
if (modifiersEnabled) editor.EnableUI();
Guest.DocumentChangedEvent.EnableSolutions = enableSolutions;
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/RhinoInside.Revit/GH/Guest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -790,8 +790,8 @@ internal async void ObjectsDeleted(object sender, (GH_Document Document, IReadOn
if (e.Document.Context != GH_DocumentContext.Loaded)
return;

var canvas = sender as GH_Canvas;
var canvasModifiersEnabled = canvas?.ModifiersEnabled;
var canvas = Instances.ActiveCanvas;
var canvasModifiersEnabled = canvas?.ModifiersEnabled is true;

var grasshopperDocument = e.Document;
var grasshopperDocumentEnabled = grasshopperDocument?.Enabled;
Expand Down Expand Up @@ -848,7 +848,7 @@ internal async void ObjectsDeleted(object sender, (GH_Document Document, IReadOn
var transactionGroups = new Queue<(ARDB.Document Document, ARDB.TransactionGroup Group)>();
try
{
if (canvasModifiersEnabled.HasValue) canvas.ModifiersEnabled = false;
if (canvasModifiersEnabled) Instances.DocumentEditor.DisableUI();
if (grasshopperDocumentEnabled.HasValue) grasshopperDocument.Enabled = false;

var revitDocuments = Revit.ActiveDBApplication.Documents.Cast<ARDB.Document>();
Expand Down Expand Up @@ -939,7 +939,7 @@ internal async void ObjectsDeleted(object sender, (GH_Document Document, IReadOn
}
}

if (canvasModifiersEnabled.HasValue) canvas.ModifiersEnabled = canvasModifiersEnabled.Value;
if (canvasModifiersEnabled) Instances.DocumentEditor.EnableUI();
if (grasshopperDocumentEnabled.HasValue) grasshopperDocument.Enabled = grasshopperDocumentEnabled.Value;

ShowEditor();
Expand Down
Loading