Site Tools


Create a RhinoScript Plug-in

Developer: RhinoScript
Summary: Demonstrates how create a RhinoScript plug-in for Rhino 5.0.

Prerequisites

Before beginning, download and install the following applications, extensions, and plug-ins in this order:

1.) Rhino 5.0 - Either 32-bit or 64-bit (or both) for testing.

2a.) Microsoft Visual C# 2010 Express - Free tools to create .NET applications on Windows using Visual C#, or
2b.) Microsoft Visual Basic 2010 Express - Free tools to create .NET applications on Windows using Visual Basic.

3.) RhinoCommon templates for Rhino 5.0 - Visual C# and Visual Basic extensions that provides Rhino plug-in and command wizards for RhinoCommon projects.

4.) RhinoScript Encrypter - Rhino 5.0 plug-in that encrypts RhinoScript script files (.RVB) for use in RhinoScript plug-ins.

5a.) RhinoScript C# Command - Note, this file contains C# source code required by your Visual C# plug-in project, or
5b.) RhinoScript VB.NET Command - Note, this file contains VB.NET source code required by your Visual Basic plug-in project.

Preparing Scripts

Before your RhinoScript files can be used in a RhinoScript plug-in, make sure that your script does not “run” when the script file is loaded. More specifically, when your script file is loaded with the LoadScript command, your script should not run - you should have to use the RunScript file to run your script.

For example, consider a script file that contains the following:

Option Explicit
 
Call HelloWorld
 
Sub HelloWorld
  MsgBox "Hello World!"
End Sub

If you were to use the LoadScript command to load this file, the script would loaded into VBScript, defining the HelloWorld procedure. But because of the “Call HelloWorld” statement, the procedure would then be executed immediately after loading.

A script file that is compatible with a RhinoScript plug-in should look like this:

Option Explicit
 
Sub HelloWorld
  MsgBox "Hello World!"
End Sub

If you were to use the LoadScript command to load this file, the script file would loaded into VBScript, defining the HelloWorld procedure. But in order to run the HelloWorld procedure, you would need to run the RunScript command.

For more information on loading and running scripts, see the Introduction section of the RhinoScript help file, or Efficient Loading of Scripts.

Watch the Video

developer/scriptsamples/rhinoscriptplugin.txt · Last modified: 2012/05/14 by dale