In order to complete this tutorial, you will need to have Microsoft Visual C++ 2005 installed on your system. You will also need to have downloaded and installed the Rhino 4.0 SDK.
Note, if you are installing the SDK on Windows 8, 7 or Vista, you will need to right click on the installer and choose Run as administrator as opposed to double clicking the installer for it to install correctly.
From a user’s standpoint, a Rhino plug-in is a software module that extends the functionality of Rhino by adding new commands, features, or capabilities. From a programmer’s perspective, a Rhino plug-in is a regular Windows Dynamic Link Libraries, or DLL that links with the Rhino SDK libraries. Examples of Rhino plug-ins include Bongo, Brazil, Flamingo, and Penguin.
There are five different types of Rhino plug-ins.
The Rhino SDK includes a Visual Studio Wizard. The wizard program generates the code a functioning plug-in. Follow these steps to build the plug-in:
Choose New → Project… from the Visual Studio File menu. From the New Project dialog, select the Rhino plug-in template from the list of installed templates.
Type the project name as show. You can enter a different name if you want, but the wizard uses the project name when it creates files and classes. If you enter a different name, your files and classes will have a name different from that of the files and classes mentioned in this tutorial.
Don’t forget to choose a location to store the project. When finished, click the OK button.
Upon clicking OK, the Overview page of the Rhino Plug-In Wizard dialog will appear. This page gives you a summary of the type of project that the wizard is going to create. By default, the wizard will do the following:
If you are satisfied with the default settings, just click the Finish button. If you want to change any of these settings, just click the Next button.
The Plug-in Settings page allows you to modify a number of settings used by the wizard when generating the plug-in source code.
For this tutorial, just accept the default settings. Click the Finish button, and the wizard begins to generate your plug-in project’s folders, files, and classes. When the wizard is finished, look through the plug-in project using Visual Studio’s Solution Explorer. The following files are of interest:
The Rhino plug-in wizard, in addition to generating code, creates a custom project file for your plug-in. This file, Test.vcproj, specifies all of the file dependencies together with the compile and link option flags.
Before we can build our project, we need to fill in the Rhino plug-in developer declarations. These declarations will let the user of our plug-in know who produced the plug-in and where they can support information if needed. Open TestPlugIn.cpp and modify the following lines of code, providing your company name and other support information.
RHINO_PLUG_IN_DEVELOPER_ORGANIZATION( L"My Company Name" ); RHINO_PLUG_IN_DEVELOPER_ADDRESS( L"123 Developer Street\r\nCity State 12345-6789" ); RHINO_PLUG_IN_DEVELOPER_COUNTRY( L"My Country" ); RHINO_PLUG_IN_DEVELOPER_PHONE( L"123.456.7890" ); RHINO_PLUG_IN_DEVELOPER_FAX( L"123.456.7891" ); RHINO_PLUG_IN_DEVELOPER_EMAIL( L"firstname.lastname@example.org" ); RHINO_PLUG_IN_DEVELOPER_WEBSITE( L"http://www.mycompany.com" ); RHINO_PLUG_IN_UPDATE_URL( L"http://www.mycompany.com/support" );
When finished, delete the following line of source code as the #error directive will prevent the project from building.
#error Developer declarations block is incomplete!
If you do not delete this line, the plug-in will build. You are now ready to build the project by picking Build Test from the Build menu. If the build was successful, a plug-in file named Test_d.rhp is created in the project’s Debug folder.
Choose Start Debugging from the Debug menu. This will load Rhino. The version of Rhino that is launched depends on the configuration that you build. The wizard adds the following configurations to your project.
For this tutorial, build the debug configuration.
From within Rhino, select Options from the Tools menu. Navigate to the Plug-ins page under Rhino Options and install your plug-in. Note, being that the debug version of Rhino will only load debug plug-ins, no other plug-ins will show up in the list.
Once your plug-in is loaded, close the options dialog and run your Test command. You have finished creating your first plug-in.