SimpleGrasshopper 0.9.10

Suggested Alternatives

ArchiToolkit.Grasshopper

Additional Details

It removed the references and had fewer reflections.

There is a newer version of this package available.
See the version list below for details.
dotnet add package SimpleGrasshopper --version 0.9.10
                    
NuGet\Install-Package SimpleGrasshopper -Version 0.9.10
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="SimpleGrasshopper" Version="0.9.10" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SimpleGrasshopper" Version="0.9.10" />
                    
Directory.Packages.props
<PackageReference Include="SimpleGrasshopper" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add SimpleGrasshopper --version 0.9.10
                    
#r "nuget: SimpleGrasshopper, 0.9.10"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package SimpleGrasshopper@0.9.10
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=SimpleGrasshopper&version=0.9.10
                    
Install as a Cake Addin
#tool nuget:?package=SimpleGrasshopper&version=0.9.10
                    
Install as a Cake Tool

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 won't copy to the output directory automatically. If there is any way to make the nuget pacakge only copy this file, please tell me.

Quick Start

Add the package from nuget package.

  <ItemGroup>
    <PackageReference Include="SimpleGrasshopper" Version="0.9.1" />
  <ItemGroup>

Don't forget to copy this SimpleGrasshopper.dll file to your output folder!

image-20231124084353080

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!

image-20231123221923982

The output is the parameters with the modifier out! And please don't use ref! It'll be regarded as input!

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.
    [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.

One more thing, for the angle parameter, is the AngleAttribute!

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;
    }
}

image-20231123223432423

image-20231123223445165

image-20231123223455689

Data Access

If you want your data access to be a list, please set the param type to List<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

For some cases, you may want to add some enum parameters to your project, 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,
}

image-20231123225356231

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
{
}

image-20231123224941091

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)
    {

    }
}

image-20231123225140458

Settings

