0
$\begingroup$

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.

$\endgroup$
2
  • $\begingroup$ Why use python? $\endgroup$
    – JakeD
    Nov 29, 2016 at 22:28
  • $\begingroup$ Because I'm writing an addon. $\endgroup$
    – cmomoney
    Nov 29, 2016 at 23:15

1 Answer 1

3
$\begingroup$

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)
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.