How to add items to the right-click menu in Grasshopper.
This example shows how we can add a text item to the right-click menu, and change a field within the class of our Grasshopper component.
The code to do this is written for compiled C# components written in an environment such as Visual Studio. Add these methods to your component class.
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;
This creates the menu item called ‘Flip myBool’ when we right-click the component. When we click on the menu item, it calls the Menu_DoClick method. We can define any method (with any name) that we want here.
References
http://www.grasshopper3d.com/forum/topics/set-input-parameter-from-a-pop-up-menu-vb