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)
acum += t
if i == 0 or i == N_seg-1:
r = (acum - 1)
r = (acum - 1) * L_seg[i] / L_seg[i-1]
Thank you for your welcome and your fast response.
Unfortunately I need to deal with the new positions of the objects when rearranged on the curve and array modifyer doesn’t allow it. The curve modifyer also deforms the object and I don’t need that for my problem.
I have solved it taking into account the residual t that corresponds to the next segment.