Target Audience
This guide is for end users who want to download, install, use, and uninstall scripts and plugins. For information about writing scripts, see the Rhino Developer Documentation.
Background
Throughout the years, Rhino has grown as a standalone product and has become a popular developer platform that allows users to add functionality in the form of scripts and plugins. Many of the scripts written are scattered around the internet and on discourse.mcneel.com in particular. The scripts you find are written in either RhinoScript (Visual Basic) or in PythonScript. When you find them in their raw format (.rvb for RhinoScript scripts or .py for PythonScript scripts), you can use them in different ways. This guide will look at the options to install, use, and uninstall scripts and plugins in Rhino for Windows.
Using RhinoScript Scripts
Option 1: Loading and executing scripts with LoadScript and RunScript
In this guide, I’m taking the script on this page as an example. If you only want to use a script written in RhinoScript and downloaded one you want to run, you can do this in two steps: First, load the script with _LoadScript and click the Add… button. Then, you need to click the name of the script and click the Load button.
After the script is loaded, it is ready to use. To execute it, close the LoadScript dialog and run _RunScript, which gives you a dialog with all loaded scripts from which to choose. In this example, the script has two SubRoutines that can run:
Option 2: Loading and executing scripts through the built-in RhinoScript editor
RhinoScript scripts can be directly run through the built-in RhinoScript editor. First, start the command _EditScript, which starts the RhinoScript editor. Here, you can load scripts through File > Open, and once the script is loaded, you can execute it by pressing F5 on the keyboard or clicking on the green triangle. This environment is most suitable if you are writing your own scripts or want to modify a script you downloaded.
When we load this script and run it, nothing appears to happen. This is because there are two SubRoutines, RingTorus1 and RingTorus2, but none are actually being called. Say you want to execute the subroutine RingTorus1, you will need to add this line above Sub RingTorus1():
Call RingTorus1()
Option 3: Drag and Drop
A third option is to drag and drop the downloaded script into Rhino. This, however, will only work if the script was made to work like that. To determine if it is, open the script in the RhinoScript editor. There will be two lines of code where the first starts with Rhino.AddStartupScript
and the second starts with Rhino.AddAlias
.
Sometimes, there can be more than one alias if the script contains more than one subroutine, e.g.:
Option Explicit
'Script written by Pascal
'RMA
Rhino.AddStartUpScript Rhino.LastLoadedScriptFile
Rhino.AddAlias "HatchDirection", "_NoEcho _-Runscript (HatchDirection)"
Rhino.AddAlias "HatchOrient", "_NoEcho _-Runscript (HatchOrient)"
'Call HatchDirection()
Sub HatchDirection()
'…(script continues)
If the RingTorus script from the example was a drag and drop script it would look like this:
No subroutines are called in this script because they are handled by the statements Rhino.AddStartUpScript Rhino.LastLoadedScriptFile
and Rhino.AddAlias ...
If you download a .rvb script, it’s best first to open and inspect it in the RhinoScript editor to see if it was meant to be drag and dropped and if it is, to note the aliases that will be added. While it is easy to add scripts to Rhino this way, removing them takes a couple of manual steps. See uninstalling rhino scripts.
d:\scripts
into Rhino, it would add the Aliases RingTorus1 and RingTorus2. This means these commands are now added to the list of commands.Option 4: Adding the script to a button
You can customize Rhino’s buttons. All toolbars that ship with Rhino contain buttons that execute a command. For example, if you open the button editor (Shift+Right click on a button) of the single point button, you’ll find under Command:
! _Point
The exclamation mark is a shortcut for Cancel (canceling any running command), and the underscore (_) will force Rhino to execute the following command as an English command. To make a button that executes a script, the command has this structure:
! -_RunScript (
[here goes the full content of the script without the square brackets]
)
Save your Toolbar once you have edited or added a new button. See Chapter 3 of the Rhino Level 2 Training Manual, for more information about customizing Rhino.
In the case of the example, we could add the script to a button and make the left and right mouse load the two different subroutines. Left calls RingTorus1 and Right calls RingTorus2:
Option 5: Adding a script file path to a button (recommended)
While Option 4 might work, maintaining or editing scripts fully pasted in a button is inconvenient. A better way is to keep your scripts in a separate folder and add the following to the button command area:
! -_LoadScript "full\path\to\script.rvb"
-_Runscript "SubRoutineName"
In our Torus example, the content of the button is like this:
Option 6: Adding a script file path to an Alias
The last option is to run scripts by adding the path to an alias, just like you have seen in the previous option. For this go to Tools > Options > Aliases, click on New, and choose a name for your alias, e.g.:
Alias | Command macro | |
---|---|---|
RingTorus1 |
! -_Loadscript "d:\scripts\RingTorus.rvb" -_RunScript "RingTorus1" |
Uninstalling RhinoScript Scripts
Technically there is nothing to uninstall when you want to remove a script. But if you want to remove a script you’ve drag-and-dropped onto Rhino, you need to take these two steps: Remove the associated Aliases through Tools > Options > Aliases.
Remove the link to the script file in Tools > Options > RhinoScript.
Using PythonScript Scripts
Option 1: Loading and executing scripts through the built-in PythonScript editor
You can run PythonScript scripts directly through the built-in PythonScript editor. Start the command _EditPythonScript, which starts the PythonScript editor. Here you can load scripts through File > Open, and once the script is loaded, you can execute it by pressing F5 on the keyboard or clicking on the green triangle. This environment is most suitable if you are writing your own scripts or want to modify a script you downloaded.
Option 2: Executing Python scripts directly through _RunPythonScript
The command _RunPythonScript opens a dialog box that allows you to open and directly run a chosen .py file. This option is convenient if you just want to run a script occasionally.
Option 3: Adding the script to a button
You can customize Rhino’s buttons. All toolbars that ship with Rhino contain buttons that execute a command. For example, if you open the button editor (Shift+Right click on a button) of the single point button, you’ll find under Command:
! _Point
The exclamation mark is a shortcut for _Cancel (canceling any running command), the underscore will force Rhino to execute the command that follows as an English command. To make a button that executes a script, the command has this structure:
! -_RunPythonScript (
[here goes the full content of the script without the square brackets]
)
E.g., if your script looks like this …
# this simple script adds a line to the document
import rhinoscriptsyntax as rs
def make_line():
rs.AddLine([0,0,0], [10,10,10])
if __name__ == "__main__":
make_line()
… your button should not use the if __name__ == "__main__"
statement and your button script should look like this:
! _Noecho -_RunPythonScript (
import rhinoscriptsyntax as rs
def make_line():
rs.AddLine([0,0,0], [10,10,10])
make_line()
)
Option 4: Adding a script file path to a button (recommended)
While Option 3 might work, maintaining or editing scripts that are fully pasted in a button is not very convenient. A better way is to keep your scripts in a separate folder and add the following to the button command area:
! -_RunPythonScript (
"full\path\to\pythonscript.py"
)
For example, if my scripts are located in d:\scripts, and I want to execute make_line.py, it will look like this:
! -_RunPythonScript (
"d:\scripts\make_line.py"
)
Option 5: Adding a script file path to an Alias
The last option is to run scripts by adding the path to an alias, just like you have seen in the previous option. To do this, go to Tools>Options>Aliases, click on New and choose a name for your alias. For example, if I want to run my make_line.py script by the commandname MakeLine, then my alias would be as follows:
Alias | Command macro | |
---|---|---|
MakeLine |
! -_RunPythonScript ("d:\scripts\make_line.py") |
Uninstalling PythonScript scripts
Python scripts are only loaded on demand, so technically, there is nothing to uninstall. The only thing you need to do is remove the aliases.
Installing Plugins
Option 1: Drag and drop onto Rhino
RhinoScript script and PythonScript scripts can be turned into installable files and will then get the same extension as the native Rhino plugins: .rhp files. These files can be drag-and-dropped onto an open Rhino session to install. After the drag-and-drop, commands added to Rhino can be found by opening _PluginManager and filtering on “Plugins that do not ship with Rhino”. After selecting the installed plugin, you will see the command that has been registered with this plugin. Clicking on the details will reveal the path.
Option 2: Install through PluginManager
Another install method is to open _PlugInManager and click the install button. For the rest, it behaves the same as drag-and-dropping onto Rhino: the .rhp file will stay in the location you installed it from, and you can retrieve the added commands in the Commands section of the plugin.
Option 3: Install through PackageManager (recommended)
The third and recommended option to install plugins is through _PackageManager. The benefit of _PackageManager is that it allows you to install, update, and uninstall plugins easily. Not all plugins are available on this platform, but it is the first place to look for plugins for the aforementioned reasons. Some plugins are released in beta phase and will only be listed when you check “include pre-releases”.
Option 4: Install through food4Rhino
The last option to install plugins is to register an account at www.food4rhino.com. Here, you can search for plugins and read what plugins are capable of. Food4Rhino contains plugins for both Rhino and Grasshopper. If the plugin has an Install button, it will launch Rhino, open _PackageManager, and list the chosen plugin, which you can install in the same way as in Option 3.
Uninstalling Plugins
The easiest way to remove installed plugins is through _PackageManager. For this open _PackageManager, search in the installed plugins (click the Installed tab), click on the plugin you want to uninstall, and click the Uninstall button.
If you have installed the plugin through _PluginManager or drag-and-drop, you cannot automatically uninstall the plugin. Open _PluginManager, and double-click on the plugin name to open its details. Here, you will find the registry key location. Click on this link to copy the path. Open Registry Editor (Windows start button: Type RegEdit), search (Ctrl + F) for the just copied key, and delete this key. After that, restart Rhino.
Installing RHI files (deprecated)
RHI files are basically zipped folders that are associated with Rhino. These zipped folders can contain multiple files: .rhp, .dll and .rui files as well as other file types like .3dm files, txt files and .ini files. What’s important to know is that installing these files will copy the content of the zipped file to a special folder. Find this location by opening Windows Explorer and typing %appdata%\McNeel\Rhinoceros\7.0\plugins. The folder is also listed when opening _PlugInManager, looking up the plugin, and double-clicking to reveal its details.
Option 1: Double-click the downloaded file
This will install the plugin for one or more Rhino versions installed on your computer. There is no option to select which version will be installed.
Option 2: Drag-and-drop onto Rhino
Same behavior as Option 1.
Uninstalling RHI files
There is no automatic uninstallation of RHI files. Open _PluginManager and double-click on the plugin name to open its details. Here, you will find the registry key location. Click on this link to copy the path. Open RegEditor (Windows start button: Type RegEdit), search for the just copied key and delete this key. After that, restart Rhino. Optionally, you can delete the files in the location explained in the install paragraph.