RSS

Rhino C# Development (III) : Add Winform UI to Rhino

09 May

Rhino C# Development (I) : Get Visual Studio Wizard ready
Rhino C# Development (II) : HelloRhino


Now that we are able to talk with Rhino, let’s add our own UI to Rhino. In Rhino 5 with RhinoCommon SDK and Rhino_DotNet, you can easily add .net Winform User Control to Rhino.

image

1. Add a reference “Rhino_DotNet.dll” to your project, this assembly is located at the same folder where Rhino.exe resides:

image

Note: after adding this reference, you should change the Copy Local property to false in the Property window of Visual Studio, otherwise, rhino will complain when you install the plugin.

image

2. In the project, add a Winform user control to the project, drag any controls from Visual Studio Toolboxes, for instance, I added a tool stripe, a label, a progress bar, a button and a group box with a few radio buttons, mine looks like below:

image

3. Open the plugin class, add a variable and type below code in the constructor, as shown inside the red rectangles below:

image

Here, we add a MRhinoUiDockBar instance (that is why we need reference Rhino_DotNet.dll) in the constructor. Note that you can generate a GUID by clicking “Tools > Create GUID” menu, and then click the copy button, as shown below.

image

4. Add an override function OnLoad to notify Rhino to load our custom designed UI on startup:

image

Now press “Ctrl + F5” in Visual Studio to fire Rhino 5, and install this plugin, you will see our .Net UI is loaded to Rhino, and your can even dock it here and there, since in the above code, we used MRhinoUiDockBar.DockStyle.any in the enumeration parameters.

image

arrow, download icon Download Visual Studio 2010 Source project: RhinoAddUI.zip; or RhinoAddUI.7z.

See also:
Rhino C# Development (I) : Get Visual Studio Wizard ready
Rhino C# Development (II) : HelloRhino

 
4 Comments

Posted by on May 9, 2013 in CAD, Dotnet/C#, Programming

 

Tags: , , , , , , ,

4 responses to “Rhino C# Development (III) : Add Winform UI to Rhino

  1. gianfrancoguzzo74

    October 12, 2013 at 4:14 pm

    thank you for this project,i don’t use .net but rhinocommon.anycase i liked it.

     
  2. Bill

    January 9, 2014 at 11:48 am

    请问第四步代码添加到哪里?我添加之后显示『Onload 没有找到适合的方法来重写』这个错误

     

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: