Hi, I’ve been modifying this script for a couple days & can’t figure out how to distribute cubes along a curve. It works great on curves with 2 points, but what if the curve has more points?
It’s more like a ‘resample’ so keeping the overall shape of the curve is a plus
import bpy
from mathutils import geometry
count = 20
# Acquire a reference to the bezier points.
bez_curve = bpy.data.objects['BezierCurve']
bez_points = bez_curve.data.splines[0].bezier_points
# Get a list of points distributed along the curve.
points_on_curve = geometry.interpolate_bezier(
bez_points[0].co,
bez_points[0].handle_right,
bez_points[1].handle_left,
bez_points[1].co,
count)
# Create an empty object to serve as parent to all cubes.
bpy.ops.object.empty_add(type='ARROWS', align='WORLD',location=bez_curve.location)
group = bpy.context.active_object
group.name = "EMPTY"
empty = bpy.data.objects['EMPTY']
# Create cubes.
cube_rad = 20 / count
for point in points_on_curve:
bpy.ops.mesh.primitive_cube_add(size=cube_rad, location=point)
cube = bpy.context.active_object
cube.parent = group