Skip to content

Instantly share code, notes, and snippets.

@StepMaher StepMaher/
Last active Nov 4, 2015

What would you like to do?
Reboots Grasshopper.
Reboots Grasshopper.
Inputs: Reboot: Set to 'True' to reboot Grasshopper.
ghenv.Component.Name = "Reboot Grasshopper"
ghenv.Component.NickName = 'GH-Rebooter'
# Stephen P. Maher / 2015
# Many thanks to Andrew Heumann for the help.
import Grasshopper as gh
import System.Drawing as sd
import rhinoscriptsyntax as rs
comp = ghenv.Component
ghdoc = comp.OnPingDocument()
canvas = gh.Instances.ActiveCanvas
hasExecutedOnce = False
# The array accessor lets you pick which input you want
targetInput = comp.Params.Input[0]
# Define a function to expire this component.
def expireThis(doc):
hasExecutedOnce = True
# Make sure the input doesn't already have a button
if targetInput.Sources.Count==0:
# Create the button
button = gh.Kernel.Special.GH_ButtonObject()
# Recompute this component so that it has access to the value of the button
if not hasExecutedOnce:
# Add the button
thisPivot = targetInput.Attributes.Pivot
# Set the button location
button.Attributes.Pivot = sd.PointF(thisPivot.X-200,thisPivot.Y-10)
# Connect the button
# Expire the solution
if Reboot:
rs.Command("_GrasshopperUnloadPlugin", True) # Unload Grasshopper
rs.Command("_Grasshopper", True) # Reload Grasshopper
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.