This repository has been archived on 2026-10-29. You can view files and clone it, but you cannot make any changes to its state, such as pushing and creating new issues, pull requests or comments.
geometry-script/examples/Repeat Grid.py

20 lines
583 B
Python
Raw Normal View History

2022-11-12 18:35:01 -05:00
from geometry_script import *
2022-11-13 15:23:11 -05:00
@tree("Repeat Grid")
def repeat_grid(geometry: Geometry, columns: Int, rows: Int):
# measure your geometry’s bounds
bbox = geometry.bounding_box()
span_x = bbox.max.x - bbox.min.x
span_y = bbox.max.y - bbox.min.y
# total grid size = N * object size
total_x = columns * span_x
total_y = rows * span_y
# one extra vertex gives N cells
2022-11-13 15:23:11 -05:00
g = grid(
size_x=total_x, size_y=total_y,
vertices_x=columns+1, vertices_y=rows+1
).mesh.mesh_to_points()
2022-11-13 15:23:11 -05:00
return g.instance_on_points(instance=geometry)