ArchiToolkit.Grasshopper 0.9.11

There is a newer version of this package available.
See the version list below for details.
dotnet add package ArchiToolkit.Grasshopper --version 0.9.11                
NuGet\Install-Package ArchiToolkit.Grasshopper -Version 0.9.11                
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="ArchiToolkit.Grasshopper" Version="0.9.11" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add ArchiToolkit.Grasshopper --version 0.9.11                
#r "nuget: ArchiToolkit.Grasshopper, 0.9.11"                
#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.
// Install ArchiToolkit.Grasshopper as a Cake Addin
#addin nuget:?package=ArchiToolkit.Grasshopper&version=0.9.11

// Install ArchiToolkit.Grasshopper as a Cake Tool
#tool nuget:?package=ArchiToolkit.Grasshopper&version=0.9.11                

ArchiToolkit.Grasshopper

This is designed for simplify your way of developing plugins in Grasshopper. It is more clean and efficient compared to SimpleGrasshopper. So almost all features are similar to SimpleGrasshopper.

This tool is using Roslyn to help you coding when you are coding.

Quick Start

Install the ArchiToolkit.Grasshopper and then make sure that your LangVersion is latest. At the moment, my Visual Studio is at the version 17.13.4.

  <PropertyGroup>
    <LangVersion>latest</LangVersion>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="ArchiToolkit.Grasshopper" Version="0.9.10" />
  </ItemGroup>

How to use

Component

All the components are methods. to simplify creating these things, a static method is a component! To let it know which method should be the component, please tag it with DocObjAttribute.

public class Test
{
    [DocObj]
    public static int Add(int x, int y) => x + y;
}

Now, you'll see a component in GH!

image-20250324110314135

The parameters can be in, out, or ref

Please notice that, the Source generator will automatically generate the ArchiToolkit.Resources.resx file and the icons.png located in Icons Folder. Here are the structure.

  • Icons
    • MyGrasshopperAssembly1.Component_Add.png
    • XXX.png
    • ...
  • l10n
    • ArchiToolkit.Resources.resx

In ArchiToolkit.Resources.resx, you can't modify it! but you can add your own languages to it, so it is how we do with l10n.

You can't modify the pngs when your IDE is open, so please turn your IDE off when you want to modify the png. And the png is the icons in the grasshopper.

General Infos

This is the general infos that almost all items can be used with.

Category and Subcategory

You can add the attribute CategoryAttirbute and SubcategoryAttribute to control them. Only the closest attribute to the DocObj will affect.

[Category("MyCategory")]
public class Test
{
    [Subcategory("SubCate")]
    [DocObj]
    public static int Add(int x, int y) => x + y;
}
Default Name/NickName/Description

For adding the name or nickname or description on the Document object, you can add the attribute ObjNamesAttribute.

public class Test
{
    [ObjNames("Addition", "Add", "Normal adding")]
    [DocObj]
    [return: ObjNames("Result", "r", "Description of the result.")]
    public static int Add(
        [ObjNames("X", "x", "Description of x")]int 
        x, int y) => x + y;
}
Exposure

For changing the Exposure, please add the ExposureAttribute on it.

public class Test
{
    [Exposure(GH_Exposure.secondary)]
    public static int Add(int x, int y) => x + y;
}
Obsolete

Of course, ObsoleteAttribute can be used on.

public class Test
{
    [Obsolete]
    [DocObj]
    public static int Add(int x, int y) => x + y;
}
Attributes

You can add your custom attributes on your object by using ObjAttrAttribute<>.

file class MyAttribute(IGH_Component component) 
    : GH_ComponentAttributes(component);

public class Test
{
    [ObjAttr<MyAttribute>]
    [DocObj]
    public static int Add(int x, int y) => x + y;
}
Component Infos

For some cases, you may want to add more information for this component.

Component

If you want to add your own base component, do it with BaseComponentAttribute<>.

file abstract class MyComponent(string name, string nickname, string description, string category, string subCategory) 
    : GH_Component(name, nickname, description, category, subCategory)
{
}

public class Test
{
    [BaseComponent<MyComponent>]
    [DocObj]
    public static int Add(int x, int y) => x + y;
}
Parameter Infos

This is for the parameters info, so you can add your own things.

Get Component or Data Access

You can get the IGH_DataAccess or IGH_Component just by adding it into your parameters

public class Test
{
    [DocObj]
    public static int Add(IGH_DataAccess access, IGH_Component component, int x, int y) => x + y;
}
Parameter Type

You can specify the parameter type by using the attribute ParamTypeAttribute. You can specify the type or the guid. But it is better to do it with type by the generic one.

public class Test
{
    [DocObj]
    public static int Add([ParamType<Param_Integer>]int x, [ParamType("{2E3AB970-8545-46bb-836C-1C11E5610BCE}")]int y) => x + y;
}
Persistent Data

For the persistent data, you need to add the attribute PersistentDataAttribute on the parameter.

public class Others
{
    internal static int yDefault = 1;
}

public class Test
{
    internal static int xDefault = 0;
    [DocObj]
    public static int Add(
        [PersistentData(nameof(xDefault))]int x,
        [PersistentData<Others>(nameof(Others.yDefault))] int y)
        => x + y;
}
Optional

Optional the data by the attribute OptionalAttribute.

public class Test
{
    [DocObj]
    public static int Add(int x, [Optional]int y) => x + y;
}
Hidden

If you wanna your geometry is hidden, just add HiddenAttribute on it.

public class Test
{
    public static int Add([Hidden]Arc arc, int y) => (int)arc.Radius + y;
}

Parameter

You can also add DocObjAttribute on the type to create a new parameter.

[DocObj]
public class MyType;
Base Goo

You can specify the Goo type by using BaseGooAttribute. Just notice that don't forget to using partial key word to implement your type.

[BaseGoo<GH_GeometricGoo<MyType>>]
[DocObj]
public class MyType;

partial class Param_MyType
{
    partial class Goo
    {
        public override IGH_GeometricGoo DuplicateGeometry()
        {
            throw new NotImplementedException();
        }

        public override BoundingBox GetBoundingBox(Transform xform)
        {
            throw new NotImplementedException();
        }

        public override IGH_GeometricGoo Transform(Transform xform)
        {
            throw new NotImplementedException();
        }

        public override IGH_GeometricGoo Morph(SpaceMorph xmorph)
        {
            throw new NotImplementedException();
        }

        public override BoundingBox Boundingbox => default;
    }
}
More features

Waiting for more features.

Product Compatible and additional computed target framework versions.
.NET net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed. 
.NET Framework net48 is compatible.  net481 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
0.9.13 0 3/25/2025
0.9.12 28 3/25/2025
0.9.11.1 50 3/24/2025
0.9.11 51 3/24/2025
0.9.10 52 3/23/2025
0.9.9 49 3/23/2025