Issue with If Statement in Evaluate component

Hey Everyone,

I am running into an issue where the Evaluate component is adding elements to the list it outputs as a result of an if statement. Here is a screenshot of my situation and the problem I am having:

In this case, x does not equal zero, so z (the list on the left) is chosen. But for some reason the output has one extra element; notice how the length of the output list is 34 elements, while z is clearly 33.

It might be worth noting that the list plugged into y on the evaluate component is indeed 34 elements long, but I do not understand why z becomes 34 units long when it is the selected output.

Has anyone else run into this issue?

Thanks,
Eric

Never use equality for floating point values. If all your numbers are integers, then run them through an integer parameter first. But when you see a number like “31.0”, it is probably rounded to look nice. The actual number is liable to be something like “31.000000000000002”.

See: Strange behavior of Smaller Than component
And: http://www.grasshopper3d.com/forum/topics/floating-point-error-why-equality-doesn-t-work-as-it-should

David,

Thanks for the reply. I have noticed that rounding can cause an equality issue, but the issue here is not with that. I know that the evaluate function is selecting list z because list y contains different numbers. I am just not sure as to why it seems that the evaluate function is appending another 38 onto the end of list z when it passes through the component.

-Eric

Sorry, I misunderstood your question. Yes, the fact that y ends up being unused doesn’t prevent it from adding another iteration to the whole process. This equation works on individual values so it has to be looped once for every triplet of x, y and z values. Whichever of those lists is longest defines the total number of iterations, while the others are lengthened by repeating the last item.

That’s how all components work. If you want to work on the lists as individual entities, you’ll have to select them in one go, rather than all items. You can do this using the Stream Filter component.

1 Like