How to differ a (Clustered) GH_ScriptComponent's InParam from a ClusterInput?

OK, so I’m manipulating input sliders on my script component, but in order to test the component I need to connect several components, and thus for every modification in the C# script I have to replace all chained script components (and wire up some 20 in + out ports per component). So I placed my script component in a cluster instead (all instances would automagically uppdate when modifying the original component).

But, and here’s my problem, since my component also manipulate input sliders, the clustered component no longer connects directly to the sliders, instead it connects via ClusterInputs to the sliders.

Q: So how do I get code access to the sliders from my clustered component through the ClusterInputs? (Component–>ClusterInput–>NumberSlider)

The picture (4 cluster instances so far, more to come) indicates why I would like to avoid replacing the auto-updating cluster-component instances with manual copies of the (4) script components (given all the wireing that comes with replacing them after each code change).

// Rolf

1 Like

A related old question which never was answered (how to access the input sources for a GH_ClusterInputHook):

No documentation (or url) seems to exist for the namespace GrassHopper.Kernel.Special …

// Rolf

I have a very similar problem.
When I try to access the component that is connected to the Cluster Input from within the cluster itself, via a python script that accesses ghenv.Component.Params[0].Sources[0], what I get back is a Grasshopper.Kernel.Special.GH_ClusterInputHook object. This makes perfect sense, however I have no clue how to get the actual component that lives outside the cluster and is connected to the GH_ClusterInputHook . (In my case the connected component is a Graph Mapper component)

I ended up passing the Component as an Input, and not the component’s values, and then dealing with those values inside the cluster. Like that:

Once the Graph Mapper object is inside the cluster, I can access and manipulate its values,like that:

I guess it would be similar for Sliders as well.

Here’s a solution in C#:

    var doc = GrasshopperDocument;
    if (doc == null)
    {
      A = "This component is not part of a document.";
      return;
    }

    var owner = doc.Owner;
    if (owner == null)
    {
      A = "This component is not part of a nested document.";
      return;
    }

    var cluster = owner as Grasshopper.Kernel.Special.GH_Cluster;
    if (cluster == null)
    {
      A = "This component is not part of a document hosted by a cluster.";
      return;
    }

    IGH_Param input = cluster.Params.Input[0];
    if (input.SourceCount == 0)
    {
      A = "The first cluster input does not have any sources.";
      return;
    }

    IGH_Param source = input.Sources[0];
    A = "Input is a " + source.Name;

cluster.gh (5.9 KB)

Thank you David!

By the way, are there plans for the Kernel.Special namespace to be officially included in the SDK documentation? I am aware of the .NET Reflector solution, but having it directly accessible on the SDK would be way more convenient for quick things like these.

The only plans for GH1 is to fix bugs and maybe proof-of-concept some ideas that don’t take too long to develop. The Kernel namespace contains no comments that can be extracted as docs, so it would just be a list of classes and (often poorly named) methods.

but, it would show what exists, and with a bit of guesswork one could try things without first spamming the Forum… :wink:

// Rolf

I’m sure it’s useful, but do note it is a direct violation of the license agreement.* You may not want to publicly post evidence of wrongdoing under your own name :slight_smile:

I mean, I’m not a lawyer, but I’m pretty sure that’s solid advice.

* That horrible document you didn’t read when installing Rhino.

1 Like

Ouch! I’m so sorry about that. I’ll delete the post in that case.

1 Like