diff --git a/src/compute.geometry/Startup.cs b/src/compute.geometry/Startup.cs index f9d51ed3..0434a22b 100644 --- a/src/compute.geometry/Startup.cs +++ b/src/compute.geometry/Startup.cs @@ -55,21 +55,8 @@ void RhinoCoreStartup() Rhino.RhinoApp.SendWriteToConsole = true; - // Load GH at startup so it can get initialized on the main thread - Log.Information("(1/3) Loading grasshopper"); - var pluginObject = Rhino.RhinoApp.GetPlugInObject("Grasshopper"); - var runheadless = pluginObject?.GetType().GetMethod("RunHeadless"); - if (runheadless != null) - runheadless.Invoke(pluginObject, null); - - Rhino.RhinoApp.SendWriteToConsole = false; - - Log.Information("(2/3) Loading compute plug-ins"); - var loadComputePlugins = typeof(Rhino.PlugIns.PlugIn).GetMethod("LoadComputeExtensionPlugins"); - if (loadComputePlugins != null) - loadComputePlugins.Invoke(null, null); - // NOTE: + // eirannejad 10/02/2024 (COMPUTE-268) // Ensure RhinoCode plugin (Rhino plugin) is loaded. This plugin registers scripting // languages and starts the scripting server that communicates with rhinocode CLI. It also makes // the ScriptEditor and RhinoCodeLogs commands available. @@ -78,13 +65,43 @@ void RhinoCoreStartup() // the script environments (especially python 3) will be initialized. This increases the execution // time on the first run on any script component. However after that the script components should run // normally. The scripting environment will only re-initialize when a new version of Rhino is installed. - Log.Information("(3/3) Loading rhino scripting plugin"); - if (!Rhino.PlugIns.PlugIn.LoadPlugIn(s_rhinoCodePluginId)) + // eirannejad 12/3/2024 (COMPUTE-268) + // This load is placed before Grasshopper in case GH needs to load any plugins published by the + // new scripting tools in Rhino >= 8 + Log.Information("(1/3) Loading rhino scripting plugin"); + if (Rhino.PlugIns.PlugIn.LoadPlugIn(s_rhinoCodePluginId)) + { + Log.Information("Successfully loaded scripting plugin"); + + // eirannejad 12/3/2024 (COMPUTE-268) + // now configuring scripting env to avoid using rhino progressbar and + // dump init and package install messages to Rhino.RhinoApp.Write + if (Rhino.RhinoApp.GetPlugInObject(s_rhinoCodePluginId) is object rhinoCodeController) + { + ((dynamic)rhinoCodeController).SendReportsToConsole = true; + Log.Information("Configured scripting plugin for compute"); + } + } + // If plugin load fails, let compute run, but log the error + else { - // If plugin load fails, let compute run, but log the error Log.Error("Error loading rhino scripting plugin. Grasshopper script components are going to fail"); } + // Load GH at startup so it can get initialized on the main thread + Log.Information("(2/3) Loading grasshopper"); + var pluginObject = Rhino.RhinoApp.GetPlugInObject("Grasshopper"); + var runheadless = pluginObject?.GetType().GetMethod("RunHeadless"); + if (runheadless != null) + runheadless.Invoke(pluginObject, null); + + Rhino.RhinoApp.SendWriteToConsole = false; + + Log.Information("(3/3) Loading compute plug-ins"); + var loadComputePlugins = typeof(Rhino.PlugIns.PlugIn).GetMethod("LoadComputeExtensionPlugins"); + if (loadComputePlugins != null) + loadComputePlugins.Invoke(null, null); + //ApiKey.Initialize(pipelines); //Rhino.Runtime.HostUtils.RegisterComputeEndpoint("grasshopper", typeof(Endpoints.GrasshopperEndpoint)); }