Adding Commands to Projects

Problem

A fresh project (Windows or Mac) is only a skeleton plugin project with a single command. However, plugins can contain more than one command. How does one add additional commands to plugin projects?

Solution

To add a new command to your RhinoCommon plugin project, you simply need to define a new class that inherits from Rhino.Commands.Command.

An easy way to do this is to just use the Empty RhinoCommmon Command template. Here is how you do that:

Windows

  1. Make sure you have the RhinoCommon Project Wizard installed.
  2. Launch Visual Studio and open your plugin project.
  3. From Visual Studio, navigate to Project > Add New Item menu item.
  4. Select the Empty RhinoCommmon Command template from the list of installed templates.
  5. Provide a unique file name that relates to the command you are adding.
  6. Click the Add button.

Mac

  1. Make sure you have Rhino.Templates installed.
  2. Launch Visual Studio Code and open your plugin project folder.
  3. Open Visual Studio Code’s Terminal via Terminal (menu entry) > New Terminal, or using the command palette (⌘ ⇧ P) and search for “Terminal”.
  4. Inside Terminal, run:
    dotnet new rhinocommand -n MyCommandName