Set a default value to variable input parameters

When creating parameters for a IGH_VariableParameterComponent in the CreateParameter method, is it possible to assign default values?

Example from my code:

public IGH_Param CreateParameter(GH_ParameterSide side, int index) {
            return new Param_Number {
                Name = m_expectedParameterTypes[index].ToString(),
                NickName = m_expectedParameterTypes[index].ToString(),
                MutableNickName = false,
                Description = m_expectedParameterTypes[index].ToString(),
                Access = GH_ParamAccess.item
            };
        }

Yes. You need to set the parameter’s PersistentData.

https://developer.rhino3d.com/api/grasshopper/html/Overload_Grasshopper_Kernel_GH_PersistentParam_1_SetPersistentData.htm

1 Like