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
Arrel 08c3cd5d67 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
2025-07-07 10:32:49 -04:00

20 lines
No EOL
583 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

from geometry_script import *
@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
g = grid(
size_x=total_x, size_y=total_y,
vertices_x=columns+1, vertices_y=rows+1
).mesh.mesh_to_points()
return g.instance_on_points(instance=geometry)