Convert poly/nurbs curves to bezier AND keeping tilt!

I’m working on some personal tools to improve my mesh-hair-workflow and i stumbled over this: When converting a non-bezier-curve into bezier, all its points lose their tilt settings:

CurveConversionOption

While i was hoping for something along the lines of what the green arrow points to, i actually get something like the right arrow points to:

Not so nice! As i’m working with hair, i’d prefer the amount of visible controls to be as low as possible, so i’m opting for poly-type curves, as it’s already confusing enough without bezier handles:

Besides, Nurbs with less than 6 points can’t converted at all. After some fiddling around, i coded a little helper func that converts those curves the correct way:

def convert_to_bezier_with_tilt(obj):

    bpy.ops.object.mode_set(mode='OBJECT')
    bpy.ops.object.duplicate()
    data=bpy.context.active_object.data
    bpy.ops.object.mode_set(mode='EDIT')

    for spline in data.splines:
        if spline.type=="NURBS":
            bpy.ops.curve.select_all(action='DESELECT')
            spline.points[0].select=True
            bpy.ops.curve.spline_type_set(type='POLY')
        if spline.type=="POLY":
            bpy.ops.curve.select_all(action='DESELECT')
            spline.points[0].select=True
            tilts=[p.tilt for p in spline.points]
            bpy.ops.curve.spline_type_set(type='BEZIER')
            for pid, point in enumerate(spline.bezier_points):
                point.tilt=tilts[pid]
                point.handle_left_type="AUTO"
                point.handle_right_type="AUTO"

That way i can have the best of both worlds: Easier editing with poly curves, nicer final geometry with bezier curves! It’s nothing amazing, but it helps my workflow a lot, so maybe somebody can get some use out of it.

3 Likes