1
$\begingroup$

I´m trying to do some nodes animation and I don´t know how find the data paths of the points that define a bezier curve.

$\endgroup$

1 Answer 1

2
$\begingroup$

You can try to figure it out yourself in the Python Console, or use the API docs as described here: Blender/Python API Reference Usage: examples of how to use the API reference docs

If you search for bezier in the docs, you will find bpy.types.BezierSplinePoint.co among others. At the bottom of the page, you can find

References

So bezier_points is an attribute of a Spline object, which is in turn an attribute of a Curve object:

References

The access path is therefore Curve.splines[#].bezier_points[#].co.

A Curve is an ID type:

Curve(ID)
base classes — bpy_struct, ID

which could be, for instance, bpy.data.curves['BezierCurve']. Or if you want the data block of the current object, you would use bpy.context.object.data:

import bpy

ob = bpy.context.object
assert ob.type == 'CURVE' # throw error if it's not a curve

curve = ob.data
spline = curve.splines.active # let's assume there's only one
assert spline.type == 'BEZIER' # throw error if it's not a bezier

print(len(spline.bezier_points)) # print number of points
print(spline.bezier_points[0].co) # print coordinate of first point
print(spline.bezier_points[0].handle_left) # ... and its left handle's coordinate
print(spline.bezier_points[0].handle_right) # ... as well as the right one
$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .