asdf
Automatically build to gh component folder: In Project Explorer, click: Properties -> Build Events, then edit (or add a new) post-build event: Copy "$(TargetPath)" "C:\Users\Josh\AppData\Roaming\Grasshopper\Libraries\<Name of Plugin>.gha"
OR Add build folder to rhino search path: After Rhino Launches enter "GrasshopperDeveloperSettings", then add your bin output folder of your project to Grasshopper’s search path.
Under "GrasshopperDeveloperSettings", consider unchecking the Memory load *.GHA assemblies using COFF byte arrays checkbox during development (will allow you to hit debug breakpoints, etc.)
(v6) After building, close open gh files, then type GrasshopperReloadAssemblies
(v6) to update component definitions without having to restart rhino. (better yet bind a keyboard shortcut, e.g. Ctrl+R
, to this cmd.)
(v5) After building, close/open grasshopper by binding shortcut, e.g. Ctrl+R
, to GrasshopperUnloadPlugin Grasshopper
using System;
using Grasshopper.Kernel;
namespace MyPlugin
{
public class MyPluginComponent : GH_Component
{
}
}
public MyPluginComponent() : base(
"MyPlugin", // name
"ABC", // component label/abbreviation
"xxx", // description
"Custom", // category (tab)
"Simple") {} // subcategory (group w/in tab)
pManager
object inside overriden implementation of RegisterInputParams
method.protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager)
{
// pManager.AddPlaneParameter(name, label, descr, access, default);
pManager.AddPlaneParameter("Plane", "P", "Base plane for spiral", GH_ParamAccess.item, Plane.WorldXY);
pManager.AddNumberParameter("Inner Radius", "R0", "Inner radius for spiral", GH_ParamAccess.item, 1.0);
pManager.AddNumberParameter("Outer Radius", "R1", "Outer radius for spiral", GH_ParamAccess.item, 10.0);
pManager.AddIntegerParameter("Turns", "T", "Number of turns between radii", GH_ParamAccess.item, 10);
// change properties of certain parameters,
pManager[0].Optional = true;
}
Note the access type parameter and optional default values.
pManager
object inside overriden implementation of RegisterOutputParams
method.Output parameters do not have default values, but they too must have the correct access type.
protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager pManager)
{
// pManager.AddPlaneParameter(name, label, descr, access);
pManager.AddCurveParameter("Spiral", "S", "Spiral curve", GH_ParamAccess.item);
// hide a specific parameter from the Rhino preview.
pManager.HideParameter(0);
}
SolveInstance
method, using DA
object to access inputs/outputs.protected override void SolveInstance(IGH_DataAccess DA)
{
// Initialize variables
Plane plane = Plane.WorldXY;
double radius0 = 0.0;
double radius1 = 0.0;
int turns = 0;
// Use the DA object to bind input params to variables
if (!DA.GetData(0, ref plane)) return;
if (!DA.GetData(1, ref radius0)) return;
if (!DA.GetData(2, ref radius1)) return;
if (!DA.GetData(3, ref turns)) return;
// Validate the data
if (radius0 < 0.0) return;
if (radius1 <= radius0) return;
if (turns <= 0) return;
// Pass validated data to helper function
Curve spiral = CreateSpiral(plane, radius0, radius1, turns);
// use DA object to Bind outputs.
DA.SetData(0, spiral);
}
private Curve CreateSpiral(Plane plane, double r0, double r1, Int32 turns)
{
// functionality goes here...
}
ComponentGuid
methodGenerate new Guids using an Online Guid Generator or Microsofts popular guidgen.exe
public override Guid ComponentGuid
{
get { return new Guid("c09fabd9-61d5-4b04-9dbd-99f4f6e7780d"); }
}
Exposure
methodThere are seven possible locations (primary to septenary), each of which can be combined with the GH_Exposure.obscure flag, which ensures the component will only be visible on panel dropdowns.
public override GH_Exposure Exposure
{
get { return GH_Exposure.primary; }
}
Icon
methodprotected override System.Drawing.Bitmap Icon
{
get
{
// add 24x24 px image files to your project resources and access them like this:
return Resources.IconForThisComponent;
}
}
http://developer.rhino3d.com/wip/api/grasshopper/html/730f0792-7bfb-4310-a416-239e8c315645.htm#! http://www.chenjingcheng.com/a-quick-guide-to-make-a-plugin-for-grasshopper-in-visual-studio-2015/
RhinoCommon SDK Grasshopper SDK
http://atlv.org/education/ C# for Grasshopper
Long Nguyen, C# Scripting and Plugin Development for Grasshopper (2018) Designalyze, Intro to C# Scripting in Grasshopper
NOC Python Grasshopper john harding on vimeo
GH_CPython on github GH_CPython on food4rhino ANT biomorpher embryo
Mahmoud Ouf - author of GH_CPython/ANT John Harding - author of biomorpher/embryo Jingcheng Chen Long Nguyen - author of DynaShape (Dynamo Plugin) and run's grasshopper plugin development workshop.