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
@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 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…
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 > 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
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.