diff --git a/content/en/guides/grasshopper/your-first-component-mac/index.md b/content/en/guides/grasshopper/your-first-component-mac/index.md index c91ebb812f8..acbee9c8d13 100644 --- a/content/en/guides/grasshopper/your-first-component-mac/index.md +++ b/content/en/guides/grasshopper/your-first-component-mac/index.md @@ -30,113 +30,37 @@ toc_type = "single" ## Prerequisites It is presumed you already have the necessary tools installed and are ready to go. If you are not there yet, see [Installing Tools (Mac)](/guides/rhinocommon/installing-tools-mac). - - ## HelloGrasshopper -We will use Visual Studio Code and the dotnet Rhino Grasshopper template to create a new, basic, Grasshopper component called *HelloGrasshopper*. - -If you are familiar with Visual Studio Code, these step-by-step instructions may be overly detailed for you. The executive summary: create a new Solution using the Grasshopper Component dotnet template, build and run, and then make a change. - -We are presuming you have never used Xamarin Studio before, so we'll go through this one step at a time. +We will use Visual Studio Code and the dotnet Rhino Grasshopper template to create a new, basic, Grasshopper component called _HelloGrasshopper_. +If you are familiar with Visual Studio Code, these step-by-step instructions may be overly detailed for you. The executive summary: create a new Solution using the Grasshopper Component dotnet template, build and run, and then make a change. +We are presuming you have never used Visual Studio Code before, so we'll go through this one step at a time. ### Download the required template 1. Launch Visual Studio Code. -1. Open *Visual Studio Code's Terminal* via *Terminal (menu entry)* > *New Terminal*, or using the command palette _(⌘ ⇧ P)_ and search for "Terminal". +1. Open _Visual Studio Code's Terminal_ via _Terminal (menu entry)_ > _New Terminal_, or using the command palette _(⌘ ⇧ P)_ and search for "Terminal". 1. Inside Terminal, run: - ``` pwsh - dotnet new install Rhino.Templates - ``` - + ```pwsh + dotnet new install Rhino.Templates + ``` ### Starting the Project 1. Create a folder on your mac where you would like your project to live. Name the folder `HelloGrasshopper`. -1. If you have not done so already, *launch Visual Studio Code*. -1. Now we can open our new folder, navigate to *File* > *Open Folder* and choose the folder we just created. -1. Open Terminal via *Terminal* > *New Terminal*, or using the command palette _(⌘ ⇧ P)_ and search for "Terminal". +1. If you have not done so already, _launch Visual Studio Code_. +1. Now we can open our new folder, navigate to _File_ > _Open Folder_ and choose the folder we just created. +1. Open Terminal via _Terminal_ > _New Terminal_, or using the command palette _(⌘ ⇧ P)_ and search for "Terminal". 1. Enter the following command into the Terminal: - ``` pwsh - dotnet new grasshopper --version 8 - ``` -6. In our Folder explorer, we should see the project appear as Visual Studio Code discovers the files. + ```pwsh + dotnet new grasshopper --version 8 -sample + ``` +1. In our Folder explorer, we should see the project appear as Visual Studio Code discovers the files. 1. Expand the Solution Explorer, this is the best way to interact with C# projects on Mac in Visual Studio Code. - - -### Setting up Debug - -1. Create a folder called *.vscode* in the solution directory. -{{< call-out hint "Can't see the folder?" >}} -If you cannot see the *.vscode* folder, toggle hidden folders in Finder: click on your Desktop and press _⌘ ⇧ ._ (`command` + `shift` + `period`) -{{< /call-out >}} -1. We will need to create three new files in the *.vscode* new folder: *settings.json*, *tasks.json*, and *launch.json*... -1. Create *settings.json* with the following contents: - ``` json - { - // This file will specify the solution we use to build - "dotnet.defaultSolution": "HelloGrasshopper.sln" - } - ``` -4. Create *tasks.json* with the following contents: - ``` json - { - "version": "2.0.0", - "tasks": [ - { - "label": "build-plugin-netcore", - // This will ensure the project is built before we try to debug it - "command": "dotnet build ${workspaceFolder}/*.csproj -f net7.0", - "type": "shell", - "args": [], - "problemMatcher": [ - "$msCompile" - ], - "presentation": { - "reveal": "always" - }, - "group": "build" - } - ] - } - ``` -5. Create *launch.json* with the following contents: - ``` json - { - "version": "0.2.0", - "configurations": [ - { - "name": "Run GH 8 (Mac)", - "type": "coreclr", - "request": "launch", - "preLaunchTask": "build-plugin-netcore", - // Launches Rhino for us - "program": "/Applications/Rhino 8.app/Contents/MacOS/Rhinoceros", - // See : http://docs.mcneel.com/rhino/8mac/help/en-us/index.htm#information/startingrhino.htm - "args": ["-runscript=_Grasshopper"], - "cwd": "${workspaceFolder}", - "stopAtEntry": false, - "console": "internalConsole", - // RHINO_PACKAGE_DIRS is required for Multi-Targeted plugins - // This is what enables Rhino to register our Plug-in - "env": { - "RHINO_PACKAGE_DIRS": "${workspaceFolder}/bin/Debug/" - } - }, - ], - "compounds": [] - } - ``` -6. The Folder Explorer should look like below (Note that we cannot see *.vscode* in the Solution Explorer) - - ![New Project](/images/your-first-plugin-mac-02.png) - - - ### Boilerplate Build {{< call-out hint "Build Issue?" >}} @@ -144,54 +68,50 @@ Older Rhino Templates do not have System.Drawing.Common referenced. To add them to your project run the command **dotnet add package System.Drawing.Common -v 7.0.0** in the terminal. {{< /call-out >}} -1. Before we do anything, let's *Run and Debug* HelloGrasshopper to make sure everything is working as expected. We'll just build the boilerplate Plugin template. Click the *Run and Debug* button on the left hand side of Visual Studio Code and then the green play button in the newly opened panel. +1. Before we do anything, let's _Run and Debug_ HelloGrasshopper to make sure everything is working as expected. We'll just build the boilerplate Plugin template. Click the _Run and Debug_ button on the left hand side of Visual Studio Code and then the green play button in the newly opened panel. - ![New Project](/images/your-first-component-mac-01.png) + ![New Project](/images/your-first-component-mac-01.png) -1. *Rhinoceros and Grasshopper* launch. +1. _Rhinoceros and Grasshopper_ launch. 1. We will find the HelloGrasshopper Component under **Category / SubCategory** - ![Solution Anatomy](/images/your-first-component-mac-02.png) - -4. Adding the component to the canvas will perform no action +![Solution Anatomy](/images/your-first-component-mac-02.png) - ![Solution Anatomy](/images/your-first-component-mac-03.png) - -5. *Quit* Rhinoceros. This stops the session. Go back to *Visual Studio Code*. Let's take a look at the Plugin Anatomy. +4. Adding the component to the canvas will run the component and output some interesting geometry in the Rhino Viewport +![Solution Anatomy](/images/your-first-component-mac-03.png) +5. Press Stop Debugging _(⇧ F5)_, in Visual Studio Code, signified by the Red Square in the debug toolbar. This stops the debugging session. Now let's n take a look at the Plugin Anatomy. ### Component Anatomy -Use the **Solution Explorer** to expand the **Solution** (*.sln*) so that it looks like this... - ![Solution Anatomy](/images/your-first-component-mac-04.png) - -1. The **HelloGrasshopper** solution (*.sln*) -1. The **HelloGrasshopper** project (*.csproj*) has the same name as its parent solution...this is the project that was created for us by the template earlier. -1. **References**: Just as with most projects, you will be referencing other libraries. The template added the necessary references to create a basic Grasshopper component. -1. **Grasshopper** is the Rhino for Mac main grasshopper DLL. Classes in this DLL are subclassed and used by your custom component. -1. **HelloGrasshopperComponent.cs** is where a custom `Grasshopper.Kernal.GH_Component` subclass is defined. Your project may contain multiple subclasses of GH_Component if you want to ship multiple components in a single *gha*. -1. **HelloGrasshopperInfo.cs** defines general information about this *gha*. +Use the **Solution Explorer** to expand the **Solution** (_.sln_) so that it looks like this... +![Solution Anatomy](/images/your-first-component-mac-04.png) +1. The **HelloGrasshopper** solution (_.sln_) +1. The **HelloGrasshopper** project (_.csproj_) has the same name as its parent solution...this is the project that was created for us by the template earlier. +1. **References**: Just as with most projects, you will be referencing other libraries. The template added the necessary references to create a basic Grasshopper component. +1. **Grasshopper** is the Rhino for Mac main grasshopper DLL. Classes in this DLL are subclassed and used by your custom component. +1. **HelloGrasshopperComponent.cs** is where a custom `Grasshopper.Kernal.GH_Component` subclass is defined. Your project may contain multiple subclasses of GH*Component if you want to ship multiple components in a single \_gha*. +1. **HelloGrasshopperInfo.cs** defines general information about this _gha_. ### Debugging -1. Add a semicolon to line 47 of *HelloGrasshopperComponent.cs*, and set a breakpoint on it. You set breakpoints in Visual Studio Code by clicking in the gutter to the left of the line numbers. -![Set a breakpoint](/images/your-first-component-mac-05.png) -1. *Run and Debug*. our project. The breakpoint will become an empty circle, this is because our code has not been loaded yet. Once we hit the breakpoint once and continue, the code will be loaded until we end our Debug session. -![Set a breakpoint](/images/your-first-component-mac-06.png) -1. Click New Model. And then run our *HelloDrawLine* command. Create the two points and as soon as you do, you should hit your breakpoint and rhino will pause -![Hit a breakpoint](/images/your-first-component-mac-07.png) -1. With Rhino paused, in *Visual Studio Code* we will see *Locals* under *Variables*. You can inspect all of the values for the variables in your component. -![Locals panel](/images/your-first-component-mac-08.png) -4. Let's Continue Execution in Rhino by pressing the Green *Play* button in the Debug Bar -1. Control is passed back to *Rhino* and your command finishes. *Quit* Rhino or *Stop* the debugging session. +1. Add a breakpoint to line 75 of _HelloGrasshopperComponent.cs_. You set breakpoints in Visual Studio Code by clicking in the gutter to the left of the line numbers. + ![Set a breakpoint](/images/your-first-component-mac-05.png) +1. _Run and Debug_. our project. The breakpoint will become an empty circle, this is because our code has not been loaded yet. Once we hit the breakpoint once and continue, the code will be loaded until we end our Debug session. + ![Set a breakpoint](/images/your-first-component-mac-06.png) +1. Rhino and Grasshopper should open, if Grasshopper does not open, click "New Model" and run the _Grasshopper_ command. +1. Place our sample component _HelloGrasshopperComponent_ and as soon as you do, you should hit your breakpoint and rhino/Grasshopper will pause (You may need to drag the Grasshopper window out of the way to see Visual Studio Code) + ![Hit a breakpoint](/images/your-first-component-mac-07.png) +1. With Rhino/Grasshopper paused, in _Visual Studio Code_ we will see _Locals_ under _Variables_. You can inspect all of the values for the variables in your component. + ![Locals panel](/images/your-first-component-mac-08.png) +1. Let's Continue Execution in Rhino and Grasshopper by pressing the Green _Play_ button in the Debug Bar +1. Control is passed back to _Rhino / Grasshopper_ and your command finishes. Now _Stop_ _(⇧ F5)_ the debugging session as before. 1. **Remove** the breakpoint you created above by clicking on it in the gutter. -**Congratulations!** You have just built your first Grasshopper component for Rhino for Mac. **Now what?** - - +**Congratulations!** You have just built your first Grasshopper component for Rhino for Mac. **Now what?** ## Next Steps @@ -199,18 +119,18 @@ Use the **Solution Explorer** to expand the **Solution** (*.sln*) so that it loo A single gha can contain more than one [GH_Component](https://mcneel.github.io/grasshopper-api-docs/api/grasshopper/html/T_Grasshopper_Kernel_GH_Component.htm) derived class (and commonly does). Dotnet has support for adding more custom components to your project. -1. Open *Visual Studio Code's Terminal* via *Terminal (menu entry)* > *New Terminal*, or using the command palette _(⌘ ⇧ P)_ and search for "Terminal". +1. Open _Visual Studio Code's Terminal_ via _Terminal (menu entry)_ > _New Terminal_, or using the command palette _(⌘ ⇧ P)_ and search for "Terminal". 1. Inside Terminal, run: - ``` pwsh - dotnet new ghcomponent -n "NewComponent" - ``` +```pwsh +dotnet new ghcomponent -n "NewComponent" +``` -1. A new component will appear called *NewComponent* +1. A new component will appear called _NewComponent_ ## Related topics -This article is focused on initial setup and debugging a Grasshopper component in Rhino for Mac. For further reading on customizing your component please see: +This article is focused on initial setup and debugging a Grasshopper component in Rhino for Mac. For further reading on customizing your component please see: - [Grasshopper](/guides/grasshopper/csharp-essentials/) - [Distributing your Plugin](/guides/yak/creating-a-rhino-plugin-package/) diff --git a/content/en/guides/grasshopper/your-first-component-windows/index.md b/content/en/guides/grasshopper/your-first-component-windows/index.md index 5a9c62fb873..1719ba070d8 100644 --- a/content/en/guides/grasshopper/your-first-component-windows/index.md +++ b/content/en/guides/grasshopper/your-first-component-windows/index.md @@ -1,6 +1,6 @@ +++ aliases = ["/5/guides/grasshopper/your-first-component-windows/", "/6/guides/grasshopper/your-first-component-windows/", "/7/guides/grasshopper/your-first-component-windows/", "/wip/guides/grasshopper/your-first-component-windows/"] -authors = [ "dan" ] +authors = [ "dan", "callum" ] categories = [ "Getting Started" ] description = "This guide walks you through your first custom Grasshopper component library using Visual Studio." keywords = [ "developer", "grasshopper", "components" ] @@ -28,14 +28,13 @@ toc_type = "single" +++ - -It is presumed you already have the necessary tools installed and are ready to go. If you are not there yet, see [Installing Tools (Windows)](/guides/grasshopper/installing-tools-windows). +It is presumed you already have the necessary tools installed and are ready to go. If you are not there yet, see [Installing Tools (Windows)](/guides/grasshopper/installing-tools-windows). ## HelloGrasshopper We will use the Grasshopper Assembly templates to create a new, basic, component library called HelloGrasshopper. -If you are familiar with Visual Studio, these step-by-step instructions may be overly detailed for you. The executive summary: create a new project using the Grasshopper Assembly template, build and run, and then make a change. +If you are familiar with Visual Studio, these step-by-step instructions may be overly detailed for you. The executive summary: create a new project using the Grasshopper Assembly template, build and run, and then make a change. We are presuming you have never used Visual Studio before, so we'll go through this one step at a time. @@ -43,116 +42,119 @@ We are presuming you have never used Visual Studio before, so we'll go through t 1. If you have not done so already, **launch Visual Studio** (for the purposes of this guide, we are using Visual Studio Community Edition and C#). 1. Navigate to **File** > **New** > **Project**... -![File New Project](/images/your-first-plugin-windows-01.png) -1. A **Create a new project** wizard should appear. In the **Search for templates** area, search for `Grasshopper` to filter the results. Find and select the **Grasshopper Assembly for Rhino (C\#)** entry and click **Next**. -1. For the purposes of this Guide, we will name our demo plugin *HelloGrasshopper*. In the **Configure your new project** dialog, fill in the **Project name** field. **Browse** and select a location for this project on your disk, then click **Next** -1. The *New Grasshopper Add-On dialog* appears. Check the *Provide sample code* checkbox. -![New Grasshopper Assembly](/images/your-first-component-windows-03.png) + ![File New Project](/images/your-first-plugin-windows-01.png) +1. A **Create a new project** wizard should appear. In the **Search for templates** area, search for `Grasshopper` to filter the results. Find and select the **Grasshopper Assembly for Rhino (C\#)** entry and click **Next**. +1. For the purposes of this Guide, we will name our demo plugin _HelloGrasshopper_. In the **Configure your new project** dialog, fill in the **Project name** field. **Browse** and select a location for this project on your disk, then click **Next** +1. The _New Grasshopper Add-On dialog_ appears. Check the _Provide sample code_ checkbox. + ![New Grasshopper Assembly](/images/your-first-component-windows-03.png) 1. This is where you fill out information about your first component: - 1. Add-on display name: the name of component library itself. - 1. Name: the name of the component as displayed in the ribbon bar and search menus. - 1. Nickname: the default name of the component when inserted into the canvas. - 1. Category: name of tab where component icon will be shown. - 1. Subcategory: name of group inside tab where icon will be shown. - 1. Description: description shown in tooltip when mouse is over the component icon in the menu. -1. For the purposes of this guide, we will **accept the defaults** and click **Finish**... + 1. Add-on display name: the name of component library itself. + 1. Name: the name of the component as displayed in the ribbon bar and search menus. + 1. Nickname: the default name of the component when inserted into the canvas. + 1. Category: name of tab where component icon will be shown. + 1. Subcategory: name of group inside tab where icon will be shown. + 1. Description: description shown in tooltip when mouse is over the component icon in the menu. +1. For the purposes of this guide, let's chek the "Provide Sample Code", and then click **Finish**... 1. A **new solution** called **HelloGrasshopper** should open... -![HelloGrasshopper Solution](/images/your-first-component-windows-04.png) - + ![HelloGrasshopper Solution](/images/your-first-component-windows-04.png) ### Boilerplate Build -1. Before we do anything, let's **build** and **run** HelloGrasshopper to make sure everything is working as expected. We'll just build the boilerplate Plugin template. Click **Start** (play) button in toolbar corner of Visual Studio (or press **F5**) to **Start Debugging**... -![Start Button](/images/your-first-plugin-windows-06.png) -1. **Rhinoceros** launches. -1. Since this is the first time you are debugging the components, you need to tell Grasshopper where to look. In the Rhino command prompt, run the `GrasshopperDeveloperSettings` command... -![Grasshopper Developer Settings](/images/your-first-component-windows-05.png) -1. **Uncheck** the **Memory load \*.GHA assemblies using COFF byte arrays** checkbox. -1. Click the **Add Folder** button and add your `bin` output folder of your project to Grasshopper's search path. *NOTE*: You only need to do this step once during the development of your component, unless you move it elsewhere. -1. (Optional) Automatically start Grasshopper every time Rhino starts... - 1. Navigate to **Tools** > **Options** > **General**. - 2. In the **Run these commands every time Rhino starts** text area, type `_Grasshopper` then click **OK**. -1. Run the `Grasshopper` command to start Grasshopper. If you don't blink, you might see Grasshopper say it is loading "HelloGrasshopper" in the status bar of the splash screen. -1. Navigate to **Curve** > **Primitive** in the components menus. You should see HelloGrasshopper in the list with a blank icon. Drag this onto the canvas. The component should "work." -1. **Exit** Rhinoceros. This stops the session. Go back to **Visual Studio**. Let's take a look at the... +1. Before we do anything, let's **build** and **run** HelloGrasshopper to make sure everything is working as expected. We'll just build the boilerplate Plugin template. Click **Start** (play) button in toolbar corner of Visual Studio (or press **F5**) to **Start Debugging**... + ![Start Button](/images/your-first-compo-windows-06.png) +1. **Rhinoceros** launches and a moment later, so will **Grasshopper**. + +{{< call-out hint "First Debug" >}} +_The first debug may take a while depending on your settings, as Visual Studio downloads debugging files, this is normal._ +{{< /call-out >}} + +1. Navigate to **Curve** > **Primitive** in the components menus. You should see HelloGrasshopper in the list with a blank icon. Drag this onto the canvas. The component will run and some interesting Geometry will appear in the Rhino Viewport. +1. **Exit** Rhinoceros. This stops the session. Go back to **Visual Studio**. Let's take a look at the... ### Component Anatomy -1. Use the **Solution Explorer** to expand the **Solution** (*.sln*) so that it looks like this... -![Grasshopper Component Anatomy](/images/your-first-component-windows-06.png) -*NOTE*: Depending on your edition of Visual Studio, it may look slightly different. -1. The **HelloGrasshopper** project (*.csproj*) has the same name as its parent solution...this is the project that was created for us by the **Grasshopper Assembly** template wizard earlier. -1. **Properties** contains the **AssemblyInfo.cs** source file. This file contains the meta-data (author, version, etc) about the component library. -1. **References**: Just as with most projects, you will be referencing other libraries. The **Grasshopper Assembly** template added the necessary references to create a custom Grasshopper component. -1. **GH_IO** - or *GH_IO.dll* - is the Grasshopper Input/Output library required to read and write Grasshopper files. -1. **Grasshopper** - or *Grasshopper.dll* - is the Grasshopper base namespace. -1. **RhinoCommon** - or *RhinoCommon.dll* - is the Rhinoceros .NET SDK. -1. **System**, **System.Core**, **System.Drawing**, **System.Windows.Forms** are .NET foundational libraries. +1. Use the **Solution Explorer** to expand the **Solution** (_.sln_) so that it looks like this... + ![Grasshopper Component Anatomy](/images/your-first-component-windows-06.png) + + _NOTE_: Depending on your edition of Visual Studio, it may look slightly different. + +1. The **HelloGrasshopper** project (_.csproj_) has the same name as its parent solution...this is the project that was created for us by the **Grasshopper Assembly** template wizard earlier. +1. **Dependencies**: Just as with most projects, you will be referencing other libraries. The **Grasshopper Assembly** template added the necessary dependencies to create a custom Grasshopper component. +1. **Framework Targets** - The **Grasshopper Assembly** template is multi-targeted so that the correct assemblies are loaded for the correct platforms. +1. **Grasshopper** - The referenced Grasshopper Nuget. +1. **Properties** contains the **launchSettings.json** file. This file contains all of the debug. 1. **HelloGrasshopperInfo.cs** contains the component library information, such as the name, icon, etc. -1. **HelloGrasshopperComponent.cs** is where the action is. Let's take a look at this file... +1. **HelloGrasshopperComponent.cs** is where the action is. Let's take a look at this file... ### Make Changes -1. Open **HelloGrasshopperComponent.cs** in Visual Studio's Source Editor (if it isn't already). -1. Notice that `HelloGrasshopperComponent` inherits from `GH_Component` ... +1. Open **HelloGrasshopperComponent.cs** in Visual Studio's Source Editor (if it isn't already). +1. Notice that `HelloGrasshopperComponent` inherits from `GH_Component` ... public class HelloGrasshopperComponent : GH_Component -1. If you hover over `GH_Component` you will notice this is actually `Grasshopper.Kernel.GH_Component`. -1. `HelloGrasshopperComponent` also overrides two methods for determining the input and output parameters ... + +1. If you hover over `GH_Component` you will notice this is actually `Grasshopper.Kernel.GH_Component`. +1. `HelloGrasshopperComponent` also overrides two methods for determining the input and output parameters ... ```cs protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager) ... protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager pManager) ``` -1. The actual work done by the component is to be found in the `SolveInstance` method... + +5. The actual work done by the component is to be found in the `SolveInstance` method... ```cs protected override void SolveInstance(IGH_DataAccess DA) ``` -1. As you can see, this is where the action happens. This boilerplate component creates a spiral on a plane. Just to make sure everything is working, let's change the default plane on which the spiral is constructed. On line[^1] 67, in `SolveInstance`, notice that an XY plane is constructed... + +6. As you can see, this is where the action happens. This boilerplate component creates a spiral on a plane. Just to make sure everything is working, let's change the default plane on which the spiral is constructed. On line[^1] 67, in `SolveInstance`, notice that an XY plane is constructed... ```cs Plane plane = Plane.WorldXY; ``` -1. Further down in the `SolveInstance` method, you will notice that the input data is being fed into this plane... + +7. Further down in the `SolveInstance` method, you will notice that the input data is being fed into this plane... ```cs if (!DA.GetData(0, ref plane)) return; ``` -1. Go back to the `RegisterInputParams`, and find the line where the *Plane* input is registered. The last argument being fed to the method - `Plane.WorldXY` - is the default value of the input... + +8. Go back to the `RegisterInputParams`, and find the line where the _Plane_ input is registered. The last argument being fed to the method - `Plane.WorldXY` - is the default value of the input... ```cs pManager.AddPlaneParameter("Plane", "P", "Base plane for spiral", GH_ParamAccess.item, Plane.WorldXY); ``` -1. Change the default value of the *Plane* input to be `Plane.WorldYZ` ... + +9. Change the default value of the _Plane_ input to be `Plane.WorldYZ` ... ```cs pManager.AddPlaneParameter("Plane", "P", "Base plane for spiral", GH_ParamAccess.item, Plane.WorldYZ); ``` -1. Now let's examine what happens when inputs are given to this component... + +10. Now let's examine what happens when inputs are given to this component... ### Debugging -1. Set a breakpoint on line[^1] 99 of *HelloGrasshopperComponent.cs*. You set breakpoints in Visual Studio by clicking in the gutter... -![Set a breakpoint](/images/your-first-component-windows-07.png) +1. Set a breakpoint on line[^1] 99 of _HelloGrasshopperComponent.cs_. You set breakpoints in Visual Studio by clicking in the gutter... + ![Set a breakpoint](/images/your-first-component-windows-07.png) 1. **Build** and **Run**. -1. In Grasshopper, place a *HelloGrasshopper* component on the canvas...as soon as you do, you should hit your breakpoint and pause... -![Hit a breakpoint](/images/your-first-component-windows-08.png) -1. The reason you hit the breakpoint is because the `SolveInstance` method was called once initially when the component was placed on the canvas. With Rhino and Grasshopper paused, in **Visual Studio** switch to the **Autos** tab (if it not already there). In the list, find the `plane` object. Our `plane` is a `Rhino.Geometry.Plane` with a value of `{Origin=0,0,0 XAxis=0,1,0, YAxis=0,0,1, ZAxis=1,0,0}` ...an YZ plane, the default, as expected. +1. In Grasshopper, place a _HelloGrasshopper_ component on the canvas...as soon as you do, you should hit your breakpoint and pause... + ![Hit a breakpoint](/images/your-first-component-windows-08.png) +1. The reason you hit the breakpoint is because the `SolveInstance` method was called once initially when the component was placed on the canvas. With Rhino and Grasshopper paused, in **Visual Studio** switch to the **Autos** tab (if it not already there). In the list, find the `plane` object. Our `plane` is a `Rhino.Geometry.Plane` with a value of `{Origin=0,0,0 XAxis=0,1,0, YAxis=0,0,1, ZAxis=1,0,0}` ...an YZ plane, the default, as expected. 1. **Continue** in Grasshopper by pressing the **Continue** button in the upper menu of **Visual Studio** (or press **F5**)... -![Continue Executing](/images/your-first-plugin-windows-11.png) -1. Control is passed back to **Grasshopper** and the spiral draws in the Rhino viewport. Now, place an *XY Plane* component on the canvas and feed it as an input into *HelloGrasshopper*'s *Plane* input. Notice you hit your breakpoint again, because the `SolveInstance` is being called now that the input values have changed. + ![Continue Executing](/images/your-first-plugin-windows-11.png) +1. Control is passed back to **Grasshopper** and the spiral draws in the Rhino viewport. Now, place an _XY Plane_ component on the canvas and feed it as an input into _HelloGrasshopper_'s _Plane_ input. Notice you hit your breakpoint again, because the `SolveInstance` is being called now that the input values have changed. 1. **Exit** Grasshopper and Rhino or **Stop** the debugging session. 1. **Remove** the breakpoint you created above by clicking on it in the gutter. **DONE!** -**Congratulations!** You have just built your first Grasshopper component for Rhino for Windows. **Now what?** +**Congratulations!** You have just built your first Grasshopper component for Rhino for Windows. **Now what?** ## Next Steps -You've built a component library from boilerplate code, but what about putting together a new simple component "from scratch" and adding it to your project? (Component libraries are made up of multiple components after all). Next, check out the [Simple Component](/guides/grasshopper/simple-component) guide. +You've built a component library from boilerplate code, but what about putting together a new simple component "from scratch" and adding it to your project? (Component libraries are made up of multiple components after all). Next, check out the [Simple Component](/guides/grasshopper/simple-component) guide. ## Related topics @@ -161,4 +163,4 @@ You've built a component library from boilerplate code, but what about putting t **Footnotes** -[^1]: **Line numbers** in Visual Studio can be enabled and disabled in **Tools** > **Options...** > **Text Editor** section > **All Languages** entry > **General** sub-entry > **Settings** subsection > check **Line numbers**. Click **OK** to close the **Options** dialog. +[^1]: **Line numbers** in Visual Studio can be enabled and disabled in **Tools** > **Options...** > **Text Editor** section > **All Languages** entry > **General** sub-entry > **Settings** subsection > check **Line numbers**. Click **OK** to close the **Options** dialog. diff --git a/content/en/guides/rhinocommon/your-first-plugin-mac/index.md b/content/en/guides/rhinocommon/your-first-plugin-mac/index.md index 40cffc0490f..da58c384b9a 100644 --- a/content/en/guides/rhinocommon/your-first-plugin-mac/index.md +++ b/content/en/guides/rhinocommon/your-first-plugin-mac/index.md @@ -27,7 +27,6 @@ toc_type = "single" +++ - It is presumed you already have the necessary tools installed and are ready to go. If you are not there yet, see [Installing Tools (Mac)](/guides/rhinocommon/installing-tools-mac). ## HelloRhinoCommon @@ -39,214 +38,110 @@ We are presuming you are new to Visual Studio Code, so we'll go through this one ### Download the required template 1. Launch Visual Studio Code. -1. Open *Visual Studio Code's Terminal* via *Terminal (menu entry)* > *New Terminal*, or using the command palette _(⌘ ⇧ P)_ and search for "Terminal". +1. Open _Visual Studio Code's Terminal_ via _Terminal (menu entry)_ > _New Terminal_, or using the command palette _(⌘ ⇧ P)_ and search for "Terminal". 1. Inside Terminal, run: - ``` pwsh - dotnet new install Rhino.Templates - ``` + ```pwsh + dotnet new install Rhino.Templates + ``` ### Starting the Project 1. Create a folder on your mac where you would like your project to live. Name the folder `HelloRhinoCommon`. -1. If you have not done so already, *launch Visual Studio Code*. -1. Now we can open our new folder, navigate to *File* > *Open Folder* and choose the folder we just created. -1. Open Terminal via *Terminal* > *New Terminal*, or using the command palette _(⌘ ⇧ P)_ and search for "Terminal". +1. If you have not done so already, _launch Visual Studio Code_. +1. Now we can open our new folder, navigate to _File_ > _Open Folder_ and choose the folder we just created. +1. Open Terminal via _Terminal_ > _New Terminal_, or using the command palette _(⌘ ⇧ P)_ and search for "Terminal". 1. Enter the following command into the Terminal: - ``` pwsh - dotnet new rhino --version 8 - ``` -6. In our Folder explorer, we should see the project appear as Visual Studio Code discovers the files. + ```pwsh + dotnet new rhino --version 8 -sample + ``` +1. In our Folder explorer, we should see the project appear as Visual Studio Code discovers the files. 1. Expand the Solution Explorer, this is the best way to interact with C# projects on Mac in Visual Studio Code. -### Setting up Debug - -1. Create a folder called *.vscode* in the solution directory. -{{< call-out hint "Can't see the folder?" >}} -If you cannot see the *.vscode* folder, toggle hidden folders in Finder: click on your Desktop and press _⌘ ⇧ ._ (`command` + `shift` + `period`) -{{< /call-out >}} -1. We will need to create three new files in the *.vscode* new folder: *settings.json*, *tasks.json*, and *launch.json*... -1. Create *settings.json* with the following contents: - ``` json - { - // This file will specify the solution we use to build - "dotnet.defaultSolution": "HelloRhinoCommon.sln" - } - ``` -4. Create *tasks.json* with the following contents: - ``` json - { - "version": "2.0.0", - "tasks": [ - { - "label": "build-plugin-netcore", - // This will ensure the project is built before we try to debug it - "command": "dotnet build ${workspaceFolder}/*.csproj -f net7.0", - "type": "shell", - "args": [], - "problemMatcher": [ - "$msCompile" - ], - "presentation": { - "reveal": "always" - }, - "group": "build" - } - ] - } - ``` -5. Create *launch.json* with the following contents: - ``` json - { - "version": "0.2.0", - "configurations": [ - { - "name": "Run Rhino 8 (Mac)", - "type": "coreclr", - "request": "launch", - "preLaunchTask": "build-plugin-netcore", - // Launches Rhino for us - "program": "/Applications/Rhino 8.app/Contents/MacOS/Rhinoceros", - // Add in any args here such as -nosplash or even -runscript - // See : http://docs.mcneel.com/rhino/8mac/help/en-us/index.htm#information/startingrhino.htm - "args": [], - "cwd": "${workspaceFolder}", - "stopAtEntry": false, - "console": "internalConsole", - // RHINO_PACKAGE_DIRS is required for Multi-Targeted plugins - // This is what enables Rhino to register our Plug-in - "env": { - "RHINO_PACKAGE_DIRS": "${workspaceFolder}/bin/Debug/" - } - }, - ], - "compounds": [] - } - ``` -6. The Folder Explorer should look like below (Note that we cannot see *.vscode* in the Solution Explorer) - - ![New Project](/images/your-first-plugin-mac-02.png) - - ### Boilerplate Build -1. Before we do anything, let's *Run and Debug* HelloRhinoCommon to make sure everything is working as expected. We'll just build the boilerplate Plugin template. Click the *Run and Debug* button on the left hand side of Visual Studio Code and then the green play button in the newly opened panel. - ![New Project](/images/your-first-plugin-mac-03.png) +1. Before we do anything, let's _Run and Debug_ HelloRhinoCommon to make sure everything is working as expected. We'll just build the boilerplate Plugin template. Click the _Run and Debug_ button on the left hand side of Visual Studio Code and then the green play button in the newly opened panel. -1. *Rhinoceros* launches. Click *New Model*. -1. Type `Hello` into the Rhino Commandline. Notice that the command autocompletes. + ![New Project](/images/your-first-plugin-mac-03.png) -![Command Autocompletes](/images/your-first-plugin-mac-04.png) - -1. The *HelloRhinoCommonCommand* command prints a message: +1. _Rhinoceros_ launches. Click _New Model_. +1. Type `Hello` into the Rhino Commandline. Notice that the command autocompletes. -![Command Prompt](/images/your-first-plugin-mac-05.png) +![Command Autocompletes](/images/your-first-plugin-mac-04.png) -1. *Quit* Rhinoceros. This stops the session. Go back to *Visual Studio Code*. Let's take a look at the Plugin Anatomy. +4. The _HelloRhinoCommonCommand_ command lets us draw a line, and then prints out a message +1. Press Stop Debugging _(⇧ F5)_, in Visual Studio Code, signified by the Red Square in the debug toolbar. This stops the debugging session. Go back to _Visual Studio Code_. Let's take a look at the Plugin Anatomy. ### Plugin Anatomy -1. Use the *Solution Explorer* to expand the project so that it looks like below. +1. Use the _Solution Explorer_ to expand the project so that it looks like below. ![Solution Anatomy](/images/your-first-plugin-mac-06.png) -1. The *HelloRhinoCommon* solution (*.sln*) contains all of our projects. This was created for us by the `dotnet` command we ran earlier. -1. The *HelloRhinoCommon* project (*.csproj*) has the same name as its parent solution. This is the project that was created for us by `dotnet` command we ran earlier. -1. *Dependencies*: Just as with most projects, you will be referencing other libraries. The *RhinoCommon Plugin* template added the necessary references to create a basic RhinoCommon plugin. -1. *EmbeddedResources*: This is where you would place any image assets you want to ship with your plugin. The *RhinoCommon Plugin* template added an icon file with a default boilerplate icon. -1. *Properties* contains the *AssemblyInfo.cs* source file. This file contains the meta-data (author, version, etc), including the very-important `Guid`, which identifies the plugin. -1. *HelloRhinoCommonCommand.cs* is where the action is. Let's take a look at this file in the next section below... -1. *HelloRhinoCommonPlugin.cs* is where this template plugin derives from *Rhino.Plugins.Plugin* and returns a static Instance of itself. +1. The _HelloRhinoCommon_ solution (_.sln_) contians all of our projects. This was created for us by the `dotnet` command we ran earlier. +1. The _HelloRhinoCommon_ project (_.csproj_) has the same name as its parent solution. This is the project that was created for us by `dotnet` command we ran earlier. +1. _Dependencies_: Just as with most projects, you will be referencing other libraries. The _RhinoCommon Plugin_ template added the necessary references to create a basic RhinoCommon plugin. +1. _EmbeddedResources_: This is where you would place any image assets you want to ship with your plugin. The _RhinoCommon Plugin_ template added an icon file with a default boilerplate icon. +1. _Properties_ contains the _AssemblyInfo.cs_ source file. This file contains the meta-data (author, version, etc), including the very-important `Guid`, which identifies the plugin. +1. _HelloRhinoCommonCommand.cs_ is where the action is. Let's take a look at this file in the next section below... +1. _HelloRhinoCommonPlugin.cs_ is where this template plugin derives from _Rhino.Plugins.Plugin_ and returns a static Instance of itself. ### Make Changes -1. Open *HelloRhinoCommonCommand.cs* in Visual Studio Code's Source Editor (if it isn't already). +1. Open _HelloRhinoCommonCommand.cs_ in Visual Studio Code's Source Editor (if it isn't already). 2. Notice that `HelloRhinoCommonCommand` inherits from `Rhino.Commands.Command` -``` c# +```c# public class HelloRhinoCommonCommand : Rhino.Commands.Command ``` 3. And that it overrides one inherited property called `EnglishName` -``` c# +```c# public override string EnglishName => "HelloRhinoCommonCommand"; ``` -4. All Rhino commands must have an `EnglishName` property. This command name will become inaccurate soon, as we're going to spice up our quite pointless command. Let's rename the command to *HelloDrawLine*: +4. All Rhino commands must have an `EnglishName` property. This command name will become inaccurate soon, as we're going to spice up our quite pointless command. Let's rename the command to _HelloDrawLine_: -``` c# +```c# public override string EnglishName => "HelloDrawLine"; ``` 5. Further down, notice that `HelloRhinoCommandCommand` overrides the `RunCommand` method: -``` c# +```c# protected override Result RunCommand (Rhino.RhinoDoc doc, RunMode mode) ``` -6. All Rhino commands must have a `RunCommand` method. Copy paste the below code into `RunCommand` between the brackets `{}` - -``` c# -Point3d pt0; -using (GetPoint getPointAction = new GetPoint()) -{ - getPointAction.SetCommandPrompt("Please select the start point"); - if (getPointAction.Get() != GetResult.Point) - { - RhinoApp.WriteLine("No start point was selected."); - return getPointAction.CommandResult(); - } - pt0 = getPointAction.Point(); -} - -Point3d pt1; -using (GetPoint getPointAction = new GetPoint()) -{ - getPointAction.SetCommandPrompt("Please select the end point"); - getPointAction.SetBasePoint(pt0, true); - getPointAction.DynamicDraw += - (sender, e) => e.Display.DrawLine(pt0, e.CurrentPoint, System.Drawing.Color.DarkRed); - if (getPointAction.Get() != GetResult.Point) - { - RhinoApp.WriteLine("No end point was selected."); - return getPointAction.CommandResult(); - } - pt1 = getPointAction.Point(); -} -``` - -7. And then type in the following by hand to get a feel for the editor. - -``` c# -doc.Objects.AddLine(pt0, pt1); -doc.Views.Redraw(); +6. And then type in the following by hand on line 62 to get a feel for the editor. -return Result.Success; +```c# +RhinoApp.WriteLine("I'm writing my first Rhino Plugin!"); ``` -8. Notice that - as you type - Visual Studio Code uses IntelliSense, just like Visual Studio for Windows (and many other editors). - +7. Notice that - as you type - Visual Studio Code uses IntelliSense, just like Visual Studio for Windows (and many other editors). ### Debugging -1. Set a breakpoint on line 52 of *HelloRhinoCommonCommand.cs*. You set breakpoints in Visual Studio Code by clicking in the gutter to the left of the line numbers. -![Set a breakpoint](/images/your-first-plugin-mac-07.png) -1. *Run and Debug*. our project. The breakpoint will become an empty circle, this is because our code has not been loaded yet. Once we hit the breakpoint once and continue, the code will be loaded until we end our Debug session. -![Set a breakpoint](/images/your-first-plugin-mac-08.png) -1. Click New Model. And then run our *HelloDrawLine* command. Create the two points and as soon as you do, you should hit your breakpoint and rhino will pause -![Hit a breakpoint](/images/your-first-plugin-mac-09.png) -1. With Rhino paused, in *Visual Studio Code* we will see *Locals* under *Variables*. In the list, find the `pt1` object we authored. Click the dropdown *arrow* to expand the list of members on `pt1`. -Our `pt1` is a `Rhino.Geometry.Point3d` this class has an `X`, `Y`, `Z` property just as we'll find documented in the [RhinoCommon API](https://developer.rhino3d.com/api/rhinocommon/rhino.geometry.point3d). -![Locals panel](/images/your-first-plugin-mac-10.png) -4. Let's Continue Execution in Rhino by pressing the Green *Play* button in the Debug Bar -1. Control is passed back to *Rhino* and your command finishes. *Quit* Rhino or *Stop* the debugging session. +1. Set a breakpoint on line 59 of _HelloRhinoCommonCommand.cs_. You set breakpoints in Visual Studio Code by clicking in the gutter to the left of the line numbers. + ![Set a breakpoint](/images/your-first-plugin-mac-07.png) +1. _Run and Debug_. our project. The breakpoint will become an empty circle, this is because our code has not been loaded yet. Once we hit the breakpoint once and continue, the code will be loaded until we end our Debug session. + ![Set a breakpoint](/images/your-first-plugin-mac-08.png) +1. Click New Model. And then run our _HelloDrawLine_ command. Create the two points and as soon as you do, you should hit your breakpoint and rhino will pause + ![Hit a breakpoint](/images/your-first-plugin-mac-09.png) +1. With Rhino paused, in _Visual Studio Code_ we will see _Locals_ under _Variables_. In the list, find the `pt1` object we authored. Click the dropdown _arrow_ to expand the list of members on `pt1`. + Our `pt1` is a `Rhino.Geometry.Point3d` this class has an `X`, `Y`, `Z` property just as we'll find documented in the [RhinoCommon API](https://developer.rhino3d.com/api/rhinocommon/rhino.geometry.point3d). + ![Locals panel](/images/your-first-plugin-mac-10.png) +1. Let's Continue Execution in Rhino by pressing the Green _Play_ button in the Debug Bar +1. Control is passed back to _Rhino_ and your command finishes. _Quit_ Rhino or _Stop_ the debugging session. -*Congratulations!* You have just built your first RhinoCommon plugin for Rhino for Mac. *Now what?* +_Congratulations!_ You have just built your first RhinoCommon plugin for Rhino for Mac. _Now what?_ ## Next Steps The above guide will also work perfectly well on Windows, if you need a more complex cross-platform plugin, check out the [Your First Plugin (Cross Platform)](/guides/rhinocommon/your-first-plugin-crossplatform) guide. +If you'd like to push your exciting new plugin to Yak so that everyone can use it, check out the [Creating a Yak Package](/guides/yak/creating-a-rhino-plugin-package/) guide. + ## Related topics - [Installing Tools (Mac)](/guides/rhinocommon/installing-tools-mac) diff --git a/content/en/guides/rhinocommon/your-first-plugin-windows/index.md b/content/en/guides/rhinocommon/your-first-plugin-windows/index.md index cd078c2e0fc..424c6a7481a 100644 --- a/content/en/guides/rhinocommon/your-first-plugin-windows/index.md +++ b/content/en/guides/rhinocommon/your-first-plugin-windows/index.md @@ -1,6 +1,6 @@ +++ aliases = ["/5/guides/rhinocommon/your-first-plugin-windows/", "/6/guides/rhinocommon/your-first-plugin-windows/", "/7/guides/rhinocommon/your-first-plugin-windows/", "/wip/guides/rhinocommon/your-first-plugin-windows/"] -authors = [ "dan" ] +authors = [ "dan", "callum" ] categories = [ "Getting Started" ] description = "This guide walks you through your first plugin for Rhino for Windows using RhinoCommon and Visual Studio." keywords = [ "first", "RhinoCommon", "Plugin" ] @@ -28,53 +28,58 @@ toc_type = "single" +++ -It is presumed you already have the necessary tools installed and are ready to go. If you are not there yet, see [Installing Tools (Windows)](/guides/rhinocommon/installing-tools-windows). +It is presumed you already have the necessary tools installed and are ready to go. If you are not there yet, see [Installing Tools (Windows)](/guides/rhinocommon/installing-tools-windows). ## Barebones plugin -We will use the *RhinoCommon Plugin for Rhino 3D (C#)* project template to create a new general purpose plugin. The project template generates the code for a functioning plugin. Follow these steps to build the plugin. +We will use the _RhinoCommon Plugin for Rhino 3D (C#)_ project template to create a new general purpose plugin. The project template generates the code for a functioning plugin. Follow these steps to build the plugin. ### Plugin Template -1. Launch *Visual Studio* and navigate to *File* > *New* > *Project...*. -2. From the *Create a new project* dialog, select the *RhinoCommon Plugin for Rhino 3D (C#)* template from the list of installed templates and click *Next*. +1. Launch _Visual Studio_ and navigate to _File_ > _New_ > _Project..._. +2. From the _Create a new project_ dialog, select the _RhinoCommon Plugin for Rhino 3D (C#)_ template from the list of installed templates and click _Next_. - ![New Project Template](/images/your-first-plugin-windows-01.png) -3. Type the project name as shown below. You can enter a different name if you want. The template 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 *Create*. + ![New Project Template](/images/your-first-plugin-windows-01.png) - ![New Project Configure](/images/your-first-plugin-windows-02.png) -4. Upon clicking *Create*, the *New Rhino C++ Plugin* dialog will appear. By default, the template will create a *General Utility* plugin. +3. Type the project name as shown below. You can enter a different name if you want. The template 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 _Create_. - ![Plugin Settings](/images/your-first-plugin-windows-03.png) -5. The *New RhinoCommon .NET Plugin* dialog allows you to modify a number of settings used by the template when generating the plugin source code: - 1. **Plugin name**: Modify this field if you want to change the name of the plugin's class name. - 2. **Command class name:**: Modify this field if you want to change the name of the plugin's initial command class name. - 3. **Plugin type**: Select the [type of plugin](/guides/general/what-is-a-rhino-plugin) that you want the template to create. - 4. **Target Version**: Select the target Rhino version. - 5. **Wndows UI**: If you are planning on using Windows Forms or WPF for user interface, instead of Eto, then check the approprate box. - 6. **Rhino location**: Modify this field if the path to *Rhino.exe* is found in a different location than what is shown. -6. For this tutorial, just accept the default settings. Click the *Finish* button, and the template begins to generate your plugin project’s folders, files, and classes. When the template is finished, look through the plugin project using *Visual Studio’s Solution Explorer*... + ![New Project Configure](/images/your-first-plugin-windows-02.png) + +4. Upon clicking _Create_, the _New Rhino C# Plugin_ dialog will appear. By default, the template will create a _General Utility_ plugin. + + ![Plugin Settings](/images/your-first-plugin-windows-03.png) + +5. The _New RhinoCommon .NET Plugin_ dialog allows you to modify a number of settings used by the template when generating the plugin source code: + 1. **Plugin name**: Modify this field if you want to change the name of the plugin's class name. + 1. **Command class name:**: Modify this field if you want to change the name of the plugin's initial command class name. + 1. **Plugin type**: Select the [type of plugin](/guides/general/what-is-a-rhino-plugin) that you want the template to create. + 1. **Minimum Target Version**: Select the lowest Rhino version to target. + 1. **Build Yak Package**: Toggle true to have Rhino build a Yak package automatically from your project + 1. **Include VS Code launch/tasks json files**: Includes `.vscode` folder so the plugin can be debugged in VSCode as well (Very handy for Mac). + 1. **Wndows UI**: If you are planning on using Windows Forms or WPF for user interface, instead of Eto, then check the approprate box. +6. For this tutorial, just accept the default settings. Click the _Finish_ button, and the template begins to generate your plugin project’s folders, files, and classes. When the template is finished, look through the plugin project using _Visual Studio’s Solution Explorer_... ### Plugin Anatomy -Use the *Solution Explorer* to expand the *Solution* (*.sln*) so that it looks like this. +Use the _Solution Explorer_ to expand the _Solution_ (_.sln_) so that it looks like this. ![Plugin Anatomy](/images/your-first-plugin-windows-04.png) -1. **HelloRhinoCommon**: The plugin project (*.csproj*), which has the same name as its parent solution. The project that was created for us by the project template we just used. +1. **HelloRhinoCommon**: The plugin project (_.csproj_), which has the same name as its parent solution. The project that was created for us by the project template we just used. 1. **Dependencies**: Contains references to both the .NET Framework 4.8 and .NET 7.0 assemblies required by the plugin. The project obtains RhinoCommon dependencies via [NuGet](https://www.nuget.org/packages/rhinocommon). -1. **Properties**: Contains the *AssemblyInfo.cs* source file. This file contains the meta-data, such as author and copyright, that appears in Rhino's [Plugin Manager](https://docs.mcneel.com/rhino/8/help/en-us/index.htm#options/plug-ins.htm). +1. **Properties**: Contains the _AssemblyInfo.cs_ source file. This file contains the meta-data, such as author and copyright, that appears in Rhino's [Plugin Manager](https://docs.mcneel.com/rhino/8/help/en-us/index.htm#options/plug-ins.htm). 1. **Embedded Resources**: Contains icons, bitmaps, and other non-code resources you want embedded in your plugin. 1. **HelloRhinoCommonCommand.cs**: The initial plugin command, which inherits from `Rhino.Commands.Command`. -1. **HelloRhinoCommonPlugin.cs**: The plugin class, which inherits from `Rhino.Plugins.Plugin`. +1. **HelloRhinoCommonPlugin.cs**: The plugin class, which inherits from `Rhino.Plugins.Plugin`. ### Testing -1. From *Visual Studio*, navigate to *Debug* > *Start Debugging*. You can also press *F5*, or click the *Debug* button on Visual Studio's toolbar. This will load Rhino. -1. From within Rhino, navigate to *Tools* > *Options*. Navigate to the *Plugins* page under *Rhino Options* and install your plugin. +1. From _Visual Studio_, navigate to _Debug_ > _Start Debugging_. You can also press _F5_, or click the _Debug_ button on Visual Studio's toolbar. This will load Rhino. +1. From within Rhino, navigate to _Tools_ > _Options_. Navigate to the _Plugins_ page under _Rhino Options_ and install your plugin. + + ![Rhino Options](/images/your-first-plugin-windows-05.png) - ![Rhino Options](/images/your-first-plugin-windows-05.png) -1. Once your plugin is loaded, close the options dialog and run your *HelloRhinoCommonCommand* command. +1. Once your plugin is loaded, close the options dialog and run your _HelloRhinoCommonCommand_ command. 1. You have finished creating your first plugin! ## Adding Additional Commands @@ -83,7 +88,7 @@ Rhino plugins can contain any number of commands. Commands are created by inheri Note, Command classes must return a unique command name. If you try to use a command name that is already in use, then your command will not work. -To add a new Rhino command to your plugin project, right-click on the project, in Visual Studio’s Solution Explorer, and click Add > New Item…. From the Add New Item dialog, select *Empty RhinoCommon Command for Rhino 3D (C++)*, specify the name of the command, and click *Add*. +To add a new Rhino command to your plugin project, right-click on the project, in Visual Studio’s Solution Explorer, and click Add > New Item…. From the Add New Item dialog, select _Empty RhinoCommon Command for Rhino 3D (C++)_, specify the name of the command, and click _Add_. ![Rhino Command](/images/your-first-plugin-windows-06.png) @@ -159,6 +164,12 @@ namespace HelloRhinoCommon } ``` +## Next Steps + +If you want to make your new Plugin Cross Platform, check out the [Your First Plugin (Cross Platform)](/guides/rhinocommon/your-first-plugin-crossplatform) guide. + +If you'd like to push your exciting new plugin to Yak so that everyone can use it, check out the [Creating a Yak Package](/guides/yak/creating-a-rhino-plugin-package/) guide. + ## Related topics - [Installing Tools (Windows)](/guides/rhinocommon/installing-tools-windows) diff --git a/static/images/your-first-component-mac-03.png b/static/images/your-first-component-mac-03.png index 1307bcfc6e1..f7635242021 100644 --- a/static/images/your-first-component-mac-03.png +++ b/static/images/your-first-component-mac-03.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:fe2ff0285382a1e375761bdf15fb02490c80b89a054b6ad0dc470557b1c43a51 -size 294022 +oid sha256:f42c1cf01cd92512cd494d4f541567cf4baadcc9d72cfda24761c5eb4200df68 +size 1091437 diff --git a/static/images/your-first-component-mac-05.png b/static/images/your-first-component-mac-05.png index a9af8322083..d83f8c4dd5a 100644 --- a/static/images/your-first-component-mac-05.png +++ b/static/images/your-first-component-mac-05.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:be11c08926335d7c89b4f2855ea0155ffa4180dc9f080bb10a381c1c09e616d9 -size 13793 +oid sha256:b927493e952789683494cbbab267248f582b7af49d61df5f6d0585cba6d2d227 +size 426823 diff --git a/static/images/your-first-component-mac-06.png b/static/images/your-first-component-mac-06.png index 6636ecb0a2d..dbb15dd038f 100644 --- a/static/images/your-first-component-mac-06.png +++ b/static/images/your-first-component-mac-06.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:821e534775ef3d1b7b9fbfbe7073db9e6c6746f95e5ff1cd79ed5a2ce4ef4c74 -size 13635 +oid sha256:4ef7249d688ee91e24ea8321b6ffd09dedc5b2dd413323eeeb5517c8b218c3fd +size 359604 diff --git a/static/images/your-first-component-mac-07.png b/static/images/your-first-component-mac-07.png index 11c10cf11c0..e510bf1ce5a 100644 --- a/static/images/your-first-component-mac-07.png +++ b/static/images/your-first-component-mac-07.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:2ff975eada8420f1e8465154fbd9fd530afc82da0158608998d0f4f1814f1443 -size 14672 +oid sha256:abf5fa190676c3c2dee8edb7f9a52d0a5ea420ec67c76183d8aed76cf6b7b326 +size 420353 diff --git a/static/images/your-first-component-mac-08.png b/static/images/your-first-component-mac-08.png index f871908f359..a85c67be743 100644 --- a/static/images/your-first-component-mac-08.png +++ b/static/images/your-first-component-mac-08.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:6c78596efd08f45f58343cb098090a9fc059b89cdf52e338e5146567f13366e1 -size 277382 +oid sha256:b6571214c5c0f24c53186a7e355233de98434e5786f8c0d53e6443c97df7aa6d +size 567895 diff --git a/static/images/your-first-component-windows-03.png b/static/images/your-first-component-windows-03.png index 77ebff0c2fc..0508bc3b3f2 100644 --- a/static/images/your-first-component-windows-03.png +++ b/static/images/your-first-component-windows-03.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:3f89ca10cfb6a7c282ac3c40ce5ddf38ca4fe29799c654bbdc9a6cde56a9d9ed -size 47273 +oid sha256:4212fa61bf636c1ce923b4517d49e35dce1e2ecded07e28f4120486dd77c6ce5 +size 38488 diff --git a/static/images/your-first-component-windows-05.png b/static/images/your-first-component-windows-05.png deleted file mode 100644 index 1594c79cd98..00000000000 --- a/static/images/your-first-component-windows-05.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:e855e5d0ff5dcf8fb3a5147ee8742a7813fa6220135956e9c902dbf5ceb95617 -size 68685 diff --git a/static/images/your-first-component-windows-06.png b/static/images/your-first-component-windows-06.png index 8ea9ba6cb13..bf74a80528b 100644 --- a/static/images/your-first-component-windows-06.png +++ b/static/images/your-first-component-windows-06.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:71a8f09195a5b2005fc1bf9b1b7762e885e6c9fb8b023d87288bb0f38a269245 -size 31032 +oid sha256:5bbd44c78dc56c4f13a057228fc216e3f665d124ec422f8b0c054868c60ac286 +size 69527 diff --git a/static/images/your-first-plugin-mac-05.png b/static/images/your-first-plugin-mac-05.png deleted file mode 100644 index d22052b20e6..00000000000 --- a/static/images/your-first-plugin-mac-05.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:9877c1656e96c6f0a13c717295d6ef7e5fa0b96151a998ca87d8ef6d55f503b0 -size 32992 diff --git a/static/images/your-first-plugin-mac-07.png b/static/images/your-first-plugin-mac-07.png index fbcd04cd379..be0d57361a4 100644 --- a/static/images/your-first-plugin-mac-07.png +++ b/static/images/your-first-plugin-mac-07.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:744727789975e8f616f4d36fc778b6c4853239d650a419038727499d342d2e62 -size 20175 +oid sha256:3dd520a004d1cdfbaea002db1fcdee7735ef87e6d0b3f004e4302fd62496c300 +size 41545 diff --git a/static/images/your-first-plugin-mac-08.png b/static/images/your-first-plugin-mac-08.png index 2596cf30cb0..676d376f305 100644 --- a/static/images/your-first-plugin-mac-08.png +++ b/static/images/your-first-plugin-mac-08.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:39c7a0644f396136cdca229d4b7d88d042787e7f7816325cc13cd7ae81ca51ed -size 21596 +oid sha256:a1d9403f92e085f4f8b1d5112444de1470bb33ab6c9b520cc4ba1c00abbd8a68 +size 41545 diff --git a/static/images/your-first-plugin-mac-09.png b/static/images/your-first-plugin-mac-09.png index 0c17756870d..5f51ca75318 100644 --- a/static/images/your-first-plugin-mac-09.png +++ b/static/images/your-first-plugin-mac-09.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:8f793b50c7ff1f7a51c5c77f1d5cb0c030f1db0c45738f18839a9f0175d4bff6 -size 21325 +oid sha256:68bcc3aa5d17d0b97bcf78421d87e9a43a7e76c30181e699b9b08deb4f74ba38 +size 43827 diff --git a/static/images/your-first-plugin-mac-10.png b/static/images/your-first-plugin-mac-10.png index ab612a90448..73011bcac40 100644 --- a/static/images/your-first-plugin-mac-10.png +++ b/static/images/your-first-plugin-mac-10.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:0e09edd3a51523fd5cc545c837fbe51b509322a63d92294d498c7f19854893f9 -size 251542 +oid sha256:ae4e6557c8e0752eb98710a45295e5cbf506dc71dde63f687a1cfc6752466745 +size 542607 diff --git a/static/images/your-first-plugin-windows-03.png b/static/images/your-first-plugin-windows-03.png index 585bbb7ae36..c015ce8fdac 100644 --- a/static/images/your-first-plugin-windows-03.png +++ b/static/images/your-first-plugin-windows-03.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:65b50e702eb2af41506178022eb591828df3cadb57ea4a9b3b504f9a9008baad -size 22888 +oid sha256:405bf120777e9b084776d4f66c16de00c5c2173f7c344f395cd1184ac6b69851 +size 38697