Skip to content

Commit 5890726

Browse files
committed
Enhance repeat_grid function: add spacing parameters for customizable grid spacing
1 parent bbadf18 commit 5890726

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

examples/Repeat Grid.py

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

33
@tree("Repeat Grid")
4-
def repeat_grid(geometry: Geometry, columns: Int, rows: Int):
4+
def repeat_grid(
5+
geometry: Geometry,
6+
columns: Int,
7+
rows: Int,
8+
spacing_x: Float = 0.0,
9+
spacing_y: Float = 0.0
10+
):
511
# measure your geometry’s bounds
612
bbox = geometry.bounding_box()
713
span_x = bbox.max.x - bbox.min.x
814
span_y = bbox.max.y - bbox.min.y
915

1016
# total grid size = N * object size
11-
total_x = columns * span_x
12-
total_y = rows * span_y
17+
total_x = columns * span_x + (columns - 1) * spacing_x
18+
total_y = rows * span_y + (rows - 1) * spacing_y
1319

1420
# one extra vertex gives N cells
1521
g = grid(
1622
size_x=total_x, size_y=total_y,
17-
vertices_x=columns+1, vertices_y=rows+1
23+
vertices_x=columns + 1, vertices_y=rows + 1
1824
).mesh.mesh_to_points()
1925

2026
return g.instance_on_points(instance=geometry)

0 commit comments

Comments
 (0)