Skip to content

Commit bbadf18

Browse files
committed
Fix Repeat Grid example: improve parameter naming, add proper spacing calculation
- Rename parameters from width/height to columns/rows for clarity - Implement proper bounding box calculation for geometry spacing - Fix grid vertex calculation (use N+1 vertices for N cells) - Add explanatory comments for grid sizing logic - Fix method chaining for mesh_to_points
1 parent 96a1b29 commit bbadf18

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

examples/Repeat Grid.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,20 @@
11
from geometry_script import *
22

33
@tree("Repeat Grid")
4-
def repeat_grid(geometry: Geometry, width: Int, height: Int):
4+
def repeat_grid(geometry: Geometry, columns: Int, rows: Int):
5+
# measure your geometry’s bounds
6+
bbox = geometry.bounding_box()
7+
span_x = bbox.max.x - bbox.min.x
8+
span_y = bbox.max.y - bbox.min.y
9+
10+
# total grid size = N * object size
11+
total_x = columns * span_x
12+
total_y = rows * span_y
13+
14+
# one extra vertex gives N cells
515
g = grid(
6-
size_x=width, size_y=height,
7-
vertices_x=width, vertices_y=height
8-
).mesh_to_points()
16+
size_x=total_x, size_y=total_y,
17+
vertices_x=columns+1, vertices_y=rows+1
18+
).mesh.mesh_to_points()
19+
920
return g.instance_on_points(instance=geometry)

0 commit comments

Comments
 (0)