Hello,
I’ve been trying to add a simple bool to the menu on a Grasshopper C# component in Rhino 8. It appears that I need to add a Nuget package? How would I do that?
What do I need to add to get the code up and running?
The code, courtesy of James Ramsden:
protected override void AppendAdditionalComponentMenuItems(System.Windows.Forms.ToolStripDropDown menu)
{
base.AppendAdditionalComponentMenuItems(menu);
Menu_AppendItem(menu, "Flip myBool", Menu_DoClick);
}
private void Menu_DoClick(object sender, EventArgs e)
{
myBool = !myBool;
}
public bool myBool = false;
Any help or advice would be very very welcome!
Ash
I’m curious to see if it can be done too.
It seems that the GH_ScriptInstance
class doesn’t have that method to override.
Also not much documentation on this GH_ScriptInstance
Ash:
System.Windows.Forms
you probably need to add the System.Window.Forms dll as a reference.
right click on references and hit Add Reference
My dll is residing in an old framework folder as I’m working on an old plugin, but you may be able to find it somewhere else for .Net Core
C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.8\System.Windows.Forms.dll
Remember to add
using System.Windows.Forms
in top of your script.
looks like this when added
Edit: maybe system.windows.forms is actually among the default list of pickable references. My VS is throwing a UI error now so can’t check.
Thanks @sonderskovmathias . That’s a really clear explanation.
That solves half the problem, the VS part. Getting System.Windows.Forms to load into the the C# node is throwing errors.
Also as @Will_Wang noted, GH_ScriptInstance
doesn’t seem to have that method for Rhino 8.