GH Component - How to "Hint" about Inport & Outport Type?

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.")
    End If

    If (Lst.Count = 0) Then
        Print("The list contains no data.")
    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

    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

pManager.Add Boolean Parameter
pManager.Add Text Parameter

You’ll need to use pManager.Add Number Parameter

ps. sorry about the weird account I’m posting under, something went wrong with my regular account authorisation and it can’t be fixed until the Seattle crew gets back in the office after July 4th. - David

1 Like

JIT-answer. :slight_smile:

Unbelievable that I didn’t see that. But this is the drawback with sooooo very looong code constructs.

Anyway, thanks. Now I should be able to speed up.

// Rolf

OK, this works very very well. So now I need to make a whole bunch of related components that belong together. How do I pack multiple components into one .gha-file?

(New to GH, new to .NET, new to VS, relatively new to CAD… much to learn in one go, but now it all starts to come together).

// Rolf

You can create any number of classes that derive from GH_Component. Just keep adding them to your project.