How would I go about placing vertices spaced evenly along a path or curve? I've looked at the Extrude Along Path addon, but I don't get the math, and it's doing more than I want to do. To be more specific, I need to know how to get the location of where to place the each vertex.
1 Answer
The mathutils module has an interpolate_bezier function that will give you a list of points along a curve.
import bpy
from mathutils.geometry import interpolate_bezier
res = 5 # number of points to get
src_spline = bpy.data.objects['BezierCurve'].data.splines[0]
k1 = src_spline.bezier_points[0].co
h1 = src_spline.bezier_points[0].handle_right
k2 = src_spline.bezier_points[1].co
h2 = src_spline.bezier_points[1].handle_left
points = interpolate_bezier(k1, h1, h2, k2, res)
for p in points:
o = bpy.data.objects.new('p', None)
o.location = p
bpy.context.scene.objects.link(o)