Monkey is a new scripting environment within Rhino4 which can be used to edit, run and debug scripts. It contains all the standard programmer editor features such as Find/Replace (with regular expressions), multi-document interface, code trees and integrated helpfiles. For a complete list of features please see the bottom of this page. Monkey also comes with a separate application called the Monkey Script Compiler. This is a standalone exe which turns .rvb scripts into .rhp plugins. More information on the script compiler can be found here .
Monkey is a DotNET plugin meaning you need the Microsoft DotNET Framework 2.0 installed on your machine. Note that many computers already are DotNET compliant, so you only need to download and install this if Monkey doesn't run (you'll get an error message telling you when this happens).
After you have installed Monkey, there should be a new menu in Rhino which gives you access to the script editor, the script runner and the script compiler. The script compiler is an external tool which means you can run it outside of Rhino, though you do need to have Rhino4 installed.
Disadvantages of compiling your scripts are:
The compiler is a typical wizard application which guides you through 4 required and one optional* stage:
Plugin attribute page:
You must supply a valid name for the plugin(no weird characters, no spaces). Apart from the plugin name, all other fields in the plugin attributes are optional. It is considered good practise though to assign a proper version code (this can be any string literal) and correct contact details. If you plan to License protect this plugin, you should also enter a correct Update URL or Website address since this link will be added to the Registration dialog.
Command list page:
Every plugin must have at east one command, but there is no upper limit. Like the plugin name, all commands must have valid names (no weird characters, no spaces). If you pick conflicting names (for example if you add a command called “Circle”) the plugin will compile but it will not load. If you attempt to load a plugin which shadows an existing command name Rhino will refuse to register the new command.
When you add a script you'll see a popup dialog which allows you to alter the script command attributes:
You can specify a custom command name and set a bunch of custom attributes:
Compiler settings page:
After you have added all scripts to the plugin, the [Next] button will take you to the compiler settings page. At this point you can save the Compiler project by pressing the button with the unfolded box. This allows you to quickly restore a project if you need to recompile it (for example when a new version of Rhino has been released or when you have made changed to the scripts).
The available settings are:
When you press the *[Compile] button the wizard will create a new Rhino plugin (.rhp) in the specified location (the desktop by default). You can load this plugin by dragging it into Rhino4 or by loading it via the PluginManager
The Monkey script editor is a real Rhino plugin, not a standalone application meaning it can only be run inside of Rhino4. You can either run the _Monkey command or open the editor via the Monkey menu. After a short delay (yes, yes, I know. We're working hard to get it to load faster) you'll see the editor in all its glory:
The large tree on the left lists all RhinoScript methods which you can use. This tree can be extended easily to cater for other plugins (such as ArchCut ) which also support scripting access. If you double click an item in the method-tree you will be taken to the appropriate page in the appropriate helpfile. You can also drag and drop these methods into the code editor. You can search the method-tree using the textfield at the top, or click on the search button to open the advanced search dialog. Advanced search allows you to specify multiple search terms (space separated) and it displays all the matching items, instead of just the first one.
Most features of the Monkey editor are available via the main menu and a large majority of these are standard coding environment tools so I will only highlight the special ones:
|• File » Recent Files » Erase MRU record||Monkey keeps track of hundreds of MRU (most recently used) files. You can wipe the record clean with this menu option. It will not delete the files of course, it will only make Monkey forget that it ever opened them.|
|• Edit » Selection » (Un)Indent Block||Adds or removes a leading tab for every selected line.|
|• Edit » Selection » (Un)Comment||Adds or removes a leading apostrophe for every selected line.|
|• Edit » Selection » To Pascal Case||Changes the casing of the selection to Pascal case (all words start with a single uppercase character).|
|• Edit » Autoformat||Automatically reformats the document whenever you add/chage code.|
|• Edit » Snippets||Displays a grouped list of example code which can be used to quickly create typical structures.|
|• Edit » Find in Files||Displays a dialog that allows you to search all loaded documents for a specific string.|
|• Edit » Outlining » Toggle Outlining||Inverts collapsed/expanded states for outline blocks.|
|• Edit » Outlining » Stop Outlining||Expands all code blocks.|
|• Edit » Outlining » Collapse to Definitions||Collapses all code blocks.|
|• View » Link To Rhino||Toggles the Monkey window to be either a free-floating window or a Rhino child window.|
|• View » Hide during Execution||Hide the Monkey window while a script is running.|
|• View » Code Blocks||Show collapsable frames around procedure and class structures.|
|• View » Clear All Markers||Remove all tags that have been added by a Mark All operation in the Find window.|
|• Source » Run||Run the currently active script.|
|• Source » Debug||Run the currently active script and stop at all breakpoint lines.|
|• Tools » Option||Display the Monkey options dialog.|
|• Tools » ASCII Table||Display the Monkey ASCII table dialog.|
|• Tools » Constant Browser||Display a list of constant defined in the vbScript language.|
|• Help » Search Rhino Help…||Searches the Rhino helpfile for a specific command name.|
|• Help » vbScript Online…||Diplays the MSDN main page for the vbScript language.|
Monkey adds a debugging feature to Rhino. If you add breakpoints on certain lines in the script (you can toggle breakpoints by clicking in the gutter) and then run it using the Debug mode, execution of the script will halt whenever a breakpoint line is encountered. At this point a dialog will be displayed which lists the values of all currently available variables. If no variables are currently on scope the breakpoint will not be triggered. The script below has breakpoints on lines 10 and 12.
Breakpoints are also an experimental feature, so beware when using it.