How to Use Scripts and Plugins
Windows only

Target Audience

This guide is for end users that 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 not only as a standalone product but 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 either in 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 you have 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 you downloaded one you want to run, you can do this in two steps: First, load the script with _LoadScript, and clicking the Add… button. Then you need to click on the name of the just script and click the Load button.

loadscript

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 to choose from. In this example, the script has two SubRoutines that can run:

runscript

Option 2: Loading and executing scripts through the built-in RhinoScript editor

rhinoscripteditor

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 if you want to modify a script you downloaded.

Important

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 find out 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.:

Example
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:

drag-and-drop

Notes

No subroutines are called in this script because that is handled by the statements Rhino.AddStartUpScript Rhino.LastLoadedScriptFile and Rhino.AddAlias ...

If you download a .rvb script it’s best to first 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 alias or aliases that are going to 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.

Important
When you have scripts that are made to be drag-and-dropped, place them in a separate folder. Rhino will not copy these scripts but adds the path to this script to the list in Tools > Options > RhinoScript and loads it each time you open Rhino. So as an example, if I drag and drop the torus script from my folder 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]
)

Make sure to save your Toolbar once you have edited or added a new button. For more information about customizing Rhino, see Chapter 3 of the Rhino Level 2 Training Manual.

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: full-script-in-button

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:

path-in-button

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.

aliases

Remove the link to the script file in Tools > Options > RhinoScript.

remove-script

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 if you 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]
)
Important
Sometimes scripts contain a check if the script is run as the main function. (You can find more info about this in the Python documentation.) When the full script is pasted inside the button this function has to be removed.

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()
)
Note
The dash (-) in front of the command will execute the command without a dialog.
Important
Make sure to save your Toolbar once you have edited or added a new button. For more information about this, see Chapter 3 of the Rhino Level 2 Training Manual.

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

A 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. 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 session of Rhino 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.

Important
Installing a plugin this way will not move the plugin file, so it is recommended to first put the plugin file into a known directory on your hard drive before dragging it into Rhino.

Option 2: Install through PluginManager

Another install method is to open _PlugInManager and click on 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.

The third and recommended option to install plugins is through _PackageManager. The benefit of _PackageManager is that it allows you to easily install, update, and uninstall plugins. Not all plugins are available on this platform though, 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 by registering an account at www.food4rhino.com. Here you can search for plugins and read what plugins are capable of. Food4Rhino contains both plugins for Rhino as well as for Grasshopper. If the plugin has an Install button, it will launch Rhino, open _PackageManager and list the chosen plugin, which you can then install 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.