Fusion of "Addition" and "Merge" native components

Hi,

For the inputs to be added automatically you need to implement the event handler ParameterSourcesChangedEventHandler

There is an example here :

This would look like this :

 public MyComponent1()
          : base("MyComponent1",
                 "Nickname",
                 "Description",
                 "Category",
                 "Subcategory")
        {
            this.Params.ParameterSourcesChanged += new GH_ComponentParamServer.ParameterSourcesChangedEventHandler(this.ParamSourcesChanged);
        
    }

There is a method ParamSourcesChanged called there, this is where you add the parameters.

private void ParamSourcesChanged(object sender, GH_ParamServerEventArgs e)
        {      

            if (e.ParameterSide == GH_ParameterSide.Input && e.ParameterIndex == this.Params.Input.Count - 1)
            {

                // add another input
                IGH_Param iGH_Param = CreateParameter(GH_ParameterSide.Input, this.Params.Input.Count);
                this.Params.RegisterInputParam(iGH_Param);
                this.VariableParameterMaintenance();
                this.Params.OnParametersChanged();

                // }

            }


        }

The VariableParameterMaintenance is only used to renumber everything.

For the second issue I guess the problem comes from double.NaN that makes the addition fail. I’ve changed it to 0, as well as looping through all inputs.

I’ve added the Optional = true option so inputs can stay empty.

If you really want the user to use the first two inputs before adding a third input, you may want to check the SourceCount property of inputs.

MyComponent1.cs (4.9 KB)