Skip to content

Instantly share code, notes, and snippets.

@brettkromkamp
Last active December 4, 2023 10:10
Show Gist options
  • Save brettkromkamp/8813b62b79f5b5ac7d9278e17e45ac0b to your computer and use it in GitHub Desktop.
Save brettkromkamp/8813b62b79f5b5ac7d9278e17e45ac0b to your computer and use it in GitHub Desktop.
Distribute objects in a circle with Blender Python
import bpy
from math import radians, sin, cos
z = 0.5
theta = radians(360) # 2 PI
columns = 60
alpha = theta / columns
# The radius of a circle is the distance from the center of the circle to any point on it's
# circumference. It is usually denoted by 'R' or 'r'.
for r in range(2, 10, 2):
for a in range(columns):
angle = a * alpha
x = r * cos(angle)
y = r * sin(angle)
bpy.ops.mesh.primitive_cube_add(location=(x, y, z))
cube = bpy.context.active_object
cube.rotation_euler.z = angle
cube.scale = (0.3, 0.05, 0.8)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment