Input filter for clusters

input
clusters
filter

(Aris Nikolopoulos) #1

Hi,
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…)

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

input filter.gh (15.8 KB)


#2

This could be one way…

input filter_re.gh (19.8 KB)


(Aris Nikolopoulos) #3

Yup! works perfectly!!!
Thanks!


(Aris Nikolopoulos) #4

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 filter.gh (4.9 KB)


#5

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.


(Aris Nikolopoulos) #6

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)

#7

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:

input_filter_2018Feb5a.gh (11.4 KB)
input_filter_2018Feb5a

input_filter_2018Feb5a2


(Aris Nikolopoulos) #8

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)
xy

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?


#9

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.


(Aris Nikolopoulos) #10

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: )
icons