![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgSFzZuEiBCiMFflGnSHiDLj59DBITXRKC4fkZb7NU7ctgA6Zvbccrczc6vlRuITNLpYlr-pCJvnR_ykG9FboEcg2hKtjlACOm30rRylqSxbBawbglf2XrtCOj32_q_2M-kXDxzlxtUtCU/s400/Screenshot+from+2019-02-28+10-17-57.png)
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