# Bezier Curve evenly division

Hi All!
I am new here and I just start developing addons for blender.
I am trying to distribute objects evenly along a bezier curve. The problem is that curve is composed with different segments and lengths.
My approach is calculate the chunk that belongs to each object, and then, for each segment start to divide the curve.
The problem comes when a chunk is in between two segments, and how to fix the last position in order to take advantage of the entire length of the curve.

``````            L_total = sum(L_seg)
step = 1/N
r = 0
acum = 0
new_locs = []
for i in range(N_seg):
acum = 0
acum = r
t = (step *  L_total) /  L_seg[i]
while (acum <= 1):
new_loc = self.spline_eval(acum, points[i].co, points[i].handle_right, points[i+1].co, points[i+1].handle_left)
new_locs.append(new_loc)
acum += t
if i == 0 or i == N_seg-1:
r = (acum - 1)
else:
r = (acum - 1) * L_seg[i] / L_seg[i-1]
``````

Any ideas?

Thank you!!

You can do this will an Array Modifier and a Curve modifier:

If the objects are not the same, you can use empties and places the objects at the empty locations, in this case use the empties’ `matrix_world` location.

The Array Mod must be above the Curve Mod and note how the Array is set up.

Cheers, Clock.

EDIT:

For irregular offsets, just use a Curve mod for each object and specify an offset in the object’s deformation axis location.

EDIT 2:

I forgot, Welcome to DevTalk!

1 Like