Remove empty items from lists

For a more Neanderthal perspective:

A mountain with 5 empty caves is still a mountain.

-Willem

4 Likes

< empty >

1 Like

…and more Swiss cheese = more holes, but more holes = less Swiss cheese.

Go figure…

First I want to make it clear I agree with the original post…

… Second I want to show the hack I usually use: do a type check on the data. Feels more readable and self-documenting. Of course this doesn’t work if you’re working with text, unfortunately. And may be slower than the textlength one.

OK, but then why is a branch full of “Empty” items not considered as an empty branch by “Clean tree” ?

What happens is the component reads the strings . So the component just reads the branch as having data (strings saying empty or “”). Empty technically means there is nothing for the data you are looking for. But the string itself does count as data :smiley:

Grasshopper 2.0 has options on all parameters for removing null values and empty twigs*. A twig with only nulls will thus disappear if both these options are active.

This still won’t treat empty strings as null though. There is a significant difference in meaning between no data and empty data which I am not willing to plaster over. I can add components for replacing certain values with nulls, or even an extra option on just text parameters for removing empty strings.

40 seconds in:

* “branches” are called “twigs” in 2.0

2 Likes

Great work. BTW, it would be convenient if a test (=, <>, >, etc) and dispatch could be combined into a single component. Also BTW, that is great that ‘sort’ and 'randomize; are added to the component.

Like this?

5 Likes

I am awed by the beauty of the new components.

Did you actually go out of your way to take these pictures ?

Off topic, I noticed in all the gh2 teasers components have colored box icons with 2 letters. Is gh2 doing away with graphic icons and longer text names?

As the default style I’m switching to two-letter codes for input and output parameters, so that part of components will become somewhat bigger. Components also by default do not come with preset user-names. However as soon as you choose to enter one that text will be included somewhere visually, haven’t decided where or how yet, except that it won’t be vertical text.

If people want the names of components on screen, I think an approach akin to the bifocals plug-in makes more sense.

As for icons, I’m planning to provide only vector/algo icons for all native components, but I haven’t really finished the tools for easily making these. So out of necessity the icons so far are all either auto-generated or very simple. I mean… this is not exactly fun to type:

/// <summary>
/// Gets the standard lambda parameter icon.
/// </summary>
public static IIcon LambdaParameter()
{
  var shape = Que.FromVertices(
    (6, 19),
    (10.8, 7.5),
    (10.6, 6.8),
    250,
    (9.0, 5.8),
    (7, 6),
    (7, 4),
    (9.0, 3.5),
    350,
    (13, 6),
    (16.5, 16.0),
    65,
    (18, 17),
    (18, 19),
    165,
    (14, 17),
    (12, 11),
    (9, 19),
    (6, 19));

  return ParameterTemplate(shape);
}

Even if I can automate a lot of the process using GH1: