Problem Creating Custom Parameter

Hi. I’m trying to create a custom parameter based on this article. But I couldn’t make it appear on the specified category and subCategory.

using Grasshopper.Kernel;
using System;
using System.Drawing;
using Rhino.Input.Custom;
using System.Collections.Generic;

namespace CustomTypeExample
{
    class TriStateParameter : GH_PersistentParam<TriStateType>
    {
        public TriStateParameter() :
          base("TriState", "Tri", "Represents a collection of TriState values", "Params", "Primitive")
        { }
        protected override TriStateType InstantiateT()
        {
            return new TriStateType();
        }
        protected override GH_GetterResult Prompt_Singular(ref TriStateType value)
        {

            GetOption go = new GetOption();
            go.SetCommandPrompt("TriState value");
            go.AcceptNothing(true);
            go.AddOption("True");
            go.AddOption("False");
            go.AddOption("Unknown");

            switch (go.Get())
            {
                case Rhino.Input.GetResult.Option:
                    if (go.Option().EnglishName == "True") { value = new TriStateType(1); }
                    if (go.Option().EnglishName == "False") { value = new TriStateType(0); }
                    if (go.Option().EnglishName == "Unknown") { value = new TriStateType(-1); }
                    return GH_GetterResult.success;

                case Rhino.Input.GetResult.Nothing:
                    return GH_GetterResult.accept;

                default:
                    return GH_GetterResult.cancel;
            }
        }

        protected override GH_GetterResult Prompt_Plural(ref List<TriStateType> values)
        {
            values = new List<TriStateType>();

            while (true)
            {
                TriStateType val = null;
                switch (Prompt_Singular(ref val))
                {

                    case GH_GetterResult.success:
                        values.Add(val);
                        break;

                    case GH_GetterResult.accept:
                        return GH_GetterResult.success;

                    case GH_GetterResult.cancel:
                        values = null;
                        return GH_GetterResult.cancel;
                }
            }
        }
        public override GH_Exposure Exposure
        {
            get
            {
                return GH_Exposure.tertiary;
            }
        }
        protected override Bitmap Icon
        {
            get
            {
                return null;
            }
        }
        
        public override Guid ComponentGuid
        {
            get { return new Guid("5df92661-8471-40ea-adf2-a487b9e18f46"); }
        }
    }
}

CustomTypeExample.zip (861.1 KB)

Any help would be appreciated.

I think your class must be public

public class TriStateParameter : GH_PersistentParam<TriStateType>
{
...
}
1 Like