1
$\begingroup$

I need to find coordinates of points extruded from blender's bezier curve with python. All I know right now is how to evaluate each point on the curve(mathutils.geometry.interpolate_bezier) but I don't know how to find the perpendicular vector with Spline's tilt.

explanation

Basically, I need to find a perpendicular vector with the original vector and tilt in each curve vertex. How do I do that in python?

So far I've only gotten the spline points but not the extrusion, here:

import bpy
import mathutils
interp = mathutils.geometry.interpolate_bezier

class DummyOp(bpy.types.Operator):
    bl_idname = "object.get_bezier"
    bl_label = "Extract Bezier Points"

    def execute(self, context):
        ob = context.object
        dat = ob.data
        bzp = dat.splines[0].bezier_points
        points=interp(bzp[0].co, bzp[0].handle_right, bzp[1].handle_left, bzp[1].co, dat.resolution_u+1)
        print(f"So far I can only extract this data:\n{dat.resolution_u},\nCurve points:")
        for p in points:
            print(p)
        return {'FINISHED'}

def register():
    bpy.utils.register_class(DummyOp)

def unregister():
    bpy.utils.unregister_class(DummyOp)

if __name__ == "__main__":
    register()

    bpy.ops.object.get_bezier()

$\endgroup$
  • $\begingroup$ I know this -> bpy.ops.object.convert(target='MESH', keep_original=False) method exists, but I was hoping for a cleaner solution without using bpy.ops. I will use this method for now $\endgroup$ – CompressedWizard Apr 8 at 18:12

Your Answer

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

Browse other questions tagged or ask your own question.