Well, for some lazy people like me, who doesn'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!

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 Compatible and additional computed target framework versions.
.NET net7.0-windows7.0 is compatible.  net8.0-windows was computed.  net9.0-windows was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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 444 10/22/2024 1.8.6 is deprecated because it is no longer maintained.
1.8.5 336 10/8/2024 1.8.5 is deprecated because it is no longer maintained.
1.8.4 393 6/27/2024 1.8.4 is deprecated because it is no longer maintained.
1.8.2 394 5/15/2024 1.8.2 is deprecated because it is no longer maintained.
1.8.1 350 5/11/2024 1.8.1 is deprecated because it is no longer maintained.
1.8.0 346 5/11/2024 1.8.0 is deprecated because it is no longer maintained.
1.7.13 355 5/10/2024 1.7.13 is deprecated because it is no longer maintained.
1.7.12 356 5/10/2024 1.7.12 is deprecated because it is no longer maintained.
1.7.11 361 5/9/2024 1.7.11 is deprecated because it is no longer maintained.
1.7.10 362 5/7/2024 1.7.10 is deprecated because it is no longer maintained.
1.7.9 347 5/6/2024 1.7.9 is deprecated because it is no longer maintained.
1.7.8 355 4/30/2024 1.7.8 is deprecated because it is no longer maintained.
1.7.7 359 4/30/2024 1.7.7 is deprecated because it is no longer maintained.
1.7.5 351 4/30/2024 1.7.5 is deprecated because it is no longer maintained.
1.7.4 352 4/30/2024 1.7.4 is deprecated because it is no longer maintained.
1.7.3 342 4/29/2024 1.7.3 is deprecated because it is no longer maintained.
1.7.2 345 4/29/2024 1.7.2 is deprecated because it is no longer maintained.
1.7.1 341 4/29/2024 1.7.1 is deprecated because it is no longer maintained.
1.7.0 347 4/28/2024 1.7.0 is deprecated because it is no longer maintained.
1.6.4 348 4/26/2024 1.6.4 is deprecated because it is no longer maintained.
1.6.3 357 4/22/2024 1.6.3 is deprecated because it is no longer maintained.
1.6.2 385 3/24/2024 1.6.2 is deprecated because it is no longer maintained.
1.6.1 360 3/24/2024 1.6.1 is deprecated because it is no longer maintained.
1.6.0 354 3/22/2024 1.6.0 is deprecated because it is no longer maintained.
1.5.4 359 3/22/2024 1.5.4 is deprecated because it is no longer maintained.
1.5.3 368 3/7/2024 1.5.3 is deprecated because it is no longer maintained.
1.5.2 366 2/20/2024 1.5.2 is deprecated because it is no longer maintained.
1.5.1 356 1/30/2024 1.5.1 is deprecated because it is no longer maintained.
1.5.0 362 1/19/2024 1.5.0 is deprecated because it is no longer maintained.
1.4.9 350 1/18/2024 1.4.9 is deprecated because it is no longer maintained.
1.4.8 359 1/17/2024 1.4.8 is deprecated because it is no longer maintained.
1.4.7 349 1/16/2024 1.4.7 is deprecated because it is no longer maintained.
1.4.5 386 1/14/2024 1.4.5 is deprecated because it is no longer maintained.
1.4.4 349 1/14/2024 1.4.4 is deprecated because it is no longer maintained.
1.4.3 361 1/13/2024 1.4.3 is deprecated because it is no longer maintained.
1.4.2 358 1/12/2024 1.4.2 is deprecated because it is no longer maintained.
1.4.1 356 1/12/2024 1.4.1 is deprecated because it is no longer maintained.
1.4.0 357 1/12/2024 1.4.0 is deprecated because it is no longer maintained.
1.3.10 359 1/12/2024 1.3.10 is deprecated because it is no longer maintained.
1.3.9 355 1/11/2024 1.3.9 is deprecated because it is no longer maintained.
1.3.8 346 1/11/2024 1.3.8 is deprecated because it is no longer maintained.
1.3.7 347 1/10/2024 1.3.7 is deprecated because it is no longer maintained.
1.3.5 346 1/10/2024 1.3.5 is deprecated because it is no longer maintained.
1.3.4 366 1/9/2024 1.3.4 is deprecated because it is no longer maintained.
1.3.3 357 1/8/2024 1.3.3 is deprecated because it is no longer maintained.
1.3.1 372 1/4/2024 1.3.1 is deprecated because it is no longer maintained.
1.3.0 370 1/3/2024 1.3.0 is deprecated because it is no longer maintained.
1.2.9 362 1/3/2024 1.2.9 is deprecated because it is no longer maintained.
1.2.8 376 1/1/2024 1.2.8 is deprecated because it is no longer maintained.
1.2.7 363 12/29/2023 1.2.7 is deprecated because it is no longer maintained.
1.2.6 374 12/28/2023 1.2.6 is deprecated because it is no longer maintained.
1.2.5 362 12/26/2023 1.2.5 is deprecated because it is no longer maintained.
1.2.4 356 12/24/2023 1.2.4 is deprecated because it is no longer maintained.
1.2.3 351 12/23/2023 1.2.3 is deprecated because it is no longer maintained.
1.2.2 376 12/22/2023 1.2.2 is deprecated because it is no longer maintained.
1.2.1 362 12/22/2023 1.2.1 is deprecated because it is no longer maintained.
1.2.0 346 12/22/2023 1.2.0 is deprecated because it is no longer maintained.
1.1.9 349 12/21/2023 1.1.9 is deprecated because it is no longer maintained.
1.1.8 354 12/21/2023 1.1.8 is deprecated because it is no longer maintained.
1.1.7 353 12/21/2023 1.1.7 is deprecated because it is no longer maintained.
1.1.6 351 12/21/2023 1.1.6 is deprecated because it is no longer maintained.
1.1.5 323 12/20/2023 1.1.5 is deprecated because it is no longer maintained.
1.1.4 376 12/20/2023 1.1.4 is deprecated because it is no longer maintained.
1.1.3 333 12/20/2023 1.1.3 is deprecated because it is no longer maintained.
1.1.2 344 12/20/2023 1.1.2 is deprecated because it is no longer maintained.
1.1.1 371 12/19/2023 1.1.1 is deprecated because it is no longer maintained.
1.1.0 345 12/19/2023 1.1.0 is deprecated because it is no longer maintained.
1.0.6 364 12/18/2023 1.0.6 is deprecated because it is no longer maintained.
1.0.5 343 12/18/2023 1.0.5 is deprecated because it is no longer maintained.
1.0.4 387 12/16/2023 1.0.4 is deprecated because it is no longer maintained.
1.0.3 373 12/14/2023 1.0.3 is deprecated because it is no longer maintained.
1.0.2 358 12/13/2023 1.0.2 is deprecated because it is no longer maintained.
1.0.1 344 12/13/2023 1.0.1 is deprecated because it is no longer maintained.
1.0.0 370 12/13/2023 1.0.0 is deprecated because it is no longer maintained.
0.10.6 371 12/11/2023 0.10.6 is deprecated because it is no longer maintained.
0.10.5 364 12/11/2023 0.10.5 is deprecated because it is no longer maintained.
0.10.4 374 12/4/2023 0.10.4 is deprecated because it is no longer maintained.
0.10.3 367 11/28/2023 0.10.3 is deprecated because it is no longer maintained.
0.10.2 348 11/27/2023 0.10.2 is deprecated because it is no longer maintained.
0.10.1 377 11/27/2023 0.10.1 is deprecated because it is no longer maintained.
0.10.0 376 11/26/2023 0.10.0 is deprecated because it is no longer maintained.
0.9.10 396 11/26/2023 0.9.10 is deprecated because it is no longer maintained.
0.9.9 370 11/26/2023 0.9.9 is deprecated because it is no longer maintained.
0.9.8 371 11/26/2023 0.9.8 is deprecated because it is no longer maintained.
0.9.7 370 11/24/2023 0.9.7 is deprecated because it is no longer maintained.