Variable Parameter Component, parameter recorded but not "connectable"


#1

Hi!

I have found a small but weird issue while developping a variable input parameter component. I basically want to always have a “free” input, as does Merge component for example.

As per David’s explanations here, i do a basic check during VariableParameterMaintenance function,like this one :

 Public Sub VariableParameterMaintenance() Implements IGH_VariableParameterComponent.VariableParameterMaintenance Dim num2 As Integer = (Me.Params.Input.Count - 1)
    Dim i As Integer = 0
    Do While (i <= num2)
            Me.Params.Input.Item(i).Name = $"Data {(i + 1)}"
            Me.Params.Input.Item(i).NickName = $"D{(i + 1)}"
            Me.Params.Input.Item(i).Description = $"Data stream {(i + 1)}"
            Me.Params.Input.Item(i).Optional = True
            Me.Params.Input.Item(i).MutableNickName = True
            Me.Params.Input.Item(i).Access = GH_ParamAccess.tree
        End If
        i += 1
    Loop

    If (Me.Params.Input.Item(num2).SourceCount > 0) Then
        CreateFreeInput() ' add a free parameter if last input is used is full
    End If
End Sub


Private Sub CreateFreeInput()
    Params.RegisterInputParam(New Param_GenericObject())
    VariableParameterMaintenance()
End Sub

Problem is, whenever an input is added, I can see it but I cannot connect anything to it until document has recomputed : the wire doesn’t ‘stick’ to the input.

Does anyone know what additional step I should perform to make this input ‘connectable’? A call to ExpireSolution may work but it sounds a bot carpet bombing to me :smile:

Thanks for your helps


#2

Ok, I’ve found the root cause of the problem : the GUI is not aware of the parameter change of the component. Just call Me.Params.OnParametersChanged() after performing any change on Input/Output parameters.