[Solved] How to fill a rectangle with variable?

I would like to fill a hexagon that repeats in a rectangle. I managed to fill in one row but I don’t know how to repeat the hexagon in the other rows?
I believe it could be done with only variables, or the repeat x times method as well.

I create hexagons on the image:
-either with a +1 to a variable “i” for X position of each new hexagon
-or the second way with a condition: if variable “r” is different from the width of rectangle - the total width of hexagon create hexagon.

Anyway, with both methods I don’t manage to fill horizontally and vertically the rectangle. Any help?

You need 2 repeats, one nested in the other. With this example screenshot you’ll need to put in your values, but to give you the idea :

Good idea I tried with my variables & values but it doesn’t work.

My variables and values:
g and i are set to 0 (I use g and i variables to iterate)

23 times: 23 columns
36 times: 36 rows

Variable(varRectangleX1): position X
Variable(varTexte): width of hexagon

Variable(varRectangleY1): position Y
Variable(varTexte): height of hexagon (same than width)

You haven’t looked at my example closely enough, and haven’t implemented it correctly. You’ve got the increment g in the wrong place - you’re increasing it the same time you increase i. It should be increased outside of the i loop, once the i loop has finished.

If you look at my example, increasing g should be after the second repeat, at the same level as the second repeat.

And you are setting g to 0 at the start of the first repeat. Again, look at my example - the setting g to 0 should be done before the first repeat.

Indeed I implemented as you said and it’ works… even if I don’t understand despite I read several time.
But I would like to understand . Could you explain to me please?


The inner repeat places the hexagon 36 times across the screen - the incrementing variable i ensures that it goes across, and is not in the same spot.

Once that inner repeat is finished (.e. a row of hexagons has been laced), the row counter (variable g) is increased, so that next time round, the next row down is filled.

The outer repeat is for the number of rows. Variable g is set before the repeat block, otherwise it gets reset every iteration.

When you had the setting of g in the repeat block, it was resetting the row to the first one. And when you increased it in the second repeat block, you were incrementing i & g (column and row) at the same time. so when i=1, g=1, and when i=2, g-2 and so on, before starting again when the outer repeat was actioned again. This creates a diagonal set of hexagons.

I hope this explains it a bit.

1 Like

Thank you for the explanation. I have to read again and again to make sure I understand.

How do you mark the topic is solved?

And ask any further questions if things aren’t clear or you feel something hasn’t been explained well enough.

By editing the title. I’ve done it already because your original request was fulfilled, and now it’s just explaining how it works.