Quantcast
Channel: Programming – Xinyustudio
Viewing all articles
Browse latest Browse all 284

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

$
0
0

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


Filed under: CAD, Dotnet/C#, Programming Tagged: .net user control, customization, example, Rhino, Rhino.net, tutorial, UI, Winform

Viewing all articles
Browse latest Browse all 284

Trending Articles