4

This question is similar to Selecting every n'th index using modulo in geometry nodes but with an added range option.

I can select every n'th number thanks to Hulifier

img1

I'm trying to select every n'th index, but only choose from the selected indexes between the ranges of b and c using modulo in geometry nodes.

My logic doesn't seem to work for selecting every n'th index between the numerical index ranges b and c using modulo. I checked the output with the viewer (it seems to select the index range I want but the modulo doesn't seem to be executing the way I thought. I should have only 3 icospheres showing up.)

img2

Timaroberts
  • 12,395
  • 6
  • 39
  • 73
Rick T
  • 4,391
  • 1
  • 20
  • 64

1 Answers1

5

you have to take modulo from index, not from boolean. Modulo is the rest of a division, so it makes no sense to get a modulo value from a boolean (which is just 0 and 1). you might want to add an add note before your modulo so that it starts with 0 and not an arbitrary value.

this should work:

enter image description here

Chris
  • 59,454
  • 6
  • 30
  • 84
  • Ok that makes sense. But is it possible to choose from a specified index range? It's like I need another Node that does an AND operation but for indexes instead of booleans. – Rick T May 09 '22 at 05:22
  • but you did this already perfectly in your node tree! you connected "and" to the "lower" and "greater" - that's the right way! So i don't understand what you mean now? – Chris May 09 '22 at 05:23
  • 1
    just connect index to "modulo value" and the "and" result boolean to the last "and" boolean – Chris May 09 '22 at 05:25
  • i updated my answer – Chris May 09 '22 at 05:27
  • Thanks that did it. – Rick T May 09 '22 at 05:28
  • you are welcome – Chris May 09 '22 at 05:28
  • if you want a "constant" start value (e.g. it start always with false) you can add a "start index modulo 3" expression to your index before doing your modulo and then add a constant value (1, 2,3 however you want the start to be like) so that you will always have a start with e.g. true, false, false. else the start of your selection will be arbitrary...only if you want ;) – Chris May 09 '22 at 05:31
  • @Chris given the min max are integer inputs it might be best to add and subtract a decimal offset to have them inclusive (most specifically evaluating the 0 index) and my interpretation was that the modulo should start at the min value so subtract min from index going into modulo but thanks for the answer. – Ratt May 09 '22 at 06:27
  • @ratt: yeah...there are several ways to do so ;) – Chris May 09 '22 at 06:29
  • Thanks! I add that to the Node tree. – Rick T May 09 '22 at 17:21