Running scripts from Toolbar buttons
This is only for Windows Rhino right now since you can’t customize toolbar buttons on Mac yet, but once that feature becomes available I’m pretty sure the technique will be the same.
In Rhino, create a new toolbar button and edit it. Consult the Rhino help for for adding and editing toolbar buttons. Now you have three options (that I can think of at the moment) for adding a python script to a toolbar button. All of these involve executing the RunPythonScript command
- Directly embed the script
Make sure the first line reads -_RunPythonScript (. Note that there needs to be a space between RunPythonScript and the parentheses.
Make sure the last line is just a closing parentheses. The lines in between are interpreted as your python script.
-_RunPythonScript ( import rhinoscriptsyntax as rs point0 = rs.GetPoint("start") point1 = rs.GetPoint("end") rs.AddLine(point0,point1) )
- Absolute path to the script
- Path to script on search path
If the script is on python’s search path, you can use the following form to let python find the script (use period separate subdirectories.)