Site Tools


Differences

This shows you the differences between two versions of the page.

Link to this comparison view

developer:simplevbplugin [2015/09/14]
127.0.0.1 external edit
developer:simplevbplugin [2016/03/22] (current)
sandy
Line 1: Line 1:
 ====== Simple VB.NET Plug-In ====== ====== Simple VB.NET Plug-In ======
 ====== .NET ====== ====== .NET ======
-> **Version:​** //Rhino 3.0//+ 
 +> **Version:​** //Rhino 3 and Rhino 4//
 > **Summary:​** //How to create a basic Rhino plug-in with VB.NET. Discusses each of the major components that go into creating a plug-in.// > **Summary:​** //How to create a basic Rhino plug-in with VB.NET. Discusses each of the major components that go into creating a plug-in.//
  
 Sometimes the hardest part to learning a new subject is the very first step. This article shows how to create a simple Rhino plug-in with VB.NET using the Rhino.NET SDK. Sometimes the hardest part to learning a new subject is the very first step. This article shows how to create a simple Rhino plug-in with VB.NET using the Rhino.NET SDK.
  
-======Part 1====== +=====Part 1===== 
-=====STEP 1 - Required ​Tools===== + 
-In order to develop Rhino plug-ins with VB.NET, you are going to need the following:+====Step 1 - Required ​tools==== 
 + 
 +To develop Rhino plug-ins with VB.NET, you need the following:
  
 **Rhino 3** **Rhino 3**
  
