Coordinates of U points in (bezier) curve

Hi,

I’m currently using the following to retrieve selected vertices from a mesh:

for i in bpy.context.active_object.data.vertices:         
    if(i.select == True):
        co = ([i.co.x] , [i.co.y] , [i.co.z])

Now I’m trying to do the same for the coordinates of (I guess) U points in a curve. I’m very new to both python and blender so not sure if I’m describing this correctly.

To expand on the U points, for example with the default bezier curve I’m looking for a way to retrieve the coordinates of the 12 points.

Thanks in advance.

Hi there and welcome!

Unfortunately, because the points that are effected by the resolution don’t exist in the same way vertices do, you can’t access them directly. For instance, if you go into edit mode on the default curve, you can’t see 12 u points, you can only see the two Bezier Points. If you want the points effected by the resolution, you need to look into using,

mathutils.geometry.interpolate_bezier()

On the otherhand, if you want the bezier points, just look into the following which will tell you if the first bezier point of the first spline is selected

bpy.data.curves['BezierCurve'].splines[0].bezier_points[0].select_control_point

You should be able to modify this to what you want.

Cheers,
Truman

PS A spline is a number of connected bezier points. There can be many in a single curve.

Thanks! the Mathutils.geometry.interpolate_bezier() solved it for me.

Also found a beginners mistake in my first code:

co = ([i.co.x] , [i.co.y] , [i.co.z])

That wouldn’t be required, as i.co already contains that information.