Skip to content

Commit f652800

Browse files
authored
REVIT-245847 (#3279)
* make Dynamo splash screen modal ### Purpose solve an issue where Dynamo does not launch correctly when there is an active Revit command running
1 parent 46e427c commit f652800

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

src/DynamoRevit/DynamoRevit.cs

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,8 @@ public Result ExecuteCommand(DynamoRevitCommandData commandData)
309309
// Show splash screen when dynamo is started, otherwise run UIless mode when needed.
310310
if (CheckJournalForKey(commandData, JournalKeys.ShowUiKey, true))
311311
{
312-
var ssEventHandler = new DynamoExternalEventHandler(new Action(() =>
312+
//var ssEventHandler = new DynamoExternalEventHandler(new Action(() =>
313+
var splashScreenInitializerFN = new Action(() =>
313314
{
314315
try
315316
{
@@ -341,11 +342,11 @@ public Result ExecuteCommand(DynamoRevitCommandData commandData)
341342
RevitDynamoModel = null;
342343
}
343344
}
344-
}));
345+
});
345346

346347
/* Register DynamoExternalEventHandler so Revit will call our callback
347348
we requested with API access. */
348-
SplashScreenExternalEvent = ExternalEvent.Create(ssEventHandler);
349+
//SplashScreenExternalEvent = ExternalEvent.Create(ssEventHandler);
349350

350351
extCommandData = commandData;
351352
UpdateSystemPathForProcess();
@@ -355,20 +356,22 @@ we requested with API access. */
355356
our callback within an api context. */
356357
splashScreen.DynamicSplashScreenReady += () =>
357358
{
358-
SplashScreenExternalEvent.Raise();
359+
// SplashScreenExternalEvent.Raise();
360+
splashScreenInitializerFN();
359361
};
360362
splashScreen.Closed += OnSplashScreenClosed;
361363

362364
// Set the owner for splashscreen window.
363365
IntPtr mwHandle = commandData.Application.MainWindowHandle;
364366
new WindowInteropHelper(splashScreen).Owner = mwHandle;
365367

366-
// show the splashscreen.
367-
splashScreen.Show();
368-
369368
// Disable the Dynamo button in Revit to avoid launching multiple instances.
370369
DynamoRevitApp.DynamoButtonEnabled = false;
371370

371+
// show the splashscreen.
372+
//splashScreen.Show();
373+
splashScreen.ShowDialog(); // TODO (REVIT-245847): Temporary solution - using modal splash screen as a workaround.
374+
372375
return Result.Succeeded;
373376
}
374377
else // Run UIless mode by just initializing RevitDynamoModel
@@ -708,19 +711,21 @@ private static DynamoView InitializeCoreView(DynamoRevitCommandData commandData)
708711
//Register DynamoExternalEventHandler so Revit will call our callback
709712
//we requested with API access.
710713

711-
var appEventHandler = new DynamoExternalEventHandler(new Action(() =>
714+
//var appEventHandler = new DynamoExternalEventHandler(new Action(() =>
715+
var appInitializerFN = new Action(() =>
712716
{
713717
UpdateLibraryLayoutSpec();
714718

715719
const int timeout = 1000 * 60; // 60s timeout
716720
Journaling.WriteAsyncEvent("Dynamo UI loaded", () => { }, timeout);
717-
}));
721+
});
718722

719-
DynamoAppExternalEvent = ExternalEvent.Create(appEventHandler);
723+
//DynamoAppExternalEvent = ExternalEvent.Create(appEventHandler);
720724

721725
dynamoView.Dispatcher.UnhandledException += Dispatcher_UnhandledException;
722726
dynamoView.Closed += OnDynamoViewClosed;
723-
dynamoView.Loaded += (o, e) => DynamoAppExternalEvent.Raise();
727+
//dynamoView.Loaded += (o, e) => DynamoAppExternalEvent.Raise();
728+
dynamoView.Loaded += (o, e) => appInitializerFN();
724729

725730
return dynamoView;
726731
}

0 commit comments

Comments
 (0)