[Add-On] Arrange objects along a curve.

Hi guys :). Here is a demonstration of my first Add-On: “arranjar_em_curva”.

Updates :slight_smile: :


There are still some things to improve. I hope you enjoy.

And thanks to @kastoria for helping me to develop this Add-On. :slight_smile:


arrange_on_curve.zip (2.95 KB)


Thanks Mano, I try it soon…

Mano I cant decompressed:


7-Zip [64] 9.20 Copyright © 1999-2010 Igor Pavlov 2010-11-18p7zip Version 9.20 (locale=fr_FR.UTF-8,Utf16=on,HugeFiles=on,4 CPUs)

Processing archive: /home/patrinux/Téléchargements/ArranjaremCurva.zip

Extracting ArranjaremCurva.py Unsupported Method

Sub items Errors: 1

I think error of compression zip!

Winrar Win7 works.

@Spirou4D, changes “.zip” to “.rar”. I’ll fix this soon.

Ok thks it’s ok now. I’m on linuxmint.

but you must change the name of the python file:
not uppercase in python file name!

Thank you @Spirou4D, now should work. I also changed the name. As you recommended. :slight_smile:

Thanks for addon…but in mine 2.73.1 Blender version…it’s not working.

File “C:\Users\Gabriel\AppData\Roaming\Blender Foundation\Blender\2.73\scripts\addons\arranjar em curva.py”, line 75,
in invoke
for e in range(0,len(points)): # For each point on the spline
UnboundLocalError: local variable ‘points’ referenced before assignment

location: <unknown location>:-1

location: <unknown location>:-1

@Elevation75, I think now has been resolved. Can you try again?

@Mano-wii: thanks for update but now it gives my this:

Traceback (most recent call last):
File “C:\Users\Gabriel\AppData\Roaming\Blender Foundation\Blender\2.73\scripts\addons\arranjar_em_curva.py”, line 90,
in invoke
obj.location = points[e] - (vetorx/vetorx.length)*x + LocCv # Putting in the correct position
AttributeError: Vector addition: vectors must have the same dimensions for this operation

location: <unknown location>:-1

location: <unknown location>:-1

What can be wrong with those dimensions… I tried to put a simple cube on a curbe.

Thanks for sharing!
Looks like one of those tools making life a bit easier :wink: however i’m getting this error on 2.73.3

    obj.location = points[e] - (vetorx/vetorx.length)*x + LocCv # Putting in the correct position
AttributeError: Vector addition: vectors must have the same dimensions for this operation

If i print values, ‘points’ and ‘vetorx’ are 2-dimensional whereas LocCv is 3-dimensional array…

Thanks for the report @Elevation75. This was a bug in Blender itself (https://developer.blender.org/T43473). But recently fixed by the developer mont29 (https://developer.blender.org/rB12a38abac6696992bc383a7745c4e15b316936d1). So you need to download the latest buildbots to not have that problem anymore (https://builder.blender.org/download/).

Ouch… Saw T43473 before but did not realize this is how it shows up. Tanks for looking into - will download a new build.

Updates :slight_smile: :

Hi Mano,
Thanks for this update but why your add-on isn’t in english, please?

Good update, that way you can align objects to any directions with straight curve. Is it easy to code that it aligns only selected objects without to need group them first ?

Hi @Spirou4D:)
I started doing all the Addon in Portuguese. Only after I was translating to English. Now only remains make the operator “Arranje Objetos” be translated to “Arrange Objects”. I will do this.

@JuhaW, The first version did that. You just need to select an object first and then the curve. And run the script.

import bpyimport mathutils
from mathutils import Vector

dist = 5.0 # distãncia entre os objetos duplicados

# referenciando o objeto selecionado
curvob = bpy.context.active_object
curve = bpy.context.active_object.data

for c in range(0,len(bpy.context.object.data.splines)): # Para cada spline na curva
    dx = 0.0 # Comprimento de cálculo inicial da seção
    for e in range(0,len(bpy.context.object.data.splines[c].bezier_points)): # Para cada ponto na spline 
        vetorx = bpy.context.object.data.splines[c].bezier_points[e].co-bpy.context.object.data.splines[c].bezier_points[e-1].co # Vetor da seção do apline
        dx += vetorx.length # Comprimento na seção da spline
        theta = mathutils.Vector.angle(mathutils.Vector.to_2d(vetorx), ((1.0, 0.0))) # Angulo da seção
        while dx &gt; dist: # Enquanto o Comprimento de cálculo total da seção for maior que a distancia definida
            x = dx - dist # Calculando o comprimento restante da seção
            bpy.context.active_object.select = False # Desselecionado a curva
            bpy.context.scene.objects.active = bpy.context.selected_objects[0] # Ativando o penúltimo objeto selecionado
            bpy.ops.object.duplicate(linked=True) # Duplicando os objetos selecionados
            bpy.context.object.location = curve.splines[c].bezier_points[e].co - (vetorx/vetorx.length)*x # Colocando na posição correta
            bpy.context.object.rotation_euler[2]=theta # Rotacionando os objetos selecionados
            bpy.context.scene.objects.active = curvob # Reativando a curva
            dx = x # Definindo o novo comprimento restante da seção

I mean many different objects, not only one, just like your group does it now.

Humm, the idea is practice, but don’t think it is intuitive. Unless I make a mark (BoolProperty) referring to the selected objects (except the active curve). I will think about it. But first I have to correct an inaccuracy when you have a large group of objects.