Grasshopper

algorithmic modeling for Rhino

How does Merge Component automatically adds an additional input when the bottom-most input is connected?

Hi guys,

now I try to make a self developed GH Component with VB.

for this, I want to know, how does GH Merge Component automatically adds an additional input when the bottom-most input is connected.

I tried to find Merge Component with Reflector in Grasshopper.dll, but I couldn't find it yet.

Can somebody tell me,

ether where can I see Merge Component Class with Reflector

or

How can I write the Code for this auto-adding function. !o!

(I did already the Implements of IGH_VariableParameterComponent. It works, but I have no idea, how can I realize auto-adding function)

Thanks!

Views: 666

Replies to This Discussion

The Merge component is part of Mathematics.GHA

The logic for appending a new parameter when the bottom most one is connected is inside an event handler method for the ParameterSourcesChanged event:

Private Sub ParamSourcesChanged(ByVal sender As Object, _

                                                    ByVal e As GH_ParamServerEventArgs)
  If (e.ParameterSide = GH_ParameterSide.Input) Then
    If (e.ParameterIndex = Params.Input.Count - 1) Then
      If (e.Parameter.SourceCount > 0) Then
        Dim param As IGH_Param = CreateParameter(GH_ParameterSide.Input, _

                                                                            Params.Input.Count)
        Params.RegisterInputParam(param)
        VariableParameterMaintenance()
        Params.OnParametersChanged()
      End If
    End If
  End If
End Sub

Note that this component also implements the IGH_VariableParameterComponent interface, which is where the CreateParameter() and VariableParameterMaintenance() methods come from.

To hook up this event handler, put the following code in the constructor for your component:

Public Sub New()
  MyBase.New("...", "...", "...", "...", "...")

  AddHandler Params.ParameterSourcesChanged, AddressOf ParamSourcesChanged
End Sub

--

David Rutten

david@mcneel.com

Poprad, Slovakia

now working perfect!! Thanks a lot :D

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service