creating a line of objects
To create a series of objects along a line, we modify the calc_midpoint function to accept a variable that allows us to scale the difference, this way we can place each object by a percentage offset along the line. The line in this demo is the path between the Camera and Lamp.
import bpy, math from mathutils import Vector def calc_midpoint( a, b, m ): a = Vector(a) b = Vector(b) dif = b-a return a + (dif*m) x = bpy.data.objects['Camera'].location y = bpy.data.objects['Lamp'].location for i in range(10): middle = calc_midpoint(x,y, i*0.1) bpy.ops.mesh.primitive_monkey_add(location=middle) monkey = bpy.context.object monkey.scale*=math.sin(i*0.5)
Comments
Post a Comment