3
$\begingroup$

I wanna numerize my cubes, its 25x25. So i wanna give each cube a number from 1 to 625.But its quite time consuming making: Shift A - Text - Edit - 1/2/3/4........

Is there a way to automatically generate grid of this numbers ? And stringify it to make boolean operations ?

I tried creating Geometry Node with Grid - Instance of objects and index, but got only points/dots...

I just wanna create grid of numbers from 1 to 625 er

$\endgroup$

2 Answers 2

3
$\begingroup$

Sure... the solution lies in that you have to avoid fields as input to the value -to-string node and the string input to the string-to-curves node.

The easiest way is to use nested repeat zones. Hmmm... or wrap it into a single repeat zone and use floored divide and mod to extract the row and column...

Something like this: Geo Nodes Solution

$\endgroup$
3
  • $\begingroup$ What is the thought process for the inputs to the nodes going into the size input String to Curves? Is it just fiddling with values until it looks right or is there some real math behind how it works? $\endgroup$
    – Jakemoyo
    Commented Sep 2 at 19:00
  • 1
    $\begingroup$ Oh, lol... now I look, I mean... it was just a quick hack-together. The reasoning is that the ceil of the log (base 10) of X is, basically, how many digits X has... then there's some fiddling (which is probably honestly better done in a couple of switches for precise control over the scale you wish each digit-length number to show up... you could also simply opt to have a smallish and constant size for the text, which is what I think I'd normally prefer and do... don't know why I was doing that... probably better with a constant size. $\endgroup$
    – V42
    Commented Sep 2 at 23:11
  • $\begingroup$ Awesome, thanks for the insight! $\endgroup$
    – Jakemoyo
    Commented Sep 3 at 13:03
2
$\begingroup$

(Using Blender 4.2.1)

Approach

A classical approach with GeometryNodes modifiers to save CPU time and memory when displaying numbers is to use an Instance on Points node to spawn digits instead of using Value to String then String to Curves nodes for each number. In the present case of a grid, this technique can be combined with an other Instance on Points node to set the points where digits are placed, avoiding a Repeat Zone.

Setup and results

Results For the demonstration, a 25x25 grid is added in Object Mode. It is rotated around X axis such that the first faces are at the top instead of the bottom. This transformation is applied.
The GeometryNodes modifier displaying the numbers (i.e. faces index) is not added to the grid, but to the default cube. The grid is specified as an input parameter of the modifier. This way, grid and numbers can be visualized independently.

Resources


GeometryNodes modifier

GN Graph 1. An Instance on Points node is used to pick digits stored in a collection (see pink contour) to spawn them at points generated by an other Instance on Points node (see red contour). Instance Index is computed from the integer to display and the digit rank (see green contour).
2. Curves outlining the digits from 0 to 9 are generated by a single String to Curves node. These are output as superimposed Instances with index ranging from 0 to 9 also. In the same String, the last character is the blank space (so not visible in the screen capture...), with instance index 10. For rendering purpose, curves are filled with N-gons and are receiving the material "Black".
3. Points are generated at the location of each digit making the grid of integers, with an Instance on Points node spawning a line of 3 vertices per face of the input object. With 3 vertices, numbers from 1 to 999 can be displayed. To support different digits, those vertices have to be converted to individual mesh elements using a Realize Instances node.
4. The coordinates of the input object faces center are recovered by a Mesh to Points node set in Faces domain. It is to notice that the Transform Space property of the Object Info node providing this object geometry is set to Relative for the labels to follow the object displacement.
5. A Mesh Line made of 3 vertices aligned with X axis extending from -1 to 1 is initialized. It is to notice that it is slightly offset in Z direction to avoid Z-fighting between faces and labels. Then it is successively shifted in X direction to make 3 instances collected by a Geometry to Instance node. The first instance of index 0 is centered on middle digit ; the second instance of index 1 is centered on the space between middle and last digits ; the third instance of index 2 is centered on last digit.
6. The spacing of digits is scaled with a Transform Geometry node to be adjusted to the font and the faces size.
7. To center on a face the associated number (i.e. its Index + 1), one of the 3 instances shifted at step 5 is picked, according how many digits are required. Using a cascade of Switch nodes, the instance of index 2 is picked for numbers lower than 10, the instance of index 1 is picked otherwise for numbers lower than 100, the instance of index 0 is picked otherwise.
8. At step 3, a triplet of spawning points is generated for each number $n$ to display, one point per digit. Let $i$ be the Index of such a point. For a given value of $n$ (starting at 1), $i$ is between $3(n-1)$ and $3(n-1)+2$. Consequently, the value of $n$ for a given value of $i$ is computed as the integer part of $\frac{1}{3}(n+3)$.
9. Let $j$ be the rank of a digit (from right to left, starting at 0) and $d_j$ be this digit value. The value of $n$ is defined as: $$\begin{array}{rcl} n & = & 100 \times d_2 + 10 \times d_1 + d_0 \\ \mbox{} & = & 10^2 \times d_2 + 10^1 \times d_1 + 10^0 \times d_0 \end{array}$$ For a given value of $n$, $d_2$ is at Index $i=3(n-1)$, $d_1$ is at Index $i=3(n-1)+1$, $d_0$ is at Index $i=3(n-1)+2$. So $d_j$ is at Index $i=3(n-1)+2-j$. Consequently, $2-j$ is the remainder of the division of $(i+3)$ by $3$.
10. Dividing $n$ by $10^j$ yields: $$10^{(2-j)} \times d_2 + 10^{(1-j)} \times d_1 + 10^{(0-j)} \times d_0$$ Consequently, $d_j$ is the integer part modulo 10 of this expression.
11. Leading zeros for numbers lower than 10 and 100 are replaced by blank space (stored as the instance of index 10) using a cascade of Switch nodes.

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .