Skip to content

Commit

Permalink
forcing commands.rhp to be loaded
Browse files Browse the repository at this point in the history
  • Loading branch information
andyopayne committed Nov 19, 2024
1 parent eb81091 commit 4cd7234
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/compute.geometry/FixedEndpoints.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ static async Task GetInstalledPluginsRhino(HttpContext ctx)
{
var info = Rhino.PlugIns.PlugIn.GetPlugInInfo(k);
//Could also use: info.IsLoaded
if (info != null && !info.ShipsWithRhino && !rhPluginInfo.ContainsKey(info.Name))
if (info != null && !rhPluginInfo.ContainsKey(info.Name) && !info.ShipsWithRhino)
{
rhPluginInfo.Add(info.Name, info.Version);
}
Expand Down
27 changes: 21 additions & 6 deletions src/compute.geometry/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,12 @@ namespace compute.geometry
{
public class Startup
{
// https://github.com/mcneel/rhino/blob/e1192835cbf03f662d0cf857ee9239b84109eeed/src4/rhino4/Plug-ins/RhinoCodePlugins/RhinoCodePlugin/AssemblyInfo.cs
//https://github.com/mcneel/rhino/blob/e1192835cbf03f662d0cf857ee9239b84109eeed/src4/rhino4/Plug-ins/RhinoCodePlugins/RhinoCodePlugin/AssemblyInfo.cs
static readonly Guid s_rhinoCodePluginId = new Guid("c9cba87a-23ce-4f15-a918-97645c05cde7");

//https://github.com/mcneel/rhino/blob/8.x/src4/rhino4/Plug-ins/Commands/Properties/AssemblyInfo.cs
static readonly Guid s_rhinoCommandsPluginId = new Guid("02bf604d-799c-4cc2-830e-8d72f21b14b7");

public void ConfigureServices(IServiceCollection services)
{
services.AddCors(options =>
Expand Down Expand Up @@ -54,6 +57,20 @@ void RhinoCoreStartup()
Logging.LogExceptionData(ex);
};

// NOTE:
// andyopayne 11/19/2024 (RH-84777)
// The commands.rhp needs to be loaded so that some features suchs as the gltf exporter will work.
// This is a temporary solution until the gltf exporter is moved into Rhinocommon or Rhino.UI
Log.Information("(1/4) Loading rhino commands plugin");
if (Rhino.PlugIns.PlugIn.LoadPlugIn(s_rhinoCommandsPluginId))
{
Log.Information("Successfully loaded commands plugin");
}
else
{
Log.Error("Error loading rhino commands plugin.");
}

// NOTE:
// eirannejad 10/02/2024 (COMPUTE-268)
// Ensure RhinoCode plugin (Rhino plugin) is loaded. This plugin registers scripting
Expand All @@ -67,7 +84,7 @@ void RhinoCoreStartup()
// 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");
Log.Information("(2/4) Loading rhino scripting plugin");
if (Rhino.PlugIns.PlugIn.LoadPlugIn(s_rhinoCodePluginId))
{
Log.Information("Successfully loaded scripting plugin");
Expand All @@ -88,20 +105,18 @@ void RhinoCoreStartup()
}

// Load GH at startup so it can get initialized on the main thread
Log.Information("(2/3) Loading grasshopper");
Log.Information("(3/4) Loading grasshopper");
var pluginObject = Rhino.RhinoApp.GetPlugInObject("Grasshopper");
var runheadless = pluginObject?.GetType().GetMethod("RunHeadless");
if (runheadless != null)
runheadless.Invoke(pluginObject, null);


Log.Information("(3/3) Loading compute plug-ins");
Log.Information("(4/4) 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));
}

}
Expand Down

0 comments on commit 4cd7234

Please sign in to comment.