Wish: True/ false to Index component

I would like to see a True/ false to Index component, as I often need to use such a procedure for culling or retrieving items.

In Grasshopper 1, this can be achieved by plugging a list length into a series, which creates a list of the indices. Thereafter, I retrieve the indices by using the displacement component and an Equal, Smaller than or Larger than component.


But, it would be helpful if you could immediately convert a True/ False list to indices. It should either give the indices for True values OR give the indeces for False values. There should be a button to switch between the two.

Hi @Intuos,

Assuming I have interpreted your screen shot correctly you can simplify this and lose the series part by replacing the final cull with despatch which - as you show above - actually allows you to use the true/false list directly already.

(And in your example you can also simplify further by using segment length in place of vertex distance).

HTH
Jeremy

Hi @jeremy5
Yeah, this example could be simplified indeed, I first went with the second simplification as well, but ran into a couple of issues further down the line. Don’t remember which though.

The point that I want to make is this: it would be good to have a True/ False to index component.

Given you don’t need it for cull because you can use dispatch instead, what other use cases do you have for such a component? Being unimaginative, I’m struggling to think of them.

In cases where I want to replace specific items in a list with others, or in general, to pick items from a list. Most logic eventually ends up being that an item is or is not at a specific point/ length/ parameter value (also think of Rhino.Inside.Revit). In which case, it is helpful to know which indices these items have in a list so you can dispatch them and/ or replace them with items that do meet a given requirement.
I also find it helpful to maintain the tree structure as much as possible, such a component would allow me to use the list that I used from the start of the script and have all items still correspond to the same index along the way.
I don’t have any particular use-case in mind atm, but I have been using the list length + series trick a bunch of times. And I’ve always thought why isn’t there an true/ false to index component?

I think I encountered this exact issue today:

I’d also love a magic “boolean list to index” node!

But I saw the dispatch workaround and managed to re-arrange my graph so that the new item order in this offshoot (since I had to use merge) wouldn’t affect the rest but still… it would have been nice and more flexible to have that node…

@eobet You can get True False to index values like so:

You could opt to create a cluster out of it, so it’s just a single component for you.
True false to index.gh (14.5 KB)