Integer Parameter default

Hi There,

I’m new at component development, and I’m trying to add some dropdown values for an integer parameter like what was done in this discussion:

My issue is that when I use the strategy in that post, I get this error: "The type or namespace name ‘Param_Integer’ could not be found (are you missing a using directive or an assembly reference?)

Here is the code for my RegisterInputParams section:

protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager)
{
pManager.AddCurveParameter(“Curve”, “C”, “Curve to be divided”, GH_ParamAccess.item);
pManager.AddIntegerParameter(“Division Mode”,“M”,“Division Mode: 0 = Point at Center, 1 = Segment at Center”,GH_ParamAccess.item);
pManager.AddNumberParameter(“Segment Length”, “L”, “Segment length for curve division”, GH_ParamAccess.item);
Param_Integer param = pManager[1] as Param_Integer;
param.AddNamedValue(“Point at Center”, 0);
param.AddNamedValue(“Segment at Center”, 1);
}

That post is a few years old, so is there something different for Rhino 6 for this kind of parameter?
Thank you!

Figured it out! rather than writing it as:
Param_Integer param = pManager[1] as Param_Integer;

I had to write it like this:
Grasshopper.Kernel.Parameters.Param_Integer param = pManager[1] as Grasshopper.Kernel.Parameters.Param_Integer;

Hey dgoff96,

You can also check that you are including it in the headers so that you don’t have to qualify the use of the types.

using Grasshopper.Kernel;
using Grasshopper.Kernel.Parameters;

then you can use:

Param_Integer param = pManager[1] as Param_Integer;
Capture

I haven’t written code for long but I try to only fully qualify the type if I have two libraries that have similar types or functions. For example: Rhino.Geometry and Mathnet.Spatial.Euclidian both contain a Quaternion type.

1 Like