-Latest build of the Rhino.NET SDK - This can be found on the WIP plug-ins web page (http://​www2.rhino3d.com/​wip_plugins/​)+Latest build of the Rhino.NET SDK. 
  
-A VB.NET compiler ​The Rhino.NET SDK is tested to work with Microsoft VB.NET 2003, but you should be able to use VB.NET 2002 or the freeware SharpDevelop+A VB.NET compilerThe Rhino.NET SDK is tested to work with Microsoft VB.NET 2003, but you should be able to use VB.NET 2002 or the freeware SharpDevelop
  
 **Rhino 4** **Rhino 4**
  
-A VB.NET compiler that will compile using Microsoft .NET 2.0. This includes VB.NET 2005 or SharpDevelop 2.0+A VB.NET compiler that will compile using Microsoft .NET 2.0. This includes VB.NET 2005 or SharpDevelop 2.0.
  
-=====STEP 2 - Create a plug-in with the .NET plug-in wizard=====+====Step 2 - Create a plug-in with the .NET plug-in wizard====
 (This step requires VB.NET) (This step requires VB.NET)
-**Rhino 3**+**Rhino 3**.
  
-After you have installed all of the software items in step 1, Open VB.NET and select New Project... from the File menu. Select the "Rhino Utility Plug-In" ​icon as shown below. I set my project name to "​FirstPlugIn"​ and saved it to "​C:​\Samples"​ on my computer.+After you have installed all of the software items in Step 1, open VB.NET and select ​**New Project...** from the File menu. Select the **Rhino Utility Plug-In** icon as shown below. I set my project name to "​FirstPlugIn"​ and saved it to "​C:​\Samples"​ on my computer.
  
 {{:​legacy:​en:​SimpleVB_NewVBProject.gif}} {{:​legacy:​en:​SimpleVB_NewVBProject.gif}}
Line 30: Line 33:
 **Rhino 4** **Rhino 4**
  
-Download and install the [[http://​files.mcneel.com/​wiki/​RhinoDotNetSDK.zip|Visual Studio project ​wiards.]] Open VB.NET and create a new projectRhino Plug-In should be one of the optional project types.+Download and install the Visual Studio project ​wizards. Open VB.NET and create a new projectRhino Plug-In should be one of the optional project types.
  
-After you click OK, the project wizard ​will create ​a new Rhino.NET plug-in project for you.+After you click **OK**, the project wizard ​creates ​a new Rhino.NET plug-in project for you.
  
-=====STEP 3 - Build your Rhino.NET plug-in====+====Step 3 - Build your Rhino.NET plug-in====
-Now that you have a simple project created by the wizard, click on the "Build solution..."​ menu item in the "​Build"​ menu. This will create a Rhino.NET plug-in (also know as a .NET assembly.) The file extension for your plug-in will be .DLL and will be located in the bin directory for your project.+
  
-=====STEP 4 - Run your Rhino.NET plug-in=====+Now that you have a simple project created by the wizard, click on the **Build solution...** menu item in the Build menu. This creates a Rhino.NET plug-in (also known as a .NET assembly.) The file extension for your plug-in will be .DLL and will be located in the bin directory for your project. 
 + 
 +====Step 4 - Run your Rhino.NET plug-in====
 **Rhino 3** **Rhino 3**
  
-Start up Rhino and execute the DotNetManager command. This will pop up the .NET plug-in manager dialog. Click the "Load Plug-In" ​button and select the plug-in dll that you just created. If you were successful, the dialog will show your loaded plug-in and it'​s ​associated command.+Start up Rhino and execute the DotNetManager command. This will pop up the .NET plug-in manager dialog. Click the **Load Plug-In** button and select the plug-in dll that you just created. If you were successful, the dialog will show your loaded plug-in and its associated command.
  
 {{:​legacy:​en:​SimpleVB_NetManager.gif}} {{:​legacy:​en:​SimpleVB_NetManager.gif}}
Line 46: Line 50:
 **Rhino 4** **Rhino 4**
  
-Start up Rhino and execute the "PlugInManager" ​command. Click the Intall... button and select the plug-in dll that you just created. If you were successful, the dialog will show your loaded plug-in.+Start up Rhino and execute the PlugInManager command. Click the **Install...** button and select the plug-in dll that you just created. If you were successful, the dialog will show your loaded plug-in.
  
 Now close the dialog and run your VB.NET command. The command name will be the same as the your project name. In my case, my VB.NET command is called "​FirstPlugIn"​. The command will run and tell you that it is under construction. Now close the dialog and run your VB.NET command. The command name will be the same as the your project name. In my case, my VB.NET command is called "​FirstPlugIn"​. The command will run and tell you that it is under construction.
  
-===== VB.NET ====+==== VB.NET ====
-<code vb> +
-</​code>​+
  
 > **Note:** //Discusses the source code and project settings for a simple VB.NET plug-in created with the project wizard.// > **Note:** //Discusses the source code and project settings for a simple VB.NET plug-in created with the project wizard.//
Line 58: Line 60:
 Part 1 of this article showed how to create and run a VB.NET plug-in using the project wizard. Getting the plug-in to run is great, but what is really going on? This article covers the project settings and source code that are "​auto-magically"​ created with the Rhino.NET Utility Plug-In project wizard. Part 1 of this article showed how to create and run a VB.NET plug-in using the project wizard. Getting the plug-in to run is great, but what is really going on? This article covers the project settings and source code that are "​auto-magically"​ created with the Rhino.NET Utility Plug-In project wizard.
  
-Let's examine just what the project wizard for Rhino.NET Utility plug-ins created. I will be refering ​to the sample project that you can download at the top of this article. This example is an unmodified VB.NET Rhino plug-in project ​that was generated with the wizard.+Let's examine just what the project wizard for Rhino.NET Utility plug-ins created. I will refer to the sample project that you can download at the top of this article. This example is an unmodified VB.NET Rhino plug-in project generated with the wizard.
  
-===== VB.NET ====+==== VB.NET ====
-<code vb> +
-</​code>​+
  
-The other important item to look at in the project properties dialog is the Debugging item under the Configuration Properties folder. Since this is a class library project, it does not start and run on its own. In order to debug the plug-in, Rhino has to be running so the Start Action is set to Start external program and rhino3.exe (or rhino4.exe) is specified as the application.+The other important item to look at in the project properties dialog is the Debugging item under the Configuration Properties folder. Since this is a class library project, it does not start and run on its own.  ​To ​debug the plug-in, Rhino has to be running so the Start Action is set to Start external program and rhino3.exe (or rhino4.exe) is specified as the application.
  
-Close the project properties dialog and expand the References node for the tree control in the Solution Explorer (or click on References tab in VB.NET 2005). You'll notice that there is a reference to Rhino3_DotNET (or Rhino_DotNET in Rhino 4). This is the Rhino.NET SDK and it contains all of the class and function information for Rhino.NET. If you were creating a Rhino.NET plug-in without the project wizard, you would need to add this as a reference by clicking on "Add Reference..." ​under the Project menu. Make sure the .NET tab is active and click on the Browse... button. The Rhino.NET SDK is named "​Rhino3_DotNET.DLL"​ or "​Rhino_DotNET.DLL"​ and is located in Rhino'​s System directory. Select this file and click OK. Make sure that the properties for the Rhino3_DotNet reference have Copy Local set to false.+Close the project properties dialog and expand the References node for the tree control in the Solution Explorer (or click on References tab in VB.NET 2005). You'll notice that there is a reference to Rhino3_DotNET (or Rhino_DotNET in Rhino 4). This is the Rhino.NET SDK and it contains all the class and function information for Rhino.NET. If you were creating a Rhino.NET plug-in without the project wizard, you would need to add this as a reference by clicking on **Add Reference...** under the Project menu. Make sure the .NET tab is active and click on the **Browse...** button. The Rhino.NET SDK is named "​Rhino3_DotNET.DLL"​ or "​Rhino_DotNET.DLL"​ and is located in Rhino'​s System directory. Select this file and click **OK**. Make sure that the properties for the Rhino3_DotNet reference have Copy Local set to false.
  
-**NOTE:** //Project references to Rhino3_DotNET appear to be stored as absolute paths to the DLL. If you open a project from someone else, most likely your path to this DLL than what was set on the computer where the project originated from. To fix this, remove the reference to Rhino3_DotNET and add it back in using the steps outlined in the previous paragraph.//​+**Note:** //Project references to Rhino3_DotNET appear to be stored as absolute paths to the DLL. If you open a project from someone else, most likely your path to this DLL than what was set on the computer where the project originated from. To fix this, remove the reference to Rhino3_DotNET and add it back in using the steps outlined in the previous paragraph.//​
  
 AssemblyInfo.vb AssemblyInfo.vb
Line 93: Line 93:
    <​Assembly:​ Guid("​5FB01338-E5AA-4118-9BB6-C931A9568DFB"​)>​    <​Assembly:​ Guid("​5FB01338-E5AA-4118-9BB6-C931A9568DFB"​)>​
  
-All of the above attributes must be defined ​in order to create a valid Rhino.NET plug-in. Your plug-in will compile without these, but the DotNetManager will complain when it tries to load a plug-in that does not have all of the above attributes.+All of the above attributes must be defined to create a valid Rhino.NET plug-in. Your plug-in will compile without these, but the DotNetManager will complain when it tries to load a plug-in that does not have all of the above attributes. 
 + 
 +Most of the attributes should be pretty self explanatory. The Guid attribute is important to ensure uniqueness of your plug-in. Every plug-in __must__ have a different Guid (so don't just copy and paste the same Guid around from plug-in to plug-in.) VB.NET has a tool for creating Guids. Click **Create Guid** under the Tools menu. Make sure your Guid style is set to **4. Registry Format** and click **Copy**. You can then paste a new Guid into your project. 
 + 
 +**Rhino 4**
  
-Most of the attributes ​should be pretty self explanatory. The Guid attribute is important ​to ensure "​uniqueness" ​of your plug-in. Every plug-in MUST have a different Guid (so don't just copy and paste the same Guid around from plug-in ​to plug-in.) VB.NET has a tool for creating Guids. Click on "​Create Guid" under the Tools menu, make sure your Guid style is set to 4. Registry Format and click on Copy. You can then paste a new Guid into your project.+These attributes ​have been moved to the beginning ​of the plug-in ​file.
  
-**Rhino 4**: These attributes have been moved to the beginning of the plug-in file+====Plug-in class (RhinoPlugIn.vb)====
  
-=====Plug-In class (RhinoPlugIn.vb)===== 
 Every Rhino.NET plug-in must contain one (and only one) MRhinoPlugIn derived class. Every Rhino.NET plug-in must contain one (and only one) MRhinoPlugIn derived class.
  
Line 147: Line 150:
    End Class    End Class
  
-=====Command class (RhinoCommand1.vb)=====+====Command class (RhinoCommand1.vb)====
 Each Rhino.NET plug-in can contain as many MRhinoCommand subclasses as you want (0 or more). Each MRhinoCommand subclass defines a new command that shows up in Rhino. Each Rhino.NET plug-in can contain as many MRhinoCommand subclasses as you want (0 or more). Each MRhinoCommand subclass defines a new command that shows up in Rhino.
  
developer/simplevbplugin.txt · Last modified: 2016/03/22 by sandy