Scripting Essentials

Getting Started with Scripting

Getting started with scripting can be a daunting task for numerous reasons: not knowing exactly where and how best to start, the mountains of documentation available, etc., so below’s an abbreviated approach that should help. Concentrate first on creating simple scripts using the Documentation and Steps to Developing Scripts. Setting up toolbars and toolbar buttons and having scripts load automatically at startup can come later on.

The scripting tool referred to here is RhinoScript accompanying Rhino, the 3D modeling software. An evaluation copy of Rhino can be obtained from the McNeel website (http://rhino3d.com).

Hello World! Steps to Developing Scripts

1) Tools menu: RhinoScript > Edit … (alternatively, Command line: _EditScript)

or use a simple text editor, like Windows Notepad, to create and edit your script;
save with the .rvb file extension (in this case, save as HelloWorld.rvb)

Sub HelloWorld
Rhino.MessageBox (“Hello World!”)
End Sub

2) Tools menu: RhinoScript > Load … (alternatively, Command line: _LoadScript)

Add … (browse to where you saved HelloWorld.rvb and Open it)
Load … (select HelloWorld from the list of scripts and press Load)

3 ) Tools menu: RhinoScript > Run … (alternatively, Command line: _RunScript)

(select HelloWorld from the list and press OK)

Facilitating Script Development / ToolBars

Creating a toolbar with the RhinoScript commands, or adding these buttons to an existing toolbar, will help immeasurably with accessing the script functions during development:

Creating toolbars and toolbar buttons is a creative undertaking all its own. A good place to start is Tools menu: Toolbar Layout > Help and read all the sections related to Toolbar Layout.

Ongoing Use of Scripts

Once a script has been written and debugged it can be loaded automatically when Rhino starts:

Tools menu: Options … > Rhino Options > Rhino Script > Startup (add a script to the list)

then run from a button, HelloWorld for example:

-_RunScript HelloWorld (this is the mouse button command)

Scripting Documentation

Rhino: Help menu: Plug-ins > RhinoScript > Introduction