SimpleGrasshopper 1.8.6
dotnet add package SimpleGrasshopper --version 1.8.6
NuGet\Install-Package SimpleGrasshopper -Version 1.8.6
<PackageReference Include="SimpleGrasshopper" Version="1.8.6" />
paket add SimpleGrasshopper --version 1.8.6
#r "nuget: SimpleGrasshopper, 1.8.6"
// Install SimpleGrasshopper as a Cake Addin #addin nuget:?package=SimpleGrasshopper&version=1.8.6 // Install SimpleGrasshopper as a Cake Tool #tool nuget:?package=SimpleGrasshopper&version=1.8.6
Simple Grasshopper
Hi, this is a repo to simplify your plugin development in Grasshopper.
With this repo, you don't need to understand what a GH_Component
is and what a GH_Param
is. All you need to do is add attributes!
NOTICE: For some reason, the SimpleGrasshopper.dll
and Newtonsoft.Json.dll
won't copy to the output directory automatically. If there is any way to make the nuget package only copy this file, please tell me.
Quick Start
Add the package from nuget package.
<ItemGroup>
<PackageReference Include="SimpleGrasshopper" Version="1.4.7" />
<ItemGroup>
Don't forget to copy this SimpleGrasshopper.dll
and Newtonsoft.Json.dll
file to your output folder!
Notice: if you want to create a plugin in rhino8 with .Net core, please add a Grasshoppper
reference to your project!
If you want to see more examples, please go here.
How to use
Component
All the components are methods. to simplify creating these things, a method is a component! To let it know which method should be the component, please tag it with DocObjAttribute
with the basic info about it called Name
, NickName
, and Description
!
using SimpleGrasshopper.Attributes;
namespace SimpleGrasshopper.GHTests;
internal class SimpleSubcategory
{
[DocObj("Addition", "Add", "The addition of the integers.")]
private static void SimpleMethod(int a, int b, out int c)
{
c = a + b;
}
}
Now, you'll see a component in GH!
The parameters can be in
, out,
or ref
.
The method can be static
or not. If it is not static, it'll create an input and an output to the instance of that class.
Component Infos
For some cases, you may want to add more information for this component, there are 3 attributes designed for this. They are SubCategoryAttribute
, IconAttribute
, and ExposureAttribute
. You can also use the attribute ObsoleteAttribute
.
using SimpleGrasshopper.Attributes;
namespace SimpleGrasshopper.GHTests;
[SubCategory("Just a test")]
internal class SimpleSubcategory
{
[Icon("ConstructRenderItemComponent_24-24.png")] // The name of the png that is embedded in your dll or the download link or the local path even the guid of some component to get the icon from it.
[Exposure(Grasshopper.Kernel.GH_Exposure.secondary)]
[DocObj("Addition", "Add", "The addition of the integers.")]
private static void SimpleMethod(int a, int b, out int c)
{
c = a + b;
}
}
Parameters Info
If you want to change the description of the param, please use DocObjAttribute
one more time to make it easier to read.
If you want to use some other Parameter with your parameter, please use ParamAttribute
.
For the angle parameter, is the AngleAttribute
!
For the geometry parameter, if you want to hide it, please use HiddenAttribute
!
If your parameter is int
or double
, you can add RangeAttribute
to control the range of it. It'll automatically make the input value in this range, and make a warning to Grasshopper.
using SimpleGrasshopper.Attributes;
using SimpleGrasshopper.Data;
namespace SimpleGrasshopper.GHTests;
[SubCategory("Just a test")]
internal class SimpleSubcategory
{
[DocObj("Special Param", "Spe", "Special Params")]
private static void ParamTest(
[DocObj("Name", "N", "The name of sth.")] string name,
[Param(ParamGuids.FilePath)]string path,
[Angle]out double angle)
{
angle = Math.PI;
}
}
Data Access
If you want your data access to be a list, please set the param type to List<T>
or T[]
.
If you want your data access to be a tree. That would be complex.
If it is a built-in type, please do it like GH_Structure<GH_XXXX>
. If it is your type, please do it like GH_Structure<SimpleGoo<XXXXX>>
.
Enum Type
You may want to add some enum parameters to your project in some cases, so just do it!
You can also add a default value for making it optional.
using SimpleGrasshopper.Attributes;
using SimpleGrasshopper.Data;
namespace SimpleGrasshopper.GHTests;
[SubCategory("Just a test")]
internal class SimpleSubcategory
{
[DocObj("Enum Param", "Enu", "Enum testing")]
private static void EnumTypeTest(out EnumTest type, EnumTest input = EnumTest.First)
{
type = EnumTest.First;
}
}
public enum EnumTest : byte
{
First,
Second,
}
Parameters
For parameters, they are just types! doing things like a type!
You can also add IconAttribute
, ExposureAttribute
, and ObsoleteAttribute
.
using SimpleGrasshopper.Attributes;
namespace SimpleGrasshopper.GHTests;
[Icon("CurveRenderAttributeParameter_24-24.png")]
[DocObj("My type", "just a type", "Testing type.")]
public class TypeTest
{
}
And this parameter can also be used in the component!
using SimpleGrasshopper.Attributes;
using SimpleGrasshopper.Data;
namespace SimpleGrasshopper.GHTests;
[SubCategory("Just a test")]
internal class SimpleSubcategory
{
[DocObj("Type Testing", "T", "Testing for my type")]
private static void MyTypeTest(TypeTest type)
{
}
}
If you want your parameter can be previewed, please add the interface IPreviewData
. If you want your data can be baked, please add the interface IGH_BakeAwareData
.
If you want your type can be converted, please do it with explicit and implicit conversion operators.
Special Components
For some common components, there are some ez ways to create them.
Property Component
If you create your data type, and you want to modify its property, you can add a tag called PropertyComponentAttribute
to your type definition.
[PropertyComponent]
[Icon("CurveRenderAttributeParameter_24-24.png")]
[DocObj("My type", "just a type", "Testing type.")]
public class TypeTest
{
[DocObj("Value", "V", "")]
public int FirstValue { get; set; }
}
Type Component
If you are soo lazy to add a lot of tags to every method in one type. You can add a tag called TypeComponentAttribute
. It'll create a method component for your plugin, and this component can use all public methods.
[TypeComponent]
[Icon("CurveRenderAttributeParameter_24-24.png")]
[DocObj("My type", "just a type", "Testing type.")]
public class TypeTest
{
[DocObj("Value", "V", "")]
public int FirstValue { get; set; }
public void AddValue(int value)
{
FirstValue += value;
}
public void ReduceValue(int value)
{
FirstValue -= value;
}
}
Well, good news for all lazy people!
Settings
Well, for some lazy people like me, who don't like to use Instances.Setting.GetValue(XXX)
, etc. I just want to make it ez.
So, just tag a static field with the attribute SettingAttribute
!
using SimpleGrasshopper.Attributes;
using System.Drawing;
namespace SimpleGrasshopper.GHTests;
internal static partial class SettingClass
{
[Setting]
private static readonly bool firstSetting = true;
[Setting]
private static readonly Color secondSetting = Color.AliceBlue;
}
internal readonly partial struct SettingStruct
{
[Setting]
private static readonly string anotherSetting = default!;
}
And you can use it like this.
var a = SettingClass.FirstSetting;
var b = SettingClass.SecondSetting;
var c = SettingStruct.AnotherSetting;
That makes it easier!
DocData
The data that you want to save in the document can be made easier. The DocDataAttribute
is here to help you! It is very similar to the Setting things.
Configurations
If you want to add your custom menu to Grasshopper. You can add a tag called ConfigAttribute
to your setting or your property.
Undo
An easier way to record undo.
Advanced
So it is making it easier. But if you still want to modify the GH_Component
or GH_PersistentParam
. You can use the keyword partial
to modify the class. For the components, the class is CLASSNAME_METHODNAME_Component
. For the parameters, the class is CLASSNAME_Parameter
.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET Framework | net48 is compatible. net481 was computed. |
-
.NETFramework 4.8
- Grasshopper (>= 7.3.21039.11201)
- Newtonsoft.Json (>= 13.0.3)
- System.Drawing.Common (>= 8.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.8.6 | 85 | 10/22/2024 |
1.8.5 | 102 | 10/8/2024 |
1.8.4 | 153 | 6/27/2024 |
1.8.2 | 150 | 5/15/2024 |
1.8.1 | 113 | 5/11/2024 |
1.8.0 | 109 | 5/11/2024 |
1.7.13 | 116 | 5/10/2024 |
1.7.12 | 117 | 5/10/2024 |
1.7.11 | 127 | 5/9/2024 |
1.7.10 | 128 | 5/7/2024 |
1.7.9 | 117 | 5/6/2024 |
1.7.8 | 124 | 4/30/2024 |
1.7.7 | 122 | 4/30/2024 |
1.7.5 | 113 | 4/30/2024 |
1.7.4 | 116 | 4/30/2024 |
1.7.3 | 112 | 4/29/2024 |
1.7.2 | 107 | 4/29/2024 |
1.7.1 | 112 | 4/29/2024 |
1.7.0 | 115 | 4/28/2024 |
1.6.4 | 117 | 4/26/2024 |
1.6.3 | 122 | 4/22/2024 |
1.6.2 | 146 | 3/24/2024 |
1.6.1 | 127 | 3/24/2024 |
1.6.0 | 120 | 3/22/2024 |
1.5.4 | 127 | 3/22/2024 |
1.5.3 | 133 | 3/7/2024 |
1.5.2 | 130 | 2/20/2024 |
1.5.1 | 118 | 1/30/2024 |
1.5.0 | 124 | 1/19/2024 |
1.4.9 | 112 | 1/18/2024 |
1.4.8 | 117 | 1/17/2024 |
1.4.7 | 112 | 1/16/2024 |
1.4.5 | 144 | 1/14/2024 |
1.4.4 | 111 | 1/14/2024 |
1.4.3 | 123 | 1/13/2024 |
1.4.2 | 120 | 1/12/2024 |
1.4.1 | 118 | 1/12/2024 |
1.4.0 | 116 | 1/12/2024 |
1.3.10 | 117 | 1/12/2024 |
1.3.9 | 115 | 1/11/2024 |
1.3.8 | 108 | 1/11/2024 |
1.3.7 | 109 | 1/10/2024 |
1.3.5 | 111 | 1/10/2024 |
1.3.4 | 128 | 1/9/2024 |
1.3.3 | 115 | 1/8/2024 |
1.3.1 | 134 | 1/4/2024 |
1.3.0 | 130 | 1/3/2024 |
1.2.9 | 115 | 1/3/2024 |
1.2.8 | 139 | 1/1/2024 |
1.2.7 | 124 | 12/29/2023 |
1.2.6 | 133 | 12/28/2023 |
1.2.5 | 126 | 12/26/2023 |
1.2.4 | 118 | 12/24/2023 |
1.2.3 | 115 | 12/23/2023 |
1.2.2 | 141 | 12/22/2023 |
1.2.1 | 123 | 12/22/2023 |
1.2.0 | 104 | 12/22/2023 |
1.1.9 | 114 | 12/21/2023 |
1.1.8 | 116 | 12/21/2023 |
1.1.7 | 115 | 12/21/2023 |
1.1.6 | 107 | 12/21/2023 |
1.1.5 | 86 | 12/20/2023 |
1.1.4 | 133 | 12/20/2023 |
1.1.3 | 96 | 12/20/2023 |
1.1.2 | 108 | 12/20/2023 |
1.1.1 | 132 | 12/19/2023 |
1.1.0 | 111 | 12/19/2023 |
1.0.6 | 122 | 12/18/2023 |
1.0.5 | 106 | 12/18/2023 |
1.0.4 | 149 | 12/16/2023 |
1.0.3 | 134 | 12/14/2023 |
1.0.2 | 117 | 12/13/2023 |
1.0.1 | 110 | 12/13/2023 |
1.0.0 | 132 | 12/13/2023 |
0.10.6 | 131 | 12/11/2023 |
0.10.5 | 126 | 12/11/2023 |
0.10.4 | 148 | 12/4/2023 |
0.10.3 | 133 | 11/28/2023 |
0.10.2 | 118 | 11/27/2023 |
0.10.1 | 141 | 11/27/2023 |
0.10.0 | 150 | 11/26/2023 |
0.9.10 | 163 | 11/26/2023 |
0.9.9 | 141 | 11/26/2023 |
0.9.8 | 145 | 11/26/2023 |
0.9.7 | 139 | 11/24/2023 |