From 6529bebbbd27cb2c33bf03d646579fd55aa99dcc Mon Sep 17 00:00:00 2001 From: mjkkirschner Date: Wed, 3 Jan 2024 17:26:15 -0500 Subject: [PATCH] when extension is late loaded run the graph to resolve the new engine. --- IronPythonExtension/IronPythonExtension.cs | 24 ++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/IronPythonExtension/IronPythonExtension.cs b/IronPythonExtension/IronPythonExtension.cs index d453858..17f3f68 100644 --- a/IronPythonExtension/IronPythonExtension.cs +++ b/IronPythonExtension/IronPythonExtension.cs @@ -1,4 +1,5 @@ using Dynamo.Extensions; +using Dynamo.Graph.Workspaces; using Dynamo.Logging; using Dynamo.PythonServices; using System; @@ -60,15 +61,30 @@ public void Startup(StartupParams sp) /// Action to be invoked when the Dynamo has started up and is ready /// for user interaction. /// - /// - public void Ready(ReadyParams sp) + /// + public void Ready(ReadyParams rp) { var extraPath = Path.Combine(new FileInfo(Assembly.GetExecutingAssembly().Location).Directory.Parent.FullName, "extra"); - var alc = new IsolatedPythonContext(Path.Combine(extraPath,"DSIronPython.dll")); - var dsIronAssem = alc.LoadFromAssemblyName(new AssemblyName("DSIronPython")); + var alc = new IsolatedPythonContext(Path.Combine(extraPath,$"{PythonEvaluatorAssembly}.dll")); + var dsIronAssem = alc.LoadFromAssemblyName(new AssemblyName(PythonEvaluatorAssembly)); //load the engine into Dynamo ourselves. LoadPythonEngine(dsIronAssem); + + //we used to do this: + //but it's not neccesary to load anything into the VM. + //instead we skip all the extra work and trigger the side effect we want + //which is re executing the graph after the dsIronPython evaluator is loaded into the PythonEngineManager. + //rp.StartupParams.LibraryLoader.LoadNodeLibrary(dsIronAssem); + + if(rp.CurrentWorkspaceModel is HomeWorkspaceModel hwm) + { + foreach (var n in hwm.Nodes) + { + n.MarkNodeAsModified(true); + } + hwm.Run(); + } } ///