How to make Optional inputParamManager using C#?

Hi, I tried this approach with Optional paramters but it does not work for me,

Here is my RegisterInputParams code with implemented optional parameters approach for _spaces . Any help will be appreciated :slight_smile:

        /// <summary>
        /// Registers all the input parameters for this component.
        /// </summary>
        protected override void RegisterInputParams(GH_InputParamManager inputParamManager)
        {
            inputParamManager.AddGenericParameter("_panels", "_panels", "SAM Analytical Panels", GH_ParamAccess.list);

            int index = inputParamManager.AddGenericParameter("_spaces", "_spaces", "SAM Analytical Spaces", GH_ParamAccess.list);
            inputParamManager[index].Optional = true;

            inputParamManager.AddNumberParameter("_tolerance_", "_tolerance_", string.Format("Topologic CellComplex default {0}", Geometry.Tolerance.MacroDistance), GH_ParamAccess.item, Geometry.Tolerance.MacroDistance);
            inputParamManager.AddBooleanParameter("_run_", "_run_", "Run", GH_ParamAccess.item, false);
        }

I think you should use

int index = inputParamManager.AddGenericParameter("_spaces", "_spaces", "SAM Analytical Spaces", GH_ParamAccess.list);
this.Params.Input[index].Optional = true;
1 Like

Thanks it works fine,
ps. I just realised that my solution worked as well but I did not place fresh new component after rebuilding