Hi,
I made a “MinMax” value component in VB.NET/VS which takes a list of Doubles and determines, well, Min and Max. But in the Documentation examples I find no code which “hints” to the component what types are expected on th in ports (or outports), and it follows; my component crashes badly.
Even the help text reports the wrong types. Like so (Expected List of Double in, and single Items of Double out, but in reality it outputs Text… )
Fig 1. Help text :
Fig 2. Crashes badly (I have a GhPython equivalent above the VB.NET version, which does everything correct) :
Fig 3. The code :
Protected Overrides Sub SolveInstance(DA As IGH_DataAccess)
Dim min_tmp As Double = Double.MaxValue
Dim max_tmp As Double = Double.MinValue
Dim Lst As New List(Of Double)
If (Not DA.GetDataList(0, Lst)) Then
Print("Invalid Input list 'Lst'. No data.")
Return
End If
If (Lst.Count = 0) Then
Print("The list contains no data.")
Return
End If
For Each v As Double In Lst
If v < min_tmp Then min_tmp = v
If v > max_tmp Then max_tmp = v
Next
DA.SetData(0, min_tmp)
DA.SetData(1, max_tmp)
End Sub
As it is now, the app perceives the list of Doubles (with perfect data in my tests) as “Booleans” and output as “Text”… but how do I Hint the correct data types for the input & outputs?
My ports:
Protected Overrides Sub RegisterInputParams(pManager As GH_Component.GH_InputParamManager)
pManager.AddBooleanParameter("List", "Lst", "List of numerical values", GH_ParamAccess.list)
End Sub
Protected Overrides Sub RegisterOutputParams(pManager As GH_Component.GH_OutputParamManager)
pManager.AddTextParameter("Min", "Min", "Smallest value found in list 'L'.", GH_ParamAccess.item)
pManager.AddTextParameter("Max", "Max", "Biggest value found in list 'L'.", GH_ParamAccess.item)
End Sub
// Rolf