Input filter for clusters

I have already made this question but I wasn’t able to explain it correctly:
I am using a lot of clusters as user objects and most of the time it is very useful to have the inputs of the cluster ‘loaded’ with a predifined value so if it is used often, you don’t have to connect a slider every time.

The problem is that I cannot find a single routine to act as an “input filter” that will cover all 4 cases:

  • no value
  • single value
  • null value
  • multiple values

In every case, null (or empty) values should be replaced by a predifined value.
(the problem with the first three routines in the file, is that the stream filter only evaluates the first value and changes the stream for all the rest…)

(edit:) the fourth routine works for all but the first case: when fed nothing, it gives nothing.

input (15.8 KB)

This could be one way…

input (19.8 KB)


Yup! works perfectly!!!

This is how my clusters look like in the inside now: clean, tidy and most of all: functional!
You put the brains, I put the pretty icons! hehehe
thanks again Kim!

input (4.9 KB)

1 Like

Why not just right-click the cluster input and set a default value, which will be overridden if a wire is connected? Adding these filters runs the risk of someone connecting a wire with the intention of overriding a default, then for some reason their code doesn’t supply the default and they won’t know it because you are internally filtering values.

Two reasons:

  1. I hadnt thought of that (when u save it as a user object does it keep the predefined value?) I’m not at a computer now to check.
  2. Very often I need to replace null items in a list (like curvature at curve ends)

Setting defaults works with clusters; I don’t do “user objects” so wouldn’t know about that.

I don’t think that hiding errors does anyone any favors though. From the outside, behavior like this is mysterious and bizarre: (11.4 KB)


1 Like

I just checked it.
When you save a user object it does retain predefined values.

Let me ask you something because you seem a very talented and experienced user:
What I do is create simple user objects (many times with just 3 or 4 components inside) so as to speed up repetitive tasks that I use all the time.

as an example, I have a user object that gives the xz and yz planes for a given plane (or better put: the uw and vw planes). This is very useful at least when I’m experimenting because with just one click I can get a plane that i want instead of putting two or three components in a row)

What’s your approach to that?
I’ve understood that you are generaly a purist, but what’s the problem with automating the simple stuff and saving a few clicks?

Depends on whether or not you want anyone else to use your code? If it depends on user objects that exist only on your machine, the code is useless to everyone else. When I use clusters, they are included in the GH file.

Later… based on a simple experiment, maybe user objects work the same way? The cluster is copied into the GH file and saved with it, making it portable? I don’t really know.

Yes, they are not referenced, they reside in the .gh file.
Saving them in ‘user objects’ folder is just so that you can have them in your ribbon
(let me boast a little bit about my pretty icons: )

1 Like