Grasshopper

algorithmic modeling for Rhino

Where to learn about connected inputs to components, c#

Hello everyone (and probably David in particular!),

I have recently needed to start learning about how to 'influence' components that are upstream from a custom component - in particular sliders.

I have found a number of bits on this blog but have a few remaining questions.

1. Events:

What events are available for tracking when a component is attached upstream (for example attaching a slider to an input).

(These events seem important to prevent locking the solution in a never ending loop).

2. Assigning values:

I understand the ability to produce a component object to assign controls to.

ie. 

Grasshopper.Kernel.Special.GH_NumberSlider slider = new Grasshopper.Kernel.Special.GH_NumberSlider();

and making the assignment

ie.

slider.Slider.Minimum = variableMin;

slider.Slider.Maximum = variableMax;

but is it possible to direct these assignments to a specific input of the custom component? For example if a number slider is attached to the second input of a custom component is there a way to target that input?

ie.

slider.Slider.Input = this.Component.Params.Input.Select(1); 

(clearly this code doesn't work - but is something similar to this available to assign the input?)

The c# equivalent of this (below) code originally posted [here ] would be helpful.

VB

Dim Slider As  Grasshopper.Kernel.Special.GH_NumberSlider = Me.Component.Params.Input.First.Sources(0)

C#

Grasshopper.Kernel.Special.GH_NumberSlider  slider = this. ...

Views: 799

Replies to This Discussion

I am not entirely sure if I understand what it is that you are trying to accomplish, so forgive me if I misunderstood. Would you like for a slider to auto-adjust its MIN/MAX values based off of information it is pulling (receiving) from a component that is downstream from itself? For instance, if I were to plug in a slider to a Construct Domain component, are you proposing that said slider would trace the path of its destination and base its defaulted MIN/MAX values on the component into which it is feeding?

I have wondered about the possibility of having a slider that is downstream from a component that feeds that slider some information (MIN/MAX values).

This would then make it possible to have sliders attached to other sliders so that their values would be interdependent. Therefore, a slider could be receiving its MIN/MAX values from an upstream slider (and whatever logic is embedded in between the two). A practical example of interdependent sliders would be the capability of constraining the Sum of those two sliders. Of course this is but one, simple example. I do think, however, that this functionality could add a nice layer of sophistication into the environment at very little cost of implementation.

William,

I do believe that upsteam components (in this case a number slider) can be fed values. It seems that common values are things for sliders are things like the slider name, its type (ie. int vs float...), its minimum, maximum, start or the slider's normalized values.

Some posts that relate to this are [ here ] and [ here ] (better) and [ here ] (best).

Adapting the code at the best link is working for me.

The only question I have is: Is there an event that I can use to track when the target slider attached to the custom plugin?

I am looking for this event because then it would be possible to limit when the slider is set and reset.

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service